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 |
|---|---|---|---|---|
Cubical/Categories/Equivalence/Base.agda | dan-iel-lee/cubical | 0 | 16759 | <filename>Cubical/Categories/Equivalence/Base.agda
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Categories.Equivalence.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Categories.Category
open import Cubical.Categories.Functor
open import Cubical.Categories.NaturalTransformation
open Precategory
open Functor
private
variable
ℓC ℓC' ℓD ℓD' : Level
-- Definition
record isEquivalence {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'}
(func : Functor C D) : Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) where
field
invFunc : Functor D C
η : 𝟙⟨ C ⟩ ≅ᶜ invFunc ∘F func
ε : func ∘F invFunc ≅ᶜ 𝟙⟨ D ⟩
record _≃ᶜ_ (C : Precategory ℓC ℓC') (D : Precategory ℓD ℓD') : Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) where
field
func : Functor C D
isEquiv : isEquivalence func
|
src/instructions.asm | JoshKing56/BB8-Breadboard-Computer | 0 | 102373 | LD A 8
LD B A
ADD C A B
SUB D A 0
SUB D D A |
bot/src/main/antlr4/co/edu/javeriana/bot/Bot.g4 | NicolasCamachoP/BOTInterpreter | 0 | 1083 | <gh_stars>0
grammar Bot;
@header {
import org.jpavlich.bot.*;
import co.edu.javeriana.bot.ast.*;
import java.util.HashMap;
import java.util.Map;
import co.edu.javeriana.bot.utils.*;
}
@parser::members {
private Bot bot;
public BotParser(TokenStream input, Bot bot) {
this(input);
this.bot = bot;
}
}
start:
{
List<ASTNode> body = new ArrayList<ASTNode>();
Map<String, Object> symbolTable = new HashMap<String, Object>();
Context contexto = new Context();
}
(sentencias{body.add($sentencias.node);})*
{
for(ASTNode n: body){
n.execute(contexto);
}
};
sentencias returns [ASTNode node]: (move_right{$node = $move_right.node;}
| move_up{$node = $move_up.node;}
| move_down{$node = $move_down.node;}
| move_left{$node = $move_left.node;}
| pick{$node = $pick.node;}
| drop{$node = $drop.node;}
| sentencia_if{$node = $sentencia_if.node;}
| sentencia_while{$node = $sentencia_while.node;}
| sentencia_impresion{$node = $sentencia_impresion.node;}
| var_decl{$node = $var_decl.node;}
| var_asig{$node = $var_asig.node;}
| sentencia_lectura{$node = $sentencia_lectura.node;}
| func_call{$node = $func_call.node;}
| define{$node = $define.node;})
SEMICOLON;
move_right returns [ASTNode node]: MRIGHT expression {$node = new MoveRight($expression.node, bot);};
move_up returns [ASTNode node]: MUP expression {$node = new MoveUp($expression.node, bot);};
move_down returns [ASTNode node]: MDOWN expression {$node = new MoveDown($expression.node, bot);};
move_left returns [ASTNode node]: MLEFT expression {$node = new MoveLeft($expression.node, bot);};
pick returns [ASTNode node]: PICK {$node = new Pick(bot);};
drop returns [ASTNode node]: DROP {$node = new Drop(bot);};
//TODO
var_decl returns [ASTNode node]: DECLARACION ID{
ASTNode valor = null;
} (ASIGNACION t1=expresion_logica{
valor = $t1.node;
}
)? {
$node = new VarDecl($ID.text, valor);
};
var_asig returns [ASTNode node]: ID ASIGNACION expresion_logica {$node = new VarAsig($ID.text, $expresion_logica.node);};
expresion_logica returns [ASTNode node]:t1=comparacion{$node = $t1.node;}
(AND t2=comparacion{$node = new And($node, $t2.node);}
| OR t2=comparacion{$node = new Or($node, $t2.node);})*;
comparacion returns [ASTNode node]:t1=expression{$node = $t1.node;} (EQ t2=expression{$node = new Igual($node, $t2.node);}
| MRIGHT t2=expression{$node = new Mayor($node, $t2.node);}
| MLEFT t2=expression{$node = new Menor($node, $t2.node);}
| GEQ t2=expression{$node = new MayorIgual($node, $t2.node);}
| LEQ t2=expression{$node = new MenorIgual($node, $t2.node);}
| NEQ t2=expression{$node = new Diff($node, $t2.node);})?;
expression returns [ASTNode node]:t1=factor{$node = $t1.node;} (SUMA t2=factor{$node = new Suma($node, $t2.node);}
|RESTA t2=factor{$node = new Resta($node, $t2.node);})*;
factor returns [ASTNode node]: t1=valor{$node = $t1.node;} (MULT t2=valor{$node = new Multiplicacion($node, $t2.node);}
|DIV t2=valor{$node = new Division($node, $t2.node);})*;
valor returns [ASTNode node]: NUMERO {$node = new Constante(Float.parseFloat($NUMERO.text));}
| STRING{$node = new Constante($STRING.text);}
| (PAR_OPEN t1=comparacion{$node = $t1.node;} PAR_CLOSE)
| (RESTA t2=valor{$node = new InversoAditivo($t2.node);})
| (NOT t3=comparacion{$node = new Not($t3.node);})
| BOOLEAN {$node =new Constante(($BOOLEAN.text).equals("@T"));}
| ID {$node = new VarRef($ID.text);}
| pick{$node = $pick.node;}
| drop{$node = $drop.node;}
| move_right{$node = $move_right.node;}
| move_left{$node = $move_left.node;}
| move_down{$node = $move_down.node;}
| move_up{$node = $move_up.node;};
//
define returns [ASTNode node]: DEFINE s1=ID {
List<String> parametros = new ArrayList<String>();
List<ASTNode> body = new ArrayList<ASTNode>();
String nombre = $s1.text;
} PAR_OPEN ((DECLARACION s2=ID{parametros.add($s2.text);}) (COMMA (DECLARACION s3=ID{parametros.add($s3.text);}))*)?
PAR_CLOSE THEN (sentencias{body.add($sentencias.node);})* END{
$node = new FunctionDecl(nombre, parametros, body);};
func_call returns [ASTNode node]: ID {
String nombre = $ID.text;
List<ASTNode> parametros = new ArrayList<ASTNode>();
} PAR_OPEN (s1=expression{parametros.add($s1.node);} (COMMA s2=expression{parametros.add($s2.node);})*)? PAR_CLOSE
{$node = new FunctionCall(nombre, parametros);};
sentencia_if returns [ASTNode node]: IF expresion_logica{
List<ASTNode> body = new ArrayList<ASTNode>();
List<ASTNode> elseBody = null;
} THEN (s1=sentencias{body.add($s1.node);})* (ELSE {
elseBody = new ArrayList<ASTNode>();
}(s2 = sentencias{ elseBody.add($s2.node);})*)? END{
$node = new If($expresion_logica.node, body, elseBody);
};
sentencia_while returns [ASTNode node]: WHILE expresion_logica {
List<ASTNode> body = new ArrayList<ASTNode>();
}THEN (s1=sentencias{body.add($s1.node);})* END{
$node = new While($expresion_logica.node, body);
};
sentencia_impresion returns [ASTNode node]: IMPRESION expresion_logica {$node = new Impresion($expresion_logica.node);};
sentencia_lectura returns [ASTNode node]: LECTURA ID{$node = new VarAsig($ID.text, new Lectura());};
// Los tokens se escriben a continuación de estos comentarios.
// Todo lo que esté en líneas previas a lo modificaremos cuando hayamos visto Análisis Sintáctico
//Palabras Clave
WS
:
[ \t\r\n]+ -> skip
;
MUP: '^';
MRIGHT: '>';
MDOWN: 'V';
MLEFT: '<';
PICK: 'P';
DROP: 'D';
DECLARACION: '\'';
ASIGNACION: '<-';
NUMERO: [0-9]+('.'[0-9]+)?;
BOOLEAN: '@T' | '@F';
STRING: '"'( '\\"' | . )*?'"';
IF: 'if';
ELSE: 'else';
THEN: '->';
END: 'end';
WHILE: 'while';
LECTURA: '?';
IMPRESION: '$';
SUMA: '+';
RESTA: '-';
MULT: '*';
DIV: '/';
AND: '&';
OR: '|';
NOT: '!';
GEQ:'>=';
LEQ:'<=';
EQ:'=';
NEQ:'<>';
DEFINE: 'define';
PAR_OPEN: '(';
PAR_CLOSE: ')';
SEMICOLON: ';';
COMMA: ',';
ID: [A-Za-z][a-zA-Z0-9_]*;
|
Categories/Category/Equivalence.agda | Taneb/agda-categories | 0 | 5189 | <reponame>Taneb/agda-categories
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Equivalence where
-- Strong equivalence of categories. Same as ordinary equivalence in Cat.
-- May not include everything we'd like to think of as equivalences, namely
-- the full, faithful functors that are essentially surjective on objects.
open import Level
open import Relation.Binary using (IsEquivalence; Setoid)
open import Categories.Adjoint.Equivalence
open import Categories.Category
import Categories.Morphism.Reasoning as MR
import Categories.Morphism.Properties as MP
open import Categories.Functor renaming (id to idF)
open import Categories.Functor.Properties
open import Categories.NaturalTransformation using (ntHelper; _∘ᵥ_; _∘ˡ_; _∘ʳ_)
open import Categories.NaturalTransformation.NaturalIsomorphism as NI
using (NaturalIsomorphism ; unitorˡ; unitorʳ; associator; _ⓘᵥ_; _ⓘˡ_; _ⓘʳ_)
renaming (sym to ≃-sym)
open import Categories.NaturalTransformation.NaturalIsomorphism.Properties
private
variable
o ℓ e : Level
C D E : Category o ℓ e
record WeakInverse (F : Functor C D) (G : Functor D C) : Set (levelOfTerm F ⊔ levelOfTerm G) where
field
F∘G≈id : NaturalIsomorphism (F ∘F G) idF
G∘F≈id : NaturalIsomorphism (G ∘F F) idF
module F∘G≈id = NaturalIsomorphism F∘G≈id
module G∘F≈id = NaturalIsomorphism G∘F≈id
private
module C = Category C
module D = Category D
module F = Functor F
module G = Functor G
-- adjoint equivalence
F⊣G : ⊣Equivalence F G
F⊣G = record
{ unit = ≃-sym G∘F≈id
; counit =
let open D
open HomReasoning
open MR D
open MP D
in record
{ F⇒G = ntHelper record
{ η = λ X → F∘G≈id.⇒.η X ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ X)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))
; commute = λ {X Y} f → begin
(F∘G≈id.⇒.η Y ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ Y)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ Y))) ∘ F.F₁ (G.F₁ f)
≈⟨ pull-last (F∘G≈id.⇐.commute (F.F₁ (G.F₁ f))) ⟩
F∘G≈id.⇒.η Y ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ Y)) ∘ (F.F₁ (G.F₁ (F.F₁ (G.F₁ f))) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X)))
≈˘⟨ refl⟩∘⟨ pushˡ F.homomorphism ⟩
F∘G≈id.⇒.η Y ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ Y) C.∘ G.F₁ (F.F₁ (G.F₁ f))) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))
≈⟨ refl ⟩∘⟨ F.F-resp-≈ (G∘F≈id.⇒.commute (G.F₁ f)) ⟩∘⟨ refl ⟩
F∘G≈id.⇒.η Y ∘ F.F₁ (G.F₁ f C.∘ G∘F≈id.⇒.η (G.F₀ X)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))
≈⟨ refl ⟩∘⟨ F.homomorphism ⟩∘⟨ refl ⟩
F∘G≈id.⇒.η Y ∘ (F.F₁ (G.F₁ f) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ X))) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))
≈⟨ center⁻¹ (F∘G≈id.⇒.commute f) refl ⟩
(f ∘ F∘G≈id.⇒.η X) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ X)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))
≈⟨ assoc ⟩
f ∘ F∘G≈id.⇒.η X ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ X)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))
∎
}
; F⇐G = ntHelper record
{ η = λ X → (F∘G≈id.⇒.η (F.F₀ (G.F₀ X)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ X))) ∘ F∘G≈id.⇐.η X
; commute = λ {X Y} f → begin
((F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ Y))) ∘ F∘G≈id.⇐.η Y) ∘ f
≈⟨ pullʳ (F∘G≈id.⇐.commute f) ⟩
(F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ Y))) ∘ F.F₁ (G.F₁ f) ∘ F∘G≈id.⇐.η X
≈⟨ center (⟺ F.homomorphism) ⟩
F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ Y) C.∘ G.F₁ f) ∘ F∘G≈id.⇐.η X
≈⟨ refl ⟩∘⟨ F.F-resp-≈ (G∘F≈id.⇐.commute (G.F₁ f)) ⟩∘⟨ refl ⟩
F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ F.F₁ (G.F₁ (F.F₁ (G.F₁ f)) C.∘ G∘F≈id.⇐.η (G.F₀ X)) ∘ F∘G≈id.⇐.η X
≈⟨ refl ⟩∘⟨ F.homomorphism ⟩∘⟨ refl ⟩
F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ (F.F₁ (G.F₁ (F.F₁ (G.F₁ f))) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ X))) ∘ F∘G≈id.⇐.η X
≈⟨ center⁻¹ (F∘G≈id.⇒.commute _) refl ⟩
(F.F₁ (G.F₁ f) ∘ F∘G≈id.⇒.η (F.F₀ (G.F₀ X))) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ X)) ∘ F∘G≈id.⇐.η X
≈⟨ center refl ⟩
F.F₁ (G.F₁ f) ∘ (F∘G≈id.⇒.η (F.F₀ (G.F₀ X)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ X))) ∘ F∘G≈id.⇐.η X
∎
}
; iso = λ X → Iso-∘ (Iso-∘ (Iso-swap (F∘G≈id.iso _)) ([ F ]-resp-Iso (G∘F≈id.iso _)))
(F∘G≈id.iso X)
}
; zig = λ {A} →
let open D
open HomReasoning
open MR D
in begin
(F∘G≈id.⇒.η (F.F₀ A) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ (F.F₀ A))) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ (F.F₀ A))))
∘ F.F₁ (G∘F≈id.⇐.η A)
≈⟨ pull-last (F∘G≈id.⇐.commute (F.F₁ (G∘F≈id.⇐.η A))) ⟩
F∘G≈id.⇒.η (F.F₀ A) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ (F.F₀ A))) ∘
F.F₁ (G.F₁ (F.F₁ (G∘F≈id.⇐.η A))) ∘ F∘G≈id.⇐.η (F.F₀ A)
≈˘⟨ refl⟩∘⟨ pushˡ F.homomorphism ⟩
F∘G≈id.⇒.η (F.F₀ A) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ (F.F₀ A)) C.∘ G.F₁ (F.F₁ (G∘F≈id.⇐.η A))) ∘ F∘G≈id.⇐.η (F.F₀ A)
≈⟨ refl ⟩∘⟨ F.F-resp-≈ (G∘F≈id.⇒.commute (G∘F≈id.⇐.η A)) ⟩∘⟨ refl ⟩
F∘G≈id.⇒.η (F.F₀ A) ∘ F.F₁ (G∘F≈id.⇐.η A C.∘ G∘F≈id.⇒.η A) ∘ F∘G≈id.⇐.η (F.F₀ A)
≈⟨ refl ⟩∘⟨ elimˡ ((F.F-resp-≈ (G∘F≈id.iso.isoˡ _)) ○ F.identity) ⟩
F∘G≈id.⇒.η (F.F₀ A) ∘ F∘G≈id.⇐.η (F.F₀ A)
≈⟨ F∘G≈id.iso.isoʳ _ ⟩
id
∎
}
module F⊣G = ⊣Equivalence F⊣G
record StrongEquivalence {o ℓ e o′ ℓ′ e′} (C : Category o ℓ e) (D : Category o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
field
F : Functor C D
G : Functor D C
weak-inverse : WeakInverse F G
open WeakInverse weak-inverse public
refl : StrongEquivalence C C
refl = record
{ F = idF
; G = idF
; weak-inverse = record
{ F∘G≈id = unitorˡ
; G∘F≈id = unitorˡ
}
}
sym : StrongEquivalence C D → StrongEquivalence D C
sym e = record
{ F = G
; G = F
; weak-inverse = record
{ F∘G≈id = G∘F≈id
; G∘F≈id = F∘G≈id
}
}
where open StrongEquivalence e
trans : StrongEquivalence C D → StrongEquivalence D E → StrongEquivalence C E
trans {C = C} {D = D} {E = E} e e′ = record
{ F = e′.F ∘F e.F
; G = e.G ∘F e′.G
; weak-inverse = record
{ F∘G≈id = let module S = Setoid (NI.Functor-NI-setoid E E)
in S.trans (S.trans (associator (e.G ∘F e′.G) e.F e′.F)
(e′.F ⓘˡ (unitorˡ ⓘᵥ (e.F∘G≈id ⓘʳ e′.G) ⓘᵥ NI.sym (associator e′.G e.G e.F))))
e′.F∘G≈id
; G∘F≈id = let module S = Setoid (NI.Functor-NI-setoid C C)
in S.trans (S.trans (associator (e′.F ∘F e.F) e′.G e.G)
(e.G ⓘˡ (unitorˡ ⓘᵥ (e′.G∘F≈id ⓘʳ e.F) ⓘᵥ NI.sym (associator e.F e′.F e′.G))))
e.G∘F≈id
}
}
where module e = StrongEquivalence e
module e′ = StrongEquivalence e′
isEquivalence : ∀ {o ℓ e} → IsEquivalence (StrongEquivalence {o} {ℓ} {e})
isEquivalence = record
{ refl = refl
; sym = sym
; trans = trans
}
setoid : ∀ o ℓ e → Setoid _ _
setoid o ℓ e = record
{ Carrier = Category o ℓ e
; _≈_ = StrongEquivalence
; isEquivalence = isEquivalence
}
|
macros/scripts/maps.asm | opiter09/ASM-Machina | 1 | 9460 | def_objects: MACRO
REDEF _NUM_OBJECTS EQUS "_NUM_OBJECTS_\@"
db {_NUM_OBJECTS}
{_NUM_OBJECTS} = 0
ENDM
;\1 sprite id
;\2 x position
;\3 y position
;\4 movement (WALK/STAY)
;\5 range or direction
;\6 text id
;\7 items only: item id
;\7 trainers only: trainer class/pokemon id
;\8 trainers only: trainer number/pokemon level
object: MACRO
db \1
db \3 + 4
db \2 + 4
db \4
db \5
IF _NARG > 7
db TRAINER | \6
db \7
db \8
ELIF _NARG > 6
db ITEM | \6
db \7
ELSE
db \6
ENDC
{_NUM_OBJECTS} = {_NUM_OBJECTS} + 1
ENDM
def_warps: MACRO
REDEF _NUM_WARPS EQUS "_NUM_WARPS_\@"
db {_NUM_WARPS}
{_NUM_WARPS} = 0
ENDM
;\1 x position
;\2 y position
;\3 destination warp id
;\4 destination map (-1 = wLastMap)
warp: MACRO
db \2, \1, \3, \4
_WARP_{d:{_NUM_WARPS}}_X = \1
_WARP_{d:{_NUM_WARPS}}_Y = \2
{_NUM_WARPS} = {_NUM_WARPS} + 1
ENDM
def_signs: MACRO
REDEF _NUM_SIGNS EQUS "_NUM_SIGNS_\@"
db {_NUM_SIGNS}
{_NUM_SIGNS} = 0
ENDM
;\1 x position
;\2 y position
;\3 sign id
sign: MACRO
db \2, \1, \3
{_NUM_SIGNS} = {_NUM_SIGNS} + 1
ENDM
;\1 source map
def_warps_to: MACRO
FOR n, _NUM_WARPS
warp_to _WARP_{d:n}_X, _WARP_{d:n}_Y, \1_WIDTH
ENDR
ENDM
;\1 x position
;\2 y position
;\3 map width
warp_to: MACRO
event_displacement \3, \1, \2
ENDM
;\1 first bit offset / first object id
def_trainers: MACRO
IF _NARG == 1
CURRENT_TRAINER_BIT = \1
ELSE
CURRENT_TRAINER_BIT = 1
ENDC
ENDM
;\1 event flag
;\2 view range
;\3 TextBeforeBattle
;\4 TextAfterBattle
;\5 TextEndBattle
trainer: MACRO
_ev_bit = \1 % 8
_cur_bit = CURRENT_TRAINER_BIT % 8
ASSERT _ev_bit == _cur_bit, \
"Expected \1 to be bit {d:_cur_bit}, got {d:_ev_bit}"
db CURRENT_TRAINER_BIT
db \2 << 4
dw wEventFlags + (\1 - CURRENT_TRAINER_BIT) / 8
dw \3, \5, \4, \4
CURRENT_TRAINER_BIT = CURRENT_TRAINER_BIT + 1
ENDM
;\1 x position
;\2 y position
;\3 movement data
map_coord_movement: MACRO
dbmapcoord \1, \2
dw \3
ENDM
;\1 map name
;\2 map id
;\3 tileset
;\4 connections: combo of NORTH, SOUTH, WEST, and/or EAST, or 0 for none
map_header: MACRO
CURRENT_MAP_WIDTH = \2_WIDTH
CURRENT_MAP_HEIGHT = \2_HEIGHT
CURRENT_MAP_OBJECT EQUS "\1_Object"
\1_h::
db \3
db CURRENT_MAP_HEIGHT, CURRENT_MAP_WIDTH
dw \1_Blocks
dw \1_TextPointers
dw \1_Script
db \4
ENDM
; Comes after map_header and connection macros
end_map_header: MACRO
dw {CURRENT_MAP_OBJECT}
PURGE CURRENT_MAP_WIDTH, CURRENT_MAP_HEIGHT, CURRENT_MAP_OBJECT
ENDM
; Connections go in order: north, south, west, east
;\1 direction
;\2 map name
;\3 map id
;\4 offset of the target map relative to the current map
; (x offset for east/west, y offset for north/south)
connection: MACRO
; Calculate tile offsets for source (current) and target maps
_src = 0
_tgt = (\4) + 3
IF _tgt < 2
_src = -_tgt
_tgt = 0
ENDC
IF !STRCMP("\1", "north")
_blk = \3_WIDTH * (\3_HEIGHT - 3) + _src
_map = _tgt
_win = (\3_WIDTH + 6) * \3_HEIGHT + 1
_y = \3_HEIGHT * 2 - 1
_x = (\4) * -2
_len = CURRENT_MAP_WIDTH + 3 - (\4)
IF _len > \3_WIDTH
_len = \3_WIDTH
ENDC
ELIF !STRCMP("\1", "south")
_blk = _src
_map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt
_win = \3_WIDTH + 7
_y = 0
_x = (\4) * -2
_len = CURRENT_MAP_WIDTH + 3 - (\4)
IF _len > \3_WIDTH
_len = \3_WIDTH
ENDC
ELIF !STRCMP("\1", "west")
_blk = (\3_WIDTH * _src) + \3_WIDTH - 3
_map = (CURRENT_MAP_WIDTH + 6) * _tgt
_win = (\3_WIDTH + 6) * 2 - 6
_y = (\4) * -2
_x = \3_WIDTH * 2 - 1
_len = CURRENT_MAP_HEIGHT + 3 - (\4)
IF _len > \3_HEIGHT
_len = \3_HEIGHT
ENDC
ELIF !STRCMP("\1", "east")
_blk = (\3_WIDTH * _src)
_map = (CURRENT_MAP_WIDTH + 6) * _tgt + CURRENT_MAP_WIDTH + 3
_win = \3_WIDTH + 7
_y = (\4) * -2
_x = 0
_len = CURRENT_MAP_HEIGHT + 3 - (\4)
IF _len > \3_HEIGHT
_len = \3_HEIGHT
ENDC
ELSE
fail "Invalid direction for 'connection'."
ENDC
db \3
dw \2_Blocks + _blk
dw wOverworldMap + _map
db _len - _src
db \3_WIDTH
db _y, _x
dw wOverworldMap + _win
ENDM
|
programs/oeis/208/A208881.asm | neoneye/loda | 22 | 10399 | ; A208881: Number of words either empty or beginning with the first letter of the ternary alphabet, where each letter of the alphabet occurs n times.
; 1,2,30,560,11550,252252,5717712,133024320,3155170590,75957810500,1850332263780,45508998487680,1128243920840400,28159366024288800,706857555303576000,17831659928458210560,451781821468671694110,11489952898943726476500,293206575828601020085500,7504788810682197854820000,192610404826158607943955300,4955459530969604457442441800,127777138319216247167110896000,3301432753397065531720362432000,85458962418663623399219798370000,2215916711930980289292409683814752,57548274844172026566298142616940512
mov $1,$0
sub $2,$0
sub $0,$2
bin $2,$0
bin $0,$1
mul $0,$2
|
4-high/gel/applet/demo/sprite/chains_2d/launch_chains_2d.adb | charlie5/lace | 20 | 29874 | <reponame>charlie5/lace<filename>4-high/gel/applet/demo/sprite/chains_2d/launch_chains_2d.adb
with
gel.Window.lumen,
gel.Applet.gui_world,
gel.Forge,
gel.Sprite,
gel.Joint,
Physics,
openGL.Palette;
pragma unreferenced (gel.Window.lumen);
procedure launch_Chains_2d
--
-- Creates a chain of balls in a 2D space.
--
is
use gel.Forge,
gel.Applet,
gel.Math,
opengl.Palette;
the_Applet : gel.Applet.gui_World.view := new_gui_Applet ("Chains 2D",
1536, 864,
space_Kind => physics.Box2D);
the_Ground : constant gel.Sprite.view := new_rectangle_Sprite (the_Applet.gui_World,
Mass => 0.0,
Width => 100.0,
Height => 1.0,
Color => apple_Green);
begin
the_Applet.gui_World .Gravity_is ((0.0, -10.0, 0.0));
the_Applet.gui_Camera.Site_is ((0.0, -30.0, 100.0));
the_Applet.Renderer .Background_is (Grey);
the_Applet.enable_simple_Dolly (in_World => gui_World.gui_world_Id);
the_Ground.Site_is ((0.0, -40.0, 0.0));
the_Applet.gui_World.add (the_Ground, and_Children => False);
-- Add joints.
--
declare
ball_Count : constant := 39;
the_root_Ball : constant gel.Sprite.view := new_circle_Sprite (the_Applet.gui_World, Mass => 0.0);
the_Balls : constant gel.Sprite.views := (1 .. ball_Count => new_circle_Sprite (the_Applet.gui_World, Mass => 1.0));
Parent : gel.Sprite.view := the_root_Ball;
new_Joint : gel.Joint .view;
begin
for i in the_Balls'Range
loop
the_Balls (i).Site_is ((Real (-i), 0.0, 0.0));
Parent.attach_via_Hinge (the_Child => the_Balls (i),
pivot_Axis => (0.0, 0.0, 1.0),
low_Limit => to_Radians (-180.0),
high_Limit => to_Radians ( 180.0),
new_joint => new_Joint);
Parent := the_Balls (i);
end loop;
the_Applet.gui_World.add (the_root_Ball, and_Children => True);
end;
while the_Applet.is_open
loop
the_Applet.freshen; -- Handle any new events, evolve physics and update the screen.
end loop;
gel.Applet.gui_world.free (the_Applet);
end launch_Chains_2d;
|
oeis/203/A203162.asm | neoneye/loda-programs | 11 | 296 | ; A203162: (n-1)-st elementary symmetric function of the first n terms of (1,2,3,1,2,3,1,2,3,...).
; Submitted by <NAME>
; 1,3,11,17,40,132,168,372,1188,1404,3024,9504,10800,22896,71280,79056,165888,513216,559872,1166400,3592512,3872448,8024832,24634368,26313984,54307584,166281984,176359680,362797056,1108546560,1169012736,2398491648,7316407296,7679204352,15721205760,47889211392,50065993728,102308769792,311279874048,324340568064,661741830144,2011346878464,2089711042560,4257786249216,12930087075840,13400272060416,27270729105408,82752557285376,85573667192832,173968444293120,527547552694272,544474212139008
add $0,1
mov $1,1
lpb $0
sub $0,1
add $2,1
mul $3,$2
add $3,$1
mul $1,$2
mod $2,3
lpe
mov $0,$3
|
src/common/trendy_terminal-completions.ads | pyjarrett/archaic_terminal | 3 | 11552 | <reponame>pyjarrett/archaic_terminal<gh_stars>1-10
-------------------------------------------------------------------------------
-- Copyright 2021, The Trendy Terminal Developers (see AUTHORS file)
-- 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 Trendy_Terminal.Lines.Line_Vectors;
package Trendy_Terminal.Completions is
-- A group of possible completions that need to be searched.
type Completion_Set is private;
procedure Clear (Self : in out Completion_Set);
function Is_Empty (Self : Completion_Set) return Boolean;
-- Sets the data used by the completion set.
procedure Fill
(Self : in out Completion_Set;
Lines : Trendy_Terminal.Lines.Line_Vectors.Vector);
procedure Set_Index (Self : in out Completion_Set; Index : Integer)
with Pre => not Is_Empty (Self);
procedure Move_Forward (Self : in out Completion_Set)
with Pre => not Is_Empty (Self);
procedure Move_Backward (Self : in out Completion_Set)
with Pre => not Is_Empty (Self);
function Get_Current (Self : in out Completion_Set) return String
with Pre => not Is_Empty (Self);
function Get_Index (Self : in out Completion_Set) return Integer
with Pre => not Is_Empty (Self);
function Length (Self : Completion_Set) return Integer;
private
type Completion_Set is record
Lines : Trendy_Terminal.Lines.Line_Vectors.Vector;
Index : Integer;
end record;
end Trendy_Terminal.Completions;
|
tests/utils-test_data-tests.adb | thindil/steamsky | 80 | 3080 | <filename>tests/utils-test_data-tests.adb
-- This package has been generated automatically by GNATtest.
-- You are allowed to add your code to the bodies of test routines.
-- Such changes will be kept during further regeneration of this file.
-- All code placed outside of test routine bodies will be lost. The
-- code intended to set up and tear down the test environment should be
-- placed into Utils.Test_Data.
with AUnit.Assertions; use AUnit.Assertions;
with System.Assertions;
-- begin read only
-- id:2.2/00/
--
-- This section can be used to add with clauses if necessary.
--
-- end read only
-- begin read only
-- end read only
package body Utils.Test_Data.Tests is
-- begin read only
-- id:2.2/01/
--
-- This section can be used to add global variables and other elements.
--
-- end read only
-- begin read only
-- end read only
-- begin read only
function Wrap_Test_Get_Random_254206_4c55ca
(Min, Max: Integer) return Integer is
begin
begin
pragma Assert(Min <= Max);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(utils.ads:0):Test_GetRandom test requirement violated");
end;
declare
Test_Get_Random_254206_4c55ca_Result: constant Integer :=
GNATtest_Generated.GNATtest_Standard.Utils.Get_Random(Min, Max);
begin
begin
pragma Assert(Test_Get_Random_254206_4c55ca_Result in Min .. Max);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(utils.ads:0:):Test_GetRandom test commitment violated");
end;
return Test_Get_Random_254206_4c55ca_Result;
end;
end Wrap_Test_Get_Random_254206_4c55ca;
-- end read only
-- begin read only
procedure Test_Get_Random_test_getrandom(Gnattest_T: in out Test);
procedure Test_Get_Random_254206_4c55ca(Gnattest_T: in out Test) renames
Test_Get_Random_test_getrandom;
-- id:2.2/2542065c792cecb1/Get_Random/1/0/test_getrandom/
procedure Test_Get_Random_test_getrandom(Gnattest_T: in out Test) is
function Get_Random(Min, Max: Integer) return Integer renames
Wrap_Test_Get_Random_254206_4c55ca;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
for I in 1 .. 5 loop
Assert(Get_Random(1, 5) in 1 .. 5, "Wrong random number returned.");
end loop;
Assert(Get_Random(5, 5) = 5, "Wrong random number from 5 returned.");
-- begin read only
end Test_Get_Random_test_getrandom;
-- end read only
-- begin read only
function Wrap_Test_Days_Difference_3eb9cd_fd50f2
(Date_To_Compare: Date_Record) return Integer is
begin
declare
Test_Days_Difference_3eb9cd_fd50f2_Result: constant Integer :=
GNATtest_Generated.GNATtest_Standard.Utils.Days_Difference
(Date_To_Compare);
begin
return Test_Days_Difference_3eb9cd_fd50f2_Result;
end;
end Wrap_Test_Days_Difference_3eb9cd_fd50f2;
-- end read only
-- begin read only
procedure Test_Days_Difference_test_daysdifference(Gnattest_T: in out Test);
procedure Test_Days_Difference_3eb9cd_fd50f2
(Gnattest_T: in out Test) renames
Test_Days_Difference_test_daysdifference;
-- id:2.2/3eb9cd623ef6a20f/Days_Difference/1/0/test_daysdifference/
procedure Test_Days_Difference_test_daysdifference
(Gnattest_T: in out Test) is
function Days_Difference
(Date_To_Compare: Date_Record) return Integer renames
Wrap_Test_Days_Difference_3eb9cd_fd50f2;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
Game_Date := (1_600, 1, 2, 0, 0);
Assert
(Days_Difference((1_600, 1, 1, 0, 0)) = 1,
"Invalid count of days difference between game dates.");
-- begin read only
end Test_Days_Difference_test_daysdifference;
-- end read only
-- begin read only
function Wrap_Test_Generate_Robotic_Name_eb65d6_cad966
return Unbounded_String is
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(utils.ads:0):Test_GenerateRoboticName test requirement violated");
end;
declare
Test_Generate_Robotic_Name_eb65d6_cad966_Result: constant Unbounded_String :=
GNATtest_Generated.GNATtest_Standard.Utils.Generate_Robotic_Name;
begin
begin
pragma Assert
(Length
(Source => Test_Generate_Robotic_Name_eb65d6_cad966_Result) >
0);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(utils.ads:0:):Test_GenerateRoboticName test commitment violated");
end;
return Test_Generate_Robotic_Name_eb65d6_cad966_Result;
end;
end Wrap_Test_Generate_Robotic_Name_eb65d6_cad966;
-- end read only
-- begin read only
procedure Test_Generate_Robotic_Name_test_generateroboticname
(Gnattest_T: in out Test);
procedure Test_Generate_Robotic_Name_eb65d6_cad966
(Gnattest_T: in out Test) renames
Test_Generate_Robotic_Name_test_generateroboticname;
-- id:2.2/eb65d6968733e831/Generate_Robotic_Name/1/0/test_generateroboticname/
procedure Test_Generate_Robotic_Name_test_generateroboticname
(Gnattest_T: in out Test) is
function Generate_Robotic_Name return Unbounded_String renames
Wrap_Test_Generate_Robotic_Name_eb65d6_cad966;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
Assert
(Length(Generate_Robotic_Name) > 0,
"Failed to generate robotic name.");
-- begin read only
end Test_Generate_Robotic_Name_test_generateroboticname;
-- end read only
-- begin read only
-- id:2.2/02/
--
-- This section can be used to add elaboration code for the global state.
--
begin
-- end read only
null;
-- begin read only
-- end read only
end Utils.Test_Data.Tests;
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c35502n.ada | best08618/asylo | 7 | 13957 | -- C35502N.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT 'POS' AND 'VAL' YIELD THE CORRECT RESULTS WHEN
-- THE PREFIX IS A FORMAL DISCRETE TYPE WHOSE ACTUAL ARGUMENT IS
-- AN ENUMERATION TYPE, OTHER THAN A BOOLEAN OR A CHARACTER TYPE,
-- WITH AN ENUMERATION REPRESENTATION CLAUSE.
-- HISTORY:
-- RJW 05/27/86
-- DWC 07/22/87 ADDED THE PARAMETER 'N' TO FUNCTION F.
-- PWB 05/11/89 CHANGED EXTENSION FROM '.DEP' TO '.ADA'.
WITH REPORT; USE REPORT;
PROCEDURE C35502N IS
TYPE ENUM IS (A, BC, ABC, A_B_C, ABCD);
FOR ENUM USE (A => 1, BC => 4, ABC => 5, A_B_C => 6,
ABCD => 8);
SUBTYPE SUBENUM IS ENUM RANGE A .. BC;
TYPE NEWENUM IS NEW ENUM;
SUBTYPE SUBNEW IS NEWENUM RANGE A .. BC;
BEGIN
TEST ("C35502N", "CHECK THAT 'POS' AND 'VAL' YIELD THE " &
"CORRECT RESULTS WHEN THE PREFIX IS A " &
"FORMAL DISCRETE TYPE WHOSE ACTUAL ARGUMENT " &
"IS AN ENUMERATION TYPE, OTHER THAN A " &
"CHARACTER OR A BOOLEAN TYPE, WITH AN " &
"ENUMERATION REPRESENTATION CLAUSE" );
DECLARE
GENERIC
TYPE E IS (<>);
STR : STRING;
PROCEDURE P;
PROCEDURE P IS
SUBTYPE SE IS E RANGE E'VAL(0) .. E'VAL(1);
POSITION : INTEGER;
BEGIN
POSITION := 0;
FOR E1 IN E LOOP
IF SE'POS (E1) /= POSITION THEN
FAILED ( "INCORRECT " & STR & "'POS (" &
E'IMAGE (E1) & ")" );
END IF;
IF SE'VAL (POSITION) /= E1 THEN
FAILED ( "INCORRECT " & STR & "'VAL (" &
INTEGER'IMAGE (POSITION) &
")" );
END IF;
POSITION := POSITION + 1;
END LOOP;
BEGIN
IF E'VAL (-1) = E'VAL (1) THEN
FAILED ( "NO EXCEPTION RAISED FOR " &
STR & "'VAL (-1) - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED FOR " &
STR & "'VAL (-1) - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED FOR " &
STR & "'VAL (-1)" );
END;
BEGIN
IF E'VAL (5) = E'VAL (4) THEN
FAILED ( "NO EXCEPTION RAISED FOR " &
STR & "'VAL (5) - 1" );
ELSE
FAILED ( "NO EXCEPTION RAISED FOR " &
STR & "'VAL (5) - 2" );
END IF;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED FOR " &
STR & "'VAL (5)" );
END;
END P;
PROCEDURE PE IS NEW P ( ENUM, "ENUM" );
PROCEDURE PN IS NEW P ( NEWENUM, "NEWENUM" );
BEGIN
PE;
PN;
END;
DECLARE
FUNCTION A_B_C RETURN ENUM IS
BEGIN
RETURN ENUM'VAL (IDENT_INT (0));
END A_B_C;
GENERIC
TYPE E IS (<>);
FUNCTION F (N : INTEGER;
E1 : E) RETURN BOOLEAN;
FUNCTION F (N : INTEGER;
E1 : E) RETURN BOOLEAN IS
BEGIN
RETURN E'VAL (N) = E1;
END F;
FUNCTION FE IS NEW F (ENUM);
BEGIN
IF NOT FE (0, A_B_C) THEN
FAILED ( "INCORRECT VAL FOR A_B_C WHEN HIDDEN " &
"BY A FUNCTION" );
END IF;
IF NOT FE (3, C35502N.A_B_C) THEN
FAILED ( "INCORRECT VAL FOR C35502N.A_B_C" );
END IF;
END;
RESULT;
END C35502N;
|
test/interaction/Issue4399.agda | cruhland/agda | 1,989 | 5581 | -- Andreas, 2020-01-28, issue #4399, reported by <NAME>
postulate
A : Set
data T : Set where
tt : T
f : {x : A} {{_ : T}} → A
f {{ p }} = {!p!}
-- Problem was:
-- Splitting on p produced pattern {{_ = tt}}
-- which was interpreted as cubical partial split.
-- Expected:
-- Splitting on p should produce an unnamed pattern.
|
test/asset/agda-stdlib-1.0/Data/List/Membership/DecPropositional.agda | omega12345/agda-mode | 5 | 8502 | <gh_stars>1-10
------------------------------------------------------------------------
-- The Agda standard library
--
-- Decidable propositional membership over lists
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary using (Decidable)
open import Relation.Binary.PropositionalEquality using (_≡_; decSetoid)
module Data.List.Membership.DecPropositional
{a} {A : Set a} (_≟_ : Decidable (_≡_ {A = A})) where
------------------------------------------------------------------------
-- Re-export contents of propositional membership
open import Data.List.Membership.Propositional {A = A} public
open import Data.List.Membership.DecSetoid (decSetoid _≟_) public
using (_∈?_)
|
Cubical/HITs/PropositionalTruncation/Monad.agda | dan-iel-lee/cubical | 0 | 13898 | <reponame>dan-iel-lee/cubical
{-# OPTIONS --cubical --safe --no-import-sorts #-}
{-
Implements the monadic interface of propositional truncation, for reasoning in do-syntax.
-}
module Cubical.HITs.PropositionalTruncation.Monad where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Structure
open import Cubical.Functions.Logic
open import Cubical.HITs.PropositionalTruncation
private
variable
ℓ : Level
P Q : Type ℓ
infix 1 proof_by_
proof_by_ : (P : hProp ℓ) → ∥ ⟨ P ⟩ ∥ → ⟨ P ⟩
proof P by p = rec (isProp⟨⟩ P) (λ p → p) p
return : P → ∥ P ∥
return p = ∣ p ∣
exact_ : ∥ P ∥ → ∥ P ∥
exact p = p
_>>=_ : ∥ P ∥ → (P → ∥ Q ∥) → ∥ Q ∥
p >>= f = rec propTruncIsProp f p
_>>_ : ∥ P ∥ → ∥ Q ∥ → ∥ Q ∥
_ >> q = q
|
benchmark/benchmark_containers.ads | skill-lang/skillAdaTestSuite | 1 | 15811 | with Ada.Containers.Indefinite_Vectors;
with Ada.Containers.Vectors;
package Benchmark_Containers is
subtype Long is Long_Integer;
procedure Test_Indefinite (N : Long; File_Name : String);
procedure Test_Non_Indefinite (N : Long; File_Name : String);
end Benchmark_Containers;
|
src/fltk-widgets-boxes.ads | micahwelf/FLTK-Ada | 1 | 6823 |
package FLTK.Widgets.Boxes is
type Box is new Widget with private;
type Box_Reference (Data : not null access Box'Class) is limited null record
with Implicit_Dereference => Data;
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Box;
end Forge;
procedure Draw
(This : in out Box);
function Handle
(This : in out Box;
Event : in Event_Kind)
return Event_Outcome;
private
type Box is new Widget with null record;
overriding procedure Finalize
(This : in out Box);
pragma Inline (Draw);
pragma Inline (Handle);
end FLTK.Widgets.Boxes;
|
main/Util/Finite.agda | awswan/nielsenschreier-hott | 0 | 12905 | {-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Coproduct
open import lib.types.Sigma
open import lib.types.Pi
open import lib.types.Fin
open import lib.types.Nat
open import lib.types.Empty
open import lib.NType2
open import lib.Equivalence2
open import Util.Misc
open import Util.Coproducts
{- Some useful lemmas about working with finite sets. E.g. An injection from a finite set
to itself is an equivalence, an injection from a finite set to a large finite set has
at least one element not in its image.
-}
module Util.Finite where
ℕ=-to-Fin= : {n : ℕ} {x y : Fin n} → (fst x == fst y) → x == y
ℕ=-to-Fin= p = pair= p prop-has-all-paths-↓
finite-lpo : {i : ULevel} {n : ℕ} (P : Fin n → Type i) (dec : (x : Fin n) → Dec (P x)) →
(Σ (Fin n) P ⊔ ((x : Fin n) → ¬ (P x)))
finite-lpo {n = 0} P dec = inr (λ x _ → –> Fin-equiv-Empty x)
finite-lpo {i} {n = S n} P dec = ⊔-fmap (–> el) (–> er) lemma
where
P' : Fin n ⊔ ⊤ → Type i
P' z = P (<– Fin-equiv-Coprod z)
el : Σ (Fin n ⊔ ⊤) P' ≃ Σ (Fin (S n)) P
el = Σ-emap-l P (Fin-equiv-Coprod ⁻¹)
er : ((x : Fin n ⊔ ⊤) → ¬ (P' x)) ≃ ((x : Fin (S n)) → ¬ (P x))
er = Π-emap-l (¬ ∘ P) (Fin-equiv-Coprod ⁻¹)
lemma : Σ (Fin n ⊔ ⊤) P' ⊔ ((x : Fin n ⊔ ⊤) → ¬ (P' x))
lemma = ⊔-rec (λ np → inl ((inl (fst np)) , (snd np)))
(λ f → ⊔-rec (λ p → inl ((inr unit) , p)) (λ np → inr (λ { (inl k) → f k ; (inr _) → np})) (dec (n , ltS))) (finite-lpo {n = n} (P' ∘ inl) λ x → dec (<– Fin-equiv-Coprod (inl x)))
fin-img-dec : {i : ULevel} {A : Type i} (dec : has-dec-eq A) {n : ℕ} (inc : Fin n → A) → (a : A) → ((hfiber inc a) ⊔ ¬ (hfiber inc a))
fin-img-dec dec inc a = ⊔-rec (λ np → inl np) (λ f → inr (λ np → f (fst np) (snd np))) (finite-lpo (λ k → inc k == a) λ k → dec (inc k) a)
Fin-eq : {n : ℕ} {x y : Fin n} → (fst x == fst y) → x == y
Fin-eq p = pair= p prop-has-all-paths-↓
<-or-≥ : (n m : ℕ) → ((n < m) ⊔ (m ≤ n))
<-or-≥ n m = ⊔-rec (λ p → inr (inl (! p))) (⊔-rec inl (λ l → inr (inr l))) (ℕ-trichotomy n m)
≤-or-> : (n m : ℕ) → ((n ≤ m) ⊔ (m < n))
≤-or-> m n = ⊔-rec (inl ∘ inl) (⊔-fmap inr (idf _)) (ℕ-trichotomy m n)
<-≤-trans : {l m n : ℕ} → (l < m) → (m ≤ n) → (l < n)
<-≤-trans p (inl q) = transport _ q p
<-≤-trans p (inr q) = <-trans p q
≤-<-trans : {l m n : ℕ} → (l ≤ m) → (m < n) → (l < n)
≤-<-trans (inl p) q = transport _ (! p) q
≤-<-trans (inr p) q = <-trans p q
<S≠-to-< : {a b : ℕ} → (a < S b) → (a ≠ b) → (a < b)
<S≠-to-< ltS ne = ⊥-elim (ne idp)
<S≠-to-< (ltSR lt) ne = lt
module _ {n : ℕ} (k : Fin n) where
private
degeneracy-aux : (x : Fin (S n)) → ((fst x ≤ fst k) ⊔ (fst k < fst x)) → Fin n
degeneracy-aux x (inl z) = (fst x) , ≤-<-trans z (snd k)
degeneracy-aux (.(S (fst k)) , snd) (inr ltS) = k
degeneracy-aux (.(S _) , snd) (inr (ltSR z)) = _ , (<-cancel-S snd)
degeneracy-almost-inj-aux : {x y : Fin (S n)} → (fst x ≠ fst k) → (fst y ≠ fst k) →
(z : ((fst x) ≤ (fst k)) ⊔ ((fst k) < (fst x))) → (w : ((fst y) ≤ (fst k)) ⊔ ((fst k) < (fst y))) →
(degeneracy-aux x z == degeneracy-aux y w) → x == y
degeneracy-almost-inj-aux f g (inl z) (inl w) p = ℕ=-to-Fin= (ap fst p)
degeneracy-almost-inj-aux f g (inl z) (inr ltS) p = ⊥-rec (f (ap fst p))
degeneracy-almost-inj-aux f g (inl z) (inr (ltSR w)) p = ⊥-rec (<-to-≠ (≤-<-trans z w) (ap fst p))
degeneracy-almost-inj-aux f g (inr ltS) (inl w) p = ⊥-rec (g (ap fst (! p)))
degeneracy-almost-inj-aux f g (inr (ltSR z)) (inl w) p = ⊥-rec (<-to-≠ (≤-<-trans w z) (ap fst (! p)))
degeneracy-almost-inj-aux f g (inr ltS) (inr ltS) p = ℕ=-to-Fin= idp
degeneracy-almost-inj-aux f g (inr ltS) (inr (ltSR w)) p = ℕ=-to-Fin= (ap S (ap fst p))
degeneracy-almost-inj-aux f g (inr (ltSR z)) (inr ltS) p = ℕ=-to-Fin= (ap S (ap fst p))
degeneracy-almost-inj-aux f g (inr (ltSR z)) (inr (ltSR w)) p = ℕ=-to-Fin= (ap S (ap fst p))
abstract
degeneracy : (x : Fin (S n)) → Fin n
degeneracy x = degeneracy-aux x (≤-or-> _ _)
degeneracy-almost-inj : {x y : Fin (S n)} → (fst x ≠ fst k) → (fst y ≠ fst k) →
(degeneracy x == degeneracy y) → x == y
degeneracy-almost-inj f g = degeneracy-almost-inj-aux f g (≤-or-> _ _) (≤-or-> _ _)
Fin-hfiber-dec : {i : ULevel} {X : Type i} {n : ℕ} (dec : has-dec-eq X) → (f : Fin n → X) →
(x : X) → Dec (hfiber f x)
Fin-hfiber-dec dec f x = ⊔-fmap (idf _) (λ g p → g (fst p) (snd p))
(finite-lpo (λ z → f z == x) (λ z → dec (f z) x))
Fin-inj-to-surj : (n : ℕ) → (inc : Fin n → Fin n) → (inc-inj : is-inj inc) → (y : Fin n) → hfiber inc y
Fin-inj-to-surj O inc inc-inj y = ⊥-rec (–> Fin-equiv-Empty y)
Fin-inj-to-surj (S n) inc inc-inj y =
⊔-rec (λ p → n<Sn , (! p))
(λ f → ⊔-rec (λ p → case1 p f) (λ g → case2 g f) (Fin-has-dec-eq k n<Sn))
(Fin-has-dec-eq y k)
where
n<Sn = (n , ltS)
k = inc n<Sn
case1 : k == n<Sn → (y ≠ k) → hfiber inc y
case1 p f = Fin-S (fst x') , ℕ=-to-Fin= (ap fst (snd x'))
where
inc' : Fin n → Fin n
inc' x = (fst (inc (Fin-S x))) , <S≠-to-< (snd (inc (Fin-S x))) λ q → <-to-≠ (snd x) (ap fst (inc-inj _ _ (ℕ=-to-Fin= q ∙ ! p)))
inc-inj' : is-inj inc'
inc-inj' x x' p = Fin-S-is-inj _ _ (inc-inj _ _ (ℕ=-to-Fin= (ap fst p)))
y' : Fin n
y' = (fst y) , (<S≠-to-< (snd y) (λ q → f (ℕ=-to-Fin= q ∙ ! p)))
x' : hfiber inc' y'
x' = Fin-inj-to-surj n inc' inc-inj' y'
case2 : k ≠ n<Sn → (y ≠ k) → hfiber inc y
case2 f g = Fin-S (fst x') , degeneracy-almost-inj k' (λ q → <-to-≠ (snd (fst x')) (ap fst (inc-inj (Fin-S (fst x')) n<Sn (ℕ=-to-Fin= q))))
(λ q → g (ℕ=-to-Fin= q)) (snd x')
where
k' = (fst k) , (<S≠-to-< (snd k) (λ q → f (ℕ=-to-Fin= q)))
inc' : Fin n → Fin n
inc' x = degeneracy k' (inc (Fin-S x))
inc-inj' : is-inj inc'
inc-inj' x x' p =
Fin-S-is-inj _ _ (inc-inj _ _ (degeneracy-almost-inj k' (λ q → <-to-≠ (snd x) (ap fst (inc-inj _ _ (ℕ=-to-Fin= q))))
(λ q → <-to-≠ (snd x') (ap fst (inc-inj _ _ (ℕ=-to-Fin= q))))
p))
x' : hfiber inc' (degeneracy k' y)
x' = Fin-inj-to-surj n inc' inc-inj' ((degeneracy k' y))
Fin-inj-to-equiv : {n : ℕ} → (inc : Fin (S n) → Fin (S n)) → (inc-inj : is-inj inc) → (is-equiv inc)
Fin-inj-to-equiv inc inc-inj =
contr-map-is-equiv λ x → inhab-prop-is-contr (Fin-inj-to-surj _ inc inc-inj x) ⦃ inj-to-embed ⦃ Fin-is-set ⦄ inc inc-inj x ⦄
Fin-smaller-is-smaller : {m n : ℕ} (l : m < n) (f : Fin m → Fin n) → Σ (Fin n) (λ k → ¬ (hfiber f k))
Fin-smaller-is-smaller {m} {n} l f = ⊔-cancel-r (finite-lpo _ (λ k → ⊔-rec (λ x → inr (λ g → g x)) inl (Fin-hfiber-dec Fin-has-dec-eq f k))) lemma
where
lemma : ((k : Fin n) → ¬ (¬ (hfiber f k))) → ⊥
lemma g = <-to-≠ (snd (g'' (fst k))) (ap fst (snd k))
where
g' : (k : Fin n) → (hfiber f k)
g' k = ⊔-cancel-r (Fin-hfiber-dec Fin-has-dec-eq f k) (g k)
g'' : Fin n → Fin m
g'' = fst ∘ g'
g''-is-inj : is-inj g''
g''-is-inj y y' p = ! (snd (g' y)) ∙ ap f p ∙ snd (g' y')
h : Fin n → Fin n
h k = (fst (g'' k)) , (<-trans (snd (g'' k)) l)
h-is-inj : is-inj h
h-is-inj x y p = g''-is-inj _ _ (ℕ=-to-Fin= (ap fst p))
k : hfiber h (m , l)
k = Fin-inj-to-surj n h h-is-inj ((m , l))
|
oeis/102/A102909.asm | neoneye/loda-programs | 11 | 101157 | ; A102909: a(n) = Sum_{j=0..8} n^j.
; 1,9,511,9841,87381,488281,2015539,6725601,19173961,48427561,111111111,235794769,469070941,883708281,1589311291,2745954241,4581298449,7411742281,11668193551,17927094321,26947368421,39714002329,57489010371,81870575521,114861197401,158945719401,217180147159,293292210961,391794664941,518112356281,678724137931,881320738689,1134979744801,1450358887561,1839908871711,2318107019761,2901713047669,3610048327641,4465300034131,5492851609441,6721641025641,8184548359849,9918814240231,11966490760401
mov $2,8
lpb $2
add $1,2
mul $1,$0
sub $2,1
lpe
div $1,4
mul $1,2
add $1,1
mov $0,$1
|
euler3.adb | kimtg/euler-ada | 7 | 21245 | with ada.text_io;
use ada.text_io;
procedure euler3 is
num : long_long_integer := 600851475143;
p : long_long_integer := 2;
begin
loop
while num mod p = 0 loop
num := num / p;
end loop;
if num <= 1 then
put_line(long_long_integer'image(p));
exit;
end if;
p := p + 1;
end loop;
end euler3;
|
chap15/ex21/mul_cpx_mem.asm | jamesreinders/optimization-manual | 374 | 164 | ;
; Copyright (C) 2021 by Intel Corporation
;
; Permission to use, copy, modify, and/or distribute this software for any
; purpose with or without fee is hereby granted.
;
; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
; AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
; OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
; PERFORMANCE OF THIS SOFTWARE.
;
; .globl mul_cpx_mem
; void mul_cpx_mem(complex_num *in1, complex_num *in2, complex_num *out, size_t len);
; On entry:
; rcx = in1
; rdx = in2
; r8 = out
; r9 = len
.code
mul_cpx_mem PROC public
push rbx
sub rsp, 32
vmovaps xmmword ptr[rsp], xmm6
vmovaps xmmword ptr[rsp+16], xmm7
mov rax, rcx ; mov rax, inPtr1
mov rbx, rdx ; mov rbx, inPtr2
; mov rdx, outPtr (rdx already contains the out array)
mov r10, r9 ; mov r8, len
xor r9, r9
loop1:
vmovaps ymm0, [rax +8*r9]
vmovaps ymm4, [rax +8*r9 +32]
vmovsldup ymm2, ymmword ptr[rbx +8*r9]
vmulps ymm2, ymm2, ymm0
vshufps ymm0, ymm0, ymm0, 177
vmovshdup ymm1, ymmword ptr[rbx +8*r9]
vmulps ymm1, ymm1, ymm0
vmovsldup ymm6, ymmword ptr[rbx +8*r9 +32]
vmulps ymm6, ymm6, ymm4
vaddsubps ymm3, ymm2, ymm1
vmovshdup ymm5, ymmword ptr[rbx +8*r9 +32]
vmovaps [r8 +8*r9], ymm3
vshufps ymm4, ymm4, ymm4, 177
vmulps ymm5, ymm5, ymm4
vaddsubps ymm7, ymm6, ymm5
vmovaps [r8 +8*r9 +32], ymm7
add r9, 8
cmp r9, r10
jl loop1
vzeroupper
vmovaps xmmword ptr[rsp+16], xmm7
vmovaps xmmword ptr[rsp], xmm6
add rsp, 32
pop rbx
ret
mul_cpx_mem ENDP
end |
test/Fail/Issue5410-2.agda | cagix/agda | 1,989 | 8124 | module _ where
open import Agda.Builtin.Bool
module M (b : Bool) where
module Inner where
some-boolean : Bool
some-boolean = b
postulate
@0 a-postulate : Bool
@0 A : @0 Bool → Set
A b = Bool
module A where
module M′ = M b
bad : @0 Bool → Bool
bad = A.M′.Inner.some-boolean
|
programs/oeis/054/A054410.asm | neoneye/loda | 22 | 84994 | <gh_stars>10-100
; A054410: Susceptibility series H_3 for 2-dimensional Ising model (divided by 2).
; 1,12,52,148,328,620,1052,1652,2448,3468,4740,6292,8152,10348,12908,15860,19232,23052,27348,32148,37480,43372,49852,56948,64688,73100,82212,92052,102648,114028,126220,139252,153152,167948,183668,200340,217992,236652,256348,277108,298960,321932,346052,371348,397848,425580,454572,484852,516448,549388,583700,619412,656552,695148,735228,776820,819952,864652,910948,958868,1008440,1059692,1112652,1167348,1223808,1282060,1342132,1404052,1467848,1533548,1601180,1670772,1742352,1815948,1891588,1969300,2049112,2131052,2215148,2301428,2389920,2480652,2573652,2668948,2766568,2866540,2968892,3073652,3180848,3290508,3402660,3517332,3634552,3754348,3876748,4001780,4129472,4259852,4392948,4528788
mov $2,$0
mul $2,2
mov $3,3
mov $4,$0
mov $0,$2
lpb $0
sub $0,1
trn $1,$0
sub $2,1
add $3,$2
sub $3,1
add $1,$3
lpe
add $1,1
mov $5,$4
mov $7,$4
lpb $7
add $6,$5
sub $7,1
lpe
mov $5,$6
mov $8,4
lpb $8
add $1,$5
sub $8,1
lpe
mov $6,0
mov $7,$4
lpb $7
add $6,$5
sub $7,1
lpe
mov $5,$6
mov $8,2
lpb $8
add $1,$5
sub $8,1
lpe
mov $0,$1
|
oeis/016/A016751.asm | neoneye/loda-programs | 11 | 7780 | <gh_stars>10-100
; A016751: a(n) = (2*n)^11.
; 0,2048,4194304,362797056,8589934592,100000000000,743008370688,4049565169664,17592186044416,64268410079232,204800000000000,584318301411328,1521681143169024,3670344486987776,8293509467471872,17714700000000000,36028797018963968,70188843638032384,131621703842267136,238572050223552512,419430400000000000,717368321110468608,1196683881290399744,1951354384207722496,3116402981210161152,4882812500000000000,7516865509350965248,11384956040305711104,16985107389382393856,24986644000165537792
pow $0,11
mul $0,2048
|
src/Source/Size/Substitution/Canonical.agda | JLimperg/msc-thesis-code | 5 | 8103 | {-# OPTIONS --without-K --safe #-}
module Source.Size.Substitution.Canonical where
open import Source.Size
open import Util.Prelude
infix 0 Sub⊢
infixl 5 _>>_
data Sub (Δ : Ctx) : (Ω : Ctx) → Set where
[] : Sub Δ []
Snoc : (σ : Sub Δ Ω) (n : Size Δ) → Sub Δ (Ω ∙ m)
variable
σ τ σ′ τ′ ι ι′ : Sub Δ Ω
subV : Sub Δ Ω → Var Ω → Size Δ
subV (Snoc σ n) zero = n
subV (Snoc σ n) (suc x) = subV σ x
sub : Sub Δ Ω → Size Ω → Size Δ
sub σ (var x) = subV σ x
sub σ ∞ = ∞
sub σ zero = zero
sub σ (suc n) = suc (sub σ n)
data Sub⊢ Δ : ∀ Ω (σ : Sub Δ Ω) → Set where
[] : Sub⊢ Δ [] []
Snoc : (⊢σ : Sub⊢ Δ Ω σ) (n<m : n < sub σ m) → Sub⊢ Δ (Ω ∙ m) (Snoc σ n)
syntax Sub⊢ Δ Ω σ = σ ∶ Δ ⇒ Ω
abstract
sub-Snoc : ∀ (σ : Sub Δ Ω) n o
→ sub (Snoc {m = m} σ n) (wk o) ≡ sub σ o
sub-Snoc σ n (var x) = refl
sub-Snoc σ n ∞ = refl
sub-Snoc σ n zero = refl
sub-Snoc σ n (suc o) = cong suc (sub-Snoc σ n o)
mutual
subV-resp-< : σ ∶ Δ ⇒ Ω → var x < n → subV σ x < sub σ n
subV-resp-< {x = zero} (Snoc {σ = σ} {n} {m} ⊢σ n<m) (var refl)
= subst (n <_) (sym (sub-Snoc σ n m)) n<m
subV-resp-< {x = suc x} (Snoc {σ = σ} {n} {m} ⊢σ n<m) (var refl)
= subst (subV σ x <_) (sym (sub-Snoc σ n (bound x)))
(subV-resp-< ⊢σ (var refl))
subV-resp-< ⊢σ <suc = <suc
subV-resp-< ⊢σ (<-trans x<m m<n)
= <-trans (subV-resp-< ⊢σ x<m) (sub-resp-< ⊢σ m<n)
sub-resp-< : σ ∶ Δ ⇒ Ω → n < m → sub σ n < sub σ m
sub-resp-< ⊢σ (var p) = subV-resp-< ⊢σ (var p)
sub-resp-< ⊢σ zero<suc = zero<suc
sub-resp-< ⊢σ zero<∞ = zero<∞
sub-resp-< ⊢σ (suc<suc n<m) = suc<suc (sub-resp-< ⊢σ n<m)
sub-resp-< ⊢σ (suc<∞ n<∞) = suc<∞ (sub-resp-< ⊢σ n<∞)
sub-resp-< ⊢σ (<-trans n<o o<m)
= <-trans (sub-resp-< ⊢σ n<o) (sub-resp-< ⊢σ o<m)
sub-resp-< ⊢σ <suc = <suc
Weaken : Sub Δ Ω → Sub (Δ ∙ n) Ω
Weaken [] = []
Weaken (Snoc σ m) = Snoc (Weaken σ) (wk m)
abstract
subV-Weaken : ∀ (σ : Sub Δ Ω) x → subV (Weaken {n = o} σ) x ≡ wk (subV σ x)
subV-Weaken (Snoc σ n) zero = refl
subV-Weaken (Snoc σ n) (suc x) = subV-Weaken σ x
sub-Weaken : ∀ (σ : Sub Δ Ω) n → sub (Weaken {n = o} σ) n ≡ wk (sub σ n)
sub-Weaken σ (var x) = subV-Weaken σ x
sub-Weaken σ ∞ = refl
sub-Weaken σ zero = refl
sub-Weaken σ (suc n) = cong suc (sub-Weaken σ n)
Weaken⊢ : σ ∶ Δ ⇒ Ω → Weaken σ ∶ Δ ∙ n ⇒ Ω
Weaken⊢ [] = []
Weaken⊢ (Snoc {σ = σ} {n} {m} ⊢σ n<m)
= Snoc (Weaken⊢ ⊢σ)
(subst (wk n <_) (sym (sub-Weaken σ m)) (wk-resp-< n<m))
Lift : (σ : Sub Δ Ω) → Sub (Δ ∙ m) (Ω ∙ n)
Lift σ = Snoc (Weaken σ) (var zero)
abstract
Lift⊢ : σ ∶ Δ ⇒ Ω → m ≡ sub σ n → Lift σ ∶ Δ ∙ m ⇒ Ω ∙ n
Lift⊢ {Δ} {σ = σ} {n = n} ⊢σ refl
= Snoc (Weaken⊢ ⊢σ) (var (sub-Weaken σ n))
mutual
Id : Sub Δ Δ
Id {[]} = []
Id {Δ ∙ n} = Lift Id
abstract
subV-Id : ∀ x → subV (Id {Δ}) x ≡ var x
subV-Id zero = refl
subV-Id (suc x) = trans (subV-Weaken Id x) (cong wk (subV-Id x))
sub-Id : ∀ n → σ ≡ Id → sub σ n ≡ n
sub-Id (var x) refl = subV-Id x
sub-Id ∞ _ = refl
sub-Id zero _ = refl
sub-Id (suc n) p = cong suc (sub-Id n p)
abstract
Id⊢ : Id ∶ Δ ⇒ Δ
Id⊢ {[]} = []
Id⊢ {Δ ∙ n} = Lift⊢ Id⊢ (sym (sub-Id _ refl))
Wk : Sub (Δ ∙ n) Δ
Wk = Weaken Id
abstract
sub-Wk : ∀ n → sub (Wk {Δ} {o}) n ≡ wk n
sub-Wk n = trans (sub-Weaken Id n) (cong wk (sub-Id _ refl))
Wk⊢ : Wk ∶ Δ ∙ n ⇒ Δ
Wk⊢ = Weaken⊢ Id⊢
Sing : Size Δ → Sub Δ (Δ ∙ m)
Sing n = Snoc Id n
abstract
Sing⊢ : n < m → Sing n ∶ Δ ⇒ Δ ∙ m
Sing⊢ {n = n} n<m
= Snoc Id⊢ (subst (n <_) (sym (sub-Id _ refl)) n<m)
_>>_ : Sub Δ Δ′ → Sub Δ′ Δ″ → Sub Δ Δ″
σ >> [] = []
σ >> Snoc τ n = Snoc (σ >> τ) (sub σ n)
abstract
subV->> : ∀ (σ : Sub Δ Δ′) (τ : Sub Δ′ Δ″) x
→ subV (σ >> τ) x ≡ sub σ (subV τ x)
subV->> σ (Snoc τ n) zero = refl
subV->> σ (Snoc τ n) (suc x) = subV->> σ τ x
sub->> : ∀ n → ι ≡ σ >> τ
→ sub ι n ≡ sub σ (sub τ n)
sub->> {σ = σ} {τ} (var x) refl = subV->> σ τ x
sub->> ∞ _ = refl
sub->> zero _ = refl
sub->> (suc n) p = cong suc (sub->> n p)
sub->>′ : σ >> τ ≡ σ′ >> τ′ → sub σ (sub τ n) ≡ sub σ′ (sub τ′ n)
sub->>′ {σ = σ} {τ = τ} {σ′ = σ′} {τ′} {n} eq
= trans (sym (sub->> n refl))
(trans (cong (λ σ → sub σ n) eq) (sub->> n refl))
>>⊢ : σ ∶ Δ ⇒ Δ′ → τ ∶ Δ′ ⇒ Δ″ → σ >> τ ∶ Δ ⇒ Δ″
>>⊢ ⊢σ [] = []
>>⊢ {σ = σ} ⊢σ (Snoc {σ = τ} {n} {m} ⊢τ n<m)
= Snoc (>>⊢ ⊢σ ⊢τ)
(subst (sub σ n <_) (sym (sub->> m refl)) (sub-resp-< ⊢σ n<m))
Skip : Sub (Δ ∙ n ∙ v0) (Δ ∙ n)
Skip = Snoc (Weaken Wk) (var zero)
abstract
Skip⊢ : Skip ∶ Δ ∙ n ∙ v0 ⇒ Δ ∙ n
Skip⊢ {n = n}
= Snoc (Weaken⊢ Wk⊢)
(<-trans (var refl)
(var (trans (sub-Weaken Wk n) (cong wk (sub-Wk n)))))
Weaken>> : Weaken σ >> τ ≡ Weaken {n = n} (σ >> τ)
Weaken>> {τ = []} = refl
Weaken>> {σ = σ} {τ = Snoc τ n} = cong₂ Snoc Weaken>> (sub-Weaken σ n)
Snoc>>Weaken : Snoc {m = m} σ n >> Weaken τ ≡ σ >> τ
Snoc>>Weaken {τ = []} = refl
Snoc>>Weaken {σ = σ} {n = n} {τ = Snoc τ k}
= cong₂ Snoc Snoc>>Weaken (sub-Snoc σ n k)
id-l : Id >> σ ≡ σ
id-l {σ = []} = refl
id-l {σ = Snoc σ n} = cong₂ Snoc id-l (sub-Id n refl)
id-r : {σ : Sub Δ Ω} → σ >> Id ≡ σ
id-r {σ = []} = refl
id-r {σ = Snoc σ n} = cong₂ Snoc (trans Snoc>>Weaken id-r) refl
>>-assoc : σ >> (τ >> ι) ≡ σ >> τ >> ι
>>-assoc {ι = []} = refl
>>-assoc {σ = σ} {τ = τ} {ι = Snoc ι n}
= cong₂ Snoc >>-assoc (sym (sub->> n refl))
Wk>> : Wk >> σ ≡ Weaken {n = n} σ
Wk>> = trans Weaken>> (cong Weaken id-l)
Snoc>>Wk : Snoc {m = m} σ n >> Wk ≡ σ
Snoc>>Wk = trans Snoc>>Weaken id-r
Lift>>Weaken : Lift {m = m} {n} σ >> Weaken τ ≡ Weaken (σ >> τ)
Lift>>Weaken = trans Snoc>>Weaken Weaken>>
Lift>>Wk : Lift {m = m} {n} σ >> Wk ≡ Wk >> σ
Lift>>Wk = trans Lift>>Weaken (trans (sym Wk>>) (cong (Wk >>_) id-r))
Sing>>Weaken : Sing {m = m} n >> Weaken σ ≡ σ
Sing>>Weaken = trans Snoc>>Weaken id-l
Sing>>Wk : Sing {m = m} n >> Wk ≡ Id
Sing>>Wk = trans Snoc>>Weaken id-r
Sing>>Lift : ∀ n → Sing (sub σ n) >> Lift {m = m} {o} σ ≡ σ >> Sing n
Sing>>Lift n = cong₂ Snoc (trans Sing>>Weaken (sym id-r)) refl
Lift>>Lift : Lift {m = m} {n} σ >> Lift {n = o} τ ≡ Lift (σ >> τ)
Lift>>Lift = cong₂ Snoc Lift>>Weaken refl
Skip>>Weaken : Skip {n = n} >> Weaken σ ≡ Weaken (Weaken σ)
Skip>>Weaken = trans Snoc>>Weaken (trans Weaken>> (cong Weaken Wk>>))
Skip>>Lift : Skip >> Lift {m = m} {n} σ ≡ Lift (Lift σ) >> Skip
Skip>>Lift
= cong₂ Snoc
(trans Skip>>Weaken
(sym (trans Lift>>Weaken (cong Weaken (trans Snoc>>Weaken id-r)))))
refl
Lift-Id : Lift {m = m} Id ≡ Id
Lift-Id = refl
LiftSing>>Wk>>Wk : Lift {m = o} {m} (Sing n) >> (Wk >> Wk) ≡ Wk
LiftSing>>Wk>>Wk {n = n} = let open ≡-Reasoning in
begin
Lift (Sing n) >> (Wk >> Wk)
≡⟨ cong (Lift (Sing n) >>_) Wk>> ⟩
Lift (Sing n) >> (Weaken Wk)
≡⟨ Lift>>Weaken ⟩
Weaken (Sing n >> Weaken Id)
≡⟨ cong Weaken Sing>>Weaken ⟩
Wk
∎
LiftSing>>Skip
: Lift {m = m} (Sing {m = m} n) >> Skip ≡ Sing {m = o} (var zero) >> Lift Wk
LiftSing>>Skip {n = n} = cong₂ Snoc go refl
where
go : Lift (Sing n) >> Weaken Wk ≡ Sing (var zero) >> Weaken Wk
go = let open ≡-Reasoning in
begin
Lift (Sing n) >> Weaken Wk
≡⟨ Lift>>Weaken ⟩
Weaken (Sing n >> Weaken Id)
≡⟨ cong Weaken Sing>>Wk ⟩
Wk
≡⟨ sym Sing>>Weaken ⟩
Sing (var zero) >> Weaken Wk
∎
LiftLift>>Skip : Lift (Lift {m = m} {n} σ) >> Skip ≡ Skip >> Lift σ
LiftLift>>Skip
= cong₂ Snoc (trans Lift>>Weaken
(sym (trans Skip>>Weaken (cong Weaken (sym Snoc>>Wk))))) refl
|
Transynther/x86/_processed/NONE/_zr_/i9-9900K_12_0xca_notsx.log_11_328.asm | ljhsiun2/medusa | 9 | 245573 | .global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r8
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x1e6b9, %r8
nop
nop
nop
nop
cmp %rbx, %rbx
mov (%r8), %esi
nop
nop
nop
nop
nop
cmp %r14, %r14
lea addresses_D_ht+0x3bb9, %rsi
lea addresses_A_ht+0x1e5b9, %rdi
nop
nop
add %r12, %r12
mov $106, %rcx
rep movsw
nop
nop
nop
nop
nop
add %r12, %r12
lea addresses_D_ht+0x1bb9, %r8
inc %r12
movb (%r8), %bl
and %rbx, %rbx
lea addresses_normal_ht+0xa8b9, %rbx
nop
nop
nop
nop
nop
xor $39225, %rsi
movl $0x61626364, (%rbx)
nop
nop
and %rsi, %rsi
lea addresses_WT_ht+0x9e35, %rsi
lea addresses_UC_ht+0xa061, %rdi
nop
nop
nop
and %r9, %r9
mov $28, %rcx
rep movsq
nop
inc %rsi
lea addresses_D_ht+0x19fb9, %r12
nop
nop
nop
nop
inc %r8
movb (%r12), %cl
cmp $36802, %rdi
lea addresses_D_ht+0x1d0b9, %rsi
lea addresses_UC_ht+0x99b9, %rdi
nop
xor %r8, %r8
mov $86, %rcx
rep movsl
nop
nop
nop
inc %r9
lea addresses_WC_ht+0x1d1b9, %r14
nop
cmp $29297, %r12
movl $0x61626364, (%r14)
nop
cmp $44761, %rbx
lea addresses_UC_ht+0x10523, %r9
nop
nop
nop
nop
inc %rbx
movb $0x61, (%r9)
nop
and $40871, %r9
lea addresses_normal_ht+0x2880, %r12
nop
nop
nop
nop
sub $33967, %rdi
movw $0x6162, (%r12)
nop
nop
cmp %r9, %r9
lea addresses_WT_ht+0x1e9b9, %r12
nop
nop
and $37467, %r8
movb $0x61, (%r12)
nop
nop
nop
nop
nop
cmp %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r8
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
// Store
mov $0xc1c, %rsi
nop
nop
nop
nop
nop
cmp $16962, %rdi
movb $0x51, (%rsi)
nop
nop
xor $19715, %r10
// Faulty Load
lea addresses_A+0x91b9, %rsi
nop
nop
nop
nop
nop
and $1651, %rcx
mov (%rsi), %di
lea oracles, %rcx
and $0xff, %rdi
shlq $12, %rdi
mov (%rcx,%rdi,1), %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_P', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 8}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_UC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 11}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 11}}
{'00': 11}
00 00 00 00 00 00 00 00 00 00 00
*/
|
programs/oeis/004/A004959.asm | karttu/loda | 0 | 9633 | <gh_stars>0
; A004959: a(n) = ceiling(n*phi^4), where phi is the golden ratio, A001622.
; 0,7,14,21,28,35,42,48,55,62,69,76,83,90,96,103,110,117,124,131,138,144,151,158,165,172,179,186,192,199,206,213,220,227,234,240,247,254,261,268,275,282,288,295,302,309
add $0,8
mul $0,48
div $0,7
mov $1,$0
sub $1,54
|
asm/asmfunc.asm | yoshitsugu/hariboteos_in_rust | 29 | 7404 | [BITS 32] ; 32ビットモード用の機械語を作らせる
GLOBAL _start_app
_start_app: ; void start_app(int eip, int cs, int esp, int ds, int *tss_esp0);
PUSHAD ; 32ビットレジスタを全部保存しておく
MOV EAX,[ESP+36] ; アプリ用のEIP
MOV ECX,[ESP+40] ; アプリ用のCS
MOV EDX,[ESP+44] ; アプリ用のESP
MOV EBX,[ESP+48] ; アプリ用のDS/SS
MOV EBP,[ESP+52] ; tss.esp0の番地
MOV [EBP ],ESP ; OS用のESPを保存
MOV [EBP+4],SS ; OS用のSSを保存
MOV ES,BX
MOV DS,BX
MOV FS,BX
MOV GS,BX
; 以下はRETFでアプリに行かせるためのスタック調整
OR ECX,3 ; アプリ用のセグメント番号に3をORする
OR EBX,3 ; アプリ用のセグメント番号に3をORする
PUSH EBX ; アプリのSS
PUSH EDX ; アプリのESP
PUSH ECX ; アプリのCS
PUSH EAX ; アプリのEIP
RETF
; アプリが終了してもここには来ない
|
45/qb/ir/txtsave.asm | minblock/msdos | 0 | 105136 | <reponame>minblock/msdos<gh_stars>0
TITLE txtsave.asm - ASCII Save Functions
;==========================================================================
;
;Module: txtsave.asm - ASCII Save Functions
;System: Quick BASIC Interpreter
;
;=========================================================================*/
include version.inc
TXTSAVE_ASM = ON
includeOnce architec
includeOnce context
includeOnce heap
includeOnce lister
includeOnce names
includeOnce opcontrl
includeOnce opid
includeOnce opmin
includeOnce opstmt
includeOnce parser
includeOnce pcode
includeOnce qbimsgs
includeOnce rtinterp
includeOnce rtps
includeOnce rttemp
includeOnce scanner
includeOnce txtmgr
includeOnce txtint
includeOnce util
includeOnce ui
includeOnce variable
includeOnce edit
assumes DS,DATA
assumes SS,DATA
assumes ES,NOTHING
ASC_CRLF EQU 0A0Dh ;ASCII Carriage return/Line Feed
ASC_TAB EQU 9 ;ASCII Tab
sBegin DATA
EXTRN tabStops:WORD ;defined in edit manager
EXTRN b$PTRFIL:WORD ;defined by runtime - current channel ptr
CrLf DW ASC_CRLF ;for file line termination
oMrsSaveDecl DW 0 ;used by SaveDeclares
sEnd DATA
sBegin CODE
;Table of opcodes used to search for DECLARE or CALL statements
;
tOpDecl LABEL WORD
opTabStart DECL
opTabEntry DECL,opStDeclare
opTabEntry DECL,opStCall
opTabEntry DECL,opStCalls
opTabEntry DECL,opStCallLess
opTabEntry DECL,opEot
sEnd CODE
EXTRN B$BUFO:FAR
EXTRN B$KILL:FAR
sBegin CP
assumes cs,CP
;*************************************************************
; ushort SaveTxdCur(ax:otxStart)
; Purpose:
; ASCII save the contents of the current text table
; Entry:
; ax = text offset to start saving text
; Exit:
; ax = size of last line output (=2 if trailing blank line)
; ps.bdpSrc is used
; Exceptions:
; Can cause runtime error (Out of memory, I/O errors)
;
;*************************************************************
SaveTxdCur PROC NEAR
DbChk Otx,ax
push si
push di
sub di,di ;Init cbLastLine = 0
mov [otxListNext],ax ;ListLine() updates [otxListNext]
test [mrsCur.MRS_flags2],FM2_NoPcode ; document file?
je GetOtxEndProg ; file is measured in Otxs, not lines
DbAssertRel [otxListNext],e,0,CP,<SaveTxdCur:Not starting at the begining of file>
push [mrsCur.MRS_pDocumentBuf]
call S_LinesInBuf ; get # lines in document buffer
jmp short SetMaximumSave
GetOtxEndProg:
call OtxEndProg ;ax = otx to Watch pcode
SetMaximumSave:
xchg si,ax ;si = otx to Watch pcode
StLoop:
mov ax,[otxListNext] ;ax=offset for next line to list
cmp ax,si
DJMP jae SlDone ;brif done with this text table
test [mrsCur.MRS_flags2],FM2_NoPcode ; document file?
je ListPcodeLine ; brif not, let lister get line
push [mrsCur.MRS_pDocumentBuf] ; document table to list from
push ax ; line to list
push ps.PS_bdpSrc.BDP_cbLogical ; length of buffer
push ps.PS_bdpSrc.BDP_pb ;pass ptr to dest buf
call S_cbGetLineBuf ; AX = cBytes in line
inc [otxListNext] ; bump pointer to next line
mov [cLeadingSpaces],0 ; start with no leading spaces
mov bx,[ps.PS_bdpSrc.BDP_pb]; BX = ptr to 0 terminated string
CheckNextChar:
cmp byte ptr [bx],' ' ; Is it a space
jne GotLine ; brif not, say that we got line
inc [cLeadingSpaces] ; indicate another space
inc bx ; point to next character
jmp CheckNextChar ; check it for a space
ListPCodeLine:
push ax ;pass offset to ListLine
PUSHI ax,<DATAOFFSET ps.PS_bdpSrc> ;pass dst buf ptr to listline
call ListLine ;ax=char count
inc ax ;test for UNDEFINED
jne NotOmErr ;brif out-of-memory
jmp OmErrCP
NotOmErr:
dec ax ;restore ax = byte count
GotLine:
cmp [fLsIncluded],0
jne StLoop ;brif line was part of $INCLUDE file
test mrsCur.MRS_flags2,FM2_EntabSource ;do we need to entab leading
;blanks?
jz NoEntab ;brif not
mov cl,[cLeadingSpaces] ;cl = count of leading spaces
or cl,cl ;any leading spaces?
jnz EntabLeadingSpaces ;brif so, replace with tabs
NoEntab:
mov bx,[ps.PS_bdpSrc.BDP_pb]
EntabCont:
; There is currently no need to call UpdChanCur here, because
; there is no chance of having nested open files during ascii save.
DbAssertRel b$PTRFIL,ne,0,CP,<SaveTxdCur:Invalid channel>
; Call OutLine as we can not guarentee that the buffer
; pointed to by BX contains at least two more bytes.
; This is slower, but will not trash the heaps.
mov di,ax ; DI = new "cbLastLine"
inc di ; account for CRLF
inc di
call OutLine ; Print line and CRLF
DJMP jmp SHORT StLoop
SlDone:
xchg ax,di ;ax = cb last line emitted
pop di
pop si
ret
SaveTxdCur ENDP
; We have a line with leading spaces which needs to be entabbed.
; We will convert spaces to tabs in the buffer, and return the
; new buffer char count, and a ptr to the start of the buffer.
;
; Entry:
; ax = count of chars in line buffer
; cl = count of leading spaces
; Exit:
; ax = adjusted count of chars in line buffer
; bx = ptr to first char in buffer
; Uses:
; bx,cx,dx
EntabLeadingSpaces:
push ax ;preserve buffer char count
xchg ax,cx
sub ah,ah ;ax = cLeadingSpaces
mov dx,ax ;remember cLeadingSpaces
mov cx,[tabStops] ;get user defined tabstop settings
; User interface guarantees tabStops will not be set to 0
DbAssertRel cx,nz,0,CP,<tabStops=0 detected in Ascii save>
div cl ;al=tab count, ah=space count
mov bx,[ps.PS_bdpSrc.BDP_pb] ;bx=ptr to line buffer
add bx,dx ;bx=ptr to first non-leading space
sub dl,al
sub dl,ah ;dx=excess space in buffer
sub bl,ah ;backup over remaining spaces
sbb bh,0
xchg ax,cx
sub ch,ch ;cx=tab count
jcxz NoTabs ;brif none to replace
mov al,ASC_TAB
TabLoop:
dec bx ;back up a char
mov [bx],al ;replace space with tab
loop TabLoop
NoTabs:
pop ax ;recover buffer char count
sub ax,dx ;adust for removed spaces
jmp EntabCont
;*************************************************************
; OutLine, OutCrLf
; Purpose:
; OutLine - Output line and CR-LF to current file
; OutCrLf - Output CR-LF to current file
; Entry:
; bx points to 1st byte to output
; ax = byte count
;
;*************************************************************
OutLine PROC NEAR
; There is currently no need to call UpdChanCur here, because
; there is no chance of having nested open files during ascii save.
DbAssertRel b$PTRFIL,ne,0,CP,<OutLine:Invalid channel>
push ds ;pass segment of buffer
push bx ;pass offset of buffer
push ax ;pass length of buffer
call B$BUFO ;output line via runtime
;fall into OutCrLf
OutLine ENDP
OutCrLf PROC
; There is currently no need to call UpdChanCur here, because
; there is no chance of having nested open files during ascii save.
DbAssertRel b$PTRFIL,ne,0,CP,<OutCrLf:Invalid channel>
push ds
PUSHI ax,<dataOFFSET CrLf>
PUSHI ax,2
call B$BUFO ;output CR/LF via runtime
ret
OutCrLf ENDP
;*************************************************************
; RelShBuf
; Purpose:
; Release temporary text table used by SaveProcHdr.
; Called when we're done saving, or when an error occurs.
;
;*************************************************************
RelShBuf PROC NEAR
mov [txdCur.TXD_bdlText_cbLogical],0
;so TxtDiscard won't examine deleted txt
call TxtDiscard ;discard temporary text table
call TxtActivate ;make module's text table cur again
mov [ps.PS_bdpDst.BDP_cbLogical],0 ;release space held by temp bd
ret
RelShBuf ENDP
;*************************************************************
; ushort SaveProcHdr(ax:otxProcDef)
; Purpose:
; ASCII save the current procedure's header.
;
; Entry:
; ax = otxProcDef = offset into procedure's text table to opBol for line
; containing SUB/FUNCTION statement. 0 if this table has no
; SUB/FUNCTION statement yet.
;
; Exit:
; ps.bdpSrc is used
; grs.fDirect = FALSE
; ax = 0 if no error, else Standard BASIC error code (i.e. ER_xxx)
;
; Exceptions:
; Can cause runtime error (Out of memory, I/O errors)
;
;*************************************************************
SaveProcHdr PROC NEAR
push si ;save caller's si,di
push di
mov di,ax ;di = otxProcDef
push [grs.GRS_oPrsCur] ;pass current oPrs to PrsActivate below
;fill tEtTemp[] with DEFTYP's from start of proc table to SUB line
mov ax,di ;ax = otxProcDef
mov bx,dataOFFSET tEtTemp ;bx -> type table
call OtxDefType
;move everything up to proc def from procedure's to temp text table
PUSHI ax,<dataOFFSET ps.PS_bdpDst>
push di ;pass otxProcDef
call BdRealloc
or ax,ax
je JE1_ShOmErr ;brif out-of-memory error
PUSHI ax,<dataOFFSET txdCur.TXD_bdlText>
SetStartOtx ax
push ax
push [ps.PS_bdpDst.BDP_pb]
push di ;pass otxProcDef
call BdlCopyFrom
;Now we create a temporary text table for saving the synthetically
;generated procedure header. We must go through the following steps
; to do this:
; PrsDeactivate() --- causes module's text table to be made active
; TxtDeactivate() --- causes no text table to be made active
; TxtCurInit() --- make temp text table active
; put synthetically generated pcode into txdCur
; ASCII save this pcode buffer to the file
; TxtDiscard() --- discard temporary text table
; TxtActivate() --- make module's text table current again
; PrsActivate(oPrsSave)
;[flagsTM.FTM_SaveProcHdr] is non-zero while in critical state
; within function SaveProcHdr. Tells SaveFile's error cleanup
; to take special action.
or [flagsTM],FTM_SaveProcHdr ;if err, remember to clean up
call PrsDeactivate ;make module's text table active
call TxtDeactivate ;causes no text table to be made active
call TxtCurInit ;make temp text table active
je ShOmErr ;brif out-of-memory error
;emit synthetic DEFxxx statements as transition from end of last
;text table to procedure definition line
PUSHI ax,<dataOFFSET ps.PS_tEtCur>
PUSHI ax,<dataOFFSET tEtTemp>
SetStartOtx ax ;insert at start of text
call InsertEtDiff
JE1_ShOmErr:
je ShOmErr ;brif out-of-memory error
call OtxEndProg ;ax = otx to Watch pcode
xchg si,ax ; = offset beyond synthetic DEFxxx stmts
;Append everything up to SUB line to temp table
push si ;pass otx to Watch pcode
push di ;pass otxProcDef
call TxtMoveUp
je ShOmErr ;brif out-of-memory error
PUSHI ax,<dataOFFSET txdCur.TXD_bdlText>
push si ;pass otx to Watch pcode
push [ps.PS_bdpDst.BDP_pb]
push di ;pass otxProcDef
call BdlCopyTo
call SqueezeDefs ;takes parm in si
;if setting of $STATIC/$DYNAMIC differs between procedure's header
;and where procedure will be listed in source file,
;insert pcode to change the state for the procedure,
;Note: fLsDynArrays's value will be changed by ListLine() when it
; lists the line emitted by InsertDynDiff (if any)
SetStartOtx ax ;insert at start of text
mov dh,[fLsDynArrays] ;dh = old $STATIC/$DYNAMIC state
mov dl,[fProcDyn] ;dl = new $STATIC/$DYNAMIC state
call InsertDynDiff
je ShOmErr ;brif out of memory error
SetStartOtx ax ;start saving at start of text
call SaveTxdCur ;save procedure's header to file
call RelShBuf ;release temp text tbl
and [flagsTM],NOT FTM_SaveProcHdr ;reset critical section flag
;oPrs parm was pushed on entry to this function
call PrsActivateCP
sub ax,ax ;return no-error result
;al = error code
ShExit:
mov [ps.PS_bdpDst.BDP_cbLogical],0 ;release space held by temp bd
or al,al ;set condition codes for caller
pop di ;restore caller's si,di
pop si
ret
ShOmErr:
pop ax ;discard oPrs
mov al,ER_OM ;return al = out-of-memory error
jmp SHORT ShExit
SaveProcHdr ENDP
;Cause runtime error "Out of memory"
OmErrCP:
mov al,ER_OM
call RtError
;*************************************************************
; ONamOtherOMrs
; Purpose:
; Given an oNam in current mrs, convert it to an oNam
; in another mrs (which has a different name table).
; Entry:
; grs.oMrsCur = source oMrs
; ax = source oNam
; dx = target oMrs
; Exit:
; ax = target oNam (0 if out of memory error)
; flags set based upon return value.
;
;*************************************************************
cProc ONamOtherOMrs,<NEAR>
localV bufNam,CB_MAX_NAMENTRY
cBegin
cmp [grs.GRS_oMrsCur],dx
je OnOExit ;brif source mrs = target mrs
xchg ax,bx ;bx = oNam (save until CopyONamPb)
push di
push [grs.GRS_oRsCur] ;save caller's oRs -for RsActivate below
mov di,dx ;di = target oMrs
lea ax,bufNam
push ax ;save ptr to string
; string ptr in ax
; oNam to CopyONamPb in bx
cCall CopyONamPb,<ax,bx> ; ax = byte count
push ax ;save byte count
cCall MrsActivateCP,<di> ;activate target mrs
pop cx ;cx = byte count
pop ax ;ax = ptr to bufNam
call ONamOfPbCb ;ax = target oNam (ax=Pb, cx=Cb)
xchg di,ax ;di = target oNam
call RsActivateCP ;re-activate caller's oRs
; parm was pushed on entry
xchg ax,di ;ax = target oNam
pop di ;restore caller's es,di
OnOExit:
or ax,ax ;set condition codes
cEnd
;*************************************************************
; SaveDeclares
; Purpose:
; Generate synthetic DECLARE stmts for forward referenced
; SUBs and FUNCTIONs in this module as follows:
; Pass1:
; For every prs in system,
; reset FTX_TmpDecl
; if prs type is FUNCTION and prs is in mrs being saved,
; set FTX_TmpRef bit, else reset it
; Pass2:
; For every text table in this module
; Search text table for a reference to a SUB or FUNCTION
; if opStDeclare ref found
; set FTX_TmpDecl bit
; else if CALL, CALLS, implied CALL
; set FTX_TmpRef bit
; Pass3:
; For every prs in system,
; if FP_DEFINED and FTX_TmpRef bit are set, and FTX_TmpDecl bit is not,
; copy pcode for definition to module, changing opcode to opStDeclare,
; and changing the oNam for each formal parm and explicitly
; listing the TYPE.
;
; Exit:
; grs.fDirect = FALSE
; ax = 0 for out of memory error.
; flags set on value in ax
;*************************************************************
;----------------------------------------------------------------
; For every prs with a text table in system,
; reset FTX_TmpDecl
; if prs type is FUNCTION and prs is in mrs being saved,
; set FTX_TmpRef bit, else reset it
;----------------------------------------------------------------
cProc SdPass1,<NEAR>
cBegin
and [txdCur.TXD_flags],NOT (FTX_TmpDecl OR FTX_TmpRef)
;start out by turning both bits off
cmp [prsCur.PRS_procType],PT_FUNCTION
jne Sd1ResetBits ;exit if SUB
mov ax,[oMrsSaveDecl]
cmp ax,[prsCur.PRS_oMrs]
jne Sd1ResetBits ;exit if Func defined in another module
;for func in module, assume it is referenced. For external func
;refs, even qbi requires user have a DECLARE stmt for it.
or [txdCur.TXD_flags],FTX_TmpRef ;turn on FTX_TmpRef bit
Sd1ResetBits:
mov ax,sp ;return TRUE for ForEachCP
cEnd
;-----------------------------------------------------------------
; For every text table in module being saved:
; Search text table for a reference to a SUB or FUNCTION
; if opStDeclare ref found
; set FTX_TmpDecl bit
; else if CALL, CALLS, implied CALL
; set FTX_TmpRef bit
;-----------------------------------------------------------------
cProc SdPass2,<NEAR>,<si>
cBegin
SetStartOtx si ;otxCur = start of text
Sd2Loop:
push si
PUSHI ax,<CODEOFFSET tOpDecl>
call TxtFindNextOp ;ax = otx to next opStDeclare opcode
cmp dl,DECL_opEot
je Sd2Exit
xchg si,ax ;si = new otxCur
GetSegTxtTblCur ;es = seg addr of text table
mov ax,es:4[si] ;ax = oPrs field
call PPrsOPrs ; es:bx points to prs structure
;all other regs preserved
test BPTRRS[bx.PRS_flags],FP_DEFINED
je Sd2Loop ;don't count references to native-code
; procedures, only those defined with
; a SUB/FUNCTION stmt
mov al,FTX_TmpRef
.errnz DECL_opStDeclare
or dl,dl ;dl = 0 for DECLARE, non-zero for CALL
jne Sd2SetBit ;brif CALL
mov al,FTX_TmpDecl
Sd2SetBit:
or BPTRRS[bx.PRS_txd.TXD_flags],al
jmp SHORT Sd2Loop
Sd2Exit:
mov ax,sp ;return TRUE for ForEachCP
cEnd
;***
;GetWord
;Purpose:
; This header block added as part of revision [5]
;Preserves:
; All but ES, BX, and SI
;******************************************************************************
GetWord PROC NEAR
GetSegTxtTblCur ;es = seg addr of text table
lods WORD PTR es:[si] ;ax = cntEos
ret
GetWord ENDP
MoveWord PROC NEAR
call GetWord
jmp Emit16_AX ;emit cntEos operand
; and return to caller
MoveWord ENDP
;------------------------------------------------------------------------------
; For every prs with a text table in system,
; if FP_DEFINED and FTX_TmpRef bit are set, and FTX_TmpDecl bit is not,
; copy pcode for definition to module, changing opcode to opStDeclare,
; and changing the oNam for each formal parm and explicitly
; listing the TYPE.
;
;------------------------------------------------------------------------------
cProc SdPass3,<NEAR>,<si,di>
localW oNamParm
cBegin
test [prsCur.PRS_flags],FP_DEFINED
je J1_Sd3Exit ; don't count references to
; undefined procedures
test [txdCur.TXD_flags],FTX_TmpRef
je J1_Sd3Exit ;don't generate DECLARE for text tbl
; with no references in this module
test [txdCur.TXD_flags],FTX_TmpDecl
je EmitDecl ;don't generate DECLARE for prs which
J1_Sd3Exit:
jmp Sd3Exit ; already has a declare in this prs
EmitDecl:
mov ax,[prsCur.PRS_otxDef] ; ax = otx to opStSub/Function
mov si,ax ;ax = si = text offset
call OtxDefTypeCur ;fill ps.tEtCur with default types
; at definition of procedure
mov ax,opBol
call Emit16_AX
mov ax,opStDeclare
call Emit16_AX
lodsw ;si=si+2 (points to cntEos parm)
.errnz DCL_cntEos
call MoveWord ;move cntEos from es:[si] to ps.bdpDst
.errnz DCL_oPrs - 2
call MoveWord ;move oPrs from es:[si] to ps.bdpDst
.errnz DCL_atr - 4
call GetWord ;ax = procAtr from es:[si]
push ax ;save proc atr
.errnz DCLA_procType - 0300h
and ah,DCLA_procType / 100h ;ah = procType
cmp ah,PT_FUNCTION
jne NoProcType ;brif this is not a FUNCTION
.errnz DCLA_Explicit - 0080h
or al,al
js NoProcType ;brif it was explicitly typed
push [prsCur.PRS_ogNam]
call ONamOfOgNam ; ax = oNam of this prs
DbAssertRel ax,nz,0,CP,<txtsave.asm: ONamOfOgNam returned ax = 0>
cCall OTypOfONamDefault,<ax> ; ax = default oTyp (ax)
or al,DCLA_Explicit ;remember this was Explicitly typed
pop dx
mov ah,dh ;ax = new procAtr
push ax
;top of stack = procAtr
NoProcType:
call Emit16 ;emit proc atr operand
.errnz DCL_cParms - 6
call GetWord ;ax = cParms operand from es:[si]
mov di,ax ;di = cParms
call Emit16_AX ;emit cParms operand
inc di
Sd3ParmLoop:
dec di ;decrement parm count
jz Sd3Exit ;brif done with parms
.errnz DCLP_id - 0
call GetWord ;ax = parm's oNam or oVar
cCall oNamoVarRudeOrParse,<ax>;if we text not in rude map oVar
; to oNam
mov [oNamParm],ax
mov dx,[oMrsSaveDecl]
call ONamOtherOMrs ;ax = equivalent oNam in module dx
; (es is preserved)
je Sd3OmExit ;brif OM error (AX=0) to stop ForEach
call Emit16_AX ; oVar in SS_PARSE or SS_EXECUTE
.errnz DCLP_atr - 2 ;Formal parm attributes (PATR_xxx)
call GetWord ;ax = formal parm atr
push ax ;save parmAtr
.errnz PATR_asClause AND 0FFh
test ah,PATR_asClause / 100h
jne Sd3AsClause ;brif 'id AS xxx'
.errnz PATR_explicit AND 0FFh
or ah,PATR_explicit / 100h ;in DECLARE, force it to be explicit
Sd3AsClause:
call Emit16_AX
; if not SS_RUDE, it is oTyp of user type.
.errnz DCLP_oTyp - 4 ;Type of the formal parm
call GetWord ;ax = oNam for <user type> if > ET_MAX
pop bx ;bx = parmAtr
.errnz PATR_asClause AND 0FFh
.errnz PATR_explicit AND 0FFh
test bh,(PATR_explicit OR PATR_asClause) / 100h
jne NotImpl ;brif not implicitly typed
push [oNamParm]
call OTypOfONamDefault ;ax = default oTyp for parm (ax)
NotImpl:
cmp ax,ET_MAX
jbe NotUserTyp ;brif it is a primitive type
;Since declares are inserted before any type declarations, we cannot
;insert any references to a type name in the declare. SOOO, we
;just always use as ANY for synthetic declares with user defined
;types.
sub ax,ax ;ax = AS ANY
NotUserTyp:
call Emit16_AX
jmp SHORT Sd3ParmLoop
Sd3Exit:
mov ax,sp ;return TRUE for ForEachCP
Sd3OmExit:
cEnd
;-------------------------------------------------------------
; SaveDeclares - main code
;-------------------------------------------------------------
PUBLIC SaveDeclares ;for debugging only
cProc SaveDeclares,<NEAR>,<si>
cBegin
DbAssertRelB [txdCur.TXD_scanState],e,SS_RUDE,CP,<SaveDeclares:TxdCur not in SS_RUDE>
call PrsDeactivate ;make module's txt tbl active
mov ax,[grs.GRS_oMrsCur]
mov [oMrsSaveDecl],ax
test [mrsCur.MRS_flags2],FM2_Include ;is this an include mrs?
jne SdGoodExit ;don't insert decls into include
;mrs's. Re-Including could break
;a previously running program.
;For each prs in system which has a text table:
mov al,FE_PcodeMrs+FE_PcodePrs+FE_SaveRs
mov bx,CPOFFSET SdPass1 ;bx = adr of function to call
call ForEachCP
;For each text table in module being saved:
mov al,FE_CallMrs+FE_PcodePrs+FE_SaveRs
mov bx,CPOFFSET SdPass2 ;bx = adr of function to call
call ForEachCP
sub ax,ax
mov [ps.PS_bdpDst.BDP_cbLogical],ax
call SetDstPbCur
;For each prs in system which has a text table:
mov al,FE_PcodeMrs+FE_PcodePrs+FE_SaveRs
mov bx,CPOFFSET SdPass3 ;bx = adr of function to call
call ForEachCP
je SdExit ;brif out-of-memory
SetStartOtx si ;insert DECLAREs at start of module
call TxtInsert
je SdExit ;brif out-of-memory
SetStartOtx si ;otxInsert = start of text
mov bx,[ps.PS_bdpDst.BDP_cbLogical] ;pass cbInserted in bx
or bx,bx ;was any pcode inserted?
je NoDeclaresInserted ;brif not
or [mrsCur.MRS_flags2],FM2_Modified ;set modified bit so compiler
;will compile same source as QBI for
;MakeExe.
push bx ;save cbInsert
call DrawDebugScrFar ;update list windows for inserted text
pop bx ;restore bx=cbInsert
NoDeclaresInserted:
call TxtInsUpdate
SdGoodExit:
mov ax,sp ;return non-zero (not out-of-memory)
SdExit:
or ax,ax ;set condition codes
cEnd
;*************************************************************
; SaveAllDeclares
; Purpose:
; Generate synthetic DECLARE stmts for forward referenced
; SUBs and FUNCTIONs for every module in the system.
; Called by UI before MakeExe to ensure that Compiler
; will compile same source as interpreter. This solves
; the situation for a QB2/3 program is loaded and works
; correctly for QBI, but will not compile in BC. If we
; have inserted synthetic declares, or altered the pcode
; in some way, we need to make sure that the dirty bit
; gets set for the module.
; Entry:
; none.
; Exit:
; grs.fDirect = FALSE
; ax = 0 for no error, else QBI standard error code.
;*************************************************************
cProc SaveAllDeclares,<PUBLIC,FAR>
cBegin
;For each mrs in system which has a pcode text table:
mov al,FE_PcodeMrs+FE_CallMrs+FE_SaveRs
mov bx,CPOFFSET SaveDeclares ;bx = adr of function to call
call ForEachCP
mov ax,ER_OM ;default Out of memory error
je SaveAllDeclaresExit ;brif out-of-memory
sub ax,ax
SaveAllDeclaresExit:
cEnd
;*************************************************************
; ushort AsciiSave()
; Purpose:
; ASCII save the current module (with all its procedures)
;
; Exit:
; grs.fDirect = FALSE
; ps.bdpSrc is used
; ax = 0 if no error, else Standard BASIC error code (i.e. ER_xxx)
;
; Exceptions:
; Can cause runtime error (Out of memory, I/O errors)
;
;*************************************************************
cProc AsciiSave,<NEAR>,<si>
cBegin
call AlphaBuildORs ; build sorted list of all oRs's
or ax,ax ;set flags based on returned value
mov ax,ER_OM ;prepare to return Out-of-memory error
je AsDone ;brif error
call PrsDeactivate ;make module's txt table active
sub ax,ax
mov [fLsDynArrays],al ;default state is $STATIC
DbAssertRel ax,e,0,CP,<AsciiSave: ax!=0> ;SaveTxdCur needs ax=0
;ax = otx of 1st line in current text table to be written to file
AsLoop:
call SaveTxdCur ;save module/procedure text table
test [mrsCur.MRS_flags2],FM2_NoPcode ; document file?
jne NotModuleText ; brif so, never add blank line
cmp ax,2 ;was last line a blank one?
jbe NotModuleText ;brif so
call OutCrLf ;output a blank line so comment blocks
;are associated with correct text tbls
NotModuleText:
call OtxDefTypeEot ;fill ps.tEtCur with default types
; at end of module/procedure
call NextAlphaPrs ;activate next procedure in module
or ax,ax ;set flags
je AsDone ;brif no more procedures in module
SetStartOtx ax
test [prsCur.PRS_flags],FP_DEFINED
je ProcNotDefined ;brif no SUB/FUNCTION stmt
push [prsCur.PRS_otxDef] ;push offset to opStSub/opStFunction
call OtxBolOfOtx ;ax = text offset for 1st line of SUB
ProcNotDefined:
mov si,ax ;si = ax = otxProcDef
call SaveProcHdr ;save proc hdr(ax) (may contain some
; synthetically generated statements
jne AsDone ;brif error
xchg ax,si ;ax = otxProcDef
jmp SHORT AsLoop
;al = 0 if no error, else standard QBI error code
AsDone:
cEnd ;AsciiSave
;****************************************************************************
;SaveModName - save the name of the current module to the file
;
;Purpose:
; Used by Save to save the name of each module in a .MAK file.
;Entry:
; The .MAK file is open to current channel
; si points to static buffer holding name of the MAK file's directory.
; di points to static buffer which can be used to hold module's name
;Exceptions:
; Assumes caller called RtSetTrap to trap runtime errors.
;
;****************************************************************************
SaveModName PROC NEAR
mov ax,di ; pDest (parm to CopyOgNamPbNear)
mov bx,[mrsCur.MRS_ogNam] ; ogNam (parm to CopyOgNamPbNear)
call CopyOgNamPbNear ; copies name to buffer, returns
; ax = cbName
mov bx,di
add bx,ax ; add cbName
mov BYTE PTR [bx],0 ; zero terminate
;MakeRelativeFileSpec(szFilename, szMakDirectory)
cCall MakeRelativeFileSpec,<di,si> ;convert szFilename to relative
; path from szMakDirectory if possible
cCall CbSz,<di> ;ax = length of result path
;ax = size of line to output
mov bx,di ;bx points to start of line to output
call OutLine ;output the line
ret
SaveModName ENDP
;****************************************************************************
; FNotMainModule
; Purpose:
; Called via ForEachCP to see if there is any pcode module
; that is not the main module (i.e. to see if this is a
; multiple-module program.
; Exit:
; Return 0 in ax if current module is not main-module
; else return non-zero in ax
;
;****************************************************************************
FNotMainModule PROC NEAR
mov ax,[grs.GRS_oMrsCur]
cmp ax,[grs.GRS_oMrsMain]
mov ax,sp ;prepare to return non-zero
je FNotMainExit
sub ax,ax ;return 0 (not main module)
FNotMainExit:
ret
FNotMainModule ENDP
;*************************************************************
; SaveMakFile
; Purpose:
; Called by SaveFile to see if we're saving the main module
; of a multi-module program. If so, this creates <filename>.MAK
; file and writes the names of all modules in the program.
; Entry:
; mrsCur.ogNam is current module's filename
; Exit:
; ax = error code (0 if none), condition codes set
; Exceptions:
; assumes caller has called SetRtTrap to trap runtime errors
;
;*************************************************************
cProc SaveMakFile,<NEAR>,<si,di>
localV szDir,FILNAML
localV filenameNew,FILNAML ; size expected by runtime routines
; used for filename normalization
localV sdFilenameNew,<SIZE SD>
cBegin
mov ax,[grs.GRS_oMrsMain]
cmp ax,[grs.GRS_oMrsCur]
jne SmfGood ;brif this isn't main module
mov bx,si ;bx = psdFilename
lea si,[sdFilenameNew] ;si = &sdFilenameNew
lea di,[filenameNew]
mov [si.SD_pb],di ; set up string descr.
call MakFilename ;fill di with <moduleName>.MAK
jne SmfExit ;brif Bad File Name
mov al,FE_PcodeMrs+FE_CallMrs+FE_SaveRs
mov bx,CPOFFSET FNotMainModule ;bx = adr of function to call
call ForEachCP ;ax=0 if multi-module program
je MultiModules ;brif multi-module program is loaded
push di ;pass ptr to szFilenameNew
call DelFile ;delete filename.MAK
jmp SHORT SmfGood ;exit if not multi-module program
;Open filename in sdFilename (si) (.MAK file) and write all module names to it
MultiModules:
;If we could assume DOS 3.0 or greater, (we can't yet) we could set
;dx to (ACCESS_WRITE OR LOCK_BOTH) SHL 8 OR MD_SQO
mov dx,MD_SQO
call OpenChan ;al = error code (0 if no error)
jne SmfExit ;brif errors
;fill si with sz for directory of .MAK file
lea si,szDir ;si points to working static buffer
push di ;pass pbSrc (filenameNew)
push si ;pass pbDst (szDir)
mov bx,[sdFilenameNew.SD_cb]
push bx ;pass byte count
mov BYTE PTR [bx+si],0 ;0-terminate destination
call CopyBlk ;copy module name to static buffer
push si ;pass szDir
call FileSpec ;ax points beyond pathname
xchg bx,ax ;bx points beyond pathname
mov BYTE PTR [bx-1],0 ;0-terminate szDir
;Save the name of the Main Module first, so it will be loaded first
;si points to szDir
;di points to filenameNew (will be used for temp buffer)
call SaveModName ;write main module's relative path
call MrsDeactivate ;start writing other module names
SmLoop:
call NextMrsFile_All ;make next mrs active
inc ax ;test for UNDEFINED (end of mrs list)
je SmDone ;brif done with all mrs's
dec ax ;restore ax = module's name
cmp ax,[grs.GRS_oMrsMain]
je SmLoop ;brif this is MAIN mod (already output)
test [mrsCur.MRS_flags2],FM2_NoPcode OR FM2_Include
jne SmLoop ;skip document and include mrs's
call SaveModName
jmp SHORT SmLoop
SmDone:
push [grs.GRS_oMrsMain] ;we know the main module was active
call MrsActivateCP ; on entry - reactivate it on exit
call CloseChan ;close [chanCur]
SmfGood:
sub ax,ax
SmfExit:
or ax,ax ;set condition codes for caller
cEnd
;*************************************************************
; ushort SaveFile()
; Purpose:
; Open the specified file and save program to it.
;
; Entry:
; mrsCur.ogNam = filename to be saved.
; (the filename need not be 0-byte terminated)
; mrsCur.flags2 FM2_AsciiLoaded is TRUE for ASCII Save
; FOR EB: parm1 = mode for opening file
;
; Exit:
; ps.bdpSrc is used
; grs.fDirect = FALSE
; ax = 0 if no error, else Standard BASIC error code (i.e. ER_xxx)
;
;*************************************************************
cProc SaveFile,<PUBLIC,FAR,NODATA>,<si>
localV FileName,FILNAML
localV sdFileName,<SIZE SD>
cBegin
mov ax,-MSG_Saving ;display Saving msg in intense video
call StatusMsgCP ; to tell user we're loading
call AlphaORsFree ;release table of sorted oRs's
; (user interface may have chosen
; a new name for this mrs)
push [grs.GRS_oRsCur] ;save mrs/prs - restored on exit
call RtPushHandler ;save caller's runtime error handler
; could be called by LoadFile->NewStmt
; (NOTE: alters stack pointer)
SetfDirect al,FALSE ;turn off direct mode
mov ax,CPOFFSET SfDone ;if any runtime errors occur,
call RtSetTrap ;branch to SfDone with sp,di =
;current values
; doesn't have to be recompiled
call ModuleRudeEdit
call SaveDeclares ;generate synthetic DECLARE stmts
; for forward-referenced
mov ax,ER_OM ;default to OM error
je SfDone ;brif error
lea si,[sdFileName] ;cant use buffers here used for
lea ax,[FileName] ;load because we may need to save
mov [si.SD_pb],ax ;current module during fileopen
mov bx,[mrsCur.MRS_ogNam]
call CopyOgNamPbNear ; ax = number of chars copied
mov [si.SD_cb],ax
call SaveMakFile ;create <filename>.MAK if main
; program of multi-module program.
jne SfDone ;brif errors
;If we could assume DOS 3.0 or greater, (we can't yet) we could set
;dx to (ACCESS_WRITE OR LOCK_BOTH) SHL 8 OR MD_SQO
mov dx,MD_SQO
call OpenChan ;[chanCur] = channel #
jne SfDone ;brif error
DoAsciiSave:
call AsciiSave ;al = errCode
;We're done trying to write the file, now try to close it.
;Closing the file can cause I/O errors when close flushes the buffer.
;al = 0 if no error, else standard QBI error code
SfDone:
sub ah,ah ;ax = error code
SfDone2:
xchg si,ax ;si = return value
test [flagsTM],FTM_SaveProcHdr
je NoShCleanup ;brif SaveProcHdr was not in critical
; section.
call RelShBuf ;release temp text tbl used by
; SaveProcHdr
NoShCleanup:
call RtFreeTrap ;free previous trap address
mov ax,CPOFFSET SfGotErr ;if any runtime errors occur,
call RtSetTrap ;branch to SfGotErr with sp,bp,si,di
;set to current values
call CloseChan ;close file before kill
; (sets ChanCur = 0)
cCall RtFreeTrap ; release error handler
test si,7FFFh ; test low 15 bits for error code
je SfNoErr ;brif no error before close
xor ax, ax ; no error during close
;If we got an error during save, delete partially created file
SfGotErr:
test si, 7fffh ; do we already have an error
jnz SfTestDelFile ; brif so, use it
or si, ax ; else add in new error
; Only delete the file if we actually created and started to save
; a binary file. We don't want to delete an existing file if we
; got an error on or before the open, and we also don't want to
; delete a partially written ascii file.
SfTestDelFile:
or si,si ; got to BinarySave?
jns SfExit ; no, then don't kill the file
push di
mov ax,CPOFFSET SfKillErr ; trap & ignore any runtime errors
cCall RtSetTrap ; in KILL
sub sp,((FILNAML+SIZE SD+2)+1) AND 0FFFEh ;[3] create a fake sd
; on the stack
mov di,sp
add di,6 ; pnt to strt of where string will be
mov [di-2],di ; setup pb part of fake sd
mov ax,di ; parm to CopyOgNamPbNear
mov bx,[mrsCur.MRS_ogNam] ; parm to CopyOgNamPbNear
call CopyOgNamPbNear ; copy name onto stack, ax = cbName
sub di,4 ; di = pFakeSd
mov [di],ax ; set up cb part of fake sd
cCall B$KILL,<di> ; call rt to delete file
add sp,((FILNAML+SIZE SD+2)+1) AND 0FFFEh ;[3] restore stack ptr
SfKillErr: ; branched to if error during KILL
pop di
jmp SHORT SfExit
SfNoErr:
and [mrsCur.MRS_flags2],NOT (FM2_Modified or FM2_ReInclude)
and [mrsCur.MRS_flags3],NOT FM3_NotFound ;If the user told
;us to save the file, we have
;found it.
test [mrsCur.MRS_flags2],FM2_Include
je SfExit ;brif this is not an $INCLUDE file
or [flagsTm],FTM_reInclude ;re-parse all $INCLUDE lines in
;all modules before next RUN
SfExit:
and [flagsTM],NOT FTM_SaveProcHdr ;reset critical section flag
call RtPopHandler ;restore caller's runtime error handler
; (saved on stack by RtPushHandler)
call RsActivateCP ;restore caller's mrs/prs
call StatusMsg0CP ;tell user interface we're done saving
xchg ax,si ;restore ax = error code
and ah,7Fh ; clear BinarySave flag bit
cEnd
sEnd CP
end
|
src/vm/arm64/crthelpers.asm | omajid/dotnet-coreclr | 3 | 169648 | <gh_stars>1-10
; Licensed to the .NET Foundation under one or more agreements.
; The .NET Foundation licenses this file to you under the MIT license.
; See the LICENSE file in the project root for more information.
;; ==++==
;;
;;
;; ==--==
#include "ksarm64.h"
TEXTAREA
; Calls to JIT_MemSet is emitted by jit for initialization of large structs.
; We need to provide our own implementation of memset instead of using the ones in crt because crt implementation does not gurantee
; that aligned 8/4/2 - byte memory will be written atomically. This is required because members in a struct can be read atomically
; and their values should be written atomically.
;
;
;void JIT_MemSet(void *dst, int val, SIZE_T count)
;{
; uint64_t valEx = (unsigned char)val;
; valEx = valEx | valEx << 8;
; valEx = valEx | valEx << 16;
; valEx = valEx | valEx << 32;
;
; size_t dc_zva_size = 4ULL << DCZID_EL0.BS;
;
; uint64_t use_dc_zva = (val == 0) && !DCZID_EL0.p ? count / (2 * dc_zva_size) : 0; // ~Minimum size (assumes worst case alignment)
;
; // If not aligned then make it 8-byte aligned
; if(((uint64_t)dst&0xf) != 0)
; {
; // Calculate alignment we can do without exceeding count
; // Use math to avoid introducing more unpredictable branches
; // Due to inherent mod in lsr, ~7 is used instead of ~0 to handle count == 0
; // Note logic will fail is count >= (1 << 61). But this exceeds max physical memory for arm64
; uint8_t align = (dst & 0x7) & (~uint64_t(7) >> (countLeadingZeros(count) mod 64))
;
; if(align&0x1)
; {
; *(unit8_t*)dst = (unit8_t)valEx;
; dst = (unit8_t*)dst + 1;
; count-=1;
; }
;
; if(align&0x2)
; {
; *(unit16_t*)dst = (unit16_t)valEx;
; dst = (unit16_t*)dst + 1;
; count-=2;
; }
;
; if(align&0x4)
; {
; *(unit32_t*)dst = (unit32_t)valEx;
; dst = (unit32_t*)dst + 1;
; count-=4;
; }
; }
;
; if(use_dc_zva)
; {
; // If not aligned then make it aligned to dc_zva_size
; if(dst&0x8)
; {
; *(uint64_t*)dst = (uint64_t)valEx;
; dst = (uint64_t*)dst + 1;
; count-=8;
; }
;
; while(dst & (dc_zva_size - 1))
; {
; *(uint64_t*)dst = valEx;
; dst = (uint64_t*)dst + 1;
; *(uint64_t*)dst = valEx;
; dst = (uint64_t*)dst + 1;
; count-=16;
; }
;
; count -= dc_zva_size;
;
; while(count >= 0)
; {
; dc_zva(dst);
; dst = (uint8_t*)dst + dc_zva_size;
; count-=dc_zva_size;
; }
;
; count += dc_zva_size;
; }
;
; count-=16;
;
; while(count >= 0)
; {
; *(uint64_t*)dst = valEx;
; dst = (uint64_t*)dst + 1;
; *(uint64_t*)dst = valEx;
; dst = (uint64_t*)dst + 1;
; count-=16;
; }
;
; if(count & 8)
; {
; *(uint64_t*)dst = valEx;
; dst = (uint64_t*)dst + 1;
; }
;
; if(count & 4)
; {
; *(uint32_t*)dst = (uint32_t)valEx;
; dst = (uint32_t*)dst + 1;
; }
;
; if(count & 2)
; {
; *(uint16_t*)dst = (uint16_t)valEx;
; dst = (uint16_t*)dst + 1;
; }
;
; if(count & 1)
; {
; *(uint8_t*)dst = (uint8_t)valEx;
; }
;}
;
; Assembly code corresponding to above C++ method. JIT_MemSet can AV and clr exception personality routine needs to
; determine if the exception has taken place inside JIT_Memset in order to throw corresponding managed exception.
; Determining this is slow if the method were implemented as C++ method (using unwind info). In .asm file by adding JIT_MemSet_End
; marker it can be easily determined if exception happened in JIT_MemSet. Therefore, JIT_MemSet has been written in assembly instead of
; as C++ method.
LEAF_ENTRY JIT_MemSet
ands w8, w1, #0xff
mrs x3, DCZID_EL0 ; x3 = DCZID_EL0
mov x6, #4
lsr x11, x2, #3 ; x11 = count >> 3
orr w8, w8, w8, lsl #8
and x5, x3, #0xf ; x5 = dczid_el0.bs
cseleq x11, x11, xzr ; x11 = (val == 0) ? count >> 3 : 0
tst x3, (1 << 4)
orr w8, w8, w8, lsl #0x10
cseleq x11, x11, xzr ; x11 = (val == 0) && !DCZID_EL0.p ? count >> 3 : 0
ands x3, x0, #7 ; x3 = dst & 7
lsl x9, x6, x5 ; x9 = size
orr x8, x8, x8, lsl #0x20
lsr x11, x11, x5 ; x11 = (val == 0) && !DCZID_EL0.p ? count >> (3 + DCZID_EL0.bs) : 0
sub x10, x9, #1 ; x10 = mask
beq JIT_MemSet_0x80
movn x4, #7
clz x5, x2
lsr x4, x4, x5
and x3, x3, x4
tbz x3, #0, JIT_MemSet_0x2c
strb w8, [x0], #1
sub x2, x2, #1
JIT_MemSet_0x2c
tbz x3, #1, JIT_MemSet_0x5c
strh w8, [x0], #2
sub x2, x2, #2
JIT_MemSet_0x5c
tbz x3, #2, JIT_MemSet_0x80
str w8, [x0], #4
sub x2, x2, #4
JIT_MemSet_0x80
cbz x11, JIT_MemSet_0x9c
tbz x0, #3, JIT_MemSet_0x84
str x8, [x0], #8
sub x2, x2, #8
b JIT_MemSet_0x85
JIT_MemSet_0x84
stp x8, x8, [x0], #16
sub x2, x2, #16
JIT_MemSet_0x85
tst x0, x10
bne JIT_MemSet_0x84
b JIT_MemSet_0x8a
JIT_MemSet_0x88
dc zva, x0
add x0, x0, x9
JIT_MemSet_0x8a
subs x2, x2, x9
bge JIT_MemSet_0x88
JIT_MemSet_0x8c
add x2, x2, x9
JIT_MemSet_0x9c
b JIT_MemSet_0xa8
JIT_MemSet_0xa0
stp x8, x8, [x0], #16
JIT_MemSet_0xa8
subs x2, x2, #16
bge JIT_MemSet_0xa0
JIT_MemSet_0xb0
tbz x2, #3, JIT_MemSet_0xb4
str x8, [x0], #8
JIT_MemSet_0xb4
tbz x2, #2, JIT_MemSet_0xc8
str w8, [x0], #4
JIT_MemSet_0xc8
tbz x2, #1, JIT_MemSet_0xdc
strh w8, [x0], #2
JIT_MemSet_0xdc
tbz x2, #0, JIT_MemSet_0xe8
strb w8, [x0]
JIT_MemSet_0xe8
ret lr
LEAF_END
LEAF_ENTRY JIT_MemSet_End
nop
LEAF_END
; See comments above for JIT_MemSet
;void JIT_MemCpy(void *dst, const void *src, SIZE_T count)
;
; // If not aligned then make it 8-byte aligned
; if(((uintptr_t)dst&0x7) != 0)
; {
; // Calculate alignment we can do without exceeding count
; // Use math to avoid introducing more unpredictable branches
; // Due to inherent mod in lsr, ~7 is used instead of ~0 to handle count == 0
; // Note logic will fail if count >= (1 << 61). But this exceeds max physical memory for arm64
; uint8_t align = (dst & 0x7) & (~uint64_t(7) >> (countLeadingZeros(count) mod 64))
;
; if(align&0x1)
; {
; *(unit8_t*)dst = *(unit8_t*)src;
; dst = (unit8_t*)dst + 1;
; src = (unit8_t*)src + 1;
; count-=1;
; }
;
; if(align&0x2)
; {
; *(unit16_t*)dst = *(unit16_t*)src;
; dst = (unit16_t*)dst + 1;
; src = (unit16_t*)src + 1;
; count-=2;
; }
;
; if(align&0x4)
; {
; *(unit32_t*)dst = *(unit32_t*)src;
; dst = (unit32_t*)dst + 1;
; src = (unit32_t*)src + 1;
; count-=4;
; }
; }
;
; count-=16;
;
; while(count >= 0)
; {
; *(unit64_t*)dst = *(unit64_t*)src;
; dst = (unit64_t*)dst + 1;
; src = (unit64_t*)src + 1;
; *(unit64_t*)dst = *(unit64_t*)src;
; dst = (unit64_t*)dst + 1;
; src = (unit64_t*)src + 1;
; count-=16;
; }
;
; if(count & 8)
; {
; *(unit64_t*)dst = *(unit64_t*)src;
; dst = (unit64_t*)dst + 1;
; src = (unit64_t*)src + 1;
; }
;
; if(count & 4)
; {
; *(unit32_t*)dst = *(unit32_t*)src;
; dst = (unit32_t*)dst + 1;
; src = (unit32_t*)src + 1;
; }
;
; if(count & 2)
; {
; *(unit16_t*)dst = *(unit16_t*)src;
; dst = (unit16_t*)dst + 1;
; src = (unit16_t*)src + 1;
; }
;
; if(count & 1)
; {
; *(unit8_t*)dst = *(unit8_t*)src;
; }
;}
;
; Assembly code corresponding to above C++ method.
; See comments above for JIT_MemSet method
LEAF_ENTRY JIT_MemCpy
ands x3, x0, #7
movn x4, #7
clz x5, x2
beq JIT_MemCpy_0xa8
lsr x4, x4, x5
and x3, x3, x4
tbz x3, #0, JIT_MemCpy_0x2c
ldrsb w8, [x1], #1
strb w8, [x0], #1
sub x2, x2, #1
JIT_MemCpy_0x2c
tbz x3, #1, JIT_MemCpy_0x5c
ldrsh w8, [x1], #2
strh w8, [x0], #2
sub x2, x2, #2
JIT_MemCpy_0x5c
tbz x3, #2, JIT_MemCpy_0xa8
ldr w8, [x1], #4
str w8, [x0], #4
sub x2, x2, #4
b JIT_MemCpy_0xa8
JIT_MemCpy_0xa0
ldp x8, x9, [x1], #16
stp x8, x9, [x0], #16
JIT_MemCpy_0xa8
subs x2, x2, #16
bge JIT_MemCpy_0xa0
JIT_MemCpy_0xb0
tbz x2, #3, JIT_MemCpy_0xb4
ldr x8, [x1], #8
str x8, [x0], #8
JIT_MemCpy_0xb4
tbz x2, #2, JIT_MemCpy_0xc8
ldr w8, [x1], #4
str w8, [x0], #4
JIT_MemCpy_0xc8
tbz x2, #1, JIT_MemCpy_0xdc
ldrsh w8, [x1], #2
strh w8, [x0], #2
JIT_MemCpy_0xdc
tbz x2, #0, JIT_MemCpy_0xe8
ldrsb w8, [x1]
strb w8, [x0]
JIT_MemCpy_0xe8
ret lr
LEAF_END
LEAF_ENTRY JIT_MemCpy_End
nop
LEAF_END
; Must be at very end of file
END
|
src/gen-commands-database.adb | My-Colaborations/dynamo | 15 | 26413 | <gh_stars>10-100
-----------------------------------------------------------------------
-- gen-commands-database -- Database creation from application model
-- Copyright (C) 2011, 2012, 2016, 2017, 2018, 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Strings.Fixed;
with Ada.Directories;
with Ada.Exceptions;
with Util.Strings;
with Util.Files;
with Util.Log.Loggers;
with Util.Strings.Vectors;
with ADO.Drivers;
with ADO.Sessions.Sources;
with ADO.Schemas.Databases;
package body Gen.Commands.Database is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Gen.Commands.Database");
function Get_Schema_Path (Model_Dir : in String;
Model : in String;
Config : in ADO.Sessions.Sources.Data_Source) return String;
function Get_Schema_Path (Model_Dir : in String;
Model : in String;
Config : in ADO.Sessions.Sources.Data_Source) return String is
Driver : constant String := Config.Get_Driver;
Dir : constant String := Util.Files.Compose (Model_Dir, Driver);
begin
return Util.Files.Compose (Dir, "create-" & Model & "-" & Driver & ".sql");
end Get_Schema_Path;
-- ------------------------------
-- Execute the command with the arguments.
-- ------------------------------
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler) is
pragma Unreferenced (Cmd, Name);
procedure Create_Database (Model_Dir : in String;
Database : in String;
Username : in String;
Password : in String);
-- ------------------------------
-- Create the database, the user and the tables.
-- ------------------------------
procedure Create_Database (Model_Dir : in String;
Database : in String;
Username : in String;
Password : in String) is
Admin : ADO.Sessions.Sources.Data_Source;
Config : ADO.Sessions.Sources.Data_Source;
Messages : Util.Strings.Vectors.Vector;
begin
Config.Set_Connection (Database);
Admin := Config;
if Config.Get_Database = "" then
Generator.Error ("Invalid database connection: no database name specified");
return;
end if;
declare
Name : constant String := Generator.Get_Project_Name;
Path : constant String := Get_Schema_Path (Model_Dir, Name, Config);
begin
Log.Info ("Creating database tables using schema '{0}'", Path);
if not Ada.Directories.Exists (Path) then
Generator.Error ("SQL file '{0}' does not exist.", Path);
Generator.Error ("Please, run the following command: dynamo generate db");
return;
end if;
if Config.Get_Driver = "mysql" or Config.Get_Driver = "postgresql" then
if Config.Get_Property ("user") = "" then
Generator.Error ("Invalid database connection: missing user property");
return;
end if;
Admin.Set_Property ("user", Username);
Admin.Set_Property ("password", Password);
elsif Config.Get_Driver /= "sqlite" then
Generator.Error ("Database driver {0} is not supported.", Config.Get_Driver);
return;
end if;
Admin.Set_Database ("");
ADO.Schemas.Databases.Create_Database (Admin, Config, Path, Messages);
-- Report the messages
for Msg of Messages loop
Log.Error ("{0}", Msg);
end loop;
end;
-- Remember the database connection string.
Generator.Set_Project_Property ("database", Database);
Generator.Save_Project;
exception
when E : others =>
Generator.Error (Ada.Exceptions.Exception_Message (E));
end Create_Database;
Model : constant String := (if Args.Get_Count > 0 then Args.Get_Argument (1) else "");
Arg1 : constant String := (if Args.Get_Count > 1 then Args.Get_Argument (2) else "");
Arg2 : constant String := (if Args.Get_Count > 2 then Args.Get_Argument (3) else "");
Arg3 : constant String := (if Args.Get_Count > 3 then Args.Get_Argument (4) else "");
begin
Generator.Read_Project ("dynamo.xml");
-- Initialize the database drivers.
ADO.Drivers.Initialize (Generator.Get_Properties);
-- Check if a database is specified in the command line and use it.
if Ada.Strings.Fixed.Index (Arg1, "://") > 0 or Arg3'Length > 0 then
Create_Database (Model, Arg1, Arg2, Arg3);
else
declare
Database : constant String := Generator.Get_Project_Property ("database");
begin
-- Otherwise, get the database identification from dynamo.xml configuration.
if Ada.Strings.Fixed.Index (Database, "://") = 0 then
Generator.Error ("No database specified.");
return;
end if;
Create_Database (Model, Database, Arg1, Arg2);
end;
end if;
end Execute;
-- ------------------------------
-- Write the help associated with the command.
-- ------------------------------
procedure Help (Cmd : in out Command;
Name : in String;
Generator : in out Gen.Generator.Handler) is
pragma Unreferenced (Cmd, Name, Generator);
use Ada.Text_IO;
begin
Put_Line ("create-database: Creates the database");
Put_Line ("Usage: create-database MODEL [CONNECTION] ADMIN-USER [ADMIN-PASSWORD]");
New_Line;
Put_Line (" Create the database specified by the connection string.");
Put_Line (" The connection string has the form:");
Put_Line (" driver://host[:port]/database");
New_Line;
Put_Line (" The database must not exist. The user specified in the connection string");
Put_Line (" is granted the access to the new database.");
end Help;
end Gen.Commands.Database;
|
oeis/233/A233020.asm | neoneye/loda-programs | 11 | 93250 | ; A233020: Number of n X 2 0..3 arrays with no element x(i,j) adjacent to value 3-x(i,j) horizontally, vertically, diagonally or antidiagonally, and top left element zero.
; Submitted by <NAME>(s2)
; 3,15,81,435,2337,12555,67449,362355,1946673,10458075,56183721,301834755,1621541217,8711375595,46799960409,251422553235,1350712686993,7256408541435,38983468081161,209430157488675,1125117723605697,6044448933005835,32472480112240569,174451298427214515,937201452360553713,5034909858657197595,27048952198007095401,145314580707349872195,780670807932763551777,4193983201078517503275,22531257621258114619929,121044254508447608106195,650283787784754269770833,3493507447940666565066555
mov $3,1
lpb $0
sub $0,1
mul $1,2
mov $2,$3
mul $3,5
add $3,$1
mov $1,$2
lpe
mov $0,$3
mul $0,3
|
boot/kernel_entry.asm | 404Dev-404/lychee | 0 | 86718 | [bits 32]
global _start
[extern main]
_start:
call main
jmp $
|
Object/Optimized/kernel/Mouse.asm | collinsmichael/spartan | 16 | 247494 | <filename>Object/Optimized/kernel/Mouse.asm
; Listing generated by Microsoft (R) Optimizing Compiler Version 18.00.40629.0
TITLE C:\Users\cex123\Desktop\FYP\develop\spartan\Source\Kernel\Device\Drivers\Mouse.c
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB OLDNAMES
PUBLIC _MOUSE_SPEED
PUBLIC _MOUSE_FORMAT
PUBLIC _MOUSE_ASSIST
PUBLIC _MOUSE_WHEEL
PUBLIC _Mouse
PUBLIC _MOUSE_BUTTONS
EXTRN __imp__ipow:PROC
EXTRN __imp__pythagoras:PROC
COMM _ms:BYTE:060H
_velocity DD 01H DUP (?)
_MOUSE_WHEEL DD 01H DUP (?)
_BSS ENDS
_MOUSE_SPEED DD 042H
_imouse DD FLAT:_IMouse_Enable
DD FLAT:_IMouse_Flush
DD FLAT:_IMouse_GetSpeed
DD FLAT:_IMouse_SetSpeed
_MOUSE_FORMAT DD 02H
_MOUSE_ASSIST DD 01H
_Mouse DD FLAT:_imouse
_MOUSE_BUTTONS DD 03H
PUBLIC _IMouse_Enable
PUBLIC _IMouse_Flush
PUBLIC _MouseIsr
PUBLIC _TranslateMouse
PUBLIC _ActiveAssist
PUBLIC _IMouse_SetSpeed
PUBLIC _IMouse_GetSpeed
PUBLIC _EnableMouse
PUBLIC _InstallMouse
ALIGN 4
_mbuf DB 04H DUP (?)
_pipe DD 01H DUP (?)
_mpos DB 01H DUP (?)
_BSS ENDS
; Function compile flags: /Ogspy
; File c:\users\cex123\desktop\fyp\develop\spartan\source\kernel\device\drivers\mouse.c
_TEXT SEGMENT
_base$ = 8 ; size = 4
_size$ = 12 ; size = 4
_InstallMouse PROC
; 108 : pipe = (CPipeAsync*)base;
mov eax, DWORD PTR _base$[esp-4]
; 109 : Pipe->CreateAsync(pipe, null, null);
push 0
push 0
mov DWORD PTR _pipe, eax
push eax
mov eax, DWORD PTR _Pipe
call DWORD PTR [eax+4]
; 110 : stosd(&ms, 0, sizeof(ms)/4);
push 24 ; 00000018H
push 0
push OFFSET _ms
call _stosd
; 111 : return true;
xor eax, eax
add esp, 24 ; 00000018H
inc eax
; 112 : }
ret 0
_InstallMouse ENDP
_TEXT ENDS
; Function compile flags: /Ogspy
; File c:\users\cex123\desktop\fyp\develop\spartan\source\kernel\device\drivers\mouse.c
_TEXT SEGMENT
_base$ = 8 ; size = 4
_size$ = 12 ; size = 4
_EnableMouse PROC
; 144 : IMouse_Enable();
call _IMouse_Enable
; 145 : Device->Latch(IRQ_MOUSE, MouseIsr);
mov eax, DWORD PTR _Device
push OFFSET _MouseIsr
push 44 ; 0000002cH
call DWORD PTR [eax]
pop ecx
; 146 : return true;
xor eax, eax
pop ecx
inc eax
; 147 : }
ret 0
_EnableMouse ENDP
_TEXT ENDS
; Function compile flags: /Ogspy
; File c:\users\cex123\desktop\fyp\develop\spartan\source\kernel\device\drivers\mouse.c
_TEXT SEGMENT
_IMouse_GetSpeed PROC
; 23 : return MOUSE_SPEED;
mov eax, DWORD PTR _MOUSE_SPEED
; 24 : }
ret 0
_IMouse_GetSpeed ENDP
_TEXT ENDS
; Function compile flags: /Ogspy
; File c:\users\cex123\desktop\fyp\develop\spartan\source\kernel\device\drivers\mouse.c
_TEXT SEGMENT
_speed$ = 8 ; size = 4
_IMouse_SetSpeed PROC
; 27 : if (speed <= 5) return false;
mov eax, DWORD PTR _speed$[esp-4]
cmp eax, 5
jg SHORT $LN1@IMouse_Set
xor eax, eax
; 30 : }
ret 0
$LN1@IMouse_Set:
; 28 : MOUSE_SPEED = speed;
mov DWORD PTR _MOUSE_SPEED, eax
; 29 : return true;
xor eax, eax
inc eax
; 30 : }
ret 0
_IMouse_SetSpeed ENDP
_TEXT ENDS
; Function compile flags: /Ogspy
; File c:\users\cex123\desktop\fyp\develop\spartan\source\kernel\device\drivers\mouse.c
_TEXT SEGMENT
_log2$1$ = -4 ; size = 4
_ActiveAssist PROC
; _adj$ = ecx
; _opp$ = edx
; 32 : void ActiveAssist(int adj, int opp) {
push ecx
push ebx
push ebp
push esi
push edi
mov ebp, edx
mov ebx, ecx
; 33 : int hyp = pythagoras(adj, opp);
push ebp
push ebx
call DWORD PTR __imp__pythagoras
; 34 : int log2 = ipow(hyp,2);
mov esi, DWORD PTR __imp__ipow
mov edi, eax
push 2
push edi
call esi
; 35 : int log10 = ipow(hyp,10);
push 10 ; 0000000aH
push edi
mov DWORD PTR _log2$1$[esp+44], eax
call esi
mov ecx, eax
add esp, 24 ; 00000018H
; 36 : velocity = log10 ? velocity/2 + log2*hyp/log10 : 0;
xor esi, esi
test ecx, ecx
je SHORT $LN3@ActiveAssi
mov eax, DWORD PTR _log2$1$[esp+20]
imul eax, edi
cdq
idiv ecx
mov ecx, eax
mov eax, DWORD PTR _velocity
cdq
sub eax, edx
sar eax, 1
add ecx, eax
jmp SHORT $LN13@ActiveAssi
$LN3@ActiveAssi:
mov ecx, esi
$LN13@ActiveAssi:
mov DWORD PTR _velocity, ecx
; 37 : int speed = (velocity) ? MAX(MOUSE_SPEED*velocity/128, 1) : 0;
test ecx, ecx
je SHORT $LN7@ActiveAssi
mov eax, DWORD PTR _MOUSE_SPEED
imul eax, ecx
cdq
and edx, 127 ; 0000007fH
lea ecx, DWORD PTR [edx+eax]
sar ecx, 7
cmp ecx, 1
jg SHORT $LN8@ActiveAssi
xor ecx, ecx
inc ecx
jmp SHORT $LN8@ActiveAssi
$LN7@ActiveAssi:
mov ecx, esi
$LN8@ActiveAssi:
; 38 : ms[1].PosX = ms[2].PosX + (hyp ? speed*adj/hyp : 0);
test edi, edi
je SHORT $LN9@ActiveAssi
mov eax, ecx
imul eax, ebx
cdq
idiv edi
mov edx, eax
jmp SHORT $LN10@ActiveAssi
$LN9@ActiveAssi:
mov edx, esi
$LN10@ActiveAssi:
mov eax, DWORD PTR _ms+64
add eax, edx
mov DWORD PTR _ms+32, eax
; 39 : ms[1].PosY = ms[2].PosY + (hyp ? speed*opp/hyp : 0);
test edi, edi
je SHORT $LN11@ActiveAssi
imul ecx, ebp
mov eax, ecx
cdq
idiv edi
mov esi, eax
$LN11@ActiveAssi:
mov eax, DWORD PTR _ms+68
pop edi
add eax, esi
pop esi
pop ebp
mov DWORD PTR _ms+36, eax
pop ebx
; 40 : }
pop ecx
ret 0
_ActiveAssist ENDP
_TEXT ENDS
; Function compile flags: /Ogspy
; File c:\users\cex123\desktop\fyp\develop\spartan\source\kernel\device\drivers\mouse.c
_TEXT SEGMENT
_TranslateMouse PROC
; _adj$ = ecx
; _opp$ = edx
; 42 : void TranslateMouse(int adj, int opp) {
push ebx
push esi
push edi
; 43 : movsd(&ms[2], &ms[1], sizeof(CMouse)/4); // old = new
push 8
mov ebx, OFFSET _ms+32
mov esi, edx
push ebx
push OFFSET _ms+64
mov edi, ecx
call _movsd
; 44 : movsd(&ms[1], &ms[0], sizeof(CMouse)/4); // new = cur
push 8
push OFFSET _ms
push ebx
call _movsd
add esp, 24 ; 00000018H
; 45 : if (MOUSE_ASSIST) ActiveAssist(adj, opp);
cmp DWORD PTR _MOUSE_ASSIST, 0
je SHORT $LN2@TranslateM
mov edx, esi
mov ecx, edi
call _ActiveAssist
; 46 : else {
mov edi, DWORD PTR _ms+32
jmp SHORT $LN1@TranslateM
$LN2@TranslateM:
; 47 : ms[1].PosX = ms[2].PosX + adj;
add edi, DWORD PTR _ms+64
; 48 : ms[1].PosY = ms[2].PosY + opp;
mov eax, DWORD PTR _ms+68
add eax, esi
mov DWORD PTR _ms+32, edi
mov DWORD PTR _ms+36, eax
$LN1@TranslateM:
; 49 : }
; 50 : ms[1].PosX = MIN(MAX(0, ms[1].PosX), Vesa->ResX()-1);
xor esi, esi
test edi, edi
jns SHORT $LN5@TranslateM
mov edi, esi
$LN5@TranslateM:
mov eax, DWORD PTR _Vesa
call DWORD PTR [eax]
movzx eax, ax
dec eax
cmp edi, eax
jge SHORT $LN9@TranslateM
mov eax, DWORD PTR _ms+32
test eax, eax
jns SHORT $LN10@TranslateM
mov eax, esi
jmp SHORT $LN10@TranslateM
$LN9@TranslateM:
mov eax, DWORD PTR _Vesa
call DWORD PTR [eax]
movzx eax, ax
dec eax
$LN10@TranslateM:
; 51 : ms[1].PosY = MIN(MAX(0, ms[1].PosY), Vesa->ResY()-1);
mov edi, DWORD PTR _ms+36
mov DWORD PTR _ms+32, eax
test edi, edi
jns SHORT $LN11@TranslateM
mov edi, esi
$LN11@TranslateM:
mov eax, DWORD PTR _Vesa
call DWORD PTR [eax+4]
movzx eax, ax
dec eax
cmp edi, eax
jge SHORT $LN15@TranslateM
mov eax, DWORD PTR _ms+36
test eax, eax
js SHORT $LN16@TranslateM
mov esi, eax
jmp SHORT $LN16@TranslateM
$LN15@TranslateM:
mov eax, DWORD PTR _Vesa
call DWORD PTR [eax+4]
movzx esi, ax
dec esi
$LN16@TranslateM:
pop edi
mov DWORD PTR _ms+36, esi
pop esi
pop ebx
; 52 : }
ret 0
_TranslateMouse ENDP
_TEXT ENDS
; Function compile flags: /Ogspy
; File c:\users\cex123\desktop\fyp\develop\spartan\source\kernel\device\drivers\mouse.c
_TEXT SEGMENT
_err$ = 8 ; size = 4
_esp$ = 12 ; size = 4
_MouseIsr PROC
; 56 : //char round = (MOUSE_FORMAT & 4) ? 4 : 3;
; 57 : char round = MOUSE_BUTTONS + MOUSE_WHEEL;
mov al, BYTE PTR _MOUSE_BUTTONS
add al, BYTE PTR _MOUSE_WHEEL
push esi
; 58 :
; 59 : mbuf[mpos = mpos % round] = inb(PS2_DATA);
movsx esi, al
movzx eax, BYTE PTR _mpos
cdq
idiv esi
push 96 ; 00000060H
mov BYTE PTR _mpos, dl
call _inb
mov dl, BYTE PTR _mpos
pop ecx
movzx ecx, dl
; 60 :
; 61 : mpos = ++mpos % round;
inc dl
mov BYTE PTR _mbuf[ecx], al
movzx eax, dl
cdq
idiv esi
mov BYTE PTR _mpos, dl
; 62 : if (mpos == 0) {
test dl, dl
jne $LN1@MouseIsr
; 63 : int status = mbuf[0];
mov eax, DWORD PTR _mbuf
push ebx
movzx ebx, al
; 64 : if (status & 0x08) {
test bl, 8
je $LN11@MouseIsr
; 65 : int x = (unsigned char)mbuf[1];
; 66 : int y = (unsigned char)mbuf[2];
movzx esi, BYTE PTR _mbuf+2
push edi
; 67 : int w = (signed char)mbuf[3];
; 68 : if (MOUSE_WHEEL == 0) w = 0;
mov edi, DWORD PTR _MOUSE_WHEEL
neg edi
movzx edx, ah
movsx eax, BYTE PTR _mbuf+3
sbb edi, edi
and edi, eax
; 69 :
; 70 : if (MOUSE_FORMAT & 1) {
test BYTE PTR _MOUSE_FORMAT, 1
je SHORT $LN9@MouseIsr
; 71 : if (status & 0x10) x |= 0xFFFFFE00;
mov eax, -512 ; fffffe00H
test bl, 16 ; 00000010H
je SHORT $LN8@MouseIsr
or edx, eax
$LN8@MouseIsr:
; 72 : if (status & 0x20) y |= 0xFFFFFE00;
test bl, 32 ; 00000020H
je SHORT $LN7@MouseIsr
or esi, eax
$LN7@MouseIsr:
; 73 : if (status & 0x40) x |= 0x100;
mov eax, 256 ; 00000100H
test bl, 64 ; 00000040H
je SHORT $LN6@MouseIsr
or edx, eax
$LN6@MouseIsr:
; 74 : if (status & 0x80) y |= 0x100;
test bl, bl
jns SHORT $LN2@MouseIsr
; 75 : } else {
jmp SHORT $LN16@MouseIsr
$LN9@MouseIsr:
; 76 : if (status & 0x10) x |= 0xFFFFFF00;
mov eax, -256 ; ffffff00H
test bl, 16 ; 00000010H
je SHORT $LN3@MouseIsr
or edx, eax
$LN3@MouseIsr:
; 77 : if (status & 0x20) y |= 0xFFFFFF00;
test bl, 32 ; 00000020H
je SHORT $LN2@MouseIsr
$LN16@MouseIsr:
or esi, eax
$LN2@MouseIsr:
; 78 : }
; 79 :
; 80 : ms[0].DeltaX = (w) ? 0 : +x;
mov ecx, edi
; 81 : ms[0].DeltaY = (w) ? 0 : -y;
; 82 : ms[0].Wheel = w;
mov DWORD PTR _ms+8, edi
neg ecx
; 83 : ms[0].Left = (status & 1);
mov eax, ebx
sbb ecx, ecx
neg esi
not ecx
and ecx, edx
mov edx, edi
neg edx
mov DWORD PTR _ms+24, ecx
sbb edx, edx
and eax, 1
mov DWORD PTR _ms+12, eax
not edx
; 84 : ms[0].Right = (status & 2)/2;
mov eax, ebx
and edx, esi
sar eax, 1
; 85 : ms[0].Middle = (status & 4)/4;
sar ebx, 2
and eax, 1
and ebx, 1
mov DWORD PTR _ms+28, edx
mov DWORD PTR _ms+20, eax
mov DWORD PTR _ms+16, ebx
; 86 :
; 87 : /*
; 88 : Logger("\n [info] Mouse [");
; 89 : for (int i = 0; i < round; i++) Logger(" %X ", mbuf[i]);
; 90 : Logger(" ]\n");
; 91 : Logger("x=%d y=%d w=%d b=%s%s%s\n",
; 92 : ms[0].DeltaX,
; 93 : ms[0].DeltaY,
; 94 : ms[0].Wheel,
; 95 : ms[0].Left ? "L" : "-",
; 96 : ms[0].Middle ? "M" : "-",
; 97 : ms[0].Right ? "R" : "-");
; 98 : */
; 99 :
; 100 : TranslateMouse(ms[0].DeltaX, ms[0].DeltaY);
call _TranslateMouse
; 101 : Pipe->WriteAsync(pipe, (u8*)&ms[1], sizeof(CMouse));
mov eax, DWORD PTR _Pipe
push 32 ; 00000020H
push OFFSET _ms+32
push DWORD PTR _pipe
call DWORD PTR [eax+32]
add esp, 12 ; 0000000cH
pop edi
jmp SHORT $LN15@MouseIsr
$LN11@MouseIsr:
; 102 : } else ++mpos;
mov BYTE PTR _mpos, 1
$LN15@MouseIsr:
pop ebx
$LN1@MouseIsr:
; 103 : }
; 104 : return esp;
mov eax, DWORD PTR _esp$[esp]
pop esi
; 105 : }
ret 0
_MouseIsr ENDP
_TEXT ENDS
; Function compile flags: /Ogspy
; File c:\users\cex123\desktop\fyp\develop\spartan\source\kernel\device\drivers\mouse.c
_TEXT SEGMENT
_IMouse_Flush PROC
; 115 : inb(PS2_STATUS);
push 100 ; 00000064H
call _inb
; 116 : inb(PS2_DATA);
push 96 ; 00000060H
call _inb
; 117 : outb(PIC2_CMD, EOI);
push 32 ; 00000020H
push 160 ; 000000a0H
call _outb
; 118 : outb(PIC1_CMD, EOI);
push 32 ; 00000020H
push 32 ; 00000020H
call _outb
add esp, 24 ; 00000018H
; 119 : }
ret 0
_IMouse_Flush ENDP
_TEXT ENDS
; Function compile flags: /Ogspy
; File c:\users\cex123\desktop\fyp\develop\spartan\source\kernel\device\drivers\mouse.c
_TEXT SEGMENT
_IMouse_Enable PROC
; 122 : inb(PS2_STATUS);
push 100 ; 00000064H
call _inb
; 123 : inb(PS2_DATA);
push 96 ; 00000060H
call _inb
pop ecx
pop ecx
; 124 : Ps2Send(0xF2); Ps2Read();
mov cl, 242 ; 000000f2H
call _Ps2Send
call _Ps2Read
; 125 : char old = Ps2Read();
call _Ps2Read
; 126 :
; 127 : Ps2Send(0xF3); Ps2Read();
mov cl, 243 ; 000000f3H
call _Ps2Send
call _Ps2Read
; 128 : Ps2Send(0xC8); Ps2Read();
mov cl, 200 ; 000000c8H
call _Ps2Send
call _Ps2Read
; 129 : Ps2Send(0xF3); Ps2Read();
mov cl, 243 ; 000000f3H
call _Ps2Send
call _Ps2Read
; 130 : Ps2Send(0x64); Ps2Read();
mov cl, 100 ; 00000064H
call _Ps2Send
call _Ps2Read
; 131 : Ps2Send(0xF3); Ps2Read();
mov cl, 243 ; 000000f3H
call _Ps2Send
call _Ps2Read
; 132 : Ps2Send(0x50); Ps2Read();
mov cl, 80 ; 00000050H
call _Ps2Send
call _Ps2Read
; 133 : Ps2Send(0xF2); Ps2Read();
mov cl, 242 ; 000000f2H
call _Ps2Send
call _Ps2Read
; 134 : if (Ps2Read() == 3) MOUSE_WHEEL = 1;
call _Ps2Read
cmp al, 3
jne SHORT $LN1@IMouse_Ena
mov DWORD PTR _MOUSE_WHEEL, 1
$LN1@IMouse_Ena:
; 135 : if (MOUSE_WHEEL) Logger(" Mouse Wheel Detected\n");
; 136 : MOUSE_BUTTONS = 3;
; 137 :
; 138 : ms[2].PosX = ms[1].PosX = ms[0].PosX = Vesa->ResX()/2;
mov eax, DWORD PTR _Vesa
mov DWORD PTR _MOUSE_BUTTONS, 3
call DWORD PTR [eax]
movzx ecx, ax
shr ecx, 1
mov DWORD PTR _ms, ecx
mov DWORD PTR _ms+32, ecx
mov DWORD PTR _ms+64, ecx
; 139 : ms[2].PosY = ms[1].PosY = ms[0].PosY = Vesa->ResY()/2;
mov ecx, DWORD PTR _Vesa
call DWORD PTR [ecx+4]
movzx ecx, ax
; 140 : return true;
xor eax, eax
shr ecx, 1
inc eax
mov DWORD PTR _ms+4, ecx
mov DWORD PTR _ms+36, ecx
mov DWORD PTR _ms+68, ecx
; 141 : }
ret 0
_IMouse_Enable ENDP
_TEXT ENDS
END
|
compiler/ti-cgt-arm_18.12.4.LTS/lib/src/fd_add32.asm | JosiahCraw/TI-Arm-Docker | 0 | 81098 | ;******************************************************************************
;* FD_ADD32.ASM - 32 BIT STATE - *
;* *
;* Copyright (c) 1996 Texas Instruments Incorporated *
;* http://www.ti.com/ *
;* *
;* 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 Texas Instruments Incorporated 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 *
;* OWNER 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. *
;* *
;******************************************************************************
;*****************************************************************************
;* FD_ADD/FD_SUB - ADD / SUBTRACT TWO IEEE 754 FORMAT DOUBLE PRECISION FLOATING
;* POINT NUMBERS.
;*****************************************************************************
;*
;* o INPUT OP1 IS IN r0:r1
;* o INPUT OP2 IS IN r2:r3
;* o RESULT IS RETURNED IN r0:r1
;* o INPUT OP2 IN r2:r3 IS PRESERVED
;*
;* o SUBTRACTION, OP1 - OP2, IS IMPLEMENTED WITH ADDITION, OP1 + (-OP2)
;* o SIGNALLING NOT-A-NUMBER (SNaN) AND QUIET NOT-A-NUMBER (QNaN)
;* ARE TREATED AS INFINITY
;* o OVERFLOW RETURNS +/- INFINITY
;* (0x7ff00000:00000000) or (0xfff00000:00000000)
;* o DENORMALIZED NUMBERS ARE TREATED AS UNDERFLOWS
;* o UNDERFLOW RETURNS ZERO (0x00000000:00000000)
;* o ROUNDING MODE: ROUND TO NEAREST (TIE TO EVEN)
;*
;* o IF OPERATION INVOLVES INFINITY AS AN INPUT, THE FOLLOWING SUMMARIZES
;* THE RESULT:
;* +----------+----------+----------+
;* ADDITION + OP2 !INF | OP2 -INF + OP2 +INF +
;* +----------+==========+==========+==========+
;* + OP1 !INF + - | -INF + +INF +
;* +----------+----------+----------+----------+
;* + OP1 -INF + -INF | -INF + -INF +
;* +----------+----------+----------+----------+
;* + OP1 +INF + +INF | +INF + +INF +
;* +----------+----------+----------+----------+
;*
;* +----------+----------+----------+
;* SUBTRACTION + OP2 !INF | OP2 -INF + OP2 +INF +
;* +----------+==========+==========+==========+
;* + OP1 !INF + - | +INF + -INF +
;* +----------+----------+----------+----------+
;* + OP1 -INF + -INF | -INF + -INF +
;* +----------+----------+----------+----------+
;* + OP1 +INF + +INF | +INF + +INF +
;* +----------+----------+----------+----------+
;*
;****************************************************************************
;*
;* +------------------------------------------------------------------+
;* | DOUBLE PRECISION FLOATING POINT FORMAT |
;* | 64-bit representation |
;* | 31 30 20 19 0 |
;* | +-+----------+---------------------+ |
;* | |S| E | M1 | |
;* | +-+----------+---------------------+ |
;* | |
;* | 31 0 |
;* | +----------------------------------+ |
;* | | M2 | |
;* | +----------------------------------+ |
;* | |
;* | <S> SIGN FIELD : 0 - POSITIVE VALUE |
;* | 1 - NEGATIVE VALUE |
;* | |
;* | <E> EXPONENT FIELD: 0000000000 - ZERO IFF M == 0 |
;* | 0000000001..1111111110 - EXPONENT VALUE(1023 BIAS) |
;* | 1111111111 - INFINITY |
;* | |
;* | <M1:M2> MANTISSA FIELDS: FRACTIONAL MAGNITUDE WITH IMPLIED 1 |
;* +------------------------------------------------------------------+
;*
;****************************************************************************
.arm
.if __TI_EABI_ASSEMBLER ; ASSIGN EXTERNAL NAMES BASED ON
.asg __aeabi_dadd, __TI_FD_ADD ; RTS BEING BUILT
.asg __aeabi_dsub, __TI_FD_SUB
.else
.clink
.asg FD_ADD, __TI_FD_ADD
.asg FD_SUB, __TI_FD_SUB
.endif
.global __TI_FD_ADD
.global __TI_FD_SUB
.if .TMS470_BIG_DOUBLE
rp1_hi .set r0 ; High word of regpair 1
rp1_lo .set r1 ; Low word of regpair 1
rp2_hi .set r2 ; High word of regpair 2
rp2_lo .set r3 ; Low word of regpair 2
.else
rp1_hi .set r1 ; High word of regpair 1
rp1_lo .set r0 ; Low word of regpair 1
rp2_hi .set r3 ; High word of regpair 2
rp2_lo .set r2 ; Low word of regpair 2
.endif
op1m1 .set r4
op1m2 .set r5
op1e .set r6
op2m1 .set r7
op2m2 .set r8
op2e .set r9
shift .set r10
sticky .set r11
tmp .set lr
.if __TI_ARM9ABI_ASSEMBLER | __TI_EABI_ASSEMBLER
.armfunc __TI_FD_SUB, __TI_FD_ADD
.endif
__TI_FD_SUB: .asmfunc stack_usage(40)
STMFD sp!, {r2-r11, lr}
EOR rp2_hi, rp2_hi, #0x80000000 ; NEGATE SECOND OPERAND
B _start
__TI_FD_ADD:
STMFD sp!, {r2-r11, lr}
_start: MOV op2m1, rp2_hi, LSL #12 ; BUILD INPUT #2 MANTISSA
MOV op2m1, op2m1, LSR #3
ORR op2m1, op2m1, rp2_lo, LSR #23
MOV op2m2, rp2_lo, LSL #9
MOV op2e, rp2_hi, LSL #1 ; BUILD INPUT #2 EXPONENT
MOVS op2e, op2e, LSR #21
BNE $1
ORR tmp, op2m1, op2m2 ; IF DENORMALIZED NUMBER (op2m != 0 AND
MOVNE rp1_hi, #0 ; op2e == 0), THEN UNDERFLOW
MOVNE rp1_lo, #0 ;
.if __TI_ARM7ABI_ASSEMBLER | __TI_ARM9ABI_ASSEMBLER | !__TI_TMS470_V4__
LDMFD sp!, {r2-r11, pc} ; ELSE IT IS ZERO SO RETURN INPUT #1
.else
LDMFD sp!, {r2-r11, lr}
BX lr
.endif
$1: ORR op2m1, op2m1, #0x20000000 ; SET IMPLIED ONE IN MANTISSA
MOV shift, #0x700 ; INITIALIZE shift WITH 0x7FF
ADD shift, shift, #0xFF
CMP op2e, shift ; IF op2e==0x7FF, THEN OVERFLOW
BNE $2
MOV rp1_lo, #0
MOV rp1_hi, rp2_hi, LSR #20
MOV rp1_hi, rp1_hi, LSL #20
.if __TI_ARM7ABI_ASSEMBLER | __TI_ARM9ABI_ASSEMBLER | !__TI_TMS470_V4__
LDMFD sp!, {r2-r11, pc}
.else
LDMFD sp!, {r2-r11, lr}
BX lr
.endif
$2: CMP rp2_hi, #0
BPL $3 ; IF INPUT #2 IS NEGATIVE,
RSBS op2m2, op2m2, #0 ; THEN NEGATE THE MANTISSA
RSC op2m1, op2m1, #0
$3: MOV op1m1, rp1_hi, LSL #12 ; BUILD INPUT #1 MANTISSA
MOV op1m1, op1m1, LSR #3
ORR op1m1, op1m1, rp1_lo, LSR #23
MOV op1m2, rp1_lo, LSL #9
MOV op1e, rp1_hi, LSL #1 ; BUILD INPUT #1 EXPONENT
MOVS op1e, op1e, LSR #21
BNE $4
ORR tmp, op1m1, op1m2 ; IF DENORMALIZED NUMBER
MOVNE rp1_hi, #0 ; (op1m != 0 AND op1e == 0),
MOVNE rp1_lo, #0 ; THEN UNDERFLOW
MOVEQ rp1_hi, rp2_hi ; ELSE IT IS ZERO SO RETURN
MOVEQ rp1_lo, rp2_lo ; INPUT #2
.if __TI_ARM7ABI_ASSEMBLER | __TI_ARM9ABI_ASSEMBLER | !__TI_TMS470_V4__
LDMFD sp!, {r2-r11, pc}
.else
LDMFD sp!, {r2-r11, lr}
BX lr
.endif
$4: ORR op1m1, op1m1, #0x20000000 ; SET IMPLIED ONE IN MANTISSA
CMP op1e, shift ; IF op1e==0x7FF, THEN OVERFLOW
BNE $5
MOV rp1_lo, #0
MOV rp1_hi, rp1_hi, LSR #20
MOV rp1_hi, rp1_hi, LSL #20
.if __TI_ARM7ABI_ASSEMBLER | __TI_ARM9ABI_ASSEMBLER | !__TI_TMS470_V4__
LDMFD sp!, {r2-r11, pc}
.else
LDMFD sp!, {r2-r11, lr}
BX lr
.endif
$5: CMP rp1_hi, #0
BPL $6 ; IF INPUT #1 IS NEGATIVE,
RSBS op1m2, op1m2, #0 ; THEN NEGATE THE MANTISSA
RSC op1m1, op1m1, #0
$6: SUBS shift, op1e, op2e ; GET THE SHIFT AMOUNT
BPL $7
MOV tmp, op1m1 ; IF THE SHIFT AMOUNT IS NEGATIVE, THEN
MOV op1m1, op2m1 ; SWAP THE TWO MANTISSA SO THAT op1m
MOV op2m1, tmp ; CONTAINS THE LARGER VALUE,
MOV tmp, op1m2
MOV op1m2, op2m2
MOV op2m2, tmp
RSB shift, shift, #0 ; AND NEGATE THE SHIFT AMOUNT,
MOV op1e, op2e ; AND ENSURE THE LARGER EXP. IS IN op1e
$7: CMP shift, #54 ; IF THE SECOND MANTISSA IS SIGNIFICANT,
MOVPL sticky, #0
BPL no_add
CMP shift, #0 ; ADJUST THE SECOND MANTISSA, BASED
MOVEQ sticky, #0
BEQ no_sft ; UPON ITS EXPONENT.
RSB tmp, shift, #57 ; CALCULATE STICKY BIT
SUBS op2e, tmp, #32 ; PERFORM LONG LONG LSL BY tmp
MOVCS sticky, op2m2, LSL op2e ; WE DON'T CARE ABOUT THE ACTUAL RESULT
MOVCC sticky, op2m1, LSL tmp
ORRCC sticky, sticky, op2m2 ; ALL OF OP2M2 IS INCLUDED IN STICKY
RSBS tmp, shift, #32 ; tmp := 32 - shift
MOV tmp, op2m1, LSL tmp ; set tmp to op2m1 shifted left by 32 - _shift_ places
MOVCC tmp, op2m1
MOV op2m1, op2m1, ASR shift ;
MOV op2m2, op2m2, LSR shift ;
SUBCC shift, shift, #32 ; used for overflow
MOVCC op2m2, tmp, ASR shift
ADDCS op2m2, op2m2, tmp ; op2m2 is zero everywhere tmp isn't and vice versa
no_sft: ADDS op1m2, op1m2, op2m2 ; ADD IT TO THE FIRST MANTISSA
ADCS op1m1, op1m1, op2m1 ;
no_add: ORRS tmp, op1m1, op1m2 ;
MOVEQ rp1_hi, #0 ; IF THE RESULT IS ZERO,
MOVEQ rp1_lo, #0 ;
.if __TI_ARM7ABI_ASSEMBLER | __TI_ARM9ABI_ASSEMBLER | !__TI_TMS470_V4__
LDMEQFD sp!, {r2-r11, pc} ; THEN UNDERFLOW
.else
LDMEQFD sp!, {r2-r11, lr}
BXEQ lr
.endif
CMP op1m1, #0 ;
MOVPL tmp, #0x0 ; IF THE RESULT IS POSITIVE, NOTE SIGN
BPL nloop ;
MOV tmp, #0x1 ; IF THE RESULT IS NEGATIVE, THEN
RSBS op1m2, op1m2, #0x0 ; NOTE THE SIGN AND
RSC op1m1, op1m1, #0x0 ; NEGATE THE RESULT
nloop: MOVS op1m2, op1m2, LSL #1 ; NORMALIZE THE RESULTING MANTISSA
ADCS op1m1, op1m1, op1m1 ;
SUB op1e, op1e, #1 ; ADJUSTING THE EXPONENT AS NECESSARY
BPL nloop ;
ANDS shift, op1m2, #0x400 ; GUARD BIT
BEQ no_round ; IF GUARD BIT 0, DO NOT ROUND
AND op2e, op1m2, #0x100 ; IF RESULT REQUIRED NORMALIZATION
ORR sticky, sticky, op2e ; BIT 26 MUST BE ADDED TO STICKY
ADDS op1m2, op1m2, #0x400 ; ROUND THE MANTISSA TO THE NEAREST
ADCS op1m1, op1m1, #0 ;
ADDCS op1e, op1e, #1 ; ADJUST EXPONENT IF AN OVERFLOW OCCURS
BCS ovfl ; IF OVERFLOW, RESULT IS ALREADY EVEN
AND op2e, op1m2, #0x200 ; GET ROUND BIT
ORRS sticky, sticky, op2e ; (ROUND + STICKY)
; IF (ROUND + STICKY) == 0
BICEQ op1m2, op1m2, #0x800 ; WE HAVE A TIE, ROUND TO EVEN
no_round:
BIC op1m2, op1m2, #0x700 ; CLEAR GUARD, ROUND, AND STICKY BITS
MOVS op1m2, op1m2, LSL #1 ; REMOVE THE IMPLIED ONE
ADC op1m1, op1m1, op1m1 ;
ovfl: ADDS op1e, op1e, #2 ; NORMALIZE THE EXPONENT
MOVLE rp1_hi, #0 ; CHECK FOR UNDERFLOW
MOVLE rp1_lo, #0 ;
.if __TI_ARM7ABI_ASSEMBLER | __TI_ARM9ABI_ASSEMBLER | !__TI_TMS470_V4__
LDMLEFD sp!, {r2-r11, pc} ;
.else
LDMLEFD sp!, {r2-r11, lr}
BXLE lr
.endif
MOV shift, #0x700 ;
ADD shift, shift, #0xFF ;
CMP op1e, shift ; CHECK FOR OVERFLOW
BCC $9
MOV rp1_lo, #0 ;
AND rp2_hi, rp2_hi, #0x80000000
MOV rp1_hi, #0xFF
MOV rp1_hi, rp1_hi, LSL #3
ADD rp1_hi, rp1_hi, #7
MOV rp1_hi, rp1_hi, LSL #20
ORR rp1_hi, rp1_hi, rp2_hi
.if __TI_ARM7ABI_ASSEMBLER | __TI_ARM9ABI_ASSEMBLER | !__TI_TMS470_V4__
LDMFD sp!, {r2-r11, pc}
.else
LDMFD sp!, {r2-r11, lr}
BX lr
.endif
$9: MOV op2m1, op1m1, LSL #20 ; REPACK THE MANTISSA INTO
ORR rp1_lo, op2m1, op1m2, LSR #12 ; rp1_hi:rp1_lo
MOV rp1_hi, op1m1, LSR #12 ;
ORR rp1_hi, rp1_hi, op1e, LSL #20 ; REPACK THE EXPONENT INTO rp1_hi
ORR rp1_hi, rp1_hi, tmp, LSL #31 ; REPACK THE SIGN INTO rp1_hi
.if __TI_ARM7ABI_ASSEMBLER | __TI_ARM9ABI_ASSEMBLER | !__TI_TMS470_V4__
LDMFD sp!, {r2-r11, pc}
.else
LDMFD sp!, {r2-r11, lr}
BX lr
.endif
.endasmfunc
.end
|
firmware/coreboot/3rdparty/libgfxinit/common/skylake/hw-gfx-gma-connectors-ddi-buffers.adb | fabiojna02/OpenCellular | 1 | 3850 | <reponame>fabiojna02/OpenCellular<gh_stars>1-10
--
-- Copyright (C) 2017 secunet Security Networks AG
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
with HW.GFX.GMA.Config;
package body HW.GFX.GMA.Connectors.DDI.Buffers
is
subtype Skylake_HDMI_Range is DDI_HDMI_Buf_Trans_Range range 0 .. 10;
type HDMI_Buf_Trans is record
Trans1 : Word32;
Trans2 : Word32;
end record;
type HDMI_Buf_Trans_Array is array (Skylake_HDMI_Range) of HDMI_Buf_Trans;
----------------------------------------------------------------------------
Skylake_Trans_EDP : constant Buf_Trans_Array :=
(16#0000_0018#, 16#0000_00a8#,
16#0000_4013#, 16#0000_00a9#,
16#0000_7011#, 16#0000_00a2#,
16#0000_9010#, 16#0000_009c#,
16#0000_0018#, 16#0000_00a9#,
16#0000_6013#, 16#0000_00a2#,
16#0000_7011#, 16#0000_00a6#,
16#0000_0018#, 16#0000_00ab#,
16#0000_7013#, 16#0000_009f#,
16#0000_0018#, 16#0000_00df#);
Skylake_U_Trans_EDP : constant Buf_Trans_Array :=
(16#0000_0018#, 16#0000_00a8#,
16#0000_4013#, 16#0000_00a9#,
16#0000_7011#, 16#0000_00a2#,
16#0000_9010#, 16#0000_009c#,
16#0000_0018#, 16#0000_00a9#,
16#0000_6013#, 16#0000_00a2#,
16#0000_7011#, 16#0000_00a6#,
16#0000_2016#, 16#0000_00ab#,
16#0000_5013#, 16#0000_009f#,
16#0000_0018#, 16#0000_00df#);
Skylake_Trans_DP : constant Buf_Trans_Array :=
(16#0000_2016#, 16#0000_00a0#,
16#0000_5012#, 16#0000_009b#,
16#0000_7011#, 16#0000_0088#,
16#8000_9010#, 16#0000_00c0#,
16#0000_2016#, 16#0000_009b#,
16#0000_5012#, 16#0000_0088#,
16#8000_7011#, 16#0000_00c0#,
16#0000_2016#, 16#0000_00df#,
16#8000_5012#, 16#0000_00c0#,
others => 0);
Skylake_U_Trans_DP : constant Buf_Trans_Array :=
(16#0000_201b#, 16#0000_00a2#,
16#0000_5012#, 16#0000_0088#,
16#8000_7011#, 16#0000_00cd#,
16#8000_9010#, 16#0000_00c0#,
16#0000_201b#, 16#0000_009d#,
16#8000_5012#, 16#0000_00c0#,
16#8000_7011#, 16#0000_00c0#,
16#0000_2016#, 16#0000_0088#,
16#8000_5012#, 16#0000_00c0#,
others => 0);
Skylake_Trans_HDMI : constant HDMI_Buf_Trans_Array :=
((16#0000_0018#, 16#0000_00ac#),
(16#0000_5012#, 16#0000_009d#),
(16#0000_7011#, 16#0000_0088#),
(16#0000_0018#, 16#0000_00a1#),
(16#0000_0018#, 16#0000_0098#),
(16#0000_4013#, 16#0000_0088#),
(16#8000_6012#, 16#0000_00cd#),
(16#0000_0018#, 16#0000_00df#),
(16#8000_3015#, 16#0000_00cd#),
(16#8000_3015#, 16#0000_00c0#),
(16#8000_0018#, 16#0000_00c0#));
----------------------------------------------------------------------------
procedure Translations (Trans : out Buf_Trans_Array; Port : Digital_Port)
is
DDIA_Low_Voltage_Swing : constant Boolean :=
Config.EDP_Low_Voltage_Swing and then Port = DIGI_A;
HDMI_Trans : constant Skylake_HDMI_Range :=
(if Config.DDI_HDMI_Buffer_Translation in Skylake_HDMI_Range
then Config.DDI_HDMI_Buffer_Translation
else Config.Default_DDI_HDMI_Buffer_Translation);
begin
Trans :=
(case Config.CPU_Var is
when Normal =>
(if DDIA_Low_Voltage_Swing
then Skylake_Trans_EDP
else Skylake_Trans_DP),
when ULT =>
(if DDIA_Low_Voltage_Swing
then Skylake_U_Trans_EDP
else Skylake_U_Trans_DP));
if not DDIA_Low_Voltage_Swing then
Trans (18) := Skylake_Trans_HDMI (HDMI_Trans).Trans1;
Trans (19) := Skylake_Trans_HDMI (HDMI_Trans).Trans2;
end if;
end Translations;
end HW.GFX.GMA.Connectors.DDI.Buffers;
|
door35_smark/src/boot/entry.asm | CZHSoft/LT_8130 | 1 | 164047 | <reponame>CZHSoft/LT_8130
;===============Define Code Segment===========================================
CODE_RESET SEGMENT PARA PUBLIC 'ENTRY'
CODE_RESET ENDS
extrn boot : far
CODE_RESET SEGMENT PARA PUBLIC 'ENTRY'
ASSUME CS:CODE_RESET
public _Entrypoint
_Entrypoint:
JMP FAR PTR boot
CODE_RESET ENDS
;===============Program End===================================================
END _ENTRYPOINT
END |
thirdparty/adasdl/thin/adasdl/AdaSDL_mixer/playwave_sprogs.adb | Lucretia/old_nehe_ada95 | 0 | 7091 |
--
-- PLAYWAVE: Port to the Ada programming language of a test application for the
-- the SDL mixer library.
--
-- The original code was written in C by <NAME> http://www.libsdl.org.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- Ada code written by:
-- <NAME> --
-- Ponta Delgada - Azores - Portugal --
-- E-mail: <EMAIL> --
-- http://www.adapower.net/~avargas --
with GNAT.OS_Lib;
with Ada.Text_IO; use Ada.Text_IO;
with SDL.Timer;
package body PlayWave_Sprogs is
package T renames SDL.Timer;
-- ======================================
procedure CleanUp is
begin
if wave /= Mix.null_Chunk_ptr then
Mix.FreeChunk (wave);
wave := Mix.null_Chunk_ptr;
end if;
if audio_open then
Mix.CloseAudio;
audio_open := False;
end if;
SDL.SDL_Quit;
end CleanUp;
-- ======================================
procedure Usage (argv0 : US.Unbounded_String) is
begin
Put_Line ("Usage: " & US.To_String (argv0)
& " [-8] [-r rate] [-l] [-m] <wavefile>");
end Usage;
-- ======================================
procedure the_exit (number : C.int) is
begin
GNAT.OS_Lib.OS_Exit (Integer (number));
end the_exit;
-- ======================================
end PlayWave_Sprogs;
|
Stm8Invaders/asm/main.asm | peteri/Invaders | 0 | 101928 | <reponame>peteri/Invaders<filename>Stm8Invaders/asm/main.asm
stm8/
.tab 0,8,16,60
#include "mapping.inc"
#include "stm8l152c6.inc"
#include "boardsetup.inc"
#include "variables.inc"
#include "videosync.inc"
#include "linerender.inc"
#include "constants.inc"
#include "attractscreen.inc"
#include "waittask.inc"
#include "screenhelper.inc"
#include "timerobject.inc"
#include "sprite.inc"
#include "aliens.inc"
#include "player.inc"
#include "alienshot.inc"
#include "playerbase.inc"
#include "playershot.inc"
stack_start.w EQU $stack_segment_start
stack_end.w EQU $stack_segment_end
segment 'ram0'
tim3cntr.w ds.w 1
segment 'ram1'
shothit_alien_index ds.b 1
shothit_col_x ds.b 1
frame_counter ds.w 1
pause_button_timer ds.b 1
segment 'rom'
main.l
; initialize SP
ldw X,#stack_end
ldw SP,X
; clear stack
ldw X,#stack_start
clear_stack.l
clr (X)
incw X
cpw X,#stack_end
jrule clear_stack
; we have clear stack
; time for more setup
call init_cpu ; speed up the cpu and turn on stuff
call clear_memory ; Clear rest of ram
call power_on_reset ; setup the game
call init_gpio ; setup the gpio pins
call init_dma ; setup dma channels
call init_timers ; setup the timers.
call init_spi1 ; setup SPI1 for video out
rim ; interrupts on
infinite_loop.l
jra infinite_loop
;==============================================
;
; PowerOnReset routine
;
;==============================================
power_on_reset
call draw_status
call reset_attract_state
call reset_wait_state
call sprite_init
bres game_flags_1,#flag1_game_mode
bres game_flags_1,#flag1_demo_mode
ret
draw_status
call clear_screen
call draw_screen_head
call draw_player_one_score
call draw_player_two_score
call draw_high_score
call draw_credit_label
call draw_num_credits
ret
;==============================================
; Interrupt handler for DMA channel
; transaction complete.
;==============================================
interrupt DMAChannel23Int
DMAChannel23Int.l
btjt DMA1_GCSR,#2,dmachan2 ;Channel2?
; Channel 3 DMA
bres DMA1_C3CR,#0 ;turn off channel
bres DMA1_C3SPR,#1 ;clear transcation completed
ldw x,syncdma ;Current value to DMA src
ldw DMA1_C3M0ARH,x
ld a,#$80 ;How many bytes to transfer
addw x,#$0100 ;Next buffer
cpw x,#synccompend ;gone off end?
jrule syncnowrap
ld a,#$62 ;Only do $62 bytes
ldw x,#synccomp ;Set us up wrapped for next
syncnowrap
ldw syncdma,x
ld DMA1_C3NDTR,a ;128 or (625*2) mod 128
bset DMA1_C3CR,#0 ;turn back on channel
iret
; Channel 2 DMA
dmachan2
bres DMA1_C2SPR,#1 ;clear transaction completed
iret
;==============================================
; Interrupt handler for timer 3 comparator
; Kicks off rendering the frame and outputting
; data for screen via SPI.
;==============================================
interrupt Timer3CompareInt
Timer3CompareInt.l
bset TIM1_DER,#3 ; Turn on CC3 DMA
bres TIM3_SR1,#1
bres TIM3_SR1,#2
ldw y,#$0
ldw linenumber,y
mov SPI1_CR2,#%00000010
mov SPI1_ICR,#%00000010
mov SPI1_CR1,#%01000000
renderloop
ld a,TIM3_CNTRH ;Save current line counter
ld xh,a
ld a,TIM3_CNTRL
ld xl,a
ldw tim3cntr,x
; Even line? Render in odd line buffer
ldw x,#{renderbuff2+1}
btjf {linenumber+1},#0,dorenderline
; odd line so render into even buffers
ldw x,#{renderbuff1+1}
dorenderline
call renderline
;wait for TIM 2 off
wait_tim2_off
btjt TIM2_CR1,#0,wait_tim2_off
EXTERN render_part2.w
call render_part2
waitforcounterchange
ld a,TIM3_CNTRH ;Read current line counter
ld xh,a
ld a,TIM3_CNTRL
ld xl,a
cpw x,tim3cntr ; Wait for line counter to change
jreq waitforcounterchange
newline
inc {linenumber+1}
ldw y,linenumber
cpw y,#{scr_height mult 8 +1} ;28*8+2 lines
jrule renderloop ;Not done yet
bres TIM1_DER,#3 ; Turn off CC3 DMA
; check for pause
call handle_pause
btjt game_flags_2,#flag2_pause_game,game_paused
call game_tick
; Do the in game frame tick
ldw y,frame_counter
incw y
ldw frame_counter,y
ldw x,#$1c10
call write_hex_word
game_paused
; Did the compare registers fire?
ld a,TIM3_SR1
and a,#%00000110
; Took too long in the game tick
; time to light up the error and die
jrne took_too_long
bcpl PC_ODR,#7 ;toggle led
btjf game_flags_2,#flag2_pause_game,game_running
btjt PC_ODR,#7,Timer3CompareInt_exit
bcpl PE_ODR,#7 ;Toggle green led in pause
jp Timer3CompareInt_exit
game_running
bres PE_ODR,#7
Timer3CompareInt_exit
iret
took_too_long
; turn on the green led die and loop
bset PE_ODR,#7
sim
jra took_too_long
interrupt NonHandledInterrupt
NonHandledInterrupt.l
iret
;============================================================
;
; Handles pausing the game
; Can either trigger off a frame counter.
; Can be single stepped by tapping button for less than 200ms
; long press removes pause entirely
;
;============================================================
handle_pause
btjt game_flags_2,#flag2_pause_game,already_paused
ldw y,frame_counter
; cpw y,#$2f5 ; Player is drawn on screen
; jreq set_pause_flag
; cpw y,#{$33d} ; Player shot hits udg
; jreq set_pause_flag
; cpw y,#$33d ; Alien bullets explodes
; jreq set_pause_flag
; cpw y,#$383 ; Alien bullets explodes
; jreq set_pause_flag
; cpw y,#$bf0 ; Alien bullets explodes
; jreq set_pause_flag
; cpw y,#$12c3
; jreq set_pause_flag
; cpw y,#$1371 ; Just before crash
; jreq set_pause_flag
cpw y,#$13C6 ; Explosion drawn wrong.
jreq set_pause_flag
already_paused
; button up?
btjf PC_IDR,#1,button_down
ld a,pause_button_timer
jreq handle_pause_exit
ld a,pause_button_timer
cp a,#$ff ;single step?
jrne check_pause_length
mov pause_button_timer,#0
jra set_pause_flag
;Ok button has gone up... If the timer is in the first
;200ms (10 frames) then assume we want to single step
;If it's longer the assume we want to stop pausing
check_pause_length
bres game_flags_2,#flag2_pause_game
cp a,#90
jrugt single_shot
mov pause_button_timer,#0
ret
single_shot
mov pause_button_timer,#$ff
handle_pause_exit
ret
button_down
ld a,pause_button_timer
jrne dec_pause_timer
mov pause_button_timer,#100
dec_pause_timer
dec pause_button_timer
set_pause_flag
bset game_flags_2,#flag2_pause_game
ret
;=============================================
;
; Main tick routine
; Called from frame interrupt.
;
;=============================================
game_tick
dec isr_delay
call handle_coin_switch
btjf game_flags_1,#flag1_suspend_play,not_wait_task
jp run_wait_task
not_wait_task
btjt game_flags_1,#flag1_game_mode,run_game
btjt game_flags_1,#flag1_demo_mode,run_game
ld a,credits
jreq do_attract_screen
jp enter_wait_start_loop
do_attract_screen
jp attract_task
run_game
call game_loop_step
mov vblank_status,#0
btjt game_flags_1,#flag1_tweak,skip_run_game_objects
bset game_flags_1,#flag1_skip_player
call run_game_objects
skip_run_game_objects
bres game_flags_1,#flag1_tweak
call game_loop_step
call cursor_next_alien
mov vblank_status,#$80
ld a,{alien_rolling_timer+timer_extra_count_offs}
ld shot_sync,a
call draw_alien
bres game_flags_1,#flag1_skip_player
call run_game_objects
call start_saucer
jp game_loop_step
;=============================================
;
;
;=============================================
game_loop_step
call player_fire_or_demo
call player_shot_hit
call count_aliens
btjf game_flags_1,#flag1_demo_mode,game_loop_game_mode
call attract_task
ret
game_loop_game_mode
;TODO Add non-demo mode code
ret
;=============================================
;
; Check for player fire or always fire
; in demo mode.
;
;=============================================
player_fire_or_demo
ld a,player_alive
cp a,#player_alive_alive
jrne player_fire_or_demo_ret
ldw y,{player_base_timer+timer_tick_offs}
jrne player_fire_or_demo_ret
ldw y,player_shot_status
cpw y,#player_shot_available
jrne player_fire_or_demo_ret
btjt game_flags_1,#flag1_game_mode,player_fire_game
ldw y,#player_shot_initiated
ldw player_shot_status,y
jp increment_demo_command
player_fire_game
; TODO check switches
player_fire_or_demo_ret
ret
;=============================================
;
; Check if the player shot has hit something
;
;=============================================
player_shot_hit
ldw y,player_shot_status
cpw y,#player_shot_normal_move
jrne player_shot_hit_ret
ld a,{sp_player_shot+sprite_y_offs}
cp a,#$d8 ;Off top of screen?
jrult check_alien_exploding
ldw y,#player_shot_hit_something
ldw player_shot_status,y
bres game_flags_2,#flag2_alien_exploding
check_alien_exploding
btjf game_flags_2,#flag2_alien_exploding,player_shot_hit_ret
cp a,#$ce ;Hit saucer?
jrult check_alien_hit
bset {alien_squigly_shot+shot_flags_offs},#saucer_hit
bres game_flags_2,#flag2_alien_exploding
ldw y,#player_shot_alien_exploded
ldw player_shot_status,y
ret
check_alien_hit
bres game_flags_2,#flag2_player_hit_alien
cp a,ref_alien_y
jrult check_player_hit_alien_flag
ld a,ref_alien_y
add a,#8
clrw y
ld yl,a
find_alien_row_loop
ld a,yl
cp a,{sp_player_shot+sprite_y_offs}
jruge found_alien_row
add a,#$10
ld yl,a
ld a,yh
add a,#11
ld yh,a
jra find_alien_row_loop
check_player_hit_alien_flag
btjt game_flags_2,#flag2_player_hit_alien,player_shot_hit_ret
bres game_flags_2,#flag2_alien_exploding
ldw y,#player_shot_hit_something
ldw player_shot_status,y
player_shot_hit_ret
ret
found_alien_row
ld a,yh
ld shothit_alien_index,a
ld a,{sp_player_shot+sprite_x_offs}
call find_column
ld yl,a ;Save column in yl for later
cp a,#0
jrult check_player_hit_alien_flag
cp a,#10
jrugt check_player_hit_alien_flag
add a,shothit_alien_index
ld shothit_alien_index,a
clrw x
ld xl,a
addw x,current_player
ld a,(aliens_offs,x)
jreq check_player_hit_alien_flag
ld a,#0 ;get rid of the alien
ld (aliens_offs,x),a
ld a,yl
sll a
sll a
sll a
sll a
add a,ref_alien_x
ld shothit_col_x,a
; If we haven't draw this alien yet in the new ref_alien_x
; then the adjust the ColX back to the correct position.
; Y is correct as we use the sprite position rounded.
ld a,shothit_alien_index
cp a,alien_cur_index
jrule no_delta_x_adjust
ld a,numaliens
cp a,1
jreq no_delta_x_adjust
ld a,shothit_col_x
sub a,ref_alien_delta_x
ld shothit_col_x,a
no_delta_x_adjust
mov alien_explode_timer,#$10
ld a,shothit_col_x
srl a
srl a
srl a
ld alien_explode_x,a
ld a,shothit_col_x
and a,#7
ld alien_explode_x_offset,a
ld a,{sp_player_shot+sprite_y_offs}
srl a
srl a
srl a
ld alien_explode_y,a
call explode_alien
mov {sp_player_shot+sprite_visible},#0
ldw y,#player_shot_alien_exploding
ldw player_shot_status,y
bset game_flags_2,#flag2_player_hit_alien
;phew now figure out what the player scored....
ldw y,#$0010
ld a,shothit_alien_index
cp a,{11 mult 2}
jrult store_score
ldw y,#$0020
cp a,{11 mult 4}
jrult store_score
ldw y,#$0030
store_score
ldw score_delta,y
bset game_flags_2,#flag2_adjust_score
jp check_player_hit_alien_flag
;=============================================
;
; Start the saucer if the timer
; has expired.
;
;=============================================
start_saucer.w
ld a,ref_alien_x
cp a,#$78
jrult start_saucer_ret
ldw y,time_to_saucer
jrne start_saucer_decy
ldw y,#$0600
bset {alien_squigly_shot+shot_flags_offs},#saucer_start
start_saucer_decy
decw y
ldw time_to_saucer,y
start_saucer_ret
ret
;=============================================
;
; stub routines start here
;
;=============================================
handle_coin_switch
ret
enter_wait_start_loop
ret
.player_ship_blown_up.w
jra player_ship_blown_up
;=============================================
;
; interrupt vector loop
;
;=============================================
segment 'vectit'
dc.l {$82000000+main} ; reset
dc.l {$82000000+NonHandledInterrupt} ; trap
dc.l {$82000000+NonHandledInterrupt} ; irq0
dc.l {$82000000+NonHandledInterrupt} ; irq1
dc.l {$82000000+NonHandledInterrupt} ; irq2
dc.l {$82000000+DMAChannel23Int} ; irq3
dc.l {$82000000+NonHandledInterrupt} ; irq4
dc.l {$82000000+NonHandledInterrupt} ; irq5
dc.l {$82000000+NonHandledInterrupt} ; irq6
dc.l {$82000000+NonHandledInterrupt} ; irq7
dc.l {$82000000+NonHandledInterrupt} ; irq8
dc.l {$82000000+NonHandledInterrupt} ; irq9
dc.l {$82000000+NonHandledInterrupt} ; irq10
dc.l {$82000000+NonHandledInterrupt} ; irq11
dc.l {$82000000+NonHandledInterrupt} ; irq12
dc.l {$82000000+NonHandledInterrupt} ; irq13
dc.l {$82000000+NonHandledInterrupt} ; irq14
dc.l {$82000000+NonHandledInterrupt} ; irq15
dc.l {$82000000+NonHandledInterrupt} ; irq16
dc.l {$82000000+NonHandledInterrupt} ; irq17
dc.l {$82000000+NonHandledInterrupt} ; irq18
dc.l {$82000000+NonHandledInterrupt} ; Timer 2 Update/overflow
dc.l {$82000000+NonHandledInterrupt} ; Timer 2 capture/compare
dc.l {$82000000+NonHandledInterrupt} ; Timer 3 Update/overflow
dc.l {$82000000+Timer3CompareInt} ; Timer 3 capture/compare
dc.l {$82000000+NonHandledInterrupt} ; irq23
dc.l {$82000000+NonHandledInterrupt} ; irq24
dc.l {$82000000+NonHandledInterrupt} ; irq25
dc.l {$82000000+NonHandledInterrupt} ; irq26
dc.l {$82000000+NonHandledInterrupt} ; irq27
dc.l {$82000000+NonHandledInterrupt} ; irq28
dc.l {$82000000+NonHandledInterrupt} ; irq29
end
|
test/Succeed/Using.agda | hborum/agda | 3 | 1527 | <filename>test/Succeed/Using.agda
module Using where
module Dummy where
data DummySet1 : Set where ds1 : DummySet1
data DummySet2 : Set where ds2 : DummySet2
open Dummy
using (DummySet1)
open Dummy -- checking that newline + comment is allowed before "using"
using (DummySet2)
|
zh/zh1/bintree/2/bintree.adb | balintsoos/LearnAda | 0 | 21434 | <filename>zh/zh1/bintree/2/bintree.adb
function bintree(t : in out Tomb) return Boolean is
l : Boolean := false;
item : Elem;
parent : Elem;
parentIndex : Integer;
begin -- bintree
for i in t'range loop
item := t(i);
parentIndex := i / 2;
if parentIndex < 1 then
parentIndex := 1;
end if;
parent := t(parentIndex);
if beta(item, parent) then
l := true;
end if;
end loop;
return l;
end bintree;
|
test/fail/Issue291a.agda | asr/agda-kanso | 1 | 529 | -- Andreas, 2011-04-14
-- {-# OPTIONS -v tc.cover:20 -v tc.lhs.unify:20 #-}
module Issue291a where
open import Imports.Coinduction
data _≡_ {A : Set}(a : A) : A -> Set where
refl : a ≡ a
data RUnit : Set where
runit : ∞ RUnit -> RUnit
j : (u : ∞ RUnit) -> ♭ u ≡ runit u -> Set
j u ()
-- needs to fail (reports a Bad split!)
|
main.asm | BlockoS/mzrunner | 0 | 92565 | <filename>main.asm
hblnk = 0xe008
vblnk = 0xe002
SCREEN_WIDTH = 40
SCREEN_HEIGHT = 25
BLOB_AREA_WIDTH = 32
BLOB_AREA_HEIGHT = SCREEN_HEIGHT
BLOB_MAX = 32
FRAME_COUNT = 520
ROTOZOOM_FRAMES = 560
SCROLL_SPEED=4
ANIM_SPEED=6
PLAYER_BASE_X=18
PLAYER_BASE_Y=17
org #1200
macro wait_vbl
; wait for vblank
ld hl, vblnk
ld a, 0x7f
@wait0:
cp (hl)
jp nc, @wait0
@wait1:
cp (hl)
jp c, @wait1
endm
main:
di
im 1
start:
ld hl,0x0000
ld (scroll_x), hl
ld a,SCROLL_SPEED
ld (scroll_counter),a
ld a,PLAYER_BASE_X
ld (player_x),a
ld a,PLAYER_BASE_Y
ld (player_y),a
ld a,ANIM_SPEED
ld (player_counter),a
xor a
ld (player_anim),a
ld (player_state),a
ld (player_jump),a
ld (score),a
ld (score+1),a
ld (score+2),a
ld (score+3),a
ld hl,10+40*4
ld (player_addr),hl
ld ix, title
ld iy, 0xd800 + 40*25 - 40 + 10
call gfx_fill
ld iy, 0xd000 + 40*25 - 40 + 10
call gfx_fill
wait_key:
ld hl, 0xe000
ld (hl), 0xf6
inc hl
bit 4,(hl)
jp nz, wait_key
wait_vbl
ld ix, playfield
ld iy, 0xd800 + 40*25 - 40 + 10
call gfx_fill
ld iy, 0xd000 + 40*25 - 40 + 10
call gfx_fill
loop:
ld bc, 1
call inc_score
call show_score
wait_vbl
ld hl, 0xe000
ld (hl), 0xf6
inc hl
bit 4,(hl)
jp nz, @no_jump
ld a,1
ld (player_state),a
@no_jump
ld hl, scroll_counter
dec (hl)
jp nz,@skip_scroll_update
ld (hl), SCROLL_SPEED
ld hl,(scroll_x)
inc hl
ld a,l
and 0xff
ld l,a
ld a,h
and 0x03
ld h,a
ld (scroll_x),hl
@skip_scroll_update:
call erase_player
call draw_field
ld hl, player_counter
dec (hl)
jp nz,@skip_anim_update
ld (hl), ANIM_SPEED
ld a,(player_anim)
inc a
and #3
ld (player_anim),a
@skip_anim_update:
ld a,(player_state)
cp 0
jp nz,@jumping
ld a,PLAYER_BASE_Y
jp @draw
@jumping:
ld hl,player_jump
ld a,(hl)
inc (hl)
cp 34
jp nz,@no_reset
xor a
ld (player_state),a
ld (hl),a
ld a, PLAYER_BASE_Y
ld (player_y), a
jp @draw
@no_reset:
ld c,a
ld b,0
ld hl,jump_curve
add hl,bc
ld b,(hl)
ld a,(player_y)
add a,b
ld (player_y),a
@draw:
ld d,a
ld e,PLAYER_BASE_X
call draw_player
ld a,17
cp d
jp z, loop
PRESS_SPACE_OFFSET = 10*SCREEN_WIDTH + SCREEN_WIDTH/2 - 6
ld hl, press_space
ld de, 0xd000+PRESS_SPACE_OFFSET
ld bc, 12
ldir
ld hl, 0xd800+PRESS_SPACE_OFFSET
ld (hl), 0x71
ld de, 0xd801+PRESS_SPACE_OFFSET
ld bc, 11
ldir
ld b,10
l0:
wait_vbl
dec b
jp nz, l0
wait_key_2:
ld hl, 0xe000
ld (hl), 0xf6
inc hl
bit 4,(hl)
jp nz, wait_key_2
ld b,10
l1:
wait_vbl
dec b
jp nz, l1
jp start
; Fill screen with gfx
gfx_fill:
ld a, 25
.l0:
ld l, 4
.l1:
ld (@gfx_fill.save), sp
di
ld sp, ix
ld bc, 10
add ix, bc
pop bc
pop de
exx
pop hl
pop bc
pop de
ld sp, iy
push de
push bc
push hl
exx
push de
push bc
ld bc, 10
add iy, bc
@gfx_fill.save equ $+1
ld sp, 0x0000
ei
dec l
jp nz, .l1
ld bc, -80
add iy, bc
dec a
jp nz, .l0
ret
draw_field:
ld (@save_sp),sp
ld hl,(scroll_x)
ld de,field
add hl,de
repeat 4, i
ld sp, hl
pop de
pop bc
exx
pop hl
pop de
pop bc
ld sp, 0xd800+16*40+(i*10)
push bc
push de
push hl
exx
push bc
push de
ld bc,10
add hl,bc
rend
repeat 4, j
repeat 4, i
ld sp, 0xd800+16*40+(i-1)*10
pop de
pop bc
exx
pop hl
pop de
pop bc
ld sp, 0xd800+16*40+(i*10)+(j*40)
push bc
push de
push hl
exx
push bc
push de
rend
rend
@save_sp equ $+1
ld sp,0x0000
ret
erase_player:
ld hl,(player_addr)
push hl
xor a
ld bc,40-4
repeat 4, j
repeat 4, i
ld (hl),a
inc hl
rend
add hl,bc
rend
pop hl
ld de, 0x0800
add hl, de
ld a, 0x11
repeat 4, j
repeat 4, i
ld (hl),a
inc hl
rend
add hl,bc
rend
ret
; e : x
; d : y
draw_player:
push de
ld a,(player_anim)
add a,a
add a,a
add a,a
add a,a
ld e,a
ld d,0
ld ix,player
add ix,de
pop de
ld a,d
; compute address
add a,a
ld l,a
ld h,hi(y_offset)
ld c,(hl)
inc hl
ld b,(hl)
ld l,e
ld h,0xd0
add hl,bc
ld (player_addr),hl
push bc
; out (char)
ld bc, 40-4
repeat 4, j
repeat 4, i
ld a,(ix+(i-1)+((j-1)*4))
ld (hl),a
inc hl
rend
add hl, bc
rend
pop bc
ld l,e
ld h,0xd8
add hl,bc
ld d,0
; out (col)
ld bc, 40-4
repeat 4, j
repeat 4, i
ld a,(hl)
or d
ld d, a
ld a,(player_col+(i-1)+((j-1)*4))
ld (hl),a
inc hl
rend
add hl, bc
rend
ret
inc_score:
ld hl,(score)
ld a,l
add c
daa
ld l,a
ld a,h
adc b
daa
ld h,a
ld (score),hl
ret nc
ld hl,(score+2)
ld a,l
add 1
daa
ld l,a
ld a,h
adc 0
daa
ld h,a
ld (score+2),hl
ret
show_score:
exx
ld hl, 0xd000+7
exx
ld hl,(score+2)
call show_bcd
ld hl,(score)
call show_bcd
ret
print_char:
exx
ld (hl),a
inc hl
exx
ret
show_bcd:
ld a,h
call @bcd
ld a,l
@bcd:
ld h,a
rra
rra
rra
rra
and 0x0f
add 0x20
call print_char
ld a,h
and 0x0f
add 0x20
call print_char
ret
field:
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,68,68,17
defb 17,17,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,17,17,17,68,68,17,17
defb 17,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17
defb 17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17
defb 17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17,17,17,17,17
defb 17,17,68,68,17,17,17,17,17,17,68,68,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,68,68,17,17
defb 17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,68,68,17
defb 17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17
defb 17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17
defb 17,68,68,17,17,17,17,68,17,17,17,17,17,68,68,17,17,17,17,17,68,17,17,17,17,17,68,17,17,17,17,17
defb 68,68,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,68,68,17
defb 17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,68,17
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,68,68,17
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17
defb 17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,68,68,17
defb 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,68,68,17,17,17,17,17,17,17,17,17,17,17,17
defb 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17
player:
; chars
defb 0x4b,0x84,0x84,0x4c
defb 0x6f,0x3a,0x3a,0x6e
defb 0x70,0x43,0x43,0x70
defb 0x00,0x56,0x42,0x00
; chars
defb 0x4b,0x83,0x84,0x4c
defb 0x6f,0x3a,0x3a,0x6e
defb 0xa8,0x43,0x43,0xa9
defb 0x00,0x42,0x42,0x00
; chars
defb 0x4b,0x82,0x83,0x4c
defb 0x6f,0x3a,0x3a,0x6e
defb 0x76,0x43,0x43,0x77
defb 0x00,0x56,0x42,0x00
; chars
defb 0x4b,0x83,0x82,0x4c
defb 0x6f,0x3a,0x3a,0x6e
defb 0xdd,0x43,0x43,0xd9
defb 0x00,0x56,0x56,0x00
player_col:
; cols
defb 0x61,0xf1,0xf1,0x61
defb 0x61,0x71,0x71,0x61
defb 0x61,0x71,0x71,0x61
defb 0x11,0x61,0x61,0x11
align 256
y_offset:
i = 0
while i < 25
defw i*40
i = i+1
wend
jump_curve:
defb -3,-2,-2,-1,-1,0,-1,0,-1,0,-1,0,-1,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,1,2,2,3
playfield:
incbin "./data/playfield.bin"
title:
incbin "./data/title.bin"
press_space:
defb 0x10,0x12,0x05,0x13,0x13,0x00,0x00,0x13,0x10,0x01,0x03,0x05
score:
defw 0x0000,0x0000
scroll_x:
defw 0x0000
scroll_counter:
defb SCROLL_SPEED
player_x:
defb PLAYER_BASE_X
player_y:
defb PLAYER_BASE_Y
player_jump:
defb 0
player_state:
defb 0
player_counter:
defb ANIM_SPEED
player_anim:
defb 0x00
player_addr:
defw 10+40*4
; [todo] RAM var at the end
buffer:
|
ftm/yakra.asm | zeta0134/bhop | 4 | 13751 | <gh_stars>1-10
; Dn-FamiTracker exported music data: yakra.0cc
;
; Module header
.word ft_song_list
.word ft_instrument_list
.word ft_sample_list
.word ft_samples
.word ft_groove_list
.byte 0 ; flags
.word 3600 ; NTSC speed
.word 3000 ; PAL speed
; Instrument pointer list
ft_instrument_list:
.word ft_inst_0
.word ft_inst_1
.word ft_inst_2
.word ft_inst_3
.word ft_inst_4
.word ft_inst_5
.word ft_inst_6
.word ft_inst_7
.word ft_inst_8
.word ft_inst_9
.word ft_inst_10
.word ft_inst_11
.word ft_inst_12
.word ft_inst_13
.word ft_inst_14
.word ft_inst_15
.word ft_inst_16
.word ft_inst_17
.word ft_inst_18
.word ft_inst_19
; Instruments
ft_inst_0:
.byte 0
.byte $11
.word ft_seq_2a03_0
.word ft_seq_2a03_4
ft_inst_1:
.byte 0
.byte $15
.word ft_seq_2a03_5
.word ft_seq_2a03_2
.word ft_seq_2a03_9
ft_inst_2:
.byte 0
.byte $11
.word ft_seq_2a03_10
.word ft_seq_2a03_14
ft_inst_3:
.byte 0
.byte $00
ft_inst_4:
.byte 0
.byte $07
.word ft_seq_2a03_15
.word ft_seq_2a03_11
.word ft_seq_2a03_7
ft_inst_5:
.byte 0
.byte $03
.word ft_seq_2a03_20
.word ft_seq_2a03_16
ft_inst_6:
.byte 0
.byte $03
.word ft_seq_2a03_25
.word ft_seq_2a03_21
ft_inst_7:
.byte 0
.byte $13
.word ft_seq_2a03_30
.word ft_seq_2a03_26
.word ft_seq_2a03_19
ft_inst_8:
.byte 0
.byte $03
.word ft_seq_2a03_35
.word ft_seq_2a03_21
ft_inst_9:
.byte 0
.byte $17
.word ft_seq_2a03_5
.word ft_seq_2a03_31
.word ft_seq_2a03_2
.word ft_seq_2a03_4
ft_inst_10:
.byte 0
.byte $11
.word ft_seq_2a03_40
.word ft_seq_2a03_4
ft_inst_11:
.byte 0
.byte $13
.word ft_seq_2a03_0
.word ft_seq_2a03_31
.word ft_seq_2a03_4
ft_inst_12:
.byte 0
.byte $15
.word ft_seq_2a03_0
.word ft_seq_2a03_12
.word ft_seq_2a03_29
ft_inst_13:
.byte 0
.byte $03
.word ft_seq_2a03_45
.word ft_seq_2a03_36
ft_inst_14:
.byte 0
.byte $03
.word ft_seq_2a03_50
.word ft_seq_2a03_41
ft_inst_15:
.byte 0
.byte $07
.word ft_seq_2a03_35
.word ft_seq_2a03_11
.word ft_seq_2a03_7
ft_inst_16:
.byte 0
.byte $13
.word ft_seq_2a03_60
.word ft_seq_2a03_51
.word ft_seq_2a03_24
ft_inst_17:
.byte 0
.byte $13
.word ft_seq_2a03_70
.word ft_seq_2a03_61
.word ft_seq_2a03_19
ft_inst_18:
.byte 0
.byte $15
.word ft_seq_2a03_75
.word ft_seq_2a03_2
.word ft_seq_2a03_9
ft_inst_19:
.byte 0
.byte $15
.word ft_seq_2a03_80
.word ft_seq_2a03_12
.word ft_seq_2a03_29
; Sequences
ft_seq_2a03_0:
.byte $03, $FF, $00, $00, $0F, $0D, $0E
ft_seq_2a03_2:
.byte $17, $0B, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $03, $01, $01, $FF, $FF
.byte $FD, $FD, $FF, $FF, $01, $01, $03
ft_seq_2a03_4:
.byte $01, $FF, $00, $00, $01
ft_seq_2a03_5:
.byte $0E, $FF, $00, $00, $06, $0A, $09, $0D, $0B, $0C, $0B, $0B, $0C, $0D, $0D, $0D, $0D, $0D
ft_seq_2a03_7:
.byte $10, $08, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $01, $FF, $FF, $FF, $FF, $01, $01
ft_seq_2a03_9:
.byte $04, $FF, $00, $00, $01, $00, $00, $00
ft_seq_2a03_10:
.byte $01, $FF, $00, $00, $04
ft_seq_2a03_11:
.byte $02, $FF, $00, $01, $26, $23
ft_seq_2a03_12:
.byte $0C, $02, $00, $00, $00, $00, $FF, $FE, $00, $02, $01, $01, $02, $00, $FE, $FF
ft_seq_2a03_14:
.byte $01, $FF, $00, $00, $00
ft_seq_2a03_15:
.byte $01, $FF, $00, $00, $0F
ft_seq_2a03_16:
.byte $0C, $FF, $00, $01, $0C, $09, $0A, $0A, $0A, $0B, $0B, $0B, $0C, $0C, $0D, $0D
ft_seq_2a03_19:
.byte $02, $FF, $00, $00, $01, $00
ft_seq_2a03_20:
.byte $02, $FF, $00, $00, $0D, $00
ft_seq_2a03_21:
.byte $02, $FF, $00, $01, $31, $2C
ft_seq_2a03_24:
.byte $02, $FF, $00, $00, $01, $00
ft_seq_2a03_25:
.byte $01, $FF, $00, $00, $0F
ft_seq_2a03_26:
.byte $02, $01, $00, $01, $05, $0C
ft_seq_2a03_29:
.byte $03, $FF, $00, $00, $02, $00, $01
ft_seq_2a03_30:
.byte $0A, $FF, $00, $00, $0D, $0D, $0A, $08, $07, $05, $04, $03, $01, $00
ft_seq_2a03_31:
.byte $03, $01, $00, $02, $00, $07, $F9
ft_seq_2a03_35:
.byte $03, $FF, $00, $00, $0F, $0F, $00
ft_seq_2a03_36:
.byte $04, $FF, $00, $02, $00, $FD, $FE, $FF
ft_seq_2a03_40:
.byte $03, $FF, $00, $00, $0D, $0E, $06
ft_seq_2a03_41:
.byte $03, $02, $00, $01, $09, $0B, $0C
ft_seq_2a03_45:
.byte $05, $FF, $00, $00, $0F, $0F, $0F, $0F, $00
ft_seq_2a03_50:
.byte $39, $FF, $00, $00, $0E, $0C, $0B, $0A, $0A, $09, $08, $08, $07, $07, $06, $06, $05, $05, $05, $05
.byte $04, $04, $04, $03, $03, $03, $02, $02, $02, $02, $01, $01, $01, $01, $01, $00, $00, $00, $00, $00
.byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
.byte $00
ft_seq_2a03_51:
.byte $02, $01, $00, $01, $0B, $0D
ft_seq_2a03_60:
.byte $09, $FF, $00, $00, $0C, $09, $08, $07, $05, $04, $03, $03, $00
ft_seq_2a03_61:
.byte $02, $01, $00, $01, $05, $0C
ft_seq_2a03_70:
.byte $0E, $FF, $00, $00, $0D, $0D, $0A, $0D, $07, $05, $08, $03, $01, $00, $00, $00, $00, $00
ft_seq_2a03_75:
.byte $09, $FF, $00, $00, $0C, $0B, $0B, $0C, $0D, $0D, $0D, $0D, $0D
ft_seq_2a03_80:
.byte $0F, $FF, $00, $00, $0F, $07, $0F, $07, $0F, $07, $0F, $07, $0F, $07, $0F, $07, $0F, $07, $0E
; DPCM instrument list (pitch, sample index)
ft_sample_list:
; DPCM samples list (location, size, bank)
ft_samples:
; Groove list
ft_groove_list:
.byte $00
; Grooves (size, terms)
; Song pointer list
ft_song_list:
.word ft_song_0
; Song info
ft_song_0:
.word ft_s0_frames
.byte 14 ; frame count
.byte 48 ; pattern length
.byte 4 ; speed
.byte 180 ; tempo
.byte 0 ; groove position
.byte 0 ; initial bank
;
; Pattern and frame data for all songs below
;
; Bank 0
ft_s0_frames:
.word ft_s0f0
.word ft_s0f1
.word ft_s0f2
.word ft_s0f3
.word ft_s0f4
.word ft_s0f5
.word ft_s0f6
.word ft_s0f7
.word ft_s0f8
.word ft_s0f9
.word ft_s0f10
.word ft_s0f11
.word ft_s0f12
.word ft_s0f13
ft_s0f0:
.word ft_s0p6c0, ft_s0p10c1, ft_s0p10c2, ft_s0p3c3, ft_s0p0c4
ft_s0f1:
.word ft_s0p7c0, ft_s0p11c1, ft_s0p11c2, ft_s0p8c3, ft_s0p0c4
ft_s0f2:
.word ft_s0p0c0, ft_s0p0c1, ft_s0p0c2, ft_s0p0c3, ft_s0p0c4
ft_s0f3:
.word ft_s0p0c0, ft_s0p1c1, ft_s0p2c2, ft_s0p1c3, ft_s0p0c4
ft_s0f4:
.word ft_s0p0c0, ft_s0p0c1, ft_s0p0c2, ft_s0p0c3, ft_s0p0c4
ft_s0f5:
.word ft_s0p0c0, ft_s0p2c1, ft_s0p8c2, ft_s0p2c3, ft_s0p0c4
ft_s0f6:
.word ft_s0p1c0, ft_s0p3c1, ft_s0p1c2, ft_s0p0c3, ft_s0p0c4
ft_s0f7:
.word ft_s0p1c0, ft_s0p4c1, ft_s0p3c2, ft_s0p1c3, ft_s0p0c4
ft_s0f8:
.word ft_s0p1c0, ft_s0p3c1, ft_s0p1c2, ft_s0p0c3, ft_s0p0c4
ft_s0f9:
.word ft_s0p1c0, ft_s0p5c1, ft_s0p9c2, ft_s0p2c3, ft_s0p0c4
ft_s0f10:
.word ft_s0p2c0, ft_s0p6c1, ft_s0p4c2, ft_s0p4c3, ft_s0p0c4
ft_s0f11:
.word ft_s0p3c0, ft_s0p7c1, ft_s0p5c2, ft_s0p5c3, ft_s0p0c4
ft_s0f12:
.word ft_s0p4c0, ft_s0p8c1, ft_s0p6c2, ft_s0p6c3, ft_s0p0c4
ft_s0f13:
.word ft_s0p5c0, ft_s0p9c1, ft_s0p7c2, ft_s0p7c3, ft_s0p0c4
; Bank 0
ft_s0p0c0:
.byte $82, $00, $E0, $F8, $2C, $E2, $FF, $1B, $E0, $F6, $27, $F1, $2C, $F6, $25, $E2, $FF, $1B, $E0, $F7
.byte $23, $F1, $25, $F6, $25, $F1, $23, $F5, $27, $E2, $FF, $1B, $E0, $F8, $2D, $E2, $FF, $1E, $E0, $F6
.byte $28, $E2, $FF, $1E, $E0, $F6, $24, $E2, $FF, $1E, $E0, $F8, $2D, $E2, $FF, $1E, $E0, $F6, $28, $F1
.byte $2D, $F6, $24, $E2, $FF, $1B, $E0, $F8, $2C, $E2, $FF, $1B, $E0, $F6, $27, $F1, $2C, $F6, $25, $E2
.byte $FF, $1B, $E0, $F7, $23, $F1, $25, $F6, $25, $F1, $23, $F5, $27, $E2, $FF, $1B, $E0, $F8, $2F, $E2
.byte $FF, $1C, $E0, $F6, $2A, $E2, $FF, $1C, $E0, $F6, $25, $E2, $FF, $1C, $E0, $F8, $2D, $E2, $FF, $19
.byte $E0, $F6, $28, $E2, $FF, $19, $E0, $F6, $23, $83, $E2, $FF, $19, $00
; Bank 0
ft_s0p0c1:
.byte $E2, $FF, $1B, $00, $7F, $02, $E1, $FA, $20, $00, $F1, $00, $00, $FC, $20, $01, $F1, $00, $01, $FA
.byte $20, $00, $F1, $00, $00, $FC, $27, $04, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00, $F1, $00, $01
.byte $FA, $20, $00, $F1, $00, $00, $FC, $27, $01, $F1, $00, $01, $FA, $20, $00, $F1, $00, $00, $FC, $27
.byte $08, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00, $F1, $00, $01, $82, $00, $80, $24, $FA, $27, $F1
.byte $00, $FB, $28, $83, $F1, $00, $00
; Bank 0
ft_s0p0c2:
.byte $E4, $14, $00, $E3, $14, $01, $7F, $00, $E4, $14, $01, $E6, $20, $02, $7F, $00, $E4, $14, $00, $7F
.byte $00, $12, $01, $7F, $01, $12, $01, $E8, $25, $03, $E4, $14, $01, $14, $00, $E3, $14, $01, $7F, $00
.byte $E4, $14, $01, $E6, $20, $02, $82, $00, $7F, $E4, $14, $7F, $15, $83, $E3, $15, $02, $E4, $15, $00
.byte $7F, $00, $E6, $12, $03, $E5, $12, $00, $7F, $00
; Bank 0
ft_s0p0c3:
.byte $E5, $FF, $1D, $03, $1D, $01, $80, $22, $1D, $03, $E5, $1D, $01, $1D, $03, $1D, $01, $E7, $FC, $1D
.byte $00, $F5, $00, $00, $80, $20, $FF, $1D, $01, $E5, $1D, $01, $1D, $03, $1D, $01, $80, $22, $1D, $03
.byte $E5, $1D, $01, $1D, $03, $1D, $01, $E7, $FC, $1D, $00, $F5, $00, $00, $80, $20, $FF, $1D, $01, $E5
.byte $1D, $01
; Bank 0
ft_s0p0c4:
.byte $00, $2F
; Bank 0
ft_s0p1c0:
.byte $82, $00, $E0, $F8, $2F, $E2, $FF, $1E, $E0, $F6, $2A, $F1, $2F, $F6, $28, $E2, $FF, $1E, $E0, $F7
.byte $27, $F1, $28, $F6, $28, $F1, $26, $F5, $2A, $E2, $FF, $1E, $E0, $F8, $30, $E2, $FF, $21, $E0, $F6
.byte $2B, $E2, $FF, $21, $E0, $F6, $26, $E2, $FF, $21, $E0, $F8, $30, $E2, $FF, $21, $E0, $F6, $2B, $F1
.byte $30, $F6, $26, $E2, $FF, $1E, $E0, $F8, $2F, $E2, $FF, $1E, $E0, $F6, $2A, $F1, $2F, $F6, $28, $E2
.byte $FF, $1E, $E0, $F7, $27, $F1, $28, $F6, $28, $F1, $26, $F5, $2A, $E2, $FF, $1E, $E0, $F8, $32, $E2
.byte $FF, $1F, $E0, $F6, $2D, $E2, $FF, $1F, $E0, $F6, $28, $E2, $FF, $1F, $E0, $F8, $30, $E2, $FF, $1C
.byte $E0, $F6, $2B, $E2, $FF, $1C, $E0, $F6, $26, $83, $E2, $FF, $1C, $00
; Bank 0
ft_s0p1c1:
.byte $E1, $FC, $2A, $04, $F1, $00, $00, $FB, $25, $04, $F1, $00, $00, $FB, $28, $02, $F1, $00, $00, $FA
.byte $27, $02, $F1, $00, $00, $FA, $25, $02, $82, $00, $F1, $00, $80, $24, $FA, $23, $F1, $00, $FA, $23
.byte $F1, $00, $FB, $25, $F8, $00, $83, $E1, $FC, $27, $08, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00
.byte $F1, $00, $05
; Bank 0
ft_s0p1c2:
.byte $E4, $17, $00, $E3, $17, $01, $7F, $00, $E4, $17, $01, $E6, $23, $02, $7F, $00, $E4, $17, $00, $7F
.byte $00, $15, $01, $7F, $01, $15, $01, $E8, $28, $03, $E4, $17, $01, $17, $00, $E3, $17, $01, $7F, $00
.byte $E4, $17, $01, $E6, $23, $02, $82, $00, $7F, $E4, $17, $7F, $18, $83, $E3, $18, $02, $E4, $18, $00
.byte $7F, $00, $E6, $15, $03, $E5, $15, $00, $7F, $00
; Bank 0
ft_s0p1c3:
.byte $E5, $FF, $1D, $03, $1D, $01, $80, $22, $1D, $03, $E5, $1D, $01, $1D, $03, $1D, $01, $E7, $FC, $1D
.byte $00, $F5, $00, $00, $80, $20, $FF, $1D, $01, $E5, $1D, $01, $1D, $03, $1D, $01, $80, $22, $1D, $03
.byte $E5, $1D, $01, $1D, $03, $82, $01, $1D, $E7, $1D, $1D, $83, $1D, $01
; Bank 0
ft_s0p2c0:
.byte $82, $00, $E0, $F9, $33, $F1, $26, $F7, $2E, $F1, $33, $F7, $29, $F1, $2E, $F9, $33, $F1, $29, $F7
.byte $2E, $F1, $33, $F7, $29, $F1, $2E, $FA, $32, $FA, $00, $F9, $00, $F8, $00, $F7, $00, $F1, $00, $F9
.byte $33, $F1, $32, $F7, $2E, $F1, $33, $F7, $29, $F1, $2E, $F9, $32, $F6, $00, $F7, $00, $F8, $00, $F9
.byte $00, $F1, $00, $F9, $35, $F9, $00, $F8, $00, $F7, $00, $F6, $00, $F1, $00, $F9, $33, $F1, $35, $F8
.byte $35, $F1, $33, $F8, $33, $F1, $35, $F9, $2E, $F1, $33, $F8, $29, $F1, $2E, $F8, $24, $83, $F1, $29
.byte $00
; Bank 0
ft_s0p2c1:
.byte $E1, $FC, $2A, $04, $F1, $00, $00, $FB, $25, $04, $F1, $00, $00, $FB, $28, $02, $F1, $00, $00, $FA
.byte $27, $02, $F1, $00, $00, $FA, $25, $02, $82, $00, $F1, $00, $80, $24, $FA, $24, $F1, $00, $FA, $24
.byte $F1, $00, $FB, $25, $F8, $00, $83, $E1, $FC, $27, $07, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00
.byte $F1, $00, $06
; Bank 0
ft_s0p2c2:
.byte $E4, $14, $00, $E3, $14, $01, $7F, $00, $E4, $14, $01, $E6, $20, $02, $7F, $00, $E4, $14, $00, $7F
.byte $00, $12, $01, $7F, $01, $12, $01, $E8, $25, $03, $E4, $14, $01, $14, $00, $E3, $14, $01, $7F, $00
.byte $E4, $14, $01, $E6, $20, $02, $82, $00, $7F, $E4, $14, $7F, $15, $83, $E3, $15, $02, $E4, $15, $00
.byte $7F, $00, $E6, $12, $01, $12, $01, $E5, $12, $00, $7F, $00
; Bank 0
ft_s0p2c3:
.byte $E5, $FF, $1D, $03, $1D, $01, $80, $22, $1D, $03, $E5, $1D, $01, $1D, $03, $1D, $01, $E7, $FC, $1D
.byte $00, $F5, $00, $00, $80, $20, $FF, $1D, $01, $E5, $1D, $01, $F9, $1D, $03, $82, $01, $F7, $1D, $F9
.byte $1D, $F7, $1D, $F7, $1D, $83, $F9, $1D, $03, $F7, $1D, $01, $EE, $FF, $1D, $05
; Bank 0
ft_s0p3c0:
.byte $82, $00, $E0, $F9, $32, $F1, $25, $F7, $2D, $F1, $32, $F7, $28, $F1, $2D, $F9, $32, $F1, $28, $F7
.byte $2D, $F1, $32, $F7, $28, $F1, $2D, $FA, $31, $FA, $00, $F9, $00, $F8, $00, $F7, $00, $F1, $00, $F9
.byte $32, $F1, $31, $F7, $2D, $F1, $32, $F7, $28, $F1, $2D, $F9, $31, $F6, $00, $F7, $00, $F8, $00, $F9
.byte $00, $F1, $00, $F9, $34, $F9, $00, $F8, $00, $F7, $00, $F6, $00, $F1, $00, $F9, $32, $F1, $34, $F8
.byte $34, $F1, $32, $F8, $32, $F1, $34, $F9, $2D, $F1, $32, $F8, $28, $F1, $2D, $F8, $23, $83, $F1, $28
.byte $00
; Bank 0
ft_s0p3c1:
.byte $E1, $FF, $1E, $00, $7F, $02, $FA, $23, $00, $F1, $00, $00, $FC, $23, $01, $F1, $00, $01, $FA, $23
.byte $00, $F1, $00, $00, $FC, $2A, $04, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00, $F1, $00, $01, $FA
.byte $23, $00, $F1, $00, $00, $FC, $2A, $01, $F1, $00, $01, $FA, $23, $00, $F1, $00, $00, $FC, $2A, $08
.byte $FB, $00, $00, $FA, $00, $00, $F9, $00, $00, $F1, $00, $01, $82, $00, $80, $24, $FA, $2A, $F1, $00
.byte $FB, $2B, $83, $F1, $00, $00
; Bank 0
ft_s0p3c2:
.byte $E4, $17, $00, $E3, $17, $01, $7F, $00, $E4, $17, $01, $E6, $23, $02, $7F, $00, $E4, $17, $00, $7F
.byte $00, $15, $01, $7F, $01, $15, $01, $E8, $28, $03, $E4, $17, $01, $17, $00, $E3, $17, $01, $7F, $00
.byte $E4, $17, $01, $E6, $23, $02, $82, $00, $7F, $E4, $17, $7F, $18, $83, $E3, $18, $02, $E4, $18, $00
.byte $7F, $00, $E6, $15, $01, $15, $01, $E5, $15, $00, $7F, $00
; Bank 0
ft_s0p3c3:
.byte $EE, $FF, $1D, $05, $82, $01, $E5, $F8, $1D, $FA, $1D, $FC, $1D, $FF, $1D, $FF, $1D, $FF, $1D, $83
.byte $E7, $FF, $1D, $03, $E5, $1D, $19
; Bank 0
ft_s0p4c0:
.byte $82, $00, $E0, $F9, $25, $F1, $23, $F7, $23, $F1, $25, $F7, $25, $F1, $23, $F9, $27, $F1, $25, $F7
.byte $25, $F1, $27, $F7, $27, $F1, $25, $FA, $28, $F1, $27, $F8, $27, $F1, $28, $F8, $28, $F1, $27, $FA
.byte $2A, $F1, $28, $F8, $28, $F1, $2A, $F8, $2A, $F1, $28, $FA, $2C, $F1, $2A, $F8, $2A, $F1, $2C, $F8
.byte $2C, $F1, $2A, $EC, $F9, $2E, $F9, $00, $F8, $00, $F7, $00, $83, $F0, $00, $01, $82, $00, $E0, $FB
.byte $2F, $F1, $2E, $F9, $2E, $F1, $2F, $F9, $2F, $F1, $2E, $EC, $FB, $31, $FB, $00, $FA, $00, $F9, $00
.byte $83, $F0, $00, $01
; Bank 0
ft_s0p4c1:
.byte $E1, $FC, $2D, $04, $F1, $00, $00, $FB, $28, $04, $F1, $00, $00, $FB, $2B, $02, $F1, $00, $00, $FA
.byte $2A, $02, $F1, $00, $00, $FA, $28, $02, $82, $00, $F1, $00, $80, $24, $FA, $26, $F1, $00, $FA, $26
.byte $F1, $00, $FB, $28, $F8, $00, $83, $E1, $FC, $2A, $08, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00
.byte $F1, $00, $05
; Bank 0
ft_s0p4c2:
.byte $E6, $21, $01, $7F, $01, $82, $00, $E4, $21, $7F, $25, $7F, $27, $7F, $2C, $7F, $83, $E6, $2B, $04
.byte $82, $00, $7F, $E4, $22, $7F, $EF, $22, $7F, $E3, $22, $7F, $83, $E6, $2B, $04, $7F, $00, $2E, $04
.byte $7F, $00, $E3, $2B, $00, $22, $00, $E4, $22, $01, $EF, $22, $01, $ED, $26, $00, $E3, $20, $00, $E4
.byte $20, $01, $EF, $20, $01
; Bank 0
ft_s0p4c3:
.byte $EE, $FF, $1D, $03, $82, $01, $F8, $1D, $E5, $FD, $1D, $FE, $1D, $FF, $1D, $83, $EE, $1D, $05, $E7
.byte $1D, $01, $1D, $01, $1D, $01, $EE, $FF, $1D, $05, $FC, $1D, $05, $82, $01, $E5, $FA, $1D, $F6, $1D
.byte $F6, $1D, $F9, $1D, $F8, $1D, $83, $F8, $1D, $01
; Bank 0
ft_s0p5c0:
.byte $82, $00, $80, $26, $FD, $33, $F9, $00, $F8, $00, $F7, $00, $83, $F0, $00, $01, $82, $00, $FC, $33
.byte $F9, $00, $F8, $00, $F7, $00, $83, $F0, $00, $01, $82, $00, $EA, $F6, $29, $F7, $2A, $F8, $2C, $F9
.byte $2E, $FA, $2F, $FB, $31, $80, $26, $FD, $33, $F9, $00, $F8, $00, $F7, $00, $83, $F0, $00, $01, $82
.byte $00, $FC, $33, $F9, $00, $F8, $00, $F7, $00, $83, $F0, $00, $01, $82, $00, $EA, $F6, $29, $F7, $2A
.byte $F8, $2C, $F9, $2E, $FA, $2F, $FB, $31, $80, $26, $F8, $33, $F0, $00, $F9, $33, $F0, $00, $FA, $33
.byte $F0, $00, $FD, $33, $F9, $00, $F8, $00, $F7, $00, $F0, $00, $83, $86, $03, $00, $00
; Bank 0
ft_s0p5c1:
.byte $E1, $FC, $2D, $04, $F1, $00, $00, $FB, $28, $04, $F1, $00, $00, $FB, $2B, $02, $F1, $00, $00, $FA
.byte $2A, $02, $F1, $00, $00, $FA, $28, $02, $82, $00, $F1, $00, $80, $24, $FA, $27, $F1, $00, $FA, $27
.byte $F1, $00, $FB, $28, $F8, $00, $83, $FC, $2A, $08, $FB, $00, $00, $FA, $00, $00, $F9, $00, $00, $F1
.byte $00, $05
; Bank 0
ft_s0p5c2:
.byte $E6, $20, $01, $7F, $01, $82, $00, $E4, $20, $7F, $24, $7F, $26, $7F, $2B, $7F, $83, $E6, $2A, $04
.byte $82, $00, $7F, $E4, $21, $7F, $EF, $21, $7F, $E3, $21, $7F, $83, $E6, $2A, $04, $7F, $00, $2D, $04
.byte $7F, $00, $E3, $2B, $00, $21, $00, $E4, $21, $01, $EF, $21, $01, $ED, $26, $00, $E3, $1F, $00, $E4
.byte $1F, $01, $EF, $1F, $01
; Bank 0
ft_s0p5c3:
.byte $E7, $FF, $1D, $03, $82, $01, $E5, $FC, $1D, $FC, $1D, $FD, $1D, $FD, $1D, $83, $EE, $FF, $1D, $05
.byte $E7, $1D, $01, $1D, $01, $1D, $01, $EE, $FF, $1D, $05, $FC, $1D, $05, $82, $01, $E5, $FA, $1D, $F6
.byte $1D, $F6, $1D, $F9, $1D, $F6, $1D, $83, $F6, $1D, $01
; Bank 0
ft_s0p6c0:
.byte $82, $00, $E0, $FD, $37, $F1, $00, $FA, $32, $F1, $37, $FB, $2D, $F1, $32, $FB, $2C, $F1, $2D, $FC
.byte $31, $F1, $2C, $FD, $36, $F1, $31, $FD, $35, $F1, $36, $FA, $30, $F1, $35, $FB, $2B, $F1, $30, $FB
.byte $2A, $F1, $2B, $FC, $2F, $F1, $2A, $FD, $34, $86, $02, $F1, $2F, $83, $FB, $33, $17
; Bank 0
ft_s0p6c1:
.byte $80, $24, $F8, $20, $01, $7F, $01, $82, $00, $20, $7F, $20, $7F, $20, $7F, $20, $7F, $E0, $F8, $2D
.byte $F8, $00, $F7, $00, $F6, $00, $F5, $00, $7F, $80, $24, $F8, $20, $7F, $20, $7F, $20, $7F, $E0, $F7
.byte $2D, $F4, $00, $F5, $00, $F6, $00, $F7, $00, $7F, $F7, $30, $F7, $00, $F6, $00, $F5, $00, $F4, $00
.byte $7F, $83, $80, $24, $F8, $1D, $03, $7F, $01, $F8, $20, $03, $7F, $01
; Bank 0
ft_s0p6c2:
.byte $E4, $1E, $03, $EF, $1E, $01, $E4, $22, $03, $EF, $22, $01, $E4, $21, $03, $EF, $21, $01, $E4, $20
.byte $03, $EF, $20, $01, $82, $00, $E6, $1B, $9B, $02, $00, $1B, $9B, $02, $00, $1B, $9B, $02, $00, $83
.byte $20, $03, $7F, $01, $82, $00, $1D, $9B, $02, $00, $1D, $9B, $02, $00, $1D, $9B, $02, $00, $83, $23
.byte $01, $23, $01, $E8, $23, $01
; Bank 0
ft_s0p6c3:
.byte $E5, $FF, $1D, $03, $1D, $01, $80, $20, $FC, $1D, $03, $E5, $FF, $1D, $01, $1D, $03, $1D, $01, $80
.byte $20, $FC, $1D, $03, $82, $01, $E5, $FF, $1D, $E7, $FC, $1D, $FC, $1D, $FC, $1D, $83, $EE, $FF, $1D
.byte $05, $82, $01, $E7, $FC, $1D, $FC, $1D, $FC, $1D, $FF, $1D, $FF, $1D, $83, $FA, $1D, $01
; Bank 0
ft_s0p7c0:
.byte $E0, $FC, $33, $01, $F8, $00, $02, $F9, $00, $02, $FA, $00, $03, $82, $05, $EC, $F9, $33, $F8, $00
.byte $F7, $00, $F6, $00, $83, $F5, $00, $03, $82, $01, $F4, $00, $F3, $00, $F2, $00, $83, $F1, $00, $01
; Bank 0
ft_s0p7c1:
.byte $80, $24, $F8, $1F, $01, $7F, $01, $82, $00, $1F, $7F, $1F, $7F, $1F, $7F, $1F, $7F, $E0, $F8, $2C
.byte $F8, $00, $F7, $00, $F6, $00, $F5, $00, $7F, $80, $24, $F8, $1F, $7F, $1F, $7F, $1F, $7F, $E0, $F7
.byte $2C, $F4, $00, $F5, $00, $F6, $00, $F7, $00, $7F, $F7, $2F, $F7, $00, $F6, $00, $F5, $00, $F4, $00
.byte $7F, $83, $80, $24, $F8, $1C, $03, $7F, $01, $F8, $1F, $03, $7F, $01
; Bank 0
ft_s0p7c2:
.byte $82, $00, $ED, $2B, $E3, $9B, $02, $25, $ED, $26, $E3, $9B, $02, $25, $ED, $1F, $7F, $2B, $E3, $9B
.byte $02, $25, $ED, $26, $E3, $9B, $02, $25, $ED, $1F, $7F, $83, $E8, $25, $03, $EF, $25, $01, $E6, $25
.byte $03, $7F, $01, $25, $03, $EF, $25, $01, $E8, $25, $05, $82, $00, $E6, $25, $9B, $02, $00, $25, $9B
.byte $02, $00, $25, $9B, $02, $00, $83, $25, $01, $25, $01, $E8, $25, $01
; Bank 0
ft_s0p7c3:
.byte $82, $01, $E5, $FF, $1D, $1D, $1D, $1D, $1D, $1D, $83, $EE, $1D, $03, $F7, $1D, $01, $E7, $FF, $1D
.byte $05, $1D, $03, $E5, $1D, $01, $EE, $1D, $05, $82, $01, $E7, $FD, $1D, $FD, $1D, $FD, $1D, $FE, $1D
.byte $FF, $1D, $83, $FF, $1D, $01
; Bank 0
ft_s0p8c1:
.byte $82, $00, $EB, $F8, $1B, $F6, $00, $F4, $00, $F2, $00, $83, $F1, $00, $01, $82, $00, $F9, $1D, $F7
.byte $00, $F5, $00, $F3, $00, $83, $F1, $00, $01, $82, $00, $FA, $1E, $F8, $00, $F6, $00, $F4, $00, $83
.byte $F1, $00, $01, $82, $00, $FB, $20, $F9, $00, $F7, $00, $F5, $00, $83, $F1, $00, $01, $82, $00, $E0
.byte $F8, $25, $F1, $00, $F8, $25, $F1, $00, $F8, $25, $F1, $00, $EC, $F9, $29, $F9, $00, $F8, $00, $F7
.byte $00, $83, $F0, $00, $01, $82, $00, $E0, $F9, $28, $F1, $00, $F9, $28, $F1, $00, $F9, $28, $F1, $00
.byte $EC, $FA, $2C, $FA, $00, $F9, $00, $F8, $00, $83, $F0, $00, $01
; Bank 0
ft_s0p8c2:
.byte $E4, $14, $00, $E3, $14, $01, $7F, $00, $E4, $14, $01, $E6, $20, $02, $7F, $00, $E4, $14, $00, $7F
.byte $00, $12, $01, $7F, $01, $12, $01, $E8, $25, $03, $E4, $14, $01, $82, $00, $ED, $2B, $E3, $14, $E4
.byte $14, $7F, $83, $14, $01, $82, $00, $ED, $26, $E3, $20, $E4, $20, $7F, $20, $7F, $ED, $2B, $E3, $15
.byte $83, $E4, $15, $01, $15, $00, $7F, $00, $12, $04, $7F, $00
; Bank 0
ft_s0p8c3:
.byte $E5, $FF, $1D, $03, $FF, $1D, $01, $80, $20, $FF, $1D, $03, $E5, $FF, $1D, $01, $FF, $1D, $03, $FF
.byte $1D, $01, $80, $20, $FF, $1D, $03, $E5, $FF, $1D, $01, $FF, $1D, $03, $FF, $1D, $01, $80, $20, $FF
.byte $1D, $03, $E5, $FF, $1D, $01, $FF, $1D, $03, $FF, $1D, $01, $80, $20, $FF, $1D, $03, $E5, $FF, $1D
.byte $01
; Bank 0
ft_s0p9c1:
.byte $82, $00, $E9, $FF, $22, $FC, $00, $F9, $00, $F6, $00, $83, $F1, $00, $01, $82, $00, $FE, $22, $FB
.byte $00, $F8, $00, $F5, $00, $83, $F1, $00, $01, $7F, $05, $82, $00, $FF, $22, $FC, $00, $F9, $00, $F6
.byte $00, $83, $F1, $00, $01, $82, $00, $FE, $22, $FB, $00, $F8, $00, $F5, $00, $83, $F1, $00, $01, $7F
.byte $05, $82, $00, $FC, $22, $F1, $00, $FC, $22, $F1, $00, $FC, $22, $F1, $00, $FF, $22, $FC, $00, $F9
.byte $00, $F6, $00, $83, $F0, $00, $01
; Bank 0
ft_s0p9c2:
.byte $E4, $17, $00, $E3, $17, $01, $7F, $00, $E4, $17, $01, $E6, $23, $02, $7F, $00, $E4, $17, $00, $7F
.byte $00, $15, $01, $7F, $01, $15, $01, $E8, $28, $03, $E4, $17, $01, $82, $00, $ED, $2B, $E3, $17, $E4
.byte $17, $7F, $83, $17, $01, $ED, $26, $01, $82, $00, $E4, $17, $7F, $17, $7F, $ED, $2B, $E3, $18, $83
.byte $E4, $18, $01, $18, $00, $7F, $00, $15, $00, $E3, $15, $02, $E5, $15, $00, $7F, $00
; Bank 0
ft_s0p10c1:
.byte $82, $00, $80, $24, $FF, $23, $F1, $00, $FE, $28, $F1, $00, $FD, $2B, $F1, $00, $FD, $2A, $F1, $00
.byte $FE, $26, $F1, $00, $FF, $22, $F1, $00, $FF, $21, $F1, $00, $FE, $26, $F1, $00, $FD, $29, $F1, $00
.byte $FD, $28, $F1, $00, $FE, $24, $F1, $00, $FF, $21, $F1, $00, $83, $E1, $F9, $20, $17
; Bank 0
ft_s0p10c2:
.byte $82, $00, $ED, $2B, $7F, $26, $7F, $1F, $7F, $2B, $7F, $26, $7F, $1F, $7F, $2B, $7F, $26, $7F, $1F
.byte $7F, $83, $E8, $0D, $03, $EF, $0D, $19
; Bank 0
ft_s0p11c1:
.byte $E1, $FC, $20, $01, $F9, $00, $05, $FA, $00, $03, $82, $05, $F9, $00, $F8, $00, $F7, $00, $F6, $00
.byte $83, $F5, $00, $03, $82, $01, $F4, $00, $F3, $00, $F2, $00, $83, $F1, $00, $01
; Bank 0
ft_s0p11c2:
.byte $E4, $20, $02, $7F, $00, $20, $00, $7F, $00, $20, $02, $7F, $00, $20, $00, $7F, $00, $20, $02, $7F
.byte $00, $20, $00, $7F, $00, $20, $02, $7F, $00, $20, $00, $7F, $00, $20, $02, $7F, $00, $20, $00, $7F
.byte $00, $20, $02, $7F, $00, $20, $00, $7F, $00, $20, $02, $7F, $00, $20, $00, $7F, $00, $20, $02, $7F
.byte $00, $20, $00, $7F, $00
; DPCM samples (located at DPCM segment)
|
exe/ldata.asm | DigitalMars/optlink | 28 | 21601 | TITLE LDATA - Copyright (c) SLR Systems 1991
INCLUDE MACROS
INCLUDE FIX2TEMP
PUBLIC EXE_OUT_LDATA,MOVE_LDATA_1,MOVE_LDATA_2,MOVE_LDATA_3
.DATA
SOFT EXTW EXETABLE
SOFT EXTD HIGH_WATER
.CODE PASS2_TEXT
SOFT EXTP LIDATA_PROC,SHL_DXDI_PAGESHIFT_DI,CONVERT_SUBBX_TO_ES,ERR_NAME_ESDI_RET
SOFT EXTA DATA_OUTSIDE_SEGMOD_ERR
ASSUME DS:NOTHING
LIDATA_TYPE PROC
;
;
;
CALL LIDATA_PROC
FIXES
RET
LIDATA_TYPE ENDP
EXE_OUT_LDATA PROC
;
;LDATA_PTR ETC IS RECORD TO BE WRITTEN TO SEGMOD-SPACE
;SIMPLY MOVE IT IN ONE OR TWO BLOCK MOVES...
;
if fg_rom
BITT OMITTING_SEGMENT
JNZ 9$
endif
LDS SI,FIX2_LDATA_PTR
MOV DI,FIX2_LDATA_LOC.LW
MOV DX,FIX2_LDATA_LOC.HW
TEST FIX2_LD_TYPE,MASK BIT_LI
JNZ LIDATA_TYPE ;OOPS, SPECIAL
MOV CX,FIX2_LD_LENGTH
MOVE_LDATA_1 LABEL PROC
ADD DI,CX ;MAKE SURE THIS RECORD DOESN'T
ADC DX,0 ;WRITE OUTSIDE SEGMOD SIZE
CMP FIX2_SM_LEN.HW,DX ;COMPARE HIGH WORD
JC MOVE_LDATA_FAIL
JNZ GOOD
CMP FIX2_SM_LEN.LW,DI
JC MOVE_LDATA_FAIL
GOOD:
; BITT DEBUG_RECORD
; JNZ OHW ;DON'T SET HIGH WATER
if fg_rom
; ADD DI,FIX2_PHASE_ADDR.LW
; ADC DX,FIX2_PHASE_ADDR.HW
endif
;OK, GET READY FOR THE BIG MOVE
;CHECK ON HIGH-WATER MARK
CMP HIGH_WATER.HW,DX
JC NHW
JNZ OHW
CMP HIGH_WATER.LW,DI
JAE OHW
NHW:
MOV HIGH_WATER.LW,DI
MOV HIGH_WATER.HW,DX
OHW:
SUB DI,CX
SBB DX,0
MOVE_LDATA_2 LABEL PROC
;
;DX:DI IS TARGET ADDRESS
;
SUB DI,FIX2_SM_START.LW ;DELTA FOR CURRENT SEGMOD...
SBB DX,FIX2_SM_START.HW
MOVE_LDATA_3 LABEL PROC
;
;CX IS # OF BYTES
;DS:SI IS SOURCE RECORD
;
CALL SHL_DXDI_PAGESHIFT_DI
MOV AX,PAGE_SIZE
SUB AX,DI ;CAN WE DO THIS IN ONE MOVE?
MOV BX,DX
ADD BX,BX
ADD BX,OFF EXETABLE
CMP AX,CX
JC TWO ;NOPE, NEED TWO
TWO_1:
CALL CONVERT_SUBBX_TO_ES ;GET ES PTR
BITT MOVE_BYTES
JNZ 6$
SHR CX,1
REP MOVSW
ADC CX,CX
6$:
REP MOVSB
FIXES
9$:
RET
MOVE_LDATA_FAIL:
LES DI,FIX2_SEG_NAME
MOV CL,DATA_OUTSIDE_SEGMOD_ERR
CALL ERR_NAME_ESDI_RET
FIXES
RET
TWO:
;
;OOPS, CROSSES A 16K BLOCK BOUNDARY... DO TWO MOVES
;
CALL TWO_PROC
JMP TWO_1
EXE_OUT_LDATA ENDP
TWO_PROC PROC NEAR
;
;
;
XCHG AX,CX
SUB AX,CX
PUSH AX ;THIS MANY NEXT TIME...
PUSH BX
CALL CONVERT_SUBBX_TO_ES
POP BX
BITT MOVE_BYTES
JNZ 7$
SHR CX,1
REP MOVSW
ADC CX,CX
7$:
REP MOVSB
POP CX
INC BX
INC BX ;NEXT LOGICAL BLOCK
XOR DI,DI
RET
TWO_PROC ENDP
END
|
src/rejuvenation-match_patterns.ads | TNO/Rejuvenation-Ada | 1 | 29750 | <gh_stars>1-10
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Hash;
package Rejuvenation.Match_Patterns is
type Match_Pattern is tagged private;
-- The class Match_Pattern represents a single occurrence of an AST pattern
-- in an AST instance. An AST pattern or AST instance is a list of physical
-- AST nodes from Libadalang.
--
-- AST patterns are expressed as code snippets that can contain
-- placeholders that can be mapped to AST nodes from the AST instance.
-- If a placeholder occurs multiple times, then the string values of the
-- mapped AST nodes must be identical.
--
-- To show diagnosis information about non-matches on the console, use:
-- Rejuvenation.Match_Pattern.DIAGNOSE := True;
-- Externally-visible data structures -------
Inconsistent_Placeholder_Values_Exception : exception;
-- Exception that indicates that a placeholder is assigned
-- two different values.
Unsupported_Placeholder_Exception : exception;
-- Exception that indicates that an unsupported placeholder was observed.
Invalid_Multiple_Placeholder_Status_Exception : exception;
-- Internal programming error; this should not happen.
DIAGNOSE : Boolean := False;
-- Flag that indicates whether diagnosis information about non-matches is
-- displayed on the console.
-- Create match --------
-- TODO: should order of parameters be in line with similar functions
-- in Finder interface?
function Match_Full
(MP : out Match_Pattern; Pattern : Ada_Node; Instance : Ada_Node)
return Boolean;
-- Return whether the single-node AST pattern fully matches
-- the single-node AST instance.
-- If succesful, then the match attributes can afterwards be inspected.
function Match_Full
(MP : out Match_Pattern; Pattern : Ada_Node_Array;
Instance : Ada_Node_Array) return Boolean;
-- Return whether the node-array AST pattern fully matches
-- the node-array AST instance.
-- If succesful, then the match attributes can afterwards be inspected.
function Match_Prefix
(MP : out Match_Pattern; Pattern : Ada_Node_Array;
Instance : Ada_Node_Array; Instance_Start_Index : Integer)
return Boolean with
Pre => Instance_Start_Index in Instance'Range;
-- Return whether the node-array AST pattern matches
-- a prefix of the node-array AST instance.
-- If succesful, then the match attributes can afterwards be inspected.
function Are_Identical
(Node1 : Ada_Node'Class; Node2 : Ada_Node'Class) return Boolean;
-- Return whether the ASTs of the two nodes match.
-- Raises an exception if a placeholder pattern occurs.
-- Inspect match --------
function Get_Nodes (MP : Match_Pattern) return Node_List.Vector;
-- Return the AST instance nodes that match with the AST pattern.
-- TODO: Should we add an Is_Valid_Placeholder_Name function?
function Has_Single
(MP : Match_Pattern; Placeholder_Name : String) return Boolean;
-- Return whether the "single" placeholder name is mapped
-- to any AST node from the AST instance.
function Get_Single_As_Node
(MP : Match_Pattern; Placeholder_Name : String) return Ada_Node with
Pre => Has_Single (MP, Placeholder_Name);
-- Return the mapped AST node from the AST instance
-- for the given "single" placeholder name.
function Get_Single_As_Raw_Signature
(MP : Match_Pattern; Placeholder_Name : String) return String with
Pre => Has_Single (MP, Placeholder_Name);
-- Return the mapped raw signature from the AST instance
-- for the given "single" placeholder name.
function Has_Multiple
(MP : Match_Pattern; Placeholder_Name : String) return Boolean;
-- Return whether the "multiple" placeholder name is mapped
-- to any AST node from the AST instance.
function Get_Multiple_As_Nodes
(MP : Match_Pattern; Placeholder_Name : String)
return Node_List.Vector with
Pre => Has_Multiple (MP, Placeholder_Name);
-- Return the mapped AST nodes from the AST instance
-- for the given "multiple" placeholder name.
function Get_Multiple_As_Raw_Signature
(MP : Match_Pattern; Placeholder_Name : String) return String with
Pre => Has_Multiple (MP, Placeholder_Name);
-- Return the mapped raw signature from the AST instance
-- for the given "multiple" placeholder name.
-- Note this includes the separators and trivia (white spaces and comments)
-- between the multiple nodes.
function Get_Placeholder_As_Nodes
(MP : Match_Pattern; Placeholder_Name : String) return Node_List.Vector;
-- Return the mapped AST nodes from the AST instance
-- for the given placeholder name (both single and multiple).
function Get_Placeholder_As_Raw_Signature
(MP : Match_Pattern; Placeholder_Name : String) return String;
-- Return the mapped raw signature from the AST instance
-- for the given placeholder name (both single and multiple).
private
-- Create match --------
function Has_Nested_Match_Full
(MP : Match_Pattern; Pattern : Ada_Node; Instance : Ada_Node)
return Boolean;
function Match
(MP : in out Match_Pattern; Pattern : Ada_Node'Class;
Instance : Ada_Node'Class) return Boolean;
function Match
(MP : in out Match_Pattern; Pattern : Ada_Node_Array;
Instance : Ada_Node_Array; Instance_Start_Index : Integer;
Pattern_Must_Cover_End_Of_Instance : Boolean; Store_Nodes : Boolean)
return Boolean with
Pre => Instance'Last < Instance'First
or else Instance_Start_Index in Instance'Range;
function Match_Multiple_Placeholder
(MP : in out Match_Pattern; Pattern : Ada_Node'Class;
Instance : Ada_Node'Class) return Boolean;
function Match_Single_Placeholder
(MP : in out Match_Pattern; Pattern : Ada_Node'Class;
Instance : Ada_Node'Class) return Boolean;
function Match_Specific
(MP : in out Match_Pattern; Pattern : Ada_Node'Class;
Instance : Ada_Node'Class) return Boolean;
procedure Dump_Partial_Match (MP : Match_Pattern);
-- Internal data structures -------
function Equivalent_Key (Left, Right : String) return Boolean;
function Equivalent_Element (Left, Right : Ada_Node) return Boolean;
function Equivalent_Element (Left, Right : Node_List.Vector) return Boolean;
package Mapping_Single_Map is new Indefinite_Hashed_Maps
(Key_Type => String, Element_Type => Ada_Node, Hash => Ada.Strings.Hash,
Equivalent_Keys => Equivalent_Key, "=" => Equivalent_Element);
package Mapping_Multiple_Map is new Indefinite_Hashed_Maps
(Key_Type => String, Element_Type => Node_List.Vector,
Hash => Ada.Strings.Hash, Equivalent_Keys => Equivalent_Key,
"=" => Equivalent_Element);
type Match_Pattern is tagged record
Nodes : Node_List.Vector;
-- The AST instance nodes that match with the AST pattern.
Mapping_Single : Mapping_Single_Map.Map;
-- Mapping from "single" placeholder name to AST node.
Mapping_Multiple : Mapping_Multiple_Map.Map;
-- Mapping from "multiple" placeholder name to AST nodes.
end record;
type Multiple_Placeholder_Status is record
Ongoing_Multiple : Boolean := False;
Multiple_PlaceHolder_Name : Ada_Node := No_Ada_Node;
-- TODO: Why called name and not node?
Multiple_Placeholder_Nodes : Node_List.Vector;
Has_Earlier_Multiple_Placeholder_Nodes : Boolean := False;
Earlier_Multiple_Placeholder_Nodes : Node_List.Vector;
end record;
function Is_Open (MPS : Multiple_Placeholder_Status) return Boolean;
procedure Open
(MPS : in out Multiple_Placeholder_Status; MP : Match_Pattern;
Placeholder_Node : Ada_Node);
procedure Close
(MPS : in out Multiple_Placeholder_Status; MP : in out Match_Pattern);
procedure Update
(MPS : in out Multiple_Placeholder_Status; Instance_Node : Ada_Node);
end Rejuvenation.Match_Patterns;
|
src/gcd.agda | shinji-kono/automaton-in-agda | 0 | 16486 | {-# OPTIONS --allow-unsolved-metas #-}
module gcd where
open import Data.Nat
open import Data.Nat.Properties
open import Data.Empty
open import Data.Unit using (⊤ ; tt)
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.Definitions
open import nat
open import logic
open Factor
gcd1 : ( i i0 j j0 : ℕ ) → ℕ
gcd1 zero i0 zero j0 with <-cmp i0 j0
... | tri< a ¬b ¬c = i0
... | tri≈ ¬a refl ¬c = i0
... | tri> ¬a ¬b c = j0
gcd1 zero i0 (suc zero) j0 = 1
gcd1 zero zero (suc (suc j)) j0 = j0
gcd1 zero (suc i0) (suc (suc j)) j0 = gcd1 i0 (suc i0) (suc j) (suc (suc j))
gcd1 (suc zero) i0 zero j0 = 1
gcd1 (suc (suc i)) i0 zero zero = i0
gcd1 (suc (suc i)) i0 zero (suc j0) = gcd1 (suc i) (suc (suc i)) j0 (suc j0)
gcd1 (suc i) i0 (suc j) j0 = gcd1 i i0 j j0
gcd : ( i j : ℕ ) → ℕ
gcd i j = gcd1 i i j j
gcd20 : (i : ℕ) → gcd i 0 ≡ i
gcd20 zero = refl
gcd20 (suc i) = gcd201 (suc i) where
gcd201 : (i : ℕ ) → gcd1 i i zero zero ≡ i
gcd201 zero = refl
gcd201 (suc zero) = refl
gcd201 (suc (suc i)) = refl
gcd22 : ( i i0 o o0 : ℕ ) → gcd1 (suc i) i0 (suc o) o0 ≡ gcd1 i i0 o o0
gcd22 zero i0 zero o0 = refl
gcd22 zero i0 (suc o) o0 = refl
gcd22 (suc i) i0 zero o0 = refl
gcd22 (suc i) i0 (suc o) o0 = refl
gcdmm : (n m : ℕ) → gcd1 n m n m ≡ m
gcdmm zero m with <-cmp m m
... | tri< a ¬b ¬c = refl
... | tri≈ ¬a refl ¬c = refl
... | tri> ¬a ¬b c = refl
gcdmm (suc n) m = subst (λ k → k ≡ m) (sym (gcd22 n m n m )) (gcdmm n m )
gcdsym2 : (i j : ℕ) → gcd1 zero i zero j ≡ gcd1 zero j zero i
gcdsym2 i j with <-cmp i j | <-cmp j i
... | tri< a ¬b ¬c | tri< a₁ ¬b₁ ¬c₁ = ⊥-elim (nat-<> a a₁)
... | tri< a ¬b ¬c | tri≈ ¬a b ¬c₁ = ⊥-elim (nat-≡< (sym b) a)
... | tri< a ¬b ¬c | tri> ¬a ¬b₁ c = refl
... | tri≈ ¬a b ¬c | tri< a ¬b ¬c₁ = ⊥-elim (nat-≡< (sym b) a)
... | tri≈ ¬a refl ¬c | tri≈ ¬a₁ refl ¬c₁ = refl
... | tri≈ ¬a b ¬c | tri> ¬a₁ ¬b c = ⊥-elim (nat-≡< b c)
... | tri> ¬a ¬b c | tri< a ¬b₁ ¬c = refl
... | tri> ¬a ¬b c | tri≈ ¬a₁ b ¬c = ⊥-elim (nat-≡< b c)
... | tri> ¬a ¬b c | tri> ¬a₁ ¬b₁ c₁ = ⊥-elim (nat-<> c c₁)
gcdsym1 : ( i i0 j j0 : ℕ ) → gcd1 i i0 j j0 ≡ gcd1 j j0 i i0
gcdsym1 zero zero zero zero = refl
gcdsym1 zero zero zero (suc j0) = refl
gcdsym1 zero (suc i0) zero zero = refl
gcdsym1 zero (suc i0) zero (suc j0) = gcdsym2 (suc i0) (suc j0)
gcdsym1 zero zero (suc zero) j0 = refl
gcdsym1 zero zero (suc (suc j)) j0 = refl
gcdsym1 zero (suc i0) (suc zero) j0 = refl
gcdsym1 zero (suc i0) (suc (suc j)) j0 = gcdsym1 i0 (suc i0) (suc j) (suc (suc j))
gcdsym1 (suc zero) i0 zero j0 = refl
gcdsym1 (suc (suc i)) i0 zero zero = refl
gcdsym1 (suc (suc i)) i0 zero (suc j0) = gcdsym1 (suc i) (suc (suc i))j0 (suc j0)
gcdsym1 (suc i) i0 (suc j) j0 = subst₂ (λ j k → j ≡ k ) (sym (gcd22 i _ _ _)) (sym (gcd22 j _ _ _)) (gcdsym1 i i0 j j0 )
gcdsym : { n m : ℕ} → gcd n m ≡ gcd m n
gcdsym {n} {m} = gcdsym1 n n m m
gcd11 : ( i : ℕ ) → gcd i i ≡ i
gcd11 i = gcdmm i i
gcd203 : (i : ℕ) → gcd1 (suc i) (suc i) i i ≡ 1
gcd203 zero = refl
gcd203 (suc i) = gcd205 (suc i) where
gcd205 : (j : ℕ) → gcd1 (suc j) (suc (suc i)) j (suc i) ≡ 1
gcd205 zero = refl
gcd205 (suc j) = subst (λ k → k ≡ 1) (gcd22 (suc j) (suc (suc i)) j (suc i)) (gcd205 j)
gcd204 : (i : ℕ) → gcd1 1 1 i i ≡ 1
gcd204 zero = refl
gcd204 (suc zero) = refl
gcd204 (suc (suc zero)) = refl
gcd204 (suc (suc (suc i))) = gcd204 (suc (suc i))
gcd+j : ( i j : ℕ ) → gcd (i + j) j ≡ gcd i j
gcd+j i j = gcd200 i i j j refl refl where
gcd202 : (i j1 : ℕ) → (i + suc j1) ≡ suc (i + j1)
gcd202 zero j1 = refl
gcd202 (suc i) j1 = cong suc (gcd202 i j1)
gcd201 : (i i0 j j0 j1 : ℕ) → gcd1 (i + j1) (i0 + suc j) j1 j0 ≡ gcd1 i (i0 + suc j) zero j0
gcd201 i i0 j j0 zero = subst (λ k → gcd1 k (i0 + suc j) zero j0 ≡ gcd1 i (i0 + suc j) zero j0 ) (+-comm zero i) refl
gcd201 i i0 j j0 (suc j1) = begin
gcd1 (i + suc j1) (i0 + suc j) (suc j1) j0 ≡⟨ cong (λ k → gcd1 k (i0 + suc j) (suc j1) j0 ) (gcd202 i j1) ⟩
gcd1 (suc (i + j1)) (i0 + suc j) (suc j1) j0 ≡⟨ gcd22 (i + j1) (i0 + suc j) j1 j0 ⟩
gcd1 (i + j1) (i0 + suc j) j1 j0 ≡⟨ gcd201 i i0 j j0 j1 ⟩
gcd1 i (i0 + suc j) zero j0 ∎ where open ≡-Reasoning
gcd200 : (i i0 j j0 : ℕ) → i ≡ i0 → j ≡ j0 → gcd1 (i + j) (i0 + j) j j0 ≡ gcd1 i i j0 j0
gcd200 i .i zero .0 refl refl = subst (λ k → gcd1 k k zero zero ≡ gcd1 i i zero zero ) (+-comm zero i) refl
gcd200 (suc (suc i)) i0 (suc j) (suc j0) i=i0 j=j0 = gcd201 (suc (suc i)) i0 j (suc j0) (suc j)
gcd200 zero zero (suc zero) .1 i=i0 refl = refl
gcd200 zero zero (suc (suc j)) .(suc (suc j)) i=i0 refl = begin
gcd1 (zero + suc (suc j)) (zero + suc (suc j)) (suc (suc j)) (suc (suc j)) ≡⟨ gcdmm (suc (suc j)) (suc (suc j)) ⟩
suc (suc j) ≡⟨ sym (gcd20 (suc (suc j))) ⟩
gcd1 zero zero (suc (suc j)) (suc (suc j)) ∎ where open ≡-Reasoning
gcd200 zero (suc i0) (suc j) .(suc j) () refl
gcd200 (suc zero) .1 (suc j) .(suc j) refl refl = begin
gcd1 (1 + suc j) (1 + suc j) (suc j) (suc j) ≡⟨ gcd203 (suc j) ⟩
1 ≡⟨ sym ( gcd204 (suc j)) ⟩
gcd1 1 1 (suc j) (suc j) ∎ where open ≡-Reasoning
gcd200 (suc (suc i)) i0 (suc j) zero i=i0 ()
open _∧_
gcd-gt : ( i i0 j j0 k : ℕ ) → k > 1 → (if : Factor k i) (i0f : Dividable k i0 ) (jf : Factor k j ) (j0f : Dividable k j0)
→ Dividable k (i - j) ∧ Dividable k (j - i)
→ Dividable k ( gcd1 i i0 j j0 )
gcd-gt zero i0 zero j0 k k>1 if i0f jf j0f i-j with <-cmp i0 j0
... | tri< a ¬b ¬c = i0f
... | tri≈ ¬a refl ¬c = i0f
... | tri> ¬a ¬b c = j0f
gcd-gt zero i0 (suc zero) j0 k k>1 if i0f jf j0f i-j = ⊥-elim (div1 k>1 (proj2 i-j)) -- can't happen
gcd-gt zero zero (suc (suc j)) j0 k k>1 if i0f jf j0f i-j = j0f
gcd-gt zero (suc i0) (suc (suc j)) j0 k k>1 if i0f jf j0f i-j =
gcd-gt i0 (suc i0) (suc j) (suc (suc j)) k k>1 (decf (DtoF i0f)) i0f (decf jf) (proj2 i-j) (div-div k>1 i0f (proj2 i-j))
gcd-gt (suc zero) i0 zero j0 k k>1 if i0f jf j0f i-j = ⊥-elim (div1 k>1 (proj1 i-j)) -- can't happen
gcd-gt (suc (suc i)) i0 zero zero k k>1 if i0f jf j0f i-j = i0f
gcd-gt (suc (suc i)) i0 zero (suc j0) k k>1 if i0f jf j0f i-j = --
gcd-gt (suc i) (suc (suc i)) j0 (suc j0) k k>1 (decf if) (proj1 i-j) (decf (DtoF j0f)) j0f (div-div k>1 (proj1 i-j) j0f )
gcd-gt (suc zero) i0 (suc j) j0 k k>1 if i0f jf j0f i-j =
gcd-gt zero i0 j j0 k k>1 (decf if) i0f (decf jf) j0f i-j
gcd-gt (suc (suc i)) i0 (suc j) j0 k k>1 if i0f jf j0f i-j =
gcd-gt (suc i) i0 j j0 k k>1 (decf if) i0f (decf jf) j0f i-j
gcd-div : ( i j k : ℕ ) → k > 1 → (if : Dividable k i) (jf : Dividable k j )
→ Dividable k ( gcd i j )
gcd-div i j k k>1 if jf = gcd-gt i i j j k k>1 (DtoF if) if (DtoF jf) jf (div-div k>1 if jf)
di-next : {i i0 j j0 : ℕ} → Dividable i0 ((j0 + suc i) - suc j ) ∧ Dividable j0 ((i0 + suc j) - suc i) →
Dividable i0 ((j0 + i) - j ) ∧ Dividable j0 ((i0 + j) - i)
di-next {i} {i0} {j} {j0} x =
⟪ ( subst (λ k → Dividable i0 (k - suc j)) ( begin
j0 + suc i ≡⟨ sym (+-assoc j0 1 i ) ⟩
(j0 + 1) + i ≡⟨ cong (λ k → k + i) (+-comm j0 _ ) ⟩
suc (j0 + i) ∎ ) (proj1 x) ) ,
( subst (λ k → Dividable j0 (k - suc i)) ( begin
i0 + suc j ≡⟨ sym (+-assoc i0 1 j ) ⟩
(i0 + 1) + j ≡⟨ cong (λ k → k + j) (+-comm i0 _ ) ⟩
suc (i0 + j) ∎ ) (proj2 x) ) ⟫
where open ≡-Reasoning
di-next1 : {i0 j j0 : ℕ} → Dividable (suc i0) ((j0 + 0) - (suc (suc j))) ∧ Dividable j0 (suc (i0 + suc (suc j)))
→ Dividable (suc i0) ((suc (suc j) + i0) - suc j) ∧ Dividable (suc (suc j)) ((suc i0 + suc j) - i0)
di-next1 {i0} {j} {j0} x =
⟪ record { factor = 1 ; is-factor = begin
1 * suc i0 + 0 ≡⟨ cong suc ( trans (+-comm _ 0) (+-comm _ 0) ) ⟩
suc i0 ≡⟨ sym (minus+y-y {suc i0} {j}) ⟩
(suc i0 + j) - j ≡⟨ cong (λ k → k - j ) (+-comm (suc i0) _ ) ⟩
(suc j + suc i0 ) - suc j ≡⟨ cong (λ k → k - suc j) (sym (+-assoc (suc j) 1 i0 )) ⟩
((suc j + 1) + i0) - suc j ≡⟨ cong (λ k → (k + i0) - suc j) (+-comm _ 1) ⟩
(suc (suc j) + i0) - suc j ∎ } ,
subst (λ k → Dividable (suc (suc j)) k) ( begin
suc (suc j) ≡⟨ sym ( minus+y-y {suc (suc j)}{i0} ) ⟩
(suc (suc j) + i0 ) - i0 ≡⟨ cong (λ k → (k + i0) - i0) (cong suc (+-comm 1 _ )) ⟩
((suc j + 1) + i0 ) - i0 ≡⟨ cong (λ k → k - i0) (+-assoc (suc j) 1 _ ) ⟩
(suc j + suc i0 ) - i0 ≡⟨ cong (λ k → k - i0) (+-comm (suc j) _) ⟩
((suc i0 + suc j) - i0) ∎ ) div= ⟫
where open ≡-Reasoning
gcd>0 : ( i j : ℕ ) → 0 < i → 0 < j → 0 < gcd i j
gcd>0 i j 0<i 0<j = gcd>01 i i j j 0<i 0<j where
gcd>01 : ( i i0 j j0 : ℕ ) → 0 < i0 → 0 < j0 → gcd1 i i0 j j0 > 0
gcd>01 zero i0 zero j0 0<i 0<j with <-cmp i0 j0
... | tri< a ¬b ¬c = 0<i
... | tri≈ ¬a refl ¬c = 0<i
... | tri> ¬a ¬b c = 0<j
gcd>01 zero i0 (suc zero) j0 0<i 0<j = s≤s z≤n
gcd>01 zero zero (suc (suc j)) j0 0<i 0<j = 0<j
gcd>01 zero (suc i0) (suc (suc j)) j0 0<i 0<j = gcd>01 i0 (suc i0) (suc j) (suc (suc j)) 0<i (s≤s z≤n) -- 0 < suc (suc j)
gcd>01 (suc zero) i0 zero j0 0<i 0<j = s≤s z≤n
gcd>01 (suc (suc i)) i0 zero zero 0<i 0<j = 0<i
gcd>01 (suc (suc i)) i0 zero (suc j0) 0<i 0<j = gcd>01 (suc i) (suc (suc i)) j0 (suc j0) (s≤s z≤n) 0<j
gcd>01 (suc i) i0 (suc j) j0 0<i 0<j = subst (λ k → 0 < k ) (sym (gcd033 i i0 j j0 )) (gcd>01 i i0 j j0 0<i 0<j ) where
gcd033 : (i i0 j j0 : ℕ) → gcd1 (suc i) i0 (suc j) j0 ≡ gcd1 i i0 j j0
gcd033 zero zero zero zero = refl
gcd033 zero zero (suc j) zero = refl
gcd033 (suc i) zero j zero = refl
gcd033 zero zero zero (suc j0) = refl
gcd033 (suc i) zero zero (suc j0) = refl
gcd033 zero zero (suc j) (suc j0) = refl
gcd033 (suc i) zero (suc j) (suc j0) = refl
gcd033 zero (suc i0) j j0 = refl
gcd033 (suc i) (suc i0) j j0 = refl
-- gcd loop invariant
--
record GCD ( i i0 j j0 : ℕ ) : Set where
field
i<i0 : i ≤ i0
j<j0 : j ≤ j0
div-i : Dividable i0 ((j0 + i) - j)
div-j : Dividable j0 ((i0 + j) - i)
div-11 : {i j : ℕ } → Dividable i ((j + i) - j)
div-11 {i} {j} = record { factor = 1 ; is-factor = begin
1 * i + 0 ≡⟨ +-comm _ 0 ⟩
i + 0 ≡⟨ +-comm _ 0 ⟩
i ≡⟨ sym (minus+y-y {i} {j}) ⟩
(i + j ) - j ≡⟨ cong (λ k → k - j ) (+-comm i j ) ⟩
(j + i) - j ∎ } where open ≡-Reasoning
div→gcd : {n k : ℕ } → k > 1 → Dividable k n → gcd n k ≡ k
div→gcd {n} {k} k>1 = n-induction {_} {_} {ℕ} {λ m → Dividable k m → gcd m k ≡ k } (λ x → x) I n where
decl : {m : ℕ } → 0 < m → m - k < m
decl {m} 0<m = y-x<y (<-trans a<sa k>1 ) 0<m
ind : (m : ℕ ) → (Dividable k (m - k) → gcd (m - k) k ≡ k) → Dividable k m → gcd m k ≡ k
ind m prev d with <-cmp (suc m) k
... | tri≈ ¬a refl ¬c = ⊥-elim ( div+1 k>1 d div= )
... | tri> ¬a ¬b c = subst (λ g → g ≡ k) ind1 ( prev (proj2 (div-div k>1 div= d))) where
ind1 : gcd (m - k) k ≡ gcd m k
ind1 = begin
gcd (m - k) k ≡⟨ sym (gcd+j (m - k) _) ⟩
gcd (m - k + k) k ≡⟨ cong (λ g → gcd g k) (minus+n {m} {k} c) ⟩
gcd m k ∎ where open ≡-Reasoning
... | tri< a ¬b ¬c with <-cmp 0 m
... | tri< a₁ ¬b₁ ¬c₁ = ⊥-elim ( div<k k>1 a₁ (<-trans a<sa a) d )
... | tri≈ ¬a refl ¬c₁ = subst (λ g → g ≡ k ) (gcdsym {k} {0} ) (gcd20 k)
fzero : (m : ℕ) → (m - k) ≡ zero → Dividable k m → gcd m k ≡ k
fzero 0 eq d = trans (gcdsym {0} {k} ) (gcd20 k)
fzero (suc m) eq d with <-cmp (suc m) k
... | tri< a ¬b ¬c = ⊥-elim ( div<k k>1 (s≤s z≤n) a d )
... | tri≈ ¬a refl ¬c = gcdmm k k
... | tri> ¬a ¬b c = ⊥-elim ( nat-≡< (sym eq) (minus>0 c) )
I : Ninduction ℕ _ (λ x → x)
I = record {
pnext = λ p → p - k
; fzero = λ {m} eq → fzero m eq
; decline = λ {m} lt → decl lt
; ind = λ {p} prev → ind p prev
}
GCDi : {i j : ℕ } → GCD i i j j
GCDi {i} {j} = record { i<i0 = refl-≤ ; j<j0 = refl-≤ ; div-i = div-11 {i} {j} ; div-j = div-11 {j} {i} }
GCD-sym : {i i0 j j0 : ℕ} → GCD i i0 j j0 → GCD j j0 i i0
GCD-sym g = record { i<i0 = GCD.j<j0 g ; j<j0 = GCD.i<i0 g ; div-i = GCD.div-j g ; div-j = GCD.div-i g }
pred-≤ : {i i0 : ℕ } → suc i ≤ suc i0 → i ≤ suc i0
pred-≤ {i} {i0} (s≤s lt) = ≤-trans lt refl-≤s
gcd-next : {i i0 j j0 : ℕ} → GCD (suc i) i0 (suc j) j0 → GCD i i0 j j0
gcd-next {i} {0} {j} {0} ()
gcd-next {i} {suc i0} {j} {suc j0} g = record { i<i0 = pred-≤ (GCD.i<i0 g) ; j<j0 = pred-≤ (GCD.j<j0 g)
; div-i = proj1 (di-next {i} {suc i0} {j} {suc j0} ⟪ GCD.div-i g , GCD.div-j g ⟫ )
; div-j = proj2 (di-next {i} {suc i0} {j} {suc j0} ⟪ GCD.div-i g , GCD.div-j g ⟫ ) }
gcd-next1 : {i0 j j0 : ℕ} → GCD 0 (suc i0) (suc (suc j)) j0 → GCD i0 (suc i0) (suc j) (suc (suc j))
gcd-next1 {i0} {j} {j0} g = record { i<i0 = refl-≤s ; j<j0 = refl-≤s
; div-i = proj1 (di-next1 ⟪ GCD.div-i g , GCD.div-j g ⟫ ) ; div-j = proj2 (di-next1 ⟪ GCD.div-i g , GCD.div-j g ⟫ ) }
-- gcd-dividable1 : ( i i0 j j0 : ℕ )
-- → Dividable i0 (j0 + i - j ) ∨ Dividable j0 (i0 + j - i)
-- → Dividable ( gcd1 i i0 j j0 ) i0 ∧ Dividable ( gcd1 i i0 j j0 ) j0
-- gcd-dividable1 zero i0 zero j0 with <-cmp i0 j0
-- ... | tri< a ¬b ¬c = ⟪ div= , {!!} ⟫ -- Dividable i0 (j0 + i - j ) ∧ Dividable j0 (i0 + j - i)
-- ... | tri≈ ¬a refl ¬c = {!!}
-- ... | tri> ¬a ¬b c = {!!}
-- gcd-dividable1 zero i0 (suc zero) j0 = {!!}
-- gcd-dividable1 i i0 j j0 = {!!}
gcd-dividable : ( i j : ℕ )
→ Dividable ( gcd i j ) i ∧ Dividable ( gcd i j ) j
gcd-dividable i j = f-induction {_} {_} {ℕ ∧ ℕ}
{λ p → Dividable ( gcd (proj1 p) (proj2 p) ) (proj1 p) ∧ Dividable ( gcd (proj1 p) (proj2 p) ) (proj2 p)} F I ⟪ i , j ⟫ where
F : ℕ ∧ ℕ → ℕ
F ⟪ 0 , 0 ⟫ = 0
F ⟪ 0 , suc j ⟫ = 0
F ⟪ suc i , 0 ⟫ = 0
F ⟪ suc i , suc j ⟫ with <-cmp i j
... | tri< a ¬b ¬c = suc j
... | tri≈ ¬a b ¬c = 0
... | tri> ¬a ¬b c = suc i
F0 : { i j : ℕ } → F ⟪ i , j ⟫ ≡ 0 → (i ≡ j) ∨ (i ≡ 0 ) ∨ (j ≡ 0)
F0 {zero} {zero} p = case1 refl
F0 {zero} {suc j} p = case2 (case1 refl)
F0 {suc i} {zero} p = case2 (case2 refl)
F0 {suc i} {suc j} p with <-cmp i j
... | tri< a ¬b ¬c = ⊥-elim ( nat-≡< (sym p) (s≤s z≤n ))
... | tri≈ ¬a refl ¬c = case1 refl
... | tri> ¬a ¬b c = ⊥-elim ( nat-≡< (sym p) (s≤s z≤n ))
F00 : {p : ℕ ∧ ℕ} → F p ≡ zero → Dividable (gcd (proj1 p) (proj2 p)) (proj1 p) ∧ Dividable (gcd (proj1 p) (proj2 p)) (proj2 p)
F00 {⟪ i , j ⟫} eq with F0 {i} {j} eq
... | case1 refl = ⟪ subst (λ k → Dividable k i) (sym (gcdmm i i)) div= , subst (λ k → Dividable k i) (sym (gcdmm i i)) div= ⟫
... | case2 (case1 refl) = ⟪ subst (λ k → Dividable k i) (sym (trans (gcdsym {0} {j} ) (gcd20 j)))div0
, subst (λ k → Dividable k j) (sym (trans (gcdsym {0} {j}) (gcd20 j))) div= ⟫
... | case2 (case2 refl) = ⟪ subst (λ k → Dividable k i) (sym (gcd20 i)) div=
, subst (λ k → Dividable k j) (sym (gcd20 i)) div0 ⟫
Fsym : {i j : ℕ } → F ⟪ i , j ⟫ ≡ F ⟪ j , i ⟫
Fsym {0} {0} = refl
Fsym {0} {suc j} = refl
Fsym {suc i} {0} = refl
Fsym {suc i} {suc j} with <-cmp i j | <-cmp j i
... | tri< a ¬b ¬c | tri< a₁ ¬b₁ ¬c₁ = ⊥-elim (nat-<> a a₁)
... | tri< a ¬b ¬c | tri≈ ¬a b ¬c₁ = ⊥-elim (¬b (sym b))
... | tri< a ¬b ¬c | tri> ¬a ¬b₁ c = refl
... | tri≈ ¬a refl ¬c | tri< a ¬b ¬c₁ = ⊥-elim (¬b refl)
... | tri≈ ¬a refl ¬c | tri≈ ¬a₁ refl ¬c₁ = refl
... | tri≈ ¬a refl ¬c | tri> ¬a₁ ¬b c = ⊥-elim (¬b refl)
... | tri> ¬a ¬b c | tri< a ¬b₁ ¬c = refl
... | tri> ¬a ¬b c | tri≈ ¬a₁ b ¬c = ⊥-elim (¬b (sym b))
... | tri> ¬a ¬b c | tri> ¬a₁ ¬b₁ c₁ = ⊥-elim (nat-<> c c₁)
record Fdec ( i j : ℕ ) : Set where
field
ni : ℕ
nj : ℕ
fdec : 0 < F ⟪ i , j ⟫ → F ⟪ ni , nj ⟫ < F ⟪ i , j ⟫
fd1 : ( i j k : ℕ ) → i < j → k ≡ j - i → F ⟪ suc i , k ⟫ < F ⟪ suc i , suc j ⟫
fd1 i j 0 i<j eq = ⊥-elim ( nat-≡< eq (minus>0 {i} {j} i<j ))
fd1 i j (suc k) i<j eq = fd2 i j k i<j eq where
fd2 : ( i j k : ℕ ) → i < j → suc k ≡ j - i → F ⟪ suc i , suc k ⟫ < F ⟪ suc i , suc j ⟫
fd2 i j k i<j eq with <-cmp i k | <-cmp i j
... | tri< a ¬b ¬c | tri< a₁ ¬b₁ ¬c₁ = fd3 where
fd3 : suc k < suc j -- suc j - suc i < suc j
fd3 = subst (λ g → g < suc j) (sym eq) (y-x<y {suc i} {suc j} (s≤s z≤n) (s≤s z≤n))
... | tri< a ¬b ¬c | tri≈ ¬a b ¬c₁ = ⊥-elim (⊥-elim (¬a i<j))
... | tri< a ¬b ¬c | tri> ¬a ¬b₁ c = ⊥-elim (⊥-elim (¬a i<j))
... | tri≈ ¬a b ¬c | tri< a ¬b ¬c₁ = s≤s z≤n
... | tri≈ ¬a b ¬c | tri≈ ¬a₁ b₁ ¬c₁ = ⊥-elim (¬a₁ i<j)
... | tri≈ ¬a b ¬c | tri> ¬a₁ ¬b c = s≤s z≤n -- i > j
... | tri> ¬a ¬b c | tri< a ¬b₁ ¬c = fd4 where
fd4 : suc i < suc j
fd4 = s≤s a
... | tri> ¬a ¬b c | tri≈ ¬a₁ b ¬c = ⊥-elim (¬a₁ i<j)
... | tri> ¬a ¬b c | tri> ¬a₁ ¬b₁ c₁ = ⊥-elim (¬a₁ i<j)
fedc0 : (i j : ℕ ) → Fdec i j
fedc0 0 0 = record { ni = 0 ; nj = 0 ; fdec = λ () }
fedc0 (suc i) 0 = record { ni = suc i ; nj = 0 ; fdec = λ () }
fedc0 0 (suc j) = record { ni = 0 ; nj = suc j ; fdec = λ () }
fedc0 (suc i) (suc j) with <-cmp i j
... | tri< i<j ¬b ¬c = record { ni = suc i ; nj = j - i ; fdec = λ lt → fd1 i j (j - i) i<j refl }
... | tri≈ ¬a refl ¬c = record { ni = suc i ; nj = suc j ; fdec = λ lt → ⊥-elim (nat-≡< fd0 lt) } where
fd0 : {i : ℕ } → 0 ≡ F ⟪ suc i , suc i ⟫
fd0 {i} with <-cmp i i
... | tri< a ¬b ¬c = ⊥-elim ( ¬b refl )
... | tri≈ ¬a b ¬c = refl
... | tri> ¬a ¬b c = ⊥-elim ( ¬b refl )
... | tri> ¬a ¬b c = record { ni = i - j ; nj = suc j ; fdec = λ lt →
subst₂ (λ s t → s < t) (Fsym {suc j} {i - j}) (Fsym {suc j} {suc i}) (fd1 j i (i - j) c refl ) }
ind3 : {i j : ℕ } → i < j
→ Dividable (gcd (suc i) (j - i)) (suc i)
→ Dividable (gcd (suc i) (suc j)) (suc i)
ind3 {i} {j} a prev =
subst (λ k → Dividable k (suc i)) ( begin
gcd (suc i) (j - i) ≡⟨ gcdsym {suc i} {j - i} ⟩
gcd (j - i ) (suc i) ≡⟨ sym (gcd+j (j - i) (suc i)) ⟩
gcd ((j - i) + suc i) (suc i) ≡⟨ cong (λ k → gcd k (suc i)) ( begin
(suc j - suc i) + suc i ≡⟨ minus+n {suc j} {suc i} (<-trans ( s≤s a) a<sa ) ⟩ -- i ≤ n → suc (suc i) ≤ suc (suc (suc n))
suc j ∎ ) ⟩
gcd (suc j) (suc i) ≡⟨ gcdsym {suc j} {suc i} ⟩
gcd (suc i) (suc j) ∎ ) prev where open ≡-Reasoning
ind7 : {i j : ℕ } → (i < j ) → (j - i) + suc i ≡ suc j
ind7 {i} {j} a = begin (suc j - suc i) + suc i ≡⟨ minus+n {suc j} {suc i} (<-trans (s≤s a) a<sa) ⟩
suc j ∎ where open ≡-Reasoning
ind6 : {i j k : ℕ } → i < j
→ Dividable k (j - i)
→ Dividable k (suc i)
→ Dividable k (suc j)
ind6 {i} {j} {k} i<j dj di = subst (λ g → Dividable k g ) (ind7 i<j) (proj1 (div+div dj di))
ind4 : {i j : ℕ } → i < j
→ Dividable (gcd (suc i) (j - i)) (j - i)
→ Dividable (gcd (suc i) (suc j)) (j - i)
ind4 {i} {j} i<j prev = subst (λ k → k) ( begin
Dividable (gcd (suc i) (j - i)) (j - i) ≡⟨ cong (λ k → Dividable k (j - i)) (gcdsym {suc i} ) ⟩
Dividable (gcd (j - i ) (suc i) ) (j - i) ≡⟨ cong (λ k → Dividable k (j - i)) ( sym (gcd+j (j - i) (suc i))) ⟩
Dividable (gcd ((j - i) + suc i) (suc i)) (j - i) ≡⟨ cong (λ k → Dividable (gcd k (suc i)) (j - i)) (ind7 i<j ) ⟩
Dividable (gcd (suc j) (suc i)) (j - i) ≡⟨ cong (λ k → Dividable k (j - i)) (gcdsym {suc j} ) ⟩
Dividable (gcd (suc i) (suc j)) (j - i) ∎ ) prev where open ≡-Reasoning
ind : ( i j : ℕ ) →
Dividable (gcd (Fdec.ni (fedc0 i j)) (Fdec.nj (fedc0 i j))) (Fdec.ni (fedc0 i j))
∧ Dividable (gcd (Fdec.ni (fedc0 i j)) (Fdec.nj (fedc0 i j))) (Fdec.nj (fedc0 i j))
→ Dividable (gcd i j) i ∧ Dividable (gcd i j) j
ind zero zero prev = ind0 where
ind0 : Dividable (gcd zero zero) zero ∧ Dividable (gcd zero zero) zero
ind0 = ⟪ div0 , div0 ⟫
ind zero (suc j) prev = ind1 where
ind1 : Dividable (gcd zero (suc j)) zero ∧ Dividable (gcd zero (suc j)) (suc j)
ind1 = ⟪ div0 , subst (λ k → Dividable k (suc j)) (sym (trans (gcdsym {zero} {suc j}) (gcd20 (suc j)))) div= ⟫
ind (suc i) zero prev = ind2 where
ind2 : Dividable (gcd (suc i) zero) (suc i) ∧ Dividable (gcd (suc i) zero) zero
ind2 = ⟪ subst (λ k → Dividable k (suc i)) (sym (trans refl (gcd20 (suc i)))) div= , div0 ⟫
ind (suc i) (suc j) prev with <-cmp i j
... | tri< a ¬b ¬c = ⟪ ind3 a (proj1 prev) , ind6 a (ind4 a (proj2 prev)) (ind3 a (proj1 prev) ) ⟫
... | tri≈ ¬a refl ¬c = ⟪ ind5 , ind5 ⟫ where
ind5 : Dividable (gcd (suc i) (suc i)) (suc i)
ind5 = subst (λ k → Dividable k (suc j)) (sym (gcdmm (suc i) (suc i))) div=
... | tri> ¬a ¬b c = ⟪ ind8 c (proj1 prev) (proj2 prev) , ind10 c (proj2 prev) ⟫ where
ind9 : {i j : ℕ} → i < j → gcd (j - i) (suc i) ≡ gcd (suc j) (suc i)
ind9 {i} {j} i<j = begin
gcd (j - i ) (suc i) ≡⟨ sym (gcd+j (j - i ) (suc i) ) ⟩
gcd (j - i + suc i) (suc i) ≡⟨ cong (λ k → gcd k (suc i)) (ind7 i<j ) ⟩
gcd (suc j) (suc i) ∎ where open ≡-Reasoning
ind8 : { i j : ℕ } → i < j
→ Dividable (gcd (j - i) (suc i)) (j - i)
→ Dividable (gcd (j - i) (suc i)) (suc i)
→ Dividable (gcd (suc j) (suc i)) (suc j)
ind8 {i} {j} i<j dji di = ind6 i<j (subst (λ k → Dividable k (j - i)) (ind9 i<j) dji) (subst (λ k → Dividable k (suc i)) (ind9 i<j) di)
ind10 : { i j : ℕ } → j < i
→ Dividable (gcd (i - j) (suc j)) (suc j)
→ Dividable (gcd (suc i) (suc j)) (suc j)
ind10 {i} {j} j<i dji = subst (λ g → Dividable g (suc j) ) (begin
gcd (i - j) (suc j) ≡⟨ sym (gcd+j (i - j) (suc j)) ⟩
gcd (i - j + suc j) (suc j) ≡⟨ cong (λ k → gcd k (suc j)) (ind7 j<i ) ⟩
gcd (suc i) (suc j) ∎ ) dji where open ≡-Reasoning
I : Finduction (ℕ ∧ ℕ) _ F
I = record {
fzero = F00
; pnext = λ p → ⟪ Fdec.ni (fedc0 (proj1 p) (proj2 p)) , Fdec.nj (fedc0 (proj1 p) (proj2 p)) ⟫
; decline = λ {p} lt → Fdec.fdec (fedc0 (proj1 p) (proj2 p)) lt
; ind = λ {p} prev → ind (proj1 p ) ( proj2 p ) prev
}
f-div>0 : { k i : ℕ } → (d : Dividable k i ) → 0 < i → 0 < Dividable.factor d
f-div>0 {k} {i} d 0<i with <-cmp 0 (Dividable.factor d)
... | tri< a ¬b ¬c = a
... | tri≈ ¬a b ¬c = ⊥-elim ( nat-≡< (begin
0 * k + 0 ≡⟨ cong (λ g → g * k + 0) b ⟩
Dividable.factor d * k + 0 ≡⟨ Dividable.is-factor d ⟩
i ∎ ) 0<i ) where open ≡-Reasoning
gcd-≤i : ( i j : ℕ ) → 0 < i → i ≤ j → gcd i j ≤ i
gcd-≤i zero _ () z≤n
gcd-≤i (suc i) (suc j) _ (s≤s i<j) = begin
gcd (suc i) (suc j) ≡⟨ sym m*1=m ⟩
gcd (suc i) (suc j) * 1 ≤⟨ *-monoʳ-≤ (gcd (suc i) (suc j)) (f-div>0 d (s≤s z≤n)) ⟩
gcd (suc i) (suc j) * f ≡⟨ +-comm 0 _ ⟩
gcd (suc i) (suc j) * f + 0 ≡⟨ cong (λ k → k + 0) (*-comm (gcd (suc i) (suc j)) _ ) ⟩
Dividable.factor (proj1 (gcd-dividable (suc i) (suc j))) * gcd (suc i) (suc j) + 0 ≡⟨ Dividable.is-factor (proj1 (gcd-dividable (suc i) (suc j))) ⟩
suc i ∎ where
d = proj1 (gcd-dividable (suc i) (suc j))
f = Dividable.factor (proj1 (gcd-dividable (suc i) (suc j)))
open ≤-Reasoning
gcd-≤ : { i j : ℕ } → 0 < i → 0 < j → gcd i j ≤ i
gcd-≤ {i} {j} 0<i 0<j with <-cmp i j
... | tri< a ¬b ¬c = gcd-≤i i j 0<i (<to≤ a)
... | tri≈ ¬a refl ¬c = gcd-≤i i j 0<i refl-≤
... | tri> ¬a ¬b c = ≤-trans (subst (λ k → k ≤ j) (gcdsym {j} {i}) (gcd-≤i j i 0<j (<to≤ c))) (<to≤ c)
record Euclid (i j gcd : ℕ ) : Set where
field
eqa : ℕ
eqb : ℕ
is-equ< : eqa * i > eqb * j → (eqa * i) - (eqb * j) ≡ gcd
is-equ> : eqb * j > eqa * i → (eqb * j) - (eqa * i) ≡ gcd
is-equ= : eqa * i ≡ eqb * j → 0 ≡ gcd
ge3 : {a b c d : ℕ } → b > a → b - a ≡ d - c → d > c
ge3 {a} {b} {c} {d} b>a eq = minus>0→x<y (subst (λ k → 0 < k ) eq (minus>0 b>a))
ge01 : ( i0 j j0 ea eb : ℕ )
→ ( di : GCD 0 (suc i0) (suc (suc j)) j0 )
→ (((ea + eb * (Dividable.factor (GCD.div-i di))) * suc i0) ≡ (ea * suc i0) + (eb * (Dividable.factor (GCD.div-i di)) ) * suc i0 )
∧ ( (eb * j0) ≡ (eb * suc (suc j) + (eb * (Dividable.factor (GCD.div-i di)) ) * suc i0) )
ge01 i0 j j0 ea eb di = ⟪ ge011 , ge012 ⟫ where
f = Dividable.factor (GCD.div-i di)
ge4 : suc (j0 + 0) > suc (suc j)
ge4 = subst (λ k → k > suc (suc j)) (+-comm 0 _ ) ( s≤s (GCD.j<j0 di ))
ge011 : (ea + eb * f) * suc i0 ≡ ea * suc i0 + eb * f * suc i0
ge011 = begin
(ea + eb * f) * suc i0 ≡⟨ *-distribʳ-+ (suc i0) ea _ ⟩
ea * suc i0 + eb * f * suc i0 ∎ where open ≡-Reasoning
ge012 : eb * j0 ≡ eb * suc (suc j) + eb * f * suc i0
ge012 = begin
eb * j0 ≡⟨ cong (λ k → eb * k) ( begin
j0 ≡⟨ +-comm 0 _ ⟩
j0 + 0 ≡⟨ sym (minus+n {j0 + 0} {suc (suc j)} ge4) ⟩
((j0 + 0) - (suc (suc j))) + suc (suc j) ≡⟨ +-comm _ (suc (suc j)) ⟩
suc (suc j) + ((j0 + 0) - suc (suc j)) ≡⟨ cong (λ k → suc (suc j) + k ) (sym (Dividable.is-factor (GCD.div-i di))) ⟩
suc (suc j) + (f * suc i0 + 0) ≡⟨ cong (λ k → suc (suc j) + k ) ( +-comm _ 0 ) ⟩
suc (suc j) + (f * suc i0 ) ∎ ) ⟩
eb * (suc (suc j) + (f * suc i0 ) ) ≡⟨ *-distribˡ-+ eb (suc (suc j)) (f * suc i0) ⟩
eb * suc (suc j) + eb * (f * suc i0) ≡⟨ cong (λ k → eb * suc (suc j) + k ) ((sym (*-assoc eb _ _ )) ) ⟩
eb * suc (suc j) + eb * f * suc i0 ∎ where open ≡-Reasoning
ge20 : {i0 j0 : ℕ } → i0 ≡ 0 → 0 ≡ gcd1 zero i0 zero j0
ge20 {i0} {zero} refl = refl
ge20 {i0} {suc j0} refl = refl
gcd-euclid1 : ( i i0 j j0 : ℕ ) → GCD i i0 j j0 → Euclid i0 j0 (gcd1 i i0 j j0)
gcd-euclid1 zero i0 zero j0 di with <-cmp i0 j0
... | tri< a' ¬b ¬c = record { eqa = 1 ; eqb = 0 ; is-equ< = λ _ → +-comm _ 0 ; is-equ> = λ () ; is-equ= = ge21 } where
ge21 : 1 * i0 ≡ 0 * j0 → 0 ≡ i0
ge21 eq = trans (sym eq) (+-comm i0 0)
... | tri≈ ¬a refl ¬c = record { eqa = 1 ; eqb = 0 ; is-equ< = λ _ → +-comm _ 0 ; is-equ> = λ () ; is-equ= = λ eq → trans (sym eq) (+-comm i0 0) }
... | tri> ¬a ¬b c = record { eqa = 0 ; eqb = 1 ; is-equ< = λ () ; is-equ> = λ _ → +-comm _ 0 ; is-equ= = ge22 } where
ge22 : 0 * i0 ≡ 1 * j0 → 0 ≡ j0
ge22 eq = trans eq (+-comm j0 0)
-- i<i0 : zero ≤ i0
-- j<j0 : 1 ≤ j0
-- div-i : Dividable i0 ((j0 + zero) - 1) -- fi * i0 ≡ (j0 + zero) - 1
-- div-j : Dividable j0 ((i0 + 1) - zero) -- fj * j0 ≡ (i0 + 1) - zero
gcd-euclid1 zero i0 (suc zero) j0 di = record { eqa = 1 ; eqb = Dividable.factor (GCD.div-j di) ; is-equ< = λ lt → ⊥-elim ( ge7 lt) ; is-equ> = λ _ → ge6
; is-equ= = λ eq → ⊥-elim (nat-≡< (sym (minus<=0 (subst (λ k → k ≤ 1 * i0) eq refl-≤ ))) (subst (λ k → 0 < k) (sym ge6) a<sa )) } where
ge6 : (Dividable.factor (GCD.div-j di) * j0) - (1 * i0) ≡ gcd1 zero i0 1 j0
ge6 = begin
(Dividable.factor (GCD.div-j di) * j0) - (1 * i0) ≡⟨ cong (λ k → k - (1 * i0)) (+-comm 0 _) ⟩
(Dividable.factor (GCD.div-j di) * j0 + 0) - (1 * i0) ≡⟨ cong (λ k → k - (1 * i0)) (Dividable.is-factor (GCD.div-j di) ) ⟩
((i0 + 1) - zero) - (1 * i0) ≡⟨ refl ⟩
(i0 + 1) - (i0 + 0) ≡⟨ minus+yx-yz {_} {i0} {0} ⟩
1 ∎ where open ≡-Reasoning
ge7 : ¬ ( 1 * i0 > Dividable.factor (GCD.div-j di) * j0 )
ge7 lt = ⊥-elim ( nat-≡< (sym ( minus<=0 (<to≤ lt))) (subst (λ k → 0 < k) (sym ge6) (s≤s z≤n)))
gcd-euclid1 zero zero (suc (suc j)) j0 di = record { eqa = 0 ; eqb = 1 ; is-equ< = λ () ; is-equ> = λ _ → +-comm _ 0
; is-equ= = λ eq → subst (λ k → 0 ≡ k) (+-comm _ 0) eq }
gcd-euclid1 zero (suc i0) (suc (suc j)) j0 di with gcd-euclid1 i0 (suc i0) (suc j) (suc (suc j)) ( gcd-next1 di )
... | e = record { eqa = ea + eb * f ; eqb = eb
; is-equ= = λ eq → Euclid.is-equ= e (ge23 eq)
; is-equ< = λ lt → subst (λ k → ((ea + eb * f) * suc i0) - (eb * j0) ≡ k ) (Euclid.is-equ< e (ge3 lt (ge1 ))) (ge1 )
; is-equ> = λ lt → subst (λ k → (eb * j0) - ((ea + eb * f) * suc i0) ≡ k ) (Euclid.is-equ> e (ge3 lt (ge2 ))) (ge2 ) } where
ea = Euclid.eqa e
eb = Euclid.eqb e
f = Dividable.factor (GCD.div-i di)
ge1 : ((ea + eb * f) * suc i0) - (eb * j0) ≡ (ea * suc i0) - (eb * suc (suc j))
ge1 = begin
((ea + eb * f) * suc i0) - (eb * j0) ≡⟨ cong₂ (λ j k → j - k ) (proj1 (ge01 i0 j j0 ea eb di)) (proj2 (ge01 i0 j j0 ea eb di)) ⟩
(ea * suc i0 + (eb * f ) * suc i0 ) - ( eb * suc (suc j) + ((eb * f) * (suc i0)) ) ≡⟨ minus+xy-zy {ea * suc i0} {(eb * f ) * suc i0} {eb * suc (suc j)} ⟩
(ea * suc i0) - (eb * suc (suc j)) ∎ where open ≡-Reasoning
ge2 : (eb * j0) - ((ea + eb * f) * suc i0) ≡ (eb * suc (suc j)) - (ea * suc i0)
ge2 = begin
(eb * j0) - ((ea + eb * f) * suc i0) ≡⟨ cong₂ (λ j k → j - k ) (proj2 (ge01 i0 j j0 ea eb di)) (proj1 (ge01 i0 j j0 ea eb di)) ⟩
( eb * suc (suc j) + ((eb * f) * (suc i0)) ) - (ea * suc i0 + (eb * f ) * suc i0 ) ≡⟨ minus+xy-zy {eb * suc (suc j)}{(eb * f ) * suc i0} {ea * suc i0} ⟩
(eb * suc (suc j)) - (ea * suc i0) ∎ where open ≡-Reasoning
ge23 : (ea + eb * f) * suc i0 ≡ eb * j0 → ea * suc i0 ≡ eb * suc (suc j)
ge23 eq = begin
ea * suc i0 ≡⟨ sym (minus+y-y {_} {(eb * f ) * suc i0} ) ⟩
(ea * suc i0 + ((eb * f ) * suc i0 )) - ((eb * f ) * suc i0 ) ≡⟨ cong (λ k → k - ((eb * f ) * suc i0 )) (sym ( proj1 (ge01 i0 j j0 ea eb di))) ⟩
((ea + eb * f) * suc i0) - ((eb * f ) * suc i0 ) ≡⟨ cong (λ k → k - ((eb * f ) * suc i0 )) eq ⟩
(eb * j0) - ((eb * f ) * suc i0 ) ≡⟨ cong (λ k → k - ((eb * f ) * suc i0 )) ( proj2 (ge01 i0 j j0 ea eb di)) ⟩
(eb * suc (suc j) + ((eb * f ) * suc i0 )) - ((eb * f ) * suc i0 ) ≡⟨ minus+y-y {_} {(eb * f ) * suc i0 } ⟩
eb * suc (suc j) ∎ where open ≡-Reasoning
gcd-euclid1 (suc zero) i0 zero j0 di = record { eqb = 1 ; eqa = Dividable.factor (GCD.div-i di) ; is-equ> = λ lt → ⊥-elim ( ge7' lt) ; is-equ< = λ _ → ge6'
; is-equ= = λ eq → ⊥-elim (nat-≡< (sym (minus<=0 (subst (λ k → k ≤ 1 * j0) (sym eq) refl-≤ ))) (subst (λ k → 0 < k) (sym ge6') a<sa )) } where
ge6' : (Dividable.factor (GCD.div-i di) * i0) - (1 * j0) ≡ gcd1 (suc zero) i0 zero j0
ge6' = begin
(Dividable.factor (GCD.div-i di) * i0) - (1 * j0) ≡⟨ cong (λ k → k - (1 * j0)) (+-comm 0 _) ⟩
(Dividable.factor (GCD.div-i di) * i0 + 0) - (1 * j0) ≡⟨ cong (λ k → k - (1 * j0)) (Dividable.is-factor (GCD.div-i di) ) ⟩
((j0 + 1) - zero) - (1 * j0) ≡⟨ refl ⟩
(j0 + 1) - (j0 + 0) ≡⟨ minus+yx-yz {_} {j0} {0} ⟩
1 ∎ where open ≡-Reasoning
ge7' : ¬ ( 1 * j0 > Dividable.factor (GCD.div-i di) * i0 )
ge7' lt = ⊥-elim ( nat-≡< (sym ( minus<=0 (<to≤ lt))) (subst (λ k → 0 < k) (sym ge6') (s≤s z≤n)))
gcd-euclid1 (suc (suc i)) i0 zero zero di = record { eqb = 0 ; eqa = 1 ; is-equ> = λ () ; is-equ< = λ _ → +-comm _ 0
; is-equ= = λ eq → subst (λ k → 0 ≡ k) (+-comm _ 0) (sym eq) }
gcd-euclid1 (suc (suc i)) i0 zero (suc j0) di with gcd-euclid1 (suc i) (suc (suc i)) j0 (suc j0) (GCD-sym (gcd-next1 (GCD-sym di)))
... | e = record { eqa = ea ; eqb = eb + ea * f
; is-equ= = λ eq → Euclid.is-equ= e (ge24 eq)
; is-equ< = λ lt → subst (λ k → ((ea * i0) - ((eb + ea * f) * suc j0)) ≡ k ) (Euclid.is-equ< e (ge3 lt ge4)) ge4
; is-equ> = λ lt → subst (λ k → (((eb + ea * f) * suc j0) - (ea * i0)) ≡ k ) (Euclid.is-equ> e (ge3 lt ge5)) ge5 } where
ea = Euclid.eqa e
eb = Euclid.eqb e
f = Dividable.factor (GCD.div-j di)
ge5 : (((eb + ea * f) * suc j0) - (ea * i0)) ≡ ((eb * suc j0) - (ea * suc (suc i)))
ge5 = begin
((eb + ea * f) * suc j0) - (ea * i0) ≡⟨ cong₂ (λ j k → j - k ) (proj1 (ge01 j0 i i0 eb ea (GCD-sym di) )) (proj2 (ge01 j0 i i0 eb ea (GCD-sym di) )) ⟩
( eb * suc j0 + (ea * f )* suc j0) - (ea * suc (suc i) + (ea * f )* suc j0) ≡⟨ minus+xy-zy {_} {(ea * f )* suc j0} {ea * suc (suc i)} ⟩
(eb * suc j0) - (ea * suc (suc i)) ∎ where open ≡-Reasoning
ge4 : ((ea * i0) - ((eb + ea * f) * suc j0)) ≡ ((ea * suc (suc i)) - (eb * suc j0))
ge4 = begin
(ea * i0) - ((eb + ea * f) * suc j0) ≡⟨ cong₂ (λ j k → j - k ) (proj2 (ge01 j0 i i0 eb ea (GCD-sym di) )) (proj1 (ge01 j0 i i0 eb ea (GCD-sym di) )) ⟩
(ea * suc (suc i) + (ea * f )* suc j0) - ( eb * suc j0 + (ea * f )* suc j0) ≡⟨ minus+xy-zy {ea * suc (suc i)} {(ea * f )* suc j0} { eb * suc j0} ⟩
(ea * suc (suc i)) - (eb * suc j0) ∎ where open ≡-Reasoning
ge24 : ea * i0 ≡ (eb + ea * f) * suc j0 → ea * suc (suc i) ≡ eb * suc j0
ge24 eq = begin
ea * suc (suc i) ≡⟨ sym ( minus+y-y {_} {(ea * f ) * suc j0 }) ⟩
(ea * suc (suc i) + (ea * f ) * suc j0 ) - ((ea * f ) * suc j0) ≡⟨ cong (λ k → k - ((ea * f ) * suc j0 )) (sym (proj2 (ge01 j0 i i0 eb ea (GCD-sym di) ))) ⟩
(ea * i0) - ((ea * f ) * suc j0) ≡⟨ cong (λ k → k - ((ea * f ) * suc j0 )) eq ⟩
((eb + ea * f) * suc j0) - ((ea * f ) * suc j0) ≡⟨ cong (λ k → k - ((ea * f ) * suc j0 )) ((proj1 (ge01 j0 i i0 eb ea (GCD-sym di)))) ⟩
( eb * suc j0 + (ea * f ) * suc j0 ) - ((ea * f ) * suc j0) ≡⟨ minus+y-y {_} {(ea * f ) * suc j0 } ⟩
eb * suc j0 ∎ where open ≡-Reasoning
gcd-euclid1 (suc zero) i0 (suc j) j0 di =
gcd-euclid1 zero i0 j j0 (gcd-next di)
gcd-euclid1 (suc (suc i)) i0 (suc j) j0 di =
gcd-euclid1 (suc i) i0 j j0 (gcd-next di)
ge12 : (p x : ℕ) → 0 < x → 1 < p → ((i : ℕ ) → i < p → 0 < i → gcd p i ≡ 1) → ( gcd p x ≡ 1 ) ∨ ( Dividable p x )
ge12 p x 0<x 1<p prime with decD {p} {x} 1<p
... | yes y = case2 y
... | no nx with <-cmp (gcd p x ) 1
... | tri< a ¬b ¬c = ⊥-elim ( nat-≤> a (s≤s (gcd>0 p x (<-trans a<sa 1<p) 0<x) ) )
... | tri≈ ¬a b ¬c = case1 b
... | tri> ¬a ¬b c = ⊥-elim ( nat-≡< (sym (prime (gcd p x) ge13 (<to≤ c) )) ge18 ) where
-- 1 < gcd p x
ge13 : gcd p x < p -- gcd p x ≡ p → ¬ nx
ge13 with <-cmp (gcd p x ) p
... | tri< a ¬b ¬c = a
... | tri≈ ¬a b ¬c = ⊥-elim ( nx (subst (λ k → Dividable k x) b (proj2 (gcd-dividable p x ))))
... | tri> ¬a ¬b c = ⊥-elim ( nat-≤> (gcd-≤ (<-trans a<sa 1<p) 0<x) c )
ge19 : Dividable (gcd p x) p
ge19 = proj1 (gcd-dividable p x )
ge18 : 1 < gcd p (gcd p x) -- Dividable p (gcd p x) → gcd p (gcd p x) ≡ (gcd p x) > 1
ge18 = subst (λ k → 1 < k ) (sym (div→gcd {p} {gcd p x} c ge19 )) c
gcd-euclid : ( p a b : ℕ ) → 1 < p → 0 < a → 0 < b → ((i : ℕ ) → i < p → 0 < i → gcd p i ≡ 1) → Dividable p (a * b) → Dividable p a ∨ Dividable p b
gcd-euclid p a b 1<p 0<a 0<b prime div-ab with decD {p} {a} 1<p
... | yes y = case1 y
... | no np = case2 ge16 where
f = Dividable.factor div-ab
ge10 : gcd p a ≡ 1
ge10 with ge12 p a 0<a 1<p prime
... | case1 x = x
... | case2 x = ⊥-elim ( np x )
ge11 : Euclid p a (gcd p a)
ge11 = gcd-euclid1 p p a a GCDi
ea = Euclid.eqa ge11
eb = Euclid.eqb ge11
ge18 : (f * eb) * p ≡ b * (a * eb )
ge18 = begin
(f * eb) * p ≡⟨ *-assoc (f) (eb) p ⟩
f * (eb * p) ≡⟨ cong (λ k → f * k) (*-comm _ p) ⟩
f * (p * eb ) ≡⟨ sym (*-assoc (f) p (eb) ) ⟩
(f * p ) * eb ≡⟨ cong (λ k → k * eb ) (+-comm 0 (f * p )) ⟩
(f * p + 0) * eb ≡⟨ cong (λ k → k * eb) (((Dividable.is-factor div-ab))) ⟩
(a * b) * eb ≡⟨ cong (λ k → k * eb) (*-comm a b) ⟩
(b * a) * eb ≡⟨ *-assoc b a (eb ) ⟩
b * (a * eb ) ∎ where open ≡-Reasoning
ge19 : ( ea * p ) ≡ ( eb * a ) → ((b * ea) - (f * eb)) * p + 0 ≡ b
ge19 eq = ⊥-elim ( nat-≡< (Euclid.is-equ= ge11 eq) (subst (λ k → 0 < k ) (sym ge10) a<sa ) )
ge14 : ( ea * p ) > ( eb * a ) → ((b * ea) - (f * eb)) * p + 0 ≡ b
ge14 lt = begin
(((b * ea) - (f * eb)) * p) + 0 ≡⟨ +-comm _ 0 ⟩
((b * ea) - ((f * eb)) * p) ≡⟨ distr-minus-* {_} {f * eb} {p} ⟩
((b * ea) * p) - (((f * eb) * p)) ≡⟨ cong (λ k → ((b * ea) * p) - k ) ge18 ⟩
((b * ea) * p) - (b * (a * eb )) ≡⟨ cong (λ k → k - (b * (a * eb)) ) (*-assoc b _ p) ⟩
(b * (ea * p)) - (b * (a * eb )) ≡⟨ sym ( distr-minus-*' {b} {ea * p} {a * eb} ) ⟩
b * (( ea * p) - (a * eb) ) ≡⟨ cong (λ k → b * ( ( ea * p) - k)) (*-comm a (eb)) ⟩
(b * ( (ea * p)) - (eb * a) ) ≡⟨ cong (b *_) (Euclid.is-equ< ge11 lt )⟩
b * gcd p a ≡⟨ cong (b *_) ge10 ⟩
b * 1 ≡⟨ m*1=m ⟩
b ∎ where open ≡-Reasoning
ge15 : ( ea * p ) < ( eb * a ) → ((f * eb) - (b * ea ) ) * p + 0 ≡ b
ge15 lt = begin
((f * eb) - (b * ea) ) * p + 0 ≡⟨ +-comm _ 0 ⟩
((f * eb) - (b * ea) ) * p ≡⟨ distr-minus-* {_} {b * ea} {p} ⟩
((f * eb) * p) - ((b * ea) * p) ≡⟨ cong (λ k → k - ((b * ea) * p) ) ge18 ⟩
(b * (a * eb )) - ((b * ea) * p ) ≡⟨ cong (λ k → (b * (a * eb)) - k ) (*-assoc b _ p) ⟩
(b * (a * eb )) - (b * (ea * p) ) ≡⟨ sym ( distr-minus-*' {b} {a * eb} {ea * p} ) ⟩
b * ( (a * eb) - (ea * p) ) ≡⟨ cong (λ k → b * ( k - ( ea * p) )) (*-comm a (eb)) ⟩
b * ( (eb * a) - (ea * p) ) ≡⟨ cong (b *_) (Euclid.is-equ> ge11 lt) ⟩
b * gcd p a ≡⟨ cong (b *_) ge10 ⟩
b * 1 ≡⟨ m*1=m ⟩
b ∎ where open ≡-Reasoning
ge17 : (x y : ℕ ) → x ≡ y → x ≤ y
ge17 x x refl = refl-≤
ge16 : Dividable p b
ge16 with <-cmp ( ea * p ) ( eb * a )
... | tri< a ¬b ¬c = record { factor = (f * eb) - (b * ea) ; is-factor = ge15 a }
... | tri≈ ¬a eq ¬c = record { factor = (b * ea) - ( f * eb) ; is-factor = ge19 eq }
... | tri> ¬a ¬b c = record { factor = (b * ea) - (f * eb) ; is-factor = ge14 c }
gcdmul+1 : ( m n : ℕ ) → gcd (m * n + 1) n ≡ 1
gcdmul+1 zero n = gcd204 n
gcdmul+1 (suc m) n = begin
gcd (suc m * n + 1) n ≡⟨⟩
gcd (n + m * n + 1) n ≡⟨ cong (λ k → gcd k n ) (begin
n + m * n + 1 ≡⟨ cong (λ k → k + 1) (+-comm n _) ⟩
m * n + n + 1 ≡⟨ +-assoc (m * n) _ _ ⟩
m * n + (n + 1) ≡⟨ cong (λ k → m * n + k) (+-comm n _) ⟩
m * n + (1 + n) ≡⟨ sym ( +-assoc (m * n) _ _ ) ⟩
m * n + 1 + n ∎
) ⟩
gcd (m * n + 1 + n) n ≡⟨ gcd+j (m * n + 1) n ⟩
gcd (m * n + 1) n ≡⟨ gcdmul+1 m n ⟩
1 ∎ where open ≡-Reasoning
m*n=m→n : {m n : ℕ } → 0 < m → m * n ≡ m * 1 → n ≡ 1
m*n=m→n {suc m} {n} (s≤s lt) eq = *-cancelˡ-≡ m eq
|
exercises/10-echo.als | xbreu/formal-methods | 0 | 786 | // Complete o seguinte modelo de um protocolo
// distribuído para formar uma spanning tree numa rede
// ----------------------------------------------------------------------------
// Definitions
// ----------------------------------------------------------------------------
sig Node {
adj : set Node, // Conjunto de nós vizinhos
var rcvd : set Node, // Nós dos quais já processou mensagens
var parent : lone Node, // O eventual pai do nó na spanning tree
var children : set Node, // Os eventuais filhos do nó na spanning tree
var inbox : set Message // Mensagens na inbox (nunca são apagadas)
}
one sig initiator extends Node {} // O nó que inicia o protocolo
// Tipos de mensagens
abstract sig Type {}
one sig Ping, Echo extends Type {}
// Mensagens enviadas
sig Message {
from : one Node, // Nó que enviou a mensagem
type : one Type // Tipo da mensagem
}
// Um nó considera-se ready quando já leu e processou mensagens de todos os
// seus vizinhos.
// E a execução do protocolo termina quando todos os nós estão ready.
fun ready : set Node {
{ n : Node | n.adj in n.rcvd }
}
// ----------------------------------------------------------------------------
// Configuration
// ----------------------------------------------------------------------------
// O grafo definido pela relação adj não tem lacetes.
fact SemLacetes {
}
// O grafo definido pela relação adj é não orientado.
fact NaoOrientado {
always {
adj = ~adj
}
}
// O grafo definido pela relação adj é ligado.
fact Ligado {
always {
all disj x, y : Node | y in (x . ^adj)
}
}
// Inicialmente rcvd, parent e children estão vazias e o initiator envia um
// Ping para todos os vizinhos
fact init {
no rcvd
no parent
no children
all n : Node | n in initiator . adj and {
n . inbox = { m : Message | m . type in Ping and m . from = initiator}
#{n . inbox} = 1
} or (n not in initiator . adj and no n . inbox)
}
// ----------------------------------------------------------------------------
// Events
// ----------------------------------------------------------------------------
// Um finish pode ocorrer quando um nó está ready, enviando esse nó uma
// mensagem do tipo Echo ao seu parent.
pred finish [n : Node] {
}
// Um read pode ocorrer quando um nó tem uma mensagem ainda não processada na
// sua inbox. Se o nó não é o initiator e é a primeira mensagem que processa
// (necessariamente um Ping) então o nó que enviou a mensagem passa a ser o seu
// parent na spanning tree e é enviado um Ping a todos os restantes vizinhos
// (todos menos o novo parent).
// Se a mensagem recebida é um Echo então o nó que enviou a mensagem é
// adicionado ao conjunto dos seus children na spanning tree.
pred read [n : Node] {
}
pred stutter {
rcvd' = rcvd
parent' = parent
children' = children
inbox' = inbox
}
fact transitions {
always (stutter or some n : Node | read[n] or finish[n])
}
// ----------------------------------------------------------------------------
// Properties
// ----------------------------------------------------------------------------
// Algumas invariantes:
// - O initiator nunca tem pai;
// - O pai tem sempre que ser um dos vizinhos;
// - Um nó só pode ser filho do seu pai.
assert Invariantes {
}
// A propriedade fundamental do protocolo:
// Quando todos os nós estão ready a relação children forma uma
// spanning tree com raiz no initiator.
assert SpanningTree {
}
check Invariantes
check SpanningTree
|
data/mapObjects/HallOfFame.asm | AmateurPanda92/pokemon-rby-dx | 9 | 166680 | HallOfFame_Object:
db $3 ; border block
db 2 ; warps
warp 4, 7, 2, CHAMPIONS_ROOM
warp 5, 7, 3, CHAMPIONS_ROOM
db 0 ; signs
db 1 ; objects
object SPRITE_OAK, 5, 2, STAY, DOWN, 1 ; person
; warp-to
warp_to 4, 7, HALL_OF_FAME_WIDTH ; CHAMPIONS_ROOM
warp_to 5, 7, HALL_OF_FAME_WIDTH ; CHAMPIONS_ROOM
|
ElementScripter.scpt | sancarn/Element-Scripter | 7 | 1620 | <reponame>sancarn/Element-Scripter
//Compiled to application with Automator.
//SIMULATE EXIT-SUB WITH BREAK:
Script: {
//Setup app for notifications.
var app = Application.currentApplication()
app.includeStandardAdditions = true
//Setup system element processing.
var system = Application('System Events')
system.includeStandardAdditions = true
var processes = system.processes()
var procTitles = []
for (var i = 0; i<processes.length; i++){
if (processes[i].title() != null) {
procTitles.push(i+1 + ': ' + processes[i].title())
}
}
var procName = system.chooseFromList(procTitles,{ withPrompt: 'Which application do you want to analyse?' })[0]
if (procName == undefined){
//EXIT-SUB
break Script
}
for (var i = 0; i<processes.length; i++){
if (i+1 + ': ' + processes[i].title() == procName) {
var proc = processes[i]
break
}
}
//Get correct window
var windows = proc.windows()
if (windows.length > 1){
var wndTitles = []
for (var i = 0; i<windows.length; i++){
if (proc.windows[i].title() != null) {
wndTitles.push(i+1 + ': ' + proc.windows[i].title())
}
}
var wndName = system.chooseFromList(wndTitles,{ withPrompt: 'Which window do you want to analyse?' })[0]
if (wndName == undefined){
//EXIT-SUB
break Script
}
for (var i = 0; i<windows.length; i++){
if (i+1 + ': ' + proc.windows[i].title() == wndName) {
var wnd = proc.windows[i]
break
}
}
//Remove "\d: " from start of wndName
wndName = wndName.substr(3)
} else if(windows.length == 1){
var wnd = proc.windows[0]
try {
var wndName = wnd.title()
} catch(e) {
wndName = procName
}
} else {
//Notify user that this may take a while
app.displayNotification('Cannot find any windows of process ' + procName, {
withTitle: 'Element Scripter',
//subtitle: 'Subtitle',
soundName: 'Sosumi'
})
//EXIT-SUB
break Script
}
//Notify user that this may take a while
app.displayNotification('Gathering GUI Elements from window "' + wndName + '" of process "' + procName + '". This may take a while...', {
withTitle: 'Element Scripter',
//subtitle: 'Subtitle',
soundName: 'Sosumi'
})
var elements = wnd.entireContents()
var a = []
var s = "Address|Title|Name|Description|Help|Role|Enabled|Focused|Position|Size|Value"
for(var i=0;i<elements.length;i++){
var el = elements[i]
s = s + "\n" + [Automation.getDisplayString(el),el.title(),el.name(),el.description(),el.help(),el.role(),el.enabled(),el.focused(),el.position(),el.size(),el.value()].join("|")
}
var textEdit = Application("TextEdit");
var newDoc = textEdit.Document().make();
newDoc.text = s
app.displayNotification('Elements from window "' + wndName + '" of process "' + procName + '" have been extracted into text edit.', {
withTitle: 'Element Scripter',
soundName: 'Sosumi'
})
//EXIT-SUB
break Script
//END-OF-SCRIPT
}
|
azcam_soguiders/dspcode/dspcode_maestroguider/gcam_ccid-21.asm | mplesser/azcam-soguiders | 0 | 14977 | ;*****************************************************************************
; GCAM.ASM -- DSP-BASED CCD CONTROLLER PROGRAM
;*****************************************************************************
PAGE 110,60,1,1
TABS 4
;*****************************************************************************
; Code modified for the CCID-21 29 June 2007 - <NAME>
; waveform code for driving SW and no TG
; Changes to parallel and serial clocking.
; parallel clocking in one direction, two serial patterns
; bright edge fix - RD, 08May13 MPL
;*****************************************************************************
;
;*****************************************************************************
; DEFINITIONS & POINTERS
;*****************************************************************************
START EQU $000100 ; program start location
SEQ EQU $000006 ; seq fragment length
DZ EQU $001000 ; DAC zero volt offset
WS EQU $073FE1 ; periph wait states
WS1 EQU $073FE1 ; 1 PERIPH 1 SRAM 31 EPROM
WS3 EQU $077FE1 ; 3 PERIPH 1 SRAM 31 EPROM
WS5 EQU $07BFE1 ; 5 PERIPH 1 SRAM 31 EPROM
;*****************************************************************************
; COMPILE-TIME OPTIONS
;*****************************************************************************
VERSION EQU $1 ;
RDMODE EQU $0 ;
HOLD_P EQU $020A ; P clock timing $20A=40us
HOLD_FT EQU $007C ; FT clock timing $7C=10us xfer
HOLD_FL EQU $007C ; FL clock timimg
HOLD_S EQU $000F ; S clock timing (leave at $000F)
HOLD_RG EQU $0008 ; RG timing
HOLD_PL EQU $1F40 ; pre-line settling (1F40=100us)
HOLD_FF EQU $0020 ; FF clock timimg
HOLD_IPC EQU $1F40 ; IPC clock timing ($1F40=100us)
HOLD_SIG EQU $001F ; preamp settling time
HOLD_ADC EQU $00AF ; pre-sample settling
INIT_NROWS EQU $20A ; $20A=(512+10)
INIT_NCOLS EQU $204 ; $204=(512+4)
INIT_NFT EQU $200 ; $200-(512) frame-transfer device
INIT_NFLUSH EQU $200 ; $200=(512)
INIT_NCH EQU $2 ;
INIT_VBIN EQU $2 ;
INIT_HBIN EQU $2 ;
INIT_VSKIP EQU $0 ;
INIT_HSKIP EQU $0 ;
INIT_GAIN EQU $0 ; 0=LOW 1=HIGH
INIT_USEC EQU $C8 ;
INIT_OPCH EQU $1 ; 0x1=right 0x2=left 0x3=both 0x4=all
INIT_SCLKS EQU $2 ; 1=right amp, 2=left amp
INIT_PID EQU $0 ; FLAG $0=OFF $1=ON
INIT_LINK EQU $0 ; 0=wire 1=single_fiber
INIT_PDIR EQU $2 ; parallel clocking direction
; 0=toward serial register 1=away
;*****************************************************************************
; EXTERNAL PERIPHERAL DEFINITIONS (GUIDER CAMERA)
;*****************************************************************************
SEQREG EQU $FFFF80 ; external CCD clock register
ADC_A EQU $FFFF81 ; A/D converter #1
ADC_B EQU $FFFF82 ; A/D converter #2
TXREG EQU $FFFF85 ; Transmit Data Register
RXREG EQU $FFFF86 ; Receive Data register
SIG_AB EQU $FFFF88 ; bias voltages A+B
CLK_AB EQU $FFFF90 ; clock voltages A+B
TEC_REG EQU $FFFF8A ; TEC register
;*****************************************************************************
; INTERNAL PERIPHERAL DEFINITIONS (DSP563000)
;*****************************************************************************
IPRC EQU $FFFFFF ; Interrupt priority register (core)
IPRP EQU $FFFFFE ; Interrupt priority register (periph)
PCTL EQU $FFFFFD ; PLL control register
BCR EQU $FFFFFB ; Bus control register (wait states)
AAR0 EQU $FFFFF9 ; Address attribute register 0
AAR1 EQU $FFFFF8 ; Address attribute register 1
AAR2 EQU $FFFFF7 ; Address attribute register 2
AAR3 EQU $FFFFF6 ; Address attribute register 3
IDR EQU $FFFFF5 ; ID Register
PDRB EQU $FFFFC9 ; Port B (HOST) GPIO data
PRRB EQU $FFFFC8 ; Port B (HOST) GPIO direction
PCRB EQU $FFFFC4 ; Port B (HOST) control register
PCRC EQU $FFFFBF ; Port C (ESSI_0) control register
PRRC EQU $FFFFBE ; Port C (ESSI_0) direction
PDRC EQU $FFFFBD ; Port C (ESSI_0) data
TXD EQU $FFFFBC ; ESSI0 Transmit Data Register 0
RXD EQU $FFFFB8 ; ESSI0 Receive Data Register
SSISR EQU $FFFFB7 ; ESSI0 Status Register
CRB EQU $FFFFB6 ; ESSI0 Control Register B
CRA EQU $FFFFB5 ; ESSI0 Control Register A
PCRD EQU $FFFFAF ; Port D (ESSI_1) control register
PRRD EQU $FFFFAE ; Port D (ESSI_1) direction
PDRD EQU $FFFFAD ; Port D (ESSI_1) data
PCRE EQU $FFFF9F ; Port E (SCI) control register
PRRE EQU $FFFF9E ; Port E (SCI) data direction
PDRE EQU $FFFF9D ; Port E (SCI) data
TCSR0 EQU $FFFF8F ; TIMER0 Control/Status Register
TLR0 EQU $FFFF8E ; TIMER0 Load Reg
TCPR0 EQU $FFFF8D ; TIMER0 Compare Register
TCR0 EQU $FFFF8C ; TIMER0 Count Register
TCSR1 EQU $FFFF8B ; TIMER1 Control/Status Register
TLR1 EQU $FFFF8A ; TIMER1 Load Reg
TCPR1 EQU $FFFF89 ; TIMER1 Compare Register
TCR1 EQU $FFFF88 ; TIMER1 Count Register
TCSR2 EQU $FFFF87 ; TIMER2 Control/Status Register
TLR2 EQU $FFFF86 ; TIMER2 Load Reg
TCPR2 EQU $FFFF85 ; TIMER2 Compare Register
TCR2 EQU $FFFF84 ; TIMER2 Count Register
TPLR EQU $FFFF83 ; TIMER Prescaler Load Register
TPCR EQU $FFFF82 ; TIMER Prescalar Count Register
DSR0 EQU $FFFFEF ; DMA source address
DDR0 EQU $FFFFEE ; DMA dest address
DCO0 EQU $FFFFED ; DMA counter
DCR0 EQU $FFFFEC ; DMA control register
;*****************************************************************************
; REGISTER DEFINITIONS (GUIDER CAMERA)
;*****************************************************************************
CMD EQU $000000 ; command word/flags from host
OPFLAGS EQU $000001 ; operational flags
NROWS EQU $000002 ; number of rows to read
NCOLS EQU $000003 ; number of columns to read
NFT EQU $000004 ; number of rows for frame transfer
NFLUSH EQU $000005 ; number of columns to flush
NCH EQU $000006 ; number of output channels (amps)
NPIX EQU $000007 ; (not used)
VBIN EQU $000008 ; vertical (parallel) binning
HBIN EQU $000009 ; horizontal (serial) binning
VSKIP EQU $00000A ; V prescan or offset (rows)
HSKIP EQU $00000B ; H prescan or offset (columns)
VSUB EQU $00000C ; V subraster size
HSUB EQU $00000D ; H subraster size
NEXP EQU $00000E ; number of exposures (not used)
NSHUFFLE EQU $00000F ; (not used)
EXP_TIME EQU $000010 ; CCD integration time(r)
TEMP EQU $000011 ; Temperature sensor reading(s)
GAIN EQU $000012 ; Sig_proc gain
USEC EQU $000013 ; Sig_proc sample time
OPCH EQU $000014 ; Output channel
HDIR EQU $000015 ; serial clock direction
LINK EQU $000016 ; 0=wire 1=single_fiber
PDIR EQU $000017 ; parallel direction
SCLKS EQU $000030 ; serial clocks
SCLKS_FL EQU $000031 ; serial clocks flush
INT_X EQU $000032 ; reset and integrate clocks
NDMA EQU $000033 ; (not used)
PCLKS EQU $000034 ; parallel clocks
VBIAS EQU $000018 ; bias voltages
VCLK EQU $000020 ; clock voltages
TEC EQU $00001A ; TEC current
PIX EQU $000300 ; start address for data storage
;*****************************************************************************
; SEQUENCE FRAGMENT STARTING ADDRESSES (& OTHER POINTERS)
;*****************************************************************************
MPP EQU $0040 ; MPP/hold state
IPCLKS EQU $0042 ; input clamp
TCLKS EQU $0044 ; Temperature monitor clocks
PCLKS_FTU EQU $0048 ; parallel frame transfer, upper
PCLKS_RDU EQU $0050 ; parallel read-out transfer, upper
PCLKS_FLU EQU $0058 ; parallel flush transfer, upper
PCLKS_FTL EQU $0060 ; parallel frame transfer, lower
PCLKS_RDL EQU $0068 ; parallel read-out transfer, lower
PCLKS_FLL EQU $0070 ; parallel flush transfer, lower
PCLKS_FLB EQU $0078 ; parallel flush transfer, both
INT_L EQU $0080 ; reset and first integration
INT_H EQU $0088 ; second integration and A/D
SCLKS_R EQU $0090 ; serial clocks shift right
SCLKS_FLR EQU $0098 ; serial clocks flush right
SCLKS_L EQU $00A0 ; serial clocks shift left
SCLKS_FLL EQU $00A8 ; serial clocks flush left
SCLKS_B EQU $00B0 ; serial clocks both
SCLKS_FLB EQU $00B8 ; serial clocks flush both
SCLKS_FF EQU $00C0 ; serial clocks fast flush
;*******************************************************************************
; INITIALIZE X MEMORY AND DEFINE PERIPHERALS
;*******************************************************************************
ORG X:CMD ; CCD control information
DC $0 ; CMD/FLAGS
DC $0 ; OPFLAGS
DC INIT_NROWS ; NROWS
DC INIT_NCOLS ; NCOLS
DC INIT_NFT ; NFT
DC INIT_NFLUSH ; NFLUSH
DC INIT_NCH ; NCH
DC $1 ; NPIX (not used)
DC INIT_VBIN ; VBIN
DC INIT_HBIN ; HBIN
DC INIT_VSKIP ; VSKIP ($0)
DC INIT_HSKIP ; HSKIP ($0)
DC $0 ; VSUB
DC $0 ; HSUB
DC $1 ; NEXP (not used)
DC $0 ; (not used)
ORG X:EXP_TIME
DC $3E8 ; EXP_TIME
DC $0 ; TEMP
DC INIT_GAIN ; GAIN
DC INIT_USEC ; USEC SAMPLE TIME
DC INIT_OPCH ; OUTPUT CHANNEL
DC INIT_SCLKS ; HORIZ DIRECTION
DC INIT_LINK ; SERIAL LINK
DC INIT_PDIR ; VERTICAL DIRECTION
;*****************************************************************************
; CCD57 SET DAC VOLTAGES DEFAULTS: OD=20V RD=8V OG=ABG=-6V
; PCLKS=+3V -9V SCLKS=+2V -8V RG=+3V -9V
;
; CCID37 SET DAC VOLTAGES DEFAULTS: OD=18V RD=10V OG=-2V
; PCLKS=+4V -6V SCLKS=+4V -4V RG=+8V -2V
;
; STA1220A SET DAC VOLTAGES DEFAULTS: OD=24V RD=15V OG=-1V
; PCLKS=+4V -9V SCLKS=+5V -5V RG=+8V 0V SW=+5V -5V TG=+4V -9V
;
; CCID-21 SET DAC VOLTAGES DEFAULTS: OD=18V RD=10V OG=-2V
; PCLKS=+4V -6V SCLKS=+4V -4V SW=+5 -5V RG=+8V -2V B7=-6V B5=+12 to +15V
;*****************************************************************************
ORG X:VBIAS
DC (DZ-0000) ; OFFSET_R (5mV/DN) (0480)
DC (DZ-0000) ; OFFSET_L
DC (DZ-1600) ; B7
DC (DZ-0200) ; OG voltage
DC (DZ+1300) ; B5 (10 mV/DN) 1200
DC (DZ+1300) ; RD 1000
DC (DZ+1800) ; OD_R 2200
DC (DZ+1800) ; OD_L 2200
ORG X:VCLK
DC (DZ-0000) ; IPC- [V0] voltage (5mV/DN) (0v)
DC (DZ+1000) ; IPC+ [V1] (+5v)
DC (DZ-0400) ; RG- [V2] (-2v)
DC (DZ+1600) ; RG+ [V3] (+8v)
DC (DZ-1000) ; S- [V4] (-5v)
DC (DZ+1000) ; S+ [V5] (+5v)
DC (DZ-1000) ; SW- [V6] (-5v)
DC (DZ+1000) ; SW+ [V7] (+5v)
DC (DZ-0000) ; TG- [V8] (-9v)
DC (DZ+0000) ; TG+ [V9] (+4v)
DC (DZ-1200) ; P1- [V10] (-6v)
DC (DZ+0800) ; P1+ [V11] (+4v)
DC (DZ-1200) ; P2- [V12] (-6v)
DC (DZ+0800) ; P2+ [V13] (+4v)
DC (DZ-1200) ; P3- [V14] (-6v)
DC (DZ+0800) ; P3+ [V15] (+4v)
;*****************************************************************************
; INITIALIZE X MEMORY
;*****************************************************************************
; R2L _______________ ________________ R1L
; R3L ______________ || _______________ R3R
; SW _____________ |||| ______________ R2R
; TG ____________ |||||| _____________ R1R
; ST1 ___________ |||||||| ____________ RG
; ST2 __________ |||||||||| ___________ IPC
; ST3 _________ |||||||||||| __________ FINT+
; IM1 ________ |||||||||||||| _________ FINT-
; IM2 _______ |||||||||||||||| ________ FRST
; IM3 ______ |||||||||||||||||| _______ CONVST
; ||||||||||||||||||||
ORG X:MPP ; reset/hold state
DC %000001001001011011000011
ORG X:IPCLKS ; input clamp
DC %000001001001011011010011
DC %000001001001011011000011
ORG X:TCLKS ; read temp monitor
DC %000001001001011011000010
DC %000001001001011011000011
ORG X:PCLKS_FTU ; frame transfer upper P2-P1-P3-P2
DC %000001101101011011000011 ; reverse direction
DC %000000100101011011000011
DC %000010110101011011000011
DC %000010010001011011000011
DC %000011011001011011000011
DC %000001001001011011000011
ORG X:PCLKS_RDU ; parallel transfer upper P2-P1-P3-P2
DC %000001001101011011010011 ; reverse direction
DC %000001000101011011010011
DC %000001010101011011010011
DC %000001010001011011000011
DC %000001011001011011010011
DC %000001001001011011010011
ORG X:PCLKS_FLU ; parallel flush upper P2-P1-P3-P2
DC %000001101101011011000011 ; reverse direction
DC %000000100101011011000011
DC %000010110101011011000011
DC %000010010001011011000011
DC %000011011001011011000011
DC %000001001001011011000011
ORG X:PCLKS_FTL ; frame transfer lower P2-P3-P1-P2
DC %000011011001011011000011 ; normal direction
DC %000010010001011011000011
DC %000010110101011011000011
DC %000000100101011011000011
DC %000001101101011011000011
DC %000001001001011011000011
ORG X:PCLKS_RDL ; parallel transfer lower P2-P3-P1-P2
DC %000001011001011011010011 ; normal direction
DC %000001010001011011010011
DC %000001010101011011010011
DC %000001000101011011010011
DC %000001001101011011010011
DC %000001001001011011000011
ORG X:PCLKS_FLL ; parallel flush lower P2-P3-P1-P2
DC %000011011001011011000011 ; normal direction
DC %000010010001011011000011
DC %000010110101011011000011
DC %000000100101011011000011
DC %000001101101011011000011
DC %000001001001011011000011
ORG X:PCLKS_FLB ; parallel flush both
DC %000001111001011011000011 ; place-holder
DC %000000110001011011000011
DC %000010110101011011000011
DC %000010000101011011000011
DC %000011001101011011000011
DC %000001001001011011000011
ORG X:INT_L ; reset and first integration
DC %000001001001011011100011 ; RG ON FRST ON
DC %000001001001011011000011 ; RG OFF
DC %000001001001011011000001 ; FRST OFF
DC %000001001001011011001001 ; FINT+ ON
DC %000001001001011011000001 ; FINT+ OFF
ORG X:INT_H ; second integration and A to D
DC %000001001000011011000101 ; FINT- ON
DC %000001001000011011000001 ; FINT- OFF
DC %000001001000011011000000 ; /CONVST ON
DC %000001001000011011000001 ; /CONVST OFF
DC %000001001001011011100011 ; FRST ON RG ON
ORG X:SCLKS_R ; serial shift (right) S2-S1-S3-S2
DC %000001001001001001000001
DC %000001001001101101000001
DC %000001001001100100000001
DC %000001001001110110000001
DC %000001001001010010000001
DC %000001001001011011000001
ORG X:SCLKS_FLR ; serial flush (right) S2-S1-S3-S2
DC %000001001001001001100011
DC %000001001001101101100011
DC %000001001001100100100011
DC %000001001001110110100011
DC %000001001001010010100011
DC %000001001001011011100011
ORG X:SCLKS_L ; serial shift (left) S2-S3-S1-S2
DC %000001001001010010000001
DC %000001001001110110000001
DC %000001001001100100000001
DC %000001001001101101000001
DC %000001001001001001000001
DC %000001001001011011000001
ORG X:SCLKS_FLL ; serial flush (left) S2-S3-S1-S2
DC %000001001001010010100011
DC %000001001001110110100011
DC %000001001001100100100011
DC %000001001001101101100011
DC %000001001001001001100011
DC %000001001001011011100011
ORG X:SCLKS_B ; serial shift (both) not used, not changed
DC %000001001001010001000001
DC %000001001001110101000001
DC %000001001001100100000001
DC %000001001001101110000001
DC %000001001001001010000001
DC %000001001001011011000001
ORG X:SCLKS_FLB ; serial flush (both) not used, not changed
DC %000001001001010001100011
DC %000001001001110101100011
DC %000001001001100100100011
DC %000001001001101110100011
DC %000001001001001010100011
DC %000001001001011011100011
ORG X:SCLKS_FF ; serial flush (fast)
DC %000001001001111111100011
DC %000001001001111111100011
DC %000001001001111111100011
DC %000001001001011011000011
DC %000001001001011011000011 ; dummy code
DC %000001001001011011000011 ; dummy code
;*******************************************************************************
; GENERAL COMMENTS
;*******************************************************************************
; Hardware RESET causes download from serial port (code in EPROM)
; R0 is a pointer to sequence fragments
; R1 is a pointer used by send/receive routines
; R2 is a pointer to the current data location
; See dspdvr.h for command and opflag definitions
;*******************************************************************************
; INITIALIZE INTERRUPT VECTORS
;*******************************************************************************
ORG P:$0000
JMP START
;*******************************************************************************
; MAIN PROGRAM
;*******************************************************************************
ORG P:START
SET_MODE ORI #$3,MR ; mask all interrupts
MOVEP #$FFFC21,X:AAR3 ; PERIPH $FFF000--$FFFFFF
MOVEP #$D00909,X:AAR1 ; EEPROM $D00000--$D07FFF 32K
MOVEP #$000811,X:AAR0 ; SRAM X $000000--$00FFFF 64K
MOVEP #WS,X:BCR ; Set periph wait states
MOVE #SEQ-1,M0 ; Set sequencer address modulus
PORTB_SETUP MOVEP #>$1,X:PCRB ; set PB[15..0] GPIO
PORTD_SETUP MOVEP #>$0,X:PCRD ; GPIO PD0=TM PD1=GAIN
MOVEP #>$3,X:PRRD ; PD2=/ENRX PD3=/ENTX
MOVEP #>$0,X:PDRD ; PD4=RXRDY
SSI_SETUP MOVEP #>$032070,X:CRB ; async, LSB, enable TE RE
MOVEP #>$140803,X:CRA ; 10 Mbps, 16 bit word
MOVEP #>$3F,X:PCRC ; enable ESSI
PORTE_SETUP MOVEP #$0,X:PCRE ; enable GPIO, disable SCI
MOVEP #>$1,X:PRRE ; PE0=SHUTTER
MOVEP #>$0,X:PDRE ;
SET_TIMER MOVEP #$300A10,X:TCSR0 ; Pulse mode, no prescale
MOVEP #$0,X:TLR0 ; timer reload value
MOVEP X:USEC,X:TCPR0 ; timer compare value
MOVEP #$308A10,X:TCSR1 ; Pulse mode, prescaled
MOVEP #$0,X:TLR1 ; timer reload value
MOVEP X:EXP_TIME,X:TCPR1 ; timer compare value
MOVEP #>$9C3F,X:TPLR ; timer prescale ($9C3F=1ms 80MHz)
DMA_SETUP MOVEP #PIX,X:DSR0 ; set DMA source
MOVEP #$0,X:DCO0 ; set DMA counter
FIBER JCLR #$0,X:LINK,RS485 ; set up optical
MOVEP #>TXREG,X:DDR0 ; set DMA destination
MOVEP #>$080255,X:DCR0 ; DMA word xfer, /IRQA, src+1
RS485 JSET #$0,X:LINK,ENDDP ; set up RS485
MOVEP #>TXD,X:DDR0 ; DMA destination
MOVEP #>$085A51,X:DCR0 ; DMA word xfer, TDE0, src+1
ENDDP NOP ;
INIT_SETUP JSR MPPHOLD ;
JSR SET_GAIN ;
JSR SET_DACS ;
JSR SET_SCLKS ;
WAIT_CMD JSR FLUSHROWS ; added 30 Mar 07 - RAT
JCLR #$0,X:LINK,WAITB ; check for cmd ready
JCLR #$4,X:PDRD,ECHO ; fiber link (single-fiber)
WAITB JSET #$0,X:LINK,ENDW ;
JCLR #7,X:SSISR,ECHO ; wire link
ENDW NOP ;
JSR READ16 ; wait for command word
MOVE A1,X:CMD ; cmd in X:CMD
JSR CMD_FIX ; interpret command word
ECHO JCLR #$1,X:CMD,GET ; test for DSP_ECHO command
JSR READ16 ;
JSR WRITE16 ;
BCLR #$1,X:CMD ;
GET JCLR #$2,X:CMD,PUT ; test for DSP_GET command
JSR MEM_SEND ;
BCLR #$2,X:CMD ;
PUT JCLR #$3,X:CMD,EXP_START ; test for DSP_PUT command
JSR MEM_LOAD ;
BCLR #$3,X:CMD ;
EXP_START JCLR #$6,X:CMD,FASTFLUSH ; test for EXPOSE command
JSR MPPHOLD ;
MOVE #PIX,R2 ; set data pointer
MOVEP X:EXP_TIME,X:TCPR1 ; timer compare value
BSET #$F,X:OPFLAGS ; set exp_in_progress flag
BCLR #$6,X:CMD ;
JCLR #$1,X:OPFLAGS,FASTFLUSH ; check for AUTO_FLUSH
BSET #$4,X:CMD ;
FASTFLUSH JCLR #$4,X:CMD,BEAM_ON ; test for FLUSH command
JSR FLUSHFRAME ; fast FLUSH
JSR FLUSHFRAME ; fast FLUSH
JSR FLUSHFRAME ; fast FLUSH
JSR FLUSHLINE ; clear serial register
BCLR #$4,X:CMD ;
BEAM_ON JCLR #$5,X:CMD,EXPOSE ; test for open shutter
BSET #$0,X:PDRE ; set SHUTTER
BCLR #$5,X:CMD ;
EXPOSE JCLR #$F,X:OPFLAGS,BEAM_OFF ; check exp_in_progress flag
JSR MPPHOLD ;
JSR M_TIMER ;
BCLR #$F,X:OPFLAGS ; clear exp_in_progress flag
OPT_A JCLR #$2,X:OPFLAGS,OPT_B ; check for AUTO_SHUTTER
BSET #$7,X:CMD ; prep to close shutter
OPT_B JCLR #$4,X:OPFLAGS,BEAM_OFF ; check for AUTO_READ
BSET #$8,X:CMD ; prep for full readout
BEAM_OFF JCLR #$7,X:CMD,READ_CCD ; test for shutter close
BCLR #$0,X:PDRE ; clear SHUTTER
BCLR #$7,X:CMD ;
READ_CCD JCLR #$8,X:CMD,AUTO_WIPE ; test for READCCD command
JSR FRAME ; frame transfer
; JSR IPC_CLAMP ; discharge ac coupling cap
JSR FLUSHROWS ; vskip
DO X:NROWS,END_READ ; read the array
JSR FLUSHLINE ;
JSR PARALLEL ;
JSR FLUSHPIX ; hskip
BSET #$0,X:OPFLAGS ; set first pixel flag
JSR READPIX ;
BCLR #$0,X:OPFLAGS ; clear first pixel flag
JSR READLINE ;
END_READ NOP ;
BCLR #$8,X:CMD ;
AUTO_WIPE JCLR #$9,X:CMD,HH_DACS ; test for AUTOWIPE command
; BSET #$E,X:OPFLAGS ;
; BSET #$5,X:OPFLAGS ;
; JSR FL_CLOCKS ; flush one parallel row
; JSR READLINE ;
; BCLR #$9,X:CMD ;
HH_DACS JCLR #$A,X:CMD,HH_TEMP ; test for HH_SYNC command
JSR SET_DACS ;
BCLR #$A,X:CMD ;
HH_TEMP JCLR #$B,X:CMD,HH_TEC ; test for HH_TEMP command
JSR TEMP_READ ; perform housekeeping chores
BCLR #$B,X:CMD ;
HH_TEC JCLR #$C,X:CMD,HH_OTHER ; test for HH_TEC command
JSR TEMP_SET ; set the TEC value
BCLR #$C,X:CMD ;
HH_OTHER JCLR #$D,X:CMD,END_CODE ; test for HH_OTHER command
JSR SET_GAIN ;
JSR SET_SCLKS ;
JSR SET_USEC ;
BCLR #$D,X:CMD ;
END_CODE JCLR #$5,X:OPFLAGS,WAIT_CMD ; check for AUTO_WIPE
BSET #$9,X:CMD ;
JMP WAIT_CMD ; Get next command
;*****************************************************************************
; HOLD (MPP MODE)
;*****************************************************************************
MPPHOLD MOVEP X:MPP,Y:<<SEQREG ;
RTS ;
;*****************************************************************************
; INPUT CLAMP
;*****************************************************************************
IPC_CLAMP MOVEP X:IPCLKS,Y:<<SEQREG ;
MOVE #>HOLD_IPC,X0 ;
REP X0 ; $1F4O=100 us
NOP ;
MOVEP X:(IPCLKS+1),Y:<<SEQREG ;
NOP ;
RTS ;
;*****************************************************************************
; FLUSHLINE (FAST FLUSH)
;*****************************************************************************
FLUSHLINE MOVE #SCLKS_FF,R0 ; initialize pointer
DO #SEQ,ENDFF ;
MOVEP X:(R0)+,Y:<<SEQREG ;
REP #HOLD_FF ;
NOP ;
ENDFF RTS ;
;*****************************************************************************
; FLUSHPIX (HSKIP)
;*****************************************************************************
FLUSHPIX DO X:HSKIP,ENDFP ;
MOVE X:SCLKS_FLR,R0 ; initialize pointer (modified -RAT)
DO #SEQ,ENDHCLK ;
MOVEP X:(R0)+,Y:<<SEQREG ;
REP #HOLD_S ;
NOP ;
ENDHCLK NOP ;
ENDFP RTS ;
;*****************************************************************************
; FLUSHROWS (VSKIP)
;*****************************************************************************
FLUSHROWS DO X:VSKIP,ENDVSKIP ;
JCLR #$2,X:PDIR,FLUSHRU ; check for parallel direction
MOVE #PCLKS_RDL,R0 ; initialize pointer (modified -RAT)
JMP FLUSHRL ; lower direction
FLUSHRU MOVE #PCLKS_RDU,R0 ; upper direction
FLUSHRL DO #SEQ,ENDVCLK ;
MOVEP X:(R0)+,Y:<<SEQREG ;
REP #HOLD_FL ;
NOP ;
ENDVCLK NOP ;
ENDVSKIP RTS ;
;*****************************************************************************
; FLUSHFRAME
;*****************************************************************************
FLUSHFRAME DO X:NFLUSH,ENDFLFR ;
JCLR #$2,X:PDIR,FLUSHFU ; check for parallel direction
FL_CLOCKS MOVE #PCLKS_FLL,R0 ; initialize pointer (modified -RAT)
JMP FLUSHFL ; lower direction
FLUSHFU MOVE #PCLKS_FLU,R0 ; upper direction
FLUSHFL DO #SEQ,ENDFLCLK ;
MOVEP X:(R0)+,Y:<<SEQREG ;
REP #HOLD_FL ;
NOP ;
ENDFLCLK NOP ;
ENDFLFR RTS ;
;*****************************************************************************
; PARALLEL TRANSFER (READOUT)
;*****************************************************************************
PARALLEL DO X:VBIN,ENDPT ;
JCLR #$2,X:PDIR,PARROU ; check for parallel direction
MOVE #PCLKS_RDL,R0 ; initialize pointer (modified -RAT)
JMP P_CLOCKS ; lower direction
PARROU MOVE #PCLKS_RDL,R0 ; upper direction (test - 28jun07 RAT)
P_CLOCKS DO #SEQ,ENDPCLK ;
MOVEP X:(R0)+,Y:<<SEQREG ;
MOVE #>HOLD_P,X0 ;
REP X0 ; $317=10us per phase
NOP ;
ENDPCLK NOP ;
ENDPT RTS ;
;*****************************************************************************
; PARALLEL TRANSFER (FRAME TRANSFER)
;*****************************************************************************
FRAME JCLR #$2,X:PDIR,FLUSHFTU ; check for parallel direction (modified -RAT)
MOVEP X:(PCLKS_FTL),Y:<<SEQREG ; 100 us CCD47 pause
JMP FLUSHFTL ; lower direction
FLUSHFTU MOVEP X:(PCLKS_FTL),Y:<<SEQREG ; upper direction (test - 28jun07 RAT)
FLUSHFTL MOVE #>$1F40,X0 ;
REP X0 ; $1F40=100 usec
NOP ;
JCLR #$2,X:PDIR,FTU_CLOCKS ; check for parallel direction (modified -RAT)
DO X:NFT,ENDFTL ;
MOVE #PCLKS_FTL,R0 ; initialize seq pointer
DO #SEQ,ENDFTLCLK ;
MOVEP X:(R0)+,Y:<<SEQREG ;
REP #HOLD_FT ;
NOP ;
ENDFTLCLK NOP ;
ENDFTL RTS ;
FTU_CLOCKS DO X:NFT,ENDFTU ;
MOVE #PCLKS_FTL,R0 ; initialize seq pointer (test - 28jun07 RAT)
DO #SEQ,ENDFTUCLK ;
MOVEP X:(R0)+,Y:<<SEQREG ;
REP #HOLD_FT ;
NOP ;
ENDFTUCLK NOP ;
ENDFTU RTS ;
;*****************************************************************************
; READLINE SUBROUTINE
;*****************************************************************************
READLINE DO X:NCOLS,ENDRL ;
READPIX MOVEP X:(INT_L),Y:<<SEQREG ; FRST=ON RG=ON
DUP HOLD_RG ; macro
NOP ;
ENDM ; end macro
MOVEP X:(INT_L+1),Y:<<SEQREG ; RG=OFF
MOVEP X:(INT_L+2),Y:<<SEQREG ; FRST=OFF
REP #HOLD_SIG ; preamp settling time
; REP #$F ; preamp settling
NOP ;
INT1 MOVEP X:(INT_L+3),Y:<<SEQREG ; FINT+=ON
SLEEP1 MOVE X:USEC,X0 ; sleep USEC * 12.5ns
REP X0 ;
NOP ;
MOVEP X:(INT_L+4),Y:<<SEQREG ; FINT+=OFF
SERIAL MOVE X:SCLKS,R0 ; serial transfer
DO X:HBIN,ENDSCLK ;
S_CLOCKS DUP SEQ ; macro
MOVEP X:(R0)+,Y:<<SEQREG ;
DUP HOLD_S ; macro
NOP ;
ENDM ;
ENDM ;
ENDSCLK REP #HOLD_SIG ; preamp settling time
NOP ; (adjust with o'scope)
GET_DATA MOVEP #WS5,X:BCR ;
NOP ;
NOP ;
MOVEP Y:<<ADC_A,A ; read ADC
MOVEP Y:<<ADC_B,B ; read ADC
MOVEP #WS,X:BCR ;
NOP ;
INT2 MOVEP X:(INT_H),Y:<<SEQREG ; FINT-=ON
SLEEP2 MOVE X:USEC,X0 ; sleep USEC * 20ns
REP X0 ;
NOP ;
MOVEP X:(INT_H+1),Y:<<SEQREG ; FINT-=OFF
MOVE A1,Y:(PIX) ;
MOVE B1,Y:(PIX+1) ;
REP #HOLD_ADC ; settling time
NOP ; (adjust for best noise)
CONVST MOVEP X:(INT_H+2),Y:<<SEQREG ; /CONVST=ON
MOVEP N5,X:DSR0 ; set DMA source
NOP ;
NOP ;
MOVEP X:(INT_H+3),Y:<<SEQREG ; /CONVST=OFF MIN 40 NS
MOVEP X:(INT_H+4),Y:<<SEQREG ; FRST=ON
JSET #$0,X:OPFLAGS,ENDCHK ; check for first pixel
BSET #$17,X:DCR0 ; enable DMA
ENDCHK NOP ;
ENDRL RTS ;
;*******************************************************************************
; READ AND WRITE 16-BIT AND 24-BIT DATA
;*******************************************************************************
READ16 JCLR #$0,X:LINK,RD16B ; check RS485 or fiber
JCLR #$4,X:PDRD,* ; wait for data in RXREG
MOVE Y:RXREG,A ; bits 15..0
AND #>$FFFF,A ;
RD16B JSET #$0,X:LINK,ENDRD16 ; check RS485 or fiber
JCLR #7,X:SSISR,* ; wait for RDRF to go high
MOVE X:RXD,A1 ; read from ESSI
NOP ;
ENDRD16 RTS ; 16-bit word in A1
WRITE16 JCLR #$0,X:LINK,WR16B ; check RS485 or fiber
MOVE A1,Y:TXREG ; write bits 15..0
WR16B JSET #$0,X:LINK,ENDWR16 ;
JCLR #6,X:SSISR,* ; wait for TDE
MOVE A1,X:TXD ;
ENDWR16 RTS ;
READ24 JCLR #$0,X:LINK,RD24B ; check RS485 or fiber
JCLR #$4,X:PDRD,* ; wait for data in RXREG
MOVE Y:RXREG,A ; bits 15..0
AND #>$FFFF,A ;
ASR #$10,A,A ; shift right 16 bits
JCLR #$4,X:PDRD,* ; wait for data in RXREG
MOVE Y:RXREG,A1 ; bits 15..0
ASL #$10,A,A ; shift left 16 bits
RD24B JSET #$0,X:LINK,ENDRD24 ;
JCLR #7,X:SSISR,* ; wait for RDRF to go high
MOVE X:RXD,A ; read from ESSI
ASR #$10,A,A ; shift right 16 bits
JCLR #7,X:SSISR,* ; wait for RDRF to go high
MOVE X:RXD,A1 ;
ASL #$10,A,A ; shift left 16 bits
ENDRD24 RTS ; 24-bit word in A1
WRITE24 JCLR #$0,X:LINK,WR24B ; check RS485 or fiber
MOVE A1,Y:TXREG ; send bits 15..0
ASR #$10,A,A ; right shift 16 bits
REP #$10 ; wait for data sent
NOP ;
MOVE A1,Y:TXREG ; send bits 23..16
WR24B JSET #$0,X:LINK,ENDWR24 ;
JCLR #6,X:SSISR,* ; wait for TDE
MOVE A1,X:TXD ; send bits 15..0
ASR #$10,A,A ; right shift 16 bits
NOP ; wait for flag update
JCLR #6,X:SSISR,* ; wait for TDE
MOVE A1,X:TXD ; send bits 23..16
ENDWR24 RTS ;
;*****************************************************************************
; LOAD NEW DATA VIA SSI PORT
;*****************************************************************************
MEM_LOAD JSR READ24 ; get memspace/address
MOVE A1,R1 ; load address into R1
MOVE A1,X0 ; store memspace code
JSR READ24 ; get data
BCLR #$17,R1 ; clear memspace bit
X_LOAD JSET #$17,X0,Y_LOAD ;
MOVE A1,X:(R1) ; load x memory
Y_LOAD JCLR #$17,X0,END_LOAD ;
MOVE A1,Y:(R1) ; load y memory
END_LOAD RTS ;
;*****************************************************************************
; SEND MEMORY CONTENTS VIA SSI PORT
;*****************************************************************************
MEM_SEND JSR READ24 ; get memspace/address
MOVE A1,R1 ; load address into R1
MOVE A1,X0 ; save memspace code
BCLR #$17,R1 ; clear memspace bit
X_SEND JSET #$17,X0,Y_SEND ;
MOVE X:(R1),A1 ; send x memory
Y_SEND JCLR #$17,X0,WRITE24 ;
MOVE Y:(R1),A1 ; send y memory
SEND24 JSR WRITE24 ;
NOP ;
RTS ;
;*****************************************************************************
; CCID-21 SET DAC VOLTAGES DEFAULTS: OD=18V RD=10V OG=-2V
; PCLKS=+4V -6V SCLKS=+4V -4V SW=+5 -5V RG=+8V -2V B7=-6V B5=+12 to +15V
;*****************************************************************************
SET_DACS JSR SET_VBIAS ;
JSR SET_VCLKS ;
RTS ;
SET_VBIAS MOVEP #WS5,X:BCR ; add wait states
MOVE #VBIAS,R3 ; bias voltages
MOVE #SIG_AB,R4 ; bias DAC registers
DO #$8,ENDSETB ; set bias voltages
MOVE X:(R3)+,X0 ;
MOVE X0,Y:(R4)+ ;
ENDSETB MOVEP #WS,X:BCR ;
RTS ;
SET_VCLKS MOVEP #WS5,X:BCR ; add wait states
MOVE #VCLK,R3 ; clock voltages
MOVE #CLK_AB,R4 ; clock DAC registers
DO #$10,ENDSETV ; set clock voltages
MOVE X:(R3)+,X0 ;
MOVE X0,Y:(R4)+ ;
ENDSETV MOVEP #WS,X:BCR ; re-set wait states
RTS
;*****************************************************************************
; TEMP MONITOR ADC START AND CONVERT
;*****************************************************************************
TEMP_READ BSET #$0,X:PDRD ; turn on temp sensor
MOVEP #$20,X:TCPR1 ; set timer compare value
JSR M_TIMER ; wait for output to settle
MOVEP #WS3,X:BCR ; set wait states for ADC
MOVEP X:TCLKS,Y:<<SEQREG ; assert /CONVST
REP #$4 ;
NOP ;
MOVEP X:(TCLKS+1),Y:<<SEQREG ; deassert /CONVST and wait
REP #$50 ;
NOP ;
MOVEP Y:<<ADC_B,A1 ; read ADC2
MOVE #>$3FFF,X1 ; prepare 14-bit mask
AND X1,A1 ; get 14 LSBs
BCLR #$0,X:PDRD ; turn off temp sensor
BCHG #$D,A1 ; 2complement to binary
MOVEP #WS,X:BCR ; re-set wait states
MOVE A1,X:TEMP ;
RTS ;
TEMP_SET MOVEP #WS5,X:BCR ; add wait states
NOP ;
MOVEP X:TEC,Y:<<TEC_REG ; set TEC DAC
MOVEP #WS,X:BCR ; re-set wait states
RTS
;*****************************************************************************
; MILLISECOND AND MICROSECOND TIMER MODULE
;*****************************************************************************
U_TIMER BSET #$0,X:TCSR0 ; start timer
BTST #$0,X:TCSR0 ; delay for flag update
JCLR #$15,X:TCSR0,* ; wait for TCF flag
BCLR #$0,X:TCSR0 ; stop timer, clear flag
RTS ; flags update during RTS
M_TIMER BSET #$0,X:TCSR1 ; start timer
BTST #$0,X:TCSR0 ; delay for flag update
JCLR #$15,X:TCSR1,* ; wait for TCF flag
BCLR #$0,X:TCSR1 ; stop timer, clear flag
RTS ; flags update during RTS
;*****************************************************************************
; SIGNAL-PROCESSING GAIN MODULE
;*****************************************************************************
SET_GAIN JSET #$0,X:GAIN,HI_GAIN ;
BCLR #$1,X:PDRD ; set gain=0
HI_GAIN JCLR #$0,X:GAIN,END_GAIN ;
BSET #$1,X:PDRD ; set gain=1
END_GAIN RTS ;
;*****************************************************************************
; SIGNAL-PROCESSING DUAL-SLOPE TIME MODULE
;*****************************************************************************
SET_USEC MOVEP X:USEC,X:TCPR0 ; timer compare value
END_USEC RTS ;
;*****************************************************************************
; SELECT SERIAL CLOCK SEQUENCE (IE OUTPUT AMPLIFIER)
;*****************************************************************************
SET_SCLKS MOVE X:OPCH,A ; 0x1=right 0x2=left
RIGHT_AMP MOVE #>$1,X0 ; 0x3=both 0x4=all
CMP X0,A ;
JNE LEFT_AMP ;
MOVE #>SCLKS_R,Y0 ; serial clock sequences
MOVE #>SCLKS_FLR,Y1 ; serial flush sequences
MOVE #PIX+1,N5 ; pointer to start of data
MOVEP #>$0,X:DCO0 ; DMA counter
LEFT_AMP MOVE #>$2,X0 ;
CMP X0,A ;
JNE BOTH_AMP ;
MOVE #>SCLKS_L,Y0 ;
MOVE #>SCLKS_FLL,Y1 ;
MOVE #PIX,N5 ;
MOVEP #>$0,X:DCO0 ;
BOTH_AMP MOVE #>$3,X0 ;
CMP X0,A ;
JNE END_AMP ;
MOVE #>SCLKS_B,Y0 ;
MOVE #>SCLKS_FLB,Y1 ;
MOVE #PIX,N5 ;
MOVEP #>$1,X:DCO0 ;
END_AMP MOVE Y0,X:SCLKS ;
MOVE Y1,X:SCLKS_FL ;
RTS ;
;*****************************************************************************
; CMD.ASM -- ROUTINE TO INTERPRET AN 8-BIT COMMAND + COMPLEMENT
;*****************************************************************************
; Each command word is sent as two bytes -- the LSB has the command
; and the MSB has the complement.
CMD_FIX MOVE X:CMD,A ; extract cmd[7..0]
AND #>$FF,A ; and put in X1
MOVE A1,X1 ;
MOVE X:CMD,A ; extract cmd[15..8]
LSR #$8,A ; complement
NOT A #>$1,B ; and put in A1
AND #>$FF,A ;
ASL X1,B,B ;
CMP X1,A ; compare X1 and A1
JEQ CMD_OK ;
CMD_NG CLR B ; cmd word no good
NOP ;
CMD_OK MOVE B1,X:CMD ; cmd word OK
NOP ;
END_CMD RTS ;
END
|
programs/oeis/191/A191902.asm | neoneye/loda | 22 | 174922 | <filename>programs/oeis/191/A191902.asm
; A191902: Number of compositions of odd positive integers into 5 parts <= n.
; 0,16,121,512,1562,3888,8403,16384,29524,50000,80525,124416,185646,268912,379687,524288,709928,944784,1238049,1600000,2042050,2576816,3218171,3981312,4882812,5940688,7174453,8605184,10255574,12150000,14314575,16777216,19567696,22717712,26260937,30233088,34671978,39617584,45112099,51200000,57928100,65345616,73504221,82458112,92264062,102981488,114672503,127401984,141237624,156250000,172512625,190102016,209097746,229582512,251642187,275365888,300846028,328178384,357462149,388800000,422298150,458066416,496218271,536870912,580145312,626166288,675062553,726966784,782015674,840350000,902114675,967458816,1036535796,1109503312,1186523437,1267762688,1353392078,1443587184,1538528199,1638400000,1743392200,1853699216,1969520321,2091059712,2218526562,2352135088,2492104603,2638659584,2792029724,2952450000,3120160725,3295407616,3478441846,3669520112,3868904687,4076863488,4293670128,4519603984,4754950249,5000000000
add $0,1
pow $0,5
div $0,2
|
src/mysql/ado-mysql.ads | My-Colaborations/ada-ado | 0 | 28527 | <gh_stars>0
-----------------------------------------------------------------------
-- ado-mysql -- MySQL Database Drivers
-- Copyright (C) 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Properties;
-- === MySQL Database Driver ===
-- The MySQL database driver can be initialize explicitly by using the `ado_mysql`
-- GNAT project and calling the initialization procedure.
--
-- ADO.Mysql.Initialize ("db.properties");
--
-- The set of configuration properties can be set programatically and passed to the
-- `Initialize` operation.
--
-- Config : Util.Properties.Manager;
-- ...
-- Config.Set ("ado.database", "mysql://localhost:3306/ado_test");
-- Config.Set ("ado.queries.path", ".;db");
-- ADO.Mysql.Initialize (Config);
--
-- The MySQL database driver supports the following properties:
--
-- | Name | Description |
-- | ----------- | --------- |
-- | user | The user name to connect to the server |
-- | password | The user password to connect to the server |
-- | socket | The optional Unix socket path for a Unix socket base connection |
-- | encoding | The encoding to be used for the connection (ex: UTF-8) |
--
package ADO.Mysql is
-- Initialize the Mysql driver.
procedure Initialize;
-- Initialize the drivers and the library by reading the property file
-- and configure the runtime with it.
procedure Initialize (Config : in String);
-- Initialize the drivers and the library and configure the runtime with the given properties.
procedure Initialize (Config : in Util.Properties.Manager'Class);
end ADO.Mysql;
|
boot/64bit.asm | theaarushgupta/smolOS | 1 | 80221 | global longModeStart
extern boot
section .text
bits 64
; load null (0) into all registers to prepare for Long mode
longModeStart:
mov ax, 0
mov ss, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
call boot
hlt |
test/Expr.g4 | ptr1120/antlr4-c3 | 202 | 1033 | <filename>test/Expr.g4
grammar Expr;
expression: assignment | simpleExpression;
assignment
: (VAR | LET) ID EQUAL simpleExpression
;
simpleExpression
: simpleExpression (PLUS | MINUS) simpleExpression
| simpleExpression (MULTIPLY | DIVIDE) simpleExpression
| variableRef
| functionRef
;
variableRef
: identifier
;
functionRef
: identifier OPEN_PAR CLOSE_PAR
;
identifier: ID;
VAR: [vV] [aA] [rR];
LET: [lL] [eE] [tT];
PLUS: '+';
MINUS: '-';
MULTIPLY: '*';
DIVIDE: '/';
EQUAL: '=';
OPEN_PAR: '(';
CLOSE_PAR: ')';
ID: [a-zA-Z] [a-zA-Z0-9_]*;
WS: [ \n\r\t] -> channel(HIDDEN);
|
oeis/095/A095265.asm | neoneye/loda-programs | 11 | 14547 | <gh_stars>10-100
; A095265: A sequence generated from a 4th degree Pascal's Triangle polynomial.
; 1,22,103,284,605,1106,1827,2808,4089,5710,7711,10132,13013,16394,20315,24816,29937,35718,42199,49420,57421,66242,75923,86504,98025,110526,124047,138628,154309,171130,189131,208352,228833,250614,273735,298236
mov $1,$0
add $0,1
mul $0,2
bin $0,3
mul $0,5
add $1,1
add $1,$0
mov $0,$1
|
asm/kernel/basic/eval.asm | majacQ/retroputer | 58 | 174149 | .segment __current__ kmemmap.basic.code-start .append {
# push-param
#
# Pushes a parameter onto the global p stack.
#
# @param DL - token type
# @param C - value (or PTR)
#######################################################################
push-param: {
enter 0x00
push x
_main:
x := 0
xl := [bdata.param-length] # get current length
[bdata.param-types, x] := dl # write the token data type
shl x, 3 # multiply by eight (width of param)
cmp dl, brodata.TOK_REAL
if !z {
[bdata.params, x] := c # write value
} else {
push y
y := c # for reals, c is pointing into memory
c := [kmemmap.basic.dbls-start,y] # byte 1
[bdata.params, x] := c #
inc y
inc y
inc x
inc x
c := [kmemmap.basic.dbls-start,y] # byte 2
[bdata.params, x] := c #
inc y
inc y
inc x
inc x
c := [kmemmap.basic.dbls-start,y] # byte 3
[bdata.params, x] := c #
inc y
inc y
inc x
inc x
c := [kmemmap.basic.dbls-start,y] # byte 4
[bdata.params, x] := c #
pop y
}
xl := [bdata.param-length]
inc xl
[bdata.param-length] := xl
_out:
pop x
exit 0x00
ret
}
# pop-param
#
# Returns the parameter at the given index
#
# @returns DL - type of parameter
# @returns C - value
# @returns FLAG:X -- set if not enough parameters
#######################################################################
pop-param: {
enter 0x00
push x
_main:
x := 0
xl := [bdata.param-length] # need to know the length of the queue
dec xl
if n {
set EX # not enough parameters on the queue, so
br _out # bail out
}
clr EX # enough parameters
dl := [bdata.param-types,x] # get type
shl x, 3 # multiply index by 8
c := [bdata.params,x] # get value; @fixme broken for reals
xl := [bdata.param-length] # reduce length
dec xl
[bdata.param-length] := xl
_out:
pop x
exit 0x00
ret
}
# get-param
#
# Returns the parameter at the given index
#
# @param X - parameter to return
# @returns DL - type of parameter
# @returns C - value
# @returns FLAG:X -- set if not enough parameters
#######################################################################
get-param: {
enter 0x00
push x
push y
_main:
y := 0
yl := [bdata.param-length] # need to know the length of the queue
cmp xl, yl
if !n {
set EX # not enough parameters on the queue, so
br _out # bail out
}
sub yl, xl # queue is in reverse order
dec yl # so subtract the parameter #
xl := yl # in order to make sure that we index right
clr EX # enough parameters
dl := [bdata.param-types,x] # get type
shl x, 3 # multiply index by 8
c := [bdata.params,x] # get value; @fixme broken for reals
_out:
pop y
pop x
exit 0x00
ret
}
# clear-params
#
# Resets the paramater queue
#
#######################################################################
clear-params: {
enter 0x00
push x
_main:
x := 0
[bdata.param-length] := x
_out:
pop x
exit 0x00
ret
}
#
# get-var looks up a variable and returns the value in C with the type
# in DL
#
# NOTE: this only works while parsing a line (having already eaten the
# TOK_VARIABLE token)
#
#######################################################################
get-var: {
push x
push b
push y
_main:
# [b,d] = [type, index]
call gettok-word # get variable index & type
b := d
and b, 0b1100_0000_0000_0000 # just want the type
shr b, 14 # in the lower bits
and d, 0b0011_1111_1111_1111 # for index, we don't want the type
# advance parser past variable name
push d # save variable index
call gettok-raw # next byte is the length of the variable name
x := [bdata.current-line-aptr]
clr c
add x, dl # x += variable length
[bdata.current-line-aptr] := x # and store it back
pop d # get variable index back
# index our variable correctly
x := d # use x so we can index in a bit
cmp b, constants.TYPE_WORD
if z { # we're a word
d := brodata.TOK_WORD
c := [kmemmap.basic.ints-start, x]
br _out
}
cmp b, constants.TYPE_STRING
if z {
d := brodata.TOK_STRING # we're a string!
c := [kmemmap.basic.strs-start, x]
br _out
}
cmp b, constants.TYPE_REAL
if z {
d := brodata.TOK_REAL # we're a real!
shl x, 2 # multiply by eight instead (64 bits)
c := x # instead of a value, we return the index into variable memory
br _out
}
# @todo: handle array bits!
_out:
pop y
pop b
pop x
ret
}
#
# EVAL is responsible for evaluating the current expression
#
# @returns DL: 0 if no error, or an error number if one occurred
#
#######################################################################
eval: {
BIG_ENTER(270)
.const cur-precedence -2
.const in-paren -3 # tracks if we're in parentheses
.const expecting -4 # tracks what we're expecting next
.const orig-sp -6
.const vector-bank -8
.const vector-offs -10
.const operator-stack -140 # operator stack has room for 32 ops (each op is 4 bytes)
.const value-stack -270 # value stack has room for 32 values
.const MAX_EXPR_SIZE 32 * 2 # 32 operations or values (each is four bytes)
push y
push x
push c
push b
push a
[bp+orig-sp] := sp # need a way to know when we've exhausted the stack
_main:
INIT_STACK_BP(operator-stack)
INIT_STACK_BP(value-stack)
call clear-params
a := 0
[bp+expecting] := al # 0 = we're expecting a non-operator
[bp+in-paren] := al # 0 = not in a parenthesis
do {
x := [bp+value-stack]
c := MAX_EXPR_SIZE
cmp x, c
br !n _too-complex # too complex an operation!
x := [bp+operator-stack]
c := MAX_EXPR_SIZE
cmp x, c
br !n _too-complex # it's too much, captain; the ship cannae take any more!
call gettok # get the next token in the stream
cmp dl, 0
br z _finish-eval # end-of-line, hope we're done!
cmp dl, brodata.TOK_END_OF_STMT
br z _finish-eval # end-of-statement, hope we're done!
al := [bp+in-paren] # check if we're in a parenthesis
cmp al, 0
if z { # we aren't, so bail if we see , or ;
cmp dl, brodata.TOK_COMMA # comma is a valid exit
br z _finish-eval
cmp dl, brodata.TOK_SEMICOLON # as is a semicolon
br z _finish-eval
} else {
cmp dl, brodata.TOK_COMMA # a comma in a paren could be a
if z { # parameter list; this is OK
continue
}
cmp dl, brodata.TOK_SEMICOLON # but a semicolon isn't
if z {
dl := brodata.SYNTAX_ERROR # syntax error
br _out
}
}
# a,b = vector, metadata for the token
c := dl # need to compute lookup address
and cl, 0b0111_1111 # drop the top bit (subtract 128)
shl c, 2 # * 4 (vector, metadata word)
push x # stash this....
x := c
a := [expression-handlers, x] # a is now the handler vector
inc x
inc x
b := [expression-handlers, x] # b is now the metadata
pop x # x is back to operator stack ptr
# is token of any value here? b will be non-zero
cmp b, 0
if z {
br _finish-eval # might be done?
}
# token is of value, what is it?
cmp dl, brodata.TOK_VARIABLE # is it a variable?
if z {
call get-var # parse the variable. it'll be in the accumulator
STPUSH_BP(d, value-stack) # push accumulator token on stack
d := c
STPUSH_BP(d, value-stack) # push accumulator on stack (@todo: wrong for reals)
continue
}
cmp dl, brodata.TOK_BYTE # is it a byte?
if z {
dl := brodata.TOK_WORD
STPUSH_BP(d, value-stack) # convert to word and push
d := 0 # clear d in prep for next token (which will be a byte)
call gettok-raw # next byte is our number
STPUSH_BP(d, value-stack) # stack has word on it
continue
}
cmp dl, brodata.TOK_WORD
if z { # it's a word
STPUSH_BP(d, value-stack)
call gettok-word
STPUSH_BP(d, value-stack)
continue
}
cmp dl, brodata.TOK_CODE_STRING
if z { # it's a string
STPUSH_BP(d, value-stack)
d := [bdata.current-line-aptr]
STPUSH_BP(d, value-stack) # push POINTER to string
do {
call gettok-raw
cmp dl, 0
} while !z # eat the rest of the string
continue
}
cmp dl, brodata.TOK_LPAR
if z { # it's a left paren -- push and continue
call _push-operator
al := [bp+in-paren]
inc al
[bp+in-paren] := al # in a parenthesis now
continue
}
cmp dl, brodata.TOK_RPAR
if z { # it's a right paren -- evaluate until we see a left paren
# @todo handle paranthetical
x := [bp+operator-stack]
c := 0
cmp x, c # is stack empty?
while !z do { # keep going until it is...
call _pop-operator
cmp a, 0xFFFE # this is ('s pseudo-vector
brs z _continue
call _do-operator # pull an op and execute it
x := [bp+operator-stack] # check stack size
c := 0
cmp x, c
}
dl := brodata.EXPECTED_LEFT_PARENTHESIS
br _out # wow; forget something? A LPAREN!!!
_continue:
al := [bp+in-paren]
dec al
[bp+in-paren] := al # out of paren
continue
}
x := [bp+operator-stack] # get current stack size
c := 0
cmp x, c # is the stack empty?
x := a
y := b
while !z do { # no, precedence and associativity need to be handled
call _pop-operator
cmp bl, yl # does token take precedence?
if n { # it doesn't
call _push-operator # (yeesh, don't eat it)
break
}
cmp a, 0xFFFE # don't execute a parenthesis
if z {
call _push-operator
break
}
call _do-operator # pull an op and execute it
push x
x := [bp+operator-stack] # check stack size
c := 0
cmp x, c
pop x
}
a := x # make sure op is what it was originally
b := y # before precedence check
call _push-operator # push op and continue
continue
} while z
_finish-eval:
call backtok # need to walk back a token
x := [bp+operator-stack]
c := 0
cmp x, c # is stack empty?
while !z do { # keep going until it is...
call _pop-operator
cmp a, 0xFFFE # shouldn't have parens anymore
if z {
dl := brodata.EXPECTED_RIGHT_PARENTHESIS
brs _out
}
call _do-operator # pull an op and execute it
x := [bp+operator-stack] # check stack size
c := 0
cmp x, c
}
_done:
STPOP_BP(d, value-stack) # pop off the last value -- this is our return
br ex _out-of-values
c := d
STPOP_BP(d, value-stack)
br ex _out-of-values
call push-param # save the result globally
dl := 0 # if we're here, we evaluated without issue
_out:
sp := [bp+orig-sp] # make sure stack is cleaned up if we exited early
pop a
pop b
pop c
pop x
pop y
BIG_EXIT(270)
ret
_too-complex:
dl := brodata.EXPRESSION_TOO_COMPLEX_ERROR
brs _out
_push-operator:
STPUSH_BP(a, operator-stack)
STPUSH_BP(b, operator-stack)
ret
_pop-operator:
STPOP_BP(b, operator-stack)
STPOP_BP(a, operator-stack)
ret
_do-operator:
d := b
and d, 0b1111_0000_0000_0000
shr d, 12
cmp dl, 0
if !z {
b := d
do {
STPOP_BP(d, value-stack)
br ex _out-of-params
c := d
STPOP_BP(d, value-stack)
br ex _out-of-params
call push-param
dec bl
} while !z
}
[bp+vector-offs] := a
call [bp+vector-offs] # call the operator handler
cmp dl, 0
br !z _out # that didn't work
# push value back on stack
call pop-param
STPUSH_BP(d, value-stack)
d := c
STPUSH_BP(d, value-stack)
ret
_out-of-values:
dl := brodata.SYNTAX_ERROR
br _out
_out-of-params:
dl := brodata.INSUFFICIENT_ARGUMENTS_ERROR
br _out
}
}
|
programs/oeis/158/A158601.asm | karttu/loda | 1 | 14057 | ; A158601: a(n) = 400*n^2 + 20.
; 20,420,1620,3620,6420,10020,14420,19620,25620,32420,40020,48420,57620,67620,78420,90020,102420,115620,129620,144420,160020,176420,193620,211620,230420,250020,270420,291620,313620,336420,360020,384420,409620,435620,462420,490020,518420,547620,577620,608420,640020,672420,705620,739620,774420,810020,846420,883620,921620,960420,1000020,1040420,1081620,1123620,1166420,1210020,1254420,1299620,1345620,1392420,1440020,1488420,1537620,1587620,1638420,1690020,1742420,1795620,1849620,1904420,1960020,2016420,2073620,2131620,2190420,2250020,2310420,2371620,2433620,2496420,2560020,2624420,2689620,2755620,2822420,2890020,2958420,3027620,3097620,3168420,3240020,3312420,3385620,3459620,3534420,3610020,3686420,3763620,3841620,3920420,4000020,4080420,4161620,4243620,4326420,4410020,4494420,4579620,4665620,4752420,4840020,4928420,5017620,5107620,5198420,5290020,5382420,5475620,5569620,5664420,5760020,5856420,5953620,6051620,6150420,6250020,6350420,6451620,6553620,6656420,6760020,6864420,6969620,7075620,7182420,7290020,7398420,7507620,7617620,7728420,7840020,7952420,8065620,8179620,8294420,8410020,8526420,8643620,8761620,8880420,9000020,9120420,9241620,9363620,9486420,9610020,9734420,9859620,9985620,10112420,10240020,10368420,10497620,10627620,10758420,10890020,11022420,11155620,11289620,11424420,11560020,11696420,11833620,11971620,12110420,12250020,12390420,12531620,12673620,12816420,12960020,13104420,13249620,13395620,13542420,13690020,13838420,13987620,14137620,14288420,14440020,14592420,14745620,14899620,15054420,15210020,15366420,15523620,15681620,15840420,16000020,16160420,16321620,16483620,16646420,16810020,16974420,17139620,17305620,17472420,17640020,17808420,17977620,18147620,18318420,18490020,18662420,18835620,19009620,19184420,19360020,19536420,19713620,19891620,20070420,20250020,20430420,20611620,20793620,20976420,21160020,21344420,21529620,21715620,21902420,22090020,22278420,22467620,22657620,22848420,23040020,23232420,23425620,23619620,23814420,24010020,24206420,24403620,24601620,24800420
mov $1,$0
mul $1,20
pow $1,2
add $1,20
|
src/main/fragment/mos6502-common/vwum1=vwum1_plus_vbsaa.asm | jbrandwood/kickc | 2 | 94592 | clc
sta $ff
adc {m1}
sta {m1}
lda $ff
ora #$7f
bmi !+
lda #0
!:
adc {m1}+1
sta {m1}+1 |
org.alloytools.alloy.extra/extra/models/book/appendixA/distribution.als | Kaixi26/org.alloytools.alloy | 527 | 2538 | <gh_stars>100-1000
module appendixA/distribution
assert union {
all s: set univ, p, q: univ->univ | s.(p+q) = s.p + s.q
}
check union for 4
|
Cubical/Structures/Parameterized.agda | dan-iel-lee/cubical | 0 | 11668 | {-
A parameterized family of structures S can be combined into a single structure:
X ↦ (a : A) → S a X
This is more general than Structures.Function in that S can vary in A.
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Structures.Parameterized where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Functions.FunExtEquiv
open import Cubical.Foundations.SIP
open import Cubical.Foundations.Univalence
private
variable
ℓ ℓ₁ ℓ₁' : Level
module _ {ℓ₀} (A : Type ℓ₀) where
ParamStructure : (S : A → Type ℓ → Type ℓ₁)
→ Type ℓ → Type (ℓ-max ℓ₀ ℓ₁)
ParamStructure S X = (a : A) → S a X
ParamEquivStr : {S : A → Type ℓ → Type ℓ₁}
→ (∀ a → StrEquiv (S a) ℓ₁') → StrEquiv (ParamStructure S) (ℓ-max ℓ₀ ℓ₁')
ParamEquivStr ι (X , l) (Y , m) e = ∀ a → ι a (X , l a) (Y , m a) e
paramUnivalentStr : {S : A → Type ℓ → Type ℓ₁}
(ι : ∀ a → StrEquiv (S a) ℓ₁') (θ : ∀ a → UnivalentStr (S a) (ι a))
→ UnivalentStr (ParamStructure S) (ParamEquivStr ι)
paramUnivalentStr ι θ e = compEquiv (equivΠCod λ a → θ a e) funExtEquiv
paramEquivAction : {S : A → Type ℓ → Type ℓ₁}
→ (∀ a → EquivAction (S a)) → EquivAction (ParamStructure S)
paramEquivAction α e = equivΠCod (λ a → α a e)
paramTransportStr : {S : A → Type ℓ → Type ℓ₁}
(α : ∀ a → EquivAction (S a)) (τ : ∀ a → TransportStr (α a))
→ TransportStr (paramEquivAction α)
paramTransportStr {S = S} α τ e f =
funExt λ a →
τ a e (f a)
∙ cong (λ fib → transport (λ i → S (fib .snd (~ i)) (ua e i)) (f (fib .snd i1)))
(isContrSingl a .snd (_ , sym (transportRefl a)))
|
Numeral/Natural/Oper/Proofs/Order.agda | Lolirofle/stuff-in-agda | 6 | 17442 | <reponame>Lolirofle/stuff-in-agda
module Numeral.Natural.Oper.Proofs.Order where
open import Functional
open import Logic
open import Logic.Propositional
open import Logic.Propositional.Theorems
open import Numeral.Natural
open import Numeral.Natural.Oper
open import Numeral.Natural.Oper.Proofs
open import Numeral.Natural.Relation.Order
open import Numeral.Natural.Relation.Order.Classical
open import Numeral.Natural.Relation.Order.Proofs
open import Relator.Equals
open import Relator.Equals.Proofs
open import Relator.Ordering.Proofs
open import Structure.Function.Domain
open import Structure.Operator
open import Structure.Operator.Properties
open import Structure.Relator.Properties
open import Syntax.Transitivity
[≤]ₗ[+] : ∀{x y : ℕ} → (x + y ≤ x) → (y ≡ 𝟎)
[≤]ₗ[+] {𝟎} = [≤][0]ᵣ
[≤]ₗ[+] {𝐒(x)}{y} (proof) = [≤]ₗ[+] {x} ([≤]-without-[𝐒] {x + y} {x} (proof))
[≤]-with-[+]ᵣ : ∀{x y z : ℕ} → (x ≤ y) → (x + z ≤ y + z)
[≤]-with-[+]ᵣ {_}{_}{𝟎} (proof) = proof
[≤]-with-[+]ᵣ {_}{_}{𝐒(z)} (proof) = [≤]-with-[𝐒] ⦃ [≤]-with-[+]ᵣ {_}{_}{z} (proof) ⦄
[≤]-with-[+]ₗ : ∀{x y z : ℕ} → (x ≤ y) → (z + x ≤ z + y)
[≤]-with-[+]ₗ {.0} {𝟎} {z } min = reflexivity(_≤_)
[≤]-with-[+]ₗ {.0} {𝐒 y} {z} min = [≤]-successor([≤]-with-[+]ₗ {0}{y}{z} [≤]-minimum)
[≤]-with-[+]ₗ {𝐒 x} {𝐒 y} {z} (succ xy ) = [≤]-with-[𝐒] ⦃ [≤]-with-[+]ₗ {x} {y} {z} xy ⦄
[≤]-of-[+]ᵣ : ∀{x y : ℕ} → (y ≤ x + y)
[≤]-of-[+]ᵣ {x} {𝟎} = [≤]-minimum
[≤]-of-[+]ᵣ {𝟎} {𝐒 x} = reflexivity(_≤_)
[≤]-of-[+]ᵣ {𝐒 x} {𝐒 y} = [≤]-with-[𝐒] ⦃ [≤]-of-[+]ᵣ {𝐒 x}{y} ⦄
[≤]-of-[+]ₗ : ∀{x y : ℕ} → (x ≤ x + y)
[≤]-of-[+]ₗ {𝟎} {y} = [≤]-minimum
[≤]-of-[+]ₗ {𝐒 x} {𝟎} = reflexivity(_≤_)
[≤]-of-[+]ₗ {𝐒 x} {𝐒 y} = [≤]-with-[𝐒] ⦃ [≤]-of-[+]ₗ {x}{𝐒 y} ⦄
[≤]-with-[+] : ∀{x₁ y₁ : ℕ} → ⦃ _ : (x₁ ≤ y₁)⦄ → ∀{x₂ y₂ : ℕ} → ⦃ _ : (x₂ ≤ y₂)⦄ → (x₁ + x₂ ≤ y₁ + y₂)
[≤]-with-[+] {x₁} {y₁} ⦃ x1y1 ⦄ {.0} {y₂} ⦃ min ⦄ = transitivity(_≤_) x1y1 [≤]-of-[+]ₗ
[≤]-with-[+] {x₁} {y₁} ⦃ x1y1 ⦄ {𝐒 x₂} {𝐒 y₂} ⦃ succ p ⦄ = succ ([≤]-with-[+] {x₁} {y₁} {x₂} {y₂} ⦃ p ⦄)
[≤]-from-[+] : ∀{ℓ}{P : ℕ → Stmt{ℓ}}{x} → (∀{n} → P(x + n)) → (∀{y} → ⦃ _ : (x ≤ y) ⦄ → P(y))
[≤]-from-[+] {ℓ} {P} {𝟎} anpxn {y} ⦃ [≤]-minimum ⦄ = anpxn{y}
[≤]-from-[+] {ℓ} {P} {𝐒 x} anpxn {𝐒 y} ⦃ succ xy ⦄ = [≤]-from-[+] {ℓ} {P ∘ 𝐒} {x} anpxn {y} ⦃ xy ⦄
[−₀][+]-nullify2 : ∀{x y} → (x ≤ y) ↔ (x + (y −₀ x) ≡ y)
[−₀][+]-nullify2 {x}{y} = [↔]-intro (l{x}{y}) (r{x}{y}) where
l : ∀{x y} → (x ≤ y) ← (x + (y −₀ x) ≡ y)
l {𝟎} {_} _ = [≤]-minimum
l {𝐒(_)}{𝟎} ()
l {𝐒(x)}{𝐒(y)} proof = [≤]-with-[𝐒] ⦃ l{x}{y} (injective(𝐒) proof) ⦄
r : ∀{x y} → (x ≤ y) → (x + (y −₀ x) ≡ y)
r {𝟎} {𝟎} proof = [≡]-intro
r {𝟎} {𝐒(_)} proof = [≡]-intro
r {𝐒(_)}{𝟎} ()
r {𝐒(x)}{𝐒(y)} (succ proof) = [≡]-with(𝐒) (r{x}{y} (proof))
[−₀][+]-nullify2ᵣ : ∀{x y} → (x ≤ y) ↔ ((y −₀ x) + x ≡ y)
[−₀][+]-nullify2ᵣ {x}{y} = [↔]-transitivity [−₀][+]-nullify2 ([≡]-substitution (commutativity(_+_) {x}{y −₀ x}) {_≡ y})
[−₀]-when-0 : ∀{x y} → (x ≤ y) ↔ (x −₀ y ≡ 𝟎)
[−₀]-when-0 {x}{y} = [↔]-intro (l{x}{y}) (r{x}{y}) where
l : ∀{x y} → (x ≤ y) ← (x −₀ y ≡ 𝟎)
l {𝟎} {_} _ = [≤]-minimum
l {𝐒(_)}{𝟎} ()
l {𝐒(x)}{𝐒(y)} proof = [≤]-with-[𝐒] ⦃ l{x}{y} proof ⦄
r : ∀{x y} → (x ≤ y) → (x −₀ y ≡ 𝟎)
r {𝟎} {_} proof = [≡]-intro
r {𝐒(_)}{𝟎} ()
r {𝐒(x)}{𝐒(y)} (succ proof) = r{x}{y} (proof)
[−₀]-lesser-[𝐒]ₗ : ∀{x y} → ((x −₀ 𝐒(y)) ≤ (x −₀ y))
[−₀]-lesser-[𝐒]ᵣ : ∀{x y} → ((x −₀ y) ≤ (𝐒(x) −₀ y))
[−₀]-lesser-[𝐒]ₗ {𝟎} {_} = [≤]-minimum
[−₀]-lesser-[𝐒]ₗ {𝐒(_)}{𝟎} = [≤]-of-[𝐒]
[−₀]-lesser-[𝐒]ₗ {𝐒(x)}{𝐒(y)} = [−₀]-lesser-[𝐒]ᵣ {x}{𝐒(y)}
[−₀]-lesser-[𝐒]ᵣ {𝟎} {_} = [≤]-minimum
[−₀]-lesser-[𝐒]ᵣ {𝐒(x)}{𝟎} = [≤]-of-[𝐒]
[−₀]-lesser-[𝐒]ᵣ {𝐒(x)}{𝐒(y)} = [−₀]-lesser-[𝐒]ₗ {𝐒(x)}{y}
[≤][−₀][𝐒]ₗ : ∀{x y} → ((𝐒(x) −₀ y) ≤ 𝐒(x −₀ y))
[≤][−₀][𝐒]ₗ {x} {𝟎} = reflexivity(_≤_)
[≤][−₀][𝐒]ₗ {𝟎} {𝐒(y)} = [≤]-minimum
[≤][−₀][𝐒]ₗ {𝐒(x)}{𝐒(y)} = [≤][−₀][𝐒]ₗ {x}{y}
[−₀][𝐒]ₗ-equality : ∀{x y} → (x ≥ y) ↔ ((𝐒(x) −₀ y) ≡ 𝐒(x −₀ y))
[−₀][𝐒]ₗ-equality = [↔]-intro l r where
l : ∀{x y} → (x ≥ y) ← ((𝐒(x) −₀ y) ≡ 𝐒(x −₀ y))
l {𝟎} {𝟎} p = [≤]-minimum
l {𝐒 x} {𝟎} p = [≤]-minimum
l {𝐒 x} {𝐒 y} p = [≤]-with-[𝐒] ⦃ l{x}{y} p ⦄
r : ∀{x y} → (x ≥ y) → ((𝐒(x) −₀ y) ≡ 𝐒(x −₀ y))
r {x} {.𝟎} min = [≡]-intro
r {𝐒 x} {𝐒 y} (succ xy) = r xy
[−₀]-lesser : ∀{x y} → ((x −₀ y) ≤ x)
[−₀]-lesser {𝟎} {_} = [≤]-minimum
[−₀]-lesser {𝐒(x)}{𝟎} = reflexivity(_≤_)
[−₀]-lesser {𝐒(x)}{𝐒(y)} = ([−₀]-lesser-[𝐒]ₗ {𝐒(x)}{y}) 🝖 ([−₀]-lesser {𝐒(x)}{y})
-- TODO: Converse is probably also true. One way to prove the equivalence is contraposition of [−₀]-comparison. Another is by [≤]-with-[+]ᵣ and some other stuff, but it seems to require more work
[−₀]-positive : ∀{x y} → (y > x) → (y −₀ x > 0)
[−₀]-positive {𝟎} {𝐒(y)} _ = [≤]-with-[𝐒] ⦃ [≤]-minimum ⦄
[−₀]-positive {𝐒(x)}{𝐒(y)} (succ p) = [−₀]-positive {x}{y} p
[−₀]-nested-sameₗ : ∀{x y} → (x ≥ y) ↔ (x −₀ (x −₀ y) ≡ y)
[−₀]-nested-sameₗ {x}{y} = [↔]-intro (l{x}{y}) (r{x}{y}) where
l : ∀{x y} → (x ≥ y) ← (x −₀ (x −₀ y) ≡ y)
l {x}{y} proof =
y 🝖[ _≤_ ]-[ [≡]-to-[≤] (symmetry(_≡_) proof) ]
x −₀ (x −₀ y) 🝖[ _≤_ ]-[ [−₀]-lesser {x}{x −₀ y} ]
x 🝖[ _≤_ ]-end
r : ∀{x y} → (x ≥ y) → (x −₀ (x −₀ y) ≡ y)
r{x}{y} x≥y =
x −₀ (x −₀ y) 🝖[ _≡_ ]-[ [≡]-with(_−₀ (x −₀ y)) (symmetry(_≡_) ([↔]-to-[→] ([−₀][+]-nullify2 {y}{x}) (x≥y)) 🝖 commutativity(_+_) {y}{x −₀ y}) ]
((x −₀ y) + y) −₀ (x −₀ y) 🝖[ _≡_ ]-[ [−₀]ₗ[+]ₗ-nullify {x −₀ y}{y} ]
y 🝖-end
[+][−₀]-almost-associativity : ∀{x y z} → (y ≥ z) → ((x + y) −₀ z ≡ x + (y −₀ z))
[+][−₀]-almost-associativity {x} {y} {.𝟎} min = [≡]-intro
[+][−₀]-almost-associativity {x} {𝐒 y} {𝐒 z} (succ p) = [+][−₀]-almost-associativity {x}{y}{z} p
[−₀][𝄩]-equality-condition : ∀{x y} → (x ≥ y) ↔ (x −₀ y ≡ x 𝄩 y)
[−₀][𝄩]-equality-condition = [↔]-intro l r where
l : ∀{x y} → (x ≥ y) ← (x −₀ y ≡ x 𝄩 y)
l {_} {𝟎} _ = min
l {𝐒 x} {𝐒 y} p = succ(l p)
r : ∀{x y} → (x ≥ y) → (x −₀ y ≡ x 𝄩 y)
r min = [≡]-intro
r (succ p) = r p
[𝄩]-intro-by[−₀] : ∀{ℓ}{P : ℕ → TYPE(ℓ)} → ∀{x y} → P(x −₀ y) → P(y −₀ x) → P(x 𝄩 y)
[𝄩]-intro-by[−₀] {x = x}{y = y} p1 p2 with [≤][>]-dichotomy {x}{y}
... | [∨]-introₗ le
rewrite [↔]-to-[→] [−₀][𝄩]-equality-condition le
rewrite commutativity(_𝄩_) {x}{y}
= p2
... | [∨]-introᵣ gt
rewrite [↔]-to-[→] [−₀][𝄩]-equality-condition ([≤]-predecessor gt)
= p1
[𝄩]-of-𝐒ₗ : ∀{x y} → (x ≥ y) → (𝐒(x) 𝄩 y ≡ 𝐒(x 𝄩 y))
[𝄩]-of-𝐒ₗ {𝟎} {𝟎} = const [≡]-intro
[𝄩]-of-𝐒ₗ {𝐒 x} {𝟎} = const [≡]-intro
[𝄩]-of-𝐒ₗ {𝐒 x} {𝐒 y} = [𝄩]-of-𝐒ₗ {x} {y} ∘ [≤]-without-[𝐒]
[𝄩]-of-𝐒ᵣ : ∀{x y} → (x ≤ y) → (x 𝄩 𝐒(y) ≡ 𝐒(x 𝄩 y))
[𝄩]-of-𝐒ᵣ {𝟎} {𝟎} = const [≡]-intro
[𝄩]-of-𝐒ᵣ {𝟎} {𝐒 y} = const [≡]-intro
[𝄩]-of-𝐒ᵣ {𝐒 x} {𝐒 y} = [𝄩]-of-𝐒ᵣ {x} {y} ∘ [≤]-without-[𝐒]
[<]-with-[+]ᵣ : ∀{x y z} → (x < y) → (x + z < y + z)
[<]-with-[+]ᵣ = [≤]-with-[+]ᵣ
[<]-with-[+]ₗ : ∀{x y z} → (y < z) → (x + y < x + z)
[<]-with-[+]ₗ {x}{y}{z} = [≤]-with-[+]ₗ {𝐒 y}{z}{x}
[<]-with-[+]-weak : ∀{x₁ x₂ y₁ y₂} → ((x₁ ≤ x₂) ∧ (y₁ < y₂)) ∨ ((x₁ < x₂) ∧ (y₁ ≤ y₂)) → (x₁ + y₁ < x₂ + y₂)
[<]-with-[+]-weak ([∨]-introₗ ([∧]-intro x12 y12)) = [≤]-with-[+] ⦃ x12 ⦄ ⦃ y12 ⦄
[<]-with-[+]-weak ([∨]-introᵣ ([∧]-intro x12 y12)) = [≤]-with-[+] ⦃ x12 ⦄ ⦃ y12 ⦄
[<]-with-[+] : ∀{x₁ x₂ y₁ y₂} → (x₁ < x₂) → (y₁ < y₂) → (x₁ + y₁ < x₂ + y₂)
[<]-with-[+] x12 y12 = [≤]-predecessor ([≤]-with-[+] ⦃ x12 ⦄ ⦃ y12 ⦄)
[≤]-with-[⋅]ᵣ : ∀{a b c} → (a ≤ b) → ((a ⋅ c) ≤ (b ⋅ c))
[≤]-with-[⋅]ᵣ {c = 𝟎} _ = [≤]-minimum
[≤]-with-[⋅]ᵣ {c = 𝐒 c} ab = [≤]-with-[+] ⦃ ab ⦄ ⦃ [≤]-with-[⋅]ᵣ {c = c} ab ⦄
[≤]-with-[⋅]ₗ : ∀{a b c} → (b ≤ c) → ((a ⋅ b) ≤ (a ⋅ c))
[≤]-with-[⋅]ₗ {a}{b}{c}
rewrite commutativity(_⋅_) {a}{b}
rewrite commutativity(_⋅_) {a}{c}
= [≤]-with-[⋅]ᵣ {c = a}
[<]-with-[⋅]ᵣ : ∀{a b c} → (a < b) → ((a ⋅ 𝐒(c)) < (b ⋅ 𝐒(c)))
[<]-with-[⋅]ᵣ {c = 𝟎} = id
[<]-with-[⋅]ᵣ {c = 𝐒 c} = [<]-with-[+] ∘ₛ [<]-with-[⋅]ᵣ {c = c}
[<]-with-[⋅]ₗ : ∀{a b c} → (b < c) → ((𝐒(a) ⋅ b) < (𝐒(a) ⋅ c))
[<]-with-[⋅]ₗ {a}{b}{c}
rewrite commutativity(_⋅_) {𝐒(a)}{b}
rewrite commutativity(_⋅_) {𝐒(a)}{c}
= [<]-with-[⋅]ᵣ {c = a}
[⋅]ᵣ-growing : ∀{n c} → (1 ≤ c) → (n ≤ (c ⋅ n))
[⋅]ᵣ-growing {n}{𝐒 c} = [≤]-with-[⋅]ᵣ {1}{𝐒(c)}{n}
[⋅]ᵣ-strictly-growing : ∀{n c} → (2 ≤ c) → (𝐒(n) < (c ⋅ 𝐒(n)))
[⋅]ᵣ-strictly-growing {n} {1} (succ())
[⋅]ᵣ-strictly-growing {n} {𝐒(𝐒 c)} = [<]-with-[⋅]ᵣ {1}{𝐒(𝐒(c))}{n}
[^]-positive : ∀{a b} → ((𝐒(a) ^ b) > 0)
[^]-positive {a}{𝟎} = reflexivity(_≤_)
[^]-positive {a}{𝐒 b} =
𝐒(a) ^ 𝐒(b) 🝖[ _≥_ ]-[]
𝐒(a) ⋅ (𝐒(a) ^ b) 🝖[ _≥_ ]-[ [<]-with-[⋅]ₗ {a} ([^]-positive {a}{b}) ]
𝐒(𝐒(a) ⋅ 0) 🝖[ _≥_ ]-[ succ min ]
1 🝖[ _≥_ ]-end
[^]ₗ-strictly-growing : ∀{n a b} → (a < b) → ((𝐒(𝐒(n)) ^ a) < (𝐒(𝐒(n)) ^ b))
[^]ₗ-strictly-growing {n} {𝟎} {.(𝐒 b)} (succ {y = b} p) = [≤]-with-[+]ᵣ [≤]-minimum 🝖 [≤]-with-[⋅]ₗ {𝐒(𝐒(n))}{1}{𝐒(𝐒(n)) ^ b} ([^]-positive {𝐒(n)}{b})
[^]ₗ-strictly-growing {n} {𝐒 a} {.(𝐒 b)} (succ {y = b} p) = [<]-with-[⋅]ₗ {𝐒(n)} ([^]ₗ-strictly-growing {n}{a}{b} p)
[^]ₗ-growing : ∀{n a b} → ¬((n ≡ 𝟎) ∧ (a ≡ 𝟎)) → (a ≤ b) → ((n ^ a) ≤ (n ^ b))
[^]ₗ-growing {𝟎} {𝟎} {_} p _ with () ← p([∧]-intro [≡]-intro [≡]-intro)
[^]ₗ-growing {𝟎} {𝐒 a} {𝐒 b} _ _ = min
[^]ₗ-growing {𝐒 𝟎}{a} {b} _ _
rewrite [^]-of-𝟏ₗ {a}
rewrite [^]-of-𝟏ₗ {b}
= succ min
[^]ₗ-growing {𝐒 (𝐒 n)}{a}{b} _ ab with [≤]-to-[<][≡] ab
... | [∨]-introₗ p = sub₂(_<_)(_≤_) ([^]ₗ-strictly-growing {n}{a}{b} p)
... | [∨]-introᵣ [≡]-intro = reflexivity(_≤_)
|
programs/oeis/326/A326725.asm | neoneye/loda | 22 | 1761 | ; A326725: a(n) = (1/2)*n*(5*n - 7); row 5 of A326728.
; 0,-1,3,12,26,45,69,98,132,171,215,264,318,377,441,510,584,663,747,836,930,1029,1133,1242,1356,1475,1599,1728,1862,2001,2145,2294,2448,2607,2771,2940,3114,3293,3477,3666,3860,4059,4263,4472,4686,4905,5129,5358,5592,5831,6075,6324,6578,6837,7101,7370,7644,7923,8207,8496,8790,9089,9393,9702,10016,10335,10659,10988,11322,11661,12005,12354,12708,13067,13431,13800,14174,14553,14937,15326,15720,16119,16523,16932,17346,17765,18189,18618,19052,19491,19935,20384,20838,21297,21761,22230,22704,23183,23667,24156
mov $1,$0
mul $1,5
sub $1,7
mul $0,$1
div $0,2
|
bb-runtimes/src/a-intnam__mpc5200.ads | JCGobbi/Nucleo-STM32G474RE | 0 | 29396 | <reponame>JCGobbi/Nucleo-STM32G474RE
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- A D A . I N T E R R U P T S . N A M E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2011-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. --
-- --
-- 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- Definitions for the MPC5200B
package Ada.Interrupts.Names is
-- All identifiers in this unit are implementation defined
pragma Implementation_Defined;
-- Interrupt IDs are assigned in order of the mask register fields, with
-- Main and Critical Interrupts following Peripheral Interrupts. See
-- Table 7-4 and Table 7-9 of the MPC5200B User Manual.
subtype Peripheral_Interrupt_ID is Interrupt_ID range 0 .. 23;
subtype Main_Interrupt_ID is Interrupt_ID range 24 .. 40;
subtype Critical_Interrupt_ID is Interrupt_ID range 41 .. 44;
BestComm : constant Peripheral_Interrupt_ID := 0;
PSC1 : constant Peripheral_Interrupt_ID := 1;
PSC2 : constant Peripheral_Interrupt_ID := 2;
PSC3 : constant Peripheral_Interrupt_ID := 3;
PSC6 : constant Peripheral_Interrupt_ID := 4;
Ethernet : constant Peripheral_Interrupt_ID := 5;
USB : constant Peripheral_Interrupt_ID := 6;
ATA : constant Peripheral_Interrupt_ID := 7;
PCI_Control_Module : constant Peripheral_Interrupt_ID := 8;
PCI_SC_Initiator_RX : constant Peripheral_Interrupt_ID := 9;
PCI_SC_Initiator_TX : constant Peripheral_Interrupt_ID := 10;
PSC4 : constant Peripheral_Interrupt_ID := 11;
PSC5 : constant Peripheral_Interrupt_ID := 12;
SPI_MODF : constant Peripheral_Interrupt_ID := 13;
SPI_SPIF : constant Peripheral_Interrupt_ID := 14;
I2C1 : constant Peripheral_Interrupt_ID := 15;
I2C2 : constant Peripheral_Interrupt_ID := 16;
CAN1 : constant Peripheral_Interrupt_ID := 17;
CAN2 : constant Peripheral_Interrupt_ID := 18;
XLB_Arbiter : constant Peripheral_Interrupt_ID := 21;
BDLC : constant Peripheral_Interrupt_ID := 22;
BestComm_LocalPlus : constant Peripheral_Interrupt_ID := 23;
Slice_Timer_1 : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 0;
IRQ1 : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 1;
IRQ2 : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 2;
IRQ3 : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 3;
LO_INT : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 4;
-- Note: LO_INT is reserved for runtime use only
RTC_PINT : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 5;
RTC_SINT : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 6;
GPIO_STD : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 7;
GPIO_WKUP : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 8;
TMR0 : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 9;
TMR1 : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 10;
TMR2 : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 11;
TMR3 : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 12;
TMR4 : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 13;
TMR5 : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 14;
TMR6 : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 15;
TMR7 : constant Main_Interrupt_ID := Main_Interrupt_ID'First + 16;
IRQ0 : constant Critical_Interrupt_ID :=
Critical_Interrupt_ID'First + 0;
Slice_Timer_0 : constant Critical_Interrupt_ID :=
Critical_Interrupt_ID'First + 1;
HI_INT : constant Critical_Interrupt_ID :=
Critical_Interrupt_ID'First + 2;
-- Note: HI_INT is reserved for runtime use only
Wake_Up : constant Critical_Interrupt_ID :=
Critical_Interrupt_ID'First + 3;
end Ada.Interrupts.Names;
|
pkg/parser/tsdbql.g4 | xephonhq/tsql | 5 | 6459 | grammar tsdbql;
|
programs/oeis/171/A171405.asm | neoneye/loda | 22 | 4985 | ; A171405: Sum of divisors of n, excluding divisors 2 and 3.
; 1,1,1,5,6,7,8,13,10,16,12,23,14,22,21,29,18,34,20,40,29,34,24,55,31,40,37,54,30,67,32,61,45,52,48,86,38,58,53,88,42,91,44,82,75,70,48,119,57,91,69,96,54,115,72,118,77,88,60,163,62,94,101,125,84,139,68,124,93,142
add $0,1
mov $2,$0
lpb $0
mov $3,$2
mov $4,$0
cmp $4,0
add $0,$4
dif $3,$0
cmp $3,$2
cmp $3,0
mul $3,$0
sub $0,1
lpb $3
add $1,$3
mov $3,3
lpe
lpe
add $1,1
mov $0,$1
|
programs/oeis/315/A315654.asm | karttu/loda | 0 | 27841 | <gh_stars>0
; A315654: Coordination sequence Gal.3.49.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; 1,6,12,16,22,28,34,40,44,50,56,62,68,72,78,84,90,96,100,106,112,118,124,128,134,140,146,152,156,162,168,174,180,184,190,196,202,208,212,218,224,230,236,240,246,252,258,264,268,274
mul $0,4
mov $2,$0
add $0,3
lpb $0,1
add $1,1
add $1,$3
mov $3,$0
sub $0,4
lpb $0,3
add $2,2
mov $1,$2
lpe
trn $0,1
lpe
|
test/Succeed/Issue952.agda | shlevy/agda | 1,989 | 13046 |
open import Agda.Primitive
open import Agda.Builtin.Nat
-- Named implicit function types
postulate
T : Set → Set → Set
foo : {A = X : Set} {B : Set} → T X B
bar : ∀ {A = X} {B} → T X B
foo₁ : (X : Set) → T X X
foo₁ X = foo {A = X} {B = X}
bar₁ : ∀ X → T X X
bar₁ X = bar {A = X} {B = X}
Id : {A = _ : Set} → Set
Id {A = X} = X
Id₁ : Set → Set
Id₁ X = Id {A = X}
-- With blanks
postulate
namedUnused : {A = _ : Set} → Set
unnamedUsed : {_ = X : Set} → X → X
unnamedUnused : {_ = _ : Set} → Set
_ : Set
_ = namedUnused {A = Nat}
_ : Nat → Nat
_ = unnamedUsed {Nat} -- can't give by name
_ : Set
_ = unnamedUnused {Nat}
-- In left-hand sides
id : {A = X : Set} → X → X
id {A = Y} x = x
-- In with-functions
with-fun : ∀ {A} {B = X} → T A X → T A X
with-fun {A = A} {B = Z} x with T A Z
with-fun {B = Z} x | Goal = x
-- In datatypes
data List {ℓ = a} (A : Set a) : Set a where
[] : List A
_∷_ : A → List A → List A
List₁ = List {ℓ = lsuc lzero}
-- In module telescopes
module Named {A : Set} {B = X : Set} where
postulate H : X → A
h : (A : Set) → A → A
h A = Named.H {A = A} {B = A}
postulate
X : Set
open Named {A = X} {B = X}
hh : X → X
hh = H
-- Constructors
data Q (n : Nat) : Set where
mkQ : Q n
data E {n = x} (q : Q x) : Set where
mkE : E q
e₁ : (q : Q 1) → E q
e₁ q = mkE {n = 1} {q = q}
-- Generalized variables
variable
m n : Nat
q₁ = mkQ {n = 1}
data D (x : Q n) : Q m → Set where
refl : {y = z : Q m} → D x z
D₁ = D {n = 1}
D₁₂ = λ x → D {n = 1} x {m = 2}
refl′ = λ x → refl {n = 1} {x = x} {m = 2} {y = mkQ}
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_276_300.asm | ljhsiun2/medusa | 9 | 27031 | <filename>Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_276_300.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r15
push %r8
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0xdfc7, %rbp
nop
nop
nop
nop
and %r13, %r13
movups (%rbp), %xmm0
vpextrq $0, %xmm0, %rdi
nop
nop
nop
nop
add $31250, %rax
lea addresses_WT_ht+0x99f, %r13
and $56323, %r10
vmovups (%r13), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $1, %xmm7, %r15
nop
nop
nop
nop
nop
cmp $17146, %rax
lea addresses_A_ht+0x417f, %r13
nop
nop
nop
nop
nop
add $58441, %r8
vmovups (%r13), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $0, %xmm4, %r15
nop
nop
xor %r15, %r15
lea addresses_D_ht+0x3be0, %rsi
lea addresses_normal_ht+0x351f, %rdi
clflush (%rsi)
nop
nop
nop
nop
xor $17872, %r13
mov $3, %rcx
rep movsb
nop
xor %rax, %rax
lea addresses_normal_ht+0xf955, %r15
xor $35507, %r8
movb (%r15), %r13b
nop
nop
nop
nop
xor $22980, %r13
lea addresses_WT_ht+0x1b025, %rdi
nop
xor $37860, %rbp
movb $0x61, (%rdi)
nop
nop
nop
nop
nop
inc %r15
lea addresses_A_ht+0x1159f, %rdi
and %r10, %r10
movw $0x6162, (%rdi)
nop
nop
nop
nop
cmp %rax, %rax
lea addresses_D_ht+0x1339f, %r15
add %rsi, %rsi
mov $0x6162636465666768, %rax
movq %rax, %xmm1
and $0xffffffffffffffc0, %r15
vmovntdq %ymm1, (%r15)
nop
nop
nop
nop
cmp $31116, %rcx
lea addresses_A_ht+0xd59f, %rbp
nop
add %rdi, %rdi
movups (%rbp), %xmm1
vpextrq $1, %xmm1, %rax
nop
nop
nop
nop
dec %r10
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r8
pop %r15
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r9
push %rax
push %rbp
push %rcx
push %rdi
// Load
mov $0x577831000000055f, %r12
xor $10912, %rax
movb (%r12), %cl
add %rax, %rax
// Load
lea addresses_D+0x1979f, %rbp
nop
nop
nop
nop
nop
inc %r9
movb (%rbp), %r12b
nop
nop
nop
nop
xor %r9, %r9
// Store
lea addresses_A+0xd41f, %r11
clflush (%r11)
nop
nop
nop
nop
xor %r9, %r9
mov $0x5152535455565758, %rdi
movq %rdi, %xmm6
movntdq %xmm6, (%r11)
nop
nop
add %rbp, %rbp
// Store
lea addresses_WC+0x1e88f, %rcx
nop
nop
nop
nop
nop
and $33960, %rbp
mov $0x5152535455565758, %rax
movq %rax, %xmm4
movaps %xmm4, (%rcx)
nop
xor $54367, %rcx
// Store
lea addresses_D+0x19953, %r11
nop
xor %rax, %rax
movb $0x51, (%r11)
nop
nop
sub %r12, %r12
// Faulty Load
lea addresses_D+0x1979f, %rbp
nop
nop
nop
nop
nop
and $3844, %r9
movb (%rbp), %cl
lea oracles, %rbp
and $0xff, %rcx
shlq $12, %rcx
mov (%rbp,%rcx,1), %rcx
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5, 'same': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'dst': {'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 6, 'same': False, 'type': 'addresses_A'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 0, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 2, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 3, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 3, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 0, 'same': True, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'STOR'}
{'dst': {'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 10, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 4, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'36': 276}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
programs/oeis/214/A214945.asm | neoneye/loda | 22 | 1215 | ; A214945: Number of squarefree words of length 6 in an (n+1)-ary alphabet.
; 0,42,696,4260,16680,50190,126672,281736,569520,1068210,1886280,3169452,5108376,7947030,11991840,17621520,25297632,35575866,49118040,66704820,89249160,117810462,153609456,198043800,252704400,319392450,400137192,497214396,613165560,750817830,913304640,1104087072,1326975936,1586154570,1886202360,2232118980,2629349352,3083809326,3601912080,4190595240,4857348720,5610243282,6457959816,7409819340,8475813720,9666637110,10993718112,12469252656,14106237600,15918505050,17920757400,20128603092,22558593096,25228258110,28156146480,31361862840,34866107472,38690716386,42858702120,47394295260,52322986680,57671570502,63468187776,69742370880,76525088640,83848792170,91747461432,100256652516,109413545640,119256993870,129827572560,141167629512,153321335856,166334737650,180255808200,195134501100,211022803992,227974793046,246046688160,265296908880,285786131040,307577344122,330735909336,355329618420,381428753160,409106145630,438437239152,469500149976,502375729680,537147628290,573902358120,612729358332,653721060216,696972953190,742583651520,790654961760,841291950912,894603015306,950699950200,1009698020100
mov $3,$0
lpb $0
sub $0,1
add $1,$0
lpe
mul $1,4
mov $4,$3
mov $6,$3
lpb $6
add $5,$4
sub $6,1
lpe
mov $2,1
mov $4,$5
lpb $2
add $1,$4
sub $2,1
lpe
mov $5,0
mov $6,$3
lpb $6
add $5,$4
sub $6,1
lpe
mov $2,16
mov $4,$5
lpb $2
add $1,$4
sub $2,1
lpe
mov $5,0
mov $6,$3
lpb $6
add $5,$4
sub $6,1
lpe
mov $2,17
mov $4,$5
lpb $2
add $1,$4
sub $2,1
lpe
mov $5,0
mov $6,$3
lpb $6
add $5,$4
sub $6,1
lpe
mov $2,7
mov $4,$5
lpb $2
add $1,$4
sub $2,1
lpe
mov $5,0
mov $6,$3
lpb $6
add $5,$4
sub $6,1
lpe
mov $2,1
mov $4,$5
lpb $2
add $1,$4
sub $2,1
lpe
mov $0,$1
|
ASSEMBLY-EMU8086/EVEN ODD Checker.asm | ar-pavel/Code-Library | 0 | 29622 | INCLUDE 'EMU8086.INC'
.MODEL SMALL
.STACK 100H
.DATA
.CODE
MAIN PROC
@INPUT:
PRINT " INPUT THE NUMBER : "
MOV AH,1
INT 21H
@CHECK:
MOV AH,0
MOV DL, 2
DIV DL
CMP AH,0
JE @EVEN
@ODD:
MOV AH,2
MOV DL,0AH
INT 21H
MOV DL,0DH
INT 21H
PRINT " THE NUMBER IS ODD "
JMP FINISH
@EVEN:
MOV AH,2
MOV DL,0AH
INT 21H
MOV DL,0DH
INT 21H
PRINT " THE NUMBER IS EVEN "
FINISH:
MOV AH,4CH
INT 21H
ENDP MAIN
END MAIN
|
forktest.asm | harshika18/xv6-assignment | 0 | 1290 | <filename>forktest.asm<gh_stars>0
_forktest: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
printf(1, "fork test OK\n");
}
int
main(void)
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 51 push %ecx
e: 83 ec 04 sub $0x4,%esp
forktest();
11: e8 3a 00 00 00 call 50 <forktest>
exit();
16: e8 77 03 00 00 call 392 <exit>
1b: 66 90 xchg %ax,%ax
1d: 66 90 xchg %ax,%ax
1f: 90 nop
00000020 <printf>:
#define N 1000
void
printf(int fd, const char *s, ...)
{
20: 55 push %ebp
21: 89 e5 mov %esp,%ebp
23: 53 push %ebx
24: 83 ec 10 sub $0x10,%esp
27: 8b 5d 0c mov 0xc(%ebp),%ebx
write(fd, s, strlen(s));
2a: 53 push %ebx
2b: e8 a0 01 00 00 call 1d0 <strlen>
30: 83 c4 0c add $0xc,%esp
33: 50 push %eax
34: 53 push %ebx
35: ff 75 08 pushl 0x8(%ebp)
38: e8 75 03 00 00 call 3b2 <write>
}
3d: 83 c4 10 add $0x10,%esp
40: 8b 5d fc mov -0x4(%ebp),%ebx
43: c9 leave
44: c3 ret
45: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000050 <forktest>:
void
forktest(void)
{
50: 55 push %ebp
51: 89 e5 mov %esp,%ebp
53: 53 push %ebx
int n, pid;
printf(1, "fork test\n");
for(n=0; n<N; n++){
54: 31 db xor %ebx,%ebx
write(fd, s, strlen(s));
}
void
forktest(void)
{
56: 83 ec 10 sub $0x10,%esp
#define N 1000
void
printf(int fd, const char *s, ...)
{
write(fd, s, strlen(s));
59: 68 54 04 00 00 push $0x454
5e: e8 6d 01 00 00 call 1d0 <strlen>
63: 83 c4 0c add $0xc,%esp
66: 50 push %eax
67: 68 54 04 00 00 push $0x454
6c: 6a 01 push $0x1
6e: e8 3f 03 00 00 call 3b2 <write>
73: 83 c4 10 add $0x10,%esp
76: eb 19 jmp 91 <forktest+0x41>
78: 90 nop
79: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(n=0; n<N; n++){
pid = fork();
if(pid < 0)
break;
if(pid == 0)
80: 0f 84 7c 00 00 00 je 102 <forktest+0xb2>
{
int n, pid;
printf(1, "fork test\n");
for(n=0; n<N; n++){
86: 83 c3 01 add $0x1,%ebx
89: 81 fb e8 03 00 00 cmp $0x3e8,%ebx
8f: 74 4f je e0 <forktest+0x90>
pid = fork();
91: e8 f4 02 00 00 call 38a <fork>
if(pid < 0)
96: 85 c0 test %eax,%eax
98: 79 e6 jns 80 <forktest+0x30>
if(n == N){
printf(1, "fork claimed to work N times!\n", N);
exit();
}
for(; n > 0; n--){
9a: 85 db test %ebx,%ebx
9c: 74 10 je ae <forktest+0x5e>
9e: 66 90 xchg %ax,%ax
if(wait() < 0){
a0: e8 f5 02 00 00 call 39a <wait>
a5: 85 c0 test %eax,%eax
a7: 78 5e js 107 <forktest+0xb7>
if(n == N){
printf(1, "fork claimed to work N times!\n", N);
exit();
}
for(; n > 0; n--){
a9: 83 eb 01 sub $0x1,%ebx
ac: 75 f2 jne a0 <forktest+0x50>
printf(1, "wait stopped early\n");
exit();
}
}
if(wait() != -1){
ae: e8 e7 02 00 00 call 39a <wait>
b3: 83 f8 ff cmp $0xffffffff,%eax
b6: 75 71 jne 129 <forktest+0xd9>
#define N 1000
void
printf(int fd, const char *s, ...)
{
write(fd, s, strlen(s));
b8: 83 ec 0c sub $0xc,%esp
bb: 68 86 04 00 00 push $0x486
c0: e8 0b 01 00 00 call 1d0 <strlen>
c5: 83 c4 0c add $0xc,%esp
c8: 50 push %eax
c9: 68 86 04 00 00 push $0x486
ce: 6a 01 push $0x1
d0: e8 dd 02 00 00 call 3b2 <write>
printf(1, "wait got too many\n");
exit();
}
printf(1, "fork test OK\n");
}
d5: 8b 5d fc mov -0x4(%ebp),%ebx
d8: c9 leave
d9: c3 ret
da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
#define N 1000
void
printf(int fd, const char *s, ...)
{
write(fd, s, strlen(s));
e0: 83 ec 0c sub $0xc,%esp
e3: 68 94 04 00 00 push $0x494
e8: e8 e3 00 00 00 call 1d0 <strlen>
ed: 83 c4 0c add $0xc,%esp
f0: 50 push %eax
f1: 68 94 04 00 00 push $0x494
f6: 6a 01 push $0x1
f8: e8 b5 02 00 00 call 3b2 <write>
exit();
}
if(n == N){
printf(1, "fork claimed to work N times!\n", N);
exit();
fd: e8 90 02 00 00 call 392 <exit>
for(n=0; n<N; n++){
pid = fork();
if(pid < 0)
break;
if(pid == 0)
exit();
102: e8 8b 02 00 00 call 392 <exit>
#define N 1000
void
printf(int fd, const char *s, ...)
{
write(fd, s, strlen(s));
107: 83 ec 0c sub $0xc,%esp
10a: 68 5f 04 00 00 push $0x45f
10f: e8 bc 00 00 00 call 1d0 <strlen>
114: 83 c4 0c add $0xc,%esp
117: 50 push %eax
118: 68 5f 04 00 00 push $0x45f
11d: 6a 01 push $0x1
11f: e8 8e 02 00 00 call 3b2 <write>
}
for(; n > 0; n--){
if(wait() < 0){
printf(1, "wait stopped early\n");
exit();
124: e8 69 02 00 00 call 392 <exit>
#define N 1000
void
printf(int fd, const char *s, ...)
{
write(fd, s, strlen(s));
129: 83 ec 0c sub $0xc,%esp
12c: 68 73 04 00 00 push $0x473
131: e8 9a 00 00 00 call 1d0 <strlen>
136: 83 c4 0c add $0xc,%esp
139: 50 push %eax
13a: 68 73 04 00 00 push $0x473
13f: 6a 01 push $0x1
141: e8 6c 02 00 00 call 3b2 <write>
}
}
if(wait() != -1){
printf(1, "wait got too many\n");
exit();
146: e8 47 02 00 00 call 392 <exit>
14b: 66 90 xchg %ax,%ax
14d: 66 90 xchg %ax,%ax
14f: 90 nop
00000150 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
150: 55 push %ebp
151: 89 e5 mov %esp,%ebp
153: 53 push %ebx
154: 8b 45 08 mov 0x8(%ebp),%eax
157: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
15a: 89 c2 mov %eax,%edx
15c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
160: 83 c1 01 add $0x1,%ecx
163: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
167: 83 c2 01 add $0x1,%edx
16a: 84 db test %bl,%bl
16c: 88 5a ff mov %bl,-0x1(%edx)
16f: 75 ef jne 160 <strcpy+0x10>
;
return os;
}
171: 5b pop %ebx
172: 5d pop %ebp
173: c3 ret
174: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
17a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000180 <strcmp>:
int
strcmp(const char *p, const char *q)
{
180: 55 push %ebp
181: 89 e5 mov %esp,%ebp
183: 56 push %esi
184: 53 push %ebx
185: 8b 55 08 mov 0x8(%ebp),%edx
188: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
18b: 0f b6 02 movzbl (%edx),%eax
18e: 0f b6 19 movzbl (%ecx),%ebx
191: 84 c0 test %al,%al
193: 75 1e jne 1b3 <strcmp+0x33>
195: eb 29 jmp 1c0 <strcmp+0x40>
197: 89 f6 mov %esi,%esi
199: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
1a0: 83 c2 01 add $0x1,%edx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
1a3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
1a6: 8d 71 01 lea 0x1(%ecx),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
1a9: 0f b6 59 01 movzbl 0x1(%ecx),%ebx
1ad: 84 c0 test %al,%al
1af: 74 0f je 1c0 <strcmp+0x40>
1b1: 89 f1 mov %esi,%ecx
1b3: 38 d8 cmp %bl,%al
1b5: 74 e9 je 1a0 <strcmp+0x20>
p++, q++;
return (uchar)*p - (uchar)*q;
1b7: 29 d8 sub %ebx,%eax
}
1b9: 5b pop %ebx
1ba: 5e pop %esi
1bb: 5d pop %ebp
1bc: c3 ret
1bd: 8d 76 00 lea 0x0(%esi),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
1c0: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
1c2: 29 d8 sub %ebx,%eax
}
1c4: 5b pop %ebx
1c5: 5e pop %esi
1c6: 5d pop %ebp
1c7: c3 ret
1c8: 90 nop
1c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000001d0 <strlen>:
uint
strlen(const char *s)
{
1d0: 55 push %ebp
1d1: 89 e5 mov %esp,%ebp
1d3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
1d6: 80 39 00 cmpb $0x0,(%ecx)
1d9: 74 12 je 1ed <strlen+0x1d>
1db: 31 d2 xor %edx,%edx
1dd: 8d 76 00 lea 0x0(%esi),%esi
1e0: 83 c2 01 add $0x1,%edx
1e3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
1e7: 89 d0 mov %edx,%eax
1e9: 75 f5 jne 1e0 <strlen+0x10>
;
return n;
}
1eb: 5d pop %ebp
1ec: c3 ret
uint
strlen(const char *s)
{
int n;
for(n = 0; s[n]; n++)
1ed: 31 c0 xor %eax,%eax
;
return n;
}
1ef: 5d pop %ebp
1f0: c3 ret
1f1: eb 0d jmp 200 <memset>
1f3: 90 nop
1f4: 90 nop
1f5: 90 nop
1f6: 90 nop
1f7: 90 nop
1f8: 90 nop
1f9: 90 nop
1fa: 90 nop
1fb: 90 nop
1fc: 90 nop
1fd: 90 nop
1fe: 90 nop
1ff: 90 nop
00000200 <memset>:
void*
memset(void *dst, int c, uint n)
{
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 57 push %edi
204: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
207: 8b 4d 10 mov 0x10(%ebp),%ecx
20a: 8b 45 0c mov 0xc(%ebp),%eax
20d: 89 d7 mov %edx,%edi
20f: fc cld
210: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
212: 89 d0 mov %edx,%eax
214: 5f pop %edi
215: 5d pop %ebp
216: c3 ret
217: 89 f6 mov %esi,%esi
219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000220 <strchr>:
char*
strchr(const char *s, char c)
{
220: 55 push %ebp
221: 89 e5 mov %esp,%ebp
223: 53 push %ebx
224: 8b 45 08 mov 0x8(%ebp),%eax
227: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
22a: 0f b6 10 movzbl (%eax),%edx
22d: 84 d2 test %dl,%dl
22f: 74 1d je 24e <strchr+0x2e>
if(*s == c)
231: 38 d3 cmp %dl,%bl
233: 89 d9 mov %ebx,%ecx
235: 75 0d jne 244 <strchr+0x24>
237: eb 17 jmp 250 <strchr+0x30>
239: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
240: 38 ca cmp %cl,%dl
242: 74 0c je 250 <strchr+0x30>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
244: 83 c0 01 add $0x1,%eax
247: 0f b6 10 movzbl (%eax),%edx
24a: 84 d2 test %dl,%dl
24c: 75 f2 jne 240 <strchr+0x20>
if(*s == c)
return (char*)s;
return 0;
24e: 31 c0 xor %eax,%eax
}
250: 5b pop %ebx
251: 5d pop %ebp
252: c3 ret
253: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000260 <gets>:
char*
gets(char *buf, int max)
{
260: 55 push %ebp
261: 89 e5 mov %esp,%ebp
263: 57 push %edi
264: 56 push %esi
265: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
266: 31 f6 xor %esi,%esi
cc = read(0, &c, 1);
268: 8d 7d e7 lea -0x19(%ebp),%edi
return 0;
}
char*
gets(char *buf, int max)
{
26b: 83 ec 1c sub $0x1c,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
26e: eb 29 jmp 299 <gets+0x39>
cc = read(0, &c, 1);
270: 83 ec 04 sub $0x4,%esp
273: 6a 01 push $0x1
275: 57 push %edi
276: 6a 00 push $0x0
278: e8 2d 01 00 00 call 3aa <read>
if(cc < 1)
27d: 83 c4 10 add $0x10,%esp
280: 85 c0 test %eax,%eax
282: 7e 1d jle 2a1 <gets+0x41>
break;
buf[i++] = c;
284: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
288: 8b 55 08 mov 0x8(%ebp),%edx
28b: 89 de mov %ebx,%esi
if(c == '\n' || c == '\r')
28d: 3c 0a cmp $0xa,%al
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
28f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
293: 74 1b je 2b0 <gets+0x50>
295: 3c 0d cmp $0xd,%al
297: 74 17 je 2b0 <gets+0x50>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
299: 8d 5e 01 lea 0x1(%esi),%ebx
29c: 3b 5d 0c cmp 0xc(%ebp),%ebx
29f: 7c cf jl 270 <gets+0x10>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
2a1: 8b 45 08 mov 0x8(%ebp),%eax
2a4: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
2a8: 8d 65 f4 lea -0xc(%ebp),%esp
2ab: 5b pop %ebx
2ac: 5e pop %esi
2ad: 5f pop %edi
2ae: 5d pop %ebp
2af: c3 ret
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
2b0: 8b 45 08 mov 0x8(%ebp),%eax
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
2b3: 89 de mov %ebx,%esi
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
2b5: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
2b9: 8d 65 f4 lea -0xc(%ebp),%esp
2bc: 5b pop %ebx
2bd: 5e pop %esi
2be: 5f pop %edi
2bf: 5d pop %ebp
2c0: c3 ret
2c1: eb 0d jmp 2d0 <stat>
2c3: 90 nop
2c4: 90 nop
2c5: 90 nop
2c6: 90 nop
2c7: 90 nop
2c8: 90 nop
2c9: 90 nop
2ca: 90 nop
2cb: 90 nop
2cc: 90 nop
2cd: 90 nop
2ce: 90 nop
2cf: 90 nop
000002d0 <stat>:
int
stat(const char *n, struct stat *st)
{
2d0: 55 push %ebp
2d1: 89 e5 mov %esp,%ebp
2d3: 56 push %esi
2d4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
2d5: 83 ec 08 sub $0x8,%esp
2d8: 6a 00 push $0x0
2da: ff 75 08 pushl 0x8(%ebp)
2dd: e8 f0 00 00 00 call 3d2 <open>
if(fd < 0)
2e2: 83 c4 10 add $0x10,%esp
2e5: 85 c0 test %eax,%eax
2e7: 78 27 js 310 <stat+0x40>
return -1;
r = fstat(fd, st);
2e9: 83 ec 08 sub $0x8,%esp
2ec: ff 75 0c pushl 0xc(%ebp)
2ef: 89 c3 mov %eax,%ebx
2f1: 50 push %eax
2f2: e8 f3 00 00 00 call 3ea <fstat>
2f7: 89 c6 mov %eax,%esi
close(fd);
2f9: 89 1c 24 mov %ebx,(%esp)
2fc: e8 b9 00 00 00 call 3ba <close>
return r;
301: 83 c4 10 add $0x10,%esp
304: 89 f0 mov %esi,%eax
}
306: 8d 65 f8 lea -0x8(%ebp),%esp
309: 5b pop %ebx
30a: 5e pop %esi
30b: 5d pop %ebp
30c: c3 ret
30d: 8d 76 00 lea 0x0(%esi),%esi
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
310: b8 ff ff ff ff mov $0xffffffff,%eax
315: eb ef jmp 306 <stat+0x36>
317: 89 f6 mov %esi,%esi
319: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000320 <atoi>:
return r;
}
int
atoi(const char *s)
{
320: 55 push %ebp
321: 89 e5 mov %esp,%ebp
323: 53 push %ebx
324: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
327: 0f be 11 movsbl (%ecx),%edx
32a: 8d 42 d0 lea -0x30(%edx),%eax
32d: 3c 09 cmp $0x9,%al
32f: b8 00 00 00 00 mov $0x0,%eax
334: 77 1f ja 355 <atoi+0x35>
336: 8d 76 00 lea 0x0(%esi),%esi
339: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
340: 8d 04 80 lea (%eax,%eax,4),%eax
343: 83 c1 01 add $0x1,%ecx
346: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
34a: 0f be 11 movsbl (%ecx),%edx
34d: 8d 5a d0 lea -0x30(%edx),%ebx
350: 80 fb 09 cmp $0x9,%bl
353: 76 eb jbe 340 <atoi+0x20>
n = n*10 + *s++ - '0';
return n;
}
355: 5b pop %ebx
356: 5d pop %ebp
357: c3 ret
358: 90 nop
359: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000360 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
360: 55 push %ebp
361: 89 e5 mov %esp,%ebp
363: 56 push %esi
364: 53 push %ebx
365: 8b 5d 10 mov 0x10(%ebp),%ebx
368: 8b 45 08 mov 0x8(%ebp),%eax
36b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
36e: 85 db test %ebx,%ebx
370: 7e 14 jle 386 <memmove+0x26>
372: 31 d2 xor %edx,%edx
374: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
378: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
37c: 88 0c 10 mov %cl,(%eax,%edx,1)
37f: 83 c2 01 add $0x1,%edx
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
382: 39 da cmp %ebx,%edx
384: 75 f2 jne 378 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
386: 5b pop %ebx
387: 5e pop %esi
388: 5d pop %ebp
389: c3 ret
0000038a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
38a: b8 01 00 00 00 mov $0x1,%eax
38f: cd 40 int $0x40
391: c3 ret
00000392 <exit>:
SYSCALL(exit)
392: b8 02 00 00 00 mov $0x2,%eax
397: cd 40 int $0x40
399: c3 ret
0000039a <wait>:
SYSCALL(wait)
39a: b8 03 00 00 00 mov $0x3,%eax
39f: cd 40 int $0x40
3a1: c3 ret
000003a2 <pipe>:
SYSCALL(pipe)
3a2: b8 04 00 00 00 mov $0x4,%eax
3a7: cd 40 int $0x40
3a9: c3 ret
000003aa <read>:
SYSCALL(read)
3aa: b8 05 00 00 00 mov $0x5,%eax
3af: cd 40 int $0x40
3b1: c3 ret
000003b2 <write>:
SYSCALL(write)
3b2: b8 10 00 00 00 mov $0x10,%eax
3b7: cd 40 int $0x40
3b9: c3 ret
000003ba <close>:
SYSCALL(close)
3ba: b8 15 00 00 00 mov $0x15,%eax
3bf: cd 40 int $0x40
3c1: c3 ret
000003c2 <kill>:
SYSCALL(kill)
3c2: b8 06 00 00 00 mov $0x6,%eax
3c7: cd 40 int $0x40
3c9: c3 ret
000003ca <exec>:
SYSCALL(exec)
3ca: b8 07 00 00 00 mov $0x7,%eax
3cf: cd 40 int $0x40
3d1: c3 ret
000003d2 <open>:
SYSCALL(open)
3d2: b8 0f 00 00 00 mov $0xf,%eax
3d7: cd 40 int $0x40
3d9: c3 ret
000003da <mknod>:
SYSCALL(mknod)
3da: b8 11 00 00 00 mov $0x11,%eax
3df: cd 40 int $0x40
3e1: c3 ret
000003e2 <unlink>:
SYSCALL(unlink)
3e2: b8 12 00 00 00 mov $0x12,%eax
3e7: cd 40 int $0x40
3e9: c3 ret
000003ea <fstat>:
SYSCALL(fstat)
3ea: b8 08 00 00 00 mov $0x8,%eax
3ef: cd 40 int $0x40
3f1: c3 ret
000003f2 <link>:
SYSCALL(link)
3f2: b8 13 00 00 00 mov $0x13,%eax
3f7: cd 40 int $0x40
3f9: c3 ret
000003fa <mkdir>:
SYSCALL(mkdir)
3fa: b8 14 00 00 00 mov $0x14,%eax
3ff: cd 40 int $0x40
401: c3 ret
00000402 <chdir>:
SYSCALL(chdir)
402: b8 09 00 00 00 mov $0x9,%eax
407: cd 40 int $0x40
409: c3 ret
0000040a <dup>:
SYSCALL(dup)
40a: b8 0a 00 00 00 mov $0xa,%eax
40f: cd 40 int $0x40
411: c3 ret
00000412 <getpid>:
SYSCALL(getpid)
412: b8 0b 00 00 00 mov $0xb,%eax
417: cd 40 int $0x40
419: c3 ret
0000041a <sbrk>:
SYSCALL(sbrk)
41a: b8 0c 00 00 00 mov $0xc,%eax
41f: cd 40 int $0x40
421: c3 ret
00000422 <sleep>:
SYSCALL(sleep)
422: b8 0d 00 00 00 mov $0xd,%eax
427: cd 40 int $0x40
429: c3 ret
0000042a <uptime>:
SYSCALL(uptime)
42a: b8 0e 00 00 00 mov $0xe,%eax
42f: cd 40 int $0x40
431: c3 ret
00000432 <waitx>:
SYSCALL(waitx)
432: b8 16 00 00 00 mov $0x16,%eax
437: cd 40 int $0x40
439: c3 ret
0000043a <cps>:
SYSCALL(cps)
43a: b8 17 00 00 00 mov $0x17,%eax
43f: cd 40 int $0x40
441: c3 ret
00000442 <set_priority>:
SYSCALL(set_priority)
442: b8 18 00 00 00 mov $0x18,%eax
447: cd 40 int $0x40
449: c3 ret
0000044a <getpinfo>:
44a: b8 19 00 00 00 mov $0x19,%eax
44f: cd 40 int $0x40
451: c3 ret
|
programs/oeis/016/A016146.asm | neoneye/loda | 22 | 173659 | ; A016146: Expansion of 1/((1-3x)(1-11x)).
; 1,14,163,1820,20101,221354,2435623,26794040,294741001,3242170694,35663936683,392303480660,4315338818701,47468728600034,522156019383343,5743716227565680,63180878546269201,694989664138101374
add $0,1
mov $1,11
pow $1,$0
mov $2,3
pow $2,$0
sub $1,$2
div $1,8
mov $0,$1
|
src/kqasm.g4 | quantum-ket/kbw | 0 | 5441 | /* Copyright 2020, 2021 <NAME> <<EMAIL>>
* Copyright 2020, 2021 <NAME> <<EMAIL>>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
grammar kqasm;
start : block* end_block;
block : label (instruction ENDL+)* end_instruction ENDL+;
end_block : label (instruction ENDL+)*;
label : 'LABEL' LABEL ENDL+;
instruction : ctrl? gate_name arg_list? QBIT # gate
| ctrl? 'PLUGIN' ADJ? name=STR qubits_list ARGS # plugin
| 'ALLOC' DIRTY? QBIT # alloc
| 'FREE' DIRTY? QBIT # free
| 'INT' result=INT left=INT bin_op right=INT # binary_op
| 'INT' INT SIG? UINT # const_int
| 'SET' target=INT from=INT # set
| 'MEASURE' INT qubits_list # measure
| 'DUMP' qubits_list # dump
;
end_instruction : 'BR' INT then=LABEL otherwise=LABEL # branch
| 'JUMP' LABEL # jump
;
ctrl : 'CTRL' qubits_list ',';
qubits_list : '[' QBIT (',' QBIT)* ']';
gate_name : 'X'|'Y'|'Z' |'H'|'S'|'SD'|'T'|'TD'|'P'|'RZ'|'RX'|'RY';
arg_list : '(' DOUBLE (',' DOUBLE)* ')';
bin_op : '=='|'!='|'>'|'>='|'<'|'<='|'+'|'-'|'*'|'/'|'<<'|'>>'|'and'|'xor'|'or';
ADJ : '!';
ARGS : '"'~["]+'"';
DIRTY : 'DIRTY';
UINT : [0-9]+;
QBIT : 'q'UINT;
INT : 'i'UINT;
DOUBLE: '-'?[0-9]+'.'[0-9]*;
ENDL : '\r''\n'?|'\n';
LABEL : '@'STR;
SIG : '-';
STR : [a-zA-Z]+[._0-9a-zA-Z]*;
WS : [ \t]+ -> skip;
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_92.asm | ljhsiun2/medusa | 9 | 81972 | <filename>Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_92.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r8
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0xf915, %rsi
lea addresses_WC_ht+0x13f36, %rdi
nop
nop
nop
nop
nop
dec %r8
mov $10, %rcx
rep movsq
add %rbp, %rbp
lea addresses_A_ht+0x1e080, %rax
nop
nop
cmp %rbx, %rbx
movb (%rax), %cl
nop
nop
xor $53640, %rbp
lea addresses_A_ht+0x18290, %rsi
lea addresses_normal_ht+0x1c1ec, %rdi
clflush (%rdi)
nop
nop
nop
nop
cmp $24570, %r12
mov $77, %rcx
rep movsq
cmp %rax, %rax
lea addresses_normal_ht+0x6e90, %rcx
nop
nop
nop
nop
nop
add %rbp, %rbp
mov $0x6162636465666768, %rsi
movq %rsi, %xmm6
movups %xmm6, (%rcx)
nop
xor $26987, %rcx
lea addresses_normal_ht+0x1090, %rbx
nop
nop
dec %rsi
movl $0x61626364, (%rbx)
nop
nop
nop
nop
add %rcx, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r8
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r9
push %rcx
push %rdi
// Store
lea addresses_D+0xad80, %r14
sub %r9, %r9
mov $0x5152535455565758, %rcx
movq %rcx, (%r14)
nop
nop
nop
nop
nop
dec %rdi
// Faulty Load
lea addresses_A+0x18a90, %rcx
nop
xor $45292, %r12
movb (%rcx), %r9b
lea oracles, %r14
and $0xff, %r9
shlq $12, %r9
mov (%r14,%r9,1), %r9
pop %rdi
pop %rcx
pop %r9
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_A', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 3}}
[Faulty Load]
{'src': {'type': 'addresses_A', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}}
{'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1, 'NT': True, 'same': False, 'congruent': 4}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 5}}
{'35': 21829}
35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35
*/
|
ecdsa128/src/GFp_src/src/zero.asm | FloydZ/Crypto-Hash | 11 | 4624 | <gh_stars>10-100
.686p
.mmx
.model flat,stdcall
option casemap:none
option prologue:none
option epilogue:none
.code
zero proc ptrA:DWORD
push eax
push esi
xor eax, eax
mov esi, dword ptr [esp+4+8]
and dword ptr [esi ], eax
and dword ptr [esi+ 4], eax
and dword ptr [esi+ 8], eax
and dword ptr [esi+12], eax
pop esi
pop eax
ret 4
zero endp
end |
oeis/345/A345380.asm | neoneye/loda-programs | 11 | 95744 | <filename>oeis/345/A345380.asm
; A345380: Number of Jacobsthal-Lucas numbers m <= n.
; Submitted by <NAME>
; 0,1,2,2,2,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
seq $0,284393 ; Positions of 1 in A284391; complement of A284392.
seq $0,70939 ; Length of binary representation of n.
mul $0,3900
sub $0,3900
div $0,3900
|
Source/HandleSpriteKicked.asm | xragey/qsmw | 0 | 84217 | <filename>Source/HandleSpriteKicked.asm
;-------------------------------------------------------------------------------
;
; qSMW - HandleSpriteKicked.asm
;
; Freed ROM: none
; Taken ROM: none
; Freed RAM: none
; Taken RAM: none
;
;-------------------------------------------------------------------------------
incsrc "Macro/Skip.asm"
; remove useless call
%Skip($01996E, 3)
|
boot.asm | One-OS-Dev/OS-One | 2 | 170348 | ORG 0x7c00
BITS 16
start:
jmp $
printchar:
mov ah, 0eh
mov al, 'A'
mov bx, 0
int 0x10
jmp $
message: db 'Hello World!', 0
times 510-($ - $$) db 0
dw 0xAA55
|
test/Fail/Polarity-pragma-and-mixed-polarity.agda | shlevy/agda | 1,989 | 8539 | <filename>test/Fail/Polarity-pragma-and-mixed-polarity.agda
postulate
F : Set → Set
{-# POLARITY F * #-}
data D : Set where
d : F D → D
|
autovectorization-tests/results/msvc19.28.29333-avx2/transform_neg.asm | clayne/toys | 0 | 24495 | <reponame>clayne/toys<gh_stars>0
_x$ = 8 ; size = 1
int <lambda_b961ac9dca32e245ad7c3bf10969bcc3>::operator()(signed char)const PROC ; <lambda_b961ac9dca32e245ad7c3bf10969bcc3>::operator(), COMDAT
movsx eax, BYTE PTR _x$[esp-4]
neg eax
ret 4
int <lambda_b961ac9dca32e245ad7c3bf10969bcc3>::operator()(signed char)const ENDP ; <lambda_b961ac9dca32e245ad7c3bf10969bcc3>::operator()
_x$ = 8 ; size = 4
int <lambda_30572cd3855b56bd1f49cceb7feff3dc>::operator()(int)const PROC ; <lambda_30572cd3855b56bd1f49cceb7feff3dc>::operator(), COMDAT
mov eax, DWORD PTR _x$[esp-4]
neg eax
ret 4
int <lambda_30572cd3855b56bd1f49cceb7feff3dc>::operator()(int)const ENDP ; <lambda_30572cd3855b56bd1f49cceb7feff3dc>::operator()
_v$ = 8 ; size = 4
void transform_neg_epi32(std::vector<int,std::allocator<int> > &) PROC ; transform_neg_epi32, COMDAT
mov ecx, DWORD PTR _v$[esp-4]
push ebx
push esi
push edi
mov edi, DWORD PTR [ecx+4]
xor ebx, ebx
mov eax, DWORD PTR [ecx]
mov esi, edi
sub esi, eax
xor ecx, ecx
add esi, 3
mov edx, eax
shr esi, 2
cmp eax, edi
cmova esi, ecx
test esi, esi
je SHORT $LN33@transform_
cmp esi, 32 ; 00000020H
jb SHORT $LN33@transform_
lea ecx, DWORD PTR [eax-4]
lea ecx, DWORD PTR [ecx+esi*4]
cmp eax, ecx
jbe SHORT $LN33@transform_
and esi, -32 ; ffffffe0H
npad 9
$LL24@transform_:
vxorpd xmm0, xmm0, xmm0
vpsubd ymm0, ymm0, YMMWORD PTR [eax]
vmovdqu YMMWORD PTR [edx], ymm0
vxorpd xmm0, xmm0, xmm0
vpsubd ymm0, ymm0, YMMWORD PTR [eax+32]
vmovdqu YMMWORD PTR [edx+32], ymm0
vxorpd xmm0, xmm0, xmm0
vpsubd ymm0, ymm0, YMMWORD PTR [eax+64]
vmovdqu YMMWORD PTR [edx+64], ymm0
vxorpd xmm0, xmm0, xmm0
vpsubd ymm0, ymm0, YMMWORD PTR [eax+96]
vmovdqu YMMWORD PTR [edx+96], ymm0
add ebx, 32 ; 00000020H
sub edx, -128 ; ffffff80H
sub eax, -128 ; ffffff80H
cmp ebx, esi
jne SHORT $LL24@transform_
$LN33@transform_:
cmp eax, edi
je SHORT $LN23@transform_
sub edx, eax
npad 7
$LL32@transform_:
mov ecx, DWORD PTR [eax]
neg ecx
mov DWORD PTR [edx+eax], ecx
add eax, 4
cmp eax, edi
jne SHORT $LL32@transform_
$LN23@transform_:
pop edi
pop esi
pop ebx
vzeroupper
ret 0
void transform_neg_epi32(std::vector<int,std::allocator<int> > &) ENDP ; transform_neg_epi32
_v$ = 8 ; size = 4
void transform_neg_epi8(std::vector<signed char,std::allocator<signed char> > &) PROC ; transform_neg_epi8, COMDAT
mov ecx, DWORD PTR _v$[esp-4]
push ebx
push esi
push edi
mov edi, DWORD PTR [ecx+4]
xor ebx, ebx
mov eax, DWORD PTR [ecx]
mov esi, edi
sub esi, eax
xor ecx, ecx
cmp eax, edi
mov edx, eax
cmova esi, ecx
test esi, esi
je SHORT $LN33@transform_
cmp esi, 128 ; 00000080H
jb SHORT $LN33@transform_
lea ecx, DWORD PTR [eax-1]
add ecx, esi
cmp eax, ecx
jbe SHORT $LN33@transform_
and esi, -128 ; ffffff80H
$LL24@transform_:
vxorpd xmm0, xmm0, xmm0
vpsubb ymm0, ymm0, YMMWORD PTR [eax]
vmovdqu YMMWORD PTR [edx], ymm0
vxorpd xmm0, xmm0, xmm0
vpsubb ymm0, ymm0, YMMWORD PTR [eax+32]
vmovdqu YMMWORD PTR [edx+32], ymm0
vxorpd xmm0, xmm0, xmm0
vpsubb ymm0, ymm0, YMMWORD PTR [eax+64]
vmovdqu YMMWORD PTR [edx+64], ymm0
vxorpd xmm0, xmm0, xmm0
vpsubb ymm0, ymm0, YMMWORD PTR [eax+96]
vmovdqu YMMWORD PTR [edx+96], ymm0
sub ebx, -128 ; ffffff80H
sub edx, -128 ; ffffff80H
sub eax, -128 ; ffffff80H
cmp ebx, esi
jne SHORT $LL24@transform_
$LN33@transform_:
cmp eax, edi
je SHORT $LN23@transform_
sub edx, eax
npad 4
$LL32@transform_:
mov cl, BYTE PTR [eax]
neg cl
mov BYTE PTR [edx+eax], cl
inc eax
cmp eax, edi
jne SHORT $LL32@transform_
$LN23@transform_:
pop edi
pop esi
pop ebx
vzeroupper
ret 0
void transform_neg_epi8(std::vector<signed char,std::allocator<signed char> > &) ENDP ; transform_neg_epi8
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_875.asm | ljhsiun2/medusa | 9 | 178094 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r15
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x20e5, %r15
nop
nop
nop
nop
add %rbp, %rbp
mov (%r15), %r14w
nop
nop
nop
cmp %rbp, %rbp
lea addresses_WC_ht+0x7ff1, %rsi
lea addresses_A_ht+0x8ea2, %rdi
clflush (%rsi)
nop
nop
nop
xor %rbp, %rbp
mov $45, %rcx
rep movsb
nop
nop
nop
nop
nop
cmp %rdi, %rdi
lea addresses_WC_ht+0x12ee1, %r14
nop
nop
nop
nop
add %rdx, %rdx
movb $0x61, (%r14)
nop
nop
nop
dec %rcx
lea addresses_WC_ht+0x1493f, %rsi
lea addresses_WC_ht+0x1bcfd, %rdi
add $24946, %r12
mov $40, %rcx
rep movsb
nop
sub %rsi, %rsi
lea addresses_WT_ht+0x2b31, %r14
nop
nop
nop
sub %rbp, %rbp
mov $0x6162636465666768, %r15
movq %r15, %xmm5
movups %xmm5, (%r14)
nop
nop
nop
inc %rsi
lea addresses_A_ht+0x18731, %rdx
clflush (%rdx)
nop
nop
and $39530, %rsi
mov (%rdx), %ebp
nop
nop
xor $14491, %rdi
lea addresses_UC_ht+0x4131, %rsi
lea addresses_D_ht+0x15ed1, %rdi
nop
nop
nop
xor %r14, %r14
mov $98, %rcx
rep movsb
nop
cmp $44607, %rcx
lea addresses_A_ht+0x10764, %r14
nop
nop
nop
nop
cmp $64156, %rcx
movw $0x6162, (%r14)
nop
add %r14, %r14
lea addresses_A_ht+0x175f1, %r14
nop
nop
nop
cmp $57995, %rdi
mov $0x6162636465666768, %r15
movq %r15, %xmm5
vmovups %ymm5, (%r14)
nop
cmp $52752, %rdi
lea addresses_A_ht+0xe399, %rsi
lea addresses_A_ht+0x8705, %rdi
nop
nop
nop
cmp $52722, %rbp
mov $127, %rcx
rep movsl
nop
nop
nop
nop
sub $37072, %rdi
lea addresses_UC_ht+0x3c44, %rbp
nop
nop
nop
nop
and %rdi, %rdi
vmovups (%rbp), %ymm7
vextracti128 $0, %ymm7, %xmm7
vpextrq $0, %xmm7, %r12
nop
nop
sub %rsi, %rsi
lea addresses_UC_ht+0x9131, %rdi
nop
nop
nop
nop
nop
and $54255, %r15
vmovups (%rdi), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $1, %xmm4, %r14
nop
nop
nop
nop
nop
sub $26454, %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r15
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r15
push %rbp
push %rbx
push %rdi
// Faulty Load
lea addresses_normal+0x12131, %rdi
nop
nop
nop
nop
add $12831, %r15
movups (%rdi), %xmm3
vpextrq $0, %xmm3, %rbp
lea oracles, %r10
and $0xff, %rbp
shlq $12, %rbp
mov (%r10,%rbp,1), %rbp
pop %rdi
pop %rbx
pop %rbp
pop %r15
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 1, 'NT': True, 'same': True, 'congruent': 4}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 8}}
{'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 8}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 5}}
{'src': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': True, 'congruent': 11}, 'OP': 'LOAD'}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
src/main/resources/FixRules.g4 | maheshsingapore/FIX_validator | 0 | 5540 | grammar FixRules;
rules: rule+;
ifRule : onlyIf tag stmt (andOr openBracket? tag stmt closeBracket?)*;
rule : tag stmt (ifRule)? ';' (ACTION_DIRECTOR action)? NEWLINE?;
stmt : listOperator list
| monoOperandOperator tagStmt
| monoOperandOperator monoOperand
| logicalCondition;
action : 'INCOMPLETE' | 'INVALID' | 'INCONSISTENT' | 'NOTUNIQ';
tagStmt : tag ('+' tag)+;
monoOperandOperator : EQ|GR|GE|LS|LE|NE|MT;
monoOperand : operand | tag;
tag : 'tag(' INT ')' ;
operand : FLOAT | INT | STRING;
biOperandOperator: between;
biOperand: '(' FLOAT ','FLOAT')'
| '(' INT ','INT')'
| '(' date ','date')';
listOperator: not? 'in';
list: '['? operand (',' operand)* ']'?;
logicalCondition: logicalOperator logicalOperand ( andOr openBracket* logicalCondition closeBracket* )*;
logicalOperator: is|mustBe|mustNotBe;
logicalOperand: present|absent|mandatory|valid|consistent|numeric|alphanumeric|before|after
|listOperator list
|biOperandOperator biOperand
|greaterThan monoOperand
|lessThan monoOperand
|equalTo monoOperand
|match stringOperand
;
stringOperand: STRING;
andOr : and|or;
or: 'or ';
and: 'and ';
not: 'not ';
is : 'is ' not?;
mustBe: 'must be';
mustNotBe: 'must not be';
between: 'between';
equalTo: 'equal to';
match : 'match';
greaterThan: 'greater than';
lessThan: 'less than';
present: 'present';
absent: 'absent';
alphanumeric: 'alphanumeric';
mandatory: 'mandatory';
valid: 'valid';
consistent: 'consistent';
numeric : 'numeric';
before: 'before ' date;
after: 'after ' date;
dateToday: 'today';
dateTomorrow: 'tomorrow';
dateYesterday: 'yesterday';
date: dateToday | dateTomorrow | dateYesterday;
onlyIf: 'if ';
openBracket:'{';
closeBracket: '}';
//Lexer rules
ID : [a-zA-Z]+ ; // match identifiers
INT : '-'? [0-9]+; // match integers
FLOAT : '0'..'9'+('.'('0'..'9')*)? ; // match float
NEWLINE :'\r'? '\n' ; // return newlines to parser (end-statement signal)
WS : [ \t\n\r]+ -> skip ; // toss out whitespace
EQ : '=';
GR : '>';
GE : '>=';
LS : '<';
LE : '<=';
NE : '!=';
MT : '~=';
T : 't'|'T';
A : 'a'|'A';
G : 'g'|'G';
STRING : '"' (' '..'~')* '"';
ACTION_DIRECTOR : '->';
|
oeis/046/A046181.asm | neoneye/loda-programs | 11 | 84080 | ; A046181: Indices of octagonal numbers which are also triangular.
; Submitted by <NAME>
; 1,3,63,261,6141,25543,601723,2502921,58962681,245260683,5777740983,24033043981,566159653621,2354993049423,55477868313843,230765285799441,5436264935102961,22612643015295763,532698485771776303,2215808250213185301,52199015340698974701,217126595877876863703,5114970804902727744363,21276190587781719457561,501214939865126619972841,2084849551006730629977243,49113949135977506029594023,204293979808071820018312221,4812665800385930464280241381,20018725171640031631164620383,471592134488685207993434061283
mov $2,$0
mul $0,2
add $2,5
mod $2,2
add $0,$2
seq $0,129445 ; Numbers k > 0 such that k^2 is a centered triangular number.
div $0,6
mul $0,2
add $0,1
|
Transynther/x86/_processed/AVXALIGN/_st_sm_/i9-9900K_12_0xca.log_21829_992.asm | ljhsiun2/medusa | 9 | 172331 | <filename>Transynther/x86/_processed/AVXALIGN/_st_sm_/i9-9900K_12_0xca.log_21829_992.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r15
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x51b7, %rsi
lea addresses_D_ht+0xfab7, %rdi
nop
nop
nop
nop
nop
and $16438, %r11
mov $57, %rcx
rep movsq
nop
nop
nop
nop
xor $21101, %r15
lea addresses_UC_ht+0xb9b7, %rsi
lea addresses_D_ht+0x14b77, %rdi
nop
nop
nop
nop
nop
sub %r12, %r12
mov $1, %rcx
rep movsq
nop
dec %r12
lea addresses_A_ht+0xff7, %rsi
lea addresses_WC_ht+0x1d5b7, %rdi
nop
nop
nop
sub %rdx, %rdx
mov $68, %rcx
rep movsw
nop
nop
nop
xor $27474, %r12
lea addresses_WT_ht+0x1b837, %rsi
lea addresses_WT_ht+0x1b90a, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
and %r11, %r11
mov $111, %rcx
rep movsl
nop
cmp %rcx, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r15
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r15
push %r9
push %rax
push %rbx
push %rdx
// Store
lea addresses_PSE+0x14db7, %r15
nop
nop
nop
inc %r9
mov $0x5152535455565758, %rbx
movq %rbx, %xmm6
vmovups %ymm6, (%r15)
inc %r10
// Store
lea addresses_WT+0x81b7, %rdx
nop
nop
nop
cmp $28670, %r12
mov $0x5152535455565758, %r15
movq %r15, %xmm4
movups %xmm4, (%rdx)
nop
nop
xor $64368, %rbx
// Store
lea addresses_WT+0x81b7, %r12
inc %rbx
mov $0x5152535455565758, %r15
movq %r15, %xmm4
vmovups %ymm4, (%r12)
add %rdx, %rdx
// Faulty Load
lea addresses_WT+0x81b7, %rdx
nop
nop
nop
nop
xor $4429, %r9
mov (%rdx), %bx
lea oracles, %r9
and $0xff, %rbx
shlq $12, %rbx
mov (%r9,%rbx,1), %rbx
pop %rdx
pop %rbx
pop %rax
pop %r9
pop %r15
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': True, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_normal_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 8}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 11}, 'dst': {'same': True, 'type': 'addresses_D_ht', 'congruent': 6}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 0}}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
saga/web/code.asm | cgvarela/irhydra | 371 | 247864 | <gh_stars>100-1000
# javabench.SmallMap object internals:
# OFFSET SIZE TYPE DESCRIPTION VALUE
# 0 12 (object header) N/A
# 12 4 int SmallMap.currentSize N/A
# 16 4 Object[] SmallMap.keys N/A
# 20 4 int[] SmallMap.hashCodes N/A
# 24 4 Object[] SmallMap.values N/A
# 28 4 Map SmallMap.fallbackMap N/A
# Instance size: 32 bytes (estimated, the sample instance is not available)
#
# {method} {0x00000001218404e0} '_findIndex' '(I)I' in 'javabench/SmallMap'
# this: rsi:rsi = 'javabench/SmallMap'
# parm0: rdx = int
# [sp+0x40] (sp of caller)
0x0000000108841700: mov %eax,-0x14000(%rsp)
0x0000000108841707: push %rbp
0x0000000108841708: sub $0x30,%rsp ;*synchronization entry
; - javabench.SmallMap::_findIndex@-1 (line 15)
0x000000010884170c: mov %edx,0x4(%rsp)
0x0000000108841710: mov %rsi,%r8
0x0000000108841713: mov 0xc(%rsi),%ecx ;*getfield currentSize
; - javabench.SmallMap::_findIndex@3 (line 15)
0x0000000108841716: mov %ecx,%r11d
0x0000000108841719: dec %r11d ;*isub
; - javabench.SmallMap::_findIndex@7 (line 15)
0x000000010884171c: test %r11d,%r11d
0x000000010884171f: jl 0x0000000108841789 ;*if_icmplt
; - javabench.SmallMap::_findIndex@11 (line 15)
0x0000000108841721: mov 0x14(%rsi),%r9d ;*getfield hashCodes
; - javabench.SmallMap::_findIndex@15 (line 16)
0x0000000108841725: mov 0xc(%r12,%r9,8),%ebx ;*iaload
; - javabench.SmallMap::_findIndex@19 (line 16)
; implicit exception: dispatches to 0x0000000108841872
0x000000010884172a: xor %edi,%edi
0x000000010884172c: test %ebx,%ebx
0x000000010884172e: jle 0x0000000108841825
0x0000000108841734: mov %ecx,%esi
0x0000000108841736: sub %ebx,%esi
0x0000000108841738: lea (%r12,%r9,8),%rbp
0x000000010884173c: mov $0x1,%r10d
0x0000000108841742: cmp %r10d,%esi
0x0000000108841745: cmovl %r10d,%esi
0x0000000108841749: cmp %ebx,%esi
0x000000010884174b: cmovg %ebx,%esi
0x000000010884174e: xchg %ax,%ax
0x0000000108841750: mov %ecx,%edx
0x0000000108841752: sub %edi,%edx ;*isub
; - javabench.SmallMap::_findIndex@7 (line 15)
0x0000000108841754: mov %edx,%eax
0x0000000108841756: dec %eax
0x0000000108841758: cmp %ebx,%edi
0x000000010884175a: jae 0x0000000108841822
0x0000000108841760: mov 0x10(%rbp,%rdi,4),%r10d
0x0000000108841765: cmp 0x4(%rsp),%r10d
0x000000010884176a: je 0x0000000108841790 ;*if_icmpne
; - javabench.SmallMap::_findIndex@21 (line 16)
0x000000010884176c: cmp %ebx,%eax
0x000000010884176e: jae 0x0000000108841849 ;*iaload
; - javabench.SmallMap::_findIndex@31 (line 17)
0x0000000108841774: mov 0xc(%rbp,%rdx,4),%r10d
0x0000000108841779: cmp 0x4(%rsp),%r10d
0x000000010884177e: je 0x0000000108841792 ;*if_icmpne
; - javabench.SmallMap::_findIndex@33 (line 17)
0x0000000108841780: add $0xfffffffe,%edx ;*iinc
; - javabench.SmallMap::_findIndex@41 (line 15)
0x0000000108841783: inc %edi ;*iinc
; - javabench.SmallMap::_findIndex@38 (line 15)
0x0000000108841785: cmp %edi,%edx
0x0000000108841787: jge 0x000000010884179e ;*iconst_m1
; - javabench.SmallMap::_findIndex@47 (line 19)
0x0000000108841789: mov $0xffffffff,%eax
0x000000010884178e: jmp 0x0000000108841792
0x0000000108841790: mov %edi,%eax ;*synchronization entry
; - javabench.SmallMap::_findIndex@-1 (line 15)
0x0000000108841792: add $0x30,%rsp
0x0000000108841796: pop %rbp
0x0000000108841797: test %eax,-0x18c879d(%rip) # 0x0000000106f79000
; {poll_return}
0x000000010884179d: retq
0x000000010884179e: cmp %esi,%edi
0x00000001088417a0: jl 0x0000000108841750
0x00000001088417a2: cmp %ebx,%ecx
0x00000001088417a4: mov %ecx,%esi
0x00000001088417a6: cmovg %ebx,%esi
0x00000001088417a9: cmp %esi,%edi
0x00000001088417ab: jge 0x00000001088417d9
0x00000001088417ad: data32 xchg %ax,%ax
0x00000001088417b0: mov 0x10(%rbp,%rdi,4),%r10d ;*iaload
; - javabench.SmallMap::_findIndex@19 (line 16)
0x00000001088417b5: cmp 0x4(%rsp),%r10d
0x00000001088417ba: je 0x0000000108841790 ;*if_icmpne
; - javabench.SmallMap::_findIndex@21 (line 16)
0x00000001088417bc: mov %r11d,%eax
0x00000001088417bf: sub %edi,%eax
0x00000001088417c1: mov 0x10(%rbp,%rax,4),%edx ;*iaload
; - javabench.SmallMap::_findIndex@31 (line 17)
0x00000001088417c5: cmp 0x4(%rsp),%edx
0x00000001088417c9: je 0x0000000108841792 ;*if_icmpne
; - javabench.SmallMap::_findIndex@33 (line 17)
0x00000001088417cb: dec %eax ;*iinc
; - javabench.SmallMap::_findIndex@41 (line 15)
0x00000001088417cd: inc %edi ;*iinc
; - javabench.SmallMap::_findIndex@38 (line 15)
0x00000001088417cf: cmp %edi,%eax
0x00000001088417d1: jl 0x0000000108841789 ;*if_icmplt
; - javabench.SmallMap::_findIndex@11 (line 15)
0x00000001088417d3: cmp %esi,%edi
0x00000001088417d5: jl 0x00000001088417b0
0x00000001088417d7: jmp 0x00000001088417db
0x00000001088417d9: mov %edx,%eax
0x00000001088417db: cmp %ebx,%edi
0x00000001088417dd: jge 0x000000010884186d
0x00000001088417e3: nop
0x00000001088417e4: mov %ecx,%r11d
0x00000001088417e7: sub %edi,%r11d ;*isub
; - javabench.SmallMap::_findIndex@7 (line 15)
0x00000001088417ea: mov %r11d,%eax
0x00000001088417ed: dec %eax
0x00000001088417ef: cmp %ebx,%edi
0x00000001088417f1: jae 0x0000000108841822
0x00000001088417f3: mov 0x10(%rbp,%rdi,4),%edx
0x00000001088417f7: cmp 0x4(%rsp),%edx
0x00000001088417fb: je 0x0000000108841790 ;*if_icmpne
; - javabench.SmallMap::_findIndex@21 (line 16)
0x00000001088417fd: cmp %ebx,%eax
0x00000001088417ff: jae 0x0000000108841869 ;*iaload
; - javabench.SmallMap::_findIndex@31 (line 17)
0x0000000108841801: mov 0xc(%rbp,%r11,4),%r10d
0x0000000108841806: cmp 0x4(%rsp),%r10d
0x000000010884180b: je 0x0000000108841792 ;*if_icmpne
; - javabench.SmallMap::_findIndex@33 (line 17)
0x000000010884180d: add $0xfffffffe,%r11d ;*iinc
; - javabench.SmallMap::_findIndex@41 (line 15)
0x0000000108841811: inc %edi ;*iinc
; - javabench.SmallMap::_findIndex@38 (line 15)
0x0000000108841813: cmp %edi,%r11d
0x0000000108841816: jl 0x0000000108841789 ;*if_icmplt
; - javabench.SmallMap::_findIndex@11 (line 15)
0x000000010884181c: cmp %ebx,%edi
0x000000010884181e: jl 0x00000001088417e4
0x0000000108841820: jmp 0x0000000108841825
0x0000000108841822: mov %eax,%r11d
0x0000000108841825: mov $0xffffffe4,%esi
0x000000010884182a: mov %edi,(%rsp)
0x000000010884182d: mov %r8,0x8(%rsp)
0x0000000108841832: mov %r11d,0x10(%rsp)
0x0000000108841837: mov %r9d,0x14(%rsp)
0x000000010884183c: data32 xchg %ax,%ax
0x000000010884183f: callq 0x0000000108720ee0 ; OopMap{[8]=Oop [20]=NarrowOop off=356}
;*iaload
; - javabench.SmallMap::_findIndex@19 (line 16)
; {runtime_call}
0x0000000108841844: callq 0x0000000107c59080 ;*iaload
; - javabench.SmallMap::_findIndex@19 (line 16)
; {runtime_call}
0x0000000108841849: mov %eax,%ebp
0x000000010884184b: mov $0xffffffe4,%esi
0x0000000108841850: mov %edi,(%rsp)
0x0000000108841853: mov %r8,0x8(%rsp)
0x0000000108841858: mov %r9d,0x10(%rsp)
0x000000010884185d: xchg %ax,%ax
0x000000010884185f: callq 0x0000000108720ee0 ; OopMap{[8]=Oop [16]=NarrowOop off=388}
;*iaload
; - javabench.SmallMap::_findIndex@31 (line 17)
; {runtime_call}
0x0000000108841864: callq 0x0000000107c59080 ;*iaload
; - javabench.SmallMap::_findIndex@31 (line 17)
; {runtime_call}
0x0000000108841869: mov %eax,%ebp
0x000000010884186b: jmp 0x000000010884184b
0x000000010884186d: mov %eax,%r11d
0x0000000108841870: jmp 0x0000000108841825
0x0000000108841872: mov $0xffffff86,%esi
0x0000000108841877: mov %r8,%rbp
0x000000010884187a: mov %r11d,(%rsp)
0x000000010884187e: nop
0x000000010884187f: callq 0x0000000108720ee0 ; OopMap{rbp=Oop off=420}
;*aload_0
; - javabench.SmallMap::_findIndex@14 (line 16)
; {runtime_call}
0x0000000108841884: callq 0x0000000107c59080 ;*aload_0
; - javabench.SmallMap::_findIndex@14 (line 16)
; {runtime_call}
0x0000000108841889: hlt
0x000000010884188a: hlt
0x000000010884188b: hlt
0x000000010884188c: hlt
0x000000010884188d: hlt
0x000000010884188e: hlt
0x000000010884188f: hlt
0x0000000108841890: hlt
0x0000000108841891: hlt
0x0000000108841892: hlt
0x0000000108841893: hlt
0x0000000108841894: hlt
0x0000000108841895: hlt
0x0000000108841896: hlt
0x0000000108841897: hlt
0x0000000108841898: hlt
0x0000000108841899: hlt
0x000000010884189a: hlt
0x000000010884189b: hlt
0x000000010884189c: hlt
0x000000010884189d: hlt
0x000000010884189e: hlt
0x000000010884189f: hlt |
programs/oeis/056/A056653.asm | neoneye/loda | 22 | 169521 | <filename>programs/oeis/056/A056653.asm<gh_stars>10-100
; A056653: Composite numbers together with 1 but excluding 4.
; 1,6,8,9,10,12,14,15,16,18,20,21,22,24,25,26,27,28,30,32,33,34,35,36,38,39,40,42,44,45,46,48,49,50,51,52,54,55,56,57,58,60,62,63,64,65,66,68,69,70,72,74,75,76,77,78,80,81,82,84,85,86,87,88,90,91,92,93,94,95,96,98,99,100,102,104,105,106,108,110,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,128,129,130,132,133
seq $0,72668 ; Numbers one less than composite numbers.
mov $1,$0
pow $1,2
sub $1,$0
lpb $0
max $0,$1
dif $0,2
bin $0,3
mov $1,$2
lpe
add $0,1
|
Engine Hacks/SuspendDebuffs/asm/Debuffs/MaxHP Getter.asm | sme23/MekkahRestrictedHackComp1 | 3 | 9001 | .thumb
@Additional Data Format:
@0-2: Debuffs, 4 bits each (str/skl/spd/def/res/luk)
@3: Rallys (bit 7 = rally move, bit 8 = rally spectrum)
@4: Str/Skl Silver Debuff (6 bits), bit 7 = half strength, HO bit = Hexing Rod
@5: Magic
@Original at 19190
push {r4-r6, lr}
mov r4, r0 @Unit
mov r5, #0x12
ldrb r5, [r4, r5] @Base HP
@Load it unsigned in case we want to do some kind of unsigned HP hack later.
ldr r6, AdditionalDataTable
ldrb r1, [r4 ,#0xB] @Deployment number
lsl r1, r1, #0x3 @*8
add r6, r1 @r0 = *debuff data
@r6 = &Additional Data
@Hexing Rod Debuff NOTE TO SELF: off of base only.
ldrb r0, [r6, #0x4]
mov r1, #0x80
and r0, r1
cmp r0, #0x0
beq noHalfHP
lsr r0, r5, #0x1 @Unsigned divide by two.
noHalfHP:
@Now get the weapon bonus.
ldr r1, GetEquippedWeapon
bl gotoR1
ldr r1, GetWeaponHPBonus
bl gotoR1
@Add it to the accumulator.
add r5, r0
@No MaxHP Debuffs
@No MaxHP Pair Up Bonus
@No MaxHP Rally Bonus
@Return the acccumulator.
mov r0, r5
cmp r0, #0x0
bge end
mov r0, #0x0
end:
pop {r4-r6}
pop {r1}
gotoR1:
bx r1
.align
GetEquippedWeapon:
.long 0x8016B29
GetWeaponHPBonus:
.long 0x80163F1
AdditionalDataTable:
@Handled by installer.
@.long 0x0203E894
|
Cubical/Data/Strict2Group/Explicit/Interface.agda | Schippmunk/cubical | 0 | 10492 |
{-# OPTIONS --cubical --safe #-}
module Cubical.Data.Strict2Group.Explicit.Interface where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Group.Base
open import Cubical.Data.Sigma
open import Cubical.Data.Strict2Group.Explicit.Base
open import Cubical.Data.Strict2Group.Explicit.Notation
module S2GInterface {ℓ : Level} ((strict2groupexp C₀ C₁ s t i ∘ si ti s∘ t∘ isMorph∘ assoc∘ lUnit∘ rUnit∘) : Strict2GroupExp ℓ) where
open S2GBaseNotation C₀ C₁ s t i ∘ public
module Identities1 where
-- to be consistent with the other notation
tarId = ti
srcId = si
-- identity is preserved by id
id1₀≡1₁ : id 1₀ ≡ 1₁
id1₀≡1₁ = morphId {G = C₀} {H = C₁} i
open Identities1 public
module C₁×₀C₁ where
-- the composable morphisms as record type
record Co : Type ℓ where
constructor co
field
g f : TC₁
coh : CohCond g f
-- syntax
𝓁 𝓇 : Co → TC₁
𝓁 = Co.g
𝓇 = Co.f
𝒸 : (gfc : Co) → CohCond (𝓁 gfc) (𝓇 gfc)
𝒸 = Co.coh
-- compose a co object using ∘
⊙ : Co → TC₁
⊙ gfc = ∘ (𝓁 gfc) (𝓇 gfc) (𝒸 gfc)
-- basically ∘, but for the sake of interfacing, we don't want to use ∘
⊙' : (g f : TC₁) → CohCond g f → TC₁
⊙' g f c = ⊙ (co g f c)
-- interface for those names aswell
src⊙ : (gfc : Co) → src (⊙ gfc) ≡ src (𝓇 gfc)
src⊙ (co g f c) = s∘ g f c
tar⊙ : (gfc : Co) → tar (⊙ gfc) ≡ tar (𝓁 gfc)
tar⊙ (co g f c) = t∘ g f c
src⊙' : (g f : TC₁) → (c : CohCond g f) → src (⊙' g f c) ≡ src f
src⊙' g f c = src⊙ (co g f c)
tar⊙' : (g f : TC₁) → (c : CohCond g f) → tar (⊙' g f c) ≡ tar g
tar⊙' g f c = tar⊙ (co g f c)
-- multiplication in C₁×₀C₁
_∙Co_ : (gfc gfc' : Co) → Co
(co g f coh) ∙Co (co g' f' coh') =
co (g ∙₁ g') (f ∙₁ f')
(src∙₁ g g' ∙ cong (_∙₀ src g') coh ∙ cong (tar f ∙₀_) coh' ∙ sym (tar∙₁ f f'))
-- unit element w.r.t. ∙c. Too bad there is no \_c
1c : Co
1c = co 1₁ 1₁ ((cong src (sym id1₀≡1₁)) ∙∙ si 1₀ ∙∙ sym (ti 1₀) ∙ cong tar id1₀≡1₁)
-- the interchange law reformulated using ⊙
isMorph⊙ : (gfc gfc' : Co) → ⊙ (gfc ∙Co gfc') ≡ ⊙ gfc ∙₁ ⊙ gfc'
isMorph⊙ (co _ _ c) (co _ _ c') = isMorph∘ c c'
-- associator notation
assoc⊙' : (h g f : TC₁) → (c : CohCond g f) → (c' : CohCond h g) → ⊙' (⊙' h g c') f ((src⊙' h g c') ∙ c) ≡ ⊙' h (⊙' g f c) (c' ∙ (sym (tar⊙' g f c)))
assoc⊙' h g f c c' = assoc∘ c c'
-- the left and right unit laws reformulated using ⊙
lUnit⊙ : (f : TC₁) → ⊙ (co (id (tar f)) f (srcId (tar f))) ≡ f
lUnit⊙ = lUnit∘
rUnit⊙ : (f : TC₁) → ⊙ (co f (id (src f)) (sym (tarId (src f)))) ≡ f
rUnit⊙ = rUnit∘
-- the path component of f in C₁
ΣC₁p : (f : TC₁) → Type ℓ
ΣC₁p f = Σ[ f' ∈ TC₁ ] (f ≡ f')
private
-- for given g, the type of f that g can be precomposed with
_∘* : TC₁ → Type ℓ
g ∘* = Σ[ f ∈ TC₁ ] (CohCond g f)
-- for given f, the type of g that f can be postcomposed with
*∘_ : TC₁ → Type ℓ
*∘ f = Σ[ g ∈ TC₁ ] (CohCond g f)
-- alternate notation for ∘
-- this is used in ∘*≡ to λ-abstract in cong
_∘*_ : (g : TC₁) (fc : g ∘*) → TC₁
_∘*_ g (f , c) = ∘ g f c
_*∘_ : (f : TC₁) (gc : *∘ f) → TC₁
_*∘_ f (g , c) = ∘ g f c
-- since we have proof irrelevance in C₀ we can show that f ≡ f' → g∘f ≡ g∘f'
∘*≡ : (g : TC₁) → (fc : g ∘*) → (f'p : ΣC₁p (fst fc)) → g ∘* fc ≡ g ∘* ((fst f'p) , snd fc ∙ cong tar (snd f'p))
∘*≡ g fc f'p = cong (g ∘*_) (ΣPathP (snd f'p , isProp→PathP (λ j → Group.setStruc C₀ (src g) (tar (snd f'p j))) (snd fc) (snd fc ∙ cong tar (snd f'p))))
*∘≡ : (f : TC₁) → (gc : *∘ f) → (g'p : ΣC₁p (fst gc)) → f *∘ gc ≡ f *∘ (fst g'p , ((cong src (sym (snd g'p))) ∙ snd gc))
*∘≡ f gc g'p = cong (_*∘_ f) (ΣPathP ((snd g'p) , (isProp→PathP (λ j → Group.setStruc C₀ (src (snd g'p j)) (tar f)) (snd gc) (cong src (sym (snd g'p)) ∙ snd gc))))
-- ⊙ respecs paths on the right
⊙≡ : ((co g f c) : Co) → (f'p : ΣC₁p f) → ⊙ (co g f c) ≡ ⊙ (co g (fst f'p) (c ∙ (cong tar (snd f'p))))
⊙≡ (co g f c) (f' , f≡f') = ∘*≡ g (f , c) (f' , f≡f')
-- ⊙ respects paths on the left
≡⊙ : ((co g f c) : Co) → ((g' , g≡g') : ΣC₁p g) → ⊙ (co g f c) ≡ ⊙ (co g' f (cong src (sym g≡g') ∙ c))
≡⊙ (co g f c) (g' , g≡g') = *∘≡ f (g , c) (g' , g≡g')
-- ⊙ resepcts paths on the coherence condition
⊙≡c : ((co g f c) : Co) → (c' : CohCond g f) → ⊙ (co g f c) ≡ ⊙ (co g f c')
⊙≡c (co g f c) c' = cong (λ z → ⊙ (co g f z)) (Group.setStruc C₀ (src g) (tar f) c c')
-- implicit version of ⊙≡c
⊙≡c~ : {g f : TC₁} (c c' : CohCond g f) → ⊙ (co g f c) ≡ ⊙ (co g f c')
⊙≡c~ {g} {f} c c' = cong (λ z → ⊙ (co g f z)) (Group.setStruc C₀ (src g) (tar f) c c')
-- ⊙ respecting paths on the left also changes the coherence condition so this should be used instead
≡⊙c* : {g g' f : TC₁} (c : CohCond g f) (g≡g' : g ≡ g') (c' : CohCond g' f) → ⊙' g f c ≡ ⊙' g' f c'
≡⊙c* {g} {g'} {f} c g≡g' c' = (≡⊙ (co g f c) (g' , g≡g')) ∙ ⊙≡c~ ((cong src (sym g≡g')) ∙ c) c'
-- ⊙ respecting paths on the right also changes the coherence condition so this should be used instead
⊙≡c* : {g f f' : TC₁} (c : CohCond g f) (f≡f' : f ≡ f') (c' : CohCond g f') → ⊙' g f c ≡ ⊙' g f' c'
⊙≡c* {g} {f} {f'} c f≡f' c' = (⊙≡ (co g f c) (f' , f≡f')) ∙ ⊙≡c~ (c ∙ cong tar f≡f') c'
-- use the left and right unit law with an arbitrary coherence proof c
lUnit⊙c : (f : TC₁) → (c : CohCond (id (tar f)) f) → ⊙ (co (id (tar f)) f c) ≡ f
lUnit⊙c f c = (⊙≡c (co (id (tar f)) f c) (srcId (tar f))) ∙ (lUnit⊙ f)
rUnit⊙c : (f : TC₁) → (c : CohCond f (id (src f))) → ⊙ (co f (id (src f)) c) ≡ f
rUnit⊙c f c = (⊙≡c (co f (id (src f)) c) (sym (tarId (src f)))) ∙ (rUnit⊙ f)
open C₁×₀C₁ public
module Identities2 where
-- source and target of unit element
tar1₁≡1₀ : tar 1₁ ≡ 1₀
tar1₁≡1₀ = morphId {G = C₁} {H = C₀} t
src1₁≡1₀ = morphId {G = C₁} {H = C₀} s
-- taking the source is the same as the target of the identity of the source
src≡tarIdSrc : (f : TC₁) → CohCond f (id (src f))
src≡tarIdSrc f = sym (ti (src f))
open Identities2 public
|
programs/oeis/214/A214865.asm | neoneye/loda | 22 | 92930 | ; A214865: n such that n XOR 9 = n - 9.
; 9,11,13,15,25,27,29,31,41,43,45,47,57,59,61,63,73,75,77,79,89,91,93,95,105,107,109,111,121,123,125,127,137,139,141,143,153,155,157,159,169,171,173,175,185,187,189,191,201,203,205,207,217,219,221,223,233,235,237,239,249,251,253,255,265,267,269,271,281,283,285,287,297,299,301,303,313,315,317,319,329,331,333,335,345,347,349,351,361,363,365,367,377,379,381,383,393,395,397,399
mov $1,$0
div $1,4
mul $1,4
add $0,$1
mul $0,2
add $0,9
|
programs/oeis/038/A038716.asm | neoneye/loda | 22 | 87313 | ; A038716: a(n) = floor(n/4)*ceiling((n+3)/4).
; 0,0,0,0,2,2,3,3,6,6,8,8,12,12,15,15,20,20,24,24,30,30,35,35,42,42,48,48,56,56,63,63,72,72,80,80,90,90,99,99,110,110,120,120,132,132,143,143,156,156,168,168,182,182,195,195,210,210,224,224,240,240,255,255,272,272,288,288,306,306,323,323,342,342,360,360,380,380,399,399,420,420,440,440,462,462,483,483,506,506,528,528,552,552,575,575,600,600,624,624
mov $1,$0
div $0,4
add $1,6
div $1,4
mul $0,$1
|
src/API/protypo-api.ads | fintatarta/protypo | 0 | 21335 | <gh_stars>0
package Protypo.Api is
end Protypo.Api;
|
assembler/asm_example/test_memory_no_hazard.asm | dpolad/dlx | 1 | 26600 | addi r1,r0,#15
addi r2,r0,#-7
nop
nop
nop
nop
nop
sw 1(r0),r1
sb 1(r1),r2
nop
nop
nop
nop
nop
lw r3,1(r0)
lw r4,1(r1)
lb r5,1(r0)
lb r6,1(r1)
lbu r7,1(r0)
lbu r8,1(r1)
lhu r9,1(r0)
lhu r10,1(r1)
nop
nop
nop
nop
nop
nop
nop
|
programs/oeis/074/A074504.asm | neoneye/loda | 22 | 161163 | ; A074504: a(n) = 1^n + 2^n + 8^n.
; 3,11,69,521,4113,32801,262209,2097281,16777473,134218241,1073742849,8589936641,68719480833,549755822081,4398046527489,35184372121601,281474976776193,2251799813816321,18014398509744129,144115188076380161
mov $1,2
pow $1,$0
mov $2,8
pow $2,$0
add $1,$2
mov $0,$1
add $0,1
|
libsrc/_DEVELOPMENT/arch/zxn/esxdos/c/sdcc_iy/esx_f_chdir.asm | jpoikela/z88dk | 640 | 4133 | ; unsigned char esx_f_chdir(unsigned char *pathname)
SECTION code_esxdos
PUBLIC _esx_f_chdir
EXTERN _esx_f_chdir_fastcall
_esx_f_chdir:
pop af
pop hl
push hl
push af
jp _esx_f_chdir_fastcall
|
mat/src/parser/mat-expressions-parser.adb | stcarrez/mat | 7 | 4182 |
pragma Style_Checks (Off);
with Interfaces;
with MAT.Expressions.Parser_Goto;
with MAT.Expressions.Parser_Tokens;
with MAT.Expressions.Parser_Shift_Reduce;
with MAT.Expressions.Parser_IO;
with MAT.Expressions.Lexer;
with MAT.Expressions.Lexer_Dfa;
with Ada.Text_IO;
package body MAT.Expressions.Parser is
use Ada;
use MAT.Expressions.Lexer;
use type Interfaces.Unsigned_64;
procedure yyparse;
procedure yyerror (Message : in String := "syntax error");
function To_Event_Id_Type (Value : in MAT.Types.Uint64) return MAT.Events.Event_Id_Type;
function To_Thread_Ref (Value : in MAT.Types.Uint64) return MAT.Types.Target_Thread_Ref;
Expr : MAT.Expressions.Expression_Type;
function To_Event_Id_Type (Value : in MAT.Types.Uint64)
return MAT.Events.Event_Id_Type is
begin
if Value > MAT.Types.Uint64 (MAT.Events.Event_Id_Type'Last) then
return MAT.Events.Event_Id_Type'Last;
else
return MAT.Events.Event_Id_Type (Value);
end if;
end To_Event_Id_Type;
function To_Thread_Ref (Value : in MAT.Types.Uint64)
return MAT.Types.Target_Thread_Ref is
begin
if Value > MAT.Types.Uint64 (MAT.Types.Target_Thread_Ref'Last) then
return MAT.Types.Target_Thread_Ref'Last;
else
return MAT.Types.Target_Thread_Ref (Value);
end if;
end To_Thread_Ref;
procedure yyerror (Message : in String := "syntax error") is
pragma Unreferenced (Message);
begin
error_count := error_count + 1;
end yyerror;
function Parse (Content : in String) return MAT.Expressions.Expression_Type is
begin
MAT.Expressions.Parser_IO.Set_Input (Content);
Expr := MAT.Expressions.EMPTY;
yyparse;
return Expr;
end Parse;
-- Warning: This file is automatically generated by AYACC.
-- It is useless to modify it. Change the ".Y" & ".L" files instead.
procedure YYParse is
-- Rename User Defined Packages to Internal Names.
package yy_goto_tables renames
Mat.Expressions.Parser_Goto;
package yy_shift_reduce_tables renames
Mat.Expressions.Parser_Shift_Reduce;
package yy_tokens renames
Mat.Expressions.Parser_Tokens;
use yy_tokens, yy_goto_tables, yy_shift_reduce_tables;
procedure yyerrok;
procedure yyclearin;
package yy is
-- the size of the value and state stacks
-- Affects error 'Stack size exceeded on state_stack'
stack_size : constant Natural := 256;
-- subtype rule is natural;
subtype parse_state is natural;
-- subtype nonterminal is integer;
-- encryption constants
default : constant := -1;
first_shift_entry : constant := 0;
accept_code : constant := -3001;
error_code : constant := -3000;
-- stack data used by the parser
tos : natural := 0;
value_stack : array(0..stack_size) of yy_tokens.yystype;
state_stack : array(0..stack_size) of parse_state;
-- current input symbol and action the parser is on
action : integer;
rule_id : rule;
input_symbol : yy_tokens.token:= Error;
-- error recovery flag
error_flag : natural := 0;
-- indicates 3 - (number of valid shifts after an error occurs)
look_ahead : boolean := true;
index : integer;
-- Is Debugging option on or off
DEBUG : constant boolean := FALSE;
end yy;
function goto_state
(state : yy.parse_state;
sym : nonterminal) return yy.parse_state;
function parse_action
(state : yy.parse_state;
t : yy_tokens.token) return integer;
pragma inline(goto_state, parse_action);
function goto_state(state : yy.parse_state;
sym : nonterminal) return yy.parse_state is
index : integer;
begin
index := goto_offset(state);
while integer(goto_matrix(index).nonterm) /= sym loop
index := index + 1;
end loop;
return integer(goto_matrix(index).newstate);
end goto_state;
function parse_action(state : yy.parse_state;
t : yy_tokens.token) return integer is
index : integer;
tok_pos : integer;
default : constant integer := -1;
begin
tok_pos := yy_tokens.token'pos(t);
index := shift_reduce_offset(state);
while integer(shift_reduce_matrix(index).t) /= tok_pos and then
integer(shift_reduce_matrix(index).t) /= default
loop
index := index + 1;
end loop;
return integer(shift_reduce_matrix(index).act);
end parse_action;
-- error recovery stuff
procedure handle_error is
temp_action : integer;
begin
if yy.error_flag = 3 then -- no shift yet, clobber input.
if yy.debug then
text_io.put_line(" -- Ayacc.YYParse: Error Recovery Clobbers " &
yy_tokens.token'image(yy.input_symbol));
end if;
if yy.input_symbol = yy_tokens.end_of_input then -- don't discard,
if yy.debug then
text_io.put_line(" -- Ayacc.YYParse: Can't discard END_OF_INPUT, quiting...");
end if;
raise yy_tokens.syntax_error;
end if;
yy.look_ahead := true; -- get next token
return; -- and try again...
end if;
if yy.error_flag = 0 then -- brand new error
yyerror("Syntax Error");
end if;
yy.error_flag := 3;
-- find state on stack where error is a valid shift --
if yy.debug then
text_io.put_line(" -- Ayacc.YYParse: Looking for state with error as valid shift");
end if;
loop
if yy.debug then
text_io.put_line(" -- Ayacc.YYParse: Examining State " &
yy.parse_state'image(yy.state_stack(yy.tos)));
end if;
temp_action := parse_action(yy.state_stack(yy.tos), error);
if temp_action >= yy.first_shift_entry then
if yy.tos = yy.stack_size then
text_io.put_line(" -- Ayacc.YYParse: Stack size exceeded on state_stack");
raise yy_Tokens.syntax_error;
end if;
yy.tos := yy.tos + 1;
yy.state_stack(yy.tos) := temp_action;
exit;
end if;
Decrement_Stack_Pointer :
begin
yy.tos := yy.tos - 1;
exception
when Constraint_Error =>
yy.tos := 0;
end Decrement_Stack_Pointer;
if yy.tos = 0 then
if yy.debug then
text_io.put_line(" -- Ayacc.YYParse: Error recovery popped entire stack, aborting...");
end if;
raise yy_tokens.syntax_error;
end if;
end loop;
if yy.debug then
text_io.put_line(" -- Ayacc.YYParse: Shifted error token in state " &
yy.parse_state'image(yy.state_stack(yy.tos)));
end if;
end handle_error;
-- print debugging information for a shift operation
procedure shift_debug(state_id: yy.parse_state; lexeme: yy_tokens.token) is
begin
text_io.put_line(" -- Ayacc.YYParse: Shift "& yy.parse_state'image(state_id)&" on input symbol "&
yy_tokens.token'image(lexeme) );
end;
-- print debugging information for a reduce operation
procedure reduce_debug(rule_id: rule; state_id: yy.parse_state) is
begin
text_io.put_line(" -- Ayacc.YYParse: Reduce by rule "&rule'image(rule_id)&" goto state "&
yy.parse_state'image(state_id));
end;
-- make the parser believe that 3 valid shifts have occured.
-- used for error recovery.
procedure yyerrok is
begin
yy.error_flag := 0;
end yyerrok;
-- called to clear input symbol that caused an error.
procedure yyclearin is
begin
-- yy.input_symbol := yylex;
yy.look_ahead := true;
end yyclearin;
begin
-- initialize by pushing state 0 and getting the first input symbol
yy.state_stack(yy.tos) := 0;
loop
yy.index := shift_reduce_offset(yy.state_stack(yy.tos));
if integer(shift_reduce_matrix(yy.index).t) = yy.default then
yy.action := integer(shift_reduce_matrix(yy.index).act);
else
if yy.look_ahead then
yy.look_ahead := false;
yy.input_symbol := yylex;
end if;
yy.action :=
parse_action(yy.state_stack(yy.tos), yy.input_symbol);
end if;
if yy.action >= yy.first_shift_entry then -- SHIFT
if yy.debug then
shift_debug(yy.action, yy.input_symbol);
end if;
-- Enter new state
if yy.tos = yy.stack_size then
text_io.put_line(" Stack size exceeded on state_stack");
raise yy_Tokens.syntax_error;
end if;
yy.tos := yy.tos + 1;
yy.state_stack(yy.tos) := yy.action;
yy.value_stack(yy.tos) := yylval;
if yy.error_flag > 0 then -- indicate a valid shift
yy.error_flag := yy.error_flag - 1;
end if;
-- Advance lookahead
yy.look_ahead := true;
elsif yy.action = yy.error_code then -- ERROR
handle_error;
elsif yy.action = yy.accept_code then
if yy.debug then
text_io.put_line(" -- Ayacc.YYParse: Accepting Grammar...");
end if;
exit;
else -- Reduce Action
-- Convert action into a rule
yy.rule_id := -1 * yy.action;
-- Execute User Action
-- user_action(yy.rule_id);
case yy.rule_id is
when 1 => -- #line 33
Expr :=
yy.value_stack(yy.tos).Expr;
when 2 => -- #line 40
yyval :=
yy.value_stack(yy.tos-1);
when 3 => -- #line 45
yyval.expr := MAT.Expressions.Create_Not (
yy.value_stack(yy.tos).expr);
when 4 => -- #line 50
yyval.expr := MAT.Expressions.Create_Or (
yy.value_stack(yy.tos-2).expr,
yy.value_stack(yy.tos).expr);
when 5 => -- #line 55
yyval.expr := MAT.Expressions.Create_And (
yy.value_stack(yy.tos-2).expr,
yy.value_stack(yy.tos).expr);
when 6 => -- #line 60
if
yy.value_stack(yy.tos-1).bval then
yyval.expr := MAT.Expressions.Create_Inside (
yy.value_stack(yy.tos).name, MAT.Expressions.INSIDE_DIRECT_REGION);
else
yyval.expr := MAT.Expressions.Create_Inside (
yy.value_stack(yy.tos).name, MAT.Expressions.INSIDE_REGION);
end if;
when 7 => -- #line 69
if
yy.value_stack(yy.tos-1).bval then
yyval.expr := MAT.Expressions.Create_Inside (
yy.value_stack(yy.tos).name, MAT.Expressions.INSIDE_DIRECT_FUNCTION);
else
yyval.expr := MAT.Expressions.Create_Inside (
yy.value_stack(yy.tos).name, MAT.Expressions.INSIDE_FUNCTION);
end if;
when 8 => -- #line 78
if
yy.value_stack(yy.tos-1).bval then
yyval.expr := MAT.Expressions.Create_Inside (
yy.value_stack(yy.tos).low, MAT.Expressions.INSIDE_DIRECT_FUNCTION);
else
yyval.expr := MAT.Expressions.Create_Inside (
yy.value_stack(yy.tos).low, MAT.Expressions.INSIDE_FUNCTION);
end if;
when 9 => -- #line 87
yyval.expr := MAT.Expressions.Create_Time (MAT.Types.Target_Tick_Ref (
yy.value_stack(yy.tos-2).low),
MAT.Types.Target_Tick_Ref (
yy.value_stack(yy.tos).low));
when 10 => -- #line 93
yyval.expr := MAT.Expressions.Create_Time (MAT.Types.Target_Tick_Ref (
yy.value_stack(yy.tos).low),
MAT.Types.Target_Tick_Ref'Last);
when 11 => -- #line 99
yyval.expr := MAT.Expressions.Create_Time (MAT.Types.Target_Tick_Ref'First,
MAT.Types.Target_Tick_Ref (
yy.value_stack(yy.tos).low));
when 12 => -- #line 105
yyval :=
yy.value_stack(yy.tos); -- new Condition( C_STIME, $2 );
when 13 => -- #line 110
yyval.expr := MAT.Expressions.Create_Size (MAT.Types.Target_Size (
yy.value_stack(yy.tos).low),
MAT.Types.Target_Size (
yy.value_stack(yy.tos).high));
when 14 => -- #line 116
yyval.expr := MAT.Expressions.Create_Thread (MAT.Types.Target_Thread_Ref (
yy.value_stack(yy.tos).low),
MAT.Types.Target_Thread_Ref (
yy.value_stack(yy.tos).high));
when 15 => -- #line 122
yyval.expr := MAT.Expressions.Create_Addr (MAT.Types.Target_Addr (
yy.value_stack(yy.tos).low),
MAT.Types.Target_Addr (
yy.value_stack(yy.tos).low));
when 16 => -- #line 128
yyval.expr := MAT.Expressions.Create_Addr (MAT.Types.Target_Addr (
yy.value_stack(yy.tos).low),
MAT.Types.Target_Addr (
yy.value_stack(yy.tos).high));
when 17 => -- #line 134
yyval.expr := MAT.Expressions.Create_Event (To_Event_Id_Type (
yy.value_stack(yy.tos).low),
To_Event_Id_Type (
yy.value_stack(yy.tos).high));
when 18 => -- #line 140
yyval.expr := MAT.Expressions.Create_Event (To_Event_Id_Type (
yy.value_stack(yy.tos-2).low),
To_Event_Id_Type (
yy.value_stack(yy.tos).low));
when 19 => -- #line 146
yyval.expr := MAT.Expressions.Create_Time (MAT.Types.Target_Tick_Ref (
yy.value_stack(yy.tos).low),
MAT.Types.Target_Tick_Ref (
yy.value_stack(yy.tos).high));
when 20 => -- #line 152
yyval.expr := MAT.Expressions.Create_Event_Type (MAT.Events.MSG_MALLOC);
when 21 => -- #line 157
yyval.expr := MAT.Expressions.Create_Event_Type (MAT.Events.MSG_FREE);
when 22 => -- #line 162
yyval.expr := MAT.Expressions.Create_Event_Type (MAT.Events.MSG_REALLOC);
when 23 => -- #line 167
yyval.expr := MAT.Expressions.Create_No_Free;
when 24 => -- #line 172
yyval.expr := MAT.Expressions.Create_No_Free;
when 25 => -- #line 177
yyval.low := 0;
when 26 => -- #line 184
yyval.low := 0;
yyval.high :=
yy.value_stack(yy.tos).low - 1;
when 27 => -- #line 190
yyval.low := 0;
yyval.high :=
yy.value_stack(yy.tos).low;
when 28 => -- #line 196
yyval.low :=
yy.value_stack(yy.tos).low + 1;
yyval.high := MAT.Types.Uint64'Last;
when 29 => -- #line 202
yyval.low :=
yy.value_stack(yy.tos).low;
yyval.high := MAT.Types.Uint64'Last;
when 30 => -- #line 208
yyval.low :=
yy.value_stack(yy.tos-2).low;
yyval.high :=
yy.value_stack(yy.tos).low;
when 31 => -- #line 214
yyval.low :=
yy.value_stack(yy.tos).low;
yyval.high :=
yy.value_stack(yy.tos).low;
when 32 => -- #line 220
yyval.low :=
yy.value_stack(yy.tos).low;
yyval.high :=
yy.value_stack(yy.tos).low;
when 33 => -- #line 228
yyval.name := Ada.Strings.Unbounded.To_Unbounded_String (MAT.Expressions.Lexer_Dfa.YYText);
when 34 => -- #line 231
yyval.name := Ada.Strings.Unbounded.To_Unbounded_String (MAT.Expressions.Lexer_Dfa.YYText);
when 35 => -- #line 236
yyval.low := 1;
when 36 => -- #line 239
yyval := MAT.Expressions.Parser_Tokens.YYLval;
when 37 => -- #line 244
yyval := MAT.Expressions.Parser_Tokens.YYLval;
when 38 => -- #line 249
yyval := MAT.Expressions.Parser_Tokens.YYLval;
when 39 => -- #line 252
yyval := MAT.Expressions.Parser_Tokens.YYLval;
yyval.low :=
yyval.low * 1_000_000;
when 40 => -- #line 257
yyval.bval := False;
when 41 => -- #line 260
yyval.bval := True;
when others => null;
end case;
-- Pop RHS states and goto next state
yy.tos := yy.tos - rule_length(yy.rule_id) + 1;
if yy.tos > yy.stack_size then
text_io.put_line(" Stack size exceeded on state_stack");
raise yy_Tokens.syntax_error;
end if;
yy.state_stack(yy.tos) := goto_state(yy.state_stack(yy.tos-1) ,
get_lhs_rule(yy.rule_id));
yy.value_stack(yy.tos) := yyval;
if yy.debug then
reduce_debug(yy.rule_id,
goto_state(yy.state_stack(yy.tos - 1),
get_lhs_rule(yy.rule_id)));
end if;
end if;
end loop;
end yyparse;
end MAT.Expressions.Parser;
|
ts2060/operators.asm | nagydani/zx-rom-mods | 15 | 173068 | <filename>ts2060/operators.asm<gh_stars>10-100
OPERTB: DEFB "%"
DEFB S_MOD - $
DEFB "?"
DEFB S_ELVIS - $
DEFB "$"
DEFB S_LSTR - $
DEFB 0
S_MOD: LD A,$08 ; priority like /
CALL TIGHTER
JP Z,ERROR_C ; only numeric lefthand
LD BC,$08C2 ; delete with priority 8
PUSH BC
LD C,$F2 ; mod with same priority
SWNEXT: LD HL,L2790 ; S-NEXT
SWPUSH: PUSH HL
SWAPOP: RST $10
S_LSTR: CALL SYNTAX_Z
JP NZ,ERROR_2 ; Variable not found in runtime
LD HL,FLAGS
BIT 6,(HL)
JR Z,SWAPOP ; must be numeric
RES 6,(HL) ; indicate string
LD A,D
OR A
JR Z,SWAPOP ; numeric expression
LD HL,(STKBOT)
SBC HL,DE
JR C,SWAPOP ; numeric literal
F_CPL: RST $20 ; skip "$"
F_CPL2: LD HL,L2723 ; S-OPERTR
JR SWPUSH
S_ELVIS:RST $20
LD A,(FLAGS) ; selector type in bit 6
ADD A,A
JR NC,S_ELVS
ADD A,A
JR NC,D_ELVS
RST $30
DEFW L1E99 ; FIND-INT2
RST $20
D_ELVSK:LD A,B
OR C
JR Z,D_ELVZ
PUSH BC
CALL SKIPEX
POP BC
JR C,D_ELVZ
LD (CH_ADD),HL
DEC BC
JR D_ELVSK
D_ELVS: LD HL,(STKEND)
DEC HL
LD A,(HL)
DEC HL
OR (HL)
JR Z,D_ELVZ0
RST $20
CALL SKIPEX
JR C,D_ELVR
DEC HL
LD (CH_ADD),HL
D_ELVZ0:LD HL,(STKEND)
LD DE,-5
ADD HL,DE
LD (STKEND),HL
RST $20
D_ELVZ: RST $30
DEFW L24FB ; SCANNING
CP ")"
JR Z,F_CPL
D_ELVT: CALL SKIPEX
JR NC,D_ELVT
D_ELVR: OR A
JR NZ,ERROR_C_ELV
LD (CH_ADD),HL
RST $18
JR F_CPL2
TIGHT_S:EX AF,AF'
LD HL,FLAGS
LD A,E
XOR (HL) ; FLAGS, bit 6
AND $40
JR NZ,ERROR_C_ELV
LD A,E
RRCA
XOR (HL)
AND $40
XOR (HL)
LD (HL),A ; set bit 6 according to bit 7 of E
EX AF,AF'
TIGHTER:POP HL ; return address
POP DE ; operator
PUSH DE
PUSH HL
CP D
BIT 6,(IY+$01) ; FLAGS, check string/numeric
RET NC
POP HL
POP DE
PUSH HL ; eliminate DE
CALL SYNTAX_Z
JR Z,TIGHT_S
PUSH BC
PUSH AF
LD A,E
AND $3F
LD B,A
RST $28
DEFB $3B ; fp_calc_2
DEFB $38 ; end
POP AF
POP BC
JR TIGHTER
S_ELVS: PUSH AF
RST $18
CP "("
JR NZ,ERROR_C_ELV
RST $20
RST $30
DEFW L24FB + 1 ; SCANNING + 1
CP ")"
JR NZ,S_ELVL
S_ELVE: LD A,(FLAGS)
ADD A,A
POP BC
XOR B
ADD A,A
F_CPLNC:JP NC,F_CPL
ERROR_C_ELV:
JP ERROR_C
S_ELVL: CP ","
JR NZ,ERROR_C_ELV
POP AF
ADD A,A
LD A,(FLAGS)
JR C,S_ELVN
PUSH AF
RST $20
RST $30
DEFW L24FB + 1 ; SCANNING + 1
CP ")"
JR NZ,ERROR_C_ELV
POP BC
LD A,(FLAGS)
XOR B
ADD A
ADD A
JR C,ERROR_C_ELV
JR F_CPLNC
S_ELVN: ADD A,A
PUSH AF
S_ELVNL:RST $20
RST $30
DEFW L24FB + 1 ; SCANNING + 1
CP ")"
JR Z,S_ELVE
CP ","
JR NZ,ERROR_C_ELV
LD A,(FLAGS)
ADD A,A
POP BC
PUSH AF
XOR B
ADD A,A
JR C,ERROR_C_ELV
JR S_ELVNL
; skip expression pointed by HL. CF cleared, it ends with comma
SKIPEX: LD DE,5
LD BC,0
SKIPEXL:LD A,(HL)
INC HL
CP $0E
JR Z,SKIPNN
CP "("
JR Z,SKIPBR
CP "\""
JR Z,SKIPQT
CP ")"
JR Z,SKIPCB
CP ":"
JR Z,SKIPEE
CP $0D
JR Z,SKIPEE
CP THEN_T
JR Z,SKIPEE
CP ","
JR NZ,SKIPEXL
LD A,B
OR C
JR NZ,SKIPEXL
RET
SKIPNN: ADD HL,DE
JR SKIPEXL
SKIPBR: INC BC
JR SKIPEXL
SKIPQT: CP (HL)
INC HL
JR NZ,SKIPQT
JR SKIPEXL
SKIPCB: LD A,B
OR C
SKIPEE: SCF
RET Z
DEC BC
JR SKIPEXL
|
src/dnscatcher/dns/server/dnscatcher-dns-server.adb | DNSCatcher/DNSCatcher | 4 | 17216 | <reponame>DNSCatcher/DNSCatcher
-- Copyright 2019 <NAME> <<EMAIL>>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to
-- deal in the Software without restriction, including without limitation the
-- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-- sell copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with Ada.Exceptions; use Ada.Exceptions;
with GNAT.Sockets; use GNAT.Sockets;
with DNSCatcher.Config;
with DNSCatcher.Utils.Logger; use DNSCatcher.Utils.Logger;
with DNSCatcher.Network.UDP.Receiver;
with DNSCatcher.Network.UDP.Sender;
with DNSCatcher.DNS.Transaction_Manager;
use DNSCatcher.DNS.Transaction_Manager;
package body DNSCatcher.DNS.Server is
Shutting_Down : Boolean := False;
procedure Start_Server is
-- Input and Output Sockets
Capture_Config : DNSCatcher.Config.Configuration;
DNS_Transactions : DNSCatcher.DNS.Transaction_Manager
.DNS_Transaction_Manager_Task;
Receiver_Interface : DNSCatcher.Network.UDP.Receiver
.UDP_Receiver_Interface;
Sender_Interface : DNSCatcher.Network.UDP.Sender.UDP_Sender_Interface;
Logger_Task : DNSCatcher.Utils.Logger.Logger;
Transaction_Manager_Ptr : DNS_Transaction_Manager_Task_Ptr;
Socket : Socket_Type;
Logger_Packet : DNSCatcher.Utils.Logger.Logger_Message_Packet_Ptr;
procedure Free_Transaction_Manager is new Ada.Unchecked_Deallocation
(Object => DNS_Transaction_Manager_Task,
Name => DNS_Transaction_Manager_Task_Ptr);
begin
-- Load the config file from disk
DNSCatcher.Config.Initialize (Capture_Config);
DNSCatcher.Config.Read_Cfg_File
(Capture_Config, "conf/dnscatcherd.conf");
-- Configure the logger
Capture_Config.Logger_Config.Log_Level := DEBUG;
Capture_Config.Logger_Config.Use_Color := True;
Logger_Task.Initialize (Capture_Config.Logger_Config);
Transaction_Manager_Ptr := new DNS_Transaction_Manager_Task;
-- Connect the packet queue and start it all up
Logger_Task.Start;
Logger_Packet := new DNSCatcher.Utils.Logger.Logger_Message_Packet;
Logger_Packet.Log_Message (NOTICE, "DNSCatcher starting up ...");
DNSCatcher.Utils.Logger.Logger_Queue.Add_Packet (Logger_Packet);
-- Socket has to be shared between receiver and sender. This likely needs
-- to move to to a higher level class
begin
Create_Socket
(Socket => Socket,
Mode => Socket_Datagram);
Set_Socket_Option
(Socket => Socket,
Level => IP_Protocol_For_IP_Level,
Option => (GNAT.Sockets.Receive_Timeout, Timeout => 1.0));
Bind_Socket
(Socket => Socket,
Address =>
(Family => Family_Inet, Addr => Any_Inet_Addr,
Port => Capture_Config.Local_Listen_Port));
exception
when Exp_Error : GNAT.Sockets.Socket_Error =>
begin
Logger_Packet :=
new DNSCatcher.Utils.Logger.Logger_Message_Packet;
Logger_Packet.Log_Message
(ERROR, "Socket error: " & Exception_Information (Exp_Error));
Logger_Packet.Log_Message (ERROR, "Refusing to start!");
Logger_Queue.Add_Packet (Logger_Packet);
goto Shutdown_Procedure;
end;
end;
Receiver_Interface.Initialize
(Capture_Config, Transaction_Manager_Ptr, Socket);
Sender_Interface.Initialize (Socket);
Transaction_Manager_Ptr.Set_Packet_Queue
(Sender_Interface.Get_Packet_Queue_Ptr);
Transaction_Manager_Ptr.Start;
Receiver_Interface.Start;
Sender_Interface.Start;
loop
if Shutting_Down
then
goto Shutdown_Procedure;
else
delay 1.0;
end if;
end loop;
<<Shutdown_Procedure>>
Sender_Interface.Shutdown;
Receiver_Interface.Shutdown;
Transaction_Manager_Ptr.Stop;
Logger_Task.Stop;
Free_Transaction_Manager (Transaction_Manager_Ptr);
end Start_Server;
-- And shutdown
procedure Stop_Server is
begin
Shutting_Down := True;
end Stop_Server;
end DNSCatcher.DNS.Server;
|
Appl/FileMgrs2/CommonDesktop/CUtil/cutilUtil.asm | steakknife/pcgeos | 504 | 168787 | COMMENT @----------------------------------------------------------------------
Copyright (c) GeoWorks 1988 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Desktop/Util
FILE: utilCode.asm
ROUTINES:
INT CheckQuickTransferType - check if quick-transfer item
supports CIF_FILES
INT CreateNewFolderWindow - create new window for newly opened
folder
INT CheckFolderWindow - check if a new Folder Window should be
created for this folder
INT SaveNewFolder - save handle of new Folder Object's block
in global table
INT BroadcastToFolderWindows - send message to all folder windows
INT CallGenCopyVisMoniker - set new vis moniker for object
INT GetDiskInfo - get volume label, etc.
INT MarkWindowForUpdate - mark the specified folder window(s)
as in need of updating
INT UpdateMarkedWindows - update the marked folder window(s)
INT GetLoadAppGenParent - stuff AppLaunchBlock with genParent
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 7/89 Initial version
DESCRIPTION:
This file contains desktop utility routines.
$Id: cutilUtil.asm,v 1.3 98/06/03 13:51:14 joon Exp $
------------------------------------------------------------------------------@
UtilCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UtilAddToFileChangeList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Add the object to the system-level file-change notification
list, as well as the application object's active list, so
we can remove it from the file-change list on detach.
CALLED BY: (EXTERNAL) FolderScan, Tree...
PASS: *ds:si = object
RETURN: nothing
DESTROYED: ax, bx, cx, dx, di
SIDE EFFECTS: object is added to both the GCNSLT_FILE_SYSTEM list and the
application object's active list. object will want to handle
MSG_META_DETACH and call UtilRemoveFromFileChangeList
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/12/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UtilAddToFileChangeList proc far
uses bp, si
.enter
;
; Add to the file-change list
;
mov cx, ds:[LMBH_handle]
mov dx, si
mov bx, MANUFACTURER_ID_GEOWORKS
mov ax, GCNSLT_FILE_SYSTEM
call GCNListAdd
;
; Add to the app's active list.
;
mov dx, size GCNListParams
sub sp, dx
mov bp, sp
mov ss:[bp].GCNLP_ID.GCNLT_manuf, MANUFACTURER_ID_GEOWORKS
mov ss:[bp].GCNLP_ID.GCNLT_type, MGCNLT_ACTIVE_LIST or \
mask GCNLTF_SAVE_TO_STATE
mov ax, ds:[LMBH_handle]
mov ss:[bp].GCNLP_optr.handle, ax
mov ss:[bp].GCNLP_optr.chunk, si
mov ax, MSG_META_GCN_LIST_ADD
clr bx
call GeodeGetAppObject
mov di, mask MF_CALL or mask MF_STACK or mask MF_FIXUP_DS
call ObjMessage
add sp, size GCNListParams
.leave
ret
UtilAddToFileChangeList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UtilRemoveFromFileChangeList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Remove the object from the system-wide file-change list
CALLED BY: (EXTERNAL) FolderClose, FolderDetach, Tree...
PASS: *ds:si = object
RETURN: nothing
DESTROYED: ax, bx, cx, dx
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/12/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UtilRemoveFromFileChangeList proc far
class FolderClass
uses bp, si
.enter
mov bx, MANUFACTURER_ID_GEOWORKS
mov ax, GCNSLT_FILE_SYSTEM
mov cx, ds:[LMBH_handle]
mov dx, si
call GCNListRemove
;
; Remove from the app's active list.
;
mov dx, size GCNListParams
sub sp, dx
mov bp, sp
mov ss:[bp].GCNLP_ID.GCNLT_manuf, MANUFACTURER_ID_GEOWORKS
mov ss:[bp].GCNLP_ID.GCNLT_type, MGCNLT_ACTIVE_LIST or \
mask GCNLTF_SAVE_TO_STATE
mov ax, ds:[LMBH_handle]
mov ss:[bp].GCNLP_optr.handle, ax
mov ss:[bp].GCNLP_optr.chunk, si
mov ax, MSG_META_GCN_LIST_REMOVE
clr bx
call GeodeGetAppObject
mov di, mask MF_CALL or mask MF_STACK or mask MF_FIXUP_DS
call ObjMessage
add sp, size GCNListParams
.leave
ret
UtilRemoveFromFileChangeList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckQuickTransferType
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: check if quick-transfer item supports CIF_FILES
CALLED BY: EXTERNAL
PASS: nothing
RETURN: carry clear if CIF_FILES is supported
ax - feedback data
bx - remote flag
carry set if CIF_FILES not supported
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 03/13/91 Initial version
dlitwin 01/21/93 Added Wizard support and new QuickTransfer
feedback data and remote flag
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CheckQuickTransferType proc far
uses cx, dx, di, si, bp, es
.enter
mov bp, mask CIF_QUICK
call ClipboardQueryItem ; bp = # formats, cx:dx = owner
push bx, ax ; bx:ax = VM file:VM block
tst bp
stc ; assume no quick-transfer item
jz done ; no item (carry set)
BA< push bx, ax >
mov cx, MANUFACTURER_ID_GEOWORKS
mov dx, CIF_FILES
call ClipboardRequestItemFormat ; is CIF_FILES there?
; cx = extra1 = feedback data
; dx = extra2 = remote flag
BA< tst ax >
BA< pop bx, ax >
BA< jnz done >
BA< mov cx, MANUFACTURER_ID_WIZARD >
BA< mov dx, CIF_FILES >
BA< call ClipboardRequestItemFormat ; is CIF_FILES there? >
BA< ; cx = extra1 = feedback data >
BA< ; dx = extra2 = remote flag >
tst ax
stc ; assume not
jz done ; nope (carry set)
clc ; else, indicate found
done:
pop bx, ax ; retrieve header
pushf ; save result flag
call ClipboardDoneWithItem
popf ; retreive result flag
mov ax, cx ; feedback flag
mov bx, dx ; remote flag
.leave
ret
CheckQuickTransferType endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CompareDiskHandles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: See if two disk handles are "the same", for the purposes
of quick-transfer and determining what the default
quick-transfer action should be.
CALLED BY: GetQuickTransferMethod, various DeskDisplay tools
PASS: ax = disk handle #1
dx = disk handle #2
RETURN: flags set so je will take if two disks are "the same"
DESTROYED: ax, dx
PSEUDO CODE/STRATEGY:
While the comparison of disk handles would appear fairly
simple, it is complicated by the existence of StandardPath
constants. For our purposes, if both ax and dx are StandardPath
constants, they're "the same". If one is a StandardPath and
the other is the system disk, the are also "the same". If
ax and dx are numerically the same, they are also "the same"
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 2/10/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CompareDiskHandles proc far
uses bp, es
.enter
clr bp ; assume same
test ax, DISK_IS_STD_PATH_MASK ; src a standard path?
jnz axIsStdPath ; yes
xchg ax, dx ; ax <- dest, dx <- src
test ax, DISK_IS_STD_PATH_MASK ; dest a standard path?
jnz axIsStdPath ; yes
cmp dx, ax ; same/diff disk?
je done ; yes
setCopy:
dec bp ; different
done:
tst bp
.leave
ret
axIsStdPath:
test dx, DISK_IS_STD_PATH_MASK ; other handle also s.p.?
jnz done ; yes => move
NOFXIP< segmov es, dgroup, ax >
FXIP< mov dx, bx >
FXIP< GetResourceSegmentNS dgroup, es, TRASH_BX >
FXIP< mov bx, dx >
cmp dx, es:[geosDiskHandle] ; other handle is system disk?
je done ; yes => move
jmp setCopy ; else copy
CompareDiskHandles endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateNewFolderWindow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: create new folder window to show folder contents
CALLED BY: InheritAndCreateNewFolderWindow,
DesktopOpenApplication
PASS: dx:bp - folder's pathname
bx - disk handle for folder window
ds - assumed to be pointing to object block
(MF_FIXUP_DS performed)
es:ax - FolderRecord of folder to open (for NewDesk only)
if ax == NIL then no FolderRecord
ds:si - FolderClass instance data
only if ax != NIL
(NewDesk):
cx - NewDeskObjectType
RETURN: carry clear if new Folder Window created
carry set if not
ax - 0 if existing Folder Window brought to front
ax - ERROR_TOO_MANY_FOLDER_WINDOWS
ax - NIL if other error
(preserves ds, si)
^lcx:dx - OD of new FolderClass object created
DESTROYED: bx, bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 7/24/89 Initial version
brianc 8/30/89 changed folder windows to GenDisplay
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateNewFolderWindow proc far
uses di
.enter
GM< clr di ; GMGR has no normal setup behavior >
ND< mov di, offset NDFolderSetup >
call CreateFolderWindowCommon
; On a network, if this machine has one of its CWDs
; set to a common directory, it's possible that the directory
; will be nuked by another user, in which case NETX drops that
; drive entirely, causing all kinds of problems. Doing a
; FilePopDir doesn't solve this, as it doesn't actually
; communicate that we no longer need that directory to NETX
; (maybe it should). The only fix is to set the CWD to
; something else, which is a total hack, and is certainly only
; going to solve the problem in a very small number of cases,
; but this case is probably the only one the testers will
; test, so here it is. Note that this causes a performance
; penalty for the opening of every folder, but it's rather
; small.
BA < mov ax, SP_TOP >
BA < call FileSetStandardPath >
.leave
ret
CreateNewFolderWindow endp
if _GMGR
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateMaxFolderWindow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets up and calls CreateFolderWindowCommon with the
call back routine MaximizeWindow, which puts up the
window in Full Screen mode, not overlapping mode.
CALLED BY: InitSetFolderDispOpts, ...
PASS: dx:bp - Pathname at which to create new folder
bx - disk handle for folder window
ds - assumed to be pointing to object block
(MF_FIXUP_DS performed)
RETURN: ^lcx:dx - OD of new folder object
DESTROYED: ax, bx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
dlitwin 7/23/92 added header
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateMaxFolderWindow proc far
uses di
.enter
if FULL_EXECUTE_IN_PLACE
;
; Make sure the fptr passed in is valid
;
EC < pushdw bxsi >
EC < movdw bxsi, dxbp >
EC < call ECAssertValidFarPointerXIP >
EC < popdw bxsi >
endif
mov di, offset MaximizeWindow
call CreateFolderWindowCommon
.leave
ret
CreateMaxFolderWindow endp
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateFolderWindowCommon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Common routine to create a folder window
CALLED BY: CreateNewFolderWindow, CreateMaxFolderWindow
PASS: dx:bp - Pathname at which to create new folder
bx - disk handle for folder
ds - assumed to be pointing to object block
(MF_FIXUP_DS performed)
di - callback routine.
es:ax - FolderRecord of folder to open (for NewDesk only)
if ax == NIL then no FolderRecord
ds:si - FolderClass instance data
only if ax != NIL
(NewDesk):
cx - NewDeskObjectType of new folder
RETURN: ^lcx:dx - OD of new folder object
DESTROYED: ax,bx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 7/13/92 added header
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateFolderWindowCommon proc near
uses si
xchg dx, bp
pathname local fptr push bp, dx
diskHandle local word push bx
callback local nptr push di
ND< objectType local NewDeskObjectType push cx >
ND< folderRecord local fptr push es, ax >
ND< containingFolder local fptr push ds, si >
ND< iconBounds local Rectangle >
windowBlock local hptr
folderBlock local hptr
.enter
if _NEWDESK
ForceRef folderRecord ; These locals are used in
ForceRef containingFolder ; a called routine that
ForceRef iconBounds ; inherits this stack
; Make sure the passed NewDeskObjectType is valid, since it was added
; as an afterthought...
EC < test cx, 1 >
EC < ERROR_NZ DESKTOP_FATAL_ERROR >
EC < cmp cx, -OFFSET_FOR_WOT_TABLES >
EC < ERROR_L DESKTOP_FATAL_ERROR >
EC < cmp cx, NewDeskObjectType >
EC < ERROR_G DESKTOP_FATAL_ERROR >
endif ; _NEWDESK
call ShowHourglass
;
; check if we can open a window for this folder
; (can't if we have MAX_NUM_FOLDER_WINDOWS opened already or
; if a window for this folder is already opened. In the latter
; case, just bring it to the front.)
;
mov cx, bx ; cx = disk handle
mov si, dx
mov dx, ss:[pathname].segment ; dx:si - pathname
ND< mov ax, ss:[objectType] >
call CheckFolderWindow
LONG jc exit ; if can't open, exit
;
; create a new folder object for the window
; In GeoManager this means copying the normal FolderObject but
; in the NewDesk and BA cases it means copying different templates
; of FolderObject subclasses according to which folder we are
; opening (determined by the path). All folder objects must be the
; only (or at least the first) object in their template resource so
; the offset "FolderObjectTemplate:FolderObject" is the same handle
; for all the different subclasses (i.e. no offset table needed)
; Since the FolderWindow (a DisplayControl in GeoManager and a primary
; in NewDesk) and associated view are the first two objects in their
; object template blocks the offsets for these objects can be reached
; by using FolderWindow and FolderView. In comments these will
; be refered to as "common offsets" because the GeoManager offset
; will be used to reference the chunk for any template.
;
GM< mov bx, handle FolderObjectTemplate ; GMGR is always normal >
if _NEWDESK
mov si, ss:[objectType]
CheckHack <segment FolderObjectTemplateTable eq @CurSeg>
mov bx, cs:[FolderObjectTemplateTable+OFFSET_FOR_WOT_TABLES][si]
cmp bx, 0 ; if the block is 0, this is
stc ; a non-openable WOT
LONG je exit
push si ; NewDeskObjectType
endif ; if _NEWDESK
clr ax ; have current geode own block
mov cx, -1 ; copy running thread
call ObjDuplicateResource
mov folderBlock, bx ; save folder object's block
mov si, FOLDER_OBJECT_OFFSET ; common offset
;
; create a new folder window
;
GM< mov bx, handle FolderWindowTemplate >
if _NEWDESK
pop si ; NewDeskObjectType
mov bx, cs:[FolderWindowTemplateTable+OFFSET_FOR_WOT_TABLES][si]
endif ; NewDesk
clr ax ; have current geode own block
mov cx, -1 ; copy running thread
call ObjDuplicateResource ; duplicate it
mov windowBlock, bx
;
; attach new folder object to new folder window via OD
; bx = folder window's block
;
mov cx, folderBlock ; cx:dx = object to be output
mov dx, FOLDER_OBJECT_OFFSET ; common offset
; bx:si = view to set output of
;
; Set the content of the view
; ^lcx:dx - folder
mov ax, MSG_GEN_VIEW_SET_CONTENT
mov si, FOLDER_VIEW_OFFSET ; common offset
call ObjMessageFixup
;
; Also, set the block's output, so that other objects in the window
; block can send messages to the folder
;
mov ax, MSG_META_SET_OBJ_BLOCK_OUTPUT
call ObjMessageFixup
;
; GeoManager has its folder windows built on the GenDisplay and
; attaches them under a GenDisplayControl. It has a folder info
; line in every window to show file sizes etc. and an updir button.
;
if _GMGR
;
; add new folder window to display control
;
push bp
mov cx, bx ; cx:dx = new folder window
mov dx, FOLDER_WINDOW_OFFSET
mov bx, handle FileSystemDisplayGroup ; bx:si = DC
mov si, offset FileSystemDisplayGroup
mov ax, MSG_GEN_ADD_CHILD
mov bp, mask CCF_MARK_DIRTY or CCO_LAST
call ObjMessageCallFixup
pop bp
;
endif ; if _GMGR
;
; NewDesk has its folder windows built on the GenPrimary and
; attaches them under the app.
;
if _NEWDESK
call UtilBringUpFolderWindow
endif
;
; call folder object to initialize itself
;
mov cx, windowBlock ; cx = folder window's block
; (pass to INIT_FOLDER)
push bp
mov bx, folderBlock ; ^lbx:si = new folder object
mov si, FOLDER_OBJECT_OFFSET
mov ax, MSG_INIT
mov bp, diskHandle ; bp = disk handle
call ObjMessageCallFixup
pop bp
;
; store new folder object into global table
;
call SaveNewFolder
;
; Set folder's path
;
push bp
movdw cxdx, pathname
mov bp, diskHandle
mov ax, MSG_FOLDER_SET_PATH
call ObjMessageCallFixup
if _NEWDESK
ifdef SMARTFOLDERS ; compilation flag, see local.mk
pop bp
;
; Set the primary's path.
;
push bp
push bx, si
movdw cxdx, pathname
mov bx, windowBlock ; bx:si = new folder primary
mov si, FOLDER_WINDOW_OFFSET ; common offset
mov bp, diskHandle
mov ax, MSG_GEN_PATH_SET
call ObjMessageCallFixup
pop bx, si
endif ; ifdef SMARTFOLDERS
endif ; if _NEWDESK
;
; call folder object to read directory contents
; bx:si = new folder object (still there)
;
mov ax, MSG_SCAN
call ObjMessageCallFixup
pop bp
;
; local variable "pathname" is no longer valid!
; (callback routines can't use it!)
;
mov cx, windowBlock ; bx:si = new folder window
mov dx, FOLDER_WINDOW_OFFSET ; common offset
mov bx, folderBlock
mov si, FOLDER_OBJECT_OFFSET ; common offset
mov di, callback
tst di
jz noCallback
call di ; call the callback routine
noCallback:
;
; make new folder window usable
;
mov bx, windowBlock ; bx:si = new folder window
mov si, FOLDER_WINDOW_OFFSET
mov dl, VUM_NOW ; udpate now
mov ax, MSG_GEN_SET_USABLE ; (also brings it up)
call ObjMessageCallFixupAndSaveBP
mov ax, MSG_FOLDER_SET_PRIMARY_MONIKER
mov bx, folderBlock ; bx:si = new folder object
mov si, FOLDER_OBJECT_OFFSET ; common offset
call ObjMessageCallFixup
mov ax, MSG_FOLDER_GET_STATE
call ObjMessageCallFixupAndSaveBP ; cx = FolderObjectStates
test cx, mask FOS_BOGUS ; will be closed b/c of error?
stc ; assume so
mov ax, -1 ; AX<>0 -> don't close current
; Folder Window
jnz done ; yes, don't bring up visually
if _GMGR ; Display Control stuff
if CLOSE_IN_OVERLAP
call GetDCMaxState ; cx = TRUE if maximized
push cx
mov ax, MSG_DESKDISPLAY_SET_OPEN_STATE
call ObjMessageCallFixupAndSaveBP
;
; before closing old Folder Window, register the new Folder Window
; in the LRU table
;
mov bx, windowBlock ; bx:si = Folder Window
mov si, FOLDER_WINDOW_OFFSET ; common offset
call UpdateWindowLRUStatus
;
; close oldest
;
pop cx ; cx = TRUE if maximized
cmp cx, TRUE
jne noClose ; don't close if overlapping
call CloseOldestWindowIfPossible
noClose:
endif ; if CLOSE_IN_OVERLAP
endif ; if _GMGR
clr ax ; no error
jmp exit
done:
cmp ax, -1 ; error creating new Folder
; Window?
jne exit ; nope, finis
mov bx, folderBlock ; bx:si = new folder object
mov si, FOLDER_OBJECT_OFFSET ; common offset
mov ax, MSG_CLOSE_FOR_BAD_CREATE
push bp
call ObjMessageForce ; destroy Folder Object
pop bp
mov ax, NIL ; signal real error
exit:
if _GMGR
; See if we excceded the max files allowed
mov cx, ss:[maxNumFiles]
mov dx, ss:[numFiles]
; zero means no limit
jcxz okToHaveOpened
cmp cx, dx
jge okToHaveOpened
; close oldest window(s) until either we have enough space or
; all but the newest one are closed
mov bx, folderBlock
push bp
call CheckMaxNumFiles
pop bp
okToHaveOpened:
endif ; if _GMGR
; Return folder's OD to caller
mov cx, folderBlock
mov dx, FOLDER_OBJECT_OFFSET ; common offset
call HideHourglass
.leave
ret
CreateFolderWindowCommon endp
if _NEWDESK
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UtilBringUpFolderWindow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Bring up the UI objects for this folder (NewDesk only)
CALLED BY: CreateFolderWindowCommon
PASS: bx - handle of UI objects
ds - object block to be fixed up
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 9/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UtilBringUpFolderWindow proc near
uses ax,bx,cx,dx,di,si,bp
.enter
BA < call UtilBringUpEntryLevelFolder >
;
; Add the child LAST so that setting it usable doesn't cause
; all the other children of the app object to be loaded.
;
mov cx, bx
mov dx, FOLDER_WINDOW_OFFSET ; common offset
mov bx, handle GenAppInterface
mov si, offset Desktop
mov ax, MSG_GEN_ADD_CHILD
mov bp, mask CCF_MARK_DIRTY or CCO_FIRST ; don't use CCO_LAST
; because if an older
; sibling is marked
; ignore dirty, our
; linkage be get
; screwed up when we
; restore from state
call ObjMessageCallFixup
.leave
ret
UtilBringUpFolderWindow endp
;-----------------------------------------------------------------------------
; For each NewDeskObjectType, there are 2 blocks of UI that are
; duplicated -- one for each thread. Below are tables that match the
; NewDeskObjectType to the handle of the template block to be
; duplicated. Note that the offsets of the Folder and GenView objects
; within each template must be identical.
;
; The tables are laid out with the BA items first, as the BA
; enumerated types start from a fixed negative such that they end at -2.
; The NewDesk items begin with 0 and grow up from there. This was done to
; allow either NewDesk or BA to gain WOT's without changing any of the
; existing WOT's stored on disk in links. When adding BA WOT's, add them
; to the negative end of the list, when adding NewDesk WOT's add them to
; the end of the enumerated type.
;-----------------------------------------------------------------------------
;
; This is the table of template folder objects. There must be one for
; each NewDeskObjectType, and the offsets of each must be the same.
;
FolderObjectTemplateTable label word
if _NEWDESKBA
word handle BAStudentUtilityObject ; WOT_STUDENT_UTILITY
word handle BAOfficeCommonObject ; WOT_OFFICE_COMMON
word handle BATeacherCommonObject ; WOT_TEACHER_COMMON
word handle BAOfficeHomeObject ; WOT_OFFICE_HOME
word handle BAStudentCourseObject ; WOT_STUDENT_COURSE
word handle BAStudentHomeObject ; WOT_STUDENT_HOME
word 0 ; WOT_GEOS_COURSEWARE
word 0 ; WOT_DOS_COURSEWARE
word handle BAOfficeAppListObject ; WOT_OFFICEAPP_LIST
word handle BASpecialUtilitiesListObject ; WOT_SPECIALS_LIST
word handle BACoursewareListObject ; WOT_COURSEWARE_LIST
word handle BAPeopleListObject ; WOT_PEOPLE_LIST
word handle BAStudentClassesObject ; WOT_STUDENT_CLASSES
word handle BAStudentHomeTViewObject ; WOT_STUDENT_HOME_TVIEW
word handle BATeacherCourseObject ; WOT_TEACHER_COURSE
word handle BARosterObject ; WOT_ROSTER
word handle BATeacherClassesObject ; WOT_TEACHER_CLASSES
word handle BATeacherHomeObject ; WOT_TEACHER_HOME
endif ; if _NEWDESKBA
word handle NDFolderObject ; WOT_FOLDER
word handle NDDesktopFolderObject ; WOT_DESKTOP
word 0 ; WOT_PRINTER
word handle NDWastebasketObject ; WOT_WASTEBASKET
if 1
word handle NDFolderObject ; WOT_DRIVE
else
word handle NDDriveObject ; WOT_DRIVE
endif
word 0 ; WOT_DOCUMENT
word 0 ; WOT_EXECUTABLE
word 0 ; WOT_HELP
word 0 ; WOT_LOGOUT
word handle NDSystemFolderObject ; WOT_SYSTEM_FOLDER
.assert (($ - FolderObjectTemplateTable) eq \
(NewDeskObjectType + OFFSET_FOR_WOT_TABLES))
.assert (offset NDFolderObject eq FOLDER_OBJECT_OFFSET)
.assert (offset NDSystemFolderObject eq FOLDER_OBJECT_OFFSET)
.assert (offset NDDesktopFolderObject eq FOLDER_OBJECT_OFFSET)
.assert (offset NDWastebasketObject eq FOLDER_OBJECT_OFFSET)
.assert (offset NDDriveObject eq FOLDER_OBJECT_OFFSET)
if _NEWDESKBA
.assert (offset BATeacherHomeObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BATeacherClassesObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BARosterObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BATeacherCourseObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BAStudentHomeTViewObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BAStudentClassesObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BAPeopleListObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BACoursewareListObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BASpecialUtilitiesListObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BAOfficeAppListObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BAOfficeCommonObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BATeacherCommonObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BAOfficeHomeObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BAStudentCourseObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BAStudentHomeObject eq FOLDER_OBJECT_OFFSET)
.assert (offset BAStudentUtilityObject eq FOLDER_OBJECT_OFFSET)
endif ; if _NEWDESKBA
; This is the table of UI resources for each folder block. There
; must be one for each NewDeskObjectType, and the offsets of each must
; be the same. The GenViews are asserted to have the same offsets --
; the same must be true for the primaries (but no .assert is made here
; -- it should be, though...)
;
FolderWindowTemplateTable label hptr
if _NEWDESKBA
hptr handle BAStudentUtilityView, ; WOT_STUDENT_UTILITY
handle BAOfficeCommonView, ; WOT_OFFICE_COMMON
handle BATeacherCommonView, ; WOT_TEACHER_COMMON
handle BAOfficeHomeView, ; WOT_OFFICE_HOME
handle BAStudentCourseView, ; WOT_STUDENT_COURSE
handle BAStudentHomeView, ; WOT_STUDENT_HOME
0, ; WOT_GEOS_COURSEWARE
0, ; WOT_DOS_COURSEWARE
handle BAOfficeAppListView, ; WOT_OFFICEAPP_LIST
handle BASpecialUtilitiesListView, ; WOT_SPECIALS_LIST
handle BACoursewareListView, ; WOT_COURSEWARE_LIST
handle BAPeopleListView, ; WOT_PEOPLE_LIST
handle BAStudentClassesView, ; WOT_STUDENT_CLASSES
handle BAStudentHomeTViewView, ; WOT_STUDENT_HOME_TVIEW
handle BATeacherCourseView, ; WOT_TEACHER_COURSE
handle BARosterView, ; WOT_ROSTER
handle BATeacherClassesView, ; WOT_TEACHER_CLASSES
handle BATeacherHomeView ; WOT_TEACHER_HOME
endif ; if _NEWDESKBA
hptr handle NDFolderView, ; WOT_FOLDER
handle NDDesktopFolderView, ; WOT_DESKTOP
0, ; WOT_PRINTER
handle NDWastebasketView, ; WOT_WASTEBASKET
if 1
handle NDFolderView, ; WOT_DRIVE
else
handle NDDriveView, ; WOT_DRIVE
endif
0, ; WOT_DOCUMENT
0, ; WOT_EXECUTABLE
0, ; WOT_HELP
0, ; WOT_LOGOUT
handle NDFolderView ; WOT_SYSTEM_FOLDER
.assert (($ - FolderWindowTemplateTable) eq \
(NewDeskObjectType + OFFSET_FOR_WOT_TABLES)) ; table length
.assert (offset NDFolderView eq FOLDER_VIEW_OFFSET)
.assert (offset NDDesktopFolderView eq FOLDER_VIEW_OFFSET)
.assert (offset NDWastebasketView eq FOLDER_VIEW_OFFSET)
.assert (offset NDDriveView eq FOLDER_VIEW_OFFSET)
if _NEWDESKBA
.assert (offset BATeacherHomeView eq FOLDER_VIEW_OFFSET)
.assert (offset BATeacherClassesView eq FOLDER_VIEW_OFFSET)
.assert (offset BARosterView eq FOLDER_VIEW_OFFSET)
.assert (offset BATeacherCourseView eq FOLDER_VIEW_OFFSET)
.assert (offset BAStudentHomeTViewView eq FOLDER_VIEW_OFFSET)
.assert (offset BAStudentClassesView eq FOLDER_VIEW_OFFSET)
.assert (offset BAPeopleListView eq FOLDER_VIEW_OFFSET)
.assert (offset BACoursewareListView eq FOLDER_VIEW_OFFSET)
.assert (offset BASpecialUtilitiesListView eq FOLDER_VIEW_OFFSET)
.assert (offset BAOfficeAppListView eq FOLDER_VIEW_OFFSET)
.assert (offset BAOfficeCommonView eq FOLDER_VIEW_OFFSET)
.assert (offset BATeacherCommonView eq FOLDER_VIEW_OFFSET)
.assert (offset BAOfficeHomeView eq FOLDER_VIEW_OFFSET)
.assert (offset BAStudentCourseView eq FOLDER_VIEW_OFFSET)
.assert (offset BAStudentHomeView eq FOLDER_VIEW_OFFSET)
.assert (offset BAStudentUtilityView eq FOLDER_VIEW_OFFSET)
endif ; if _NEWDESKBA
endif ; NEWDESK
if _GMGR
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MaximizeWindow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Makes a folder window Full Sized (as opposed to
Overlapping).
CALLED BY: CreateFolderWindowCommon
PASS: ^lbx:si folder object
^lcx:dx folder window
RETURN: none
DESTROYED: ???
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
dlitwin 7/23/92 added this header
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MaximizeWindow proc near
push bp
push cx, dx ; save Folder Window
mov bx, segment GenDisplayGroupClass
mov si, offset GenDisplayGroupClass
mov ax, MSG_GEN_DISPLAY_GROUP_SET_FULL_SIZED
mov di, mask MF_RECORD
call ObjMessage ; di = event handle
mov cx, di ; cx = event handle
pop bx, si
mov ax, MSG_GEN_CALL_PARENT
call ObjMessageCallFixup
pop bp
ret
MaximizeWindow endp
endif ; if _GMGR
if _NEWDESK
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NDFolderSetup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sends a message to itself to setup any special behavior
dealing with the FolderWindow and FolderObject. This
is basically a hook to allow subclasses special setup
circumstances.
CALLED BY: CreateFolderWindowCommon
PASS: ^lbx:si - NDFolderObject or subclass
^lcx:dx - NDFolderWindow or subclass
RETURN: none
DESTROYED: all but bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
dlitwin 7/31/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NDFolderSetup proc near
uses bp
.enter
call NDFolderStoreIconBounds
BA< mov ax, MSG_BA_CONSTRAIN_DROP_DOWN_MENU >
BA< call ObjMessageCallFixup >
mov ax, MSG_ND_SET_CONTROL_BUTTON_MONIKER
call ObjMessageCallFixup
mov ax, MSG_ND_FOLDER_SETUP ; hook for subclasses.
call ObjMessageCallFixup
.leave
ret
NDFolderSetup endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NDFolderStoreIconBounds
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Store the icon bounds of a folder so when it is brought
on screen its zoom lines come from the right place.
CALLED BY: NDFolderSetup
PASS: none
RETURN: none
DESTROYED: ax, di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
JS 11/15/92 Store icon bounds for zoom-lines
dlitwin 7/31/92 broke out from NDFolderSetup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NDFolderStoreIconBounds proc near
class DeskVisClass
uses bx, si, cx, dx
.enter inherit CreateFolderWindowCommon
cmp ss:[folderRecord].offset, NIL
jne getIconBounds
noIconBounds:
mov ax, PARAM_0
mov ss:[iconBounds].R_left, ax
mov ss:[iconBounds].R_top, ax
mov ss:[iconBounds].R_right, ax
mov ss:[iconBounds].R_bottom, ax
jmp short setIconBounds
getIconBounds:
push ds
lds si, ss:[containingFolder]
mov di, ds:[si].DVI_window
pop ds
tst di
jz noIconBounds
call WinGetWinScreenBounds
les di, ss:[folderRecord]
mov cx, es:[di].FR_iconBounds.R_left
add cx, ax
mov ss:[iconBounds].R_left, cx
mov dx, es:[di].FR_iconBounds.R_top
add dx, bx
mov ss:[iconBounds].R_top, dx
add ax, es:[di].FR_iconBounds.R_right
mov ss:[iconBounds].R_right, ax
add bx, es:[di].FR_iconBounds.R_bottom
mov ss:[iconBounds].R_bottom, bx
setIconBounds:
mov ax, MSG_ND_PRIMARY_INITIALIZE
mov bx, ss:[windowBlock]
mov si, FOLDER_WINDOW_OFFSET ; bx:si = new folder window
mov cx, ss
lea dx, ss:[iconBounds]
call ObjMessageCallFixup
ifdef SMARTFOLDERS
;
; now check if we loaded display options from dir info file
;
push bp
sub sp, size GetVarDataParams + size NDPSavedDisplayOptions
mov bp, sp
mov ss:[bp].GVDP_buffer.segment, ss
lea ax, ss:[bp][(size GetVarDataParams)]
mov ss:[bp].GVDP_buffer.offset, ax
mov ss:[bp].GVDP_bufferSize, size NDPSavedDisplayOptions
mov ss:[bp].GVDP_dataType, ATTR_ND_PRIMARY_SAVED_DISPLAY_OPTIONS
mov ax, MSG_META_GET_VAR_DATA
mov dx, size GetVarDataParams
mov di, mask MF_CALL or mask MF_STACK or mask MF_FIXUP_DS
push bp
call ObjMessage
pop bp
mov cl, ss:[bp][(size GetVarDataParams)].NDPSDO_types
mov ch, ss:[bp][(size GetVarDataParams)].NDPSDO_attrs
mov dl, ss:[bp][(size GetVarDataParams)].NDPSDO_sort
mov dh, ss:[bp][(size GetVarDataParams)].NDPSDO_mode
add sp, size GetVarDataParams + size NDPSavedDisplayOptions
pop bp
cmp ax, size NDPSavedDisplayOptions
jne noOptions
;
; sanity check the options
;
tst dl ; must have sort mode
jz noOptions
tst dh ; must have display mode
jz noOptions
mov bx, ss:[folderBlock]
mov si, FOLDER_OBJECT_OFFSET
mov ax, MSG_RESTORE_DISPLAY_OPTIONS
mov di, mask MF_FORCE_QUEUE
call ObjMessage
mov ax, MSG_REDRAW
mov di, mask MF_FORCE_QUEUE
call ObjMessage
noOptions:
endif
.leave
ret
NDFolderStoreIconBounds endp
endif ; if _NEWDESK
if _GMGR
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GetDCMaxState
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Returns if the state of the the document control object
for the GeoManagers folder windows is maximized or not.
CALLED BY:
PASS: none
RETURN: cx = TRUE if it is in maximized state
FALSE if it is not in maximized state
DESTROYED: none
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
dlitwin 12/30/92 added this header
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GetDCMaxState proc near
push bx, si ; save new folder window
mov bx, handle FileSystemDisplayGroup
mov si, offset FileSystemDisplayGroup
mov ax, MSG_GEN_DISPLAY_GROUP_GET_FULL_SIZED
call ObjMessageCallFixupAndSaveBP ; carry set if maximized
mov cx, FALSE ; assume not maximized
jnc done
mov cx, TRUE ; maximized
done:
pop bx, si ; bx:si = new folder window
ret
GetDCMaxState endp
endif ; if _GMGR
ObjMessageCallFixupAndSaveBP proc near
push bp
call ObjMessageCallFixup
pop bp
ret
ObjMessageCallFixupAndSaveBP endp
if _GMGR
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CloseOldestWindowIfPossible
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: closes oldest Folder Window or Tree Window, if possible
CALLED BY: EXTERNAL
CreateFolderWindowCommon (opening new Folder Window)
TreeWindowCommon (opening Tree Window)
PASS: nothing
RETURN: nothing
DESTROYED: ax, bx, cx, dx, si, di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 10/08/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CloseOldestWindowIfPossible proc far
uses bp
.enter
mov ax, MSG_GEN_COUNT_CHILDREN
mov bx, handle FileSystemDisplayGroup
mov si, offset FileSystemDisplayGroup
call ObjMessageCallFixup
cmp dl, ss:[lruNumber] ; initilized by .ini file
jbe done ; can't be anything to close
mov ss:[oldestUsage], 0xffff
mov ss:[oldestWindow].handle, 0
mov ss:[closableCount], 0
;
; ask all Windows to check if they are the one to be axed
; (ask via DisplayControl)
;
;still set from above
; mov bx, handle FileSystemDisplayGroup
; mov si, offset FileSystemDisplayGroup
mov ax, MSG_DESKDG_CLOSE_OLDEST_CHECK
call ObjMessageCallFixup
jnc done ; nothing found to close
;
; axe oldest Window, if any
;
mov bx, ss:[oldestWindow].handle
tst bx ; any?
je done ; nope
mov si, ss:[oldestWindow].offset ; bx:si = Window to close
mov ax, MSG_GEN_DISPLAY_CLOSE
call ObjMessageCallFixup
done:
.leave
ret
CloseOldestWindowIfPossible endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CloseOldestWindow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: closes oldest window
CALLED BY: CheckMaxNumFiles
PASS: bx - newest folder's handle
RETURN: carry set - if we're tryimg to close the window that
we just opened
carry clear - if we closed an old window successfully
DESTROYED: evrything, but cx
SIDE EFFECTS: ss:[numFiles] gets updated
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CP 4/22/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CloseOldestWindow proc far
uses cx
.enter
;
; save handle of newest folder
;
push bx
;
; erase all memory of previuosly oldestWindow
;
mov ss:[oldestUsage], 0xffff
mov ss:[oldestWindow].handle, 0
mov ss:[closableCount], 0
;
; ask all Windows to check if they are the one to be axed
; (ask via DisplayControl)
;
mov bx, handle FileSystemDisplayGroup
mov si, offset FileSystemDisplayGroup
mov ax, MSG_DESKDG_CLOSE_OLDEST
call ObjMessageCallFixup
;
; axe oldest Window, if any
;
mov bx, ss:[oldestWindow].handle
tst bx ; any?
; restore current folder handle
pop bp
je doneNoMoreClose ; nope
; save again
push bp
mov si, offset FolderWindowTemplate:FolderView
;
; get the folder (which is the content) of the display
;
mov ax, MSG_GEN_VIEW_GET_CONTENT
call ObjMessageCallFixup
; restore again and see if we're trying to close the one we
; just opened
pop bp
cmp bp, cx
je doneNoMoreClose
; close the folder that we found to be the oldest
movdw bxsi, cxdx
mov ax, MSG_FOLDER_CLOSE
call ObjMessageCallFixup
clc
exit:
.leave
ret
doneNoMoreClose:
stc
jmp exit
CloseOldestWindow endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UpdateWindowLRUStatus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: update usage of window in LRU table
CALLED BY: EXTERNAL
FolderGainTarget, TreeGainTarget
CreateFolderWindowCommon
TreeWindowCommon
PASS: bx:si = Folder Window or Tree Window (GenDisplay)
ds = segment that can be fixed up
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 10/08/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UpdateWindowLRUStatus proc far
uses ax, cx, dx, di, bp
.enter
inc ss:[windowUsageCount]
mov cx, ss:[windowUsageCount]
mov ax, MSG_DESKDISPLAY_SET_USAGE
call ObjMessageCallFixup
.leave
ret
UpdateWindowLRUStatus endp
endif ; if _GMGR
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckFolderWindow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: checks if we can open another window for this folder and
if there is already an open window for this folder; in the
latter case, just bring that window to the front
CALLED BY: CreateNewFolderWindow
PASS: dx:si - folder's pathname
cx - disk handle of folder
ds - fixupable segment
ND< ax = object type >
RETURN: carry - set if window CANNOT be created
ax = 0 if brought to front
otherwise handles the errors:
ax = ERROR_TOO_MANY_FOLDER_WINDOWS
ax = ERROR_LINK_TARGET_GONE
ax = ERROR_DRIVE_LINK_TARGET_GONE
carry - clear if window CAN be created
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
Could optimize opening of folders by returning actual path (from
FindFolderWindow) to the caller.
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 8/8/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CheckFolderWindow proc near
uses ax, bx, cx, dx, si, di, bp, ds, es
.enter
mov bp, si ; dx:bp = pathname
mov di, mask MF_CALL or mask MF_FIXUP_DS
call FindFolderWindow ; check if already opened
; For NewDesk, we want to allow multiple windows in the same folder
if _GMGR
jnc notFound ; if not, check # windows
;
; If an error occurred for a student, put up error about generic
; students. If for a drive, put up message about drives. Otherwise
; we've got a link whose target has dissappeared.
;
BA< cmp ax, WOT_STUDENT_HOME_TVIEW >
BA< je isStudent >
BA< cmp ax, WOT_STUDENT_UTILITY >
BA< jne checkOtherTypes >
BA<isStudent: >
BA< mov ax, ERROR_GENERIC_HOME_NOT_OPENABLE >
BA< jmp gotErrorMsg >
BA<checkOtherTypes: >
ND< cmp ax, WOT_DRIVE >
mov ax, ERROR_LINK_TARGET_GONE
ND< jne gotErrorMsg >
ND< mov ax, ERROR_DRIVE_LINK_TARGET_GONE >
ND<gotErrorMsg: >
tst bx
jz errorButCheckSPLink
;
; found matching folder window, bring to front
; bx = folder window block
;
mov si, FOLDER_OBJECT_OFFSET ; common offset
mov ax, MSG_FOLDER_BRING_TO_FRONT
call ObjMessageCallFixup ; tell window to come to front
; via the FolderObject
clr ax ; no error
jmp short noCreate ; brought-to-front,
; don't create
errorButCheckSPLink:
;
; If we have a ERROR_LINK_TARGET_GONE error, but if the path is a
; StandardPath, CD'ing to that directory will create it (the kernel
; ensures this). Pretend we didn't find the folder window if this
; is the case - brianc 6/18/93
; dx:si = path
; cx = disk handle
;
cmp ax, ERROR_LINK_TARGET_GONE
jne error
push es, di, bx, ax
movdw esdi, dxsi
mov bx, cx
call FileParseStandardPath
test ax, DISK_IS_STD_PATH_MASK ; (clears carry)
jz popAndErrorNC ; is not SP, return error
SBCS < cmp {byte} es:[di], 0 ; no tail? >
DBCS < cmp {wchar} es:[di], 0 ; no tail? >
stc ; assume no tail, say not found
je popAndErrorNC ; no tail, fall thru to notFound
clc ; else, return error
popAndErrorNC:
pop es, di, bx, ax
jnc error
notFound:
endif ; _GMGR
;
; Removed call to CheckIfLinkIsValid. Most links are, so the
; time we waste checking isn't worth it. If the link isn't
; valid, the folder will go away soon enough...
;
;
; folder window isn't open yet, check if we can open any
; more folder windows without exceeding the max
;
if _GMGR
clr ax
mov al, ss:[lruNumber]
; maxNumFolderWindows is the maximum for overlapping windows,
; check if we're overlapping or maximized
tst ss:[displayIsMaximized]
jz isMaximized
mov ax, ss:[maxNumFolderWindows]
isMaximized:
cmp ss:[numFolderWindows], ax
jl canCreate ; if so, signal can create
call CloseOldestWindow
jnc canCreate
else ; if _GMGR
cmp ss:[numFolderWindows], MAX_NUM_FOLDER_WINDOWS
jne canCreate ; if so, signal can create
endif ; if _GMGR
mov ax, ERROR_TOO_MANY_FOLDER_WINDOWS ; else, report error
cmp ss:[doingMultiFileLaunch], TRUE ; need to check flag?
jne error ; nope, report error
cmp ss:[tooManyFoldersReported], TRUE ; already reported?
je noCreate ; yes, skip error box
mov ss:[tooManyFoldersReported], TRUE ; mark as reported
error:
call DesktopOKError ; preserves AX
noCreate:
stc ; carry set =
; no-create-window
jmp short done
canCreate:
clc ; carry clear = can-create-win
done:
call ShellFreePathBuffer
.leave
ret
CheckFolderWindow endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FindFolderWindow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Finds a folder given a path if one exists
CALLED BY: INTERNAL
CheckFolderWindow
DesktopDriveToolInternal
NewDeskGetDummyOrRealObject
SendToOpenedOrDummy
NDOpenDropDownIfFolderType
PASS: dx:bp = pathname to find
cx = disk handle to match
di = MessageFlags for the call to the FolderClass
don't set to FIXUP_DS if ds isn't an object block!
ax = object type
RETURN: carry set if found, or error
bx = block of matching folder object
(bx=0 if path does not exist)
carry clear if not found
es = segment of path buffer containing the actual path of dx:bp
(buffer should be freed by caller)
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
BA-ONLY HACK: If the folder we're trying to open is of type
WOT_STUDENT_HOME_TVIEW or WOT_STUDENT_UTILITY and is a link to
\GENERICS, then return carry set and bx = 0.
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 04/06/90 broken out from CheckFolderWindow
dlitwin 10/10/92 Made di be passed message flags, because
we don't necessarily want to always fixup ds.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FindFolderWindow proc far
uses ax, cx, dx, si, bp, di
.enter
;
; Construct the actual path to find
;
push di, ds, ax
mov ds, dx
mov si, bp
mov bx, cx
clr dx
call ShellAllocPathBuffer
call FileConstructActualPath
mov bp, di
pop di, ds, ax
jc error
BA< cmp ax, WOT_STUDENT_HOME_TVIEW >
BA< je student >
BA< cmp ax, WOT_STUDENT_UTILITY >
BA< jne notStudent >
BA<student: >
BA< call CheckForGenericsLink >
BA< jz error >
BA<notStudent: >
mov dx, es
mov cx, bx ; cx, dx:bp - path to find
clr si ; init index into table
checkNext:
; bx = handle of opened window
mov bx, ss:[folderTrackingTable][si].FTE_folder.handle
tst bx ; check if window here
jz tryNext ; if not, don't check it
mov ax, MSG_FOLDER_CHECK_PATH ; compare dx:bp to
; this folder's pathname
; (also have cx = disk handle)
push si, di
mov si, ss:[folderTrackingTable][si].FTE_folder.chunk
call ObjMessage ; carry set if different
pop si, di ; retrieve table offset + flags
jnc foundOrError ; if match, return BX
;
; this window's pathname doesn't match, try to match next window
;
tryNext:
add si, size FolderTrackingEntry ; move to next window
; check if end of list
cmp si, MAX_NUM_FOLDER_WINDOWS * (size FolderTrackingEntry)
jne checkNext ; if not, go back to check next
;
; Not found -- clear carry
;
clc
jmp done
foundOrError:
stc ; indicate found
done:
.leave
ret
error:
clr bx
jmp foundOrError
FindFolderWindow endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckForGenericsLink
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: See if the passed path is \GENERICS
CALLED BY: FindFolderWindow
PASS: es:bp = actual path of some folder
RETURN: zero flag set if path is \GENERICS
DESTROYED: nothing
SIDE EFFECTS: none
PSEUDO CODE/STRATEGY:
KNOWN BUGS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
dloft 3/23/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if _NEWDESKBA
genericsPath char C_BACKSLASH, 'GENERICS', C_NULL
CheckForGenericsLink proc near
uses ds, si, cx, di
.enter
segmov ds, cs
mov si, offset cs:[genericsPath]
mov di, bp
clr cx ; null terminated
call LocalCmpStrings
.leave
ret
CheckForGenericsLink endp
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SaveNewFolder
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: save the OD of the new folder into a global table and
increment count of opened windows
CALLED BY: INTERNAL
CreateNewFolderWindow
PASS: ^lbx:si - Folder OD
RETURN: preserves bx
numFolderWindows incremented
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 8/8/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SaveNewFolder proc far
uses bp
.enter
clr bp
checkNext:
; check if this is empty spot
tst ss:[folderTrackingTable][bp].FTE_folder.handle
jz foundFree ; if so, use it
add bp, size FolderTrackingEntry ; move to next spot
EC < cmp bp, MAX_NUM_FOLDER_WINDOWS * (size FolderTrackingEntry) >
EC < ERROR_Z FOLDER_TRACKING_TABLE_FULL >
jmp checkNext
foundFree:
inc ss:[numFolderWindows] ; bump window count
; save new block
movdw ss:[folderTrackingTable][bp].FTE_folder, bxsi
mov ss:[folderTrackingTable][bp].FTE_state, 0
.leave
ret
SaveNewFolder endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
InitForWindowUpdate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: prepare for usage of MarkWindowForUpdate/UpdateMarkedWindows
CALLED BY: file operation routines
PASS: nothing
RETURN: sets up update variables
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 01/02/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
InitForWindowUpdate proc far
mov ss:[updateSrcDiskHandle], 0 ; preserve flags
mov ss:[updateDestDiskHandle], 0
mov ss:[updateSrcDiskOpened], FALSE
mov ss:[updateDestDiskOpened], FALSE
ret
InitForWindowUpdate endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SuspendFolders
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Suspend any folders affected by the operation about to be
performed.
CALLED BY: (EXTERNAL)
PASS: ds = FileQuickTransfer block
current dir = destination
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS: file-changes are batched
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/12/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SuspendFolders proc far
uses ax
.enter
mov ax, SUSPEND_UPDATE_STRATEGY
call MarkWindowForUpdate
.leave
ret
SuspendFolders endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UnsuspendFolders
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Unsuspend any folders affected by the operation just
performed.
CALLED BY: (EXTERNAL)
PASS: ds = FileQuickTransfer block
current dir = destination
RETURN: nothing
DESTROYED: nothing (flags preserved)
SIDE EFFECTS: file-changes are flushed
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/12/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UnsuspendFolders proc far
uses ax
.enter
pushf
mov ax, UNSUSPEND_UPDATE_STRATEGY
call MarkWindowForUpdate
popf
.leave
ret
UnsuspendFolders endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MarkWindowForUpdate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: checks passed path(s) against all open folder windows
and marks the ones that need to be updated
CALLED BY: INTERNAL
DesktopEndRename
DesktopEndDelete
DesktopEndCreateDir
DesktopEndMove
DesktopEndCopy
PASS: ax - flag for update strategy (FolderWindowUpdateFlags)
mask FWUF_RESCAN_DEST - rescan folder containing
file/directory specified by es:di
mask FWUF_CLOSE_SOURCE - close all folders that are
children of the directory specified
by ds:dx
mask FWUF_CLOSE_DEST - close all folders that are
children of the directory specified
by es:di
mask FWUF_GREY_SOURCE_FILE - grey out source file
in folder window to show file operation
progress
mask FWUF_REDRAW_SOURCE - redraw source folder window
ds:si = FileOperationInfoEntry containing
pathname of renamed file/directory
pathname of newly created directory
pathname of deleted file/directory
pathname of copied file
pathname of moved file
ds:0 = FileQuickTransferHeader
es:di - destination of operation (in thread's current dir)
name of new copy of file
new name of moved file
RETURN: appropriate folder windows marked in global folder window
table.
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
if (FWUF_RESCAN_SOURCE and/or FWUF_CLOSE_SOURCE)
BuildCompletePath(ds:dx, source);
if (FWUF_RESCAN_DEST and/or FWUF_CLOSE_DEST)
BuildCompletePath(es:di, dest);
if (FWUF_RESCAN_SOURCE)
MarkForRescan(source);
if (FWUF_REDRAW_SOURCE)
MarkForRedraw(source);
if (FWUF_GREY_SOURCE_FILE)
GreySourceFile(source);
if (FWUF_CLOSE_SOURCE)
MarkChildrenForClose(source);
if (FWUF_RESCAN_DEST)
MarkForRescan(dest);
if (FWUF_CLOSE_DEST)
MarkChildrenForClose(dest);
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 9/6/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MarkWindowForUpdate proc far
updateFlags local FolderWindowUpdateFlags push ax
updatePath local PathName
uses ax, bx, cx, dx, si, di, ds, es
.enter
EC < test ax, not mask FolderWindowUpdateFlags >
EC < ERROR_NZ BAD_MARK_WINDOW_FOR_UPDATE_FLAGS >
;
; Load up registers for source path
;
test ss:[updateFlags], mask FWUF_DS_IS_FQT_BLOCK
jz checkCurDirSrc
mov ax, ds
mov bx, offset FQTH_pathname
mov cx, ds:[FQTH_diskHandle]
jmp handleSource
checkCurDirSrc:
test ss:[updateFlags], mask FWUF_CUR_DIR_HOLDS_SOURCE
jz checkFCNAsSrc
push ds, si
segmov ds, ss
lea si, ss:[updatePath]
mov cx, size updatePath
call FileGetCurrentPath
mov cx, bx ; cx <- disk handle
mov ax, ds
mov bx, si ; ax:bx <- path
pop ds, si
jmp handleSource
checkFCNAsSrc:
; XXX: FILL THIS IN WHEN APPROPRIATE
ERROR DESKTOP_FATAL_ERROR
;
; Now perform whatever marking is appropriate with the source path
; we've got.
;
handleSource:
mov ss:[updateSrcDiskHandle], cx
test ss:[updateFlags], mask FWUF_REDRAW_SOURCE
jz closeSource
mov dx, mask FTES_REDRAW
call MarkFoldersCommon
closeSource:
test ss:[updateFlags], mask FWUF_CLOSE_SOURCE
jz greySource
;closing is handled by file change notification
; mov dx, mask FTES_CLOSE
; call MarkFoldersCommon
greySource:
test ss:[updateFlags], mask FWUF_GREY_SOURCE_FILE
jz suspendSource
call GreySourceFile
suspendSource:
test ss:[updateFlags], mask FWUF_SUSPEND
jz unsuspendSource
;there is nothing to suspend - brianc 6/9/93
; mov dx, mask FTES_SUSPEND
; call MarkFoldersCommon
unsuspendSource:
test ss:[updateFlags], mask FWUF_UNSUSPEND
jz scanDest
; change to mark as suspended, to ensure unsuspend will happen when
; local standard path is created - brianc 6/9/93
if 0
; mov dx, mask FTES_UNSUSPEND
; call MarkFoldersCommon
else
jmp short handleUnsuspend
endif
scanDest:
;
; Any dest-related things?
;
test ss:[updateFlags], mask FWUF_CLOSE_DEST or \
mask FWUF_SUSPEND or \
mask FWUF_UNSUSPEND
jz done
EC < test ss:[updateFlags], mask FWUF_CUR_DIR_HOLDS_DEST >
EC < ERROR_Z DESKTOP_FATAL_ERROR ; no other option yet >
;
; Fetch current path for passing th marking routines
;
push ds, si
segmov ds, ss
lea si, ss:[updatePath]
mov cx, size updatePath
call FileGetCurrentPath
mov cx, bx
mov ax, ds
mov bx, si
pop ds, si
mov ss:[updateDestDiskHandle], cx
test ss:[updateFlags], mask FWUF_CLOSE_DEST
jz suspendDest
mov dx, mask FTES_CLOSE
call MarkFoldersCommon
suspendDest:
test ss:[updateFlags], mask FWUF_SUSPEND
jz unsuspendDest
;there is nothing to suspend - brianc 6/9/93
; mov dx, mask FTES_SUSPEND
; call MarkFoldersCommon
unsuspendDest:
; change to mark as suspended, to ensure unsuspend will happen when
; local standard path is created - brianc 6/9/93
if 0
test ss:[updateFlags], mask FWUF_UNSUSPEND
jz done
; mov dx, mask FTES_UNSUSPEND
; call MarkFoldersCommon
else
handleUnsuspend:
;
; loop through folders to unsuspend all suspended ones
;
clr di ; start at the beginning...
checkLoop:
; bx:si = folder obj
movdw bxsi, ss:[folderTrackingTable][di].FTE_folder
tst bx ; check if folder here
jz nextFolder ; if not, check next
test ss:[folderTrackingTable][di].FTE_state, mask FTES_SUSPEND
jz nextFolder ; not suspended, check next
andnf ss:[folderTrackingTable][di].FTE_state, not mask FTES_SUSPEND
mov ax, MSG_META_UNSUSPEND
mov di, mask MF_FORCE_QUEUE
call ObjMessage ; else, queue an unsuspend
nextFolder:
add di, size FolderTrackingEntry
cmp di, (size FolderTrackingEntry) * MAX_NUM_FOLDER_WINDOWS
jne checkLoop ; if more, go back and check it
endif
done:
.leave
ret
MarkWindowForUpdate endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MarkFoldersCommon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Mark all folders open to the given path
CALLED BY: MarkWindowForUpdate
PASS: dx = FolderTrackingEntryState to set if
a folder is using the path
cx = disk handle of path to check
ax:bx = path to check
RETURN: nothing
DESTROYED: dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 3/ 3/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MarkFoldersCommon proc near
uses bp, si, ax, bx, cx, es, di
.enter
call ShellAllocPathBuffer ; es:di - buffer in
; which to construct
; actual path
push dx ; FTES
mov ds, ax
mov si, bx
mov bx, cx
clr dx
call FileConstructActualPath
pop ax ; FTES
jc exit
mov bp, di
mov dx, es
mov cx, bx ; cx, dx:bp - actual path
clr di ; start at the beginning...
checkLoop:
; bx:si = folder obj
movdw bxsi, ss:[folderTrackingTable][di].FTE_folder
tst bx ; check if folder here
jz tryNextMarkerInAX ; if not, check next
push ax, di
mov ax, MSG_FOLDER_CHECK_PATH ; compare to this folder
call ObjMessageCall
pop bx, di
jnc markFolder ; match -- always mark
test bx, mask FTES_CLOSE
jz tryNext ; if not close, don't care
; about children
tst ax
jnz tryNext ; not a child, so don't mark
markFolder:
test bx, mask FTES_SUSPEND or mask FTES_UNSUSPEND
jnz actImmediately
ornf ss:[folderTrackingTable][di].FTE_state, bx
test bx, mask FTES_RESCAN or mask FTES_REDRAW
jnz exit ; exit, since only one window
; per folder
tryNext:
mov_tr ax, bx ; ax <- marking bit
tryNextMarkerInAX:
add di, size FolderTrackingEntry
cmp di, (size FolderTrackingEntry) * MAX_NUM_FOLDER_WINDOWS
jne checkLoop ; if more, go back and check it
exit:
call ShellFreePathBuffer
.leave
ret
actImmediately:
;
; Suspend happens right away, while unsuspend gets queued. Neither
; modifies FTE_state. They also can only apply to one folder, so once
; we've called the folder, we're done.
;
test bx, mask FTES_SUSPEND
; change to mark as suspended, to ensure unsuspend will happen when
; local standard path is created - brianc 6/9/93
EC < ERROR_Z DESKTOP_FATAL_ERROR >
test ss:[folderTrackingTable][di].FTE_state, mask FTES_SUSPEND
jnz exit ; already suspended
ornf ss:[folderTrackingTable][di].FTE_state, mask FTES_SUSPEND
mov bx, ss:[folderTrackingTable][di].FTE_folder.handle
mov di, mask MF_CALL
mov ax, MSG_META_SUSPEND
; change to mark as suspended, to ensure unsuspend will happen when
; local standard path is created - brianc 6/9/93
; jnz haveMessage
; mov ax, MSG_META_UNSUSPEND
; mov di, mask MF_FORCE_QUEUE
;haveMessage:
call ObjMessage
jmp exit
MarkFoldersCommon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GreySourceFile
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: greys out file icon in folder window to show progress in
file operation
CALLED BY: INTERNAL
MarkWindowForUpdate
PASS: bp = FolderWinUpdateFlags
if FWUF_DS_IS_FQT_BLOCK:
ds:dx = FileOperationInfoEntry of file
just processed
if FWUF_CUR_DIR_HOLDS_SOURCE
ds:dx = name of file just processed
ax:bx = source path
cx = source disk handle
RETURN: file in folder window grey'ed out
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 12/27/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GreySourceFile proc near
uses cx, dx, bp, si, es, di, bx, ax
.enter
mov si, dx ; ds:si <- src name
CheckHack <offset FOIE_name eq 0>
push ds, si
mov_tr dx, ax
mov bp, bx ; dx:bp <- path against which to compare
;
; search folderTrackingTable for Folder Window corresponding to
; this pathname, if any
;
mov ds, dx ; bx, ds:si - path
mov si, bp
mov bx, cx
call ShellAllocPathBuffer
clr dx
call FileConstructActualPath
mov dx, es ; cx, dx:bp - actual path
mov bp, di
mov cx, bx
clr di
searchLoop:
; bx:si = folder obj
movdw bxsi, ss:[folderTrackingTable][di].FTE_folder
tst bx ; check if folder here
jz tryNext ; if not, check next
mov ax, MSG_FOLDER_CHECK_PATH ; compare to this folder
push di ; window's pathname
call ObjMessageCall
pop di
jc tryNext ; if no match, try next
;
; found Folder Window for this pathname, now send filename to
; associated Folder Object so it can do the grey'ing
; ^lbx:si = Folder Object
; dx:bp = pathname
;
pop dx, bp ; dx:bp <- file
mov ax, MSG_GREY_FILE
call ObjMessageCall ; wait for grey'ing to occur
jmp short exit ; done
tryNext:
add di, size FolderTrackingEntry
cmp di, (size FolderTrackingEntry) * MAX_NUM_FOLDER_WINDOWS
jne short searchLoop ; if more, go back and check it
pop ds, si ; restore FOIE
exit:
call ShellFreePathBuffer
.leave
ret
GreySourceFile endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UpdateMarkedWindows
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: updates the folder windows that are marked for rescan or
for closing
CALLED BY: INTERNAL
DesktopEndRename
DesktopEndDelete
DesktopEndCreateDir
DesktopEndMove
DesktopEndCopy
PASS: ss:[folderTrackingTable] - table of opened folder windows
ss:[updateSrcDiskHandle]
ss:[updateDestDiskHandle]
- src and dest disk handles to update
if no Folder Windows are
actually marked for update
(need to rescan free space)
if 0, do nothing
RETURN: marked windows updated
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
go through all opened folder windows and check if
they are marked for rescan or for close;
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 9/8/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UpdateMarkedWindows proc far
uses bp, di, bx, si, ax, ds
.enter
;
; first, update folder windows
;
clr di ; init index into folder window
; table
UMW_loop:
; bx:si = an open window
movdw bxsi, ss:[folderTrackingTable][di].FTE_folder
tst bx ; check if window here
jz UMW_checkNext ; if not, skip this one
;
; if this disk display in this Folder Window is involved in the
; file operation, flag that the disk's free space needs to
; be rescanned
;
mov ax, ss:[folderTrackingTable][di].FTE_state
call SetExtraUpdateVars
;
; close this folder window, if so marked
;
test ss:[folderTrackingTable][di].FTE_state, mask FTES_CLOSE
jz UMW_rescanCheck ; if not, check for rescan
push di ; save table offset
mov si, FOLDER_OBJECT_OFFSET ; common offset
mov ax, MSG_CLOSE_IF_GONE
call ObjMessageForce ; close it, clears entry from
; tracking table
; queue this so other methods
; for the object are
; processed before it
; goes away
pop di ; retrieve table offset
andnf ss:[folderTrackingTable][di].FTE_state, not \
(mask FTES_CLOSE or mask FTES_RESCAN)
jmp short UMW_checkNext ; if closed, no rescan
;
; rescan this folder window, if so marked
;
UMW_rescanCheck:
test ss:[folderTrackingTable][di].FTE_state, mask FTES_RESCAN
jz UMW_redrawCheck ; if not, check for redraw
push di ; save table offset
mov si, FOLDER_OBJECT_OFFSET ; common offset
mov ax, MSG_RESCAN
call ObjMessageCall ; rescan current directory
mov ax, MSG_REDRAW
call ObjMessageCall ; redraw the window
; clear rescan flag
pop di ; retrieve table offset
andnf ss:[folderTrackingTable][di].FTE_state, \
not (mask FTES_RESCAN or mask FTES_REDRAW)
jmp short UMW_checkNext ; if rescan, no need to redraw
;
; redraw this folder window, if so marked
;
UMW_redrawCheck:
test ss:[folderTrackingTable][di].FTE_state, mask FTES_REDRAW
jz UMW_checkNext ; if not, check next
push di ; save table offset
mov si, FOLDER_OBJECT_OFFSET ; common offset
mov ax, MSG_REDRAW
call ObjMessageCall ; redraw the window
; clear redraw flag
pop di ; retrieve table offset
andnf ss:[folderTrackingTable][di].FTE_state, not (mask FTES_REDRAW)
UMW_checkNext:
add di, size FolderTrackingEntry ; move to next window
; check if end of list
cmp di, MAX_NUM_FOLDER_WINDOWS * (size FolderTrackingEntry)
jne UMW_loop ; if not, go back to check next
.leave
ret
UpdateMarkedWindows endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SetExtraUpdateVars
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: ???
CALLED BY: UpdateMarkedWindows
PASS: ^lbx:si - FolderClass object
ax - FolderTrackingEntryFlags
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 11/20/92 added header
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SetExtraUpdateVars proc near
uses ax, cx, dx, di, bp
.enter
sub sp, size DiskInfoStruct
mov dx, ss
mov bp, sp
push ax ; save update flags
push bp ; save structure pointer
mov ax, MSG_GET_DISK_INFO
call ObjMessageCall ; get disk info for Folder Win.
; ax <- disk handle
pop bp ; ss:bp = DiskInfoStruct
pop cx ; cx = update flags
; will be closed or rescanned?
test cx, mask FTES_CLOSE ; if Folder Window will be
jnz noEffect ; closed, no effect
test cx, mask FTES_RESCAN
jz noScan ; nope
;
; since it's going to be rescanned, we don't need to do seperate
; free-space scan --> clear disk handles to be free-space scanned
;
cmp ax, ss:[updateSrcDiskHandle] ; is it source disk?
jne 10$ ; nope
mov ss:[updateSrcDiskHandle], 0 ; yes, don't need extra update
10$:
cmp ax, ss:[updateDestDiskHandle] ; is it dest disk?
jne 20$ ; nope
mov ss:[updateDestDiskHandle], 0 ; yes, don't need extra update
20$:
noScan:
;
; set flag saying that the src/dest disk handles have a Folder Window
; opened on them (don't want to free-space scan disks involved in file
; operation but don't have any Folder Windows opened on them)
;
cmp ax, ss:[updateSrcDiskHandle] ; is it source disk?
jne 30$ ; nope
mov ss:[updateSrcDiskOpened], TRUE ; yes, flag disk valid
30$:
cmp ax, ss:[updateDestDiskHandle] ; is it dest disk?
jne 40$ ; nope
mov ss:[updateDestDiskOpened], TRUE ; yes, flag disk valid
40$:
noEffect:
add sp, size DiskInfoStruct
.leave
ret
SetExtraUpdateVars endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BroadcastToFolderWindows
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: sends a message to all Folder objects
CALLED BY: UTILITY
PASS: ss:[folderTrackingTable] - table of opened folder windows
ax, cx, dx, bp - message data
di - MessageFlags for ObjMessage
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 01/02/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
BroadcastToFolderWindows proc far
uses ax, bx, cx, dx, bp, si, es, di
.enter
test di, mask MF_FIXUP_DS
jnz fixupDS
push ds
fixupDS:
clr si ; init index into folder window
; table
folderLoop:
mov bx, ss:[folderTrackingTable][si].FTE_folder.handle
tst bx ; check if window here
jz checkNext ; if not, skip this one
;
; send message
;
push ax, cx, dx, bp, di, si ; save message data
;
; If their is a custom callback to check for duplicate
; messages, retrieve it from checkDuplicateProc and put it on
; the stack.
;
test di, mask MF_CUSTOM
jz noCallback
mov bx, es
push bx
mov bx, segment dgroup
mov es, bx
pop bx
push es:[checkDuplicateProc].segment
push es:[checkDuplicateProc].offset
mov es, bx
mov bx, ss:[folderTrackingTable][si].FTE_folder.handle
noCallback:
mov si, ss:[folderTrackingTable][si].FTE_folder.chunk
call ObjMessage
pop ax, cx, dx, bp, di, si ; save method data
checkNext:
add si, size FolderTrackingEntry ; move to next window
; check if end of list
cmp si, MAX_NUM_FOLDER_WINDOWS * (size FolderTrackingEntry)
jne folderLoop ; if not, go back to check next
test di, mask MF_FIXUP_DS
jnz fixedDS
pop ds
fixedDS:
.leave
ret
BroadcastToFolderWindows endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SendToTreeAndBroadcast
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: sends method to Tree Window (if opened) and to all
Folder Windows
CALLED BY: EXTERNAL
PASS: ss:[folderTrackingTable] - table of opened folder windows
ax - method to send
cx, dx, bp - method data
di - MessageFlags for ObjMessage
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 04/05/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SendToTreeAndBroadcast proc far
uses bx, si
.enter
;
; send to tree, if opened
;
if _GMGR
if not _ZMGR
ifndef GEOLAUNCHER ; no Tree Window for GeoLauncher
if _TREE_MENU
cmp ss:[treeRelocated], TRUE ; tree alive?
jne noTree ; nope
test di, mask MF_FIXUP_DS
jnz fixupDS
push ds
fixupDS:
push ax, di, cx, dx, bp ; save method, flags
;
; If their is a custom callback to check for duplicate
; messages, retrieve it from checkDuplicateProc and put it on
; the stack.
;
test di, mask MF_CUSTOM
jz noCallback
mov si, es
mov bx, segment dgroup
mov es, bx
push es:[checkDuplicateProc].segment
push es:[checkDuplicateProc].offset
mov es, si
noCallback:
mov bx, handle TreeObject
mov si, offset TreeObject
call ObjMessage
pop ax, di, cx, dx, bp ; retrieve method, flags
test di, mask MF_FIXUP_DS
jnz fixedDS
pop ds
fixedDS:
noTree:
endif ; if _TREE_MENU
endif ; ifndef GEOLAUNCHER
endif ; if (not _ZMGR)
endif ; if _GMGR
;
; broadcast to Folder Windows
;
call BroadcastToFolderWindows
.leave
ret
SendToTreeAndBroadcast endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GetDiskInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: fetch volume name, free disk space, disk ID for this
disk; reports error if disk not readable and asks for volume
lable if none exists
CALLED BY: INTERNAL
DriveToolStartSelect
PASS: ds:si = pointer to DiskInfoStruct
al = drive number
RETURN: carry set if error (reported)
carry clear otherwise:
bx = disk handle
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 01/02/90 Initial version
brianc 01/15/90 broken out
brianc 03/13/90 rewritten
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GetDiskInfo proc far
uses ax, cx, dx, ds, si, es, di
.enter
;
; attempt to register disk
;
call DiskRegisterDiskSilently
jnc noRegisterError ; if no error, continue
mov ax, ERROR_DRIVE_NOT_READY ; else, report it
error:
call DesktopOKError
stc ; indicate error
jmp done
noRegisterError:
;
; check if volume name exists
; bx = disk handle
;
segmov es, ds ; es:di = volume name field
mov di, si
call DiskGetVolumeInfo
jc error ; if error, report it
done:
.leave
ret
GetDiskInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GetVolumeNameAndFreeSpace
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: fill in volume name and free space fields from disk handle
field in DiskInfoStruct
CALLED BY: INTERNAL
FolderScan (Folder object)
ReadVolumeLabel (Tree object)
PASS: ds:si = DiskInfoStruct
bx = disk handle
RETURN: carry clear if no error
volume name and free space fields filled in
carry set if error (reported)
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 03/06/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GetVolumeNameAndFreeSpace proc far
uses es, di, bx, cx, dx, bp
.enter
;
; Get all the pertinent info at once.
;
segmov es, ds
mov di, si
call DiskGetVolumeInfo
jc error
if _GMGR
;
; Notify anyone interested in the free space for this disk of the
; current amount of free space.
;
mov cx, ds:[si].DIS_freeSpace.high
mov dx, ds:[si].DIS_freeSpace.low
mov di, mask MF_FORCE_QUEUE or mask MF_CHECK_DUPLICATE or \
mask MF_REPLACE
mov ax, MSG_UPDATE_FREE_SPACE
mov bp, bx
call SendToTreeAndBroadcast
clc
endif ; if _GMGR
done:
.leave
ret
error:
call DesktopOKError
jmp done
GetVolumeNameAndFreeSpace endp
;not needed - usability 4/3/90
if 0
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AskForVolumeLabel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: ask user for volume for this disk, adds to disk
CALLED BY: INTERNAL
GetDiskInfo
PASS: bx - disk handle
RETURN: carry clear if successful
carry set otherwise
ax = error code
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 10/5/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AskForVolumeLabel proc near
uses bx, cx, dx, ds, si, es, di, bp
.enter
push bx ; save disk handle
mov bx, handle MiscUI
mov si, offset MiscUI:VolumeNameEntry
NOFXIP< mov dx, cs >
NOFXIP< mov bp, offset nukeVolumeEntry ; clear vol. entry field>
FXIP< clr dx >
FXIP< push dx >
FXIP< mov dx, ss >
FXIP< mov bp, sp ; dx:bp = ptr to null >
call CallSetText
FXIP< pop si ; restore stack >
mov si, offset MiscUI:VolumeNameBox
call UserDoDialog
pop bx ; retrieve disk handle
cmp ax, OKCANCEL_OK ; continue?
clc ; indicate no error
jne AFVL_done ; if not, done
push bx ; save disk handle
mov bx, handle MiscUI
mov si, offset MiscUI:VolumeNameEntry
clr cx ; use global memory block
mov ax, MSG_VIS_TEXT_GET_ALL
call ObjMessageCall ; ax = global mem block w/text
;deal with mapping from GEOS character set to DOS character set
pop bp ; retrieve disk handle
tst cx ; any text?
clc ; indicate no error
jz AFVL_done ; if no text, no vol. label
mov bx, ax ; lock text block
call MemLock ; else, get vol. label
mov ds, ax ; ds:si = new vol label
clr si
spaceLoop:
LocalGetChar ax, dssi ; skip leading spaces
LocalCmpChar ax, ' '
je spaceLoop
dec si ; point at first non-space
DBCS < dec si >
tst al
jz AFVL_done ; if only spaces + null, done
mov bx, bp ; bx = disk handle
call DiskFileSetVolumeName ; exit with error code
AFVL_done:
.leave
ret
AskForVolumeLabel endp
SBCS <nukeVolumeEntry byte 0 >
DBCS <nukeVolumeEntry wchar 0 >
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GetLoadAppGenParent
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: stuff genParent field of AppLaunchBlock
CALLED BY: EXTERNAL
DesktopLoadApplication,
CallApplToGetMoniker,
PASS: dx - handle of AppLaunchBlock
RETURN: ALB_genParent filled
DESTROYED: ax, bx, cx, si, di, bp, ds
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
DS is NO LONGER considered to be a fixupable object block.
It's up to the caller to fixup DS if necessary
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 04/20/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GetLoadAppGenParent proc far
uses es
.enter
;
; query for field to use as ALB_genParent
;
push dx ; save AppLaunchBlock
mov bx, handle Desktop
mov si, offset Desktop
mov ax, MSG_GEN_GUP_QUERY
mov cx, GUQT_FIELD
call ObjMessageCall ; cx:dx = field
EC < ERROR_NC NO_RESPONSE_TO_GUQT_FIELD >
pop bx
call MemLock ; lock AppLaunchBlock
mov es, ax
mov es:[ALB_genParent].handle, cx ; save genParent
mov es:[ALB_genParent].chunk, dx
call MemUnlock
mov dx, bx ; AppLaunchBlock in DX again
.leave
ret
GetLoadAppGenParent endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UtilFormatDateAndTime
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Format a FileDate and FileTime record into a standard
display.
CALLED BY: EXTERNAL
PASS: ax = FileTime
bx = FileDate
es:di = buffer into which to format it
RETURN: buffer null-terminated
cx = # chars in the string w/o null term
DESTROYED: ax
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 2/24/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UtilFormatDateAndTime proc far
uses bx, di, si
.enter
tst bx
jz invalid
;
; Even though the name is LocalFormatFileDateTime, we don't seem to
; have any format that combines the two, so do the formatting
; in two parts, time first.
;
xchg ax, bx ; ax <- date, bx <- time
mov si, DTF_HMS
call LocalFormatFileDateTime
;
; Put space between the time and the date.
;
add di, cx ; es:di=byte after time
DBCS < add di, cx >
mov_tr si, ax ; save date
LocalLoadChar ax, ' ' ; spacing btwn time and date
LocalPutChar esdi, ax
inc cx
LocalPutChar esdi, ax
inc cx
if GPC_NAMES_AND_DETAILS_TITLES
LocalPutChar esdi, ax
inc cx
LocalPutChar esdi, ax
inc cx
endif
push cx
;
; Now format the date appropriately
;
mov_tr ax, si
mov si, DTF_ZERO_PADDED_SHORT
call LocalFormatFileDateTime
pop ax
add cx, ax
done:
.leave
ret
invalid:
;
; Just use a minus sign if the date/time are invalid (as indicated by
; the FileDate being 0)
;
mov ax, '-'
stosw
DBCS < clr ax >
DBCS < stosw >
DBCS < mov cx, 2 >
SBCS < mov cx, 1 >
jmp done
UtilFormatDateAndTime endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckMaxNumFiles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: checkes whether there is enough memory fro new folder
CALLED BY: CreateFolderWindowCommon
PASS: bx - folder's handle
cx - maxNumFiles
dx - numFiles
RETURN: carry set - can't open any more
carry not set - go ahead and open folder
DESTROYED: everything
SIDE EFFECTS: closes on an LRU basis if not enough memory available
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CP 4/20/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if _GMGR
CheckMaxNumFiles proc near
.enter
checkAgain:
; close the oldest window
call CloseOldestWindow
; did we get to last window
jc lastWindow
; see if we need to close another one
mov dx, ss:[numFiles]
cmp cx, dx
jl checkAgain
lastWindow:
.leave
ret
CheckMaxNumFiles endp
endif ; if _GMGR
UtilCode ends
if _PEN_BASED
PseudoResident segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SendAbortQuickTransfer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: stop quick transfer via process thread
CALLED BY: END_OTHER handlers
PASS: ds - fixupable block
es - dgroup
RETURN: nothing
DESTROYED: di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 6/24/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SendAbortQuickTransfer proc far
uses ax, bx
.enter
EC < push ds, bx, ax >
EC < GetResourceSegmentNS dgroup, ds >
EC < mov ax, ds >
EC < mov bx, es >
EC < cmp bx, ax >
EC < ERROR_NE DESKTOP_FATAL_ERROR >
EC < pop ds, bx, ax >
;
; as we are about to send MSG_DESKTOP_ABORT_QUICK_TRANSFER, which
; unconditionally aborts, we can clear the fileDragging flags
; - brianc 6/25/93
;
mov es:[fileDragging], 0
mov es:[delayedFileDraggingEnd], BB_FALSE
mov ax, MSG_DESKTOP_ABORT_QUICK_TRANSFER
mov bx, handle 0
mov di, mask MF_FIXUP_DS
call ObjMessage
.leave
ret
SendAbortQuickTransfer endp
PseudoResident ends
endif
UtilCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UtilCheckReadDirInfo, UtilCheckWriteDirInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: check if dir info file should read/written
CALLED BY: EXTERNAL
PASS: current directory set for folder
RETURN: carry set if should _not_ read/write
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 1/22/98 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UtilCheckReadDirInfo proc far
; first check .ini override?
call UtilCheckDirInfoCommon
ret
UtilCheckReadDirInfo endp
UtilCheckWriteDirInfo proc far
; first check .ini override?
call UtilCheckDirInfoCommon
ret
UtilCheckWriteDirInfo endp
UtilCheckDirInfoCommon proc near
uses ax, bx, cx, dx, di, si, ds, es
.enter
call ShellAlloc2PathBuffers ; es = PathBuffer2
mov cx, size PathName
segmov ds, es, si
mov si, offset PB2_path1
call FileGetCurrentPath ; bx = disk handle
mov di, offset PB2_path2
clr dx ; no drive name
call FileConstructActualPath ; bx = disk handle
jc done ; error, no r/w
call DiskGetDrive ; al = drive
tst al
jz noRW ; no r/w for drive A:
call DriveGetExtStatus ; ax = DriveExtendedStatus
test ax, mask DS_MEDIA_REMOVABLE
jnz noRW ; no r/w for removable
test ax, mask DES_READ_ONLY
jnz noRW ; no r/w for r/o
call FileParseStandardPath ; get StandardPath
cmp ax, SP_NOT_STANDARD_PATH
je noRW ; no r/w for non-StandardPath
clc ; allow r/w
jmp short done
noRW:
stc ; no r/w
done:
call ShellFreePathBuffer ; (flags preserved)
.leave
ret
UtilCheckDirInfoCommon endp
UtilCode ends
|
oeis/343/A343560.asm | neoneye/loda-programs | 11 | 85098 | ; A343560: a(n) = (n-1)*(4*n+1).
; 0,9,26,51,84,125,174,231,296,369,450,539,636,741,854,975,1104,1241,1386,1539,1700,1869,2046,2231,2424,2625,2834,3051,3276,3509,3750,3999,4256,4521,4794,5075,5364,5661,5966,6279,6600,6929,7266,7611,7964,8325
sub $2,$0
mul $2,4
sub $2,2
bin $2,2
mov $0,$2
sub $0,3
div $0,2
|
json.applescript | bevacqua/keynote-extractor | 34 | 3975 | <gh_stars>10-100
-- credit to <NAME>: https://github.com/mgax/applescript-json
on encode(value)
set type to class of value
if type = integer or type = boolean
return value as text
else if type = text
return encodeString(value)
else if type = list
return encodeList(value)
else if type = script
return value's toJson()
else
error "Unknown type " & type
end
end
on encodeList(value_list)
set out_list to {}
repeat with value in value_list
copy encode(value) to end of out_list
end
return "[" & join(out_list, ", ") & "]"
end
on encodeString(value)
set rv to ""
set codepoints to id of value
if (class of codepoints) is not list
set codepoints to {codepoints}
end
repeat with codepoint in codepoints
set codepoint to codepoint as integer
if codepoint = 34
set quoted_ch to "\\\""
else if codepoint = 92 then
set quoted_ch to "\\\\"
else if codepoint >= 32 and codepoint < 127
set quoted_ch to character id codepoint
else
set quoted_ch to "\\u" & hex4(codepoint)
end
set rv to rv & quoted_ch
end
return "\"" & rv & "\""
end
on join(value_list, delimiter)
set original_delimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to delimiter
set rv to value_list as text
set AppleScript's text item delimiters to original_delimiter
return rv
end
on hex4(n)
set digit_list to "0123456789abcdef"
set rv to ""
repeat until length of rv = 4
set digit to (n mod 16)
set n to (n - digit) / 16 as integer
set rv to (character (1+digit) of digit_list) & rv
end
return rv
end
on createDictWith(item_pairs)
set item_list to {}
script Dict
on setkv(key, value)
copy {key, value} to end of item_list
end
on toJson()
set item_strings to {}
repeat with kv in item_list
set key_str to encodeString(item 1 of kv)
set value_str to encode(item 2 of kv)
copy key_str & ": " & value_str to end of item_strings
end
return "{" & join(item_strings, ", ") & "}"
end
end
repeat with pair in item_pairs
Dict's setkv(item 1 of pair, item 2 of pair)
end
return Dict
end
on createDict()
return createDictWith({})
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.