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 |
|---|---|---|---|---|
Keyboard-Maestro/Refactor-Macro.applescript | boisy/AppleScripts | 116 | 2289 | use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
use kl : script "Kevin's Library"
use script "Dialog Toolkit Plus" version "1.1.0"
try
set accViewWidth to 400
set {theButtons, minWidth} to create buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel" with equal widths
if minWidth > accViewWidth then set accViewWidth to minWidth -- make sure buttons fit
-- to make it look better, we can get the length of the longest label we will use, and use that to align the controls
set theLabelStrings to {"Replace This:", "With That:"}
set maxLabelWidth to max width for labels theLabelStrings
set controlLeft to maxLabelWidth + 8
set {replaceField, replaceLabel, theTop, fieldLeft} to create side labeled field "" placeholder text "replace string" left inset 0 bottom (0) total width accViewWidth - 50 label text (item 2 of theLabelStrings) field left controlLeft
set {searchField, searchLabel, theTop, fieldLeft} to create side labeled field "" placeholder text "find string" left inset 0 bottom (theTop + 8) total width accViewWidth - 50 label text (item 1 of theLabelStrings) field left controlLeft
set {messageLabel, theTop} to create label "This will refactor the search string for every action in this macro." bottom theTop + 12 max width accViewWidth control size small size
-- then a bold message
set {boldLabel, theTop} to create label "Refactor Current Macro" bottom theTop + 8 max width accViewWidth control size regular size with bold type
-- make list of cotronls and pass to display command
set allControls to {replaceField, replaceLabel, searchField, searchLabel, boldLabel, messageLabel}
-- controlResults will in the same order as allControls
set {buttonName, controlsResults} to display enhanced window "Refactor Keyboard Maestro" acc view width accViewWidth acc view height theTop acc view controls allControls buttons theButtons initial position {100, 30} giving up after 50 with align cancel button
set {replace, unused, srch, unused, unused, unused} to controlsResults
if buttonName = "Cancel" then return
if srch = "" or srch = missing value then return
tell application "Keyboard Maestro"
set m to first macro whose selected is true
repeat with a in actions of m
set a's xml to kl's SearchandReplace(a's xml, srch, replace)
end repeat
end tell
on error errMsg number errNum
display dialog errMsg & return & return & errNum buttons {"Cancel", "OK"} ¬
default button "OK" with icon caution
end try
|
Lala.g4 | alizand1992/cmpe-152-project-4 | 0 | 1514 | <reponame>alizand1992/cmpe-152-project-4<gh_stars>0
grammar Lala;
program : block;
block : OFB decls stmts CFB;
decls : | decls decl;
decl : type ID SEMI;
type : INT | FLOAT;
stmts : | stmts stmt;
stmt : IF OB allexpr CB stmt | IF OB allexpr CB stmt ELSE stmt | WHILE OB allexpr CB stmt | DO stmt WHILE OB allexpr CB SEMI | FOR OB assign allexpr SEMI incdecexpr CB stmt | BREAK SEMI | block
| assign | print;
assign : ID EQUAL allexpr SEMI;
allexpr : allexpr OR andexpr | andexpr;
andexpr : andexpr AND equal | equal;
equal : equal EQUAL EQUAL rel | equal NOT EQUAL rel | rel;
rel : expr LT expr | expr GTE expr | expr GT expr | expr LTE expr | expr;
expr : expr PLUS term | expr MINUS term | term;
term : term MUL factor | term DIV factor | factor MUL term | factor;
incdecexpr : ID PLUS PLUS| ID MINUS MINUS;
factor : OB allexpr CB | incdecexpr | ID | NUM | REAL;
print: PRINT REAL SEMI | PRINT NUM SEMI | PRINT ID SEMI;
INT : 'int';
FLOAT : 'float';
BOOL : 'bool';
IF : 'if';
WHILE : 'while';
ELSE : 'else';
BREAK : 'break';
FOR : 'for';
DO : 'do';
AND : '&&';
PRINT : 'print';
REAL : '-'?[0-9]+ . [0-9]*[1-9];
NUM : ( '-'?[0] | '-'?[1-9][0-9]*);
TRUE : 'true' | '1';
FALSE : 'false' | '0';
LT : '<';
LTE : '<=';
GTE : '>=';
GT : '>';
PLUS : '+';
MINUS : '-';
MUL : '*';
DIV : '/';
SEMI : ';';
EQUAL : '=';
NOT : '!';
OR : '||';
OB : '(';
CB : ')';
WS : [ \t\r\n]+ -> skip;
OFB : '{';
CFB : '}';
ID : ([a-zA-Z])+;
|
grammar/Aremelle.g4 | gene-levitzky/caremelle | 0 | 7121 | grammar Aremelle;
program
: importStatement* function?
;
importStatement
: IMPORT String DOT
;
function
: DEFINE Identifier COLON functionBody DOT
;
functionBody
: function* ( expression | rewriteRules )
;
rewriteRules
: rewriteRule (SEMICOLON rewriteRule)*
;
rewriteRule
: signatures EQUAL expression
;
expression
: atomicExpression+
;
atomicExpression
: functionCall
| String
| Number
| Identifier
;
functionCall
: Identifier LEFT_PAREN arguments? RIGHT_PAREN
;
arguments
: argument (COMMA argument)*
;
argument
: expression
;
signatures
: signature (BAR signature)*
;
signature
: pattern (COMMA pattern)*
;
pattern
: atomicPattern+
;
atomicPattern
: IdentifierEmpty | Identifier | regexp
;
regexp
: atomicRegexp
| LEFT_BRACE expression RIGHT_BRACE (COLON Identifier)?
;
atomicRegexp
: String | Number
;
/*------------------------------------------------------------------
* LEXER RULES
*------------------------------------------------------------------*/
BAR
: '|'
;
CARET
: '^'
;
COMMA
: ','
;
COLON
: ':'
;
DEFINE
: 'define'
;
fragment DIGIT
: '0'..'9'
;
DOLLAR
: '$'
;
DOT
: '.'
;
EQUAL
: '='
;
IMPORT
: 'import'
;
fragment LETTER
: ('a'..'z' | 'A'..'Z')
;
LEFT_BRACE
: '{'
;
LEFT_PAREN
: '('
;
PAREN
: '"'
;
RIGHT_BRACE
: '}'
;
RIGHT_PAREN
: ')'
;
SEMICOLON
: ';'
;
SLASH
: '/'
;
SPACE
: (' ' | '\t' | '\r' | '\n' | '\u000C')+ -> channel(HIDDEN)
;
Comment
: PAREN StringText PAREN -> channel(HIDDEN)
;
fragment Complex
: Real '+' Real 'i'
;
fragment IdentifierFragment
: LETTER (LETTER | DIGIT)*
;
Identifier
: IdentifierFragment
;
IdentifierEmpty
: DOLLAR IdentifierFragment
;
fragment Integer
: '-'? Natural
;
fragment Natural
: DIGIT+
;
Number
: Natural | Integer | Rational | Real | Complex
| '(' Number ')'
;
fragment Rational
: Integer SLASH Natural
;
fragment Real
: Integer (DOT Integer)?
;
RegexpOperatorBinary
: BAR
;
RegexpOperatorExponent
: CARET
;
RegexpOperatorUnary
: '*' | '+' | '?'
;
String
: '\'' StringText '\''
;
fragment StringText
: .*?
; |
source/amf/mofext/amf-internals-factories-mof_factories.ads | svn2github/matreshka | 24 | 25676 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.CMOF.Associations;
with AMF.CMOF.Classes;
with AMF.CMOF.Data_Types;
with AMF.Factories.MOF_Factories;
with AMF.Links;
with AMF.MOF.Tags;
with League.Holders;
package AMF.Internals.Factories.MOF_Factories is
type MOF_Factory is
limited new AMF.Internals.Factories.Metamodel_Factory_Base
and AMF.Factories.MOF_Factories.MOF_Factory with null record;
overriding function Convert_To_String
(Self : not null access MOF_Factory;
Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class;
Value : League.Holders.Holder) return League.Strings.Universal_String;
overriding function Create
(Self : not null access MOF_Factory;
Meta_Class : not null access AMF.CMOF.Classes.CMOF_Class'Class)
return not null AMF.Elements.Element_Access;
overriding function Create_From_String
(Self : not null access MOF_Factory;
Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class;
Image : League.Strings.Universal_String) return League.Holders.Holder;
overriding function Create_Link
(Self : not null access MOF_Factory;
Association :
not null access AMF.CMOF.Associations.CMOF_Association'Class;
First_Element : not null AMF.Elements.Element_Access;
Second_Element : not null AMF.Elements.Element_Access)
return not null AMF.Links.Link_Access;
overriding function Get_Package
(Self : not null access constant MOF_Factory)
return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package;
function Constructor
(Extent : AMF.Internals.AMF_Extent)
return not null AMF.Factories.Factory_Access;
function Get_Package return not null AMF.CMOF.Packages.CMOF_Package_Access;
function Create_Tag
(Self : not null access MOF_Factory)
return AMF.MOF.Tags.MOF_Tag_Access;
end AMF.Internals.Factories.MOF_Factories;
|
libsrc/fcntl/nc100/creat.asm | meesokim/z88dk | 0 | 93644 | <filename>libsrc/fcntl/nc100/creat.asm
;
; create a file on an Amstrad NC100
;
PUBLIC creat
.creat pop de
pop bc ; don't care
pop hl
push hl
push bc
push de
call 0xB8A5
ret c
ld hl, 0xffff
ret
|
src/cola/parser/CoLa.g4 | Wolff09/seal | 7 | 3306 | grammar CoLa;
/* Parser rules: programs */
program : opts* struct_decl* var_decl* function* EOF ;
opts : '#' ident=Identifier str=String #option ;
struct_decl : ('struct' || 'class') name=Identifier '{' field_decl* '}' (';')? ;
typeName : VoidType #nameVoid
| BoolType #nameBool
| IntType #nameInt
| DataType #nameData
| Identifier #nameIdentifier
;
type : name=typeName #typeValue
| name=typeName '*' #typePointer
;
field_decl : type names+=Identifier (',' names+=Identifier)* ';' ;
var_decl : type names+=Identifier (',' names+=Identifier)* ';' ;
/* Type check for inline function calls:
* - start function call with empty type environment (maybe retain locals if not passed)
* - end of function call takes type of returned pointer(s) from function environment (+ maybe retained locals)
*/
function : (modifier=Inline)? returnType=type name=Identifier '(' args=argDeclList ')' body=scope //'{' var_decl* statement* '}' // TODO: use scope
| modifier=Extern returnType=type name=Identifier '(' args=argDeclList ')' ';'
;
argDeclList : (argTypes+=type argNames+=Identifier (',' argTypes+=type argNames+=Identifier)*)? ;
block : statement #blockStmt
| scope #blockScope
;
scope : '{' var_decl* statement* '}' ;
statement : 'choose' scope+ #stmtChoose
| 'loop' scope #stmtLoop
| annotation? 'atomic' body=block #stmtAtomic
| annotation? 'if' '(' expr=expression ')' bif=block ('else' belse=block)? #stmtIf
| annotation? 'while' '(' expr=expression ')' body=block #stmtWhile
| annotation? 'do' body=block 'while' '(' expr=expression ')' ';' #stmtDo
| annotation? command ';' #stmtCom
;
annotation : '@invariant' '(' invariant ')';
/* Simplifying expression may not yield the desired result.
* It may not correlate temporary variables of @invariant and subsequent assume.
*
* Another problem: if @invariant does not occur atomically together with assume, then the @invariant guarantees get lost.
* ==> interpret @invariant as atomically attached to a command?
*
* Splitting is problematic with invariant, because one needs to spam it for all produced assumes
* ==> just one global variable per expression? then all assumes can be done together.
*/
command : 'skip' #cmdSkip
| lhs=expression '=' rhs=expression #cmdAssign
| lhs=Identifier '=' 'malloc' #cmdMalloc
| 'assume' '(' expr=expression ')' #cmdAssume
| 'assert' '(' expr=invariant ')' #cmdAssert
| 'angel' '(' expr=angelexpr ')' #cmdAngel
| name=Identifier '(' argList ')' #cmdCall // TODO: support enter/exit
| 'continue' #cmdContinue
| 'break' #cmdBreak
| 'return' expr=expression? #cmdReturn
| cas #cmdCas
;
argList : (arg+=expression (',' arg+=expression)*)? ;
cas : 'CAS' '(' dst+=expression ',' cmp+=expression ',' src+=expression ')'
| 'CAS' '(' '<' dst+=expression (',' dst+=expression)* '>' ','
'<' cmp+=expression (',' cmp+=expression)* '>' ','
'<' src+=expression (',' src+=expression)* '>' ',' ')'
;
binop : Eq #opEq
| Neq #opNeq
| Lt #opLt
| Lte #opLte
| Gt #opGt
| Gte #opGte
| And #opAnd
| Or #opOr
;
value : Null #valueNull
| True #valueTrue
| False #valueFalse
| Ndet #valueNDet
| Empty #valueEmpty
| Maxval #valueMax
| Minval #valueMin
;
expression : name=Identifier #exprIdentifier
| value #exprValue
| '(' expr=expression ')' #exprParens
| Neg expr=expression #exprNegation
| expr=expression '->' field=Identifier #exprDeref
| lhs=expression binop rhs=expression #exprBinary
| cas #exprCas
;
invariant : 'active' '(' expr=expression ')' #invActive
| expr=expression #invExpr
;
angelexpr : 'choose' #angelChoose
| 'active' #angelActive
| 'choose active' #angelChooseActive
| 'member' '(' name=Identifier ')' #angelContains
;
/* Parser rules: observers */
observer : obs_def+ EOF #observerList ;
obs_def : 'observer' name=Identifier ('[' (positive='positive' | negative='negative') ']')? '{' var_list state_list trans_list '}' #observerDefinition ;
var_list : 'variables' ':' obs_var* #observerVariableList ;
obs_var : (thread='thread' | pointer='pointer') name=Identifier ';' #observerVariable ;
state_list : 'states' ':' state* #observerStateList ;
state : name=Identifier ('(' verbose=Identifier ')')? ('[' initial='initial' ']')? ('[' final='final' ']')? ';' #observerState ;
trans_list : 'transitions' ':' transition* #observerTransitionList ;
transition : src=Identifier '--' (enter='enter' | exit='exit')? name=Identifier '(' thisguard=guard_expr (',' argsguard+=guard_expr)* ')' '>>' dst=Identifier ';' #observerTransition ;
guard_expr : '*' #observerGuardTrue
| name=Identifier #observerGuardIdentifierEq
| '!' name=Identifier #observerGuardIdentifierNeq
;
/* Lexer rules */
Inline : 'inline' ;
Extern : 'extern' ;
VoidType : 'void' ;
DataType : 'data_t' ;
BoolType : 'bool' ;
IntType : 'int' ;
Null : 'NULL' ;
Empty : 'EMPTY' ;
True : 'true' ;
False : 'false' ;
Ndet : '*' ;
Maxval : 'MAX_VAL' ;
Minval : 'MIN_VAL' ;
Eq : '==' ;
Neq : '!=' ;
Lt : '<' ;
Lte : '<=' ;
Gt : '>' ;
Gte : '>=' ;
And : '&&' ;
Or : '||' ;
Neg : '!' ;
Identifier : Letter ( ('-' | '_')* (Letter | '0'..'9') )* ;
fragment Letter : [a-zA-Z] ;
// Identifier : [a-zA-Z][a-zA-Z0-9_]* ;
String : '"' ~[\r\n]* '"'
| '\'' ~[\r\n]* '\'' ;
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
COMMENT : '/*' .*? '*/' -> channel(HIDDEN) ;
LINE_COMMENT : '//' ~[\r\n]* -> channel(HIDDEN) ;
// UNMATCHED : . -> channel(HIDDEN);
|
src/bitmap.asm | Mario-Kart-Felix/9os | 13 | 86877 | ;-----------------------------------------------------------------------------------------------------
;
; Bitmap rendering here
;
;-----------------------------------------------------------------------------------------------------
;--------------------------------------------
;
; Bitmap structure:
;
; struct bitmap
; {
; short width;
; short height;
; char data[width * height];
; };
;
;--------------------------------------------
;--------------------------------------------
; Draw an animation bitmap
; Parameters: animbitmap, x, y, scale
;--------------------------------------------
drawAnimBitmap:
pusha
mov bp, sp
; Get animbitmap
mov bx, [bp + 12h]
; Get current position
mov ax, [bx]
add ax, 2
add bx, ax
; Check if end of anim
mov cx, [bx]
test cx, cx
jnz drawAnimBitmapDraw
; Reset position to 0
sub bx, ax
add bx, 2
mov ax, 2
drawAnimBitmapDraw:
; Store new position
push bx
mov bx, [bp + 12h]
mov [bx], ax
pop bx
; Scale
mov dx, [bp + 18h]
push dx
; Y coord
mov dx, [bp + 16h]
push dx
; X coord
mov dx, [bp + 14h]
push dx
; Push bitmap
mov bx, [bx]
push bx
call drawBitmap
popa
retn 8
;--------------------------------------------
; Draw a bitmap
; Parameters: bitmap, x, y, scale
;--------------------------------------------
drawBitmap:
pusha
mov bp, sp
xor dx, dx
mov bx, [bp + 12h] ; Get bitmap
add bx, 4h
mov ax, bx
drawBitmapLoop:
xor cx, cx
drawBitmapLoopScaleLoop:
; Push scale
mov bx, [bp + 18h] ; Get scale
push bx
; Push width
mov bx, [bp + 12h] ; Get bitmap
mov bx, [bx] ; Get width
push bx
; Push Y coord
push ax
push dx
mov ax, [bp + 18h] ; Get scale
mul dx
mov bx, [bp + 16h] ; Get Y coordinate
add bx, ax
pop dx
pop ax
add bx, cx
push bx
; Check if exceeding height (not visible, but might overwrite later memory)
push ax
mov ax, [screenHeight]
cmp bx, ax
jl drawBitmapLoopScaleLoopContinue
; Terminate if exceeding
add sp, 8h
jmp drawBitmapFinish
; Continue if not exceeding
drawBitmapLoopScaleLoopContinue:
pop ax
; Push X coord
mov bx, [bp + 14h] ; Get X coordinate
push bx
; Push row buffer/pointer
push ax
call drawBitmapRow
inc cx
mov bx, [bp + 18h] ; Get scale
cmp cx, bx
jl drawBitmapLoopScaleLoop
; Increment buffer position
mov bx, [bp + 12h] ; Get bitmap
mov bx, [bx] ; Get width
add ax, bx
; Increment row num
inc dx
mov bx, [bp + 12h] ; Get bitmap
mov cx, [bx + 2h] ; Get height
cmp dx, cx
jl drawBitmapLoop
drawBitmapFinish:
popa
retn 8
;--------------------------------------------
; Draw a bitmap row
; Parameters: pointer, x, y, width, scale
;--------------------------------------------
drawBitmapRow:
pusha
mov bp, sp
xor cx, cx
drawBitmapRowLoop:
xor dx, dx
drawBitmapRowLoopScaleLoop:
; Check if exceeding width within scale
push dx
mov ax, [bp + 1Ah] ; Get scale
mul cx
mov bx, [bp + 14h] ; Get X coord
add bx, ax
pop dx
add bx, dx
mov ax, [screenWidth]
cmp bx, ax
jge drawBitmapRowFinish
; Push color
mov bx, [bp + 12h] ; Get pointer
add bx, cx
mov bx, word [bx]
; Check if transparent
cmp bl, 10h
je drawBitmapRowLoopPaintDone
push bx
; Push Y coord
mov bx, [bp + 16h] ; Get Y coord
push bx
; Push X coord
push dx
mov ax, [bp + 1Ah] ; Get scale
mul cx
mov bx, [bp + 14h] ; Get X coord
add bx, ax
pop dx
add bx, dx
push bx
call paintPixel
inc dx
; Check if scale loop is done
mov ax, [bp + 1Ah]
cmp dx, ax
jl drawBitmapRowLoopScaleLoop
drawBitmapRowLoopPaintDone:
; Increment counter
inc cx
; Check if row finished
mov bx, [bp + 18h] ; Get width
cmp cx, bx
jge drawBitmapRowFinish
; Return to loop, if no condition applies
jmp drawBitmapRowLoop
drawBitmapRowFinish:
popa
retn 10
|
alloy4fun_models/trashltl/models/11/aoDa5gZQuHptNqN6c.als | Kaixi26/org.alloytools.alloy | 0 | 1881 | <reponame>Kaixi26/org.alloytools.alloy
open main
pred idaoDa5gZQuHptNqN6c_prop12 {
always( all f: File | f not in Trash and eventually f in Trash and after always f in Trash)
}
pred __repair { idaoDa5gZQuHptNqN6c_prop12 }
check __repair { idaoDa5gZQuHptNqN6c_prop12 <=> prop12o } |
programs/oeis/184/A184049.asm | neoneye/loda | 22 | 89285 | ; A184049: T(n,k) is the number of order-preserving and order-decreasing partial isometries (of an n-chain) of height k (height of alpha = |Im(alpha)|).
; 1,1,1,1,3,1,1,6,4,1,1,10,10,5,1,1,15,20,15,6,1,1,21,35,35,21,7,1,1,28,56,70,56,28,8,1,1,36,84,126,126,84,36,9,1,1,45,120,210,252,210,120,45,10,1,1,55,165,330,462,462,330,165,55,11,1,1,66,220
lpb $0
add $2,$1
add $1,1
trn $2,$0
trn $0,$1
lpe
bin $1,$2
mov $0,$1
|
src/spark_unbound.ads | mhatzl/spark_unbound | 8 | 9729 | with Ada.Numerics.Big_Numbers.Big_Integers; use Ada.Numerics.Big_Numbers.Big_Integers;
--- @summary
--- The `Spark_Unbound` package contains various unbound generic data structures.
--- All data structures are formally proven by Spark and `Storage_Error` for heap allocation is handled internally.
---
--- @description
--- The `Spark_Unbound` package contains the following unbound generic data structures:
---
--- - `Unbound_Array`: The package `Spark_Unbound.Arrays` provides the type and functionality for this data structure.
---
--- The functionality for safe heap allocation is provided in the package `Spark_Unbound.Safe_Alloc`.
---
--- The source code is MIT licensed and can be found at: https://github.com/mhatzl/spark_unbound
package Spark_Unbound with SPARK_Mode is
package Long_Integer_To_Big is new Signed_Conversions(Int => Long_Integer);
subtype Long_Natural is Long_Integer range 0 .. Long_Integer'Last;
package Long_Natural_To_Big is new Signed_Conversions(Int => Long_Natural);
subtype Long_Positive is Long_Integer range 1 .. Long_Integer'Last;
package Long_Positive_To_Big is new Signed_Conversions(Int => Long_Positive);
end Spark_Unbound;
|
examples/m68k/amiga_hello_world.asm | rakati/ppci-mirror | 161 | 20126 | <filename>examples/m68k/amiga_hello_world.asm
; Roughly taken from:
; https://github.com/Sakura-IT/Amiga-programming-examples/blob/master/ASM/HelloWorld/helloworld.s
; See also:
; http://amigadev.elowar.com/read/ADCD_2.1/Includes_and_Autodocs_2._guide/node0367.html
; open library
lea dosname, a1
moveq #36, d0 ; version 36 = Kick 2.0
moveal (4).W, a6
jsr (-552, a6) ; -552 = OpenLibrary
lea txt, a6 ; load string name
movel a6, d1 ; d1 = string to print
moveal d0, a6 ; Move dosbase to a6
jsr (-948, a6) ; -948 = PutStr
; close library
moveal a6, a1 ; Library to close
moveal (4).W, a6
jsr (-414, a6) ; -414 = CloseLibrary
; clr.l d0
moveq #0, d0
rts
dosname:
; TODO: ds "dos.library", 0
db 0x64
db 0x6f
db 0x73
db 0x2e
db 0x6c
db 0x69
db 0x62
db 0x72
db 0x61
db 0x72
db 0x79
db 0
txt:
; "Hoi!", 0
db 0x48
db 0x6f
db 0x69
db 0x21
db 0
|
oeis/044/A044388.asm | neoneye/loda-programs | 11 | 82787 | ; A044388: Numbers n such that string 5,6 occurs in the base 10 representation of n but not of n-1.
; Submitted by <NAME>
; 56,156,256,356,456,556,560,656,756,856,956,1056,1156,1256,1356,1456,1556,1560,1656,1756,1856,1956,2056,2156,2256,2356,2456,2556,2560,2656,2756,2856,2956,3056,3156,3256,3356,3456,3556
add $0,1
mul $0,10
add $0,1
mov $1,$0
add $0,6
div $0,11
sub $1,6
div $1,11
mul $1,16
add $1,3
add $0,$1
add $0,4
mul $0,2
add $1,$0
mul $1,2
mov $0,$1
add $0,18
|
programs/oeis/039/A039737.asm | neoneye/loda | 22 | 23995 | <reponame>neoneye/loda
; A039737: a(n)=number of primes q<p having (p mod q)=3, where p=n-th prime.
; 0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,2,1,1,1,1,1,1,1,1,2,1,0,1,1,1,1,2,1,1,2,1,1,1,2,1,1,1,2,1,1,2,1,2,1,1,2,2,1,1,1,2,2,1,2,2,1,1,1,1,1,2,1,2,2,1,2,1,1,1,2,1,2,1,2,1,2,1,1,1,2
seq $0,40 ; The prime numbers.
trn $0,4
seq $0,1221 ; Number of distinct primes dividing n (also called omega(n)).
trn $0,1
|
src/Editor.agda | cruhland/agda-editor | 0 | 5686 | module Editor where
open import Agda.Builtin.FromNat
open import BasicIO
open import Data.Bool
open import Data.Char
open import Data.List hiding (_++_)
open import Data.String
open import Data.Unit
open import Function
open import Int
open import Terminal
readTimeout : Int
readTimeout = 0
readMinChars : Int
readMinChars = 1
attrUpdates : TerminalAttributes → TerminalAttributes
attrUpdates =
(flip withoutMode processInput)
∘ (flip withoutMode enableEcho)
∘ (flip withTime readTimeout)
∘ (flip withMinInput readMinChars)
handleInput : String → IO Bool
handleInput "q" = return false
handleInput cs = termWrite cs >>= const (return true)
parsePath : List (List Char) → IO (List Char)
parsePath (path ∷ []) = return path
parsePath _ = fail (toList "Exactly one file path argument required")
{-# NON_TERMINATING #-}
mainLoop : IO ⊤
mainLoop = do
input ← termRead
continue ← handleInput input
if continue then mainLoop else return tt
setupAndRun : IO ⊤
setupAndRun = do
args ← getArgs
path ← parsePath args
bracket
(termWrite (hideCursor ++ altScreenEnable) >> return tt)
(const (termWrite (altScreenDisable ++ showCursor)))
(const mainLoop)
main : IO ⊤
main = withUpdatedAttributes attrUpdates setupAndRun
|
test/Fail/Issue1944-instance.agda | shlevy/agda | 1,989 | 9586 | <reponame>shlevy/agda
-- Andreas, Issue 1944, <NAME> 2016-04-28
-- A reason why issue 1098 (automatic opening of record modules)
-- cannot easily be fixed
data Bool : Set where
true false : Bool
if_then_else_ : ∀{A : Set} → Bool → A → A → A
if true then t else e = t
if false then t else e = e
record Testable (A : Set) : Set where
field
test : A -> Bool
open Testable {{...}}
open Testable -- overloading projection `test`
mytest : ∀{A} → Testable A → A → Bool
mytest dict = test dict -- Should work.
t : ∀{A}{{_ : Testable A}} → A → A
t = λ x → if test x then x else x
-- This may fail when test is overloaded.
|
vendor/stdlib/src/Algebra/Props/Lattice.agda | isabella232/Lemmachine | 56 | 7776 | ------------------------------------------------------------------------
-- Some derivable properties
------------------------------------------------------------------------
open import Algebra
module Algebra.Props.Lattice (l : Lattice) where
open Lattice l
open import Algebra.Structures
import Algebra.FunctionProperties as P; open P _≈_
import Relation.Binary.EqReasoning as EqR; open EqR setoid
open import Data.Function
open import Data.Product
∧-idempotent : Idempotent _∧_
∧-idempotent x = begin
x ∧ x ≈⟨ refl ⟨ ∧-pres-≈ ⟩ sym (proj₁ absorptive _ _) ⟩
x ∧ (x ∨ x ∧ x) ≈⟨ proj₂ absorptive _ _ ⟩
x ∎
∨-idempotent : Idempotent _∨_
∨-idempotent x = begin
x ∨ x ≈⟨ refl ⟨ ∨-pres-≈ ⟩ sym (∧-idempotent _) ⟩
x ∨ x ∧ x ≈⟨ proj₁ absorptive _ _ ⟩
x ∎
-- The dual construction is also a lattice.
∧-∨-isLattice : IsLattice _≈_ _∧_ _∨_
∧-∨-isLattice = record
{ isEquivalence = isEquivalence
; ∨-comm = ∧-comm
; ∨-assoc = ∧-assoc
; ∨-pres-≈ = ∧-pres-≈
; ∧-comm = ∨-comm
; ∧-assoc = ∨-assoc
; ∧-pres-≈ = ∨-pres-≈
; absorptive = swap absorptive
}
∧-∨-lattice : Lattice
∧-∨-lattice = record
{ _∧_ = _∨_
; _∨_ = _∧_
; isLattice = ∧-∨-isLattice
}
|
mugene-project/mugene/src/commonAntlr/antlr/MugeneParser.g4 | atsushieno/mugene-ng | 2 | 3840 | <reponame>atsushieno/mugene-ng<filename>mugene-project/mugene/src/commonAntlr/antlr/MugeneParser.g4<gh_stars>1-10
parser grammar MugeneParser;
options { tokenVocab=MugeneLexer; }
expressionOrOperationUses :
operationUses
| expression
;
operationUses :
operationUse+
;
operationUse :
canBeIdentifier argumentsOptCurly?
;
argumentsOptCurly :
OpenCurly arguments? CloseCurly
| arguments
;
arguments :
argument (commas arguments)?
;
argument :
expression
;
expression :
conditionalExpr
;
conditionalExpr :
comparisonExpr
| comparisonExpr Question conditionalExpr Comma conditionalExpr
;
comparisonExpr :
addSubExpr
| addSubExpr comparisonOperator comparisonExpr
;
comparisonOperator
: BackSlashLesser
| BackSlashLesserEqual
| BackSlashGreater
| BackSlashGreaterEqual
;
addSubExpr :
mulDivModExpr
| addSubExpr Plus mulDivModExpr
| addSubExpr Caret mulDivModExpr
| addSubExpr Minus mulDivModExpr
;
mulDivModExpr :
primaryExpr
| mulDivModExpr Asterisk primaryExpr
| mulDivModExpr Slash primaryExpr
| mulDivModExpr Percent primaryExpr
;
primaryExpr :
variableReference
| stringConstant
| OpenCurly expression CloseCurly
| stepConstant
| unaryExpr
;
unaryExpr :
Minus numberOrLengthConstant
| Caret numberOrLengthConstant
| numberOrLengthConstant
;
variableReference :
Dollar canBeIdentifier
;
stringConstant :
StringLiteral
;
stepConstant :
Percent NumberLiteral
| Percent Minus NumberLiteral
;
numberOrLengthConstant :
NumberLiteral
| NumberLiteral dots
| dots
;
dots :
Dot
| dots Dot
;
canBeIdentifier :
Identifier
| Colon
| Slash
;
commas :
Comma
| commas Comma
;
|
oeis/165/A165563.asm | neoneye/loda-programs | 11 | 104524 | ; A165563: a(n) = 1 + 2*n + n^2 + 2*n^3 + n^4.
; 1,7,41,151,409,911,1777,3151,5201,8119,12121,17447,24361,33151,44129,57631,74017,93671,117001,144439,176441,213487,256081,304751,360049,422551,492857,571591,659401,756959,864961,984127,1115201,1258951,1416169,1587671,1774297,1976911,2196401,2433679,2689681,2965367,3261721,3579751,3920489,4284991,4674337,5089631,5532001,6002599,6502601,7033207,7595641,8191151,8821009,9486511,10188977,10929751,11710201,12531719,13395721,14303647,15256961,16257151,17305729,18404231,19554217,20757271,22015001
mov $2,1
add $2,$0
pow $2,2
mul $2,$0
add $2,2
mul $0,$2
div $0,2
mul $0,2
add $0,1
|
ESEMPI/11 PROGRAMMA TRASFERIMENTO.asm | Porchetta/py-pdp8-tk | 8 | 640 | <reponame>Porchetta/py-pdp8-tk<gh_stars>1-10
ORG 100 /Trasferisce i dati da X+i a Y+i con i = (0,1,2,3)
BUN L
SBR, ISZ L
ISZ N
L, LDA X
N, STA Y
ISZ CNT
BUN SBR
HLT
CNT, DEC -4
X, DEC 10
DEC 20
DEC 30
DEC 40
Y, DEC 0
DEC 0
DEC 0
DEC 0
END
|
oeis/078/A078711.asm | neoneye/loda-programs | 11 | 167950 | <gh_stars>10-100
; A078711: Sequence is S(infinity), where S(1)={1,2,3}, S(n+1)=S(n)S'(n) and S'(n) is obtained from S(n) by changing last term using the cyclic permutation 1->2->3->1.
; Submitted by <NAME>(s1)
; 1,2,3,1,2,1,1,2,3,1,2,2,1,2,3,1,2,1,1,2,3,1,2,3,1,2,3,1,2,1,1,2,3,1,2,2,1,2,3,1,2,1,1,2,3,1,2,1,1,2,3,1,2,1,1,2,3,1,2,2,1,2,3,1,2,1,1,2,3,1,2,3,1,2,3,1,2,1,1,2,3,1,2,2,1,2,3,1,2,1,1,2,3,1,2,2,1,2,3,1
lpb $0
add $1,1
mod $1,3
mov $2,$0
mod $2,3
sub $2,1
mul $0,$2
div $0,2
lpe
add $1,1
mov $0,$1
|
Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0xca.log_146_1894.asm | ljhsiun2/medusa | 9 | 17530 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x108dc, %rbx
cmp $33654, %rdx
movl $0x61626364, (%rbx)
nop
nop
nop
nop
nop
xor %rcx, %rcx
lea addresses_UC_ht+0x183e7, %rsi
lea addresses_WT_ht+0xdb07, %rdi
cmp %rdx, %rdx
mov $14, %rcx
rep movsw
nop
nop
sub $43088, %rdx
lea addresses_normal_ht+0x5f67, %rsi
lea addresses_WC_ht+0x2f67, %rdi
sub $8462, %rax
mov $9, %rcx
rep movsl
sub $61304, %r9
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r15
push %rax
push %rbx
push %rcx
push %rdx
push %rsi
// Store
lea addresses_A+0xebe7, %rax
cmp %r12, %r12
movw $0x5152, (%rax)
nop
nop
nop
nop
nop
cmp %rbx, %rbx
// Store
lea addresses_A+0x1a7, %r12
xor %rdx, %rdx
mov $0x5152535455565758, %rsi
movq %rsi, %xmm6
movups %xmm6, (%r12)
nop
nop
inc %r15
// Store
lea addresses_PSE+0xdee3, %r12
clflush (%r12)
nop
nop
nop
sub %rcx, %rcx
mov $0x5152535455565758, %rdx
movq %rdx, (%r12)
xor $26409, %r12
// Store
mov $0x6fd1b20000000be7, %rbx
add %rcx, %rcx
mov $0x5152535455565758, %rdx
movq %rdx, (%rbx)
nop
nop
and %r15, %r15
// Store
lea addresses_US+0x2267, %rcx
nop
sub $50296, %rax
movl $0x51525354, (%rcx)
nop
nop
nop
and %r15, %r15
// Load
lea addresses_WC+0x8ee7, %rdx
nop
nop
add %rcx, %rcx
mov (%rdx), %ax
nop
nop
nop
nop
dec %rcx
// Store
lea addresses_PSE+0x7d47, %r15
nop
nop
add %r12, %r12
mov $0x5152535455565758, %rsi
movq %rsi, %xmm0
vmovups %ymm0, (%r15)
nop
nop
nop
inc %rbx
// Faulty Load
lea addresses_UC+0x43e7, %rax
dec %r12
movb (%rax), %dl
lea oracles, %rsi
and $0xff, %rdx
shlq $12, %rdx
mov (%rsi,%rdx,1), %rdx
pop %rsi
pop %rdx
pop %rcx
pop %rbx
pop %rax
pop %r15
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 2, 'NT': True, 'type': 'addresses_A'}}
{'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_A'}}
{'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_PSE'}}
{'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_NC'}}
{'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_US'}}
{'src': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_PSE'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_A_ht'}}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 7, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_WC_ht'}}
{'00': 146}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
programs/oeis/304/A304377.asm | neoneye/loda | 22 | 94342 | ; A304377: a(n) = 102*2^n - 96 (n>=1).
; 108,312,720,1536,3168,6432,12960,26016,52128,104352,208800,417696,835488,1671072,3342240,6684576,13369248,26738592,53477280,106954656,213909408,427818912,855637920,1711275936,3422551968,6845104032,13690208160,27380416416,54760832928,109521665952,219043332000,438086664096,876173328288,1752346656672,3504693313440,7009386626976,14018773254048,28037546508192,56075093016480,112150186033056,224300372066208,448600744132512,897201488265120,1794402976530336,3588805953060768,7177611906121632,14355223812243360,28710447624486816,57420895248973728,114841790497947552,229683580995895200,459367161991790496,918734323983581088,1837468647967162272,3674937295934324640,7349874591868649376,14699749183737298848,29399498367474597792,58798996734949195680,117597993469898391456,235195986939796783008,470391973879593566112,940783947759187132320,1881567895518374264736,3763135791036748529568,7526271582073497059232,15052543164146994118560,30105086328293988237216,60210172656587976474528,120420345313175952949152,240840690626351905898400,481681381252703811796896,963362762505407623593888,1926725525010815247187872,3853451050021630494375840,7706902100043260988751776,15413804200086521977503648,30827608400173043955007392,61655216800346087910014880,123310433600692175820029856,246620867201384351640059808,493241734402768703280119712,986483468805537406560239520,1972966937611074813120479136,3945933875222149626240958368,7891867750444299252481916832,15783735500888598504963833760,31567471001777197009927667616,63134942003554394019855335328,126269884007108788039710670752,252539768014217576079421341600,505079536028435152158842683296,1010159072056870304317685366688,2020318144113740608635370733472,4040636288227481217270741467040,8081272576454962434541482934176,16162545152909924869082965868448,32325090305819849738165931736992,64650180611639699476331863474080,129300361223279398952663726948256
mov $1,2
pow $1,$0
sub $1,1
mul $1,204
add $1,108
mov $0,$1
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48_notsx.log_21829_1647.asm | ljhsiun2/medusa | 9 | 170692 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0xc515, %rbp
nop
nop
and $27626, %rax
and $0xffffffffffffffc0, %rbp
movntdqa (%rbp), %xmm1
vpextrq $1, %xmm1, %r9
nop
nop
nop
nop
nop
sub $41447, %rax
lea addresses_UC_ht+0x16d65, %r10
nop
nop
cmp %rsi, %rsi
mov (%r10), %r9d
nop
nop
nop
sub %r9, %r9
lea addresses_A_ht+0x7115, %rdx
nop
cmp %rcx, %rcx
mov $0x6162636465666768, %r10
movq %r10, %xmm5
vmovups %ymm5, (%rdx)
add $7721, %rcx
lea addresses_UC_ht+0xe815, %r9
nop
dec %rsi
mov $0x6162636465666768, %rdx
movq %rdx, %xmm5
vmovups %ymm5, (%r9)
add %rsi, %rsi
lea addresses_UC_ht+0x14d15, %rsi
nop
nop
nop
nop
cmp $21220, %r10
movl $0x61626364, (%rsi)
nop
nop
nop
inc %r9
lea addresses_normal_ht+0x6d15, %r10
nop
nop
nop
nop
nop
cmp $42026, %rax
movb $0x61, (%r10)
cmp $48393, %rdx
lea addresses_UC_ht+0x1da75, %rsi
lea addresses_normal_ht+0xbf61, %rdi
xor %r10, %r10
mov $78, %rcx
rep movsw
nop
nop
nop
nop
add $22508, %r10
lea addresses_WC_ht+0x4115, %rbp
nop
nop
inc %r10
movw $0x6162, (%rbp)
and %rcx, %rcx
lea addresses_WC_ht+0x10c95, %rsi
lea addresses_UC_ht+0x108d8, %rdi
nop
nop
and %rbp, %rbp
mov $40, %rcx
rep movsb
nop
nop
cmp $33845, %rsi
lea addresses_UC_ht+0x13f8d, %r9
nop
xor %rcx, %rcx
mov $0x6162636465666768, %rdx
movq %rdx, (%r9)
nop
nop
nop
nop
nop
sub $25833, %r10
lea addresses_normal_ht+0x17515, %rax
nop
nop
nop
nop
and %rbp, %rbp
mov (%rax), %di
cmp $38329, %rdx
lea addresses_D_ht+0x1aaa0, %rdi
nop
nop
nop
and $13536, %r10
mov (%rdi), %ecx
and $62186, %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r15
push %r8
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
// Store
lea addresses_D+0x1e9f1, %rdx
clflush (%rdx)
nop
nop
sub %r8, %r8
movw $0x5152, (%rdx)
nop
nop
nop
xor $55694, %r15
// Store
lea addresses_D+0xb0f5, %rdi
cmp $6581, %rsi
mov $0x5152535455565758, %rbx
movq %rbx, %xmm2
movups %xmm2, (%rdi)
nop
nop
nop
nop
xor %r15, %r15
// Store
lea addresses_WT+0x1415, %r8
nop
nop
and $3478, %rdi
movw $0x5152, (%r8)
nop
nop
nop
nop
add %rbp, %rbp
// Load
lea addresses_WC+0x1a515, %rsi
nop
nop
nop
nop
nop
and %rbp, %rbp
mov (%rsi), %edx
nop
sub $41575, %rbp
// Store
lea addresses_WC+0xab15, %r15
and %rdi, %rdi
mov $0x5152535455565758, %rdx
movq %rdx, (%r15)
nop
nop
nop
and %rsi, %rsi
// REPMOV
lea addresses_WC+0x1a15, %rsi
lea addresses_D+0x1d715, %rdi
nop
nop
xor $15612, %r8
mov $16, %rcx
rep movsq
nop
nop
nop
xor %rbp, %rbp
// Load
lea addresses_WT+0x1826d, %rsi
nop
nop
nop
dec %rdi
mov (%rsi), %dx
nop
nop
nop
nop
nop
dec %rcx
// Store
lea addresses_D+0xc47d, %rbx
nop
nop
nop
nop
nop
and %rcx, %rcx
movl $0x51525354, (%rbx)
nop
nop
nop
dec %rbp
// Faulty Load
lea addresses_UC+0x6115, %r8
nop
nop
add %rcx, %rcx
mov (%r8), %bp
lea oracles, %r15
and $0xff, %rbp
shlq $12, %rbp
mov (%r15,%rbp,1), %rbp
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r15
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_UC', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_D', 'congruent': 2}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_D', 'congruent': 4}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_WT', 'congruent': 7}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WC', 'congruent': 9}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WC', 'congruent': 8}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 8, 'type': 'addresses_D'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_WC'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WT', 'congruent': 1}}
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 4, 'type': 'addresses_D', 'congruent': 3}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_UC', 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': True, 'NT': True, 'AVXalign': False, 'size': 16, 'type': 'addresses_WC_ht', 'congruent': 7}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_UC_ht', 'congruent': 4}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A_ht', 'congruent': 11}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_UC_ht', 'congruent': 7}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_UC_ht', 'congruent': 10}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 10}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_UC_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC_ht', 'congruent': 9}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 0, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_WC_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC_ht', 'congruent': 0}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal_ht', 'congruent': 9}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D_ht', 'congruent': 0}}
{'37': 21829}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
src/CORE32/ldexp.asm | masscry/dmc | 86 | 12852 | ;_ ldexp.asm Modified by: <NAME> */
; Written by <NAME>
; Copyright (C) 1984-1991 by <NAME>
; All rights reserved
include macros.asm
include flthead.asm
.287
if _FLAT
begcode double
else
ifdef _MT
extrn __FEEXCEPT:near
endif
begdata
extrn __8087:word
ifndef _MT
extrn __fe_cur_env:word
endif
enddata
begcode double
extrn dunnorm:near, dround:near, dget_dtype:near, exception:near
endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; double ldexp(value,exp)
; double value;
; int exp;
; Returns:
; value*(2**exp)
c_public ldexp
func ldexp
if _RETST0
fild dword ptr PS+8[ESP] ;load exp
fld qword ptr PS[ESP] ;load value
fscale ;ST(0) = ST(0) * (2**ST(1))
fstp ST(1)
_ret 8+4
else
push EBP
mov EBP,ESP
_ifs __8087 e 0, Ld2 ;if 8087 not installed
fild dword ptr P+8[EBP] ;load exp
fld qword ptr P[EBP] ;load value
fscale ;ST(0) = ST(0) * (2**ST(1))
fstp qword ptr P[EBP]
fstp ST ;leave stack as we found it
;(also doing an fwait, MASM doesn't
; recognize fnstp !@#$%^&)
mov EDX,P+4[EBP]
mov EAX,P+0[EBP] ;transfer result to EDX,EAX
pop EBP
ret
Ld2: uses <ESI,EDI>
mov EAX,P+0[EBP]
mov EDX,P+4[EBP] ;transfer double to EDX,EAX
call dget_dtype
jmp dword ptr cs:LdIndex[ESI*4]
LdIndex label word
if _FLAT
dd offset FLAT:LdNormal ;other
dd offset FLAT:LdZero ;zero
dd offset FLAT:LdInfinite ;infinite
dd offset FLAT:LdSNaN ;SNaN
dd offset FLAT:LdQNaN ;QNaN
else
dd LdNormal ;other
dd LdZero ;zero
dd LdInfinite ;infinite
dd LdSNaN ;SNaN
dd LdQNaN ;QNaN
endif
LdNormal:
mov ESI,EDX
and ESI,longexp ;mask off exponent bits
je LdSubNormal
xor EDX,ESI ;clear exponent bits in EDX
shr ESI,20 ;right justify exponent
add ESI,P+8[EBP] ;add exp
jle Ld7 ;test for underflow
cmp ESI,7ffh ;test for overflow
jge Ld6 ;yes
shl ESI,20
; and ESI,longexp ;dump extraneous bits (not necessary)
or EDX,ESI ;install exponent
; jmps LdDone
LdZero:
LdInfinite:
LdQNaN:
LdDone:
unuse <EDI,ESI>
pop EBP
ret
Ld6: ;overflow
mov EDI,EDX
feexcept <FE_OVERFLOW or FE_INEXACT>
call exception ;raise overflow exception
jmps LdDone
Ld7: ;underflow
; AX,BX,CX,DX <<= 11 normalize so dround will work
mov EDI,EDX ;save sign bit
or EDX,longhid
shld EDX,EAX,11
shl EAX,11
call dround
jmps LdDone
LdSNaN:
or EAX,dqnan_bit
feexcept FE_INVALID
jmps LdDone
LdSubNormal: ; do it the slow but safe way
call dunnorm ;unpack
add ESI,P+8[EBP] ;add exp
call dround
jmps LdDone
endif
c_endp ldexp
endcode double
end
|
gstack.adb | tyudosen/DualStack | 0 | 19176 | with Ada.Text_IO; use Ada.Text_IO;
package body gstack is
stack : entries(1..max);
ttop: integer range 0.. max + 1;
stop: integer range 0..max +1;
procedure tpush(x: in item) is
begin
if ttop < (stop -1) then
ttop := ttop + 1;
stack(ttop) := x;
else
put("-----------------------------------------------------------------------------------");new_line;
put("Garagebay Full. Send to Dagobah.");new_line;
put("-----------------------------------------------------------------------------------");new_line;
end if;
--top:= top + 1; s(top):= x;
end tpush;
procedure tpop(x: out item) is
begin
if ttop /= 0 then
x := stack(ttop);
ttop := ttop -1;
else
put("-----------------------------------------------------------------------------------");new_line;
put("There are no Tie Figthers available for repair."); new_line;
put("-----------------------------------------------------------------------------------");new_line;
end if;
end tpop;
procedure spush(x: in item) is
begin
if stop > (ttop +1)
then
stop := stop -1;
stack(stop) := x;
else
put("-----------------------------------------------------------------------------------");new_line;
put("Garagebay Full. Send to Dagobah.");new_line;
put("-----------------------------------------------------------------------------------");new_line;
end if;
end spush;
procedure spop(x: out item) is
begin
if stop < (max +1)
then
x := stack(stop);
stop := stop + 1;
else
put("-----------------------------------------------------------------------------------");new_line;
put("There are no Star Destroyers available for repair.");new_line;
put("-----------------------------------------------------------------------------------");new_line;
end if;
end spop;
function spaceAvail return Boolean is
begin
if ((ttop - 0) + (max - stop) ) > 0
then
return False;
else
return True;
end if;
end spaceAvail;
begin
ttop := 0; -- Sets Tie fighers to empty.
stop := max + 1; -- Sets Star Destroyers to empty.
end gstack; |
orka_plugin_terrain/src/orka-features-terrain-spheres.adb | onox/orka | 52 | 8641 | <filename>orka_plugin_terrain/src/orka-features-terrain-spheres.adb
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <<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.Numerics.Generic_Elementary_Functions;
with GL.Types;
with Orka.Transforms.Singles.Matrices;
package body Orka.Features.Terrain.Spheres is
function Plane_To_Sphere
(Vertex : Orka.Transforms.Singles.Vectors.Vector4;
Parameters : Orka.Features.Terrain.Spheroid_Parameters)
return Orka.Transforms.Singles.Vectors.Vector4
is
package EF is new Ada.Numerics.Generic_Elementary_Functions (GL.Types.Single);
use Orka.Transforms.Singles.Vectors;
Axis : GL.Types.Single renames Parameters (1);
E2 : GL.Types.Single renames Parameters (2);
Y_Mask : GL.Types.Single renames Parameters (3);
Z_Mask : GL.Types.Single renames Parameters (4);
Unit : Vector4 := Vertex * (2.0, 2.0, 1.0, 1.0) - (1.0, 1.0, 0.0, 0.0);
-- Centers the plane
begin
-- World matrix assumes ECEF, meaning:
--
-- z
-- |
-- o--y
-- /
-- x
--
-- So the 3rd element (1.0) must be moved to the 'x' position,
-- and the first two elements (H and V) must be moved to 'y' and 'z'.
Unit := Normalize ((Unit (Z), Unit (X), Unit (Y), 0.0));
Unit (W) := 1.0;
declare
Height : constant GL.Types.Single :=
Length ((Unit (Y), Unit (Z), 0.0, 0.0) * (Y_Mask, Z_Mask, 0.0, 0.0));
N : constant GL.Types.Single :=
Axis / EF.Sqrt (1.0 - E2 * Height * Height);
Scale : Vector4 := ((1.0, 1.0, 1.0, 1.0) - E2 * (0.0, Y_Mask, Z_Mask, 0.0)) * N;
begin
Scale (W) := 1.0;
return Scale * Unit;
end;
end Plane_To_Sphere;
function Get_Sphere_Visibilities
(Parameters : Spheroid_Parameters;
Front, Back, World, View : Orka.Types.Singles.Matrix4)
return GL.Types.Single_Array is
use Orka.Transforms.Singles.Matrices;
World_View : constant Orka.Types.Singles.Matrix4 := View * World;
Vertices : constant array (GL.Types.Size range 0 .. 3) of Orka.Types.Singles.Vector4 :=
(Plane_To_Sphere ((0.0, 0.0, 1.0, 1.0), Parameters),
Plane_To_Sphere ((1.0, 0.0, 1.0, 1.0), Parameters),
Plane_To_Sphere ((0.0, 1.0, 1.0, 1.0), Parameters),
Plane_To_Sphere ((1.0, 1.0, 1.0, 1.0), Parameters));
Faces : constant array (GL.Types.Size range 0 .. 1) of Orka.Types.Singles.Matrix4 :=
(Front, Back);
Result : GL.Types.Single_Array (0 .. 7);
use Orka.Transforms.Singles.Vectors;
use all type GL.Types.Int;
begin
for Index in Result'Range loop
declare
V : Orka.Types.Singles.Vector4 renames Vertices (Index mod 4);
F : Orka.Types.Singles.Matrix4 renames Faces (Index / 4);
-- Vector pointing to vertex from camera or sphere
V_From_C : constant Orka.Types.Singles.Vector4 := World_View * (F * V);
V_From_S : constant Orka.Types.Singles.Vector4 := View * (F * V);
begin
Result (Index) := Dot (Normalize (V_From_C), Normalize (V_From_S));
end;
end loop;
return Result;
end Get_Sphere_Visibilities;
-----------------------------------------------------------------------------
subtype Tile_Index is Positive range 1 .. 6;
subtype Vertex_Index is GL.Types.Size range 0 .. 7;
type Edge_Index is range 1 .. 12;
type Edge_Index_Array is array (Positive range 1 .. 4) of Edge_Index;
type Vertex_Index_Array is array (Positive range 1 .. 2) of Vertex_Index;
type Tile_Index_Array is array (Positive range <>) of Tile_Index;
type Tile_3_Array is array (Vertex_Index) of Tile_Index_Array (1 .. 3);
type Tile_2_Array is array (Edge_Index) of Tile_Index_Array (1 .. 2);
type Edges_Array is array (Tile_Index) of Edge_Index_Array;
type Vertices_Array is array (Edge_Index) of Vertex_Index_Array;
-- The three tiles that are visible when a particular
-- vertex is visible
Vertex_Buffer_Indices : constant Tile_3_Array :=
(0 => (1, 4, 6),
1 => (1, 2, 6),
2 => (1, 4, 5),
3 => (1, 2, 5),
4 => (2, 3, 6),
5 => (3, 4, 6),
6 => (2, 3, 5),
7 => (3, 4, 5));
-- The vertices that form each edge
Edge_Vertex_Indices : constant Vertices_Array :=
(1 => (0, 2),
2 => (1, 3),
3 => (2, 3),
4 => (0, 1),
5 => (4, 6),
6 => (5, 7),
7 => (6, 7),
8 => (4, 5),
9 => (2, 7),
10 => (3, 6),
11 => (0, 5),
12 => (1, 4));
-- The two tiles to which each edge belongs
Edge_Tiles_Indices : constant Tile_2_Array :=
(1 => (1, 4),
2 => (1, 2),
3 => (1, 5),
4 => (1, 6),
5 => (3, 2),
6 => (3, 4),
7 => (3, 5),
8 => (3, 6),
9 => (4, 5),
10 => (2, 5),
11 => (4, 6),
12 => (2, 6));
-- The four edges of each tile
Tile_Edge_Indices : constant Edges_Array :=
(1 => (1, 2, 3, 4),
2 => (2, 5, 10, 12),
3 => (5, 6, 7, 8),
4 => (1, 6, 9, 11),
5 => (3, 7, 9, 10),
6 => (4, 8, 11, 12));
Threshold_A : constant := 0.55;
Threshold_B : constant := 0.25;
function Get_Visible_Tiles
(Visibilities : GL.Types.Single_Array) return Visible_Tile_Array
is
Visible_Tile_Count : array (Tile_Index) of Natural := (others => 0);
Vertex_Visible : Boolean := False;
Result : Visible_Tile_Array := (Tile_Index => False);
begin
-- Heuristic 1: a tile is visible if it surrounds a vertex that is
-- pointing towards the camera
for Vertex in Vertex_Buffer_Indices'Range loop
if Visibilities (Vertex) < 0.0 then
for Tile of Vertex_Buffer_Indices (Vertex) loop
Result (Tile) := True;
end loop;
Vertex_Visible := True;
end if;
end loop;
-- If all vertices point away from the camera, the camera is usually
-- close to some of the tiles
if not Vertex_Visible then
-- Heuristic 2: an edge is visible if the maximum vertex visibility
-- is less than some threshold
for Edge in Edge_Vertex_Indices'Range loop
if (for all Vertex of Edge_Vertex_Indices (Edge) =>
Visibilities (Vertex) < Threshold_A)
then
for Tile of Edge_Tiles_Indices (Edge) loop
Visible_Tile_Count (Tile) := Visible_Tile_Count (Tile) + 1;
end loop;
end if;
end loop;
declare
Max_Count : Natural := 0;
function Average_Visibility (Vertices : Vertex_Index_Array) return GL.Types.Single is
Sum : GL.Types.Single := 0.0;
begin
for Vertex of Vertices loop
Sum := Sum + Visibilities (Vertex);
end loop;
return Sum / GL.Types.Single (Vertices'Length);
end Average_Visibility;
begin
for Tile in Visible_Tile_Count'Range loop
Max_Count := Natural'Max (Max_Count, Visible_Tile_Count (Tile));
end loop;
-- A tile is visible if it has the highest number (1, 2, or 4)
-- of visible edges
--
-- For example, tile 1 might have a count of 4, while its surrounding
-- tiles (2, 4, 5, and 6) have a count of 1. In that case choose to
-- display tile 1.
for Tile in Visible_Tile_Count'Range loop
if Visible_Tile_Count (Tile) = Max_Count then
Result (Tile) := True;
end if;
end loop;
-- Sometimes the camera might be positioned above a tile with count 4
-- and looking at some of its edges. In that case we should render the
-- adjacent tiles as well if those tiles are 'likely' to be visible.
if Max_Count in 2 | 4 then
for Tile in Tile_Edge_Indices'Range loop
if Result (Tile) then
-- Heuristic 3: all tiles that surround an edge of a visible tile
-- with an average vertex visibility less than some threshold
-- are visible as well
for Edge of Tile_Edge_Indices (Tile) loop
if Average_Visibility (Edge_Vertex_Indices (Edge)) < Threshold_B then
for Tile of Edge_Tiles_Indices (Edge) loop
Result (Tile) := True;
end loop;
end if;
end loop;
end if;
end loop;
end if;
end;
end if;
return Result;
end Get_Visible_Tiles;
end Orka.Features.Terrain.Spheres;
|
programs/oeis/170/A170836.asm | karttu/loda | 0 | 9614 | <reponame>karttu/loda
; A170836: First differences of A170837.
; 0,1,4,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16
mov $1,$0
lpb $0,1
mov $0,2
mov $1,4
lpe
pow $1,2
|
programs/oeis/053/A053388.asm | neoneye/loda | 22 | 21932 | <filename>programs/oeis/053/A053388.asm
; A053388: A053398(8, n).
; 3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,5,5,5,5,5,5,5,5,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,6,6,6,6,6,6,6,6,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,5,5,5,5,5,5,5,5,3,3,3,3
div $0,8
add $0,1
lpb $0
dif $0,2
add $1,1
lpe
add $1,3
mov $0,$1
|
word_lists.ads | cborao/Ada-P1-words | 0 | 17639 | with Ada.Strings.Unbounded;
package Word_Lists is
package ASU renames Ada.Strings.Unbounded;
type Cell;
type Word_List_Type is access Cell;
type Cell is record
Word: ASU.Unbounded_String;
Count: Natural := 0;
Next: Word_List_Type;
end record;
Word_List_Error: exception;
procedure Add_Word (List: in out Word_List_Type;
Word: in ASU.Unbounded_String);
procedure Delete_Word (List: in out Word_List_Type;
Word: in ASU.Unbounded_String);
procedure Search_Word (List: in Word_List_Type;
Word: in ASU.Unbounded_String;
Count: out Natural);
procedure Max_Word (List: in Word_List_Type;
Word: out ASU.Unbounded_String;
Count: out Natural);
procedure Print_All (List: in Word_List_Type);
end Word_Lists;
|
awa/plugins/awa-tags/regtests/awa-tags-modules-tests.adb | twdroeger/ada-awa | 81 | 12154 | -----------------------------------------------------------------------
-- awa-tags-modules-tests -- Unit tests for tags module
-- Copyright (C) 2013, 2018 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
with Util.Beans.Basic;
with Util.Beans.Objects;
with Security.Contexts;
with AWA.Users.Models;
with AWA.Services.Contexts;
with AWA.Tests.Helpers.Users;
with AWA.Tags.Beans;
package body AWA.Tags.Modules.Tests is
package Caller is new Util.Test_Caller (Test, "Tags.Modules");
function Create_Tag_List_Bean (Module : in Tag_Module_Access)
return AWA.Tags.Beans.Tag_List_Bean_Access;
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test AWA.Tags.Modules.Add_Tag",
Test_Add_Tag'Access);
Caller.Add_Test (Suite, "Test AWA.Tags.Modules.Remove_Tag",
Test_Remove_Tag'Access);
Caller.Add_Test (Suite, "Test AWA.Tags.Modules.Update_Tags",
Test_Remove_Tag'Access);
end Add_Tests;
function Create_Tag_List_Bean (Module : in Tag_Module_Access)
return AWA.Tags.Beans.Tag_List_Bean_Access is
Bean : constant Util.Beans.Basic.Readonly_Bean_Access
:= AWA.Tags.Beans.Create_Tag_List_Bean (Module);
begin
return AWA.Tags.Beans.Tag_List_Bean'Class (Bean.all)'Access;
end Create_Tag_List_Bean;
-- ------------------------------
-- Test tag creation.
-- ------------------------------
procedure Test_Add_Tag (T : in out Test) is
Sec_Ctx : Security.Contexts.Security_Context;
Context : AWA.Services.Contexts.Service_Context;
begin
AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "<EMAIL>");
declare
Tag_Manager : constant Tag_Module_Access := Get_Tag_Module;
User : constant AWA.Users.Models.User_Ref := Context.Get_User;
List : AWA.Tags.Beans.Tag_List_Bean_Access;
Cleanup : Util.Beans.Objects.Object;
begin
T.Assert (Tag_Manager /= null, "There is no tag module");
List := Create_Tag_List_Bean (Tag_Manager);
Cleanup := Util.Beans.Objects.To_Object (List.all'Access);
List.Set_Value ("entity_type", Util.Beans.Objects.To_Object (String '("awa_user")));
-- Create a tag.
Tag_Manager.Add_Tag (User.Get_Id, "awa_user", "workspaces-create", "user-tag");
Tag_Manager.Add_Tag (User.Get_Id, "awa_user", "workspaces-create", "user-tag");
-- Load the list.
List.Load_Tags (Tag_Manager.Get_Session, User.Get_Id);
Util.Tests.Assert_Equals (T, 1, Integer (List.Get_Count), "Invalid number of tags");
T.Assert (not Util.Beans.Objects.Is_Null (Cleanup), "Cleanup instance is null");
end;
end Test_Add_Tag;
-- ------------------------------
-- Test tag removal.
-- ------------------------------
procedure Test_Remove_Tag (T : in out Test) is
Sec_Ctx : Security.Contexts.Security_Context;
Context : AWA.Services.Contexts.Service_Context;
begin
AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "<EMAIL>");
declare
Tag_Manager : constant Tag_Module_Access := Get_Tag_Module;
User : constant AWA.Users.Models.User_Ref := Context.Get_User;
List : AWA.Tags.Beans.Tag_List_Bean_Access;
Cleanup : Util.Beans.Objects.Object;
begin
T.Assert (Tag_Manager /= null, "There is no tag module");
List := Create_Tag_List_Bean (Tag_Manager);
Cleanup := Util.Beans.Objects.To_Object (List.all'Access);
List.Set_Value ("entity_type", Util.Beans.Objects.To_Object (String '("awa_user")));
Tag_Manager.Add_Tag (User.Get_Id, "awa_user", "workspaces-create", "user-tag-1");
Tag_Manager.Add_Tag (User.Get_Id, "awa_user", "workspaces-create", "user-tag-2");
Tag_Manager.Add_Tag (User.Get_Id, "awa_user", "workspaces-create", "user-tag-3");
Tag_Manager.Remove_Tag (User.Get_Id, "awa_user", "workspaces-create", "user-tag-2");
Tag_Manager.Remove_Tag (User.Get_Id, "awa_user", "workspaces-create", "user-tag-1");
-- Load the list.
List.Load_Tags (Tag_Manager.Get_Session, User.Get_Id);
Util.Tests.Assert_Equals (T, 1, Integer (List.Get_Count), "Invalid number of tags");
T.Assert (not Util.Beans.Objects.Is_Null (Cleanup), "Cleanup instance is null");
end;
end Test_Remove_Tag;
-- ------------------------------
-- Test tag creation and removal.
-- ------------------------------
procedure Test_Update_Tag (T : in out Test) is
Sec_Ctx : Security.Contexts.Security_Context;
Context : AWA.Services.Contexts.Service_Context;
begin
AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "<EMAIL>");
declare
Tag_Manager : constant Tag_Module_Access := Get_Tag_Module;
User : constant AWA.Users.Models.User_Ref := Context.Get_User;
List : AWA.Tags.Beans.Tag_List_Bean_Access;
Cleanup : Util.Beans.Objects.Object;
Tags : Util.Strings.Vectors.Vector;
begin
T.Assert (Tag_Manager /= null, "There is no tag module");
List := Create_Tag_List_Bean (Tag_Manager);
Cleanup := Util.Beans.Objects.To_Object (List.all'Access);
List.Set_Value ("entity_type", Util.Beans.Objects.To_Object (String '("awa_user")));
List.Set_Value ("permission",
Util.Beans.Objects.To_Object (String '("workspace-create")));
-- Add 3 tags.
Tags.Append ("user-tag-1");
Tags.Append ("user-tag-2");
Tags.Append ("user-tag-3");
List.Set_Added (Tags);
List.Update_Tags (User.Get_Id);
-- Load the list.
List.Load_Tags (Tag_Manager.Get_Session, User.Get_Id);
Util.Tests.Assert_Equals (T, 3, Integer (List.Get_Count), "Invalid number of tags");
-- Remove a tag that was not created.
Tags.Append ("user-tag-4");
List.Set_Deleted (Tags);
Tags.Clear;
Tags.Append ("user-tag-5");
List.Set_Added (Tags);
List.Update_Tags (User.Get_Id);
-- 'user-tag-5' is the only tag that should exist now.
List.Load_Tags (Tag_Manager.Get_Session, User.Get_Id);
Util.Tests.Assert_Equals (T, 1, Integer (List.Get_Count), "Invalid number of tags");
T.Assert (not Util.Beans.Objects.Is_Null (Cleanup), "Cleanup instance is null");
end;
end Test_Update_Tag;
end AWA.Tags.Modules.Tests;
|
Cubical/Algebra/Group.agda | Schippmunk/cubical | 0 | 7639 | <filename>Cubical/Algebra/Group.agda<gh_stars>0
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Group where
open import Cubical.Algebra.Group.Base public
open import Cubical.Algebra.Group.Properties public
open import Cubical.Algebra.Group.Morphism public
open import Cubical.Algebra.Group.MorphismProperties public
open import Cubical.Algebra.Group.Algebra public
open import Cubical.Algebra.Group.Action public
-- open import Cubical.Algebra.Group.Higher public
-- open import Cubical.Algebra.Group.EilenbergMacLane1 public
open import Cubical.Algebra.Group.Semidirect public
open import Cubical.Algebra.Group.Notation public
|
fiat-amd64/66.82_ratio12314_seed31939672603401_mul_p224.asm | dderjoel/fiat-crypto | 491 | 7196 | <filename>fiat-amd64/66.82_ratio12314_seed31939672603401_mul_p224.asm
SECTION .text
GLOBAL mul_p224
mul_p224:
sub rsp, 0xc0 ; last 0x30 (6) for Caller - save regs
mov [ rsp + 0x90 ], rbx; saving to stack
mov [ rsp + 0x98 ], rbp; saving to stack
mov [ rsp + 0xa0 ], r12; saving to stack
mov [ rsp + 0xa8 ], r13; saving to stack
mov [ rsp + 0xb0 ], r14; saving to stack
mov [ rsp + 0xb8 ], r15; saving to stack
mov rax, [ rsi + 0x0 ]; load m64 x4 to register64
mov r10, rdx; preserving value of arg2 into a new reg
mov rdx, [ rdx + 0x0 ]; saving arg2[0] in rdx.
mulx r11, rbx, rax; x12, x11<- x4 * arg2[0]
mov rdx, rax; x4 to rdx
mulx rax, rbp, [ r10 + 0x8 ]; x10, x9<- x4 * arg2[1]
mov r12, 0xffffffffffffffff ; moving imm to reg
xchg rdx, r12; 0xffffffffffffffff, swapping with x4, which is currently in rdx
mulx r13, r14, rbx; _, x20<- x11 * 0xffffffffffffffff
mov r13, r14; _, copying x20 here, cause x20 is needed in a reg for other than _, namely all: , _--x34, x22--x23, x26--x27, x24--x25, size: 4
test al, al
adox r13, rbx
adcx rbp, r11
xchg rdx, r12; x4, swapping with 0xffffffffffffffff, which is currently in rdx
mulx r13, r15, [ r10 + 0x10 ]; x8, x7<- x4 * arg2[2]
mov rcx, 0xffffffff00000000 ; moving imm to reg
xchg rdx, rcx; 0xffffffff00000000, swapping with x4, which is currently in rdx
mulx r8, r9, r14; x27, x26<- x20 * 0xffffffff00000000
adox r9, rbp
mov r11, [ rsi + 0x8 ]; load m64 x1 to register64
xchg rdx, r11; x1, swapping with 0xffffffff00000000, which is currently in rdx
mulx rbx, rbp, [ r10 + 0x0 ]; x50, x49<- x1 * arg2[0]
adcx r15, rax
setc al; spill CF x16 to reg (rax)
clc;
adcx rbp, r9
xchg rdx, r12; 0xffffffffffffffff, swapping with x1, which is currently in rdx
mulx r9, r11, rbp; _, x68<- x58 * 0xffffffffffffffff
mov r9, 0xffffffff ; moving imm to reg
xchg rdx, r9; 0xffffffff, swapping with 0xffffffffffffffff, which is currently in rdx
mov [ rsp + 0x0 ], rdi; spilling out1 to mem
mulx r9, rdi, r14; x23, x22<- x20 * 0xffffffff
xchg rdx, r12; x1, swapping with 0xffffffff, which is currently in rdx
mov [ rsp + 0x8 ], r9; spilling x23 to mem
mulx r12, r9, [ r10 + 0x8 ]; x48, x47<- x1 * arg2[1]
mov [ rsp + 0x10 ], r12; spilling x48 to mem
mov r12, 0xffffffffffffffff ; moving imm to reg
xchg rdx, r14; x20, swapping with x1, which is currently in rdx
mov [ rsp + 0x18 ], r13; spilling x8 to mem
mulx rdx, r13, r12; x25, x24<- x20 * 0xffffffffffffffff
xchg rdx, rcx; x4, swapping with x25, which is currently in rdx
mulx rdx, r12, [ r10 + 0x18 ]; x6, x5<- x4 * arg2[3]
mov [ rsp + 0x20 ], rdx; spilling x6 to mem
mov rdx, r11; _, copying x68 here, cause x68 is needed in a reg for other than _, namely all: , x72--x73, _--x82, x74--x75, x70--x71, size: 4
mov [ rsp + 0x28 ], r12; spilling x5 to mem
setc r12b; spill CF x59 to reg (r12)
clc;
adcx rdx, rbp
setc bpl; spill CF x82 to reg (rbp)
clc;
adcx r9, rbx
setc bl; spill CF x52 to reg (rbx)
clc;
adcx r13, r8
mov r8, 0xffffffff ; moving imm to reg
mov rdx, r11; x68 to rdx
mov byte [ rsp + 0x30 ], bl; spilling byte x52 to mem
mulx r11, rbx, r8; x71, x70<- x68 * 0xffffffff
adcx rdi, rcx
adox r13, r15
mov r15, 0xffffffff00000000 ; moving imm to reg
mulx rcx, r8, r15; x75, x74<- x68 * 0xffffffff00000000
setc r15b; spill CF x31 to reg (r15)
clc;
mov [ rsp + 0x38 ], rsi; spilling arg1 to mem
mov rsi, -0x1 ; moving imm to reg
movzx r12, r12b
adcx r12, rsi; loading flag
adcx r13, r9
setc r12b; spill CF x61 to reg (r12)
clc;
movzx rbp, bpl
adcx rbp, rsi; loading flag
adcx r13, r8
mov rbp, rdx; preserving value of x68 into a new reg
mov rdx, [ r10 + 0x18 ]; saving arg2[3] in rdx.
mulx r9, r8, r14; x44, x43<- x1 * arg2[3]
mov rsi, [ rsp + 0x28 ]; load m64 x5 to register64
mov [ rsp + 0x40 ], r13; spilling x83 to mem
setc r13b; spill CF x84 to reg (r13)
clc;
mov [ rsp + 0x48 ], r9; spilling x44 to mem
mov r9, -0x1 ; moving imm to reg
movzx rax, al
adcx rax, r9; loading flag
adcx rsi, [ rsp + 0x18 ]
adox rdi, rsi
mov rax, 0xffffffffffffffff ; moving imm to reg
mov rdx, rbp; x68 to rdx
mulx rdx, rbp, rax; x73, x72<- x68 * 0xffffffffffffffff
movzx rsi, r15b; x32, copying x31 here, cause x31 is needed in a reg for other than x32, namely all: , x32, size: 1
mov r9, [ rsp + 0x8 ]; load m64 x23 to register64
lea rsi, [ rsi + r9 ]; r8/64 + m8
mov r9, [ rsp + 0x20 ]; x19, copying x6 here, cause x6 is needed in a reg for other than x19, namely all: , x19, size: 1
mov r15, 0x0 ; moving imm to reg
adcx r9, r15
adox rsi, r9
xchg rdx, r14; x1, swapping with x73, which is currently in rdx
mulx rdx, r9, [ r10 + 0x10 ]; x46, x45<- x1 * arg2[2]
movzx r15, byte [ rsp + 0x30 ]; load byte memx52 to register64
clc;
mov rax, -0x1 ; moving imm to reg
adcx r15, rax; loading flag
adcx r9, [ rsp + 0x10 ]
setc r15b; spill CF x54 to reg (r15)
clc;
movzx r12, r12b
adcx r12, rax; loading flag
adcx rdi, r9
setc r12b; spill CF x63 to reg (r12)
clc;
adcx rbp, rcx
adcx rbx, r14
seto cl; spill OF x42 to reg (rcx)
inc rax; OF<-0x0, preserve CF (debug: state 2 (y: -1, n: 0))
mov r14, -0x1 ; moving imm to reg
movzx r13, r13b
adox r13, r14; loading flag
adox rdi, rbp
adcx r11, rax
clc;
movzx r15, r15b
adcx r15, r14; loading flag
adcx rdx, r8
mov r13, [ rsp + 0x38 ]; load m64 arg1 to register64
mov r8, [ r13 + 0x10 ]; load m64 x2 to register64
mov r9, [ rsp + 0x48 ]; x57, copying x44 here, cause x44 is needed in a reg for other than x57, namely all: , x57, size: 1
adcx r9, rax
mov r15, [ r13 + 0x18 ]; load m64 x3 to register64
xchg rdx, r8; x2, swapping with x55, which is currently in rdx
mulx rbp, rax, [ r10 + 0x0 ]; x99, x98<- x2 * arg2[0]
mov [ rsp + 0x50 ], r15; spilling x3 to mem
mulx r14, r15, [ r10 + 0x10 ]; x95, x94<- x2 * arg2[2]
clc;
mov [ rsp + 0x58 ], rdi; spilling x85 to mem
mov rdi, -0x1 ; moving imm to reg
movzx r12, r12b
adcx r12, rdi; loading flag
adcx rsi, r8
adox rbx, rsi
movzx r12, cl; x66, copying x42 here, cause x42 is needed in a reg for other than x66, namely all: , x66--x67, size: 1
adcx r12, r9
mulx rcx, r8, [ r10 + 0x8 ]; x97, x96<- x2 * arg2[1]
mulx rdx, r9, [ r10 + 0x18 ]; x93, x92<- x2 * arg2[3]
adox r11, r12
seto sil; spill OF x90 to reg (rsi)
inc rdi; OF<-0x0, preserve CF (debug: state 2 (y: -1, n: 0))
adox r8, rbp
movzx rbp, sil; x91, copying x90 here, cause x90 is needed in a reg for other than x91, namely all: , x91, size: 1
adcx rbp, rdi
clc;
adcx rax, [ rsp + 0x40 ]
adox r15, rcx
adox r9, r14
mov r14, 0xffffffffffffffff ; moving imm to reg
xchg rdx, rax; x107, swapping with x93, which is currently in rdx
mulx r12, rcx, r14; _, x117<- x107 * 0xffffffffffffffff
xchg rdx, r14; 0xffffffffffffffff, swapping with x107, which is currently in rdx
mulx r12, rsi, rcx; x122, x121<- x117 * 0xffffffffffffffff
adox rax, rdi
mov rdi, 0xffffffff00000000 ; moving imm to reg
xchg rdx, rcx; x117, swapping with 0xffffffffffffffff, which is currently in rdx
mov [ rsp + 0x60 ], rax; spilling x106 to mem
mulx rcx, rax, rdi; x124, x123<- x117 * 0xffffffff00000000
mov rdi, [ rsp + 0x58 ]; x109, copying x85 here, cause x85 is needed in a reg for other than x109, namely all: , x109--x110, size: 1
adcx rdi, r8
mov r8, rdx; _, copying x117 here, cause x117 is needed in a reg for other than _, namely all: , _--x131, x119--x120, size: 2
mov [ rsp + 0x68 ], rbp; spilling x91 to mem
mov rbp, -0x2 ; moving imm to reg
inc rbp; OF<-0x0, preserve CF (debug: 6; load -2, increase it, save as -1)
adox r8, r14
mov r8, 0xffffffff ; moving imm to reg
mulx rdx, r14, r8; x120, x119<- x117 * 0xffffffff
adcx r15, rbx
adox rax, rdi
setc bl; spill CF x112 to reg (rbx)
clc;
adcx rsi, rcx
mov rcx, rdx; preserving value of x120 into a new reg
mov rdx, [ r10 + 0x0 ]; saving arg2[0] in rdx.
mulx rdi, rbp, [ rsp + 0x50 ]; x148, x147<- x3 * arg2[0]
adcx r14, r12
mov r12, 0x0 ; moving imm to reg
adcx rcx, r12
clc;
mov r12, -0x1 ; moving imm to reg
movzx rbx, bl
adcx rbx, r12; loading flag
adcx r11, r9
adox rsi, r15
mov rdx, [ rsp + 0x50 ]; x3 to rdx
mulx r9, rbx, [ r10 + 0x8 ]; x146, x145<- x3 * arg2[1]
adox r14, r11
mov r15, [ rsp + 0x60 ]; load m64 x106 to register64
mov r11, [ rsp + 0x68 ]; x115, copying x91 here, cause x91 is needed in a reg for other than x115, namely all: , x115--x116, size: 1
adcx r11, r15
setc r15b; spill CF x116 to reg (r15)
clc;
adcx rbx, rdi
mulx rdi, r12, [ r10 + 0x10 ]; x144, x143<- x3 * arg2[2]
adox rcx, r11
mulx rdx, r11, [ r10 + 0x18 ]; x142, x141<- x3 * arg2[3]
movzx r8, r15b; x140, copying x116 here, cause x116 is needed in a reg for other than x140, namely all: , x140, size: 1
mov [ rsp + 0x70 ], rcx; spilling x138 to mem
mov rcx, 0x0 ; moving imm to reg
adox r8, rcx
mov r15, -0x3 ; moving imm to reg
inc r15; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox rbp, rax
mov rax, 0xffffffffffffffff ; moving imm to reg
xchg rdx, rax; 0xffffffffffffffff, swapping with x142, which is currently in rdx
mulx rcx, r15, rbp; _, x166<- x156 * 0xffffffffffffffff
adox rbx, rsi
adcx r12, r9
mov rcx, r15; _, copying x166 here, cause x166 is needed in a reg for other than _, namely all: , x168--x169, _--x180, x172--x173, x170--x171, size: 4
setc sil; spill CF x152 to reg (rsi)
clc;
adcx rcx, rbp
mov rcx, 0xffffffff00000000 ; moving imm to reg
xchg rdx, r15; x166, swapping with 0xffffffffffffffff, which is currently in rdx
mulx r9, rbp, rcx; x173, x172<- x166 * 0xffffffff00000000
adcx rbp, rbx
adox r12, r14
mulx r14, rbx, r15; x171, x170<- x166 * 0xffffffffffffffff
mov rcx, 0xffffffff ; moving imm to reg
mulx rdx, r15, rcx; x169, x168<- x166 * 0xffffffff
setc cl; spill CF x182 to reg (rcx)
mov [ rsp + 0x78 ], rdx; spilling x169 to mem
seto dl; spill OF x161 to reg (rdx)
mov [ rsp + 0x80 ], r12; spilling x160 to mem
mov r12, rbp; x190, copying x181 here, cause x181 is needed in a reg for other than x190, namely all: , x190--x191, x200, size: 2
sub r12, 0x00000001
mov [ rsp + 0x88 ], r12; spilling x190 to mem
mov r12, -0x2 ; moving imm to reg
inc r12; OF<-0x0, preserve CF (debug: 6; load -2, increase it, save as -1)
adox rbx, r9
adox r15, r14
setc r9b; spill CF x191 to reg (r9)
clc;
movzx rsi, sil
adcx rsi, r12; loading flag
adcx rdi, r11
mov r11, 0x0 ; moving imm to reg
adcx rax, r11
clc;
movzx rdx, dl
adcx rdx, r12; loading flag
adcx rdi, [ rsp + 0x70 ]
adcx rax, r8
setc r8b; spill CF x165 to reg (r8)
clc;
movzx rcx, cl
adcx rcx, r12; loading flag
adcx rbx, [ rsp + 0x80 ]
adcx r15, rdi
mov rsi, [ rsp + 0x78 ]; x178, copying x169 here, cause x169 is needed in a reg for other than x178, namely all: , x178, size: 1
adox rsi, r11
adcx rsi, rax
movzx rcx, r8b; x189, copying x165 here, cause x165 is needed in a reg for other than x189, namely all: , x189, size: 1
adc rcx, 0x0
movzx rdx, r9b; x191, copying x191 here, cause x191 is needed in a reg for other than x191, namely all: , x192--x193, size: 1
add rdx, -0x1
mov r9, rbx; x192, copying x183 here, cause x183 is needed in a reg for other than x192, namely all: , x192--x193, x201, size: 2
mov r14, 0xffffffff00000000 ; moving imm to reg
sbb r9, r14
mov rdi, r15; x194, copying x185 here, cause x185 is needed in a reg for other than x194, namely all: , x194--x195, x202, size: 2
mov r8, 0xffffffffffffffff ; moving imm to reg
sbb rdi, r8
mov rax, rsi; x196, copying x187 here, cause x187 is needed in a reg for other than x196, namely all: , x196--x197, x203, size: 2
mov r11, 0xffffffff ; moving imm to reg
sbb rax, r11
sbb rcx, 0x00000000
cmovc r9, rbx; if CF, x201<- x183 (nzVar)
mov rcx, [ rsp + 0x88 ]; x200, copying x190 here, cause x190 is needed in a reg for other than x200, namely all: , x200, size: 1
cmovc rcx, rbp; if CF, x200<- x181 (nzVar)
cmovc rdi, r15; if CF, x202<- x185 (nzVar)
cmovc rax, rsi; if CF, x203<- x187 (nzVar)
mov rbp, [ rsp + 0x0 ]; load m64 out1 to register64
mov [ rbp + 0x10 ], rdi; out1[2] = x202
mov [ rbp + 0x8 ], r9; out1[1] = x201
mov [ rbp + 0x18 ], rax; out1[3] = x203
mov [ rbp + 0x0 ], rcx; out1[0] = x200
mov rbx, [ rsp + 0x90 ]; restoring from stack
mov rbp, [ rsp + 0x98 ]; restoring from stack
mov r12, [ rsp + 0xa0 ]; restoring from stack
mov r13, [ rsp + 0xa8 ]; restoring from stack
mov r14, [ rsp + 0xb0 ]; restoring from stack
mov r15, [ rsp + 0xb8 ]; restoring from stack
add rsp, 0xc0
ret
; cpu AMD Ryzen 7 5800X 8-Core Processor
; clocked at 2200 MHz
; first cyclecount 86.83, best 65.55, lastGood 66.81666666666666
; seed 31939672603401
; CC / CFLAGS clang / -march=native -mtune=native -O3
; time needed: 642005 ms / 60000 runs=> 10.700083333333334ms/run
; Time spent for assembling and measureing (initial batch_size=119, initial num_batches=101): 131960 ms
; Ratio (time for assembling + measure)/(total runtime for 60000runs): 0.20554357053293978
; number reverted permutation/ tried permutation: 25098 / 29885 =83.982%
; number reverted decision/ tried decision: 21881 / 30116 =72.656% |
ejercicios6/interseccion.adb | iyan22/AprendeAda | 0 | 27134 | <filename>ejercicios6/interseccion.adb
with Datos, Posicion;
use Datos;
function Interseccion (L1, L2 : in Lista ) return Lista is
-- pre:
-- post: se ha insertado el nuevo valor en L de manera ordenada
LI : Lista;
Num : Integer;
begin
crear_lista_vacia(LI);
while L1 /= null loop
while L2 /= null loop
if Num = L2.all.info then
LI : new Nodo;
end Interseccion;
|
projects/batfish/src/main/antlr4/org/batfish/grammar/f5_bigip_structured/F5BigipStructuredLexer.g4 | yrll/batfish-repair | 0 | 7558 | <filename>projects/batfish/src/main/antlr4/org/batfish/grammar/f5_bigip_structured/F5BigipStructuredLexer.g4
lexer grammar F5BigipStructuredLexer;
options {
superClass = 'org.batfish.grammar.f5_bigip_structured.parsing.F5BigipStructuredBaseLexer';
}
tokens {
BACKSLASH_CARRIAGE_RETURN,
BACKSLASH_CHAR,
BACKSLASH_NEWLINE,
BACKSLASH_NEWLINE_WS,
CHARS,
COMMENT,
DOLLAR,
DOUBLE_QUOTED_STRING,
EVENT,
PAREN_LEFT,
PAREN_RIGHT,
PROC,
RULE_SPECIAL,
WHEN
}
// Keywords
ACTION: 'action';
ACTIVATE: 'activate';
ACTIVE_BONUS: 'active-bonus';
ACTIVE_MODULES: 'active-modules';
ADAPTIVE: 'adaptive';
ADDRESS: 'address';
ADDRESS_FAMILY: 'address-family';
ALERT_TIMEOUT: 'alert-timeout';
ALL: 'all';
ALLOW_DYNAMIC_RECORD_SIZING: 'allow-dynamic-record-sizing';
ALLOW_NON_SSL: 'allow-non-ssl';
ALLOW_SERVICE: 'allow-service';
ALWAYS: 'always';
ANALYTICS: 'analytics';
AND: 'and';
ANY: 'any';
APP_SERVICE: 'app-service';
ARP: 'arp';
AUTO_SYNC: 'auto-sync';
BASE_MAC: 'base-mac';
BGP: 'bgp';
BUILD: 'build';
BUNDLE: 'bundle';
BUNDLE_SPEED: 'bundle-speed';
CA_CERT: 'ca-cert';
CA_CERT_BUNDLE: 'ca-cert-bundle';
CA_DEVICES: 'ca-devices';
CA_KEY: 'ca-key';
CACHE_SIZE: 'cache-size';
CACHE_TIMEOUT: 'cache-timeout';
CAPABILITY: 'capability';
CERT: 'cert';
CERT_EXTENSION_INCLUDES: 'cert-extension-includes';
CERT_KEY_CHAIN: 'cert-key-chain';
CERT_LIFESPAN: 'cert-lifespan';
CERT_LOOKUP_BY_IPADDR_PORT: 'cert-lookup-by-ipaddr-port';
CERTIFICATE_AUTHORITY: 'certificate-authority';
CHAIN: 'chain';
CHASSIS_ID: 'chassis-id';
CIPHER_GROUP: 'cipher-group';
CIPHERLIST: 'cipherlist';
CIPHERS: 'ciphers';
CLASSIFICATION: 'classification';
CLIENT_LDAP: 'client-ldap';
CLIENT_SSL: 'client-ssl';
CM: 'cm';
COMMUNITY: 'community';
COMPATIBILITY: 'compatibility';
CONFIGSYNC_IP: 'configsync-ip';
COOKIE: 'cookie';
DATA_GROUP: 'data-group';
DEFAULT: 'default';
DEFAULT_NODE_MONITOR: 'default-node-monitor';
DEFAULTS_FROM: 'defaults-from';
DENY: 'deny';
DESCRIPTION: 'description';
DESTINATION: 'destination';
DEVICE: 'device';
DEVICE_GROUP: 'device-group';
DEVICES: 'devices';
DHCPV4: 'dhcpv4';
DHCPV6: 'dhcpv6';
DIAMETER: 'diameter';
DISABLED: 'disabled';
DNS: 'dns';
DNS_RESOLVER: 'dns-resolver';
DYNAD: 'dynad';
EBGP_MULTIHOP: 'ebgp-multihop';
EDITION: 'edition';
EFFECTIVE_IP: 'effective-ip';
EFFECTIVE_PORT: 'effective-port';
ENABLED: 'enabled';
ENTRIES: 'entries';
EXPIRATION: 'expiration';
EXTERNAL: 'external';
FALL_OVER: 'fall-over';
FALSE: 'false';
FASTHTTP: 'fasthttp';
FASTL4: 'fastl4';
FDB: 'fdb';
FEATURE_MODULE: 'feature-module';
FIX: 'fix';
FOLDER: 'folder';
FORTY_G: '40G';
FORWARD_ERROR_CORRECTION: 'forward-error-correction';
FPGA: 'fpga';
FTP: 'ftp';
GATEWAY_ICMP: 'gateway-icmp';
GENERIC_ALERT: 'generic-alert';
GLOBAL_SETTINGS: 'global-settings';
GTP: 'gtp';
GUI_SECURITY_BANNER_TEXT: 'gui-security-banner-text';
GUI_SETUP: 'gui-setup';
GUID: 'guid';
GW: 'gw';
HA_GROUP: 'ha-group';
HANDSHAKE_TIMEOUT: 'handshake-timeout';
HIDDEN_LITERAL: 'hidden';
HOSTNAME: 'hostname';
HTML: 'html';
HTTP: 'http';
HTTP_COMPRESSION: 'http-compression';
HTTP_PROXY_CONNECT: 'http-proxy-connect';
HTTP2: 'http2';
HTTPD: 'httpd';
HTTPS: 'https';
ICAP: 'icap';
ICMP_ECHO: 'icmp-echo';
IDLE_TIMEOUT_OVERRIDE: 'idle-timeout-override';
IFILE: 'ifile';
INHERIT_CERTKEYCHAIN: 'inherit-certkeychain';
ILX: 'ilx';
INTERFACE: 'interface';
INTERFACES: 'interfaces';
INTERNAL: 'internal';
INTERVAL: 'interval';
IP: 'ip';
IP_DSCP: 'ip-dscp';
IP_FORWARD: 'ip-forward';
IP_PROTOCOL: 'ip-protocol';
IPOTHER: 'ipother';
IPSECALG: 'ipsecalg';
IPV4: 'ipv4';
IPV6: 'ipv6';
KERNEL: 'kernel';
KEY: 'key';
LACP: 'lacp';
LDAP: 'ldap';
LIMIT_TYPE: 'limit-type';
LLDP_ADMIN: 'lldp-admin';
LLDP_GLOBALS: 'lldp-globals';
LLDP_TLVMAP: 'lldp-tlvmap';
LOAD_BALANCING_MODE: 'load-balancing-mode';
LOCAL_AS: 'local-as';
LTM: 'ltm';
MAC: 'mac';
MANAGEMENT_DHCP: 'management-dhcp';
MANAGEMENT_IP: 'management-ip';
MANAGEMENT_ROUTE: 'management-route';
MAP_T: 'map-t';
MARKETING_NAME: 'marketing-name';
MASK: 'mask';
MATCH: 'match';
MATCH_ACROSS_POOLS: 'match-across-pools';
MATCH_ACROSS_SERVICES: 'match-across-services';
MATCH_ACROSS_VIRTUALS: 'match-across-virtuals';
MAX_ACTIVE_HANDSHAKES: 'max-active-handshakes';
MAX_AGE: 'max-age';
MAX_AGGREGATE_RENEGOTIATION_PER_MINUTE: 'max-aggregate-renegotiation-per-minute';
MAX_RENEGOTIATIONS_PER_MINUTE: 'max-renegotiations-per-minute';
MAX_REUSE: 'max-reuse';
MAX_SIZE: 'max-size';
MAXIMUM_PREFIX: 'maximum-prefix';
MAXIMUM_RECORD_SIZE: 'maximum-record-size';
MEMBERS: 'members';
MIN_ACTIVE_MEMBERS: 'min-active-members';
MOD_SSL_METHODS: 'mod-ssl-methods';
MODE: 'mode';
MQTT: 'mqtt';
MONITOR: 'monitor';
NEIGHBOR: 'neighbor';
NET: 'net';
NETFLOW: 'netflow';
NETWORK: 'network';
NETWORK_FAILOVER: 'network-failover';
NODE: 'node';
NTP: 'ntp';
OCSP_STAPLING: 'ocsp-stapling';
OCSP_STAPLING_PARAMS: 'ocsp-stapling-params';
ONE_CONNECT: 'one-connect';
ONE_HUNDRED_G: '100G';
OPTIONAL_MODULES
:
'optional-modules'
;
OPTIONS: 'options';
ORIGINS: 'origins';
OUT: 'out';
OVERRIDE_CONNECTION_LIMIT: 'override-connection-limit';
PCP: 'pcp';
PASSPHRASE: 'passphrase';
PEER_NO_RENEGOTIATE_TIMEOUT: 'peer-no-renegotiate-timeout';
PERMIT: 'permit';
PERSIST: 'persist';
PERSISTENCE: 'persistence';
PLATFORM_ID: 'platform-id';
POOL: 'pool';
POOLS: 'pools';
PORT: 'port';
PPTP: 'pptp';
PREFIX: 'prefix';
PREFIX_LEN_RANGE: 'prefix-len-range';
PREFIX_LIST: 'prefix-list';
PRIORITY_GROUP: 'priority-group';
PRODUCT: 'product';
PROFILE: 'profile';
PROFILES: 'profiles';
PROVISION: 'provision';
PROXY_CA_CERT: 'proxy-ca-cert';
PROXY_CA_KEY: 'proxy-ca-key';
PROXY_SSL: 'proxy-ssl';
PROXY_SSL_PASSTHROUGH: 'proxy-ssl-passthrough';
QOE: 'qoe';
RADIUS: 'radius';
RECV: 'recv';
RECV_DISABLE: 'recv-disable';
REDISTRIBUTE: 'redistribute';
REJECT: 'reject';
REMOTE_AS: 'remote-as';
RENEGOTIATE_MAX_RECORD_DELAY: 'renegotiate-max-record-delay';
RENEGOTIATE_PERIOD: 'renegotiate-period';
RENEGOTIATE_SIZE: 'renegotiate-size';
RENEGOTIATION: 'renegotiation';
REQUEST_ADAPT: 'request-adapt';
REQUEST_LOG: 'request-org.batfish.log';
RESPONDER_URL: 'responder-url';
RESPONSE_ADAPT: 'response-adapt';
REWRITE: 'rewrite';
ROUTE: 'route';
ROUTE_ADVERTISEMENT: 'route-advertisement';
ROUTE_DOMAIN: 'route-domain';
ROUTE_MAP: 'route-map';
ROUTER_ID: 'router-id';
ROUTING: 'routing';
RTSP: 'rtsp';
RULE
:
'rule'
{
if (lastTokenType() == LTM && secondToLastTokenType() == NEWLINE) {
setLtmRuleDeclaration();
setType(RULE_SPECIAL);
}
}
;
RULES: 'rules';
SCTP: 'sctp';
SECURE_RENEGOTIATION: 'secure-renegotiation';
SECURITY: 'security';
SELECTIVE: 'selective';
SELF: 'self';
SELF_ALLOW: 'self-allow';
SELF_DEVICE: 'self-device';
SEND: 'send';
SERVER_LDAP: 'server-ldap';
SERVER_NAME: 'server-name';
SERVER_SSL: 'server-ssl';
SERVERS: 'servers';
SERVICE_DOWN_ACTION: 'service-down-action';
SESSION_MIRRORING: 'session-mirroring';
SESSION_TICKET: 'session-ticket';
SESSION_TICKET_TIMEOUT: 'session-ticket-timeout';
SET: 'set';
SET_SYNC_LEADER: 'set-sync-leader';
SFLOW: 'sflow';
SIGN_HASH: 'sign-hash';
SIP: 'sip';
SLOW_RAMP_TIME: 'slow-ramp-time';
SMTPS: 'smtps';
SNAT: 'snat';
SNAT_TRANSLATION: 'snat-translation';
SNATPOOL: 'snatpool';
SNI_DEFAULT: 'sni-default';
SNI_REQUIRE: 'sni-require';
SNMP: 'snmp';
SOCKS: 'socks';
SOURCE: 'source';
SOURCE_ADDR: 'source-addr';
SOURCE_ADDRESS_TRANSLATION: 'source-address-translation';
SOURCE_MASK: 'source-mask';
SPLITSESSIONCLIENT: 'splitsessionclient';
SPLITSESSIONSERVER: 'splitsessionserver';
SSL: 'ssl';
SSL_FORWARD_PROXY: 'ssl-forward-proxy';
SSL_FORWARD_PROXY_BYPASS: 'ssl-forward-proxy-bypass';
SSL_PROFILE: 'ssl-profile';
SSL_SIGN_HASH: 'ssl-sign-hash';
STATISTICS: 'statistics';
STATUS: 'status';
STATUS_AGE: 'status-age';
STP: 'stp';
STP_GLOBALS: 'stp-globals';
STREAM: 'stream';
STRICT_RESUME: 'strict-resume';
SYNC_FAILOVER: 'sync-failover';
SYNC_ONLY: 'sync-only';
SYS: 'sys';
TAG: 'tag';
TCP: 'tcp';
TCP_ANALYTICS: 'tcp-analytics';
TFTP: 'tftp';
TIME_UNTIL_UP: 'time-until-up';
TIME_ZONE: 'time-zone';
TIMEOUT: 'timeout';
TIMEZONE: 'timezone';
TRAFFIC_ACCELERATION: 'traffic-acceleration';
TRAFFIC_GROUP: 'traffic-group';
TRANSLATE_ADDRESS: 'translate-address';
TRANSLATE_PORT: 'translate-port';
TRUE: 'true';
TRUNK: 'trunk';
TRUNKS: 'trunks';
TRUST_DOMAIN: 'trust-domain';
TRUST_GROUP: 'trust-group';
TRUSTED_RESPONDERS: 'trusted-responders';
TUNNELS: 'tunnels';
TURBOFLEX: 'turboflex';
TYPE: 'type';
UDP: 'udp';
UNCLEAN_SHUTDOWN: 'unclean-shutdown';
UNICAST_ADDRESS: 'unicast-address';
UNIT_ID: 'unit-id';
UPDATE_SOURCE: 'update-source';
VALUE: 'value';
VERSION: 'version';
VIRTUAL: 'virtual';
VIRTUAL_ADDRESS: 'virtual-address';
VLAN: 'vlan';
VLANS: 'vlans';
VLANS_DISABLED: 'vlans-disabled';
VLANS_ENABLED: 'vlans-enabled';
WEB_ACCELERATION: 'web-acceleration';
WEB_SECURITY: 'web-security';
WEBSOCKET: 'websocket';
WEIGHT: 'weight';
XML: 'xml';
// Complex tokens
BRACE_LEFT
:
'{'
{
if (isLtmRuleDeclaration()) {
pushMode(M_Irule);
unsetLtmRuleDeclaration();
}
}
;
BRACE_RIGHT
:
'}'
;
BRACKET_LEFT
:
'['
;
BRACKET_RIGHT
:
']'
;
COMMENT_LINE
:
(
F_Whitespace
)* '#'
{lastTokenType() == NEWLINE || lastTokenType() == -1}?
F_NonNewlineChar* F_Newline+ -> channel ( HIDDEN )
;
COMMENT_TAIL
:
'#' F_NonNewlineChar* -> channel ( HIDDEN )
;
MAC_ADDRESS
:
F_MacAddress
;
VLAN_ID
:
F_VlanId
;
UINT16
:
F_Uint16
;
UINT32
:
F_Uint32
;
DEC
:
F_Digit+
;
DOUBLE_QUOTE
:
'"' -> more, pushMode(M_DoubleQuote)
;
IMISH_CHUNK
:
'!'
{lastTokenType() == NEWLINE}?
F_NonNewlineChar* F_Newline+ F_Anything*
;
IP_ADDRESS
:
F_IpAddress
;
IP_ADDRESS_PORT
:
F_IpAddressPort
;
IP_PREFIX
:
F_IpPrefix
;
IPV6_ADDRESS
:
F_Ipv6Address
;
IPV6_ADDRESS_PORT
:
F_Ipv6AddressPort
;
IPV6_PREFIX
:
F_Ipv6Prefix
;
NEWLINE
:
F_Newline+
;
PARTITION
:
F_Partition
;
SEMICOLON
:
';' -> channel ( HIDDEN )
;
STANDARD_COMMUNITY
:
F_StandardCommunity
;
WORD_PORT
:
F_WordPort
;
WORD_ID
:
F_WordId
;
WORD
:
F_Word
;
WS
:
F_Whitespace+ -> channel ( HIDDEN ) // parser never sees tokens on hidden channel
;
// Fragments
fragment
F_Anything
:
.
;
fragment
F_DecByte
:
F_Digit
| F_PositiveDigit F_Digit
| '1' F_Digit F_Digit
| '2' [0-4] F_Digit
| '25' [0-5]
;
fragment
F_Digit
:
[0-9]
;
fragment
F_BackslashChar
:
~[0-9abfnrtvxuU\r\n]
;
fragment
F_BackslashNewlineWhitespace
:
'\\' F_Newline
(
F_Newline
| F_Whitespace
)*
;
fragment
F_HexDigit
:
[0-9A-Fa-f]
;
fragment
F_HexWord
:
F_HexDigit F_HexDigit? F_HexDigit? F_HexDigit?
;
fragment
F_HexWord2
:
F_HexWord ':' F_HexWord
;
fragment
F_HexWord3
:
F_HexWord2 ':' F_HexWord
;
fragment
F_HexWord4
:
F_HexWord3 ':' F_HexWord
;
fragment
F_HexWord5
:
F_HexWord4 ':' F_HexWord
;
fragment
F_HexWord6
:
F_HexWord5 ':' F_HexWord
;
fragment
F_HexWord7
:
F_HexWord6 ':' F_HexWord
;
fragment
F_HexWord8
:
F_HexWord6 ':' F_HexWordFinal2
;
fragment
F_HexWordFinal2
:
F_HexWord2
| F_IpAddress
;
fragment
F_HexWordFinal3
:
F_HexWord ':' F_HexWordFinal2
;
fragment
F_HexWordFinal4
:
F_HexWord ':' F_HexWordFinal3
;
fragment
F_HexWordFinal5
:
F_HexWord ':' F_HexWordFinal4
;
fragment
F_HexWordFinal6
:
F_HexWord ':' F_HexWordFinal5
;
fragment
F_HexWordFinal7
:
F_HexWord ':' F_HexWordFinal6
;
fragment
F_HexWordLE1
:
F_HexWord?
;
fragment
F_HexWordLE2
:
F_HexWordLE1
| F_HexWordFinal2
;
fragment
F_HexWordLE3
:
F_HexWordLE2
| F_HexWordFinal3
;
fragment
F_HexWordLE4
:
F_HexWordLE3
| F_HexWordFinal4
;
fragment
F_HexWordLE5
:
F_HexWordLE4
| F_HexWordFinal5
;
fragment
F_HexWordLE6
:
F_HexWordLE5
| F_HexWordFinal6
;
fragment
F_HexWordLE7
:
F_HexWordLE6
| F_HexWordFinal7
;
fragment
F_IpAddress
:
F_DecByte '.' F_DecByte '.' F_DecByte '.' F_DecByte
;
fragment
F_IpAddressPort
:
F_IpAddress ':' F_Uint16
;
fragment
F_IpPrefix
:
F_IpAddress '/' F_IpPrefixLength
;
fragment
F_IpPrefixLength
:
F_Digit
| [12] F_Digit
| [3] [012]
;
fragment
F_Ipv6Address
:
'::' F_HexWordLE7
| F_HexWord '::' F_HexWordLE6
| F_HexWord2 '::' F_HexWordLE5
| F_HexWord3 '::' F_HexWordLE4
| F_HexWord4 '::' F_HexWordLE3
| F_HexWord5 '::' F_HexWordLE2
| F_HexWord6 '::' F_HexWordLE1
| F_HexWord7 '::'
| F_HexWord8
;
fragment
F_Ipv6AddressPort
:
F_Ipv6Address '.' F_Uint16
;
fragment
F_Ipv6Prefix
:
F_Ipv6Address '/' F_Ipv6PrefixLength
;
fragment
F_Ipv6PrefixLength
:
F_Digit
| F_PositiveDigit F_Digit
| '1' [01] F_Digit
| '12' [0-8]
;
fragment
F_IruleVarName
:
[0-9A-Za-z_]+
(
'::' [0-9A-Za-z_]+
)*
;
fragment
F_MacAddress
:
F_HexDigit F_HexDigit ':'
F_HexDigit F_HexDigit ':'
F_HexDigit F_HexDigit ':'
F_HexDigit F_HexDigit ':'
F_HexDigit F_HexDigit ':'
F_HexDigit F_HexDigit
;
fragment
F_Newline
:
[\r\n] // carriage return or line feed
;
fragment
F_NonNewlineChar
:
~[\r\n] // carriage return or line feed
;
fragment
F_Partition
:
'/'
(
F_PartitionChar+ '/'
)*
;
fragment
F_PartitionChar
:
F_WordCharCommon
| [:]
;
fragment
F_PositiveDigit
:
'1' .. '9'
;
fragment
F_StandardCommunity
:
F_Uint16 ':' F_Uint16
;
fragment
F_TclIdentifier
:
[a-zA-Z_] [a-zA-Z0-9_]*
;
fragment
F_Uint16
:
// 0-65535
F_Digit
| F_PositiveDigit F_Digit F_Digit? F_Digit?
| [1-5] F_Digit F_Digit F_Digit F_Digit
| '6' [0-4] F_Digit F_Digit F_Digit
| '65' [0-4] F_Digit F_Digit
| '655' [0-2] F_Digit
| '6553' [0-5]
;
fragment
F_Uint32
:
// 0-4294967295
F_Digit
| F_PositiveDigit F_Digit F_Digit? F_Digit? F_Digit? F_Digit? F_Digit?
F_Digit? F_Digit?
| [1-3] F_Digit F_Digit F_Digit F_Digit F_Digit F_Digit F_Digit F_Digit
F_Digit
| '4' [0-1] F_Digit F_Digit F_Digit F_Digit F_Digit F_Digit F_Digit F_Digit
| '42' [0-8] F_Digit F_Digit F_Digit F_Digit F_Digit F_Digit F_Digit
| '429' [0-3] F_Digit F_Digit F_Digit F_Digit F_Digit F_Digit
| '4294' [0-8] F_Digit F_Digit F_Digit F_Digit F_Digit
| '42949' [0-5] F_Digit F_Digit F_Digit F_Digit
| '429496' [0-6] F_Digit F_Digit F_Digit
| '4294967' [0-1] F_Digit F_Digit
| '42949672' [0-8] F_Digit
| '429496729' [0-5]
;
fragment
F_VlanId
:
// 1-4094
F_PositiveDigit F_Digit? F_Digit?
| [1-3] F_Digit F_Digit F_Digit
| '40' [0-8] F_Digit
| '409' [0-4]
;
fragment
F_Whitespace
:
[ \t\u000C] // tab or space or unicode 0x000C
;
fragment
F_Word
:
F_WordCharCommon
(
F_WordChar* F_WordCharCommon
)?
;
fragment
F_WordCharCommon
:
~[ \t\n\r{}[\]/:"]
;
fragment
F_WordChar
:
F_WordCharCommon
| [:/]
;
fragment
F_WordPort
:
F_WordId ':' F_Uint16
;
fragment
F_WordId
:
F_WordCharCommon+
;
mode M_DoubleQuote;
M_DoubleQuote_BODY_CHAR
:
~'"' -> more
;
M_DoubleQuote_DOUBLE_QUOTE
:
'"' -> type(DOUBLE_QUOTED_STRING), popMode
;
M_DoubleQuote_ESCAPED_DOUBLE_QUOTE
:
'\\"' -> more
;
mode M_Irule;
M_Irule_BRACE_RIGHT
:
'}' -> type(BRACE_RIGHT), popMode
;
M_Irule_COMMENT
:
'#' F_NonNewlineChar* F_Newline+ -> channel(HIDDEN)
;
M_Irule_NEWLINE
:
F_Newline+ -> type(NEWLINE)
;
M_Irule_PROC
:
'proc' -> type(PROC), pushMode(M_Proc)
;
M_Irule_WHEN
:
'when' -> type(WHEN), pushMode(M_Event)
;
M_Irule_WS
:
F_Whitespace+ -> channel(HIDDEN)
;
mode M_Proc;
M_Proc_BRACE_LEFT
:
'{' -> type(BRACE_LEFT), mode(M_ProcArgs)
;
M_Proc_CHARS
:
F_IruleVarName -> type(CHARS)
;
M_Proc_WS
:
F_Whitespace+ -> channel(HIDDEN)
;
mode M_ProcArgs;
M_ProcArgs_BRACE_RIGHT
:
'}' -> type(BRACE_RIGHT), mode(M_ProcPostArgs)
;
M_ProcArgs_CHARS
:
F_IruleVarName -> type(CHARS)
;
M_ProcArgs_WS
:
F_Whitespace+ -> channel(HIDDEN)
;
mode M_ProcPostArgs;
M_ProcPostArgs_BRACE_LEFT
:
'{' -> type(BRACE_LEFT), mode(M_Command)
;
M_ProcPostArgs_WS
:
F_Whitespace+ -> channel(HIDDEN)
;
mode M_Event;
M_Event_EVENT
:
~'{'+ -> type(EVENT)
;
M_Event_BRACE_LEFT
:
'{' -> type(BRACE_LEFT), mode(M_Command)
;
mode M_Command;
M_Command_BRACE_LEFT
:
'{' -> pushMode(M_BracedSegment), type(BRACE_LEFT)
;
M_Command_BRACE_RIGHT
:
'}' -> type(BRACE_RIGHT), popMode
;
M_Command_BRACKET_LEFT
:
'[' -> type ( BRACKET_LEFT ) , pushMode ( M_Command )
;
M_Command_BRACKET_RIGHT
:
']' -> type ( BRACKET_RIGHT ) , popMode
;
M_Command_CHARS
:
~[ \t\r\n\\{}[\]$"]+ -> type(CHARS)
;
M_Command_COMMENT
:
'#' F_NonNewlineChar* F_Newline -> type(COMMENT)
;
M_Command_DOLLAR
:
'$' -> type(DOLLAR), pushMode(M_VariableSubstitution)
;
M_Command_DOUBLE_QUOTE
:
'"' -> type(DOUBLE_QUOTE), pushMode(M_DoubleQuotedSegment)
;
M_Command_NEWLINE
:
F_Newline+ -> type(NEWLINE)
;
M_Command_WS
:
[ \t]+ -> type(WS)
;
mode M_BracedSegment;
M_BracedSegment_CHARS
:
~[{}]+ -> type(CHARS)
;
M_BracedSegment_BACKSLASH_NEWLINE_WS
:
F_BackslashNewlineWhitespace -> type(BACKSLASH_NEWLINE_WS)
;
M_BracedSegment_BRACE_LEFT
:
'{' -> pushMode(M_BracedSegment), type(BRACE_LEFT)
;
M_BracedSegment_BRACE_RIGHT
:
'}' -> type(BRACE_RIGHT), popMode
;
mode M_DoubleQuotedSegment;
M_DoubleQuotedSegment_CHARS
:
~[["$\\]+ -> type(CHARS)
;
M_DoubleQuotedSegment_BACKSLASH_CARRIAGE_RETURN
:
'\\r' -> type(BACKSLASH_CARRIAGE_RETURN)
;
M_DoubleQuotedSegment_BACKSLASH_CHAR
:
'\\' F_BackslashChar -> type(BACKSLASH_CHAR)
;
M_DoubleQuotedSegment_BACKSLASH_NEWLINE
:
'\\n' -> type(BACKSLASH_NEWLINE)
;
M_DoubleQuotedSegment_BACKSLASH_NEWLINE_WS
:
F_BackslashNewlineWhitespace -> type(BACKSLASH_NEWLINE_WS)
;
M_DoubleQuotedSegment_BRACKET_LEFT
:
'[' -> type(BRACKET_LEFT), pushMode(M_Command)
;
M_DoubleQuotedSegment_DOLLAR
:
'$' -> type(DOLLAR), pushMode(M_VariableSubstitution)
;
M_DoubleQuotedSegment_DOUBLE_QUOTE
:
'"' -> type(DOUBLE_QUOTE), popMode
;
mode M_VariableSubstitution;
M_VariableSubstitution_BACKSLASH
:
'\\'
{
less();
} -> popMode
;
M_VariableSubstitution_BRACE_LEFT
:
'{' -> type(BRACE_LEFT), pushMode(M_BracedVariableSubstitution)
;
M_VariableSubstitution_BRACKET_RIGHT
:
']'
{
less();
} -> popMode
;
M_VariableSubstitution_CHARS
:
F_IruleVarName -> type(CHARS)
;
M_VariableSubstitution_DOLLAR
:
// kinda screwed here
'$' -> type(DOLLAR), popMode
;
M_VariableSubstitution_DOUBLE_QUOTE
:
'"'
{
less();
} -> popMode
;
M_VariableSubstitution_NEWLINE
:
F_Newline+ -> type(NEWLINE), popMode
;
M_VariableSubstitution_WS
:
F_Whitespace+ -> type(WS), popMode
;
mode M_BracedVariableSubstitution;
M_BracedVariableSubstitution_BRACE_RIGHT
:
'}' -> type(BRACE_RIGHT), popMode
;
M_BracedVariableSubstitution_CHARS
:
~'}'+ -> type(CHARS)
;
|
src/main/antlr4/botGrammar/BotOperations.g4 | marvin1997/Refactoring-Bot | 54 | 7915 | grammar BotOperations;
@parser::members
{
public java.util.HashMap<String, Double> memory = new java.util.HashMap<String, Double>();
@Override
public void notifyErrorListeners(Token offendingToken, String msg, RecognitionException ex)
{
throw new RuntimeException(msg);
}
}
@lexer::members
{
@Override
public void recover(RecognitionException ex)
{
throw new RuntimeException(ex.getMessage());
}
}
botCommand: USERNAME WHITESPACE REFACTORING EOF;
REFACTORING: (ADD | RENAME | REORDER | REMOVE);
ADD: 'ADD' WHITESPACE ADDKIND;
RENAME: 'RENAME' WHITESPACE RENAMEKIND WHITESPACE 'TO' WHITESPACE WORD;
REORDER: 'REORDER' WHITESPACE REORDERKIND;
REMOVE: 'REMOVE' WHITESPACE REMOVEKIND;
ADDKIND: ANNOTATION;
REORDERKIND: 'MODIFIER';
REMOVEKIND: PARAMETER;
RENAMEKIND: 'METHOD';
ANNOTATION: 'ANNOTATION' WHITESPACE SUPPORTEDANNOTATIONS;
SUPPORTEDANNOTATIONS: 'Override';
PARAMETER: 'PARAMETER' WHITESPACE WORD;
WORD: (LOWERCASE | UPPERCASE)+;
USERNAME: (UPPERCASE | LOWERCASE | NUMBER | SYMBOL)+;
fragment UPPERCASE: [A-Z];
fragment LOWERCASE: [a-z];
DIGIT: [0-9]+;
NUMBER: [0-9];
SYMBOL: ('-' | '_' | '%' | '&' | '/' | 'ß' | '@');
WHITESPACE: ' '; |
test/interaction/Issue3353.agda | cruhland/agda | 1,989 | 7465 | <reponame>cruhland/agda
-- Andreas, 2018-11-23, 2019-07-22, issue #3353
--
-- Preserved names of named arguments under case splitting.
-- {-# OPTIONS -v tc.lhs:40 #-}
-- {-# OPTIONS -v interaction.case:60 -v reify:30 #-}
open import Agda.Builtin.Nat
test : {m n : Nat} → Nat
test {m} {n = n} = {!n!} -- C-c C-c
-- Splitting on n gives:
-- test {m} {zero} = {!!}
-- test {m} {suc n} = {!!}
-- Expected:
-- test {m} {n = zero} = {!!}
-- test {m} {n = suc n} = {!!}
data Vec (A : Set) : Nat → Set where
_∷_ : ∀{n} (x : A) (xs : Vec A n) → Vec A (suc n)
foo : ∀{A n} → Vec A n → Vec A n
foo (_∷_ {n = n} x xs) = {!n!} -- C-c C-c
-- Expected:
-- foo (_∷_ {n = suc n} x xs) = {!!}
|
ADL/drivers/stm32g474/stm32-timers.adb | JCGobbi/Nucleo-STM32G474RE | 0 | 23830 | <gh_stars>0
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_tim.c --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief timers HAL module driver. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
with STM32.Device;
package body STM32.Timers is
---------------
-- Configure --
---------------
procedure Configure
(This : in out Timer;
Prescaler : UInt16;
Period : UInt32)
is
begin
This.ARR := Period;
This.Prescaler := Prescaler;
end Configure;
---------------
-- Configure --
---------------
procedure Configure
(This : in out Timer;
Prescaler : UInt16;
Period : UInt32;
Clock_Divisor : Timer_Clock_Divisor;
Counter_Mode : Timer_Counter_Alignment_Mode)
is
begin
This.ARR := Period;
This.Prescaler := Prescaler;
This.CR1.Clock_Division := Clock_Divisor;
This.CR1.Mode_And_Dir := Counter_Mode;
end Configure;
----------------------
-- Set_Counter_Mode --
----------------------
procedure Set_Counter_Mode
(This : in out Timer;
Value : Timer_Counter_Alignment_Mode)
is
begin
This.CR1.Mode_And_Dir := Value;
end Set_Counter_Mode;
------------------------
-- Set_Clock_Division --
------------------------
procedure Set_Clock_Division
(This : in out Timer;
Value : Timer_Clock_Divisor)
is
begin
This.CR1.Clock_Division := Value;
end Set_Clock_Division;
----------------------------
-- Current_Clock_Division --
----------------------------
function Current_Clock_Division (This : Timer) return Timer_Clock_Divisor is
begin
return This.CR1.Clock_Division;
end Current_Clock_Division;
---------------
-- Configure --
---------------
procedure Configure
(This : in out Timer;
Prescaler : UInt16;
Period : UInt32;
Clock_Divisor : Timer_Clock_Divisor;
Counter_Mode : Timer_Counter_Alignment_Mode;
Repetitions : UInt8)
is
begin
This.ARR := Period;
This.Prescaler := Prescaler;
This.CR1.Clock_Division := Clock_Divisor;
This.CR1.Mode_And_Dir := Counter_Mode;
This.RCR := UInt32 (Repetitions);
This.EGR := Immediate'Enum_Rep;
end Configure;
------------
-- Enable --
------------
procedure Enable (This : in out Timer) is
begin
This.CR1.Timer_Enabled := True;
end Enable;
-------------
-- Enabled --
-------------
function Enabled (This : Timer) return Boolean is
begin
return This.CR1.Timer_Enabled;
end Enabled;
------------------------
-- No_Outputs_Enabled --
------------------------
function No_Outputs_Enabled (This : Timer) return Boolean is
begin
for C in Channel_1 .. Channel_3 loop
if This.CCER (C).CCxE = Enable or This.CCER (C).CCxNE = Enable then
return False;
end if;
end loop;
-- Channel_4 doesn't have the complementary enabler and polarity bits.
-- If it did they would be in the reserved area, which is zero, so we
-- could be tricky and pretend that they exist for this function but
-- doing that would be unnecessarily subtle. The money is on clarity.
if This.CCER (Channel_4).CCxE = Enable then
return False;
end if;
return True;
end No_Outputs_Enabled;
-------------
-- Disable --
-------------
procedure Disable (This : in out Timer) is
begin
if No_Outputs_Enabled (This) then
This.CR1.Timer_Enabled := False;
end if;
end Disable;
------------------------
-- Enable_Main_Output --
------------------------
procedure Enable_Main_Output (This : in out Timer) is
begin
This.BDTR.Main_Output_Enabled := True;
end Enable_Main_Output;
-------------------------
-- Disable_Main_Output --
-------------------------
procedure Disable_Main_Output (This : in out Timer) is
begin
if No_Outputs_Enabled (This) then
This.BDTR.Main_Output_Enabled := False;
end if;
end Disable_Main_Output;
-------------------------
-- Main_Output_Enabled --
-------------------------
function Main_Output_Enabled (This : Timer) return Boolean is
begin
return This.BDTR.Main_Output_Enabled;
end Main_Output_Enabled;
-----------------
-- Set_Counter --
-----------------
procedure Set_Counter (This : in out Timer; Value : UInt16) is
begin
This.Counter := UInt32 (Value);
end Set_Counter;
-----------------
-- Set_Counter --
-----------------
procedure Set_Counter (This : in out Timer; Value : UInt32) is
begin
This.Counter := Value;
end Set_Counter;
---------------------
-- Current_Counter --
---------------------
function Current_Counter (This : Timer) return UInt32 is
begin
return This.Counter;
end Current_Counter;
----------------------------
-- Set_Repetition_Counter --
----------------------------
procedure Set_Repetition_Counter (This : in out Timer; Value : UInt32) is
begin
This.RCR := Value;
end Set_Repetition_Counter;
--------------------------------
-- Current_Repetition_Counter --
--------------------------------
function Current_Repetition_Counter (This : Timer) return UInt32 is
begin
return This.RCR;
end Current_Repetition_Counter;
--------------------
-- Set_Autoreload --
--------------------
procedure Set_Autoreload (This : in out Timer; Value : UInt32) is
begin
This.ARR := Value;
end Set_Autoreload;
------------------------
-- Current_Autoreload --
------------------------
function Current_Autoreload (This : Timer) return UInt32 is
begin
return This.ARR;
end Current_Autoreload;
----------------------
-- Enable_Interrupt --
----------------------
procedure Enable_Interrupt
(This : in out Timer;
Source : Timer_Interrupt)
is
begin
This.DIER := This.DIER or Source'Enum_Rep;
end Enable_Interrupt;
----------------------
-- Enable_Interrupt --
----------------------
procedure Enable_Interrupt
(This : in out Timer;
Sources : Timer_Interrupt_List)
is
begin
for Source of Sources loop
This.DIER := This.DIER or Source'Enum_Rep;
end loop;
end Enable_Interrupt;
-----------------------
-- Disable_Interrupt --
-----------------------
procedure Disable_Interrupt
(This : in out Timer;
Source : Timer_Interrupt)
is
begin
This.DIER := This.DIER and not Source'Enum_Rep;
end Disable_Interrupt;
-----------------------------
-- Clear_Pending_Interrupt --
-----------------------------
procedure Clear_Pending_Interrupt
(This : in out Timer;
Source : Timer_Interrupt)
is
begin
This.SR := not Source'Enum_Rep;
-- We do not, and must not, use the read-modify-write pattern because
-- it leaves a window of vulnerability open to changes to the state
-- after the read but before the write. The hardware for this register
-- is designed so that writing other bits will not change them. This is
-- indicated by the "rc_w0" notation in the status register definition.
-- See the RM, page 57 for that notation explanation.
end Clear_Pending_Interrupt;
-----------------------
-- Interrupt_Enabled --
-----------------------
function Interrupt_Enabled
(This : Timer;
Source : Timer_Interrupt)
return Boolean
is
begin
return (This.DIER and Source'Enum_Rep) = Source'Enum_Rep;
end Interrupt_Enabled;
------------
-- Status --
------------
function Status (This : Timer; Flag : Timer_Status_Flag) return Boolean is
begin
return (This.SR and Flag'Enum_Rep) = Flag'Enum_Rep;
end Status;
------------------
-- Clear_Status --
------------------
procedure Clear_Status (This : in out Timer; Flag : Timer_Status_Flag) is
begin
This.SR := not Flag'Enum_Rep;
-- We do not, and must not, use the read-modify-write pattern because
-- it leaves a window of vulnerability open to changes to the state
-- after the read but before the write. The hardware for this register
-- is designed so that writing other bits will not change them. This is
-- indicated by the "rc_w0" notation in the status register definition.
-- See the RM, page 57 for that notation explanation.
end Clear_Status;
-----------------------
-- Enable_DMA_Source --
-----------------------
procedure Enable_DMA_Source
(This : in out Timer;
Source : Timer_DMA_Source)
is
begin
This.DIER := This.DIER or Source'Enum_Rep;
end Enable_DMA_Source;
------------------------
-- Disable_DMA_Source --
------------------------
procedure Disable_DMA_Source
(This : in out Timer;
Source : Timer_DMA_Source)
is
begin
This.DIER := This.DIER and not Source'Enum_Rep;
end Disable_DMA_Source;
------------------------
-- DMA_Source_Enabled --
------------------------
function DMA_Source_Enabled
(This : Timer;
Source : Timer_DMA_Source)
return Boolean
is
begin
return (This.DIER and Source'Enum_Rep) = Source'Enum_Rep;
end DMA_Source_Enabled;
-------------------------
-- Configure_Prescaler --
-------------------------
procedure Configure_Prescaler
(This : in out Timer;
Prescaler : UInt16;
Reload_Mode : Timer_Prescaler_Reload_Mode)
is
begin
This.Prescaler := Prescaler;
This.EGR := Reload_Mode'Enum_Rep;
end Configure_Prescaler;
-------------------
-- Configure_DMA --
-------------------
procedure Configure_DMA
(This : in out Timer;
Base_Address : Timer_DMA_Base_Address;
Burst_Length : Timer_DMA_Burst_Length)
is
begin
This.DCR.Base_Address := Base_Address;
This.DCR.Burst_Length := Burst_Length;
end Configure_DMA;
--------------------------------
-- Enable_Capture_Compare_DMA --
--------------------------------
procedure Enable_Capture_Compare_DMA
(This : in out Timer)
-- TODO: note that the CCDS field description in the RM, page 550, seems
-- to indicate other than simply enabled/disabled
is
begin
This.CR2.Capture_Compare_DMA_Selection := True;
end Enable_Capture_Compare_DMA;
---------------------------------
-- Disable_Capture_Compare_DMA --
---------------------------------
procedure Disable_Capture_Compare_DMA
(This : in out Timer)
-- TODO: note that the CCDS field description in the RM, page 550, seems
-- to indicate other than simply enabled/disabled
is
begin
This.CR2.Capture_Compare_DMA_Selection := False;
end Disable_Capture_Compare_DMA;
-----------------------
-- Current_Prescaler --
-----------------------
function Current_Prescaler (This : Timer) return UInt16 is
begin
return This.Prescaler;
end Current_Prescaler;
-----------------------
-- Set_UpdateDisable --
-----------------------
procedure Set_UpdateDisable
(This : in out Timer;
To : Boolean)
is
begin
This.CR1.Update_Disable := To;
end Set_UpdateDisable;
-----------------------
-- Set_UpdateRequest --
-----------------------
procedure Set_UpdateRequest
(This : in out Timer;
Source : Timer_Update_Source)
is
begin
This.CR1.Update_Request_Source := Source /= Global;
end Set_UpdateRequest;
----------------------------
-- Set_Autoreload_Preload --
----------------------------
procedure Set_Autoreload_Preload
(This : in out Timer;
To : Boolean)
is
begin
This.CR1.ARPE := To;
end Set_Autoreload_Preload;
---------------------------
-- Select_One_Pulse_Mode --
---------------------------
procedure Select_One_Pulse_Mode
(This : in out Timer;
Mode : Timer_One_Pulse_Mode)
is
begin
This.CR1.One_Pulse_Mode := Mode;
end Select_One_Pulse_Mode;
----------------------------------
-- Compute_Prescaler_and_Period --
----------------------------------
procedure Compute_Prescaler_And_Period
(This : access Timer;
Requested_Frequency : UInt32;
Prescaler : out UInt32;
Period : out UInt32)
is
Max_Prescaler : constant := 16#FFFF#;
Max_Period : UInt32;
Hardware_Frequency : UInt32;
CK_CNT : UInt32;
begin
Hardware_Frequency := STM32.Device.Get_Clock_Frequency (This.all);
if Has_32bit_Counter (This.all) then
Max_Period := 16#FFFF_FFFF#;
else
Max_Period := 16#FFFF#;
end if;
if Requested_Frequency > Hardware_Frequency then
raise Invalid_Request with "Frequency too high";
end if;
Prescaler := 0; -- Corresponds to value 1
loop
-- Compute the Counter's clock
CK_CNT := Hardware_Frequency / (Prescaler + 1);
-- Determine the CK_CNT periods to achieve the requested frequency
Period := CK_CNT / Requested_Frequency;
exit when ((Period <= Max_Period) or (Prescaler > Max_Prescaler));
Prescaler := Prescaler + 1;
end loop;
if Prescaler > Max_Prescaler then
raise Invalid_Request with "Frequency too low";
end if;
end Compute_Prescaler_And_Period;
-----------------------
-- Counter_Direction --
-----------------------
function Current_Counter_Mode
(This : Timer)
return Timer_Counter_Alignment_Mode
is
begin
if Basic_Timer (This) then
return Up;
else
return This.CR1.Mode_And_Dir;
end if;
end Current_Counter_Mode;
--------------------
-- Generate_Event --
--------------------
procedure Generate_Event
(This : in out Timer;
Source : Timer_Event_Source)
is
Temp_EGR : UInt32 := This.EGR;
begin
Temp_EGR := Temp_EGR or Source'Enum_Rep;
This.EGR := Temp_EGR;
end Generate_Event;
---------------------------
-- Select_Output_Trigger --
---------------------------
procedure Select_Output_Trigger
(This : in out Timer;
Source : Timer_Trigger_Output_Source)
is
begin
This.CR2.Master_Mode_Selection := Source;
end Select_Output_Trigger;
-----------------------
-- Select_Slave_Mode --
-----------------------
procedure Select_Slave_Mode
(This : in out Timer;
Mode : Timer_Slave_Mode)
is
begin
case Mode is
when Disabled .. External_1 =>
This.SMCR.Slave_Mode_Selection_2 := False;
This.SMCR.Slave_Mode_Selection := UInt3 (Mode'Enum_Rep);
when Combined_Reset_Trigger .. Quadrature_Encoder_Mode_5 =>
This.SMCR.Slave_Mode_Selection_2 := True;
This.SMCR.Slave_Mode_Selection := UInt3 (Mode'Enum_Rep);
end case;
end Select_Slave_Mode;
------------------------------
-- Enable_Master_Slave_Mode --
------------------------------
procedure Enable_Master_Slave_Mode (This : in out Timer) is
begin
This.SMCR.Master_Slave_Mode := True;
end Enable_Master_Slave_Mode;
-------------------------------
-- Disable_Master_Slave_Mode --
-------------------------------
procedure Disable_Master_Slave_Mode (This : in out Timer) is
begin
This.SMCR.Master_Slave_Mode := False;
end Disable_Master_Slave_Mode;
--------------------------------
-- Configure_External_Trigger --
--------------------------------
procedure Configure_External_Trigger
(This : in out Timer;
Polarity : Timer_External_Trigger_Polarity;
Prescaler : Timer_External_Trigger_Prescaler;
Filter : Timer_External_Trigger_Filter)
is
begin
This.SMCR.External_Trigger_Polarity := Polarity;
This.SMCR.External_Trigger_Prescaler := Prescaler;
This.SMCR.External_Trigger_Filter := Filter;
end Configure_External_Trigger;
---------------------------------
-- Configure_As_External_Clock --
---------------------------------
procedure Configure_As_External_Clock
(This : in out Timer;
Source : Timer_Internal_Trigger_Source)
is
begin
Select_Input_Trigger (This, Source);
Select_Slave_Mode (This, External_1);
end Configure_As_External_Clock;
---------------------------------
-- Configure_As_External_Clock --
---------------------------------
procedure Configure_As_External_Clock
(This : in out Timer;
Source : Timer_External_Clock_Source;
Polarity : Timer_Input_Capture_Polarity;
Filter : Timer_Input_Capture_Filter)
is
begin
if Source = Filtered_Timer_Input_2 then
Configure_Channel_Input
(This,
Channel_2,
Polarity,
Direct_TI,
Div1, -- default prescalar zero value
Filter);
else
Configure_Channel_Input
(This,
Channel_1,
Polarity,
Direct_TI,
Div1, -- default prescalar zero value
Filter);
end if;
Select_Input_Trigger (This, Source);
Select_Slave_Mode (This, External_1);
end Configure_As_External_Clock;
------------------------------------
-- Configure_External_Clock_Mode1 --
------------------------------------
procedure Configure_External_Clock_Mode1
(This : in out Timer;
Polarity : Timer_External_Trigger_Polarity;
Prescaler : Timer_External_Trigger_Prescaler;
Filter : Timer_External_Trigger_Filter)
is
begin
Configure_External_Trigger (This, Polarity, Prescaler, Filter);
Select_Slave_Mode (This, External_1);
Select_Input_Trigger (This, External_Trigger_Input);
end Configure_External_Clock_Mode1;
------------------------------------
-- Configure_External_Clock_Mode2 --
------------------------------------
procedure Configure_External_Clock_Mode2
(This : in out Timer;
Polarity : Timer_External_Trigger_Polarity;
Prescaler : Timer_External_Trigger_Prescaler;
Filter : Timer_External_Trigger_Filter)
is
begin
Configure_External_Trigger (This, Polarity, Prescaler, Filter);
This.SMCR.External_Clock_Enable := True;
end Configure_External_Clock_Mode2;
--------------------------
-- Select_Input_Trigger --
--------------------------
procedure Select_Input_Trigger
(This : in out Timer;
Source : Timer_Trigger_Input_Source)
is
begin
This.SMCR.Trigger_Selection := UInt3 (Source'Enum_Rep);
This.SMCR.Trigger_Selection_1 :=
UInt2 (Shift_Right (UInt8 (Source'Enum_Rep), 3));
end Select_Input_Trigger;
------------------------------
-- Configure_Channel_Output --
------------------------------
procedure Configure_Channel_Output
(This : in out Timer;
Channel : Timer_Channel;
Mode : Timer_Output_Compare_And_PWM_Mode;
State : Timer_Capture_Compare_State;
Pulse : UInt32;
Polarity : Timer_Output_Compare_Polarity)
is
begin
-- first disable the channel CC output
This.CCER (Channel).CCxE := Disable;
Set_Output_Compare_Mode (This, Channel, Mode);
This.CCER (Channel).CCxE := State;
This.CCER (Channel).CCxP := Polarity'Enum_Rep;
case Channel is
when Channel_1 .. Channel_4 =>
This.CCR1_4 (Channel) := Pulse;
when Channel_5 =>
This.CCR5 := Pulse;
when Channel_6 =>
This.CCR6 := Pulse;
end case;
-- Only timers 2 and 5 have 32-bit CCR registers. The others must
-- maintain the upper half at zero. We use a precondition to ensure
-- values greater than a half-word are only specified for the proper
-- timers.
end Configure_Channel_Output;
------------------------------
-- Configure_Channel_Output --
------------------------------
procedure Configure_Channel_Output
(This : in out Timer;
Channel : Timer_Channel;
Mode : Timer_Output_Compare_And_PWM_Mode;
State : Timer_Capture_Compare_State;
Pulse : UInt32;
Polarity : Timer_Output_Compare_Polarity;
Idle_State : Timer_Capture_Compare_State;
Complementary_Polarity : Timer_Output_Compare_Polarity;
Complementary_Idle_State : Timer_Capture_Compare_State)
is
begin
-- first disable the channel CC output
This.CCER (Channel).CCxE := Disable;
Set_Output_Compare_Mode (This, Channel, Mode);
This.CCER (Channel).CCxE := State;
This.CCER (Channel).CCxNP := Complementary_Polarity'Enum_Rep;
This.CCER (Channel).CCxP := Polarity'Enum_Rep;
case Channel is
when Channel_1 =>
This.CR2.Channel_1_Output_Idle_State := Idle_State;
This.CR2.Channel_1_Complementary_Output_Idle_State :=
Complementary_Idle_State;
when Channel_2 =>
This.CR2.Channel_2_Output_Idle_State := Idle_State;
This.CR2.Channel_2_Complementary_Output_Idle_State :=
Complementary_Idle_State;
when Channel_3 =>
This.CR2.Channel_3_Output_Idle_State := Idle_State;
This.CR2.Channel_3_Complementary_Output_Idle_State :=
Complementary_Idle_State;
when Channel_4 =>
This.CR2.Channel_4_Output_Idle_State := Idle_State;
when Channel_5 =>
This.CR2.Channel_5_Output_Idle_State := Idle_State;
when Channel_6 =>
This.CR2.Channel_6_Output_Idle_State := Idle_State;
end case;
case Channel is
when Channel_1 .. Channel_4 =>
This.CCR1_4 (Channel) := Pulse;
when Channel_5 =>
This.CCR5 := Pulse;
when Channel_6 =>
This.CCR6 := Pulse;
end case;
-- Only timers 2 and 5 have 32-bit CCR registers. The others must
-- maintain the upper half at zero. We use a precondition to ensure
-- values greater than a half-word are only specified for the proper
-- timers.
end Configure_Channel_Output;
-----------------------
-- Set_Single_Output --
-----------------------
procedure Set_Single_Output
(This : in out Timer;
Channel : Timer_Channel;
Mode : Timer_Output_Compare_And_PWM_Mode;
OC_Clear_Enabled : Boolean;
Preload_Enabled : Boolean;
Fast_Enabled : Boolean)
is
CCMR_Index : CCMRx_Index;
Descriptor_Index : Half_Index;
Temp : TIMx_CCMRx;
Mode0_2 : UInt3;
Mode_3 : Boolean;
Description_1 : Lower_Channel_Output_Descriptor;
Description_2 : Higher_Channel_Output_Descriptor;
begin
case Channel is
when Channel_1 =>
CCMR_Index := 1;
Descriptor_Index := 1;
when Channel_2 =>
CCMR_Index := 1;
Descriptor_Index := 2;
when Channel_3 =>
CCMR_Index := 2;
Descriptor_Index := 1;
when Channel_4 =>
CCMR_Index := 2;
Descriptor_Index := 2;
when Channel_5 =>
CCMR_Index := 3;
Descriptor_Index := 1;
when Channel_6 =>
CCMR_Index := 3;
Descriptor_Index := 2;
end case;
case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3
when 1 =>
Temp := This.CCMR1;
when 2 =>
Temp := This.CCMR2;
when 3 =>
Temp := This.CCMR3;
end case;
Mode0_2 := UInt3 (Mode'Enum_Rep);
Mode_3 := Mode'Enum_Rep > 7;
Description_1 := (OCxMode => Mode0_2,
OCxFast_Enable => Fast_Enabled,
OCxPreload_Enable => Preload_Enabled,
OCxClear_Enable => OC_Clear_Enabled);
Description_2 := (OCxMode_3 => Mode_3);
Temp.Low_Descriptors (Descriptor_Index) := (Output, Description_1);
Temp.High_Descriptors (Descriptor_Index) := (Output, Description_2);
case CCMR_Index is
when 1 =>
This.CCMR1 := Temp;
when 2 =>
This.CCMR2 := Temp;
when 3 =>
This.CCMR3 := Temp;
end case;
end Set_Single_Output;
-----------------------------
-- Set_Output_Compare_Mode --
-----------------------------
procedure Set_Output_Compare_Mode
(This : in out Timer;
Channel : Timer_Channel;
Mode : Timer_Output_Compare_And_PWM_Mode)
is
CCMR_Index : CCMRx_Index;
Descriptor_Index : Half_Index;
Temp : TIMx_CCMRx;
Mode0_2 : UInt3;
Mode_3 : Boolean;
begin
case Channel is
when Channel_1 =>
CCMR_Index := 1;
Descriptor_Index := 1;
when Channel_2 =>
CCMR_Index := 1;
Descriptor_Index := 2;
when Channel_3 =>
CCMR_Index := 2;
Descriptor_Index := 1;
when Channel_4 =>
CCMR_Index := 2;
Descriptor_Index := 2;
when Channel_5 =>
CCMR_Index := 3;
Descriptor_Index := 1;
when Channel_6 =>
CCMR_Index := 3;
Descriptor_Index := 2;
end case;
case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3
when 1 =>
Temp := This.CCMR1;
when 2 =>
Temp := This.CCMR2;
when 3 =>
Temp := This.CCMR3;
end case;
if Temp.Low_Descriptors (Descriptor_Index).CCxSelection /= Output then
raise Timer_Channel_Access_Error;
end if;
Mode0_2 := UInt3 (Mode'Enum_Rep);
Mode_3 := Mode'Enum_Rep > 7;
Temp.Low_Descriptors (Descriptor_Index).Compare_1.OCxMode := Mode0_2;
Temp.High_Descriptors (Descriptor_Index).Compare_2.OCxMode_3 := Mode_3;
case CCMR_Index is
when 1 =>
This.CCMR1 := Temp;
when 2 =>
This.CCMR2 := Temp;
when 3 =>
This.CCMR3 := Temp;
end case;
end Set_Output_Compare_Mode;
----------------------------------
-- Current_Capture_Compare_Mode --
----------------------------------
function Current_Capture_Compare_Mode
(This : Timer;
Channel : Timer_Channel)
return Timer_Capture_Compare_Modes
is
CCMR_Index : CCMRx_Index;
Descriptor_Index : Half_Index;
Temp : TIMx_CCMRx;
begin
case Channel is
when Channel_1 =>
CCMR_Index := 1;
Descriptor_Index := 1;
when Channel_2 =>
CCMR_Index := 1;
Descriptor_Index := 2;
when Channel_3 =>
CCMR_Index := 2;
Descriptor_Index := 1;
when Channel_4 =>
CCMR_Index := 2;
Descriptor_Index := 2;
when Channel_5 =>
CCMR_Index := 3;
Descriptor_Index := 1;
when Channel_6 =>
CCMR_Index := 3;
Descriptor_Index := 2;
end case;
case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3
when 1 =>
Temp := This.CCMR1;
return Temp.Low_Descriptors (Descriptor_Index).CCxSelection;
when 2 =>
Temp := This.CCMR2;
return Temp.Low_Descriptors (Descriptor_Index).CCxSelection;
when 3 =>
Temp := This.CCMR3;
return Temp.Low_Descriptors (Descriptor_Index).CCxSelection;
end case;
end Current_Capture_Compare_Mode;
------------------------------
-- Set_Output_Forced_Action --
------------------------------
procedure Set_Output_Forced_Action
(This : in out Timer;
Channel : Timer_Channel;
Active : Boolean)
is
CCMR_Index : CCMRx_Index;
Descriptor_Index : Half_Index;
Temp : TIMx_CCMRx;
Mode0_2 : UInt3;
Mode_3 : Boolean;
begin
case Channel is
when Channel_1 =>
CCMR_Index := 1;
Descriptor_Index := 1;
when Channel_2 =>
CCMR_Index := 1;
Descriptor_Index := 2;
when Channel_3 =>
CCMR_Index := 2;
Descriptor_Index := 1;
when Channel_4 =>
CCMR_Index := 2;
Descriptor_Index := 2;
when Channel_5 =>
CCMR_Index := 3;
Descriptor_Index := 1;
when Channel_6 =>
CCMR_Index := 3;
Descriptor_Index := 2;
end case;
case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3
when 1 =>
Temp := This.CCMR1;
when 2 =>
Temp := This.CCMR2;
when 3 =>
Temp := This.CCMR3;
end case;
if Temp.Low_Descriptors (Descriptor_Index).CCxSelection /= Output then
raise Timer_Channel_Access_Error;
end if;
if Active then
Mode0_2 := UInt3 (Force_Active'Enum_Rep);
Mode_3 := Force_Active'Enum_Rep > 7;
Temp.Low_Descriptors (Descriptor_Index).Compare_1.OCxMode := Mode0_2;
Temp.High_Descriptors (Descriptor_Index).Compare_2.OCxMode_3 := Mode_3;
else
Mode0_2 := UInt3 (Force_Inactive'Enum_Rep);
Mode_3 := Force_Inactive'Enum_Rep > 7;
Temp.Low_Descriptors (Descriptor_Index).Compare_1.OCxMode := Mode0_2;
Temp.High_Descriptors (Descriptor_Index).Compare_2.OCxMode_3 := Mode_3;
end if;
case CCMR_Index is
when 1 =>
This.CCMR1 := Temp;
when 2 =>
This.CCMR2 := Temp;
when 3 =>
This.CCMR3 := Temp;
end case;
end Set_Output_Forced_Action;
-------------------------------
-- Set_Output_Preload_Enable --
-------------------------------
procedure Set_Output_Preload_Enable
(This : in out Timer;
Channel : Timer_Channel;
Enabled : Boolean)
is
CCMR_Index : CCMRx_Index;
Descriptor_Index : Half_Index;
Temp : TIMx_CCMRx;
begin
case Channel is
when Channel_1 =>
CCMR_Index := 1;
Descriptor_Index := 1;
when Channel_2 =>
CCMR_Index := 1;
Descriptor_Index := 2;
when Channel_3 =>
CCMR_Index := 2;
Descriptor_Index := 1;
when Channel_4 =>
CCMR_Index := 2;
Descriptor_Index := 2;
when Channel_5 =>
CCMR_Index := 3;
Descriptor_Index := 1;
when Channel_6 =>
CCMR_Index := 3;
Descriptor_Index := 2;
end case;
case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3
when 1 =>
Temp := This.CCMR1;
when 2 =>
Temp := This.CCMR2;
when 3 =>
Temp := This.CCMR3;
end case;
Temp.Low_Descriptors (Descriptor_Index).Compare_1.OCxPreload_Enable := Enabled;
case CCMR_Index is
when 1 =>
This.CCMR1 := Temp;
when 2 =>
This.CCMR2 := Temp;
when 3 =>
This.CCMR3 := Temp;
end case;
end Set_Output_Preload_Enable;
----------------------------
-- Set_Output_Fast_Enable --
----------------------------
procedure Set_Output_Fast_Enable
(This : in out Timer;
Channel : Timer_Channel;
Enabled : Boolean)
is
CCMR_Index : CCMRx_Index;
Descriptor_Index : Half_Index;
Temp : TIMx_CCMRx;
begin
case Channel is
when Channel_1 =>
CCMR_Index := 1;
Descriptor_Index := 1;
when Channel_2 =>
CCMR_Index := 1;
Descriptor_Index := 2;
when Channel_3 =>
CCMR_Index := 2;
Descriptor_Index := 1;
when Channel_4 =>
CCMR_Index := 2;
Descriptor_Index := 2;
when Channel_5 =>
CCMR_Index := 3;
Descriptor_Index := 1;
when Channel_6 =>
CCMR_Index := 3;
Descriptor_Index := 2;
end case;
case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3
when 1 =>
Temp := This.CCMR1;
when 2 =>
Temp := This.CCMR2;
when 3 =>
Temp := This.CCMR3;
end case;
Temp.Low_Descriptors (Descriptor_Index).Compare_1.OCxFast_Enable := Enabled;
case CCMR_Index is
when 1 =>
This.CCMR1 := Temp;
when 2 =>
This.CCMR2 := Temp;
when 3 =>
This.CCMR3 := Temp;
end case;
end Set_Output_Fast_Enable;
-----------------------
-- Set_Clear_Control --
-----------------------
procedure Set_Clear_Control
(This : in out Timer;
Channel : Timer_Channel;
Enabled : Boolean)
is
CCMR_Index : CCMRx_Index;
Descriptor_Index : Half_Index;
Temp : TIMx_CCMRx;
begin
case Channel is
when Channel_1 =>
CCMR_Index := 1;
Descriptor_Index := 1;
when Channel_2 =>
CCMR_Index := 1;
Descriptor_Index := 2;
when Channel_3 =>
CCMR_Index := 2;
Descriptor_Index := 1;
when Channel_4 =>
CCMR_Index := 2;
Descriptor_Index := 2;
when Channel_5 =>
CCMR_Index := 3;
Descriptor_Index := 1;
when Channel_6 =>
CCMR_Index := 3;
Descriptor_Index := 2;
end case;
case CCMR_Index is -- effectively get CCMR1, CCMR2 or CCMR3
when 1 =>
Temp := This.CCMR1;
when 2 =>
Temp := This.CCMR2;
when 3 =>
Temp := This.CCMR3;
end case;
Temp.Low_Descriptors (Descriptor_Index).Compare_1.OCxClear_Enable := Enabled;
case CCMR_Index is
when 1 =>
This.CCMR1 := Temp;
when 2 =>
This.CCMR2 := Temp;
when 3 =>
This.CCMR3 := Temp;
end case;
end Set_Clear_Control;
--------------------
-- Enable_Channel --
--------------------
procedure Enable_Channel
(This : in out Timer;
Channel : Timer_Channel)
is
Temp_EGR : UInt32 := This.EGR;
begin
This.CCER (Channel).CCxE := Enable;
-- Trigger an event to initialize preload register
Temp_EGR := Temp_EGR or (2 ** (Timer_Channel'Pos (Channel) + 1));
This.EGR := Temp_EGR;
end Enable_Channel;
-------------------------
-- Set_Output_Polarity --
-------------------------
procedure Set_Output_Polarity
(This : in out Timer;
Channel : Timer_Channel;
Polarity : Timer_Output_Compare_Polarity)
is
begin
This.CCER (Channel).CCxP := Polarity'Enum_Rep;
end Set_Output_Polarity;
---------------------------------------
-- Set_Output_Complementary_Polarity --
---------------------------------------
procedure Set_Output_Complementary_Polarity
(This : in out Timer;
Channel : Timer_Channel;
Polarity : Timer_Output_Compare_Polarity)
is
begin
This.CCER (Channel).CCxNP := Polarity'Enum_Rep;
end Set_Output_Complementary_Polarity;
---------------------
-- Disable_Channel --
---------------------
procedure Disable_Channel
(This : in out Timer;
Channel : Timer_Channel)
is
begin
This.CCER (Channel).CCxE := Disable;
end Disable_Channel;
---------------------
-- Channel_Enabled --
---------------------
function Channel_Enabled
(This : Timer;
Channel : Timer_Channel)
return Boolean
is
begin
return This.CCER (Channel).CCxE = Enable;
end Channel_Enabled;
----------------------------------
-- Enable_Complementary_Channel --
----------------------------------
procedure Enable_Complementary_Channel
(This : in out Timer;
Channel : Timer_Channel)
is
begin
This.CCER (Channel).CCxNE := Enable;
end Enable_Complementary_Channel;
-----------------------------------
-- Disable_Complementary_Channel --
-----------------------------------
procedure Disable_Complementary_Channel
(This : in out Timer;
Channel : Timer_Channel)
is
begin
This.CCER (Channel).CCxNE := Disable;
end Disable_Complementary_Channel;
-----------------------------------
-- Complementary_Channel_Enabled --
-----------------------------------
function Complementary_Channel_Enabled
(This : Timer; Channel : Timer_Channel)
return Boolean
is
begin
return This.CCER (Channel).CCxNE = Enable;
end Complementary_Channel_Enabled;
-----------------------
-- Set_Compare_Value --
-----------------------
procedure Set_Compare_Value
(This : in out Timer;
Channel : Timer_Channel;
Word_Value : UInt32)
is
begin
This.CCR1_4 (Channel) := Word_Value;
-- Timers 2 and 5 really do have 32-bit capture/compare registers so we
-- don't need to require half-words as inputs.
end Set_Compare_Value;
-----------------------
-- Set_Compare_Value --
-----------------------
procedure Set_Compare_Value
(This : in out Timer;
Channel : Timer_Channel;
Value : UInt16)
is
begin
This.CCR1_4 (Channel) := UInt32 (Value);
-- These capture/compare registers are really only 15-bits wide, except
-- for those of timers 2 and 5. For the sake of simplicity we represent
-- all of them with full words, but only write word values when
-- appropriate. The caller has to treat them as half-word values, since
-- that's the type for the formal parameter, therefore our casting up to
-- a word value will retain the reserved upper half-word value of zero.
end Set_Compare_Value;
---------------------------
-- Current_Capture_Value --
---------------------------
function Current_Capture_Value
(This : Timer;
Channel : Timer_Channel)
return UInt32
is
begin
return This.CCR1_4 (Channel);
end Current_Capture_Value;
---------------------------
-- Current_Capture_Value --
---------------------------
function Current_Capture_Value
(This : Timer;
Channel : Timer_Channel)
return UInt16
is
begin
return UInt16 (This.CCR1_4 (Channel));
end Current_Capture_Value;
-------------------------------------
-- Write_Channel_Input_Description --
-------------------------------------
procedure Write_Channel_Input_Description
(This : in out Timer;
Channel : Timer_Channel;
Kind : Timer_Input_Capture_Selection;
Description : Lower_Channel_Input_Descriptor)
is
CCMR_Index : CCMRx_Index;
Descriptor_Index : Half_Index;
Temp : TIMx_CCMRx;
New_Value : Lower_IO_Descriptor;
begin
case Kind is
when Direct_TI =>
New_Value := (CCxSelection => Direct_TI, Capture => Description);
when Indirect_TI =>
New_Value := (CCxSelection => Indirect_TI, Capture => Description);
when TRC =>
New_Value := (CCxSelection => TRC, Capture => Description);
end case;
case Channel is
when Channel_1 =>
CCMR_Index := 1;
Descriptor_Index := 1;
when Channel_2 =>
CCMR_Index := 1;
Descriptor_Index := 2;
when Channel_3 =>
CCMR_Index := 2;
Descriptor_Index := 1;
when Channel_4 =>
CCMR_Index := 2;
Descriptor_Index := 2;
when others =>
null;
end case;
case CCMR_Index is -- effectively get CCMR1 or CCMR2
when 1 =>
Temp := This.CCMR1;
when 2 =>
Temp := This.CCMR2;
when 3 =>
null;
end case;
Temp.Low_Descriptors (Descriptor_Index) := New_Value;
case CCMR_Index is
when 1 =>
This.CCMR1 := Temp;
when 2 =>
This.CCMR2 := Temp;
when 3 =>
null;
end case;
end Write_Channel_Input_Description;
-------------------------
-- Set_Input_Prescaler --
-------------------------
procedure Set_Input_Prescaler
(This : in out Timer;
Channel : Timer_Channel;
Value : Timer_Input_Capture_Prescaler)
is
CCMR_Index : CCMRx_Index;
Descriptor_Index : Half_Index;
Temp : TIMx_CCMRx;
begin
case Channel is
when Channel_1 =>
CCMR_Index := 1;
Descriptor_Index := 1;
when Channel_2 =>
CCMR_Index := 1;
Descriptor_Index := 2;
when Channel_3 =>
CCMR_Index := 2;
Descriptor_Index := 1;
when Channel_4 =>
CCMR_Index := 2;
Descriptor_Index := 2;
when others =>
null;
end case;
case CCMR_Index is -- effectively get CCMR1 or CCMR2
when 1 =>
Temp := This.CCMR1;
when 2 =>
Temp := This.CCMR2;
when 3 =>
null;
end case;
Temp.Low_Descriptors (Descriptor_Index).Capture.ICxPrescaler := Value;
case CCMR_Index is
when 1 =>
This.CCMR1 := Temp;
when 2 =>
This.CCMR2 := Temp;
when 3 =>
null;
end case;
end Set_Input_Prescaler;
-----------------------------
-- Current_Input_Prescaler --
-----------------------------
function Current_Input_Prescaler
(This : Timer;
Channel : Timer_Channel)
return Timer_Input_Capture_Prescaler
is
CCMR_Index : CCMRx_Index;
Descriptor_Index : Half_Index;
Temp : TIMx_CCMRx;
begin
case Channel is
when Channel_1 =>
CCMR_Index := 1;
Descriptor_Index := 1;
when Channel_2 =>
CCMR_Index := 1;
Descriptor_Index := 2;
when Channel_3 =>
CCMR_Index := 2;
Descriptor_Index := 1;
when Channel_4 =>
CCMR_Index := 2;
Descriptor_Index := 2;
when others =>
null;
end case;
case CCMR_Index is -- effectively get CCMR1 or CCMR2
when 1 =>
Temp := This.CCMR1;
when 2 =>
Temp := This.CCMR2;
when 3 =>
null;
end case;
return Temp.Low_Descriptors (Descriptor_Index).Capture.ICxPrescaler;
end Current_Input_Prescaler;
-----------------------------
-- Configure_Channel_Input --
-----------------------------
procedure Configure_Channel_Input
(This : in out Timer;
Channel : Timer_Channel;
Polarity : Timer_Input_Capture_Polarity;
Selection : Timer_Input_Capture_Selection;
Prescaler : Timer_Input_Capture_Prescaler;
Filter : Timer_Input_Capture_Filter)
is
Input : Lower_Channel_Input_Descriptor;
begin
-- first disable the channel
This.CCER (Channel).CCxE := Disable;
Input := (ICxFilter => Filter, ICxPrescaler => Prescaler);
Write_Channel_Input_Description
(This => This,
Channel => Channel,
Kind => Selection,
Description => Input);
case Polarity is
when Rising =>
This.CCER (Channel).CCxNP := 0;
This.CCER (Channel).CCxP := 0;
when Falling =>
This.CCER (Channel).CCxNP := 0;
This.CCER (Channel).CCxP := 1;
when Both_Edges =>
This.CCER (Channel).CCxNP := 1;
This.CCER (Channel).CCxP := 1;
end case;
This.CCER (Channel).CCxE := Enable;
end Configure_Channel_Input;
---------------------------------
-- Configure_Channel_Input_PWM --
---------------------------------
procedure Configure_Channel_Input_PWM
(This : in out Timer;
Channel : Timer_Channel;
Selection : Timer_Input_Capture_Selection;
Polarity : Timer_Input_Capture_Polarity;
Prescaler : Timer_Input_Capture_Prescaler;
Filter : Timer_Input_Capture_Filter)
is
Opposite_Polarity : Timer_Input_Capture_Polarity;
Opposite_Selection : Timer_Input_Capture_Selection;
begin
Disable_Channel (This, Channel);
if Polarity = Rising then
Opposite_Polarity := Falling;
else
Opposite_Polarity := Rising;
end if;
if Selection = Indirect_TI then
Opposite_Selection := Direct_TI;
else
Opposite_Selection := Indirect_TI;
end if;
if Channel = Channel_1 then
Configure_Channel_Input
(This, Channel_1, Polarity, Selection, Prescaler, Filter);
Configure_Channel_Input (This,
Channel_2,
Opposite_Polarity,
Opposite_Selection,
Prescaler,
Filter);
else
Configure_Channel_Input
(This, Channel_2, Polarity, Selection, Prescaler, Filter);
Configure_Channel_Input (This,
Channel_1,
Opposite_Polarity,
Opposite_Selection,
Prescaler,
Filter);
end if;
Enable_Channel (This, Channel);
end Configure_Channel_Input_PWM;
-------------------------------
-- Enable_CC_Preload_Control --
-------------------------------
procedure Enable_CC_Preload_Control (This : in out Timer) is
begin
This.CR2.Capture_Compare_Preloaded_Control := True;
end Enable_CC_Preload_Control;
--------------------------------
-- Disable_CC_Preload_Control --
--------------------------------
procedure Disable_CC_Preload_Control (This : in out Timer) is
begin
This.CR2.Capture_Compare_Preloaded_Control := False;
end Disable_CC_Preload_Control;
------------------------
-- Select_Commutation --
------------------------
procedure Select_Commutation (This : in out Timer) is
begin
This.CR2.Capture_Compare_Control_Update_Selection := True;
end Select_Commutation;
--------------------------
-- Deselect_Commutation --
--------------------------
procedure Deselect_Commutation (This : in out Timer) is
begin
This.CR2.Capture_Compare_Control_Update_Selection := False;
end Deselect_Commutation;
---------------------
-- Configure_Break --
---------------------
procedure Configure_Break
(This : in out Timer;
Automatic_Output_Enabled : Boolean;
Break_Polarity : Timer_Break_Polarity;
Break_Enabled : Boolean;
Break_Filter : Timer_Break_Filter;
Off_State_Selection_Run_Mode : Bit;
Off_State_Selection_Idle_Mode : Bit)
is
begin
This.BDTR.Automatic_Output_Enabled := Automatic_Output_Enabled;
This.BDTR.Break_Polarity := Break_Polarity;
This.BDTR.Break_Enable := Break_Enabled;
This.BDTR.Break_Filter := Break_Filter;
This.BDTR.Off_State_Selection_Run_Mode := Off_State_Selection_Run_Mode;
This.BDTR.Off_State_Selection_Idle_Mode := Off_State_Selection_Idle_Mode;
end Configure_Break;
---------------------
-- Configure_Break --
---------------------
procedure Configure_Break
(This : in out Timer;
Automatic_Output_Enabled : Boolean;
Break_Polarity : Timer_Break_Polarity;
Break_Enabled : Boolean;
Break_Filter : Timer_Break_Filter;
Break_2_Polarity : Timer_Break_Polarity;
Break_2_Enabled : Boolean;
Break_2_Filter : Timer_Break_Filter;
Off_State_Selection_Run_Mode : Bit;
Off_State_Selection_Idle_Mode : Bit)
is
begin
This.BDTR.Automatic_Output_Enabled := Automatic_Output_Enabled;
This.BDTR.Break_Polarity := Break_Polarity;
This.BDTR.Break_Enable := Break_Enabled;
This.BDTR.Break_2_Filter := Break_2_Filter;
This.BDTR.Break_2_Polarity := Break_2_Polarity;
This.BDTR.Break_2_Enable := Break_2_Enabled;
This.BDTR.Break_Filter := Break_Filter;
This.BDTR.Off_State_Selection_Run_Mode := Off_State_Selection_Run_Mode;
This.BDTR.Off_State_Selection_Idle_Mode := Off_State_Selection_Idle_Mode;
end Configure_Break;
------------------------
-- Configure_Deadtime --
------------------------
procedure Configure_Deadtime (This : in out Timer; Time : Float)
is
Timer_Frequency : constant UInt32 :=
STM32.Device.Get_Clock_Frequency (This);
-- The clock frequency of this timer.
Clock_Divisor : constant Float :=
(case Current_Clock_Division (This) is
when Div1 => 1.0,
when Div2 => 2.0,
when Div4 => 4.0);
-- The division factor for dead-time of this timer.
T_DTS : constant Float := Clock_Divisor / Float (Timer_Frequency);
-- Time period for one cycle of the input timer frequency.
Deadtime : UInt8 := 0;
begin
declare
Tick_Time : Float;
-- Time for one tick of the timer.
DT_Max_Factor : constant array (0 .. 3) of Float :=
(2.0**7 - 1.0,
(64.0 + 2.0**6 - 1.0) * 2.0,
(32.0 + 2.0**5 - 1.0) * 8.0,
(32.0 + 2.0**5 - 1.0) * 16.0);
begin
for I in DT_Max_Factor'Range loop
if Time <= DT_Max_Factor (I) * T_DTS then
case I is
when 0 =>
Tick_Time := Time / T_DTS;
Deadtime := UInt8 (UInt7 (Tick_Time));
exit;
when 1 =>
Tick_Time := Time / T_DTS / 2.0 - 64.0;
Deadtime := 16#80# + UInt8 (UInt6 (Tick_Time));
exit;
when 2 =>
Tick_Time := Time / T_DTS / 8.0 - 32.0;
Deadtime := 16#C0# + UInt8 (UInt5 (Tick_Time));
exit;
when 3 =>
Tick_Time := Time / T_DTS / 16.0 - 32.0;
Deadtime := 16#E0# + UInt8 (UInt5 (Tick_Time));
exit;
end case;
end if;
end loop;
end;
This.BDTR.Deadtime_Generator := Deadtime;
end Configure_Deadtime;
-------------------
-- Set_BDTR_Lock --
-------------------
procedure Set_BDTR_Lock (This : in out Timer;
Lock : Timer_Lock_Level)
is
begin
This.BDTR.Lock := Lock;
end Set_BDTR_Lock;
---------------------------------
-- Configure_Encoder_Interface --
---------------------------------
procedure Configure_Encoder_Interface
(This : in out Timer;
Mode : Timer_Encoder_Mode;
IC1_Polarity : Timer_Input_Capture_Polarity;
IC2_Polarity : Timer_Input_Capture_Polarity)
is
begin
case Mode is
when Quadrature_Encoder_Mode_1 .. Quadrature_Encoder_Mode_3 =>
This.SMCR.Slave_Mode_Selection_2 := False;
This.SMCR.Slave_Mode_Selection := UInt3 (Mode'Enum_Rep);
when Encoder_Mode_1 .. Quadrature_Encoder_Mode_5 =>
This.SMCR.Slave_Mode_Selection_2 := True;
This.SMCR.Slave_Mode_Selection := UInt3 (Mode'Enum_Rep);
end case;
Write_Channel_Input_Description
(This,
Channel => Channel_1,
Kind => Direct_TI,
Description => Lower_Channel_Input_Descriptor'(ICxFilter => No_Filter,
ICxPrescaler => Div1));
Write_Channel_Input_Description
(This,
Channel => Channel_2,
Kind => Direct_TI,
Description => Lower_Channel_Input_Descriptor'(ICxFilter => No_Filter,
ICxPrescaler => Div1));
case IC1_Polarity is
when Rising =>
This.CCER (Channel_1).CCxNP := 0;
This.CCER (Channel_1).CCxP := 0;
when Falling =>
This.CCER (Channel_1).CCxNP := 0;
This.CCER (Channel_1).CCxP := 1;
when Both_Edges =>
This.CCER (Channel_1).CCxNP := 1;
This.CCER (Channel_1).CCxP := 1;
end case;
case IC2_Polarity is
when Rising =>
This.CCER (Channel_2).CCxNP := 0;
This.CCER (Channel_2).CCxP := 0;
when Falling =>
This.CCER (Channel_2).CCxNP := 0;
This.CCER (Channel_2).CCxP := 1;
when Both_Edges =>
This.CCER (Channel_2).CCxNP := 1;
This.CCER (Channel_2).CCxP := 1;
end case;
end Configure_Encoder_Interface;
------------------------
-- Enable_Hall_Sensor --
------------------------
procedure Enable_Hall_Sensor
(This : in out Timer)
is
begin
This.CR2.TI1_Selection := True;
end Enable_Hall_Sensor;
-------------------------
-- Disable_Hall_Sensor --
-------------------------
procedure Disable_Hall_Sensor
(This : in out Timer)
is
begin
This.CR2.TI1_Selection := False;
end Disable_Hall_Sensor;
end STM32.Timers;
|
src/metadslx.soal.runtime/src/generated/resources/SoalParser.g4 | balazssimon/soal-java | 0 | 6038 | <reponame>balazssimon/soal-java<gh_stars>0
parser grammar SoalParser;
options {
tokenVocab=SoalLexer;
}
@header {
import metadslx.core.ResolutionLocation;
}
main : namespaceDeclaration*;
qualifiedName : identifier (TDot identifier)*;
identifierList : identifier (TComma identifier)*;
qualifiedNameList : qualifiedName (TComma qualifiedName)*;
annotationList : annotation+;
returnAnnotationList : returnAnnotation+;
annotation : TOpenBracket annotationBody TCloseBracket;
returnAnnotation : TOpenBracket KReturn TColon annotationBody TCloseBracket;
annotationBody : identifier annotationProperties?;
annotationProperties : TOpenParen annotationPropertyList? TCloseParen;
annotationPropertyList : annotationProperty (TComma annotationProperty)*;
annotationProperty : identifier TAssign annotationPropertyValue;
annotationPropertyValue
: constantValue
| typeofValue
;
namespaceDeclaration: annotationList? KNamespace qualifiedName TAssign ( identifier TColon)? stringLiteral TOpenBrace declaration* TCloseBrace;
declaration : enumDeclaration | structDeclaration | databaseDeclaration | interfaceDeclaration | componentDeclaration | compositeDeclaration | assemblyDeclaration | bindingDeclaration | endpointDeclaration | deploymentDeclaration;
// Enums
enumDeclaration : annotationList? KEnum identifier (TColon qualifiedName)? TOpenBrace enumLiterals? TCloseBrace;
enumLiterals : enumLiteral (TComma enumLiteral)* TComma?;
enumLiteral : annotationList? identifier;
// Structs and exceptions
structDeclaration : annotationList? KStruct identifier (TColon qualifiedName)? TOpenBrace propertyDeclaration* TCloseBrace;
propertyDeclaration : annotationList? typeReference identifier TSemicolon;
// Database
databaseDeclaration : annotationList? KDatabase identifier TOpenBrace entityReference* operationDeclaration* TCloseBrace;
entityReference : KEntity qualifiedName TSemicolon;
// Interface
interfaceDeclaration : annotationList? KInterface identifier TOpenBrace operationDeclaration* TCloseBrace;
operationDeclaration : annotationList? operationResult identifier TOpenParen parameterList? TCloseParen (KThrows qualifiedNameList)? TSemicolon;
parameterList : parameter (',' parameter)*;
parameter : annotationList? typeReference identifier;
operationResult : returnAnnotationList? ( returnType| onewayType);
// Component
componentDeclaration : KAbstract? KComponent identifier (TColon qualifiedName)? TOpenBrace componentElements? TCloseBrace;
componentElements : componentElement+;
componentElement
: componentService
| componentReference
| componentProperty
| componentImplementation
| componentLanguage
;
componentService : KService qualifiedName identifier? componentServiceOrReferenceBody;
componentReference : KReference qualifiedName identifier? componentServiceOrReferenceBody;
componentServiceOrReferenceBody
: TSemicolon
| TOpenBrace componentServiceOrReferenceElement* TCloseBrace;
componentServiceOrReferenceElement
: KBinding qualifiedName TSemicolon;
componentProperty : typeReference identifier TSemicolon;
componentImplementation : KImplementation identifier TSemicolon;
componentLanguage : KLanguage identifier TSemicolon;
compositeDeclaration : KComposite identifier (TColon qualifiedName)? TOpenBrace compositeElements? TCloseBrace;
assemblyDeclaration : KAssembly identifier (TColon qualifiedName)? TOpenBrace compositeElements? TCloseBrace;
compositeElements : compositeElement+;
compositeElement
: componentService
| componentReference
| componentProperty
| componentImplementation
| componentLanguage
| compositeComponent
| compositeWire
;
compositeComponent : KComponent qualifiedName TSemicolon;
compositeWire : KWire wireSource KTo wireTarget TSemicolon;
wireSource : qualifiedName;
wireTarget : qualifiedName;
deploymentDeclaration : KDeployment identifier TOpenBrace deploymentElements? TCloseBrace;
deploymentElements : deploymentElement+;
deploymentElement
: environmentDeclaration
| compositeWire
;
environmentDeclaration : KEnvironment identifier TOpenBrace runtimeDeclaration runtimeReference* TCloseBrace;
runtimeDeclaration : KRuntime identifier TSemicolon;
runtimeReference
: assemblyReference
| databaseReference
;
assemblyReference : KAssembly qualifiedName TSemicolon;
databaseReference : KDatabase qualifiedName TSemicolon;
// Binding
bindingDeclaration : KBinding identifier TOpenBrace bindingLayers? TCloseBrace;
bindingLayers : transportLayer encodingLayer+ protocolLayer*;
transportLayer
: httpTransportLayer
| restTransportLayer
| webSocketTransportLayer
;
httpTransportLayer : KTransport IHTTP (TSemicolon | TOpenBrace httpTransportLayerProperties* TCloseBrace);
restTransportLayer : KTransport IREST (TSemicolon | TOpenBrace TCloseBrace);
webSocketTransportLayer : KTransport IWebSocket (TSemicolon | TOpenBrace TCloseBrace);
httpTransportLayerProperties
: httpSslProperty
| httpClientAuthenticationProperty
;
httpSslProperty : ISSL TAssign booleanLiteral TSemicolon;
httpClientAuthenticationProperty : IClientAuthentication TAssign booleanLiteral TSemicolon;
encodingLayer
: soapEncodingLayer
| xmlEncodingLayer
| jsonEncodingLayer
;
soapEncodingLayer : KEncoding ISOAP (TSemicolon | TOpenBrace soapEncodingProperties* TCloseBrace);
xmlEncodingLayer : KEncoding IXML (TSemicolon | TOpenBrace TCloseBrace);
jsonEncodingLayer : KEncoding IJSON (TSemicolon | TOpenBrace TCloseBrace);
soapEncodingProperties
: soapVersionProperty
| soapMtomProperty
| soapStyleProperty
;
soapVersionProperty : IVersion TAssign identifier TSemicolon;
soapMtomProperty : IMTOM TAssign booleanLiteral TSemicolon;
soapStyleProperty : IStyle TAssign identifier TSemicolon;
protocolLayer : KProtocol protocolLayerKind TSemicolon;
protocolLayerKind :
identifier;
// Endpoint:
endpointDeclaration : KEndpoint identifier TColon qualifiedName TOpenBrace endpointProperties? TCloseBrace;
endpointProperties : endpointProperty+;
endpointProperty
: endpointBindingProperty
| endpointAddressProperty
;
endpointBindingProperty : KBinding qualifiedName TSemicolon;
endpointAddressProperty : KAddress stringLiteral TSemicolon;
// Types
returnType
: typeReference
| voidType
;
typeReference
: nonNullableArrayType
| arrayType
| simpleType
| nulledType
;
simpleType : valueType | objectType | qualifiedName;
nulledType : nullableType | nonNullableType;
referenceType : objectType | qualifiedName;
objectType
: KObject
| KString
;
valueType
: KInt
| KLong
| KFloat
| KDouble
| KByte
| KBool
| IDate
| ITime
| IDateTime
| ITimeSpan
;
voidType
: KVoid
;
onewayType
: KOneway
;
nullableType : valueType TQuestion;
nonNullableType : referenceType TExclamation;
nonNullableArrayType : arrayType TExclamation;
arrayType
: simpleArrayType
| nulledArrayType
;
simpleArrayType : simpleType TOpenBracket TCloseBracket;
nulledArrayType : nulledType TOpenBracket TCloseBracket;
constantValue
: literal
| identifier
;
typeofValue : KTypeof TOpenParen returnType TCloseParen;
// Identifiers
identifier
: IdentifierNormal
| IdentifierVerbatim
| contextualKeywords;
// Literals
literal
: nullLiteral
| booleanLiteral
| integerLiteral
| decimalLiteral
| scientificLiteral
| stringLiteral
;
// Null literal
nullLiteral : KNull;
// Boolean literals
booleanLiteral : KTrue | KFalse;
// Number literals
integerLiteral : IntegerLiteral;
decimalLiteral : DecimalLiteral;
scientificLiteral : ScientificLiteral;
// String literals
stringLiteral
: RegularStringLiteral
| SingleQuoteVerbatimStringLiteral
| DoubleQuoteVerbatimStringLiteral;
contextualKeywords
: IDate
| ITime
| IDateTime
| ITimeSpan
| IVersion
| IStyle
| IMTOM
| ISSL
| IHTTP
| IREST
| IWebSocket
| ISOAP
| IXML
| IJSON
| IClientAuthentication
;
|
wof/lcs/base/32A.asm | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | 6 | 176754 | <gh_stars>1-10
copyright zengfr site:http://github.com/zengfr/romhack
001658 move.w A0, -(A4) [base+32A]
00165A move.w A4, ($32a,A5) [base+50A, base+50C, base+50E]
00165E addq.w #1, ($31e,A5) [base+32A]
01A68E move.w D0, ($31e,A5) [base+32A]
021CE4 move.w D0, ($31e,A5) [base+32A]
copyright zengfr site:http://github.com/zengfr/romhack
|
test-roms/multiply.asm | martinkauppinen/gibberish | 1 | 19490 | SECTION "Header", ROM0[$100]
jp start
ds $150 - @, 0 ; Header
start:
ld de, $dead ; Values to check that stack
ld hl, $beef ; popping works as intended
ld a, $0
ld b, $1
call multiply
ld a, $2
ld b, $2
call multiply
ld a, $5
ld b, $3
call multiply
ld a, $F
ld b, $F
call multiply
di
; Enable V-Blank interrupt
ld hl, $FFFF
ld a, 1
ld [hl], a
; Request V-Blank interrupt
ld hl, $FF0F
ld [hl], a
ld hl, $0040
ld a, $D3 ; Invalid opcode
ld [hl], a
ei ; This will crash the emulator
nop
; Multiply A with B through repeated addition
; Result is stored in A
multiply:
; Early quit if one factor is zero
push hl
ld h, $0
cp h
pop hl
ret z
call swap_ab
push hl
ld h, $0
cp h
pop hl
ret z
push de
ld d, a
ld a, $0
loop:
add a, b
dec d
jp nz, loop
pop de
ret
; Swap contents of registers A and B
swap_ab:
push de
ld d, a
ld a, b
ld b, d
pop de
ret
|
src/intel/tools/tests/gen7/halt.asm | PWN-Hunter/mesa3d | 0 | 92828 | <filename>src/intel/tools/tests/gen7/halt.asm<gh_stars>0
(-f0.1.any4h) halt(8) JIP: 72 UIP: 74 { align1 1Q };
halt(8) JIP: 2 UIP: 2 { align1 1Q };
(-f0.1.any4h) halt(16) JIP: 76 UIP: 78 { align1 1H };
halt(16) JIP: 2 UIP: 2 { align1 1H };
|
libsrc/_DEVELOPMENT/arch/zx/bifrost2/c/sdcc/BIFROST2_drawTileH_callee.asm | jpoikela/z88dk | 640 | 90934 | <filename>libsrc/_DEVELOPMENT/arch/zx/bifrost2/c/sdcc/BIFROST2_drawTileH_callee.asm
; ----------------------------------------------------------------
; Z88DK INTERFACE LIBRARY FOR THE BIFROST*2 ENGINE
;
; See "bifrost2.h" for further details
; ----------------------------------------------------------------
; void BIFROST2_drawTileH(unsigned char lin,unsigned char col,unsigned char tile)
; callee
SECTION code_clib
SECTION code_bifrost2
PUBLIC _BIFROST2_drawTileH_callee
EXTERN asm_BIFROST2_drawTileH
_BIFROST2_drawTileH_callee:
pop hl
dec sp
pop de ; D = lin
ex (sp),hl
ld e,l ; E = col
ld a,h ; A = tile
jp asm_BIFROST2_drawTileH
|
src/compiling/ANTLR/grammar/SpecifyPathDelays.g4 | jecassis/VSCode-SystemVerilog | 75 | 5683 | <filename>src/compiling/ANTLR/grammar/SpecifyPathDelays.g4
grammar SpecifyPathDelays;
import SystemTimingChecks;
path_delay_value : list_of_path_delay_expressions | '(' list_of_path_delay_expressions ')' ;
list_of_path_delay_expressions : t_path_delay_expression
| trise_path_delay_expression ',' tfall_path_delay_expression
| trise_path_delay_expression ',' tfall_path_delay_expression ',' tz_path_delay_expression
| t01_path_delay_expression ',' t10_path_delay_expression ',' t0z_path_delay_expression ','
tz1_path_delay_expression ',' t1z_path_delay_expression ',' tz0_path_delay_expression
| t01_path_delay_expression ',' t10_path_delay_expression ',' t0z_path_delay_expression ','
tz1_path_delay_expression ',' t1z_path_delay_expression ',' tz0_path_delay_expression ','
t0x_path_delay_expression ',' tx1_path_delay_expression ',' t1x_path_delay_expression ','
tx0_path_delay_expression ',' txz_path_delay_expression ',' tzx_path_delay_expression ;
t_path_delay_expression : path_delay_expression ;
trise_path_delay_expression : path_delay_expression ;
tfall_path_delay_expression : path_delay_expression ;
tz_path_delay_expression : path_delay_expression ;
t01_path_delay_expression : path_delay_expression ;
t10_path_delay_expression : path_delay_expression ;
t0z_path_delay_expression : path_delay_expression ;
tz1_path_delay_expression : path_delay_expression ;
t1z_path_delay_expression : path_delay_expression ;
tz0_path_delay_expression : path_delay_expression ;
t0x_path_delay_expression : path_delay_expression ;
tx1_path_delay_expression : path_delay_expression ;
t1x_path_delay_expression : path_delay_expression ;
tx0_path_delay_expression : path_delay_expression ;
txz_path_delay_expression : path_delay_expression ;
tzx_path_delay_expression : path_delay_expression ;
path_delay_expression : constant_mintypmax_expression ;
edge_sensitive_path_declaration : parallel_edge_sensitive_path_description '=' path_delay_value
| full_edge_sensitive_path_description '=' path_delay_value ;
parallel_edge_sensitive_path_description :
'(' ( edge_identifier )? specify_input_terminal_descriptor ( polarity_operator )? '=>'
'(' specify_output_terminal_descriptor ( polarity_operator )? ':' data_source_expression ')' ')' ;
full_edge_sensitive_path_description : '(' ( edge_identifier )? list_of_path_inputs
( polarity_operator )? '*>' '(' list_of_path_outputs ( polarity_operator )? ':'
data_source_expression ')' ')' ;
data_source_expression : expression ;
edge_identifier : 'posedge' | 'negedge' | 'edge' ;
state_dependent_path_declaration : 'if' '(' module_path_expression ')' simple_path_declaration
| 'if' '(' module_path_expression ')' edge_sensitive_path_declaration
| 'ifnone' simple_path_declaration ;
polarity_operator : '+' | '-' ;
|
src/sound.ads | JeremyGrosser/the_grid | 0 | 5815 | <filename>src/sound.ads
with RP.PWM;
package Sound is
type Octaves is range 0 .. 11;
type Notes is (C, Cs, D, Ds, E, F, Fs, G, Gs, A, As, B);
subtype Milliseconds is Natural;
procedure Initialize;
procedure Update;
procedure Play
(Note : Notes;
Octave : Octaves;
Length : Milliseconds);
-- Length = 0 will play until Stop or Play are called.
function Is_Playing
return Boolean;
-- Stop playing immediately, aborts any in progress playback
procedure Stop;
private
-- See finddiv.py
Lookup_Div : constant array (Octaves) of RP.PWM.Divider :=
(77.5625, 36.0000, 18.0000, 9.0000, 4.5000, 2.2500, 1.1250, 1.0000, 1.2500, 1.2500, 1.2500, 1.1875);
Lookup_Interval : constant array (Octaves, Notes) of RP.PWM.Period := (
0 => (58603, 55314, 52210, 49279, 46513, 43903, 41439, 39113, 36918, 34846, 32890, 31044),
1 .. 6 => (63131, 59588, 56243, 53086, 50107, 47295, 44640, 42135, 39770, 37538, 35431, 33442),
7 => (35511, 33518, 31637, 29861, 28185, 26603, 25110, 23700, 22370, 21115, 19930, 18811),
8 => (14204, 13407, 12654, 11944, 11274, 10641, 10044, 9480, 8948, 8446, 7972, 7524),
9 => (7102, 6703, 6327, 5972, 5637, 5320, 5022, 4740, 4474, 4223, 3986, 3762),
10 => (3551, 3351, 3163, 2986, 2818, 2660, 2511, 2370, 2237, 2111, 1993, 1881),
11 => (1869, 1764, 1665, 1571, 1483, 1400, 1321, 1247, 1177, 1111, 1048, 990)
);
end Sound;
|
oeis/293/A293639.asm | neoneye/loda-programs | 11 | 1072 | ; A293639: a(n) is the greatest integer k such that k/Fibonacci(n) < 2/5.
; Submitted by <NAME>
; 0,0,0,0,1,2,3,5,8,13,22,35,57,93,150,244,394,638,1033,1672,2706,4378,7084,11462,18547,30010,48557,78567,127124,205691,332816,538507,871323,1409831,2281154,3690986,5972140,9663126,15635267,25298394,40933662,66232056,107165718,173397774,280563493,453961268,734524761,1188486029,1923010790,3111496819,5034507610,8146004429,13180512039,21326516469,34507028508,55833544978,90340573486,146174118464,236514691951,382688810416,619203502368,1001892312784,1621095815152,2622988127936,4244083943089
mov $3,1
lpb $0
sub $0,1
mov $2,$3
add $3,$1
mov $1,$2
lpe
mov $0,$1
mul $0,2
div $0,5
|
src/_test/scenarios/apsepp_test_node_class_early_test_case.ads | thierr26/ada-apsepp | 0 | 12815 | <reponame>thierr26/ada-apsepp
-- Copyright (C) 2019 <NAME> <<EMAIL>>
-- MIT license. Please refer to the LICENSE file.
with Ada.Tags; use Ada.Tags;
with Apsepp.Test_Node_Class.Testing; use Apsepp.Test_Node_Class.Testing;
with Apsepp.Abstract_Early_Test_Case; use Apsepp.Abstract_Early_Test_Case;
package Apsepp_Test_Node_Class_Early_Test_Case is
function Expected_Routine_State_Array return Routine_State_Array;
function Routine_State_Array_To_Tag_Array
(A : Routine_State_Array) return Tag_Array
with Post => Routine_State_Array_To_Tag_Array'Result'First = A'First
and then
Routine_State_Array_To_Tag_Array'Result'Length = A'Length
and then
(for all K in A'Range
=> Routine_State_Array_To_Tag_Array'Result(K) = A(K).T);
type Apsepp_Test_Node_Class_E_T_C
is limited new Early_Test_Case with null record;
overriding
function Early_Routine
(Obj : Apsepp_Test_Node_Class_E_T_C) return Test_Routine;
end Apsepp_Test_Node_Class_Early_Test_Case;
|
Transynther/x86/_processed/NC/_st_zr_sm_/i7-7700_9_0xca.log_21829_1678.asm | ljhsiun2/medusa | 9 | 22425 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r9
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x18542, %rsi
lea addresses_A_ht+0x1d602, %rdi
nop
nop
nop
nop
xor %r9, %r9
mov $4, %rcx
rep movsq
inc %r10
lea addresses_A_ht+0xc842, %rsi
lea addresses_WC_ht+0x1142, %rdi
nop
nop
nop
add %rdx, %rdx
mov $59, %rcx
rep movsw
nop
sub $38411, %rsi
lea addresses_normal_ht+0x140b2, %rdi
nop
nop
add %rbp, %rbp
mov (%rdi), %rsi
nop
nop
nop
nop
nop
and %rbp, %rbp
lea addresses_D_ht+0x22c2, %r10
nop
nop
nop
nop
and %rdi, %rdi
movb (%r10), %cl
nop
nop
nop
sub %rbp, %rbp
lea addresses_WC_ht+0x14e42, %rsi
clflush (%rsi)
nop
nop
cmp $63758, %rcx
vmovups (%rsi), %ymm5
vextracti128 $1, %ymm5, %xmm5
vpextrq $1, %xmm5, %rdi
nop
nop
nop
nop
add $39582, %rdx
lea addresses_WC_ht+0x1b042, %r9
nop
and $58125, %rdx
mov (%r9), %rcx
inc %rbp
lea addresses_normal_ht+0x15728, %rsi
lea addresses_D_ht+0x4577, %rdi
nop
nop
nop
and %r10, %r10
mov $27, %rcx
rep movsl
add $61788, %r9
lea addresses_A_ht+0x39e2, %rsi
lea addresses_WC_ht+0xaf02, %rdi
nop
nop
cmp $31928, %rbx
mov $12, %rcx
rep movsl
nop
nop
dec %rdx
lea addresses_normal_ht+0x124de, %r10
add %rbx, %rbx
movw $0x6162, (%r10)
nop
nop
sub %rsi, %rsi
lea addresses_WC_ht+0x16418, %rsi
nop
xor %rcx, %rcx
mov $0x6162636465666768, %rbp
movq %rbp, %xmm0
vmovups %ymm0, (%rsi)
cmp %rdx, %rdx
lea addresses_UC_ht+0xc042, %rsi
nop
nop
nop
nop
nop
sub %rbp, %rbp
mov $0x6162636465666768, %rdi
movq %rdi, %xmm1
movups %xmm1, (%rsi)
nop
nop
and $32350, %rbx
lea addresses_UC_ht+0x9042, %rsi
nop
nop
dec %r9
movl $0x61626364, (%rsi)
nop
nop
nop
nop
and $44834, %r10
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r9
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r14
push %r15
push %r8
push %rdi
push %rsi
// Store
mov $0x442, %r14
add $13373, %rsi
movl $0x51525354, (%r14)
nop
nop
nop
inc %rsi
// Load
mov $0x6033cc0000000042, %r15
nop
nop
nop
and %rdi, %rdi
movntdqa (%r15), %xmm5
vpextrq $0, %xmm5, %rsi
nop
nop
nop
nop
xor $42706, %r11
// Store
mov $0x6033cc0000000042, %r15
nop
nop
nop
cmp $22730, %rsi
mov $0x5152535455565758, %r14
movq %r14, %xmm7
vmovups %ymm7, (%r15)
nop
xor $38218, %rsi
// Store
mov $0x6033cc0000000042, %rdi
nop
sub $60510, %r14
movb $0x51, (%rdi)
nop
nop
add $30474, %r11
// Load
lea addresses_A+0x7042, %rdi
clflush (%rdi)
add %r15, %r15
mov (%rdi), %esi
nop
nop
sub %r11, %r11
// Faulty Load
mov $0x6033cc0000000042, %r15
clflush (%r15)
nop
nop
nop
nop
nop
sub %rsi, %rsi
mov (%r15), %r11d
lea oracles, %r10
and $0xff, %r11
shlq $12, %r11
mov (%r10,%r11,1), %r11
pop %rsi
pop %rdi
pop %r8
pop %r15
pop %r14
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_P'}}
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': True, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 32, 'NT': False, 'type': 'addresses_NC'}}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_NC'}}
{'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_A'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_A_ht'}}
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 8, 'NT': True, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 8, 'NT': True, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 1, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 5, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 6, 'same': True, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': True, 'size': 2, 'NT': True, 'type': 'addresses_normal_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_UC_ht'}}
{'00': 2073, '51': 19756}
51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 00 51 00 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 00 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 00 51 51 51 00 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 00 51 51 00 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 00 51 51 51 51 51 51 51 51 51 51 51 00 51 51 00 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 00 51 51 00 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 00 51 51 51 51 51 00 51 51 51 51 51 00 51 51 51 51 51 51 51 00 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 00 51 51 00 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 00 51 51 51 51 51 00 51 51 51 51 00 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 00 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 00 51 51 51 51 00 51 51 51 00 51 51 51 51 00 51 00 51 51 51 00 51 51 51 51 51 51 51 51 00 51 00 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 00 51 00 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 00 51 00 51 51 51 00 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 00 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 00 51 51 51 51 51
*/
|
FormalAnalyzer/models/apps/ItsTooHot.als | Mohannadcse/IoTCOM_BehavioralRuleExtractor | 0 | 4604 | module app_ItsTooHot
open IoTBottomUp as base
open cap_runIn
open cap_now
open cap_temperatureMeasurement
open cap_switch
open cap_userInput
one sig app_ItsTooHot extends IoTApp {
temperatureSensor1 : one cap_temperatureMeasurement,
switch1 : one cap_switch,
sendPushMessage : one cap_userInput,
} {
rules = r
//capabilities = temperatureSensor1 + switch1 + sendPushMessage
}
abstract sig cap_userInput_attr_sendPushMessage_val extends cap_userInput_attr_value_val {}
one sig cap_userInput_attr_sendPushMessage_val_Yes extends cap_userInput_attr_sendPushMessage_val {}
one sig cap_userInput_attr_sendPushMessage_val_No extends cap_userInput_attr_sendPushMessage_val {}
one sig range_0,range_1 extends cap_temperatureMeasurement_attr_temperature_val {}
abstract sig r extends Rule {}
one sig r0 extends r {}{
triggers = r0_trig
conditions = r0_cond
commands = r0_comm
}
abstract sig r0_trig extends Trigger {}
one sig r0_trig0 extends r0_trig {} {
capabilities = app_ItsTooHot.temperatureSensor1
attribute = cap_temperatureMeasurement_attr_temperature
no value
}
abstract sig r0_cond extends Condition {}
one sig r0_cond0 extends r0_cond {} {
capabilities = app_ItsTooHot.temperatureSensor1
attribute = cap_temperatureMeasurement_attr_temperature
value = range_1//cap_temperatureMeasurement_attr_temperature_val_gte_tooHot
}
abstract sig r0_comm extends Command {}
one sig r0_comm0 extends r0_comm {} {
capability = app_ItsTooHot.switch1
attribute = cap_switch_attr_switch
value = cap_switch_attr_switch_val_on
}
|
programs/oeis/184/A184654.asm | neoneye/loda | 22 | 160910 | <gh_stars>10-100
; A184654: floor(n*sqrt(3)-2/3); complement of A184655.
; 1,2,4,6,7,9,11,13,14,16,18,20,21,23,25,27,28,30,32,33,35,37,39,40,42,44,46,47,49,51,53,54,56,58,59,61,63,65,66,68,70,72,73,75,77,79,80,82,84,85,87,89,91,92,94,96,98,99,101,103,104,106,108,110,111,113,115,117,118,120,122,124,125,127,129,130,132,134,136,137,139,141,143,144,146,148,150,151,153,155,156,158,160,162,163,165,167,169,170,172
mov $2,$0
mul $0,2
mov $1,$0
mul $0,6
div $1,7
sub $0,$1
div $0,16
add $0,1
add $0,$2
|
spec/assert_x_not_equal_spec.asm | andrzejsliwa/64spec | 53 | 12175 | <filename>spec/assert_x_not_equal_spec.asm
.import source "64spec.asm"
sfspec: :init_spec()
assert_x_not_equal_works_for_all_values_of_x: {
.var x = floor(random()*256)
.print "x = " + x + " in assert_x_not_equal_works_for_all_values_of_x test"
.for (var expected = 0;expected < 256; expected++) {
.if (x != expected) {
ldx #x
:assert_x_not_equal #expected
} else {
ldx #x
:assert_x_not_equal #expected: _64SPEC.assertion_failed_subroutine: _64SPEC.assertion_passed_subroutine
}
}
}
assert_x_not_equal_does_not_affect_x:
.var x = floor(random()*256)
.print "x = " + x + " in assert_x_not_equal_works_for_all_values_of_x test"
ldx #x
.for (var expected = 0;expected < 256; expected++) {
.if (x != expected) {
:assert_x_not_equal #expected
} else {
:assert_x_not_equal #expected: _64SPEC.assertion_failed_subroutine: _64SPEC.assertion_passed_subroutine
}
:assert_x_equal #x
}
:finish_spec()
|
src/boot.asm | drdanick/apricot-os | 0 | 80724 | <filename>src/boot.asm
; asmsyntax=apricos
; ===================================
; == ==
; == ApricotOS Stage 1 Bootloader ==
; == ==
; == Revision 1 ==
; == ==
; == (C) 2014-17 <NAME> ==
; == ==
; == ==
; == Provides a stage 1 bootloader ==
; == which loads a stage 2 ==
; == bootloader from the first ==
; == logical disk and executes it. ==
; == ==
; ===================================
;
#name "bootloader"
#segment 0
;=========================================
;== ==
;== MACROS ==
;== ==
;=========================================
; Clear the Screen
#macro CLS {
LARl 0x12
PRTout 7
PRTout 7
}
; Set the current TTY mode
#macro TTY_MODE mode {
LARl mode
PRTout 7
}
;=========================================
;== ==
;== MAIN ROUTINE ==
;== ==
;=========================================
;TODO: TTY should not have the cursor invisible by default
TTY_MODE 0x03 ; End any previous TTY command
CLS ; Clear screen
LARl 0x0C
PRTout 7
LARl 2
PRTout 7
ASET 8 ; Enable line mode, zero $a8, and enable line character output on TTY.
LARl 0x7F
PRTout 7
AND 0
PRTout 7
; Use $a14 to hold the sleep period (we will use 1000ms, so $a14 must hold 100)
ASET 14
LARl 100
; Select first disk and try to read.
; Give up on 3rd attempt and print error
ASET 1 ; $a1 will hold a negation of the counter we want (-3)
LARl 0xFD ; 0xFD is -3
ASET 0 ; Use $a0 to hold the ID of disk 0
AND 0
LOAD_DISK:
ASET 0
PRTout 0x03
; Get disk status
ASET 2
PRTin 0x03
; Check if it is equal to -1 (or -1 + 0 = 0)
ADD 1
BRnp CHECK_DISK
; Increment counter, pause, and jump if counter is negative or zero
ASET 14
PRTout 0x00
ASET 1
ADD 1
BRnz LOAD_DISK
; If counter is positive, print an error and halt.
ASET 9
LARl DISK_READ_ERROR
JMP INVALID_DISK
; Check that the disk is bootable
CHECK_DISK:
; Select track 0
ASET 15
AND 0
PRTout 0x04
; NOTE: The disk paging sector is 0xFE
LAh 0xFE ; Use $a15 to hold the base address of the disk paging region
LDah
ASET 0 ; Use $a0 to hold the disk segment number we want to read
LARl 0x3E
; Load sector 0x3E
PRTout 0x05
; Check that the first 4 bytes of this sector are 0xC0, 0x30, 0x0C, and 0x03 (xoring them together will produce 0xFF)
ASET 15
STah
AND 0
STal
ASET 10
LD ; Load first char
SPUSH
LDal
ADD 1
STal
LD ; Load second char
SPUSH
LDal
ADD 1
STal
LD ; Load third char
SPUSH
LDal
ADD 1
STal
LD ; Load fourth char
SPOP XOR ; Pop the other three characters
SPOP XOR
SPOP XOR
ADD 1 ; Adding 1 should make it equal to zero
BRz BOOT_CODE_CHECK
; Disk is not valid
ASET 9
LARl DISK_FORMAT_ERROR
JMP INVALID_DISK
BOOT_CODE_CHECK:
; Check that the last 2 bytes of this sector are 0xAA and 0x55 (xoring them together will produce 0xFF)
ASET 15
LDah
STal ; Load the first byte
ASET 10
LD
SPUSH
; Load the second byte
LDal
ADD 1
STal
LD
SPOP XOR
ADD 1 ; Adding 1 should make it equal to zero
BRz COPY_LOADER
; Disk is not bootable
ASET 9
LARl DISK_NOT_BOOTABLE_ERROR
; Common code for printing an error and then halting
; $a9 must already hold the segment local address of the string to print.
INVALID_DISK:
ASET 10
LARl HALT
SPUSH
JMP PRINT_STRING
; Disk is bootable. Copy the first 128 sectors into memory.
COPY_LOADER:
; Print a loading message
ASET 9
LARl END_LOAD_MESSAGE
SPUSH
LARl LOADING
JMP PRINT_STRING
END_LOAD_MESSAGE:
ASET 1 ; Use $a1 to store the value of -4 (negative number of sectors we want to load)
LARl 252 ; On a signed 8-bit machine, this is equivalent to -4.
ASET 0 ; Use $a0 to store the sector currently being read from disk (the block being written to is this + 1)
AND 0
LOADER_COPY_LOOP:
ASET 0
PRTout 0x05 ; Load the next sector from disk
ADD 1 ; Increment sector (this now points to the sector we are writing to in memory)
ASET 3 ; Use $a3 as a counter for the inner copy loop which must run exactly 256 times (increment until it overflows back to zero)
AND 0
COPY_SEGMENT_LOOP:
STal ; Set sector local address
ASET 15 ; Set sector address to disk paging area
STah
ASET 4 ; Temporary register for loading values
LD ; Load from the disk paging area
ASET 0 ; Set the sector address to the sector we're writing to
STah
ASET 4
ST ; Write to memory
ASET 3 ; Increment memory location being written to
ADD 1
BRnp COPY_SEGMENT_LOOP ; Repeat if our counter hasn't overflown yet
ASET 1
ADD 1
BRnp LOADER_COPY_LOOP
; Set the address of the first loaded segment, and prepare to jump to it
LAh 1
LAl 0
; Jump to first loaded segment
JMP
; Shared print routine.
; TTY must already be in line mode.
; Segment local return address must be on the stack.
;
; $a8 - Segment number of string to print
; $a9 - Segment local address of string to print
;
; Volatile registers:
; $a9
;
PRINT_STRING:
ASET 8
STah
ASET 9
PRINT_LOOP:
STal
SPUSH
LD
BRz PRINT_END
PRTout 0x07
SPOP
ADD 1
JMP PRINT_LOOP
PRINT_END:
SPOP ; Pop residual address
SPOP
STal
JMP
; Halt the CPU
;
; $a14 - The sleep delay to use in the busy loop
;
HALT:
ASET 14
PRTout 0x00
JMP
; Messages
DISK_READ_ERROR: .stringz "Disk read error!"
DISK_NOT_BOOTABLE_ERROR: .stringz "Disk 0 not bootable!"
DISK_FORMAT_ERROR: .stringz "Disk 0 not valid!"
LOADING: .stringz "Loading Operating System..."
|
forktest.asm | kishan1468/memory-management-in-xv6 | 0 | 93753 | <reponame>kishan1468/memory-management-in-xv6
_forktest: file format elf32-i386
Disassembly of section .text:
00001000 <main>:
printf(1, "fork test OK\n");
}
int
main(void)
{
1000: f3 0f 1e fb endbr32
1004: 55 push %ebp
1005: 89 e5 mov %esp,%ebp
1007: 83 e4 f0 and $0xfffffff0,%esp
forktest();
100a: e8 41 00 00 00 call 1050 <forktest>
exit();
100f: e8 9f 03 00 00 call 13b3 <exit>
1014: 66 90 xchg %ax,%ax
1016: 66 90 xchg %ax,%ax
1018: 66 90 xchg %ax,%ax
101a: 66 90 xchg %ax,%ax
101c: 66 90 xchg %ax,%ax
101e: 66 90 xchg %ax,%ax
00001020 <printf>:
{
1020: f3 0f 1e fb endbr32
1024: 55 push %ebp
1025: 89 e5 mov %esp,%ebp
1027: 53 push %ebx
1028: 83 ec 10 sub $0x10,%esp
102b: 8b 5d 0c mov 0xc(%ebp),%ebx
write(fd, s, strlen(s));
102e: 53 push %ebx
102f: e8 9c 01 00 00 call 11d0 <strlen>
1034: 83 c4 0c add $0xc,%esp
1037: 50 push %eax
1038: 53 push %ebx
1039: ff 75 08 pushl 0x8(%ebp)
103c: e8 92 03 00 00 call 13d3 <write>
}
1041: 8b 5d fc mov -0x4(%ebp),%ebx
1044: 83 c4 10 add $0x10,%esp
1047: c9 leave
1048: c3 ret
1049: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00001050 <forktest>:
{
1050: f3 0f 1e fb endbr32
1054: 55 push %ebp
1055: 89 e5 mov %esp,%ebp
1057: 53 push %ebx
for(n=0; n<N; n++){
1058: 31 db xor %ebx,%ebx
{
105a: 83 ec 10 sub $0x10,%esp
write(fd, s, strlen(s));
105d: 68 64 14 00 00 push $0x1464
1062: e8 69 01 00 00 call 11d0 <strlen>
1067: 83 c4 0c add $0xc,%esp
106a: 50 push %eax
106b: 68 64 14 00 00 push $0x1464
1070: 6a 01 push $0x1
1072: e8 5c 03 00 00 call 13d3 <write>
1077: 83 c4 10 add $0x10,%esp
107a: eb 15 jmp 1091 <forktest+0x41>
107c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(pid == 0)
1080: 74 58 je 10da <forktest+0x8a>
for(n=0; n<N; n++){
1082: 83 c3 01 add $0x1,%ebx
1085: 81 fb e8 03 00 00 cmp $0x3e8,%ebx
108b: 0f 84 92 00 00 00 je 1123 <forktest+0xd3>
pid = fork();
1091: e8 15 03 00 00 call 13ab <fork>
if(pid < 0)
1096: 85 c0 test %eax,%eax
1098: 79 e6 jns 1080 <forktest+0x30>
for(; n > 0; n--){
109a: 85 db test %ebx,%ebx
109c: 74 10 je 10ae <forktest+0x5e>
109e: 66 90 xchg %ax,%ax
if(wait() < 0){
10a0: e8 16 03 00 00 call 13bb <wait>
10a5: 85 c0 test %eax,%eax
10a7: 78 36 js 10df <forktest+0x8f>
for(; n > 0; n--){
10a9: 83 eb 01 sub $0x1,%ebx
10ac: 75 f2 jne 10a0 <forktest+0x50>
if(wait() != -1){
10ae: e8 08 03 00 00 call 13bb <wait>
10b3: 83 f8 ff cmp $0xffffffff,%eax
10b6: 75 49 jne 1101 <forktest+0xb1>
write(fd, s, strlen(s));
10b8: 83 ec 0c sub $0xc,%esp
10bb: 68 96 14 00 00 push $0x1496
10c0: e8 0b 01 00 00 call 11d0 <strlen>
10c5: 83 c4 0c add $0xc,%esp
10c8: 50 push %eax
10c9: 68 96 14 00 00 push $0x1496
10ce: 6a 01 push $0x1
10d0: e8 fe 02 00 00 call 13d3 <write>
}
10d5: 8b 5d fc mov -0x4(%ebp),%ebx
10d8: c9 leave
10d9: c3 ret
exit();
10da: e8 d4 02 00 00 call 13b3 <exit>
write(fd, s, strlen(s));
10df: 83 ec 0c sub $0xc,%esp
10e2: 68 6f 14 00 00 push $0x146f
10e7: e8 e4 00 00 00 call 11d0 <strlen>
10ec: 83 c4 0c add $0xc,%esp
10ef: 50 push %eax
10f0: 68 6f 14 00 00 push $0x146f
10f5: 6a 01 push $0x1
10f7: e8 d7 02 00 00 call 13d3 <write>
exit();
10fc: e8 b2 02 00 00 call 13b3 <exit>
write(fd, s, strlen(s));
1101: 83 ec 0c sub $0xc,%esp
1104: 68 83 14 00 00 push $0x1483
1109: e8 c2 00 00 00 call 11d0 <strlen>
110e: 83 c4 0c add $0xc,%esp
1111: 50 push %eax
1112: 68 83 14 00 00 push $0x1483
1117: 6a 01 push $0x1
1119: e8 b5 02 00 00 call 13d3 <write>
exit();
111e: e8 90 02 00 00 call 13b3 <exit>
write(fd, s, strlen(s));
1123: 83 ec 0c sub $0xc,%esp
1126: 68 a4 14 00 00 push $0x14a4
112b: e8 a0 00 00 00 call 11d0 <strlen>
1130: 83 c4 0c add $0xc,%esp
1133: 50 push %eax
1134: 68 a4 14 00 00 push $0x14a4
1139: 6a 01 push $0x1
113b: e8 93 02 00 00 call 13d3 <write>
exit();
1140: e8 6e 02 00 00 call 13b3 <exit>
1145: 66 90 xchg %ax,%ax
1147: 66 90 xchg %ax,%ax
1149: 66 90 xchg %ax,%ax
114b: 66 90 xchg %ax,%ax
114d: 66 90 xchg %ax,%ax
114f: 90 nop
00001150 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
1150: f3 0f 1e fb endbr32
1154: 55 push %ebp
char *os;
os = s;
while((*s++ = *t++) != 0)
1155: 31 c0 xor %eax,%eax
{
1157: 89 e5 mov %esp,%ebp
1159: 53 push %ebx
115a: 8b 4d 08 mov 0x8(%ebp),%ecx
115d: 8b 5d 0c mov 0xc(%ebp),%ebx
while((*s++ = *t++) != 0)
1160: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx
1164: 88 14 01 mov %dl,(%ecx,%eax,1)
1167: 83 c0 01 add $0x1,%eax
116a: 84 d2 test %dl,%dl
116c: 75 f2 jne 1160 <strcpy+0x10>
;
return os;
}
116e: 89 c8 mov %ecx,%eax
1170: 5b pop %ebx
1171: 5d pop %ebp
1172: c3 ret
1173: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
117a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00001180 <strcmp>:
int
strcmp(const char *p, const char *q)
{
1180: f3 0f 1e fb endbr32
1184: 55 push %ebp
1185: 89 e5 mov %esp,%ebp
1187: 53 push %ebx
1188: 8b 4d 08 mov 0x8(%ebp),%ecx
118b: 8b 55 0c mov 0xc(%ebp),%edx
while(*p && *p == *q)
118e: 0f b6 01 movzbl (%ecx),%eax
1191: 0f b6 1a movzbl (%edx),%ebx
1194: 84 c0 test %al,%al
1196: 75 19 jne 11b1 <strcmp+0x31>
1198: eb 26 jmp 11c0 <strcmp+0x40>
119a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
11a0: 0f b6 41 01 movzbl 0x1(%ecx),%eax
p++, q++;
11a4: 83 c1 01 add $0x1,%ecx
11a7: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
11aa: 0f b6 1a movzbl (%edx),%ebx
11ad: 84 c0 test %al,%al
11af: 74 0f je 11c0 <strcmp+0x40>
11b1: 38 d8 cmp %bl,%al
11b3: 74 eb je 11a0 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
11b5: 29 d8 sub %ebx,%eax
}
11b7: 5b pop %ebx
11b8: 5d pop %ebp
11b9: c3 ret
11ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
11c0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
11c2: 29 d8 sub %ebx,%eax
}
11c4: 5b pop %ebx
11c5: 5d pop %ebp
11c6: c3 ret
11c7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
11ce: 66 90 xchg %ax,%ax
000011d0 <strlen>:
uint
strlen(char *s)
{
11d0: f3 0f 1e fb endbr32
11d4: 55 push %ebp
11d5: 89 e5 mov %esp,%ebp
11d7: 8b 55 08 mov 0x8(%ebp),%edx
int n;
for(n = 0; s[n]; n++)
11da: 80 3a 00 cmpb $0x0,(%edx)
11dd: 74 21 je 1200 <strlen+0x30>
11df: 31 c0 xor %eax,%eax
11e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
11e8: 83 c0 01 add $0x1,%eax
11eb: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
11ef: 89 c1 mov %eax,%ecx
11f1: 75 f5 jne 11e8 <strlen+0x18>
;
return n;
}
11f3: 89 c8 mov %ecx,%eax
11f5: 5d pop %ebp
11f6: c3 ret
11f7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
11fe: 66 90 xchg %ax,%ax
for(n = 0; s[n]; n++)
1200: 31 c9 xor %ecx,%ecx
}
1202: 5d pop %ebp
1203: 89 c8 mov %ecx,%eax
1205: c3 ret
1206: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
120d: 8d 76 00 lea 0x0(%esi),%esi
00001210 <memset>:
void*
memset(void *dst, int c, uint n)
{
1210: f3 0f 1e fb endbr32
1214: 55 push %ebp
1215: 89 e5 mov %esp,%ebp
1217: 57 push %edi
1218: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
121b: 8b 4d 10 mov 0x10(%ebp),%ecx
121e: 8b 45 0c mov 0xc(%ebp),%eax
1221: 89 d7 mov %edx,%edi
1223: fc cld
1224: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
1226: 89 d0 mov %edx,%eax
1228: 5f pop %edi
1229: 5d pop %ebp
122a: c3 ret
122b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
122f: 90 nop
00001230 <strchr>:
char*
strchr(const char *s, char c)
{
1230: f3 0f 1e fb endbr32
1234: 55 push %ebp
1235: 89 e5 mov %esp,%ebp
1237: 8b 45 08 mov 0x8(%ebp),%eax
123a: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for(; *s; s++)
123e: 0f b6 10 movzbl (%eax),%edx
1241: 84 d2 test %dl,%dl
1243: 75 16 jne 125b <strchr+0x2b>
1245: eb 21 jmp 1268 <strchr+0x38>
1247: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
124e: 66 90 xchg %ax,%ax
1250: 0f b6 50 01 movzbl 0x1(%eax),%edx
1254: 83 c0 01 add $0x1,%eax
1257: 84 d2 test %dl,%dl
1259: 74 0d je 1268 <strchr+0x38>
if(*s == c)
125b: 38 d1 cmp %dl,%cl
125d: 75 f1 jne 1250 <strchr+0x20>
return (char*)s;
return 0;
}
125f: 5d pop %ebp
1260: c3 ret
1261: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
return 0;
1268: 31 c0 xor %eax,%eax
}
126a: 5d pop %ebp
126b: c3 ret
126c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00001270 <gets>:
char*
gets(char *buf, int max)
{
1270: f3 0f 1e fb endbr32
1274: 55 push %ebp
1275: 89 e5 mov %esp,%ebp
1277: 57 push %edi
1278: 56 push %esi
int i, cc;
char c;
for(i=0; i+1 < max; ){
1279: 31 f6 xor %esi,%esi
{
127b: 53 push %ebx
127c: 89 f3 mov %esi,%ebx
127e: 83 ec 1c sub $0x1c,%esp
1281: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
1284: eb 33 jmp 12b9 <gets+0x49>
1286: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
128d: 8d 76 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
1290: 83 ec 04 sub $0x4,%esp
1293: 8d 45 e7 lea -0x19(%ebp),%eax
1296: 6a 01 push $0x1
1298: 50 push %eax
1299: 6a 00 push $0x0
129b: e8 2b 01 00 00 call 13cb <read>
if(cc < 1)
12a0: 83 c4 10 add $0x10,%esp
12a3: 85 c0 test %eax,%eax
12a5: 7e 1c jle 12c3 <gets+0x53>
break;
buf[i++] = c;
12a7: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
12ab: 83 c7 01 add $0x1,%edi
12ae: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
12b1: 3c 0a cmp $0xa,%al
12b3: 74 23 je 12d8 <gets+0x68>
12b5: 3c 0d cmp $0xd,%al
12b7: 74 1f je 12d8 <gets+0x68>
for(i=0; i+1 < max; ){
12b9: 83 c3 01 add $0x1,%ebx
12bc: 89 fe mov %edi,%esi
12be: 3b 5d 0c cmp 0xc(%ebp),%ebx
12c1: 7c cd jl 1290 <gets+0x20>
12c3: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
12c5: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
12c8: c6 03 00 movb $0x0,(%ebx)
}
12cb: 8d 65 f4 lea -0xc(%ebp),%esp
12ce: 5b pop %ebx
12cf: 5e pop %esi
12d0: 5f pop %edi
12d1: 5d pop %ebp
12d2: c3 ret
12d3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
12d7: 90 nop
12d8: 8b 75 08 mov 0x8(%ebp),%esi
12db: 8b 45 08 mov 0x8(%ebp),%eax
12de: 01 de add %ebx,%esi
12e0: 89 f3 mov %esi,%ebx
buf[i] = '\0';
12e2: c6 03 00 movb $0x0,(%ebx)
}
12e5: 8d 65 f4 lea -0xc(%ebp),%esp
12e8: 5b pop %ebx
12e9: 5e pop %esi
12ea: 5f pop %edi
12eb: 5d pop %ebp
12ec: c3 ret
12ed: 8d 76 00 lea 0x0(%esi),%esi
000012f0 <stat>:
int
stat(char *n, struct stat *st)
{
12f0: f3 0f 1e fb endbr32
12f4: 55 push %ebp
12f5: 89 e5 mov %esp,%ebp
12f7: 56 push %esi
12f8: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
12f9: 83 ec 08 sub $0x8,%esp
12fc: 6a 00 push $0x0
12fe: ff 75 08 pushl 0x8(%ebp)
1301: e8 ed 00 00 00 call 13f3 <open>
if(fd < 0)
1306: 83 c4 10 add $0x10,%esp
1309: 85 c0 test %eax,%eax
130b: 78 2b js 1338 <stat+0x48>
return -1;
r = fstat(fd, st);
130d: 83 ec 08 sub $0x8,%esp
1310: ff 75 0c pushl 0xc(%ebp)
1313: 89 c3 mov %eax,%ebx
1315: 50 push %eax
1316: e8 f0 00 00 00 call 140b <fstat>
close(fd);
131b: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
131e: 89 c6 mov %eax,%esi
close(fd);
1320: e8 b6 00 00 00 call 13db <close>
return r;
1325: 83 c4 10 add $0x10,%esp
}
1328: 8d 65 f8 lea -0x8(%ebp),%esp
132b: 89 f0 mov %esi,%eax
132d: 5b pop %ebx
132e: 5e pop %esi
132f: 5d pop %ebp
1330: c3 ret
1331: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
return -1;
1338: be ff ff ff ff mov $0xffffffff,%esi
133d: eb e9 jmp 1328 <stat+0x38>
133f: 90 nop
00001340 <atoi>:
int
atoi(const char *s)
{
1340: f3 0f 1e fb endbr32
1344: 55 push %ebp
1345: 89 e5 mov %esp,%ebp
1347: 53 push %ebx
1348: 8b 55 08 mov 0x8(%ebp),%edx
int n;
n = 0;
while('0' <= *s && *s <= '9')
134b: 0f be 02 movsbl (%edx),%eax
134e: 8d 48 d0 lea -0x30(%eax),%ecx
1351: 80 f9 09 cmp $0x9,%cl
n = 0;
1354: b9 00 00 00 00 mov $0x0,%ecx
while('0' <= *s && *s <= '9')
1359: 77 1a ja 1375 <atoi+0x35>
135b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
135f: 90 nop
n = n*10 + *s++ - '0';
1360: 83 c2 01 add $0x1,%edx
1363: 8d 0c 89 lea (%ecx,%ecx,4),%ecx
1366: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx
while('0' <= *s && *s <= '9')
136a: 0f be 02 movsbl (%edx),%eax
136d: 8d 58 d0 lea -0x30(%eax),%ebx
1370: 80 fb 09 cmp $0x9,%bl
1373: 76 eb jbe 1360 <atoi+0x20>
return n;
}
1375: 89 c8 mov %ecx,%eax
1377: 5b pop %ebx
1378: 5d pop %ebp
1379: c3 ret
137a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00001380 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
1380: f3 0f 1e fb endbr32
1384: 55 push %ebp
1385: 89 e5 mov %esp,%ebp
1387: 57 push %edi
1388: 8b 45 10 mov 0x10(%ebp),%eax
138b: 8b 55 08 mov 0x8(%ebp),%edx
138e: 56 push %esi
138f: 8b 75 0c mov 0xc(%ebp),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
1392: 85 c0 test %eax,%eax
1394: 7e 0f jle 13a5 <memmove+0x25>
1396: 01 d0 add %edx,%eax
dst = vdst;
1398: 89 d7 mov %edx,%edi
139a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
*dst++ = *src++;
13a0: a4 movsb %ds:(%esi),%es:(%edi)
while(n-- > 0)
13a1: 39 f8 cmp %edi,%eax
13a3: 75 fb jne 13a0 <memmove+0x20>
return vdst;
}
13a5: 5e pop %esi
13a6: 89 d0 mov %edx,%eax
13a8: 5f pop %edi
13a9: 5d pop %ebp
13aa: c3 ret
000013ab <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
13ab: b8 01 00 00 00 mov $0x1,%eax
13b0: cd 40 int $0x40
13b2: c3 ret
000013b3 <exit>:
SYSCALL(exit)
13b3: b8 02 00 00 00 mov $0x2,%eax
13b8: cd 40 int $0x40
13ba: c3 ret
000013bb <wait>:
SYSCALL(wait)
13bb: b8 03 00 00 00 mov $0x3,%eax
13c0: cd 40 int $0x40
13c2: c3 ret
000013c3 <pipe>:
SYSCALL(pipe)
13c3: b8 04 00 00 00 mov $0x4,%eax
13c8: cd 40 int $0x40
13ca: c3 ret
000013cb <read>:
SYSCALL(read)
13cb: b8 05 00 00 00 mov $0x5,%eax
13d0: cd 40 int $0x40
13d2: c3 ret
000013d3 <write>:
SYSCALL(write)
13d3: b8 10 00 00 00 mov $0x10,%eax
13d8: cd 40 int $0x40
13da: c3 ret
000013db <close>:
SYSCALL(close)
13db: b8 15 00 00 00 mov $0x15,%eax
13e0: cd 40 int $0x40
13e2: c3 ret
000013e3 <kill>:
SYSCALL(kill)
13e3: b8 06 00 00 00 mov $0x6,%eax
13e8: cd 40 int $0x40
13ea: c3 ret
000013eb <exec>:
SYSCALL(exec)
13eb: b8 07 00 00 00 mov $0x7,%eax
13f0: cd 40 int $0x40
13f2: c3 ret
000013f3 <open>:
SYSCALL(open)
13f3: b8 0f 00 00 00 mov $0xf,%eax
13f8: cd 40 int $0x40
13fa: c3 ret
000013fb <mknod>:
SYSCALL(mknod)
13fb: b8 11 00 00 00 mov $0x11,%eax
1400: cd 40 int $0x40
1402: c3 ret
00001403 <unlink>:
SYSCALL(unlink)
1403: b8 12 00 00 00 mov $0x12,%eax
1408: cd 40 int $0x40
140a: c3 ret
0000140b <fstat>:
SYSCALL(fstat)
140b: b8 08 00 00 00 mov $0x8,%eax
1410: cd 40 int $0x40
1412: c3 ret
00001413 <link>:
SYSCALL(link)
1413: b8 13 00 00 00 mov $0x13,%eax
1418: cd 40 int $0x40
141a: c3 ret
0000141b <mkdir>:
SYSCALL(mkdir)
141b: b8 14 00 00 00 mov $0x14,%eax
1420: cd 40 int $0x40
1422: c3 ret
00001423 <chdir>:
SYSCALL(chdir)
1423: b8 09 00 00 00 mov $0x9,%eax
1428: cd 40 int $0x40
142a: c3 ret
0000142b <dup>:
SYSCALL(dup)
142b: b8 0a 00 00 00 mov $0xa,%eax
1430: cd 40 int $0x40
1432: c3 ret
00001433 <getpid>:
SYSCALL(getpid)
1433: b8 0b 00 00 00 mov $0xb,%eax
1438: cd 40 int $0x40
143a: c3 ret
0000143b <sbrk>:
SYSCALL(sbrk)
143b: b8 0c 00 00 00 mov $0xc,%eax
1440: cd 40 int $0x40
1442: c3 ret
00001443 <sleep>:
SYSCALL(sleep)
1443: b8 0d 00 00 00 mov $0xd,%eax
1448: cd 40 int $0x40
144a: c3 ret
0000144b <uptime>:
SYSCALL(uptime)
144b: b8 0e 00 00 00 mov $0xe,%eax
1450: cd 40 int $0x40
1452: c3 ret
00001453 <shm_open>:
SYSCALL(shm_open)
1453: b8 16 00 00 00 mov $0x16,%eax
1458: cd 40 int $0x40
145a: c3 ret
0000145b <shm_close>:
SYSCALL(shm_close)
145b: b8 17 00 00 00 mov $0x17,%eax
1460: cd 40 int $0x40
1462: c3 ret
|
gb_02/src_bug/lists.adb | gerr135/gnat_bugs | 0 | 8057 | <filename>gb_02/src_bug/lists.adb
package body Lists is
function Has_Element (Position : Cursor) return Boolean is
begin
return Position /= No_Element;
end Has_Element;
end Lists;
|
bootdict/tc/h-dot-8.asm | ikysil/ikforth | 8 | 163234 | <filename>bootdict/tc/h-dot-8.asm
; Output the value on the top of the data stack in hexadecimal representation.
; S: a --
$COLON 'H.8',$HOUT8
CW $SPLIT8, $HOUT2, $HOUT2, $HOUT2, $HOUT2
$END_COLON
|
oeis/288/A288023.asm | neoneye/loda-programs | 11 | 173339 | <filename>oeis/288/A288023.asm<gh_stars>10-100
; A288023: Number of steps to reach 1 in the Collatz 3x+1 problem starting with the n-th triangular number, or -1 if 1 is never reached.
; Submitted by Jon Maiga
; 0,7,8,6,17,7,18,21,16,112,27,35,92,38,20,15,36,124,106,39,127,109,16,16,24,81,107,40,27,35,110,30,43,74,38,113,170,46,121,28,103,116,36,98,124,137,18,119,132,83,26,127,26,47,34,122,91,148,117,130,37,37,112,32,76,94,58,120,120,89,133,53,115,66,27,141,40,154,79,30,105,61,180,30,118,131,56,51,144,157,126,77,108,46,108,121,51,165,72,41
seq $0,73577 ; a(n) = 4*n^2 + 4*n - 1.
seq $0,6577 ; Number of halving and tripling steps to reach 1 in '3x+1' problem, or -1 if 1 is never reached.
sub $0,3
|
notes/FOT/FOTC/Program/GCD/GCD00-SL.agda | asr/fotc | 11 | 1639 | ------------------------------------------------------------------------------
-- In the Agda standard library, gcd 0 0 = 0.
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Program.GCD.GCD00-SL where
open import Data.Nat.GCD
open import Data.Product
open import Relation.Binary.PropositionalEquality
open GCD hiding ( refl )
------------------------------------------------------------------------------
gcd00 : proj₁ (gcd 0 0) ≡ 0
gcd00 = refl
-- A different proof.
gcd00' : GCD 0 0 0
gcd00' = base
|
session_07/02-maxmmin/max.asm | DigiOhhh/LabArchitettura2-2017-2018 | 1 | 4774 | <reponame>DigiOhhh/LabArchitettura2-2017-2018
# INPUT
# $a0: base address array
# $a1: dimensione array
# $a2: passo
# OUTPUT
# $v0: massimo tra i numeri considerati
.text
.globl max
max:
mul $t0, $a2, 4 #t0=offset tra el. (passo)
move $t1, $a0 #t1=indirizzo prossimo el.
lw $t2, 0($t1) #t2=el. considerato
j updatemax
loop:
slt $t4, $zero, $a1
beq $t4, 0, end
lw $t2, 0($t1)
slt $t3, $v0, $t2
bne $t3, 1, continue
updatemax:
move $v0, $t2
continue:
sub $a1, $a1, $a2
add $t1, $t1, $t0
j loop
end:
jr $ra
|
src/boot/init.asm | robey/funos | 5 | 22471 | <reponame>robey/funos
;
; bootstrap:
; this is launched by the (multiboot-compatible) bootloader. it runs in old
; "short" mode (32 bits), initializes the basic hardware, and then loads the
; 64-bit kernel and jumps into it in "long" mode (64 bits).
;
; sometimes multiboot is called a "stage 2 loader", so i guess we are at
; stage 3 now.
;
%define module init
%include "api.macro"
%define BOOT_MAGIC 0x1badb002
%define BOOT_INFO_MAGIC 0x2badb002
%define BF_ALIGN (1 << 0) ; align loaded modules on page boundaries
%define BF_MEMINFO (1 << 1) ; provide memory map
%define BOOT_FLAGS (BF_ALIGN | BF_MEMINFO)
%define BOOT_CHECKSUM (-(BOOT_MAGIC + BOOT_FLAGS))
section .multiboot
align 4
dd BOOT_MAGIC, BOOT_FLAGS, BOOT_CHECKSUM
; require: TSC, MSR, PAE, APIC, CMOV
%define CPUID_REQUIRED_EDX 0x00008270
; require: NX, LONG
%define CPUID_REQUIRED_EXT_EDX 0x20100000
%define EXCEPTION_INVALID_OPCODE 6
%define EXCEPTION_DOUBLE_FAULT 8
%define EXCEPTION_SEGMENT_MISSING 11
%define EXCEPTION_STACK_FAULT 12
%define EXCEPTION_PROTECTION_FAULT 13
%define EXCEPTION_PAGE_FAULT 14
;
; procedures in the bootstrap follow a special calling convention (not the
; intel one):
; - int parameters, in order: eax, edx
; - ptr parameters, in order: edi, esi
; - clobbered by callee: edi, esi -- everything else must be preserved
;
section .text
global _start
_start:
mov esp, stack_top
mov ebp, esp
push eax
push ebx
mov eax, ds
mov es, eax
; display a status line showing progress
call vga_init
call vga_status_update ; A
; check that we got a multiboot header
cmp dword [ebp - 4], BOOT_INFO_MAGIC
jne die
call vga_status_update ; B
; check cpuid for vital features
mov eax, 0
cpuid
call vga_display_register_b
;; must be at least 1 attribute.
cmp eax, 1
jl die
call vga_status_update ; C
mov eax, 0x80000000
cpuid
call vga_display_register_b
;; must be at least 1 extended attribute.
and eax, 0x7fffffff
cmp eax, 1
jl die
call vga_status_update ; D
;; verify that our required features are present.
mov eax, 1
cpuid
mov eax, edx
call vga_display_register_b
mov eax, ecx
call vga_display_register_a
and edx, CPUID_REQUIRED_EDX
cmp edx, CPUID_REQUIRED_EDX
jne die
call vga_status_update ; E
mov eax, 0x80000001
cpuid
mov eax, edx
call vga_display_register_b
mov eax, ecx
call vga_display_register_a
and edx, CPUID_REQUIRED_EXT_EDX
cmp edx, CPUID_REQUIRED_EXT_EDX
jne die
call vga_status_update ; F
; enter protected mode, if we aren't already.
; we may not call BIOS because multiboot might have put us into protected mode already!
;; disable NMI.
in al, 0x70
or al, 0x80
out 0x70, al
cli
;; set up a new GDT that marks all of memory as code & data.
lgdt [initial_gdt_locator]
;; doesn't become active until we load the segment registers.
;; (the first non-null entry is CS, and the second is DS/ES/FS/GS/SS.)
jmp 0x08:.reload_cs
.reload_cs:
mov eax, 0x10
mov ds, eax
mov es, eax
mov fs, eax
mov gs, eax
mov ss, eax
call vga_status_update ; G
;; make sure A20 pin is active (seriously don't ask).
in al, 0x92
test al, 2
jnz .no_a20
or al, 2
and al, 0xfe
out 0x92, al
.no_a20:
;; set PE (protection enable) bit in CR0.
mov eax, cr0
or al, 1
mov cr0, eax
call vga_status_update ; H
;; enable NMI.
in al, 0x70
and al, 0x7f
out 0x70, al
call vga_status_update ; I
call irq_init
call vga_status_update ; J
; now we should start catching cpu exceptions and showing the crash screen.
mov edi, crash_opcode
mov eax, EXCEPTION_INVALID_OPCODE
call irq_set_handler
mov edi, crash_double_fault
mov eax, EXCEPTION_DOUBLE_FAULT
call irq_set_handler
mov edi, crash_segment_missing
mov eax, EXCEPTION_SEGMENT_MISSING
call irq_set_handler
mov edi, crash_stack_fault
mov eax, EXCEPTION_STACK_FAULT
call irq_set_handler
mov edi, crash_protection_fault
mov eax, EXCEPTION_PROTECTION_FAULT
call irq_set_handler
mov edi, crash_page_fault
mov eax, EXCEPTION_PAGE_FAULT
call irq_set_handler
call vga_status_update ; K
call serial_init
call vga_status_update ; L
call keyboard_init
call vga_status_update ; M
call timer_init
call vga_status_update ; N
sti
call loader
; just loop forever, waking up only long enough to handle interrupts.
die:
hlt
ja die
crash_opcode:
mov dword [crash_reason], 'UD'
jmp crash
crash_double_fault:
mov dword [crash_reason], 'DF'
jmp crash
crash_segment_missing:
mov dword [crash_reason], 'NP'
jmp crash
crash_stack_fault:
mov dword [crash_reason], 'SS'
jmp crash
crash_protection_fault:
mov dword [crash_reason], 'GP'
jmp crash
crash_page_fault:
mov dword [crash_reason], 'PF'
jmp crash
global get_boot_info
get_boot_info:
mov eax, [stack_top - 8]
ret
; ----- data
section .data
align 4
; initial GDT (global descriptor table for memory)
;
; GDT entry format appears to be:
; LL LL BB BB BB TT xl bb
;
; L - limit (bits 0 - 15, LSB)
; B - base (bits 0 - 23, LSB)
; T - type: 0 = null, 9a = code, 92 = data
; x - format of limit:
; 4: limit is only 16 bits long
; c: limit is bits 13 - 31, bottom 12 bits are 0xfff
; l - limit (bits 16 - 19)
; b - base (bits 24 - 31)
align 8
initial_gdt:
.gdt_entry_null:
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.gdt_entry_code:
db 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00
.gdt_entry_data:
db 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00
initial_gdt_size equ $ - initial_gdt - 1
align 8
initial_gdt_locator:
dw initial_gdt_size
dd initial_gdt
section .bootstrap_stack, nobits
align 4096
resb 4096
stack_top:
section .kernel64
incbin "../blob.dat"
|
lib.asm | jorgicor/altair | 0 | 9837 | <filename>lib.asm<gh_stars>0
; ----------------------------------------------------------------------------
; Altair, CIDLESA's 1981 arcade game remade for the ZX Spectrum and
; Amstrad CPC.
; ----------------------------------------------------------------------------
; -----------------
; 'jphl' Juml to HL
; -----------------
; This can be used with 'call jphl' to call the routine contained in HL.
jphl jp (hl)
; -------------
; 'modb' Modulo
; -------------
; Calculates A mod E. If E is 0, returns A, that is, acts as A mod 256.
;
; In A, E.
; Out A = A mod E
; Saves HL, BC, DE
; Works by subtracting E, E * 2, E * 4, ... and again E, E * 2, E * 4 until
; no more can be subtracted.
modb
; Check if E is 0.
rlc e
jr nz,modb3
; It's 0.
rrc e
ret
modb3
; Not 0. Restore and continue.
rrc e
modb4 push de
modb1 cp e
jr c,modb2
sub e
sla e
jr nz,modb1
modb2 pop de
cp e
jr nc,modb4
ret
; -----------------------
; 'randr' Random In Range
; -----------------------
; Calcs a random number in range [D,E].
;
; In [D,E] range.
; Out A random number.
; Saves HL, BC
randr inc e
ld a,e
sub d
ld e,a
call rand
call modb
add a,d
ret
; -------------------
; 'memset' Memory Set
; -------------------
; Like the C function. Sets memory to a value.
;
; In HL address of first byte. BC how many to set. A value to set to.
memset
; Save value to set in e.
ld e,a
; If 0 return.
ld a,b
or c
ret z
; Set first value.
ld (hl),e
; We are going to set BC - 1, as the first is already set.
dec bc
; If we are done return.
ld a,b
or c
ret z
; Copy from the previous to the next byte.
ld d,h
ld e,l
inc de
ldir
ret
; ----------------------------
; 'getwt' Get Word in Table
; ----------------------------
; Implements LD HL,(HL+A*2)
;
; In A index in table. HL table.
; Out HL word at HL+A*2.
; Saves AF, DE, BC.
getwt push af
push bc
ld c,a
ld b,0
add hl,bc
add hl,bc
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
pop bc
pop af
ret
; ----------------------------
; 'getbt' Get Byte in Table
; ----------------------------
; Implements LD A,(HL+A)
;
; In A index in table. HL table.
; Out A byte.
; Saves HL, DE, BC.
getbt push hl
add a,l
ld l,a
ld a,h
adc a,0
ld h,a
ld a,(hl)
pop hl
ret
; ------
; 'loop'
; ------
; Loops.
;
; In BC cicles.
; Out BC 0.
; Saves DE, HL.
loop dec bc
ld a,c
or b
jr nz,loop
ret
; --------------------
; 'chadr' Char Address
; --------------------
; Gets an address of a 8 byte character.
;
; In HL Address of char 0 data. A char number.
; Out HL address of character data.
; Saves BC, DE
chadr push bc
ld b,h
ld c,l
ld l,a
ld h,0
add hl,hl
add hl,hl
add hl,hl
add hl,bc
pop bc
ret
; -------------------
; 'drstr' Draw String
; -------------------
; Draws a string on VRAM.
; A string is a series of characters from 32 to 127.
; If 0 is encountered, it signals the end of the string.
; If 1 is encountered, the next byte is a color to paint the rest
; of the string.
;
; In HL string address. DE y,x position in characters. A color.
drstr
; Set initial color.
call set_char_color
; Get character or command. Return if 0.
drstr2 ld a,(hl)
inc hl
or a
ret z
cp 1
jr nz,drstr1
; Set new color.
ld a,(hl)
inc hl
call set_char_color
jr drstr2
drstr1
; Find address in rom.
push hl
call font_chadr
push de
; Draw draw.
call drchrc
pop de
inc e
pop hl
jr drstr2
; ----------------------
; 'strlen' String length
; ----------------------
; Calculates the length of a string.
;
; In HL str address.
; Out B len.
; Saves DE, C.
strlen ld b,0
strlen_next
ld a,(hl)
inc hl
; If 0 end of string.
or a
ret z
; If 1 the next byte is a color.
cp 1
jr z,strlen_color
; Increment length.
inc b
jr strlen_next
strlen_color
inc hl
jr strlen_next
; -------------------
; 'addnum' Add number
; -------------------
; Decimal addition. The numbers are stored each digit in a byte.
; The number in address pointed by HL is added to the one pointed by DE
; and stores in this same sequence pointed by DE.
;
; If HL points to these bytes 0019
; And DE to these 0001
; Then the bytes pointed by DE will contain 0020
;
; In HL array of digits. DE array of digits. B number of digits.
; Saves None.
addnum
; Go to the end of the numbers.
ld c,b
ld b,0
dec c
add hl,bc
ex de,hl
add hl,bc
ex de,hl
ld b,c
inc b
; Reset CY.
or a
addnum1 ld a,(de)
adc a,(hl)
cp 10
jr c,addnum0
; The sum is equal or more than 10.
sub 10
ld (de),a
scf
jr addnum2
; The sum is less than 10.
addnum0 ld (de),a
; Reset CY.
or a
addnum2 dec hl
dec de
djnz addnum1
ret
; -------------------
; 'drnum' Draw number
; -------------------
;
; In B number of digits. HL pointer to digits. DE y,x in chars. C color.
; Saves C
drnum
; In the begining, while it is a zero digit, draw a space.
dec b
drnum_zero
ld a,(hl)
or a
jr nz,drnum_rest
ld a,' '
call drchrsf
inc e
inc hl
djnz drnum_zero
drnum_rest
; Now, some digits remain.
inc b
drnum_num
ld a,(hl)
add a,'0'
; Find in rom and draw with color.
call drchrsf
drnum_next
; Go to next digit.
inc e
inc hl
djnz drnum_num
ret
; -------------------------
; 'drchrsf' Draw char safe.
; -------------------------
; Draws a character, preserves most of registers.
;
; In A character code. DE y,x in characters. C color.
; Saves BC, DE, HL.
drchrsf push hl
call font_chadr
push de
push bc
ld a,c
call set_char_color
call drchrc
pop bc
pop de
pop hl
ret
; --------
; 'minnum'
; --------
; Selects the minimum of two decimal numbers.
;
; In HL addr number 1. DE addr number 2. B digits.
; Out A 0 if equal, -1 if HL is the minimum, 1 if DE is the minimum.
; Saves HL, DE.
minnum
push de
push hl
minnum_loop
ld a,(de)
cp (hl)
jr nz,minnum_cp
; Digits are equal, go to next.
inc hl
inc de
djnz minnum_loop
xor a
jr minnum_end
minnum_cp
; The digits are different.
jr c,minnum_is_2
ld a,-1
jr minnum_end
minnum_is_2
; The second number is less than the first.
ld a,1
minnum_end
pop hl
pop de
ret
; --------------------
; 'digit' Gets a digit
; --------------------
; Gets a digit of a number, starting from the most significant.
;
; In HL number address. B digit to obtain (number length - digits from
; the least significant).
; Out A digit. B 0. HL points at digit.
digit dec hl
inc b
digit_loop
inc hl
ld a,(hl)
djnz digit_loop
ret
; ---------------
; 'mirror' Mirror
; ---------------
; Mirrors the left side of an image into the left side.
;
; In HL image address.
mirror
; Load A,C height, width.
ld c,(hl)
inc hl
ld a,(hl)
inc hl
; BC is width.
ld b,0
; Save height counter and first position in line.
mirror3 push af
push hl
; Point DE to first byte in line, HL to last.
ld d,h
ld e,l
add hl,bc
dec hl
; Bytes to mirror on a line in B (careful when width is odd).
push bc
ld a,c
or a
rra
ld b,a
; Mirror line.
mirror2 push bc
ld a,(de)
inc de
ld b,8
mirror1 rlca
rr c
djnz mirror1
ld (hl),c
dec hl
pop bc
djnz mirror2
pop bc
; Go to next line.
pop hl
add hl,bc
pop af
dec a
jr nz,mirror3
ret
; ----------------------
; 'mirims' Mirror Images
; ----------------------
; Runs through a null terminated list of image pointers, takes each
; image and builds its right side by mirroring its left side.
;
; In HL address of a table of pointer to Images.
mirims ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld a,d
or e
ret z
push hl
ex de,hl
call mirror
pop hl
jr mirims
; -----------------------
; 'flipv' Vertically flip
; -----------------------
; Flips and image vertically.
;
; In HL Image address.
flipv ld c,(hl)
inc hl
ld b,(hl)
inc hl
; If only one row, nothing to do.
ld a,1
cp b
ret z
; Point DE to start of last image row.
push hl
ld a,b
ld d,0
ld e,c
jr flipv3
flipv2 add hl,de
flipv3 dec a
jr nz,flipv2
ex de,hl
pop hl
; How many lines to swap?
srl b
; Swap one line.
flipv4 push bc
ld b,c
flipv1 ld c,(hl)
ld a,(de)
ld (hl),a
ld a,c
ld (de),a
inc hl
inc de
djnz flipv1
pop bc
; All lines served.
dec b
ret z
; Go to next lines.
; HL already pointing to next line. Fix DE.
push hl
ex de,hl
ld d,0
ld e,c
xor a
sbc hl,de
sbc hl,de
ex de,hl
pop hl
jr flipv4
; -------------------------
; 'cppad' Copy with padding
; -------------------------
; Copies one image src into image dst. Height of the src
; must be less or equal than the width of dst.
; The width of the dst image must equal the width src image if
; we are copying, or it has to be the width of src plus one if we
; want padding.
;
; In HL source image. DE dest image.
; A 0 for copy, 1 for copying with padding.
; Saves A.
cppad
; Take width and height of source.
ld c, (hl)
inc hl
ld b, (hl)
inc hl
; Point to dest image data.
inc de
inc de
; Put a 0 in A'.
ex af,af'
xor a
ex af,af'
; Copy all lines.
cppad1 push bc
ld b,0
ldir
or a
jr z,cppad2
; Put a 0 on last row byte if padding.
ex af,af'
ld (de),a
inc de
ex af,af'
; For all rows.
cppad2 pop bc
djnz cppad1
ret
#if 0
; -----------
; 'two_pow_n'
; -----------
; Given A, it is taken modulus 8 (thus 0-7) and then returns in A the
;
; In A.
; Out A 1,2,4,8,16,32,64,128.
two_pow_n
push hl
and 7
ld hl,two_pow_t
call getbt
pop hl
ret
two_pow_t .db 1,2,4,8,16,32,64,128
#endif
|
source/distributed/a-proces.adb | ytomino/drake | 33 | 5539 | <filename>source/distributed/a-proces.adb
with Ada.Streams.Naked_Stream_IO;
with Ada.Streams.Stream_IO.Naked;
with System.Unwind.Occurrences;
package body Ada.Processes is
-- implementation
function Image (Command : Command_Type) return String is
Native_Command : System.Native_Processes.Command_Type
renames Controlled_Commands.Reference (Command).all;
begin
return System.Native_Processes.Image (Native_Command);
end Image;
function Value (Command_Line : String) return Command_Type is
begin
return Result : Command_Type do
declare
Native_Result : System.Native_Processes.Command_Type
renames Controlled_Commands.Reference (Result).all;
begin
System.Native_Processes.Value (Command_Line, Native_Result);
end;
end return;
end Value;
procedure Append (Command : in out Command_Type; New_Item : String) is
Native_Command : System.Native_Processes.Command_Type
renames Controlled_Commands.Reference (Command).all;
begin
System.Native_Processes.Append (Native_Command, New_Item);
end Append;
procedure Append (
Command : in out Command_Type;
New_Item :
Ada.Command_Line.Iterator_Interfaces.Reversible_Iterator'Class)
is
Native_Command : System.Native_Processes.Command_Type
renames Controlled_Commands.Reference (Command).all;
First : constant Natural :=
Ada.Command_Line.Iterator_Interfaces.First (New_Item);
begin
if Ada.Command_Line.Has_Element (First) then
System.Native_Processes.Append (Native_Command,
First => First,
Last => Ada.Command_Line.Iterator_Interfaces.Last (New_Item));
end if;
end Append;
function Is_Open (Child : Process) return Boolean is
N_Child : System.Native_Processes.Process
renames Controlled_Processes.Reference (Child).all;
begin
return System.Native_Processes.Is_Open (N_Child);
end Is_Open;
procedure Create (
Child : in out Process;
Command : Command_Type;
Directory : String := "";
Search_Path : Boolean := False;
Input : Streams.Stream_IO.File_Type :=
Streams.Stream_IO.Standard_Files.Standard_Input.all;
Output : Streams.Stream_IO.File_Type :=
Streams.Stream_IO.Standard_Files.Standard_Output.all;
Error : Streams.Stream_IO.File_Type :=
Streams.Stream_IO.Standard_Files.Standard_Error.all)
is
pragma Check (Pre, not Is_Open (Child) or else raise Status_Error);
Naked_Output : constant
not null access Streams.Naked_Stream_IO.Non_Controlled_File_Type :=
Streams.Stream_IO.Naked.Non_Controlled (Output);
Naked_Error : constant
not null access Streams.Naked_Stream_IO.Non_Controlled_File_Type :=
Streams.Stream_IO.Naked.Non_Controlled (Error);
begin
if Streams.Naked_Stream_IO.Is_Standard (Naked_Output.all)
or else Streams.Naked_Stream_IO.Is_Standard (Naked_Error.all)
then
System.Unwind.Occurrences.Flush_IO;
end if;
declare
N_Child : System.Native_Processes.Process
renames Controlled_Processes.Reference (Child).all;
Native_Command : System.Native_Processes.Command_Type
renames Controlled_Commands.Reference (Command).all;
begin
System.Native_Processes.Create (
N_Child,
Native_Command,
Directory,
Search_Path,
Streams.Stream_IO.Naked.Non_Controlled (Input).all,
Naked_Output.all,
Naked_Error.all);
end;
end Create;
procedure Create (
Child : in out Process;
Command_Line : String;
Directory : String := "";
Search_Path : Boolean := False;
Input : Streams.Stream_IO.File_Type :=
Streams.Stream_IO.Standard_Files.Standard_Input.all;
Output : Streams.Stream_IO.File_Type :=
Streams.Stream_IO.Standard_Files.Standard_Output.all;
Error : Streams.Stream_IO.File_Type :=
Streams.Stream_IO.Standard_Files.Standard_Error.all)
is
pragma Check (Pre, not Is_Open (Child) or else raise Status_Error);
N_Child : System.Native_Processes.Process
renames Controlled_Processes.Reference (Child).all;
begin
System.Native_Processes.Create (
N_Child,
Command_Line,
Directory,
Search_Path,
Streams.Stream_IO.Naked.Non_Controlled (Input).all,
Streams.Stream_IO.Naked.Non_Controlled (Output).all,
Streams.Stream_IO.Naked.Non_Controlled (Error).all);
end Create;
procedure Wait (
Child : in out Process;
Status : out Ada.Command_Line.Exit_Status)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Child) or else raise Status_Error);
N_Child : System.Native_Processes.Process
renames Controlled_Processes.Reference (Child).all;
begin
System.Native_Processes.Wait (N_Child, Status);
end Wait;
procedure Wait (
Child : in out Process)
is
Dummy : Ada.Command_Line.Exit_Status;
begin
Wait (Child, Dummy); -- checking the predicate
end Wait;
procedure Wait_Immediate (
Child : in out Process;
Terminated : out Boolean;
Status : out Ada.Command_Line.Exit_Status)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Child) or else raise Status_Error);
N_Child : System.Native_Processes.Process
renames Controlled_Processes.Reference (Child).all;
begin
System.Native_Processes.Wait_Immediate (N_Child, Terminated, Status);
end Wait_Immediate;
procedure Wait_Immediate (
Child : in out Process;
Terminated : out Boolean)
is
Dummy : Ada.Command_Line.Exit_Status;
begin
Wait_Immediate (Child, Terminated, Dummy); -- checking the predicate
end Wait_Immediate;
procedure Abort_Process (Child : in out Process) is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Child) or else raise Status_Error);
N_Child : System.Native_Processes.Process
renames Controlled_Processes.Reference (Child).all;
begin
System.Native_Processes.Abort_Process (N_Child);
end Abort_Process;
procedure Forced_Abort_Process (Child : in out Process) is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Child) or else raise Status_Error);
N_Child : System.Native_Processes.Process
renames Controlled_Processes.Reference (Child).all;
begin
System.Native_Processes.Forced_Abort_Process (N_Child);
end Forced_Abort_Process;
procedure Shell (
Command : Command_Type;
Status : out Ada.Command_Line.Exit_Status) is
begin
System.Unwind.Occurrences.Flush_IO;
declare
Native_Command : System.Native_Processes.Command_Type
renames Controlled_Commands.Reference (Command).all;
begin
System.Native_Processes.Shell (Native_Command, Status);
end;
end Shell;
procedure Shell (
Command_Line : String;
Status : out Ada.Command_Line.Exit_Status) is
begin
System.Unwind.Occurrences.Flush_IO;
System.Native_Processes.Shell (Command_Line, Status);
end Shell;
procedure Shell (Command : Command_Type) is
Dummy : Ada.Command_Line.Exit_Status;
begin
Shell (Command, Dummy);
end Shell;
procedure Shell (Command_Line : String) is
Dummy : Ada.Command_Line.Exit_Status;
begin
Shell (Command_Line, Dummy);
end Shell;
package body Controlled_Commands is
function Reference (Object : Processes.Command_Type)
return not null access System.Native_Processes.Command_Type is
begin
return Command_Type (Object).Native_Command'Unrestricted_Access;
end Reference;
overriding procedure Finalize (Object : in out Command_Type) is
begin
System.Native_Processes.Free (Object.Native_Command);
end Finalize;
end Controlled_Commands;
package body Controlled_Processes is
function Reference (Object : Processes.Process)
return not null access System.Native_Processes.Process is
begin
return Process (Object).Data'Unrestricted_Access;
end Reference;
function Create (
Command : Command_Type;
Directory : String := "";
Search_Path : Boolean := False;
Input : Streams.Stream_IO.File_Type :=
Streams.Stream_IO.Standard_Files.Standard_Input.all;
Output : Streams.Stream_IO.File_Type :=
Streams.Stream_IO.Standard_Files.Standard_Output.all;
Error : Streams.Stream_IO.File_Type :=
Streams.Stream_IO.Standard_Files.Standard_Error.all)
return Processes.Process is
begin
return Result : Processes.Process do
Create (
Result,
Command,
Directory,
Search_Path,
Input,
Output,
Error);
end return;
end Create;
function Create (
Command_Line : String;
Directory : String := "";
Search_Path : Boolean := False;
Input : Streams.Stream_IO.File_Type :=
Streams.Stream_IO.Standard_Files.Standard_Input.all;
Output : Streams.Stream_IO.File_Type :=
Streams.Stream_IO.Standard_Files.Standard_Output.all;
Error : Streams.Stream_IO.File_Type :=
Streams.Stream_IO.Standard_Files.Standard_Error.all)
return Processes.Process is
begin
return Result : Processes.Process do
Create (
Result,
Command_Line,
Directory,
Search_Path,
Input,
Output,
Error);
end return;
end Create;
overriding procedure Finalize (Object : in out Process) is
begin
System.Native_Processes.Close (Object.Data);
end Finalize;
end Controlled_Processes;
end Ada.Processes;
|
videocodec/libvpx_internal/libvpx/vp8/encoder/ppc/fdct_altivec.asm | Omegaphora/hardware_intel_common_omx-components | 49 | 246731 | ;
; Copyright (c) 2010 The WebM project authors. All Rights Reserved.
;
; Use of this source code is governed by a BSD-style license
; that can be found in the LICENSE file in the root of the source
; tree. An additional intellectual property rights grant can be found
; in the file PATENTS. All contributing project authors may
; be found in the AUTHORS file in the root of the source tree.
;
.globl vp8_short_fdct4x4_ppc
.globl vp8_short_fdct8x4_ppc
.macro load_c V, LABEL, OFF, R0, R1
lis \R0, \LABEL@ha
la \R1, \LABEL@l(\R0)
lvx \V, \OFF, \R1
.endm
;# Forward and inverse DCTs are nearly identical; only differences are
;# in normalization (fwd is twice unitary, inv is half unitary)
;# and that they are of course transposes of each other.
;#
;# The following three accomplish most of implementation and
;# are used only by ppc_idct.c and ppc_fdct.c.
.macro prologue
mfspr r11, 256 ;# get old VRSAVE
oris r12, r11, 0xfffc
mtspr 256, r12 ;# set VRSAVE
stwu r1,-32(r1) ;# create space on the stack
li r6, 16
load_c v0, dct_tab, 0, r9, r10
lvx v1, r6, r10
addi r10, r10, 32
lvx v2, 0, r10
lvx v3, r6, r10
load_c v4, ppc_dctperm_tab, 0, r9, r10
load_c v5, ppc_dctperm_tab, r6, r9, r10
load_c v6, round_tab, 0, r10, r9
.endm
.macro epilogue
addi r1, r1, 32 ;# recover stack
mtspr 256, r11 ;# reset old VRSAVE
.endm
;# Do horiz xf on two rows of coeffs v8 = a0 a1 a2 a3 b0 b1 b2 b3.
;# a/A are the even rows 0,2 b/B are the odd rows 1,3
;# For fwd transform, indices are horizontal positions, then frequencies.
;# For inverse transform, frequencies then positions.
;# The two resulting A0..A3 B0..B3 are later combined
;# and vertically transformed.
.macro two_rows_horiz Dst
vperm v9, v8, v8, v4 ;# v9 = a2 a3 a0 a1 b2 b3 b0 b1
vmsumshm v10, v0, v8, v6
vmsumshm v10, v1, v9, v10
vsraw v10, v10, v7 ;# v10 = A0 A1 B0 B1
vmsumshm v11, v2, v8, v6
vmsumshm v11, v3, v9, v11
vsraw v11, v11, v7 ;# v11 = A2 A3 B2 B3
vpkuwum v10, v10, v11 ;# v10 = A0 A1 B0 B1 A2 A3 B2 B3
vperm \Dst, v10, v10, v5 ;# Dest = A0 B0 A1 B1 A2 B2 A3 B3
.endm
;# Vertical xf on two rows. DCT values in comments are for inverse transform;
;# forward transform uses transpose.
.macro two_rows_vert Ceven, Codd
vspltw v8, \Ceven, 0 ;# v8 = c00 c10 or c02 c12 four times
vspltw v9, \Codd, 0 ;# v9 = c20 c30 or c22 c32 ""
vmsumshm v8, v8, v12, v6
vmsumshm v8, v9, v13, v8
vsraw v10, v8, v7
vspltw v8, \Codd, 1 ;# v8 = c01 c11 or c03 c13
vspltw v9, \Ceven, 1 ;# v9 = c21 c31 or c23 c33
vmsumshm v8, v8, v12, v6
vmsumshm v8, v9, v13, v8
vsraw v8, v8, v7
vpkuwum v8, v10, v8 ;# v8 = rows 0,1 or 2,3
.endm
.macro two_rows_h Dest
stw r0, 0(r8)
lwz r0, 4(r3)
stw r0, 4(r8)
lwzux r0, r3,r5
stw r0, 8(r8)
lwz r0, 4(r3)
stw r0, 12(r8)
lvx v8, 0,r8
two_rows_horiz \Dest
.endm
.align 2
;# r3 short *input
;# r4 short *output
;# r5 int pitch
vp8_short_fdct4x4_ppc:
prologue
vspltisw v7, 14 ;# == 14, fits in 5 signed bits
addi r8, r1, 0
lwz r0, 0(r3)
two_rows_h v12 ;# v12 = H00 H10 H01 H11 H02 H12 H03 H13
lwzux r0, r3, r5
two_rows_h v13 ;# v13 = H20 H30 H21 H31 H22 H32 H23 H33
lvx v6, r6, r9 ;# v6 = Vround
vspltisw v7, -16 ;# == 16 == -16, only low 5 bits matter
two_rows_vert v0, v1
stvx v8, 0, r4
two_rows_vert v2, v3
stvx v8, r6, r4
epilogue
blr
.align 2
;# r3 short *input
;# r4 short *output
;# r5 int pitch
vp8_short_fdct8x4_ppc:
prologue
vspltisw v7, 14 ;# == 14, fits in 5 signed bits
addi r8, r1, 0
addi r10, r3, 0
lwz r0, 0(r3)
two_rows_h v12 ;# v12 = H00 H10 H01 H11 H02 H12 H03 H13
lwzux r0, r3, r5
two_rows_h v13 ;# v13 = H20 H30 H21 H31 H22 H32 H23 H33
lvx v6, r6, r9 ;# v6 = Vround
vspltisw v7, -16 ;# == 16 == -16, only low 5 bits matter
two_rows_vert v0, v1
stvx v8, 0, r4
two_rows_vert v2, v3
stvx v8, r6, r4
;# Next block
addi r3, r10, 8
addi r4, r4, 32
lvx v6, 0, r9 ;# v6 = Hround
vspltisw v7, 14 ;# == 14, fits in 5 signed bits
addi r8, r1, 0
lwz r0, 0(r3)
two_rows_h v12 ;# v12 = H00 H10 H01 H11 H02 H12 H03 H13
lwzux r0, r3, r5
two_rows_h v13 ;# v13 = H20 H30 H21 H31 H22 H32 H23 H33
lvx v6, r6, r9 ;# v6 = Vround
vspltisw v7, -16 ;# == 16 == -16, only low 5 bits matter
two_rows_vert v0, v1
stvx v8, 0, r4
two_rows_vert v2, v3
stvx v8, r6, r4
epilogue
blr
.data
.align 4
ppc_dctperm_tab:
.byte 4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11
.byte 0,1,4,5, 2,3,6,7, 8,9,12,13, 10,11,14,15
.align 4
dct_tab:
.short 23170, 23170,-12540,-30274, 23170, 23170,-12540,-30274
.short 23170, 23170, 30274, 12540, 23170, 23170, 30274, 12540
.short 23170,-23170, 30274,-12540, 23170,-23170, 30274,-12540
.short -23170, 23170, 12540,-30274,-23170, 23170, 12540,-30274
.align 4
round_tab:
.long (1 << (14-1)), (1 << (14-1)), (1 << (14-1)), (1 << (14-1))
.long (1 << (16-1)), (1 << (16-1)), (1 << (16-1)), (1 << (16-1))
|
programs/oeis/051/A051490.asm | neoneye/loda | 22 | 98794 | ; A051490: a(n) = n^(n+2)*(n+2)^n.
; 0,3,256,30375,5308416,1313046875,440301256704,193010051319183,107374182400000000,73994897046174912819,61917364224000000000000,61870237399093306018139447,72790360926157879387298463744,99617732553594016079725341796875
mov $1,$0
add $1,2
mov $2,$0
pow $0,$1
pow $1,$2
mul $1,$0
mov $0,$1
|
RMonads/Restriction.agda | jmchapman/Relative-Monads | 21 | 9904 | <filename>RMonads/Restriction.agda
module RMonads.Restriction where
open import Library
open import Categories
open import Functors
open import Naturals
open import Monads
open import RMonads
open Cat
open Fun
restrictM : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}(J : Fun C D) →
Monad D → RMonad J
restrictM J M = record {
T = T ∘ OMap J;
η = η;
bind = bind;
law1 = law1;
law2 = law2;
law3 = law3}
where open Monad M
open import Monads.MonadMorphs
open import RMonads.RMonadMorphs
restrictMM : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{M M' : Monad D}
(J : Fun C D) → MonadMorph M M' →
RMonadMorph (restrictM J M) (restrictM J M')
restrictMM J MM = record {
morph = λ{X} → morph {OMap J X};
lawη = lawη;
lawbind = lawbind}
where open MonadMorph MM
open import Adjunctions
open import RAdjunctions
restrictA : ∀{a b c d e f}{C : Cat {a}{b}}{D : Cat {c}{d}}{E : Cat {e}{f}}
(J : Fun C D) → Adj D E → RAdj J E
restrictA J A = record{
L = L ○ J;
R = R;
left = left;
right = right;
lawa = lawa;
lawb = lawb;
natleft = natleft ∘ HMap J;
natright = natright ∘ HMap J}
where open Adj A
|
misc/excel_to_tab.scpt | widdowquinn/scripts | 15 | 3485 | <gh_stars>10-100
# excel_to_tab.scpt
#
# This script takes as input an Excel workbook containing one or more
# worksheets. It creates a new directory with the same name as the workbook,
# with the appended string _extracted. This directory contains a set of
# tab-separated plaintext files, one per worksheet. Each file has the same
# name as the corresponding worksheet, with the extension .tab.
#
# Installation:
#
# This script is written in AppleScript, and is only expected to work on OSX.
#
# Place the excel_to_tab.scpt into your ~/Library/Scripts directory (create
# this directory if it does not exist).
#
# Open AppleScript Editor (in /Applications/Utilities) and open the General
# Preferences. Check the Show Script menu in menu bar setting, and close
# AppleScript Editor. You should now see the script symbol in the top menu
# bar.
#
# Usage:
#
# Click on the script symbol in the menu bar, and select the excel_to_tab
# option (it will be in the lower section). This will open a file selection
# dialog box. Select the appropriate Excel file, and click Choose. The script
# will generate the output directory in the same location as the Excel file.
#
# (c) <NAME>
# Authors: <NAME>
#
# Contact:
# <EMAIL>
#
# <NAME>,
# Information and Computing Sciences,
# James Hutton Institute,
# Errol Road,
# Invergowrie,
# Dundee,
# DD6 9LH,
# Scotland,
# UK
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
# Select Excel workbook via dialogue
set theWorkbookFile to choose file with prompt "Please select an Excel Workbook"
# Open Excel and get useful information
tell application "Microsoft Excel"
open theWorkbookFile
set workbookName to name of active workbook
if workbookName ends with ".xls" then set workbookName to text 1 thru -5 of workbookName
if workbookName ends with ".xlsx" then set workbookName to text 1 thru -6 of workbookName
end tell
# Create new folder for output
set outputDirectory to (theWorkbookFile as text) & "_extracted"
if outputDirectory ends with ":" then set outputDirectory to text 1 thru -2 of outputDirectory
do shell script "mkdir -p " & quoted form of POSIX path of outputDirectory
# Loop over worksheets and write out in tab-separated format
tell application "Microsoft Excel"
set theSheets to worksheets of active workbook
repeat with aSheet in theSheets
set thisPath to outputDirectory & ":" & workbookName & "_" & name of aSheet & ".tab"
save aSheet in thisPath as text Mac file format
end repeat
close active workbook without saving
end tell
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca.log_21829_1108.asm | ljhsiun2/medusa | 9 | 174954 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %r8
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x6c2b, %rsi
lea addresses_UC_ht+0x1401f, %rdi
nop
nop
nop
nop
nop
and %r11, %r11
mov $84, %rcx
rep movsb
dec %r14
lea addresses_A_ht+0x12c8f, %rsi
nop
nop
nop
nop
nop
add %rdi, %rdi
movl $0x61626364, (%rsi)
nop
add %rcx, %rcx
lea addresses_normal_ht+0x15c8f, %r11
nop
nop
nop
nop
nop
and $34422, %r10
mov (%r11), %r14d
nop
cmp $27927, %r10
lea addresses_WC_ht+0x5d8f, %r11
nop
nop
nop
nop
nop
cmp %r8, %r8
movb (%r11), %r14b
nop
nop
nop
nop
nop
add %rdi, %rdi
lea addresses_normal_ht+0x182f4, %r14
nop
add $61656, %rdi
movl $0x61626364, (%r14)
nop
add $50543, %r10
lea addresses_WT_ht+0x1748f, %r10
nop
nop
nop
and $33857, %rsi
movb $0x61, (%r10)
nop
nop
sub $23569, %r14
lea addresses_WT_ht+0x19be7, %rsi
lea addresses_A_ht+0x1247f, %rdi
clflush (%rdi)
dec %rbp
mov $108, %rcx
rep movsw
xor %rdi, %rdi
lea addresses_D_ht+0x1088f, %rcx
cmp %rbp, %rbp
mov (%rcx), %r14w
nop
dec %r11
lea addresses_normal_ht+0x184bf, %rsi
lea addresses_A_ht+0x1d6cf, %rdi
sub %rbp, %rbp
mov $103, %rcx
rep movsq
nop
nop
xor %rsi, %rsi
lea addresses_D_ht+0x18207, %rdi
nop
nop
cmp %rsi, %rsi
mov (%rdi), %bp
nop
nop
nop
nop
sub $46309, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r14
push %r15
push %r9
push %rbp
// Faulty Load
lea addresses_D+0xac8f, %r10
nop
xor $38388, %r15
movups (%r10), %xmm2
vpextrq $0, %xmm2, %r12
lea oracles, %rbp
and $0xff, %r12
shlq $12, %r12
mov (%rbp,%r12,1), %r12
pop %rbp
pop %r9
pop %r15
pop %r14
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 1, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_A_ht'}}
{'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_normal_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 2, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_A_ht'}}
{'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 2, 'NT': True, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 4, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_A_ht'}}
{'src': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
src/intro.asm | fjpena/sword-of-ianna-zx | 67 | 93388 | <gh_stars>10-100
intro_var: db 0
number_screens: db 0
menu_string_list: dw 0
menu_screen_list: dw 0
menu_attr_list: dw 0
menu_cls_loop: db 0
load_buffer: EQU $AC80 ; using the tiles/superfiles buffer to load stuff
screen_buffer: EQU $7800 ; strings/scripts level for screen bitmap buffer
attr_buffer: EQU $BE00 ; dirty tiles / spdata area for attribute buffer
intro_strings: dw string01, string02, string03, string04, string05
intro_strings_en: dw string01_en, string02_en, string03_en, string04_en, string05_en
final_strings: dw end_string01, end_string02, end_string03
final_strings_en: dw end_string01_en, end_string02_en, end_string03_en
intro_screens: dw load_buffer, load_buffer+1020, load_buffer+1020+592, load_buffer+1020+592+777, load_buffer+1020+592+777+484
intro_attrs: dw load_buffer+3777, load_buffer+3777+59, load_buffer+3777+59+96, load_buffer+3777+59+96+102, load_buffer+3777+59+96+102+69
final_screens: dw load_buffer, load_buffer+592, load_buffer+592+1302
final_attrs: dw load_buffer+2819, load_buffer+2819+96, load_buffer+2819+96+66
string01: db 'HACE TIEMPO, EL MUNDO ESTUVO DOMINADO POR EL SE$OR DEL CAOS.',0
string02: db 'ANTE TAL SITUACI;N, LA DIOSA IANNA ELIGI; A TUKARAM PARA PORTAR LA ESPADA SAGRADA QUE ELIMINAR>A EL MAL.',0
string03: db 'TUKARAM CONSIGUI; TRAER LA PAZ A NUESTRAS TIERRAS, SIENDO SU ESTIRPE BENDECIDA COMO SIERVOS DE LA DIOSA.',0
string04: db 'PERO EL MAL NO DESCANSA, Y SIGLOS M%S TARDE INTENTA RECUPERAR TERRENO.',0
string05: db 'COMO HEREDERO DE TUKARAM, TU DEBER ES PONERTE EN MARCHA, VENCER AL CAOS Y RESTABLECER EL ORDEN.',0
string01_en: db 'A LONG TIME AGO, THE WORLD WAS RULED BY THE NOCUOUS LORD OF CHAOS.',0
string02_en: db 'THE GODDESS IANNA APPOINTED TUKARAM TO WIELD THE SACRED SWORD THAT COULD DEFEAT EVILNESS.',0
string03_en: db 'TUKARAM BROUGHT PEACE TO OUR LANDS, AND HIS LINEAGE WAS BLESSED AS SERVANTS OF THE GODDESS.',0
string04_en: db 'BUT EVIL DOES NOT REST, AND SOME CENTURIES LATER IT TRIES TO RECOVER.',0
string05_en: db 'AS AN HEIR OF TUKARAM, IT IS YOUR SWORN DUTY TO GO NOW, OVERCOME CHAOS AND RESTORE ORDER.',0
end_string01: db 'EL CAOS HA SIDO EXPULSADO Y LA DIOSA IANNA EST% AGRADECIDA.',0
end_string02: db 'VUELVE CON TU PUEBLO, FIEL GUERRERO, Y VIVE TRANQUILO. CUSTODIAR? LA ESPADA, PUES EL MAL NO DESCANSA.',0
end_string03: db 'REGRESAR AL HOGAR ES LA <NAME>, Y LA PAZ EL BIEN M%S PRECIADO.',0
end_string01_en: db 'THE LORD OF CHAOS HAS BEEN DEFEATED, AND IANNA IS WELL PLEASED.',0
end_string02_en: db 'GO BACK TO YOUR VILLAGE AND ENJOY A PEACEFUL LIFE. I WILL KEEP THE SWORD, FOR EVIL DOES NOT REST.',0
end_string03_en: db 'RETURNING HOME IS THE HIGHEST REWARD, AND PEACE THE MOST PRECIOUS POSSESSION.',0
intro:
ld a, 1
ld (intro_shown), a
; Now do the usual stuff
ld a, (language)
and a
jr nz, intro_english
ld hl, intro_strings
jr intro_common
intro_english:
ld hl, intro_strings_en
intro_common:
ld de, intro_screens
ld a, 5
ld (number_screens), a
ld c, 1 ; intro
call slideshow
ld b, 120
intro_end_loop:
halt
djnz intro_end_loop
ret
ending:
ld a, (language)
and a
jr nz, end_english
ld hl, final_strings
jr end_common
end_english:
ld hl, final_strings_en
end_common:
ld de, final_screens
ld a, 3
ld (number_screens), a
ld c, 2 ; end
call slideshow
ld b, 100
end_wait_loop:
halt
djnz end_wait_loop
call cls
call MUSIC_Stop
jp end_credits
; INPUT:
; A: number of screens
; C: 1: intro, 2: end
; HL: pointer to strings
; DE: pointer to screen addresses
slideshow:
push bc
ld (number_screens), a
ld (menu_string_list), hl
ld (menu_screen_list), de
add a, a
ld l, a
ld h, 0
add hl, de ; HL = right after screen_list, that is, attr_list
ld (menu_attr_list), hl
xor a
call IO_LoadIntro ; load intro frame
ld hl, load_buffer
ld de, screen_buffer
ld bc, 2000 ; that's more than needed, but hey :)
ldir
pop bc
ld a, c
call IO_LoadIntro ; load screens
; Now show the frame, and start with the slideshow
ld hl, screen_buffer
call depackscr
ld a, 1
ld (music_playing), a ; music is now playing
xor a
ld (intro_var), a
intro_loop:
ld a, (intro_var)
call load_screen
call menu_cls
call menu_cls_textarea
call draw_screen
ld a, (intro_var)
add a, a
ld hl, (menu_string_list)
ld e, a
ld d, 0
add hl, de
ld a, (hl)
ld iyl, a
inc hl
ld a, (hl)
ld iyh, a
ld bc, 2*256+18
; ld b, 2
; ld c, 18
call print_string_menu
ld b, 0
waitloop:
xor a
ld (joystick_state), a ; reset joystick state
halt
ld a, (joystick_state)
bit 4, a
jr nz, waitloop_done
djnz waitloop
waitloop_done:
ld a, (intro_var)
inc a
ld hl, number_screens
cp (hl)
ret nc
ld (intro_var), a
jr intro_loop
; A: screen number
load_screen:
ld de, screen_buffer
add a, a
ld c, a
ld b, 0
push bc
ld hl, (menu_screen_list)
add hl, bc
ld c, (hl)
inc hl
ld b, (hl)
ld h, b
ld l, c
call depack ; Place bitmap in bitmap buffer
pop bc
ld de, attr_buffer
ld hl, (menu_attr_list)
add hl, bc
ld c, (hl)
inc hl
ld b, (hl)
ld h, b
ld l, c
jp depack ; Place attributes in attr buffer
; ret
draw_screen:
ld bc, $0800
ld de, screen_buffer
draw_screen_loop_char:
push bc
push de
call print_char_menu_go
pop de
pop bc
ld hl, 8
add hl, de
ex de, hl ; DE points to the next char
inc b
ld a, b
cp 24
jr nz, draw_screen_loop_char
ld b, 8
; next y
inc c
ld a, c
cp 16
jr nz, draw_screen_loop_char
draw_screen_attributes:
ld hl, attr_buffer ; go to the start of the attribute area
ld bc, $0800
halt
draw_screen_loop_attr:
ld a, (hl)
push hl
push bc
ld e, a
call SetAttribute
pop bc
pop hl
inc hl
inc b
ld a, b
cp 24
jr nz, draw_screen_loop_attr
halt
ld b, 8
; next y
inc c
ld a, c
cp 16
jr nz, draw_screen_loop_attr
ret
; Print a string, terminated by 0
; INPUT:
; IY: pointer to string
; B: X in chars
; C: Y in chars
print_string_menu:
push iy
call next_word_menu
pop iy
ld a, d
and a
ret z ; return on NULL
add a, b
cp 32
jr c, print_str_nonextline_menu
print_str_nextline_menu: ; go to next line
ld b, 2
inc c
print_str_nonextline_menu:
; now print word
call print_word_menu
jr print_string_menu
; ret
; Find next word
; INPUT:
; IY: pointer to string
; OUTPUT:
; D: word length
next_word_menu:
ld d, 0
next_word_menu_loop:
ld a, (iy+0)
and a
ret z
cp ' '
jr z, next_word_menu_finished
cp ','
jr z, next_word_menu_finished
cp '.'
jr z, next_word_menu_finished
inc d
inc iy
jr next_word_menu_loop
next_word_menu_finished:
inc d
ret
; Print a word on screen
; INPUT:
; - B: X in chars
; - C: Y in chars
; - D: word length
print_word_menu:
halt
ld a, (iy+0)
push de
push iy
push bc
call print_char_menu
pop bc
pop iy
pop de
inc iy
inc b
ld a, d
dec a
ld d, a
jr nz, print_word_menu
ret
menu_cls:
xor a
ld (menu_cls_loop), a
ld b, 20
menu_cls_outerloop:
ld hl, 16384+6144+5
ld e, a
ld d, 0
add hl, de ; HL points to the first row
ld de, 30
ld c, 16
halt
halt
menu_cls_inerloop:
xor a
ld (hl), a
inc hl
ld (hl), 2
inc hl
ld (hl), 2
add hl, de
dec c
jr nz, menu_cls_inerloop
ld a, (menu_cls_loop)
inc a
ld (menu_cls_loop), a
dec b
jr nz, menu_cls_outerloop
; last line, the last column is red, now clean
ret
menu_cls_textarea:
ld de, FONT
ld c, 18
menu_cls_textarea_yloop:
ld b, 2
menu_cls_textarea_xloop:
push bc
push de
call print_char_menu_go
pop de
pop bc
inc b
ld a, b
cp 30
jr nz, menu_cls_textarea_xloop
inc c
ld a, c
cp 23
jr nz, menu_cls_textarea_yloop
ret
print_char_menu:
sub 32 ; first char is number 32
ld e, a
ld d, 0
rl e
rl d
rl e
rl d
rl e
rl d ; Char*8, to get to the first byte
ld hl, FONT
add hl, de ; HL points to the first byte
ex de, hl ; DE points to the first byte
print_char_menu_go:
ld hl, TileScAddress ; address table
ld a, c
add a,c ; C = 2*Y, to address the table
ld c,a
ld a, b ; A = X
ld b, 0 ; Clear B for the addition
add hl, bc ; hl = address of the first tile
ld c, (hl)
inc hl
ld b, (hl) ; BC = Address
ld l,a ; hl = X
ld h, 0
add hl, bc ; hl = tile address in video memory
ld b, 8
print_char_menu_loop:
ld a, (de)
ld (hl), a
inc de ; FIXME! will be able to do INC E, when FONTS is aligned in memory
inc h
djnz print_char_menu_loop
ret
end_credits:
ld a, 3
call IO_LoadIntro ; load credits screen
; Load credits music
call MUSIC_LoadCredits
call MUSIC_Init ; little trick: load but don't play
call cls
ld hl, load_buffer
call depackscr
ld a, 1
ld (music_playing), a ; music is now playing
ld iy, credits01
ld b, 40
end_credits_line:
push iy
push bc
call credits_string
call end_credits_loop
pop bc
pop iy
ld de, 16
add iy, de
djnz end_credits_line
ld b, 14
end_credits_end:
push bc
call end_credits_loop
pop bc
djnz end_credits_end
ld bc, 12*256+16
ld iy, credits_end
call credits_string_loop
end_credits_wait_loop:
xor a
ld (joystick_state), a ; reset joystick state
halt
ld a, (joystick_state)
bit 4, a
jr z, end_credits_wait_loop
call MUSIC_Stop
ret
end_credits_loop:
ld a, 8
end_credits_loop_inner:
halt
halt
halt
halt
push af
call credits_scrollup
pop af
dec a
jr nz, end_credits_loop_inner
ret
; IY: string
credits_string:
ld bc, 10*256+23
; ld c, 23
credits_string_loop
ld a, (iy+0)
and a
ret z
push iy
push bc
call print_char_menu
pop bc
pop iy
inc iy
inc b
jr credits_string_loop
; 16 bytes starting at X=10 (in tile coords)
; D: destination Y (in pixels)
; E: source Y
credits_scroll_line:
push de
ld c, d
ld b, 80
call calcscreenpos ; destination screen position in HL
pop de
ex de, hl ; destination screen position in DE
ld c, l
ld b, 80
call calcscreenpos ; source screen position in HL
ld b, 16
credits_scroll_line_loop:
ld a, (hl)
ld (de), a
inc l
inc e
djnz credits_scroll_line_loop
ret
; scroll all lines from Y=87 to Y=184
credits_scrollup:
ld de, 87*256+88
ld b, 191-87
credits_scrollup_loop:
push bc
push de
call credits_scroll_line
pop de
inc d
inc e
pop bc
djnz credits_scrollup_loop
ret
; FIXME: this will be compressed here
credits01: db 'RETROWORKS 2017',0
credits02: db ' ',0
credits03: db 'CODE: ',0
credits04: db ' UTOPIAN',0
credits05: db ' ',0
credits06: db 'GFX, LEVELS: ',0
credits07: db ' PAGANTIPACO',0
credits08: db ' ',0
credits09: db 'MUSIC AND SFX: ',0
credits10: db ' MCALBY',0
credits11: db ' ',0
credits12: db 'LOADING SCREEN:',0
credits13: db ' MAC',0
credits14: db ' ',0
credits15: db 'OPTIMIZATIONS: ',0
credits16: db ' METALBRAIN',0
credits17: db ' ',0
credits18: db 'CARTRIDGE HW: ',0
credits19: db ' DANDARE',0
credits20: db ' ',0
credits21: db 'PROOFREADING: ',0
credits22: db ' <NAME>',0
credits23: db ' ',0
credits24: db 'TESTING: ',0
credits25: db ' METR81',0
credits26: db ' IVANZX',0
credits27: db 'RETROWORKS TEAM',0
credits28: db ' ',0
credits29: db 'WE WANT TO SAY ',0
credits30: db ' THANK YOU TO:',0
credits31: db ' ',0
credits32: db 'FRIENDWARE AND ',0
credits33: db ' REBEL ACT ',0
credits34: db ' STUDIOS, FOR ',0
credits35: db ' CREATING ',0
credits36: db 'BLADE: THE EDGE',0
credits37: db ' OF DARKNESS ',0
credits38: db ' ',0
credits39: db ' YOU, PLAYER, ',0
credits40: db ' FOR PLAYING ',0
credits_end: db ' THE END ',0
|
payloads/x64/src/kernel/find_process_name.asm | kurobeats/MS17-010 | 2 | 82244 | ;
; Windows x64 Kernel Find Process by Name Shellcode
;
; Author: <NAME> <<EMAIL>> (@zerosum0x0)
; Copyright: (c) 2017 RiskSense, Inc.
; License: Apache 2.0
;
; Arguments: r10d = process hash, r15 = nt!, rdx = *PEPROCESS
; Clobbers: RAX, RCX, RDX, R8, R9, R10, R11
;
[BITS 64]
[ORG 0]
find_process_name:
xor ecx, ecx
_find_process_name_loop_pid:
add cx, 0x4
cmp ecx, 0x10000
jge kernel_exit
push rdx
; rcx = PID
; rdx = *PEPROCESS
mov r11d, PSLOOKUPPROCESSBYPROCESSID_HASH
call block_api_direct
add rsp, 0x20
test rax, rax ; see if STATUS_SUCCESS
jnz _find_process_name_loop_pid
pop rdx
mov rcx, dword [rdx] ; *rcx = *PEPROCESS
push rcx
mov r11d, PSGETPROCESSIMAGEFILENAME_HASH
call block_api_direct
add rsp, 0x20
pop rcx
mov rsi, rax
call calc_hash
cmp r9d, r10d
jne _find_process_name_loop_pid
|
programs/oeis/174/A174989.asm | karttu/loda | 0 | 162589 | ; A174989: Partial sums of A003602.
; 1,2,4,5,8,10,14,15,20,23,29,31,38,42,50,51,60,65,75,78,89,95,107,109,122,129,143,147,162,170,186,187,204,213,231,236,255,265,285,288,309,320,342,348,371,383,407,409,434,447,473,480,507,521,549,553,582,597
mov $1,$0
mov $2,$0
add $2,2
lpb $2,1
add $1,$3
add $3,4
mov $4,4
lpb $4,1
sub $3,$2
sub $4,$3
lpe
sub $2,1
trn $3,3
lpe
add $1,1
|
rts/src/common/s-atacco.ads | ScottWLoyd/bare-metal-ada-tools | 7 | 16667 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . A D D R E S S _ T O _ A C C E S S _ C O N V E R S I O N S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
generic
type Object (<>) is limited private;
package System.Address_To_Access_Conversions is
pragma Preelaborate;
pragma Elaborate_Body;
-- This pragma Elaborate_Body is there to ensure the requirement of what is
-- at the moment a dummy null body. The reason this null body is there is
-- that we used to have a real body, and it causes bootstrap problems with
-- old compilers if we try to remove the corresponding file.
pragma Compile_Time_Warning
(Object'Unconstrained_Array,
"Object is unconstrained array type" & ASCII.LF &
"To_Pointer results may not have bounds");
-- Capture constrained status, suppressing warnings, since this is
-- an obsolescent feature to use Constrained in this way (RM J.4).
pragma Warnings (Off);
Xyz : Boolean := Object'Constrained;
pragma Warnings (On);
type Object_Pointer is access all Object;
for Object_Pointer'Size use Standard'Address_Size;
pragma No_Strict_Aliasing (Object_Pointer);
-- Strictly speaking, this routine should not be used to generate pointers
-- to other than proper values of the proper type, but in practice, this
-- is done all the time. This pragma stops the compiler from doing some
-- optimizations that may cause unexpected results based on the assumption
-- of no strict aliasing.
function To_Pointer (Value : Address) return Object_Pointer;
function To_Address (Value : Object_Pointer) return Address;
pragma Import (Intrinsic, To_Pointer);
pragma Import (Intrinsic, To_Address);
end System.Address_To_Access_Conversions;
|
COR1.asm | ELASRIYASSINE/DSP-DIGITAL-SIGNAL-PROCESSING-CODES- | 0 | 15118 | <filename>COR1.asm<gh_stars>0
.text
x .int 0,1,2,3,4,5,6,7
adr_x .word x
ldi @adr_x,AR0
ldi @adr_x,AR1
addi 1,AR0
ldi 0,R2
ldi 0,R0
ldi 6,RC
Rpts RC
mpyi *AR0++,*AR1++,R0
||addi R0,R2
addi R0,R2
sti R2,@30h
.end |
Transynther/x86/_processed/AVXALIGN/_ht_zr_/i9-9900K_12_0xca.log_21829_224.asm | ljhsiun2/medusa | 9 | 80157 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r14
push %r9
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x11587, %r14
clflush (%r14)
nop
and $58583, %r13
mov $0x6162636465666768, %r9
movq %r9, %xmm7
movups %xmm7, (%r14)
nop
nop
add $60388, %rax
lea addresses_A_ht+0x5417, %rsi
lea addresses_A_ht+0x1e017, %rdi
nop
add $27931, %rdx
mov $59, %rcx
rep movsq
nop
nop
nop
nop
nop
add $33496, %rsi
lea addresses_WT_ht+0x1ba17, %rsi
lea addresses_UC_ht+0x1d617, %rdi
nop
nop
nop
dec %rdx
mov $108, %rcx
rep movsq
xor $58258, %rdi
lea addresses_A_ht+0x17e17, %r14
sub %rax, %rax
mov (%r14), %rdi
nop
nop
cmp %rdi, %rdi
lea addresses_WC_ht+0x14d17, %rsi
lea addresses_A_ht+0xf617, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
add %rax, %rax
mov $116, %rcx
rep movsq
nop
nop
nop
nop
nop
and %r14, %r14
lea addresses_UC_ht+0x3bf7, %r14
nop
nop
nop
nop
and %rsi, %rsi
mov (%r14), %r9w
nop
nop
nop
nop
nop
dec %rax
lea addresses_D_ht+0x877, %rsi
lea addresses_WT_ht+0xb403, %rdi
nop
nop
and $2984, %r13
mov $50, %rcx
rep movsw
nop
nop
dec %rcx
lea addresses_normal_ht+0x2cb7, %rdx
nop
nop
nop
sub $43469, %rdi
movw $0x6162, (%rdx)
nop
nop
nop
nop
nop
lfence
lea addresses_D_ht+0x14817, %rsi
lea addresses_A_ht+0x15817, %rdi
xor $36131, %rdx
mov $4, %rcx
rep movsw
nop
nop
nop
add %rdi, %rdi
lea addresses_WC_ht+0x61e3, %rdi
nop
nop
nop
nop
nop
sub $22303, %rdx
mov $0x6162636465666768, %r9
movq %r9, (%rdi)
nop
nop
nop
nop
add %rcx, %rcx
lea addresses_normal_ht+0xcbf, %rsi
clflush (%rsi)
nop
nop
nop
nop
add %rcx, %rcx
mov (%rsi), %rax
nop
nop
nop
xor $27356, %rsi
lea addresses_UC_ht+0x12217, %rcx
nop
nop
sub %rax, %rax
mov $0x6162636465666768, %r13
movq %r13, %xmm3
and $0xffffffffffffffc0, %rcx
vmovaps %ymm3, (%rcx)
nop
nop
nop
nop
dec %r14
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r14
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r14
push %r15
push %r9
push %rbp
push %rdi
// Load
lea addresses_RW+0xea17, %r15
nop
nop
nop
nop
nop
dec %rbp
mov (%r15), %edi
add $52756, %r14
// Store
mov $0x497, %r11
nop
nop
nop
cmp $13623, %r9
movl $0x51525354, (%r11)
nop
nop
and %r9, %r9
// Store
lea addresses_A+0x10d12, %r13
nop
nop
nop
nop
nop
and %rbp, %rbp
mov $0x5152535455565758, %r15
movq %r15, %xmm6
vmovups %ymm6, (%r13)
cmp %rbp, %rbp
// Store
lea addresses_A+0x15893, %rdi
nop
nop
nop
nop
nop
inc %r9
mov $0x5152535455565758, %r14
movq %r14, %xmm7
movups %xmm7, (%rdi)
nop
nop
nop
nop
add $40622, %r13
// Faulty Load
mov $0xa17, %r11
nop
nop
sub %r13, %r13
movaps (%r11), %xmm3
vpextrq $1, %xmm3, %rdi
lea oracles, %r15
and $0xff, %rdi
shlq $12, %rdi
mov (%r15,%rdi,1), %rdi
pop %rdi
pop %rbp
pop %r9
pop %r15
pop %r14
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 2}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_P', 'same': True, 'AVXalign': True, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 2}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 8}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 10}}
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 8}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 10}}
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 5}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 4}, 'dst': {'same': True, 'type': 'addresses_WT_ht', 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 7}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 1}}
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': True, 'congruent': 11}}
{'45': 9522, '49': 3388, '48': 1170, '00': 3167, '46': 4582}
49 45 45 49 45 45 45 45 45 49 45 49 00 45 45 45 46 45 46 45 46 48 45 45 49 00 46 46 45 46 00 49 46 45 45 45 45 45 45 45 45 45 45 45 45 49 46 00 46 45 46 00 45 49 48 45 00 46 00 00 46 49 46 00 49 00 45 45 46 46 45 45 46 00 46 49 45 45 00 00 45 45 48 00 46 00 46 45 49 45 45 45 00 45 00 48 45 46 45 46 48 45 49 45 49 45 45 45 45 46 00 45 45 46 49 00 45 45 45 49 46 00 46 00 46 45 45 45 46 49 48 45 45 46 00 45 49 45 49 45 45 46 00 45 45 00 00 45 45 49 46 00 46 00 46 45 46 45 45 45 45 49 45 46 00 45 45 46 45 46 45 45 45 49 48 00 46 00 46 45 46 00 45 45 48 45 46 46 48 45 45 45 48 00 46 45 46 00 45 49 00 45 48 00 46 49 49 45 45 48 00 46 49 49 45 45 45 49 00 46 49 45 45 45 45 45 45 48 45 46 45 45 46 00 46 45 45 45 49 49 00 45 00 49 46 00 46 45 46 48 45 45 48 45 46 46 45 46 00 46 00 45 00 45 49 00 45 00 45 45 45 49 48 00 46 45 46 00 46 48 45 45 45 45 48 48 45 46 00 46 45 46 00 45 49 45 45 46 49 45 45 46 00 46 45 46 48 45 45 48 45 46 46 45 45 45 46 45 45 45 46 49 00 46 00 46 00 45 00 46 45 46 00 45 45 45 46 45 46 48 45 45 49 00 00 46 48 45 45 45 45 46 45 46 00 49 45 45 45 46 00 45 45 45 46 00 45 45 45 45 45 45 46 00 45 45 45 48 45 46 45 45 46 00 46 49 46 48 45 49 45 45 46 45 45 46 00 45 45 45 49 00 49 45 45 49 49 49 46 48 45 46 45 46 46 45 45 46 00 49 00 45 46 45 49 45 00 49 45 48 45 46 48 45 49 45 49 46 00 45 45 45 45 45 00 00 46 00 00 46 45 46 00 45 45 45 48 45 46 46 45 49 00 45 45 45 49 00 45 49 46 46 45 46 00 45 49 49 45 49 49 00 45 45 49 46 49 46 00 45 45 45 46 00 45 49 45 49 49 00 45 49 49 49 45 45 45 45 45 00 46 45 45 46 49 46 00 46 48 45 45 45 49 46 45 45 45 46 00 45 45 46 00 45 45 49 45 46 00 46 45 46 48 49 45 45 48 45 49 49 45 45 45 45 45 48 45 46 46 45 46 00 45 49 00 46 46 45 46 00 49 45 46 45 46 46 45 49 46 45 46 00 45 49 45 00 45 49 46 00 45 45 45 45 45 46 49 49 49 45 45 45 48 45 46 00 49 45 45 46 00 45 45 46 45 46 49 45 45 46 49 45 45 45 46 45 46 45 45 46 00 46 45 46 00 49 49 45 00 00 46 49 45 45 49 45 45 45 45 49 00 46 48 45 45 45 45 45 45 49 45 45 45 45 45 45 45 48 48 45 49 45 48 00 46 00 46 49 46 48 45 45 49 00 45 45 49 45 48 00 46 49 49 49 45 46 45 46 46 45 49 45 48 00 46 45 46 00 45 45 45 46 45 46 49 45 45 49 45 46 45 45 46 45 45 45 46 45 46 49 49 45 45 49 45 00 45 45 49 49 45 46 00 45 45 45 45 45 46 45 46 48 45 45 45 46 00 46 45 46 48 45 45 49 00 45 46 00 45 00 45 45 46 00 45 45 45 45 45 00 46 00 46 00 45 49 00 46 00 45 48 45 49 45 45 49 45 45 45 45 46 45 00 45 49 45 45 46 00 45 45 46 49 48 00 46 45 00 46 45 46 00 45 45 49 45 48 45 49 45 49 45 45 45 45 45 45 00 46 48 49 49 45 45 45 49 45 45 46 45 00 45 48 49 00 45 48 45 45 45 45 45 45 45 46 00 46 00 00 46 00 45 00 46 49 49 49 45 00 48 46 00 46 48 45 00 00 46 48 49 46 00 45 45 45 00 46 45 45 45 49 46 00 45 45 45 49 45 45 46 00 45 49 45 00 45 49 46 00 46 45 46 00 45 49 45 45 46 45 00 46 48 49 49 00 45 00 46 45 49 45 49 49 45 46 00 46 00 45 46 00 46 45 45 49 45 45 46 46 45 49 45 45 45 45 46 00 45 45 45 46 00 49 45 46 45 46 45 45 45 45 45 48 00 46 00 46 49 46 00 45 45 48 45 46 45 45 49 45 48
*/
|
sieve.asm | Sprigg-Matthew/sieve | 0 | 89202 | <gh_stars>0
;
; file: sieve
; Author: <NAME>
; Description: Finds all multiples of a given
; prime within a certain range and mark
; them as non-prime.
;
;
%include "asm_io.inc"
%define prime [ebp+8]
%define range [ebp+12]
%define array [ebp+16]
;--------------------------------------------------------
; initialized data is put in the .data segment
;
segment .data
;--------------------------------------------------------
; uninitialized data is put in the .bss segment
;
segment .bss
;--------------------------------------------------------
; code is put in the .text segment
;
segment .text
global sieve
;--------------------------------------------------------
; MAIN FUNCTION ;
;--------------------------------------------------------
sieve:
; void sieve(prime,range, array) {
; register int j = prime ** 2;
; do {
; *(&array+j) = 0;
; j+=prime
; } while(j<range);
;}
;--------------------------------------------------------
; PROLOGUE ;
;--------------------------------------------------------
; Var Table
; ==========================
; Var | Stack | Pseudo
; --------------------------
; Local 1 @ [eax] = j
; Sav EBP @ [ebp]
; RetAddr @ [ebp+4]
; Param 1 @ [ebp+8] = prime
; Param 2 @ [ebp+12] = range
; Param 3 @ [ebp+16] = array
enter 0,0 ; setup routine
pusha
mov edx, array ; point edx to array.
CLD ; DF = 0, String instr inc.
mov eax, prime ; eax = i**2
mul eax
;--------------------------------------------------------
; CODE ;
;--------------------------------------------------------
do_while:
sbreak:
add edx, eax ;
mov dword [edx], 0 ; array[j] = 0
add eax, prime
cmp eax, range
jg do_while ; break if j > range
;--------------------------------------------------------
; EPILOGUE ;
;--------------------------------------------------------
popa
;mov eax, 0 ; return back to C
leave
ret
;--------------------------------------------------------
; FUNCTIONS / SUBPROGRAMS ;
;--------------------------------------------------------
|
asm/startup.asm | yoo2001818/rust-pc-emu | 0 | 16684 | <gh_stars>0
bits 16
org 0xffff
; Do long jump to 7c00:0000
; Replace CS to 0x7c00, IP to 0x0000
jmp 0x7c00:0x0000
|
msp430x2/msp430g2553/startup.ads | ekoeppen/MSP430_Generic_Ada_Drivers | 0 | 29399 | <filename>msp430x2/msp430g2553/startup.ads
package Startup is
pragma Preelaborate;
procedure Reset_Handler with Export => True, External_Name => "_start_rom";
end Startup;
|
libsrc/stdio/pc88/generic_console.asm | jpoikela/z88dk | 0 | 103924 | <gh_stars>0
SECTION code_clib
PUBLIC generic_console_cls
PUBLIC generic_console_vpeek
PUBLIC generic_console_printc
PUBLIC generic_console_scrollup
PUBLIC generic_console_set_ink
PUBLIC generic_console_set_paper
PUBLIC generic_console_set_inverse
PUBLIC generic_console_pointxy
EXTERN CONSOLE_COLUMNS
EXTERN CONSOLE_ROWS
EXTERN asm_toupper
EXTERN l_push_di
EXTERN l_pop_ei
EXTERN __pc88_mode
EXTERN __pc88_ink
EXTERN __pc88_paper
EXTERN printc_MODE2
EXTERN scrollup_MODE2
defc DISPLAY = 0xf3c8
generic_console_set_paper:
and 7
ld (__pc88_paper),a
ret
generic_console_set_ink:
and 7
ld (__pc88_ink),a
generic_console_set_inverse:
ret
generic_console_cls:
ld a,(__pc88_mode)
and a
jr z,clear_text
; Clear the hires planes
call l_push_di
out ($5e),a ;Switch to green
call clear_plane
out ($5d),a ;Switch to red
call clear_plane
out ($5c),a ;Switch to blue
call clear_plane
out ($5f),a ;Back to main memory
call l_pop_ei
clear_text:
in a,($32)
push af
res 4,a
out ($32),a
; Clearing for text
ld hl, DISPLAY
ld c,25
cls_1:
ld b,80
cls_2:
ld (hl),' '
inc hl
djnz cls_2
ld b,20
cls_3:
ld (hl),0
inc hl
ld (hl),0
inc hl
djnz cls_3
dec c
jr nz,cls_1
pop af
out ($32),a
ret
clear_plane:
ld hl,$c000
ld de,$c001
ld bc,15999 ;80x200 - 1
ld (hl),0
ldir
ret
; c = x
; b = y
; a = d = character to print
; e = raw
generic_console_printc:
ld a,(__pc88_mode)
cp 2
jp z,printc_MODE2
push de
call generic_console_scale
call xypos
not_40_col:
pop de
in a,($32)
ld e,a
res 4,a
out ($32),a
ld (hl),d
; TODO: Attribute
ld a,e
out ($32),a
ret
generic_console_pointxy:
call generic_console_vpeek
and a
ret
;Entry: c = x,
; b = y
; e = rawmode
;Exit: nc = success
; a = character,
; c = failure
generic_console_vpeek:
call generic_console_scale
call xypos
in a,($32)
ld c,a
res 4,a
out ($32),a
ld d,(hl)
ld a,c
out ($32),a
ld a,d
and a
ret
generic_console_scale:
push af
ld a,(__pc88_mode)
cp 1
jr nz,no_scale
sla c ;40 -> 80 column
no_scale:
pop af
ret
xypos:
ld hl,DISPLAY - 120
ld de,120
inc b
generic_console_printc_1:
add hl,de
djnz generic_console_printc_1
generic_console_printc_3:
add hl,bc ;hl now points to address in display
ret
generic_console_scrollup:
push de
push bc
ld a,(__pc88_mode)
cp 2
jp z,scrollup_MODE2
in a,($32)
push af
res 4,a
out ($32),a
ld hl, DISPLAY + 120
ld de, DISPLAY
ld bc, 120 * 24
ldir
ex de,hl
ld b,80
generic_console_scrollup_3:
ld (hl),32
inc hl
djnz generic_console_scrollup_3
ld b,40
scroll_2:
ld (hl),0
inc hl
djnz scroll_2
pop af
out ($32),a
pop bc
pop de
ret
SECTION code_crt_init
EXTERN pc88_cursoroff
call pc88_cursoroff
ld hl,$E6B9
res 1,(hl)
ld a,($E6C0)
set 1,a
ld ($E6C0),a
out ($30),a
|
libsrc/_DEVELOPMENT/env/esxdos/z80/asm_tmpnam.asm | jpoikela/z88dk | 640 | 18933 | ; char *tmpnam(char *s)
INCLUDE "config_private.inc"
SECTION code_env
PUBLIC asm_tmpnam
EXTERN __ENV_TMPNAM_TEMPLATE
EXTERN asm_env_tmpnam, asm_strcpy
asm_tmpnam:
; Return an unused filename in the /tmp directory
;
; enter : hl = char *s (0 = use internal static memory)
;
; exit : success
;
; hl = char *s (or internal filename)
; carry set
;
; fail
;
; hl = 0
; carry reset
;
; uses : af, bc, de, hl, bc', de', hl', ix
ld a,h
or l
jp z, asm_env_tmpnam ; if using internal memory
ex de,hl ; de = char *s
ld hl,__ENV_TMPNAM_TEMPLATE
call asm_strcpy ; hl = char *s
jp asm_env_tmpnam
|
src/third_party/nasm/rdoff/test/rdfseg.asm | Mr-Sheep/naiveproxy | 2,219 | 1524 | ;; program to test inter-segment production and linkage of RDF objects
;; [1] should produce segment base ref
;; [2] should produce standard relocation
[GLOBAL _main]
[EXTERN _puts: far]
[BITS 16]
_main:
mov ax, seg _message ; 0000 [1]
mov ds, ax ; 0003
mov dx, _message ; 0005 [2]
call far _puts ; 0008 [2][1]
xor ax,ax ; 000D
int 21h ; 000F
[SECTION .data]
_message: db 'Hello, World', 10, 13, 0
|
unittests/ASM/X87_F64/FLDCW_F64.asm | Seas0/FEX | 0 | 243359 | %ifdef CONFIG
{
"Env": { "FEX_X87REDUCEDPRECISION" : "1" },
"RegData": {
"RAX": "0x3",
"RBX": "0x2"
}
}
%endif
lea rbp, [rel data]
mov rdx, 0xe0000000
mov rcx, 0xe0004000
; save fcw
fnstcw [rdx]
; set rounding to truncate
mov eax, 0
mov ax, [rdx]
or ah, 0xc
mov [rdx+8], ax
fldcw [rdx+8]
fld dword [rbp]
fistp dword [rdx+16]
mov ebx, [rdx+16]
; restore fcw
fldcw [rdx]
fld dword [rbp]
fistp dword[rdx+16]
mov eax, [rdx+16]
hlt
align 8
data:
dd 0x40266666 ; 2.6
|
汇编语言/第6章/1.asm | jckling/only-python | 1 | 176436 | assume cs:code,ds:data,ss:stack
data segment
dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h
data ends
stack segment
dw 0,0,0,0,0,0,0,0
stack ends
code segment
start: mov ax,stack
mov ss,ax
mov sp,16
mov ax,data
mov ds,ax
push ds:[0]
push ds:[2]
pop ds:[2]
pop ds:[0]
mov ax,4c00h
int 21h
code ends
end start |
programs/oeis/131/A131509.asm | jmorken/loda | 1 | 164044 | ; A131509: a(n) = (n + 1)*(n^2 + 2)*(n^3 + 3)/6.
; 1,4,33,220,1005,3456,9709,23528,50985,101260,187561,328164,547573,877800,1359765,2044816,2996369,4291668,6023665,8303020,11260221,15047824,19842813,25849080,33300025,42461276,53633529,67155508,83407045,102812280,125842981
mov $1,$0
add $0,1
pow $0,2
pow $1,3
add $1,1
add $0,$1
add $1,2
mul $1,$0
sub $1,6
div $1,6
add $1,1
|
source/web/spikedog/api/spikedog-http_sessions.adb | svn2github/matreshka | 24 | 10966 | <reponame>svn2github/matreshka
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2018, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the <NAME>, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Streams;
with Ada.Unchecked_Conversion;
with League.Base_Codecs;
with League.Strings.Hash;
with League.Stream_Element_Vectors;
package body Spikedog.HTTP_Sessions is
type Session_Identifier_Buffer is
new Ada.Streams.Stream_Element_Array (1 .. 32);
------------
-- Decode --
------------
procedure Decode
(Image : League.Strings.Universal_String;
Identifier : out Session_Identifier;
Success : out Boolean)
is
use type Ada.Streams.Stream_Element_Offset;
function To_Session_Identifier is
new Ada.Unchecked_Conversion
(Session_Identifier_Buffer, Session_Identifier);
Aux : League.Stream_Element_Vectors.Stream_Element_Vector;
begin
-- Декодирование строки в бинарный массив.
League.Base_Codecs.From_Base_64_URL (Image, Aux, Success);
if not Success then
return;
end if;
-- Проверка длины декодированных данных.
if Aux.Length /= 32 then
Success := False;
return;
end if;
-- Преобразование во внутреннее представление идентификатора.
Identifier :=
To_Session_Identifier
(Session_Identifier_Buffer (Aux.To_Stream_Element_Array));
end Decode;
------------
-- Encode --
------------
function Encode
(Value : Session_Identifier) return League.Strings.Universal_String
is
function To_Session_Identifier_Buffer is
new Ada.Unchecked_Conversion
(Session_Identifier, Session_Identifier_Buffer);
begin
return
League.Base_Codecs.To_Base_64_URL
(League.Stream_Element_Vectors.To_Stream_Element_Vector
(Ada.Streams.Stream_Element_Array
(To_Session_Identifier_Buffer (Value))));
end Encode;
-----------------------
-- Get_Creation_Time --
-----------------------
overriding function Get_Creation_Time
(Self : Spikedog_HTTP_Session) return League.Calendars.Date_Time is
begin
if Self.Valid then
return Self.Creation_Time;
else
raise Program_Error;
end if;
end Get_Creation_Time;
------------
-- Get_Id --
------------
overriding function Get_Id
(Self : Spikedog_HTTP_Session) return League.Strings.Universal_String is
begin
return Encode (Self.Identifier);
end Get_Id;
----------------------------
-- Get_Last_Accessed_Time --
----------------------------
overriding function Get_Last_Accessed_Time
(Self : Spikedog_HTTP_Session) return League.Calendars.Date_Time is
begin
if Self.Valid then
return Self.Last_Accessed_Time;
else
raise Program_Error;
end if;
end Get_Last_Accessed_Time;
----------
-- Hash --
----------
function Hash (Value : Session_Identifier) return Ada.Containers.Hash_Type is
begin
return League.Strings.Hash (Encode (Value));
end Hash;
------------
-- Is_New --
------------
overriding function Is_New (Self : Spikedog_HTTP_Session) return Boolean is
begin
if Self.Valid then
return Self.Is_New;
else
raise Program_Error;
end if;
end Is_New;
end Spikedog.HTTP_Sessions;
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/renaming9.ads | best08618/asylo | 7 | 19079 | <reponame>best08618/asylo<gh_stars>1-10
package Renaming9 is
pragma Elaborate_Body;
type Object is tagged null record;
type Pointer is access all Object'Class;
type Derived is new Object with record
I : Integer;
end record;
Ptr : Pointer := new Derived;
Obj : Derived renames Derived (Ptr.all);
end Renaming9;
|
src/asm/constants.asm | Threetwosevensixseven/nget | 3 | 9671 | <reponame>Threetwosevensixseven/nget<filename>src/asm/constants.asm<gh_stars>1-10
; constants.asm
; Application
CoreMinVersion equ $3007 ; 3.00.07
DotBank1: equ 30
ResetWait equ 5
DisableScroll equ false
//NGetServer equ "192.168.1.3"
NGetServer equ "nget.nxtel.org"
; NextZXOS
IDE_BANK equ $01BD
; UART
UART_RxD equ $143B ; Also used to set the baudrate
UART_TxD equ $133B ; Also reads status
UART_SetBaud equ UART_RxD ; Sets baudrate
UART_GetStatus equ UART_TxD ; Reads status bits
UART_mRX_DATA_READY equ %xxxxx 0 0 1 ; Status bit masks
UART_mTX_BUSY equ %xxxxx 0 1 0 ; Status bit masks
UART_mRX_FIFO_FULL equ %xxxxx 1 0 0 ; Status bit masks
IPDBuffer equ $C000 ; IPD buffer lives in two banks allocated
IPDBufferLen equ $4000 ; by BANK_IDE, from $C000 to $FFFF.
; ESP
ESPTimeout equ 65535*4;65535 ; Use 10000 for 3.5MHz, but 28NHz needs to be 65535
ESPTimeout2 equ 10000 ; Use 10000 for 3.5MHz, but 28NHz needs to be 65535
ESPTimeoutFrames equ 1000 ; Wait 20 seconds
; Ports
Port proc
NextReg equ $243B
pend
; Registers
Reg proc
MachineID equ $00
Peripheral2 equ $06
CPUSpeed equ $07
CoreMSB equ $01
CoreLSB equ $0E
pend
; Chars
SMC equ 0
CR equ 13
LF equ 10
Space equ 32
Copyright equ 127
; ROM Calls
BC_SPACES equ $0030 ; Reserve BC bytes, rets DE addr first byte, HL addr last byte
ROMSM equ $16B0 ; (SET-MIN, like BC_SPACES but clears)
; Screen
SCREEN equ $4000 ; Start of screen bitmap
ATTRS_8x8 equ $5800 ; Start of 8x8 attributes
ATTRS_8x8_END equ $5B00 ; End of 8x8 attributes
ATTRS_8x8_COUNT equ ATTRS_8x8_END-ATTRS_8x8 ; 768
SCREEN_LEN equ ATTRS_8x8_END-SCREEN
PIXELS_COUNT equ ATTRS_8x8-SCREEN
FRAMES equ 23672 ; Frame counter
BORDCR equ 23624 ; Border colour system variable
ULA_PORT equ $FE ; out (254), a
STIMEOUT equ $5C81 ; Screensaver control sysvar
SCR_CT equ $5C8C ; Scroll counter sysvar
; Font
FWSpace equ 2
FWColon equ 4
FWFullStop equ 3
FW0 equ 4
FW1 equ 4
FW2 equ 4
FW3 equ 4
FW4 equ 4
FW5 equ 4
FW6 equ 4
FW7 equ 4
FW8 equ 4
FW9 equ 4
FWA equ 4
FWB equ 4
FWC equ 4
FWD equ 4
FWE equ 4
FWF equ 4
FWG equ 4
FWH equ 4
FWI equ 4
FWJ equ 4
FWK equ 4
FWL equ 4
FWM equ 6
FWN equ 4
FWO equ 4
FWP equ 4
FWQ equ 4
FWR equ 4
FWS equ 4
FWT equ 4
FWU equ 4
FWV equ 4
FWW equ 6
FWX equ 4
FWY equ 4
FWZ equ 4
FWa equ 4
FWb equ 4
FWc equ 4
FWd equ 4
FWe equ 4
FWf equ 4
FWg equ 4
FWh equ 4
FWi equ 4
FWj equ 4
FWk equ 4
FWl equ 4
FWm equ 6
FWn equ 4
FWo equ 4
FWp equ 4
FWq equ 4
FWr equ 4
FWs equ 4
FWt equ 4
FWu equ 4
FWv equ 4
FWw equ 6
FWx equ 4
FWy equ 4
FWz equ 4
VersionPrefix equ "1."
|
FormalAnalyzer/models/apps/AutoHumidityVent.als | Mohannadcse/IoTCOM_BehavioralRuleExtractor | 0 | 1125 | module app_AutoHumidityVent
open IoTBottomUp as base
open cap_runIn
open cap_now
open cap_relativeHumidityMeasurement
open cap_switch
open cap_energyMeter
one sig app_AutoHumidityVent extends IoTApp {
humidity_sensor : one cap_relativeHumidityMeasurement,
fans : set cap_switch,
emeters : some cap_energyMeter,
state : one cap_state,
} {
rules = r
//capabilities = humidity_sensor + fans + emeters + state
}
one sig cap_state extends cap_runIn {} {
attributes = cap_state_attr + cap_runIn_attr
}
abstract sig cap_state_attr extends Attribute {}
one sig cap_state_attr_fansLastRunTime extends cap_state_attr {} {
values = cap_state_attr_fansLastRunTime_val
}
abstract sig cap_state_attr_fansLastRunTime_val extends AttrValue {}
one sig cap_state_attr_fansLastRunTime_val_0 extends cap_state_attr_fansLastRunTime_val {}
one sig cap_state_attr_fansLastRunTime_val_ extends cap_state_attr_fansLastRunTime_val {}
one sig cap_state_attr_fansLastRunCost extends cap_state_attr {} {
values = cap_state_attr_fansLastRunCost_val
}
abstract sig cap_state_attr_fansLastRunCost_val extends AttrValue {}
one sig cap_state_attr_fansLastRunCost_val_ extends cap_state_attr_fansLastRunCost_val {}
one sig cap_state_attr_app_enabled extends cap_state_attr {} {
values = cap_state_attr_app_enabled_val
}
abstract sig cap_state_attr_app_enabled_val extends AttrValue {}
one sig cap_state_attr_app_enabled_val_false extends cap_state_attr_app_enabled_val {}
one sig cap_state_attr_app_enabled_val_true extends cap_state_attr_app_enabled_val {}
one sig cap_state_attr_fan_control_enabled extends cap_state_attr {} {
values = cap_state_attr_fan_control_enabled_val
}
abstract sig cap_state_attr_fan_control_enabled_val extends AttrValue {}
one sig cap_state_attr_fan_control_enabled_val_false extends cap_state_attr_fan_control_enabled_val {}
one sig cap_state_attr_fan_control_enabled_val_true extends cap_state_attr_fan_control_enabled_val {}
one sig cap_state_attr_fansOn extends cap_state_attr {} {
values = cap_state_attr_fansOn_val
}
abstract sig cap_state_attr_fansOn_val extends AttrValue {}
one sig cap_state_attr_fansOn_val_false extends cap_state_attr_fansOn_val {}
one sig cap_state_attr_fansOn_val_true extends cap_state_attr_fansOn_val {}
abstract sig r extends Rule {}
one sig r0 extends r {}{
triggers = r0_trig
conditions = r0_cond
commands = r0_comm
}
abstract sig r0_trig extends Trigger {}
one sig r0_trig0 extends r0_trig {} {
capabilities = app_AutoHumidityVent.humidity_sensor
attribute = cap_relativeHumidityMeasurement_attr_humidity
no value
}
abstract sig r0_cond extends Condition {}
one sig r0_cond0 extends r0_cond {} {
capabilities = app_AutoHumidityVent.state
attribute = cap_state_attr_fansOn
value = cap_state_attr_fansOn_val_false
}
abstract sig r0_comm extends Command {}
/*
one sig r0_comm0 extends r0_comm {} {
capability = app_AutoHumidityVent.state
attribute = cap_state_attr_fansOnTime
value = cap_state_attr_fansOnTime_val_not_null
}
*/
one sig r0_comm1 extends r0_comm {} {
capability = app_AutoHumidityVent.state
attribute = cap_state_attr_fansOn
value = cap_state_attr_fansOn_val_true
}
one sig r1 extends r {}{
triggers = r1_trig
conditions = r1_cond
commands = r1_comm
}
abstract sig r1_trig extends Trigger {}
one sig r1_trig0 extends r1_trig {} {
capabilities = app_AutoHumidityVent.humidity_sensor
attribute = cap_relativeHumidityMeasurement_attr_humidity
no value
}
abstract sig r1_cond extends Condition {}
one sig r1_cond0 extends r1_cond {} {
capabilities = app_AutoHumidityVent.state
attribute = cap_state_attr_fansOn
value = cap_state_attr_fansOn_val_true
}
abstract sig r1_comm extends Command {}
one sig r1_comm0 extends r1_comm {} {
capability = app_AutoHumidityVent.state
attribute = cap_state_attr_fansLastRunTime
value = cap_state_attr_fansLastRunTime_val
}
one sig r1_comm1 extends r1_comm {} {
capability = app_AutoHumidityVent.state
attribute = cap_state_attr_fansOn
value = cap_state_attr_fansOn_val_false
}
/*
one sig r1_comm2 extends r1_comm {} {
capability = app_AutoHumidityVent.state
attribute = cap_state_attr_fansHoldoff
value = cap_state_attr_fansHoldoff_val
}
*/
|
ffight/lcs/boss/61.asm | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | 6 | 170876 | copyright zengfr site:http://github.com/zengfr/romhack
03D450 move.b #$28, ($61,A6)
03D456 move.w #$17, D0 [boss+61]
03D568 jmp $3270.w [boss+61]
03E9CA move.b #$28, ($61,A6)
03E9D0 bsr $3f270 [boss+61]
03F2CE lea ($61e,PC) ; ($3f8ee), A1 [boss+61]
copyright zengfr site:http://github.com/zengfr/romhack
|
Transynther/x86/_processed/AVXALIGN/_zr_/i3-7100_9_0xca_notsx.log_21829_223.asm | ljhsiun2/medusa | 9 | 166717 | <filename>Transynther/x86/_processed/AVXALIGN/_zr_/i3-7100_9_0xca_notsx.log_21829_223.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r15
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x16819, %rsi
nop
nop
nop
nop
sub $22005, %rbx
mov $0x6162636465666768, %r11
movq %r11, (%rsi)
nop
nop
sub %rax, %rax
lea addresses_normal_ht+0x1671d, %r11
nop
nop
nop
nop
nop
add %rcx, %rcx
movb (%r11), %dl
nop
sub %rax, %rax
lea addresses_WC_ht+0x1d7d9, %rax
nop
nop
cmp $63814, %r15
movb $0x61, (%rax)
nop
nop
nop
nop
nop
and %rsi, %rsi
lea addresses_WT_ht+0x196d9, %rax
nop
nop
nop
sub $7781, %rcx
movups (%rax), %xmm4
vpextrq $1, %xmm4, %rsi
nop
nop
nop
nop
nop
add %rcx, %rcx
lea addresses_D_ht+0x72c9, %rsi
lea addresses_A_ht+0x1dd9, %rdi
nop
nop
nop
cmp %rbx, %rbx
mov $25, %rcx
rep movsw
nop
nop
nop
nop
nop
cmp $58634, %rdx
lea addresses_normal_ht+0xa5dc, %rcx
nop
dec %rdx
mov (%rcx), %r15w
nop
nop
nop
nop
nop
cmp %r15, %r15
lea addresses_UC_ht+0xbd7, %rbx
clflush (%rbx)
nop
nop
nop
nop
and $2175, %rax
mov $0x6162636465666768, %rdx
movq %rdx, %xmm4
and $0xffffffffffffffc0, %rbx
movaps %xmm4, (%rbx)
nop
nop
nop
xor %rdx, %rdx
lea addresses_UC_ht+0x163a9, %rax
nop
nop
nop
inc %rcx
movl $0x61626364, (%rax)
nop
sub %rax, %rax
lea addresses_normal_ht+0x1d059, %rax
nop
cmp %rdx, %rdx
movups (%rax), %xmm1
vpextrq $0, %xmm1, %rbx
sub $44186, %r15
lea addresses_D_ht+0x1ac83, %rax
nop
nop
nop
nop
nop
cmp %rdx, %rdx
mov $0x6162636465666768, %rbx
movq %rbx, (%rax)
nop
nop
sub %r11, %r11
lea addresses_WT_ht+0x1d749, %rsi
lea addresses_D_ht+0x18f09, %rdi
nop
nop
dec %rbx
mov $97, %rcx
rep movsw
nop
nop
nop
nop
sub $1330, %rbx
lea addresses_normal_ht+0x3fd9, %rsi
lea addresses_A_ht+0xd219, %rdi
xor %r11, %r11
mov $80, %rcx
rep movsq
nop
nop
nop
cmp %rbx, %rbx
lea addresses_WC_ht+0xa5d9, %rsi
lea addresses_WT_ht+0x18319, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
xor %rax, %rax
mov $47, %rcx
rep movsw
nop
nop
nop
nop
lfence
lea addresses_UC_ht+0x14a1d, %rsi
lea addresses_WT_ht+0x1a7d9, %rdi
nop
add $2926, %r11
mov $79, %rcx
rep movsw
nop
nop
nop
nop
nop
add %rsi, %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r15
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r8
push %r9
push %rbp
push %rdx
push %rsi
// Store
lea addresses_normal+0x136d9, %rdx
and $43897, %r8
mov $0x5152535455565758, %rsi
movq %rsi, %xmm3
vmovups %ymm3, (%rdx)
cmp %rsi, %rsi
// Load
lea addresses_PSE+0x16dd9, %r9
xor $60960, %rbp
mov (%r9), %r10
nop
nop
nop
xor %rbp, %rbp
// Store
lea addresses_WC+0x7051, %rdx
nop
sub %r11, %r11
mov $0x5152535455565758, %r10
movq %r10, (%rdx)
nop
nop
nop
nop
nop
dec %rbp
// Faulty Load
lea addresses_PSE+0x16dd9, %r11
nop
nop
nop
sub $32249, %rbp
movntdqa (%r11), %xmm4
vpextrq $0, %xmm4, %r10
lea oracles, %rbp
and $0xff, %r10
shlq $12, %r10
mov (%rbp,%r10,1), %r10
pop %rsi
pop %rdx
pop %rbp
pop %r9
pop %r8
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': True, 'type': 'addresses_PSE', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_normal', 'size': 32, 'AVXalign': False}}
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_PSE', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WC', 'size': 8, 'AVXalign': True}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': True, 'type': 'addresses_PSE', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': True}}
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': True}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}}
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': True}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': True, 'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}}
{'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
programs/oeis/135/A135561.asm | neoneye/loda | 22 | 92106 | ; A135561: a(n) = 2^A135560(n) - 1.
; 3,7,1,15,1,3,1,31,1,3,1,7,1,3,1,63,1,3,1,7,1,3,1,15,1,3,1,7,1,3,1,127,1,3,1,7,1,3,1,15,1,3,1,7,1,3,1,31,1,3,1,7,1,3,1,15,1,3,1,7,1,3,1,255,1,3,1,7,1,3,1,15,1,3,1,7,1,3,1,31,1,3,1,7,1,3,1,15,1,3,1,7,1,3,1,63,1,3,1,7
add $0,1
mov $1,$0
lpb $1
div $0,$1
bin $0,$1
mov $2,1
lpb $1
dif $1,2
mul $2,2
lpe
mov $1,$2
lpe
add $0,$1
mul $0,2
sub $0,2
div $0,2
mul $0,2
add $0,1
|
pocs/linux/kvm_vma/kernel_code.asm | ashdoeshax/security-research | 1,129 | 97504 | <gh_stars>1000+
BITS 64
; Linux chief-vm 5.8.0-41-generic #46~20.04.1-Ubuntu SMP Mon Jan 18 17:52:23 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
;ffffffff810d1e10 T commit_creds
;ffffffff810d22a0 T prepare_kernel_cred
;ffffffff8119d740 t __seccomp_filter
push rax
mov rax, [rsp + 8] ; Grab return addr
; Offset to __seccomp_filter
sub rax, 0x7E
push rdi
push rax
; Offset `__seccomp_filter` to `prepare_kernel_cred`
sub rax, 832672
xor rdi, rdi
call rax
mov rdi, rax
pop rax
; Offset `__seccomp_filter` to `commit_creds`
sub rax, 833840
call rax
pop rdi
pop rax
mov eax, 0x7FFF0000 ; SECCOMP_RET_ALLOW
ret
|
alloy4fun_models/trashltl/models/18/PtuRC6uK7KWcvo3EH.als | Kaixi26/org.alloytools.alloy | 0 | 4323 | <reponame>Kaixi26/org.alloytools.alloy
open main
pred idPtuRC6uK7KWcvo3EH_prop19 {
all f : Protected | f in Protected until f in Trash
}
pred __repair { idPtuRC6uK7KWcvo3EH_prop19 }
check __repair { idPtuRC6uK7KWcvo3EH_prop19 <=> prop19o } |
tests/relocate/relocation_temporary_labels_consistency.asm | fengjixuchui/sjasmplus | 220 | 247635 | ORG $1000
RELOCATE_START
dw relocate_count
dw relocate_size
; these ahead of RELOCATE_TABLE will refresh the table content to keep it consistent
1:
jp 1B
jp 1B
jp 1F
jp 1F
1:
; emit intetionally table ahead of labels "3B"/"3F" to break table consistency
RELOCATE_TABLE
3: ; warning about different address (between pass2 and pass3)
jp 3B ; warning about inconsistent table (content differs)
jp 3B ; second warning is not issued (one only)
jp 3F ; forward label test (also two more opportunities to warn if not yet)
jp 3F
3: ; warning about different address (between pass2 and pass3)
; emit final version of the table for comparison
RELOCATE_TABLE
RELOCATE_END
|
src/main.adb | kqr/qweyboard | 33 | 7239 | <filename>src/main.adb
with Unicode_Strings; use Unicode_Strings;
with Ada.Command_Line;
with Ada.Task_Termination;
with Ada.Task_Identification;
with Configuration;
with Logging;
with Qweyboard.Emulation;
with Input_Backend;
with Output_Backend;
procedure Main is
use Logging;
Settings : Configuration.Settings;
begin
Ada.Task_Termination.Set_Specific_Handler
(Ada.Task_Identification.Current_Task,
Logging.Logging_Termination_Handler.Log_Termination_Cause'Access);
Ada.Task_Termination.Set_Dependents_Fallback_Handler
(Logging.Logging_Termination_Handler.Log_Termination_Cause'Access);
Configuration.Get_Settings (Settings);
Log.Set_Verbosity (Settings.Log_Level);
Log.Chat ("[Main] Got settings and set log verbosity");
Log.Chat ("[Main] Loading language");
Configuration.Load_Language (Settings);
-- Then kick off the emulation!
--Qweyboard.Emulation.Process.Ready_Wait;
Log.Chat ("[Main] Emulation started");
-- Configure softboard
--Qweyboard.Emulation.Process.Configure (Settings);
Log.Chat ("[Main] Emulation configured");
-- First wait for the output backend to be ready
Output_Backend.Output.Ready_Wait;
Log.Chat ("[Main] Output backend ready");
-- Then wait for input backend to be ready
Input_Backend.Input.Ready_Wait;
Log.Chat ("[Main] Input backend ready");
exception
when Configuration.ARGUMENTS_ERROR =>
Log.Error ("Usage: " & W (Ada.Command_Line.Command_Name) & " [OPTION]");
Log.Error (" ");
Log.Error ("[OPTION] is any combination of the following options: ");
Log.Error (" ");
Log.Error (" -l <language file> : Modifies the standard layout with the ");
Log.Error (" key mappings indicated in the specified ");
Log.Error (" language file. ");
Log.Error (" ");
Log.Error (" -t <milliseconds> : Set the timeout for what counts as one ");
Log.Error (" stroke. If you want 0, NKRO is strongly ");
Log.Error (" recommended. Default value is 500, which ");
Log.Error (" is probably way too high. ");
Log.Error (" ");
Log.Error (" -v,-vv,-vvv : Sets the log level of the software. If you ");
Log.Error (" want to know what goes on inside, this is ");
Log.Error (" where to poke... ");
Ada.Command_Line.Set_Exit_Status (1);
end Main;
|
test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Sublist/Setoid.agda | omega12345/agda-mode | 0 | 13458 | ------------------------------------------------------------------------
-- The Agda standard library
--
-- An inductive definition of the sublist relation with respect to a
-- setoid. This is a generalisation of what is commonly known as Order
-- Preserving Embeddings (OPE).
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary using (Setoid; Rel)
module Data.List.Relation.Binary.Sublist.Setoid
{c ℓ} (S : Setoid c ℓ) where
open import Level using (_⊔_)
open import Data.List.Base using (List; []; _∷_)
import Data.List.Relation.Binary.Equality.Setoid as SetoidEquality
import Data.List.Relation.Binary.Sublist.Heterogeneous as Heterogeneous
import Data.List.Relation.Binary.Sublist.Heterogeneous.Core
as HeterogeneousCore
import Data.List.Relation.Binary.Sublist.Heterogeneous.Properties
as HeterogeneousProperties
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open Setoid S renaming (Carrier to A)
open SetoidEquality S
------------------------------------------------------------------------
-- Definition
infix 4 _⊆_
_⊆_ : Rel (List A) (c ⊔ ℓ)
_⊆_ = Heterogeneous.Sublist _≈_
------------------------------------------------------------------------
-- Re-export definitions and operations from heterogeneous sublists
open HeterogeneousCore _≈_ using ([]; _∷_; _∷ʳ_) public
open Heterogeneous {R = _≈_} hiding (Sublist; []; _∷_; _∷ʳ_) public
renaming
(toAny to to∈; fromAny to from∈)
------------------------------------------------------------------------
-- Relational properties holding for Setoid case
⊆-reflexive : _≋_ ⇒ _⊆_
⊆-reflexive = HeterogeneousProperties.fromPointwise
⊆-refl : Reflexive _⊆_
⊆-refl = HeterogeneousProperties.refl refl
⊆-trans : Transitive _⊆_
⊆-trans = HeterogeneousProperties.trans trans
⊆-antisym : Antisymmetric _≋_ _⊆_
⊆-antisym = HeterogeneousProperties.antisym (λ x≈y _ → x≈y)
⊆-isPreorder : IsPreorder _≋_ _⊆_
⊆-isPreorder = record
{ isEquivalence = ≋-isEquivalence
; reflexive = ⊆-reflexive
; trans = ⊆-trans
}
⊆-isPartialOrder : IsPartialOrder _≋_ _⊆_
⊆-isPartialOrder = record
{ isPreorder = ⊆-isPreorder
; antisym = ⊆-antisym
}
⊆-preorder : Preorder c (c ⊔ ℓ) (c ⊔ ℓ)
⊆-preorder = record
{ isPreorder = ⊆-isPreorder
}
⊆-poset : Poset c (c ⊔ ℓ) (c ⊔ ℓ)
⊆-poset = record
{ isPartialOrder = ⊆-isPartialOrder
}
|
idrougge-applescript/day_01_2.applescript | tomasskare/advent_of_code_2019 | 9 | 267 | set the_file to choose file
set sum to 0
repeat with mass in paragraphs of (read the_file)
set sum to sum + (calculate_fuel for mass)
end repeat
return sum
on calculate_fuel for mass
set fuel to mass div 3 - 2
if fuel is greater than 0 then
return fuel + (calculate_fuel for fuel)
else
return 0
end if
end calculate_fuel |
src/Sessions/Semantics/Expr.agda | laMudri/linear.agda | 34 | 10089 | module Sessions.Semantics.Expr where
open import Prelude
open import Data.Fin
open import Relation.Unary.PredicateTransformer hiding (_⊔_)
open import Relation.Ternary.Separation.Morphisms
open import Relation.Ternary.Separation.Monad
open import Relation.Ternary.Separation.Monad.Reader
open import Sessions.Syntax.Types
open import Sessions.Syntax.Values
open import Sessions.Syntax.Expr
open import Sessions.Semantics.Commands
open import Sessions.Semantics.Runtime
open import Relation.Ternary.Separation.Construct.List Type
open import Relation.Ternary.Separation.Monad.Free Cmd δ
hiding (⟪_⟫)
open import Relation.Ternary.Separation.Monad.Error
open ErrorTrans Free {{monad = free-monad}} public
open ReaderTransformer id-morph Val (ErrorT Free) {{error-monad}}
renaming (Reader to M)
public
open Monads using (Monad; str; _&_)
open Monad reader-monad
mutual
eval⊸ : ∀ {Γ} → ℕ → Exp (a ⊸ b) Γ → ∀[ Val a ⇒ⱼ M Γ [] (Val b) ]
eval⊸ n e v = do
(clos e env) ×⟨ σ₂ ⟩ v ← ►eval n e & v
empty ← append (cons (v ×⟨ ⊎-comm σ₂ ⟩ env))
►eval n e
►eval : ℕ → Exp a Γ → ε[ M Γ [] (Val a) ]
app (►eval zero e) _ _ = partial (pure (inj₁ err))
►eval (suc n) e = eval n e
⟪_⟫ : ∀ {Γ Φ} → (c : Cmd Φ) → M Γ Γ (δ c) Φ
app (⟪_⟫ c) (inj E) σ =
partial (impure (c ×⟨ σ ⟩
wand λ r σ' → pure (inj₂ (r ×⟨ ⊎-comm σ' ⟩ E))))
eval : ℕ → Exp a Γ → ε[ M Γ [] (Val a) ]
eval n unit = do
return tt
eval n (var refl) = do
(v :⟨ σ ⟩: nil) ← ask
case ⊎-id⁻ʳ σ of λ where
refl → return v
eval n (lam a e) = do
env ← ask
return (clos e env)
eval n (ap (f ×⟨ Γ≺ ⟩ e)) = do
v ← frame (⊎-comm Γ≺) (►eval n e)
eval⊸ n f v
eval n (pairs (e₁ ×⟨ Γ≺ ⟩ e₂)) = do
v₁ ← frame Γ≺ (►eval n e₁)
v₂⋆v₂ ← ►eval n e₂ & v₁
return (pairs (✴-swap v₂⋆v₂))
eval n (letunit (e₁ ×⟨ Γ≺ ⟩ e₂)) = do
tt ← frame Γ≺ (►eval n e₁)
►eval n e₂
eval n (letpair (e₁ ×⟨ Γ≺ ⟩ e₂)) = do
pairs (v₁ ×⟨ σ ⟩ v₂) ← frame Γ≺ (►eval n e₁)
empty ← prepend (cons (v₁ ×⟨ σ ⟩ singleton v₂))
►eval n e₂
eval n (send (e₁ ×⟨ Γ≺ ⟩ e₂)) = do
v₁ ← frame Γ≺ (►eval n e₁)
cref φ ×⟨ σ ⟩ v₁ ← ►eval n e₂ & v₁
φ' ← ⟪ send (φ ×⟨ σ ⟩ v₁) ⟫
return (cref φ')
eval n (recv e) = do
cref φ ← ►eval n e
v ×⟨ σ ⟩ φ' ← ⟪ receive φ ⟫
return (pairs (cref φ' ×⟨ ⊎-comm σ ⟩ v))
eval n (mkchan α) = do
φₗ ×⟨ σ ⟩ φᵣ ← ⟪ mkchan α ⟫
return (pairs (cref φₗ ×⟨ σ ⟩ cref φᵣ))
eval n (fork e) = do
clos body env ← ►eval n e
empty ←
⟪ fork (app (runReader (cons (tt ×⟨ ⊎-idˡ ⟩ env))) (►eval n body) ⊎-idʳ) ⟫
return tt
eval n (terminate e) = do
cref φ ← ►eval n e
empty ← ⟪ close φ ⟫
return tt
|
example_relationships/src/one_to_many_associative.adb | cortlandstarrett/mcada | 0 | 6604 | -- *************************************************************************************
--
-- The recipient is warned that this code should be handled in accordance
-- with the HM Government Security Classification indicated throughout.
--
-- This code and its contents shall not be used for other than UK Government
-- purposes.
--
-- The copyright in this code is the property of BAE SYSTEMS Electronic Systems Limited.
-- The Code is supplied by BAE SYSTEMS on the express terms that it is to be treated in
-- confidence and that it may not be copied, used or disclosed to others for any
-- purpose except in accordance with DEFCON 91 (Edn 10/92).
--
-- File Name: One_To_Many_Associative.adb
-- Version: As detailed by ClearCase
-- Version Date: As detailed by ClearCase
-- Creation Date: 11-11-99
-- Security Classification: Unclassified
-- Project: SRLE (Sting Ray Life Extension)
-- Author: <NAME>
-- Section: Tactical Software/ Software Architecture
-- Division: Underwater Systems Division
-- Description: Generic implementation of 1-1:M relationship
-- Comments:
--
-- MODIFICATION RECORD
-- --------------------
-- NAME DATE ECR No MODIFICATION
--
-- jmm 11/11/99 008310/9SR056 Order of instance specification in Unlink is wrong. Reverse it.
--
-- jmm 25/04/00 PILOT_0000_0325 Increase length of role to 32 characters for compatibility with
-- type base_text_type.
--
-- jmm 28/06/00 PILOT_0000_0423 Include diagnostic references.
--
-- jmm 26/01/01 PILOT_0000_0701 Comment out a line which was erroneously left uncommented.
--
-- db 09/08/01 PILOT_0000_1422 Illegal navigation should return null instance.
--
-- DB 24/09/01 PILOT_0000_2473 Rename Link, Unlink & Unassociate parameters
-- to match those for 1:1 type relationships,
-- at the request of George.
--
-- db 17/04/02 SRLE100003005 Correlated associative navigations supported.
--
-- db 22/04/02 SRLE100002907 Procedure initialise removed as surplus to requirements
--
-- db 09/05/02 SRLE100002899 Role phrase string is limited to 32 characters
-- by calling routine, no checks necessary here.
--
-- db 10/10/02 SRLE100003929 Remove exit condition from within Check_List_For_Multiple
-- and Check_List_For_Associative and rearrange loop
-- conditions accordingly.
--
-- db 11/10/02 SRLE100003928 Remove null checks on source navigates and
-- calls to log.
--
-- DNS 20/05/15 CR 10265 For Navigate procedures returning a list,
-- the Return is now an "in" parameter
--
-- **************************************************************************************
with Application_Types;
with Root_Object;
use type Root_Object.Object_Access;
use type Root_Object.Object_List.Node_Access_Type;
with Ada.Tags;
use type Ada.Tags.Tag;
with Ada.Unchecked_Deallocation;
package body One_To_Many_Associative is
------------------------------------------------------------------------
--
-- 'Minor' element
--
type Relationship_Pair_Type;
type Relationship_Pair_Access_Type is access all Relationship_Pair_Type;
type Relationship_Pair_Type is record
Multiple : Root_Object.Object_Access;
Associative : Root_Object.Object_Access;
Next : Relationship_Pair_Access_Type;
Previous : Relationship_Pair_Access_Type;
end record;
procedure Remove_Pair is new Ada.Unchecked_Deallocation (
Relationship_Pair_Type, Relationship_Pair_Access_Type);
--
-- 'Major' element
--
type Relationship_Entry_Type;
type Relationship_Entry_Access_Type is access all Relationship_Entry_Type;
type Relationship_Entry_Type is record
Single : Root_Object.Object_Access;
Completion_List : Relationship_Pair_Access_Type;
Next : Relationship_Entry_Access_Type;
Previous : Relationship_Entry_Access_Type;
end record;
procedure Remove_Entry is new Ada.Unchecked_Deallocation (
Relationship_Entry_Type, Relationship_Entry_Access_Type);
------------------------------------------------------------------------
The_Relationship_List: Relationship_Entry_Access_Type;
subtype Role_Phrase_Type is string (1 .. Application_Types.Maximum_Number_Of_Characters_In_String);
Multiple_Side : Ada.Tags.Tag;
Multiple_Side_Role : Role_Phrase_Type;
Multiple_Side_Role_Length : Natural;
Single_Side : Ada.Tags.Tag;
Single_Side_Role : Role_Phrase_Type;
Single_Side_Role_Length : Natural;
Associative_Side : Ada.Tags.Tag;
Associative_Side_Role : Role_Phrase_Type;
Associative_Side_Role_Length : Natural;
--
-- A = LEFT = MULTIPLE
-- B = RIGHT = SINGLE
--
------------------------------------------------------------------------
procedure Check_List_For_Multiple (
Multiple_Instance : in Root_Object.Object_Access;
Associative_Instance : out Root_Object.Object_Access;
Single_Instance : out Root_Object.Object_Access;
Multiple_Instance_Found : out Boolean) is
Temp_Minor_Pointer : Relationship_Pair_Access_Type;
Temp_Major_Pointer : Relationship_Entry_Access_Type;
begin
Multiple_Instance_Found := False;
Temp_Major_Pointer := The_Relationship_List;
Major_Loop:
while (not Multiple_Instance_Found) and then Temp_Major_Pointer /= null loop
Temp_Minor_Pointer := Temp_Major_Pointer.Completion_List;
Minor_Loop:
while (not Multiple_Instance_Found) and then Temp_Minor_Pointer /= null loop
Multiple_Instance_Found := (Temp_Minor_Pointer.Multiple = Multiple_Instance);
if Multiple_Instance_Found then
Associative_Instance := Temp_Minor_Pointer.Associative;
Single_Instance := Temp_Major_Pointer.Single;
else
-- Prevent access if we have got what we are after
-- Bailing out of the search loop is a neater solution, but test team defects
-- have been raised against this sort of thing.
Temp_Minor_Pointer := Temp_Minor_Pointer.Next;
end if;
end loop Minor_Loop;
-- Prevent the possibility that the next entry in the major queue is null causing an access error
if not Multiple_Instance_Found then
Temp_Major_Pointer := Temp_Major_Pointer.Next;
end if;
end loop Major_Loop;
end Check_List_For_Multiple;
------------------------------------------------------------------------
procedure Check_List_For_Associative (
Associative_Instance : in Root_Object.Object_Access;
Multiple_Instance : out Root_Object.Object_Access;
Single_Instance : out Root_Object.Object_Access;
Associative_Instance_Found : out Boolean) is
Temp_Minor_Pointer : Relationship_Pair_Access_Type;
Temp_Major_Pointer : Relationship_Entry_Access_Type;
begin
Associative_Instance_Found := False;
Temp_Major_Pointer := The_Relationship_List;
Major_Loop:
while (not Associative_Instance_Found) and then Temp_Major_Pointer /= null loop
Temp_Minor_Pointer := Temp_Major_Pointer.Completion_List;
Minor_Loop:
while (not Associative_Instance_Found) and then Temp_Minor_Pointer /= null loop
Associative_Instance_Found := (Temp_Minor_Pointer.Associative = Associative_Instance);
if Associative_Instance_Found then
Multiple_Instance := Temp_Minor_Pointer.Multiple;
Single_Instance := Temp_Major_Pointer.Single;
else
-- Prevent access if we have got what we are after
-- Bailing out of the search loop is a neater solution, but test team defects
-- have been raised against this sort of thing.
Temp_Minor_Pointer := Temp_Minor_Pointer.Next;
end if;
end loop Minor_Loop;
-- Prevent the possibility that the next entry in the major queue is null causing an access error
if not Associative_Instance_Found then
Temp_Major_Pointer := Temp_Major_Pointer.Next;
end if;
end loop Major_Loop;
end Check_List_For_Associative;
-----------------------------------------------------------------------
procedure Do_Link (
Multiple_Instance : in Root_Object.Object_Access;
Single_Instance : in Root_Object.Object_Access;
Associative_Instance : in Root_Object.Object_Access) is
Temp_Minor_Pointer : Relationship_Pair_Access_Type;
Temp_Major_Pointer : Relationship_Entry_Access_Type;
Found : Boolean := False;
begin
Temp_Major_Pointer := The_Relationship_List;
while (not Found) and then Temp_Major_Pointer /= null loop
Found := (Temp_Major_Pointer.Single = Single_Instance);
if not Found then -- grab the next item
Temp_Major_Pointer := Temp_Major_Pointer.Next;
end if;
end loop;
if not Found then
Temp_Major_Pointer := new Relationship_Entry_Type;
Temp_Major_Pointer.Single := Single_Instance;
Temp_Major_Pointer.Completion_List := null;
Temp_Major_Pointer.Previous := null;
Temp_Major_Pointer.Next := The_Relationship_List;
if The_Relationship_List /= null then
The_Relationship_List.Previous := Temp_Major_Pointer;
end if;
The_Relationship_List := Temp_Major_Pointer;
end if;
Temp_Minor_Pointer := new Relationship_Pair_Type;
Temp_Minor_Pointer.Multiple := Multiple_Instance;
Temp_Minor_Pointer.Associative := Associative_Instance;
Temp_Minor_Pointer.Previous := null;
Temp_Minor_Pointer.Next := Temp_Major_Pointer.Completion_List;
if Temp_Major_Pointer.Completion_List /= null then
Temp_Major_Pointer.Completion_List.Previous := Temp_Minor_Pointer;
end if;
Temp_Major_Pointer.Completion_List := Temp_Minor_Pointer;
end Do_Link;
-----------------------------------------------------------------------
procedure Do_Unlink (
Left_Instance : in Root_Object.Object_Access;
Right_Instance : in Root_Object.Object_Access) is
Temp_Minor_Pointer : Relationship_Pair_Access_Type;
Temp_Major_Pointer : Relationship_Entry_Access_Type;
Delete_List : Boolean := False;
begin
Temp_Major_Pointer := The_Relationship_List;
Major_Loop:
while Temp_Major_Pointer /= null loop
if Temp_Major_Pointer.Single = Left_Instance then
Temp_Minor_Pointer := Temp_Major_Pointer.Completion_List;
Minor_Loop:
while Temp_Minor_Pointer /= null loop
if Temp_Minor_Pointer.Multiple = Right_Instance then
if Temp_Minor_Pointer.Previous = null then
--
-- first instance in list
--
Temp_Major_Pointer.Completion_List := Temp_Minor_Pointer.Next;
--
-- it's also the last and only instance in list
-- So we're going to delete the whole relationship instance
-- (but not just yet)
--
Delete_List := (Temp_Minor_Pointer.Next = null);
end if;
if Temp_Minor_Pointer.Next /= null then
--
-- there are more instances following in the list
--
Temp_Minor_Pointer.Next.Previous := Temp_Minor_Pointer.Previous;
end if;
if Temp_Minor_Pointer.Previous /= null then
--
-- there are more instances previous in the list
--
Temp_Minor_Pointer.Previous.Next := Temp_Minor_Pointer.Next;
end if;
Remove_Pair (Temp_Minor_Pointer);
exit Major_Loop;
end if;
Temp_Minor_Pointer := Temp_Minor_Pointer.Next;
end loop Minor_Loop;
end if;
Temp_Major_Pointer := Temp_Major_Pointer.Next;
end loop Major_Loop;
--
-- if needed, now delete the list
-- the same logic applies
--
if Delete_List then
if Temp_Major_Pointer.Previous = null then
--
-- first instance in list
--
The_Relationship_List := Temp_Major_Pointer.Next;
end if;
if Temp_Major_Pointer.Next /= null then
--
-- there are more instances following in the list
--
Temp_Major_Pointer.Next.Previous := Temp_Major_Pointer.Previous;
end if;
if Temp_Major_Pointer.Previous /= null then
--
-- there are more instances previous in the list
--
Temp_Major_Pointer.Previous.Next := Temp_Major_Pointer.Next;
end if;
Remove_Entry (Temp_Major_Pointer);
end if;
end Do_Unlink;
-------------------------------------------------------------------------
procedure Register_Multiple_End_Class (Multiple_Instance : in Ada.Tags.Tag) is
begin
Multiple_Side := Multiple_Instance;
end Register_Multiple_End_Class;
---------------------------------------------------------------------
procedure Register_Multiple_End_Role (Multiple_Role : in String) is
begin
Multiple_Side_Role (1 .. Multiple_Role'Length) := Multiple_Role;
Multiple_Side_Role_Length := Multiple_Role'Length;
end Register_Multiple_End_Role;
---------------------------------------------------------------------
procedure Register_Single_End_Class (Single_Instance : in Ada.Tags.Tag) is
begin
Single_Side := Single_Instance;
end Register_Single_End_Class;
---------------------------------------------------------------------
procedure Register_Single_End_Role (Single_Role : in String) is
begin
Single_Side_Role (1..Single_Role'Length) := Single_Role;
Single_Side_Role_Length := Single_Role'Length;
end Register_Single_End_Role;
---------------------------------------------------------------------
procedure Register_Associative_End_Class (Associative_Instance : in Ada.Tags.Tag) is
begin
Associative_Side := Associative_Instance;
end Register_Associative_End_Class;
---------------------------------------------------------------------
procedure Register_Associative_End_Role (Associative_Role : in String) is
begin
Associative_Side_Role (1 .. Associative_Role'Length) := Associative_Role;
Associative_Side_Role_Length := Associative_Role'Length;
end Register_Associative_End_Role;
---------------------------------------------------------------------
procedure Link (
A_Instance : in Root_Object.Object_Access;
B_Instance : in Root_Object.Object_Access;
Using : in Root_Object.Object_Access) is
begin
if Using.all'Tag = Associative_Side then
if A_Instance.all'Tag = Multiple_Side then
Do_Link (
Multiple_Instance => A_Instance,
Single_Instance => B_Instance,
Associative_Instance => Using);
--
-- PILOT_0000_0423 Include diagnostic references.
--
Application_Types.Count_Of_Relationships := Application_Types.Count_Of_Relationships + 1;
elsif A_Instance.all'Tag = Single_Side then
Do_Link (
Multiple_Instance => B_Instance,
Single_Instance => A_Instance,
Associative_Instance => Using);
--
-- PILOT_0000_0423 Include diagnostic references.
--
Application_Types.Count_Of_Relationships := Application_Types.Count_Of_Relationships + 1;
end if;
end if; -- Using.all'tag /= Associative_Side
end Link;
-----------------------------------------------------------------------
procedure Unassociate (
A_Instance : in Root_Object.Object_Access;
B_Instance : in Root_Object.Object_Access;
From : in Root_Object.Object_Access) is
begin
null;
end Unassociate;
-----------------------------------------------------------------------
procedure Unlink (
A_Instance : in Root_Object.Object_Access;
B_Instance : in Root_Object.Object_Access) is
begin
if A_Instance.all'Tag = Multiple_Side then
Do_Unlink (
Left_Instance => B_Instance,
Right_Instance => A_Instance);
--
-- PILOT_0000_0423 Include diagnostic references.
--
Application_Types.Count_Of_Relationships := Application_Types.Count_Of_Relationships - 1;
elsif A_Instance.all'Tag = Single_Side then
--
Do_Unlink (
Left_Instance => A_Instance,
Right_Instance => B_Instance);
--
-- PILOT_0000_0423 Include diagnostic references.
--
Application_Types.Count_Of_Relationships := Application_Types.Count_Of_Relationships - 1;
end if;
end Unlink;
-----------------------------------------------------------------------
procedure Navigate (
From : in Root_Object.Object_List.List_Header_Access_Type;
Class : in Ada.Tags.Tag;
To : in Root_Object.Object_List.List_Header_Access_Type) is
Source_Instance: Root_Object.Object_Access;
Temp_Node: Root_Object.Object_List.Node_Access_Type;
Temp_Instance: Root_Object.Object_Access;
--Temp_Single: Root_Object.Object_Access;
--Temp_Associative: Root_Object.Object_Access;
--Temp_Multiple: Root_Object.Object_Access;
begin
Temp_Node := Root_Object.Object_List.First_Entry_Of (From);
while Temp_Node /= null loop
Source_Instance := Temp_Node.Item;
if Source_Instance.all'Tag = Multiple_Side then
Navigate (
From => Source_Instance,
Class => Class,
To => Temp_Instance);
if Temp_Instance /= null then
Root_Object.Object_List.Insert (
New_Item => Temp_Instance,
On_To => To );
end if;
--
elsif Source_Instance.all'Tag = Single_Side then
Navigate (
From => Source_Instance,
Class => Class,
To => To);
--
elsif Source_Instance.all'Tag = Associative_Side then
Navigate (
From => Source_Instance,
Class => Class,
To => Temp_Instance);
if Temp_Instance /= null then
Root_Object.Object_List.Insert (
New_Item => Temp_Instance,
On_To => To );
end if;
--
end if;
Temp_Node := Root_Object.Object_List.Next_Entry_Of (From);
end loop;
end Navigate;
-----------------------------------------------------------------------
procedure Navigate (
From : in Root_Object.Object_Access;
Class : in Ada.Tags.Tag;
To : out Root_Object.Object_Access) is
--
-- navigate from a single to a single
-- valid for:
-- A -> M
-- A -> S
-- M -> S
-- M -> A
--
Temp_Single: Root_Object.Object_Access;
Temp_Associative: Root_Object.Object_Access;
Temp_Multiple: Root_Object.Object_Access;
Found: Boolean;
begin
-- PILOT_0000_1422
-- Defaulting the return parameter ensures that if an attempt
-- is made to navigate this type of one to many associative
-- without having linked it, the correct null parameter is
-- returned. This relationship mechanism relies on the link
-- operation to sort out all the tags. We can't rely on that
-- happening in all cases.
To := null;
if From.all'Tag = Multiple_Side then
--
Check_List_For_Multiple (
Multiple_Instance => From,
Associative_Instance => Temp_Associative,
Single_Instance => Temp_Single,
Multiple_Instance_Found => Found);
if Found then
--
if Class = Single_Side then
To := Temp_Single;
elsif Class = Associative_Side then
To := Temp_Associative;
end if;
--
end if;
--
elsif From.all'Tag = Associative_Side then
Check_List_For_Associative (
Associative_Instance => From,
Multiple_Instance => Temp_Multiple,
Single_Instance => Temp_Single,
Associative_Instance_Found => Found);
if Found then
--
if Class = Single_Side then
To := Temp_Single;
elsif Class = Multiple_Side then
To := Temp_Multiple;
end if;
end if;
end if;
end Navigate;
---------------------------------------------------------------------
procedure Navigate (
From : in Root_Object.Object_Access;
Class : in Ada.Tags.Tag;
To : in Root_Object.Object_List.List_Header_Access_Type) is
--
-- navigate from a single to a set
-- valid for:
-- S -> M
-- S -> A
--
Temp_Minor_Pointer: Relationship_Pair_Access_Type;
Temp_Major_Pointer: Relationship_Entry_Access_Type;
begin
if From.all'Tag = Single_Side then
Temp_Major_Pointer := The_Relationship_List;
Major_Loop:
while Temp_Major_Pointer /= null loop
if Temp_Major_Pointer.Single = From then
Temp_Minor_Pointer := Temp_Major_Pointer.Completion_List;
Minor_Loop:
while Temp_Minor_Pointer /= null loop
if Class = Multiple_Side then
Root_Object.Object_List.Insert (
New_Item => Temp_Minor_Pointer.Multiple,
On_To => To);
elsif Class = Associative_Side then
Root_Object.Object_List.Insert (
New_Item => Temp_Minor_Pointer.Associative,
On_To => To);
end if;
Temp_Minor_Pointer := Temp_Minor_Pointer.Next;
end loop Minor_Loop;
exit Major_Loop;
end if;
Temp_Major_Pointer := Temp_Major_Pointer.Next;
end loop Major_Loop;
--
end if;
end Navigate;
------------------------------------------------------------------------
-- associative correlated navigation
procedure Navigate (
From : in Root_Object.Object_Access;
Also : in Root_Object.Object_Access;
Class : in Ada.Tags.Tag;
To : out Root_Object.Object_Access) is
-- navigate from two singles to a single
-- valid for:
-- M and S -> A
-- S and M -> A
Temp_Single,
Single_Side_Source ,
Multiple_Side_Source,
Temp_Associative_Multiple,
Temp_Associative_Single : Root_Object.Object_Access := null;
Assoc_Set : Root_Object.Object_List.List_Header_Access_Type := Root_Object.Object_List.Initialise;
Found,
Tags_Correct : Boolean := FALSE;
begin
-- Reset the output pointer to null so that if we don't find anything
-- useful, the caller can check for it.
To := null;
Tags_Correct := ((( From.all'Tag = Multiple_Side) and then
( Also.all'Tag = Single_Side))
or else ((( From.all'Tag = Single_Side) and then
( Also.all'Tag = Multiple_Side)))) ;
if Tags_Correct then
if From.all'Tag = Multiple_Side then
Multiple_Side_Source := From;
Single_Side_Source := Also;
else
Multiple_Side_Source := Also;
Single_Side_Source := From;
end if;
-- Do the navigations now, all is correct.
-- Navigate from multiple side to associative side.
Check_List_For_Multiple (
Multiple_Instance => Multiple_Side_Source,
Associative_Instance => Temp_Associative_Multiple,
Single_Instance => Temp_Single,
Multiple_Instance_Found => Found);
-- Navigate from single side to associative side.
if Found then
-- do the navigation
declare
Input_List : Root_Object.Object_List.List_Header_Access_Type;
begin
Input_List := Root_Object.Object_List.Initialise;
Root_Object.Object_List.Clear(Assoc_Set);
Root_Object.Object_List.Insert (
New_Item => Single_Side_Source,
On_To => Input_List);
Navigate(
From => Input_List,
Class => Class,
To => Assoc_Set);
Root_Object.Object_List.Destroy_List(Input_List);
end;
-- Extract out the instance from the set by looping through the
-- set and looking for a match with the instance found from the
-- multiple side navigation.
declare
use type Root_Object.Object_List.Node_Access_Type;
Temp_Entry : Root_Object.Object_List.Node_Access_Type;
begin
-- Grab the first entry of the set
Temp_Entry := Root_Object.Object_List.First_Entry_Of(Assoc_Set);
-- While the set is not empty, and the entry does not match the
-- assoc instance already found, loop
while (Temp_Entry /= null) and then
(Temp_Associative_Single /= Temp_Associative_Multiple) loop
Temp_Associative_Single := Temp_Entry.Item;
Temp_Entry := Root_Object.Object_List.Next_Entry_Of(Assoc_Set);
end loop;
end;
if Temp_Associative_Single = Temp_Associative_Multiple then
To := Temp_Associative_Single;
end if;
end if;
end if;
end Navigate;
-----------------------------------------------------------------------
end One_To_Many_Associative;
|
awa/awaunit/awa-tests-helpers-users.ads | fuzzysloth/ada-awa | 0 | 16394 | <reponame>fuzzysloth/ada-awa
-----------------------------------------------------------------------
-- users-tests-helpers -- Helpers for user creation
-- Copyright (C) 2011, 2012, 2013, 2014, 2017 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Finalization;
with Security.Contexts;
with ASF.Requests.Mockup;
with AWA.Users.Models;
with AWA.Users.Services;
with AWA.Services.Contexts;
with AWA.Users.Principals;
package AWA.Tests.Helpers.Users is
type Test_User is new Ada.Finalization.Limited_Controlled with record
Context : AWA.Services.Contexts.Service_Context;
Manager : AWA.Users.Services.User_Service_Access := null;
User : AWA.Users.Models.User_Ref;
Email : AWA.Users.Models.Email_Ref;
Session : AWA.Users.Models.Session_Ref;
Principal : AWA.Users.Principals.Principal_Access;
end record;
-- Initialize the service context.
procedure Initialize (Principal : in out Test_User);
-- Create a test user associated with the given email address.
-- Get an open session for that user. If the user already exists, no error is reported.
procedure Create_User (Principal : in out Test_User;
Email : in String);
-- Create a test user for a new test and get an open session.
procedure Create_User (Principal : in out Test_User);
-- Find the access key associated with a user (if any).
procedure Find_Access_Key (Principal : in out Test_User;
Email : in String;
Key : in out AWA.Users.Models.Access_Key_Ref);
-- Login a user and create a session
procedure Login (Principal : in out Test_User);
-- Logout the user and closes the current session.
procedure Logout (Principal : in out Test_User);
-- Simulate a user login in the given service context.
procedure Login (Context : in out AWA.Services.Contexts.Service_Context'Class;
Sec_Context : in out Security.Contexts.Security_Context;
Email : in String);
-- Simulate a user login on the request. Upon successful login, a session that is
-- authentified is associated with the request object.
procedure Login (Email : in String;
Request : in out ASF.Requests.Mockup.Request);
-- Setup the context and security context to simulate an anonymous user.
procedure Anonymous (Context : in out AWA.Services.Contexts.Service_Context'Class;
Sec_Context : in out Security.Contexts.Security_Context);
-- Simulate the recovery password process for the given user.
procedure Recover_Password (Email : in String);
overriding
procedure Finalize (Principal : in out Test_User);
-- Cleanup and release the Principal that have been allocated from the Login session
-- but not released because the Logout is not called from the unit test.
procedure Tear_Down;
end AWA.Tests.Helpers.Users;
|
libsrc/stdio/ansi/nascom/f_ansi_attr.asm | meesokim/z88dk | 0 | 17768 | ;
; ANSI Video handling for the NASCOM1/2
; By <NAME>
;
; Text Attributes
; m - Set Graphic Rendition
;
; $Id: f_ansi_attr.asm,v 1.3 2015/01/19 01:33:18 pauloscustodio Exp $
;
PUBLIC ansi_attr
.ansi_attr
ret |
assembly/fibof0.asm | mohsend/Magnificent-University-projects | 0 | 166082 | <reponame>mohsend/Magnificent-University-projects
; writes fibonacci series to data segment. starting from 0
;------------
; stack segment :
STSEG SEGMENT
DB 64 DUP (?)
STSEG ENDS
;------------
; data segment :
DTSEG SEGMENT
; place program data here
DW 20 DUP (0000H)
DTSEG ENDS
;------------
; code segment :
CDSEG SEGMENT
MAIN PROC FAR
ASSUME CS:CDSEG, DS:DTSEG, SS:STSEG
MOV AX, DTSEG
MOV DS, AX
; main code starts here
; initialize
MOV CX, 10
MOV DI, 00
MOV AX, 00
MOV DX, 01
loop1:
MOV [DI], AX
INC DI
INC DI
MOV [DI], DX
INC DI
INC DI
ADD AX, DX
ADD DX, AX
LOOP loop1
; end (terminate) program
terminate:
MOV AH, 4CH
INT 21H
MAIN ENDP
CDSEG ENDS
END MAIN
|
oeis/037/A037555.asm | neoneye/loda-programs | 11 | 166219 | <gh_stars>10-100
; A037555: Base 6 digits are, in order, the first n terms of the periodic sequence with initial period 2,1,1.
; Submitted by <NAME>(s4)
; 2,13,79,476,2857,17143,102860,617161,3702967,22217804,133306825,799840951,4799045708,28794274249,172765645495,1036593872972,6219563237833,37317379426999,223904276561996,1343425659371977
add $0,1
mov $2,2
lpb $0
mov $3,$2
lpb $3
mod $0,30
add $2,1
mod $3,5
div $3,2
add $2,$3
add $4,1
lpe
sub $0,1
mul $4,6
lpe
mov $0,$4
sub $0,12
div $0,6
add $0,2
|
tools/scitools/conf/understand/ada/ada12/s-imgenu.ads | brucegua/moocos | 1 | 28457 | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . I M G _ E N U M --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Enumeration_Type'Image for all enumeration types except those in package
-- Standard (where we have no opportunity to build image tables), and in
-- package System (where it is too early to start building image tables).
-- Special routines exist for the enumeration types in these packages.
-- Note: this is an obsolete package, replaced by System.Img_Enum_New, which
-- provides procedures instead of functions for these enumeration image calls.
-- The reason we maintain this package is that when bootstrapping with old
-- compilers, the old compiler will search for this unit, expecting to find
-- these functions. The new compiler will search for procedures in the new
-- version of the unit.
pragma Compiler_Unit;
package System.Img_Enum is
pragma Pure;
function Image_Enumeration_8
(Pos : Natural;
Names : String;
Indexes : System.Address) return String;
-- Used to compute Enum'Image (Str) where Enum is some enumeration type
-- other than those defined in package Standard. Names is a string with a
-- lower bound of 1 containing the characters of all the enumeration
-- literals concatenated together in sequence. Indexes is the address of an
-- array of type array (0 .. N) of Natural_8, where N is the number of
-- enumeration literals in the type. The Indexes values are the starting
-- subscript of each enumeration literal, indexed by Pos values, with an
-- extra entry at the end containing Names'Length + 1. The reason that
-- Indexes is passed by address is that the actual type is created on the
-- fly by the expander. The value returned is the desired 'Image value.
function Image_Enumeration_16
(Pos : Natural;
Names : String;
Indexes : System.Address) return String;
-- Identical to Image_Enumeration_8 except that it handles types
-- using array (0 .. Num) of Natural_16 for the Indexes table.
function Image_Enumeration_32
(Pos : Natural;
Names : String;
Indexes : System.Address) return String;
-- Identical to Image_Enumeration_8 except that it handles types
-- using array (0 .. Num) of Natural_32 for the Indexes table.
end System.Img_Enum;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.