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
Data/ships/Asteroid.asm
ped7g/EliteNext
0
4508
Asteroid: DB $00, $19, $00 DW AsteroidEdges DB AsteroidEdgesSize DB $00, $22 DB AsteroidVertSize DB AsteroidEdgesCnt DB $00, $05 DB AsteroidNormalsSize DB $32, $3C, $1E DW AsteroidNormals DB $01, $00 DW AsteroidVertices DB 0,0 ; Type and Tactics AsteroidVertices: DB $00, $50, $00, $1F, $FF, $FF DB $50, $0A, $00, $DF, $FF, $FF DB $00, $50, $00, $5F, $FF, $FF DB $46, $28, $00, $5F, $FF, $FF DB $3C, $32, $00, $1F, $65, $DC DB $32, $00, $3C, $1F, $FF, $FF DB $28, $00, $46, $9F, $10, $32 DB $00, $1E, $4B, $3F, $FF, $FF DB $00, $32, $3C, $7F, $98, $BA AsteroidVertSize: equ $ - AsteroidVertices AsteroidEdges: DB $1F, $72, $00, $04 DB $1F, $D6, $00, $10 DB $1F, $C5, $0C, $10 DB $1F, $B4, $08, $0C DB $1F, $A3, $04, $08 DB $1F, $32, $04, $18 DB $1F, $31, $08, $18 DB $1F, $41, $08, $14 DB $1F, $10, $14, $18 DB $1F, $60, $00, $14 DB $1F, $54, $0C, $14 DB $1F, $20, $00, $18 DB $1F, $65, $10, $14 DB $1F, $A8, $04, $20 DB $1F, $87, $04, $1C DB $1F, $D7, $00, $1C DB $1F, $DC, $10, $1C DB $1F, $C9, $0C, $1C DB $1F, $B9, $0C, $20 DB $1F, $BA, $08, $20 DB $1F, $98, $1C, $20 AsteroidEdgesSize: equ $ - AsteroidEdges AsteroidEdgesCnt: equ AsteroidEdgesSize/4 AsteroidNormals: DB $1F, $09, $42, $51 DB $5F, $09, $42, $51 DB $9F, $48, $40, $1F DB $DF, $40, $49, $2F DB $5F, $2D, $4F, $41 DB $1F, $87, $0F, $23 DB $1F, $26, $4C, $46 DB $BF, $42, $3B, $27 DB $FF, $43, $0F, $50 DB $7F, $42, $0E, $4B DB $FF, $46, $50, $28 DB $7F, $3A, $66, $33 DB $3F, $51, $09, $43 DB $3F, $2F, $5E, $3F AsteroidNormalsSize: equ $ - AsteroidNormals AsteroidLen: equ $ - Asteroid
programs/oeis/138/A138986.asm
jmorken/loda
1
178583
; A138986: a(n) = Frobenius number for 6 successive numbers = F(n+1,n+2,n+3,n+4,n+5,n+6). ; 1,2,3,4,5,13,15,17,19,21,35,38,41,44,47,67,71,75,79,83,109,114,119,124,129,161,167,173,179,185,223,230,237,244,251,295,303,311,319,327,377,386,395,404,413,469,479,489,499,509,571,582,593,604,615,683,695,707 mov $1,$0 add $0,2 div $1,5 mul $1,$0 add $1,$0 sub $1,1
programs/oeis/186/A186301.asm
neoneye/loda
22
25500
; A186301: a(n) = A007521(n) - 2. ; 3,11,27,35,51,59,99,107,147,155,171,179,195,227,267,275,291,315,347,371,387,395,419,459,507,539,555,611,651,659,675,699,707,731,755,771,795,819,827,851,875,939,995,1011,1019,1059,1067,1091,1107,1115,1179,1211 mov $1,1 mov $2,$0 pow $2,2 add $2,1 mov $5,1 lpb $2 add $1,3 mov $3,$1 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,4 add $1,$5 sub $2,1 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe sub $1,3 div $1,2 mul $1,2 sub $1,3 mov $0,$1
alloy4fun_models/trashltl/models/6/RYGegq2n4cQWsNZdy.als
Kaixi26/org.alloytools.alloy
0
3533
open main pred idRYGegq2n4cQWsNZdy_prop7 { always all f : File | after f in Protected } pred __repair { idRYGegq2n4cQWsNZdy_prop7 } check __repair { idRYGegq2n4cQWsNZdy_prop7 <=> prop7o }
src/BinaryDataDecoders.ExpressionCalculator/Parser/ExpressionTree.g4
mwwhited/BinaryDataDecoders
5
3618
<reponame>mwwhited/BinaryDataDecoders<filename>src/BinaryDataDecoders.ExpressionCalculator/Parser/ExpressionTree.g4<gh_stars>1-10 grammar ExpressionTree; /* * Parser Rules This version supports defined order of operations */ start : expression EOF; value : NUMBER | VARIABLE; innerExpression : '[' inner=expression ']' | '(' inner=expression ')' ; unaryOperatorLeftExpression : operator=SUB (value | innerExpression | unaryOperatorLeftExpression) ; unaryOperatorRightExpression : value operator=FACTORIAL | innerExpression operator=FACTORIAL | unaryOperatorRightExpression operator=FACTORIAL ; expression : value | unaryOperatorLeftExpression | unaryOperatorRightExpression | innerExpression | left=expression operator=POW right=expression | left=expression operator=(MUL|DIV|MOD) right=expression | left=expression operator=(ADD|SUB) right=expression ; /* * Lexer Rules */ POW: '^'; MUL: '*'; DIV: '/'; ADD: '+'; SUB: '-'; MOD: '%'; FACTORIAL: '!'; NUMBER: /*'-'?*/ [0-9]+ ('.' [0-9]+)?; /* Allowed Examples 1 1.1 0.5 -1 -1.1 ... */ VARIABLE: [A-Z][a-zA-Z0-9]*; /* Allowed Examples A Ab A1 Abbb A123 */ WHITESPACE: [ \r\n\t]+ -> skip;
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/test_unknown_discrs.adb
best08618/asylo
7
3628
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/test_unknown_discrs.adb -- { dg-do compile } procedure Test_Unknown_Discrs is package Display is type Component_Id (<>) is limited private; Deferred_Const : constant Component_Id; private type Component_Id is (Clock); type Rec1 is record C : Component_Id := Deferred_Const; end record; Priv_Cid_Object : Component_Id := Component_Id'First; type Rec2 is record C : Component_Id := Priv_Cid_Object; end record; Deferred_Const : constant Component_Id := Priv_Cid_Object; end Display; begin null; end Test_Unknown_Discrs;
stdlib/linux64_oppio.asm
MadMax129/C-Interpreter
9
165038
<reponame>MadMax129/C-Interpreter<filename>stdlib/linux64_oppio.asm<gh_stars>1-10 global __oppio_println global __oppio_printnumb global __oppio_panic global __oppio_printc extern putc ; global _start global main section .text __oppio_strlen: xor rax, rax start_len: cmp byte [rdi], 0 je end_len inc rax inc rdi jmp start_len end_len: ret __oppio_println: mov r10, rdi call __oppio_strlen mov r9, rax mov rax, 1 mov rdi, 1 mov rsi, r10 mov rdx, r9 syscall xor rax, rax ret __oppio_printnumb: cmp rdi, 0 jns posative neg rdi push rdi mov dil, '-' call putc pop rdi posative: mov rax, rdi mov rcx, 0xa push rcx mov rsi, rsp sub rsp, 16 digit: xor rdx, rdx div rcx add rdx, '0' dec rsi mov [rsi], dl test rax,rax jnz digit mov rax, 0x2000004 mov rdi, 1 lea rdx, [rsp+16 + 1] sub rdx, rsi syscall add rsp, 24 ret __oppio_panic: mov rax, 60 syscall main: mov rdi, 'A' call __oppio_printc ret section .data
stage2/init16.asm
vendu/Ukko
0
84978
; init16.asm: 16-bit, real-mode initialization ; ; Copyright 2015, 2016 <NAME> ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; ; 1. Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; ; 2. Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. extern Init32 %define PMemTableCount 0x3300 %define MemTableCount dword[PMemTableCount] %define MemTableCountHi [PMemTableCount+4] %define PMemTable (PMemTableCount+8) section .data GdtPointer: limit: dw 23 base: dd GdtTable GdtTable: null: times 8 db 0 sys_code: .limit_low: dw 0xFFFF ; lower 16 bits of limit .base_low: dw 0x0000 ; Low 16 bits of the base .base_middle: db 0x00 ; Next 8 bytes of the base. .access db 0x9A ; Access flags, ring, etc .granularity db 0xCF ; Example code set all to 0xCF .base_high db 0x00 ; highest 0 bits of base sys_data: .limit_low: dw 0xFFFF ; lower 16 bits of limit .base_low: dw 0x0000 ; Low 16 bits of the base .base_middle: db 0x00 ; Next 8 bytes of the base. .access db 0x92 ; Access flags, ring, etc .granularity db 0xCF ; Example code set all to 0xCF .base_high db 0x00 ; highest 0 bits of base usr_code: .limit_low: dw 0xFFFF ; lower 16 bits of limit .base_low: dw 0x0000 ; Low 16 bits of the base .base_middle: db 0x00 ; Next 8 bytes of the base. .access db 0xFA ; Access flags, ring, etc .granularity db 0xCF ; Example code set all to 0xCF .base_high db 0x00 ; highest 0 bits of base usr_data: .limit_low: dw 0xFFFF ; lower 16 bits of limit .base_low: dw 0x0000 ; Low 16 bits of the base .base_middle: db 0x00 ; Next 8 bytes of the base. .access db 0xF2 ; Access flags, ring, etc .granularity db 0xCF ; Example code set all to 0xCF .base_high db 0x00 ; highest 0 bits of base section .text [BITS 16] global Init16 Init16: xor eax, eax mov dx, ax mov es, ax LoadMemoryTable: ; The following blanks a qword for alignment purposes. mov MemTableCount, eax mov MemTableCountHi, eax mov di, PMemTable xor ebx, ebx mov edx, 0x534D4150 .loop: mov eax, 0xE820 mov ecx, 24 int 0x15 jc .invalid inc MemTableCount or ebx, ebx jz .done add di, 24 jmp .loop .invalid: xor eax, eax dec eax mov ecx, 24 rep stosb .done: EnableA20: mov ax, 0x2401 int 0x15 LoadGdt: ; GdtPointer will be a 32-bit address, so here ; we convert it. mov ebx, GdtPointer ; Segment to ds mov eax, ebx shr eax, 4 mov ds, ax ; Offset to eax. This is probably always going ; to be 0, but just in case we calculate here. mov eax, ebx and eax, 0x0F cli lgdt [eax] EnterProtectedMode: mov eax, cr0 or al, 1 mov cr0, eax jmp dword 0x08:Init32
output/test3_corrected.asm
josuerocha/KPiler
1
81145
START PUSHN 2 PUSHN 1 PUSHN 1 PUSHS "Sim" STOREL 2 PUSHI 50 STOREL 3 PUSHI 100 STOREL 1 E: PUSHS "Pontuacao Candidato: " WRITES READ ATOI STOREL 0 PUSHS "Disponibilidade Candidato: " WRITES READ STOREL 2 PUSHL 0 PUSHL 3 SUP NOT JZ A JUMP D A: PUSHL 2 PUSHS "Sim" EQUAL NOT JZ B JUMP D B: PUSHS "Candidato aprovado" WRITES JUMP C D: PUSHS "Candidato reprovado" WRITES C: PUSHL 0 PUSHI 0 SUPEQ NOT JZ E JUMP F F: STOP
bugs/bug19.ada
daveshields/AdaEd
3
18509
<filename>bugs/bug19.ada GENERIC TYPE ValueType IS PRIVATE; WITH FUNCTION "+"(L, R: ValueType) RETURN ValueType; PACKAGE Matrices IS TYPE Matrix IS ARRAY(Integer RANGE <>, Integer RANGE <>) OF ValueType; FUNCTION "+" (K : IN ValueType; M : IN Matrix) RETURN Matrix; end Matrices; PACKAGE BODY Matrices IS FUNCTION "+" (K : IN ValueType; M : IN Matrix) RETURN Matrix IS BEGIN RETURN M; END "+"; END Matrices; WITH Matrices; PROCEDURE UseMatrices IS PACKAGE Float_Matrices IS NEW Matrices(ValueType => Float, "+" => "+"); BEGIN NULL; END UseMatrices;
src/pbkdf2.ads
AntonMeep/pbkdf2
0
3681
<reponame>AntonMeep/pbkdf2 with Ada.Streams; use Ada.Streams; with PBKDF2_Generic; with HMAC; use HMAC; with SHA1; with SHA2; package PBKDF2 with Pure, Preelaborate is package PBKDF2_HMAC_SHA_1_Package is new PBKDF2_Generic (Element => Stream_Element, Index => Stream_Element_Offset, Element_Array => Stream_Element_Array, Hash_Length => SHA1.Digest_Length, Hash_Context => HMAC_SHA_1.Context, Hash_Initialize => HMAC_SHA_1.Initialize, Hash_Update => HMAC_SHA_1.Update, Hash_Finalize => HMAC_SHA_1.Finalize); function PBKDF2_HMAC_SHA_1 (Password : String; Salt : String; Iterations : Positive; Derived_Key_Length : Stream_Element_Offset := SHA1.Digest_Length) return Stream_Element_Array renames PBKDF2_HMAC_SHA_1_Package.PBKDF2; function PBKDF2_HMAC_SHA_1 (Password : Stream_Element_Array; Salt : Stream_Element_Array; Iterations : Positive; Derived_Key_Length : Stream_Element_Offset := SHA1.Digest_Length) return Stream_Element_Array renames PBKDF2_HMAC_SHA_1_Package.PBKDF2; package PBKDF2_HMAC_SHA_256_Package is new PBKDF2_Generic (Element => Stream_Element, Index => Stream_Element_Offset, Element_Array => Stream_Element_Array, Hash_Length => SHA2.SHA_256.Digest_Length, Hash_Context => HMAC_SHA_256.Context, Hash_Initialize => HMAC_SHA_256.Initialize, Hash_Update => HMAC_SHA_256.Update, Hash_Finalize => HMAC_SHA_256.Finalize); function PBKDF2_HMAC_SHA_256 (Password : String; Salt : String; Iterations : Positive; Derived_Key_Length : Stream_Element_Offset := SHA2.SHA_256.Digest_Length) return Stream_Element_Array renames PBKDF2_HMAC_SHA_256_Package.PBKDF2; function PBKDF2_HMAC_SHA_256 (Password : Stream_Element_Array; Salt : Stream_Element_Array; Iterations : Positive; Derived_Key_Length : Stream_Element_Offset := SHA2.SHA_256.Digest_Length) return Stream_Element_Array renames PBKDF2_HMAC_SHA_256_Package.PBKDF2; package PBKDF2_HMAC_SHA_512_Package is new PBKDF2_Generic (Element => Stream_Element, Index => Stream_Element_Offset, Element_Array => Stream_Element_Array, Hash_Length => SHA2.SHA_512.Digest_Length, Hash_Context => HMAC_SHA_512.Context, Hash_Initialize => HMAC_SHA_512.Initialize, Hash_Update => HMAC_SHA_512.Update, Hash_Finalize => HMAC_SHA_512.Finalize); function PBKDF2_HMAC_SHA_512 (Password : String; Salt : String; Iterations : Positive; Derived_Key_Length : Stream_Element_Offset := SHA2.SHA_512.Digest_Length) return Stream_Element_Array renames PBKDF2_HMAC_SHA_512_Package.PBKDF2; function PBKDF2_HMAC_SHA_512 (Password : Stream_Element_Array; Salt : Stream_Element_Array; Iterations : Positive; Derived_Key_Length : Stream_Element_Offset := SHA2.SHA_512.Digest_Length) return Stream_Element_Array renames PBKDF2_HMAC_SHA_512_Package.PBKDF2; end PBKDF2;
src/Text/Lex.agda
t-more/agda-prelude
0
16050
<filename>src/Text/Lex.agda module Text.Lex where open import Prelude record TokenDFA {s} (A : Set) (Tok : Set) : Set (lsuc s) where field State : Set s initial : State accept : State → Maybe Tok consume : A → State → Maybe State instance FunctorTokenDFA : ∀ {s} {A : Set} → Functor (TokenDFA {s = s} A) TokenDFA.State (fmap {{FunctorTokenDFA}} f dfa) = TokenDFA.State dfa TokenDFA.initial (fmap {{FunctorTokenDFA}} f dfa) = TokenDFA.initial dfa TokenDFA.accept (fmap {{FunctorTokenDFA}} f dfa) s = f <$> TokenDFA.accept dfa s TokenDFA.consume (fmap {{FunctorTokenDFA}} f dfa) = TokenDFA.consume dfa keywordToken : {A : Set} {{EqA : Eq A}} → List A → TokenDFA A ⊤ TokenDFA.State (keywordToken {A = A} kw) = List A TokenDFA.initial (keywordToken kw) = kw TokenDFA.accept (keywordToken kw) [] = just _ TokenDFA.accept (keywordToken kw) (_ ∷ _) = nothing TokenDFA.consume (keywordToken kw) _ [] = nothing TokenDFA.consume (keywordToken kw) y (x ∷ xs) = ifYes (x == y) then just xs else nothing matchToken : ∀ {A : Set} (p : A → Bool) → TokenDFA A (List (Σ A (IsTrue ∘ p))) TokenDFA.State (matchToken {A = A} p) = List (Σ A (IsTrue ∘ p)) TokenDFA.initial (matchToken _) = [] TokenDFA.accept (matchToken _) xs = just (reverse xs) TokenDFA.consume (matchToken p) x xs = if′ p x then just ((x , it) ∷ xs) else nothing natToken : TokenDFA Char Nat natToken = pNat <$> matchToken isDigit where pNat = foldl (λ { n (d , _) → 10 * n + (charToNat d - charToNat '0') }) 0 identToken : ∀ {A : Set} → (A → Bool) → (A → Bool) → TokenDFA A (List A) TokenDFA.State (identToken {A = A} _ _) = Maybe (List A) TokenDFA.initial (identToken _ _) = nothing TokenDFA.accept (identToken _ _) = fmap reverse TokenDFA.consume (identToken first _) x nothing = if first x then just (just [ x ]) else nothing TokenDFA.consume (identToken _ then) x (just xs) = if then x then just (just (x ∷ xs)) else nothing module _ {s : Level} {A Tok : Set} where private DFA = TokenDFA {s = s} A Tok open TokenDFA init : DFA → Σ DFA State init d = d , initial d feed : A → Σ DFA State → Either DFA (Σ DFA State) feed x (d , s) = maybe (left d) (right ∘ _,_ d) (consume d x s) accepts : List (Σ DFA State) → List Tok accepts = concatMap (λ { (d , s) → maybe [] [_] (accept d s) }) tokenize-loop : List DFA → List (Σ DFA State) → List A → List Tok tokenize-loop idle active [] = case accepts active of λ where [] → [] -- not quite right if there are active DFAs (t ∷ _) → [ t ] tokenize-loop idle [] (x ∷ xs) = flip uncurry (partitionMap (feed x) (map init idle)) λ where idle₁ [] → [] idle₁ active₁ → tokenize-loop idle₁ active₁ xs tokenize-loop idle active (x ∷ xs) = flip uncurry (partitionMap (feed x) active) λ where idle₁ [] → case accepts active of λ where [] → [] (t ∷ _) → flip uncurry (partitionMap (feed x) (map init (idle ++ idle₁))) λ where _ [] → t ∷ [] idle₂ active₂ → t List.∷ tokenize-loop idle₂ active₂ xs idle₁ active₁ → tokenize-loop (idle ++ idle₁) active₁ xs tokenize : List (TokenDFA {s = s} A Tok) → List A → List Tok tokenize dfas xs = tokenize-loop dfas [] xs
src/Categories/Morphism/HeterogeneousIdentity.agda
MirceaS/agda-categories
0
9525
<reponame>MirceaS/agda-categories {-# OPTIONS --without-K --safe #-} open import Categories.Category using (Category) -- 'Heterogeneous' identity morphism and some laws about them. module Categories.Morphism.HeterogeneousIdentity {o ℓ e} (C : Category o ℓ e) where open import Level open import Relation.Binary.PropositionalEquality import Categories.Morphism as Morphism open Category C open Morphism C -- If Agda was an extensional type theory, any pair of morphisms -- -- f : A ⇒ B and g : A ⇒ C, -- -- where `A ≡ B`, would belong to the same homset, even if `A` and `B` -- are not definitionally equal. In particular, the identity on `B` -- could be given the type |id {B} : B ⇒ C|. -- -- But Agda is an intensional type theory, so the identity cannot have -- this type, in general. Instead one needs to manually 'transport' -- |id {B}| into the homset |B ⇒ C|. Given |p : B ≡ C| one obtains -- -- subst (B ⇒_) p (id {B}) -- -- Morphisms like thes are no longer identities (in the strict -- sense) but they still enjoy many of the properties identities do. -- -- To make this precise, this module introduces a notion of -- 'heterogeneous identity', which is an identity morphism whose -- domain and codomain are propositionally equal (but not necessarily -- syntically equal). -- A heterogeneous identity is just the transport of an identity -- along a 'strict' equation of objects. hid : ∀ {A B} (p : A ≡ B) → A ⇒ B hid {A} p = subst (A ⇒_) p id -- Lemmas about heterogeneous identities hid-refl : ∀ {A : Obj} → hid refl ≈ id {A} hid-refl = Equiv.refl hid-trans : ∀ {A B C} (p : B ≡ C) (q : A ≡ B) → hid p ∘ hid q ≈ hid (trans q p) hid-trans refl refl = identityˡ hid-symˡ : ∀ {A B} (p : A ≡ B) → hid (sym p) ∘ hid p ≈ id {A} hid-symˡ refl = identityˡ hid-symʳ : ∀ {A B} (p : A ≡ B) → hid p ∘ hid (sym p) ≈ id {B} hid-symʳ refl = identityˡ hid-iso : ∀ {A B} (p : A ≡ B) → Iso (hid p) (hid (sym p)) hid-iso p = record { isoˡ = hid-symˡ p ; isoʳ = hid-symʳ p } hid-cong : ∀ {A B} {p q : A ≡ B} → p ≡ q → hid p ≈ hid q hid-cong refl = Equiv.refl -- Transporting the domain/codomain is the same as -- pre/post-composing with heterogeneous identity. hid-subst-dom : ∀ {A B C} (p : A ≡ B) (f : B ⇒ C) → subst (_⇒ C) (sym p) f ≈ f ∘ hid p hid-subst-dom refl f = Equiv.sym identityʳ hid-subst-cod : ∀ {A B C} (f : A ⇒ B) (p : B ≡ C) → subst (A ⇒_) p f ≈ hid p ∘ f hid-subst-cod f refl = Equiv.sym identityˡ hid-subst₂ : ∀ {A B C D} (p : A ≡ B) (q : C ≡ D) (f : A ⇒ C) → subst₂ (_⇒_) p q f ≈ hid q ∘ f ∘ hid (sym p) hid-subst₂ refl refl f = Equiv.sym (Equiv.trans identityˡ identityʳ)
gcc-gcc-7_3_0-release/gcc/ada/a-szunau.ads
best08618/asylo
7
17921
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S T R I N G S . W I D E _ W I D E _ U N B O U N D E D . A U X -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-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. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This child package of Ada.Strings.Wide_Wide_Unbounded provides some -- specialized access functions which are intended to allow more efficient -- use of the facilities of Ada.Strings.Wide_Wide_Unbounded, particularly by -- other layered utilities. package Ada.Strings.Wide_Wide_Unbounded.Aux is pragma Preelaborate; subtype Big_Wide_Wide_String is Wide_Wide_String (Positive); type Big_Wide_Wide_String_Access is access all Big_Wide_Wide_String; procedure Get_Wide_Wide_String (U : Unbounded_Wide_Wide_String; S : out Big_Wide_Wide_String_Access; L : out Natural); pragma Inline (Get_Wide_Wide_String); -- This procedure returns the internal string pointer used in the -- representation of an unbounded string as well as the actual current -- length (which may be less than S.all'Length because in general there -- can be extra space assigned). The characters of this string may be -- not be modified via the returned pointer, and are valid only as -- long as the original unbounded string is not accessed or modified. -- -- This procedure is more efficient than the use of To_Wide_Wide_String -- since it avoids the need to copy the string. The lower bound of the -- referenced string returned by this call is always one, so the actual -- string data is always accessible as S (1 .. L). procedure Set_Wide_Wide_String (UP : out Unbounded_Wide_Wide_String; S : Wide_Wide_String) renames Set_Unbounded_Wide_Wide_String; -- This function sets the string contents of the referenced unbounded -- string to the given string value. It is significantly more efficient -- than the use of To_Unbounded_Wide_Wide_String with an assignment, since -- it avoids the necessity of messing with finalization chains. The lower -- bound of the string S is not required to be one. procedure Set_Wide_Wide_String (UP : in out Unbounded_Wide_Wide_String; S : Wide_Wide_String_Access); pragma Inline (Set_Wide_Wide_String); -- This version of Set_Wide_Wide_String takes a string access value, rather -- than string. The lower bound of the string value is required to be one, -- and this requirement is not checked. end Ada.Strings.Wide_Wide_Unbounded.Aux;
Library/Kernel/Sys/sysMisc.asm
steakknife/pcgeos
504
246905
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1989 -- All Rights Reserved PROJECT: PC GEOS MODULE: Kernel System Functions -- Miscellaneous Functions FILE: sysMisc.asm AUTHOR: <NAME>, Apr 6, 1989 ROUTINES: Name Description ---- ----------- GLB SysEmptyRoutine Routine that should never be called GLB SysShutdown Exit the system gracefully GLB SysGetConfig Return system configuration information GLB SysSetExitFlags Set/clear exit flags GLB UtilHex32ToAscii Convert a 32-bit number to an ascii GLB UtilAsciiToHex32 Convert an ASCII string to a 32-bit number string. RGLB SysLockBIOS Gain exclusive access to DOS/BIOS RGLB SysUnlockBIOS Release exclusive access to DOS/BIOS EXT SysCallCallbackBP Call a standard callback function passing bp properly. EXT SysJumpVector Call a vector w/o trashing registers EXT SysLockCommon Perform common module-lock lock operations EXT SysUnlockCommon Perform common module-lock unlock operations EXT SysPSemCommon Perform common PSem operations EXT SysVSemCommon Perform common VSem operations EXT SysCopyToStack* Copy a buffer to the stack for XIP GLB SYSSETINKWIDTHANDHEIGHT Set the default ink thickness GLB SYSGETINKWIDTHANDHEIGHT GLB SYSDISABLEAPO disable auto power off GLB SYSENABLEAPO enable auto power off REVISION HISTORY: Name Date Description ---- ---- ----------- Adam 4/ 6/89 Initial revision DESCRIPTION: Miscellaneous system functions $Id: sysMisc.asm,v 1.2 98/04/30 15:50:39 joon Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysSetExitFlags %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Sets and clears the exit flags (this is intended for use by task-switching drivers, primarily) CALLED BY: RESTRICTED GLOBAL PASS: bh - flags to clear bl - flags to set RETURN: bl - exitFlags DESTROYED: bh PSEUDO CODE/STRATEGY: This page intentionally left blank KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 5/ 2/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysSetExitFlags proc far uses ds .enter EC < test bl, not mask ExitFlags > EC < jnz bad > EC < test bh, not mask ExitFlags > EC < jz good > EC <bad: > EC < ERROR BAD_EXIT_FLAGS > EC <good: > LoadVarSeg ds ;Get ptr to idata or bl,ds:[exitFlags] ;Set bits not bh ; and bl,bh ;Clear bits mov ds:[exitFlags],bl ; .leave ret SysSetExitFlags endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LoadVarSegDS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Load the kernel's data segment into DS CALLED BY: INTERNAL PASS: nothing RETURN: ds = idata DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/ 8/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ kernelData word dgroup LoadVarSegDS proc near .enter mov ds, cs:kernelData .leave ret LoadVarSegDS endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LoadVarSegES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Load the kernel's data segment into ES CALLED BY: INTERNAL PASS: nothing RETURN: es = idata DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/ 8/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ LoadVarSegES proc near .enter mov es, cs:kernelData .leave ret LoadVarSegES endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysEmptyRoutine %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: A routine to which empty slots in the jump table are vectored CALLED BY: Shouldn't be PASS: Anything RETURN: Never DESTROYED: Everything PSEUDO CODE/STRATEGY: FatalError(SYS_EMPTY_CALLED) KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/ 6/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysEmptyRoutine proc far ERROR SYS_EMPTY_CALLED SysEmptyRoutine endp ForceRef SysEmptyRoutine ;Used for "skip" in .gp file COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysShutdown %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Cause the system to exit CALLED BY: EXTERNAL PASS: ax - SysShutdownType. See documentation in system.def for additional parameters specific to the type of shutdown RETURN: only as noted in system.def DESTROYED: ax, bx, cx, dx, bp PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/13/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysShutdown proc far uses es, ds, si, di .enter EC < cmp ax,SysShutdownType > EC < ERROR_AE BAD_SHUTDOWN_TYPE > mov_tr di, ax LoadVarSeg es, ax shl di jmp cs:[shutdownTable][di] shutdownTable nptr.near clean, ; SST_CLEAN cleanForced, ; SST_CLEAN_FORCED dirty, ; SST_DIRTY EndGeosDoubleFault, ; SST_PANIC reboot, ; SST_REBOOT restart, ; SST_RESTART final, ; SST_FINAL suspend, ; SST_SUSPEND confirmStart, ; SST_CONFIRM_START confirmEnd, ; SST_CONFIRM_END cleanReboot, ; SST_CLEAN_REBOOT powerOff ; SST_POWER_OFF ;-------------------- dirty: inc es:[errorFlag] ; set errorFlag so we don't delete ; the GEOS_ACT.IVE file, thereby ; alerting us to the non-standard ; exit next time. ; FALL THROUGH ;-------------------- final: cmp si, -1 je die ; move the string to messageBuffer mov di, offset messageBuffer mov cx, length messageBuffer-1 copyLoop: if not DBCS_PCGEOS lodsb else lodsw EC < tst ah > EC < WARNING_NZ LARGE_VALUE_FOR_CHARACTER > endif stosb tst al loopne copyLoop clr al stosb die: jmp EndGeos ;-------------------- reboot: ornf es:[exitFlags], mask EF_RESET jmp EndGeos ;-------------------- restart: call DosExecPrepareForRestart LONG jc done ;-------------------- cleanForced: ; If the UI is not running, just exit mov bx,es:[uiHandle] tst bx jz die ; The UI is running -- tell it to kill all apps & fields. No ack optr ; or ID, as the UI will call us back with SST_FINAL when everything's ; ready to go. mov ax, MSG_META_DETACH clr cx, dx, bp, di call ObjMessage clc jmp done ;-------------------- powerOff: push ds, si, di ; jfh 12/05/03 - lets put the string in a resource for localization mov bx, handle MovableStrings call MemLock mov ds, ax ; segmov ds, cs mov si, offset PowerOffString mov si, ds:[si] ; ds:si <- PowerOffString mov di, offset messageBuffer LocalCopyString call MemUnlock pop ds, si, di ornf es:[exitFlags], mask EF_POWER_OFF jmp short clean ;PowerOffString char "You may now safely turn off the computer.",0 ;-------------------- cleanReboot: ornf es:[exitFlags], mask EF_RESET ; FALL THROUGH ;-------------------- clean: mov di, GCNSCT_SHUTDOWN cleanSuspendCommon: segmov ds, es ; ; Gain exclusive access to the shutdown-status variables. ; PSem ds, shutdownBroadcastSem, TRASH_AX_BX ; ; If something else is already shutting down the system, fail this ; request. ; tst ds:[shutdownConfirmCount] jnz failCleanSuspend ; ; Record the object we should notify when the final confirmation ; comes in. ; mov ds:[shutdownAckOD].handle, cx mov ds:[shutdownAckOD].chunk, dx mov ds:[shutdownAckMsg], bp ; ; Start the count off at 1 so we can reliably figure out when to send ; out notification and deal with not having anyone interested in what ; we've got to say...The extra 10,000 are to deal with having something ; being notified being run by this thread (since we can't add the ; count of the number of notifications in until GCNListRecordAndSend ; returns). ; mov ds:[shutdownConfirmCount], 10001 VSem ds, shutdownBroadcastSem, TRASH_AX_BX ; ; Broadcast the intent to shutdown. ; mov bx, MANUFACTURER_ID_GEOWORKS mov si, GCNSLT_SHUTDOWN_CONTROL mov bp, di clr di ; not status message mov ax, MSG_META_CONFIRM_SHUTDOWN call GCNListRecordAndSend ; ; Record the number of acks needed and remove our protective 10,000 ; add ds:[shutdownConfirmCount], cx sub ds:[shutdownConfirmCount], 10000 ; ; Now perform an SST_CONFIRM_END allowing the shutdown, thereby sending ; confirmation to the caller if there was no one on the list. ; mov cx, TRUE jmp confirmEnd failCleanSuspend: ; ; Someone else is doing a shutdown, so we can't start this one off. ; Release the broadcast semaphore and return carry set. ; VSem ds, shutdownBroadcastSem, TRASH_AX_BX doneCarrySet: stc done: .leave ret ;-------------------- suspend: mov di, GCNSCT_SUSPEND jmp cleanSuspendCommon ;-------------------- confirmStart: ; ; Gain the exclusive right to ask the user to confirm. ; segmov ds, es PSem ds, shutdownConfirmSem, TRASH_AX_BX ; ; If not already refused, return carry clear. ; tst ds:[shutdownOK] jnz done ; ; Someone's already refused the shutdown, so call ourselves to deny ; the request and return carry set. clr cx mov ax, SST_CONFIRM_END call SysShutdown jmp doneCarrySet ;-------------------- confirmEnd: segmov ds, es jcxz denied releaseConfirmSem: VSem ds, shutdownConfirmSem, TRASH_AX_BX ; ; Gain exclusive access to the confirm count & attendant variables, to ; prevent some other thread from coming in after the dec but before we ; can load the other variables, and trashing them... ; PSem ds, shutdownBroadcastSem, TRASH_AX_BX dec ds:[shutdownConfirmCount] jz sendShutdownConfirmAck confirmEndComplete: VSem ds, shutdownBroadcastSem, TRASH_AX_BX clc ; carry clear for SST_CLEAN/SST_SUSPEND... jmp done denied: ; ; Caller is refusing the shutdown, so mark the shutdown as denied ; and do all the normal processing for SST_CONFIRM_END. ; mov ds:[shutdownOK], FALSE jmp releaseConfirmSem sendShutdownConfirmAck: ; ; Fetch shutdownOK into CX to tell the original caller whether it's ; ok to shutdown/suspend. ; clr cx mov cl, TRUE xchg ds:[shutdownOK], cl ; ; If no shutdownAckOD, it means we should notify the UI in the normal ; fashion. ; mov bx, ds:[shutdownAckOD].handle tst bx jz sendToUI mov ax, ds:[shutdownAckMsg] mov si, ds:[shutdownAckOD].chunk sendShutdownAckMessage: clr di call ObjMessage jmp confirmEndComplete sendToUI: ; ; If the shutdown was refused and there's no one specific to notify, we ; don't need to notify anyone. The UI hasn't been involved in the shut- ; down hitherto, so there's no need to notify it. ; mov bx, ds:[uiHandle] EC < tst bx > EC < ERROR_Z NO_ONE_TO_SEND_SHUTDOWN_ACK_TO_ALAS > mov ax, MSG_META_DETACH clr dx, bp ; no Ack OD tst cx jnz sendShutdownAckMessage ; ; If marked as running a DOS application, let the task driver know ; the shutdown was aborted. ; test ds:[exitFlags], mask EF_RUN_DOS jz confirmEndComplete mov di, DR_TASK_SHUTDOWN_COMPLETE call ds:[taskDriverStrategy] jmp confirmEndComplete SysShutdown endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYSGETCONFIG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return the system configuration CALLED BY: GLOBAL PASS: Nothing RETURN: AL = SysConfigFlags reflecting system status AH = reserved DL = SysProcessorType given processor type DH = SysMachineType giving machine type DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 5/17/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SYSGETCONFIG proc far push ds LoadVarSeg ds clr ax mov al, ds:sysConfig mov dx, word ptr ds:sysProcessorType pop ds ret SYSGETCONFIG endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYSGETPENMODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: This routine returns AX = TRUE or FALSE depending upon whether or not the machine PC/GEOS is running on is Pen-based or not. CALLED BY: GLOBAL PASS: nada RETURN: AX = TRUE if PC/GEOS is running on a pen-based system. DESTROYED: nada PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 11/18/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SYSGETPENMODE proc far uses ds .enter LoadVarSeg ds, ax mov ax, ds:[penBoolean] .leave ret SYSGETPENMODE endp IMResident segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysDisableAPO %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Disable auto power off feature CALLED BY: Global PASS: nothing RETURN: nothing DESTROYED: ds SIDE EFFECTS: PSEUDO CODE/STRATEGY: if disableAPOCount > 0 dec disableAPOCount REVISION HISTORY: Name Date Description ---- ---- ----------- IP 4/29/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SYSDISABLEAPO proc far uses ds .enter call LoadVarSegDS inc ds:[disableAPOCount] EC< ERROR_Z DISABLE_APO_COUNT_OVERFLOW > .leave ret SYSDISABLEAPO endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysEnableAPO %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Enable auto power off feature CALLED BY: Global PASS: nothing RETURN: nothing DESTROYED: ds SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- IP 4/29/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SYSENABLEAPO proc far uses ds .enter call LoadVarSegDS dec ds:[disableAPOCount] EC< ERROR_S DISABLE_APO_COUNT_OVERFLOW > .leave ret SYSENABLEAPO endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysGetInkWidthAndHeight %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: This function returns the current height and width to be used as defaults for drawing ink CALLED BY: Global PASS: nothing RETURN: ax - default width and height DESTROYED: SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- IP 4/28/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SYSGETINKWIDTHANDHEIGHT proc far uses ds .enter LoadVarSeg ds, ax mov ax, ds:[inkDefaultWidthAndHeight] .leave ret SYSGETINKWIDTHANDHEIGHT endp IMResident ends IMPenCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysSetInkWidthAndHeight %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Sets the default ink width value CALLED BY: global PASS: ax - ink height and width RETURN: nothing DESTROYED: SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- IP 4/28/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysSetInkWidthAndHeight proc far uses bx, ds .enter LoadVarSeg ds, bx mov ds:[inkDefaultWidthAndHeight], ax .leave ret SysSetInkWidthAndHeight endp IMPenCode ends COMMENT @----------------------------------------------------------------------- FUNCTION: UtilHex32ToAscii DESCRIPTION: Converts a 32 bit unsigned number to its ASCII representation. CALLED BY: INTERNAL (GenerateLabel) PASS: DX:AX = DWord to convert CX = UtilHexToAsciiFlags UHTAF_INCLUDE_LEADING_ZEROS UHTAF_NULL_TERMINATE ES:DI = Buffer to place string. Should be of size: UHTA_NO_NULL_TERM_BUFFER_SIZE or UHTA_NULL_TERM_BUFFER_SIZE RETURN: CX = Length of the string (not including NULL) DESTROYED: Nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: You might think that one could use the 8086 32bit divide instruction to perform the conversion here. You'd be wrong. The divisor (10) is too small. Given something greater than 64k * 10, we will get a divide- by-zero trap the first time we try to divide. So we use "32-bit" division with a 16-bit divisor to avoid such problems, doing two divides instead of one, etc. KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Cheng 7/89 Initial version Don 1/92 Changed dword parameter to DX:AX -------------------------------------------------------------------------------@ UtilHex32ToAscii proc far uses ax, bx, dx, di, si, bp .enter if FULL_EXECUTE_IN_PLACE EC < push bx, si > EC < movdw bxsi, esdi > EC < call ECAssertValidFarPointerXIP > EC < pop bx, si > endif mov si, cx ;place flags in si ; ; Check for a signed value ; test si, mask UHTAF_SIGNED_VALUE jz notSigned tst dx jns notSigned ; ; The value is signed and negative. Stick in a minus sign and negate. ; negdw dxax ;dx:ax <- negative of value push ax DBCS < LocalLoadChar ax, C_MINUS_SIGN > SBCS < LocalLoadChar ax, C_MINUS > LocalPutChar esdi, ax pop ax jmp afterSigned notSigned: andnf si, not (mask UHTAF_SIGNED_VALUE) afterSigned: ; ; First convert the number to characters, storing each on the stack ; mov bx, 10 ;print in base ten clr cx ;cx <- char count xchg ax, dx nextDigit: mov bp, dx ;bp = low word clr dx ;dx:ax = high word div bx xchg ax, bp ;ax = low word, bp = quotient div bx xchg ax, dx ;ax = remainder, dx = quotient add al, '0' ;convert to ASCII push ax ;save character inc cx mov ax, bp ;retrieve quotient of high word or bp, dx ;check if done jnz nextDigit ;if not, do next digit ; Now let's see if we need to provide leading zeroes. A 32-bit ; binary values can be as long as ten digits. ; test si, mask UHTAF_INCLUDE_LEADING_ZEROS jz copyChars sub bx, cx ;bx <- number of 0s needed mov cx, bx ;place count in cx jcxz tenDigits ;if already ten digits, jump mov ax, '0' ;character to push addLeadZeros: push ax loop addLeadZeros tenDigits: mov cx, 10 ;digit count = 10 ; Now pop the characters into its buffer, one-by-one ; copyChars: mov dx, cx ;dx = character count DBCS < test si, mask UHTAF_SBCS_STRING ;want SBCS string? > DBCS < jnz nextCharSBCS ;branch if SBCS > nextChar: pop ax ;retrieve character SBCS < stosb > DBCS < stosw > ; ; Check for thousands separators ; test si, mask UHTAF_THOUSANDS_SEPARATORS jz afterComma ;branch if no separators cmp cx, 10 je storeComma cmp cx, 7 je storeComma cmp cx, 4 je storeComma afterComma: loop nextChar ;loop to print all DBCS <afterChars: > ; ; Count the sign character if we added it above ; test si, mask UHTAF_SIGNED_VALUE jz noSignChar inc dx ;dx <- one more char noSignChar: ; ; Add a NULL if requested ; test si, mask UHTAF_NULL_TERMINATE ;NULL-terminate the string ?? jz noNULL ;nope, so we're done SBCS < mov {byte} es:[di], 0 ;this is fastest > DBCS < mov {wchar}es:[di], 0 ;this is fastest > noNULL: mov cx, dx ;cx = character count .leave ret storeComma: inc dx ;dx <- 1 more character push cx, dx call LocalGetNumericFormat mov ax, bx ;ax <- thousands separator LocalPutChar esdi, ax pop cx, dx jmp afterComma if DBCS_PCGEOS nextCharSBCS: pop ax ;retrieve character stosb ;store SBCS character loop nextCharSBCS ;loop to print all jmp afterChars endif UtilHex32ToAscii endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% UtilAsciiToHex32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Converts a null-terminated ASCII string into a dword. The string may be signed or unsigned. CALLED BY: GLOBAL PASS: DS:SI = String to convert RETURN: DX:AX = DWord value Carry = Clear (valid number) - or - Carry = Set (invalid number) AX = UtilAsciiToHexError DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 1/ 2/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ UtilAsciiToHex32 proc far uses bx, cx, bp, si .enter if FULL_EXECUTE_IN_PLACE EC < call ECCheckBounds > endif ; See if we have a leading minus sign ; clr ax ; assume positive number LocalCmpChar ds:[si], '+' ; just skip over a '+', as we je skipChar ; assume the number is positive LocalCmpChar ds:[si], '-' ; check for negative sign jne startConversion ; if not there, jump dec ax ; else set minus boolean skipChar: inc si ; increment past minus sign LocalNextChar dssi ; increment past minus sign ; Calculate the number, digit by digit ; startConversion: push ax ; save minus boolean clrdw dxcx ; initialize our number convertDigit: LocalGetChar ax, dssi ; get the next digit LocalIsNull ax ; NULL termination ?? jz done ; yes, so jump SBCS < sub al, '0' ; turn into a number > DBCS < sub ax, '0' ; turn into a number > SBCS < cmp al, 9 ; ensure we have a digit > DBCS < cmp ax, 9 ; ensure we have a digit > ja notADigit shldw dxcx ; double current value jc overflow movdw bpbx, dxcx shldw dxcx jc overflow shldw dxcx ; 8 * original value => DX:CX jc overflow adddw dxcx, bpbx ; and in 2 * original value jc overflow SBCS < clr ah > add cx, ax ; add in new digit adc dx, 0 ; propogate carry jnc convertDigit ; loop until done, or overflow ; Deal with error - either an invalid digit or overflow overflow: mov cx, UATH_CONVERT_OVERFLOW jmp error ; we fail with an error notADigit: mov cx, UATH_NON_NUMERIC_DIGIT_IN_STRING error: stc done: pop ax ; minus boolean => AX xchg ax, cx ; result => DX:AX, boolean => CX jc exit ; if error, don't do anything jcxz exit ; if zero, we're OK mov cx, UATH_CONVERT_OVERFLOW test dh, 0x80 ; high bit must be clear stc jnz exit ; ...else we have overflow negdw dxax ; else negate the number clc ; ensure carry is clear exit: .leave ret UtilAsciiToHex32 endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCallCallbackBP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Standard utility function for calling a callback function where bp must be passed. The calling function must have a stack frame whose first local variable is a far pointer to the callback routine. CALLED BY: ThreadProcess, FilePathProcess, GeodeProcess, DiskForEach, WinForEach PASS: ax, cx, dx, ss:[bp] = data to pass to callback. ss:[bp] is the bp from entry to the calling function RETURN: ax, cx, dx, ss:[bp] = data returned by callback carry - returned from callback DESTROYED: si (callback may destroy di as well) PSEUDO CODE/STRATEGY: Notes - ss:bp points to the word to pass in to called routine as bp. save this pointer load in bp to pass to routine call routine restore pointer to BPData stuff returned BP value into BPData return KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 5/24/90 Initial version todd 02/10/94 Added XIP version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysCallCallbackBP proc near callback local fptr.far .enter inherit push bp ; ; See if we are passed a vfptr, or an fptr. ; Do different actions, depending upon the state ; of the high-byte of the segment. ; -- todd 02/17/94 FXIP< cmp {byte}callback.segment.high, SIG_UNUSED_FF > FXIP< je doHighMemCall > FXIP< cmp {byte}callback.segment.high, high MAX_SEGMENT > FXIP< jae doProcCall > doHighMemCall:: ; ; We got here by one of two ways, either we are ; calling something in high memory, or we are calling ; a segment that doesn't have an 0fh, in the high nibble. ; -- todd 02/17/94 lea si, callback ; ss:[si] = callback routine mov bp, ss:[bp] ; recover bp passed to caller call {dword}ss:[si] done:: mov si, bp ; preserve returned bp pop bp ; recover our frame pointer mov ss:[bp], si ; store returned bp for possible ; return/next call .leave ret doProcCall:: ; ; Stuff AX and BX into ThreadPrivData so they will be ; passed along to routine. Passing BX in this way ; is easier than pushing and popping, and faster as well. ; -- todd 02/10/94 FXIP< mov ss:[TPD_dataAX], ax > FXIP< mov ss:[TPD_dataBX], bx > FXIP< movdw bxax, callback ; bx:ax <- vfptr to callback > FXIP< mov bp, ss:[bp] ; bp <- data to pass in bp > FXIP< call ProcCallFixedOrMovable > FXIP< jmp short done > SysCallCallbackBP endp SysCallCallbackBPFar proc far call SysCallCallbackBP ret SysCallCallbackBPFar endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysLockBIOS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Gain exclusive access to BIOS/DOS CALLED BY: RESTRICTED GLOBAL PASS: nothing RETURN: nothing DESTROYED: flags PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 10/16/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysLockBIOSFar proc far call SysLockBIOS ret SysLockBIOSFar endp public SysLockBIOSFar SysLockBIOS proc near push bx mov bx, offset biosLock jmp SysLockCommon SysLockBIOS endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysUnlockBIOS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Release exclusive access to BIOS/DOS CALLED BY: RESTRICTED GLOBAL PASS: nothing RETURN: nothing DESTROYED: nothing (flags preserved) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 10/16/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysUnlockBIOSFar proc far call SysUnlockBIOS ret SysUnlockBIOSFar endp public SysUnlockBIOSFar SysUnlockBIOS proc near if CHECKSUM_DOS_BLOCKS ; ; Before releasing the BIOS lock, perform checksums of various DOS ; blocks and save them away for SysLockBIOS. ; call SysComputeDOSBlockChecksums endif push bx mov bx, offset biosLock jmp SysUnlockCommon SysUnlockBIOS endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysLockCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Perform common module-lock activities for the various module locks in the kernel. THIS MUST BE JUMPED TO CALLED BY: EXTERNAL PASS: bx = offset in idata of the ThreadLock to lock previous bx pushed on stack RETURN: doesn't. DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/ 5/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysLockCommon proc near jmp on_stack bx retn push ds on_stack ds bx retn LoadVarSeg ds push ax on_stack ax ds bx retn ; Crash if someone is trying to call this from the kernel thread, ; after the kernel has been initialized. This catches problems where ; people try to grab semaphores from the Idle loop. ; ; It turns out that ThreadDestroy locks down blocks while on the kernel ; thread, but it already has the heap semaphore, so we don't bother ; checking the heap semaphore here (if we actually block on the heap ; semaphore, it will still die in BlockOnLongQueue). EC < cmp bx, offset heapSem > EC < jz notKernel > EC < tst ds:[currentThread] > EC < jnz notKernel > EC < tst ds:[interruptCount] > EC < jnz notKernel > EC < tst ds:[initFlag] > EC < jnz notKernel > ; the stub sometimes calls MemLock pretending to be the kernel. so ; it sets TPD_dataAX to be 0xadeb specifically for this piece of EC ; code, so that it knows that its really the stub and not the kernel ; that is running here. jimmy - 8/94 ; This is no longer true. Instead, the swat stub does nothing ; special when it calls MemLock. It just so happens that when the ; stub fakes calling MemLock, its ThreadPrivateData has no exception ; handlers. So, to make things all better (now that the exception ; handlers are in a separate block), simply check to see if the ; TPD_exceptionHandlers ptr is null. If it is NULL, and the ; "currentThread" is 0, we know it is the swat stub. In that case, ; DO NOT fatal error. JimG - 6/4/96 EC < tst ss:[TPD_exceptionHandlers] > EC < jz notKernel > ; At this point, we know that this is actually the kernel thread. But ; there is a special case for ThreadDestroy where we know that (1) the ; kernel thread has the BIOS lock (in a manner of speaking) and (2) it ; will not block if we call SysLockBIOS. So, if the kernel thread ; tries to grab the BIOS and the kernel already has it (i.e., the ; TL_owner is 0) then don't complain about it. EC < cmp bx, offset biosLock > EC < jne notBiosLock > EC < tst ds:[bx].TL_owner > EC < jz notKernel > EC <notBiosLock: > EC < ERROR BLOCK_IN_KERNEL > EC <notKernel: > EC < tst ds:[interruptCount] > EC < ERROR_NZ NOT_ALLOWED_TO_PSEM_IN_INTERRUPT_CODE > ; XXX: TRASH_AX_BX doesn't really trash BX, since it holds the ; address of the module lock. This is just to save bytes and ; cycles by not pushing and popping BX when the macro can't ; destroy BX anyway, since it has to use it to claim ownership ; of the lock once the semaphore in the lock has been grabbed. ; So much for data-hiding-via-macros... -- ardeb/tony 11/15/90 LockModule ds:[currentThread], ds, [bx], TRASH_AX_BX, \ <ax ds bx retn> pop ax cmp bx, offset biosLock je saveStack done: on_stack ds bx retn pop ds on_stack bx retn pop bx on_stack retn ret saveStack: ; ; Save the current stack segment away so ThreadFindStack has a chance ; of finding the right one. ; mov ds:[biosStack], ss if CHECKSUM_DOS_BLOCKS ; ; After acquiring the BIOS lock, perform checksums of various DOS ; blocks, and see if they have changed from the last SysUnlockBIOS. ; call SysCompareDOSBlockChecksums endif ; CHECKSUM_DOS_BLOCKS jmp done SysLockCommon endp if CHECKSUM_DOS_BLOCKS dosBlockNames char 7, "COMMAND" char 0 MAX_DOS_CHECKSUMS equ 10 DOSBlockStruct struct dbSeg word dbSize word dbSum word DOSBlockStruct ends udata segment DOSBlockInit byte ? numDOSBlocks byte ? DOSBlocks DOSBlockStruct MAX_DOS_CHECKSUMS dup(<>) udata ends COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysSetDOSTables %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Initialize the DOS block checksum structures. This routine loops thru the DOS MCB chain, identifying each block in the system. Blocks of interest include certain subsegments of system blocks and blocks listed in dosBlockNames. These currently include: DOS system subsegments: System file tables FCB's Current Directory Table Stacks Blocks identified by name: COMMAND Each block's segment and size is stored in the global DOSBlocks table. This table is used later by SysCompute... and SysCompareDOSBlockChecksums to monitor each block independently. CALLED BY: BootInit PASS: nothing RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: Scan the DOS MCB chain for blocks to check Store interesting blocks in DOSBlocks KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- dhunter 3/7/2000 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysSetDOSTables proc far pusha ; ; Get the address of the various DOS system tables and store ; it in the reply. This uses the undocumented DOS function ; 52, which returns in ES:BX a pointer to a table of pointers ; to various system data structures. ; mov ah, 52h ; Get DOS tables... int 21h ; ; Point to the start of the checksum table and clear it. ; mov bp, offset DOSBlocks clr ds:[numDOSBlocks] clr ds:[DOSBlockInit] ; ; Iterate the DOS MCBs to find interesting blocks ; segmov es, es:[bx-2] next: mov cx, {word}es:3 ; cx <- size (in paragraphs) mov ax, {word}es:1 ; ax <- owner tst ax ; maybe IRQ je nope cmp ax, 8 ; system - yes je doSystem cmp ax, 7 ; excluded - no je nope cmp ax, 6 ; umb - no je nope cmp ax, 0fffdh ; 386MAX - no jae nope ; ; It's something real, check the name. ; push ax, cx, ds, es dec ax mov es, ax ; es:0 <- owner's MCB segmov ds, cs, ax mov si, offset dosBlockNames nextName: mov cl, {byte}ds:[si] tst cl stc jz endName inc si clr ch mov di, 8 repe cmpsb clc jne goNextName ; mismatch in given bytes cmp di, 16 ; compared all 8 chars? je endName tst {byte}es:[di] ; if not, is null term there? je endName goNextName: add si, cx jmp nextName endName: pop ax, cx, ds, es jc nope if 0 ; This turned out not to be such a great idea. ; jnc doit ; ; Check if it's our (loader's) block, and if so, add the PSP to the ; list (only the first 110h bytes (MCB + PSP)) ; mov ax, es inc ax cmp ax, ds:[loaderVars].KLV_pspSegment jne nope mov cx, (110h shr 4) ; fall-thru to doit... endif ; ; We like this one, add it to the list. ; doit:: segmov ds:[bp].dbSeg, es, ax mov ds:[bp].dbSize, cx inc ds:[numDOSBlocks] add bp, size DOSBlockStruct ; ; Advance to next block. ; nope: mov al, {byte}es:0 mov cx, {word}es:3 ; cx <- size (in paragraphs) mov dx, es add dx, cx inc dx mov es, dx ; es <- next block cmp al, 04dh ; was block control? je next cmp {byte}es:0, 04dh ; is next block control? LONG je next popa ret ; ; Check the subsegments of the system block (if it has any). ; doSystem: cmp {word}es:8, 04353h ; Is this video memory? je nope mov di, 16 ; di <= byte offset of current sub mov dx, 1 ; dx <= paragraph offset of current sub nextSub: cmp dx, cx ; stop when we exceed main block size ja doneSystem mov al, {byte}es:[di] mov bx, {word}es:[di+3] ; bx <= paragraphs in sub cmp al, 'F' ; System file tables je doSub cmp al, 'X' ; FCB's je doSub cmp al, 'L' ; Current Directory Table je doSub ; cmp al, 'S' ; Stacks ; je doSub jmp nopeSub ; ; We like this subsegment, add it to the list. ; doSub: mov ax, es ; compute zero-based segment add ax, dx mov ds:[bp].dbSeg, ax mov ds:[bp].dbSize, bx inc ds:[numDOSBlocks] add bp, size DOSBlockStruct ; ; Move to next subsegment. ; nopeSub: inc bx add dx, bx ; update current paragraph offset shl bx shl bx shl bx shl bx ; bx <- byte length of sub add di, bx ; update current byte offset jmp nextSub ; ; We're currently pointing to the next block, so update es ; and return to the main loop. ; doneSystem: mov ax, es ; compute zero-based segment add ax, dx mov es, ax jmp next SysSetDOSTables endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysComputeDOSBlockChecksums %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Loop thru DOSBlocks, compute the checksums for each block, and store the results for future comparison. CALLED BY: SysUnlockBIOS PASS: nothing RETURN: nothing DESTROYED: nothing (flags preserved) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- dhunter 3/7/2000 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysComputeDOSBlockChecksums proc near uses ax, bx, cx, si, di, ds, es .enter pushf LoadVarSeg ds ; ; Only compute if biosLock is about to be completely unlocked. ; cmp ds:[biosLock].TL_nesting, 1 jne done ; ; Iterate the DOSBlocks table, checksumming (is that a real word?) ; each block and storing the result. ; clr ch mov cl, ds:[numDOSBlocks] tst cl jz done mov si, offset DOSBlocks next: xchg bx, cx segmov es, ds:[si].dbSeg, ax mov cx, ds:[si].dbSize call SysComputeDBChecksum mov ds:[si].dbSum, ax add si, size DOSBlockStruct xchg bx, cx loop next done: popf .leave ret SysComputeDOSBlockChecksums endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCompareDOSBlockChecksums %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Loop thru DOSBlocks, compute the checksums for each block, and compare them to the previously stored results. If a block has changed, EC will throw a FatalError, and NC will display a SysNotify box. CALLED BY: SysLockCommon PASS: nothing RETURN: nothing DESTROYED: nothing (flags preserved) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- dhunter 3/7/2000 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysCompareDOSBlockChecksums proc near uses ax, bx, cx, si, di, ds, es .enter pushf LoadVarSeg ds ; ; Only compare if biosLock was locked for the first time. ; cmp ds:[biosLock].TL_nesting, 1 jne done ; ; If this is the first call, do nothing. The checksums are not ; initialized, and the FS skeleton driver has been making direct ; int 21h calls up until now. Allow the followup SysUnlockBIOS ; to initialize the checksums and then all will be happy. ; tst ds:[DOSBlockInit] jz notYet ; ; Iterate the DOSBlocks table, checksumming (is that a real word?) ; each block and comparing the result with the previous results. ; clr ch mov cl, ds:[numDOSBlocks] tst cl jz done mov si, offset DOSBlocks next: xchg bx, cx segmov es, ds:[si].dbSeg, ax mov cx, ds:[si].dbSize call SysComputeDBChecksum cmp ds:[si].dbSum, ax jne mismatch add si, size DOSBlockStruct xchg bx, cx loop next done: popf .leave ret notYet: inc ds:[DOSBlockInit] jmp done ; ; Raiase a SysNotify error message. ; mismatch: EC < ERROR_NE DOS_BLOCK_CHECKSUM_CHANGED > call SysDBCFailure ; allow shutdown to occur unchallenged clr ds:[numDOSBlocks] jmp done SysCompareDOSBlockChecksums endp SysComputeDBChecksum proc near ; es:0 = start of block ; cx = length (in paragraphs) of block push dx mov dx, es clr ax next: add ax, {word}es:00h ; sum this paragraph add ax, {word}es:02h add ax, {word}es:04h add ax, {word}es:06h add ax, {word}es:08h add ax, {word}es:0ah add ax, {word}es:0ch add ax, {word}es:0eh inc dx ; go to the next one mov es, dx ; ack! Segment arithmetic! loop next pop dx ret SysComputeDBChecksum endp SysDBCFailure proc near ; ds:si = DOSBlockStruct that changed ; ax = new checksum newSum local word push ax ; save new checksum uses ds .enter mov al, KS_DOS_BLOCK_CHECKSUM_BAD call AddStringAtMessageBuffer inc di ;put second string after first push di mov al, 'B' ; write "B" stosb mov ax, ds:[si].dbSeg ; write segment call Hex16ToAscii mov ax, ('S' shl 8) or C_SPACE ; write " S" stosw mov ax, ds:[si].dbSize ; write size call Hex16ToAscii mov ax, ('O' shl 8) or C_SPACE ; write " O" stosw mov ax, ds:[si].dbSum ; write old sum call Hex16ToAscii mov ax, ('N' shl 8) or C_SPACE ; write " N" stosw mov ax, ss:newSum ; write new sum call Hex16ToAscii clr al ; write null term stosb segmov ds, es ; both strings are in dgroup... pop di ; ds:di <- second string mov si, offset messageBuffer ; ds:si <- first string mov ax, mask SNF_EXIT call SysNotify .leave ret SysDBCFailure endp nibbles db "0123456789ABCDEF" Hex16ToAscii proc near push ax xchg ah, al push ax mov bx, offset nibbles shr al, 1 shr al, 1 shr al, 1 shr al, 1 and al, 0fh xlatb cs: stosb pop ax and al, 0fh xlatb cs: stosb pop ax push ax mov bx, offset nibbles shr al, 1 shr al, 1 shr al, 1 shr al, 1 and al, 0fh xlatb cs: stosb pop ax and al, 0fh xlatb cs: stosb ret Hex16ToAscii endp endif ; CHECKSUM_DOS_BLOCKS COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysUnlockCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Perform common module-unlock activities for the various module locks in the kernel. THIS MUST BE JUMPED TO CALLED BY: Unlock* PASS: bx = offset in idata of the ThreadLock to unlock previous bx pushed on stack RETURN: doesn't. DESTROYED: nothing, not even flags PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/ 5/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysUnlockCommon proc near jmp on_stack bx retn pushf on_stack cc bx retn push ds on_stack ds cc bx retn LoadVarSeg ds push ax on_stack ax ds cc bx retn UnlockModule ds:[currentThread], ds, [bx], TRASH_AX_BX, \ <ax ds cc bx retn> pop ax on_stack ds cc bx retn pop ds on_stack cc bx retn popf on_stack bx retn pop bx on_stack retn ret SysUnlockCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysPSemCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Perform common PSem activities for the various semaphores in the kernel. THIS MUST BE JUMPED TO CALLED BY: PSem* PASS: bx = offset in idata of the Semaphore to P previous bx pushed on stack RETURN: doesn't. DESTROYED: nothing (carry flag preserved) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/ 5/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysPSemCommon proc near jmp on_stack bx retn push ds on_stack ds bx retn LoadVarSeg ds EC < tst ds:[interruptCount] > EC < ERROR_NZ NOT_ALLOWED_TO_PSEM_IN_INTERRUPT_CODE > push ax on_stack ax ds bx retn PSem ds, [bx], TRASH_AX_BX, NO_EC pop ax on_stack ds bx retn pop ds on_stack bx retn pop bx on_stack retn ret SysPSemCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysVSemCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Perform common VSem activities for the various semaphores in kernel. THIS MUST BE JUMPED TO CALLED BY: VSem* PASS: bx = offset in idata of the Semaphore to V previous bx pushed on stack RETURN: doesn't. DESTROYED: nothing, not even flags PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/ 5/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysVSemCommon proc near jmp on_stack bx retn pushf on_stack cc bx retn push ds on_stack ds cc bx retn LoadVarSeg ds on_stack ax ds cc bx retn push ax VSem ds, [bx], TRASH_AX_BX, NO_EC pop ax on_stack ds cc bx retn pop ds on_stack cc bx retn popf on_stack bx retn pop bx on_stack retn ret SysVSemCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysJmpVector %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Jump through a vector w/o destroying registers CALLED BY: Thread{Exception}Handlers PASS: ds:bx = vector on stack: sp -> ds ax bx ret RETURN: doesn't DESTROYED: ax, bx and ds restored to their values from entry to the interrupt. PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 11/ 8/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SPOIStack struct SPOIS_bp word SPOIS_ax word SPOIS_bx word SPOIS_retAddr fptr.far SPOIS_flags word SPOIStack ends SysJmpVector proc far jmp on_stack ds ax bx retf ; ; Fetch the old vector into ax and bx ; mov ax, ds:[bx].offset mov bx, ds:[bx].segment pop ds on_stack ax bx retf ; ; Now replace the saved ax and bx with the old vector, so we can ; just perform a far return to get to the old handler. ; push bp on_stack bp ax bx retf mov bp, sp xchg ax, ss:[bp].SPOIS_ax xchg bx, ss:[bp].SPOIS_bx pop bp on_stack retf ret SysJmpVector endp COMMENT @---------------------------------------------------------------------- FUNCTION: SysGetECLevel DESCRIPTION: Return value of sysECLevel CALLED BY: GLOBAL PASS: Nothing RETURN: ax - ErrorCheckingFlags bx - error checking block (valid if ECF_BLOCK_CHECKSUM) DESTROYED: Nothing REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: Get exclusive on default video driver KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Doug 5/89 Initial version ------------------------------------------------------------------------------@ SysGetECLevel proc far if ERROR_CHECK push ds LoadVarSeg ds mov ax, ds:[sysECLevel] ; fetch the error checking level mov bx, ds:[sysECBlock] pop ds else clr ax clr bx endif ret SysGetECLevel endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysSetECLevel %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the current error-check level CALLED BY: GLOBAL PASS: AX = ErrorCheckingFlags BX = error checking block (if any) RETURN: Nothing DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 5/17/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysSetECLevel proc far if ERROR_CHECK push ds LoadVarSeg ds mov ds:[sysECLevel], ax mov ds:[sysECBlock], bx mov ds:[sysECChecksum], 0 ;invalid -- recalculate pop ds endif ret SysSetECLevel endp Filemisc segment COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysGetDosEnvironment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Looks up an environment variable in the environment buffer. CALLED BY: GLOBAL PASS: ds:si - variable name to look up (null terminated) es:di - dest buffer to store data (null terminated string) cx - max # bytes to store in buffer including null RETURN: carry set if environment variable not found DESTROYED: none PSEUDO CODE/STRATEGY: Data in Environment Block consists of null terminated strings of the form: <variable name>=<variable data>. The end of the block comes when a null byte is found in place of the variable name. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 8/13/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE CopyStackCodeXIP segment resource SysGetDosEnvironment proc far mov ss:[TPD_dataBX], handle SysGetDosEnvironmentReal mov ss:[TPD_dataAX], offset SysGetDosEnvironmentReal GOTO SysCallMovableXIPWithDSSI SysGetDosEnvironment endp CopyStackCodeXIP ends else SysGetDosEnvironment proc far FALL_THRU SysGetDosEnvironmentReal SysGetDosEnvironment endp endif SysGetDosEnvironmentReal proc far uses ax, bx, ds, si, cx, di .enter EC < call FarCheckDS_ES > push es, di, cx if FULL_EXECUTE_IN_PLACE EC < push bx, si > EC < movdw bxsi, esdi > EC < call ECAssertValidFarPointerXIP > EC < pop bx, si > endif ; GET LENGTH OF PASSED VARIABLE NAME segmov es, ds, di ;ES:DI <- ptr to variable string mov di, si mov cx, -1 clr ax repne scasb not cx ;CX <- # bytes (sans null term) dec cx ;If passed nullstring, return not found jcxz notFound ; segmov es, dgroup, di mov es, es:[loaderVars].KLV_pspSegment mov es, es:[PSP_envBlk] ;es:di <- env block clr di mov ax, di ; SEARCH THROUGH THE ENVIRONMENT BLOCK varSearchTop: ; ES:DI <- PTR TO ENVIRONMENT BLOCK ENTRY ; DS:SI <- PTR TO VARIABLE NAME TO MATCH ; CX <- # BYTES IN SOURCE STRING (NOT COUNTING NULL) cmp {byte} es:[di], 0 ;At end of env block? jz notFound ;Branch if so push cx, si ; repe cmpsb ;Compare source and dest strings pop si ; jnz noMatch ;Branch if they didn't match cmp {byte} es:[di], '=' ;If they matched, make sure next byte jz match ; is '=' -- branch if so noMatch: ;AX is always 0 here mov cx, -1 repne scasb ;ES:DI <- ptr beyond null terminator pop cx jmp varSearchTop match: inc sp inc sp ;discard saved CX inc di ;ES:DI <- ptr to variable data segmov ds, es, si ;DS:SI <- ptr to variable data mov si, di mov cx, -1 repne scasb not cx ;CX <- # bytes + null terminator pop es, di, bx ;BX <- max # bytes to copy ;ES:DI <- dest buffer cmp cx, bx ; jle 80$ ; mov cx, bx ; 80$: rep movsb ; mov {byte} es:[di][-1], 0 ;Null terminate the string clc jmp exit notFound: pop es, di, cx stc exit: .leave ret SysGetDosEnvironmentReal endp Filemisc ends CopyStackCodeXIP segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCopyToStackDSBX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy passed parameter to stack CALLED BY: GLOBAL PASS: ds:bx -> fptr to block to copy cx -> size of buffer to copy (0 if null terminated string (DBCS or SBCS)) RETURN: ds:bx <- fptr to block on stack DESTROYED: nothing SIDE EFFECTS: Modifies TPD_stackBot to reserve space on stack PSEUDO CODE/STRATEGY: Fiddle with pointers, then call SysCopyToStack REVISION HISTORY: Name Date Description ---- ---- ----------- TS 4/23/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysCopyToStackDSBXFar proc far if FULL_EXECUTE_IN_PLACE call SysCopyToStackDSBX endif ret SysCopyToStackDSBXFar endp if FULL_EXECUTE_IN_PLACE SysCopyToStackDSBX proc near xchg si, bx call SysCopyToStack xchg bx, si ret SysCopyToStackDSBX endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCopyToStackDSDX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy passed parameter to stack CALLED BY: GLOBAL PASS: ds:dx -> fptr to block to copy cx -> size of buffer to copy (0 if null terminated string (DBCS or SBCS)) RETURN: ds:dx <- fptr to block on stack DESTROYED: nothing SIDE EFFECTS: Modifies TPD_stackBot to reserve space on stack PSEUDO CODE/STRATEGY: Fiddle with pointers, then call SysCopyToStack REVISION HISTORY: Name Date Description ---- ---- ----------- TS 4/23/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysCopyToStackDSDXFar proc far if FULL_EXECUTE_IN_PLACE call SysCopyToStackDSDX endif ret SysCopyToStackDSDXFar endp if FULL_EXECUTE_IN_PLACE SysCopyToStackDSDX proc near xchg si, dx call SysCopyToStack xchg dx, si ret SysCopyToStackDSDX endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCopyToStackBXSI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy passed parameter to stack CALLED BY: GLOBAL PASS: bx:si -> fptr to block to copy cx -> size of buffer to copy (0 if null temrinated string (DBCS or SBCS)) RETURN: bx:si <- fptr to block on stack DESTROYED: nothing SIDE EFFECTS: Modified TPD_stackBot to reserve space on stack PSEUDO CODE/STRATEGY: Fiddle with pointers, then call SysCopyToStack REVISION HISTORY: Name Date Description ---- ---- ----------- TS 4/21/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysCopyToStackBXSIFar proc far if FULL_EXECUTE_IN_PLACE call SysCopyToStackBXSI endif ret SysCopyToStackBXSIFar endp if FULL_EXECUTE_IN_PLACE SysCopyToStackBXSI proc near segxchg bx, ds call SysCopyToStack segxchg ds, bx ret SysCopyToStackBXSI endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCopyToStackESDI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy passed parameter to stack CALLED BY: GLOBAL PASS: es:di -> fptr to block to copy cx -> size of buffer to copy (0 if null termined string (DBCS or SBCS)) RETURN: es:di <- fptr to block on stack DESTROYED: nothing SIDE EFFECTS: Allocates space on bottom of stack (below TPD_stackBot) PSEUDO CODE/STRATEGY: Swap the pointers around so we can call SysCopyToStack REVISION HISTORY: Name Date Description ---- ---- ----------- TS 4/19/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysCopyToStackESDIFar proc far if FULL_EXECUTE_IN_PLACE call SysCopyToStackESDI endif ret SysCopyToStackESDIFar endp if FULL_EXECUTE_IN_PLACE SysCopyToStackESDI proc near xchg si, di ; ds:si <- buffer segxchg ds, es call SysCopyToStack ; ds:si <- new buffer on stack segxchg es, ds ; es:di <- new buffer xchg di, si ret SysCopyToStackESDI endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCopyToStack, SysCopyToStackDSSI, SysCopyToStackDSSIFar %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Move a passed in parameter block to the stack CALLED BY: SysCopyToStack* PASS: ds:si -> block to copy cx -> size (or zero if null terminated) RETURN: ds:si <- buffer on stack DESTROYED: nothing SIDE EFFECTS: Modifies TPD_stackBot. This reduces the amount of stack space temporarily available to the thread, but it has the same affect as allocating the space on the stack, and this method doesn't mess up the call stack. It all gets returned to the thread in the end... PSEUDO CODE/STRATEGY: As opposed to mucking about with the stack (my idea), Andrew suggested we just copy the needed data to the TPD_stackBot, and adjust TPD_stackBot so that we don't worry about it being written over. This is inspired, and he should be given a large golden plack indicating what a computer stud he is. REVISION HISTORY: Name Date Description ---- ---- ----------- TS 4/ 4/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EC_VALUE equ 042294 SysCopyToStackStruct struct SCTSS_oldBottom word ;The old bottom of the stack SCTSS_siDifference word ;The difference between the old value of SI and new value. We can ; convert between pointers into the copied buffer and the original ; buffer by adding this difference to the pointer. SCTSS_restoreRegsRout nptr.near ;The routine to call to restore registers when ; SysRemoveFromStackPreserveRegs is called EC < SCTSS_ecValue word > ;An EC value we store/check to make sure the stack isn't ; mangled. SysCopyToStackStruct ends SysCopyToStackDSSIFar proc far if FULL_EXECUTE_IN_PLACE call SysCopyToStack endif ret SysCopyToStackDSSIFar endp if FULL_EXECUTE_IN_PLACE SysCopyToStackDSSI label near SysCopyToStack proc near uses ax, bp .enter pushf ; ; First things first. See if the value needs to be copied ; to the stack at all (if it's not in an XIP resource, ; we don't need to worry about it.) push ds mov ax, ds ; ax <- current segment LoadVarSeg ds sub ax, ds:[loaderVars].KLV_mapPageAddr pop ds jc noCopy ; => Below XIP segment cmp ax, (MAPPING_PAGE_SIZE/16) jb copy ; => In XIP segment noCopy: ; ; No need to copy it, but we still need to leave the ; stack in a state that SysReturnStack will understand. mov bp, ss:[TPD_stackBot] ; bp <- current bottom add ss:[TPD_stackBot], size SysCopyToStackStruct ; Make space for structure mov ss:[bp].SCTSS_oldBottom, bp ; Store old stackBot value clr ss:[bp].SCTSS_siDifference EC < clr ss:[bp].SCTSS_restoreRegsRout > EC < mov ss:[bp].SCTSS_ecValue, EC_VALUE > ; Store sentinel to check for stack ; mangling done: popf ; ; With that done, let's return... .leave ret copy: push cx, di, es ; save trashed registers ; ; Now, with the case of null terminated strings, we ; won't know the length until we scan the string. Sigh. ; See if we need to scan the list, or if we were passed ; in the string length jcxz getLength ; => look for null reserveSpaceOnStack: ; ; With the correct length available (for whatever reason), ; we now reserve space at the base of the stack and ; move the data over. mov ax, ss:[TPD_stackBot] ; ax <- original stack bottom ; ; To reserve space, we adjust the stack bottom so ; we have room to copy the buffer, the previous stack ; bottom, and possibly an EC value as well. segmov es, ss, di ; es:di <- new buffer mov di, ax mov bp, ax ; bp <- current stack bottom add bp, cx ; reserve space at base of stack add bp, size SysCopyToStackStruct ; ; Now that we know what we want to change the stackBot ; to, let's make sure we don't overwrite the existing ; stack, shall we? EC < cmp bp, sp > EC < ERROR_AE STACK_OVERFLOW > mov ss:[TPD_stackBot], bp ; mark new bottom of stack mov ss:[bp - size SysCopyToStackStruct].SCTSS_oldBottom, ax mov ss:[bp - size SysCopyToStackStruct].SCTSS_siDifference, si sub ss:[bp - size SysCopyToStackStruct].SCTSS_siDifference, ax ; store original stack bottom EC < mov ss:[bp - size SysCopyToStackStruct].SCTSS_restoreRegsRout,0 > EC < mov ss:[bp - size SysCopyToStackStruct].SCTSS_ecValue, EC_VALUE> ; mark with special value EC < call ECCheckStack > ; ; Now that that has been taken care of, copy the buffer ; to the stack, storing the start of the buffer for later. shr cx, 1 ; convert from byte to words... rep movsw ; move all the words... jnc cleanUp ; => even byte length movsb ; and the byte... cleanUp: mov_tr si, ax ; ds:si <- buffer segmov ds, ss, ax pop cx, di, es ; restore trashed registers jmp done getLength: ; ; Get the length of the passed in null-terminated string ; worrying about DBCS... segmov es, ds, ax ; es:di <- length mov di, si LocalStrSize <includeNull> ; cx <- length ; ax, di destroyed jmp reserveSpaceOnStack SysCopyToStack endp endif ForceRef SysCopyToStack COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysRemoveFromStack %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Restore Stack space used to hold parameters CALLED BY: INTERNAL PASS: ss:sp -> as returned by SysCopyToStack RETURN: ss:sp -> as before call to SysCopyToStack DESTROYED: nothing SIDE EFFECTS: None PSEUDO CODE/STRATEGY: Get value at top of bottom of stack and assign it as new bottom of stack. For EC, make sure our value is there as well... REVISION HISTORY: Name Date Description ---- ---- ----------- TS 4/11/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysRemoveFromStackFar proc far if FULL_EXECUTE_IN_PLACE call SysRemoveFromStack endif ret SysRemoveFromStackFar endp if FULL_EXECUTE_IN_PLACE SysRemoveFromStack proc near uses bp .enter mov bp, ss:[TPD_stackBot] EC < pushf > EC < cmp ss:[bp-size SysCopyToStackStruct].SCTSS_ecValue, EC_VALUE> EC < ERROR_NE SYS_COPY_TO_STACK_ERROR_BOTTOM_OF_STACK_MANGLED > EC < popf > mov bp, ss:[bp-size SysCopyToStackStruct].SCTSS_oldBottom ;bp <- old stackBot EC < pushf > EC < cmp bp, ss:[TPD_stackBot] > EC < ERROR_AE SYS_COPY_TO_STACK_ERROR_BOTTOM_OF_STACK_MANGLED > EC < popf > mov ss:[TPD_stackBot], bp EC< call ECCheckStack > .leave ret SysRemoveFromStack endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCopyToStackPreserve* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calls SysCopyToStack, but stores a routine to call to restore the registers afterwards. CALLED BY: GLOBAL PASS: nada RETURN: registers munged DESTROYED: nada (flags preserved) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 5/13/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE SysCopyToStackPreserveDSDX proc near mov ss:[TPD_callTemporary], offset SysRemoveFromStackPreserveDX xchg dx, si call SysCopyToStackPreserveCommon xchg dx, si ret SysCopyToStackPreserveDSDX endp if 0 SysCopyToStackPreserveDSBX proc near mov ss:[TPD_callTemporary], offset SysRemoveFromStackPreserveBX xchg bx, si call SysCopyToStackPreserveCommon xchg bx, si ret SysCopyToStackPreserveDSBX endp endif SysCopyToStackPreserveESDI proc near xchg si, di segxchg ds, es mov ss:[TPD_callTemporary], offset SysRemoveFromStackPreserveDI call SysCopyToStackPreserveCommon segxchg ds, es xchg si, di ret SysCopyToStackPreserveESDI endp SysCopyToStackPreserveDSDI proc near mov ss:[TPD_callTemporary], offset SysRemoveFromStackPreserveDI xchg si, di call SysCopyToStackPreserveCommon xchg si, di ret SysCopyToStackPreserveDSDI endp SysCopyToStackPreserveDXSI proc near mov ss:[TPD_callTemporary], offset SysRemoveFromStackPreserveSI xchg bx, dx call SysCopyToStackPreserveCommon xchg bx, dx ret SysCopyToStackPreserveDXSI endp SysCopyToStackPreserveDSSI proc near mov ss:[TPD_callTemporary], offset SysRemoveFromStackPreserveSI FALL_THRU SysCopyToStackPreserveCommon SysCopyToStackPreserveDSSI endp SysCopyToStackPreserveCommon proc near uses bp, ax .enter call SysCopyToStackDSSI mov bp, ss:[TPD_stackBot] mov ax, ss:[TPD_callTemporary] mov ss:[bp - size SysCopyToStackStruct].SCTSS_restoreRegsRout, ax .leave ret SysCopyToStackPreserveCommon endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysRemoveFromStackPreserveRegs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calls the appropriate routine to remove the data from the stack and preserve register values (we have to go through these shenanigans because we copy data to the stack, and call routines, that return pointers into that data, so we need to modify those pointers to return to the correct place. CALLED BY: GLOBAL PASS: various RETURN: regs updated DESTROYED: nada PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 5/13/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE SysRemoveFromStackPreserveRegs proc near uses bp .enter mov bp, ss:[TPD_stackBot] EC < pushf > EC < cmp ss:[bp-size SysCopyToStackStruct].SCTSS_ecValue, EC_VALUE> EC < ERROR_NE SYS_COPY_TO_STACK_ERROR_BOTTOM_OF_STACK_MANGLED > EC < cmp ss:[bp - size SysCopyToStackStruct].SCTSS_restoreRegsRout,0 > EC < ERROR_Z SYS_COPY_TO_STACK_ERROR_NO_RESTORE_REGS_ROUTINE > EC < popf > call ss:[bp - size SysCopyToStackStruct].SCTSS_restoreRegsRout .leave ret SysRemoveFromStackPreserveRegs endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysRemoveFromStackPreserve* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Restores registers after a call to a routine that may have changed them, and updates the stack CALLED BY: GLOBAL PASS: various regs RETURN: regs updated DESTROYED: nada PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 5/13/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE SysRemoveFromStackPreserveDI proc near xchg si, di call SysRemoveFromStackPreserveSI xchg si, di ret SysRemoveFromStackPreserveDI endp SysRemoveFromStackPreserveDX proc near xchg si, dx call SysRemoveFromStackPreserveSI xchg si, dx ret SysRemoveFromStackPreserveDX endp if 0 SysRemoveFromStackPreserveBX proc near xchg si, bx call SysRemoveFromStackPreserveSI xchg si, bx ret SysRemoveFromStackPreserveBX endp endif SysRemoveFromStackPreserveSI proc near uses bp .enter pushf mov bp, ss:[TPD_stackBot] add si, ss:[bp - size SysCopyToStackStruct].SCTSS_siDifference popf call SysRemoveFromStack .leave ret SysRemoveFromStackPreserveSI endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCopyToBlock %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Allocate a block and copy data into it. CALLED BY: INTERNAL PASS: ds:si = address of data to copy cx = size of data RETURN: carry set if insufficient memory, else ds:si = address to copy of data bx = handle of locked data block DESTROYED: nothing PSEUDO CODE/STRATEGY: NOTE: Caller is responsible for freeing block. REVISION HISTORY: Name Date Description ---- ---- ----------- jwu 4/19/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SysCopyToBlockFar proc far if FULL_EXECUTE_IN_PLACE call SysCopyToBlock endif ret SysCopyToBlockFar endp if FULL_EXECUTE_IN_PLACE SysCopyToBlock proc near uses ax,cx,di .enter ; ; Allocate a locked block for the data. ; push cx ; save size for copy mov_tr ax, cx ; ax = size of data mov cx, ALLOC_FIXED call MemAllocFar ; ^hbx = block ; ax = address of block pop cx ; cx = size of data jc exit ; no more memory... ; ; Copy the data to the block. ; mov es, ax clr di ; es:di = dest of copy shr cx, 1 ; convert byte to words rep movsw jnc done ; even byte length movsb ; and the byte... done: segmov ds, es, si clr si ; ds:si = copied data clc ; all is well exit: .leave ret SysCopyToBlock endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCallMovableXIPWithDSSIAndESDI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Call a movable routine passing DS:SI and ES:DI on stack CALLED BY: INTERNAL PASS: ds:dx -> 1st buffer to pass es:di -> 2nd buffer to pass TPD_dataBX:TPD_dataAX -> handle:offset of routine to call RETURN: As per routine DESTROYED: si, di, ds, es unchanged others as per routine SIDE EFFECTS: Copies blocks to stack PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- TS 4/26/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE SysCallMovableXIPWithDSSIAndESDI proc far uses ds, es .enter ; On full-XIP systems, we need to copy the data to the stack, but ; also return a pointer into that data, so calculate the amount ; the pointer changes, and return the original pointer, modified by ; the passed amount. push cx clr cx call SysCopyToStackPreserveDSSI pop cx mov ss:[TPD_callTemporary], offset SysCopyToStackPreserveESDI call SysCallMovableXIP call SysRemoveFromStackPreserveRegs .leave ret SysCallMovableXIPWithDSSIAndESDI endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCallMovableXIPWithDSDXAndESDI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copies ds:dx and es:di to the stack before calling a movable routine CALLED BY: various PASS: ds:dx, es:di - null terminated strings RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- TS 5/10/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE SysCallMovableXIPWithDSDXAndESDI proc far uses ds, es .enter push cx clr cx call SysCopyToStackPreserveDSDX pop cx mov ss:[TPD_callTemporary], offset SysCopyToStackPreserveESDI call SysCallMovableXIP call SysRemoveFromStackPreserveRegs .leave ret SysCallMovableXIPWithDSDXAndESDI endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCallMovableXIPWithDSDX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Call a movable routine with ds:dx pointing to valid parameter CALLED BY: INTERNAL PASS: ds:dx -> Parameters to copy to stack (null terminated) TPD_dataBX:TPD_dataAX -> handle:offset to routine to call after copying to stack Others as per Routine RETURN: As per routine DESTROYED: dx, ds unchanged others as per routine SIDE EFFECTS: Copies block to stack PSEUDO CODE/STRATEGY: Copy the parameter block to the stack Call the specified routine REVISION HISTORY: Name Date Description ---- ---- ----------- TS 4/26/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE SysCallMovableXIPWithDSDX proc far uses ds .enter mov ss:[TPD_callTemporary], offset SysCopyToStackPreserveDSDX call SysCallMovableXIP .leave ret SysCallMovableXIPWithDSDX endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCallMovableXIPWithDSBX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Call a movable routine with ds:bx pointing to valid parameter CALLED BY: INTERNAL PASS: ds:bx -> Parameters to copy to stack (null terminated) TPD_dataBX:TPD_dataAX -> handle:offset to routine to call after copying to stack Others as per Routine RETURN: As per routine DESTROYED: bx, ds unchanged others as per routine SIDE EFFECTS: Copies block to stack PSEUDO CODE/STRATEGY: Copy the parameter block to the stack Call the specified routine REVISION HISTORY: Name Date Description ---- ---- ----------- TS 4/26/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if 0 if FULL_EXECUTE_IN_PLACE SysCallMovableXIPWithDSBX proc far uses ds .enter mov ss:[TPD_callTemporary], offset SysCopyToStackPreserveDSBX call SysCallMovableXIP .leave ret SysCallMovableXIPWithDSBX endp endif endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCallMovableXIPWithESDI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Call a movable routine with es:di pointing to valid parameter CALLED BY: INTERNAL PASS: es:di -> Parameters to copy to stack (null terminated) TPD_dataBX:TPD_dataAX -> handle:offset to routine to call after copying to stack Others as per Routine RETURN: As per routine DESTROYED: di, es unchanged others as per routine SIDE EFFECTS: Copies block to stack PSEUDO CODE/STRATEGY: Copy the parameter block to the stack Call the specified routine REVISION HISTORY: Name Date Description ---- ---- ----------- TS 4/26/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE SysCallMovableXIPWithESDI proc far uses es .enter mov ss:[TPD_callTemporary], offset SysCopyToStackPreserveESDI call SysCallMovableXIP .leave ret SysCallMovableXIPWithESDI endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCallMovableXIPWithDSSI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Call a movable routine with ds:si pointing to valid parameter CALLED BY: INTERNAL PASS: ds:si -> Parameters to copy to stack (null terminated) TPD_dataBX:TPD_dataAX -> handle:offset to routine to call after copying to stack Others as per Routine RETURN: As per routine DESTROYED: si, ds unchanged others as per routine SIDE EFFECTS: Copies block to stack PSEUDO CODE/STRATEGY: Copy the parameter block to the stack Call the specified routine REVISION HISTORY: Name Date Description ---- ---- ----------- TS 4/26/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE SysCallMovableXIPWithDSSI proc far uses ds .enter mov ss:[TPD_callTemporary], offset SysCopyToStackPreserveDSSI call SysCallMovableXIP .leave ret SysCallMovableXIPWithDSSI endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCallMovableXIP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Call a passed routine, saving the specified parameter block on the stack if needed CALLED BY: INTERNAL PASS: ss:[TPD_callTemporary] -> near SysCopyTo* to call fptr of routine call after copy stored in: ss:[TPD_dataBX]:ss:[dataAX] ( that is dataBX is handle, dataAX is offset) RETURN: as per routine DESTROYED: as per SysCopyTo* routine SIDE EFFECTS: Copies and frees block on the stack PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- TS 4/26/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE SysCallMovableXIP proc near .enter ; ; Copy parameter to stack (assume null terminated) push cx clr cx call ss:[TPD_callTemporary] pop cx ; ; Call routine passing correct values in AX & BX xchg ss:[TPD_dataBX], bx ; bx <- handle xchg ss:[TPD_dataAX], ax ; ax <- offset call ProcCallModuleRoutine ; ; Remove parameter from stack call SysRemoveFromStackPreserveRegs .leave ret SysCallMovableXIP endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCallMovableXIPWithDSDIBlock /*DSSIBlock /*DXSIBlock... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Call a movable routine with ds:di/ds:si/dx:si pointing to a valid parameter. CALLED BY: INTERNAL PASS: ds:di/ds:si/dx:si -> Parameters to copy to stack TPD_dataBX:TPD_dataAX -> handle:offset to routine to call after copying to stack TPD_callVector.segment -> size of data to copy to stack RETURN: As per routine DESTROYED: ds, di unchanged (or ds, si or dx, si, depending on routine) others as per routine SIDE EFFECTS: Copies block to stack PSEUDO CODE/STRATEGY: Copy the parameter block to the stack Call the specified routine REVISION HISTORY: Name Date Description ---- ---- ----------- jwu 5/11/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE SysCallMovableXIPWithDSDIBlock proc far uses ds .enter mov ss:[TPD_callTemporary], offset SysCopyToStackPreserveDSDI call SysCallMovableXIPBlock .leave ret SysCallMovableXIPWithDSDIBlock endp SysCallMovableXIPWithDSSIBlock proc far uses ds .enter mov ss:[TPD_callTemporary], offset SysCopyToStackPreserveDSSI call SysCallMovableXIPBlock .leave ret SysCallMovableXIPWithDSSIBlock endp SysCallMovableXIPWithDXSIBlock proc far uses dx .enter mov ss:[TPD_callTemporary], offset SysCopyToStackPreserveDXSI call SysCallMovableXIPBlock .leave ret SysCallMovableXIPWithDXSIBlock endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCallMovableXIPWithDSSIAndESDIBlock %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Call a movable routine with ds:si and es:di pointing to a valid parameter. CALLED BY: INTERNAL PASS: es:di -> Parameter to copy to stack ds:si -> Parameter to copy to stack TPD_dataBX:TPD_dataAX -> handle:offset to routine to call after copying to stack TPD_callVector.segment -> size of data to copy to stack ( Data in es:di and ds:si MUST be same size!) RETURN: As per routine DESTROYED: ds, di unchanged others as per routine SIDE EFFECTS: Copies block to stack PSEUDO CODE/STRATEGY: Copy the parameter block to the stack Call the specified routine Copy ESDI data to stack first so we don't have to write a SysCallMovableXIPWithESDIBlock. REVISION HISTORY: Name Date Description ---- ---- ----------- jwu 5/11/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE SysCallMovableXIPWithDSSIAndESDIBlock proc far uses ds, es .enter push cx mov cx, ss:[TPD_callVector].segment ; cx = size call SysCopyToStackPreserveESDI pop cx mov ss:[TPD_callTemporary], offset SysCopyToStackPreserveDSSI call SysCallMovableXIPBlock call SysRemoveFromStackPreserveRegs .leave ret SysCallMovableXIPWithDSSIAndESDIBlock endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SysCallMovableXIPBlock %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Call a passed routine, saving the specified parameter block on the stack if needed CALLED BY: INTERNAL PASS: ss:[TPD_callTemporary] -> near SysCopyTo* to call ss:[TPD_callVector].segment -> size of data to be copied fptr of routine to call after copy stored in: ss:[TPD_dataBX]:ss:[dataAX] ( that is dataBX is handle, dataAX is offset) RETURN: as per routine DESTROYED: as per SysCopyTo* routine SIDE EFFECTS: Copies and frees block on the stack. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jwu 5/11/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if FULL_EXECUTE_IN_PLACE SysCallMovableXIPBlock proc near ; ; Copy paramter to stack. ; push cx mov cx, ss:[TPD_callVector].segment ; cx = size call ss:[TPD_callTemporary] pop cx ; ; Call routine passing correct values in AX & BX ; xchg ss:[TPD_dataBX], bx ; bx <- handle xchg ss:[TPD_dataAX], ax ; ax <- offset call ProcCallModuleRoutine ; ; Remove parameter from stack ; call SysRemoveFromStackPreserveRegs ret SysCallMovableXIPBlock endp endif CopyStackCodeXIP ends
dev/src/main/antlr/nl/knaw/huygens/lobsang/iso8601/Iso8601Format.g4
culturesofknowledge/emdates
4
2307
/* * Heaviliy based on: * https://github.com/ksclarke/freelib-edtf/blob/master/src/main/antlr/info/freelibrary/edtf/internal/ExtendedDateTimeFormat.g4 */ grammar Iso8601Format; /** Parser rule wrapper **/ iso8601: level0 EOF | level1 EOF; /** Level 0: Tokens **/ Dash : '-'; LeapYear : Year {!"".equals(getText()) && (Integer.valueOf(getText()) % 400 == 0 || (Integer.valueOf(getText()) % 100 != 0 && Integer.valueOf(getText()) % 4 == 0))}?; Year : PositiveYear | NegativeYear | YearZero; NegativeYear : Dash PositiveYear; PositiveYear : PositiveDigit Digit Digit Digit | Digit PositiveDigit Digit Digit | Digit Digit PositiveDigit Digit | Digit Digit Digit PositiveDigit ; Digit : PositiveDigit | '0'; PositiveDigit : '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'; YearZero : '0000'; Month : OneThru12; MonthDay : ( '01' | '03' | '05' | '07' | '08' | '10' | '12' ) Dash OneThru31 | ( '04' | '06' | '09' | '11' ) Dash OneThru30 | '02' Dash OneThru28 ; MonthDayCompact : ( '01' | '03' | '05' | '07' | '08' | '10' | '12' ) OneThru31 | ( '04' | '06' | '09' | '11' ) OneThru30 | '02' OneThru28 ; LeapMonthDay : ( '01' | '03' | '05' | '07' | '08' | '10' | '12' ) Dash OneThru31 | ( '04' | '06' | '09' | '11' ) Dash OneThru30 | '02' Dash OneThru29 ; LeapMonthDayCompact : ( '01' | '03' | '05' | '07' | '08' | '10' | '12' ) OneThru31 | ( '04' | '06' | '09' | '11' ) OneThru30 | '02' OneThru29 ; YearMonth : Year Dash Month; YearMonthDay : Year Dash MonthDay; YearMonthDayCompact : Year MonthDayCompact; LeapYearMonthDay: LeapYear Dash LeapMonthDay; LeapYearMonthDayCompact: LeapYear LeapMonthDayCompact; OneThru12 : '01' | '02' | '03' | '04' | '05' | '06' | '07' | '08' | '09' | '10' | '11' | '12' ; OneThru13 : OneThru12 | '13'; OneThru23 : OneThru13 | '14' | '15' | '16' | '17' | '18' | '19' | '20' | '21' | '22' | '23' ; ZeroThru23 : '00' | OneThru23; OneThru28 : OneThru23 | '24' | '25' | '26' | '27' | '28'; OneThru29 : OneThru28 | '29'; OneThru30 : OneThru29 | '30'; OneThru31 : OneThru30 | '31'; OneThru59 : OneThru31 | '32' | '33' | '34' | '35' | '36' | '37' | '38' | '39' | '40' | '41' | '42' | '43' | '44' | '45' | '46' | '47' | '48' | '49' | '50' | '51' | '52' | '53' | '54' | '55' | '56' | '57' | '58' | '59' ; /** Level 0 Parser rules **/ level0 : year | yearMonth | yearMonthDay | leapYearMonthDay | yearMonthDayCompact | leapYearMonthDayCompact; year : Year; yearMonth : YearMonth; yearMonthDay : YearMonthDay; leapYearMonthDay : LeapYearMonthDay; yearMonthDayCompact : YearMonthDayCompact; leapYearMonthDayCompact : LeapYearMonthDayCompact; /** Level 1: Tokens **/ Questionmark : '?'; Tilde : '~'; PercentSign : '%'; X : 'X'; YearUnspecifiedMonth: Year Dash X X; UnspecifiedYearAndMonth: X X X X Dash X X; YearMonthUnspecifiedDay : YearMonth Dash X X; YearUnspecifiedMonthAndDay : Year Dash X X Dash X X; UnspecifiedYearAndMonthAndDay : X X X X Dash X X Dash X X; UnspecifiedSingleYear : PositiveUnspecifiedSingleYear | NegativeUnspecifiedSingleYear; NegativeUnspecifiedSingleYear : Dash PositiveUnspecifiedSingleYear; PositiveUnspecifiedSingleYear : PositiveDigit Digit Digit X | Digit PositiveDigit Digit X | Digit Digit PositiveDigit X | Digit Digit Digit X ; UnspecifiedDecadeAndSingleYear : PositiveUnspecifiedDecadeAndSingleYear | NegativeUnspecifiedDecadeAndSingleYear; NegativeUnspecifiedDecadeAndSingleYear : Dash PositiveUnspecifiedDecadeAndSingleYear; PositiveUnspecifiedDecadeAndSingleYear : PositiveDigit Digit X X | Digit PositiveDigit X X | Digit Digit X X ; UnspecifiedCenturyAndDecadeAndSingleYear : PositiveUnspecifiedCenturyAndDecadeAndSingleYear | NegativeUnspecifiedCenturyAndDecadeAndSingleYear ; PositiveUnspecifiedCenturyAndDecadeAndSingleYear : PositiveDigit X X X | Digit X X X ; NegativeUnspecifiedCenturyAndDecadeAndSingleYear : Dash PositiveUnspecifiedCenturyAndDecadeAndSingleYear; UnspecifiedPositiveYear : X X X X; UnspecifiedNegativeYear : Dash X X X X; /** Level 1 ParserRules **/ level1 : yearUncertain | yearApproximate | yearUncertainApproximate | yearMonthUncertain | yearMonthApproximate | yearMonthUncertainApproximate | yearMonthDayUncertain | leapYearMonthDayUncertain | yearMonthDayApproximate | leapYearMonthDayApproximate | yearMonthDayUncertainApproximate | leapYearMonthDayUncertainApproximate | yearMonthUnspecifiedDay | yearUnspecifiedMonthAndDay | unspecifiedYearAndMonthAndDay | yearUnspecifiedMonth | unspecifiedYearAndMonth | unspecifiedSingleYear | unspecifiedDecadeAndSingleYear | unspecifiedCenturyAndDecadeAndSingleYear | unspecifiedPositiveYear | unspecifiedNegativeYear ; yearUncertain: Year Questionmark; yearApproximate: Year Tilde; yearUncertainApproximate: Year PercentSign; yearMonthUncertain : YearMonth Questionmark; yearMonthApproximate : YearMonth Tilde; yearMonthUncertainApproximate : YearMonth PercentSign; yearMonthDayUncertain : YearMonthDay Questionmark; leapYearMonthDayUncertain : LeapYearMonthDay Questionmark; yearMonthDayApproximate : YearMonthDay Tilde; leapYearMonthDayApproximate : LeapYearMonthDay Tilde; yearMonthDayUncertainApproximate : YearMonthDay PercentSign; leapYearMonthDayUncertainApproximate : LeapYearMonthDay PercentSign; yearMonthUnspecifiedDay : YearMonthUnspecifiedDay; yearUnspecifiedMonthAndDay : YearUnspecifiedMonthAndDay; unspecifiedYearAndMonthAndDay : UnspecifiedYearAndMonthAndDay; yearUnspecifiedMonth : YearUnspecifiedMonth; unspecifiedYearAndMonth : UnspecifiedYearAndMonth; unspecifiedSingleYear : UnspecifiedSingleYear; unspecifiedDecadeAndSingleYear : UnspecifiedDecadeAndSingleYear; unspecifiedCenturyAndDecadeAndSingleYear : UnspecifiedCenturyAndDecadeAndSingleYear; unspecifiedPositiveYear: UnspecifiedPositiveYear; unspecifiedNegativeYear: UnspecifiedNegativeYear;
programs/oeis/111/A111684.asm
neoneye/loda
22
94812
<reponame>neoneye/loda<filename>programs/oeis/111/A111684.asm ; A111684: Least k such that the product of n consecutive integers beginning with k exceeds n^n. ; 2,2,3,3,4,4,5,5,6,6,7,8,8,9,9,10,10,11,11,12,12,13,13,14,15,15,16,16,17,17,18,18,19,19,20,21,21,22,22,23,23,24,24,25,25,26,26,27,28,28,29,29,30,30,31,31,32,32,33,34,34,35,35,36,36,37,37,38,38,39,39,40,41,41 mul $0,12 add $0,1 mul $0,52 div $0,1152 add $0,2
oeis/142/A142796.asm
neoneye/loda-programs
11
92670
<gh_stars>10-100 ; A142796: Primes congruent to 47 mod 60. ; Submitted by <NAME>(s4) ; 47,107,167,227,347,467,587,647,827,887,947,1187,1307,1367,1427,1487,1607,1667,1787,1847,1907,2027,2087,2207,2267,2447,2687,2927,3167,3347,3407,3467,3527,3767,3947,4007,4127,4547,4787,4967,5087,5147,5387,5507,5807,5867,5927,5987,6047,6287,6827,6947,7127,7187,7247,7307,7487,7547,7607,7727,7907,8087,8147,8387,8447,8627,8747,8807,8867,9227,9467,9587,9767,9887,10007,10067,10247,10427,10487,10607,10667,10847,11027,11087,11447,11807,11867,11927,11987,12107,12227,12347,12527,12647,13007,13127,13187 mov $1,3 mov $2,$0 pow $2,2 lpb $2 add $1,20 mov $3,$1 sub $1,6 mul $3,2 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,16 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 sub $2,1 lpe mov $0,$1 mul $0,2 add $0,41
src/scratch/Data/List/Relation/Helpers.agda
zampino/ggt
2
13308
module Scratch.Data.List.Relation.Helpers where open import Relation.Nullary open import Relation.Nullary.Decidable open import Relation.Unary open import Relation.Binary hiding (Decidable) open import Data.Product open import Data.List.Base open import Data.List.Relation.Unary.All as All open import Data.List.Relation.Unary.All.Properties open import Data.List.Relation.Unary.AllPairs module _ {a ℓ ℓ₁ ℓ₂} {A : Set a} {R : Rel A ℓ₁} {S : Rel A ℓ₂} {P : Pred A ℓ} (P? : Decidable P) where filter⁺⁺ : ∀ {xs} → (∀ {x y} → P x → P y → R x y → S x y) → AllPairs R xs → AllPairs S (filter P? xs) filter⁺⁺ {[]} _ _ = [] filter⁺⁺ {x ∷ xs} Δ (h ∷ t) with (P? x) ... | yes p = let hf : All (R x) (filter P? xs) hf = filter⁺ P? h ap : All P (filter P? xs) ap = all-filter P? xs w : All (P ∩ R x) (filter P? xs) w = All.zip ( ap , hf ) y : P ∩ R x ⊆ S x y = λ z → Δ p (proj₁ z) (proj₂ z) z : All (S x) (filter P? xs) z = All.map y w in z ∷ filter⁺⁺ {xs} Δ t ... | no ¬p = filter⁺⁺ {xs} Δ t
src/FLutil.agda
shinji-kono/Galois
1
7156
<reponame>shinji-kono/Galois {-# OPTIONS --allow-unsolved-metas #-} module FLutil where open import Level hiding ( suc ; zero ) open import Data.Fin hiding ( _<_ ; _≤_ ; _-_ ; _+_ ; _≟_) open import Data.Fin.Properties hiding ( <-trans ; ≤-refl ; ≤-trans ; ≤-irrelevant ; _≟_ ) renaming ( <-cmp to <-fcmp ) open import Data.Fin.Permutation -- hiding ([_,_]) open import Data.Nat -- using (ℕ; suc; zero; s≤s ; z≤n ) open import Data.Nat.Properties as DNP open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Data.List using (List; []; _∷_ ; length ; _++_ ; tail ) renaming (reverse to rev ) open import Data.Product open import Relation.Nullary open import Data.Empty open import Relation.Binary.Core open import Relation.Binary.Definitions open import logic open import nat infixr 100 _::_ data FL : (n : ℕ )→ Set where f0 : FL 0 _::_ : { n : ℕ } → Fin (suc n ) → FL n → FL (suc n) data _f<_ : {n : ℕ } (x : FL n ) (y : FL n) → Set where f<n : {m : ℕ } {xn yn : Fin (suc m) } {xt yt : FL m} → xn Data.Fin.< yn → (xn :: xt) f< ( yn :: yt ) f<t : {m : ℕ } {xn : Fin (suc m) } {xt yt : FL m} → xt f< yt → (xn :: xt) f< ( xn :: yt ) FLeq : {n : ℕ } {xn yn : Fin (suc n)} {x : FL n } {y : FL n} → xn :: x ≡ yn :: y → ( xn ≡ yn ) × (x ≡ y ) FLeq refl = refl , refl FLpos : {n : ℕ} → FL (suc n) → Fin (suc n) FLpos (x :: _) = x f-<> : {n : ℕ } {x : FL n } {y : FL n} → x f< y → y f< x → ⊥ f-<> (f<n x) (f<n x₁) = nat-<> x x₁ f-<> (f<n x) (f<t lt2) = nat-≡< refl x f-<> (f<t lt) (f<n x) = nat-≡< refl x f-<> (f<t lt) (f<t lt2) = f-<> lt lt2 f-≡< : {n : ℕ } {x : FL n } {y : FL n} → x ≡ y → y f< x → ⊥ f-≡< refl (f<n x) = nat-≡< refl x f-≡< refl (f<t lt) = f-≡< refl lt FLcmp : {n : ℕ } → Trichotomous {Level.zero} {FL n} _≡_ _f<_ FLcmp f0 f0 = tri≈ (λ ()) refl (λ ()) FLcmp (xn :: xt) (yn :: yt) with <-fcmp xn yn ... | tri< a ¬b ¬c = tri< (f<n a) (λ eq → nat-≡< (cong toℕ (proj₁ (FLeq eq)) ) a) (λ lt → f-<> lt (f<n a) ) ... | tri> ¬a ¬b c = tri> (λ lt → f-<> lt (f<n c) ) (λ eq → nat-≡< (cong toℕ (sym (proj₁ (FLeq eq)) )) c) (f<n c) ... | tri≈ ¬a refl ¬c with FLcmp xt yt ... | tri< a ¬b ¬c₁ = tri< (f<t a) (λ eq → ¬b (proj₂ (FLeq eq) )) (λ lt → f-<> lt (f<t a) ) ... | tri≈ ¬a₁ refl ¬c₁ = tri≈ (λ lt → f-≡< refl lt ) refl (λ lt → f-≡< refl lt ) ... | tri> ¬a₁ ¬b c = tri> (λ lt → f-<> lt (f<t c) ) (λ eq → ¬b (proj₂ (FLeq eq) )) (f<t c) f<-trans : {n : ℕ } { x y z : FL n } → x f< y → y f< z → x f< z f<-trans {suc n} (f<n x) (f<n x₁) = f<n ( Data.Fin.Properties.<-trans x x₁ ) f<-trans {suc n} (f<n x) (f<t y<z) = f<n x f<-trans {suc n} (f<t x<y) (f<n x) = f<n x f<-trans {suc n} (f<t x<y) (f<t y<z) = f<t (f<-trans x<y y<z) infixr 250 _f<?_ _f<?_ : {n : ℕ} → (x y : FL n ) → Dec (x f< y ) x f<? y with FLcmp x y ... | tri< a ¬b ¬c = yes a ... | tri≈ ¬a refl ¬c = no ( ¬a ) ... | tri> ¬a ¬b c = no ( ¬a ) _f≤_ : {n : ℕ } (x : FL n ) (y : FL n) → Set _f≤_ x y = (x ≡ y ) ∨ (x f< y ) FL0 : {n : ℕ } → FL n FL0 {zero} = f0 FL0 {suc n} = zero :: FL0 fmax : { n : ℕ } → FL n fmax {zero} = f0 fmax {suc n} = fromℕ< a<sa :: fmax {n} fmax< : { n : ℕ } → {x : FL n } → ¬ (fmax f< x ) fmax< {suc n} {x :: y} (f<n lt) = nat-≤> (fmax1 x) lt where fmax1 : {n : ℕ } → (x : Fin (suc n)) → toℕ x ≤ toℕ (fromℕ< {n} a<sa) fmax1 {zero} zero = z≤n fmax1 {suc n} zero = z≤n fmax1 {suc n} (suc x) = s≤s (fmax1 x) fmax< {suc n} {x :: y} (f<t lt) = fmax< {n} {y} lt fmax¬ : { n : ℕ } → {x : FL n } → ¬ ( x ≡ fmax ) → x f< fmax fmax¬ {zero} {f0} ne = ⊥-elim ( ne refl ) fmax¬ {suc n} {x} ne with FLcmp x fmax ... | tri< a ¬b ¬c = a ... | tri≈ ¬a b ¬c = ⊥-elim ( ne b) ... | tri> ¬a ¬b c = ⊥-elim (fmax< c) x≤fmax : {n : ℕ } → {x : FL n} → x f≤ fmax x≤fmax {n} {x} with FLcmp x fmax ... | tri< a ¬b ¬c = case2 a ... | tri≈ ¬a b ¬c = case1 b ... | tri> ¬a ¬b c = ⊥-elim ( fmax< c ) open import Data.Nat.Properties using ( ≤-trans ; <-trans ) fsuc : { n : ℕ } → (x : FL n ) → x f< fmax → FL n fsuc {n} (x :: y) (f<n lt) = fromℕ< fsuc1 :: y where fsuc1 : suc (toℕ x) < n fsuc1 = Data.Nat.Properties.≤-trans (s≤s lt) ( s≤s ( toℕ≤pred[n] (fromℕ< a<sa)) ) fsuc (x :: y) (f<t lt) = x :: fsuc y lt open import fin flist1 : {n : ℕ } (i : ℕ) → i < suc n → List (FL n) → List (FL n) → List (FL (suc n)) flist1 zero i<n [] _ = [] flist1 zero i<n (a ∷ x ) z = ( zero :: a ) ∷ flist1 zero i<n x z flist1 (suc i) (s≤s i<n) [] z = flist1 i (Data.Nat.Properties.<-trans i<n a<sa) z z flist1 (suc i) i<n (a ∷ x ) z = ((fromℕ< i<n ) :: a ) ∷ flist1 (suc i) i<n x z flist : {n : ℕ } → FL n → List (FL n) flist {zero} f0 = f0 ∷ [] flist {suc n} (x :: y) = flist1 n a<sa (flist y) (flist y) FL1 : List ℕ → List ℕ FL1 [] = [] FL1 (x ∷ y) = suc x ∷ FL1 y FL→plist : {n : ℕ} → FL n → List ℕ FL→plist {0} f0 = [] FL→plist {suc n} (zero :: y) = zero ∷ FL1 (FL→plist y) FL→plist {suc n} (suc x :: y) with FL→plist y ... | [] = zero ∷ [] ... | x1 ∷ t = suc x1 ∷ FL2 x t where FL2 : {n : ℕ} → Fin n → List ℕ → List ℕ FL2 zero y = zero ∷ FL1 y FL2 (suc i) [] = zero ∷ [] FL2 (suc i) (x ∷ y) = suc x ∷ FL2 i y tt0 = (# 2) :: (# 1) :: (# 0) :: zero :: f0 tt1 = FL→plist tt0 open _∧_ find-zero : {n i : ℕ} → List ℕ → i < n → Fin n ∧ List ℕ find-zero [] i<n = record { proj1 = fromℕ< i<n ; proj2 = [] } find-zero x (s≤s z≤n) = record { proj1 = fromℕ< (s≤s z≤n) ; proj2 = x } find-zero (zero ∷ y) (s≤s (s≤s i<n)) = record { proj1 = fromℕ< (s≤s (s≤s i<n)) ; proj2 = y } find-zero (suc x ∷ y) (s≤s (s≤s i<n)) with find-zero y (s≤s i<n) ... | record { proj1 = i ; proj2 = y1 } = record { proj1 = suc i ; proj2 = suc x ∷ y1 } plist→FL : {n : ℕ} → List ℕ → FL n -- wrong implementation plist→FL {zero} [] = f0 plist→FL {suc n} [] = zero :: plist→FL {n} [] plist→FL {zero} x = f0 plist→FL {suc n} x with find-zero x a<sa ... | record { proj1 = i ; proj2 = y } = i :: plist→FL y tt2 = 2 ∷ 1 ∷ 0 ∷ 3 ∷ [] tt3 : FL 4 tt3 = plist→FL tt2 tt4 = FL→plist tt3 tt5 = plist→FL {4} (FL→plist tt0) -- maybe FL→iso can be easier using this ... -- FL→plist-iso : {n : ℕ} → (f : FL n ) → plist→FL (FL→plist f ) ≡ f -- FL→plist-iso = {!!} -- FL→plist-inject : {n : ℕ} → (f g : FL n ) → FL→plist f ≡ FL→plist g → f ≡ g -- FL→plist-inject = {!!} open import Relation.Binary as B hiding (Decidable; _⇔_) open import Data.Sum.Base as Sum -- inj₁ open import Relation.Nary using (⌊_⌋) open import Data.List.Fresh hiding ([_]) FList : (n : ℕ ) → Set FList n = List# (FL n) ⌊ _f<?_ ⌋ fr1 : FList 3 fr1 = ((# 0) :: ((# 0) :: ((# 0 ) :: f0))) ∷# ((# 0) :: ((# 1) :: ((# 0 ) :: f0))) ∷# ((# 1) :: ((# 0) :: ((# 0 ) :: f0))) ∷# ((# 2) :: ((# 0) :: ((# 0 ) :: f0))) ∷# ((# 2) :: ((# 1) :: ((# 0 ) :: f0))) ∷# [] open import Data.Product open import Relation.Nullary.Decidable hiding (⌊_⌋) -- open import Data.Bool hiding (_<_ ; _≤_ ) open import Data.Unit.Base using (⊤ ; tt) -- fresh a [] = ⊤ -- fresh a (x ∷# xs) = R a x × fresh a xs -- toWitness -- ttf< : {n : ℕ } → {x a : FL n } → x f< a → T (isYes (x f<? a)) -- ttf< {n} {x} {a} x<a with x f<? a -- ... | yes y = subst (λ k → Data.Bool.T k ) refl tt -- ... | no nn = ⊥-elim ( nn x<a ) ttf : {n : ℕ } {x a : FL (n)} → x f< a → (y : FList (n)) → fresh (FL (n)) ⌊ _f<?_ ⌋ a y → fresh (FL (n)) ⌊ _f<?_ ⌋ x y ttf _ [] fr = Level.lift tt ttf {_} {x} {a} lt (cons a₁ y x1) (lift lt1 , x2 ) = (Level.lift (fromWitness (ttf1 lt1 lt ))) , ttf (ttf1 lt1 lt) y x1 where ttf1 : True (a f<? a₁) → x f< a → x f< a₁ ttf1 t x<a = f<-trans x<a (toWitness t) -- by https://gist.github.com/aristidb/1684202 FLinsert : {n : ℕ } → FL n → FList n → FList n FLfresh : {n : ℕ } → (a x : FL (suc n) ) → (y : FList (suc n) ) → a f< x → fresh (FL (suc n)) ⌊ _f<?_ ⌋ a y → fresh (FL (suc n)) ⌊ _f<?_ ⌋ a (FLinsert x y) FLinsert {zero} f0 y = f0 ∷# [] FLinsert {suc n} x [] = x ∷# [] FLinsert {suc n} x (cons a y x₁) with FLcmp x a ... | tri≈ ¬a b ¬c = cons a y x₁ ... | tri< lt ¬b ¬c = cons x ( cons a y x₁) ( Level.lift (fromWitness lt ) , ttf lt y x₁) FLinsert {suc n} x (cons a [] x₁) | tri> ¬a ¬b lt = cons a ( x ∷# [] ) ( Level.lift (fromWitness lt) , Level.lift tt ) FLinsert {suc n} x (cons a y yr) | tri> ¬a ¬b a<x = cons a (FLinsert x y) (FLfresh a x y a<x yr ) FLfresh a x [] a<x (Level.lift tt) = Level.lift (fromWitness a<x) , Level.lift tt FLfresh a x (cons b [] (Level.lift tt)) a<x (Level.lift a<b , a<y) with FLcmp x b ... | tri< x<b ¬b ¬c = Level.lift (fromWitness a<x) , Level.lift a<b , Level.lift tt ... | tri≈ ¬a refl ¬c = Level.lift (fromWitness a<x) , Level.lift tt ... | tri> ¬a ¬b b<x = Level.lift a<b , Level.lift (fromWitness (f<-trans (toWitness a<b) b<x)) , Level.lift tt FLfresh a x (cons b y br) a<x (Level.lift a<b , a<y) with FLcmp x b ... | tri< x<b ¬b ¬c = Level.lift (fromWitness a<x) , Level.lift a<b , ttf (toWitness a<b) y br ... | tri≈ ¬a refl ¬c = Level.lift (fromWitness a<x) , ttf a<x y br FLfresh a x (cons b [] br) a<x (Level.lift a<b , a<y) | tri> ¬a ¬b b<x = Level.lift a<b , Level.lift (fromWitness (f<-trans (toWitness a<b) b<x)) , Level.lift tt FLfresh a x (cons b (cons a₁ y x₁) br) a<x (Level.lift a<b , a<y) | tri> ¬a ¬b b<x = Level.lift a<b , FLfresh a x (cons a₁ y x₁) a<x a<y fr6 = FLinsert ((# 1) :: ((# 1) :: ((# 0 ) :: f0))) fr1 open import Data.List.Fresh.Relation.Unary.Any open import Data.List.Fresh.Relation.Unary.All x∈FLins : {n : ℕ} → (x : FL n ) → (xs : FList n) → Any (x ≡_) (FLinsert x xs) x∈FLins {zero} f0 [] = here refl x∈FLins {zero} f0 (cons f0 xs x) = here refl x∈FLins {suc n} x [] = here refl x∈FLins {suc n} x (cons a xs x₁) with FLcmp x a ... | tri< x<a ¬b ¬c = here refl ... | tri≈ ¬a b ¬c = here b x∈FLins {suc n} x (cons a [] x₁) | tri> ¬a ¬b a<x = there ( here refl ) x∈FLins {suc n} x (cons a (cons a₁ xs x₂) x₁) | tri> ¬a ¬b a<x = there ( x∈FLins x (cons a₁ xs x₂) ) nextAny : {n : ℕ} → {x h : FL n } → {L : FList n} → {hr : fresh (FL n) ⌊ _f<?_ ⌋ h L } → Any (x ≡_) L → Any (x ≡_) (cons h L hr ) nextAny (here x₁) = there (here x₁) nextAny (there any) = there (there any) insAny : {n : ℕ} → {x h : FL n } → (xs : FList n) → Any (x ≡_) xs → Any (x ≡_) (FLinsert h xs) insAny {zero} {f0} {f0} (cons a L xr) (here refl) = here refl insAny {zero} {f0} {f0} (cons a L xr) (there any) = insAny {zero} {f0} {f0} L any insAny {suc n} {x} {h} (cons a L xr) any with FLcmp h a ... | tri< x<a ¬b ¬c = there any ... | tri≈ ¬a b ¬c = any insAny {suc n} {a} {h} (cons a [] (Level.lift tt)) (here refl) | tri> ¬a ¬b c = here refl insAny {suc n} {x} {h} (cons a (cons a₁ L x₁) xr) (here refl) | tri> ¬a ¬b c = here refl insAny {suc n} {x} {h} (cons a (cons a₁ L x₁) xr) (there any) | tri> ¬a ¬b c = there (insAny (cons a₁ L x₁) any) -- FLinsert membership module FLMB { n : ℕ } where FL-Setoid : Setoid Level.zero Level.zero FL-Setoid = record { Carrier = FL n ; _≈_ = _≡_ ; isEquivalence = record { sym = sym ; refl = refl ; trans = trans }} open import Data.List.Fresh.Membership.Setoid FL-Setoid FLinsert-mb : (x : FL n ) → (xs : FList n) → x ∈ FLinsert x xs FLinsert-mb x xs = x∈FLins {n} x xs
add/clean-run-time-system/acompact_rmark.asm
ErinvanderVeen/C-to-Clean
0
161800
<gh_stars>0 rmark_stack_nodes1: mov rbx,qword ptr [rcx] lea rax,1[rsi] mov qword ptr [rsi],rbx mov qword ptr [rcx],rax rmark_next_stack_node: add rsi,8 rmark_stack_nodes: cmp rsi,qword ptr end_vector+0 je end_rmark_nodes rmark_more_stack_nodes: mov rcx,qword ptr [rsi] mov rax,qword ptr neg_heap_p3+0 add rax,rcx cmp rax,qword ptr heap_size_64_65+0 jnc rmark_next_stack_node mov rbx,rax and rax,31*8 shr rbx,8 ifdef PIC lea r9,bit_set_table2+0 mov eax,dword ptr [r9+rax] else mov eax,dword ptr (bit_set_table2)[rax] endif mov ebp,dword ptr [rdi+rbx*4] test rbp,rax jne rmark_stack_nodes1 or rbp,rax mov dword ptr [rdi+rbx*4],ebp mov rax,qword ptr [rcx] call rmark_stack_node add rsi,8 cmp rsi,qword ptr end_vector+0 jne rmark_more_stack_nodes ret rmark_stack_node: sub rsp,16 mov qword ptr [rsi],rax lea rbp,1[rsi] mov qword ptr 8[rsp],rsi mov rbx,-1 mov qword ptr [rsp],0 mov qword ptr [rcx],rbp jmp rmark_no_reverse rmark_node_d1: mov rax,qword ptr neg_heap_p3+0 add rax,rcx cmp rax,qword ptr heap_size_64_65+0 jnc rmark_next_node jmp rmark_node_ rmark_hnf_2: lea rbx,8[rcx] mov rax,qword ptr 8[rcx] sub rsp,16 mov rsi,rcx mov rcx,qword ptr [rcx] mov qword ptr 8[rsp],rbx mov qword ptr [rsp],rax cmp rsp,qword ptr end_stack+0 jb rmark_using_reversal rmark_node: mov rax,qword ptr neg_heap_p3+0 add rax,rcx cmp rax,qword ptr heap_size_64_65+0 jnc rmark_next_node mov rbx,rsi rmark_node_: mov rdx,rax and rax,31*8 shr rdx,8 ifdef PIC lea r9,bit_set_table2+0 mov eax,dword ptr [r9+rax] else mov eax,dword ptr (bit_set_table2)[rax] endif mov ebp,dword ptr [rdi+rdx*4] test rbp,rax jne rmark_reverse_and_mark_next_node or rbp,rax mov dword ptr [rdi+rdx*4],ebp mov rax,qword ptr [rcx] rmark_arguments: cmp rcx,rbx ja rmark_no_reverse lea rbp,1[rsi] mov qword ptr [rsi],rax mov qword ptr [rcx],rbp rmark_no_reverse: test al,2 je rmark_lazy_node movzx rbp,word ptr (-2)[rax] test rbp,rbp je rmark_hnf_0 add rcx,8 cmp rbp,256 jae rmark_record sub rbp,2 je rmark_hnf_2 jc rmark_hnf_1 rmark_hnf_3: mov rdx,qword ptr 8[rcx] rmark_hnf_3_: cmp rsp,qword ptr end_stack+0 jb rmark_using_reversal_ mov rax,qword ptr neg_heap_p3+0 add rax,rdx mov rbx,rax and rax,31*8 shr rbx,8 ifdef PIC lea r9,bit_set_table2+0 mov eax,dword ptr [r9+rax] else mov eax,dword ptr (bit_set_table2)[rax] endif test eax,[rdi+rbx*4] jne rmark_shared_argument_part or dword ptr [rdi+rbx*4],eax rmark_no_shared_argument_part: sub rsp,16 mov qword ptr 8[rsp],rcx lea rsi,8[rcx] mov rcx,qword ptr [rcx] lea rdx,[rdx+rbp*8] mov qword ptr [rsp],rcx rmark_push_hnf_args: mov rbx,qword ptr [rdx] sub rsp,16 mov qword ptr 8[rsp],rdx sub rdx,8 mov qword ptr [rsp],rbx sub rbp,1 jg rmark_push_hnf_args mov rcx,qword ptr [rdx] cmp rdx,rsi ja rmark_no_reverse_argument_pointer lea rbp,3[rsi] mov qword ptr [rsi],rcx mov qword ptr [rdx],rbp mov rax,qword ptr neg_heap_p3+0 add rax,rcx cmp rax,qword ptr heap_size_64_65+0 jnc rmark_next_node mov rbx,rdx jmp rmark_node_ rmark_no_reverse_argument_pointer: mov rsi,rdx jmp rmark_node rmark_shared_argument_part: cmp rdx,rcx ja rmark_hnf_1 mov rbx,qword ptr [rdx] lea rax,(8+2+1)[rcx] mov qword ptr [rdx],rax mov qword ptr 8[rcx],rbx jmp rmark_hnf_1 rmark_record: sub rbp,258 je rmark_record_2 jb rmark_record_1 rmark_record_3: movzx rbp,word ptr (-2+2)[rax] mov rdx,qword ptr (16-8)[rcx] sub rbp,1 jb rmark_record_3_bb je rmark_record_3_ab sub rbp,1 je rmark_record_3_aab jmp rmark_hnf_3_ rmark_record_3_bb: sub rcx,8 mov rax,qword ptr neg_heap_p3+0 add rax,rdx mov rbp,rax and rax,31*8 shr rbp,8 ifdef PIC lea r9,bit_set_table2+0 mov eax,dword ptr [r9+rax] else mov eax,dword ptr (bit_set_table2)[rax] endif or dword ptr [rdi+rbp*4],eax cmp rdx,rcx ja rmark_next_node add eax,eax jne rmark_bit_in_same_word1 inc rbp mov rax,1 rmark_bit_in_same_word1: test eax,dword ptr [rdi+rbp*4] je rmark_not_yet_linked_bb mov rax,qword ptr neg_heap_p3+0 add rax,rcx add rax,16 mov rbp,rax and rax,31*8 shr rbp,8 ifdef PIC lea r9,bit_set_table2+0 mov eax,dword ptr [r9+rax] else mov eax,dword ptr (bit_set_table2)[rax] endif or dword ptr [rdi+rbp*4],eax mov rbp,qword ptr [rdx] lea rax,(16+2+1)[rcx] mov qword ptr 16[rcx],rbp mov qword ptr [rdx],rax jmp rmark_next_node rmark_not_yet_linked_bb: or dword ptr [rdi+rbp*4],eax mov rbp,qword ptr [rdx] lea rax,(16+2+1)[rcx] mov qword ptr 16[rcx],rbp mov qword ptr [rdx],rax jmp rmark_next_node rmark_record_3_ab: mov rax,qword ptr neg_heap_p3+0 add rax,rdx mov rbp,rax and rax,31*8 shr rbp,8 ifdef PIC lea r9,bit_set_table2+0 mov eax,dword ptr [r9+rax] else mov eax,dword ptr (bit_set_table2)[rax] endif or dword ptr [rdi+rbp*4],eax cmp rdx,rcx ja rmark_hnf_1 add eax,eax jne rmark_bit_in_same_word2 inc rbp mov rax,1 rmark_bit_in_same_word2: test eax,dword ptr [rdi+rbp*4] je rmark_not_yet_linked_ab mov rax,qword ptr neg_heap_p3+0 add rax,rcx add rax,8 mov rbp,rax and rax,31*8 shr rbp,8 ifdef PIC lea r9,bit_set_table2+0 mov eax,dword ptr [r9+rax] else mov eax,dword ptr (bit_set_table2)[rax] endif or dword ptr [rdi+rbp*4],eax mov rbp,qword ptr [rdx] lea rax,(8+2+1)[rcx] mov qword ptr 8[rcx],rbp mov qword ptr [rdx],rax jmp rmark_hnf_1 rmark_not_yet_linked_ab: or dword ptr [rdi+rbp*4],eax mov rbp,qword ptr [rdx] lea rax,(8+2+1)[rcx] mov qword ptr 8[rcx],rbp mov qword ptr [rdx],rax jmp rmark_hnf_1 rmark_record_3_aab: cmp rsp,qword ptr end_stack+0 jb rmark_using_reversal_ mov rax,qword ptr neg_heap_p3+0 add rax,rdx mov rbp,rax and rax,31*8 shr rbp,8 ifdef PIC lea r9,bit_set_table2+0 mov eax,dword ptr [r9+rax] else mov eax,dword ptr (bit_set_table2)[rax] endif test eax,dword ptr [rdi+rbp*4] jne rmark_shared_argument_part or dword ptr [rdi+rbp*4],eax sub rsp,16 mov qword ptr 8[rsp],rcx lea rsi,8[rcx] mov rcx,qword ptr [rcx] mov qword ptr [rsp],rcx mov rcx,qword ptr [rdx] cmp rdx,rsi ja rmark_no_reverse_argument_pointer lea rbp,3[rsi] mov qword ptr [rsi],rcx mov qword ptr [rdx],rbp mov rax,qword ptr neg_heap_p3+0 add rax,rcx cmp rax,qword ptr heap_size_64_65+0 jnc rmark_next_node mov rbx,rdx jmp rmark_node_ rmark_record_2: cmp word ptr (-2+2)[rax],1 ja rmark_hnf_2 je rmark_hnf_1 jmp rmark_next_node rmark_record_1: cmp word ptr (-2+2)[rax],0 jne rmark_hnf_1 jmp rmark_next_node rmark_lazy_node_1: ; selectors: jne rmark_selector_node_1 rmark_hnf_1: mov rsi,rcx mov rcx,qword ptr [rcx] jmp rmark_node ; selectors rmark_indirection_node: mov rdx,qword ptr neg_heap_p3+0 sub rcx,8 add rdx,rcx mov rbp,rdx and rbp,31*8 shr rdx,8 ifdef PIC lea r9,bit_clear_table2+0 mov ebp,dword ptr [r9+rbp] else mov ebp,dword ptr (bit_clear_table2)[rbp] endif and dword ptr [rdi+rdx*4],ebp mov rdx,rcx cmp rcx,rbx mov rcx,qword ptr 8[rcx] mov qword ptr [rsi],rcx ja rmark_node_d1 mov qword ptr [rdx],rax jmp rmark_node_d1 rmark_selector_node_1: add rbp,3 je rmark_indirection_node mov rdx,qword ptr [rcx] mov qword ptr pointer_compare_address+0,rbx mov rbx,qword ptr neg_heap_p3+0 add rbx,rdx shr rbx,3 add rbp,1 jle rmark_record_selector_node_1 mov rbp,rbx shr rbx,5 and rbp,31 ifdef PIC lea r9,bit_set_table+0 mov ebp,dword ptr [r9+rbp*4] else mov ebp,dword ptr (bit_set_table)[rbp*4] endif mov ebx,dword ptr [rdi+rbx*4] and rbx,rbp jne rmark_hnf_1 mov rbx,qword ptr [rdx] test bl,2 je rmark_hnf_1 cmp word ptr (-2)[rbx],2 jbe rmark_small_tuple_or_record rmark_large_tuple_or_record: mov d2,qword ptr 16[rdx] mov rbx,qword ptr neg_heap_p3+0 add rbx,d2 shr rbx,3 mov rbp,rbx shr rbx,5 and rbp,31 ifdef PIC lea r9,bit_set_table+0 mov ebp,dword ptr [r9+rbp*4] else mov ebp,dword ptr (bit_set_table)[rbp*4] endif mov ebx,dword ptr [rdi+rbx*4] and rbx,rbp jne rmark_hnf_1 ifdef NEW_DESCRIPTORS mov rbx,qword ptr neg_heap_p3+0 lea rbx,(-8)[rcx+rbx] ifdef PIC movsxd d3,dword ptr (-8)[rax] add rax,d3 else mov eax,dword ptr (-8)[rax] endif mov d3,rbx and d3,31*8 shr rbx,8 ifdef PIC lea r9,bit_clear_table2+0 mov d3d,dword ptr [r9+d3] else mov d3d,dword ptr (bit_clear_table2)[d3] endif and dword ptr [rdi+rbx*4],d3d ifdef PIC movzx eax,word ptr (4-8)[rax] else movzx eax,word ptr 4[rax] endif mov rbx,qword ptr pointer_compare_address+0 ifdef PIC lea r9,__indirection+0 mov qword ptr (-8)[rcx],r9 else mov qword ptr (-8)[rcx],offset __indirection endif cmp rax,16 jl rmark_tuple_or_record_selector_node_2 mov rdx,rcx je rmark_tuple_selector_node_2 mov rcx,qword ptr (-24)[d2+rax] mov qword ptr [rsi],rcx mov qword ptr [rdx],rcx jmp rmark_node_d1 rmark_tuple_selector_node_2: mov rcx,qword ptr [d2] mov qword ptr [rsi],rcx mov qword ptr [rdx],rcx jmp rmark_node_d1 else rmark_small_tuple_or_record: mov rbx,qword ptr neg_heap_p3 lea rbx,(-8)[rcx+rbx] push rcx mov rcx,rbx and rcx,31*8 shr rbx,8 mov ecx,dword ptr (bit_clear_table2)[rcx] and dword ptr [rdi+rbx*4],ecx mov eax,(-8)[rax] mov rcx,rdx push rsi mov eax,4[rax] call near ptr rax pop rsi pop rdx mov qword ptr [rsi],rcx mov rbx,qword ptr pointer_compare_address mov qword ptr (-8)[rdx],offset __indirection mov qword ptr [rdx],rcx jmp rmark_node_d1 endif rmark_record_selector_node_1: je rmark_strict_record_selector_node_1 mov rbp,rbx shr rbx,5 and rbp,31 ifdef PIC lea r9,bit_set_table+0 mov ebp,dword ptr [r9+rbp*4] else mov ebp,dword ptr (bit_set_table)[rbp*4] endif mov ebx,dword ptr [rdi+rbx*4] and rbx,rbp jne rmark_hnf_1 mov rbx,qword ptr [rdx] test bl,2 je rmark_hnf_1 cmp word ptr (-2)[rbx],258 jbe rmark_small_tuple_or_record ifdef NEW_DESCRIPTORS mov d2,qword ptr 16[rdx] mov rbx,qword ptr neg_heap_p3+0 add rbx,d2 shr rbx,3 mov rbp,rbx shr rbx,5 and rbp,31 ifdef PIC lea r9,bit_set_table+0 mov ebp,dword ptr [r9+rbp*4] else mov ebp,dword ptr (bit_set_table)[rbp*4] endif mov ebx,dword ptr [rdi+rbx*4] and rbx,rbp jne rmark_hnf_1 rmark_small_tuple_or_record: mov rbx,qword ptr neg_heap_p3+0 lea rbx,(-8)[rcx+rbx] ifdef PIC movsxd d3,dword ptr(-8)[rax] add rax,d3 else mov eax,(-8)[rax] endif mov d3,rbx and d3,31*8 shr rbx,8 ifdef PIC lea r9,bit_clear_table2+0 mov d3d,dword ptr [r9+d3] else mov d3d,dword ptr (bit_clear_table2)[d3] endif and dword ptr [rdi+rbx*4],d3d ifdef PIC movzx eax,word ptr (4-8)[rax] else movzx eax,word ptr 4[rax] endif mov rbx,qword ptr pointer_compare_address+0 ifdef PIC lea r9,__indirection+0 mov qword ptr (-8)[rcx],r9 else mov qword ptr (-8)[rcx],offset __indirection endif cmp rax,16 jle rmark_tuple_or_record_selector_node_2 mov rdx,d2 sub rax,24 rmark_tuple_or_record_selector_node_2: mov rbp,rcx mov rcx,qword ptr [rdx+rax] mov qword ptr [rsi],rcx mov qword ptr [rbp],rcx mov rdx,rbp jmp rmark_node_d1 else jmp rmark_large_tuple_or_record endif rmark_strict_record_selector_node_1: mov rbp,rbx shr rbx,5 and rbp,31 ifdef PIC lea r9,bit_set_table+0 mov ebp,dword ptr [r9+rbp*4] else mov ebp,dword ptr (bit_set_table)[rbp*4] endif mov ebx,dword ptr [rdi+rbx*4] and rbx,rbp jne rmark_hnf_1 mov rbx,qword ptr [rdx] test bl,2 je rmark_hnf_1 cmp word ptr (-2)[rbx],258 jbe rmark_select_from_small_record mov d2,qword ptr 16[rdx] mov rbx,qword ptr neg_heap_p3+0 add rbx,d2 mov rbp,rbx shr rbx,8 and rbp,31*8 ifdef PIC lea r9,bit_set_table2+0 mov ebp,dword ptr [r9+rbp] else mov ebp,dword ptr (bit_set_table2)[rbp] endif mov ebx,dword ptr [rdi+rbx*4] and rbx,rbp jne rmark_hnf_1 rmark_select_from_small_record: ifdef PIC movsxd rbx,dword ptr(-8)[rax] add rbx,rax else mov ebx,(-8)[rax] endif sub rcx,8 cmp rcx,qword ptr pointer_compare_address+0 ja rmark_selector_pointer_not_reversed ifdef NEW_DESCRIPTORS ifdef PIC movzx eax,word ptr (4-8)[rbx] else movzx eax,word ptr 4[rbx] endif cmp rax,16 jle rmark_strict_record_selector_node_2 mov rax,qword ptr (-24)[d2+rax] jmp rmark_strict_record_selector_node_3 rmark_strict_record_selector_node_2: mov rax,qword ptr [rdx+rax] rmark_strict_record_selector_node_3: mov qword ptr 8[rcx],rax ifdef PIC movzx eax,word ptr (6-8)[rbx] else movzx eax,word ptr 6[rbx] endif test rax,rax je rmark_strict_record_selector_node_5 cmp rax,16 jle rmark_strict_record_selector_node_4 mov rdx,d2 sub rax,24 rmark_strict_record_selector_node_4: mov rax,qword ptr [rdx+rax] mov qword ptr 16[rcx],rax rmark_strict_record_selector_node_5: ifdef PIC mov rax,qword ptr ((-8)-8)[rbx] else mov rax,qword ptr (-8)[rbx] endif else mov qword ptr [rcx],rax mov qword ptr [rsi],rcx push rsi mov ebx,4[rbx] call near ptr rbx pop rsi mov rax,qword ptr [rcx] endif add rsi,1 mov qword ptr [rcx],rsi mov qword ptr (-1)[rsi],rax jmp rmark_next_node rmark_selector_pointer_not_reversed: ifdef NEW_DESCRIPTORS ifdef PIC movzx eax,word ptr (4-8)[rbx] else movzx eax,word ptr 4[rbx] endif cmp rax,16 jle rmark_strict_record_selector_node_6 mov rax,qword ptr (-24)[d2+rax] jmp rmark_strict_record_selector_node_7 rmark_strict_record_selector_node_6: mov rax,qword ptr [rdx+rax] rmark_strict_record_selector_node_7: mov qword ptr 8[rcx],rax ifdef PIC movzx eax,word ptr (6-8)[rbx] else movzx eax,word ptr 6[rbx] endif test rax,rax je rmark_strict_record_selector_node_9 cmp rax,16 jle rmark_strict_record_selector_node_8 mov rdx,d2 sub rax,24 rmark_strict_record_selector_node_8: mov rax,qword ptr [rdx+rax] mov qword ptr 16[rcx],rax rmark_strict_record_selector_node_9: ifdef PIC mov rax,qword ptr ((-8)-8)[rbx] else mov rax,qword ptr (-8)[rbx] endif mov qword ptr [rcx],rax else mov ebx,4[rbx] call near ptr rbx endif jmp rmark_next_node rmark_reverse_and_mark_next_node: cmp rcx,rbx ja rmark_next_node mov rax,qword ptr [rcx] mov qword ptr [rsi],rax add rsi,1 mov qword ptr [rcx],rsi ; %rbp ,%rbx : free rmark_next_node: mov rcx,qword ptr [rsp] mov rsi,qword ptr 8[rsp] add rsp,16 cmp rcx,1 ja rmark_node rmark_next_node_: end_rmark_nodes: ret rmark_lazy_node: movsxd rbp,dword ptr (-4)[rax] test rbp,rbp je rmark_next_node add rcx,8 sub rbp,1 jle rmark_lazy_node_1 cmp rbp,255 jge rmark_closure_with_unboxed_arguments rmark_closure_with_unboxed_arguments_: lea rcx,[rcx+rbp*8] rmark_push_lazy_args: mov rbx,qword ptr [rcx] sub rsp,16 mov qword ptr 8[rsp],rcx sub rcx,8 mov qword ptr [rsp],rbx sub rbp,1 jg rmark_push_lazy_args mov rsi,rcx mov rcx,qword ptr [rcx] cmp rsp,qword ptr end_stack+0 jae rmark_node jmp rmark_using_reversal rmark_closure_with_unboxed_arguments: ; (a_size+b_size)+(b_size<<8) ; addl $1,%rbp mov rax,rbp and rbp,255 shr rax,8 sub rbp,rax ; subl $1,%rbp jg rmark_closure_with_unboxed_arguments_ je rmark_hnf_1 jmp rmark_next_node rmark_hnf_0: ifdef PIC lea r9,dINT+2+0 cmp rax,r9 else cmp rax,offset dINT+2 endif je rmark_int_3 ifdef PIC lea r9,CHAR+2+0 cmp rax,r9 else cmp rax,offset CHAR+2 endif je rmark_char_3 jb rmark_no_normal_hnf_0 mov rbp,qword ptr neg_heap_p3+0 add rbp,rcx mov rdx,rbp and rdx,31*8 shr rbp,8 ifdef PIC lea r9,bit_clear_table2+0 mov edx,dword ptr [r9+rdx] else mov edx,dword ptr (bit_clear_table2)[rdx] endif and dword ptr [rdi+rbp*4],edx ifdef NEW_DESCRIPTORS lea rdx,((-8)-2)[rax] else lea rdx,((-12)-2)[rax] endif mov qword ptr [rsi],rdx cmp rcx,rbx ja rmark_next_node mov qword ptr [rcx],rax jmp rmark_next_node rmark_int_3: mov rbp,qword ptr 8[rcx] cmp rbp,33 jnc rmark_next_node shl rbp,4 ifdef PIC lea rdx,small_integers+0 add rdx,rbp else lea rdx,(small_integers)[rbp] endif mov rbp,qword ptr neg_heap_p3+0 mov qword ptr [rsi],rdx add rbp,rcx mov rdx,rbp and rdx,31*8 shr rbp,8 ifdef PIC lea r9,bit_clear_table2+0 mov edx,dword ptr [r9+rdx] else mov edx,dword ptr (bit_clear_table2)[rdx] endif and dword ptr [rdi+rbp*4],edx cmp rcx,rbx ja rmark_next_node mov qword ptr [rcx],rax jmp rmark_next_node rmark_char_3: movzx rdx,byte ptr 8[rcx] mov rbp,qword ptr neg_heap_p3+0 shl rdx,4 add rbp,rcx ifdef PIC lea r9,static_characters+0 add rdx,r9 else add rdx,offset static_characters endif mov qword ptr [rsi],rdx mov rdx,rbp and rdx,31*8 shr rbp,8 ifdef PIC lea r9,bit_clear_table2+0 mov edx,dword ptr [r9+rdx] else mov edx,dword ptr (bit_clear_table2)[rdx] endif and dword ptr [rdi+rbp*4],edx cmp rcx,rbx ja rmark_next_node mov qword ptr [rcx],rax jmp rmark_next_node rmark_no_normal_hnf_0: lea r9,__ARRAY__+2+0 cmp rax,r9 jne rmark_next_node mov rax,qword ptr 16[rcx] test rax,rax je rmark_lazy_array movzx rdx,word ptr (-2+2)[rax] test rdx,rdx je rmark_b_array movzx rax,word ptr (-2)[rax] test rax,rax je rmark_b_array cmp rsp,qword ptr end_stack+0 jb rmark_array_using_reversal sub rax,256 cmp rdx,rax mov rbx,rdx je rmark_a_record_array rmark_ab_record_array: mov rdx,qword ptr 8[rcx] add rcx,16 push rcx imul rdx,rax shl rdx,3 sub rax,rbx add rcx,8 add rdx,rcx call reorder pop rcx mov rax,rbx imul rax,qword ptr (-8)[rcx] jmp rmark_lr_array rmark_b_array: mov rax,qword ptr neg_heap_p3+0 add rax,rcx add rax,8 mov rbp,rax and rax,31*8 shr rbp,8 ifdef PIC lea r9,bit_set_table2+0 mov eax,dword ptr [r9+rax] else mov eax,dword ptr (bit_set_table2)[rax] endif or dword ptr [rdi+rbp*4],eax jmp rmark_next_node rmark_a_record_array: mov rax,qword ptr 8[rcx] add rcx,16 cmp rbx,2 jb rmark_lr_array imul rax,rbx jmp rmark_lr_array rmark_lazy_array: cmp rsp,qword ptr end_stack+0 jb rmark_array_using_reversal mov rax,qword ptr 8[rcx] add rcx,16 rmark_lr_array: mov rbx,qword ptr neg_heap_p3+0 add rbx,rcx shr rbx,3 add rbx,rax mov rdx,rbx and rbx,31 shr rdx,5 ifdef PIC lea r9,bit_set_table+0 mov ebx,dword ptr [r9+rbx*4] else mov ebx,dword ptr (bit_set_table)[rbx*4] endif or dword ptr [rdi+rdx*4],ebx cmp rax,1 jbe rmark_array_length_0_1 mov rdx,rcx lea rcx,[rcx+rax*8] mov rax,qword ptr [rcx] mov rbx,qword ptr [rdx] mov qword ptr [rdx],rax mov qword ptr [rcx],rbx mov rax,qword ptr (-8)[rcx] sub rcx,8 mov rbx,qword ptr (-8)[rdx] sub rdx,8 mov qword ptr [rcx],rbx mov qword ptr [rdx],rax push rcx mov rsi,rdx jmp rmark_array_nodes rmark_array_nodes1: cmp rcx,rsi ja rmark_next_array_node mov rbx,qword ptr [rcx] lea rax,1[rsi] mov qword ptr [rsi],rbx mov qword ptr [rcx],rax rmark_next_array_node: add rsi,8 cmp rsi,qword ptr [rsp] je end_rmark_array_node rmark_array_nodes: mov rcx,qword ptr [rsi] mov rax,qword ptr neg_heap_p3+0 add rax,rcx cmp rax,qword ptr heap_size_64_65+0 jnc rmark_next_array_node mov rbx,rax and rax,31*8 shr rbx,8 ifdef PIC lea r9,bit_set_table2+0 mov eax,dword ptr [r9+rax] else mov eax,dword ptr (bit_set_table2)[rax] endif mov ebp,dword ptr [rdi+rbx*4] test rbp,rax jne rmark_array_nodes1 or rbp,rax mov dword ptr [rdi+rbx*4],ebp mov rax,qword ptr [rcx] call rmark_array_node add rsi,8 cmp rsi,qword ptr [rsp] jne rmark_array_nodes end_rmark_array_node: add rsp,8 jmp rmark_next_node rmark_array_node: sub rsp,16 mov qword ptr 8[rsp],rsi mov rbx,rsi mov qword ptr [rsp],1 jmp rmark_arguments rmark_array_length_0_1: lea rcx,-16[rcx] jb rmark_next_node mov rbx,qword ptr 24[rcx] mov rbp,qword ptr 16[rcx] mov qword ptr 24[rcx],rbp mov rbp,qword ptr 8[rcx] mov qword ptr 16[rcx],rbp mov qword ptr 8[rcx],rbx add rcx,8 jmp rmark_hnf_1 _TEXT ends _DATA segment pointer_compare_address: dq 0 _DATA ends _TEXT segment
programs/oeis/138/A138432.asm
neoneye/loda
22
245443
; A138432: a(n) = ((n-th prime)^5-(n-th prime)^3)/2. ; 12,108,1500,8232,79860,184548,707472,1234620,3212088,10243380,14299680,34646652,57893640,73464468,114620592,209023308,357359460,422184660,674912172,901935720,1036341288,1538281680,1969234428,2791677240 seq $0,40 ; The prime numbers. mov $1,$0 pow $1,2 mul $0,$1 sub $1,1 mul $0,$1 div $0,2
src/fot/FOTC/Data/List/Type.agda
asr/fotc
11
15993
<filename>src/fot/FOTC/Data/List/Type.agda ------------------------------------------------------------------------------ -- The FOTC lists type ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- N.B. This module is re-exported by FOTC.Data.List. module FOTC.Data.List.Type where open import FOTC.Base open import FOTC.Base.List ------------------------------------------------------------------------------ -- The FOTC lists type (inductive predicate for total lists). data List : D → Set where lnil : List [] lcons : ∀ x {xs} → List xs → List (x ∷ xs) {-# ATP axioms lnil lcons #-} -- Induction principle. List-ind : (A : D → Set) → A [] → (∀ x {xs} → A xs → A (x ∷ xs)) → ∀ {xs} → List xs → A xs List-ind A A[] h lnil = A[] List-ind A A[] h (lcons x Lxs) = h x (List-ind A A[] h Lxs)
oeis/154/A154251.asm
neoneye/loda-programs
11
14126
; A154251: Expansion of (1-x+7x^2)/((1-x)(1-2x)). ; 1,2,11,29,65,137,281,569,1145,2297,4601,9209,18425,36857,73721,147449,294905,589817,1179641,2359289,4718585,9437177,18874361,37748729,75497465,150994937,301989881,603979769,1207959545,2415919097,4831838201,9663676409,19327352825,38654705657,77309411321,154618822649,309237645305,618475290617,1236950581241,2473901162489,4947802324985,9895604649977,19791209299961,39582418599929,79164837199865,158329674399737,316659348799481,633318697598969,1266637395197945,2533274790395897,5066549580791801 mov $1,2 pow $1,$0 mul $1,9 trn $1,15 div $1,2 add $1,1 mov $0,$1
lc4programs/gcd.asm
ArmaanT/yallc
2
18869
<filename>lc4programs/gcd.asm ;; Expected: 21 gcd ADD R6, R6, #-3 STR R7, R6, #1 STR R5, R6, #0 ADD R5, R6, #0 LDR R0, R5, #4 ADD R6, R6, #-1 STR R0, R6, #0 CONST R0, #0 ADD R6, R6, #-1 STR R0, R6, #0 LDR R0, R6, #0 LDR R1, R6, #1 CMP R0, R1 BRz test_gcd_j_cmp_true_0 CONST R0, #0 STR R0, R6, #1 BRnzp test_gcd_j_cmp_end_0 test_gcd_j_cmp_true_0 CONST R0, #1 STR R0, R6, #1 test_gcd_j_cmp_end_0 ADD R6, R6, #1 ADD R6, R6, #1 LDR R0, R6, #-1 BRz test_gcd_j_else_0 LDR R0, R5, #3 ADD R6, R6, #-1 STR R0, R6, #0 BRnzp test_gcd_j_endif_0 test_gcd_j_else_0 LDR R0, R5, #4 ADD R6, R6, #-1 STR R0, R6, #0 LDR R0, R5, #3 ADD R6, R6, #-1 STR R0, R6, #0 LDR R0, R6, #0 LDR R1, R6, #1 MOD R0, R0, R1 ADD R6, R6, #1 STR R0, R6, #0 LDR R0, R5, #4 ADD R6, R6, #-1 STR R0, R6, #0 JSR gcd ADD R6, R6, #-1 test_gcd_j_endif_0 LDR R7, R6, #0 STR R7, R5, #2 ADD R6, R5, #0 LDR R5, R6, #0 LDR R7, R6, #1 ADD R6, R6, #3 RET main ADD R6, R6, #-3 STR R7, R6, #1 STR R5, R6, #0 ADD R5, R6, #0 CONST R0, #206 HICONST R0, #1 ADD R6, R6, #-1 STR R0, R6, #0 CONST R0, #47 HICONST R0, #4 ADD R6, R6, #-1 STR R0, R6, #0 JSR gcd ADD R6, R6, #-1 LDR R7, R6, #0 STR R7, R5, #2 ADD R6, R5, #0 LDR R5, R6, #0 LDR R7, R6, #1 ADD R6, R6, #3 RET
libsrc/_DEVELOPMENT/arch/zx/misc/c/sdcc_iy/zx_scroll_up_pix.asm
jpoikela/z88dk
640
20381
; void zx_scroll_up_pix(uchar rows, uchar pix) SECTION code_clib SECTION code_arch PUBLIC _zx_scroll_up_pix EXTERN asm0_zx_scroll_up_pix _zx_scroll_up_pix: pop af pop de push de push af ld l,d ld d,0 jp asm0_zx_scroll_up_pix
programs/oeis/129/A129026.asm
neoneye/loda
22
7768
<filename>programs/oeis/129/A129026.asm ; A129026: a(n) = (1/2)*(n^4 + 11*n^3 + 53*n^2 + 97*n + 54). ; 0,27,108,282,600,1125,1932,3108,4752,6975,9900,13662,18408,24297,31500,40200,50592,62883,77292,94050,113400,135597,160908,189612,222000,258375,299052,344358,394632,450225,511500,578832,652608,733227,821100,916650,1020312,1132533,1253772,1384500,1525200,1676367,1838508,2012142,2197800,2396025,2607372,2832408,3071712,3325875,3595500,3881202,4183608,4503357,4841100,5197500,5573232,5968983,6385452,6823350,7283400,7766337,8272908,8803872,9360000,9942075,10550892,11187258,11851992,12545925,13269900,14024772,14811408,15630687,16483500,17370750,18293352,19252233,20248332,21282600,22356000,23469507,24624108,25820802,27060600,28344525,29673612,31048908,32471472,33942375,35462700,37033542,38656008,40331217,42060300,43844400,45684672,47582283,49538412,51554250 mov $2,$0 mov $6,$0 lpb $0 add $6,2 trn $0,$6 mov $5,$6 lpe mov $3,$5 bin $5,2 mul $5,$3 mul $5,$3 mov $1,$5 trn $1,4 mov $7,$2 mul $7,$2 mov $4,$7 mul $4,4 add $1,$4 mov $0,$1
programs/oeis/173/A173193.asm
neoneye/loda
22
174450
<reponame>neoneye/loda<gh_stars>10-100 ; A173193: (2*10^n+43)/9. ; 7,27,227,2227,22227,222227,2222227,22222227,222222227,2222222227,22222222227,222222222227,2222222222227,22222222222227,222222222222227,2222222222222227,22222222222222227,222222222222222227 mov $1,10 pow $1,$0 div $1,3 mul $1,40 add $1,6 div $1,6 add $1,6 mov $0,$1
gtk/akt-windows-load_ui_gtk3.adb
My-Colaborations/ada-keystore
25
21043
<reponame>My-Colaborations/ada-keystore<gh_stars>10-100 ----------------------------------------------------------------------- -- akt-windows -- GtK Windows for Ada Keystore GTK application -- Copyright (C) 2019, 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. ----------------------------------------------------------------------- separate (AKT.Windows) -- ------------------------------ -- Load the glade XML definition. -- ------------------------------ procedure Load_UI (Application : in out Application_Type) is use type Glib.Guint; Result : Glib.Guint; Error : aliased Glib.Error.GError; begin Result := Application.Builder.Add_From_File ("gakt.glade", Error'Access); if Result /= 1 then Log.Error ("Cannot load the 'gakt.glade' configuration file"); raise Initialize_Error; end if; end Load_UI;
src/el-contexts-properties.ads
My-Colaborations/ada-el
0
5737
<filename>src/el-contexts-properties.ads<gh_stars>0 ----------------------------------------------------------------------- -- EL.Contexts.Properties -- EL Resolver using util properties -- Copyright (C) 2011 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with EL.Objects; with Util.Beans.Basic; with Util.Properties; package EL.Contexts.Properties is -- ------------------------------ -- Property Resolver -- ------------------------------ -- The <b>Property_Resolver</b> uses a property manager to resolve names. type Property_Resolver is new ELResolver with private; type Property_Resolver_Access is access all Property_Resolver'Class; -- Set the properties used for resolving values. procedure Set_Properties (Resolver : in out Property_Resolver; Properties : in Util.Properties.Manager'Class); -- Get the value associated with a base object and a given property. overriding function Get_Value (Resolver : in Property_Resolver; Context : in ELContext'Class; Base : access Util.Beans.Basic.Readonly_Bean'Class; Name : in Unbounded_String) return EL.Objects.Object; -- Set the value associated with a base object and a given property. overriding procedure Set_Value (Resolver : in out Property_Resolver; Context : in ELContext'Class; Base : access Util.Beans.Basic.Bean'Class; Name : in Unbounded_String; Value : in EL.Objects.Object); private type Property_Resolver is new ELResolver with record Props : Util.Properties.Manager; end record; end EL.Contexts.Properties;
vio/debug.asm
osfree-project/FamilyAPI
1
162040
.8086 include helpers.inc INCL_VIO EQU 1 include bsesub.inc EXTERN VIOWRTTTY: Far _DATA SEGMENT BYTE PUBLIC 'DATA' USE16 @tracemsg2 VioDeRegister @tracemsg2 VioEndPopUp @tracemsg2 VioGetAnsi @tracemsg2 VioGetBuf @tracemsg2 VioGetConfig @tracemsg2 VioGetCP @tracemsg2 VioGetCurPos @tracemsg2 VioGetCurType @tracemsg2 VioGetFont @tracemsg2 VioGetMode @tracemsg2 VioGetPhysBuf @tracemsg2 VioGetState @tracemsg2 VioModeUndo @tracemsg2 VioModeWait @tracemsg2 VioPopUp @tracemsg2 VioPrtSc @tracemsg2 VioPrtScToggle @tracemsg2 VioReadCellStr @tracemsg2 VioReadCharStr @tracemsg2 VioRegister @tracemsg2 VioRoute @tracemsg2 VioSavRedrawUndo @tracemsg2 VioSavRedrawWait @tracemsg2 VioScrLock @tracemsg2 VioScrollDn @tracemsg2 VioScrollLf @tracemsg2 VioScrollRt @tracemsg2 VioScrollUp @tracemsg2 VioScrUnLock @tracemsg2 VioSetAnsi @tracemsg2 VioSetCP @tracemsg2 VioSetCurPos @tracemsg2 VioSetCurType @tracemsg2 VioSetFont @tracemsg2 VioSetMode @tracemsg2 VioSetState @tracemsg2 VioShowBuf @tracemsg2 VioWrtCellStr @tracemsg2 VioWrtCharStr @tracemsg2 VioWrtCharStrAtt @tracemsg2 VioWrtNAttr @tracemsg2 VioWrtNCell @tracemsg2 VioWrtNChar @tracemsg2 VioWrtTTY _DATA ENDS _TEXT SEGMENT BYTE PUBLIC 'CODE' USE16 @tracecall2 VioDeRegister @tracecall2 VioEndPopUp @tracecall2 VioGetAnsi @tracecall2 VioGetBuf @tracecall2 VioGetConfig @tracecall2 VioGetCP @tracecall2 VioGetCurPos @tracecall2 VioGetCurType @tracecall2 VioGetFont @tracecall2 VioGetMode @tracecall2 VioGetPhysBuf @tracecall2 VioGetState @tracecall2 VioModeUndo @tracecall2 VioModeWait @tracecall2 VioPopUp @tracecall2 VioPrtSc @tracecall2 VioPrtScToggle @tracecall2 VioReadCellStr @tracecall2 VioReadCharStr @tracecall2 VioRegister @tracecall2 VioRoute @tracecall2 VioSavRedrawUndo @tracecall2 VioSavRedrawWait @tracecall2 VioScrLock @tracecall2 VioScrollDn @tracecall2 VioScrollLf @tracecall2 VioScrollRt @tracecall2 VioScrollUp @tracecall2 VioScrUnLock @tracecall2 VioSetAnsi @tracecall2 VioSetCP @tracecall2 VioSetCurPos @tracecall2 VioSetCurType @tracecall2 VioSetFont @tracecall2 VioSetMode @tracecall2 VioSetState @tracecall2 VioShowBuf @tracecall2 VioWrtCellStr @tracecall2 VioWrtCharStr @tracecall2 VioWrtCharStrAtt @tracecall2 VioWrtNAttr @tracecall2 VioWrtNCell @tracecall2 VioWrtNChar @tracecall2 VioWrtTTY _TEXT ends end
libsrc/_DEVELOPMENT/arch/sms/SMSlib/z80/asm_SMSlib_getMDKeysPressed.asm
jpoikela/z88dk
640
104778
<reponame>jpoikela/z88dk ; ************************************************** ; SMSlib - C programming library for the SMS/GG ; ( part of devkitSMS - github.com/sverx/devkitSMS ) ; ************************************************** INCLUDE "SMSlib_private.inc" SECTION code_clib SECTION code_SMSlib PUBLIC asm_SMSlib_getMDKeysPressed EXTERN __SMSlib_MDKeysStatus, __SMSlib_PreviousMDKeysStatus asm_SMSlib_getMDKeysPressed: ; unsigned int SMS_getMDKeysPressed (void) ; ; exit : hl = MD keys pressed ; ; uses : af, hl ld hl,(__SMSlib_MDKeysStatus) ld a,(__SMSlib_PreviousMDKeysStatus) cpl and l ld l,a ld a,(__SMSlib_PreviousMDKeysStatus+1) cpl and h ld h,a ret
Transynther/x86/_processed/AVXALIGN/_st_/i7-8650U_0xd2_notsx.log_16706_422.asm
ljhsiun2/medusa
9
25856
<filename>Transynther/x86/_processed/AVXALIGN/_st_/i7-8650U_0xd2_notsx.log_16706_422.asm .global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r8 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x2597, %r8 nop nop nop nop add $54867, %r12 mov (%r8), %r10d cmp %r11, %r11 lea addresses_WC_ht+0x11b97, %rdx clflush (%rdx) nop nop and $48740, %rax mov $0x6162636465666768, %rsi movq %rsi, %xmm4 vmovups %ymm4, (%rdx) nop nop nop nop xor $42988, %r11 lea addresses_normal_ht+0x1c0d7, %rsi xor %r8, %r8 movb $0x61, (%rsi) nop nop nop nop and $34797, %r12 lea addresses_WC_ht+0x4397, %rsi lea addresses_A_ht+0xc197, %rdi clflush (%rsi) nop nop dec %r12 mov $115, %rcx rep movsl nop nop nop cmp %rdx, %rdx lea addresses_WC_ht+0xe341, %rsi lea addresses_WC_ht+0x1e577, %rdi nop nop nop nop nop dec %rdx mov $127, %rcx rep movsq nop nop add $3409, %rsi lea addresses_A_ht+0x15071, %rdx nop nop nop add %r12, %r12 mov $0x6162636465666768, %r11 movq %r11, (%rdx) nop nop nop add %r8, %r8 lea addresses_UC_ht+0x18597, %r10 nop nop nop and %r8, %r8 movl $0x61626364, (%r10) nop nop nop cmp $58184, %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r8 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %rbp push %rdx push %rsi // Faulty Load lea addresses_D+0x18d97, %rbp nop cmp %rsi, %rsi mov (%rbp), %r10w lea oracles, %rsi and $0xff, %r10 shlq $12, %r10 mov (%rsi,%r10,1), %r10 pop %rsi pop %rdx pop %rbp pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'36': 16706} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
llvm-gcc-4.2-2.9/gcc/ada/par-labl.adb
vidkidz/crossbridge
1
16416
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P A R . L A B L -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ separate (Par) procedure Labl is Enclosing_Body_Or_Block : Node_Id; -- Innermost enclosing body or block statement Label_Decl_Node : Node_Id; -- Implicit label declaration node Defining_Ident_Node : Node_Id; -- Defining identifier node for implicit label declaration Next_Label_Elmt : Elmt_Id; -- Next element on label element list Label_Node : Node_Id; -- Next label node to process function Find_Enclosing_Body_Or_Block (N : Node_Id) return Node_Id; -- Find the innermost body or block that encloses N function Find_Enclosing_Body (N : Node_Id) return Node_Id; -- Find the innermost body that encloses N procedure Check_Distinct_Labels; -- Checks the rule in RM-5.1(11), which requires distinct identifiers -- for all the labels in a given body. procedure Find_Natural_Loops; -- Recognizes loops created by backward gotos, and rewrites the -- corresponding statements into a proper loop, for optimization -- purposes (for example, to control reclaiming local storage). --------------------------- -- Check_Distinct_Labels -- --------------------------- procedure Check_Distinct_Labels is Label_Id : constant Node_Id := Identifier (Label_Node); Enclosing_Body : constant Node_Id := Find_Enclosing_Body (Enclosing_Body_Or_Block); -- Innermost enclosing body Next_Other_Label_Elmt : Elmt_Id := First_Elmt (Label_List); -- Next element on label element list Other_Label : Node_Id; -- Next label node to process begin -- Loop through all the labels, and if we find some other label -- (i.e. not Label_Node) that has the same identifier, -- and whose innermost enclosing body is the same, -- then we have an error. -- Note that in the worst case, this is quadratic in the number -- of labels. However, labels are not all that common, and this -- is only called for explicit labels. -- ???Nonetheless, the efficiency could be improved. For example, -- call Labl for each body, rather than once per compilation. while Present (Next_Other_Label_Elmt) loop Other_Label := Node (Next_Other_Label_Elmt); exit when Label_Node = Other_Label; if Chars (Label_Id) = Chars (Identifier (Other_Label)) and then Enclosing_Body = Find_Enclosing_Body (Other_Label) then Error_Msg_Sloc := Sloc (Other_Label); Error_Msg_N ("& conflicts with label#", Label_Id); exit; end if; Next_Elmt (Next_Other_Label_Elmt); end loop; end Check_Distinct_Labels; ------------------------- -- Find_Enclosing_Body -- ------------------------- function Find_Enclosing_Body (N : Node_Id) return Node_Id is Result : Node_Id := N; begin -- This is the same as Find_Enclosing_Body_Or_Block, except -- that we skip block statements and accept statements, instead -- of stopping at them. while Present (Result) and then Nkind (Result) /= N_Entry_Body and then Nkind (Result) /= N_Task_Body and then Nkind (Result) /= N_Package_Body and then Nkind (Result) /= N_Subprogram_Body loop Result := Parent (Result); end loop; return Result; end Find_Enclosing_Body; ---------------------------------- -- Find_Enclosing_Body_Or_Block -- ---------------------------------- function Find_Enclosing_Body_Or_Block (N : Node_Id) return Node_Id is Result : Node_Id := Parent (N); begin -- Climb up the parent chain until we find a body or block while Present (Result) and then Nkind (Result) /= N_Accept_Statement and then Nkind (Result) /= N_Entry_Body and then Nkind (Result) /= N_Task_Body and then Nkind (Result) /= N_Package_Body and then Nkind (Result) /= N_Subprogram_Body and then Nkind (Result) /= N_Block_Statement loop Result := Parent (Result); end loop; return Result; end Find_Enclosing_Body_Or_Block; ------------------------ -- Find_Natural_Loops -- ------------------------ procedure Find_Natural_Loops is Node_List : constant Elist_Id := New_Elmt_List; N : Elmt_Id; Succ : Elmt_Id; function Goto_Id (Goto_Node : Node_Id) return Name_Id; -- Find Name_Id of goto statement, which may be an expanded name function Matches (Label_Node : Node_Id; Goto_Node : Node_Id) return Boolean; -- A label and a goto are candidates for a loop if the names match, -- and both nodes appear in the same body. In addition, both must -- appear in the same statement list. If they are not in the same -- statement list, the goto is from within an nested structure, and -- the label is not a header. We ignore the case where the goto is -- within a conditional structure, and capture only infinite loops. procedure Merge; -- Merge labels and goto statements in order of increasing sloc value. -- Discard labels of loop and block statements. procedure No_Header (N : Elmt_Id); -- The label N is known not to be a loop header. Scan forward and -- remove all subsequent goto's that may have this node as a target. procedure Process_Goto (N : Elmt_Id); -- N is a forward jump. Scan forward and remove all subsequent goto's -- that may have the same target, to preclude spurious loops. procedure Rewrite_As_Loop (Loop_Header : Node_Id; Loop_End : Node_Id); -- Given a label and a backwards goto, rewrite intervening statements -- as a loop. Remove the label from the node list, and rewrite the -- goto with the body of the new loop. procedure Try_Loop (N : Elmt_Id); -- N is a label that may be a loop header. Scan forward to find some -- backwards goto with which to make a loop. Do nothing if there is -- an intervening label that is not part of a loop, or more than one -- goto with this target. ------------- -- Goto_Id -- ------------- function Goto_Id (Goto_Node : Node_Id) return Name_Id is begin if Nkind (Name (Goto_Node)) = N_Identifier then return Chars (Name (Goto_Node)); elsif Nkind (Name (Goto_Node)) = N_Selected_Component then return Chars (Selector_Name (Name (Goto_Node))); else -- In case of error, return Id that can't match anything return Name_Null; end if; end Goto_Id; ------------- -- Matches -- ------------- function Matches (Label_Node : Node_Id; Goto_Node : Node_Id) return Boolean is begin return Chars (Identifier (Label_Node)) = Goto_Id (Goto_Node) and then Find_Enclosing_Body (Label_Node) = Find_Enclosing_Body (Goto_Node); end Matches; ----------- -- Merge -- ----------- procedure Merge is L1 : Elmt_Id; G1 : Elmt_Id; begin L1 := First_Elmt (Label_List); G1 := First_Elmt (Goto_List); while Present (L1) and then Present (G1) loop if Sloc (Node (L1)) < Sloc (Node (G1)) then -- Optimization: remove labels of loops and blocks, which -- play no role in what follows. if Nkind (Node (L1)) /= N_Loop_Statement and then Nkind (Node (L1)) /= N_Block_Statement then Append_Elmt (Node (L1), Node_List); end if; Next_Elmt (L1); else Append_Elmt (Node (G1), Node_List); Next_Elmt (G1); end if; end loop; while Present (L1) loop Append_Elmt (Node (L1), Node_List); Next_Elmt (L1); end loop; while Present (G1) loop Append_Elmt (Node (G1), Node_List); Next_Elmt (G1); end loop; end Merge; --------------- -- No_Header -- --------------- procedure No_Header (N : Elmt_Id) is S1, S2 : Elmt_Id; begin S1 := Next_Elmt (N); while Present (S1) loop S2 := Next_Elmt (S1); if Nkind (Node (S1)) = N_Goto_Statement and then Matches (Node (N), Node (S1)) then Remove_Elmt (Node_List, S1); end if; S1 := S2; end loop; end No_Header; ------------------ -- Process_Goto -- ------------------ procedure Process_Goto (N : Elmt_Id) is Goto1 : constant Node_Id := Node (N); Goto2 : Node_Id; S, S1 : Elmt_Id; begin S := Next_Elmt (N); while Present (S) loop S1 := Next_Elmt (S); Goto2 := Node (S); if Nkind (Goto2) = N_Goto_Statement and then Goto_Id (Goto1) = Goto_Id (Goto2) and then Find_Enclosing_Body (Goto1) = Find_Enclosing_Body (Goto2) then -- Goto2 may have the same target, remove it from -- consideration. Remove_Elmt (Node_List, S); end if; S := S1; end loop; end Process_Goto; --------------------- -- Rewrite_As_Loop -- --------------------- procedure Rewrite_As_Loop (Loop_Header : Node_Id; Loop_End : Node_Id) is Loop_Body : constant List_Id := New_List; Loop_Stmt : constant Node_Id := New_Node (N_Loop_Statement, Sloc (Loop_Header)); Stat : Node_Id; Next_Stat : Node_Id; begin Stat := Next (Loop_Header); while Stat /= Loop_End loop Next_Stat := Next (Stat); Remove (Stat); Append (Stat, Loop_Body); Stat := Next_Stat; end loop; Set_Statements (Loop_Stmt, Loop_Body); Set_Identifier (Loop_Stmt, Identifier (Loop_Header)); Remove (Loop_Header); Rewrite (Loop_End, Loop_Stmt); Error_Msg_N ("code between label and backwards goto rewritten as loop?", Loop_End); end Rewrite_As_Loop; -------------- -- Try_Loop -- -------------- procedure Try_Loop (N : Elmt_Id) is Source : Elmt_Id; Found : Boolean := False; S1 : Elmt_Id; begin S1 := Next_Elmt (N); while Present (S1) loop if Nkind (Node (S1)) = N_Goto_Statement and then Matches (Node (N), Node (S1)) then if not Found then if Parent (Node (N)) = Parent (Node (S1)) then Source := S1; Found := True; else -- The goto is within some nested structure No_Header (N); return; end if; else -- More than one goto with the same target No_Header (N); return; end if; elsif Nkind (Node (S1)) = N_Label and then not Found then -- Intervening label before possible end of loop. Current -- label is not a candidate. This is conservative, because -- the label might not be the target of any jumps, but not -- worth dealing with useless labels! No_Header (N); return; else -- If the node is a loop_statement, it corresponds to a -- label-goto pair rewritten as a loop. Continue forward scan. null; end if; Next_Elmt (S1); end loop; if Found then Rewrite_As_Loop (Node (N), Node (Source)); Remove_Elmt (Node_List, N); Remove_Elmt (Node_List, Source); end if; end Try_Loop; begin -- Start of processing for Find_Natural_Loops Merge; N := First_Elmt (Node_List); while Present (N) loop Succ := Next_Elmt (N); if Nkind (Node (N)) = N_Label then if No (Succ) then exit; elsif Nkind (Node (Succ)) = N_Label then Try_Loop (Succ); -- If a loop was found, the label has been removed, and -- the following goto rewritten as the loop body. Succ := Next_Elmt (N); if Nkind (Node (Succ)) = N_Label then -- Following label was not removed, so current label -- is not a candidate header. No_Header (N); else -- Following label was part of inner loop. Current -- label is still a candidate. Try_Loop (N); Succ := Next_Elmt (N); end if; elsif Nkind (Node (Succ)) = N_Goto_Statement then Try_Loop (N); Succ := Next_Elmt (N); end if; elsif Nkind (Node (N)) = N_Goto_Statement then Process_Goto (N); Succ := Next_Elmt (N); end if; N := Succ; end loop; end Find_Natural_Loops; -- Start of processing for Par.Labl begin Next_Label_Elmt := First_Elmt (Label_List); while Present (Next_Label_Elmt) loop Label_Node := Node (Next_Label_Elmt); if not Comes_From_Source (Label_Node) then goto Next_Label; end if; -- Find the innermost enclosing body or block, which is where -- we need to implicitly declare this label Enclosing_Body_Or_Block := Find_Enclosing_Body_Or_Block (Label_Node); -- If we didn't find a parent, then the label in question never got -- hooked into a reasonable declarative part. This happens only in -- error situations, and we simply ignore the entry (we aren't going -- to get into the semantics in any case given the error). if Present (Enclosing_Body_Or_Block) then Check_Distinct_Labels; -- Now create the implicit label declaration node and its -- corresponding defining identifier. Note that the defining -- occurrence of a label is the implicit label declaration that -- we are creating. The label itself is an applied occurrence. Label_Decl_Node := New_Node (N_Implicit_Label_Declaration, Sloc (Label_Node)); Defining_Ident_Node := New_Entity (N_Defining_Identifier, Sloc (Identifier (Label_Node))); Set_Chars (Defining_Ident_Node, Chars (Identifier (Label_Node))); Set_Defining_Identifier (Label_Decl_Node, Defining_Ident_Node); Set_Label_Construct (Label_Decl_Node, Label_Node); -- The following makes sure that Comes_From_Source is appropriately -- set for the entity, depending on whether the label appeared in -- the source explicitly or not. Set_Comes_From_Source (Defining_Ident_Node, Comes_From_Source (Identifier (Label_Node))); -- Now attach the implicit label declaration to the appropriate -- declarative region, creating a declaration list if none exists if No (Declarations (Enclosing_Body_Or_Block)) then Set_Declarations (Enclosing_Body_Or_Block, New_List); end if; Append (Label_Decl_Node, Declarations (Enclosing_Body_Or_Block)); end if; <<Next_Label>> Next_Elmt (Next_Label_Elmt); end loop; Find_Natural_Loops; end Labl;
tools-src/gnu/gcc/gcc/ada/5qtaprop.adb
enfoTek/tomato.linksys.e2000.nvram-mod
80
27164
------------------------------------------------------------------------------ -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 1991-2001, Florida State University -- -- -- -- 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 2, 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. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNARL; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ -- RT GNU/Linux version -- ???? Later, look at what we might want to provide for interrupt -- management. pragma Suppress (All_Checks); pragma Polling (Off); -- Turn off polling, we do not want ATC polling to take place during -- tasking operations. It causes infinite loops and other problems. with System.Machine_Code; -- used for Asm with System.OS_Interface; -- used for various types, constants, and operations with System.OS_Primitives; -- used for Delay_Modes with System.Parameters; -- used for Size_Type with System.Storage_Elements; with System.Tasking; -- used for Ada_Task_Control_Block -- Task_ID with Ada.Unchecked_Conversion; package body System.Task_Primitives.Operations is use System.Machine_Code, System.OS_Interface, System.OS_Primitives, System.Parameters, System.Tasking, System.Storage_Elements; -------------------------------- -- RT GNU/Linux specific Data -- -------------------------------- -- Define two important parameters necessary for a GNU/Linux kernel module. -- Any module that is going to be loaded into the kernel space needs these -- parameters. Mod_Use_Count : Integer; pragma Export (C, Mod_Use_Count, "mod_use_count_"); -- for module usage tracking by the kernel type Aliased_String is array (Positive range <>) of aliased Character; pragma Convention (C, Aliased_String); Kernel_Version : constant Aliased_String := "2.0.33" & ASCII.Nul; pragma Export (C, Kernel_Version, "kernel_version"); -- So that insmod can find the version number. -- The following procedures have their name specified by the GNU/Linux -- module loader. Note that they simply correspond to adainit/adafinal. function Init_Module return Integer; pragma Export (C, Init_Module, "init_module"); procedure Cleanup_Module; pragma Export (C, Cleanup_Module, "cleanup_module"); ---------------- -- Local Data -- ---------------- LF : constant String := ASCII.LF & ASCII.Nul; LFHT : constant String := ASCII.LF & ASCII.HT; -- used in inserted assembly code Max_Tasks : constant := 10; -- ??? Eventually, this should probably be in System.Parameters. Known_Tasks : array (0 .. Max_Tasks) of Task_ID; -- Global array of tasks read by gdb, and updated by Create_Task and -- Finalize_TCB. It's from System.Tasking.Debug. We moved it here to -- cut the dependence on that package. Consider moving it here or to -- this package specification, permanently???? Max_Sensible_Delay : constant RTIME := 365 * 24 * 60 * 60 * RT_TICKS_PER_SEC; -- Max of one year delay, needed to prevent exceptions for large -- delay values. It seems unlikely that any test will notice this -- restriction. -- ??? This is really declared in System.OS_Primitives, -- and the type is Duration, here its type is RTIME. Tick_Count : constant := RT_TICKS_PER_SEC / 20; Nano_Count : constant := 50_000_000; -- two constants used in conversions between RTIME and Duration. Addr_Bytes : constant Storage_Offset := System.Address'Max_Size_In_Storage_Elements; -- number of bytes needed for storing an address. Guess : constant RTIME := 10; -- an approximate amount of RTIME used in scheduler to awake a task having -- its resume time within 'current time + Guess' -- The value of 10 is estimated here and may need further refinement TCB_Array : array (0 .. Max_Tasks) of aliased Restricted_Ada_Task_Control_Block (Entry_Num => 0); pragma Volatile_Components (TCB_Array); Available_TCBs : Task_ID; pragma Atomic (Available_TCBs); -- Head of linear linked list of available TCB's, linked using TCB's -- LL.Next. This list is Initialized to contain a fixed number of tasks, -- when the runtime system starts up. Current_Task : Task_ID; pragma Export (C, Current_Task, "current_task"); pragma Atomic (Current_Task); -- This is the task currently running. We need the pragma here to specify -- the link-name for Current_Task is "current_task", rather than the long -- name (including the package name) that the Ada compiler would normally -- generate. "current_task" is referenced in procedure Rt_Switch_To below Idle_Task : aliased Restricted_Ada_Task_Control_Block (Entry_Num => 0); -- Tail of the circular queue of ready to run tasks. Scheduler_Idle : Boolean := False; -- True when the scheduler is idle (no task other than the idle task -- is on the ready queue). In_Elab_Code : Boolean := True; -- True when we are elaborating our application. -- Init_Module will set this flag to false and never revert it. Timer_Queue : aliased Restricted_Ada_Task_Control_Block (Entry_Num => 0); -- Header of the queue of delayed real-time tasks. -- Timer_Queue.LL has to be initialized properly before being used Timer_Expired : Boolean := False; -- flag to show whether the Timer_Queue needs to be checked -- when it becomes true, it means there is a task in the -- Timer_Queue having to be awakened and be moved to ready queue Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. -- Once initialized, this behaves as a constant. -- In the current implementation, this is the task assigned permanently -- as the regular GNU/Linux kernel. All_Tasks_L : aliased RTS_Lock; -- See comments on locking rules in System.Tasking (spec). -- The followings are internal configuration constants needed. Next_Serial_Number : Task_Serial_Number := 100; pragma Volatile (Next_Serial_Number); -- We start at 100, to reserve some special values for -- using in error checking. GNU_Linux_Irq_State : Integer := 0; -- This needs comments ??? type Duration_As_Integer is delta 1.0 range -2.0**(Duration'Size - 1) .. 2.0**(Duration'Size - 1) - 1.0; -- used for output RTIME value during debugging type Address_Ptr is access all System.Address; pragma Convention (C, Address_Ptr); -------------------------------- -- Local conversion functions -- -------------------------------- function To_Task_ID is new Ada.Unchecked_Conversion (System.Address, Task_ID); function To_Address is new Ada.Unchecked_Conversion (Task_ID, System.Address); function RTIME_To_D_Int is new Ada.Unchecked_Conversion (RTIME, Duration_As_Integer); function Raw_RTIME is new Ada.Unchecked_Conversion (Duration, RTIME); function Raw_Duration is new Ada.Unchecked_Conversion (RTIME, Duration); function To_Duration (T : RTIME) return Duration; pragma Inline (To_Duration); function To_RTIME (D : Duration) return RTIME; pragma Inline (To_RTIME); function To_Integer is new Ada.Unchecked_Conversion (System.Parameters.Size_Type, Integer); function To_Address_Ptr is new Ada.Unchecked_Conversion (System.Address, Address_Ptr); function To_RTS_Lock_Ptr is new Ada.Unchecked_Conversion (Lock_Ptr, RTS_Lock_Ptr); ----------------------------------- -- Local Subprogram Declarations -- ----------------------------------- procedure Rt_Switch_To (Tsk : Task_ID); pragma Inline (Rt_Switch_To); -- switch from the 'current_task' to 'Tsk' -- and 'Tsk' then becomes 'current_task' procedure R_Save_Flags (F : out Integer); pragma Inline (R_Save_Flags); -- save EFLAGS register to 'F' procedure R_Restore_Flags (F : Integer); pragma Inline (R_Restore_Flags); -- restore EFLAGS register from 'F' procedure R_Cli; pragma Inline (R_Cli); -- disable interrupts procedure R_Sti; pragma Inline (R_Sti); -- enable interrupts procedure Timer_Wrapper; -- the timer handler. It sets Timer_Expired flag to True and -- then calls Rt_Schedule procedure Rt_Schedule; -- the scheduler procedure Insert_R (T : Task_ID); pragma Inline (Insert_R); -- insert 'T' into the tail of the ready queue for its active -- priority -- if original queue is 6 5 4 4 3 2 and T has priority of 4 -- then after T is inserted the queue becomes 6 5 4 4 T 3 2 procedure Insert_RF (T : Task_ID); pragma Inline (Insert_RF); -- insert 'T' into the front of the ready queue for its active -- priority -- if original queue is 6 5 4 4 3 2 and T has priority of 4 -- then after T is inserted the queue becomes 6 5 T 4 4 3 2 procedure Delete_R (T : Task_ID); pragma Inline (Delete_R); -- delete 'T' from the ready queue. If 'T' is not in any queue -- the operation has no effect procedure Insert_T (T : Task_ID); pragma Inline (Insert_T); -- insert 'T' into the waiting queue according to its Resume_Time. -- If there are tasks in the waiting queue that have the same -- Resume_Time as 'T', 'T' is then inserted into the queue for -- its active priority procedure Delete_T (T : Task_ID); pragma Inline (Delete_T); -- delete 'T' from the waiting queue. procedure Move_Top_Task_From_Timer_Queue_To_Ready_Queue; pragma Inline (Move_Top_Task_From_Timer_Queue_To_Ready_Queue); -- remove the task in the front of the waiting queue and insert it -- into the tail of the ready queue for its active priority ------------------------- -- Local Subprograms -- ------------------------- procedure Rt_Switch_To (Tsk : Task_ID) is begin pragma Debug (Printk ("procedure Rt_Switch_To called" & LF)); Asm ( "pushl %%eax" & LFHT & "pushl %%ebp" & LFHT & "pushl %%edi" & LFHT & "pushl %%esi" & LFHT & "pushl %%edx" & LFHT & "pushl %%ecx" & LFHT & "pushl %%ebx" & LFHT & "movl current_task, %%edx" & LFHT & "cmpl $0, 36(%%edx)" & LFHT & -- 36 is hard-coded, 36(%%edx) is actually -- Current_Task.Common.LL.Uses_Fp "jz 25f" & LFHT & "sub $108,%%esp" & LFHT & "fsave (%%esp)" & LFHT & "25: pushl $1f" & LFHT & "movl %%esp, 32(%%edx)" & LFHT & -- 32 is hard-coded, 32(%%edx) is actually -- Current_Task.Common.LL.Stack "movl 32(%%ecx), %%esp" & LFHT & -- 32 is hard-coded, 32(%%ecx) is actually Tsk.Common.LL.Stack. -- Tsk is the task to be switched to "movl %%ecx, current_task" & LFHT & "ret" & LFHT & "1: cmpl $0, 36(%%ecx)" & LFHT & -- 36(%%exc) is Tsk.Common.LL.Stack (hard coded) "jz 26f" & LFHT & "frstor (%%esp)" & LFHT & "add $108,%%esp" & LFHT & "26: popl %%ebx" & LFHT & "popl %%ecx" & LFHT & "popl %%edx" & LFHT & "popl %%esi" & LFHT & "popl %%edi" & LFHT & "popl %%ebp" & LFHT & "popl %%eax", Outputs => No_Output_Operands, Inputs => Task_ID'Asm_Input ("c", Tsk), Clobber => "cx", Volatile => True); end Rt_Switch_To; procedure R_Save_Flags (F : out Integer) is begin Asm ( "pushfl" & LFHT & "popl %0", Outputs => Integer'Asm_Output ("=g", F), Inputs => No_Input_Operands, Clobber => "memory", Volatile => True); end R_Save_Flags; procedure R_Restore_Flags (F : Integer) is begin Asm ( "pushl %0" & LFHT & "popfl", Outputs => No_Output_Operands, Inputs => Integer'Asm_Input ("g", F), Clobber => "memory", Volatile => True); end R_Restore_Flags; procedure R_Sti is begin Asm ( "sti", Outputs => No_Output_Operands, Inputs => No_Input_Operands, Clobber => "memory", Volatile => True); end R_Sti; procedure R_Cli is begin Asm ( "cli", Outputs => No_Output_Operands, Inputs => No_Input_Operands, Clobber => "memory", Volatile => True); end R_Cli; -- A wrapper for Rt_Schedule, works as the timer handler procedure Timer_Wrapper is begin pragma Debug (Printk ("procedure Timer_Wrapper called" & LF)); Timer_Expired := True; Rt_Schedule; end Timer_Wrapper; procedure Rt_Schedule is Now : RTIME; Top_Task : Task_ID; Flags : Integer; procedure Debug_Timer_Queue; -- Check the state of the Timer Queue. procedure Debug_Timer_Queue is begin if Timer_Queue.Common.LL.Succ /= Timer_Queue'Address then Printk ("Timer_Queue not empty" & LF); end if; if To_Task_ID (Timer_Queue.Common.LL.Succ).Common.LL.Resume_Time < Now + Guess then Printk ("and need to move top task to ready queue" & LF); end if; end Debug_Timer_Queue; begin pragma Debug (Printk ("procedure Rt_Schedule called" & LF)); -- Scheduler_Idle means that this call comes from an interrupt -- handler (e.g timer) that interrupted the idle loop below. if Scheduler_Idle then return; end if; <<Idle>> R_Save_Flags (Flags); R_Cli; Scheduler_Idle := False; if Timer_Expired then pragma Debug (Printk ("Timer expired" & LF)); Timer_Expired := False; -- Check for expired time delays. Now := Rt_Get_Time; -- Need another (circular) queue for delayed tasks, this one ordered -- by wakeup time, so the one at the front has the earliest resume -- time. Wake up all the tasks sleeping on time delays that should -- be awakened at this time. -- ??? This is not very good, since we may waste time here waking -- up a bunch of lower priority tasks, adding to the blocking time -- of higher priority ready tasks, but we don't see how to get -- around this without adding more wasted time elsewhere. pragma Debug (Debug_Timer_Queue); while Timer_Queue.Common.LL.Succ /= Timer_Queue'Address and then To_Task_ID (Timer_Queue.Common.LL.Succ).Common.LL.Resume_Time < Now + Guess loop To_Task_ID (Timer_Queue.Common.LL.Succ).Common.LL.State := RT_TASK_READY; Move_Top_Task_From_Timer_Queue_To_Ready_Queue; end loop; -- Arm the timer if necessary. -- ??? This may be wasteful, if the tasks on the timer queue are -- of lower priority than the current task's priority. The problem -- is that we can't tell this without scanning the whole timer -- queue. This scanning takes extra time. if Timer_Queue.Common.LL.Succ /= Timer_Queue'Address then -- Timer_Queue is not empty, so set the timer to interrupt at -- the next resume time. The Wakeup procedure must also do this, -- and must do it while interrupts are disabled so that there is -- no danger of interleaving with this code. Rt_Set_Timer (To_Task_ID (Timer_Queue.Common.LL.Succ).Common.LL.Resume_Time); else Rt_No_Timer; end if; end if; Top_Task := To_Task_ID (Idle_Task.Common.LL.Succ); -- If the ready queue is empty, the kernel has to wait until the timer -- or another interrupt makes a task ready. if Top_Task = To_Task_ID (Idle_Task'Address) then Scheduler_Idle := True; R_Restore_Flags (Flags); pragma Debug (Printk ("!!!kernel idle!!!" & LF)); goto Idle; end if; if Top_Task = Current_Task then pragma Debug (Printk ("Rt_Schedule: Top_Task = Current_Task" & LF)); -- if current task continues, just return. R_Restore_Flags (Flags); return; end if; if Top_Task = Environment_Task_ID then pragma Debug (Printk ("Rt_Schedule: Top_Task = Environment_Task" & LF)); -- If there are no RT tasks ready, we execute the regular -- GNU/Linux kernel, and allow the regular GNU/Linux interrupt -- handlers to preempt the current task again. if not In_Elab_Code then SFIF := GNU_Linux_Irq_State; end if; elsif Current_Task = Environment_Task_ID then pragma Debug (Printk ("Rt_Schedule: Current_Task = Environment_Task" & LF)); -- We are going to preempt the regular GNU/Linux kernel to -- execute an RT task, so don't allow the regular GNU/Linux -- interrupt handlers to preempt the current task any more. GNU_Linux_Irq_State := SFIF; SFIF := 0; end if; Top_Task.Common.LL.State := RT_TASK_READY; Rt_Switch_To (Top_Task); R_Restore_Flags (Flags); end Rt_Schedule; procedure Insert_R (T : Task_ID) is Q : Task_ID := To_Task_ID (Idle_Task.Common.LL.Succ); begin pragma Debug (Printk ("procedure Insert_R called" & LF)); pragma Assert (T.Common.LL.Succ = To_Address (T)); pragma Assert (T.Common.LL.Pred = To_Address (T)); -- T is inserted in the queue between a task that has higher -- or the same Active_Priority as T and a task that has lower -- Active_Priority than T while Q /= To_Task_ID (Idle_Task'Address) and then T.Common.LL.Active_Priority <= Q.Common.LL.Active_Priority loop Q := To_Task_ID (Q.Common.LL.Succ); end loop; -- Q is successor of T T.Common.LL.Succ := To_Address (Q); T.Common.LL.Pred := Q.Common.LL.Pred; To_Task_ID (T.Common.LL.Pred).Common.LL.Succ := To_Address (T); Q.Common.LL.Pred := To_Address (T); end Insert_R; procedure Insert_RF (T : Task_ID) is Q : Task_ID := To_Task_ID (Idle_Task.Common.LL.Succ); begin pragma Debug (Printk ("procedure Insert_RF called" & LF)); pragma Assert (T.Common.LL.Succ = To_Address (T)); pragma Assert (T.Common.LL.Pred = To_Address (T)); -- T is inserted in the queue between a task that has higher -- Active_Priority as T and a task that has lower or the same -- Active_Priority as T while Q /= To_Task_ID (Idle_Task'Address) and then T.Common.LL.Active_Priority < Q.Common.LL.Active_Priority loop Q := To_Task_ID (Q.Common.LL.Succ); end loop; -- Q is successor of T T.Common.LL.Succ := To_Address (Q); T.Common.LL.Pred := Q.Common.LL.Pred; To_Task_ID (T.Common.LL.Pred).Common.LL.Succ := To_Address (T); Q.Common.LL.Pred := To_Address (T); end Insert_RF; procedure Delete_R (T : Task_ID) is Tpred : constant Task_ID := To_Task_ID (T.Common.LL.Pred); Tsucc : constant Task_ID := To_Task_ID (T.Common.LL.Succ); begin pragma Debug (Printk ("procedure Delete_R called" & LF)); -- checking whether T is in the queue is not necessary because -- if T is not in the queue, following statements changes -- nothing. But T cannot be in the Timer_Queue, otherwise -- activate the check below, note that checking whether T is -- in a queue is a relatively expensive operation Tpred.Common.LL.Succ := To_Address (Tsucc); Tsucc.Common.LL.Pred := To_Address (Tpred); T.Common.LL.Succ := To_Address (T); T.Common.LL.Pred := To_Address (T); end Delete_R; procedure Insert_T (T : Task_ID) is Q : Task_ID := To_Task_ID (Timer_Queue.Common.LL.Succ); begin pragma Debug (Printk ("procedure Insert_T called" & LF)); pragma Assert (T.Common.LL.Succ = To_Address (T)); while Q /= To_Task_ID (Timer_Queue'Address) and then T.Common.LL.Resume_Time > Q.Common.LL.Resume_Time loop Q := To_Task_ID (Q.Common.LL.Succ); end loop; -- Q is the task that has Resume_Time equal to or greater than that -- of T. If they have the same Resume_Time, continue looking for the -- location T is to be inserted using its Active_Priority while Q /= To_Task_ID (Timer_Queue'Address) and then T.Common.LL.Resume_Time = Q.Common.LL.Resume_Time loop exit when T.Common.LL.Active_Priority > Q.Common.LL.Active_Priority; Q := To_Task_ID (Q.Common.LL.Succ); end loop; -- Q is successor of T T.Common.LL.Succ := To_Address (Q); T.Common.LL.Pred := Q.Common.LL.Pred; To_Task_ID (T.Common.LL.Pred).Common.LL.Succ := To_Address (T); Q.Common.LL.Pred := To_Address (T); end Insert_T; procedure Delete_T (T : Task_ID) is Tpred : constant Task_ID := To_Task_ID (T.Common.LL.Pred); Tsucc : constant Task_ID := To_Task_ID (T.Common.LL.Succ); begin pragma Debug (Printk ("procedure Delete_T called" & LF)); pragma Assert (T /= To_Task_ID (Timer_Queue'Address)); Tpred.Common.LL.Succ := To_Address (Tsucc); Tsucc.Common.LL.Pred := To_Address (Tpred); T.Common.LL.Succ := To_Address (T); T.Common.LL.Pred := To_Address (T); end Delete_T; procedure Move_Top_Task_From_Timer_Queue_To_Ready_Queue is Top_Task : Task_ID := To_Task_ID (Timer_Queue.Common.LL.Succ); begin pragma Debug (Printk ("procedure Move_Top_Task called" & LF)); if Top_Task /= To_Task_ID (Timer_Queue'Address) then Delete_T (Top_Task); Top_Task.Common.LL.State := RT_TASK_READY; Insert_R (Top_Task); end if; end Move_Top_Task_From_Timer_Queue_To_Ready_Queue; ---------- -- Self -- ---------- function Self return Task_ID is begin pragma Debug (Printk ("function Self called" & LF)); return Current_Task; end Self; --------------------- -- Initialize_Lock -- --------------------- procedure Initialize_Lock (Prio : System.Any_Priority; L : access Lock) is begin pragma Debug (Printk ("procedure Initialize_Lock called" & LF)); L.Ceiling_Priority := Prio; L.Owner := System.Null_Address; end Initialize_Lock; procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level) is begin pragma Debug (Printk ("procedure Initialize_Lock (RTS) called" & LF)); L.Ceiling_Priority := System.Any_Priority'Last; L.Owner := System.Null_Address; end Initialize_Lock; ------------------- -- Finalize_Lock -- ------------------- procedure Finalize_Lock (L : access Lock) is begin pragma Debug (Printk ("procedure Finalize_Lock called" & LF)); null; end Finalize_Lock; procedure Finalize_Lock (L : access RTS_Lock) is begin pragma Debug (Printk ("procedure Finalize_Lock (RTS) called" & LF)); null; end Finalize_Lock; ---------------- -- Write_Lock -- ---------------- procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is Prio : constant System.Any_Priority := Current_Task.Common.LL.Active_Priority; begin pragma Debug (Printk ("procedure Write_Lock called" & LF)); Ceiling_Violation := False; if Prio > L.Ceiling_Priority then -- Ceiling violation. -- This should never happen, unless something is seriously -- wrong with task T or the entire run-time system. -- ???? extreme error recovery, e.g. shut down the system or task Ceiling_Violation := True; pragma Debug (Printk ("Ceiling Violation in Write_Lock" & LF)); return; end if; L.Pre_Locking_Priority := Prio; L.Owner := To_Address (Current_Task); Current_Task.Common.LL.Active_Priority := L.Ceiling_Priority; if Current_Task.Common.LL.Outer_Lock = null then -- If this lock is not nested, record a pointer to it. Current_Task.Common.LL.Outer_Lock := To_RTS_Lock_Ptr (L.all'Unchecked_Access); end if; end Write_Lock; procedure Write_Lock (L : access RTS_Lock) is Prio : constant System.Any_Priority := Current_Task.Common.LL.Active_Priority; begin pragma Debug (Printk ("procedure Write_Lock (RTS) called" & LF)); if Prio > L.Ceiling_Priority then -- Ceiling violation. -- This should never happen, unless something is seriously -- wrong with task T or the entire runtime system. -- ???? extreme error recovery, e.g. shut down the system or task Printk ("Ceiling Violation in Write_Lock (RTS)" & LF); return; end if; L.Pre_Locking_Priority := Prio; L.Owner := To_Address (Current_Task); Current_Task.Common.LL.Active_Priority := L.Ceiling_Priority; if Current_Task.Common.LL.Outer_Lock = null then Current_Task.Common.LL.Outer_Lock := L.all'Unchecked_Access; end if; end Write_Lock; procedure Write_Lock (T : Task_ID) is Prio : constant System.Any_Priority := Current_Task.Common.LL.Active_Priority; begin pragma Debug (Printk ("procedure Write_Lock (Task_ID) called" & LF)); if Prio > T.Common.LL.L.Ceiling_Priority then -- Ceiling violation. -- This should never happen, unless something is seriously -- wrong with task T or the entire runtime system. -- ???? extreme error recovery, e.g. shut down the system or task Printk ("Ceiling Violation in Write_Lock (Task)" & LF); return; end if; T.Common.LL.L.Pre_Locking_Priority := Prio; T.Common.LL.L.Owner := To_Address (Current_Task); Current_Task.Common.LL.Active_Priority := T.Common.LL.L.Ceiling_Priority; if Current_Task.Common.LL.Outer_Lock = null then Current_Task.Common.LL.Outer_Lock := T.Common.LL.L'Access; end if; end Write_Lock; --------------- -- Read_Lock -- --------------- procedure Read_Lock (L : access Lock; Ceiling_Violation : out Boolean) is begin pragma Debug (Printk ("procedure Read_Lock called" & LF)); Write_Lock (L, Ceiling_Violation); end Read_Lock; ------------ -- Unlock -- ------------ procedure Unlock (L : access Lock) is Flags : Integer; begin pragma Debug (Printk ("procedure Unlock called" & LF)); if L.Owner /= To_Address (Current_Task) then -- ...error recovery null; Printk ("The caller is not the owner of the lock" & LF); return; end if; L.Owner := System.Null_Address; -- Now that the lock is released, lower own priority, if Current_Task.Common.LL.Outer_Lock = To_RTS_Lock_Ptr (L.all'Unchecked_Access) then -- This lock is the outer-most one, reset own priority to -- Current_Priority; Current_Task.Common.LL.Active_Priority := Current_Task.Common.Current_Priority; Current_Task.Common.LL.Outer_Lock := null; else -- If this lock is nested, pop the old active priority. Current_Task.Common.LL.Active_Priority := L.Pre_Locking_Priority; end if; -- Reschedule the task if necessary. Note we only need to reschedule -- the task if its Active_Priority becomes less than the one following -- it. The check depends on the fact that Environment_Task (tail of -- the ready queue) has the lowest Active_Priority if Current_Task.Common.LL.Active_Priority < To_Task_ID (Current_Task.Common.LL.Succ).Common.LL.Active_Priority then R_Save_Flags (Flags); R_Cli; Delete_R (Current_Task); Insert_RF (Current_Task); R_Restore_Flags (Flags); Rt_Schedule; end if; end Unlock; procedure Unlock (L : access RTS_Lock) is Flags : Integer; begin pragma Debug (Printk ("procedure Unlock (RTS_Lock) called" & LF)); if L.Owner /= To_Address (Current_Task) then null; Printk ("The caller is not the owner of the lock" & LF); return; end if; L.Owner := System.Null_Address; if Current_Task.Common.LL.Outer_Lock = L.all'Unchecked_Access then Current_Task.Common.LL.Active_Priority := Current_Task.Common.Current_Priority; Current_Task.Common.LL.Outer_Lock := null; else Current_Task.Common.LL.Active_Priority := L.Pre_Locking_Priority; end if; -- Reschedule the task if necessary if Current_Task.Common.LL.Active_Priority < To_Task_ID (Current_Task.Common.LL.Succ).Common.LL.Active_Priority then R_Save_Flags (Flags); R_Cli; Delete_R (Current_Task); Insert_RF (Current_Task); R_Restore_Flags (Flags); Rt_Schedule; end if; end Unlock; procedure Unlock (T : Task_ID) is begin pragma Debug (Printk ("procedure Unlock (Task_ID) called" & LF)); Unlock (T.Common.LL.L'Access); end Unlock; ----------- -- Sleep -- ----------- -- Unlock Self_ID.Common.LL.L and suspend Self_ID, atomically. -- Before return, lock Self_ID.Common.LL.L again -- Self_ID can only be reactivated by calling Wakeup. -- Unlock code is repeated intentionally. procedure Sleep (Self_ID : Task_ID; Reason : ST.Task_States) is Flags : Integer; begin pragma Debug (Printk ("procedure Sleep called" & LF)); -- Note that Self_ID is actually Current_Task, that is, only the -- task that is running can put itself into sleep. To preserve -- consistency, we use Self_ID throughout the code here Self_ID.Common.State := Reason; Self_ID.Common.LL.State := RT_TASK_DORMANT; R_Save_Flags (Flags); R_Cli; Delete_R (Self_ID); -- Arrange to unlock Self_ID's ATCB lock. The following check -- may be unnecessary because the specification of Sleep says -- the caller shoud hold its own ATCB lock before calling Sleep if Self_ID.Common.LL.L.Owner = To_Address (Self_ID) then Self_ID.Common.LL.L.Owner := System.Null_Address; if Self_ID.Common.LL.Outer_Lock = Self_ID.Common.LL.L'Access then Self_ID.Common.LL.Active_Priority := Self_ID.Common.Current_Priority; Self_ID.Common.LL.Outer_Lock := null; else Self_ID.Common.LL.Active_Priority := Self_ID.Common.LL.L.Pre_Locking_Priority; end if; end if; R_Restore_Flags (Flags); Rt_Schedule; -- Before leave, regain the lock Write_Lock (Self_ID); end Sleep; ----------------- -- Timed_Sleep -- ----------------- -- Arrange to be awakened after/at Time (depending on Mode) then Unlock -- Self_ID.Common.LL.L and suspend self. If the timeout expires first, -- that should awaken the task. If it's awakened (by some other task -- calling Wakeup) before the timeout expires, the timeout should be -- cancelled. -- This is for use within the run-time system, so abort is -- assumed to be already deferred, and the caller should be -- holding its own ATCB lock. procedure Timed_Sleep (Self_ID : Task_ID; Time : Duration; Mode : ST.Delay_Modes; Reason : Task_States; Timedout : out Boolean; Yielded : out Boolean) is Flags : Integer; Abs_Time : RTIME; begin pragma Debug (Printk ("procedure Timed_Sleep called" & LF)); Timedout := True; Yielded := False; -- ??? These two boolean seems not relevant here if Mode = Relative then Abs_Time := To_RTIME (Time) + Rt_Get_Time; else Abs_Time := To_RTIME (Time); end if; Self_ID.Common.LL.Resume_Time := Abs_Time; Self_ID.Common.LL.State := RT_TASK_DELAYED; R_Save_Flags (Flags); R_Cli; Delete_R (Self_ID); Insert_T (Self_ID); -- Check if the timer needs to be set if Timer_Queue.Common.LL.Succ = To_Address (Self_ID) then Rt_Set_Timer (Abs_Time); end if; -- Another way to do it -- -- if Abs_Time < -- To_Task_ID (Timer_Queue.Common.LL.Succ).Common.LL.Resume_Time -- then -- Rt_Set_Timer (Abs_Time); -- end if; -- Arrange to unlock Self_ID's ATCB lock. see comments in Sleep if Self_ID.Common.LL.L.Owner = To_Address (Self_ID) then Self_ID.Common.LL.L.Owner := System.Null_Address; if Self_ID.Common.LL.Outer_Lock = Self_ID.Common.LL.L'Access then Self_ID.Common.LL.Active_Priority := Self_ID.Common.Current_Priority; Self_ID.Common.LL.Outer_Lock := null; else Self_ID.Common.LL.Active_Priority := Self_ID.Common.LL.L.Pre_Locking_Priority; end if; end if; R_Restore_Flags (Flags); Rt_Schedule; -- Before leaving, regain the lock Write_Lock (Self_ID); end Timed_Sleep; ----------------- -- Timed_Delay -- ----------------- -- This is for use in implementing delay statements, so we assume -- the caller is not abort-deferred and is holding no locks. -- Self_ID can only be awakened after the timeout, no Wakeup on it. procedure Timed_Delay (Self_ID : Task_ID; Time : Duration; Mode : ST.Delay_Modes) is Flags : Integer; Abs_Time : RTIME; begin pragma Debug (Printk ("procedure Timed_Delay called" & LF)); -- Only the little window between deferring abort and -- locking Self_ID is the reason we need to -- check for pending abort and priority change below! :( Write_Lock (Self_ID); -- Take the lock in case its ATCB needs to be modified if Mode = Relative then Abs_Time := To_RTIME (Time) + Rt_Get_Time; else Abs_Time := To_RTIME (Time); end if; Self_ID.Common.LL.Resume_Time := Abs_Time; Self_ID.Common.LL.State := RT_TASK_DELAYED; R_Save_Flags (Flags); R_Cli; Delete_R (Self_ID); Insert_T (Self_ID); -- Check if the timer needs to be set if Timer_Queue.Common.LL.Succ = To_Address (Self_ID) then Rt_Set_Timer (Abs_Time); end if; -- Arrange to unlock Self_ID's ATCB lock. -- Note that the code below is slightly different from Unlock, so -- it is more than inline it. if To_Task_ID (Self_ID.Common.LL.L.Owner) = Self_ID then Self_ID.Common.LL.L.Owner := System.Null_Address; if Self_ID.Common.LL.Outer_Lock = Self_ID.Common.LL.L'Access then Self_ID.Common.LL.Active_Priority := Self_ID.Common.Current_Priority; Self_ID.Common.LL.Outer_Lock := null; else Self_ID.Common.LL.Active_Priority := Self_ID.Common.LL.L.Pre_Locking_Priority; end if; end if; R_Restore_Flags (Flags); Rt_Schedule; end Timed_Delay; --------------------- -- Monotonic_Clock -- --------------------- -- RTIME is represented as a 64-bit signed count of ticks, -- where there are 1_193_180 ticks per second. -- Let T be a count of ticks and N the corresponding count of nanoseconds. -- From the following relationship -- T / (ticks_per_second) = N / (ns_per_second) -- where ns_per_second is 1_000_000_000 (number of nanoseconds in -- a second), we get -- T * (ns_per_second) = N * (ticks_per_second) -- or -- T * 1_000_000_000 = N * 1_193_180 -- which can be reduced to -- T * 50_000_000 = N * 59_659 -- Let Nano_Count = 50_000_000 and Tick_Count = 59_659, we then have -- T * Nano_Count = N * Tick_Count -- IMPORTANT FACT: -- These numbers are small enough that we can do arithmetic -- on them without overflowing 64 bits. To see this, observe -- 10**3 = 1000 < 1024 = 2**10 -- Tick_Count < 60 * 1000 < 64 * 1024 < 2**16 -- Nano_Count < 50 * 1000 * 1000 < 64 * 1024 * 1024 < 2**26 -- It follows that if 0 <= R < Tick_Count, we can compute -- R * Nano_Count < 2**42 without overflow in 64 bits. -- Similarly, if 0 <= R < Nano_Count, we can compute -- R * Tick_Count < 2**42 without overflow in 64 bits. -- GNAT represents Duration as a count of nanoseconds internally. -- To convert T from RTIME to Duration, let -- Q = T / Tick_Count, with truncation -- R = T - Q * Tick_Count, the remainder 0 <= R < Tick_Count -- so -- N * Tick_Count -- = T * Nano_Count - Q * Tick_Count * Nano_Count -- + Q * Tick_Count * Nano_Count -- = (T - Q * Tick_Count) * Nano_Count -- + (Q * Nano_Count) * Tick_Count -- = R * Nano_Count + (Q * Nano_Count) * Tick_Count -- Now, let -- Q1 = R * Nano_Count / Tick_Count, with truncation -- R1 = R * Nano_Count - Q1 * Tick_Count, 0 <= R1 <Tick_Count -- R * Nano_Count = Q1 * Tick_Count + R1 -- so -- N * Tick_Count -- = R * Nano_Count + (Q * Nano_Count) * Tick_Count -- = Q1 * Tick_Count + R1 + (Q * Nano_Count) * Tick_Count -- = R1 + (Q * Nano_Count + Q1) * Tick_Count -- and -- N = Q * Nano_Count + Q1 + R1 /Tick_Count, -- where 0 <= R1 /Tick_Count < 1 function To_Duration (T : RTIME) return Duration is Q, Q1, RN : RTIME; begin Q := T / Tick_Count; RN := (T - Q * Tick_Count) * Nano_Count; Q1 := RN / Tick_Count; return Raw_Duration (Q * Nano_Count + Q1); end To_Duration; -- To convert D from Duration to RTIME, -- Let D be a Duration value, and N be the representation of D as an -- integer count of nanoseconds. Let -- Q = N / Nano_Count, with truncation -- R = N - Q * Nano_Count, the remainder 0 <= R < Nano_Count -- so -- T * Nano_Count -- = N * Tick_Count - Q * Nano_Count * Tick_Count -- + Q * Nano_Count * Tick_Count -- = (N - Q * Nano_Count) * Tick_Count -- + (Q * Tick_Count) * Nano_Count -- = R * Tick_Count + (Q * Tick_Count) * Nano_Count -- Now, let -- Q1 = R * Tick_Count / Nano_Count, with truncation -- R1 = R * Tick_Count - Q1 * Nano_Count, 0 <= R1 < Nano_Count -- R * Tick_Count = Q1 * Nano_Count + R1 -- so -- T * Nano_Count -- = R * Tick_Count + (Q * Tick_Count) * Nano_Count -- = Q1 * Nano_Count + R1 + (Q * Tick_Count) * Nano_Count -- = (Q * Tick_Count + Q1) * Nano_Count + R1 -- and -- T = Q * Tick_Count + Q1 + R1 / Nano_Count, -- where 0 <= R1 / Nano_Count < 1 function To_RTIME (D : Duration) return RTIME is N : RTIME := Raw_RTIME (D); Q, Q1, RT : RTIME; begin Q := N / Nano_Count; RT := (N - Q * Nano_Count) * Tick_Count; Q1 := RT / Nano_Count; return Q * Tick_Count + Q1; end To_RTIME; function Monotonic_Clock return Duration is begin pragma Debug (Printk ("procedure Clock called" & LF)); return To_Duration (Rt_Get_Time); end Monotonic_Clock; ------------------- -- RT_Resolution -- ------------------- function RT_Resolution return Duration is begin return 10#1.0#E-6; end RT_Resolution; ------------ -- Wakeup -- ------------ procedure Wakeup (T : Task_ID; Reason : ST.Task_States) is Flags : Integer; begin pragma Debug (Printk ("procedure Wakeup called" & LF)); T.Common.State := Reason; T.Common.LL.State := RT_TASK_READY; R_Save_Flags (Flags); R_Cli; if Timer_Queue.Common.LL.Succ = To_Address (T) then -- T is the first task in Timer_Queue, further check if T.Common.LL.Succ = Timer_Queue'Address then -- T is the only task in Timer_Queue, so deactivate timer Rt_No_Timer; else -- T is the first task in Timer_Queue, so set timer to T's -- successor's Resume_Time Rt_Set_Timer (To_Task_ID (T.Common.LL.Succ).Common.LL.Resume_Time); end if; end if; Delete_T (T); -- If T is in Timer_Queue, T is removed. If not, nothing happened Insert_R (T); R_Restore_Flags (Flags); Rt_Schedule; end Wakeup; ----------- -- Yield -- ----------- procedure Yield (Do_Yield : Boolean := True) is Flags : Integer; begin pragma Debug (Printk ("procedure Yield called" & LF)); pragma Assert (Current_Task /= To_Task_ID (Idle_Task'Address)); R_Save_Flags (Flags); R_Cli; Delete_R (Current_Task); Insert_R (Current_Task); -- Remove Current_Task from the top of the Ready_Queue -- and reinsert it back at proper position (the end of -- tasks with the same active priority). R_Restore_Flags (Flags); Rt_Schedule; end Yield; ------------------ -- Set_Priority -- ------------------ -- This version implicitly assume that T is the Current_Task procedure Set_Priority (T : Task_ID; Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False) is Flags : Integer; begin pragma Debug (Printk ("procedure Set_Priority called" & LF)); pragma Assert (T = Self); T.Common.Current_Priority := Prio; if T.Common.LL.Outer_Lock /= null then -- If the task T is holding any lock, defer the priority change -- until the lock is released. That is, T's Active_Priority will -- be set to Prio after it unlocks the outer-most lock. See -- Unlock for detail. -- Nothing needs to be done here for this case null; else -- If T is not holding any lock, change the priority right away. R_Save_Flags (Flags); R_Cli; T.Common.LL.Active_Priority := Prio; Delete_R (T); Insert_RF (T); -- Insert at the front of the queue for its new priority R_Restore_Flags (Flags); end if; Rt_Schedule; end Set_Priority; ------------------ -- Get_Priority -- ------------------ function Get_Priority (T : Task_ID) return System.Any_Priority is begin pragma Debug (Printk ("procedure Get_Priority called" & LF)); return T.Common.Current_Priority; end Get_Priority; ---------------- -- Enter_Task -- ---------------- -- Do any target-specific initialization that is needed for a new task -- that has to be done by the task itself. This is called from the task -- wrapper, immediately after the task starts execution. procedure Enter_Task (Self_ID : Task_ID) is begin -- Use this as "hook" to re-enable interrupts. pragma Debug (Printk ("procedure Enter_Task called" & LF)); R_Sti; end Enter_Task; ---------------- -- New_ATCB -- ---------------- function New_ATCB (Entry_Num : Task_Entry_Index) return Task_ID is T : constant Task_ID := Available_TCBs; begin pragma Debug (Printk ("function New_ATCB called" & LF)); if Entry_Num /= 0 then -- We are preallocating all TCBs, so they must all have the -- same number of entries, which means the value of -- Entry_Num must be bounded. We probably could choose a -- non-zero upper bound here, but the Ravenscar Profile -- specifies that there be no task entries. -- ??? -- Later, do something better for recovery from this error. null; end if; if T /= null then Available_TCBs := To_Task_ID (T.Common.LL.Next); T.Common.LL.Next := System.Null_Address; Known_Tasks (T.Known_Tasks_Index) := T; end if; return T; end New_ATCB; ---------------------- -- Initialize_TCB -- ---------------------- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is begin pragma Debug (Printk ("procedure Initialize_TCB called" & LF)); -- Give the task a unique serial number. Self_ID.Serial_Number := Next_Serial_Number; Next_Serial_Number := Next_Serial_Number + 1; pragma Assert (Next_Serial_Number /= 0); Self_ID.Common.LL.L.Ceiling_Priority := System.Any_Priority'Last; Self_ID.Common.LL.L.Owner := System.Null_Address; Succeeded := True; end Initialize_TCB; ----------------- -- Create_Task -- ----------------- procedure Create_Task (T : Task_ID; Wrapper : System.Address; Stack_Size : System.Parameters.Size_Type; Priority : System.Any_Priority; Succeeded : out Boolean) is Adjusted_Stack_Size : Integer; Bottom : System.Address; Flags : Integer; begin pragma Debug (Printk ("procedure Create_Task called" & LF)); Succeeded := True; if T.Common.LL.Magic = RT_TASK_MAGIC then Succeeded := False; return; end if; if Stack_Size = Unspecified_Size then Adjusted_Stack_Size := To_Integer (Default_Stack_Size); elsif Stack_Size < Minimum_Stack_Size then Adjusted_Stack_Size := To_Integer (Minimum_Stack_Size); else Adjusted_Stack_Size := To_Integer (Stack_Size); end if; Bottom := Kmalloc (Adjusted_Stack_Size, GFP_KERNEL); if Bottom = System.Null_Address then Succeeded := False; return; end if; T.Common.LL.Uses_Fp := 1; -- This field has to be reset to 1 if T uses FP unit. But, without -- a library-level procedure provided by this package, it cannot -- be set easily. So temporarily, set it to 1 (which means all the -- tasks will use FP unit. ??? T.Common.LL.Magic := RT_TASK_MAGIC; T.Common.LL.State := RT_TASK_READY; T.Common.LL.Succ := To_Address (T); T.Common.LL.Pred := To_Address (T); T.Common.LL.Active_Priority := Priority; T.Common.Current_Priority := Priority; T.Common.LL.Stack_Bottom := Bottom; T.Common.LL.Stack := Bottom + Storage_Offset (Adjusted_Stack_Size); -- Store the value T into the stack, so that Task_wrapper (defined -- in System.Tasking.Stages) will find that value for its parameter -- Self_ID, when the scheduler eventually transfers control to the -- new task. T.Common.LL.Stack := T.Common.LL.Stack - Addr_Bytes; To_Address_Ptr (T.Common.LL.Stack).all := To_Address (T); -- Leave space for the return address, which will not be used, -- since the task wrapper should never return. T.Common.LL.Stack := T.Common.LL.Stack - Addr_Bytes; To_Address_Ptr (T.Common.LL.Stack).all := System.Null_Address; -- Put the entry point address of the task wrapper -- procedure on the new top of the stack. T.Common.LL.Stack := T.Common.LL.Stack - Addr_Bytes; To_Address_Ptr (T.Common.LL.Stack).all := Wrapper; R_Save_Flags (Flags); R_Cli; Insert_R (T); R_Restore_Flags (Flags); end Create_Task; ------------------ -- Finalize_TCB -- ------------------ procedure Finalize_TCB (T : Task_ID) is begin pragma Debug (Printk ("procedure Finalize_TCB called" & LF)); pragma Assert (T.Common.LL.Succ = To_Address (T)); if T.Common.LL.State = RT_TASK_DORMANT then Known_Tasks (T.Known_Tasks_Index) := null; T.Common.LL.Next := To_Address (Available_TCBs); Available_TCBs := T; Kfree (T.Common.LL.Stack_Bottom); end if; end Finalize_TCB; --------------- -- Exit_Task -- --------------- procedure Exit_Task is Flags : Integer; begin pragma Debug (Printk ("procedure Exit_Task called" & LF)); pragma Assert (Current_Task /= To_Task_ID (Idle_Task'Address)); pragma Assert (Current_Task /= Environment_Task_ID); R_Save_Flags (Flags); R_Cli; Current_Task.Common.LL.State := RT_TASK_DORMANT; Current_Task.Common.LL.Magic := 0; Delete_R (Current_Task); R_Restore_Flags (Flags); Rt_Schedule; end Exit_Task; ---------------- -- Abort_Task -- ---------------- -- ??? Not implemented for now procedure Abort_Task (T : Task_ID) is -- Should cause T to raise Abort_Signal the next time it -- executes. -- ??? Can this ever be called when T = Current_Task? -- To be safe, do nothing in this case. begin pragma Debug (Printk ("procedure Abort_Task called" & LF)); null; end Abort_Task; ---------------- -- Check_Exit -- ---------------- -- Dummy versions. The only currently working versions is for solaris -- (native). -- We should probably copy the working versions over from the Solaris -- version of this package, with any appropriate changes, since without -- the checks on it will probably be nearly impossible to debug the -- run-time system. -- Not implemented for now function Check_Exit (Self_ID : Task_ID) return Boolean is begin pragma Debug (Printk ("function Check_Exit called" & LF)); return True; end Check_Exit; -------------------- -- Check_No_Locks -- -------------------- function Check_No_Locks (Self_ID : Task_ID) return Boolean is begin pragma Debug (Printk ("function Check_No_Locks called" & LF)); if Self_ID.Common.LL.Outer_Lock = null then return True; else return False; end if; end Check_No_Locks; ---------------------- -- Environment_Task -- ---------------------- function Environment_Task return Task_ID is begin return Environment_Task_ID; end Environment_Task; ------------------------- -- Lock_All_Tasks_List -- ------------------------- procedure Lock_All_Tasks_List is begin pragma Debug (Printk ("procedure Lock_All_Tasks_List called" & LF)); Write_Lock (All_Tasks_L'Access); end Lock_All_Tasks_List; --------------------------- -- Unlock_All_Tasks_List -- --------------------------- procedure Unlock_All_Tasks_List is begin pragma Debug (Printk ("procedure Unlock_All_Tasks_List called" & LF)); Unlock (All_Tasks_L'Access); end Unlock_All_Tasks_List; ----------------- -- Stack_Guard -- ----------------- -- Not implemented for now procedure Stack_Guard (T : Task_ID; On : Boolean) is begin null; end Stack_Guard; -------------------- -- Get_Thread_Id -- -------------------- function Get_Thread_Id (T : Task_ID) return OSI.Thread_Id is begin return To_Address (T); end Get_Thread_Id; ------------------ -- Suspend_Task -- ------------------ function Suspend_Task (T : Task_ID; Thread_Self : OSI.Thread_Id) return Boolean is begin return False; end Suspend_Task; ----------------- -- Resume_Task -- ----------------- function Resume_Task (T : ST.Task_ID; Thread_Self : OSI.Thread_Id) return Boolean is begin return False; end Resume_Task; ----------------- -- Init_Module -- ----------------- function Init_Module return Integer is procedure adainit; pragma Import (C, adainit); begin adainit; In_Elab_Code := False; Set_Priority (Environment_Task_ID, Any_Priority'First); return 0; end Init_Module; -------------------- -- Cleanup_Module -- -------------------- procedure Cleanup_Module is procedure adafinal; pragma Import (C, adafinal); begin adafinal; end Cleanup_Module; ---------------- -- Initialize -- ---------------- -- The environment task is "special". The TCB of the environment task is -- not in the TCB_Array above. Logically, all initialization code for the -- runtime system is executed by the environment task, but until the -- environment task has initialized its own TCB we dare not execute any -- calls that try to access the TCB of Current_Task. It is allocated by -- target-independent runtime system code, in System.Tasking.Initializa- -- tion.Init_RTS, before the call to this procedure Initialize. The -- target-independent runtime system initializes all the components that -- are target-independent, but this package needs to be given a chance to -- initialize the target-dependent data. We do that in this procedure. -- In the present implementation, Environment_Task is set to be the -- regular GNU/Linux kernel task. procedure Initialize (Environment_Task : Task_ID) is begin pragma Debug (Printk ("procedure Initialize called" & LF)); Environment_Task_ID := Environment_Task; -- Build the list of available ATCB's. Available_TCBs := To_Task_ID (TCB_Array (1)'Address); for J in TCB_Array'First + 1 .. TCB_Array'Last - 1 loop -- Note that the zeroth element in TCB_Array is not used, see -- comments following the declaration of TCB_Array TCB_Array (J).Common.LL.Next := TCB_Array (J + 1)'Address; end loop; TCB_Array (TCB_Array'Last).Common.LL.Next := System.Null_Address; -- Initialize the idle task, which is the head of Ready_Queue. Idle_Task.Common.LL.Magic := RT_TASK_MAGIC; Idle_Task.Common.LL.State := RT_TASK_READY; Idle_Task.Common.Current_Priority := System.Any_Priority'First; Idle_Task.Common.LL.Active_Priority := System.Any_Priority'First; Idle_Task.Common.LL.Succ := Idle_Task'Address; Idle_Task.Common.LL.Pred := Idle_Task'Address; -- Initialize the regular GNU/Linux kernel task. Environment_Task.Common.LL.Magic := RT_TASK_MAGIC; Environment_Task.Common.LL.State := RT_TASK_READY; Environment_Task.Common.Current_Priority := System.Any_Priority'First; Environment_Task.Common.LL.Active_Priority := System.Any_Priority'First; Environment_Task.Common.LL.Succ := To_Address (Environment_Task); Environment_Task.Common.LL.Pred := To_Address (Environment_Task); -- Initialize the head of Timer_Queue Timer_Queue.Common.LL.Succ := Timer_Queue'Address; Timer_Queue.Common.LL.Pred := Timer_Queue'Address; Timer_Queue.Common.LL.Resume_Time := Max_Sensible_Delay; -- Set the current task to regular GNU/Linux kernel task Current_Task := Environment_Task; -- Set Timer_Wrapper to be the timer handler Rt_Free_Timer; Rt_Request_Timer (Timer_Wrapper'Address); -- Initialize the lock used to synchronize chain of all ATCBs. Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); Enter_Task (Environment_Task); end Initialize; end System.Task_Primitives.Operations;
src/tests/generated/bug-cmpxgch-02-06-21.asm
mguarnieri/revizor
29
240490
.intel_syntax noprefix .test_case_enter: MFENCE # instrumentation AND RBX, 0b0111111000000 # instrumentation CMPXCHG8B qword ptr [R14 + RBX] MFENCE # instrumentation
pulse_interrupt.ads
gonma95/RealTimeSystem_CarDistrations
0
19535
with Ada.Real_Time; use Ada.Real_Time; with System; use System; package pulse_interrupt is --------------------------------------------------------------------- ------ declaracion de procedimientos de acceso a DISPOSITIVOS E/S -- --------------------------------------------------------------------- Interr_1: constant Time_Span := To_Time_Span (0.5); Interr_2: constant Time_Span := To_Time_Span (0.5); Interr_3: constant Time_Span := To_Time_Span (0.7); Interr_4: constant Time_Span := To_Time_Span (0.9); Interr_5: constant Time_Span := To_Time_Span (0.9); Interr_6: constant Time_Span := To_Time_Span (0.8); Interr_7: constant Time_Span := To_Time_Span (0.7); Interr_8: constant Time_Span := To_Time_Span (0.7); Interr_9: constant Time_Span := To_Time_Span (0.6); Interr_10: constant Time_Span := To_Time_Span (0.6); -------------------------------------------------------------------------- -- Tarea que fuerza la interrupcion externa 2 en los instantes indicados -- -------------------------------------------------------------------------- Priority_Of_External_Interrupts_2 : constant System.Interrupt_Priority := System.Interrupt_Priority'First + 9; task Interrupt is pragma Priority (Priority_Of_External_Interrupts_2); end Interrupt; end pulse_interrupt;
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/opt61_pkg.adb
best08618/asylo
7
27806
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/opt61_pkg.adb with Interfaces; use Interfaces; with Ada.Unchecked_Conversion; package body Opt61_Pkg is pragma Suppress (Overflow_Check); pragma Suppress (Range_Check); subtype Uns64 is Unsigned_64; function To_Int is new Ada.Unchecked_Conversion (Uns64, Int64); subtype Uns32 is Unsigned_32; ----------------------- -- Local Subprograms -- ----------------------- function "+" (A : Uns64; B : Uns32) return Uns64 is (A + Uns64 (B)); -- Length doubling additions function "*" (A, B : Uns32) return Uns64 is (Uns64 (A) * Uns64 (B)); -- Length doubling multiplication function "&" (Hi, Lo : Uns32) return Uns64 is (Shift_Left (Uns64 (Hi), 32) or Uns64 (Lo)); -- Concatenate hi, lo values to form 64-bit result function "abs" (X : Int64) return Uns64 is (if X = Int64'First then 2**63 else Uns64 (Int64'(abs X))); -- Convert absolute value of X to unsigned. Note that we can't just use -- the expression of the Else, because it overflows for X = Int64'First. function Lo (A : Uns64) return Uns32 is (Uns32 (A and 16#FFFF_FFFF#)); -- Low order half of 64-bit value function Hi (A : Uns64) return Uns32 is (Uns32 (Shift_Right (A, 32))); -- High order half of 64-bit value ------------------- -- Double_Divide -- ------------------- procedure Double_Divide (X, Y, Z : Int64; Q, R : out Int64; Round : Boolean) is Xu : constant Uns64 := abs X; Yu : constant Uns64 := abs Y; Yhi : constant Uns32 := Hi (Yu); Ylo : constant Uns32 := Lo (Yu); Zu : constant Uns64 := abs Z; Zhi : constant Uns32 := Hi (Zu); Zlo : constant Uns32 := Lo (Zu); T1, T2 : Uns64; Du, Qu, Ru : Uns64; Den_Pos : Boolean; begin if Yu = 0 or else Zu = 0 then raise Constraint_Error; end if; -- Compute Y * Z. Note that if the result overflows 64 bits unsigned, -- then the rounded result is clearly zero (since the dividend is at -- most 2**63 - 1, the extra bit of precision is nice here). if Yhi /= 0 then if Zhi /= 0 then Q := 0; R := X; return; else T2 := Yhi * Zlo; end if; else T2 := (if Zhi /= 0 then Ylo * Zhi else 0); end if; T1 := Ylo * Zlo; T2 := T2 + Hi (T1); if Hi (T2) /= 0 then Q := 0; R := X; return; end if; Du := Lo (T2) & Lo (T1); -- Set final signs (RM 4.5.5(27-30)) Den_Pos := (Y < 0) = (Z < 0); -- Check overflow case of largest negative number divided by 1 if X = Int64'First and then Du = 1 and then not Den_Pos then raise Constraint_Error; end if; -- Perform the actual division Qu := Xu / Du; Ru := Xu rem Du; -- Deal with rounding case if Round and then Ru > (Du - Uns64'(1)) / Uns64'(2) then Qu := Qu + Uns64'(1); end if; -- Case of dividend (X) sign positive if X >= 0 then R := To_Int (Ru); Q := (if Den_Pos then To_Int (Qu) else -To_Int (Qu)); -- Case of dividend (X) sign negative else R := -To_Int (Ru); Q := (if Den_Pos then -To_Int (Qu) else To_Int (Qu)); end if; end Double_Divide; end Opt61_Pkg;
thirdparty/glut/progs/ada/ada_sphere_procs.ads
ShiroixD/pag_zad_2
1
27385
with GL; use GL; with Glut; use Glut; package ada_sphere_procs is procedure display; procedure reshape (w : Integer; h : Integer); procedure menu (value : Integer); procedure init; end ada_sphere_procs;
externals/mpir-3.0.0/mpn/x86w/copyi.asm
JaminChan/eos_win
12
89711
<gh_stars>10-100 ; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. ; ; This file is part of the GNU MP Library. ; ; The GNU MP Library is free software; you can redistribute it and/or ; modify it under the terms of the GNU Lesser General Public License as ; published by the Free Software Foundation; either version 2.1 of the ; License, or (at your option) any later version. ; ; The GNU MP Library is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ; Lesser General Public License for more details. ; ; You should have received a copy of the GNU Lesser General Public ; License along with the GNU MP Library; see the file COPYING.LIB. If ; not, write to the Free Software Foundation, Inc., 59 Temple Place - ; Suite 330, Boston, MA 02111-1307, USA. ; ; Translation of AT&T syntax code by <NAME> %include "x86i.inc" global ___gmpn_copyi %ifdef DLL export ___gmpn_copyi %endif %define PARAM_SIZE esp+frame+12 %define PARAM_SRC esp+frame+8 %define PARAM_DST esp+frame+4 %assign frame 0 section .text align 32 ; eax saved esi ; ebx ; ecx counter ; edx saved edi ; esi src ; edi dst ; ebp ___gmpn_copyi: mov ecx,[PARAM_SIZE] mov eax,esi mov esi,[PARAM_SRC] mov edx,edi mov edi,[PARAM_DST] cld ; better safe than sorry,see mpn/x86/README rep movsd mov esi,eax mov edi,edx ret end
other.7z/NEWS.7z/NEWS/テープリストア/NEWS_05/NEWS_05.tar/home/kimura/kart/mak.lzh/mak/test.asm
prismotizm/gigaleak
0
96761
<reponame>prismotizm/gigaleak Name: test.asm Type: file Size: 29 Last-Modified: '1992-02-13T07:48:36Z' SHA-1: 66D543C1459ACB0BBA55EBC46F1751923E3D48A8 Description: null
org.alloytools.alloy.diff/misc/inheritance/extendsWithFieldRestriction_flattened.als
jringert/alloy-diff
1
28
<reponame>jringert/alloy-diff sig A { x : some A } sig B { x : some A } sig C { x : one (A+B) } fact { no (A<:x + B<:x).(A+B) } run {}
sk/music-optimized/Competition Menu.asm
Cancer52/flamedriver
9
240742
<filename>sk/music-optimized/Competition Menu.asm Snd_2PMenu_Header: smpsHeaderStartSong 3, 1 smpsHeaderVoice Snd_2PMenu_Voices smpsHeaderChan $06, $03 smpsHeaderTempo $01, $4A smpsHeaderDAC Snd_2PMenu_DAC smpsHeaderFM Snd_2PMenu_FM1, $00, $03 smpsHeaderFM Snd_2PMenu_FM2, $00, $00 ; Previously this transpose was -$C, causing a note to underflow smpsHeaderFM Snd_2PMenu_FM3, $00, $05 smpsHeaderFM Snd_2PMenu_FM4, $00, $05 smpsHeaderFM Snd_2PMenu_FM5, $00, $05 smpsHeaderPSG Snd_2PMenu_PSG1, $E8, $00, $00, sTone_0F smpsHeaderPSG Snd_2PMenu_PSG2, $E8, $01, $00, sTone_0F smpsHeaderPSG Snd_2PMenu_PSG3, $2E, $00, $00, sTone_0D ; FM1 Data Snd_2PMenu_FM1: smpsSetvoice $00 Snd_2PMenu_Loop03: dc.b nE3, $06, nRst, $1E, nE3, $06, nD3, $12, nB2, $06, nRst, nA2 dc.b nRst, nRst, nRst smpsLoop $00, $08, Snd_2PMenu_Loop03 dc.b nE3, $06, nRst, $36, nB2, $06, nD3, $12, nE3, $06, nRst, nFs3 dc.b $06, nRst, $2A, nCs3, $06, nCs3, nE3, nFs3, nRst, $18, nB2, $06 dc.b nRst, $36, nFs2, $06, nA2, $12, nB2, $06, nRst, nB2, $06, nRst dc.b $24, nD2, $06, nD3, nRst, nCs3, nRst, nB2, nRst, nA2, nRst, nE2 dc.b $06, nRst, $36, nB1, $06, nD2, nB1, nE2, nB1, nRst, nFs2, $06 dc.b nRst, $2A, nCs2, $06, nCs2, nE2, nFs2, $1E, nB2, $06, nRst, $36 dc.b nFs2, $06, nA2, $12, nB2, $06, nRst, nB2, $06, nRst, $12, nRst dc.b $0C, nB2, nA2, nRst, nRst, nRst Snd_2PMenu_Loop04: dc.b nE3, $06, nRst, $1E, nE3, $06, nD3, $12, nB2, $06, nRst, nA2 dc.b nRst, nRst, nRst smpsLoop $00, $08, Snd_2PMenu_Loop04 smpsJump Snd_2PMenu_Loop03 ; FM2 Data Snd_2PMenu_FM2: smpsCall Snd_2PMenu_Call03 smpsSetvoice $06 dc.b nG7, $60, nRst smpsSetvoice $07 dc.b nE4, $0D smpsFMAlterVol $08 dc.b nE4, $0B, nRst, $48 smpsFMAlterVol $F8 dc.b nE4, $0D smpsFMAlterVol $08 dc.b nE4, $0B, nRst, $48 smpsFMAlterVol $F8 smpsSetvoice $06 dc.b nG7, $60, nRst smpsSetvoice $07 dc.b nE4, $0D smpsFMAlterVol $08 dc.b nE4, $0B, nRst, $48 smpsFMAlterVol $F8 dc.b nE4, $0D smpsFMAlterVol $08 dc.b nE4, $0B, nRst, $48 smpsFMAlterVol $F8 smpsCall Snd_2PMenu_Call03 smpsJump Snd_2PMenu_FM2 Snd_2PMenu_Call03: smpsSetvoice $06 dc.b nC3, $60, nRst smpsSetvoice $07 dc.b nE4, $0D smpsFMAlterVol $08 dc.b nE4, $0B, nRst, $48 smpsFMAlterVol $F8 dc.b nRst, $60 smpsSetvoice $06 dc.b nRst, $06, nC3, $5A, nRst, $60 smpsSetvoice $07 dc.b nE4, $0D smpsFMAlterVol $08 dc.b nE4, $0B, nRst, $48 smpsFMAlterVol $F8 dc.b nRst, $60 smpsReturn ; FM3 Data Snd_2PMenu_FM3: smpsPan panLeft, $00 smpsAlterNote $01 Snd_2PMenu_Jump01: smpsCall Snd_2PMenu_Call02 smpsSetvoice $02 dc.b nG3, $60, nA3, $24, nE3, $3C, nA3, $60, nA3, nG3, $60, nA3 dc.b $24, nE3, $3C, nA3, $60, nA3, $48, nCs4, $18 smpsCall Snd_2PMenu_Call02 smpsJump Snd_2PMenu_Jump01 Snd_2PMenu_Call02: smpsSetvoice $03 dc.b nRst, $24, nA3, $3C, smpsNoAttack, $3C smpsSetvoice $01 smpsNoteFill $06 dc.b nG5, $06, nG5 smpsFMAlterVol $10 dc.b nG5, nRst smpsFMAlterVol $F0 dc.b nA5, nRst smpsNoteFill $00 smpsSetvoice $03 dc.b nA3, $60, smpsNoAttack, $54 smpsSetvoice $05 smpsModSet $01, $01, $03, $06 dc.b nE5, $12 smpsModOff smpsSetvoice $03 dc.b nRst, $1E, nA3, $3C, smpsNoAttack, $3C smpsSetvoice $01 smpsNoteFill $06 dc.b nG5, $06, nG5 smpsFMAlterVol $10 dc.b nG5, nRst smpsFMAlterVol $F0 dc.b nA5, nRst smpsNoteFill $00 smpsSetvoice $03 dc.b nA3, $60, smpsNoAttack, $60 smpsReturn ; FM4 Data Snd_2PMenu_FM4: smpsPan panRight, $00 Snd_2PMenu_Jump00: smpsCall Snd_2PMenu_Call01 smpsSetvoice $02 dc.b nB3, $60, nE4, nD4, nD4, nB3, $60, nE4, nCs4, nD4, $48, nE4 dc.b $18 smpsCall Snd_2PMenu_Call01 smpsJump Snd_2PMenu_Jump00 Snd_2PMenu_Call01: smpsSetvoice $03 dc.b nRst, $24, nB3, $3C, smpsNoAttack, $3C smpsSetvoice $01 smpsNoteFill $06 dc.b nG4, $06, nG4 smpsFMAlterVol $10 dc.b nG4, nRst smpsFMAlterVol $F0 dc.b nA4, nRst smpsNoteFill $00 smpsSetvoice $03 dc.b nB3, $60, smpsNoAttack, $54 smpsSetvoice $05 smpsModSet $01, $01, $03, $06 dc.b nG5, $12 smpsModOff smpsSetvoice $03 dc.b nRst, $1E, nB3, $3C, smpsNoAttack, $3C smpsSetvoice $01 smpsNoteFill $06 dc.b nG4, $06, nG4 smpsFMAlterVol $10 dc.b nG4, nRst smpsFMAlterVol $F0 dc.b nA4, nRst smpsNoteFill $00 smpsSetvoice $03 dc.b nB3, $60, smpsNoAttack, $60 smpsReturn ; FM5 Data Snd_2PMenu_FM5: smpsCall Snd_2PMenu_Call00 smpsSetvoice $02 dc.b nD4, $3C, nG4, $12, nA4, nA4, $60, nA4, nA4, nD4, $3C, nG4 dc.b $12, nA4, nA4, $60, nE4, nA4, $48, nCs5, $18 smpsCall Snd_2PMenu_Call00 smpsJump Snd_2PMenu_FM5 Snd_2PMenu_Call00: smpsSetvoice $03 dc.b nRst, $24, nD4, $3C, smpsNoAttack, $60, nE4, smpsNoAttack, nE4 smpsLoop $00, $02, Snd_2PMenu_Call00 smpsReturn ; PSG1 Data Snd_2PMenu_PSG1: dc.b nRst, $01 smpsAlterNote $FF ; PSG2 Data Snd_2PMenu_PSG2: smpsPSGvoice sTone_1F Snd_2PMenu_Jump03: smpsCall Snd_2PMenu_Call08 smpsCall Snd_2PMenu_Call08 dc.b nRst, $60, nRst, nRst, nRst, $18, nD5, nE5, $03, nFs5, $15, nD5 dc.b $18, nG4, $03, nA4, $2D, nRst, $30, nRst, $18, nA4, $12, nG4 dc.b $06, nFs4, $18, nA4, nE4, $24, nRst, $3C, nRst, $60 smpsCall Snd_2PMenu_Call08 Snd_2PMenu_Loop05: dc.b nRst, $18, nD5, $0C, nB4, $06, nRst, nG4, $0C, nB4, $06, nRst dc.b nD5, $0C, nB4, $06, nRst smpsLoop $00, $02, Snd_2PMenu_Loop05 dc.b nRst, $18, nE5, $0C, nB4, $06, nRst, nG4, $0C, nB4, $06, nRst dc.b nE5, $0C, nB4, $06, nRst, nRst, $60 smpsJump Snd_2PMenu_Jump03 Snd_2PMenu_Call08: dc.b nRst, $18, nD5, $0C, nB4, $06, nRst, nG4, $0C, nB4, $06, nRst dc.b nD5, $0C, nB4, $06, nRst smpsLoop $00, $02, Snd_2PMenu_Call08 Snd_2PMenu_Loop06: dc.b nRst, $18, nE5, $0C, nB4, $06, nRst, nG4, $0C, nB4, $06, nRst dc.b nE5, $0C, nB4, $06, nRst smpsLoop $00, $02, Snd_2PMenu_Loop06 smpsReturn ; PSG3 Data Snd_2PMenu_PSG3: smpsPSGform $E7 smpsPSGvoice sTone_1E Snd_2PMenu_Jump02: smpsCall Snd_2PMenu_Call04 smpsCall Snd_2PMenu_Call05 smpsCall Snd_2PMenu_Call06 smpsCall Snd_2PMenu_Call05 smpsCall Snd_2PMenu_Call07 smpsCall Snd_2PMenu_Call07 smpsCall Snd_2PMenu_Call04 smpsCall Snd_2PMenu_Call05 smpsCall Snd_2PMenu_Call04 smpsCall Snd_2PMenu_Call04 smpsCall Snd_2PMenu_Call04 smpsCall Snd_2PMenu_Call04 smpsCall Snd_2PMenu_Call07 smpsCall Snd_2PMenu_Call06 smpsCall Snd_2PMenu_Call06 smpsCall Snd_2PMenu_Call05 smpsCall Snd_2PMenu_Call04 smpsCall Snd_2PMenu_Call07 smpsCall Snd_2PMenu_Call04 smpsCall Snd_2PMenu_Call04 smpsCall Snd_2PMenu_Call07 smpsCall Snd_2PMenu_Call06 smpsCall Snd_2PMenu_Call04 smpsCall Snd_2PMenu_Call07 smpsJump Snd_2PMenu_Jump02 Snd_2PMenu_Call04: smpsPSGvoice sTone_1E smpsPSGAlterVol $02 dc.b (nMaxPSG1-$2E)&$FF, $0C smpsPSGAlterVol $FE dc.b (nMaxPSG1-$2E)&$FF, (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $02 dc.b (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $FE dc.b (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $02 dc.b (nMaxPSG1-$2E)&$FF, (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $FE smpsPSGvoice sTone_27 dc.b (nMaxPSG1-$2E)&$FF, $06, nRst smpsReturn Snd_2PMenu_Call05: smpsPSGvoice sTone_1E smpsPSGAlterVol $02 dc.b (nMaxPSG1-$2E)&$FF, $0C smpsPSGAlterVol $FE dc.b (nMaxPSG1-$2E)&$FF, (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $02 dc.b (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $FE dc.b (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $02 dc.b (nMaxPSG1-$2E)&$FF, (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $FE dc.b (nMaxPSG1-$2E)&$FF, $06, (nMaxPSG1-$2E)&$FF smpsReturn Snd_2PMenu_Call06: smpsPSGvoice sTone_1E smpsPSGAlterVol $02 dc.b (nMaxPSG1-$2E)&$FF, $0C smpsPSGAlterVol $FE dc.b (nMaxPSG1-$2E)&$FF, (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $02 dc.b (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $FE dc.b (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $02 dc.b (nMaxPSG1-$2E)&$FF, (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $FE dc.b (nMaxPSG1-$2E)&$FF, $06 smpsPSGvoice sTone_27 dc.b (nMaxPSG1-$2E)&$FF smpsReturn Snd_2PMenu_Call07: smpsPSGvoice sTone_1E smpsPSGAlterVol $02 dc.b (nMaxPSG1-$2E)&$FF, $0C smpsPSGAlterVol $FE dc.b (nMaxPSG1-$2E)&$FF, (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $02 dc.b (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $FE dc.b (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $02 dc.b (nMaxPSG1-$2E)&$FF, (nMaxPSG1-$2E)&$FF smpsPSGAlterVol $FE smpsPSGvoice sTone_27 dc.b (nMaxPSG1-$2E)&$FF smpsReturn ; DAC Data Snd_2PMenu_DAC: dc.b dKickS3, $06, nRst, nRst, nRst, dSnareS3, nRst, nRst, dKickS3, dKickS3, nRst, dKickS3 dc.b nRst, dSnareS3, nRst, nRst, nRst smpsLoop $00, $03, Snd_2PMenu_DAC dc.b dKickS3, nRst, nRst, nRst, dSnareS3, nRst, nRst, dKickS3, dKickS3, nRst, dKickS3, nRst dc.b dSnareS3, nRst, dSnareS3, dSnareS3 Snd_2PMenu_Loop00: dc.b dKickS3, $06, nRst, nRst, nRst, dSnareS3, nRst, nRst, dKickS3, dKickS3, nRst, dKickS3 dc.b nRst, dSnareS3, nRst, nRst, nRst smpsLoop $00, $03, Snd_2PMenu_Loop00 dc.b dKickS3, nRst, dSnareS3, nRst, dSnareS3, nRst, nRst, dKickS3, dKickS3, nRst, dSnareS3, dSnareS3 dc.b dSnareS3, nRst, dSnareS3, dSnareS3 Snd_2PMenu_Loop01: dc.b dKickS3, nRst, nRst, nRst, dSnareS3, nRst, nRst, dKickS3, dKickS3, nRst, dKickS3, nRst dc.b dSnareS3, nRst, dKickS3, nRst smpsLoop $00, $03, Snd_2PMenu_Loop01 dc.b dKickS3, nRst, nRst, nRst, dSnareS3, nRst, nRst, dKickS3, dKickS3, nRst, dKickS3, nRst dc.b dSnareS3, nRst, dSnareS3, dSnareS3 smpsLoop $01, $02, Snd_2PMenu_Loop01 Snd_2PMenu_Loop02: dc.b dKickS3, $06, nRst, nRst, nRst, dSnareS3, nRst, nRst, dKickS3, dKickS3, nRst, dKickS3 dc.b nRst, dSnareS3, nRst, nRst, nRst smpsLoop $00, $03, Snd_2PMenu_Loop02 dc.b dKickS3, nRst, nRst, nRst, dSnareS3, nRst, nRst, dKickS3, dKickS3, nRst, dKickS3, nRst dc.b dSnareS3, nRst, dSnareS3, dSnareS3 smpsLoop $01, $02, Snd_2PMenu_Loop02 smpsJump Snd_2PMenu_DAC Snd_2PMenu_Voices: ; Voice $00 ; $00 ; $27, $33, $30, $21, $DF, $DF, $9F, $9F, $07, $06, $09, $06 ; $07, $06, $06, $08, $20, $10, $10, $0F, $19, $37, $10, $84 smpsVcAlgorithm $00 smpsVcFeedback $00 smpsVcUnusedBits $00 smpsVcDetune $02, $03, $03, $02 smpsVcCoarseFreq $01, $00, $03, $07 smpsVcRateScale $02, $02, $03, $03 smpsVcAttackRate $1F, $1F, $1F, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $06, $09, $06, $07 smpsVcDecayRate2 $08, $06, $06, $07 smpsVcDecayLevel $00, $01, $01, $02 smpsVcReleaseRate $0F, $00, $00, $00 smpsVcTotalLevel $84, $10, $37, $19 ; Voice $01 ; $05 ; $30, $52, $01, $31, $51, $53, $52, $53, $05, $00, $00, $00 ; $00, $00, $00, $00, $1F, $0F, $0F, $0F, $0C, $90, $90, $90 smpsVcAlgorithm $05 smpsVcFeedback $00 smpsVcUnusedBits $00 smpsVcDetune $03, $00, $05, $03 smpsVcCoarseFreq $01, $01, $02, $00 smpsVcRateScale $01, $01, $01, $01 smpsVcAttackRate $13, $12, $13, $11 smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $00, $00, $00, $05 smpsVcDecayRate2 $00, $00, $00, $00 smpsVcDecayLevel $00, $00, $00, $01 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $90, $90, $90, $0C ; Voice $02 ; $2E ; $05, $77, $58, $02, $1F, $1F, $14, $14, $00, $00, $00, $00 ; $08, $0B, $09, $06, $0F, $0F, $0F, $0F, $18, $90, $90, $90 smpsVcAlgorithm $06 smpsVcFeedback $05 smpsVcUnusedBits $00 smpsVcDetune $00, $05, $07, $00 smpsVcCoarseFreq $02, $08, $07, $05 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $14, $14, $1F, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $00, $00, $00, $00 smpsVcDecayRate2 $06, $09, $0B, $08 smpsVcDecayLevel $00, $00, $00, $00 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $90, $90, $90, $18 ; Voice $03 ; $2C ; $71, $62, $31, $32, $5F, $54, $5F, $5F, $00, $09, $00, $09 ; $00, $03, $00, $03, $0F, $8F, $0F, $AF, $16, $8B, $11, $8B smpsVcAlgorithm $04 smpsVcFeedback $05 smpsVcUnusedBits $00 smpsVcDetune $03, $03, $06, $07 smpsVcCoarseFreq $02, $01, $02, $01 smpsVcRateScale $01, $01, $01, $01 smpsVcAttackRate $1F, $1F, $14, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $09, $00, $09, $00 smpsVcDecayRate2 $03, $00, $03, $00 smpsVcDecayLevel $0A, $00, $08, $00 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $8B, $11, $8B, $16 ; Voice $04 ; $03 ; $02, $02, $02, $02, $1F, $1F, $1F, $1F, $08, $08, $00, $0E ; $00, $00, $00, $05, $3F, $3F, $0F, $7F, $81, $20, $1D, $82 smpsVcAlgorithm $03 smpsVcFeedback $00 smpsVcUnusedBits $00 smpsVcDetune $00, $00, $00, $00 smpsVcCoarseFreq $02, $02, $02, $02 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $1F, $1F, $1F, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $0E, $00, $08, $08 smpsVcDecayRate2 $05, $00, $00, $00 smpsVcDecayLevel $07, $00, $03, $03 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $82, $1D, $20, $81 ; Voice $05 ; $04 ; $22, $02, $21, $02, $18, $0B, $19, $08, $00, $05, $04, $00 ; $00, $00, $00, $00, $0F, $FF, $4F, $0F, $20, $90, $20, $88 smpsVcAlgorithm $04 smpsVcFeedback $00 smpsVcUnusedBits $00 smpsVcDetune $00, $02, $00, $02 smpsVcCoarseFreq $02, $01, $02, $02 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $08, $19, $0B, $18 smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $00, $04, $05, $00 smpsVcDecayRate2 $00, $00, $00, $00 smpsVcDecayLevel $00, $04, $0F, $00 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $88, $20, $90, $20 ; Voice $06 ; $00 ; $38, $1C, $1E, $1F, $1F, $1F, $1F, $1F, $00, $00, $00, $0C ; $00, $00, $00, $0C, $0F, $0F, $0F, $1F, $00, $3D, $00, $88 smpsVcAlgorithm $00 smpsVcFeedback $00 smpsVcUnusedBits $00 smpsVcDetune $01, $01, $01, $03 smpsVcCoarseFreq $0F, $0E, $0C, $08 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $1F, $1F, $1F, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $0C, $00, $00, $00 smpsVcDecayRate2 $0C, $00, $00, $00 smpsVcDecayLevel $01, $00, $00, $00 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $88, $00, $3D, $00 ; Voice $07 ; $00 ; $70, $30, $13, $01, $1F, $1F, $0E, $1F, $00, $0B, $0E, $00 ; $08, $01, $10, $12, $0F, $1F, $FF, $0F, $15, $1E, $94, $00 smpsVcAlgorithm $00 smpsVcFeedback $00 smpsVcUnusedBits $00 smpsVcDetune $00, $01, $03, $07 smpsVcCoarseFreq $01, $03, $00, $00 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $1F, $0E, $1F, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $00, $0E, $0B, $00 smpsVcDecayRate2 $12, $10, $01, $08 smpsVcDecayLevel $00, $0F, $01, $00 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $00, $94, $1E, $15
unittests/ASM/Primary/Primary_6A.asm
cobalt2727/FEX
628
92624
<filename>unittests/ASM/Primary/Primary_6A.asm %ifdef CONFIG { "RegData": { "RAX": "0xFFFFFFFFFFFFFF81", "RSP": "0xE0000018" }, "MemoryRegions": { "0x100000000": "4096" } } %endif mov rsp, 0xe0000020 push -127 mov rdx, 0xe0000020 mov rax, [rdx - 8] hlt
programs/oeis/330/A330707.asm
neoneye/loda
22
90262
<filename>programs/oeis/330/A330707.asm ; A330707: a(n) = ( 3*n^2 + n - 1 + (-1)^floor(n/2) )/4. ; 0,1,3,7,13,20,28,38,50,63,77,93,111,130,150,172,196,221,247,275,305,336,368,402,438,475,513,553,595,638,682,728,776,825,875,927,981,1036,1092,1150,1210,1271,1333,1397,1463,1530,1598,1668,1740,1813,1887,1963,2041,2120,2200,2282,2366,2451,2537,2625,2715,2806,2898,2992,3088,3185,3283,3383,3485,3588,3692,3798,3906,4015,4125,4237,4351,4466,4582,4700,4820,4941,5063,5187,5313,5440,5568,5698,5830,5963,6097,6233,6371,6510,6650,6792,6936,7081,7227,7375 mul $0,-3 bin $0,2 div $0,6
src/LibraBFT/Impl/Consensus/BlockStorage/SyncManager.agda
LaudateCorpus1/bft-consensus-agda
0
11142
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import Haskell.Modules.RWS.RustAnyHow import LibraBFT.Impl.Consensus.BlockStorage.BlockRetriever as BlockRetriever import LibraBFT.Impl.Consensus.BlockStorage.BlockStore as BlockStore import LibraBFT.Impl.Consensus.BlockStorage.BlockTree as BlockTree import LibraBFT.Impl.OBM.ECP-LBFT-OBM-Diff.ECP-LBFT-OBM-Diff-1 as ECP-LBFT-OBM-Diff-1 import LibraBFT.Impl.Consensus.ConsensusTypes.Vote as Vote import LibraBFT.Impl.Consensus.PersistentLivenessStorage as PersistentLivenessStorage open import LibraBFT.Impl.OBM.Logging.Logging open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Util.Dijkstra.All open import Optics.All open import Util.Hash open import Util.Prelude ------------------------------------------------------------------------------ open import Data.String using (String) module LibraBFT.Impl.Consensus.BlockStorage.SyncManager where data NeedFetchResult : Set where QCRoundBeforeRoot QCAlreadyExist QCBlockExist NeedFetch : NeedFetchResult ------------------------------------------------------------------------------ fastForwardSyncM : QuorumCert → BlockRetriever → LBFT (Either ErrLog RecoveryData) fetchQuorumCertM : QuorumCert → BlockRetriever → LBFT (Either ErrLog Unit) insertQuorumCertM : QuorumCert → BlockRetriever → LBFT (Either ErrLog Unit) syncToHighestCommitCertM : QuorumCert → BlockRetriever → LBFT (Either ErrLog Unit) ------------------------------------------------------------------------------ needSyncForQuorumCert : QuorumCert → BlockStore → Either ErrLog Bool needSyncForQuorumCert qc bs = maybeS (bs ^∙ bsRoot) (Left fakeErr) {-bsRootErrL here-} $ λ btr → Right (not ( BlockStore.blockExists (qc ^∙ qcCommitInfo ∙ biId) bs ∨ ⌊ btr ^∙ ebRound ≥?ℕ qc ^∙ qcCommitInfo ∙ biRound ⌋ )) where here' : List String → List String here' t = "SyncManager" ∷ "needSyncForQuorumCert" ∷ t needFetchForQuorumCert : QuorumCert → BlockStore → Either ErrLog NeedFetchResult needFetchForQuorumCert qc bs = maybeS (bs ^∙ bsRoot) (Left fakeErr) {-bsRootErrL here-} $ λ btr → grd‖ qc ^∙ qcCertifiedBlock ∙ biRound <?ℕ btr ^∙ ebRound ≔ Right QCRoundBeforeRoot ‖ is-just (BlockStore.getQuorumCertForBlock (qc ^∙ qcCertifiedBlock ∙ biId) bs) ≔ Right QCAlreadyExist ‖ BlockStore.blockExists (qc ^∙ qcCertifiedBlock ∙ biId) bs ≔ Right QCBlockExist ‖ otherwise≔ Right NeedFetch where here' : List String → List String here' t = "SyncManager" ∷ "needFetchForQuorumCert" ∷ t ------------------------------------------------------------------------------ addCertsM : SyncInfo → BlockRetriever → LBFT (Either ErrLog Unit) addCertsM {-reason-} syncInfo retriever = syncToHighestCommitCertM (syncInfo ^∙ siHighestCommitCert) retriever ∙?∙ \_ -> insertQuorumCertM {-reason-} (syncInfo ^∙ siHighestCommitCert) retriever ∙?∙ \_ -> insertQuorumCertM {-reason-} (syncInfo ^∙ siHighestQuorumCert) retriever ∙?∙ \_ -> maybeSD (syncInfo ^∙ siHighestTimeoutCert) (ok unit) $ \tc -> BlockStore.insertTimeoutCertificateM tc ------------------------------------------------------------------------------ module insertQuorumCertM (qc : QuorumCert) (retriever : BlockRetriever) where step₀ : LBFT (Either ErrLog Unit) step₁ : BlockStore → LBFT (Either ErrLog Unit) step₁-else : LBFT (Either ErrLog Unit) step₂ : ExecutedBlock → LBFT (Either ErrLog Unit) step₃ : LedgerInfoWithSignatures → LBFT (Either ErrLog Unit) step₀ = do bs ← use lBlockStore _ ← case⊎D needFetchForQuorumCert qc bs of λ where (Left e) → bail e (Right NeedFetch) → fetchQuorumCertM qc retriever ∙^∙ withErrCtx ("" ∷ []) (Right QCBlockExist) → BlockStore.insertSingleQuorumCertM qc ∙^∙ withErrCtx ("" ∷ []) ∙?∙ λ _ → do use lBlockStore >>= const (logInfo fakeInfo) -- InfoBlockStoreShort (here [lsQC qc]) ok unit (Right _) → ok unit step₁ bs step₁ bs = do maybeSD (bs ^∙ bsRoot) (bail fakeErr) $ λ bsr → ifD (bsr ^∙ ebRound) <?ℕ (qc ^∙ qcCommitInfo ∙ biRound) then step₂ bsr else step₁-else step₂ bsr = do let finalityProof = qc ^∙ qcLedgerInfo BlockStore.commitM finalityProof ∙?∙ λ xx → step₃ finalityProof step₃ finalityProof = do ifD qc ^∙ qcEndsEpoch then ECP-LBFT-OBM-Diff-1.e_SyncManager_insertQuorumCertM_commit finalityProof else ok unit step₁-else = ok unit insertQuorumCertM = insertQuorumCertM.step₀ ------------------------------------------------------------------------------ loop1 : BlockRetriever → List Block → QuorumCert → LBFT (Either ErrLog (List Block)) loop2 : List Block → LBFT (Either ErrLog Unit) hereFQCM' : List String → List String fetchQuorumCertM qc retriever = loop1 retriever [] qc ∙?∙ loop2 -- TODO-1 PROVE IT TERMINATES {-# TERMINATING #-} loop1 retriever pending retrieveQC = do bs ← use lBlockStore ifD (BlockStore.blockExists (retrieveQC ^∙ qcCertifiedBlock ∙ biId) bs) then ok pending else BlockRetriever.retrieveBlockForQCM retriever retrieveQC 1 ∙^∙ withErrCtx (hereFQCM' ("loop1" ∷ [])) ∙?∙ λ where (block ∷ []) → loop1 retriever (block ∷ pending) (block ^∙ bQuorumCert) (_ ∷ _ ∷ _) → errorCase [] → errorCase where errorCase : LBFT (Either ErrLog (List Block)) errorCase = do -- let msg = here ["loop1", "retrieveBlockForQCM returned more than asked for"] -- logErrExit msg bail fakeErr -- (ErrL msg) loop2 = λ where [] -> ok unit (block ∷ bs) → BlockStore.insertSingleQuorumCertM (block ^∙ bQuorumCert) ∙^∙ withErrCtx (hereFQCM' ("loop2" ∷ [])) ∙?∙ \_ -> BlockStore.executeAndInsertBlockM block ∙?∙ \_ -> loop2 bs hereFQCM' t = "SyncManager" ∷ "fetchQuorumCertM" ∷ t ------------------------------------------------------------------------------ syncToHighestCommitCertM highestCommitCert retriever = do bs ← use lBlockStore eitherSD (needSyncForQuorumCert highestCommitCert bs) bail $ λ b → if not b then ok unit else fastForwardSyncM highestCommitCert retriever ∙?∙ \rd -> do logInfo fakeInfo -- (here ["fastForwardSyncM success", lsRD rd]) BlockStore.rebuildM (rd ^∙ rdRoot) (rd ^∙ rdRootMetadata) (rd ^∙ rdBlocks) (rd ^∙ rdQuorumCerts) ∙^∙ withErrCtx (here' []) ∙?∙ λ _ -> do whenD (highestCommitCert ^∙ qcEndsEpoch) $ do me ← use (lRoundManager ∙ rmObmMe) -- TODO-1 : Epoch Change Proof -- let ecp = EpochChangeProof ∙ new [highestCommitCert ^∙ qcLedgerInfo] False logInfo fakeInfo -- (here ["fastForwardSyncM detected an EpochChange"]) -- TODO-1 : uncomment this and remove pure unit when Epoch Change supported -- act (BroadcastEpochChangeProof lEC ecp (mkNodesInOrder1 me)) pure unit ok unit where here' : List String → List String here' t = "SyncManager" ∷ "syncToHighestCommitCertM" ∷ t ------------------------------------------------------------------------------ fastForwardSyncM highestCommitCert retriever = do logInfo fakeInfo -- (here' [ "start state sync with peer", lsA (retriever^.brPreferredPeer) -- , "to block", lsBI (highestCommitCert^.qcCommitInfo) ]) BlockRetriever.retrieveBlockForQCM retriever highestCommitCert 3 ∙?∙ λ where blocks@(_ ∷ _ ∷ i ∷ []) -> if highestCommitCert ^∙ qcCommitInfo ∙ biId /= i ^∙ bId then bail fakeErr -- (here' [ "should have a 3-chain" -- , lsHV (highestCommitCert^.qcCommitInfo.biId), lsHV (i^.bId) ])) else continue blocks x -> bail fakeErr -- (here' ["incorrect number of blocks returned", show (length x)])) where here' : List String → List String zipWithNatsFrom : {A : Set} → ℕ → List A → List (ℕ × A) zipWithNatsFrom n = λ where [] → [] (x ∷ xs) → (n , x) ∷ zipWithNatsFrom (n + 1) xs checkBlocksMatchQCs : List QuorumCert → List (ℕ × Block) → LBFT (Either ErrLog Unit) continue : List Block → LBFT (Either ErrLog RecoveryData) continue blocks = do logInfo fakeInfo -- (here' (["received blocks"] <> fmap (lsHV . (^.bId)) blocks)) let quorumCerts = highestCommitCert ∷ fmap (_^∙ bQuorumCert) blocks logInfo fakeInfo -- (here' (["quorumCerts"] <> fmap (lsHV . (^.qcCommitInfo.biId)) quorumCerts)) checkBlocksMatchQCs quorumCerts (zipWithNatsFrom 0 blocks) ∙?∙ λ _ → PersistentLivenessStorage.saveTreeM blocks quorumCerts ∙?∙ λ _ → do -- TODO-1 : requires adding bsStorage to BlockStore -- use (lBlockStore ∙ bsStorage) >>= λ x → logInfo fakeInfo -- (here' ["XXX", lsPLS x]) -- OBM NOT NEEDED: state_computer.sync_to -- This returns recovery data PersistentLivenessStorage.startM ∙^∙ withErrCtx (here' []) checkBlocksMatchQCs quorumCerts = λ where [] → ok unit ((i , block) ∷ xs) → maybeSD (quorumCerts !? i) (bail fakeErr) -- (here' ["checkBlocksMatchQCs", "!?"]) $ λ qc → ifD (block ^∙ bId /= qc ^∙ qcCertifiedBlock ∙ biId) then (do logInfo fakeInfo -- [lsHV (block^.bId), lsB block] logInfo fakeInfo -- [lsHV (quorumCerts Prelude.!! i ^.qcCertifiedBlock.biId) -- ,lsQC (quorumCerts Prelude.!! i)] bail fakeErr) -- (here' ("checkBlocksMatchQCs" ∷ "/=" ∷ [])) else checkBlocksMatchQCs quorumCerts xs here' t = "SyncManager" ∷ "fastForwardSyncM" ∷ t
CS/计算机系统概论/Lab03/data.asm
RabbitWhite1/USTC-CS-Resources
7
8659
<filename>CS/计算机系统概论/Lab03/data.asm .ORIG x3200 .FILL #13461 .FILL #27928 .FILL #23897 .FILL #4332 .FILL #13343 .FILL #28652 .FILL #28356 .FILL #13361 .FILL #21501 .FILL #17042 .FILL #29268 .FILL #61 .FILL #4068 .FILL #16891 .FILL #8451 .FILL #6833 .FILL #17733 .FILL #10977 .FILL #1396 .FILL #24886 .FILL #8820 .FILL #23643 .FILL #1075 .FILL #24756 .FILL #4361 .FILL #10415 .FILL #14653 .FILL #19653 .FILL #8071 .FILL #10343 .FILL #20163 .FILL #2921 .FILL #11835 .FILL #17319 .FILL #12587 .FILL #10491 .FILL #25447 .FILL #26045 .FILL #17496 .FILL #18531 .FILL #10912 .FILL #3834 .FILL #32299 .FILL #25486 .FILL #17269 .FILL #14528 .FILL #2633 .FILL #28699 .FILL #9041 .FILL #16349 .FILL #23327 .FILL #15447 .FILL #11939 .FILL #18711 .FILL #19492 .FILL #6252 .FILL #3387 .FILL #21512 .FILL #14686 .FILL #8149 .FILL #7671 .FILL #28717 .FILL #12328 .FILL #14101 .FILL #19872 .FILL #18489 .FILL #7474 .FILL #4521 .FILL #21775 .FILL #30639 .FILL #7113 .FILL #21563 .FILL #8852 .FILL #24239 .FILL #19033 .FILL #10008 .FILL #29336 .FILL #26640 .FILL #18480 .FILL #19684 .FILL #23424 .FILL #30128 .FILL #16516 .FILL #4493 .FILL #20693 .FILL #26376 .FILL #9912 .FILL #9597 .FILL #24994 .FILL #28164 .FILL #2011 .FILL #14612 .FILL #13854 .FILL #9745 .FILL #5490 .FILL #27733 .FILL #4235 .FILL #8567 .FILL #19831 .FILL #26335 .FILL #21854 .FILL #24809 .FILL #25505 .FILL #11295 .FILL #24224 .FILL #26970 .FILL #20454 .FILL #32709 .FILL #7828 .FILL #27667 .FILL #9791 .FILL #28276 .FILL #21914 .FILL #13571 .FILL #7083 .FILL #20158 .FILL #24403 .FILL #21334 .FILL #23670 .FILL #20047 .FILL #23302 .FILL #12361 .FILL #6075 .FILL #24424 .FILL #13123 .FILL #2108 .FILL #25640 .FILL #6800 .FILL #18630 .FILL #31240 .FILL #25089 .FILL #26758 .FILL #17565 .FILL #8340 .FILL #15975 .FILL #2169 .FILL #21902 .FILL #27299 .FILL #31707 .FILL #18043 .FILL #23731 .FILL #9456 .FILL #9214 .FILL #30260 .FILL #19815 .FILL #27261 .FILL #18074 .FILL #1491 .FILL #17510 .FILL #28456 .FILL #27110 .FILL #15690 .FILL #6703 .FILL #22655 .FILL #20486 .FILL #32187 .FILL #29869 .FILL #6357 .FILL #13778 .FILL #5421 .FILL #7191 .FILL #150 .FILL #28376 .FILL #31364 .FILL #5909 .FILL #31191 .FILL #676 .FILL #1456 .FILL #21028 .FILL #8753 .FILL #12095 .FILL #30756 .FILL #22075 .FILL #14032 .FILL #29941 .FILL #27018 .FILL #21167 .FILL #1735 .FILL #3931 .FILL #27829 .FILL #32340 .FILL #24486 .FILL #32657 .FILL #215 .FILL #5093 .FILL #10319 .FILL #3013 .FILL #8948 .FILL #28069 .FILL #7685 .FILL #22520 .FILL #5014 .FILL #1095 .FILL #26566 .FILL #31749 .FILL #9411 .FILL #21771 .FILL #29659 .FILL #15071 .FILL #9260 .FILL #29483 .FILL #21421 .FILL #16154 .FILL #13735 .FILL #18549 .FILL #2522 .FILL #173 .FILL #12767 .FILL #18745 .FILL #32392 .FILL #14326 .FILL #23882 .FILL #8037 .FILL #3578 .FILL #510 .FILL #2908 .FILL #4335 .FILL #25953 .FILL #6655 .FILL #507 .FILL #9587 .FILL #8692 .FILL #19491 .FILL #12594 .FILL #20254 .FILL #26178 .FILL #1423 .FILL #4905 .FILL #6858 .FILL #22983 .FILL #9632 .FILL #18517 .FILL #11114 .FILL #18110 .FILL #29812 .FILL #17388 .FILL #1193 .FILL #18999 .FILL #25261 .FILL #7324 .FILL #26830 .FILL #19049 .FILL #30321 .FILL #21884 .FILL #19939 .FILL #10057 .FILL #2485 .FILL #13123 .FILL #11798 .FILL #22876 .FILL #15804 .FILL #29112 .FILL #14175 .FILL #29385 .FILL #18394 .FILL #28009 .FILL #7779 .FILL #14002 .FILL #31614 .FILL #5536 .FILL #6297 .FILL #15044 .FILL #13680 .FILL #14995 .FILL #16811 .FILL #18189 .FILL #3158 .FILL #3035 .FILL #28703 .FILL #26638 .FILL #27261 .FILL #23335 .FILL #15670 .FILL #26386 .FILL #29910 .FILL #30514 .FILL #17428 .FILL #7358 .FILL #25407 .FILL #13042 .FILL #23586 .FILL #20968 .FILL #11780 .FILL #27923 .FILL #21169 .FILL #8877 .FILL #13478 .FILL #11171 .FILL #26592 .FILL #6077 .FILL #16859 .FILL #8207 .FILL #4799 .FILL #27130 .FILL #4309 .FILL #10062 .FILL #20660 .FILL #9282 .FILL #14279 .FILL #6748 .FILL #1054 .FILL #6024 .FILL #7078 .FILL #746 .FILL #9785 .FILL #21802 .FILL #20781 .FILL #2132 .FILL #20546 .FILL #9086 .FILL #3875 .FILL #10451 .FILL #24539 .FILL #8366 .FILL #5600 .FILL #4852 .FILL #15024 .FILL #1991 .FILL #12302 .FILL #13128 .FILL #30043 .FILL #19468 .FILL #12461 .FILL #19037 .FILL #24965 .FILL #32400 .FILL #4697 .FILL #7918 .FILL #18254 .FILL #12804 .FILL #7120 .FILL #8279 .FILL #19951 .FILL #20685 .FILL #11695 .FILL #3403 .FILL #22430 .FILL #6490 .FILL #7548 .FILL #29385 .FILL #21683 .FILL #13492 .FILL #16873 .FILL #5964 .FILL #21000 .FILL #6998 .FILL #5207 .FILL #9795 .FILL #18085 .FILL #15424 .FILL #2970 .FILL #12224 .FILL #25757 .FILL #6727 .FILL #5116 .FILL #20596 .FILL #28979 .FILL #21423 .FILL #18564 .FILL #5595 .FILL #26689 .FILL #18427 .FILL #20856 .FILL #29364 .FILL #28379 .FILL #20484 .FILL #3104 .FILL #22452 .FILL #22831 .FILL #15433 .FILL #24525 .FILL #17531 .FILL #18351 .FILL #3462 .FILL #25626 .FILL #25799 .FILL #8051 .FILL #7048 .FILL #15474 .FILL #3560 .FILL #25048 .FILL #7743 .FILL #19666 .FILL #12404 .FILL #10094 .FILL #19733 .FILL #11216 .FILL #4667 .FILL #16913 .FILL #2174 .FILL #30173 .FILL #25725 .FILL #19029 .FILL #16848 .FILL #26055 .FILL #2651 .FILL #7208 .FILL #5462 .FILL #22146 .FILL #9100 .FILL #1714 .FILL #19103 .FILL #4647 .FILL #12113 .FILL #13184 .FILL #12060 .FILL #4669 .FILL #23467 .FILL #2274 .FILL #32491 .FILL #5432 .FILL #21707 .FILL #2961 .FILL #20461 .FILL #11583 .FILL #10442 .FILL #917 .FILL #13086 .FILL #11314 .FILL #5018 .FILL #26726 .FILL #38 .FILL #4332 .FILL #18237 .FILL #22610 .FILL #32555 .FILL #22981 .FILL #1076 .FILL #7966 .FILL #25834 .FILL #24667 .FILL #5691 .FILL #4080 .FILL #21766 .FILL #8851 .FILL #2355 .FILL #13933 .FILL #24223 .FILL #7386 .FILL #10848 .FILL #8990 .FILL #10023 .FILL #6577 .FILL #10708 .FILL #22296 .FILL #14193 .FILL #6760 .FILL #28715 .FILL #4828 .FILL #7947 .FILL #15657 .FILL #31865 .FILL #3196 .FILL #25038 .FILL #17465 .FILL #24193 .FILL #20735 .FILL #25523 .FILL #8827 .FILL #8488 .FILL #21767 .FILL #18153 .FILL #12598 .FILL #14633 .FILL #30897 .FILL #28708 .FILL #29463 .FILL #19465 .FILL #701 .FILL #9527 .FILL #2170 .FILL #25422 .FILL #22255 .FILL #31205 .FILL #14565 .FILL #24556 .FILL #27572 .FILL #32500 .FILL #13781 .FILL #16896 .FILL #17161 .FILL #26500 .FILL #31422 .FILL #6336 .FILL #27289 .FILL #6303 .FILL #28237 .FILL #11954 .FILL #18213 .FILL #22289 .FILL #10480 .FILL #17949 .FILL #12073 .FILL #1914 .FILL #1176 .FILL #31166 .FILL #6333 .FILL #13473 .FILL #22974 .FILL #5563 .FILL #24249 .FILL #20491 .FILL #3492 .FILL #31965 .FILL #24860 .FILL #24781 .FILL #21981 .FILL #28153 .FILL #1199 .FILL #5278 .FILL #21775 .FILL #15791 .FILL #21989 .FILL #26416 .FILL #29944 .FILL #22615 .FILL #21254 .FILL #21441 .FILL #8623 .FILL #8249 .FILL #8588 .FILL #17645 .FILL #18988 .FILL #31740 .FILL #13006 .FILL #14022 .FILL #18955 .FILL #10594 .FILL #7131 .FILL #16166 .FILL #8333 .FILL #10290 .FILL #9385 .FILL #28740 .FILL #6368 .FILL #20853 .FILL #21103 .FILL #18822 .FILL #18336 .FILL #28388 .FILL #29007 .FILL #10902 .FILL #413 .FILL #26274 .FILL #24888 .FILL #31928 .FILL #12255 .FILL #20263 .FILL #10763 .FILL #1627 .FILL #9447 .FILL #32636 .FILL #6908 .FILL #7405 .FILL #22328 .FILL #28590 .FILL #31036 .FILL #10484 .FILL #9494 .FILL #32125 .FILL #469 .FILL #12379 .FILL #1422 .FILL #26964 .FILL #17109 .FILL #23305 .FILL #19126 .FILL #8062 .FILL #4014 .FILL #9657 .FILL #22838 .FILL #8598 .FILL #5341 .FILL #14085 .FILL #30983 .FILL #9279 .FILL #20170 .FILL #2755 .FILL #9083 .FILL #13590 .FILL #26607 .FILL #26517 .FILL #29310 .FILL #31973 .FILL #16957 .FILL #21180 .FILL #5403 .FILL #29210 .FILL #12219 .FILL #30253 .FILL #27970 .FILL #3959 .FILL #7793 .FILL #11495 .FILL #15048 .FILL #25354 .FILL #15236 .FILL #10627 .FILL #30639 .FILL #2400 .FILL #20898 .FILL #27405 .FILL #18856 .FILL #26870 .FILL #26272 .FILL #29714 .FILL #11478 .FILL #16880 .FILL #23650 .FILL #30714 .FILL #15317 .FILL #26125 .FILL #6396 .FILL #29336 .FILL #14587 .FILL #11483 .FILL #31254 .FILL #24064 .FILL #15581 .FILL #30759 .FILL #6037 .FILL #31385 .FILL #11797 .FILL #23736 .FILL #6520 .FILL #23923 .FILL #26179 .FILL #17213 .FILL #9471 .FILL #14554 .FILL #10322 .FILL #5507 .FILL #9491 .FILL #4907 .FILL #19453 .FILL #19435 .FILL #29154 .FILL #24550 .FILL #17041 .FILL #28444 .FILL #7114 .FILL #12037 .FILL #22772 .FILL #25077 .FILL #23928 .FILL #26252 .FILL #23270 .FILL #1989 .FILL #31057 .FILL #14946 .FILL #31623 .FILL #6847 .FILL #1552 .FILL #22111 .FILL #10009 .FILL #18088 .FILL #28337 .FILL #28326 .FILL #8712 .FILL #23507 .FILL #10639 .FILL #10805 .FILL #6439 .FILL #11855 .FILL #27337 .FILL #7098 .FILL #1853 .FILL #30047 .FILL #21993 .FILL #15528 .FILL #5056 .FILL #16170 .FILL #29384 .FILL #7819 .FILL #20192 .FILL #19636 .FILL #27052 .FILL #18073 .FILL #28360 .FILL #27149 .FILL #19124 .FILL #26505 .FILL #29216 .FILL #5833 .FILL #25718 .FILL #28072 .FILL #19414 .FILL #4783 .FILL #28134 .FILL #4393 .FILL #31774 .FILL #8886 .FILL #1914 .FILL #25276 .FILL #15031 .FILL #8749 .FILL #22411 .FILL #1635 .FILL #5744 .FILL #13369 .FILL #17919 .FILL #4225 .FILL #11756 .FILL #10628 .FILL #6949 .FILL #14644 .FILL #26018 .FILL #28212 .FILL #1504 .FILL #23013 .FILL #16167 .FILL #5146 .FILL #19720 .FILL #26910 .FILL #13744 .FILL #19756 .FILL #12301 .FILL #26779 .FILL #17363 .FILL #27190 .FILL #15069 .FILL #31139 .FILL #30349 .FILL #12748 .FILL #4360 .FILL #2969 .FILL #12681 .FILL #9091 .FILL #29730 .FILL #22734 .FILL #2207 .FILL #31585 .FILL #2410 .FILL #9625 .FILL #21148 .FILL #2449 .FILL #8872 .FILL #30122 .FILL #22849 .FILL #12891 .FILL #3676 .FILL #11163 .FILL #19086 .FILL #10836 .FILL #13076 .FILL #18120 .FILL #20288 .FILL #17106 .FILL #31262 .FILL #13153 .FILL #27288 .FILL #23203 .FILL #19807 .FILL #24765 .FILL #1886 .FILL #18175 .FILL #11395 .FILL #4593 .FILL #22054 .FILL #18618 .FILL #7511 .FILL #7330 .FILL #24786 .FILL #25022 .FILL #31602 .FILL #2583 .FILL #30552 .FILL #7865 .FILL #27419 .FILL #20114 .FILL #22981 .FILL #10515 .FILL #29543 .FILL #2785 .FILL #17282 .FILL #13603 .FILL #930 .FILL #3120 .FILL #15318 .FILL #8354 .FILL #26608 .FILL #32289 .FILL #20397 .FILL #21856 .FILL #28980 .FILL #799 .FILL #6296 .FILL #17461 .FILL #21553 .FILL #9967 .FILL #13588 .FILL #3131 .FILL #1008 .FILL #24455 .FILL #5647 .FILL #8762 .FILL #2913 .FILL #4132 .FILL #17832 .FILL #3172 .FILL #10820 .FILL #17047 .FILL #2871 .FILL #1603 .FILL #14666 .FILL #2783 .FILL #4237 .FILL #8431 .FILL #6520 .FILL #18685 .FILL #27773 .FILL #13188 .FILL #13005 .FILL #15620 .FILL #13979 .FILL #12243 .FILL #17956 .FILL #8560 .FILL #2115 .FILL #12120 .FILL #5724 .FILL #16312 .FILL #3805 .FILL #19565 .FILL #11445 .FILL #13095 .FILL #4960 .FILL #7100 .FILL #15485 .FILL #19943 .FILL #6933 .FILL #23034 .FILL #27117 .FILL #21599 .FILL #1438 .FILL #8659 .FILL #30798 .FILL #703 .FILL #19510 .FILL #15904 .FILL #9055 .FILL #4312 .FILL #17978 .FILL #27744 .FILL #10235 .FILL #10290 .FILL #5865 .FILL #9062 .FILL #16375 .FILL #88 .FILL #10344 .FILL #12879 .FILL #5450 .FILL #5495 .FILL #22536 .FILL #19383 .FILL #28784 .FILL #11559 .FILL #14284 .FILL #20781 .FILL #9744 .FILL #7561 .FILL #2342 .FILL #29411 .FILL #2012 .FILL #2706 .FILL #21762 .FILL #30634 .FILL #23736 .FILL #3494 .FILL #17669 .FILL #16670 .FILL #9247 .FILL #31593 .FILL #8727 .FILL #24606 .FILL #10435 .FILL #15314 .FILL #7199 .FILL #19840 .FILL #9844 .FILL #26753 .FILL #16141 .FILL #6914 .FILL #1859 .FILL #9554 .FILL #14622 .FILL #12419 .FILL #31719 .FILL #26418 .FILL #22107 .FILL #26995 .FILL #29536 .FILL #7473 .FILL #21860 .FILL #9864 .FILL #13786 .FILL #28633 .FILL #31083 .FILL #10162 .FILL #9939 .FILL #2750 .FILL #32131 .FILL #16978 .FILL #29312 .FILL #9303 .FILL #19739 .FILL #18343 .FILL #10861 .FILL #14348 .FILL #9669 .FILL #12168 .FILL #5477 .FILL #9872 .FILL #1597 .FILL #23385 .FILL #13969 .FILL #12401 .FILL #3750 .FILL #1336 .FILL #20451 .FILL #32494 .FILL #13846 .FILL #12151 .FILL #25526 .FILL #12040 .FILL #31061 .FILL #10319 .FILL #31150 .FILL #4828 .FILL #26338 .FILL #30162 .FILL #10982 .FILL #7471 .FILL #11319 .FILL #15906 .FILL #14666 .FILL #11083 .FILL #2126 .FILL #32737 .FILL #13889 .FILL #8458 .FILL #18276 .FILL #12008 .FILL #31888 .FILL #2864 .FILL #11261 .FILL #2364 .FILL #379 .FILL #15357 .FILL #26920 .FILL #14397 .FILL #16684 .FILL #5635 .FILL #4612 .FILL #4641 .FILL #19033 .FILL #31030 .FILL #8835 .FILL #4001 .FILL #11554 .FILL #1602 .FILL #1390 .FILL #18930 .FILL #20792 .FILL #11297 .FILL #15274 .FILL #5367 .FILL #30532 .FILL #13292 .FILL #2233 .FILL #2485 .FILL #27015 .FILL #16113 .FILL #18563 .FILL #5383 .FILL #8125 .FILL #27399 .FILL #21079 .FILL #24211 .FILL #23112 .FILL #4382 .FILL #3373 .FILL #7164 .FILL #30858 .FILL #21018 .FILL #6446 .FILL #9306 .FILL #3731 .FILL #26082 .FILL #12918 .FILL #22503 .FILL #32252 .FILL #24755 .FILL #12568 .FILL #12282 .FILL #5650 .FILL #25275 .FILL #19042 .FILL #2874 .FILL #-1 .END
src/Utilities/tokenize-private_token_lists.adb
fintatarta/eugen
0
13981
pragma Ada_2012; package body Tokenize.Private_Token_Lists with SPARK_Mode => On is ------------ -- Append -- ------------ procedure Append (List : in out Token_List; What : String) is begin if List.First_Free > List.Tokens'Last then raise Constraint_Error; end if; List.Tokens (List.First_Free) := To_Unbounded_String (What); List.First_Free := List.First_Free + 1; end Append; end Tokenize.Private_Token_Lists;
programs/oeis/295/A295869.asm
neoneye/loda
22
29611
<reponame>neoneye/loda ; A295869: Numbers not divisible by 2, 3 or 5 (A007775) with digital root 8. ; 17,53,71,89,107,143,161,179,197,233,251,269,287,323,341,359,377,413,431,449,467,503,521,539,557,593,611,629,647,683,701,719,737,773,791,809,827,863,881,899,917,953,971,989,1007,1043,1061,1079,1097,1133,1151,1169,1187,1223,1241,1259,1277,1313,1331,1349,1367,1403,1421,1439,1457,1493,1511,1529,1547,1583,1601,1619,1637,1673,1691,1709,1727,1763,1781,1799,1817,1853,1871,1889,1907,1943,1961,1979,1997,2033,2051,2069,2087,2123,2141,2159,2177,2213,2231,2249 mov $1,5 mul $1,$0 add $1,3 div $1,4 mul $1,18 add $1,17 mov $0,$1
programs/oeis/058/A058645.asm
neoneye/loda
22
160812
<filename>programs/oeis/058/A058645.asm<gh_stars>10-100 ; A058645: a(n) = 2^(n-3)*n^2*(n+3). ; 0,1,10,54,224,800,2592,7840,22528,62208,166400,433664,1105920,2768896,6823936,16588800,39845888,94699520,222953472,520486912,1205862400,2774532096,6343884800,14422114304,32614907904,73400320000 mov $2,$0 mov $3,$0 lpb $0 add $2,$0 sub $0,1 mov $1,$3 mul $3,2 lpe mul $1,$2 div $1,2 mov $0,$1
programs/oeis/076/A076389.asm
karttu/loda
1
102264
<filename>programs/oeis/076/A076389.asm ; A076389: Sum of squares of numbers that cannot be written as t*n + u*(n+1) for nonnegative integers t,u. ; 0,1,30,220,950,3045,8036,18480,38340,73425,131890,224796,366730,576485,877800,1300160,1879656,2659905,3693030,5040700,6775230,8980741,11754380,15207600,19467500,24678225,31002426,38622780,47743570 mov $2,$0 bin $0,2 mov $1,$2 mul $1,2 add $1,$0 add $0,$1 mul $0,2 mul $1,$0 add $1,$0 sub $0,2 mul $1,$0 div $1,24
Transynther/x86/_processed/NC/_ht_zr_/i3-7100_9_0xca_notsx.log_21829_2001.asm
ljhsiun2/medusa
9
101068
<reponame>ljhsiun2/medusa .global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r8 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_WT_ht+0x1a1a0, %r8 nop nop nop sub %r14, %r14 vmovups (%r8), %ymm0 vextracti128 $1, %ymm0, %xmm0 vpextrq $0, %xmm0, %rcx sub %r13, %r13 lea addresses_A_ht+0x8b20, %r8 nop cmp $23617, %r9 vmovups (%r8), %ymm7 vextracti128 $1, %ymm7, %xmm7 vpextrq $1, %xmm7, %rax nop nop nop xor %rcx, %rcx lea addresses_normal_ht+0xd078, %rsi lea addresses_A_ht+0xac20, %rdi nop nop nop nop xor $40903, %r8 mov $45, %rcx rep movsb nop nop nop sub %rsi, %rsi lea addresses_WC_ht+0x1a220, %rdi nop nop nop nop inc %r8 movl $0x61626364, (%rdi) nop nop nop add %r14, %r14 lea addresses_WT_ht+0xd2e0, %r13 nop nop nop nop cmp $32700, %rsi mov $0x6162636465666768, %r8 movq %r8, %xmm4 movups %xmm4, (%r13) nop nop nop and $42993, %r13 pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r15 push %r8 push %r9 push %rbx push %rdi // Store lea addresses_A+0x1e900, %r9 add %r10, %r10 mov $0x5152535455565758, %r13 movq %r13, (%r9) nop nop and %r15, %r15 // Store lea addresses_WC+0x1c276, %r8 nop nop nop nop nop cmp %rbx, %rbx movb $0x51, (%r8) nop nop nop nop nop add $46224, %rbx // Load mov $0x88c, %r13 nop nop cmp $25069, %r15 mov (%r13), %edi nop nop nop xor %r13, %r13 // Store lea addresses_WT+0x81c0, %r9 nop nop xor %r15, %r15 movw $0x5152, (%r9) nop nop nop nop and %r8, %r8 // Store lea addresses_normal+0x15bb0, %rdi nop nop nop nop xor $50009, %r15 mov $0x5152535455565758, %r8 movq %r8, %xmm1 vmovups %ymm1, (%rdi) cmp $48115, %rdi // Store lea addresses_A+0x2528, %rdi sub %r9, %r9 mov $0x5152535455565758, %r10 movq %r10, (%rdi) add %rdi, %rdi // Store lea addresses_WT+0x1b820, %r10 nop nop nop nop sub $30752, %rdi movb $0x51, (%r10) nop nop nop nop nop xor %rbx, %rbx // Store lea addresses_WT+0x1fa20, %rdi nop inc %rbx movl $0x51525354, (%rdi) add $55702, %rdi // Store lea addresses_D+0x1b350, %rdi nop nop nop nop nop xor $12461, %r10 movw $0x5152, (%rdi) nop nop nop nop nop sub $20203, %rdi // Faulty Load mov $0x5a12e00000000c20, %r13 nop nop nop cmp $43162, %r15 movups (%r13), %xmm5 vpextrq $1, %xmm5, %r10 lea oracles, %r8 and $0xff, %r10 shlq $12, %r10 mov (%r8,%r10,1), %r10 pop %rdi pop %rbx pop %r9 pop %r8 pop %r15 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_NC', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_A', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WC', 'size': 1, 'AVXalign': False}} {'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_P', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_WT', 'size': 2, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_normal', 'size': 32, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_A', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_WT', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_WT', 'size': 4, 'AVXalign': True}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_D', 'size': 2, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_NC', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 9, 'NT': False, 'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}} {'45': 614, '44': 20531, '00': 318, '49': 366} 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 44 44 44 44 44 44 44 44 44 49 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 45 44 44 44 44 44 44 44 44 44 44 44 44 44 44 49 44 44 44 44 44 44 45 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 49 44 44 44 44 44 00 44 44 44 44 44 44 45 44 44 44 44 45 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 49 44 44 44 44 44 44 44 44 44 44 49 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 44 44 00 44 44 44 44 44 45 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 44 44 44 44 44 44 44 44 49 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 49 44 44 44 44 44 44 44 44 44 44 44 45 44 44 44 44 44 44 44 45 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 49 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 49 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 49 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 49 44 49 44 44 44 45 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 49 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 45 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 44 44 44 44 44 44 44 */
allinstr.asm
JayTee42/MimaSim
0
104397
<reponame>JayTee42/MimaSim ADD 0xFF0 // DEBUG: does not make any sense, but includes all instructions AND 0xFF0 OR 0xFF0 XOR 0xFF0 LDV 0xFF0 STV 0xFF0 LDC 0 JMP 0x8 JMN 0x9 EQL 0xFF0 NOT RAR RRN 0 HLT 0xFF0 0
Categories/Preorder.agda
copumpkin/categories
98
8119
<filename>Categories/Preorder.agda module Categories.Preorder where
alloy4fun_models/trashltl/models/18/SYXawMEEFRkzZmAnZ.als
Kaixi26/org.alloytools.alloy
0
4601
<gh_stars>0 open main pred idSYXawMEEFRkzZmAnZ_prop19 { always all f: (Protected - Trash) | eventually f in Trash } pred __repair { idSYXawMEEFRkzZmAnZ_prop19 } check __repair { idSYXawMEEFRkzZmAnZ_prop19 <=> prop19o }
thirdparty/adasdl/thin/adasdl/AdaSDL/binding/bind_check/verify_ada_sizes.adb
Lucretia/old_nehe_ada95
0
9484
<gh_stars>0 with Ada.Text_IO; use Ada.Text_IO; with SDL_Ada_Sizes; use SDL_Ada_Sizes; with SDL.Types; with SDL.Cdrom; with SDL.Events; with Interfaces.C; procedure Verify_Ada_Sizes is package C renames Interfaces.C; package AI is new Ada.Text_IO.Integer_IO (Integer); package CI is new Ada.Text_IO.Integer_IO (C.int); use type C.int; No_Failure : Boolean := True; -- ============================================= procedure Comparison ( name : String; A_Size : Integer; C_Size : C.int) is A_Size_Bytes : integer := A_Size / C.CHAR_BIT; begin Put ("Testing "); Put_Line(name); if Integer (C_Size) /= A_Size_Bytes then Put ("Incompatibility in byte sizes of type : "); Put (name); Put ("; Ada size = "); AI.Put (A_Size_Bytes, 4); Put ("; C size = "); CI.Put (C_Size, 4); New_line; No_Failure := No_Failure and False; end if; No_Failure := No_Failure and True; end; -- ============================================= begin Put_Line ("************* STARTING TYPES COMPARISON ******************"); Comparison ("Uint8", SDL.Types.Uint8'size, Uint8_Size); Comparison ("CDtrack", SDL.Cdrom.CDtrack'size, SDL_CDtrack_Size); comparison ("CD", SDL.Cdrom.CD'size, SDL_CD_Size); comparison ("JoyAxisEvent", SDL.Events.JoyAxisEvent'Size, SDL_JoyAxisEvent_Size); comparison ("JoyBallEvent", SDL.Events.JoyBallEvent'Size, SDL_JoyBallEvent_Size); comparison ("JoyHatEvent", SDL.Events.JoyHatEvent'Size, SDL_JoyHatEvent_Size); comparison ("JoyButtonEvent", SDL.Events.JoyButtonEvent'Size, SDL_JoyButtonEvent_Size); comparison ("Event", SDL.Events.Event'Size, SDL_Event_Size); if No_Failure then Put_Line ("The tested sizes are all correct"); else Put_Line ("Some sizes are not correct"); end if; Put_Line ("************** END OF TYPES COMPARISON ******************"); end Verify_Ada_Sizes;
1581/64tass/crc.asm
silverdr/assembly
23
104522
<gh_stars>10-100 ;CRC GENERATOR/CHECKER 04/17/86 ; POLYNOMIAL: X^16 + X^12 + X^5 + 1 ; INITIALIZED STATE: B230h (PRELOADED WITH A1h,A1h,A1h,FEh) ; SHIFTING CHARACTERS: TRACK,SIDE,SECTOR,SECTOR_LENGTH,CRC,CRC crcheader .proc lda tmp pha lda tmp+1 pha lda tmp+2 pha lda tmp+3 pha lda tmp+4 pha lda tmp+5 pha lda tmp+6 pha lda #$30 sta tmp+5 ; sig_lo lda #$B2 sta tmp+6 ; sig_hi (3) A1H, (1) FEH ldy #0 m1 lda header,y sta tmp+1 ; msb tax iny lda header,y sta tmp ; lsb txa ldx #16 m2 sta tmp+2 clc rol tmp rol tmp+1 lda #0 sta tmp+3 sta tmp+4 bit tmp+2 bpl + lda #$21 sta tmp+3 lda #$10 sta tmp+4 + bit tmp+6 bpl + lda tmp+3 eor #$21 sta tmp+3 lda tmp+4 eor #$10 sta tmp+4 + clc rol tmp+5 rol tmp+6 lda tmp+5 eor tmp+3 sta tmp+5 lda tmp+6 eor tmp+4 sta tmp+6 lda tmp+1 dex bne m2 iny cpy #5 bcc m1 ldy tmp+5 ldx tmp+6 pla sta tmp+6 pla sta tmp+5 pla sta tmp+4 pla sta tmp+3 pla sta tmp+2 pla sta tmp+1 pla sta tmp cpy #0 ; must be zero bne + cpx #0 ; * bne + clc rts + lda #9 ; crc header in header jmp errr ; bye bye .... .pend
programs/oeis/268/A268292.asm
jmorken/loda
1
6269
<gh_stars>1-10 ; A268292: a(n) is the total number of isolated 1's at the boundary between n-th and (n-1)-th iterations in the pattern of A267489. ; 0,0,0,0,0,0,0,1,3,5,7,9,11,14,18,22,26,30,34,39,45,51,57,63,69,76,84,92,100,108,116,125,135,145,155,165,175,186,198,210,222,234,246,259,273,287,301,315,329,344,360,376,392,408,424,441 lpb $0 trn $0,6 trn $1,1 add $1,$0 add $1,$0 lpe
oeis/323/A323117.asm
neoneye/loda-programs
11
27440
; A323117: a(n) = T_{n}(n-1) where T_{n}(x) is a Chebyshev polynomial of the first kind. ; Submitted by <NAME> ; 1,0,1,26,577,15124,470449,17057046,708158977,33165873224,1730726404001,99612037019890,6269617090376641,428438743526336412,31592397706723526737,2500433598371461203374,211434761022028192051201,19023879409608991280267536,1814760628704486452002305601,182954529286351218755341206858,19436609957075163398170578312001,2170322914970859497558286272480420,254116819101915322117548795461866481,31132792074611632960462317474979197382,3983168088007489839688132918019106009601 mov $3,$0 sub $3,2 mul $3,2 mov $4,1 lpb $0 sub $0,1 add $1,1 add $2,$3 mul $2,$1 add $4,$2 add $1,$4 mov $2,0 lpe mov $0,$4 add $0,1 div $0,2
gfx/pokemon/unown_frame_pointers.asm
Dev727/ancientplatinum
28
95607
<reponame>Dev727/ancientplatinum<filename>gfx/pokemon/unown_frame_pointers.asm UnownFramesPointers: dw UnownAFrames dw UnownBFrames dw UnownCFrames dw UnownDFrames dw UnownEFrames dw UnownFFrames dw UnownGFrames dw UnownHFrames dw UnownIFrames dw UnownJFrames dw UnownKFrames dw UnownLFrames dw UnownMFrames dw UnownNFrames dw UnownOFrames dw UnownPFrames dw UnownQFrames dw UnownRFrames dw UnownSFrames dw UnownTFrames dw UnownUFrames dw UnownVFrames dw UnownWFrames dw UnownXFrames dw UnownYFrames dw UnownZFrames
1-base/lace/source/text/lace-text-cursor.adb
charlie5/lace
20
10473
with ada.Characters.latin_1, ada.Strings.fixed, ada.strings.Maps; package body lace.text.Cursor is use ada.Strings; Integer_Numerals : constant maps.character_Set := maps.to_Set ("+-0123456789"); Float_Numerals : constant maps.character_Set := maps.to_Set ("+-0123456789."); -- Forge -- function First (of_Text : access constant Text.item) return Cursor.item is the_Cursor : constant Cursor.item := (of_Text.all'unchecked_Access, 1); begin return the_Cursor; end First; -- Attributes -- function at_End (Self : in Item) return Boolean is begin return Self.Current = 0; end at_End; function has_Element (Self : in Item) return Boolean is begin return not at_End (Self) and Self.Current <= Self.Target.Length; end has_Element; procedure advance (Self : in out Item; Delimiter : in String := " "; Repeat : in Natural := 0; skip_Delimiter : in Boolean := True) is begin for Count in 1 .. Repeat + 1 loop declare delimiter_Position : Natural; begin delimiter_Position := fixed.Index (Self.Target.Data, Delimiter, from => Self.Current); if delimiter_Position = 0 then Self.Current := 0; return; else if skip_Delimiter then Self.Current := delimiter_Position + Delimiter'Length; elsif Count = Repeat + 1 then Self.Current := delimiter_Position - 1; else Self.Current := delimiter_Position + Delimiter'Length - 1; end if; end if; end; end loop; exception when constraint_Error => raise at_end_Error; end advance; procedure skip_White (Self : in out Item) is begin while has_Element (Self) and then ( Self.Target.Data (Self.Current) = ' ' or Self.Target.Data (Self.Current) = ada.Characters.Latin_1.CR or Self.Target.Data (Self.Current) = ada.Characters.Latin_1.LF or Self.Target.Data (Self.Current) = ada.Characters.Latin_1.HT) loop Self.Current := Self.Current + 1; end loop; end skip_White; function next_Token (Self : in out Item; Delimiter : in Character := ' '; Trim : in Boolean := False) return String is begin return next_Token (Self, "" & Delimiter, Trim); end next_Token; function next_Token (Self : in out item; Delimiter : in String := " "; Trim : in Boolean := False) return String is begin if at_End (Self) then raise at_end_Error; end if; declare use ada.Strings.fixed; delimiter_Position : constant Natural := Index (Self.Target.Data, Delimiter, from => Self.Current); begin if delimiter_Position = 0 then return the_Token : constant String := (if Trim then fixed.Trim (Self.Target.Data (Self.Current .. Self.Target.Length), Both) else Self.Target.Data (Self.Current .. Self.Target.Length)) do Self.Current := 0; end return; end if; return the_Token : constant String := (if Trim then fixed.Trim (Self.Target.Data (Self.Current .. delimiter_Position - 1), Both) else Self.Target.Data (Self.Current .. delimiter_Position - 1)) do Self.Current := delimiter_Position + Delimiter'Length; end return; end; end next_Token; procedure skip_Token (Self : in out Item; Delimiter : in String := " ") is ignored_Token : String := Self.next_Token (Delimiter); begin null; end skip_Token; function get_Integer (Self : in out Item) return Integer is use ada.Strings.fixed; Text : String (1 .. Self.Length); First : Positive; Last : Natural; begin Text := Self.Target.Data (Self.Current .. Self.Target.Length); find_Token (Text, integer_Numerals, Inside, First, Last); if Last = 0 then raise No_Data_Error; end if; Self.Current := Self.Current + Last; return Integer'Value (Text (First .. Last)); end get_Integer; function get_Real (Self : in out Item) return long_Float is use ada.Strings.fixed; Text : String (1 .. Self.Length); First : Positive; Last : Natural; begin Text := Self.Target.Data (Self.Current .. Self.Target.Length); find_Token (Text, float_Numerals, Inside, First, Last); if Last = 0 then raise No_Data_Error; end if; Self.Current := Self.Current + Last; return long_Float'Value (Text (First .. Last)); end get_Real; function Length (Self : in Item) return Natural is begin return Self.Target.Length - Self.Current + 1; end Length; function Peek (Self : in Item; Length : in Natural := Remaining) return String is Last : constant Natural := (if Length = Natural'Last then Self.Target.Length else Self.Current + Length - 1); begin if at_End (Self) then return ""; end if; return Self.Target.Data (Self.Current .. Last); end Peek; end lace.text.Cursor;
projects/batfish/src/main/antlr4/org/batfish/grammar/fortios/Fortios_firewall.g4
jawyoonis/batfish
0
3393
parser grammar Fortios_firewall; options { tokenVocab = FortiosLexer; } c_firewall: FIREWALL cf_service;
libsrc/_DEVELOPMENT/math/float/am9511/lam32/z80/asm_atanf.asm
ahjelm/z88dk
640
94058
<filename>libsrc/_DEVELOPMENT/math/float/am9511/lam32/z80/asm_atanf.asm ; float _atanf (float number) __z88dk_fastcall SECTION code_clib SECTION code_fp_am9511 PUBLIC asm_atanf EXTERN asm_am9511_atan_fastcall ; square (^2) sccz80 float ; ; enter : stack = ret ; DEHL = sccz80_float number ; ; exit : DEHL = sccz80_float(atan(number)) ; ; uses : af, bc, de, hl, af' DEFC asm_atanf = asm_am9511_atan_fastcall ; enter stack = ret ; DEHL = IEEE-754 float ; return DEHL = IEEE-754 float
Validation/pyFrame3DD-master/gcc-master/gcc/ada/switch-c.adb
djamal2727/Main-Bearing-Analytical-Model
0
29140
<filename>Validation/pyFrame3DD-master/gcc-master/gcc/ada/switch-c.adb ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S W I T C H - C -- -- -- -- B o d y -- -- -- -- Copyright (C) 2001-2020, 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. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package is for switch processing and should not depend on higher level -- packages such as those for the scanner, parser, etc. Doing so may cause -- circularities, especially for back ends using Adabkend. with Debug; use Debug; with Errout; use Errout; with Lib; use Lib; with Osint; use Osint; with Opt; use Opt; with Stylesw; use Stylesw; with Targparm; use Targparm; with Ttypes; use Ttypes; with Validsw; use Validsw; with Warnsw; use Warnsw; with Ada.Unchecked_Deallocation; with System.WCh_Con; use System.WCh_Con; with System.OS_Lib; package body Switch.C is RTS_Specified : String_Access := null; -- Used to detect multiple use of --RTS= flag procedure Add_Symbol_Definition (Def : String); -- Add a symbol definition from the command line procedure Free is new Ada.Unchecked_Deallocation (String_List, String_List_Access); -- Avoid using System.Strings.Free, which also frees the designated strings function Get_Overflow_Mode (C : Character) return Overflow_Mode_Type; -- Given a digit in the range 0 .. 3, returns the corresponding value of -- Overflow_Mode_Type. Raises Program_Error if C is outside this range. function Switch_Subsequently_Cancelled (C : String; Args : String_List; Arg_Rank : Positive) return Boolean; -- This function is called from Scan_Front_End_Switches. It determines if -- the switch currently being scanned is followed by a switch of the form -- "-gnat-" & C, where C is the argument. If so, then True is returned, -- and Scan_Front_End_Switches will cancel the effect of the switch. If -- no such switch is found, False is returned. --------------------------- -- Add_Symbol_Definition -- --------------------------- procedure Add_Symbol_Definition (Def : String) is begin -- If Preprocessor_Symbol_Defs is not large enough, double its size if Preprocessing_Symbol_Last = Preprocessing_Symbol_Defs'Last then declare New_Symbol_Definitions : constant String_List_Access := new String_List (1 .. 2 * Preprocessing_Symbol_Last); begin New_Symbol_Definitions (Preprocessing_Symbol_Defs'Range) := Preprocessing_Symbol_Defs.all; Free (Preprocessing_Symbol_Defs); Preprocessing_Symbol_Defs := New_Symbol_Definitions; end; end if; Preprocessing_Symbol_Last := Preprocessing_Symbol_Last + 1; Preprocessing_Symbol_Defs (Preprocessing_Symbol_Last) := new String'(Def); end Add_Symbol_Definition; ----------------------- -- Get_Overflow_Mode -- ----------------------- function Get_Overflow_Mode (C : Character) return Overflow_Mode_Type is begin case C is when '1' => return Strict; when '2' => return Minimized; -- Eliminated allowed only if Long_Long_Integer is 64 bits (since -- the current implementation of System.Bignums assumes this). when '3' => if Standard_Long_Long_Integer_Size /= 64 then Bad_Switch ("-gnato3 not implemented for this configuration"); else return Eliminated; end if; when others => raise Program_Error; end case; end Get_Overflow_Mode; ----------------------------- -- Scan_Front_End_Switches -- ----------------------------- procedure Scan_Front_End_Switches (Switch_Chars : String; Args : String_List; Arg_Rank : Positive) is Max : constant Natural := Switch_Chars'Last; C : Character := ' '; Ptr : Natural; Dot : Boolean; -- This flag is set upon encountering a dot in a debug switch First_Char : Positive; -- Marks start of switch to be stored First_Ptr : Positive; -- Save position of first character after -gnatd (for checking that -- debug flags that must come first are first, in particular -gnatd.b). First_Switch : Boolean := True; -- False for all but first switch Store_Switch : Boolean; -- For -gnatxx switches, the normal processing, signalled by this flag -- being set to True, is to store the switch on exit from the case -- statement, the switch stored is -gnat followed by the characters -- from First_Char to Ptr-1. For cases like -gnaty, where the switch -- is stored in separate pieces, this flag is set to False, and the -- appropriate calls to Store_Compilation_Switch are made from within -- the case branch. Underscore : Boolean; -- This flag is set upon encountering an underscode in a debug switch begin Ptr := Switch_Chars'First; -- Skip past the initial character (must be the switch character) if Ptr = Max then Bad_Switch (C); else Ptr := Ptr + 1; end if; -- Handle switches that do not start with -gnat if Ptr + 3 > Max or else Switch_Chars (Ptr .. Ptr + 3) /= "gnat" then -- There are two front-end switches that do not start with -gnat: -- -I, --RTS if Switch_Chars (Ptr) = 'I' then -- Set flag Search_Directory_Present if switch is "-I" only: -- the directory will be the next argument. if Ptr = Max then Search_Directory_Present := True; return; end if; Ptr := Ptr + 1; -- Find out whether this is a -I- or regular -Ixxx switch -- Note: -I switches are not recorded in the ALI file, since the -- meaning of the program depends on the source files compiled, -- not where they came from. if Ptr = Max and then Switch_Chars (Ptr) = '-' then Look_In_Primary_Dir := False; else Add_Src_Search_Dir (Switch_Chars (Ptr .. Max)); end if; -- Processing of the --RTS switch. --RTS may have been modified by -- gcc into -fRTS (for GCC targets). elsif Ptr + 3 <= Max and then (Switch_Chars (Ptr .. Ptr + 3) = "fRTS" or else Switch_Chars (Ptr .. Ptr + 3) = "-RTS") then Ptr := Ptr + 1; if Ptr + 4 > Max or else Switch_Chars (Ptr + 3) /= '=' then Osint.Fail ("missing path for --RTS"); else declare Runtime_Dir : String_Access; begin if System.OS_Lib.Is_Absolute_Path (Switch_Chars (Ptr + 4 .. Max)) then Runtime_Dir := new String'(System.OS_Lib.Normalize_Pathname (Switch_Chars (Ptr + 4 .. Max))); else Runtime_Dir := new String'(Switch_Chars (Ptr + 4 .. Max)); end if; -- Valid --RTS switch Opt.No_Stdinc := True; Opt.RTS_Switch := True; RTS_Src_Path_Name := Get_RTS_Search_Dir (Runtime_Dir.all, Include); RTS_Lib_Path_Name := Get_RTS_Search_Dir (Runtime_Dir.all, Objects); if RTS_Specified /= null then if RTS_Src_Path_Name = null or else RTS_Lib_Path_Name = null or else System.OS_Lib.Normalize_Pathname (RTS_Specified.all) /= System.OS_Lib.Normalize_Pathname (RTS_Lib_Path_Name.all) then Osint.Fail ("--RTS cannot be specified multiple times"); end if; elsif RTS_Src_Path_Name /= null and then RTS_Lib_Path_Name /= null then -- Store the -fRTS switch (Note: Store_Compilation_Switch -- changes -fRTS back into --RTS for the actual output). Store_Compilation_Switch (Switch_Chars); RTS_Specified := new String'(RTS_Lib_Path_Name.all); elsif RTS_Src_Path_Name = null and then RTS_Lib_Path_Name = null then Osint.Fail ("RTS path not valid: missing " & "adainclude and adalib directories"); elsif RTS_Src_Path_Name = null then Osint.Fail ("RTS path not valid: missing " & "adainclude directory"); elsif RTS_Lib_Path_Name = null then Osint.Fail ("RTS path not valid: missing " & "adalib directory"); end if; end; end if; -- There are no other switches not starting with -gnat else Bad_Switch (Switch_Chars); end if; -- Case of switch starting with -gnat else Ptr := Ptr + 4; -- Loop to scan through switches given in switch string while Ptr <= Max loop First_Char := Ptr; Store_Switch := True; C := Switch_Chars (Ptr); case C is -- -gnata (assertions enabled) when 'a' => Ptr := Ptr + 1; Assertions_Enabled := True; -- -gnatA (disregard gnat.adc) when 'A' => Ptr := Ptr + 1; Config_File := False; -- -gnatb (brief messages to stderr) when 'b' => Ptr := Ptr + 1; Brief_Output := True; -- -gnatB (assume no invalid values) when 'B' => Ptr := Ptr + 1; Assume_No_Invalid_Values := True; -- -gnatc (check syntax and semantics only) when 'c' => if not First_Switch then Osint.Fail ("-gnatc must be first if combined with other switches"); end if; Ptr := Ptr + 1; Operating_Mode := Check_Semantics; -- -gnatC (Generate CodePeer information) when 'C' => Ptr := Ptr + 1; CodePeer_Mode := True; -- -gnatd (compiler debug options) when 'd' => Dot := False; Store_Switch := False; Underscore := False; First_Ptr := Ptr + 1; -- Note: for the debug switch, the remaining characters in this -- switch field must all be debug flags, since all valid switch -- characters are also valid debug characters. -- Loop to scan out debug flags while Ptr < Max loop Ptr := Ptr + 1; C := Switch_Chars (Ptr); exit when C = ASCII.NUL or else C = '/' or else C = '-'; if C in '1' .. '9' or else C in 'a' .. 'z' or else C in 'A' .. 'Z' then -- Case of dotted flag if Dot then Set_Dotted_Debug_Flag (C); Store_Compilation_Switch ("-gnatd." & C); -- Special check, -gnatd.b must come first if C = 'b' and then (Ptr /= First_Ptr + 1 or else not First_Switch) then Osint.Fail ("-gnatd.b must be first if combined with other " & "switches"); end if; -- Case of an underscored flag elsif Underscore then Set_Underscored_Debug_Flag (C); Store_Compilation_Switch ("-gnatd_" & C); -- Normal flag else Set_Debug_Flag (C); Store_Compilation_Switch ("-gnatd" & C); end if; elsif C = '.' then Dot := True; elsif C = '_' then Underscore := True; elsif Dot then Bad_Switch ("-gnatd." & Switch_Chars (Ptr .. Max)); elsif Underscore then Bad_Switch ("-gnatd_" & Switch_Chars (Ptr .. Max)); else Bad_Switch ("-gnatd" & Switch_Chars (Ptr .. Max)); end if; end loop; return; -- -gnatD (debug expanded code) when 'D' => Ptr := Ptr + 1; -- Not allowed if previous -gnatR given -- The reason for this prohibition is that the rewriting of -- Sloc values causes strange malfunctions in the tests of -- whether units belong to the main source. This is really a -- bug, but too hard to fix for a marginal capability ??? -- The proper fix is to completely redo -gnatD processing so -- that the tree is not messed with, and instead a separate -- table is built on the side for debug information generation. if List_Representation_Info /= 0 then Osint.Fail ("-gnatD not permitted since -gnatR given previously"); end if; -- Scan optional integer line limit value if Nat_Present (Switch_Chars, Max, Ptr) then Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'D'); Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40); end if; -- Note: -gnatD also sets -gnatx (to turn off cross-reference -- generation in the ali file) since otherwise this generation -- gets confused by the "wrong" Sloc values put in the tree. Debug_Generated_Code := True; Xref_Active := False; Set_Debug_Flag ('g'); -- -gnate? (extended switches) when 'e' => Ptr := Ptr + 1; -- The -gnate? switches are all double character switches -- so we must always have a character after the e. if Ptr > Max then Bad_Switch ("-gnate"); end if; case Switch_Chars (Ptr) is -- -gnatea (initial delimiter of explicit switches) -- This is an internal switch -- All switches that come before -gnatea have been added by -- the GCC driver and are not stored in the ALI file. -- See also -gnatez below. when 'a' => Store_Switch := False; Enable_Switch_Storing; Ptr := Ptr + 1; -- -gnateA (aliasing checks on parameters) when 'A' => Ptr := Ptr + 1; Check_Aliasing_Of_Parameters := True; -- -gnatec (configuration pragmas) when 'c' => Store_Switch := False; Ptr := Ptr + 1; -- There may be an equal sign between -gnatec and -- the path name of the config file. if Ptr <= Max and then Switch_Chars (Ptr) = '=' then Ptr := Ptr + 1; end if; if Ptr > Max then Bad_Switch ("-gnatec"); end if; declare Config_File_Name : constant String_Access := new String' (Switch_Chars (Ptr .. Max)); begin if Config_File_Names = null then Config_File_Names := new String_List'(1 => Config_File_Name); else declare New_Names : constant String_List_Access := new String_List (1 .. Config_File_Names'Length + 1); begin for Index in Config_File_Names'Range loop New_Names (Index) := Config_File_Names (Index); Config_File_Names (Index) := null; end loop; New_Names (New_Names'Last) := Config_File_Name; Free (Config_File_Names); Config_File_Names := New_Names; end; end if; end; return; -- -gnateC switch (generate CodePeer messages) when 'C' => Ptr := Ptr + 1; if not Generate_CodePeer_Messages then Generate_CodePeer_Messages := True; CodePeer_Mode := True; Warning_Mode := Normal; Warning_Doc_Switch := True; -- -gnatw.d -- Enable warnings potentially useful for non GNAT -- users. Constant_Condition_Warnings := True; -- -gnatwc Warn_On_Assertion_Failure := True; -- -gnatw.a Warn_On_Assumed_Low_Bound := True; -- -gnatww Warn_On_Bad_Fixed_Value := True; -- -gnatwb Warn_On_Biased_Representation := True; -- -gnatw.b Warn_On_Export_Import := True; -- -gnatwx Warn_On_No_Value_Assigned := True; -- -gnatwv Warn_On_Object_Renames_Function := True; -- -gnatw.r Warn_On_Overlap := True; -- -gnatw.i Warn_On_Parameter_Order := True; -- -gnatw.p Warn_On_Questionable_Missing_Parens := True; -- -gnatwq Warn_On_Redundant_Constructs := True; -- -gnatwr Warn_On_Suspicious_Modulus_Value := True; -- -gnatw.m end if; -- -gnated switch (disable atomic synchronization) when 'd' => Suppress_Options.Suppress (Atomic_Synchronization) := True; -- -gnateD switch (preprocessing symbol definition) when 'D' => Store_Switch := False; Ptr := Ptr + 1; if Ptr > Max then Bad_Switch ("-gnateD"); end if; Add_Symbol_Definition (Switch_Chars (Ptr .. Max)); -- Store the switch Store_Compilation_Switch ("-gnateD" & Switch_Chars (Ptr .. Max)); Ptr := Max + 1; -- -gnateE (extra exception information) when 'E' => Exception_Extra_Info := True; Ptr := Ptr + 1; -- -gnatef (full source path for brief error messages) when 'f' => Store_Switch := False; Ptr := Ptr + 1; Full_Path_Name_For_Brief_Errors := True; -- -gnateF (Check_Float_Overflow) when 'F' => Ptr := Ptr + 1; Check_Float_Overflow := not Machine_Overflows_On_Target; -- -gnateg (generate C code) when 'g' => -- Special check, -gnateg must occur after -gnatc if Operating_Mode /= Check_Semantics then Osint.Fail ("gnateg requires previous occurrence of -gnatc"); end if; Generate_C_Code := True; Ptr := Ptr + 1; -- -gnateG (save preprocessor output) when 'G' => Generate_Processed_File := True; Ptr := Ptr + 1; -- -gnatei (max number of instantiations) when 'i' => Ptr := Ptr + 1; Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Instantiations, C); -- -gnateI (index of unit in multi-unit source) when 'I' => Ptr := Ptr + 1; Scan_Pos (Switch_Chars, Max, Ptr, Multiple_Unit_Index, C); -- -gnatel when 'l' => Ptr := Ptr + 1; Elab_Info_Messages := True; -- -gnateL when 'L' => Ptr := Ptr + 1; Elab_Info_Messages := False; -- -gnatem (mapping file) when 'm' => Store_Switch := False; Ptr := Ptr + 1; -- There may be an equal sign between -gnatem and -- the path name of the mapping file. if Ptr <= Max and then Switch_Chars (Ptr) = '=' then Ptr := Ptr + 1; end if; if Ptr > Max then Bad_Switch ("-gnatem"); end if; Mapping_File_Name := new String'(Switch_Chars (Ptr .. Max)); return; -- -gnaten (memory to allocate for nodes) when 'n' => Ptr := Ptr + 1; Scan_Pos (Switch_Chars, Max, Ptr, Nodes_Size_In_Meg, C); -- -gnateO= (object path file) -- This is an internal switch when 'O' => Store_Switch := False; Ptr := Ptr + 1; -- Check for '=' if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then Bad_Switch ("-gnateO"); else Object_Path_File_Name := new String'(Switch_Chars (Ptr + 1 .. Max)); end if; return; -- -gnatep (preprocessing data file) when 'p' => Store_Switch := False; Ptr := Ptr + 1; -- There may be an equal sign between -gnatep and -- the path name of the mapping file. if Ptr <= Max and then Switch_Chars (Ptr) = '=' then Ptr := Ptr + 1; end if; if Ptr > Max then Bad_Switch ("-gnatep"); end if; Preprocessing_Data_File := new String'(Switch_Chars (Ptr .. Max)); -- Store the switch, normalizing to -gnatep= Store_Compilation_Switch ("-gnatep=" & Preprocessing_Data_File.all); Ptr := Max + 1; -- -gnateP (Treat pragma Pure/Preelaborate errs as warnings) when 'P' => Treat_Categorization_Errors_As_Warnings := True; Ptr := Ptr + 1; -- -gnates=file (specify extra file switches for gnat2why) -- This is an internal switch when 's' => if not First_Switch then Osint.Fail ("-gnates must not be combined with other switches"); end if; -- Check for '=' Ptr := Ptr + 1; if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then Bad_Switch ("-gnates"); else SPARK_Switches_File_Name := new String'(Switch_Chars (Ptr + 1 .. Max)); end if; return; -- -gnateS (generate SCO information) -- Include Source Coverage Obligation information in ALI -- files for use by source coverage analysis tools -- (gnatcov) (equivalent to -fdump-scos, provided for -- backwards compatibility). when 'S' => Generate_SCO := True; Generate_SCO_Instance_Table := True; Ptr := Ptr + 1; -- -gnatet (write target dependent information) when 't' => if not First_Switch then Osint.Fail ("-gnatet must not be combined with other switches"); end if; -- Check for '=' Ptr := Ptr + 1; if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then Bad_Switch ("-gnatet"); else Target_Dependent_Info_Write_Name := new String'(Switch_Chars (Ptr + 1 .. Max)); end if; return; -- -gnateT (read target dependent information) when 'T' => if not First_Switch then Osint.Fail ("-gnateT must not be combined with other switches"); end if; -- Check for '=' Ptr := Ptr + 1; if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then Bad_Switch ("-gnateT"); else -- This parameter was stored by Set_Targ earlier pragma Assert (Target_Dependent_Info_Read_Name.all = Switch_Chars (Ptr + 1 .. Max)); null; end if; return; -- -gnateu (unrecognized y,V,w switches) when 'u' => Ignore_Unrecognized_VWY_Switches := True; Ptr := Ptr + 1; -- -gnateV (validity checks on parameters) when 'V' => Ptr := Ptr + 1; Check_Validity_Of_Parameters := True; -- -gnateY (ignore Style_Checks pragmas) when 'Y' => Ignore_Style_Checks_Pragmas := True; Ptr := Ptr + 1; -- -gnatez (final delimiter of explicit switches) -- This is an internal switch -- All switches that come after -gnatez have been added by -- the GCC driver and are not stored in the ALI file. See -- also -gnatea above. when 'z' => Store_Switch := False; Disable_Switch_Storing; Ptr := Ptr + 1; -- All other -gnate? switches are unassigned when others => Bad_Switch ("-gnate" & Switch_Chars (Ptr .. Max)); end case; -- -gnatE (dynamic elaboration checks) when 'E' => Ptr := Ptr + 1; Dynamic_Elaboration_Checks := True; -- -gnatf (full error messages) when 'f' => Ptr := Ptr + 1; All_Errors_Mode := True; -- -gnatF (overflow of predefined float types) when 'F' => Ptr := Ptr + 1; External_Name_Exp_Casing := Uppercase; External_Name_Imp_Casing := Uppercase; -- -gnatg (GNAT implementation mode) when 'g' => Ptr := Ptr + 1; GNAT_Mode := True; GNAT_Mode_Config := True; Identifier_Character_Set := 'n'; System_Extend_Unit := Empty; Warning_Mode := Treat_As_Error; Style_Check_Main := True; Ada_Version := Ada_2012; Ada_Version_Explicit := Ada_2012; Ada_Version_Pragma := Empty; -- Set default warnings and style checks for -gnatg Set_GNAT_Mode_Warnings; Set_GNAT_Style_Check_Options; -- -gnatG (output generated code) when 'G' => Ptr := Ptr + 1; Print_Generated_Code := True; -- Scan optional integer line limit value if Nat_Present (Switch_Chars, Max, Ptr) then Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'G'); Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40); end if; -- -gnath (help information) when 'h' => Ptr := Ptr + 1; Usage_Requested := True; -- -gnatH (legacy static elaboration checking mode enabled) when 'H' => Ptr := Ptr + 1; Legacy_Elaboration_Checks := True; -- -gnati (character set) when 'i' => if Ptr = Max then Bad_Switch ("-gnati"); end if; Ptr := Ptr + 1; C := Switch_Chars (Ptr); if C in '1' .. '5' or else C = '8' or else C = '9' or else C = 'p' or else C = 'f' or else C = 'n' or else C = 'w' then Identifier_Character_Set := C; Ptr := Ptr + 1; else Bad_Switch ("-gnati" & Switch_Chars (Ptr .. Max)); end if; -- -gnatI (ignore representation clauses) when 'I' => Ptr := Ptr + 1; Ignore_Rep_Clauses := True; -- -gnatj (messages in limited length lines) when 'j' => Ptr := Ptr + 1; Scan_Nat (Switch_Chars, Max, Ptr, Error_Msg_Line_Length, C); -- -gnatJ (relaxed elaboration checking mode enabled) when 'J' => Ptr := Ptr + 1; Relaxed_Elaboration_Checks := True; -- Common relaxations for both ABE mechanisms -- -- -gnatd.G (ignore calls through generic formal parameters -- for elaboration) -- -gnatd.U (ignore indirect calls for static elaboration) -- -gnatd.y (disable implicit pragma Elaborate_All on task -- bodies) Debug_Flag_Dot_GG := True; Debug_Flag_Dot_UU := True; Debug_Flag_Dot_Y := True; -- Relaxatons to the legacy ABE mechanism if Legacy_Elaboration_Checks then null; -- Relaxations to the default ABE mechanism -- -- -gnatd_a (stop elaboration checks on accept or select -- statement) -- -gnatd_e (ignore entry calls and requeue statements for -- elaboration) -- -gnatd_i (ignore activations and calls to instances for -- elaboration) -- -gnatd_p (ignore assertion pragmas for elaboration) -- -gnatd_s (stop elaboration checks on synchronous -- suspension) -- -gnatdL (ignore external calls from instances for -- elaboration) else Debug_Flag_Underscore_A := True; Debug_Flag_Underscore_E := True; Debug_Flag_Underscore_I := True; Debug_Flag_Underscore_P := True; Debug_Flag_Underscore_S := True; Debug_Flag_LL := True; end if; -- -gnatk (limit file name length) when 'k' => Ptr := Ptr + 1; Scan_Pos (Switch_Chars, Max, Ptr, Maximum_File_Name_Length, C); -- -gnatl (output full source) when 'l' => Ptr := Ptr + 1; Full_List := True; -- There may be an equal sign between -gnatl and a file name if Ptr <= Max and then Switch_Chars (Ptr) = '=' then if Ptr = Max then Osint.Fail ("file name for -gnatl= is null"); else Opt.Full_List_File_Name := new String'(Switch_Chars (Ptr + 1 .. Max)); Ptr := Max + 1; end if; end if; -- -gnatL (corresponding source text) when 'L' => Ptr := Ptr + 1; Dump_Source_Text := True; -- -gnatm (max number or errors/warnings) when 'm' => Ptr := Ptr + 1; Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Messages, C); -- -gnatn (enable pragma Inline) when 'n' => Ptr := Ptr + 1; Inline_Active := True; -- There may be a digit (1 or 2) appended to the switch if Ptr <= Max then C := Switch_Chars (Ptr); if C in '1' .. '2' then Ptr := Ptr + 1; Inline_Level := Character'Pos (C) - Character'Pos ('0'); end if; end if; -- -gnatN (obsolescent) when 'N' => Ptr := Ptr + 1; Inline_Active := True; Front_End_Inlining := True; -- -gnato (overflow checks) when 'o' => Ptr := Ptr + 1; -- Case of -gnato0 (overflow checking turned off) if Ptr <= Max and then Switch_Chars (Ptr) = '0' then Ptr := Ptr + 1; Suppress_Options.Suppress (Overflow_Check) := True; -- We set strict mode in case overflow checking is turned -- on locally (also records that we had a -gnato switch). Suppress_Options.Overflow_Mode_General := Strict; Suppress_Options.Overflow_Mode_Assertions := Strict; -- All cases other than -gnato0 (overflow checking turned on) else Suppress_Options.Suppress (Overflow_Check) := False; -- Case of no digits after the -gnato if Ptr > Max or else Switch_Chars (Ptr) not in '1' .. '3' then Suppress_Options.Overflow_Mode_General := Strict; Suppress_Options.Overflow_Mode_Assertions := Strict; -- At least one digit after the -gnato else -- Handle first digit after -gnato Suppress_Options.Overflow_Mode_General := Get_Overflow_Mode (Switch_Chars (Ptr)); Ptr := Ptr + 1; -- Only one digit after -gnato, set assertions mode to be -- the same as general mode. if Ptr > Max or else Switch_Chars (Ptr) not in '1' .. '3' then Suppress_Options.Overflow_Mode_Assertions := Suppress_Options.Overflow_Mode_General; -- Process second digit after -gnato else Suppress_Options.Overflow_Mode_Assertions := Get_Overflow_Mode (Switch_Chars (Ptr)); Ptr := Ptr + 1; end if; end if; end if; -- -gnatO (specify name of the object file) -- This is an internal switch when 'O' => Store_Switch := False; Ptr := Ptr + 1; Output_File_Name_Present := True; -- -gnatp (suppress all checks) when 'p' => Ptr := Ptr + 1; -- Skip processing if cancelled by subsequent -gnat-p if Switch_Subsequently_Cancelled ("p", Args, Arg_Rank) then Store_Switch := False; else -- Set all specific options as well as All_Checks in the -- Suppress_Options array, excluding Elaboration_Check, -- since this is treated specially because we do not want -- -gnatp to disable static elaboration processing. Also -- exclude Atomic_Synchronization, since this is not a real -- check. for J in Suppress_Options.Suppress'Range loop if J /= Elaboration_Check and then J /= Atomic_Synchronization then Suppress_Options.Suppress (J) := True; end if; end loop; Validity_Checks_On := False; Opt.Suppress_Checks := True; -- Set overflow mode checking to strict in case it gets -- turned on locally (also signals that overflow checking -- has been specifically turned off). Suppress_Options.Overflow_Mode_General := Strict; Suppress_Options.Overflow_Mode_Assertions := Strict; end if; -- -gnatq (don't quit) when 'q' => Ptr := Ptr + 1; Try_Semantics := True; -- -gnatQ (always write ALI file) when 'Q' => Ptr := Ptr + 1; Force_ALI_File := True; Try_Semantics := True; -- -gnatr (restrictions as warnings) when 'r' => Ptr := Ptr + 1; Treat_Restrictions_As_Warnings := True; -- -gnatR (list rep. info) when 'R' => -- Not allowed if previous -gnatD given. See more extensive -- comments in the 'D' section for the inverse test. if Debug_Generated_Code then Osint.Fail ("-gnatR not permitted since -gnatD given previously"); end if; -- Set to annotate rep info, and set default -gnatR mode Back_Annotate_Rep_Info := True; List_Representation_Info := 1; -- Scan possible parameter Ptr := Ptr + 1; while Ptr <= Max loop C := Switch_Chars (Ptr); case C is when '0' .. '4' => List_Representation_Info := Character'Pos (C) - Character'Pos ('0'); when 's' => List_Representation_Info_To_File := True; when 'j' => List_Representation_Info_To_JSON := True; when 'm' => List_Representation_Info_Mechanisms := True; when 'e' => List_Representation_Info_Extended := True; when others => Bad_Switch ("-gnatR" & Switch_Chars (Ptr .. Max)); end case; Ptr := Ptr + 1; end loop; if List_Representation_Info_To_JSON and then List_Representation_Info_Extended then Osint.Fail ("-gnatRe is incompatible with -gnatRj"); end if; -- -gnats (syntax check only) when 's' => if not First_Switch then Osint.Fail ("-gnats must be first if combined with other switches"); end if; Ptr := Ptr + 1; Operating_Mode := Check_Syntax; -- -gnatS (print package Standard) when 'S' => Print_Standard := True; Ptr := Ptr + 1; -- -gnatT (change start of internal table sizes) when 'T' => Ptr := Ptr + 1; Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor, C); -- -gnatu (list units for compilation) when 'u' => Ptr := Ptr + 1; List_Units := True; -- -gnatU (unique tags) when 'U' => Ptr := Ptr + 1; Unique_Error_Tag := True; -- -gnatv (verbose mode) when 'v' => Ptr := Ptr + 1; Verbose_Mode := True; -- -gnatV (validity checks) when 'V' => Store_Switch := False; Ptr := Ptr + 1; if Ptr > Max then Bad_Switch ("-gnatV"); else declare OK : Boolean; begin Set_Validity_Check_Options (Switch_Chars (Ptr .. Max), OK, Ptr); if not OK then Bad_Switch ("-gnatV" & Switch_Chars (Ptr .. Max)); end if; for Index in First_Char + 1 .. Max loop Store_Compilation_Switch ("-gnatV" & Switch_Chars (Index)); end loop; end; end if; Ptr := Max + 1; -- -gnatw (warning modes) when 'w' => Store_Switch := False; Ptr := Ptr + 1; if Ptr > Max then Bad_Switch ("-gnatw"); end if; while Ptr <= Max loop C := Switch_Chars (Ptr); -- Case of dot switch if C = '.' and then Ptr < Max then Ptr := Ptr + 1; C := Switch_Chars (Ptr); if Set_Dot_Warning_Switch (C) then Store_Compilation_Switch ("-gnatw." & C); else Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max)); end if; -- Case of underscore switch elsif C = '_' and then Ptr < Max then Ptr := Ptr + 1; C := Switch_Chars (Ptr); if Set_Underscore_Warning_Switch (C) then Store_Compilation_Switch ("-gnatw_" & C); else Bad_Switch ("-gnatw_" & Switch_Chars (Ptr .. Max)); end if; -- Normal case else if Set_Warning_Switch (C) then Store_Compilation_Switch ("-gnatw" & C); else Bad_Switch ("-gnatw" & Switch_Chars (Ptr .. Max)); end if; end if; Ptr := Ptr + 1; end loop; return; -- -gnatW (wide character encoding method) when 'W' => Ptr := Ptr + 1; if Ptr > Max then Bad_Switch ("-gnatW"); end if; begin Wide_Character_Encoding_Method := Get_WC_Encoding_Method (Switch_Chars (Ptr)); exception when Constraint_Error => Bad_Switch ("-gnatW" & Switch_Chars (Ptr .. Max)); end; Wide_Character_Encoding_Method_Specified := True; Upper_Half_Encoding := Wide_Character_Encoding_Method in WC_Upper_Half_Encoding_Method; Ptr := Ptr + 1; -- -gnatx (suppress cross-ref information) when 'x' => Ptr := Ptr + 1; Xref_Active := False; -- -gnatX (language extensions) when 'X' => Ptr := Ptr + 1; Extensions_Allowed := True; Ada_Version := Ada_Version_Type'Last; Ada_Version_Explicit := Ada_Version_Type'Last; Ada_Version_Pragma := Empty; -- -gnaty (style checks) when 'y' => Ptr := Ptr + 1; Style_Check_Main := True; if Ptr > Max then Set_Default_Style_Check_Options; else Store_Switch := False; declare OK : Boolean; begin Set_Style_Check_Options (Switch_Chars (Ptr .. Max), OK, Ptr); if not OK then Osint.Fail ("bad -gnaty switch (" & Style_Msg_Buf (1 .. Style_Msg_Len) & ')'); end if; Ptr := First_Char + 1; while Ptr <= Max loop if Switch_Chars (Ptr) = 'M' then First_Char := Ptr; loop Ptr := Ptr + 1; exit when Ptr > Max or else Switch_Chars (Ptr) not in '0' .. '9'; end loop; Store_Compilation_Switch ("-gnaty" & Switch_Chars (First_Char .. Ptr - 1)); else Store_Compilation_Switch ("-gnaty" & Switch_Chars (Ptr)); Ptr := Ptr + 1; end if; end loop; end; end if; -- -gnatz (stub generation) when 'z' => -- -gnatz must be the first and only switch in Switch_Chars, -- and is a two-letter switch. if Ptr /= Switch_Chars'First + 5 or else (Max - Ptr + 1) > 2 then Osint.Fail ("-gnatz* may not be combined with other switches"); end if; if Ptr = Max then Bad_Switch ("-gnatz"); end if; Ptr := Ptr + 1; -- Only one occurrence of -gnat* is permitted if Distribution_Stub_Mode = No_Stubs then case Switch_Chars (Ptr) is when 'r' => Distribution_Stub_Mode := Generate_Receiver_Stub_Body; when 'c' => Distribution_Stub_Mode := Generate_Caller_Stub_Body; when others => Bad_Switch ("-gnatz" & Switch_Chars (Ptr .. Max)); end case; Ptr := Ptr + 1; else Osint.Fail ("only one -gnatz* switch allowed"); end if; -- -gnatZ (obsolescent) when 'Z' => Ptr := Ptr + 1; Osint.Fail ("-gnatZ is no longer supported: consider using --RTS=zcx"); -- Note on language version switches: whenever a new language -- version switch is added, Switch.M.Normalize_Compiler_Switches -- must be updated. -- -gnat83 when '8' => if Ptr = Max then Bad_Switch ("-gnat8"); end if; Ptr := Ptr + 1; if Switch_Chars (Ptr) /= '3' or else Latest_Ada_Only then Bad_Switch ("-gnat8" & Switch_Chars (Ptr .. Max)); else Ptr := Ptr + 1; Ada_Version := Ada_83; Ada_Version_Explicit := Ada_83; Ada_Version_Pragma := Empty; end if; -- -gnat95 when '9' => if Ptr = Max then Bad_Switch ("-gnat9"); end if; Ptr := Ptr + 1; if Switch_Chars (Ptr) /= '5' or else Latest_Ada_Only then Bad_Switch ("-gnat9" & Switch_Chars (Ptr .. Max)); else Ptr := Ptr + 1; Ada_Version := Ada_95; Ada_Version_Explicit := Ada_95; Ada_Version_Pragma := Empty; end if; -- -gnat05 when '0' => if Ptr = Max then Bad_Switch ("-gnat0"); end if; Ptr := Ptr + 1; if Switch_Chars (Ptr) /= '5' or else Latest_Ada_Only then Bad_Switch ("-gnat0" & Switch_Chars (Ptr .. Max)); else Ptr := Ptr + 1; Ada_Version := Ada_2005; Ada_Version_Explicit := Ada_2005; Ada_Version_Pragma := Empty; end if; -- -gnat12 when '1' => if Ptr = Max then Bad_Switch ("-gnat1"); end if; Ptr := Ptr + 1; if Switch_Chars (Ptr) /= '2' then Bad_Switch ("-gnat1" & Switch_Chars (Ptr .. Max)); else Ptr := Ptr + 1; Ada_Version := Ada_2012; Ada_Version_Explicit := Ada_2012; Ada_Version_Pragma := Empty; end if; -- -gnat2005 and -gnat2012 when '2' => if Ptr > Max - 3 then Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max)); elsif Switch_Chars (Ptr .. Ptr + 3) = "2005" and then not Latest_Ada_Only then Ada_Version := Ada_2005; elsif Switch_Chars (Ptr .. Ptr + 3) = "2012" then Ada_Version := Ada_2012; elsif Switch_Chars (Ptr .. Ptr + 3) = "2020" then Ada_Version := Ada_2020; else Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Ptr + 3)); end if; Ada_Version_Explicit := Ada_Version; Ada_Version_Pragma := Empty; Ptr := Ptr + 4; -- Switch cancellation, currently only -gnat-p is allowed. -- All we do here is the error checking, since the actual -- processing for switch cancellation is done by calls to -- Switch_Subsequently_Cancelled at the appropriate point. when '-' => -- Simple ignore -gnat-p if Switch_Chars = "-gnat-p" then return; -- Any other occurrence of minus is ignored. This is for -- maximum compatibility with previous version which ignored -- all occurrences of minus. else Store_Switch := False; Ptr := Ptr + 1; end if; -- We ignore '/' in switches, this is historical, still needed??? when '/' => Store_Switch := False; -- Anything else is an error (illegal switch character) when others => Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max)); end case; if Store_Switch then Store_Compilation_Switch ("-gnat" & Switch_Chars (First_Char .. Ptr - 1)); end if; First_Switch := False; end loop; end if; end Scan_Front_End_Switches; ----------------------------------- -- Switch_Subsequently_Cancelled -- ----------------------------------- function Switch_Subsequently_Cancelled (C : String; Args : String_List; Arg_Rank : Positive) return Boolean is begin -- Loop through arguments following the current one for Arg in Arg_Rank + 1 .. Args'Last loop if Args (Arg).all = "-gnat-" & C then return True; end if; end loop; -- No match found, not cancelled return False; end Switch_Subsequently_Cancelled; end Switch.C;
oeis/038/A038558.asm
neoneye/loda-programs
11
169883
<reponame>neoneye/loda-programs ; A038558: Smallest number with derivative n. ; Submitted by <NAME> ; 0,2,4,5,8,9,11,10,16,17,19,18,23,22,20,21,32,33,35,34,39,38,36,37,47,46,44,45,40,41,43,42,64,65,67,66,71,70,68,69,79,78,76,77,72,73,75,74,95,94,92,93,88,89,91,90,80,81,83,82,87,86,84,85,128,129,131,130,135,134,132,133,143,142,140,141,136,137,139,138,159,158,156,157,152,153,155,154,144,145,147,146,151,150,148,149,191,190,188,189 mul $0,2 mov $1,2 mov $2,2 lpb $0 div $0,2 sub $2,$3 mul $2,2 add $3,$0 mod $3,2 mov $4,$2 add $2,$1 mul $3,$4 add $1,$3 lpe mov $0,$2 div $0,4
source/amf/mof/cmof/amf-cmof-opaque_expressions.ads
svn2github/matreshka
24
16856
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- An opaque expression is an uninterpreted textual statement that denotes a -- (possibly empty) set of values when evaluated in a context. ------------------------------------------------------------------------------ with AMF.CMOF.Value_Specifications; with AMF.String_Collections; package AMF.CMOF.Opaque_Expressions is pragma Preelaborate; type CMOF_Opaque_Expression is limited interface and AMF.CMOF.Value_Specifications.CMOF_Value_Specification; type CMOF_Opaque_Expression_Access is access all CMOF_Opaque_Expression'Class; for CMOF_Opaque_Expression_Access'Storage_Size use 0; not overriding function Get_Body (Self : not null access constant CMOF_Opaque_Expression) return AMF.String_Collections.Sequence_Of_String is abstract; -- Getter of OpaqueExpression::body. -- -- The text of the expression, possibly in multiple languages. not overriding function Get_Language (Self : not null access constant CMOF_Opaque_Expression) return AMF.String_Collections.Ordered_Set_Of_String is abstract; -- Getter of OpaqueExpression::language. -- -- Specifies the languages in which the expression is stated. The -- interpretation of the expression body depends on the languages. If the -- languages are unspecified, they might be implicit from the expression -- body or the context. Languages are matched to body strings by order. end AMF.CMOF.Opaque_Expressions;
kernel/src/interrupts/gdt.asm
inonitz/bruhOS
2
167340
<gh_stars>1-10 [bits 64] global load_gdt_internal load_gdt_internal: lgdt [rdi] mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax pop rdi mov rax, 0x08 push rax push rdi retfq
Transynther/x86/_processed/AVXALIGN/_ht_st_zr_un_/i3-7100_9_0x84_notsx.log_21829_1279.asm
ljhsiun2/medusa
9
82518
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r15 push %r8 push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0x9f2e, %rsi lea addresses_normal_ht+0x1915c, %rdi clflush (%rdi) nop nop nop nop nop sub $36830, %rbx mov $11, %rcx rep movsq nop nop nop nop nop add %r15, %r15 lea addresses_WC_ht+0x1c83a, %r13 nop nop nop nop cmp %r8, %r8 mov $0x6162636465666768, %rsi movq %rsi, %xmm2 vmovups %ymm2, (%r13) nop nop xor $9061, %rbx lea addresses_normal_ht+0x395a, %r8 clflush (%r8) nop nop nop cmp $41092, %r13 mov (%r8), %di nop and %rsi, %rsi lea addresses_A_ht+0x1654b, %r15 nop nop and $54145, %r8 movb $0x61, (%r15) nop nop nop xor $25188, %rsi lea addresses_D_ht+0x3560, %r13 clflush (%r13) nop nop nop nop nop inc %rdi mov $0x6162636465666768, %r15 movq %r15, %xmm4 vmovups %ymm4, (%r13) nop nop sub %r13, %r13 lea addresses_WT_ht+0xdb5a, %rsi lea addresses_D_ht+0x12e0a, %rdi nop nop nop xor $21887, %r12 mov $16, %rcx rep movsl nop nop nop nop add %rdi, %rdi lea addresses_UC_ht+0x11caa, %rsi lea addresses_WT_ht+0x1b15a, %rdi nop xor $44916, %rbx mov $75, %rcx rep movsw nop nop nop nop add $64178, %r15 lea addresses_normal_ht+0xf35a, %rdi nop nop sub $27185, %r13 vmovups (%rdi), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $0, %xmm4, %rcx add %rdi, %rdi lea addresses_D_ht+0x2092, %r12 nop nop and $24366, %r8 movl $0x61626364, (%r12) nop nop add $22822, %rcx lea addresses_normal_ht+0xd4a, %rdi nop add $17107, %r15 movl $0x61626364, (%rdi) nop xor %r8, %r8 lea addresses_UC_ht+0xb6da, %rsi nop nop nop nop nop inc %r12 mov $0x6162636465666768, %r13 movq %r13, (%rsi) add %rcx, %rcx lea addresses_A_ht+0x1115a, %r8 nop nop nop nop sub $35911, %rdi vmovups (%r8), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $0, %xmm2, %r13 nop add $50824, %r15 lea addresses_D_ht+0x1b19a, %rsi lea addresses_A_ht+0x1c2da, %rdi clflush (%rsi) inc %r8 mov $75, %rcx rep movsq dec %r8 lea addresses_WT_ht+0x12b32, %rsi lea addresses_normal_ht+0xa75a, %rdi nop nop nop nop add $23700, %r12 mov $90, %rcx rep movsw nop nop nop nop nop dec %rdi pop %rsi pop %rdi pop %rcx pop %rbx pop %r8 pop %r15 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r14 push %r8 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi // Store lea addresses_UC+0x13a9a, %rbx xor $49080, %r14 mov $0x5152535455565758, %rbp movq %rbp, %xmm2 movups %xmm2, (%rbx) nop nop nop nop sub $52541, %rbp // REPMOV lea addresses_RW+0x1295a, %rsi lea addresses_PSE+0xcfe4, %rdi inc %rax mov $124, %rcx rep movsb nop nop nop dec %rbp // REPMOV lea addresses_WC+0x815a, %rsi lea addresses_WT+0x11ada, %rdi nop nop nop nop nop cmp $8072, %rax mov $55, %rcx rep movsl nop nop nop nop cmp $32811, %r14 // Store lea addresses_A+0x1015a, %r14 nop add $38907, %rcx movl $0x51525354, (%r14) xor $15084, %r8 // Load lea addresses_WC+0x1c95a, %rbx nop nop nop nop nop sub $23407, %rbp movb (%rbx), %cl inc %rax // Store lea addresses_WC+0x1b05a, %rsi nop nop nop nop sub $4003, %rcx mov $0x5152535455565758, %rdi movq %rdi, (%rsi) nop nop and %rcx, %rcx // Faulty Load lea addresses_WC+0x815a, %rdi nop add $18776, %rcx vmovaps (%rdi), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $0, %xmm3, %rbx lea oracles, %r14 and $0xff, %rbx shlq $12, %rbx mov (%r14,%rbx,1), %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r8 pop %r14 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_WC', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 16, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_RW', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_PSE', 'congruent': 1, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WC', 'congruent': 0, 'same': True}, 'dst': {'type': 'addresses_WT', 'congruent': 6, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_A', 'same': False, 'size': 4, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WC', 'same': False, 'size': 1, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WC', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_WC', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 2, 'congruent': 11, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 32, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 32, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'} {'32': 937, 'f0': 1, '5a': 1, '6c': 1, '44': 6, 'd7': 1, '06': 2, 'd6': 1, '46': 89, '49': 37, '00': 20751, '45': 2} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
programs/oeis/057/A057050.asm
neoneye/loda
22
9932
; A057050: Let R(i,j) be the rectangle with antidiagonals 1; 2,3; 4,5,6; ...; each k is an R(i(k),j(k)) and A057050(n)=j(n^2). ; 1,3,2,6,4,1,7,3,11,6,16,10,3,15,7,21,12,2,18,7,25,13,33,20,6,28,13,37,21,4,30,12,40,21,1,31,10,42,20,54,31,7,43,18,56,30,3,43,15,57,28,72,42,11,57,25,73,40,6,56,21,73,37,91,54,16,72 add $0,1 pow $0,2 sub $0,1 seq $0,212012 ; Triangle read by rows in which row n lists the number of states of the subshells of the n-th shell of the nuclear shell model ordered by energy level in increasing order. div $0,2
PIM/TP3_Sous_Programmes/tours_de_hanoi.adb
Hathoute/ENSEEIHT
1
18616
-- Score PIXAL le 05/10/2020 à 17:27 : 100% with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure Tours_De_Hanoi is procedure Afficher_Deplacement(Debut: in Character; Fin: in Character) is begin Put_Line(Debut & " -> " & Fin); end Afficher_Deplacement; procedure Resoudre_Hanoi(N: in Integer; Debut: in Character; Interm: in Character; Fin: in Character) --with -- Pre => N >= 1 is begin if N <= 0 then -- Joue le rôle de la Precondition (sans jeter une exception) return; elsif N = 1 then Afficher_Deplacement(Debut, Fin); return; end if; -- Déplacer les N-1 premiers disques à l'intermediaire Resoudre_Hanoi(N-1, Debut, Fin, Interm); -- Déplacer le dernier à la fin Afficher_Deplacement(Debut, Fin); -- Déplacer le reste à la fin Resoudre_Hanoi(N-1, Interm, Debut, Fin); end Resoudre_Hanoi; Nb: Integer; -- Nombre de disque du jeu begin -- Demander le réel Put ("Nombre de disques : "); Get (Nb); -- Résoudre Hanoï avec NB disques et les tiges 'A' (départ), 'B' (intermédiaire) et 'C' (arrivée) Resoudre_Hanoi(Nb, 'A', 'B', 'C'); -- Questions: -- 1: A -> C -- 2: A -> B; A -> C; B -> C -- 3: On a N disque, il suffit, puisqu'on sait résoudre le problème pour N-1 disque, -- de déplacer les N-1 premières en B et après déplacer le dernier en C. -- Or puisque tous les disques sont petits que celui dans C, on se ramène encore -- en un problème à N-1 qu'on sait résoudre. end Tours_De_Hanoi;
alloy4fun_models/trashltl/models/15/NRDbtkjCxgZL5DgDT.als
Kaixi26/org.alloytools.alloy
0
1092
<reponame>Kaixi26/org.alloytools.alloy open main pred idNRDbtkjCxgZL5DgDT_prop16 { all f:File | historically f in Protected implies after f in Protected } pred __repair { idNRDbtkjCxgZL5DgDT_prop16 } check __repair { idNRDbtkjCxgZL5DgDT_prop16 <=> prop16o }
lib/Explore/Experimental/DataBitsSearch.agda
crypto-agda/explore
2
3010
<reponame>crypto-agda/explore<gh_stars>1-10 {-# OPTIONS --without-K #-} -- most of this is subsumed by crypto-agda Search code open import Type hiding (★) open import Data.Nat.NP hiding (_==_) renaming (_<=_ to _ℕ<=_) open import Data.Bits open import Data.Bit hiding (_==_) open import Data.Bool.Properties using (not-involutive) import Data.Vec.NP as V open V hiding (rewire; rewireTbl; sum) renaming (map to vmap; swap to vswap) import Relation.Binary.PropositionalEquality.NP as ≡ open ≡ open import Function.NP hiding (_→⟨_⟩_) open import Algebra.FunctionProperties.NP module Data.Bits.Search where module Search {i} {I : ★ i} (`1 : I) (`2*_ : I → I) {a} {A : I → ★ a} (_∙_ : ∀ {m} → A m → A m → A (`2* m)) where `2^_ : ℕ → I `2^_ = fold `1 `2*_ search : ∀ {n} → (Bits n → A `1) → A (`2^ n) search {zero} f = f [] search {suc n} f = search (f ∘ 0∷_) ∙ search (f ∘ 1∷_) searchBit : (Bit → A `1) → A (`2* `1) searchBit f = f 0b ∙ f 1b -- search-ext search-≗ : ∀ {n} (f g : Bits n → A `1) → f ≗ g → search f ≡ search g search-≗ {zero} f g f≗g = f≗g [] search-≗ {suc n} f g f≗g rewrite search-≗ (f ∘ 0∷_) (g ∘ 0∷_) (f≗g ∘ 0∷_) | search-≗ (f ∘ 1∷_) (g ∘ 1∷_) (f≗g ∘ 1∷_) = refl module Comm (∙-comm : ∀ {m} (x y : A m) → x ∙ y ≡ y ∙ x) where {- This pad bit vector allows to specify which bit do we negate in the vector. -} search-comm : ∀ {n} (pad : Bits n) (f : Bits n → A `1) → search f ≡ search (f ∘ _⊕_ pad) search-comm {zero} pad f = refl search-comm {suc n} (b ∷ pad) f rewrite search-comm pad (f ∘ 0∷_) | search-comm pad (f ∘ 1∷_) with b ... | true = ∙-comm (search (f ∘ 0∷_ ∘ _⊕_ pad)) _ ... | false = refl open Comm public module SimpleSearch {a} {A : ★ a} (_∙_ : A → A → A) where open Search 1 2*_ {A = const A} _∙_ public module SearchUnit ε (ε∙ε : ε ∙ ε ≡ ε) where search-constε≡ε : ∀ n → search {n = n} (const ε) ≡ ε search-constε≡ε zero = refl search-constε≡ε (suc n) rewrite search-constε≡ε n = ε∙ε searchBit-search : ∀ n (f : Bits (suc n) → A) → searchBit (λ b → search (f ∘ _∷_ b)) ≡ search f searchBit-search n f = refl search-≗₂ : ∀ {m n} (f g : Bits m → Bits n → A) → f ≗₂ g → search (search ∘ f) ≡ search (search ∘ g) search-≗₂ f g f≗g = search-≗ (search ∘ f) (search ∘ g) (λ xs → search-≗ (f xs) (g xs) (λ ys → f≗g xs ys)) search-+ : ∀ {m n} (f : Bits (m + n) → A) → search {m + n} f ≡ search {m} (λ xs → search {n} (λ ys → f (xs ++ ys))) search-+ {zero} f = refl search-+ {suc m} f rewrite search-+ {m} (f ∘ 0∷_) | search-+ {m} (f ∘ 1∷_) = refl module SearchInterchange (∙-interchange : Interchange _≡_ _∙_ _∙_) where search-dist : ∀ {n} (f₀ f₁ : Bits n → A) → search (λ x → f₀ x ∙ f₁ x) ≡ search f₀ ∙ search f₁ search-dist {zero} _ _ = refl search-dist {suc n} f₀ f₁ rewrite search-dist (f₀ ∘ 0∷_) (f₁ ∘ 0∷_) | search-dist (f₀ ∘ 1∷_) (f₁ ∘ 1∷_) = ∙-interchange _ _ _ _ search-searchBit : ∀ {n} (f : Bits (suc n) → A) → search (λ xs → searchBit (λ b → f (b ∷ xs))) ≡ search f search-searchBit f = search-dist (f ∘ 0∷_) (f ∘ 1∷_) search-search : ∀ {m n} (f : Bits (m + n) → A) → search {m} (λ xs → search {n} (λ ys → f (xs ++ ys))) ≡ search {n} (λ ys → search {m} (λ xs → f (xs ++ ys))) search-search {zero} f = refl search-search {suc m} {n} f rewrite search-search {m} {n} (f ∘ 0∷_) | search-search {m} {n} (f ∘ 1∷_) | search-searchBit {n} (λ { (b ∷ ys) → search {m} (λ xs → f (b ∷ xs ++ ys)) }) = refl {- -- It might also be done by using search-dist twice and commutativity of addition. -- However, this also affect 'f' and makes this proof actually longer. search-search {m} {n} f = search {m} (λ xs → search {n} (λ ys → f (xs ++ ys))) ≡⟨ {!!} ⟩ search {m + n} f ≡⟨ {!!} ⟩ search {n + m} (f ∘ vswap n) ≡⟨ {!!} ⟩ search {n} (λ ys → search {m} (λ xs → f (vswap n (ys ++ xs)))) ≡⟨ {!!} ⟩ search {n} (λ ys → search {m} (λ xs → f (xs ++ ys))) ∎ where open ≡-Reasoning -} search-swap : ∀ {m n} (f : Bits (m + n) → A) → search {n + m} (f ∘ vswap n) ≡ search {m + n} f search-swap {m} {n} f = search {n + m} (f ∘ vswap n) ≡⟨ search-+ {n} {m} (f ∘ vswap n) ⟩ search {n} (λ ys → search {m} (λ xs → f (vswap n (ys ++ xs)))) ≡⟨ search-≗₂ {n} {m} (λ ys → f ∘ vswap n ∘ _++_ ys) (λ ys → f ∘ flip _++_ ys) (λ ys xs → cong f (swap-++ n ys xs)) ⟩ search {n} (λ ys → search {m} (λ xs → f (xs ++ ys))) ≡⟨ sym (search-search {m} {n} f) ⟩ search {m} (λ xs → search {n} (λ ys → f (xs ++ ys))) ≡⟨ sym (search-+ {m} {n} f) ⟩ search {m + n} f ∎ where open ≡-Reasoning search-0↔1 : ∀ {n} (f : Bits n → A) → search {n} (f ∘ 0↔1) ≡ search {n} f search-0↔1 {zero} _ = refl search-0↔1 {suc zero} _ = refl search-0↔1 {suc (suc n)} _ = ∙-interchange _ _ _ _ module Bij (∙-comm : Commutative _≡_ _∙_) (∙-interchange : Interchange _≡_ _∙_ _∙_) where open SearchInterchange ∙-interchange using (search-0↔1) open import Data.Bits.OperationSyntax hiding (_∙_) search-bij : ∀ {n} f (g : Bits n → A) → search (g ∘ eval f) ≡ search g search-bij `id _ = refl search-bij `0↔1 f = search-0↔1 f search-bij (f `⁏ g) h rewrite search-bij f (h ∘ eval g) | search-bij g h = refl search-bij {suc n} (`id `∷ f) g rewrite search-bij (f 0b) (g ∘ 0∷_) | search-bij (f 1b) (g ∘ 1∷_) = refl search-bij {suc n} (`notᴮ `∷ f) g rewrite search-bij (f 1b) (g ∘ 0∷_) | search-bij (f 0b) (g ∘ 1∷_) = ∙-comm _ _ |de-morgan| : ∀ {n} (f g : Bits n → Bit) → f |∨| g ≗ not ∘ ((not ∘ f) |∧| (not ∘ g)) |de-morgan| f g x with f x ... | true = refl ... | false = sym (not-involutive _) open SimpleSearch search-de-morgan : ∀ {n} op (f g : Bits n → Bit) → search op (f |∨| g) ≡ search op (not ∘ ((not ∘ f) |∧| (not ∘ g))) search-de-morgan op f g = search-≗ op _ _ (|de-morgan| f g) search-hom : ∀ {n a b} {A : ★ a} {B : ★ b} (_+_ : A → A → A) (_*_ : B → B → B) (f : A → B) (p : Bits n → A) (hom : ∀ x y → f (x + y) ≡ f x * f y) → f (search _+_ p) ≡ search _*_ (f ∘ p) search-hom {zero} _ _ _ _ _ = refl search-hom {suc n} _+_ _*_ f p hom = trans (hom _ _) (cong₂ _*_ (search-hom _+_ _*_ f (p ∘ 0∷_) hom) (search-hom _+_ _*_ f (p ∘ 1∷_) hom))
grammar/JSONTable.g4
Blueswing/tableconverter
1
4627
/* Simplified JSON grammar Taken from "The Definitive ANTLR 4 Reference" by <NAME> Derived from http://json.org */ grammar JSONTable; table: arr EOF?; arr: '[' simpleObj (',' simpleObj)* ']' # objTable | '[' simpleArr (',' simpleArr)* ']' # arrTable | '[' ']' # arrTable; simpleObj: '{' pair (',' pair)* '}' | '{' '}'; simpleArr: '[' simpleValue (',' simpleValue)* ']' | '[' ']'; pair: STRING ':' simpleValue; simpleValue: STRING | INT | FLOAT | TRUE | FALSE | NULL; TRUE: 'true'; FALSE: 'false'; NULL: 'null'; STRING: '"' (ESC | SAFECODEPOINT)* '"'; fragment ESC: '\\' (["\\/bfnrt] | UNICODE); fragment UNICODE: 'u' HEX HEX HEX HEX; fragment HEX: [0-9a-fA-F]; fragment SAFECODEPOINT: ~ ["\\\u0000-\u001F]; FLOAT: '-'? INT '.' [0-9]+ | '-'? INT ('.' [0-9]+)? EXP; // no leading zeros INT: '0' | [1-9] [0-9]*; fragment EXP: [Ee] [+\-]? INT; // \- since - means "range" inside [...] WS: [ \t\n\r]+ -> skip;
Task/Pig-the-dice-game/Ada/pig-the-dice-game-3.ada
mullikine/RosettaCodeData
1
821
with Pig, Ada.Text_IO; procedure Play_Pig is use Pig; type Hand is new Actor with record Name: String(1 .. 5); end record; function Roll_More(A: Hand; Self, Opponent: Player'Class) return Boolean; function Roll_More(A: Hand; Self, Opponent: Player'Class) return Boolean is Ch: Character := ' '; use Ada.Text_IO; begin Put(A.Name & " you:" & Natural'Image(Self.Score) & " (opponent:" & Natural'Image(Opponent.Score) & ") this round:" & Natural'Image(Self.All_Recent) & " this roll:" & Natural'Image(Self.Recent) & "; add to score(+)?"); Get(Ch); return Ch /= '+'; end Roll_More; A1: Hand := (Name => "Alice"); A2: Hand := (Name => "Bob "); Alice: Boolean; begin Play(A1, A2, Alice); Ada.Text_IO.Put_Line("Winner = " & (if Alice then "Alice!" else "Bob!")); end Play_Pig;
programs/oeis/182/A182305.asm
neoneye/loda
22
7456
; A182305: a(n+1) = a(n) + floor(a(n)/4) with a(0)=4. ; 4,5,6,7,8,10,12,15,18,22,27,33,41,51,63,78,97,121,151,188,235,293,366,457,571,713,891,1113,1391,1738,2172,2715,3393,4241,5301,6626,8282,10352,12940,16175,20218,25272,31590,39487 mov $1,4 lpb $0 sub $0,1 mul $1,5 div $1,4 lpe mov $0,$1
programs/oeis/337/A337895.asm
neoneye/loda
22
10046
; A337895: Number of oriented colorings of the tetrahedral facets (or vertices) of a regular 4-dimensional simplex using n or fewer colors. ; 1,6,21,56,127,258,483,848,1413,2254,3465,5160,7475,10570,14631,19872,26537,34902,45277,58008,73479,92114,114379,140784,171885,208286,250641,299656,356091,420762,494543,578368,673233 mov $1,$0 pow $0,2 add $0,1 lpb $1 mov $2,$1 seq $2,227161 ; Number of n X 2 0,1 arrays indicating 2 X 2 subblocks of some larger (n+1) X 3 binary array having a sum of one or less, with rows and columns of the latter in lexicographically nondecreasing order. sub $2,$1 sub $1,1 mul $2,2 add $0,$2 lpe
Transynther/x86/_processed/NC/_zr_un_/i7-7700_9_0x48.log_21829_1577.asm
ljhsiun2/medusa
9
24279
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r15 push %r8 push %rdx // Faulty Load mov $0x7f44c100000005c1, %r15 nop nop nop nop add %rdx, %rdx movups (%r15), %xmm2 vpextrq $1, %xmm2, %r8 lea oracles, %r10 and $0xff, %r8 shlq $12, %r8 mov (%r10,%r8,1), %r8 pop %rdx pop %r8 pop %r15 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}} <gen_prepare_buffer> {'08': 158, '86': 111, 'fd': 26, '00': 21534} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
programs/oeis/198/A198694.asm
neoneye/loda
22
244578
<reponame>neoneye/loda ; A198694: 7*4^n-1. ; 6,27,111,447,1791,7167,28671,114687,458751,1835007,7340031,29360127,117440511,469762047,1879048191,7516192767,30064771071,120259084287,481036337151,1924145348607,7696581394431,30786325577727,123145302310911,492581209243647,1970324836974591,7881299347898367,31525197391593471,126100789566373887,504403158265495551,2017612633061982207,8070450532247928831,32281802128991715327,129127208515966861311,516508834063867445247,2066035336255469780991,8264141345021879123967,33056565380087516495871,132226261520350065983487,528905046081400263933951,2115620184325601055735807,8462480737302404222943231,33849922949209616891772927,135399691796838467567091711,541598767187353870268366847,2166395068749415481073467391,8665580274997661924293869567,34662321099990647697175478271,138649284399962590788701913087,554597137599850363154807652351,2218388550399401452619230609407,8873554201597605810476922437631,35494216806390423241907689750527,141976867225561692967630759002111,567907468902246771870523036008447,2271629875608987087482092144033791,9086519502435948349928368576135167,36346078009743793399713474304540671,145384312038975173598853897218162687,581537248155900694395415588872650751 mov $1,4 pow $1,$0 mul $1,7 sub $1,1 mov $0,$1
grammar/SolidityLexer.g4
qiuxiang/antlr4-solidity
0
3601
lexer grammar SolidityLexer; /** * Keywords reserved for future use in Solidity. */ ReservedKeywords: 'after' | 'alias' | 'apply' | 'auto' | 'byte' | 'case' | 'copyof' | 'default' | 'define' | 'final' | 'implements' | 'in' | 'inline' | 'let' | 'macro' | 'match' | 'mutable' | 'null' | 'of' | 'partial' | 'promise' | 'reference' | 'relocatable' | 'sealed' | 'sizeof' | 'static' | 'supports' | 'switch' | 'typedef' | 'typeof' | 'var'; Pragma: 'pragma' -> pushMode(PragmaMode); Abstract: 'abstract'; Anonymous: 'anonymous'; Address: 'address'; As: 'as'; Assembly: 'assembly' -> pushMode(AssemblyBlockMode); Bool: 'bool'; Break: 'break'; Bytes: 'bytes'; Calldata: 'calldata'; Catch: 'catch'; Constant: 'constant'; Constructor: 'constructor'; Continue: 'continue'; Contract: 'contract'; Delete: 'delete'; Do: 'do'; Else: 'else'; Emit: 'emit'; Enum: 'enum'; Error: 'error'; // not a real keyword Revert: 'revert'; // not a real keyword Event: 'event'; External: 'external'; Fallback: 'fallback'; False: 'false'; Fixed: 'fixed' | ('fixed' [1-9][0-9]* 'x' [1-9][0-9]*); From: 'from'; // not a real keyword /** * Bytes types of fixed length. */ FixedBytes: 'bytes1' | 'bytes2' | 'bytes3' | 'bytes4' | 'bytes5' | 'bytes6' | 'bytes7' | 'bytes8' | 'bytes9' | 'bytes10' | 'bytes11' | 'bytes12' | 'bytes13' | 'bytes14' | 'bytes15' | 'bytes16' | 'bytes17' | 'bytes18' | 'bytes19' | 'bytes20' | 'bytes21' | 'bytes22' | 'bytes23' | 'bytes24' | 'bytes25' | 'bytes26' | 'bytes27' | 'bytes28' | 'bytes29' | 'bytes30' | 'bytes31' | 'bytes32'; For: 'for'; Function: 'function'; Global: 'global'; // not a real keyword Hex: 'hex'; If: 'if'; Immutable: 'immutable'; Import: 'import'; Indexed: 'indexed'; Interface: 'interface'; Internal: 'internal'; Is: 'is'; Library: 'library'; Mapping: 'mapping'; Memory: 'memory'; Modifier: 'modifier'; New: 'new'; /** * Unit denomination for numbers. */ NumberUnit: 'wei' | 'gwei' | 'ether' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'years'; Override: 'override'; Payable: 'payable'; Private: 'private'; Public: 'public'; Pure: 'pure'; Receive: 'receive'; Return: 'return'; Returns: 'returns'; /** * Sized signed integer types. * int is an alias of int256. */ SignedIntegerType: 'int' | 'int8' | 'int16' | 'int24' | 'int32' | 'int40' | 'int48' | 'int56' | 'int64' | 'int72' | 'int80' | 'int88' | 'int96' | 'int104' | 'int112' | 'int120' | 'int128' | 'int136' | 'int144' | 'int152' | 'int160' | 'int168' | 'int176' | 'int184' | 'int192' | 'int200' | 'int208' | 'int216' | 'int224' | 'int232' | 'int240' | 'int248' | 'int256'; Storage: 'storage'; String: 'string'; Struct: 'struct'; True: 'true'; Try: 'try'; Type: 'type'; Ufixed: 'ufixed' | ('ufixed' [1-9][0-9]+ 'x' [1-9][0-9]+); Unchecked: 'unchecked'; /** * Sized unsigned integer types. * uint is an alias of uint256. */ UnsignedIntegerType: 'uint' | 'uint8' | 'uint16' | 'uint24' | 'uint32' | 'uint40' | 'uint48' | 'uint56' | 'uint64' | 'uint72' | 'uint80' | 'uint88' | 'uint96' | 'uint104' | 'uint112' | 'uint120' | 'uint128' | 'uint136' | 'uint144' | 'uint152' | 'uint160' | 'uint168' | 'uint176' | 'uint184' | 'uint192' | 'uint200' | 'uint208' | 'uint216' | 'uint224' | 'uint232' | 'uint240' | 'uint248' | 'uint256'; Using: 'using'; View: 'view'; Virtual: 'virtual'; While: 'while'; LParen: '('; RParen: ')'; LBrack: '['; RBrack: ']'; LBrace: '{'; RBrace: '}'; Colon: ':'; Semicolon: ';'; Period: '.'; Conditional: '?'; DoubleArrow: '=>'; RightArrow: '->'; Assign: '='; AssignBitOr: '|='; AssignBitXor: '^='; AssignBitAnd: '&='; AssignShl: '<<='; AssignSar: '>>='; AssignShr: '>>>='; AssignAdd: '+='; AssignSub: '-='; AssignMul: '*='; AssignDiv: '/='; AssignMod: '%='; Comma: ','; Or: '||'; And: '&&'; BitOr: '|'; BitXor: '^'; BitAnd: '&'; Shl: '<<'; Sar: '>>'; Shr: '>>>'; Add: '+'; Sub: '-'; Mul: '*'; Div: '/'; Mod: '%'; Exp: '**'; Equal: '=='; NotEqual: '!='; LessThan: '<'; GreaterThan: '>'; LessThanOrEqual: '<='; GreaterThanOrEqual: '>='; Not: '!'; BitNot: '~'; Inc: '++'; Dec: '--'; //@doc:inline DoubleQuote: '"'; //@doc:inline SingleQuote: '\''; /** * A non-empty quoted string literal restricted to printable characters. */ NonEmptyStringLiteral: '"' DoubleQuotedStringCharacter+ '"' | '\'' SingleQuotedStringCharacter+ '\''; /** * An empty string literal */ EmptyStringLiteral: '"' '"' | '\'' '\''; // Note that this will also be used for Yul string literals. //@doc:inline fragment DoubleQuotedStringCharacter: DoubleQuotedPrintable | EscapeSequence; // Note that this will also be used for Yul string literals. //@doc:inline fragment SingleQuotedStringCharacter: SingleQuotedPrintable | EscapeSequence; /** * Any printable character except single quote or back slash. */ fragment SingleQuotedPrintable: [\u0020-\u0026\u0028-\u005B\u005D-\u007E]; /** * Any printable character except double quote or back slash. */ fragment DoubleQuotedPrintable: [\u0020-\u0021\u0023-\u005B\u005D-\u007E]; /** * Escape sequence. * Apart from common single character escape sequences, line breaks can be escaped * as well as four hex digit unicode escapes \\uXXXX and two digit hex escape sequences \\xXX are allowed. */ fragment EscapeSequence: '\\' ( ['"\\nrt\n\r] | 'u' HexCharacter HexCharacter HexCharacter HexCharacter | 'x' HexCharacter HexCharacter ); /** * A single quoted string literal allowing arbitrary unicode characters. */ UnicodeStringLiteral: 'unicode"' DoubleQuotedUnicodeStringCharacter* '"' | 'unicode\'' SingleQuotedUnicodeStringCharacter* '\''; //@doc:inline fragment DoubleQuotedUnicodeStringCharacter: ~["\r\n\\] | EscapeSequence; //@doc:inline fragment SingleQuotedUnicodeStringCharacter: ~['\r\n\\] | EscapeSequence; // Note that this will also be used for Yul hex string literals. /** * Hex strings need to consist of an even number of hex digits that may be grouped using underscores. */ HexString: 'hex' (('"' EvenHexDigits? '"') | ('\'' EvenHexDigits? '\'')); /** * Hex numbers consist of a prefix and an arbitrary number of hex digits that may be delimited by underscores. */ HexNumber: '0' 'x' HexDigits; //@doc:inline fragment HexDigits: HexCharacter ('_'? HexCharacter)*; //@doc:inline fragment EvenHexDigits: HexCharacter HexCharacter ('_'? HexCharacter HexCharacter)*; //@doc:inline fragment HexCharacter: [0-9A-Fa-f]; /** * A decimal number literal consists of decimal digits that may be delimited by underscores and * an optional positive or negative exponent. * If the digits contain a decimal point, the literal has fixed point type. */ DecimalNumber: (DecimalDigits | (DecimalDigits? '.' DecimalDigits)) ([eE] '-'? DecimalDigits)?; //@doc:inline fragment DecimalDigits: [0-9] ('_'? [0-9])* ; /** * An identifier in solidity has to start with a letter, a dollar-sign or an underscore and * may additionally contain numbers after the first symbol. */ Identifier: IdentifierStart IdentifierPart*; //@doc:inline fragment IdentifierStart: [a-zA-Z$_]; //@doc:inline fragment IdentifierPart: [a-zA-Z0-9$_]; WS: [ \t\r\n\u000C]+ -> skip ; COMMENT: '/*' .*? '*/' -> channel(HIDDEN) ; LINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN); mode AssemblyBlockMode; //@doc:inline AssemblyDialect: '"evmasm"'; AssemblyLBrace: '{' -> popMode, pushMode(YulMode); AssemblyFlagString: '"' DoubleQuotedStringCharacter+ '"'; AssemblyBlockLParen: '('; AssemblyBlockRParen: ')'; AssemblyBlockComma: ','; AssemblyBlockWS: [ \t\r\n\u000C]+ -> skip ; AssemblyBlockCOMMENT: '/*' .*? '*/' -> channel(HIDDEN) ; AssemblyBlockLINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN) ; mode YulMode; YulBreak: 'break'; YulCase: 'case'; YulContinue: 'continue'; YulDefault: 'default'; YulFalse: 'false'; YulFor: 'for'; YulFunction: 'function'; YulIf: 'if'; YulLeave: 'leave'; YulLet: 'let'; YulSwitch: 'switch'; YulTrue: 'true'; YulHex: 'hex'; /** * Builtin functions in the EVM Yul dialect. */ YulEVMBuiltin: 'stop' | 'add' | 'sub' | 'mul' | 'div' | 'sdiv' | 'mod' | 'smod' | 'exp' | 'not' | 'lt' | 'gt' | 'slt' | 'sgt' | 'eq' | 'iszero' | 'and' | 'or' | 'xor' | 'byte' | 'shl' | 'shr' | 'sar' | 'addmod' | 'mulmod' | 'signextend' | 'keccak256' | 'pop' | 'mload' | 'mstore' | 'mstore8' | 'sload' | 'sstore' | 'msize' | 'gas' | 'address' | 'balance' | 'selfbalance' | 'caller' | 'callvalue' | 'calldataload' | 'calldatasize' | 'calldatacopy' | 'extcodesize' | 'extcodecopy' | 'returndatasize' | 'returndatacopy' | 'extcodehash' | 'create' | 'create2' | 'call' | 'callcode' | 'delegatecall' | 'staticcall' | 'return' | 'revert' | 'selfdestruct' | 'invalid' | 'log0' | 'log1' | 'log2' | 'log3' | 'log4' | 'chainid' | 'origin' | 'gasprice' | 'blockhash' | 'coinbase' | 'timestamp' | 'number' | 'difficulty' | 'gaslimit' | 'basefee'; YulLBrace: '{' -> pushMode(YulMode); YulRBrace: '}' -> popMode; YulLParen: '('; YulRParen: ')'; YulAssign: ':='; YulPeriod: '.'; YulComma: ','; YulArrow: '->'; /** * Yul identifiers consist of letters, dollar signs, underscores and numbers, but may not start with a number. * In inline assembly there cannot be dots in user-defined identifiers. Instead see yulPath for expressions * consisting of identifiers with dots. */ YulIdentifier: YulIdentifierStart YulIdentifierPart*; //@doc:inline fragment YulIdentifierStart: [a-zA-Z$_]; //@doc:inline fragment YulIdentifierPart: [a-zA-Z0-9$_]; /** * Hex literals in Yul consist of a prefix and one or more hexadecimal digits. */ YulHexNumber: '0' 'x' [0-9a-fA-F]+; /** * Decimal literals in Yul may be zero or any sequence of decimal digits without leading zeroes. */ YulDecimalNumber: '0' | ([1-9] [0-9]*); /** * String literals in Yul consist of one or more double-quoted or single-quoted strings * that may contain escape sequences and printable characters except unescaped line breaks or * unescaped double-quotes or single-quotes, respectively. */ YulStringLiteral: '"' DoubleQuotedStringCharacter* '"' | '\'' SingleQuotedStringCharacter* '\''; //@doc:inline YulHexStringLiteral: HexString; YulWS: [ \t\r\n\u000C]+ -> skip ; YulCOMMENT: '/*' .*? '*/' -> channel(HIDDEN) ; YulLINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN) ; mode PragmaMode; /** * Pragma token. Can contain any kind of symbol except a semicolon. * Note that currently the solidity parser only allows a subset of this. */ //@doc:name pragma-token //@doc:no-diagram PragmaToken: ~[;]+; PragmaSemicolon: ';' -> popMode; PragmaWS: [ \t\r\n\u000C]+ -> skip ; PragmaCOMMENT: '/*' .*? '*/' -> channel(HIDDEN) ; PragmaLINE_COMMENT: '//' ~[\r\n]* -> channel(HIDDEN) ;
tools/scitools/conf/understand/ada/ada12/s-casuti.ads
brucegua/moocos
1
25208
<reponame>brucegua/moocos<gh_stars>1-10 ------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . C A S E _ U T I L -- -- -- -- S p e c -- -- -- -- Copyright (C) 1995-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. -- -- -- ------------------------------------------------------------------------------ -- Simple casing functions -- This package provides simple casing functions that do not require the -- overhead of the full casing tables found in Ada.Characters.Handling. -- Note that all the routines in this package are available to the user -- via GNAT.Case_Util, which imports all the entities from this package. pragma Compiler_Unit; package System.Case_Util is pragma Pure; -- Note: all the following functions handle the full Latin-1 set function To_Upper (A : Character) return Character; -- Converts A to upper case if it is a lower case letter, otherwise -- returns the input argument unchanged. procedure To_Upper (A : in out String); -- Folds all characters of string A to upper case function To_Lower (A : Character) return Character; -- Converts A to lower case if it is an upper case letter, otherwise -- returns the input argument unchanged. procedure To_Lower (A : in out String); -- Folds all characters of string A to lower case procedure To_Mixed (A : in out String); -- Converts A to mixed case (i.e. lower case, except for initial -- character and any character after an underscore, which are -- converted to upper case. end System.Case_Util;
alloy4fun_models/trainstlt/models/5/7SR55twydAC9xnWWv.als
Kaixi26/org.alloytools.alloy
0
766
open main pred id7SR55twydAC9xnWWv_prop6 { always no (Green & Green') } pred __repair { id7SR55twydAC9xnWWv_prop6 } check __repair { id7SR55twydAC9xnWWv_prop6 <=> prop6o }
tools/ada-larl/ada_larl.adb
reznikmm/gela
0
16768
<reponame>reznikmm/gela -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Ada.Command_Line; with Ada.Text_IO; with Anagram.Grammars; with Anagram.Grammars.Reader; with Anagram.Grammars_Convertors; with Anagram.Grammars.Rule_Templates; with Anagram.Grammars_Debug; with Anagram.Grammars.LR_Tables; with Anagram.Grammars.LR.LALR; with Anagram.Grammars.Constructors; with Anagram.Grammars.Conflicts; with Writers; use Writers; with League.String_Vectors; with League.Strings; procedure Ada_LARL is use type Anagram.Grammars.Rule_Count; use type Anagram.Grammars.LR.State_Count; procedure Put_Proc_Decl (Output : in out Writer; Suffix : Wide_Wide_String); procedure Put_Piece (Piece : in out Writer; From : Anagram.Grammars.Production_Index; To : Anagram.Grammars.Production_Index); procedure Put_Rule (Output : in out Writer; Prod : Anagram.Grammars.Production; Rule : Anagram.Grammars.Rule); function Image (X : Integer) return Wide_Wide_String; procedure Print_Go_To; procedure Print_Action; File : constant String := Ada.Command_Line.Argument (1); G : constant Anagram.Grammars.Grammar := Anagram.Grammars.Reader.Read (File); Plain : constant Anagram.Grammars.Grammar := Anagram.Grammars_Convertors.Convert (G, Left => False); AG : constant Anagram.Grammars.Grammar := Anagram.Grammars.Constructors.To_Augmented (Plain); Table : constant Anagram.Grammars.LR_Tables.Table_Access := Anagram.Grammars.LR.LALR.Build (Input => AG, Right_Nulled => False); Resolver : Anagram.Grammars.Conflicts.Resolver; Output : Writer; ----------- -- Image -- ----------- function Image (X : Integer) return Wide_Wide_String is Img : constant Wide_Wide_String := Integer'Wide_Wide_Image (X); begin return Img (2 .. Img'Last); end Image; ------------------ -- Print_Action -- ------------------ procedure Print_Action is use type Anagram.Grammars.Production_Count; use type Anagram.Grammars.Part_Count; type Action_Code is mod 2 ** 16; Count : Natural; Code : Action_Code; begin Output.P (" type Action_Code is mod 2 ** 16;"); Output.P (" for Action_Code'Size use 16;"); Output.P; Output.P (" Action_Table : constant array"); Output.N (" (State_Index range 1 .. "); Output.N (Natural (Anagram.Grammars.LR_Tables.Last_State (Table.all))); Output.P (","); Output.N (" Anagram.Grammars.Terminal_Count range 0 .. "); Output.N (Natural (Plain.Last_Terminal)); Output.P (") of Action_Code :="); for State in 1 .. Anagram.Grammars.LR_Tables.Last_State (Table.all) loop if State = 1 then Output.N (" ("); else Output.P (","); Output.N (" "); end if; Output.N (Natural (State)); Output.P (" =>"); Output.N (" ("); Count := 0; for T in 0 .. Plain.Last_Terminal loop declare use Anagram.Grammars.LR_Tables; S : constant Anagram.Grammars.LR.State_Count := Shift (Table.all, State, T); R : constant Reduce_Iterator := Reduce (Table.all, State, T); begin if S /= 0 then Code := Action_Code (S) + 16#80_00#; elsif not Is_Empty (R) then Code := Action_Code (Production (R)); else Code := 0; end if; if Code /= 0 then Output.N (Natural (T)); Output.N (" => "); Output.N (Natural (Code)); Count := Count + 1; if Count < 4 then Output.N (", "); else Count := 0; Output.P (","); Output.N (" "); end if; end if; end; end loop; Output.N ("others => 0)"); end loop; Output.P (");"); Output.P; Output.P (" type Production_Record is record"); Output.P (" NT : Anagram.Grammars.Non_Terminal_Index;"); Output.P (" Parts : Natural;"); Output.P (" end record;"); Output.P; Output.N (" Prods : constant array (Action_Code range 1 .. "); Output.N (Natural (Plain.Last_Production)); Output.P (") of"); Output.P (" Production_Record :="); Count := 0; for J in 1 .. Plain.Last_Production loop if J = 1 then Output.N (" ("); elsif Count > 5 then Count := 0; Output.P (","); Output.N (" "); else Output.N (", "); end if; Output.N ("("); Output.N (Natural (Plain.Production (J).Parent)); Output.N (", "); Output.N (Natural (Plain.Production (J).Last - Plain.Production (J).First + 1)); Output.N (")"); Count := Count + 1; end loop; Output.P (");"); Output.P; Output.P (" procedure Next_Action"); Output.P (" (State : Anagram.Grammars.LR_Parsers.State_Index;"); Output.P (" Token : Anagram.Grammars.Terminal_Count;"); Output.P (" Value : out Anagram.Grammars.LR_Parsers.Action)"); Output.P (" is"); Output.P (" Code : constant Action_Code := " & "Action_Table (State, Token);"); Output.P (" begin"); Output.P (" if (Code and 16#80_00#) /= 0 then"); Output.P (" Value := (Kind => Shift, " & "State => State_Index (Code and 16#7F_FF#));"); Output.P (" elsif Code /= 0 then"); Output.P (" Value := (Kind => Reduce,"); Output.P (" Prod => " & "Anagram.Grammars.Production_Index (Code),"); Output.P (" NT => Prods (Code).NT,"); Output.P (" Parts => Prods (Code).Parts);"); for State in 1 .. Anagram.Grammars.LR_Tables.Last_State (Table.all) loop if Anagram.Grammars.LR_Tables.Finish (Table.all, State) then Output.N (" elsif State = "); Output.N (Natural (State)); Output.P (" then"); Output.P (" Value := (Kind => Finish);"); end if; end loop; Output.P (" else"); Output.P (" Value := (Kind => Error);"); Output.P (" end if;"); Output.P (" end Next_Action;"); Output.P; end Print_Action; ----------------- -- Print_Go_To -- ----------------- procedure Print_Go_To is Count : Natural; begin Output.P (" Go_To_Table : constant array"); Output.N (" (Anagram.Grammars.LR_Parsers.State_Index range 1 .. "); Output.N (Natural (Anagram.Grammars.LR_Tables.Last_State (Table.all))); Output.P (","); Output.N (" Anagram.Grammars.Non_Terminal_Index range 1 .. "); Output.N (Natural (Plain.Last_Non_Terminal)); Output.P (") of State_Index :="); for State in 1 .. Anagram.Grammars.LR_Tables.Last_State (Table.all) loop if State = 1 then Output.N (" ("); else Output.P (","); Output.N (" "); end if; Output.N (Natural (State)); Output.P (" =>"); Output.N (" ("); Count := 0; for NT in 1 .. Plain.Last_Non_Terminal loop declare use Anagram.Grammars.LR; Next : constant State_Count := Anagram.Grammars.LR_Tables.Shift (Table.all, State, NT); begin if Next /= 0 then Output.N (Natural (NT)); Output.N (" => "); Output.N (Natural (Next)); Count := Count + 1; if Count < 4 then Output.N (", "); else Count := 0; Output.P (","); Output.N (" "); end if; end if; end; end loop; Output.N ("others => 0)"); end loop; Output.P (");"); Output.P; Output.P (" function Go_To"); Output.P (" (State : Anagram.Grammars.LR_Parsers.State_Index;"); Output.P (" NT : Anagram.Grammars.Non_Terminal_Index)"); Output.P (" return Anagram.Grammars.LR_Parsers.State_Index"); Output.P (" is"); Output.P (" begin"); Output.P (" return Go_To_Table (State, NT);"); Output.P (" end Go_To;"); Output.P; end Print_Go_To; -------------- -- Put_Rule -- -------------- procedure Put_Rule (Output : in out Writer; Prod : Anagram.Grammars.Production; Rule : Anagram.Grammars.Rule) is use Anagram.Grammars.Rule_Templates; use type League.Strings.Universal_String; Template : constant Rule_Template := Create (Rule.Text); Args : League.String_Vectors.Universal_String_Vector; Value : League.Strings.Universal_String; begin for J in 1 .. Template.Count loop Value.Clear; if Plain.Non_Terminal (Prod.Parent).Name = Template.Part_Name (J) then Value.Append ("Nodes (1)"); else declare Index : Positive := 1; begin for Part of Plain.Part (Prod.First .. Prod.Last) loop if Part.Name = Template.Part_Name (J) then Value.Append ("Nodes ("); Value.Append (Image (Index)); Value.Append (")"); end if; Index := Index + 1; end loop; if Value.Is_Empty then if Template.Has_Default (J) then Value := Template.Default (J); else Ada.Text_IO.Put_Line ("Wrong part " & Template.Part_Name (J).To_UTF_8_String & " in rule for production " & Plain.Non_Terminal (Prod.Parent).Name.To_UTF_8_String & "." & Prod.Name.To_UTF_8_String); Ada.Text_IO.Put_Line (Rule.Text.To_UTF_8_String); raise Constraint_Error; end if; end if; end; end if; Args.Append (Value); end loop; Output.P (Template.Substitute (Args)); end Put_Rule; procedure Put_Proc_Decl (Output : in out Writer; Suffix : Wide_Wide_String) is begin Output.N ("procedure Program.Parsers.On_Reduce"); Output.P (Suffix); Output.P (" (Self : access Parse_Context;"); Output.P (" Prod : Anagram.Grammars.Production_Index;"); Output.N (" Nodes : in out " & "Program.Parsers.Nodes.Node_Array)"); end Put_Proc_Decl; procedure Put_Piece (Piece : in out Writer; From : Anagram.Grammars.Production_Index; To : Anagram.Grammars.Production_Index) is Suffix : Wide_Wide_String := Anagram.Grammars.Production_Index'Wide_Wide_Image (From); begin Suffix (1) := '_'; Piece.P ("with Anagram.Grammars;"); Piece.P ("with Program.Parsers.Nodes;"); Piece.N ("private "); Put_Proc_Decl (Piece, Suffix); Piece.P (";"); Piece.N ("pragma Preelaborate (Program.Parsers.On_Reduce"); Piece.N (Suffix); Piece.P (");"); Piece.P; -- Piece.P ("pragma Warnings (""U"");"); Piece.P ("with Program.Parsers.Nodes;"); Piece.P ("use Program.Parsers.Nodes;"); Piece.P ("pragma Style_Checks (""N"");"); Put_Proc_Decl (Piece, Suffix); Piece.P (" is"); Piece.P ("begin"); Piece.P (" case Prod is"); for Prod of Plain.Production (From .. To) loop Piece.N (" when"); Piece.N (Anagram.Grammars.Production_Index'Wide_Wide_Image (Prod.Index)); Piece.P (" =>"); for Rule of Plain.Rule (Prod.First_Rule .. Prod.Last_Rule) loop Put_Rule (Piece, Prod, Rule); end loop; if Prod.First_Rule > Prod.Last_Rule then Piece.P (" null;"); end if; end loop; Piece.P (" when others =>"); Piece.P (" raise Constraint_Error;"); Piece.P (" end case;"); Piece.N ("end Program.Parsers.On_Reduce"); Piece.N (Suffix); Piece.P (";"); end Put_Piece; use type Anagram.Grammars.Production_Count; Piece_Length : constant Anagram.Grammars.Production_Count := 500; Piece : Writer; begin Resolver.Resolve (AG, Table.all); Output.P ("with Anagram.Grammars;"); Output.P ("with Anagram.Grammars.LR_Parsers;"); Output.P; Output.P ("package Program.Parsers.Data is"); Output.P (" pragma Preelaborate;"); Output.P; Output.P (" procedure Next_Action"); Output.P (" (State : Anagram.Grammars.LR_Parsers.State_Index;"); Output.P (" Token : Anagram.Grammars.Terminal_Count;"); Output.P (" Value : out Anagram.Grammars.LR_Parsers.Action);"); Output.P; Output.P (" function Go_To"); Output.P (" (State : Anagram.Grammars.LR_Parsers.State_Index;"); Output.P (" NT : Anagram.Grammars.Non_Terminal_Index)"); Output.P (" return Anagram.Grammars.LR_Parsers.State_Index;"); Output.P; Output.P ("end Program.Parsers.Data;"); Output.P; Output.P ("package body Program.Parsers.Data is"); Output.P (" use Anagram.Grammars.LR_Parsers;"); Output.P; Print_Go_To; Print_Action; Output.P ("end Program.Parsers.Data;"); Output.P; Output.P ("with Anagram.Grammars;"); Output.P ("with Program.Parsers.Nodes;"); Output.N ("private "); Put_Proc_Decl (Output, ""); Output.P (";"); Output.P ("pragma Preelaborate (Program.Parsers.On_Reduce);"); Output.P; for Piece_Index in 0 .. (Plain.Last_Production - 1) / Piece_Length loop declare From : constant Anagram.Grammars.Production_Index := Piece_Index * Piece_Length + 1; begin Output.N ("with Program.Parsers.On_Reduce_"); Output.N (Natural (From)); Output.P (";"); end; end loop; Put_Proc_Decl (Output, ""); Output.P (" is"); Output.P ("begin"); Output.P (" case Prod is"); for Piece_Index in 0 .. (Plain.Last_Production - 1) / Piece_Length loop declare From : constant Anagram.Grammars.Production_Index := Piece_Index * Piece_Length + 1; To : constant Anagram.Grammars.Production_Index := Anagram.Grammars.Production_Index'Min (Plain.Last_Production, (Piece_Index + 1) * Piece_Length); begin Output.N (" when "); Output.N (Natural (From)); Output.N (" .. "); Output.N (Natural (To)); Output.P (" =>"); Output.N (" On_Reduce_"); Output.N (Natural (From)); Output.P (" (Self, Prod, Nodes);"); Put_Piece (Piece => Piece, From => From, To => To); end; end loop; Output.P (" when others =>"); Output.P (" raise Constraint_Error;"); Output.P (" end case;"); Output.P ("end Program.Parsers.On_Reduce;"); Ada.Text_IO.Put_Line (Output.Text.To_UTF_8_String); Ada.Text_IO.Put_Line (Piece.Text.To_UTF_8_String); Anagram.Grammars_Debug.Print_Conflicts (AG, Table.all); if Ada.Command_Line.Argument_Count > 1 then Anagram.Grammars_Debug.Print (G); end if; end Ada_LARL;
oeis/166/A166965.asm
neoneye/loda-programs
11
87464
; A166965: a(n) = 20*a(n-1) - 64*a(n-2) for n > 1; a(0) = 1, a(1) = 19. ; 1,19,316,5104,81856,1310464,20970496,335540224,5368692736,85899280384,1374389272576,21990231506944,351843716694016,5629499517435904,90071992480301056,1441151880490123264,23058430091063197696,368934881469896065024,5902958103569876647936,94447329657324184797184,1511157274518011590475776,24178516392291483982495744,386856262276676937859465216,6189700196426883782309576704,99035203142830351623185760256,1584563250285286470395902296064,25353012004564586904034157264896,405648192073033403975345398349824 mul $0,2 mov $1,2 pow $1,$0 mul $1,5 bin $1,2 div $1,10 mov $0,$1
job/flink-cep-pdl/src/main/antlr4/PDL.g4
dorukerenaktas/cep-intelligent-assistant
1
6890
grammar PDL ; @header { package com.ia.pdl.language ; } /* Pattern Sequence. https://ci.apache.org/projects/flink/flink-docs-stable/dev/libs/cep.html#the-pattern-api */ patternSequence: skipStrategy? pattern (patternCombination)* stopCondition? timeWindow? EOF ; /* After Match Skip Strategy. noSkip, Every possible match will be emitted. skipToNext, Discards every partial match that started with the same event, emitted match was started. skipPastLast, Discards every partial match that started after the match started but before it ended. skipToFirst, Discards every partial match that started after the match started but before the first event of PatternName occurred. skipToLast, Discards every partial match that started after the match started but before the last event of PatternName occurred. https://ci.apache.org/projects/flink/flink-docs-stable/dev/libs/cep.html#after-match-skip-strategy */ skipStrategy: MOD (noSkip | skipToNext | skipPastLast | skipToFirst | skipToLast) ; noSkip: SKIP_NO_SKIP ; skipToNext: SKIP_TO_NEXT ; skipPastLast: SKIP_SKIP_PAST_LAST ; skipToFirst: SKIP_SKIP_TO_FIRST LBRACK stringconstant RBRACK ; skipToLast: SKIP_SKIP_TO_LAST LBRACK stringconstant RBRACK ; /* Pattern Combination. Strict Contiguity: Expects all matching events to appear strictly one after the other, without any non-matching events in-between. Relaxed Contiguity: Ignores non-matching events appearing in-between the matching ones. Non-Deterministic Relaxed Contiguity: Further relaxes contiguity, allowing additional matches that ignore some matching events. next, for strict, followedBy, for relaxed, and followedByAny, for non-deterministic relaxed contiguity. or notNext, if you do not want an event type to directly follow another notFollowedBy, if you do not want an event type to be anywhere between two other event types. https://ci.apache.org/projects/flink/flink-docs-stable/dev/libs/cep.html#combining-patterns */ patternCombination: (next | followedBy | followedByAny | notNext | notFollowedBy) pattern ; next: NEXT ; followedBy: FOLLOWED_BY ; followedByAny: FOLLOWED_BY_ANY ; notNext: NOT_NEXT ; notFollowedBy: NOT_FOLLOWED_BY ; pattern: patternName quantifier? condition?; patternName: IDENT | TICKED_STRING_LITERAL ; /* */ quantifier: times | timesOrMore | oneOrMore | zeroOrMore ; times: (LCURLY numberconstant RCURLY optional?) | (LCURLY numberconstant COMMA numberconstant RCURLY optional? greedy?); timesOrMore: LCURLY numberconstant COMMA PLUS RCURLY optional? greedy? ; oneOrMore: PLUS optional? greedy? ; zeroOrMore: STAR optional? greedy? ; optional: QUESTION ; greedy: BXOR ; condition: LPAREN expression? RPAREN ; stopCondition: LBRACK expression? RBRACK ; expression: orExpression ; orExpression: andExpression (OR_EXPR andExpression)* ; andExpression: operation (AND_EXPR operation)* ; operation: equalsOperation | notEqualsOperation | lowerThanOperation | lowerEqualsOperation | greaterThanOperation | greaterEqualsOperation | containsOperation | notContainsOperation ; equalsOperation: unaryExpression EQUALS unaryExpression ; notEqualsOperation: unaryExpression NOT_EQUAL unaryExpression ; lowerThanOperation: unaryExpression LT unaryExpression ; lowerEqualsOperation: unaryExpression LE unaryExpression ; greaterThanOperation: unaryExpression GT unaryExpression ; greaterEqualsOperation: unaryExpression GE unaryExpression ; containsOperation: unaryExpression CONTAINS unaryExpression ; notContainsOperation: unaryExpression NOT_CONTAINS unaryExpression ; unaryExpression: eventProperty | constant ; eventProperty: eventPropertyAtomic (DOT eventPropertyAtomic)* ; eventPropertyAtomic: eventPropertyIdent ( lb=LBRACK ni=number RBRACK (q=QUESTION)? | lp=LPAREN (s=STRING_LITERAL | s=QUOTED_STRING_LITERAL) RPAREN (q=QUESTION)? | q1=QUESTION )? ; eventPropertyIdent: ipi=keywordAllowedIdent (ESCAPECHAR DOT ipi2=keywordAllowedIdent?)* ; timeWindow: WITHIN c=numberconstant (u=HOUR_SHORT | u=MINUTE_SHORT | u=SECOND_SHORT | u=MILLSECONDS_SHORT) ; constant: numberconstant | stringconstant | t=BOOLEAN_TRUE | BOOLEAN_FALSE | nu=VALUE_NULL ; numberconstant: (m=MINUS | p=PLUS)? number ; stringconstant: sl=STRING_LITERAL | qsl=QUOTED_STRING_LITERAL ; keywordAllowedIdent: i1=IDENT | i2=TICKED_STRING_LITERAL | AT | ESCAPE | SUM | AVG | MAX | MIN | UNTIL | WEEKDAY | LW | INSTANCEOF | TYPEOF | CAST ; number: INTEGER_LITERAL | FLOATING_POINT_LITERAL ; /* Lexer rules. */ // Tokens SKIP_NO_SKIP: 'no_skip' ; SKIP_TO_NEXT: 'skip_to_next' ; SKIP_SKIP_PAST_LAST: 'skip_past_last' ; SKIP_SKIP_TO_FIRST: 'skip_to_first' ; SKIP_SKIP_TO_LAST: 'skip_to_last' ; IN_SET:'in' ; BETWEEN:'between' ; LIKE:'like' ; REGEXP:'regexp' ; ESCAPE:'escape' ; OR_EXPR:'or' ; AND_EXPR:'and' ; NOT_EXPR:'not' ; WHERE:'where' ; AS:'as' ; SUM:'sum' ; AVG:'avg' ; MAX:'max' ; MIN:'min' ; ON:'on' ; IS:'is' ; WEEKDAY:'weekday' ; LW:'lastweekday' ; INSTANCEOF:'instanceof' ; TYPEOF:'typeof' ; CAST:'cast' ; CURRENT_TIMESTAMP:'current_timestamp' ; UNTIL:'until' ; AT:'at' ; TIMEPERIOD_YEAR:'year' ; TIMEPERIOD_YEARS:'years' ; TIMEPERIOD_MONTH:'month' ; TIMEPERIOD_MONTHS:'months' ; TIMEPERIOD_WEEK:'week' ; TIMEPERIOD_WEEKS:'weeks' ; TIMEPERIOD_DAY:'day' ; TIMEPERIOD_DAYS:'days' ; TIMEPERIOD_HOUR:'hour' ; TIMEPERIOD_HOURS:'hours' ; TIMEPERIOD_MINUTE:'minute' ; TIMEPERIOD_MINUTES:'minutes' ; TIMEPERIOD_SEC:'sec' ; TIMEPERIOD_SECOND:'second' ; TIMEPERIOD_SECONDS:'seconds' ; TIMEPERIOD_MILLISEC:'msec' ; TIMEPERIOD_MILLISECOND:'millisecond' ; TIMEPERIOD_MILLISECONDS:'milliseconds' ; TIMEPERIOD_MICROSEC:'usec' ; TIMEPERIOD_MICROSECOND:'microsecond' ; TIMEPERIOD_MICROSECONDS:'microseconds' ; BOOLEAN_TRUE:'true' ; BOOLEAN_FALSE:'false' ; VALUE_NULL:'null' ; WITHIN: 'within' ; HOUR_SHORT: 'h' ; MINUTE_SHORT: 'm' ; SECOND_SHORT: 's' ; MILLSECONDS_SHORT: 'ms' ; // Operators NEXT: '->>' ; FOLLOWED_BY: '->' ; FOLLOWED_BY_ANY: '--' ; NOT_NEXT: '!->>' ; NOT_FOLLOWED_BY: '!->' ; GOES: '=>' ; EQUALS: '=' ; QUESTION: '?' ; LPAREN: '(' ; RPAREN: ')' ; LBRACK: '[' ; RBRACK: ']' ; LCURLY: '{' ; RCURLY: '}' ; COLON: ':' ; COMMA: ',' ; LNOT: '!' ; BNOT: '~' ; NOT_EQUAL: '!=' ; DIV: '/' ; PLUS: '+' ; MINUS: '-' ; STAR: '*' ; MOD: '%' ; GE: '>=' ; GT: '>' ; LE: '<=' ; LT: '<' ; CONTAINS: '><' ; NOT_CONTAINS: '>!<' ; BXOR: '^' ; BOR: '|' ; LOR: '||' ; BAND: '&' ; BAND_ASSIGN: '&=' ; LAND: '&&' ; SEMI: ' ;' ; DOT: '.' ; NUM_LONG: '\u18FF' ; // assign bogus unicode characters so the token exists NUM_DOUBLE: '\u18FE' ; NUM_FLOAT: '\u18FD' ; ESCAPECHAR: '\\' ; ESCAPEBACKTICK: '`' ; ATCHAR: '@' ; HASHCHAR: '#' ; // Whitespace -- ignored WS: (' ' | '\t' | '\f' | ('\r' | '\n'))+ -> channel(HIDDEN) ; // Single-line comments SL_COMMENT: '//' (~('\n'|'\r'))* ('\n'|'\r'('\n')?)? -> channel(HIDDEN) ; // multiple-line comments ML_COMMENT: '/*' (.)*? '*/' -> channel(HIDDEN) ; TICKED_STRING_LITERAL: '`' ( EscapeSequence | ~('`'|'\\') )* '`' ; QUOTED_STRING_LITERAL: '\'' ( EscapeSequence | ~('\''|'\\') )* '\'' ; STRING_LITERAL: '"' ( EscapeSequence | ~('\\'|'"') )* '"' ; INTEGER_LITERAL: DecimalIntegerLiteral | HexIntegerLiteral | OctalIntegerLiteral | BinaryIntegerLiteral ; FLOATING_POINT_LITERAL: DecimalFloatingPointLiteral | HexadecimalFloatingPointLiteral ; IDENT: ('a'..'z'|'_'|'$') ('a'..'z'|'_'|'0'..'9'|'$')* ; fragment EscapeSequence: '\\' ( 'n' | 'r' | 't' | 'b' | 'f' | '"' | '\'' | '\\' | UnicodeEscape | OctalEscape | . ) ; fragment OctalEscape: '\\' ('0'..'3') ('0'..'7') ('0'..'7') | '\\' ('0'..'7') ('0'..'7') | '\\' ('0'..'7') ; fragment UnicodeEscape: '\\' 'u' HexDigit HexDigit HexDigit HexDigit ; fragment DecimalIntegerLiteral: DecimalNumeral IntegerTypeSuffix? ; fragment HexIntegerLiteral: HexNumeral IntegerTypeSuffix? ; fragment OctalIntegerLiteral: OctalNumeral IntegerTypeSuffix? ; fragment BinaryIntegerLiteral: BinaryNumeral IntegerTypeSuffix? ; fragment IntegerTypeSuffix: [lL] ; fragment DecimalNumeral: '0' | ('0')* NonZeroDigit (Digits? | Underscores Digits) ; fragment Digits: Digit (DigitOrUnderscore* Digit)? ; fragment Digit: '0' | NonZeroDigit ; fragment NonZeroDigit: [1-9] ; fragment DigitOrUnderscore: Digit | '_' ; fragment Underscores: '_'+ ; fragment HexNumeral: '0' [xX] HexDigits ; fragment HexDigits: HexDigit (HexDigitOrUnderscore* HexDigit)? ; fragment HexDigit: [0-9a-fA-F] ; fragment HexDigitOrUnderscore: HexDigit | '_' ; fragment OctalNumeral: '0' Underscores? OctalDigits ; fragment OctalDigits: OctalDigit (OctalDigitOrUnderscore* OctalDigit)? ; fragment OctalDigit: [0-7] ; fragment OctalDigitOrUnderscore: OctalDigit | '_' ; fragment BinaryNumeral: '0' [bB] BinaryDigits ; fragment BinaryDigits: BinaryDigit (BinaryDigitOrUnderscore* BinaryDigit)? ; fragment BinaryDigit: [01] ; fragment BinaryDigitOrUnderscore: BinaryDigit | '_' ; fragment DecimalFloatingPointLiteral: Digits '.' Digits? ExponentPart? FloatTypeSuffix? | '.' Digits ExponentPart? FloatTypeSuffix? | Digits ExponentPart FloatTypeSuffix? | Digits FloatTypeSuffix ; fragment ExponentPart: ExponentIndicator SignedInteger ; fragment ExponentIndicator: [eE] ; fragment SignedInteger: Sign? Digits ; fragment Sign: [+-] ; fragment FloatTypeSuffix: [fFdD] ; fragment HexadecimalFloatingPointLiteral: HexSignificand BinaryExponent FloatTypeSuffix? ; fragment HexSignificand: HexNumeral '.'? | '0' [xX] HexDigits? '.' HexDigits ; fragment BinaryExponent: BinaryExponentIndicator SignedInteger ; fragment BinaryExponentIndicator: [pP] ;
src/iTerm2Background.scpt
limaner2002/backgrounds
0
858
tell application "iTerm2" repeat with w in windows set tablist to (the tabs of w) repeat with t in tablist set sessionlist to (the sessions of t) repeat with s in sessionlist tell s set background image to "/tmp/bg.jpg" end tell end repeat end repeat end repeat end tell
oeis/174/A174777.asm
neoneye/loda-programs
11
21375
; A174777: y-values in the solution to x^2 - 38*y^2 = 1. ; Submitted by <NAME>(s1) ; 0,6,444,32850,2430456,179820894,13304315700,984339540906,72827821711344,5388274467098550,398659482743581356,29495413448557921794,2182261935710542631400,161457887829131596801806,11945701437420027620702244,883820448481252912335164250,65390767486175295485181452256,4838032973528490612991092302694,357949049273622130065855648947100,26483391613274509134260326929782706,1959413030333040053805198337154973144,144970080853031689472450416622538229950,10725826570094011980907525631730674043156 lpb $0 sub $0,1 mov $1,$3 mul $1,72 add $2,1 add $2,$1 add $3,$2 lpe mov $0,$2 mul $0,6
programs/oeis/128/A128549.asm
neoneye/loda
22
80678
<reponame>neoneye/loda ; A128549: Difference between triangular number and next perfect square. ; 3,1,3,6,1,4,8,13,4,9,15,3,9,16,1,8,16,25,6,15,25,3,13,24,36,10,22,35,6,19,33,1,15,30,46,10,26,43,4,21,39,58,15,34,54,8,28,49,71,21,43,66,13,36,60,4,28,53,79,19,45,72,9,36,64,93,26,55,85,15,45,76,3,34,66,99,22,55,89,9,43,78,114,30,66,103,16,53,91,1,39,78,118,24,64,105,8,49,91,134 add $0,2 bin $0,2 seq $0,80883 ; Distance of n to next square.
programs/oeis/321/A321003.asm
jmorken/loda
1
853
<gh_stars>1-10 ; A321003: a(n) = 2^n*(4*3^n-1). ; 3,22,140,856,5168,31072,186560,1119616,6718208,40310272,241863680,1451186176,8707125248,52242767872,313456640000,1880739905536,11284439564288,67706637647872,406239826411520,2437438959517696,14624633759203328,87747802559414272 mov $1,14 mov $2,12 lpb $0 sub $0,1 mul $1,2 mul $2,3 lpe sub $2,3 mul $1,$2 sub $1,126 div $1,42 add $1,3
arch/RISC-V/SiFive/drivers/fe310-pwm.adb
rocher/Ada_Drivers_Library
192
7570
<gh_stars>100-1000 ------------------------------------------------------------------------------ -- -- -- Copyright (C) 2018, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package body FE310.PWM is ----------- -- Count -- ----------- function Count (This : PWM_Device) return Count_Value is (This.Periph.COUNT.CNT); --------------- -- Set_Count -- --------------- procedure Set_Count (This : in out PWM_Device; Value : Count_Value) is begin This.Periph.COUNT.CNT := Value; end Set_Count; ---------------------- -- Enable_Continous -- ---------------------- procedure Enable_Continous (This : in out PWM_Device) is begin This.Periph.CONFIG.ENALWAYS := True; end Enable_Continous; --------------------- -- Enable_One_Shot -- --------------------- procedure Enable_One_Shot (This : in out PWM_Device) is begin This.Periph.CONFIG.ENONESHOT := True; end Enable_One_Shot; ------------- -- Disable -- ------------- procedure Disable (This : in out PWM_Device) is begin This.Periph.CONFIG.ENONESHOT := False; This.Periph.CONFIG.ENALWAYS := False; end Disable; -------------------- -- Scaled_Counter -- -------------------- function Scaled_Counter (This : PWM_Device) return Scaled_Value is (This.Periph.SCALE_COUNT.CNT); --------------- -- Configure -- --------------- procedure Configure (This : in out PWM_Device; Scale : FE310_SVD.PWM.CONFIG_SCALE_Field; Sticky : Boolean; Reset_To_Zero : Boolean; Deglitch : Boolean) is begin This.Periph.CONFIG.SCALE := Scale; This.Periph.CONFIG.STICKY := Sticky; This.Periph.CONFIG.ZEROCMP := Reset_To_Zero; This.Periph.CONFIG.DEGLITCH := Deglitch; end Configure; --------------- -- Configure -- --------------- procedure Configure (This : in out PWM_Device; ID : Comparator_ID; Compare_Center : Boolean; Compare_Gang : Boolean) is begin This.Periph.CONFIG.CMP_CENTER.Arr (ID) := Compare_Center; This.Periph.CONFIG.CMP_GANG.Arr (ID) := Compare_Gang; end Configure; ----------------- -- Set_Compare -- ----------------- procedure Set_Compare (This : in out PWM_Device; ID : Comparator_ID; Value : Compare_Value) is begin case ID is when 0 => This.Periph.COMPARE0.COMPARE := Value; when 1 => This.Periph.COMPARE1.COMPARE := Value; when 2 => This.Periph.COMPARE2.COMPARE := Value; when 3 => This.Periph.COMPARE3.COMPARE := Value; end case; end Set_Compare; ------------- -- Compare -- ------------- function Compare (This : PWM_Device; ID : Comparator_ID) return Compare_Value is (case ID is when 0 => This.Periph.COMPARE0.COMPARE, when 1 => This.Periph.COMPARE1.COMPARE, when 2 => This.Periph.COMPARE2.COMPARE, when 3 => This.Periph.COMPARE3.COMPARE); ----------------------- -- Interrupt_Pending -- ----------------------- function Interrupt_Pending (This : PWM_Device; ID : Comparator_ID) return Boolean is (This.Periph.CONFIG.CMP_IP.Arr (ID)); end FE310.PWM;
Irvine/Examples/ch13/DirectoryListing/asmMain.asm
alieonsido/ASM_TESTING
0
98706
<gh_stars>0 ; ASM program launched from C++ (asmMain.asm) .586 .MODEL flat,C ; Standard C library functions: system PROTO, pCommand:PTR BYTE printf PROTO, pString:PTR BYTE, args:VARARG scanf PROTO, pFormat:PTR BYTE,pBuffer:PTR BYTE, args:VARARG fopen PROTO, mode:PTR BYTE, filename:PTR BYTE fclose PROTO, pFile:DWORD BUFFER_SIZE = 5000 .data str1 BYTE "cls",0 str2 BYTE "dir/w",0 str3 BYTE "Enter the name of a file: ",0 str4 BYTE "%s",0 str5 BYTE "cannot open file",0dh,0ah,0 str6 BYTE "The file has been opened and closed",0dh,0ah,0 modeStr BYTE "r",0 fileName BYTE 60 DUP(0) pBuf DWORD ? pFile DWORD ? .code asm_main PROC ; clear the screen, display disk directory INVOKE system,ADDR str1 INVOKE system,ADDR str2 ; ask for a filename INVOKE printf,ADDR str3 INVOKE scanf, ADDR str4, ADDR fileName ; try to open the file INVOKE fopen, ADDR fileName, ADDR modeStr mov pFile,eax .IF eax == 0 ; cannot open file? INVOKE printf,ADDR str5 jmp quit .ELSE INVOKE printf,ADDR str6 .ENDIF ; Close the file INVOKE fclose, pFile quit: ret ; return to C++ main asm_main ENDP END
oeis/302/A302560.asm
neoneye/loda-programs
11
21588
; A302560: Partial sums of icosahedral numbers (A006564). ; 1,13,61,185,440,896,1638,2766,4395,6655,9691,13663,18746,25130,33020,42636,54213,68001,84265,103285,125356,150788,179906,213050,250575,292851,340263,393211,452110,517390,589496,668888,756041,851445,955605,1069041,1192288,1325896,1470430,1626470,1794611,1975463,2169651,2377815,2600610,2838706,3092788,3363556,3651725,3958025,4283201,4628013,4993236,5379660,5788090,6219346,6674263,7153691,7658495,8189555,8747766,9334038,9949296,10594480,11270545,11978461,12719213,13493801,14303240,15148560 lpb $0 mov $2,$0 sub $0,1 seq $2,6564 ; Icosahedral numbers: a(n) = n*(5*n^2 - 5*n + 2)/2. add $1,$2 lpe add $1,1 mov $0,$1
programs/oeis/151/A151842.asm
neoneye/loda
22
165387
<gh_stars>10-100 ; A151842: a(3n)=n, a(3n+1)=2n+1, a(3n+2)=n+1. ; 0,1,1,1,3,2,2,5,3,3,7,4,4,9,5,5,11,6,6,13,7,7,15,8,8,17,9,9,19,10,10,21,11,11,23,12,12,25,13,13,27,14,14,29,15,15,31,16,16,33,17,17,35,18,18,37,19,19,39,20,20,41,21,21,43,22,22,45,23,23,47 mov $1,$0 div $0,3 sub $1,$0 dif $1,2 mov $0,$1
source/vampire-villages-teaming.adb
ytomino/vampire
1
22736
<reponame>ytomino/vampire -- The Village of Vampire by YT, このソースコードはNYSLです with Ada.Numerics.Distributions; package body Vampire.Villages.Teaming is use type Casts.Person_Sex; function Possibilities ( People_Count : Ada.Containers.Count_Type; Male_And_Female : Boolean; Execution : Execution_Mode; Formation : Formation_Mode; Unfortunate : Unfortunate_Mode; Monster_Side : Monster_Side_Mode) return Role_Set_Array is Result : Role_Set_Array (1 .. 2 ** (Role_Set'Length - 2)); Last : Natural := 0; subtype Village_Side_Superman_Count_Type is Natural range 0 .. 7; -- 天猟探医数恋恋 subtype Vampire_Count_Type is Natural range 0 .. 4; -- KQJ + 一時的に使徒を計算に含める分 subtype Servant_Count_Type is Natural range 0 .. 1; subtype Gremlin_Count_Type is Natural range 0 .. 1; procedure Add (Set : in Role_Set) is begin Last := Last + 1; Result (Last) := Set; end Add; procedure Process_Inhabitants ( Set : in Role_Set; Village_Side_Superman_Count : in Village_Side_Superman_Count_Type; Total_Village_Side_Superman_Count : in Village_Side_Superman_Count_Type) is Set_2 : Role_Set := Set; Count : Ada.Containers.Count_Type := 0; begin if Village_Side_Superman_Count = 0 or else ( Village_Side_Superman_Count = 1 and then Total_Village_Side_Superman_Count >= 3 and then Unfortunate /= None) then if Village_Side_Superman_Count = 1 then Set_2 (Unfortunate_Inhabitant) := 1; end if; for I in Set_2'Range loop Count := Count + Ada.Containers.Count_Type (Set_2 (I)); end loop; Set_2 (Inhabitant) := Natural ( Ada.Containers.Count_Type'Max (0, People_Count - Count)); Add (Set_2); end if; end Process_Inhabitants; procedure Process_Lovers ( Set : in Role_Set; Village_Side_Superman_Count : in Village_Side_Superman_Count_Type; Total_Village_Side_Superman_Count : in Village_Side_Superman_Count_Type) is begin Process_Inhabitants ( Set, Village_Side_Superman_Count, Total_Village_Side_Superman_Count); if Male_And_Female then if Village_Side_Superman_Count >= 1 and then Total_Village_Side_Superman_Count >= 3 then declare Set_2 : Role_Set := Set; begin Set_2 (Lover) := 1; Set_2 (Loved_Inhabitant) := 1; Process_Inhabitants ( Set_2, Village_Side_Superman_Count - 1, Total_Village_Side_Superman_Count); end; end if; if Village_Side_Superman_Count >= 2 and then Total_Village_Side_Superman_Count >= 4 then declare Set_2 : Role_Set := Set; begin Set_2 (Sweetheart_M) := 1; Set_2 (Sweetheart_F) := 1; Process_Inhabitants ( Set_2, Village_Side_Superman_Count - 2, Total_Village_Side_Superman_Count); end; end if; end if; end Process_Lovers; procedure Process_Detective ( Set : in Role_Set; Village_Side_Superman_Count : in Village_Side_Superman_Count_Type; Total_Village_Side_Superman_Count : in Village_Side_Superman_Count_Type) is Set_2 : Role_Set := Set; begin Process_Lovers ( Set, Village_Side_Superman_Count, Total_Village_Side_Superman_Count); if Village_Side_Superman_Count > 0 and then ( Set (Astronomer) + Set (Hunter) + Set (Doctor) < 3 or else Set (Vampire_K) + Set (Vampire_Q) + Set (Vampire_J) + Set (Servant) + Set (Gremlin) >= 4) then Set_2 (Detective) := 1; Process_Lovers ( Set_2, Village_Side_Superman_Count - 1, Total_Village_Side_Superman_Count); end if; end Process_Detective; procedure Process_Doctor ( Set : in Role_Set; Village_Side_Superman_Count : in Village_Side_Superman_Count_Type; Total_Village_Side_Superman_Count : in Village_Side_Superman_Count_Type) is Set_2 : Role_Set := Set; begin if not (Set (Gremlin) >= 1 and then Set (Astronomer) = 0) then Process_Detective ( Set, Village_Side_Superman_Count, Total_Village_Side_Superman_Count); end if; if Village_Side_Superman_Count > 0 then Set_2 (Doctor) := 1; Process_Detective ( Set_2, Village_Side_Superman_Count - 1, Total_Village_Side_Superman_Count); end if; end Process_Doctor; procedure Process_Hunter ( Set : in Role_Set; Village_Side_Superman_Count : in Village_Side_Superman_Count_Type; Total_Village_Side_Superman_Count : in Village_Side_Superman_Count_Type) is Set_2 : Role_Set := Set; begin if Village_Side_Superman_Count = 0 or else Set (Astronomer) >= 1 then Process_Doctor ( Set, Village_Side_Superman_Count, Total_Village_Side_Superman_Count); end if; if Village_Side_Superman_Count > 0 and then ( Set (Astronomer) = 0 or else Set (Vampire_K) + Set (Vampire_Q) + Set (Vampire_J) + Set (Servant) + Set (Gremlin) >= 3) then Set_2 (Hunter) := 1; Process_Doctor ( Set_2, Village_Side_Superman_Count - 1, Total_Village_Side_Superman_Count); end if; end Process_Hunter; procedure Process_Astronomer ( Set : in Role_Set; Village_Side_Superman_Count : in Village_Side_Superman_Count_Type; Total_Village_Side_Superman_Count : in Village_Side_Superman_Count_Type) is Set_2 : Role_Set := Set; begin if Village_Side_Superman_Count = 0 or else Formation /= Hidden then Process_Hunter ( Set, Village_Side_Superman_Count, Total_Village_Side_Superman_Count); end if; if Village_Side_Superman_Count > 0 then Set_2 (Astronomer) := 1; Process_Hunter ( Set_2, Village_Side_Superman_Count - 1, Total_Village_Side_Superman_Count); end if; end Process_Astronomer; procedure Process_Vampires ( Set : in Role_Set; Village_Side_Superman_Count : in Village_Side_Superman_Count_Type; Vampire_Count : in Vampire_Count_Type) is Set_2 : Role_Set := Set; begin if Vampire_Count >= 1 then Set_2 (Vampire_K) := 1; if Vampire_Count >= 2 then Set_2 (Vampire_Q) := 1; if Vampire_Count >= 3 then Set_2 (Vampire_J) := 1; end if; end if; end if; Process_Astronomer ( Set_2, Village_Side_Superman_Count, Village_Side_Superman_Count); end Process_Vampires; procedure Process_Servant ( Set : in Role_Set; Village_Side_Superman_Count : in Village_Side_Superman_Count_Type; Vampire_Count : in Vampire_Count_Type; Servant_Count : in Servant_Count_Type) is Set_2 : Role_Set := Set; Vampire_Count_2 : Vampire_Count_Type; begin if Monster_Side = Shuffling then Vampire_Count_2 := Vampire_Count + Servant_Count; Process_Vampires ( Set_2, Village_Side_Superman_Count, Vampire_Count_2); if Vampire_Count_2 >= 2 then Vampire_Count_2 := Vampire_Count_2 - 1; Set_2 (Servant) := 1; Process_Vampires ( Set_2, Village_Side_Superman_Count, Vampire_Count_2); end if; else Set_2 (Servant) := Servant_Count; Process_Vampires ( Set_2, Village_Side_Superman_Count, Vampire_Count); end if; end Process_Servant; procedure Process_Gremlin ( Set : in Role_Set; Village_Side_Superman_Count : in Village_Side_Superman_Count_Type; Vampire_Count : in Vampire_Count_Type; Servant_Count : in Servant_Count_Type; Gremlin_Count : in Gremlin_Count_Type) is Set_2 : Role_Set := Set; begin Set_2 (Gremlin) := Gremlin_Count; Process_Servant ( Set_2, Village_Side_Superman_Count, Vampire_Count, Servant_Count); end Process_Gremlin; Village_Side_Superman_Count : Village_Side_Superman_Count_Type; Vampire_Count : Vampire_Count_Type; Servant_Count : Servant_Count_Type := 0; Gremlin_Count : Gremlin_Count_Type := 0; begin case Execution is when Infection_And_From_First => if People_Count >= 15 then Village_Side_Superman_Count := 4; elsif People_Count >= 11 then Village_Side_Superman_Count := 3; elsif People_Count >= 8 then Village_Side_Superman_Count := 2; else Village_Side_Superman_Count := 1; end if; if People_Count >= 14 then Vampire_Count := 3; Servant_Count := 1; elsif People_Count >= 12 then Vampire_Count := 3; elsif People_Count >= 10 then Vampire_Count := 2; Servant_Count := 1; elsif People_Count >= 8 then Vampire_Count := 2; elsif People_Count >= 6 then Vampire_Count := 1; Servant_Count := 1; else Vampire_Count := 1; end if; if People_Count >= 16 then Gremlin_Count := 1; end if; when Dummy_Killed_And_From_First | From_First | From_Second => declare People_Count_2 : Ada.Containers.Count_Type := People_Count; begin if Execution = From_Second then People_Count_2 := People_Count_2 - 1; end if; if People_Count_2 >= 15 then Village_Side_Superman_Count := 5; elsif People_Count_2 >= 13 then Village_Side_Superman_Count := 4; elsif People_Count_2 >= 10 then Village_Side_Superman_Count := 3; elsif People_Count_2 >= 8 then Village_Side_Superman_Count := 2; else Village_Side_Superman_Count := 1; end if; if People_Count_2 >= 14 then Vampire_Count := 3; Servant_Count := 1; elsif People_Count_2 = 13 then Vampire_Count := 3; elsif People_Count_2 >= 9 then Vampire_Count := 2; Servant_Count := 1; elsif People_Count_2 = 8 then Vampire_Count := 2; elsif People_Count_2 = 7 then Vampire_Count := 1; Servant_Count := 1; else Vampire_Count := 1; end if; if People_Count_2 >= 16 then Gremlin_Count := 1; end if; end; end case; -- 編成隠し時能力者+1 if Formation = Hidden then Village_Side_Superman_Count := Village_Side_Superman_Count + 1; end if; -- カップル作成不可能の場合は能力者の種類が足りなくなる if not Male_And_Female then if Unfortunate = None and then Village_Side_Superman_Count >= 5 then Village_Side_Superman_Count := 4; -- 天猟探医 elsif Village_Side_Superman_Count >= 6 then Village_Side_Superman_Count := 5; -- 天猟探医奇 end if; end if; -- 使徒妖魔交換 if Monster_Side = Gremlin and then People_Count >= 11 then declare T : constant Natural := Servant_Count; begin Servant_Count := Gremlin_Count; Gremlin_Count := T; end; -- 使徒がいなかった場合は吸血鬼と交換 if Gremlin_Count = 0 then Vampire_Count := Vampire_Count - 1; Gremlin_Count := 1; end if; end if; -- 組み合わせ探索 declare Zero_Set : constant Role_Set := (others => 0); begin Process_Gremlin ( Zero_Set, Village_Side_Superman_Count, Vampire_Count, Servant_Count, Gremlin_Count); end; return Result (1 .. Last); end Possibilities; function Select_Set ( Sets : Role_Set_Array; Appearance : Role_Appearances; Generator : aliased in out Ada.Numerics.MT19937.Generator) return Role_Set is subtype T is Positive range Sets'Range; function Random is new Ada.Numerics.Distributions.Linear_Discrete_Random ( Ada.Numerics.MT19937.Unsigned_32, T, Ada.Numerics.MT19937.Generator, Ada.Numerics.MT19937.Random_32); Index : T; begin Index := Random (Generator); -- 片想いと数奇な運命の村人の出現率を少し下げる if Sets (Index)(Lover) > 0 or else Sets (Index) (Unfortunate_Inhabitant) > 0 then Index := Random (Generator); end if; -- 天文家無しの出現率を少し下げる if Sets (Index)(Astronomer) = 0 then Index := Random (Generator); end if; return Sets (Index); end Select_Set; procedure Shuffle ( People : in out Villages.People.Vector; Victim : access Villages.Person_Role; Set : Role_Set; Generator : aliased in out Ada.Numerics.MT19937.Generator) is subtype People_Index is Person_Index'Base range Person_Index'First .. People.Last_Index; function People_Random is new Ada.Numerics.Distributions.Linear_Discrete_Random ( Ada.Numerics.MT19937.Unsigned_32, People_Index, Ada.Numerics.MT19937.Generator, Ada.Numerics.MT19937.Random_32); type Role_Set is array (Person_Role) of Boolean; pragma Pack(Role_Set); function Request_To_Role_Set (Request : Requested_Role) return Role_Set is begin case Request is when Random => return Role_Set'(others => True); when Rest => pragma Assert(False); return Role_Set'(others => False); when Inhabitant => return Role_Set'( Inhabitant | Loved_Inhabitant | Unfortunate_Inhabitant => True, others => False); when Detective => return Role_Set'(Detective => True, others => False); when Astronomer => return Role_Set'(Astronomer => True, others => False); when Doctor => return Role_Set'(Doctor => True, others => False); when Hunter => return Role_Set'(Hunter => True, others => False); when Sweetheart => return Role_Set'(Sweetheart_M | Sweetheart_F | Lover => True, others => False); when Servant => return Role_Set'(Servant => True, others => False); when Vampire => return Role_Set'(Vampire_Role => True, others => False); when Village_Side => return Role_Set'( Vampire_Role | Servant => False, Gremlin => False, others => True); when Vampire_Side => return Role_Set'( Vampire_Role | Servant => True, Gremlin => False, others => False); when Gremlin => return Role_Set'(Gremlin => True, others => False); end case; end Request_To_Role_Set; type Request_Matrix is array (People_Index) of Role_Set; function Get_Request_Matrix return Request_Matrix is function Get_Rest_Role_Set return Role_Set is Result : Role_Set := (others => True); begin for I in People_Index loop declare Person : Person_Type renames People.Constant_Reference(I); begin if not Person.Ignore_Request then declare R : constant Requested_Role := Person.Request; begin if R /= Rest then Result := Result and not Request_To_Role_Set(R); end if; end; end if; end; end loop; return Result; end Get_Rest_Role_Set; Rest_Roles : constant Role_Set := Get_Rest_Role_Set; Result : Request_Matrix; begin for I in People_Index loop declare Person : Person_Type renames People.Constant_Reference(I); begin if Person.Ignore_Request then Result (I) := Rest_Roles and Role_Set'( Inhabitant | Loved_Inhabitant | Unfortunate_Inhabitant => True, Vampire_Role | Servant => True, others => False); else declare R : constant Requested_Role := Person.Request; begin if R /= Rest then Result(I) := Request_To_Role_Set(R); else Result(I) := Rest_Roles; end if; end; end if; end; end loop; return Result; end Get_Request_Matrix; Request : constant Request_Matrix := Get_Request_Matrix; type Assignment is array(People_Index) of Person_Role; function Random_Assignment return Assignment is Result : Assignment := (others => Inhabitant); begin for I in Person_Role loop for J in 1 .. Set (I) loop Selecting : loop declare Who : constant People_Index := People_Random (Generator); begin if Result(Who) = Inhabitant then Result(Who) := I; exit Selecting; end if; end; end loop Selecting; end loop; end loop; return Result; end Random_Assignment; function Evaluate (Candidacy : Assignment) return Integer is Bad : constant Integer := -1; Result : Integer := 0; Lover_Sex : Casts.Person_Sex := Casts.Male; Loved_Sex : Casts.Person_Sex := Casts.Female; begin for I in People_Index loop declare S : constant Casts.Person_Sex := People.Constant_Reference(I).Sex; begin if (S = Casts.Male and then Candidacy (I) = Sweetheart_F) or else (S = Casts.Female and then Candidacy (I) = Sweetheart_M) then return Bad; elsif Candidacy(I) = Lover then Lover_Sex := S; elsif Candidacy(I) = Loved_Inhabitant then Loved_Sex := S; end if; end; if Request (I)(Candidacy (I)) then declare Person : Person_Type renames People.Constant_Reference(I); begin if Person.Ignore_Request then Result := Result + 20; else case Person.Request is when Random | Village_Side => Result := Result + 1; when Rest => Result := Result + 10; when others => Result := Result + 2; end case; end if; end; end if; end loop; if Loved_Sex = Lover_Sex then return Bad; end if; return Result; end Evaluate; type Gene is record Assignment : Shuffle.Assignment; Rating : Integer; end record; function Random_Valid_Gene return Gene is Result : Gene; begin loop Result.Assignment := Random_Assignment; Result.Rating := Evaluate(Result.Assignment); exit when Result.Rating >= 0; end loop; return Result; end Random_Valid_Gene; Current : Gene := Random_Valid_Gene; begin for I in 1 .. 1024 loop declare Candidacy : constant Gene := Random_Valid_Gene; begin if Candidacy.Rating > Current.Rating then Current := Candidacy; end if; end; end loop; -- 初日犠牲者 if Victim /= null then declare Changing : constant People_Index := People_Random (Generator); begin case Current.Assignment(Changing) is when Vampire_Role | Gremlin | Sweetheart_M | Sweetheart_F | Loved_Inhabitant => Victim.all := Inhabitant; when others => Victim.all := Current.Assignment(Changing); Current.Assignment(Changing) := Inhabitant; end case; end; end if; -- 設定 for I in People_Index loop People.Reference (I).Role := Current.Assignment(I); end loop; end Shuffle; end Vampire.Villages.Teaming;
space_raid.asm
nanochess/Space-Raid
8
94854
; ; Space Raid para Atari 2600 ; ; por <NAME> ; ; (c) Copyright 2013 <NAME> ; ; Creación: 27-ago-2011. ; Revisión: 23-may-2013. Se agrega posicionamiento en X. ; Revisión: 24-sep-2013. La nave se mueve en seudo-3D, crece y se ; achica, tiene sombra, dispara. Y hay un ; avión enemigo pasando. ; Revisión: 25-sep-2013. Ya hay una bala enemiga y hasta tres sprites ; enemigos. ; Revisión: 26-sep-2013. Se introducen todos los sprites. ; Revisión: 27-sep-2013. Fortalezas semi-operativas, va mostrando ; diferentes elementos. El espacio ya muestra ; olas de ataque de aviones :) La sombra del ; jugador desaparece en el espacio. Ya puede ; destruir enemigos. Se agrega espectacular ; raya 3D :P. ; Revisión: 28-sep-2013. Los cañones y los aviones ya disparan. ; Solucionado bug al explotar satélite. Se ; ajusta sincronía NTSC/PAL. Gasta gasolina en ; fortaleza, recupera con depósitos. Muestra ; total de gasolina, puntos y vida. Pantalla de ; Game Over preliminar. ; Revisión: 29-sep-2013. Se pone pantalla de título con efecto de ; brillo. Se agrandan las balas. Optimización ; del núcleo para corregir defectos visuales. ; Ya puntúa por destruir enemigos. La ; electricidad detiene la bala. El campo de ; electricidad ya se mueve. ; Revisión: 30-sep-2013. Se implementa la explosión de la nave. Ya se ; ve completo el robotote. El misil teledirigido ; ya sigue a la nave y son necesarios cinco ; impactos para destruirlo. Ya no tiene disparo ; continuo. El jugador explota cuando se le ; acaba la gasolina. El robotote avanza y ; dispara (10 impactos para detenerlo). Se ; soluciona bug en que no podía seleccionar ; nivel fortaleza como inicio (no iniciaba ; largo_sprite). Nuevo dibujo para el misil ; teledirigido. Ya dispara misiles verticales ; y pueden ser destruidos si el jugador va al ; nivel correcto. Se implementan los colores ; para PAL. Se integran efectos de sonido. Se ; corrige bug de avión invisible destruido en ; espacio. El avión pequeño ya no es tan ; pequeño. ; Revisión: 01-oct-2013. Las balas de los enemigos ya destruyen al ; jugador. El jugador ya puede chocar con los ; elementos del juego. Al tomar gasolina ; aumenta a unidades completas. Se hace "alta" ; la barrera eléctrica. El jugador inicia ; arriba después de ser destruido. Ya disparan ; los aviones chicos en la fortaleza. El botón ; de reset ya reinicia el juego. El switch de ; dificultad para el jugador 1 ya se toma en ; cuenta para que los cañones disparen más ; seguido. Juego completo :). Se alarga el ; sprite de electricidad, se acelera su ; movimiento para que parezca campo de fuerza y ; ya no se sale de la pantalla. El robotote ; empieza 10 pixeles más a la izquierda para ; no salirse de la pantalla. Corrección en la ; ubicación del disparo del robotote. Desaparece ; bala cuando ocurre explosión del jugador. Se ; agrega bitmap "by nanochess" :). Retorna el ; fondo a negro en caso de Game Over. ; Revisión: 02-oct-2013. Evita que disparen cañones invisibles (se ; escuchaba el sonido). Se optimiza más el ; código. No se podía hacer reset mientras ; explotaba. Ajuste en consumo de gasolina. La ; explosión del robotote y del satélite ya es ; animada. Corrección en misiles verticales, ; seguían subiendo aunque ya hubieran ; desaparecido. Se ajusta con el emulador ; Stella para que emita exactamente 262 líneas ; con NTSC (eran 265) y 312 con PAL (eran 315) ; Revisión: 03-oct-2013. La bala del jugador se centra en la punta de ; la nave, también la bala de los enemigos. ; Ya hay suficientes botes de gasolina de ; acuerdo a la longitud del nivel y máxima ; dificultad. Descubrí el uso de HMCLR para ; ahorrar bytes :). Se integra mira para ; apuntar en el espacio (sólo dificultad fácil) ; Los campos eléctricos ya pueden estar arriba ; o abajo. Gané tiempo en el kernel para usar ; HMOVE en cada línea de la visualización ; principal y así desaparecen los fragmentos ; de pixeles que aparecían en la columna ; izquierda del video. Se modifica el indicador ; de puntuación para mantener la barra negra a ; la izquierda. ; Revisión: 04-oct-2013. Se reescribe otra vez el kernel de pantalla ; para que quepa una escritura en HMBL para ; evitar que las rayas 3D se desplacen cuando ; aparecía un sprite. La raya 3D se desplaza ; más rápido. Corrección en tabla de puntuación. ; Los agujeros de misil ahora a veces disparan ; al llegar al centro. Se agregan dos adornos en ; la pared de la fortaleza usando un cuarto ; sprite (nuevo). Colores variables en el ; espacio (es que es hiperespacio :P) Se centra ; el disparo del robotote. Mejores colores para ; los sprites. Los disparos son más aleatorios ; y la dificultad es progresiva. ; Revisión: 05-oct-2013. Color alterno cada dos fortalezas. Más ; optimización. Limita puntos a 9999. Se ; agrega cañón giratorio. Se corrige un bug ; en que cuando aparecía la mirilla y se ; disparaba entonces los enemigos explotaban ; inmediato. ; Revisión: 06-oct-2013. Se implementa PAL60, es la misma frecuencia ; que NTSC pero con colores PAL. ; Revisión: 07-oct-2013. Se optimiza el minireproductor de sonido y se ; cambia el formato (18 bytes ahorrados más tres ; posibles en efectos). Se corrige bug en ; fortaleza en un nivel avanzado al ser tocado ; podía explotar dos veces ya que la gasolina ; seguía acabándose. ; Revisión: 08-oct-2013. Más optimización. Corrección en adornos de ; fortaleza, no salía la flecha amarilla. ; Ligera mejora en kernel de visualización. Ya ; hay sonido para cuando los aviones enemigos ; disparan. Ya se alternan los disparos de los ; aviones enemigos, antes sólo disparaba el ; primero de estos. El agujero de misil ya se ; llena de fuego al disparar misil y destruye ; al jugador si se toca en ese momento. ; Revisión: 09-oct-2013. Más optimización. ; Revisión: 10-oct-2013. Más optimización. Se reutiliza byte ; desaprovechado en letras para puntuación. Se ; combina la detección de colisión de bala y ; de nave y ahorré montones de bytes. Se ; agrega detección de código importante dividido ; entre dos páginas de 256 bytes (un salto 6502 ; usa un ciclo extra) ; Revisión: 11-oct-2013. Más optimización. Permite seleccionar ; dificultad en Game Over. ; Revisión: 12-oct-2013. Rediseño del fondo en el espacio para que ; las rayas parezcan estrellas. Se agregan ; planetas (dos sprites) en el espacio :) Se ; agrega alienígena que anda en el piso de la ; fortaleza. Los cañones ya disparan a la ; derecha (aleatoriamente). Se compacta la ; representación de nivel de las fortalezas. Se ; agregan adornos de piso antes de los agujeros ; de misil. Se agrega un tiempo aleatorio entre ; elementos de fortaleza para que no se sientan ; "tan" iguales. El misil teledirigido congela ; el scroll de la raya 3D. ; Revisión: 19-oct-2013. Se corrige bug en que mira aparecía cuando ; el avión enemigo ya está detrás del jugador. ; Se corrige bug en que misil teledirigido iba ; muy abajo con respecto a la nave y era ; imposible atinarle cuando la nave estaba hasta ; arriba. Ahora son sólo tres niveles de gasto ; de gasolina y más altos, ya que en los niveles ; primarios apenas se consumía gasolina. ; Gasolina es 5.3. Ya dispara el tercer avión, ; era a causa de var. 'ola' no era tomada en ; cuenta cuando era $3b. ; ; ; ROM de 4K: ; o Espacio usado: 4079 bytes. ; o Espacio libre: 17 bytes. ; ; ; Manual del usuario: ; ; En este sorprendente juego isométrico en 3D, pilotee su nave de ; guerra y pase a la ofensiva contra el enemigo, aniquile sus fuerzas ; en el espacio y haga un ataque rápido a las fortalezas que encuentre ; en su camino. ¡Cuidado con el robot maestro y los misiles ; teledirigidos! ; ; o Seleccione dificultad con P1, Easy (A) / Hard (B) ; En dificultad fácil obtendrá una mirilla para apuntar a los ; aviones enemigos. ; o Oprima Reset en cualquier momento para reiniciar el juego ; o Mueva su nave utilizando la palanca de mandos (izq+der, arriba ; para bajar y abajo para subir) ¡cuidado con los campos de fuerza! ; o Dispare a los enemigos utilizando el botón de la palanca de mandos. ; o Su nivel de combustible se muestra con una barra roja doble en la ; parte inferior de la pantalla y se irá reduciendo. Destruya ; bidones de combustible para recuperarlo. En el espacio el gasto ; de combustible es mínimo, pero en fortalezas se consumirá y más ; rápidamente en niveles avanzados. ; o Su puntuación se muestra en la parte inferior junto con el número ; de naves restante. ; ; Tabla de puntuación. ; Misil - 1 punto ; Combustible - 1 punto ; Cañón - 2 puntos ; Avión - 2 puntos ; Alienígena - 3 puntos ; Antena de satélite - 5 puntos ; Misil teledirigido - 5 puntos ; Satélite - 10 puntos ; Robot - 25 puntos ; ; ; Notas: ; o En grupos de 3 los aviones destruidos no pueden dejar de moverse ; de lo contrario alguno quedaría en coordenada Y "mezclada" y ; "arruinaría" los demás sprites. ; o Personalmente no lo he probado en hardware real, pero en Atariage ; varias personas dicen que ya lo probaron :) y según las mediciones ; con el emulador Stella todo va bien. ; o Duración de la fortaleza 1: 53 segundos. ; o En ocasiones hay glitches gráficos en los pixeles superiores de ; los sprites de los enemigos. Es normal. ; o En ocasiones las balas miden 3 líneas de video en lugar de 2. Es ; normal. ; ; ; Sprites disponibles: 0 ; ; Otras cosas interesantes que se pueden hacer: ; o Música de Game Over ; o Música en pantalla de título. ; o Usar botón de "Select" para algo ; o Usar botón de "B/W" para algo. ; o Que las antenas de satélite muevan la "cabeza" ; o Sprite extra y comprobación aleatoria ; ; Con flicker se puede: ; o Pasar a 8K para hacer todo lo que está listado aquí :> ; o Colocar sprites de piso en la fortaleza ; o Sprite extra, variables extra ; o Paredes de 48 pixeles de alto con un hueco para pasar (48+40) ; probablemente usando NUSIZ de robot para reducir parpadeo. ; o Dos bitmaps gigantes (hueco izq, hueco der) ; o Bitmaps de adorno para simular abismo en la entrada y salida de ; la fortaleza (bitmap 48 pixeles) ; o Dos bitmaps gigantes (dibujo entrada, dibujo salida) ; o Robotote mejor diseñado (bitmap 16 pixeles) ; o Hacer volar misiles mientras hay otros objetos en el piso. ; ; Cosas que no me convencen: ; o Sombras en el espacio para ayudarse con la altitud ; o Cambio de color de enemigo/nave cuando están en línea (preferí ; la mirilla) ; o Sombra para robotote. (no es muy importante porque se pone al ; nivel del jugador) ; o Sombra para misil teledirigido. (no es muy importante porque se ; pone al nivel del jugador) ; o Fondo de estrellas con scrolling usando solamente ball (es ; extremadamente difícil, no hay tiempo en el kernel). Hay un truco ; en el Cosmic Ark, pero no se puede usar si se hace HMOVE en cada ; línea. ; ; ; Defina esto a 1 para frecuencias NTSC (60 hz) ; Defina esto a 0 para frecuencias PAL (50 hz) ; ; Desactive comentario para http://8bitworkshop.com ; ;NTSC = 1 ; ; Defina esto a 1 para colores NTSC ; Defina esto a 0 para colores PAL ; ; Desactive comentario para http://8bitworkshop.com ; ;COLOR_NTSC = 1 ; ; Cada línea de video toma 76 ciclos del procesador ; ; Para NTSC (262 líneas): ; 3 - VSYNC ; 37 - VBLANK ; 2812 (37 * 76) - 14 ; 2798 / 64 = 43.71 valor para TIM64T ; 202 - VIDEO ; 20 - VBLANK ; ; Para PAL (312 líneas): ; 3 - VSYNC ; 62 - VBLANK ; 4712 (62 * 76) - 14 ; 4698 / 64 = 73.40 valor para TIM64T ; 202 - VIDEO ; 45 - VBLANK ; ; Notese que STA WSYNC no hace ninguna generación de sincronía, ; simplemente espera hasta que inicia el próximo HBLANK que es ; generado automáticamente por el hardware. ; ; Lo único que controla el software es la sincronía vertical ; (el VBLANK) ; ; El procesador 6507 del Atari 2600 es compatible con 6502 pero ; no tiene líneas de interrupción y su bus de direcciones está ; limitado a 13 bits. ; ; Para confirmar que el timing es correcto, utilice el emulador ; Stella y oprima Alt+I. ; ; Otros emuladores probados: z26. ; processor 6502 ; ; Registros del TIA ; VSYNC = $00 ; 0000 00x0 Vertical Sync Set-Clear VBLANK = $01 ; xx00 00x0 Vertical Blank Set-Clear WSYNC = $02 ; ---- ---- Wait for Horizontal Blank RSYNC = $03 ; ---- ---- Reset Horizontal Sync Counter NUSIZ0 = $04 ; 00xx 0xxx Number-Size player/missile 0 NUSIZ1 = $05 ; 00xx 0xxx Number-Size player/missile 1 COLUP0 = $06 ; xxxx xxx0 Color-Luminance Player 0 COLUP1 = $07 ; xxxx xxx0 Color-Luminance Player 1 COLUPF = $08 ; xxxx xxx0 Color-Luminance Playfield COLUBK = $09 ; xxxx xxx0 Color-Luminance Background CTRLPF = $0a ; 00xx 0xxx Control Playfield, Ball, Collisions REFP0 = $0b ; 0000 x000 Reflection Player 0 REFP1 = $0c ; 0000 x000 Reflection Player 1 PF0 = $0d ; xxxx 0000 Playfield Register Byte 0 PF1 = $0e ; xxxx xxxx Playfield Register Byte 1 PF2 = $0f ; xxxx xxxx Playfield Register Byte 2 RESP0 = $10 ; ---- ---- Reset Player 0 RESP1 = $11 ; ---- ---- Reset Player 1 RESM0 = $12 ; ---- ---- Reset Missile 0 RESM1 = $13 ; ---- ---- Reset Missile 1 RESBL = $14 ; ---- ---- Reset Ball AUDC0 = $15 ; 0000 xxxx Audio Control 0 AUDC1 = $16 ; 0000 xxxx Audio Control 1 AUDF0 = $17 ; 000x xxxx Audio Frequency 0 AUDF1 = $18 ; 000x xxxx Audio Frequency 1 AUDV0 = $19 ; 0000 xxxx Audio Volume 0 AUDV1 = $1a ; 0000 xxxx Audio Volume 1 GRP0 = $1b ; xxxx xxxx Graphics Register Player 0 GRP1 = $1c ; xxxx xxxx Graphics Register Player 1 ENAM0 = $1d ; 0000 00x0 Graphics Enable Missile 0 ENAM1 = $1e ; 0000 00x0 Graphics Enable Missile 1 ENABL = $1f ; 0000 00x0 Graphics Enable Ball HMP0 = $20 ; xxxx 0000 Horizontal Motion Player 0 HMP1 = $21 ; xxxx 0000 Horizontal Motion Player 1 HMM0 = $22 ; xxxx 0000 Horizontal Motion Missile 0 HMM1 = $23 ; xxxx 0000 Horizontal Motion Missile 1 HMBL = $24 ; xxxx 0000 Horizontal Motion Ball VDELP0 = $25 ; 0000 000x Vertical Delay Player 0 VDELP1 = $26 ; 0000 000x Vertical Delay Player 1 VDELBL = $27 ; 0000 000x Vertical Delay Ball RESMP0 = $28 ; 0000 00x0 Reset Missile 0 to Player 0 RESMP1 = $29 ; 0000 00x0 Reset Missile 1 to Player 1 HMOVE = $2a ; ---- ---- Apply Horizontal Motion HMCLR = $2b ; ---- ---- Clear Horizontal Move Registers CXCLR = $2c ; ---- ---- Clear Collision Latches CXM0P = $00 ; xx00 0000 Read Collision M0-P1 M0-P0 CXM1P = $01 ; xx00 0000 M1-P0 M1-P1 CXP0FB = $02 ; xx00 0000 P0-PF P0-BL CXP1FB = $03 ; xx00 0000 P1-PF P1-BL CXM0FB = $04 ; xx00 0000 M0-PF M0-BL CXM1FB = $05 ; xx00 0000 M1-PF M1-BL CXBLPF = $06 ; x000 0000 BL-PF ----- CXPPMM = $07 ; xx00 0000 P0-P1 M0-M1 INPT0 = $08 ; x000 0000 Read Pot Port 0 INPT1 = $09 ; x000 0000 Read Pot Port 1 INPT2 = $0a ; x000 0000 Read Pot Port 2 INPT3 = $0b ; x000 0000 Read Pot Port 3 INPT4 = $0c ; x000 0000 Read Input (Trigger) 0 (0=pressed) INPT5 = $0d ; x000 0000 Read Input (Trigger) 1 (0=pressed) ; RIOT MEMORY MAP SWCHA = $280 ; Port A data register for joysticks: ; Bits 4-7 for player 1. Bits 0-3 for player 2. ; bit 4/0 = 0 = Up ; bit 5/1 = 0 = Down ; bit 6/2 = 0 = Left ; bit 7/3 = 0 = Right SWACNT = $281 ; Port A data direction register (DDR) SWCHB = $282 ; Port B data (console switches) ; bit 0 = 0 = Reset button pressed ; bit 1 = 0 = Select button pressed ; bit 3 = 0 = B/W 1 = Color ; bit 6 = Jugador 1. 0 = Principiante 1 = Avanzado ; bit 7 = Jugador 2. 0 = Principiante 1 = Avanzado SWBCNT = $283 ; Port B DDR INTIM = $284 ; Timer output TIMINT = $285 TIM1T = $294 ; set 1 clock interval TIM8T = $295 ; set 8 clock interval TIM64T = $296 ; set 64 clock interval T1024T = $297 ; set 1024 clock interval ; ; Inicia línea de jugador ; cuadro = $80 ; Contador de cuadros visualizados y_jugador = $81 ; Coordenada Y 3D del jugador ; Siguientes 2 accedidos en indice x_jugador = $82 ; Coordenada X 3D del jugador x_bala = $83 ; Coordenada X bala ; Siguientes 2 accedidos en indice yj3d = $84 ; Coordenada Y 3D para jugador y_bala = $85 ; Coordenada Y bala linea_jugador = $86 ; Línea actual de sprite player 0 xj3d = $87 ; Temporal yj3d2 = $88 ; Coordenada Y 3D para sombra linea_doble = $89 ; Línea actual de sprite player 1 avance = $8a ; Avance de aviones (espacio) ; Siguientes 3 accedidos en indice x_enemigo1 = $8b ; Coordenada X de enemigo 1 x_enemigo2 = $8c ; Coordenada X de enemigo 2 x_enemigo3 = $8d ; Coordenada X de enemigo 3 ; Siguientes 3 accedidos en indice y_enemigo1 = $8e ; Coordenada Y de enemigo 1 y_enemigo2 = $8f ; Coordenada Y de enemigo 2 y_enemigo3 = $90 ; Coordenada Y de enemigo 3 ; Siguientes 5 accedidos en indice offset9 = $91 ; Offset a tabla sprites para player 0 offset0 = $92 ; Offset a tabla sprites para enemigo 1 offset1 = $93 ; Offset a tabla sprites para enemigo 2 offset2 = $94 ; Offset a tabla sprites para enemigo 3 offset3 = $95 ; Offset a tabla sprites para enemigo 4 ; Siguientes 4 accedidos en indice xe3d0 = $96 ; Coordenada X final de sprite 1 xe3d1 = $97 ; Coordenada X final de sprite 2 xe3d2 = $98 ; Coordenada X final de sprite 3 xe3d3 = $99 ; Coordenada X final de sprite 4 ; Siguientes 5 accedidos en indice ye3d0 = $9a ; Coordenada Y final de sprite 1 ye3d1 = $9b ; Coordenada Y final de sprite 2 ye3d2 = $9c ; Coordenada Y final de sprite 3 ye3d3 = $9d ; Coordenada Y final de sprite 4 ye3d4 = $9e ; Siempre a cero para que funcione x_bala2 = $9f ; Coordenada X bala y_bala2 = $a0 ; Coordenada Y bala nivel_bala2 = $a1 ; Nivel de la bala sprite = $a2 ; Sprite actual en visualización (0-3 puede haber más) nivel = $a3 ; Nivel actual (0-3) (bit 0= 0=Espacio, 1=Fortaleza) tiempo = $a4 ; Tiempo para que aparezca otro elemento lector = $a5 ; Lector de nivel (2 bytes) puntos = $a7 ; Puntos (2 bytes) (BCD) ; Siguientes 3 accedidos en indice ola = $a9 ; Ola de ataque actual secuencia = $aa ; Contador de secuencia explosion = $ab ; Indica si explota vidas = $ac ; Total de vidas gasolina = $ad ; Total de gasolina (5.3) ($00-$50) largo_sprite = $ae ; Largo actual de sprites rand = $af ; Random electrico = $b0 ; Electricidad nucita = $b1 ; Estado de NUSIZ antirebote = $b2 ; Antirebote para disparo (INPT4) ; Siguientes 3 accedidos en indice sonido_efecto = $b3 ; Sonido actual de efecto sonido_fondo = $b4 ; Sonido actual de fondo sonido_ap1 = $b5 ; Apuntador a efecto sonido_ap2 = $b8 ; Apuntador a fondo sonido_f1 = $b6 ; Último dato de efecto sonido_f2 = $b9 ; Último dato de fondo sonido_d1 = $b7 ; Duración de efecto sonido_d2 = $ba ; Duración de fondo sonido_control = $bb ; Valor de control para canal 1 sonido_frec = $bc ; Dato (frec/vol) para canal 1 dificultad = $bd ; Dificultad mira = $be ; Indica si la mira está activa mira_off = $bf ; Restaura sprite mira_x = $c0 ; Restaura coordenada X mira_y = $c1 ; Restaura coordenada Y. fondo = $c2 ; Color de fondo offset9s = $c3 ; Sprite de sombra proximo = $c4 ; Próximo avión que disparará espacio = $c5 ; Contador de movimiento del espacio bala_der = $c6 ; Indica si bala enemigo va a la derecha ; Siguientes 12 accedidos en indice ap_digito = $c7 ; Seis digitos de puntuación/vidas (12 bytes) if COLOR_NTSC=1 COLOR_BALA = $0e COLOR_FORTALEZA = $92 COLOR_FORTALEZA2 = $42 COLOR_3D = $90 COLOR_ESPACIO = $00 COLOR_GASOLINA = $36 COLOR_PUNTOS = $BA COLOR_TITULO = $20 else COLOR_BALA = $0e COLOR_FORTALEZA = $B2 COLOR_FORTALEZA2 = $62 COLOR_3D = $B0 COLOR_ESPACIO = $00 COLOR_GASOLINA = $46 COLOR_PUNTOS = $7A COLOR_TITULO = $20 endif ; ; La RAM se halla entre $0080 y $00FF. ; org $f000 ; Locación de inicio del ROM (4K) ; >>> EL NUCLEO DEBE CABER EN UNA PÁGINA DE 256 BYTES <<< ; >>> COMPROBAR CHECANDO EL ARCHIVO LST GENERADO POR DASM <<< ; ; 6 ciclos previos (entrada) ; 10 ciclos previos (pan6) ; 16 ciclos previos (pex2) ; ; Dado el caso se puede usar el registro S para ahorrar tiempo, ; pero no es necesario pan0 ; ¿Llega a sprite de jugador? cpy yj3d ; 3 beq pan8 ; 5 6 ; ¿Llega a sombra de jugador? cpy yj3d2 ; 8 beq pan14 ; 10 11 ldx linea_jugador ; 13 txa ; 15 and #$07 ; 17 beq pan5 ; 19 dex ; 21 bpl pan1 ; 24 pan14 ldx offset9s ; 14 .byte $ad ; 17 pan8 ldx offset9 ; 9 pan1 stx linea_jugador ; 27 12 20 lda colores,x ; 31 16 24 sta COLUP0 ; 34 19 27 lda sprites,x ; 38 23 31 pan5 sta GRP0 ; 3 3 Pone bitmap Player 0 (note que llega con A=0) sta HMCLR ; 3 6 ; ¿Llega a sprite de enemigo? ldx sprite ; 3 9 sprite actual tya ; 2 11 cmp ye3d0,x ; 4 15 bne pan4 ; 2/3 17 ; >>> Como cmp resultó en Z=1, entonces C=1 <<< no hace falta SEC lda xe3d0,x ; 3 21 sta WSYNC ; 76 24 - ciclos maximo :) - Inicia sincronía de línea sta HMOVE ; 3 pex2 sbc #15 ; 7- Gasta el tiempo necesario dividiendo X por 15 bcs pex2 ; 9/10 - 14/19/24/29/34/39/44/49/54/59/64/69 tax ; 11 lda tabla_ajuste_fino-$f1,x; 15 - Consume 5 ciclos cruzando página tsx ; ldx #$40 sta HMP1 ; 18 sta RESP1 ; 21/26/31/36/41/46/51/56/61/66/71 - Pos. "grande" stx HMBL sta WSYNC sta HMOVE ; 3 lda largo_sprite ; 6 sta linea_doble ; 9 dey ; 11 bne pan0 ; 13/14 jmp pan10 ; 16 ; Reg. X contiene 'sprite' pan4 sta WSYNC ; 73 ciclos máximo hasta aquí sta HMOVE ; 3 3 ; ; ¿Visualizar la bala? ; if 0 ; Ahorra cinco ciclos, hay que ver si puedo usarlos ldx #ENAM1 ; 2 txs ; 4 cpy y_bala2 ; 7 php ; 10 Z cae perfecto en bit 1 cpy y_bala ; 13 php ; 16 ldx sprite ; 19 ldx sprite ; 22 nop ; 24 else lda #0 ; 2 2 cpy y_bala ; 3 5 bne pan3 ; 2/3 8 lda #2 ; 2 9 pan3 sta ENAM0 ; 3 11 12 ; ¿Visualizar la bala del enemigo? lda #0 ; 2 2 cpy y_bala2 ; 3 5 bne pan7 ; 2/3 8 lda #2 ; 2 9 pan7 sta ENAM1 ; 11 12 endif lda #0 ; 5 dec linea_doble ; 10 bmi pan6 ; 12/13 lda linea_doble ; 15 bne pan9 ; 17/18 inc sprite ; 22 pan9 ora offset0,x ; 26 tax ; 28 lda colores,x ; 32 sta COLUP1 ; 35 lda sprites,x ; 39 pan6 sta GRP1 ; 42 (notese que se llega aquí con A=0) tsx ; ldx #$40 ; 68 stx HMBL ; 71 sta WSYNC ; 74 ciclos hasta aquí sta HMOVE ; 3 dey ; 5 beq pan10 ; 7/8 jmp pan0 ; 10 ; Llega aquí con 13 ó 8 ciclos pan10 ldx #$ff ; 15 txs ; 17 jsr muestra_puntos ; 23 jmp pan12 ; Detecta código dividido entre dos páginas (usa un ciclo más) if (pan0&$ff00)!=(pan10&$ff00) lda megabug1 ; :P endif ; Posiciona un sprite en X ; A = Posición X (¿rango?) ; X = Objeto por posicionar (0=P0, 1=P1, 2=M0, 3=M1, 4=BALL) ; ; >>> EL NUCLEO DEBE CABER EN UNA PÁGINA DE 256 BYTES <<< ; >>> COMPROBAR CHECANDO EL ARCHIVO LST GENERADO POR DASM <<< ; posiciona_en_x sec sta WSYNC ; 0- Inicia sincronía de línea ldy offset9 ; Necesita desperdiciar tres ciclos pex1 sbc #15 ; 4- Gasta el tiempo necesario dividiendo X por 15 bcs pex1 ; 6/7 - 11/16/21/26/31/36/41/46/51/56/61/66 pex3 tay ; 8 lda tabla_ajuste_fino-$f1,y; 13 - Consume 5 ciclos cruzando página sta HMP0,x sta RESP0,x ; 21/26/31/36/41/46/51/56/61/66/71 - Pos. "grande" rts ; Detecta código dividido entre dos páginas (usa un ciclo más) if (pex1&$ff00)!=(pex3&$ff00) lda megabug2 ; :P endif ; ; Inicia explosión ; inicia_explosion_sprite jsr gana_puntos inicia_explosion ldx #3 ie1 lda x_jugador sta xe3d0,x lda #$48 sta offset0,x dex bne ie1 sta offset9 stx AUDV0 ; Quita sonido de motor stx x_bala stx y_bala stx x_bala2 stx y_bala2 stx yj3d2 ; Quita sombra stx ye3d0 ; Quita adorno lda yj3d sta ye3d2 clc adc #8 sta ye3d1 sbc #15 sta ye3d3 lda #60 ; Duración de la explosión en cuadros sta explosion lda #8 sta largo_sprite dec vidas lda #sonido_3-base_sonido jmp efecto_sonido_prioridad .byte "OTG:)Oct19/13" org $f0f1 ; Locación de inicio del ROM tabla_ajuste_fino .byte $70 ; 7 a la izq. .byte $60 ; 6 a la izq. .byte $50 ; 5 a la izq. .byte $40 ; 4 a la izq. .byte $30 ; 3 a la izq. .byte $20 ; 2 a la izq. .byte $10 ; 1 a la izq. .byte $00 ; Sin cambio .byte $f0 ; 1 a la der. .byte $e0 ; 2 a la der. .byte $d0 ; 3 a la der. .byte $c0 ; 4 a la der. .byte $b0 ; 5 a la der. .byte $a0 ; 6 a la der. .byte $90 ; 7 a la der. ; ; Visualiza puntuación, vidas y gasolina (sub-kernel) ; >>> EL NUCLEO DEBE CABER EN UNA PÁGINA DE 256 BYTES <<< ; >>> COMPROBAR CHECANDO EL ARCHIVO LST GENERADO POR DASM <<< ; muestra_puntos lda #1 ; 25 sta CTRLPF ; 28 ldx #0 ; 30 stx ENABL ; 33 stx GRP0 ; 36 stx GRP1 ; 39 stx ENAM0 ; 42 stx ENAM1 ; 45 lda #COLOR_GASOLINA ; 47 sta COLUPF ; 50 lda gasolina ; 53 clc ; 55 adc #7 ; 57 lsr ; 59 lsr ; 61 sta WSYNC ; 66 sta HMOVE ; 3 stx COLUBK ; 6 lsr ; 8 tax ; 10 lda gas1,x ; 14 sta PF0 ; 17 lda gas2,x ; 21 sta PF1 ; 24 lda #COLOR_PUNTOS ; 26 sta COLUP0 ; 29 sta COLUP1 ; 32 lda #$03 ; 34 3 copias juntas ldx #$f0 ; 36 ; El código anterior reemplazó este código ; ldx #6 ; 2 ; sta WSYNC ;mp2: dex ; bpl mp2 ; nop stx RESP0 ; 39 stx RESP1 ; 42 stx HMP0 ; 45 sta NUSIZ0 ; 48 sta NUSIZ1 ; 51 lsr ; 53 sta VDELP0 ; 56 sta VDELP1 ; 59 sta WSYNC ; 62 sta HMOVE ; 3 lda #6 sta linea_doble mp1 ldy linea_doble ; 2 lda (ap_digito),y ; 7 sta GRP0 ; 10 sta WSYNC ; 13 + 61 = 76 lda (ap_digito+2),y ; 5 sta GRP1 ; 8 lda (ap_digito+4),y ; 13 sta GRP0 ; 16 lda (ap_digito+6),y ; 21 sta linea_jugador ; 24 lda (ap_digito+8),y ; 29 tax ; 31 lda (ap_digito+10),y; 36 tay ; 38 lda linea_jugador ; 41 sta GRP1 ; 44 stx GRP0 ; 47 sty GRP1 ; 50 sta GRP0 ; 53 dec linea_doble ; 58 bpl mp1 ; 60/61 mp3 ; Detecta código dividido entre dos páginas (usa un ciclo más) if (mp1&$ff00)!=(mp3&$ff00) lda megabug3 ; :P endif ldy #0 ; 63 sty VDELP0 ; 66 sty VDELP1 ; 69 if NTSC=1 ldx #(21*76-14)/64 else ldx #(46*76-14)/64 endif lda #2 sta WSYNC sta VBLANK ; Comienza VBLANK stx TIM64T lda #$25 sta NUSIZ0 ; Tamaño de Player/Missile 0 lda nucita sta NUSIZ1 ; Tamaño de Player/Missile 1 inc cuadro ; ; Generador de números bien aleatorios :P ; lda rand sec ror eor cuadro ror eor rand ror eor #9 sta rand sty PF1 sty PF0 sty GRP1 sty GRP0 rts ; ; Inicio del programa ; inicio sei ; Desactiva interrupciones cld ; Desactiva modo decimal ldx #$ff ; Carga X con FF... txs ; ...copia a registro de pila. lda #0 ; Carga cero en A limpia_mem sta 0,X ; Guarda en posición 0 más X dex ; Decrementa X bne limpia_mem ; Continua hasta que X es cero. sta SWACNT ; Permite leer palancas sta SWBCNT ; Permite leer botones sty rand tsx ; lda #$ff stx antirebote ; ; Aquí reinicia el juego después de Game Over ; reinicio ; ; Arma cadena de caracteres que forman mi logo ; lda #(128+letras)&$ff ldx #11 lm1 pha lda #(letras+80)>>8 sta ap_digito,x pla dex sta ap_digito,x sec sbc #8 dex bpl lm1 ; ; Pantalla de título ; lda #mensaje_titulo&$ff jsr mensaje ; ; Tacha un caracter para separar puntos y vidas ; lda #(80+letras)&$ff sta ap_digito+8 ; ; Selecciona la dificultad ; lda SWCHB and #$40 ora #$0f sta dificultad lda #15 ; Coordenada X mínima (15), X máxima (55) sta x_jugador lda #0 ; Cero puntos sta puntos sta puntos+1 lda #0 ; Nivel inicial sta nivel lda #4 ; 5 vidas (la actual y cuatro extras) sta vidas jsr sel_nivel2 ; Carga el nivel ; ; Bucle principal del juego ; bucle ; VERTICAL_SYNC lda #2 sta VSYNC ; Inicia sincronía vertical sta WSYNC ; 3 líneas de espera ldy sonido_fondo ; 3 beq s02d ; 5 dec sonido_d2 ; 10 bpl s02c ; 12 ldx sonido_ap2 ; 15 lda base_sonido,x ; 19 bne s02a ; 21 ldx sonido_fondo ; 24 inx ; 26 lda base_sonido,x ; 30 s02a sta sonido_d2 ; 33 inx ; 35 lda base_sonido,x ; 39 sta sonido_f2 ; 42 inx ; 44 stx sonido_ap2 ; 47 s02c lda base_sonido,y ; 51 sta sonido_control ; 54 ldy sonido_f2 ; 57 s02d sty sonido_frec ; 60 s03 sta WSYNC ldy sonido_efecto ; 3 beq s01 ; 5 dec sonido_d1 ; 10 bpl s01b ; 12 ldx sonido_ap1 ; 15 lda base_sonido,x ; 19 bne s01a ; 22 sta sonido_efecto beq s01 s01a sta sonido_d1 ; 25 inx ; 27 lda base_sonido,x ; 31 sta sonido_f1 ; 34 inx ; 36 stx sonido_ap1 ; 39 s01b lda base_sonido,y ; 43 sta sonido_control ; 46 lda sonido_f1 ; 49 sta sonido_frec ; 52 s01 lda sonido_control ; 55 sta AUDC1 ; 58 lda sonido_frec ; 61 and #$1f ; 63 sta AUDF1 ; 66 if NTSC=1 ldx #(37*76-14)/64 else ldx #(62*76-14)/64 endif sta WSYNC ; stx TIM64T lda #0 sta VSYNC ; Detiene sincronía vertical sta linea_jugador sta linea_doble lda fondo sta COLUBK lda sonido_frec beq s01d rol rol rol ora #$08 ; Suma 8 al volumen s01d sta AUDV1 lda #$ff sta mira lda explosion ; ¿Jugador explotando? beq b23a ; No, salta. inc xe3d1 inc xe3d3 ldx ye3d1 beq mex1 inx cpx #96 bne mex0 ldx #0 mex0 stx ye3d1 mex1 lda ye3d3 beq mex2 dec ye3d3 mex2 lda ye3d2 beq mex3 inc xe3d2 inc xe3d2 lda xe3d2 cmp #120 bcc mex3 lda #0 sta ye3d2 mex3 dec explosion ; ¿Finalizó explosión? bne b23b ; No, salta. lda vidas ; ¿Aún tiene vidas? bpl b23c ; Sí, salta. lda #mensaje_final&$ff jsr mensaje ; GAME OVER jmp reinicio b23c jsr sel_nivel2 ; Reinicia el nivel b23b jmp b11 ; Agrega elementos según el nivel b23a lda nivel lsr bcs b23 jmp b10 ; ; Fortaleza: enemigos fijos ; b23 lda tiempo cmp #25 ; ¿Agrega un adorno? bne b23d ; No, salta. lda offset1 cmp #$60 beq b23d cmp #$88 ; $88,$98,$a0 o $b8 bcs b23d lda ye3d0 bne b23d b23e lda #150 sta xe3d0 lda #96 sta ye3d0 lda #$e8 ; Adorno 1 ldx rand bpl b23f lda #$b0 ; Adorno 2 b23f sta offset0 b23d dec tiempo ; ¿Tiempo de poner otro enemigo? beq b61 ; Sí, salta. jmp b12 ; No, desplaza los actuales b61 ldy #0 lda (lector),y beq b28 ; Salta si es el final del nivel and #$f8 cmp #$e0 ; ¿Adorno de nivel? beq b60 cmp #$90 ; ¿Alienígena, misil, robotote $a0 o electricidad $b8? bcc b60 ; No, salta. b28 lda ye3d1 ora ye3d2 ora ye3d3 ; ¿Ya desapareció todo? beq b28c ; No, espera un poco más jmp b27 b28c ldx #8 lda (lector),y bne b61a ; Salta si no es el final del nivel jsr adelanta_nivel jmp b25 b61a and #$f8 cmp #$b8 ; ¿Electricidad? beq b28b cmp #$a0 ; ¿Robotote? bne b28a lda #$27 ; Usa un sprite más gordo sta NUSIZ1 ; Tamaño de Player/Missile 1 sta nucita ldx #16 .byte $ad ; LDA para brincar siguientes dos bytes b28b ldx #24 ; Largo del sprite (triple) b28a stx largo_sprite jmp b26 b60 lda ye3d1 beq b26c lda offset1 cmp #$88 ; ¿Hay un misil vertical activo? beq b27 ; Sí, espera que termine antes de poner otra cosa cmp #$60 ; ¿Hay un agujero de misil? bne b26a ; No, salta. lda electrico ; ¿Ya disparó? bne b26 ; ; Para reducir vacíos del área de juego en ciertas ocasiones ; dispara al llegar al centro. ; lda rand asl asl lda #80 ; Centro de la pantalla bcs b26d ; ; Pequeña ecuación para atinarle al jugador si pasa por encima :> ; lda yj3d sec sbc ye3d1 bcs b26b lda #0 b26b asl clc adc x_jugador b26d cmp xe3d1 bcc b27 jsr insercion adc #8 ; carry es 1, 9 pixeles mínimo entre sprites sta ye3d1 lda #sonido_4-base_sonido jsr efecto_sonido_prioridad lda #$88 ; Misil vertical sta offset1 lda #$80 ; Agujero disparando sta offset2 bne b27 b26a cmp #$e0 ; ¿Adorno de piso? beq b26c cmp #$98 ; ¿Hay misil teledirigido, robotote $a0 o campo $b8? bcs b27 ; Sí, salta a esperar b26c ldx #8 stx largo_sprite b26 lda (lector),y and #$07 tax lda offset_y,x sec sbc #10 ; Tolerancia cmp ye3d1 ; Se asegura de que la coordenada Y es aceptable bcs b20 b27 inc tiempo ; Espera un poco más b22 jmp b12 b20 jsr insercion ldy #0 sty electrico lda (lector),y and #$f8 sta offset1 ldx #150 cmp #$a0 ; ¿Robotote? bne b20a ldx #140 b20a stx xe3d1 ldx #5 cmp #$e0 ; ¿Adorno de piso? beq b20b lda rand and #4 adc #40 tax b20b stx tiempo lda (lector),y and #$07 tax lda offset_y,x sta ola ; Para referencia campo eléctrico sta ye3d1 jsr adelanta_lector ; ; Desplaza los elementos de la fortaleza para efecto de scrolling ; b12 ldx #0 stx xj3d ldx #$fc ; Ajuste Y de bala para alienígena ldy #32 ; Nivel con respecto al piso para posible bala lda offset1 cmp #$90 ; ¿Alienígena? beq b12g ; Sí, salta. inc xj3d ; Ajuste Y del misil teledirigido inc xj3d ; Ajuste Y del misil teledirigido cmp #$98 ; ¿Misil teledirigido? beq b12b ; Sí, salta ldx #$f3 ; Ajuste Y de bala para robotote ldy y_jugador ; Nivel idéntico al del jugador para posible bala cmp #$a0 ; ¿Robotote? bne b12a ; No, salta b12g lda xe3d1 cmp #140 ; ¿Recién salido? bcs b12d ; Sí, salta, debe centrarlo lda x_bala2 ; ¿Bala activa? bne b12d ; Sí, salta sta bala_der lda rand cmp dificultad ; ¿Tiempo de disparar? bcs b12d ; No, salta. txa adc ye3d1 sta y_bala2 lda xe3d1 jsr efecto_disparo b12d lda offset1 cmp #$90 beq b12b lda cuadro lsr ; El robotote sólo se mueve cada dos cuadros bcc b12c ldx #8 stx xj3d ; ; Robotote y misil teledirigido siguen al jugador ; b12b lda xe3d1 cmp #16 ; No desaparece porque el choque es inevitable bne b14a lda #0 sta ye3d1 jmp b25 b14a dec xe3d1 sbc x_jugador bpl b14b lda #0 b14b lsr lsr clc adc yj3d adc xj3d ; Corrección robotote tax lda offset1 cmp #$90 ; ¿Alienígena? bne b12f lda #32 ; Sí, lleva al piso sbc y_jugador sta xj3d txa clc adc xj3d tax b12f txa cmp #96 ; Limita a la pantalla visible bcc b12e lda #96 b12e sta ye3d1 b12c jmp b25 ; ; Desplaza los elementos fijos por el piso ; b12a ldx #0 b15 lda ye3d0,x ; ¿Elemento activo? beq b24 ; No, salta. dec xe3d0,x lda xe3d0,x cmp #16 bcs b14 lda #16 sta xe3d0,x lda #0 sta ye3d0,x b14 and #3 cmp #3 bne b17 dec ye3d0,x b17 lda x_bala2 ; ¿Bala activa? bne b24 ; Sí, salta sta bala_der lda rand cmp dificultad ; ¿Tiempo de disparar? bcs b24 ; No, salta. lda offset0,x cmp #$40 ; ¿Avión chico? beq b17a cmp #$68 ; ¿Cañón? beq b17a cmp #$50 ; ¿Cañón? bne b24 ; No, salta. lda rand lsr bcs b17b lda #1 sta bala_der bne b17a b17b lda #$68 ; Gira cañón sta offset0,x b17a lda ye3d0,x sec sbc #7 sta y_bala2 lda offset0,x sec sbc #$50 beq b17c lda #$f8 b17c clc adc xe3d0,x adc #8 ldy #32 jsr efecto_disparo b24 inx cpx #4 bne b15 lda offset1 cmp #$88 ; ¿Misil vertical? bne b24a lda cuadro lsr ; Se alza un pixel cada dos cuadros bcs b24a lda ye3d1 beq b24c ; ¿Salió de la pantalla? inc ye3d1 sec sbc ye3d2 cmp #24 bcc b24d lda #$60 ; Fin de fuego en agujero de misil sta offset2 b24d lda ye3d1 cmp #97 bne b24a b24c lda #1 sta electrico ; Ya disparó ldx #0 b24b lda ye3d2,x sta ye3d1,x lda xe3d2,x sta xe3d1,x lda offset2,x sta offset1,x inx cpx #2 bne b24b b24a jmp b25 ; Espacio exterior b10 dec tiempo bne b37a lda y_enemigo1 ora y_enemigo2 ora y_enemigo3 ; ¿Aún hay enemigos activos? bne b37 tay ; ldy #0 lda (lector),y bne b31 ; Salta si no es el final del nivel jsr adelanta_nivel jmp b25 b37 inc tiempo b37a jmp b38 b31 sta ola jsr adelanta_lector ldx #0 stx secuencia stx proximo ldx #8 stx largo_sprite cmp #$e0 ; Planetoide bcs b36a cmp #$c0 ; ¿Satélite? beq b36 ldx #35 cmp #$3a bcc b32 beq b34 cmp #$3c beq b34 ldx #15 cmp #$3d bne b34 ldx #55 b34 stx x_enemigo1 lda (lector),y jsr adelanta_lector tay ldx #$40 lda #96 bne b35 b36a ldx #15 stx x_enemigo1 ldx #35 stx x_enemigo2 lsr ldy #50 ldx #12 bcs b36b ldy #72 ldx #32 b36b stx y_enemigo2 lda #96 ldx #$f8 stx offset2 ldx #$f0 bne b35a b36 tax ; Satélite lda #105 sta x_enemigo1 ldy #72 lda #16 sta largo_sprite lda #48 bne b35 b32 lda #15 sta x_enemigo1 stx x_enemigo2 lda #55 sta x_enemigo3 ldy #72 lda ola cmp #$38 beq b33 ldy #32 b33 sty y_enemigo2 sty y_enemigo3 ldx #$40 lda #125 b35 stx offset2 b35a stx offset1 stx offset3 sty y_enemigo1 sta avance lda #50 sta tiempo b38 ; ; Posiciona los enemigos ; ldx #0 ldy #0 lda avance pha ; Corrimiento a la derecha con signo (2 veces) rol pla ror pha rol pla ror sta xj3d b6 lda x_enemigo1,y lsr sta xe3d1,x lda y_enemigo1,y beq b6c clc adc #7 ; Sólo suma 7 para evitar tener que usar sec sbc xe3d1,x sec adc xj3d sta ye3d1,x beq b6c cmp #97 ; ¿Invisible? bcs b6c lda x_enemigo1,y ; clc ; La condición lo permite adc avance sta xe3d1,x cmp #151 ; ¿Invisible? bcc b6d b6c jmp b5 b6d ; ; Verifica si pone "mira" ; lda offset1,x cmp #$c0 beq mr4 cmp #$48 bcs mr1 lda avance cmp #160 bcs mr0 cmp #50 bcc mr0 mr4 lda cuadro lsr bcs mr0 ; Debe ser bcs o va a tratar de disparar siendo mira lda dificultad rol ; ¿Máxima dificultad? bmi mr0 ; Sí, salta. lda y_enemigo1,y sec sbc y_jugador clc adc #2 cmp #5 bcs mr0 lda x_enemigo1,y sec sbc x_jugador clc adc #3 cmp #7 bcs mr0 stx mira ; Depende de que no haya un avión detrás del otro lda offset1,x sta mira_off ; Para restaurar cmp #$c0 ; ¿Satélite? lda #$d0 bcs mr3 ; Sí, salta (usa mirilla de 16 líneas) lda #$d8 ; No, usa mirilla de 8 líneas mr3 sta offset1,x lda xe3d1,x sta mira_x lda x_jugador clc adc #32 sta xe3d1,x lda ye3d1,x sta mira_y lda yj3d adc #8 sta ye3d1,x lda #1 sta AUDC1 sta AUDF1 lda #15 sta AUDV1 bne b8 mr0 lda offset1,x mr1 cmp #$48 bcs b8 b7 lda y_enemigo1,y cmp #48 lda #$40 bcc b4 lda y_enemigo1,y cmp #64 lda #$38 bcc b4 lda #$30 b4 sta offset1,x lda x_bala2 ; ¿Bala activa? bne b8 sta bala_der lda rand cmp dificultad ; ¿Tiempo de disparar? bcs b8 cpy proximo ; ¿Es el avión que debe disparar? bne b8 lda ye3d1,x sec sbc #7 sta y_bala2 lda y_enemigo1 sta nivel_bala2 lda xe3d1,x jsr efecto_disparo2 lda ola cmp #$3b ; ¿Aviones después de bajar/subir? beq b8a cmp #$3a ; ¿Ola de avión simple? bcs b8 ; Sí, salta. b8a inc proximo lda proximo cmp #3 bne b8 lda #0 sta proximo b8 inx b5 iny cpy #3 beq b3 jmp b6 b3 lda #0 b3b sta ye3d1,x inx cpx #4 bne b3b ; Efecto de sonido según altitud de la nave b25 lda #72 sec sbc y_jugador lsr lsr adc #7 sta AUDF0 lda #8 sta AUDC0 lda #5 sta AUDV0 ; Cambio de tamaño de la nave del jugador ldx #16 lda y_jugador cmp #48 bcc b1 ldx #8 cmp #64 bcc b1 ldx #0 b1 stx offset9 ; Posicionamiento player 0 (nave) lda x_jugador lsr sta xj3d lda y_jugador clc adc #7 ; Sólo suma 7 para evitar tener que usar sec sbc xj3d sta yj3d lda nivel lsr ; ¿Nivel en el espacio? bcc b01 ; Salta, nunca pone sombra lda #31 ldx offset9 cpx #16+7 bne b00 lda #30 b00 clc adc #7 ; Sólo suma 7 para evitar tener que usar sec sbc xj3d sta yj3d2 ; Coordenada Y de la sombra sbc yj3d cmp #$fa ; ¿Se sobrepone con nave? bcc b001 b01 lda #0 b0 sta yj3d2 b001 b11 ; ; Posiciona horizontalmente la nave del jugador ; lda x_jugador ldx #0 ; Player 0 jsr posiciona_en_x ; ; Posiciona horizontalmente la bala del jugador ; lda x_bala ldx #2 ; Missile 0 jsr posiciona_en_x ; ; Posiciona la bala del enemigo ; lda x_bala2 inx ; Missile 1 jsr posiciona_en_x ; ; Posiciona la raya "3D" ; lda nivel lsr bcc b44b lda offset1 cmp #$98 ; ¿Misil teledirigido? beq b44c ; Sí, salta y congela la raya. lda cuadro b44c eor #3 and #3 bpl b44 b44b ldy espacio dey cpy #14 bcc b29 ldy #13 b29 sty espacio tya lsr ; Movimiento lento en espacio bcc b44 sbc #$4b ; Genera línea duplicada en espacio b44 adc #$78 inx ; Ball jsr posiciona_en_x lda nivel lsr ldx #$40 bcs b46 ldx #$70 b46 txs ; Parpadeo de explosiones lda cuadro and #3 bne b43 ldx #4 b40 lda offset9,x cmp #$48 beq b41 cmp #$58 bne b42 b41 eor #$10 sta offset9,x b42 dex bpl b40 b43 ; ; Un poco más de aritmética ; ldx #1 lda ye3d0 beq b45 sec sbc #10 cmp ye3d1 bcc b45 dex b45 stx sprite ; ; Inicio de gráficas ; sta WSYNC sta HMOVE ; Ajuste fino de último posiciona_en_x espera_vblank lda INTIM bne espera_vblank lda #$02 sta ENABL lda nivel lsr ldx #$10 lda #COLOR_3D bcs pan11 ldx #$00 lda cuadro lsr and #$78 ora #$04 bcc pan11a eor #$7a pan11a asl pan11 stx CTRLPF ; Tamaño de la raya 3D (ball) sta COLUPF ; Color de la raya 3D (playfield no se usa) sta HMCLR ; Evita movimiento posterior lda #COLOR_BALA ; Para que la bala sea visible sta COLUP0 ldy #96 ; 96 líneas ; ; Inicia núcleo gráfico ; ; Características: ; * 1 bala usando missile 0 ; * 1 bala usando missile 1 ; * 2 sprites usando player0 (nave y sombra) ; * 4 sprites usando player1 (tres enemigos más adorno) ; * 1 raya de escenario usando ball ; ; Cuenta de ciclos exacta para no perder líneas de video (si eso ; ocurriera, la cuenta de líneas hecha por Stella crecería) ; lda offset9 ora #7 sta offset9 clc adc #24 sta offset9s lda #0 sta WSYNC sta HMOVE sta VBLANK ; Sale de VBLANK jmp pan0 ; ; Fin de gráficas (200 líneas) ; pan12 lda offset9 and #$f8 sta offset9 ldx mira ; Restaura mira si hubo bmi mr2 lda mira_off sta offset1,x lda mira_x sta xe3d1,x lda mira_y sta ye3d1,x mr2 ; ; Corriendo a 30 cuadros por segundo ; lda cuadro lsr bcs z1a jmp z1 z1a jsr generico lda explosion beq z2a jmp b50 z2a ; Lee el joystick del jugador 0 ldy x_jugador lda SWCHA bmi z2 ; ¿Derecha? cpy #55 beq z2 inc x_jugador z2 rol ; ¿Izquierda? bmi z3 cpy #15 beq z3 dec x_jugador z3 ldy y_jugador rol ; ¿Abajo? bmi z4 cpy #72 beq z4 inc y_jugador z4 rol ; ¿Arriba? bmi z5 cpy #32 ; Nave va para abajo beq z5 dec y_jugador z5 jsr boton_disparo ; ¿Botón oprimido? bpl z8 lda x_bala bne z8 lda x_jugador clc adc #12 sta x_bala ldx #-2 ; Ajusta coordenada de la bala lda offset9 cmp #8 beq z0 ldx #-3 bcs z0 ldx #-1 z0 txa clc adc yj3d sta y_bala lda #sonido_1-base_sonido jsr efecto_sonido z8 ; ; Mueve bala del enemigo ; lda x_bala2 ; ¿Bala activa? beq z10 ldx bala_der beq z10a clc adc #1 sta x_bala2 lda y_bala2 sec sbc #2 sta y_bala2 beq z11 bcc z11 bcs z11a z10a sec sbc #4 cmp #15 bcc z11 sta x_bala2 dec y_bala2 z11a lda nivel_bala2 sec sbc y_jugador clc adc #2 cmp #5 bcs z10 lda CXM1P ; Colisión misil 1 bpl z10 ; ¿Chocó con player 0? no, salta jsr inicia_explosion z11 lda #0 sta y_bala2 sta x_bala2 z10 ; ; Corriendo a 60 cuadros por segundo ; z1 ldy #0 ; Sólo comprueba jugador lda x_bala ; ¿Bala activa? beq z44 z40 inc y_bala clc adc #4 cmp #150 bcc z7 lda #0 sta y_bala z7 sta x_bala iny ; Comprueba bala y jugador ; ; Comprueba si el jugador (y=0) o la bala (y=1) chocan con ; algún elemento ; z44 ldx #2 z30 lda nivel lsr bcc z35 ; Fortaleza lda ye3d1,x bne zz35 jmp z32 zz35 lda offset1,x cmp #$b8 ; ¿Electricidad? beq z35b cmp #$98 ; ¿Misil teledirigido o robotote $a0? bcs z35c ; Sí, salta, siempre al nivel cmp #$88 ; ¿Misil vertical? bne z35a lda ye3d1,x ; Saca nivel en referencia a su agujero ; sec ; Garantizado sbc ye3d2,x clc adc #32 bne z36 z35a lda #32 ; En el piso bne z36 z35b lda ola cmp #105 lda y_jugador bcc z35e cmp #48 ; Arriba de la zona: pasa a choque bcs z35c z35g jmp z32b z35e cmp #56 bcs z35g ; Simplifica detección de impacto robotote z35c tya lsr lda CXM0P ; ¿Choque entre misil 0 y player 1? bcs z35f lda CXPPMM ; ¿Choque entre player 0 y player 1? z35f bpl z35d ; No, salta. bmi z34 ; Espacio z35 lda y_enemigo1,x bne z36 z35d jmp z32 z36 sec sbc y_jugador clc adc #2 cmp #5 bcs z35d z31 lda x_jugador,y sec sbc xe3d1,x cpy #0 clc beq z31a adc #8 cmp #10 jmp z31b z31a adc #4 cmp #13 z31b bcs z32 z33 lda yj3d,y sec sbc ye3d1,x cpy #0 clc beq z33a adc #7 cmp #8 jmp z33b z33a adc #4 cmp #9 z33b bcs z32 z34 ; El jugador/bala tocó un enemigo lda offset1,x cmp #$e0 ; ¿Adorno o planetoides? bcs z32 ; Sí, no afecta cmp #$48 ; ¿Explosión 1? beq z32 ; Sí, no afecta cmp #$58 ; ¿Explosión 2? beq z32 ; Sí, no afecta cmp #$60 ; ¿Agujero de misil? beq z32 ; Sí, no afecta cpy #0 bne z34a jsr inicia_explosion_sprite jmp z32c z34a lda offset1,x ; Toma sprite cmp #$80 ; ¿Agujero de misil disparando? beq z37 ; Sí, detiene bala cmp #$b8 ; ¿Electricidad? beq z37 ; Sí, detiene bala cmp #$70 ; ¿Gasolina? bne z38 ; No, salta. lda gasolina clc adc #$0f ; Más gasolina and #$f8 cmp #$50 ; Limita a diez unidades bcc z39 lda #$50 z39 sta gasolina z38 lda offset1,x ; Toma sprite cmp #$98 ; ¿Misil teledirigido? bne z38a inc electrico ldy electrico cpy #5 ; ¿Cinco impactos? bne z37 ; No, salta. z38a cmp #$a0 ; ¿Robotote? bne z38b inc electrico ldy electrico cpy #10 ; ¿Diez impactos? bne z37 ; No, salta. z38b jsr gana_puntos lda #$48 ; Convierte en explosión sta offset1,x lda #sonido_3-base_sonido jsr efecto_sonido_prioridad z37 lda #0 ; Desaparece la bala sta y_bala sta x_bala ldy #1 z32 dex bmi z32b jmp z30 z32b dey bmi z32c jmp z44 z32c z6 ; ; Procesa ola de ataque ; inc secuencia ldx secuencia ldy y_enemigo1 lda ola cmp #$38 bne z14 cpx #32 bcc z17 dey cpy #32 z16 bne z22 lda #$3b sta ola bne z22 z14 cmp #$39 bne z15 cpx #32 bcc z17 iny cpy #72 jmp z16 z15 cmp #$c0 ; Satélite bne z20 dec x_enemigo1 lda x_enemigo1 cmp #10 beq z21 bne z9 z20 cmp #$3a bne z17 lda offset1 cmp #$48 bcs z17 tya cmp y_jugador beq z23 lda #$fe bcs z18 lda #$01 z18 adc y_enemigo1 sta y_enemigo1 z23 lda x_enemigo1 cmp x_jugador beq z17 lda #$fe bcs z19 lda #$01 z19 adc x_enemigo1 sta x_enemigo1 z17 dec avance lda x_enemigo1 clc adc avance cmp #15 bne z9 z21 ldy #0 z22 sty y_enemigo1 sty y_enemigo2 sty y_enemigo3 z9 ; ; Mueve el campo eléctrico ; lda ye3d1 beq z41 lda offset1 cmp #$b8 ; ¿Electricidad? bne z41 ldx electrico cpx #5 ; ¿Alcanzó el ancho horizontal? bne z43 ; No, salta. z42 lda ye3d1 clc adc #4 sta ye3d1 lda xe3d1 sbc #8-1 sta xe3d1 dex bne z42 beq z43a z43 inx lda ye3d1 sec sbc #4 sta ye3d1 lda xe3d1 clc adc #8 sta xe3d1 cmp #160 ; ¿Se sale de la pantalla? bcs z42 z43a stx electrico z41 ; Sonido de fondo ldx offset1 lda #sonido_5-base_sonido cpx #$c0 ; ¿Satèlite? beq b11b lda #sonido_6-base_sonido cpx #$98 ; ¿Misil teledirigido? beq b11b lda #sonido_7-base_sonido cpx #$b8 ; ¿Electricidad? beq b11b lda #sonido_8-base_sonido cpx #$a0 ; ¿Robotote? beq b11b lda #0 b11b cmp sonido_fondo beq b11c sta sonido_fondo tax inx stx sonido_ap2 lda #0 sta sonido_d2 b11c lda cuadro ;and #$ff ; ¿256 cuadros? (4 segundos) bne b50 lda nivel lsr ; ¿Espacio? bcc b50 ; Sí, no gasta gasolina cmp #6 ldx #-2 bcc b51 dex ; -3 cmp #12 bcc b51 dex ; -4 b51 txa clc adc gasolina ; Resta gasolina sta gasolina beq b50a ; ¿Se acabó? bpl b50 lda #0 sta gasolina b50a jsr inicia_explosion b50 ; ; Actualiza el indicador de puntos, se hace hasta ; después de haber visualizado el indicador de puntos, ; así que puede haber un desfase de un cuadro ; ldx #0 ldy #6 ap1 lda puntos,x and #$0f asl asl asl ; clc adc #letras&$ff sta ap_digito,y dey dey lda puntos,x inx lsr and #$78 clc adc #letras&$ff sta ap_digito,y dey dey bpl ap1 ; ; Actualiza indicador de vidas ; lda vidas bpl av1 lda #0 av1 asl asl asl adc #letras&$ff sta ap_digito+10 overscan lda INTIM bne overscan sta WSYNC sta CXCLR ; Limpia colisiones jmp bucle ; ; Inserción de nuevo sprite ; insercion ldx #1 in0 lda offset1,x sta offset2,x lda xe3d1,x sta xe3d2,x lda ye3d1,x sta ye3d2,x dex bpl in0 rts ; Efecto de disparo enemigo efecto_disparo sty nivel_bala2 efecto_disparo2 sta x_bala2 lda #sonido_2-base_sonido ; Pone un efecto de sonido efecto_sonido pha lda sonido_efecto cmp #sonido_3-base_sonido; ¿Hay explosión o lanzamiento? pla bcs es1 efecto_sonido_prioridad sta sonido_efecto sta sonido_ap1 inc sonido_ap1 lda #0 sta sonido_d1 es1 rts ; ; Gana puntos por destruir un enemigo ; gana_puntos lda offset1,x ; Este valor siempre es un múltiplo de 8 sec sbc #64 bcs gp2 lda #0 gp2 tay lda letras+7,y ; Indexa en puntuación sed clc adc puntos sta puntos lda puntos+1 adc #0 bcc gp1 lda #$99 sta puntos gp1 sta puntos+1 cld rts ; ; ; Selecciona el siguiente nivel e incrementa la dificultad ; adelanta_nivel lda dificultad clc adc #4 bpl an1 lda #$7f an1 sta dificultad inc nivel bcc sel_nivel sel_nivel2 lda #$50 ; Valor 5.3 sta gasolina lda #72 ; El jugador empieza arriba sta y_jugador ; Coordenada Y mínima (72), Y máxima (32) sel_nivel lda nivel and #3 bne sn1 lda #espacio_1&$ff ldx #espacio_1>>8 bne sn4 sn1 cmp #1 bne sn2 lda #fortaleza_1&$ff ldx #fortaleza_1>>8 bne sn4 sn2 cmp #2 bne sn3 lda #espacio_2&$ff ldx #espacio_2>>8 bne sn4 sn3 lda #fortaleza_2&$ff ldx #fortaleza_2>>8 sn4 sta lector stx lector+1 lda #0 ldx #2 sn6 sta ola,x ;sta secuencia ;sta explosion sta ye3d1,x ;sta ye3d2 ;sta ye3d3 sta y_enemigo1,x ;sta y_enemigo2 ;sta y_enemigo3 sta sonido_efecto,x ;sta sonido_fondo ;sta sonido_ap1 dex bpl sn6 sta ye3d0 sta sonido_ap2 lda #10 sta tiempo ldx #COLOR_ESPACIO ; Espacio lda nivel lsr bcc sn5 ldx #COLOR_FORTALEZA; Fortaleza lsr lsr bcc sn5 ldx #COLOR_FORTALEZA2; Fortaleza sn5 stx fondo ; Color de fondo lda #$25 sta NUSIZ0 ; Tamaño de Player/Missile 0 sta NUSIZ1 ; Tamaño de Player/Missile 1 sta nucita ldx #8 stx largo_sprite rts ; ; Mensaje hasta botón oprimido ; mensaje ldx #mensaje_final>>8 sta lector stx lector+1 lda #0 sta ola sta AUDV0 ; Apaga el sonido sta AUDV1 me0 ; VERTICAL_SYNC lda #2 sta VSYNC ; Inicia sincronía vertical sta WSYNC ; 3 líneas de espera sta WSYNC if NTSC=1 ldx #(37*76-14)/64 else ldx #(62*76-14)/64 endif sta WSYNC ; stx TIM64T lda #0 sta VSYNC ; Detiene sincronía vertical ; ; Inicio de gráficas ; ; Asume inicialización previa (inicio del juego) ; o que se llamó muestra_puntos (deja vars. iniciadas) ; lda cuadro lsr tax and #$10 bne me3 txa eor #$0e tax me3 txa and #$0e ora #COLOR_TITULO sta COLUP0 eor #$0e sta COLUP1 lda #$02 sta CTRLPF me1 lda INTIM bne me1 tay sta VBLANK ldx #53 me4 sta WSYNC dex bne me4 ; ; Visualiza mensaje ; me2 sta WSYNC lda (lector),y sta PF0 iny lda (lector),y sta PF1 iny lda (lector),y sta PF2 iny ldx #7 me6 sta WSYNC dex bne me6 cpy #33 bne me2 lda #0 sta PF0 sta PF1 sta PF2 ldx #53 me5 sta WSYNC dex bne me5 ; ; ; jsr muestra_puntos ; ; Fin de gráficas (200 líneas) ; me7 lda INTIM bne me7 sta WSYNC lda ola cmp #32 beq me9 inc ola me10 jmp me0 me9 jsr generico jsr boton_disparo ; ¿Botón oprimido? bpl me10 rts ; ; Formato de sonido: ; Primer byte - Instrumento (control TIA en realidad) ; ; Después: ; Primer byte - Frec. (bits 0-4) y vol (bits 5-7) (sumar 8) ; Segundo byte - Duración en cuadros ; ; Si el primer byte es 0xff termina el efecto ; ; Por su estructura se garantiza que termina alineado en 2 bytes ; org $fc10 ; Offset Y de elementos en fortaleza offset_y .byte 35,45,55,65,81,105 ; Espacio 1 espacio_1 .byte $f0 ; Planetoide .byte $38 ; Tres aviones por arriba .byte $39 ; Tres aviones por abajo .byte $3a,52 ; Avión loquito .byte $3b,72 ; Un avión a la vez .byte $3c,52 ; Un avión a la vez .byte $3d,32 ; Un avión a la vez .byte $c0 ; Satélite .byte $39 ; Tres aviones por abajo .byte $3b,32 ; Un avión a la vez .byte $3c,52 ; Un avión a la vez .byte $3d,72 ; Un avión a la vez .byte $38 ; Tres aviones por arriba .byte $3a,52 ; Avión loquito .byte $00 ; Fin de nivel ; Avión grande = $30 3 ; Avión medio = $38 3 ; Avión chico = $40 3 ; Combustible = $70 2 ; Antena = $78 2 ; Agujero = $60 ; Cañón girado = $50 2 ; Cañón = $68 2 ; Alienígena = $90 3 ; Misil = $98 5 ; Satélite = $C0 10 ; Robotote = $A0 25 ; Electricidad = $B8 ; Adorno de piso = $e0, sólo antes de $60 ; Fortaleza 1 fortaleza_1 .byte $70 .byte $71 .byte $6b .byte $e1 .byte $62 .byte $e0 .byte $63 .byte $79 .byte $68 .byte $53 .byte $e0 .byte $61 .byte $e0 .byte $62 .byte $70 .byte $6a .byte $e2 .byte $63 .byte $79 .byte $60 .byte $e2 .byte $63 .byte $52 .byte $72 .byte $61 .byte $6a .byte $78 .byte $bc ; Electricidad .byte $9b ; Misil .byte $70 .byte $73 .byte $73 .byte $79 .byte $93 ; Alienígena .byte $6a .byte $51 .byte $6b .byte $71 .byte $60 .byte $62 .byte $78 .byte $62 .byte $00 ; Fin de nivel base_sonido ; Silencio sonido_0 .byte $00 ; Debe usar un byte ; Disparo del jugador sonido_1 .byte $08 ; Instrumento .byte 1,$80 .byte 2,$82 .byte 3,$85 .byte 3,$45 .byte 3,$05 .byte 0 ; Disparo enemigo sonido_2 .byte $0e .byte 1,$e3 .byte 1,$c1 .byte 1,$a2 .byte 1,$81 .byte 1,$60 .byte 0 ; Explosión sonido_3 .byte $08 .byte 2,$84 .byte 3,$e5 .byte 3,$e6 .byte 2,$a7 .byte 2,$68 .byte 2,$6c .byte 2,$70 .byte 5,$78 .byte 5,$1c .byte 5,$1f .byte 0 ; Lanzamiento sonido_4 .byte $08 .byte 10,$9f .byte 10,$f0 .byte 20,$ee .byte 0 ; Los siguientes cuatro son sonidos de fondo continuos ; Satélite sonido_5 .byte $01 .byte 7,$41 .byte 3,$43 .byte 7,$81 .byte 3,$83 .byte 0 ; <NAME> sonido_6 .byte $05 .byte 1,$e0 .byte 2,$e2 .byte 3,$e3 .byte 0 ; Electricidad sonido_7 .byte $0f .byte 2,$01 .byte 1,$e0 .byte 2,$82 .byte 0 ; Robotote sonido_8 .byte $04 .byte 5,$84 .byte 5,$82 .byte 5,$83 .byte 5,$88 .byte 5,$84 .byte 3,$86 .byte 0 ; Fortaleza 2 fortaleza_2 .byte $42 .byte $43 .byte $71 .byte $71 .byte $60 .byte $e2 .byte $63 .byte $e0 .byte $61 .byte $7a .byte $68 .byte $51 .byte $6a .byte $6b .byte $79 .byte $72 .byte $9b ; Misil .byte $bc ; Electricidad .byte $e0 .byte $61 .byte $93 ; Alienígena .byte $60 .byte $68 .byte $bd ; Electricidad .byte $73 .byte $72 .byte $78 .byte $7b .byte $bc ; Electricidad .byte $73 .byte $72 .byte $79 .byte $9b ; Misil .byte $bd ; Electricidad .byte $40 .byte $70 .byte $93 ; Alienígena .byte $93 ; Alienígena .byte $93 ; Alienígena .byte $43 .byte $7a .byte $71 .byte $7b .byte $a3 ; Robotote .byte $00 ; Fin de nivel ; Espacio 2 espacio_2 .byte $f1 ; Planetoide .byte $3a,32 ; Avión loquito .byte $c0 ; Satélite .byte $3b,52 ; Un avión a la vez .byte $3c,52 ; Un avión a la vez .byte $3d,52 ; Un avión a la vez .byte $38 ; Tres aviones por arriba .byte $3a,72 ; Avión loquito .byte $39 ; Tres aviones por abajo .byte $3b,72 ; Un avión a la vez .byte $3c,52 ; Un avión a la vez .byte $3d,72 ; Un avión a la vez .byte $c0 ; Satélite .byte $39 ; Tres aviones por abajo .byte $3a,52 ; Avión loquito .byte $00 ; Fin de nivel y alineación org $fd00 ; Locación de inicio del ROM ; Para evitar cruces de página ; Sprites de 8 líneas ubicados en múltiplos de 8 ; Sprites de 16 líneas ubicados en múltiplos de 16 ; ; Colores de sprite por línea ; colores if COLOR_NTSC = 1 ; Nave .byte $0c .byte $0e .byte $18 .byte $0e .byte $0e .byte $0e .byte $0e .byte $0c .byte $0c .byte $0c .byte $18 .byte $0e .byte $0e .byte $0e .byte $0e .byte $0c .byte $0c .byte $0c .byte $18 .byte $0e .byte $0e .byte $0e .byte $0c .byte $0c ; Sombra .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 .byte $90 ; Aviones .byte $b6 .byte $b8 .byte $ba .byte $ba .byte $ba .byte $ba .byte $b8 .byte $b8 .byte $b6 .byte $b8 .byte $ba .byte $ba .byte $ba .byte $ba .byte $b8 .byte $b8 .byte $b6 .byte $b8 .byte $ba .byte $ba .byte $ba .byte $ba .byte $b8 .byte $b8 ; Explosión 1 .byte $34 .byte $34 .byte $34 .byte $1a .byte $1a .byte $34 .byte $34 .byte $34 ; Cañón .byte $26 .byte $28 .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a ; Explosión 2 .byte $38 .byte $38 .byte $1c .byte $1c .byte $1c .byte $1c .byte $38 .byte $38 ; Agujero .byte $14 .byte $16 .byte $18 .byte $1a .byte $1c .byte $1c .byte $1a .byte $1a ; Cañón .byte $26 .byte $28 .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a ; Combustible .byte $b0 .byte $ba .byte $ba .byte $ba .byte $ba .byte $98 .byte $98 .byte $0e ; Antena .byte $26 .byte $18 .byte $0c .byte $0c .byte $0e .byte $0e .byte $0e .byte $0c ; Agujero disparando .byte $36 .byte $36 .byte $36 .byte $36 .byte $36 .byte $36 .byte $36 .byte $36 ; Misil V .byte $34 .byte $38 .byte $0c .byte $0e .byte $0e .byte $0e .byte $0e .byte $0c ; Alienígena .byte $44 .byte $44 .byte $44 .byte $4a .byte $4a .byte $4a .byte $48 .byte $48 ; Misil teledirigido .byte $36 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $34 ; Robotote .byte $0c .byte $0e .byte $0c .byte $0e .byte $0c .byte $0e .byte $0c .byte $0e .byte $0c .byte $0e .byte $0c .byte $0e .byte $0c .byte $0e .byte $0c .byte $0e ; Adorno en pared de fortaleza .byte $b2 .byte $b2 .byte $b4 .byte $b4 .byte $b6 .byte $b6 .byte $b6 .byte $b6 ; Electricidad .byte $0e .byte $0e .byte $0e .byte $0e .byte $0e .byte $0e .byte $0e .byte $0e ; Satélite .byte $0c .byte $0c .byte $98 .byte $98 .byte $98 .byte $98 .byte $0c .byte $0c .byte $0e .byte $0e .byte $0e .byte $0e .byte $38 .byte $0e .byte $0e .byte $0e ; Mira .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 .byte $38 ; Adorno en piso de fortaleza .byte $0c .byte $0c .byte $0c .byte $0c .byte $0c .byte $0c .byte $0c .byte $0c ; Adorno en pared de fortaleza .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a ; Planetoide .byte $94 .byte $96 .byte $98 .byte $9a .byte $9c .byte $9c .byte $9a .byte $98 ; Planetoide .byte $94 .byte $94 .byte $94 .byte $98 .byte $9a .byte $9c .byte $9c .byte $9c else ; Nave .byte $0c .byte $0e .byte $28 .byte $0e .byte $0e .byte $0e .byte $0e .byte $0c .byte $0c .byte $0c .byte $28 .byte $0e .byte $0e .byte $0e .byte $0e .byte $0c .byte $0c .byte $0c .byte $28 .byte $0e .byte $0e .byte $0e .byte $0c .byte $0c ; Sombra .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 .byte $B0 ; Aviones .byte $76 .byte $78 .byte $7a .byte $7a .byte $7a .byte $7a .byte $78 .byte $78 .byte $76 .byte $78 .byte $7a .byte $7a .byte $7a .byte $7a .byte $78 .byte $78 .byte $76 .byte $78 .byte $7a .byte $7a .byte $7a .byte $7a .byte $78 .byte $78 ; Explosión 1 .byte $44 .byte $44 .byte $44 .byte $2a .byte $2a .byte $44 .byte $44 .byte $44 ; Cañón .byte $26 .byte $28 .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a ; Explosión 2 .byte $48 .byte $48 .byte $2c .byte $2c .byte $2c .byte $2c .byte $48 .byte $48 ; Agujero .byte $24 .byte $26 .byte $28 .byte $2a .byte $2c .byte $2c .byte $2a .byte $2a ; Cañón .byte $26 .byte $28 .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a ; Combustible .byte $70 .byte $7a .byte $7a .byte $7a .byte $7a .byte $B8 .byte $B8 .byte $0e ; Antena .byte $26 .byte $28 .byte $0c .byte $0c .byte $0e .byte $0e .byte $0e .byte $0c ; Agujero disparando .byte $46 .byte $46 .byte $46 .byte $46 .byte $46 .byte $46 .byte $46 .byte $46 ; Misil V .byte $44 .byte $48 .byte $0c .byte $0e .byte $0e .byte $0e .byte $0e .byte $0c ; Alienígena .byte $64 .byte $64 .byte $64 .byte $6a .byte $6a .byte $6a .byte $68 .byte $68 ; <NAME> .byte $46 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $44 ; Robotote .byte $0c .byte $0e .byte $0c .byte $0e .byte $0c .byte $0e .byte $0c .byte $0e .byte $0c .byte $0e .byte $0c .byte $0e .byte $0c .byte $0e .byte $0c .byte $0e ; Adorno en pared de fortaleza .byte $72 .byte $72 .byte $74 .byte $74 .byte $76 .byte $76 .byte $76 .byte $76 ; Electricidad .byte $0e .byte $0e .byte $0e .byte $0e .byte $0e .byte $0e .byte $0e .byte $0e ; Satélite .byte $0c .byte $0c .byte $b8 .byte $b8 .byte $b8 .byte $b8 .byte $0c .byte $0c .byte $0e .byte $0e .byte $0e .byte $0e .byte $48 .byte $0e .byte $0e .byte $0e ; Mira .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 .byte $48 ; Adorno en piso de fortaleza .byte $0c .byte $0c .byte $0c .byte $0c .byte $0c .byte $0c .byte $0c .byte $0c ; Adorno en pared de fortaleza .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a .byte $2a ; Planetoide .byte $b4 .byte $b6 .byte $b8 .byte $ba .byte $bc .byte $bc .byte $ba .byte $b8 ; Planetoide .byte $b4 .byte $b4 .byte $b4 .byte $b8 .byte $ba .byte $bc .byte $bc .byte $bc endif org $fe00 ; Locación de inicio del ROM ; Para evitar cruces de página ; ; Los sprites están verticalmente al revés, para ahorrar ; instrucciones al visualizar. ; sprites ; Nave grande ($00) .byte $1c .byte $38 .byte $78 .byte $fc .byte $fe .byte $ef .byte $6d .byte $46 ; Nave media ($08) .byte $00 .byte $30 .byte $70 .byte $fc .byte $fe .byte $6a .byte $6c .byte $40 ; Nave chica ($10) .byte $00 .byte $10 .byte $30 .byte $7c .byte $7a .byte $34 .byte $20 .byte $00 ; Sombra chica ($18) .byte $00 .byte $00 .byte $00 .byte $20 .byte $30 .byte $78 .byte $7c .byte $48 ; Sombra media ($20) .byte $00 .byte $00 .byte $10 .byte $30 .byte $7c .byte $7e .byte $6c .byte $40 ; Sombra grande ($28) .byte $00 .byte $00 .byte $30 .byte $70 .byte $7c .byte $7e .byte $7e .byte $6c ; Avión grande ($30) .byte $04 .byte $cc .byte $f8 .byte $5c .byte $3e .byte $66 .byte $42 .byte $02 ; Avión medio ($38) .byte $04 .byte $0c .byte $78 .byte $5c .byte $3e .byte $66 .byte $42 .byte $00 ; Avión chico ($40) .byte $08 .byte $18 .byte $70 .byte $58 .byte $3c .byte $6c .byte $44 .byte $00 ; Explosión ($48) .byte $00 .byte $08 .byte $56 .byte $6c .byte $12 .byte $38 .byte $66 .byte $00 ; Cañón mirando a la der. ($50) .byte $39 .byte $7b .byte $7e .byte $44 .byte $3a .byte $7e .byte $3c .byte $00 ; Explosión ($58) .byte $22 .byte $99 .byte $66 .byte $44 .byte $13 .byte $58 .byte $a6 .byte $49 ; Agujero ($60) .byte $18 .byte $3e .byte $76 .byte $c3 .byte $c3 .byte $6e .byte $38 .byte $00 ; Cañón mirando a la izq. ($68) .byte $9c .byte $de .byte $7e .byte $22 .byte $5c .byte $7e .byte $3c .byte $00 ; Combustible ($70) .byte $3c .byte $7e .byte $7e .byte $66 .byte $5a .byte $3c .byte $7e .byte $3c ; Antena ($78) .byte $38 .byte $18 .byte $30 .byte $7c .byte $74 .byte $68 .byte $74 .byte $3a ; Agujero disparando ($80) .byte $5f .byte $be .byte $7f .byte $eb .byte $df .byte $3a .byte $5c .byte $28 ; Misil vertical ($88) .byte $38 .byte $38 .byte $7c .byte $38 .byte $38 .byte $38 .byte $38 .byte $10 ; Alienígena ($90) .byte $38 .byte $7c .byte $44 .byte $ba .byte $ba .byte $7c .byte $7c .byte $38 ; Misil teledirigido ($98) .byte $00 .byte $c0 .byte $f6 .byte $7c .byte $1e .byte $0e .byte $0a .byte $02 ; Robotote ($a0) .byte $06 .byte $1a .byte $7f .byte $fa .byte $bf .byte $ea .byte $af .byte $fa .byte $bf .byte $fa .byte $b3 .byte $93 .byte $9f .byte $e2 .byte $84 .byte $40 ; Adorno en pared de fortaleza ($b0) .byte $c0 .byte $f0 .byte $fc .byte $ff .byte $f3 .byte $ee .byte $dc .byte $b8 ; Electricidad ($b8) ; Tiene truco para replicar 3 veces, al hacer OR con $00-$17 sigue ; estando en el rango $b8-$bf .byte $05 .byte $2b .byte $59 .byte $48 .byte $85 .byte $2b .byte $59 .byte $48 ; Satélite ($c0) .byte $10 .byte $38 .byte $14 .byte $18 .byte $30 .byte $50 .byte $18 .byte $3e .byte $20 .byte $5e .byte $3a .byte $7a .byte $7a .byte $7e .byte $7c .byte $30 ; Mira ($d0 y $d8) .byte $00 .byte $00 .byte $00 .byte $00 .byte $00 .byte $00 .byte $00 .byte $00 .byte $00 .byte $00 .byte $44 .byte $28 .byte $00 .byte $28 .byte $44 .byte $00 ; Adorno de piso ($e0) .byte $30 .byte $7c .byte $7f .byte $3f .byte $cf .byte $f2 .byte $3c .byte $08 ; Adorno 2 ($e8) .byte $c0 .byte $f0 .byte $fc .byte $ff .byte $ff .byte $fc .byte $f0 .byte $c0 ; Planetoide ($f0) .byte $d8 .byte $bc .byte $8e .byte $76 .byte $7a .byte $7d .byte $3d .byte $1b ; Planetoide ($f8) .byte $00 .byte $38 .byte $7c .byte $7c .byte $7c .byte $7c .byte $38 .byte $00 gas1 .byte $00,$40,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0 gas2 .byte $00,$00,$00,$80,$c0,$e0,$f0,$f8,$fc,$fe,$ff letras .byte $00,$fe,$c6,$c6,$c6,$fe,$00,$02 .byte $00,$78,$30,$30,$70,$30,$00,$00 .byte $00,$fe,$c0,$fe,$06,$fe,$00,$02 .byte $00,$fe,$06,$fe,$06,$fe,$00,$00 .byte $00,$06,$06,$fe,$c6,$c6,$00,$00 .byte $00,$fe,$06,$fe,$c0,$fe,$00,$02 .byte $00,$fe,$c6,$fe,$c0,$fe,$00,$01 .byte $00,$18,$18,$0c,$06,$fe,$00,$02 .byte $00,$fe,$c6,$fe,$c6,$fe,$00,$00 .byte $00,$fe,$06,$fe,$c6,$fe,$00,$01 .byte $00,$00,$00,$00,$00,$00,$00,$03 .byte $0e,$e2,$ae,$aa,$aa,$ea,$80,$05 .byte $00,$0a,$0a,$0a,$0a,$0e,$00,$25 .byte $00,$ea,$aa,$ea,$2a,$ee,$00,$00 .byte $00,$ee,$a8,$a8,$a8,$ee,$00,$00 .byte $00,$ae,$a8,$ae,$aa,$ee,$80,$00 .byte $00,$ee,$22,$ee,$88,$ee,$00,$10 mensaje_titulo .byte $70,$ee,$77 .byte $10,$aa,$11 .byte $70,$ee,$71 .byte $40,$8a,$11 .byte $70,$8a,$77 .byte $00,$00,$00 .byte $c0,$9e,$1d .byte $40,$52,$25 .byte $c0,$9e,$25 .byte $40,$52,$25 .byte $40,$52,$1d mensaje_final .byte $f0,$7a,$7a .byte $10,$4b,$0b .byte $d0,$7b,$3b .byte $90,$4a,$0a .byte $f0,$4a,$7a .byte $00,$00,$00 .byte $f0,$4b,$3b .byte $90,$4a,$48 .byte $90,$4b,$39 .byte $90,$32,$48 .byte $f0,$33,$4b ; ; Adelanta lector de nivel ; adelanta_lector inc lector bne al1 inc lector+1 al1 rts ; ; Obtiene botón de disparo. ; Se asegura de que el jugador no puede dejar oprimido el botón :> ; boton_disparo lda INPT4 eor #$ff tax eor antirebote stx antirebote bpl bd1 lda antirebote ; Puede ser txa pero desalinea JMP construido abajo bd1 rts ; Servicio genérico generico lda SWCHB lsr ; ¿Reset? bcs bd1 ;jmp $f000 .byte $4c ; Forma JMP org $fffc .word inicio ; Posición de inicio al recibir RESET .word inicio ; Posición para servir BRK
programs/oeis/121/A121569.asm
neoneye/loda
22
173462
; A121569: a(n) = Fibonacci((prime(n)+3)/2) - 1. ; 1,2,4,12,20,54,88,232,986,1596,6764,17710,28656,75024,317810,1346268,2178308,9227464,24157816,39088168,165580140,433494436,1836311902,12586269024,32951280098,53316291172,139583862444,225851433716 seq $0,98090 ; Numbers k such that 2k-3 is prime. sub $0,3 seq $0,166876 ; a(n) = a(n-1) + Fibonacci(n), a(1)=1983. sub $0,1982
libsrc/_DEVELOPMENT/math/float/am9511/lam32/c/sccz80/modf.asm
ahjelm/z88dk
640
11015
<reponame>ahjelm/z88dk SECTION code_fp_am9511 PUBLIC modf EXTERN cam32_sccz80_modf defc modf = cam32_sccz80_modf ; SDCC bridge for Classic IF __CLASSIC PUBLIC _modf EXTERN _am9511_modf defc _modf = _am9511_modf ENDIF
test/annotation/test_annotation-write.ads
skill-lang/skillAdaTestSuite
1
17273
with Ada.Directories; with Ahven.Framework; with Annotation.Api; package Test_Annotation.Write is package Skill renames Annotation.Api; use Annotation; use Annotation.Api; type Test is new Ahven.Framework.Test_Case with null record; procedure Initialize (T : in out Test); procedure Set_Up (T : in out Test); procedure Tear_Down (T : in out Test); procedure Read_Written (T : in out Ahven.Framework.Test_Case'Class); procedure Check_Annotation (T : in out Ahven.Framework.Test_Case'Class); procedure Annotation_Type_Safety (T : in out Ahven.Framework.Test_Case'Class); end Test_Annotation.Write;
DIVISION 0.1.asm
Jon2G/ASMCalculator
0
161440
<filename>DIVISION 0.1.asm .model small .data num1 db 0,0,0,0,0,0,0,0,0,3,'$' decimales_1 db 0,0,0,0,0,0,0,0,0,0,'$' num2 db 0,0,0,0,0,0,0,0,1,5,'$' decimales_2 db 0,0,0,0,0,0,0,0,0,0,'$' ;;;-------------------------------------------------- ;;;;;;;;OPERANDOS PARA LA DIVISION num_res_div db 0,0,0,0,0,0,0,0,0,0,'$' decimales_Res_div db 0,0,0,0,0,0,0,0,0,0,'$' resultado_entero_div db 01h es_negativo_resuido_div db 00h indefinida db 'Indeterminado' dividi_una_vez db 00h ;;;--------------------------------------------------------- num_res db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'$' decimales_Res db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'$' Aux db 00h ajuste_decimales_1 db 0,0,0,0,0,0,0,0,0,0,'$' .stack .code begin proc far mov ax,@data mov ds,ax CALL DIVIDE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;IMPRIMIR RESULTADO LEA DX,num_res MOV AH,09 INT 21H MOV AH,02 MOV DL,'.' INT 21H LEA DX,decimales_Res MOV AH,09 INT 21H XOR AX,AX INT 16H begin endp DIVIDE PROC NEAR ;;REVISAR QUE LA DIVISION NO SEA x/0 MOV SI,09h revisa_indefinidos: CMP num2[SI],00H JNE no_es_indefinida CMP decimales_2[SI],00H JNE no_es_indefinida DEC SI JNS revisa_indefinidos MOV CX,0Dh ;longuitud de la palabra "Indeterminado" MOV SI,00h indeterminado_cpy: MOV AL,indefinida[SI] MOV num_res[SI],Al INC SI Loop indeterminado_cpy MOV decimales_Res[00h],07h ;borrar los decimales MOV decimales_Res[01h],07h ;borrar los decimales RET no_es_indefinida: ;;COPIAR LOS OPERANDOS ORIGINALES EN LAS VARIABLES ESPECIALES ;;PARA LA DIVISION MOV DI,0000h aun_hay_resuido: ;------------------------------------------------------------------------------------INICIA_RESTA ;DETERMINAR CUAL NUMERO ES MAYOR ;reccorer el num1 y num2 desde la posicion 0 MOV SI,00h cual_es_mayor_div: INC SI MOV AL,num2[SI] ;COMPARAR num1 CON num2 CMP num1[SI],AL ;si num1 es mayor ya podemos restar JA acomodados_para_la_resta_div ;si son iguales_div JE iguales_div ;si no significa que num2 es mayor JMP num2_mayor_div acomodados_para_la_resta_div: JMP ya_puedes_restar_div iguales_div: MOV es_negativo_resuido_div,00h ;no hay signo en la parte entera CMP SI,09h ;si el el fin de cadena ambos numeros son exactamente iguales_div en su parte entera JE revisar_parte_decimal JMP cual_es_mayor_div ;----------------------------------------------------------------------------- revisar_parte_decimal: ;revisar su parte decimal para determinar el mayor MOV SI,00h cual_es_mayor_dec: INC SI MOV AL,decimales_2[SI] ;COMPARAR num1 CON num2 CMP decimales_1[SI],AL ;si num1 es mayor ya podemos restar JA acomodados_para_la_resta_div ;si son iguales_div ; JE iguales_div ;si no significa que num2 es mayor JL num2_mayor_div CMP SI,09h JL cual_es_mayor_dec JMP ya_puedes_restar_div ;----------------------------------------------------------------------------- ;------------------->inicia ajuste para que num 1 sea siempre mayor num2_mayor_div: MOV es_negativo_resuido_div,01h MOV resultado_entero_div,00h JMP la_resta_ya_es_negativa ;copiamos el numero mayor (num2) a la variable temporal ajuste_decimales_1 MOV SI,00h num2_mayor_div_cpy: MOV AL,num2[SI] MOV ajuste_decimales_1[SI],AL INC SI CMP SI,09h JLE num2_mayor_div_cpy ;copiamos el numero (num1) menor a num2 MOV SI,00h num2_menor_cpy_div: MOV AL,num1[SI] MOV num2[SI],AL INC SI CMP SI,09h JLE num2_menor_cpy_div ;copiamos el numero mayor guardado en ajuste_decimales_1 a num1 MOV SI,00h num1_ajuste_cpy_div: MOV AL,ajuste_decimales_1[SI] MOV num1[SI],AL MOV ajuste_decimales_1[SI],00h ;limpiamos la variable temporal INC SI CMP SI,09h JLE num1_ajuste_cpy_div ;;INVERTIR LOS DECIMALES TAMBIEN ;------------------------------------------------------------------ ;copiamos el numero mayor (decimales_2) a la variable temporal ajuste_decimales_1 MOV SI,00h dec2_mayor_cpy_div: MOV AL,decimales_2[SI] MOV ajuste_decimales_1[SI],AL INC SI CMP SI,09h JLE dec2_mayor_cpy_div ;copiamos el numero (decimales_1) menor a decimales_2 MOV SI,00h dec2_menor_cpy_div: MOV AL,decimales_1[SI] MOV decimales_2[SI],AL INC SI CMP SI,09h JLE dec2_menor_cpy_div ;copiamos el numero mayor guardado en ajuste_decimales_1 a decimales_1 MOV SI,00h dec1_ajuste_cpy_div: MOV AL,ajuste_decimales_1[SI] MOV decimales_1[SI],AL MOV ajuste_decimales_1[SI],00h ;limpiamos la variable temporal INC SI CMP SI,09h JLE dec1_ajuste_cpy_div ;------------------------------------------------------------------ ya_puedes_restar_div: MOV dividi_una_vez,01h ;RESTAR PARTES DECIMALES MOV SI,09h ;asigna a SI 9 (la ultima posicion del numero) JMP siguiente_decimal_res_div ;salta a la etiqueta siguiente_entero_res_div fin_decimal_res_div: MOV decimales_Res_div[SI],'$' DEC SI JMP siguiente_decimal_res_div siguiente_decimal_res_div: MOV AL,decimales_1[SI] CMP AL,24h ;si es el fin de cadena JE fin_decimal_res_div CMP AL,decimales_2[SI] ;compara al y JL pide_prestado_d_div JMP resta_conNormalidad_d_div pide_prestado_d_div: CMP SI,0000h JE prestamo_desde_los_enteros_div DEC decimales_1[SI-1] ADD decimales_1[SI],0Ah resta_conNormalidad_d_div: MOV AL,decimales_1[SI] SUB AL,decimales_2[SI] MOV decimales_Res_div[SI],AL DEC SI JNS siguiente_decimal_res_div JMP enteros_res_div ;AJUSTAR ACARREO DECIMAL NEGATIVO PARA LOS ENTEROS prestamo_desde_los_enteros_div: DEC num1[09h] MOV decimales_Res_div[0h],00h ;limpiar el acarreo ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; enteros_res_div: ;RESTAR PARTES ENTERAS MOV SI,09h ;asigna a SI 9 (la ultima posicion del numero) JMP siguiente_entero_res_div ;salta a la etiqueta siguiente_entero_res_div fin_enteros_res_div: MOV num_res_div[SI],'$' DEC SI JMP siguiente_entero_res_div siguiente_entero_res_div: MOV AL,num1[SI] CMP AL,24h ;si es el fin de cadena JE fin_enteros_res_div CMP AL,num2[SI] ;compara al y JL pide_prestado_e_div JMP resta_conNormalidad_e_div pide_prestado_e_div: DEC num1[SI-1] ADD num1[SI],0Ah resta_conNormalidad_e_div: MOV AL,num1[SI] SUB AL,num2[SI] MOV num_res_div[SI],AL DEC SI JNS siguiente_entero_res_div ;-------------------------------------------------------------------------------------FIN_RESTA ;COPIAR NUM_RES_DIV A NUM1 MOV SI,09H siguiente_resultado_resta: ;para su parte entera MOV Al,num_res_div[SI] MOV num1[SI],Al ;para su parte decimal MOV AL,decimales_Res_div[SI] MOV decimales_1[SI],AL DEC SI JNS siguiente_resultado_resta ;;INICIA INCREMENTO DE CONTADOR PARA EL RESULTADO CMP resultado_entero_div,01h JE enteros_div JMP decimales_div enteros_div: INC num_res[13h] ;agregamos 1 a la ultima posicion de el resultado entero ;ajustar los acarreos MOV SI,14h siguiente_posicion_enteros_div: DEC SI CMP num_res[SI],0Ah JLE siguiente_posicion_enteros_div JMP fin_incremento_contador ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; XOR AX,AX INT 16h MOV AL,num_res[SI] AAM MOV CL,AL ADD AL,CL MOV num_res[SI-1],Ah ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; JMP siguiente_posicion_enteros_div decimales_div: ;------------------------------------------------------------------------------------------- INC decimales_res[DI] ;agregamos 1 a la posicion actual del resultado decimal ;ajustar los acarreos MOV SI,14h siguiente_posicion_decimales_div: DEC SI CMP decimales_res[SI],0Ah JLE siguiente_posicion_decimales_div JMP fin_incremento_contador ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; XOR AX,AX INT 16h MOV AL,decimales_res[SI] AAM MOV CL,AL ADD AL,CL MOV decimales_res[SI-1],Ah ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; JMP siguiente_posicion_decimales_div ;------------------------------------------------------------------------------------------- fin_incremento_contador: JMP aun_hay_resuido la_resta_ya_es_negativa: CMP dividi_una_vez,01h JNE resultado_menor_que_cero JMP resultado_mayor_que_cero resultado_menor_que_cero: ;;si el resultado es 0.xxxxxxx copiamos el operador num1 a num_res_div para que lo ;;multiplique por 10 MOV resultado_entero_div,00h MOV SI,09h cpy_menor_cero: ;para los enteros MOV AL,num1[SI] MOV Num_res_div[SI],Al ;para los decimales MOV AL,decimales_1[SI] MOV decimales_res_div[SI],Al DEC SI JNS cpy_menor_cero resultado_mayor_que_cero: ;------------------------------------------------------------------------------ ;;MULTIPLICAR EL RESUIDO GUARADO EN NUM_RES_DIV Y DECIAMALES_RES_DIV X10 ;incrementar el 1 el destino decimal INC DI CMP DI,14H JNE no_periodico_div JMP periodico_div no_periodico_div: MOV SI,09H multiplica_siguiente_resuido: ;multiplicar su parte entera MOV AL,Num_res_div[SI] MOV AUX,0AH MUL Aux MOV Num_res_div[SI],Al ;multiplicar su parte decimal MOV AL,decimales_res_div[SI] MUL Aux MOV decimales_res_div[SI],Al DEC SI JNS multiplica_siguiente_resuido ;------------------------------------------------------------------------------ ;AJUSTAR LOS ACARREOS PROVOCADOS POR LA MULTIPLICACION POR 10 ;para el acarreo decimal MOV SI,09H siguiente_res_div_mul10: MOV AL,decimales_res_div[SI] CMP AL,0AH JAE acarreo_por_resuido DEC SI JNS siguiente_res_div_mul10 JMP fin_res_div_mul10 acarreo_por_resuido: AAM MOV decimales_res_div[SI],Al MOV CL,decimales_res_div[SI-1] ADD Ah,CL MOV decimales_res_div[SI-1],Ah JNS siguiente_res_div_mul10 fin_res_div_mul10: ;-------------------------------------------------- ;Agregar acarreo pendiente guarado en la primer posicion de decimales_res_div MOV AL,decimales_res_div[00h] MOV decimales_res_div[00h],00h MOV CL,num_res_div[09h] ADD AL,CL MOV num_res_div[09h],Al ;-------------------------------------------------- ;para el acarreo entero MOV SI,09H siguiente_res_div_mul10_e: MOV AL,num_res_div[SI] CMP AL,0AH JAE acarreo_por_resuido_e DEC SI JNS siguiente_res_div_mul10_e JMP fin_res_div_mul10_e acarreo_por_resuido_e: AAM MOV num_res_div[SI],Al MOV CL,num_res_div[SI-1] ADD Ah,CL MOV num_res_div[SI-1],Ah JNS siguiente_res_div_mul10_e fin_res_div_mul10_e: ;------------------------------------------------------------------------------ ;copiar el resuido ajustado a las variables de operacion num1 y decimales_1 MOV SI,09H siguiente_resuido_div: ;para su parte entera MOV Al,num_res_div[SI] MOV num1[SI],Al ;para su parte decimal MOV AL,decimales_Res_div[SI] MOV decimales_1[SI],AL DEC SI JNS siguiente_resuido_div ;------------------------------------------------------------------------------ ;saltamos a 'restar' el residuo ;XOR AX,AX ;INT 16H JMP aun_hay_resuido periodico_div: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;AJUSTAR PARA IMPRESION ;;ajustar la parte entera MOV SI,13h JMP inicia_ajuste_div salta_fin_div: DEC SI JMP inicia_ajuste_div inicia_ajuste_div: MOV AL,num_res[SI] CMP AL,24h JE salta_fin_div ADD AL,30h MOV num_res[SI],AL DEC SI JNS inicia_ajuste_div ;;ajustar la parte decimal MOV SI,13h JMP inicia_ajuste_d_div salta_fin_d_div: DEC SI JMP inicia_ajuste_d_div inicia_ajuste_d_div: MOV AL,decimales_Res[SI] CMP AL,24h JE salta_fin_d_div ADD AL,30h MOV decimales_Res[SI],AL DEC SI JNS inicia_ajuste_d_div MOV decimales_Res[0h],07h ;limpiar el acarreo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;NO OLVIDES AGREGAR Y LIMPIAR EL SIGNO DEL RESULTADO MARCADO EN LA VARIABLE hay_signo ;CALL AJUSTE_PARA_IMPRESION RET DIVIDE ENDP end begin
oeis/081/A081295.asm
neoneye/loda-programs
11
247239
; A081295: a(n) = (-1)^(n+1)* coefficient of x^n in Sum_{k>=1} x^k/(1+2*x^k). ; Submitted by <NAME> ; 1,1,5,9,17,29,65,137,261,497,1025,2085,4097,8129,16405,32905,65537,130845,262145,524793,1048645,2096129,4194305,8390821,16777233,33550337,67109125,134225865,268435457,536855053,1073741825,2147516553,4294968325,8589869057,17179869265,34359871269,68719476737,137438691329,274877911045,549756338809,1099511627777,2199022215133,4398046511105,8796095118345,17592186061077,35184367894529,70368744177665,140737496778917,281474976710721,562949936644593,1125899906908165,2251799847235593,4503599627370497 add $0,1 mov $2,$0 lpb $0 div $1,-1 mul $1,2 mov $3,$2 dif $3,$0 sub $0,1 cmp $3,$2 cmp $3,0 add $1,$3 lpe add $1,1 gcd $0,$1
programs/oeis/057/A057349.asm
karttu/loda
1
20502
; A057349: Leap years in the Hebrew Calendar starting in year 1 (3761 BCE). The leap year has an extra-month. ; 3,6,8,11,14,17,19,22,25,27,30,33,36,38,41,44,46,49,52,55,57,60,63,65,68,71,74,76,79,82,84,87,90,93,95,98,101,103,106,109,112,114,117,120,122,125,128,131,133,136,139,141,144,147,150,152,155,158,160,163,166 mul $0,19 mov $1,$0 add $1,10 div $1,7 add $1,2