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 |
|---|---|---|---|---|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/cc/cc3016f.ada | best08618/asylo | 7 | 28550 | <reponame>best08618/asylo
-- CC3016F.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OFFICE, 3E 114, THE PENTAGON, WASHINGTON DC 20301-3081.
-- OBJECTIVE:
-- CHECK THAT AN INSTANTIATED PACKAGE HAS THE PROPERTIES REQUIRED
-- OF A PACKAGE.
-- CHECK THAT IF THE PARENT TYPE IN A DERIVED TYPE DEFINITION IS
-- A GENERIC FORMAL TYPE, THE OPERATIONS DECLARED FOR THE DERIVED
-- TYPE IN THE TEMPLATE ARE DETERMINED BY THE DECLARATION OF THE
-- FORMAL TYPE. THE OPERATIONS DECLARED FOR DERIVED TYPE IN THE
-- INSTANCE ARE DETERMINED BY THE ACTUAL TYPE DENOTED BY THE FORMAL
-- PARAMETER. SEE AI-00398.
-- HISTORY:
-- DAS 8 OCT 90 INITIAL VERSION.
-- JRL 02/19/93 ADDED USE CLAUSES FOR INSTANCES TO ENSURE DIRECT
-- OPERATOR VISIBILITY. CHANGED NT4'LAST TO P4.NT4'LAST
-- IN ASSIGNMENT STATEMENT FOR P4.X IN EXAMPLE_4.
-- CORRECTED ABE ERRORS IN EXAMPLE_2 AND EXAMPLE_3.
-- CHANGED R3."+" FROM MULTIPLICATION TO SUBTRACTION TO
-- AVOID CONSTRAINT_ERROR.
WITH REPORT;
PROCEDURE CC3016F IS
BEGIN
REPORT.TEST ("CC3016F", "CHECK THAT IF THE PARENT TYPE IN A " &
"DERIVED TYPE DEFINITION IS A GENERIC " &
"FORMAL TYPE, THE OPERATIONS DECLARED " &
"FOR THE DERIVED TYPE IN THE TEMPLATE " &
"ARE DETERMINED BY THE DECLARATION OF " &
"THE FORMAL TYPE, AND THAT THE " &
"OPERATIONS DECLARED FOR THE DERIVED " &
"TYPE IN THE INSTANCE ARE DETERMINED BY " &
"THE ACTUAL TYPE DENOTED BY THE FORMAL " &
"PARAMETER (AI-00398)");
EXAMPLE_2:
DECLARE
GENERIC
TYPE PRIV IS PRIVATE;
PACKAGE GP2 IS
TYPE NT2 IS NEW PRIV;
END GP2;
PACKAGE R2 IS
TYPE T2 IS RANGE 1..10;
FUNCTION F RETURN T2;
END R2;
PACKAGE P2 IS NEW GP2 (PRIV => R2.T2);
USE P2;
XX1 : P2.NT2;
XX2 : P2.NT2;
XX3 : P2.NT2;
PACKAGE BODY R2 IS
FUNCTION F RETURN T2 IS
BEGIN
RETURN T2'LAST;
END F;
END R2;
BEGIN
XX1 := 5; -- IMPLICIT CONVERSION FROM
-- UNIVERSAL INTEGER TO P2.NT2
-- IN P2.
XX2 := XX1 + XX1; -- PREDEFINED "+" DECLARED FOR
-- P2.NT2.
XX3 := P2.F; -- FUNCTION F DERIVED WITH THE
-- INSTANCE.
END EXAMPLE_2;
EXAMPLE_3:
DECLARE
GENERIC
TYPE T3 IS RANGE <>;
PACKAGE GP3 IS
TYPE NT3 IS NEW T3;
X : NT3 := 5;
Y : NT3 := X + 3; -- USES PREDEFINED "+" EVEN IN
-- INSTANCES
END GP3;
PACKAGE R3 IS
TYPE S IS RANGE 1..10;
FUNCTION "+" (LEFT : IN S; RIGHT : IN S) RETURN S;
END R3;
PACKAGE P3 IS NEW GP3 ( T3 => R3.S );
USE P3;
Z : P3.NT3;
PACKAGE BODY R3 IS
FUNCTION "+" (LEFT : IN S; RIGHT : IN S) RETURN S IS
BEGIN -- IMPLEMENT AS SUBTRACTION, NOT ADDITION
RETURN LEFT - RIGHT;
END "+";
END R3;
BEGIN
Z := P3.X + 3; -- USES REDEFINED "+"
IF ( P3.Y /= P3.NT3'(8) ) THEN
REPORT.FAILED ("PREDEFINED ""+"" NOT USED TO COMPUTE " &
"P3.Y");
END IF;
IF (Z /= P3.NT3'(2) ) THEN
REPORT.FAILED ("REDEFINED ""+"" NOT USED TO COMPUTE Z");
END IF;
END EXAMPLE_3;
EXAMPLE_4:
DECLARE
GENERIC
TYPE T4 IS LIMITED PRIVATE;
PACKAGE GP4 IS
TYPE NT4 IS NEW T4;
X : NT4;
END GP4;
PACKAGE P4 IS NEW GP4 (BOOLEAN);
USE P4;
BEGIN
P4.X := P4.NT4'LAST;
IF ( P4.X OR (NOT P4.X) ) THEN
REPORT.COMMENT ("P4.X CORRECTLY HAS A BOOLEAN TYPE");
END IF;
END EXAMPLE_4;
EXAMPLE_5:
DECLARE
GENERIC
TYPE T5 (D : POSITIVE) IS PRIVATE;
PACKAGE GP5 IS
TYPE NT5 IS NEW T5;
X : NT5 (D => 5);
Y : POSITIVE := X.D; -- REFERS TO DISCRIMINANT OF NT5
END GP5;
TYPE REC (A : POSITIVE) IS
RECORD
D : POSITIVE := 7;
END RECORD;
PACKAGE P5 IS NEW GP5 (T5 => REC);
-- P5.Y INITIALIZED WITH VALUE USING COMPONENT SELECTION
-- OPERATION FOR THE DISCRIMINANT, I.E. FOR PARENT TYPE
-- T5 WHICH DENOTES REC.
W1 : POSITIVE := P5.X.D; -- VALUE IS 7
W2 : POSITIVE := P5.X.A; -- VALUE IS 5
W3 : POSITIVE := P5.Y; -- VALUE IS 5;
BEGIN
IF ( ( W1 /= 7 ) OR ( W2 /= 5 ) OR (W3 /= 5 ) ) THEN
REPORT.FAILED ("INCORRECT COMPONENT SELECTION");
END IF;
END EXAMPLE_5;
REPORT.RESULT;
END CC3016F;
|
src/dql/DqlParser.g4 | guneysus/predicate-builder | 1 | 239 | parser grammar DqlParser ;
options { tokenVocab=DqlLexer; }
startRule :
selectAllFromTable
;
selectAllFromTable:
SELECT
ALL
FROM
TABLE_NAME
SEMI_COLON
;
|
examples/simulator/src/gdb_remote.ads | Fabien-Chouteau/libriscv | 0 | 26102 | with Interfaces; use Interfaces;
private with ESF;
package GDB_Remote is
type Packet_Kind is (Bad_Packet, Unknown_Packet,
General_Query,
Must_Reply_Empty,
Set_Thread,
Question_Halt,
Read_General_Registers,
Read_Register,
Read_Memory,
Write_Memory,
Query_Supported_Continue,
Continue,
Continue_Addr,
Single_Step,
Single_Step_Addr,
Insert_Breakpoint,
Remove_Breakpoint,
Detach);
type General_Query_Topic is (Unknown_General_Query, Supported, TStatus,
Attached, Thread_Info_Start, Thread_Info_Cont);
type Breakpoint_Type is (Software_Breakpoint,
Hardware_Breakpoint,
Read_Watchpoint,
Write_Watchpoint,
Access_Watchpoint);
type Data_Format is (Hexadecimal, Binary);
type Packet (Kind : Packet_Kind := Bad_Packet) is record
case Kind is
when Bad_Packet | Unknown_Packet | Must_Reply_Empty | Question_Halt |
Read_General_Registers | Query_Supported_Continue | Continue |
Single_Step | Detach
=> null;
when General_Query =>
Q_Topic : General_Query_Topic;
when Set_Thread =>
Op : Character;
Thread_ID : Integer;
when Read_Register =>
Register_Id : Integer;
when Read_Memory | Write_Memory =>
M_Address : Unsigned_64;
M_Size : Unsigned_64;
M_Data_Fmt : Data_Format;
when Continue_Addr | Single_Step_Addr =>
C_Address : Unsigned_64;
when Insert_Breakpoint | Remove_Breakpoint =>
B_Type : Breakpoint_Type;
B_Addr : Unsigned_64;
B_Kind : Natural;
end case;
end record;
function Parse_Packet (Str : String; Cursor : out Natural) return Packet;
function Next_Field (P : String;
Cursor : in out Natural)
return String;
function Next_Data (P : String;
Cursor : in out Natural;
Fmt : Data_Format;
Success : out Boolean)
return Unsigned_8;
-- Return the next octet of data part of a packet
subtype Buffer_Lenght_Type is Positive range 1 .. 4096;
private
function Parse_General_Query (Str : String; Cursor : in out Natural) return Packet;
function Parse_v_Packet (Str : String; Cursor : in out Natural) return Packet;
function Parse_Set_Thread (Str : String; Cursor : in out Natural) return Packet;
function Parse_Read_Register (Str : String; Cursor : in out Natural) return Packet;
function Parse_Read_Memory (Str : String; Cursor : in out Natural) return Packet;
function Parse_Write_Memory (Str : String; Cursor : in out Natural; Fmt : Data_Format) return Packet;
function Parse_Continue (Str : String; Cursor : in out Natural) return Packet;
function Parse_Single_Step (Str : String; Cursor : in out Natural) return Packet;
function Parse_Breakpoint (Str : String; Cursor : in out Natural; Insert : Boolean) return Packet;
function Hex is new ESF.Hex_Image (Unsigned_8);
function Is_Hex (C : Character) return Boolean
is (C in '0' .. '9' | 'A' .. 'F' | 'a' .. 'f')
with Inline;
function From_Hex (C : Character) return Unsigned_8
is (case C is
when '0' .. '9' => Character'Pos (C) - Character'Pos ('0'),
when 'A' .. 'F' => Character'Pos (C) - Character'Pos ('A') + 10,
when 'a' .. 'f' => Character'Pos (C) - Character'Pos ('a') + 10,
when others => raise Program_Error)
with Pre => Is_Hex (C);
function From_Hex (Str : String) return Unsigned_64
with Pre => (for all C of Str => Is_Hex (C));
function To_Int (Str : String) return Integer;
end GDB_Remote;
|
Assembly/mimic_fixes.asm | CaitSith2/Enemizer | 2 | 84883 | <filename>Assembly/mimic_fixes.asm
; replace SpritePrep_Eyegore if flag is on
SpritePrep_EyegoreNew:
{
LDA !ENABLE_MIMIC_OVERRIDE : BNE .new
; old
JSL SpritePrep_Eyegore
RTL
.new
LDA $0E20, X : CMP.b #$B8 : BEQ .mimic ;If sprite id == debugger sprite
JSL $1EC71A ; 0xF471A set eyegore to be only eyegore (.not_goriya?)
RTL
.mimic
LDA #$83 : STA $0E20, X : JSL $0DB818 ; 0x6B818 Sprite_LoadProperties of green eyegore
LDA #$B8 : STA $0E20, X ; set the sprite back to mimic
LDA $0CAA, X : AND #$FB : ORA #$80 : STA $0CAA, X ; STZ $0CAA, X
;INC $0DA0, X
JSL $1EC70D ;0xF470D set eyegore to be mimic (.is_goriya?)
RTL
}
resetSprite_Mimic:
{
LDA !ENABLE_MIMIC_OVERRIDE : BEQ .notMimic ; skip to what it would have done normally
LDA $0E20, X
CMP.b #$B8 : BNE .notMimic
LDA #$83 : STA $0E20, X ; overwrite the sprite id with green eyegore id
.notMimic
; restore code
LDA $0E20, X
CMP.b #$7A
RTL
}
notItemSprite_Mimic:
{ ; don't change this unless you go update SetKillableThief in c# side since it assumes +4 bytes to update the value on the CMP from B8 to C4
; if we set killable thief we want to update the sprite id so it can be killed
LDA $0E20, X
CMP.b #$B8 : BEQ .changeSpriteId ; thief #$C4
; if we don't have mimic code turned on we want to skip, but we also need to reload the sprite id because we just smoked it with this LDA
LDA !ENABLE_MIMIC_OVERRIDE : BEQ .reloadSpriteIdAndSkipMimic ; skip to what it would have done normally
LDA $0E20, X ; I hate assembly
CMP.b #$B8 : BNE .continue ; "mimic" (dialogue test sprite we hijacked). skip to vanilla behavior if it's not a "mimic"
.changeSpriteId
LDA #$83 ; load green eyegore sprite id so we can kill the thing
JMP .continue
.reloadSpriteIdAndSkipMimic
LDA $0E20, X
.continue
; restore code
REP #$20 : ASL #2
;REP #$20 : ASL #4 : ORA $0CF2 : PHX : REP #$10 : TAX
;SEP #$20
;LDA $7F6000, X : STA $02
;SEP #$10
RTL
} |
kv-avm-executable_lists.ads | davidkristola/vole | 4 | 29814 |
with kv.avm.Control;
with kv.avm.Executables;
with kv.avm.Actor_References;
package kv.avm.Executable_Lists is
type Cursor_Type is new Natural;
subtype Index_Type is Cursor_Type range 1 .. Cursor_Type'LAST;
type Executable_Handle_Type is tagged private;
type Executable_Handle_Access is access Executable_Handle_Type;
function Get_List(Self : Executable_Handle_Type) return kv.avm.Control.Status_Type;
function Get_Cursor(Self : Executable_Handle_Type) return Cursor_Type;
function Get_Reference(Self : Executable_Handle_Type) return kv.avm.Actor_References.Actor_Reference_Type;
function Get_Executable(Self : Executable_Handle_Type) return kv.avm.Executables.Executable_Access;
type Executable_Holder_Type is tagged private;
procedure Initialize
(Self : in out Executable_Holder_Type;
Kind : in kv.avm.Control.Status_Type);
procedure Add
(Self : in out Executable_Holder_Type;
This : in kv.avm.Executables.Executable_Access;
Ref : in kv.avm.Actor_References.Actor_Reference_Type);
function Find(Self : Executable_Holder_Type; Executable : kv.avm.Executables.Executable_Access) return Cursor_Type;
function Is_In(Self : Executable_Holder_Type; Executable : kv.avm.Executables.Executable_Access) return Boolean;
function Get(Self : Executable_Holder_Type; Position : Cursor_Type) return kv.avm.Executables.Executable_Access;
procedure Delete -- deallocate the handle
(Self : in out Executable_Holder_Type;
This : in Cursor_Type);
procedure Drop -- just remove the handle from the list
(Self : in out Executable_Holder_Type;
This : in Cursor_Type);
procedure Drop
(Self : in out Executable_Holder_Type;
This : in kv.avm.Executables.Executable_Access);
procedure Acquire_From
(Self : in out Executable_Holder_Type;
Place : in Cursor_Type;
From : in out Executable_Holder_Type);
function Get_Handle
(Self : Executable_Holder_Type;
Position : Cursor_Type) return Executable_Handle_Access;
function Get_Last
(Self : Executable_Holder_Type) return Cursor_Type;
private
type Executable_Handle_Type is tagged
record
Executable : kv.avm.Executables.Executable_Access;
Reference : kv.avm.Actor_References.Actor_Reference_Type;
Status : kv.avm.Control.Status_Type; -- This is also the list that holds the executable
Position : Cursor_Type; -- Zero means that this executable isn't in a list
end record;
type Executable_Array_Type is array (Index_Type range <>) of Executable_Handle_Access;
type Executable_Array_Access is access Executable_Array_Type;
type Executable_Holder_Type is tagged
record
List : Executable_Array_Access;
Count : Cursor_Type;
Kind : kv.avm.Control.Status_Type;
end record;
procedure Add
(Self : in out Executable_Holder_Type;
This : in Executable_Handle_Access);
end kv.avm.Executable_Lists;
|
examples/utils/keyboard.adb | Fabien-Chouteau/GESTE | 13 | 6323 | <gh_stars>10-100
with Interfaces.C; use Interfaces.C;
with SDL_SDL_events_h; use SDL_SDL_events_h;
with SDL_SDL_keysym_h; use SDL_SDL_keysym_h;
package body Keyboard is
Is_Pressed : array (Key_Kind) of Boolean := (others => False);
------------
-- Update --
------------
procedure Update is
Evt : aliased SDL_Event;
begin
while SDL_PollEvent (Evt'Access) /= 0 loop
if Evt.c_type = SDL_KEYDOWN or else Evt.c_type = SDL_KEYUP then
case Evt.key.keysym.sym is
when SDLK_LEFT =>
Is_Pressed (Left) := Evt.c_type = SDL_KEYDOWN;
when SDLK_RIGHT =>
Is_Pressed (Right) := Evt.c_type = SDL_KEYDOWN;
when SDLK_DOWN =>
Is_Pressed (Down) := Evt.c_type = SDL_KEYDOWN;
when SDLK_UP =>
Is_Pressed (Up) := Evt.c_type = SDL_KEYDOWN;
when SDLK_ESCAPE =>
Is_Pressed (Esc) := Evt.c_type = SDL_KEYDOWN;
when others =>
null;
end case;
end if;
end loop;
end Update;
-------------
-- Pressed --
-------------
function Pressed (Key : Key_Kind) return Boolean
is (Is_Pressed (Key));
end Keyboard;
|
third_party/antlr_grammars_v4/oberon/oberon.g4 | mikhan808/rsyntaxtextarea-antlr4-extension | 2 | 650 | /*
BSD License
Copyright (c) 2020, <NAME>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of Tom Everett 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.
*/
/*
* https://people.inf.ethz.ch/wirth/Oberon/Oberon07.Report.pdf
*/
grammar oberon;
ident
: IDENT
;
qualident
: (ident '.')? ident
;
identdef
: ident '*'?
;
integer
: (DIGIT+)
| (DIGIT HEXDIGIT* 'H')
;
real
: DIGIT+ '.' DIGIT* scaleFactor?
;
scaleFactor
: 'E' ('+' | '-')? DIGIT+
;
number
: integer
| real
;
constDeclaration
: identdef '=' constExpression
;
constExpression
: expression
;
typeDeclaration
: identdef '=' type
;
type
: qualident
| arrayType
| recordType
| pointerType
| procedureType
;
arrayType
: ARRAY length (',' length)* OF type
;
length
: constExpression
;
recordType
: RECORD ('(' baseType ')')? fieldListSequence? END
;
baseType
: qualident
;
fieldListSequence
: fieldList (';' fieldList)*
;
fieldList
: identList ':' type
;
identList
: identdef (',' identdef)*
;
pointerType
: POINTER TO type
;
procedureType
: PROCEDURE formalParameters?
;
variableDeclaration
: identList ':' type
;
expression
: simpleExpression (relation simpleExpression)?
;
relation
: '='
| '#'
| '<'
| '<='
| '>'
| '>='
| IN
| IS
;
simpleExpression
: ('+' | '-')? term (addOperator term)*
;
addOperator
: '+'
| '-'
| OR
;
term
: factor (mulOperator factor)*
;
mulOperator
: '*'
| '/'
| DIV
| MOD
| '&'
;
factor
: number
| STRING
| NIL
| TRUE
| FALSE
| set
| designator (actualParameters)?
| '(' expression ')'
| '~' factor
;
designator
: qualident selector*
;
selector
: '.' ident
| '[' expList ']'
| '^'
| '(' qualident ')'
;
set
: '{' (element (',' element)*)? '}'
;
element
: expression ('..' expression)?
;
expList
: expression (',' expression)*
;
actualParameters
: '(' expList? ')'
;
statement
: (assignment | procedureCall | ifStatement | caseStatement | whileStatement | repeatStatement | forStatement)?
;
assignment
: designator ':=' expression
;
procedureCall
: designator actualParameters?
;
statementSequence
: statement (';' statement)*
;
ifStatement
: IF expression THEN statementSequence (ELSIF expression THEN statementSequence)* (ELSE statementSequence)? END
;
caseStatement
: CASE expression OF case_ ('|' case_)* END
;
case_
: (caseLabelList ':' statementSequence)?
;
caseLabelList
: labelRange (',' labelRange)*
;
labelRange
: label ('..' label)?
;
label
: integer
| STRING
| qualident
;
whileStatement
: WHILE expression DO statementSequence (ELSIF expression DO statementSequence)* END
;
repeatStatement
: REPEAT statementSequence UNTIL expression
;
forStatement
: FOR ident ':=' expression TO expression (BY constExpression)? DO statementSequence END
;
procedureDeclaration
: procedureHeading ';' procedureBody ident
;
procedureHeading
: PROCEDURE identdef formalParameters?
;
procedureBody
: declarationSequence (BEGIN statementSequence)? (RETURN expression)? END
;
declarationSequence
: (CONST (constDeclaration ';')*)? (TYPE (typeDeclaration ';')*)? (VAR (variableDeclaration ';')*)? (procedureDeclaration ';')*
;
formalParameters
: '(' (fPSection (';' fPSection)*)? ')' (':' qualident)?
;
fPSection
: VAR? ident (',' ident)* ':' formalType
;
formalType
: (ARRAY OF)* qualident
;
module
: MODULE ident ';' importList? declarationSequence (BEGIN statementSequence)? END ident '.'
;
importList
: IMPORT import_ (',' import_)* ';'
;
import_
: ident (':=' ident)?
;
ARRAY
: 'ARRAY'
;
OF
: 'OF'
;
END
: 'END'
;
POINTER
: 'POINTER'
;
TO
: 'TO'
;
RECORD
: 'RECORD'
;
PROCEDURE
: 'PROCEDURE'
;
IN
: 'IN'
;
IS
: 'IS'
;
OR
: 'OR'
;
DIV
: 'DIV'
;
MOD
: 'MOD'
;
NIL
: 'NIL'
;
TRUE
: 'TRUE'
;
FALSE
: 'FALSE'
;
IF
: 'IF'
;
THEN
: 'THEN'
;
ELSIF
: 'ELSIF'
;
ELSE
: 'ELSE'
;
CASE
: 'CASE'
;
WHILE
: 'WHILE'
;
DO
: 'DO'
;
REPEAT
: 'REPEAT'
;
UNTIL
: 'UNTIL'
;
FOR
: 'FOR'
;
BY
: 'BY'
;
BEGIN
: 'BEGIN'
;
RETURN
: 'RETURN'
;
CONST
: 'CONST'
;
TYPE
: 'TYPE'
;
VAR
: 'VAR'
;
MODULE
: 'MODULE'
;
IMPORT
: 'IMPORT'
;
STRING
: ('"' .*? '"')
| (DIGIT HEXDIGIT* 'X')
;
HEXDIGIT
: DIGIT
| 'A'
| 'B'
| 'C'
| 'D'
| 'E'
| 'F'
;
IDENT
: LETTER (LETTER | DIGIT)*
;
LETTER
: [a-zA-Z]
;
DIGIT
: [0-9]
;
COMMENT
: '(*' .*? '*)' -> skip
;
WS
: [ \t\r\n] -> skip
;
|
programs/oeis/184/A184583.asm | neoneye/loda | 22 | 171295 | <filename>programs/oeis/184/A184583.asm
; A184583: floor[(n-1/5)(1+r)], where r=(1+sqrt(5))/2; complement of A184582.
; 2,4,7,9,12,15,17,20,23,25,28,30,33,36,38,41,43,46,49,51,54,57,59,62,64,67,70,72,75,78,80,83,85,88,91,93,96,98,101,104,106,109,112,114,117,119,122,125,127,130,132,135,138,140,143,146,148,151,153,156,159,161,164,167,169,172,174,177,180,182,185,187,190,193,195,198,201,203,206,208,211,214,216,219,222,224,227,229,232,235,237,240,242,245,248,250,253,256,258,261
add $0,4
mul $0,2
add $0,2
mul $0,377
div $0,288
sub $0,11
|
src/Data/List/Prefix.agda | metaborg/mj.agda | 10 | 17331 | module Data.List.Prefix where
open import Level
open import Data.Nat
open import Data.List
open import Data.List.At
open import Data.List.Membership.Propositional
open import Data.List.Relation.Unary.Any hiding (map)
open import Data.List.Relation.Binary.Pointwise as P hiding (refl; map)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as ≡
-- prefix predicate for lists
infix 4 _⊑_
data _⊑_ {a} {A : Set a} : List A → List A → Set a where
[] : ∀ {ys} → [] ⊑ ys
_∷_ : ∀ x {xs ys} → xs ⊑ ys → x ∷ xs ⊑ x ∷ ys
⊑-refl : ∀ {a} {A : Set a} → Reflexive (_⊑_ {A = A})
⊑-refl {x = []} = []
⊑-refl {x = x ∷ xs} = x ∷ ⊑-refl
⊑-trans : ∀ {a} {A : Set a} → Transitive (_⊑_ {A = A})
⊑-trans [] _ = []
⊑-trans (x ∷ p) (.x ∷ q) = x ∷ ⊑-trans p q
open import Relation.Binary.PropositionalEquality
⊑-unique : ∀ {a}{A : Set a}{k l : List A}(xs ys : k ⊑ l) → xs ≡ ys
⊑-unique [] [] = refl
⊑-unique (x ∷ xs) (.x ∷ ys) = cong (λ u → x ∷ u) (⊑-unique xs ys)
⊑-trans-refl : ∀ {a}{A : Set a}{k l}{xs : k ⊑ l} → ⊑-trans {A = A} ⊑-refl xs ≡ xs
⊑-trans-refl {xs = []} = refl
⊑-trans-refl {xs = x ∷ xs} = cong (λ u → x ∷ u) ⊑-trans-refl
⊑-trans-refl' : ∀ {a}{A : Set a}{k l}{xs : k ⊑ l} → ⊑-trans {A = A} xs ⊑-refl ≡ xs
⊑-trans-refl' {xs = []} = refl
⊑-trans-refl' {xs = x ∷ xs} = cong (λ u → x ∷ u) ⊑-trans-refl'
⊑-trans-assoc : ∀ {a}{A : Set a}{k l m n : List A}{p : k ⊑ l}{q : l ⊑ m}{r : m ⊑ n} →
⊑-trans p (⊑-trans q r) ≡ ⊑-trans (⊑-trans p q) r
⊑-trans-assoc {p = []} {q} = refl
⊑-trans-assoc {p = x ∷ p} {.x ∷ q} {.x ∷ r} = cong (λ u → x ∷ u) ⊑-trans-assoc
remainder : ∀ {a}{A : Set a}{xs ys : List A} → xs ⊑ ys → List A
remainder ([] {ys}) = ys
remainder (x ∷ xs) = remainder xs
-- list extensions; reverse prefix relation
infix 4 _⊒_
_⊒_ : ∀ {a} {A : Set a} → List A → List A → Set a
xs ⊒ ys = ys ⊑ xs
-- appending to a list gives a list extension;
-- or, appending to a list makes the original a prefix
∷ʳ-⊒ : ∀ {a} {A : Set a} (x : A) xs → xs ∷ʳ x ⊒ xs
∷ʳ-⊒ x [] = []
∷ʳ-⊒ x (x₁ ∷ Σ₁) = x₁ ∷ (∷ʳ-⊒ x Σ₁)
-- indexes into a prefix point to the same element in extensions
xs⊒ys[i] : ∀ {a} {A : Set a} {xs : List A} {ys : List A} {i y} →
xs [ i ]= y → (p : ys ⊒ xs) → ys [ i ]= y
xs⊒ys[i] () []
xs⊒ys[i] {i = zero} p (x ∷ a) = p
xs⊒ys[i] {i = suc i} p (x ∷ a) = xs⊒ys[i] p a
-- prefix is preserved by map
⊑-map : ∀ {a b} {A : Set a} {B : Set b} {xs ys : List A} {f : A → B} →
xs ⊑ ys → map f xs ⊑ map f ys
⊑-map [] = []
⊑-map {f = f} (x ∷ p) = f x ∷ (⊑-map p)
-- all elemens in a list, also exist in it's extensions
∈-⊒ : ∀ {a}{A : Set a}{xs : List A}{x} → x ∈ xs → ∀ {ys} → ys ⊒ xs → x ∈ ys
∈-⊒ () []
∈-⊒ (here px) (x ∷ q) = here px
∈-⊒ (there p) (x ∷ q) = there (∈-⊒ p q)
∈-⊒-refl : ∀ {a}{A : Set a}{xs : List A}{x}{p : x ∈ xs} → ∈-⊒ p ⊑-refl ≡ p
∈-⊒-refl {p = here px} = refl
∈-⊒-refl {p = there p} = cong there ∈-⊒-refl
∈-⊒-trans : ∀ {a}{A : Set a}{xs ys zs : List A}{x}{p : x ∈ xs}(q : ys ⊒ xs)(r : zs ⊒ ys) → ∈-⊒ p (⊑-trans q r) ≡ ∈-⊒ (∈-⊒ p q) r
∈-⊒-trans {p = here px} (x ∷ l) (.x ∷ r) = refl
∈-⊒-trans {p = there p} (x ∷ l) (.x ∷ r) = cong there (∈-⊒-trans l r)
open import Relation.Binary
open import Relation.Binary.Core
open import Relation.Nullary
module Decidable {a}{A : Set a}(_≟_ : Decidable (_≡_ {A = A})) where
_⊑?_ : Decidable (_⊑_ {A = A})
[] ⊑? _ = yes []
(x ∷ xs) ⊑? [] = no (λ ())
(x ∷ xs) ⊑? (y ∷ ys) with x ≟ y
(x ∷ xs) ⊑? (y ∷ ys) | no ¬p = no (λ{ (.x ∷ z) → ¬p refl })
(x ∷ xs) ⊑? (.x ∷ ys) | yes refl with xs ⊑? ys
... | yes px = yes (x ∷ px)
... | no ¬px = no (λ{ (.x ∷ px) → ¬px px})
_⊒?_ : Decidable (_⊒_ {A = A})
xs ⊒? ys = ys ⊑? xs
import Relation.Binary.PropositionalEquality.Core as PC
⊑-preorder : ∀ {ℓ}{A : Set ℓ} → Preorder ℓ ℓ ℓ
⊑-preorder {A = A} = record {
Carrier = List A ; _≈_ = _≡_ ; _∼_ = _⊑_ ;
isPreorder = record {
isEquivalence = ≡.isEquivalence ;
reflexive = λ{ refl → ⊑-refl } ; trans = ⊑-trans } }
⊒-preorder : ∀ {ℓ}{A : Set ℓ} → Preorder _ _ _
⊒-preorder {A = A} = record {
Carrier = List A ; _≈_ = _≡_ ; _∼_ = _⊒_ ;
isPreorder = record {
isEquivalence = ≡.isEquivalence ;
reflexive = λ{ refl → ⊑-refl } ; trans = λ p q → ⊑-trans q p } }
|
Transynther/x86/_processed/US/_zr_/i3-7100_9_0x84_notsx.log_74_2320.asm | ljhsiun2/medusa | 9 | 244633 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r8
push %rdx
lea addresses_normal_ht+0x88de, %rdx
nop
nop
nop
nop
nop
sub $16173, %r10
mov $0x6162636465666768, %r11
movq %r11, %xmm6
vmovups %ymm6, (%rdx)
xor $6048, %r8
pop %rdx
pop %r8
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r14
push %rax
push %rbp
push %rbx
push %rcx
// Store
lea addresses_UC+0x1a7fc, %r11
nop
sub %rcx, %rcx
movb $0x51, (%r11)
nop
nop
nop
nop
add $9661, %rcx
// Store
lea addresses_D+0x238c, %r13
clflush (%r13)
and %rax, %rax
mov $0x5152535455565758, %rcx
movq %rcx, (%r13)
nop
nop
nop
nop
nop
and %rcx, %rcx
// Faulty Load
lea addresses_US+0xfafc, %r11
nop
nop
nop
nop
xor %rbx, %rbx
mov (%r11), %ax
lea oracles, %rcx
and $0xff, %rax
shlq $12, %rax
mov (%rcx,%rax,1), %rax
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r14
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_US', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_UC', 'same': False, 'size': 1, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_D', 'same': False, 'size': 8, 'congruent': 2, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_US', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'00': 74}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
Scripts Pack Source Items/Scripts Pack/Core Components/Switch User (Login Window).applescript | Phorofor/ScriptsPack.macOS | 1 | 3741 | # Scripts Pack - Tweak various preference variables in macOS
# <Phorofor, https://github.com/Phorofor/>
-- Allows the user to switch user accounts without having to close running applications.
-- Fast User Switching
-- For best performance on computers without very powerful hardware please make sure that you close programs that aren't in use or else the computer may lag when logging in back to this user account.
-- No settings are changed when running this script
set useR to do shell script "whoami"
tell current application
display alert "Are you sure you want to switch the user on your computer now?" message "This will allow you to switch user account without logging out and closing everything. This takes you to the login window when activated. Login back to resume your work." & return & return & "You're currently using the account '" & useR & "'." buttons {"Cancel", "Sleep", "Switch User"} default button 3 cancel button 1
end tell
set the button_pressed to the button returned of the result
if the button_pressed is "Switch User" then
do shell script ("/System/Library/CoreServices/Menu' 'Extras/User.menu/Contents/Resources/CGSession -suspend")
else
ignoring application responses
delay 1
tell application "System Events" to sleep
end ignoring
end if |
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/opt18.adb | best08618/asylo | 7 | 20310 | <reponame>best08618/asylo
-- { dg-do compile }
-- { dg-options "-O3" }
with Opt18_Pkg; use Opt18_Pkg;
package body Opt18 is
function Mag (Item : in Cart_Vector_Type) return Float is
begin
return Sqrt (Item (X) * Item (X) + Item (Y) * Item (Y)
+ Item (Z) * Item (Z));
end;
function Unit_Quaternion_To_Mag_Axis (Quaternion : in Unit_Quaternion_Type)
return Mag_Axis_Type is
Sin_Half : Float
:= Mag (Cart_Vector_Type'(Quaternion.X, Quaternion.Y, Quaternion.Z));
begin
if Sin_Half > 3.0 * First_Order_Trig then
return
(Mag => Atan2 (Double_Trig (Unchecked_Trig_Pair (Sin_Half,
Quaternion.S))),
Axis => Unit_Vector_Type'(Quaternion.X / Sin_Half,
Quaternion.Y / Sin_Half,
Quaternion.Z / Sin_Half));
else
return (0.0, X_Unit);
end if;
end;
end Opt18;
|
modules/simpleRender/SimpleRender.asm | jaredwhitney/os3 | 5 | 9723 | <filename>modules/simpleRender/SimpleRender.asm
Point2D_x equ 0
Point2D_y equ 4
Point_x equ 0
Point_y equ 4
Point_z equ 8
SimpleRender.init :
pusha
push dword SimpleRender.COMMAND_RUN
call iConsole2.RegisterCommand
popa
ret
SimpleRender.trinumber :
dd 0x8
SimpleRender.tridata :
dd -100, -100, 500 ; tri 1
dd 100, -100, 500
dd -100, 100, 500
dd 100, -100, 500 ; tri 2
dd -100, 100, 500
dd 100, 100, 500
dd -100, -100, 500
dd -100, 100, 500
dd -100, -100, 700
dd -100, 100, 500
dd -100, 100, 700
dd -100, -100, 700
dd 100, -100, 500
dd 100, 100, 500
dd 100, -100, 700
dd 100, 100, 500
dd 100, 100, 700
dd 100, -100, 700
dd -100, -100, 700
dd 100, -100, 700
dd 100, 100, 700
dd -100, -100, 700
dd -100, 100, 700
dd 100, 100, 700
SimpleRender.TRI_SIZE equ SimpleRender.POINT_SIZE*3
SimpleRender.POINT_SIZE equ 4*3
SimpleRender.drawTri :
times 2*3 dd 0x0
SimpleRender.currentTri :
dd SimpleRender.tridata
SimpleRender.newPoint :
times 3 dd 0x0
SimpleRender.window :
dd 0x0
SimpleRender.image :
dd 0x0
SimpleRender.tempZ :
dd 0x0
SimpleRender.mxacc :
dd 0
SimpleRender.mxaccf :
times 2 dd 0x0
SimpleRender.lockMouse :
dd FALSE
SimpleRender.STR_SIMPLERENDER :
db "3dengine", 0x0
SimpleRender.COMMAND_RUN :
dd SimpleRender.STR_SIMPLERENDER
dd SimpleRender.main
dd null
SimpleRender.main :
pusha
push dword .STR_TITLE
push dword 0*4
push dword 0
push dword 400*4
push dword 400
call WinMan.CreateWindow;Dolphin2.makeWindow
mov [SimpleRender.window], ecx
mov ebx, 400*400*4
call ProgramManager.reserveMemory
mov [SimpleRender.image], ebx
push ebx
push dword 400*4
push dword 400
push dword 0*4
push dword 0
push dword 400*4
push dword 400
call Image.Create
mov ebx, [SimpleRender.window]
mov eax, ecx
call Grouping.Add
;mov [Dolphin2.focusedComponent], ecx
mov dword [ecx+Component_keyHandlerFunc], SimpleRender.keyFunc
mov eax, [SimpleRender.image]
mov ebx, 400
mov ecx, 400
call L3gxImage.FromBuffer
mov [SimpleRender.ximage], ecx
push dword SimpleRender.TASK_MAINLOOP
call iConsole2.RegisterTask
mov eax, SimpleRender.exit
mov ebx, [SimpleRender.window]
call WindowGrouping.RegisterCloseCallback
popa
ret
.STR_TITLE :
db "SimpleRender v2", 0
SimpleRender.ximage :
dd 0x0
SimpleRender.keyFunc :
xor dword [SimpleRender.lockMouse], TRUE
cmp dword [SimpleRender.lockMouse], TRUE
jne .aret
mov dword [Mouse.cursor], Mouse.CURSOR_TRANSPARENT
jmp .ret
.aret :
mov dword [Mouse.cursor], Mouse.CURSOR_DEFAULT
.ret :
ret
SimpleRender.exit :
pusha
push dword SimpleRender.TASK_MAINLOOP
call iConsole2.UnregisterTask
popa
ret
SimpleRender.TASK_MAINLOOP :
dd SimpleRender.loop
dd null
SimpleRender.loop :
pusha
cmp dword [SimpleRender.lockMouse], TRUE
jne .dontUseMouse
mov eax, [Mouse.x]
mov ebx, [Graphics.SCREEN_WIDTH]
shr ebx, 2 ; /4 to get in pixels
shr ebx, 1 ; /2 to get center of width
sub eax, ebx
add [SimpleRender.mxacc], eax
;add dword [SimpleRender.mxacc], 20
mov [Mouse_xsum], ebx
;mov [Mouse_ysum],
.dontUseMouse :
; repaint the thing!
mov eax, [SimpleRender.image]
mov ebx, 400*400*4
call Buffer.clear
fild dword [SimpleRender.mxacc]
fdiv dword [.f500]
fstp dword [SimpleRender.mxaccf]
mov dword [SimpleRender.currentTri], SimpleRender.tridata
mov edx, [SimpleRender.trinumber]
.loop :
call SimpleRender.goDrawTri
add dword [SimpleRender.currentTri], SimpleRender.TRI_SIZE
dec edx
cmp edx, 0x0
jg .loop
popa
ret
SimpleRender.goDrawTri :
push edx
xor ecx, ecx
mov [SimpleRender.loop.count], ecx
.loop :
mov eax, [SimpleRender.currentTri]
mov ecx, [SimpleRender.loop.count]
imul ecx, 4*3
add eax, ecx
mov [SimpleRender.triS], eax
mov ebx, SimpleRender.drawTri
mov ecx, [SimpleRender.loop.count]
imul ecx, 4*2
add ebx, ecx
mov [SimpleRender.drawTriS], eax
; r0y
mov ebx, [SimpleRender.triS]
mov ecx, SimpleRender.newPoint
mov edx, [ebx+Point_z]
sub edx, 600
mov [SimpleRender.tempZ], edx
fld dword [SimpleRender.mxaccf]
fcos
fimul dword [ebx+Point_x]
fstp dword [.fstor0]
fld dword [SimpleRender.mxaccf]
fsin
fimul dword [SimpleRender.tempZ]
fsub dword [.fstor0]
fistp dword [ecx+Point_x]
fld dword [SimpleRender.mxaccf]
fsin
fimul dword [ebx+Point_x]
fstp dword [.fstor0]
fld dword [SimpleRender.mxaccf]
fcos
fimul dword [SimpleRender.tempZ]
fadd dword [.fstor0]
fistp dword [ecx+Point_z]
add dword [ecx+Point_z], 600
mov eax, [ebx+Point_y]
mov [ecx+Point_y], eax
.nor0y :
mov edx, SimpleRender.newPoint
mov eax, [edx+Point_x]
mov ebx, [edx+Point_z]
call SimpleRender.p_func
add ecx, 200
mov [.u], ecx
mov eax, [edx+Point_y]
mov ebx, [edx+Point_z]
call SimpleRender.p_func
add ecx, 200
mov [.v], ecx
cmp dword [SimpleRender.loop.count], 0
jne .goon
mov eax, [.u]
mov [.u0], eax
mov eax, [.v]
mov [.v0], eax
jmp .noDraw
.goon :
push dword [SimpleRender.ximage]
push dword [.u]
push dword [.v]
push dword [.ul]
push dword [.vl]
call SimpleRender.drawLine
cmp dword [SimpleRender.loop.count], 2
jne .noDraw
push dword [SimpleRender.ximage]
push dword [.u]
push dword [.v]
push dword [.u0]
push dword [.v0]
call SimpleRender.drawLine
.noDraw :
mov eax, [.u]
mov [.ul], eax
mov eax, [.v]
mov [.vl], eax
inc dword [SimpleRender.loop.count]
cmp dword [SimpleRender.loop.count], 3
jl .loop
pop edx
ret
.u :
dd 0x0
.v :
dd 0x0
.u0 :
dd 0x0
.v0 :
dd 0x0
.ul :
dd 0x0
.vl :
dd 0x0
.fstor0 :
dd 0x0
SimpleRender.triS :
dd 0x0
SimpleRender.drawTriS :
dd 0x0
SimpleRender.loop.count :
dd 0x0
SimpleRender.loop.f500 :
dd 500.
SimpleRender.p_func :
push eax
push ebx
push edx
xor ecx, ecx
cmp ebx, 0
jle .ret
mov [.zstor], ebx
mov [.astor], eax
fild dword [.zstor]
fdiv dword [.f80]
fstp dword [.zdstor]
fild dword [.astor]
fdiv dword [.zdstor]
fistp dword [.rstor]
mov ecx, [.rstor]
.ret :
pop edx
pop ebx
pop eax
ret
.zstor :
dd 0x0
.astor :
dd 0x0
.zdstor :
dd 0x0
.rstor :
dd 0x0
.f80 :
dd 160.
%include "../modules/simpleRender/lineFunc.asm"
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/taft_type2.adb | best08618/asylo | 7 | 26145 | -- { dg-do compile }
-- { dg-options "-g" }
with Taft_Type2_Pkg; use Taft_Type2_Pkg;
package body Taft_Type2 is
procedure Proc is
A : T;
function F return T is
My_T : T;
begin
My_T := Open;
return My_T;
end;
begin
A := F;
end;
end Taft_Type2;
|
dsl/antlr/Examples/CSV.g4 | y2ghost/study | 0 | 7263 | <reponame>y2ghost/study<gh_stars>0
grammar CSV;
file: hdr row+;
hdr: row;
row: field (',' field)* '\r'? '\n';
field
: TEXT
| STRING
|
;
TEXT: ~[,\n\r"]+ ;
STRING: '"' ('""'|~'"')* '"';
|
euler13.adb | kimtg/euler-ada | 7 | 25942 | <filename>euler13.adb
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
procedure Euler13 is
function To_Integer(C : Character) return Integer is (Character'Pos(C) - Character'Pos('0'));
function Digit(A : String; D : Positive) return Natural is
begin
if D in A'Range then
return To_Integer(A(A'Length - D + 1));
else
return 0;
end if;
end Digit;
function "+"(A, B : String) return String is
Length : Natural := Natural'Max(A'Length, B'Length);
R : Unbounded_String;
Carry : Natural := 0;
S : Natural;
begin
for D in 1 .. Length loop
S := Carry + Digit(A, D) + Digit(B, D);
R := Integer'Image(S mod 10)(2) & R;
Carry := S / 10;
end loop;
if Carry > 0 then
R := Integer'Image(Carry)(2) & R;
end if;
return To_String(R);
end "+";
Nums : constant array(Positive range <>) of String(1 .. 50) :=
(
"37107287533902102798797998220837590246510135740250",
"46376937677490009712648124896970078050417018260538",
"74324986199524741059474233309513058123726617309629",
"91942213363574161572522430563301811072406154908250",
"23067588207539346171171980310421047513778063246676",
"89261670696623633820136378418383684178734361726757",
"28112879812849979408065481931592621691275889832738",
"44274228917432520321923589422876796487670272189318",
"47451445736001306439091167216856844588711603153276",
"70386486105843025439939619828917593665686757934951",
"62176457141856560629502157223196586755079324193331",
"64906352462741904929101432445813822663347944758178",
"92575867718337217661963751590579239728245598838407",
"58203565325359399008402633568948830189458628227828",
"80181199384826282014278194139940567587151170094390",
"35398664372827112653829987240784473053190104293586",
"86515506006295864861532075273371959191420517255829",
"71693888707715466499115593487603532921714970056938",
"54370070576826684624621495650076471787294438377604",
"53282654108756828443191190634694037855217779295145",
"36123272525000296071075082563815656710885258350721",
"45876576172410976447339110607218265236877223636045",
"17423706905851860660448207621209813287860733969412",
"81142660418086830619328460811191061556940512689692",
"51934325451728388641918047049293215058642563049483",
"62467221648435076201727918039944693004732956340691",
"15732444386908125794514089057706229429197107928209",
"55037687525678773091862540744969844508330393682126",
"18336384825330154686196124348767681297534375946515",
"80386287592878490201521685554828717201219257766954",
"78182833757993103614740356856449095527097864797581",
"16726320100436897842553539920931837441497806860984",
"48403098129077791799088218795327364475675590848030",
"87086987551392711854517078544161852424320693150332",
"59959406895756536782107074926966537676326235447210",
"69793950679652694742597709739166693763042633987085",
"41052684708299085211399427365734116182760315001271",
"65378607361501080857009149939512557028198746004375",
"35829035317434717326932123578154982629742552737307",
"94953759765105305946966067683156574377167401875275",
"88902802571733229619176668713819931811048770190271",
"25267680276078003013678680992525463401061632866526",
"36270218540497705585629946580636237993140746255962",
"24074486908231174977792365466257246923322810917141",
"91430288197103288597806669760892938638285025333403",
"34413065578016127815921815005561868836468420090470",
"23053081172816430487623791969842487255036638784583",
"11487696932154902810424020138335124462181441773470",
"63783299490636259666498587618221225225512486764533",
"67720186971698544312419572409913959008952310058822",
"95548255300263520781532296796249481641953868218774",
"76085327132285723110424803456124867697064507995236",
"37774242535411291684276865538926205024910326572967",
"23701913275725675285653248258265463092207058596522",
"29798860272258331913126375147341994889534765745501",
"18495701454879288984856827726077713721403798879715",
"38298203783031473527721580348144513491373226651381",
"34829543829199918180278916522431027392251122869539",
"40957953066405232632538044100059654939159879593635",
"29746152185502371307642255121183693803580388584903",
"41698116222072977186158236678424689157993532961922",
"62467957194401269043877107275048102390895523597457",
"23189706772547915061505504953922979530901129967519",
"86188088225875314529584099251203829009407770775672",
"11306739708304724483816533873502340845647058077308",
"82959174767140363198008187129011875491310547126581",
"97623331044818386269515456334926366572897563400500",
"42846280183517070527831839425882145521227251250327",
"55121603546981200581762165212827652751691296897789",
"32238195734329339946437501907836945765883352399886",
"75506164965184775180738168837861091527357929701337",
"62177842752192623401942399639168044983993173312731",
"32924185707147349566916674687634660915035914677504",
"99518671430235219628894890102423325116913619626622",
"73267460800591547471830798392868535206946944540724",
"76841822524674417161514036427982273348055556214818",
"97142617910342598647204516893989422179826088076852",
"87783646182799346313767754307809363333018982642090",
"10848802521674670883215120185883543223812876952786",
"71329612474782464538636993009049310363619763878039",
"62184073572399794223406235393808339651327408011116",
"66627891981488087797941876876144230030984490851411",
"60661826293682836764744779239180335110989069790714",
"85786944089552990653640447425576083659976645795096",
"66024396409905389607120198219976047599490197230297",
"64913982680032973156037120041377903785566085089252",
"16730939319872750275468906903707539413042652315011",
"94809377245048795150954100921645863754710598436791",
"78639167021187492431995700641917969777599028300699",
"15368713711936614952811305876380278410754449733078",
"40789923115535562561142322423255033685442488917353",
"44889911501440648020369068063960672322193204149535",
"41503128880339536053299340368006977710650566631954",
"81234880673210146739058568557934581403627822703280",
"82616570773948327592232845941706525094512325230608",
"22918802058777319719839450180888072429661980811197",
"77158542502016545090413245809786882778948721859617",
"72107838435069186155435662884062257473692284509516",
"20849603980134001723930671666823555245252804609722",
"53503534226472524250874054075591789781264330331690");
Sum : Unbounded_String;
begin
for I in Nums'Range loop
Sum := To_Unbounded_String(To_String(Sum) + Nums(I));
end loop;
Put_Line(To_String(Sum));
Put_Line(To_String(Sum)(1 .. 10));
end Euler13;
|
src/main/antlr4/naipmoro/gramm/MM.g4 | naipmoro/gramm | 0 | 4887 | <gh_stars>0
grammar MM ;
db : stat* EOF ;
stat : (axiom
| theorem
| comment
| constStat
| varStat
| disjointStat
| varTypeHyp
| logicalHyp
| scopeStat
| includeStat) ;
scopeStat : '${' stat* '$}' ;
includeStat : '$[' comment* includeFile comment* '$]' ;
includeFile : LABEL | MATHWORD ;
axiom : axiomLabel '$a' axiomConst axiomStat '$.' ;
axiomLabel : LABEL ;
axiomConst : LABEL | MATHWORD ;
axiomStat : (LABEL | MATHWORD)* ;
theorem : theoremLabel '$p' theoremConst theoremStat '$=' proof '$.' ;
theoremLabel : LABEL ;
theoremConst : LABEL | MATHWORD ;
theoremStat : (LABEL | MATHWORD)* ;
proof : (LABEL | MATHWORD)+ ;
comment : COMMENT ;
constStat : '$c' constants '$.' ;
constants : (LABEL | MATHWORD)+ ;
varStat : '$v' vars '$.' ;
vars : (LABEL | MATHWORD)+ ;
disjointStat : '$d' disjointVars '$.' ;
disjointVars : (LABEL | MATHWORD) (LABEL | MATHWORD)+ ;
varTypeHyp : varTypeHypLabel '$f' varTypeHypConst varTypeHypVar '$.' ;
varTypeHypLabel : LABEL ;
varTypeHypConst : LABEL | MATHWORD ;
varTypeHypVar : LABEL | MATHWORD ;
logicalHyp : logicalHypLabel '$e' logicalHypConst logicalHypStat '$.' ;
logicalHypLabel : LABEL ;
logicalHypConst : LABEL | MATHWORD ;
logicalHypStat : (LABEL | MATHWORD)* ;
LABEL : [A-Za-z0-9._-]+ ;
MATHWORD : ~[ \t\r\n$]+ ;
COMMENT : '$(' .*? '$)' -> channel(HIDDEN) ;
WS : [ \t\r\n]+ -> skip ;
|
test/Succeed/Issue1821.agda | shlevy/agda | 3 | 807 | -- Andreas, 2016-04-14 Issue 1821
-- pts rule for SizeUniv not implemented properly
open import Common.Size
open import Common.Equality
record Reveal_·_is_ {A : Set} {B : A → Set}
(f : (x : A) → B x) (x : A) (y : B x) :
Set where
constructor [_]
field eq : f x ≡ y
inspect : ∀ {A : Set} {B : A → Set}
(f : (x : A) → B x) (x : A) → Reveal f · x is f x
inspect f x = [ refl ]
record Co i : Set where
coinductive
field force : ∀{j : Size< i} → Co j
test : ∀ (n : Co ∞) → Set
(test n) with inspect Co.force n
(test n) | n' = Co ∞
-- Error WAS:
-- SizeUniv != Set
-- when checking that the type
-- ...
-- of the generated with function is well-formed
|
tests/src/test_string_utils.adb | TNO/Rejuvenation-Ada | 0 | 15288 | with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with AUnit.Assertions; use AUnit.Assertions;
with Rejuvenation.String_Utils; use Rejuvenation.String_Utils;
package body Test_String_Utils is
Prefix : constant String := "Prefix";
New_Prefix : constant String := "New_Prefix";
Remainder : constant String := "Remainder";
Empty : constant String := "";
procedure TestCase (Prefix, New_Prefix, Remainder : String);
procedure TestCase (Prefix, New_Prefix, Remainder : String) is
begin
Assert
(Actual =>
Replace_Prefix
(String_With_Prefix => Prefix & Remainder,
Prefix => Prefix,
New_Prefix => New_Prefix),
Expected => New_Prefix & Remainder,
Message =>
"Substitution failed with" & ASCII.LF &
"Prefix => " & Prefix & ASCII.LF &
"New_Prefix => " & New_Prefix & ASCII.LF &
"Remainder => " & Remainder & ASCII.LF);
end TestCase;
procedure Test_example (T : in out Test_Case'Class);
procedure Test_example (T : in out Test_Case'Class) is
pragma Unreferenced (T);
begin
TestCase (Prefix, New_Prefix, Remainder);
end Test_example;
procedure Test_new_prefix_same_size
(T : in out Test_Case'Class);
procedure Test_new_prefix_same_size
(T : in out Test_Case'Class)
is
pragma Unreferenced (T);
Same_Size_Prefix : constant String := Prefix'Length * "A";
begin
Assert
(Condition => Same_Size_Prefix'Length = Prefix'Length,
Message => "Test precondition not realized");
TestCase (Prefix, Same_Size_Prefix, Remainder);
end Test_new_prefix_same_size;
procedure Test_new_prefix_longer
(T : in out Test_Case'Class);
procedure Test_new_prefix_longer (T : in out Test_Case'Class)
is
pragma Unreferenced (T);
Longer_Prefix : constant String := "Longer_Prefix";
begin
Assert
(Condition => Longer_Prefix'Length > Prefix'Length,
Message => "Test precondition not realized");
TestCase (Prefix, Longer_Prefix, Remainder);
end Test_new_prefix_longer;
procedure Test_new_prefix_shorter
(T : in out Test_Case'Class);
procedure Test_new_prefix_shorter
(T : in out Test_Case'Class)
is
pragma Unreferenced (T);
Shorter_Prefix : constant String := "SP"; -- Shorter Prefix
begin
Assert
(Condition => Shorter_Prefix'Length < Prefix'Length,
Message => "Test precondition not realized");
TestCase (Prefix, Shorter_Prefix, Remainder);
end Test_new_prefix_shorter;
procedure Test_slices (T : in out Test_Case'Class);
procedure Test_slices (T : in out Test_Case'Class) is
pragma Unreferenced (T);
begin
TestCase (Prefix (3 .. 5), New_Prefix (6 .. 8), Remainder (2 .. 4));
end Test_slices;
procedure Test_empty_prefix (T : in out Test_Case'Class);
procedure Test_empty_prefix (T : in out Test_Case'Class) is
pragma Unreferenced (T);
begin
TestCase (Empty, New_Prefix, Remainder);
end Test_empty_prefix;
procedure Test_empty_new_prefix
(T : in out Test_Case'Class);
procedure Test_empty_new_prefix (T : in out Test_Case'Class)
is
pragma Unreferenced (T);
begin
TestCase (Prefix, Empty, Remainder);
end Test_empty_new_prefix;
procedure Test_empty_remainder (T : in out Test_Case'Class);
procedure Test_empty_remainder (T : in out Test_Case'Class)
is
pragma Unreferenced (T);
begin
TestCase (Prefix, New_Prefix, Empty);
end Test_empty_remainder;
procedure Test_empty_prefix_and_new_prefix
(T : in out Test_Case'Class);
procedure Test_empty_prefix_and_new_prefix
(T : in out Test_Case'Class)
is
pragma Unreferenced (T);
begin
TestCase (Empty, Empty, Remainder);
end Test_empty_prefix_and_new_prefix;
procedure Test_empty_prefix_and_remainder
(T : in out Test_Case'Class);
procedure Test_empty_prefix_and_remainder
(T : in out Test_Case'Class)
is
pragma Unreferenced (T);
begin
TestCase (Empty, New_Prefix, Empty);
end Test_empty_prefix_and_remainder;
procedure Test_empty_new_prefix_and_remainder
(T : in out Test_Case'Class);
procedure Test_empty_new_prefix_and_remainder
(T : in out Test_Case'Class)
is
pragma Unreferenced (T);
begin
TestCase (Prefix, Empty, Empty);
end Test_empty_new_prefix_and_remainder;
procedure Test_all_empty (T : in out Test_Case'Class);
procedure Test_all_empty (T : in out Test_Case'Class)
is
pragma Unreferenced (T);
begin
TestCase (Empty, Empty, Empty);
end Test_all_empty;
-- Test plumbing
overriding function Name
(T : String_Utils_Test_Case) return AUnit.Message_String
is
pragma Unreferenced (T);
begin
return AUnit.Format ("String Utils");
end Name;
overriding procedure Register_Tests (T : in out String_Utils_Test_Case) is
begin
Registration.Register_Routine
(T, Test_example'Access, "Example");
Registration.Register_Routine
(T, Test_new_prefix_same_size'Access,
"New Prefix Same Size");
Registration.Register_Routine
(T, Test_new_prefix_longer'Access, "New Prefix Longer");
Registration.Register_Routine
(T, Test_new_prefix_shorter'Access,
"New Prefix Shorter");
Registration.Register_Routine
(T, Test_slices'Access, "Slices");
Registration.Register_Routine
(T, Test_empty_prefix'Access, "Empty Prefix");
Registration.Register_Routine
(T, Test_empty_new_prefix'Access, "Empty New Prefix");
Registration.Register_Routine
(T, Test_empty_remainder'Access, "Empty Remainder");
Registration.Register_Routine
(T, Test_empty_prefix_and_new_prefix'Access,
"Empty Prefix and New Prefix");
Registration.Register_Routine
(T, Test_empty_prefix_and_remainder'Access,
"Empty Prefix and Remainder");
Registration.Register_Routine
(T, Test_empty_new_prefix_and_remainder'Access,
"Empty New Prefix and Remainder");
Registration.Register_Routine
(T, Test_all_empty'Access, "All Empty");
end Register_Tests;
end Test_String_Utils;
|
test/interaction/Issue2493.agda | cruhland/agda | 1,989 | 12961 | <filename>test/interaction/Issue2493.agda
-- Andreas, 2017-03-10, issue #2493, reported by nad
-- {-# OPTIONS -v tc.meta.assign:10 -v tc.size:90 -v tc:30 #-}
A : Set
A = {!!}
P : A → Set
P = {!λ _ → ?!} -- give
-- Giving this made Agda loop as it solved ?0 := A.
-- Solution: don't assign metas during CheckInternal!
|
programs/oeis/069/A069403.asm | neoneye/loda | 22 | 97133 | <filename>programs/oeis/069/A069403.asm
; A069403: a(n) = 2*Fibonacci(2*n+1) - 1.
; 1,3,9,25,67,177,465,1219,3193,8361,21891,57313,150049,392835,1028457,2692537,7049155,18454929,48315633,126491971,331160281,866988873,2269806339,5942430145,15557484097,40730022147,106632582345,279167724889,730870592323,1913444052081,5009461563921,13114940639683,34335360355129,89891140425705,235338060921987,616123042340257,1613031066098785,4222970155956099,11055879401769513,28944668049352441,75778124746287811,198389706189510993,519390993822245169,1359783275277224515,3559958832009428377,9320093220751060617,24400320830243753475,63880869269980199809,167242286979696845953,437845991669110338051,1146295688027634168201,3001041072413792166553,7856827529213742331459,20569441515227434827825,53851497016468562152017,140985049534178251628227,369103651586066192732665,966325905224020326569769,2529874064085994786976643,6623296287033964034360161,17340014797015897316103841,45396748104013727913951363,118850229515025286425750249,311153940441062131363299385,814611591808161107664147907,2132680834983421191629144337,5583430913142102467223285105,14617611904442886210040710979,38269404800186556162898847833,100190602496116782278655832521,262302402688163790673068649731,686716605568374589740550116673,1797847414016959978548581700289,4706825636482505345905194984195,12322629495430556059167003252297,32261062849809162831595814772697,84460559053996932435620441065795,221120614312181634475265508424689,578901283882547970990176084208273,1515583237335462278495262744200131,3967848428123838864495612148392121,10387962047036054314991573700976233,27196037712984324080479108954536579,71200151091916917926445753162633505,186404415562766429698858150533363937,488013095596382371170128698437458307
mov $1,2
lpb $0
sub $0,1
add $2,$1
add $1,$2
lpe
sub $1,1
mov $0,$1
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48_notsx.log_21829_653.asm | ljhsiun2/medusa | 9 | 174828 | <filename>Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48_notsx.log_21829_653.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r8
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0xbea6, %rsi
lea addresses_WT_ht+0x17a3e, %rdi
nop
nop
nop
nop
and $27892, %r12
mov $97, %rcx
rep movsw
nop
nop
inc %rdx
lea addresses_A_ht+0x1d83e, %r8
and %rsi, %rsi
mov (%r8), %edi
nop
nop
nop
add %rsi, %rsi
lea addresses_A_ht+0x19b63, %rsi
lea addresses_normal_ht+0x2111, %rdi
xor $11815, %r10
mov $39, %rcx
rep movsb
cmp %rcx, %rcx
lea addresses_normal_ht+0xd03e, %rcx
nop
nop
nop
nop
nop
sub $13388, %rsi
movups (%rcx), %xmm5
vpextrq $0, %xmm5, %r12
nop
nop
nop
nop
nop
sub %r10, %r10
lea addresses_UC_ht+0x8bf0, %r8
nop
nop
inc %rcx
mov $0x6162636465666768, %rdi
movq %rdi, (%r8)
nop
nop
nop
and $15920, %r12
lea addresses_WC_ht+0x1269e, %rcx
nop
nop
nop
nop
nop
add %rsi, %rsi
mov (%rcx), %dx
nop
cmp %r10, %r10
lea addresses_normal_ht+0xf5fe, %rdi
nop
nop
nop
nop
xor %r8, %r8
mov (%rdi), %rdx
nop
xor %r12, %r12
lea addresses_UC_ht+0x1296, %rsi
lea addresses_UC_ht+0x1a3e, %rdi
nop
add $19162, %rbp
mov $24, %rcx
rep movsq
nop
nop
nop
add $7165, %rsi
lea addresses_WT_ht+0x172fe, %rsi
lea addresses_normal_ht+0xd23e, %rdi
clflush (%rdi)
add $62673, %r8
mov $87, %rcx
rep movsw
nop
nop
nop
nop
nop
lfence
lea addresses_normal_ht+0x1be6, %rsi
lea addresses_WT_ht+0xa2fe, %rdi
nop
nop
nop
nop
and %r8, %r8
mov $120, %rcx
rep movsl
nop
nop
nop
and %r12, %r12
lea addresses_normal_ht+0xb13e, %rsi
nop
nop
nop
nop
nop
xor %rbp, %rbp
movb $0x61, (%rsi)
nop
nop
inc %rcx
lea addresses_D_ht+0x1483e, %r12
add %rsi, %rsi
mov $0x6162636465666768, %r10
movq %r10, (%r12)
nop
nop
nop
xor $15689, %rdi
lea addresses_D_ht+0x1689e, %rcx
nop
nop
and $25557, %r8
mov $0x6162636465666768, %r10
movq %r10, (%rcx)
nop
nop
nop
nop
nop
xor $17710, %rsi
lea addresses_UC_ht+0x1b666, %rsi
lea addresses_WC_ht+0x1787e, %rdi
nop
nop
nop
dec %rdx
mov $83, %rcx
rep movsl
nop
nop
nop
cmp $25747, %r8
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %r8
push %rbp
push %rcx
push %rdi
push %rsi
// Store
lea addresses_WT+0x18700, %r15
and $6826, %rsi
movl $0x51525354, (%r15)
inc %rsi
// Load
lea addresses_normal+0x12fbe, %rcx
nop
nop
nop
xor $20897, %r8
movups (%rcx), %xmm6
vpextrq $1, %xmm6, %r15
nop
nop
and %r8, %r8
// Faulty Load
lea addresses_WC+0xca3e, %r13
nop
nop
nop
nop
nop
cmp %rcx, %rcx
mov (%r13), %ebp
lea oracles, %r8
and $0xff, %rbp
shlq $12, %rbp
mov (%r8,%rbp,1), %rbp
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WT', 'congruent': 1}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal', 'congruent': 7}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WC', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': True, 'congruent': 10, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_WC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A_ht', 'congruent': 7}}
{'dst': {'same': True, 'congruent': 0, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_A_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 5}}
{'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC_ht', 'congruent': 1}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC_ht', 'congruent': 5}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_normal_ht', 'congruent': 5}}
{'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_UC_ht'}}
{'dst': {'same': False, 'congruent': 11, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_WT_ht'}}
{'dst': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 6}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 8}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 2}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 6, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_UC_ht'}}
{'38': 21829}
38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38
*/
|
Transynther/x86/_processed/NONE/_xt_sm_/i9-9900K_12_0xca_notsx.log_21829_975.asm | ljhsiun2/medusa | 9 | 5116 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r14
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x194b2, %rsi
lea addresses_normal_ht+0x1ee1e, %rdi
cmp %r13, %r13
mov $103, %rcx
rep movsq
nop
nop
sub %r10, %r10
lea addresses_normal_ht+0x18f32, %r14
nop
nop
nop
nop
sub %rax, %rax
movw $0x6162, (%r14)
nop
nop
nop
nop
nop
add $40560, %r10
lea addresses_WT_ht+0x4332, %rsi
lea addresses_normal_ht+0x12f1a, %rdi
clflush (%rdi)
nop
nop
nop
nop
xor $14019, %rbx
mov $51, %rcx
rep movsw
nop
sub %rsi, %rsi
lea addresses_D_ht+0xe052, %rdi
nop
add $19412, %rax
movups (%rdi), %xmm4
vpextrq $0, %xmm4, %r14
nop
nop
nop
nop
add $6424, %rax
lea addresses_A_ht+0x13d32, %rsi
lea addresses_D_ht+0x15432, %rdi
nop
nop
nop
xor $56855, %r10
mov $13, %rcx
rep movsw
nop
nop
nop
nop
nop
sub %r13, %r13
lea addresses_normal_ht+0x2132, %rcx
sub %rax, %rax
mov (%rcx), %si
nop
nop
nop
lfence
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r14
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r15
push %r9
push %rbp
push %rcx
push %rdi
push %rsi
// Store
lea addresses_PSE+0x1dc32, %r12
nop
nop
nop
nop
nop
cmp %r11, %r11
movw $0x5152, (%r12)
nop
xor %r9, %r9
// REPMOV
lea addresses_PSE+0x6642, %rsi
lea addresses_A+0x7332, %rdi
and %r11, %r11
mov $87, %rcx
rep movsb
nop
inc %rsi
// Store
lea addresses_normal+0x17c8, %rcx
nop
nop
sub $55335, %r11
movw $0x5152, (%rcx)
nop
nop
nop
dec %r15
// Store
lea addresses_WT+0x18932, %r12
nop
nop
dec %rcx
movb $0x51, (%r12)
dec %r12
// REPMOV
lea addresses_normal+0x7de2, %rsi
lea addresses_D+0x19132, %rdi
nop
sub %r11, %r11
mov $86, %rcx
rep movsb
nop
nop
nop
inc %rcx
// Faulty Load
lea addresses_WT+0x18932, %rcx
nop
add %r11, %r11
mov (%rcx), %r15
lea oracles, %r11
and $0xff, %r15
shlq $12, %r15
mov (%r11,%r15,1), %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r15
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_PSE'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_A'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_normal'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_D'}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 8}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 5}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 11}}
{'51': 21829}
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
*/
|
regtests/el-expressions-tests.adb | Letractively/ada-el | 0 | 27347 | -----------------------------------------------------------------------
-- EL testsuite - EL Testsuite
-- Copyright (C) 2009, 2010, 2011, 2012, 2013 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with EL.Functions;
with EL.Functions.Default;
with EL.Expressions;
with EL.Functions.Namespaces;
with EL.Variables.Default;
with Test_Bean;
with Action_Bean;
with Ada.Strings.Unbounded;
with Ada.Unchecked_Deallocation;
with Util.Log.Loggers;
with Util.Test_Caller;
with Util.Measures;
with Util.Beans.Objects;
package body EL.Expressions.Tests is
use Test_Bean;
use EL.Expressions;
use Ada.Strings.Unbounded;
use Util.Log;
use Util.Tests;
LOG : constant Util.Log.Loggers.Logger := Loggers.Create ("Tests");
procedure Free is
new Ada.Unchecked_Deallocation (Object => EL.Contexts.Default.Default_Context'Class,
Name => EL.Contexts.Default.Default_Context_Access);
function Format1 (Arg : EL.Objects.Object) return EL.Objects.Object;
function Format2 (Arg1, Arg2 : EL.Objects.Object) return EL.Objects.Object;
function Format3 (Arg1, Arg2, Arg3 : EL.Objects.Object) return EL.Objects.Object;
function Format4 (Arg1, Arg2, Arg3, Arg4 : EL.Objects.Object) return EL.Objects.Object;
procedure Check_Error (T : in out Test'Class;
Expr : in String);
-- Set up performed before each test case
procedure Set_Up (T : in out Test) is
begin
-- Ada.Text_IO.Put_Line ("Allocate context");
T.Context := new EL.Contexts.Default.Default_Context;
end Set_Up;
-- Tear down performed after each test case
procedure Tear_Down (T : in out Test) is
begin
-- Ada.Text_IO.Put_Line ("Free context");
Free (T.Context);
end Tear_Down;
-- Check that evaluating an expression raises an exception
procedure Check_Error (T : in out Test'Class;
Expr : in String) is
E : Expression;
begin
begin
E := Create_Expression (Context => T.Context.all, Expr => Expr);
T.Assert (Condition => False,
Message => "Evaluation of '" & Expr & "' should raise an exception");
exception
when Invalid_Expression =>
T.Assert (Condition => E.Is_Constant,
Message => "Invalid expression value");
end;
end Check_Error;
-- ------------------------------
-- Check that evaluating an expression returns the expected result
-- (to keep the test simple, results are only checked using strings)
-- ------------------------------
procedure Check (T : in out Test;
Expr : in String;
Expect : in String) is
E : constant Expression := Create_Expression (Context => T.Context.all,
Expr => Expr);
V : constant Object := E.Get_Value (Context => T.Context.all);
begin
T.Assert (Condition => To_String (V) = Expect,
Message => "Evaluate '" & Expr & "' returned '" & To_String (V)
& "' when we expect '" & Expect & "'");
declare
E2 : constant Expression := E.Reduce_Expression (Context => T.Context.all);
V2 : constant Object := E2.Get_Value (Context => T.Context.all);
begin
T.Assert (To_String (V2) = Expect,
"Reduce produced incorrect result: " & To_String (V2));
end;
T.Assert_Equals (Expr, E.Get_Expression, "Invalid expression stored");
end Check;
-- ------------------------------
-- Test evaluation of expression using a bean
-- ------------------------------
procedure Test_Simple_Evaluation (T : in out Test) is
begin
Check (T, "#{true}", "TRUE");
Check (T, "#{false}", "FALSE");
Check (T, "#{not false}", "TRUE");
Check (T, "#{! false}", "TRUE");
Check (T, "#{4 * 3}", "12");
Check (T, "#{12 / 3}", "4");
Check (T, "#{12 div 3}", "4");
Check (T, "#{3 % 2}", "1");
Check (T, "#{3 mod 2}", "1");
Check (T, "#{(3 * 2) + (5 * 4) - (2*3)}", "20");
Check (T, "#{3 <= 2}", "FALSE");
Check (T, "#{3 < 2}", "FALSE");
Check (T, "#{3 > 2}", "TRUE");
Check (T, "#{3 >= 2}", "TRUE");
Check (T, "#{3 >= 2 && 2 >= 3}", "FALSE");
Check (T, "#{3 >= 4 || 2 < 3}", "TRUE");
Check (T, "#{3 > 4 ? 1 : 2}", "2");
Check (T, "#{3 < 4 ? 1 : 2}", "1");
Check (T, "#{3 == 3}", "TRUE");
Check (T, "#{3 != 3}", "FALSE");
Check (T, "#{true and false}", "FALSE");
Check (T, "#{true or false}", "TRUE");
Check (T, "#{- 23}", "-23");
Check (T, "#{1.0}", "1");
Check (T, "#{'a\'b'}", "a'b");
Check (T, "'a'", "'a'");
Check (T, "\#{test}", "#{test}");
Check (T, "\${test}", "${test}");
end Test_Simple_Evaluation;
-- ------------------------------
-- Test evaluation of expression using a bean
-- ------------------------------
procedure Test_Bean_Evaluation (T : in out Test) is
P : Person_Access := Create_Person ("Joe", "Black", 42);
begin
T.Context.all.Set_Variable ("user", P);
Check (T, "#{user ne null}", "TRUE");
Check (T, "#{empty user}", "FALSE");
Check (T, "#{not empty user}", "TRUE");
Check (T, "#{user.firstName}", "Joe");
Check (T, "#{user.lastName}", "Black");
Check (T, "#{user.age}", "42");
Check (T, "#{user.age le 42}", "TRUE");
Check (T, "#{user.age lt 44}", "TRUE");
Check (T, "#{user.age ge 42}", "TRUE");
Check (T, "#{user.age ge 45}", "FALSE");
Check (T, "#{user.age gt 42}", "FALSE");
-- Check (T, "#{user.date}", To_String (To_Object (P.Date)));
Check (T, "#{user.weight}", To_String (To_Object (P.Weight)));
P.Age := P.Age + 1;
Check (T, "#{user.age}", "43");
Check (T, "#{user.firstName & ' ' & user.lastName}", "<NAME>");
Check (T, "#{user.firstName eq 'Joe'}", "TRUE");
Check (T, "#{user.firstName ne 'Joe'}", "FALSE");
Check (T, "#{user.firstName eq 'Boe' or user.firstName eq 'Joe'}", "TRUE");
Check (T, "Joe is #{user.age} year#{user.age > 0 ? 's' : ''} old",
"Joe is 43 years old");
Free (P);
end Test_Bean_Evaluation;
-- ------------------------------
-- Test evaluation of expression using a bean
-- ------------------------------
procedure Test_Parse_Error (T : in out Test) is
begin
Check_Error (T, "#{1 +}");
Check_Error (T, "#{12(}");
Check_Error (T, "#{foo(1)}");
Check_Error (T, "#{1+2+'abc}");
Check_Error (T, "#{1+""}");
Check_Error (T, "#{12");
Check_Error (T, "${1");
Check_Error (T, "test #{'}");
Check_Error (T, "#{12 > 23 ? 44}");
Check_Error (T, "#{");
Check_Error (T, "${(12+1}");
Check_Error (T, "#{'a\\'b'}");
Check_Error (T, "#");
Check_Error (T, "$");
Check_Error (T, "#{name");
Check_Error (T, "#{name.name");
Check_Error (T, "#{name.name.name");
Check_Error (T, "#{name:");
Check_Error (T, "#{name:name");
Check_Error (T, "#{name:name(");
Check_Error (T, "#{name:name(12");
Check_Error (T, "#{name:name(12,");
Check_Error (T, "#{name:name(12,+");
Check_Error (T, "#{name:name(12,12");
Check_Error (T, "#{name:name(12,12,");
Check_Error (T, "#{name:name(12,12,+");
Check_Error (T, "#{name:name(12,12,12");
Check_Error (T, "#{name:name(12,12,12.12");
Check_Error (T, "#{name:name(12,12,12.12,12");
Check_Error (T, "#{,}");
Check_Error (T, "#{.}");
Check_Error (T, "#{:}");
Check_Error (T, "#{~}");
Check_Error (T, "#{@}");
Check_Error (T, "#{name['index'}");
Check_Error (T, "#{name[1+1]}");
end Test_Parse_Error;
-- ------------------------------
-- Function to format a string
-- ------------------------------
function Format1 (Arg : EL.Objects.Object) return EL.Objects.Object is
S : constant String := To_String (Arg);
begin
return To_Object ("[" & S & "]");
end Format1;
-- ------------------------------
-- Function to format a string
-- ------------------------------
function Format2 (Arg1, Arg2 : EL.Objects.Object) return EL.Objects.Object is
S1 : constant String := To_String (Arg1);
S2 : constant String := To_String (Arg2);
begin
return To_Object ("[" & S1 & "-" & S2 & "]");
end Format2;
-- ------------------------------
-- Function to format a string
-- ------------------------------
function Format3 (Arg1, Arg2, Arg3 : EL.Objects.Object) return EL.Objects.Object is
S1 : constant String := To_String (Arg1);
S2 : constant String := To_String (Arg2);
S3 : constant String := To_String (Arg3);
begin
return To_Object ("[" & S1 & "-" & S2 & "-" & S3 & "]");
end Format3;
-- ------------------------------
-- Function to format a string
-- ------------------------------
function Format4 (Arg1, Arg2, Arg3, Arg4 : EL.Objects.Object) return EL.Objects.Object is
S1 : constant String := To_String (Arg1);
S2 : constant String := To_String (Arg2);
S3 : constant String := To_String (Arg3);
S4 : constant String := To_String (Arg4);
begin
return To_Object ("[" & S1 & "-" & S2 & "-" & S3 & "-" & S4 & "]");
end Format4;
-- ------------------------------
-- Test function evaluation
-- ------------------------------
procedure Test_Function_Evaluation (T : in out Test) is
P : Person_Access := Create_Person ("Joe", "Black", 42);
Fn : aliased EL.Functions.Default.Default_Function_Mapper;
begin
T.Context.all.Set_Variable ("user", P);
-- Register the 'format' function.
Fn.Set_Function (Namespace => "fn",
Name => "format1",
Func => Format1'Access);
Fn.Set_Function (Namespace => "fn",
Name => "format2",
Func => Format2'Access);
Fn.Set_Function (Namespace => "fn",
Name => "format3",
Func => Format3'Access);
Fn.Set_Function (Namespace => "fx",
Name => "format4",
Func => Format4'Access);
T.Context.Set_Function_Mapper (Fn'Unchecked_Access);
-- Create the expression with function call and check the result
Check (T, "#{fn:format1(10)} #{fn:format2(10,12)}", "[10] [10-12]");
Check (T, "#{fn:format2(10,20)} #{fn:format3(20,32,33)}", "[10-20] [20-32-33]");
Check (T, "#{fx:format4(10,20,30,40)}", "[10-20-30-40]");
Check (T, "#{fn:format1(user.age)}", "[42]");
Check (T, "#{fn:format2(user.age,10)}", "[42-10]");
Check (T, "#{fn:format2(10,user.age)}", "[10-42]");
Check (T, "#{fn:format3(user.age,user.age,user.age)}", "[42-42-42]");
Check (T, "#{fn:format3(10,user.age,user.age)}", "[10-42-42]");
Check (T, "#{fn:format3(10,10,user.age)}", "[10-10-42]");
Check (T, "#{fx:format4(user.age,user.age,user.age,user.age)}", "[42-42-42-42]");
Check (T, "#{fx:format4(user.age,10,user.age,user.age)}", "[42-10-42-42]");
Check (T, "#{fx:format4(user.age,10,10,user.age)}", "[42-10-10-42]");
Check (T, "#{fx:format4(user.age,10,10,10)}", "[42-10-10-10]");
Check_Error (T, "#{fx:format4(12(");
Check_Error (T, "#{fx:format4(12,12(");
Check_Error (T, "#{fx:format4(12,12,12(");
Check_Error (T, "#{fx:format4(12,12,12,12(");
Free (P);
end Test_Function_Evaluation;
-- ------------------------------
-- Test function namespace
-- ------------------------------
procedure Test_Function_Namespace (T : in out Test) is
P : Person_Access := Create_Person ("Joe", "Black", 42);
Fn : aliased EL.Functions.Default.Default_Function_Mapper;
Ns : aliased EL.Functions.Namespaces.NS_Function_Mapper;
begin
T.Context.all.Set_Variable ("user", P);
-- Register the 'format' function (use a different URI for each function).
Fn.Set_Function (Namespace => "http://code.google.com/p/ada-el",
Name => "format1",
Func => Format1'Access);
Fn.Set_Function (Namespace => "http://code.google.com/p/ada-asf",
Name => "format2",
Func => Format2'Access);
Fn.Set_Function (Namespace => "http://code.google.com/p/ada-awa",
Name => "format3",
Func => Format3'Access);
Fn.Set_Function (Namespace => "http://code.google.com/p/ada-util",
Name => "format4",
Func => Format4'Access);
Ns.Set_Function_Mapper (Fn'Unchecked_Access);
Ns.Set_Namespace (Prefix => "fn",
URI => "http://code.google.com/p/ada-el");
Ns.Set_Namespace (Prefix => "fp",
URI => "http://code.google.com/p/ada-asf");
Ns.Set_Namespace (Prefix => "fa",
URI => "http://code.google.com/p/ada-awa");
Ns.Set_Namespace (Prefix => "fu",
URI => "http://code.google.com/p/ada-util");
T.Context.Set_Function_Mapper (Ns'Unchecked_Access);
-- Create the expression with function call and check the result
Check (T, "#{fn:format1(10)} #{fp:format2(10,12)}", "[10] [10-12]");
Check (T, "#{fp:format2(10,20)} #{fa:format3(20,32,33)}", "[10-20] [20-32-33]");
Check (T, "#{fu:format4(10,20,30,40)}", "[10-20-30-40]");
Check (T, "#{fn:format1(user.age)}", "[42]");
Check (T, "#{fp:format2(user.age,10)}", "[42-10]");
Check (T, "#{fp:format2(10,user.age)}", "[10-42]");
Check (T, "#{fa:format3(user.age,user.age,user.age)}", "[42-42-42]");
Check (T, "#{fa:format3(10,user.age,user.age)}", "[10-42-42]");
Check (T, "#{fa:format3(10,10,user.age)}", "[10-10-42]");
Check (T, "#{fu:format4(user.age,user.age,user.age,user.age)}", "[42-42-42-42]");
Check (T, "#{fu:format4(user.age,10,user.age,user.age)}", "[42-10-42-42]");
Check (T, "#{fu:format4(user.age,10,10,user.age)}", "[42-10-10-42]");
Check (T, "#{fu:format4(user.age,10,10,10)}", "[42-10-10-10]");
--
-- Check_Error (T, "#{fx:format4(12(");
-- Check_Error (T, "#{fx:format4(12,12(");
-- Check_Error (T, "#{fx:format4(12,12,12(");
-- Check_Error (T, "#{fx:format4(12,12,12,12(");
Free (P);
end Test_Function_Namespace;
-- ------------------------------
-- Test to verify the Is_Valid operation
-- ------------------------------
procedure Test_Method_Is_Valid (T : in out Test) is
use Action_Bean;
A1 : aliased Action;
M : constant EL.Expressions.Method_Expression :=
Create_Expression (Context => T.Context.all,
Expr => "#{action.notify}");
begin
declare
Method : Method_Info;
begin
T.Assert (not Proc_Action.Is_Valid (Method), "Method is invalid");
end;
T.Context.all.Set_Variable ("action", A1'Unchecked_Access);
declare
Method : constant Method_Info := M.Get_Method_Info (T.Context.all);
begin
T.Assert (Proc_Action.Is_Valid (Method), "Method is invalid");
T.Assert (not Proc2_Action.Is_Valid (Method), "Method is invalid");
end;
end Test_Method_Is_Valid;
-- ------------------------------
-- Test evaluation of method expression
-- ------------------------------
procedure Test_Method_Evaluation (T : in out Test) is
use Action_Bean;
A1 : aliased Action;
A2 : aliased Action;
P : Person_Access := Create_Person ("Joe", "Black", 42);
M : EL.Expressions.Method_Expression :=
Create_Expression (Context => T.Context.all,
Expr => "#{action.notify}");
E : constant EL.Expressions.Expression :=
Create_Expression (Context => T.Context.all,
Expr => "#{action.notify}");
begin
T.Context.all.Set_Variable ("action", A1'Unchecked_Access);
A1.Count := 0;
A2.Count := 0;
Proc_Action.Execute (M, Person (P.all), T.Context.all);
T.Assert (P.Last_Name = A1.Person.Last_Name, "Name was not set");
P.Last_Name := To_Unbounded_String ("John");
T.Context.all.Set_Variable ("action", A2'Unchecked_Access);
Proc_Action.Execute (M, Person (P.all), T.Context.all);
T.Assert ("John" = A2.Person.Last_Name, "Name was not set");
-- Build the method expression from the expression
M := Create_Expression (Expr => E);
P.Last_Name := To_Unbounded_String ("Harry");
Proc_Action.Execute (M, Person (P.all), T.Context.all);
T.Assert ("Harry" = A2.Person.Last_Name, "Name was not set");
M := Create_Expression (Context => T.Context.all,
Expr => "#{action.notify2}");
-- Execute the method expression and check the count value.
for I in 1 .. 5 loop
Proc2_Action.Execute (M, Person (P.all), I, T.Context.all);
T.Assert (I = A2.Count, "Count was not set");
T.Assert (0 = A1.Count, "First action modified as side effect");
end loop;
Free (P);
-- Free (A1);
-- Free (A2);
end Test_Method_Evaluation;
-- ------------------------------
-- Test evaluation of invalid method expression
-- ------------------------------
procedure Test_Invalid_Method (T : in out Test) is
use Action_Bean;
A1 : aliased Action;
P : Person_Access := Create_Person ("Joe", "Black", 42);
M2 : EL.Expressions.Method_Expression;
M : EL.Expressions.Method_Expression :=
Create_Expression (Context => T.Context.all,
Expr => "#{action2.bar}");
begin
-- Bean is not found
begin
Proc_Action.Execute (M, Person (P.all), T.Context.all);
T.Assert (False, "The Invalid_Variable exception was not raised");
exception
when EL.Expressions.Invalid_Variable =>
null;
end;
T.Context.all.Set_Variable ("action2", A1'Unchecked_Access);
begin
Proc_Action.Execute (M, Person (P.all), T.Context.all);
T.Assert (False, "The Invalid_Method exception was not raised");
exception
when EL.Expressions.Invalid_Method =>
null;
end;
-- M2 is not initialized, this should raise Invalid_Expression
begin
Proc_Action.Execute (M2, Person (P.all), T.Context.all);
T.Assert (False, "The Invalid_Method exception was not raised");
exception
when EL.Expressions.Invalid_Expression =>
null;
end;
-- Create a method expression with an invalid expression
begin
M := Create_Expression ("#{12+13}", T.Context.all);
T.Assert (False, "The Invalid_Expression exception was not raised");
exception
when EL.Expressions.Invalid_Expression =>
null;
end;
-- Create a method expression from a valid expression
declare
D : constant Expression := Create_Expression ("#{12+13}", T.Context.all);
begin
-- This should raise an Invalid_Expression exception
M := Create_Expression (D);
T.Assert (False, "The Invalid_Expression exception was not raised");
exception
when EL.Expressions.Invalid_Expression =>
null;
end;
Free (P);
-- Free (A1);
-- Free (A2);
end Test_Invalid_Method;
-- ------------------------------
-- Test the use of a value expression.
-- ------------------------------
procedure Test_Value_Expression (T : in out Test) is
P : Person_Access := Create_Person ("Joe", "Black", 42);
V1 : constant Expression := Create_Expression (Context => T.Context.all,
Expr => "#{user.age}");
begin
T.Context.all.Set_Variable ("user", P);
for I in 1 .. 30 loop
declare
VE : constant Value_Expression := Create_Expression (V1);
begin
VE.Set_Value (Context => T.Context.all,
Value => EL.Objects.To_Object (I));
Assert_Equals (T, I, P.Age, "The value expression did not set the age");
T.Assert (not VE.Is_Readonly (T.Context.all),
"Value expression should not be readonly");
end;
end loop;
Free (P);
end Test_Value_Expression;
-- ------------------------------
-- Test the invalid value expression
-- ------------------------------
procedure Test_Invalid_Value_Expression (T : in out Test) is
V1 : constant Expression := Create_Expression (Context => T.Context.all,
Expr => "#{12 + 3}");
V2 : constant Expression := Create_Expression (Context => T.Context.all,
Expr => "#{user.firstName}");
begin
-- Check that an exception is raised when the expression is not a value expression.
begin
declare
VE : constant Value_Expression := Create_Expression (V1);
begin
T.Assert (False, "No exception raised for an invalid value expression");
VE.Set_Value (Context => T.Context.all, Value => EL.Objects.Null_Object);
end;
exception
when Invalid_Expression =>
null;
end;
-- Check that an exception is raised when the bean is not found.
declare
VE : constant Value_Expression := Create_Expression (V2);
begin
VE.Set_Value (Context => T.Context.all,
Value => EL.Objects.To_Object (Integer (2)));
T.Assert (False, "No exception raised when setting the value expression");
exception
when Invalid_Variable =>
null;
end;
end Test_Invalid_Value_Expression;
-- ------------------------------
-- Info about object sizes
-- ------------------------------
procedure Test_Object_Sizes (T : in out Test) is
pragma Unreferenced (T);
V : EL.Objects.Object;
Expr : EL.Expressions.Expression;
begin
LOG.Info ("EL.Objects.Object size = {0} bytes", Integer'Image (V'Size / 8));
LOG.Info ("EL.Expression.Expression size = {0} bytes", Integer'Image (Expr'Size / 8));
end Test_Object_Sizes;
-- ------------------------------
-- Test some reductions.
-- ------------------------------
procedure Test_Reduce_Expression (T : in out Test) is
Expr : EL.Expressions.Expression;
Red : EL.Expressions.Expression;
Count : constant Positive := 100_000;
begin
declare
S : Util.Measures.Stamp;
begin
for I in 1 .. Count loop
Expr := Create_Expression ("#{bean.name}", T.Context.all);
end loop;
Util.Measures.Report (S, "Create_Expression", Count);
end;
declare
S : Util.Measures.Stamp;
begin
for I in 1 .. Count loop
Red := Reduce_Expression (Expr, T.Context.all);
end loop;
Util.Measures.Report (S, "Reduce_Expression", Count);
T.Assert (not Red.Is_Null, "Null expr after reduce");
T.Assert (not Red.Is_Constant, "Expression was not constant");
end;
Expr := Create_Expression ("#{1+2+3+4+5}", T.Context.all);
Red := Reduce_Expression (Expr, T.Context.all);
T.Assert (not Red.Is_Null, "Null expr after reduce");
T.Assert (Red.Is_Constant, "Expression was not constant");
Util.Tests.Assert_Equals (T, 15,
Util.Beans.Objects.To_Integer (Red.Get_Value (T.Context.all)),
"Invalid reduction");
end Test_Reduce_Expression;
-- ------------------------------
-- Test some reductions.
-- ------------------------------
procedure Test_Reduce_Expression_Variable (T : in out Test) is
Expr : EL.Expressions.Expression;
Red : EL.Expressions.Expression;
Var : aliased EL.Variables.Default.Default_Variable_Mapper;
begin
Expr := Create_Expression (" this is a sting ", T.Context.all);
Var.Set_Variable (To_Unbounded_String ("param_name"), Expr);
T.Context.Set_Variable_Mapper (Var'Unchecked_Access);
Expr := Create_Expression ("|#{param_name}|", T.Context.all);
Red := Reduce_Expression (Expr, T.Context.all);
T.Assert (Red.Is_Constant, "Expression was not constant");
Util.Tests.Assert_Equals (T, "| this is a sting |",
Util.Beans.Objects.To_String (Red.Get_Value (T.Context.all)),
"Invalid reduction");
end Test_Reduce_Expression_Variable;
package Caller is new Util.Test_Caller (Test, "EL.Expressions");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
-- Test_Bean verifies several methods. Register several times
-- to enumerate what is tested.
Caller.Add_Test (Suite, "Object sizes",
Test_Object_Sizes'Access);
Caller.Add_Test (Suite, "Test EL.Beans.Get_Value (constant expressions)",
Test_Simple_Evaluation'Access);
Caller.Add_Test (Suite, "Test EL.Contexts.Set_Variable",
Test_Bean_Evaluation'Access);
Caller.Add_Test (Suite, "Test EL.Beans.Get_Value",
Test_Bean_Evaluation'Access);
Caller.Add_Test (Suite, "Test EL.Expressions.Create_Expression",
Test_Bean_Evaluation'Access);
Caller.Add_Test (Suite, "Test EL.Expressions.Get_Value",
Test_Bean_Evaluation'Access);
Caller.Add_Test (Suite, "Test EL.Expressions.Create_Expression (Parse Error)",
Test_Parse_Error'Access);
Caller.Add_Test (Suite, "Test EL.Expressions.Get_Method_Info",
Test_Method_Evaluation'Access);
Caller.Add_Test (Suite, "Test EL.Expressions.Get_Method_Info (Invalid_method)",
Test_Invalid_Method'Access);
Caller.Add_Test (Suite, "Test EL.Functions.Set_Function (and evaluation)",
Test_Function_Evaluation'Access);
Caller.Add_Test (Suite, "Test EL.Expressions.Set_Value",
Test_Value_Expression'Access);
Caller.Add_Test (Suite, "Test EL.Expressions.Set_Value (raise Invalid_Variable)",
Test_Invalid_Value_Expression'Access);
Caller.Add_Test (Suite, "Test EL.Expressions.Get_Method_Info (Invalid_method)",
Test_Invalid_Method'Access);
Caller.Add_Test (Suite, "Test EL.Functions.Namespaces.Set_Namespace (and evaluation)",
Test_Function_Namespace'Access);
Caller.Add_Test (Suite, "Test EL.Expressions.Reduce_Expression",
Test_Reduce_Expression'Access);
Caller.Add_Test (Suite, "Test EL.Expressions.Reduce_Expression (reduce variable)",
Test_Reduce_Expression_Variable'Access);
Caller.Add_Test (Suite, "Test EL.Methods.Proc_1.Is_Valid",
Test_Method_Is_Valid'Access);
end Add_Tests;
end EL.Expressions.Tests;
|
programs/oeis/192/A192976.asm | karttu/loda | 0 | 176562 | <gh_stars>0
; A192976: Coefficient of x in the reduction by x^2 -> x+1 of the polynomial p(n,x) defined at Comments.
; 0,1,2,10,29,70,148,289,534,950,1645,2794,4680,7761,12778,20930,34157,55598,90332,146577,237630,385006,623517,1009490,1634064,2644705,4280018,6926074,11207549,18135190,29344420,47481409,76827750,124311206,201141133,325454650,526598232,852055473,1378656442,2230714802,3609374285,5840092286,9449469932,15289565745,24739039374,40028608990,64767652413,104796265634,169563922464,274360192705,443924119970,718284317674,1162208442845,1880492765926,3042701214388,4923193986145,7965895206582,12889089198998,20854984412077,33744073617802,54599058036840,88343131661841,142942189706122,231285321375650,374227511089709,605512832473550,979740343571708,1585253176053969,2564993519634654,4150246695697870,6715240215342045
mov $12,$0
mov $14,$0
lpb $14,1
clr $0,12
mov $0,$12
sub $14,1
sub $0,$14
mov $9,$0
mov $11,$0
lpb $11,1
mov $0,$9
sub $11,1
sub $0,$11
mov $5,$0
mov $7,2
lpb $7,1
mov $0,$5
sub $7,1
add $0,$7
sub $0,1
mov $3,$0
sub $0,1
bin $0,$3
cal $3,22131 ; Fibonacci sequence beginning 4, 11.
sub $3,2
cal $0,75349 ; a(1) = 1; first differences follow the pattern 1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,..., i.e., the next n differences are n.
mul $3,$0
mov $1,$3
mov $8,$7
lpb $8,1
mov $6,$1
sub $8,1
lpe
lpe
lpb $5,1
mov $5,0
sub $6,$1
lpe
mov $1,$6
sub $1,4
add $10,$1
lpe
add $13,$10
lpe
mov $1,$13
|
oeis/184/A184044.asm | neoneye/loda-programs | 11 | 104997 | ; A184044: 1/9 the number of (n+1) X 6 0..2 arrays with all 2 X 2 subblocks having the same four values.
; Submitted by <NAME>
; 81,87,97,117,153,225,361,633,1161,2217,4297,8457,16713,33225,66121,131913,263241,525897,1050697,2100297,4198473,8394825,16785481,33566793,67125321,134242377,268468297,536920137,1073807433,2147582025,4295098441,8590131273,17180131401,34360131657,68720001097,137439739977,274878955593,549757386825,1099513725001,2199026401353,4398050705481,8796099313737,17592194433097,35184384671817,70368760954953,140737513521225,281475010265161,562950003753033,1125899973951561,2251799914348617,4503599761588297
mov $3,$0
seq $0,209726 ; 1/4 the number of (n+1) X 8 0..2 arrays with every 2 X 2 subblock having distinct clockwise edge differences.
mov $2,2
add $3,1
pow $2,$3
add $0,$2
mul $0,2
add $0,45
|
llvm/test/tools/llvm-ml/feat00.asm | mkinsner/llvm | 2,338 | 1892 | ; RUN: llvm-ml -m32 %s /Fo - | llvm-readobj --syms - | FileCheck %s --check-prefix=CHECK-OBJ --check-prefix=CHECK-OBJ-NOSAFESEH
; RUN: llvm-ml -m64 %s /Fo - | llvm-readobj --syms - | FileCheck %s --check-prefix=CHECK-OBJ --check-prefix=CHECK-OBJ-NOSAFESEH
; RUN: llvm-ml -m32 -safeseh %s /Fo - | llvm-readobj --syms - | FileCheck %s --check-prefix=CHECK-OBJ --check-prefix=CHECK-OBJ-SAFESEH
; RUN: llvm-ml -m64 -safeseh %s /Fo %t.obj 2>&1 | FileCheck %s --check-prefix=CHECK-SAFESEH64
; RUN: llvm-readobj --syms %t.obj | FileCheck %s --check-prefix=CHECK-OBJ --check-prefix=CHECK-OBJ-NOSAFESEH
; CHECK-SAFESEH64: warning: /safeseh applies only to 32-bit X86 platforms; ignoring.
.code
noop:
ret
end
; CHECK-OBJ: Symbol {
; CHECK-OBJ: Name: @feat.00
; CHECK-OBJ-NOSAFESEH: Value: 2
; CHECK-OBJ-SAFESEH: Value: 3
; CHECK-OBJ-NEXT: Section: IMAGE_SYM_ABSOLUTE
; CHECK-OBJ-NEXT: BaseType: Null
; CHECK-OBJ-NEXT: ComplexType: Null
; CHECK-OBJ-NEXT: StorageClass: External
; CHECK-OBJ-NEXT: AuxSymbolCount: 0
; CHECK-OBJ-NEXT: }
|
bb-runtimes/runtimes/ravenscar-full-stm32g474/gnat/a-exstat.adb | JCGobbi/Nucleo-STM32G474RE | 0 | 23414 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- ADA.EXCEPTIONS.STREAM_ATTRIBUTES --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2021, 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. --
-- --
------------------------------------------------------------------------------
pragma Warnings (Off);
-- Allow withing of non-Preelaborated units in Ada 2005 mode where this
-- package will be categorized as Preelaborate. See AI-362 for details.
-- It is safe in the context of the run-time to violate the rules.
with System.Exception_Table; use System.Exception_Table;
with System.Storage_Elements; use System.Storage_Elements;
pragma Warnings (On);
separate (Ada.Exceptions)
package body Stream_Attributes is
-------------------
-- EId_To_String --
-------------------
function EId_To_String (X : Exception_Id) return String is
begin
if X = Null_Id then
return "";
else
return Exception_Name (X);
end if;
end EId_To_String;
------------------
-- EO_To_String --
------------------
-- We use the null string to represent the null occurrence, otherwise we
-- output the Untailored_Exception_Information string for the occurrence.
function EO_To_String (X : Exception_Occurrence) return String is
begin
if X.Id = Null_Id then
return "";
else
return Exception_Data.Untailored_Exception_Information (X);
end if;
end EO_To_String;
-------------------
-- String_To_EId --
-------------------
function String_To_EId (S : String) return Exception_Id is
begin
if S = "" then
return Null_Id;
else
return Exception_Id (Internal_Exception (S));
end if;
end String_To_EId;
------------------
-- String_To_EO --
------------------
function String_To_EO (S : String) return Exception_Occurrence is
From : Natural;
To : Integer;
X : aliased Exception_Occurrence;
-- This is the exception occurrence we will create
procedure Bad_EO;
pragma No_Return (Bad_EO);
-- Signal bad exception occurrence string
procedure Next_String;
-- On entry, To points to last character of previous line of the
-- message, terminated by LF. On return, From .. To are set to
-- specify the next string, or From > To if there are no more lines.
procedure Bad_EO is
begin
Raise_Exception
(Program_Error'Identity,
"bad exception occurrence in stream input");
-- The following junk raise of Program_Error is required because
-- this is a No_Return procedure, and unfortunately Raise_Exception
-- can return (this particular call can't, but the back end is not
-- clever enough to know that).
raise Program_Error;
end Bad_EO;
procedure Next_String is
begin
From := To + 2;
if From < S'Last then
To := From + 1;
while To < S'Last - 1 loop
if To >= S'Last then
Bad_EO;
elsif S (To + 1) = ASCII.LF then
exit;
else
To := To + 1;
end if;
end loop;
end if;
end Next_String;
-- Start of processing for String_To_EO
begin
if S = "" then
return Null_Occurrence;
end if;
To := S'First - 2;
Next_String;
if S (From .. From + 6) /= "raised " then
Bad_EO;
end if;
declare
Name_Start : constant Positive := From + 7;
begin
From := Name_Start + 1;
while From < To and then S (From) /= ' ' loop
From := From + 1;
end loop;
X.Id :=
Exception_Id (Internal_Exception (S (Name_Start .. From - 1)));
end;
if From <= To then
if S (From .. From + 2) /= " : " then
Bad_EO;
end if;
X.Msg_Length := To - From - 2;
X.Msg (1 .. X.Msg_Length) := S (From + 3 .. To);
else
X.Msg_Length := 0;
end if;
Next_String;
X.Pid := 0;
if From <= To and then S (From) = 'P' then
if S (From .. From + 3) /= "PID:" then
Bad_EO;
end if;
From := From + 5; -- skip past PID: space
while From <= To loop
X.Pid := X.Pid * 10 +
(Character'Pos (S (From)) - Character'Pos ('0'));
From := From + 1;
end loop;
Next_String;
end if;
X.Num_Tracebacks := 0;
if From <= To then
if S (From .. To) /= "Call stack traceback locations:" then
Bad_EO;
end if;
Next_String;
loop
exit when From > To;
declare
Ch : Character;
C : Integer_Address;
N : Integer_Address;
begin
if S (From) /= '0'
or else S (From + 1) /= 'x'
then
Bad_EO;
else
From := From + 2;
end if;
C := 0;
while From <= To loop
Ch := S (From);
if Ch in '0' .. '9' then
N :=
Character'Pos (S (From)) - Character'Pos ('0');
elsif Ch in 'a' .. 'f' then
N :=
Character'Pos (S (From)) - Character'Pos ('a') + 10;
elsif Ch = ' ' then
From := From + 1;
exit;
else
Bad_EO;
end if;
C := C * 16 + N;
From := From + 1;
end loop;
if X.Num_Tracebacks = Max_Tracebacks then
Bad_EO;
end if;
X.Num_Tracebacks := X.Num_Tracebacks + 1;
X.Tracebacks (X.Num_Tracebacks) :=
TBE.TB_Entry_For (To_Address (C));
end;
end loop;
end if;
-- The occurrence we're crafting is not currently being
-- propagated.
X.Machine_Occurrence := System.Null_Address;
-- If an exception was converted to a string, it must have
-- already been raised, so flag it accordingly and we are done.
X.Exception_Raised := True;
return X;
end String_To_EO;
end Stream_Attributes;
|
day17/src/day.adb | jwarwick/aoc_2020 | 3 | 18828 | <filename>day17/src/day.adb<gh_stars>1-10
-- AoC 2020, Day 17
with Ada.Text_IO;
package body Day is
package TIO renames Ada.Text_IO;
function location_hash(key : in Location) return Hash_Type is
begin
return Hash_Type(abs((key.x * 137) + (key.y * 149) + (key.z * 163) + (key.w * 13)));
end location_hash;
procedure parse_line(line : in String; y : in Natural; g : in out Grid_Set.Set) is
x : Natural := 0;
begin
for c of line loop
if c = '#' then
g.insert(Location'(X => x, Y => y, Z=> 0, W => 0));
end if;
x := x + 1;
end loop;
end parse_line;
function load_file(filename : in String) return Grid_Set.Set is
file : TIO.File_Type;
g : Grid_Set.Set := Empty_Set;
y : Natural := 0;
begin
TIO.open(File => file, Mode => TIO.In_File, Name => filename);
while not TIO.end_of_file(file) loop
parse_line(TIO.get_line(file), y, g);
y := y + 1;
end loop;
TIO.close(file);
return g;
end load_file;
pragma Warnings (Off);
procedure put_line(l : in Location) is
pragma Warnings (On);
begin
TIO.put_line(l.x'IMAGE & "," & l.y'IMAGE & "," & l.z'IMAGE & "," & l.w'IMAGE);
end put_line;
function neighbors(l : in Location) return Grid_Set.Set is
g : Grid_Set.Set := Empty_Set;
begin
for x in l.x-1 .. l.x+1 loop
for y in l.y-1 .. l.y+1 loop
for z in l.z-1 .. l.z+1 loop
g.include(Location'(X=>x, Y=>y, Z=>z, W=>0));
end loop;
end loop;
end loop;
g.exclude(l);
return g;
end neighbors;
function neighbors_4d(l : in Location) return Grid_Set.Set is
g : Grid_Set.Set := Empty_Set;
begin
for x in l.x-1 .. l.x+1 loop
for y in l.y-1 .. l.y+1 loop
for z in l.z-1 .. l.z+1 loop
for w in l.w-1 .. l.w+1 loop
g.include(Location'(X=>x, Y=>y, Z=>z, W=>w));
end loop;
end loop;
end loop;
end loop;
g.exclude(l);
return g;
end neighbors_4d;
function active(to_check : in Grid_Set.Set; active : in Grid_Set.Set) return Natural is
cnt : Natural := 0;
begin
for l of to_check loop
if active.contains(l) then
cnt := cnt + 1;
end if;
end loop;
return cnt;
end active;
procedure step(g : in out Grid_Set.Set; fourd : in Boolean) is
old_grid : constant Grid_Set.Set := g;
new_grid : Grid_Set.Set := Empty_Set;
all_possible : Grid_Set.Set := Empty_Set;
begin
for p of old_grid loop
all_possible.include(p);
if fourd then
all_possible := all_possible or neighbors_4d(p);
else
all_possible := all_possible or neighbors(p);
end if;
end loop;
for p of all_possible loop
declare
neighs : Grid_Set.Set := Empty_Set;
active_neigh : Natural := 0;
was_active : constant Boolean := old_grid.contains(p);
begin
if fourd then
neighs := neighbors_4d(p);
else
neighs := neighbors(p);
end if;
active_neigh := active(neighs, old_grid);
if was_active then
if active_neigh = 2 or active_neigh = 3 then
new_grid.include(p);
end if;
else
if active_neigh = 3 then
new_grid.include(p);
end if;
end if;
end;
end loop;
g := new_grid;
end step;
function active_count(g : in Grid_Set.Set; cycles : in Natural) return Natural is
grid : Grid_Set.Set := g;
begin
for i in 1..cycles loop
step(grid, false);
end loop;
return Natural(grid.length);
end active_count;
function active_count_4d(g : in Grid_Set.Set; cycles : in Natural) return Natural is
grid : Grid_Set.Set := g;
begin
for i in 1..cycles loop
step(grid, true);
end loop;
return Natural(grid.length);
end active_count_4d;
end Day;
|
data/github.com/xorpd/asm_prog_ex/90cd6c43921349330b6b44ae19e162b08524c1c1/4_basic_assembly/0_branching/4_structured_branching/answers/2_write_code/0.asm | ajnavarro/language-dataset | 9 | 241141 | <gh_stars>1-10
; 0. Write a program that takes the number n as input. Then it prints all the
; numbers x below n that have exactly 2 different integral divisors (Besides 1
; and x).
;
; For example: 15 is such a number. It is divisible by 1,3,5,15. (Here 3 and 5
; are the two different divisiors, besides 1 and 15).
;
; However, 4 is not such a number. It is divisible by 1,2,4
;
format PE console
entry start
include 'win32a.inc'
; ===============================================
section '.text' code readable executable
start:
call read_hex
mov esi, eax ; user input
mov ebx, 2 ; counter for x, x must be at least 3 or higher (inc in first iteration)
next_integral:
inc ebx
mov ecx, 2 ; counter for divisor, at least 2
mov edi, 0 ; counter for integral divisors
try_division:
mov eax, ebx
mov edx, 0
div ecx
cmp edx, 0 ; check if there is a remainder
jnz we_have_remainder
inc edi ; no remainder, so increase the counter for integral diviors
we_have_remainder:
inc ecx
cmp ebx, ecx
jnz try_division
cmp edi, 2 ; check if we have exactely 2 divisors
jnz no_print_integral
mov eax, ebx
call print_eax
no_print_integral:
cmp esi, ebx ; check if our counter ebx has reached the user limit esi
jnz next_integral
; Exit the process:
push 0
call [ExitProcess]
include 'training.inc'
|
rom0/reportz.asm | nagydani/zx-rom-mods | 15 | 25070 | REPORT: CP MAX_ERR
JR C,REPORTZ
SUB $81
LD (ERR_NR),A
EX DE,HL
REPORTL:LD A,(DE) ; Find end of command line
INC DE
CP $80
JR Z,MESSAGE
CP $0E
JR NZ,REPORTL
INC DE
INC DE
INC DE
INC DE
INC DE
JR REPORTL
STDERR_MSG:
XOR A
PUSH DE
RST $30
DEFW L1601
POP DE
JR MESSAGE
REPORTZ:SUB $1C
LD B,A
INC B
ADD "S"
RST $30
DEFW L0010
LD A," "
RST $30
DEFW L0010
LD DE,REPORTS
TOKEN: LD A,(DE)
ADD A,A
INC DE
JR NC,TOKEN
RET Z ; end of token table
DJNZ TOKEN
TOKEN_S:LD A,(DE)
CP " "
JR NZ,MSGNSP
MSG_SP: BIT 0,(IY+$01)
JR NZ,MSGSKIP
MESSAGE:LD A,(DE)
MSGNSP: AND $7F
RST $30
DEFW L0C3B ; PO-SAVE
LD A,(DE)
MSGSKIP:INC DE
ADD A,A
JR NC,MESSAGE
RES 0,(IY+$01) ; allow leading space
CP $40 ; 2 * " "
RET NZ
INC A ; clear Z
NOLEAD: SET 0,(IY+$01) ; suppress leading space
RET
SYNTAX_Z:
BIT 7,(IY+1)
RET
UNSTACK_Z:
CALL SYNTAX_Z
POP HL
RET Z
JP (HL)
|
Framework/trackmo/framework/partlauncher.asm | kosmonautdnb/TheLandsOfZador | 0 | 4751 |
launchpart SUBROUTINE
;
; ; quelle
; clc
; lda load_start
; sta .reloc_addr1+1
; sta .reloc_addr2+1
; adc #$02
; sta .copysrc+1
; lda load_start+1
; sta .reloc_addr1+2
; sta .reloc_addr2+2
; adc #$00
; sta .copysrc+2
;
; ; ziel mit "safety-offset", exomizer will das so
; ldx #$00
; sec
;.reloc_addr1
; lda $1234,x
; sta .runpart+1
; sbc #SAFETY_OFFSET
; sta .copydst+1
; inx
;.reloc_addr2
; lda $1234,x
; sta .runpart+2
; sbc #$00
; sta .copydst+2
;
; ; endmarke, exomizer nimmt das zum decrunchen
; sec
; lda load_end
; sbc load_start
; sta .decrunch_lo+1
; lda load_end+1
; sbc load_start+1
; sta .decrunch_hi+1
;
; clc
; lda .decrunch_lo+1
; adc .copydst+1
; sta .decrunch_lo+1
; lda .decrunch_hi+1
; adc .copydst+2
; sta .decrunch_hi+1
;
; sec
; lda .decrunch_lo+1
; sbc #$02
; sta .decrunch_lo+1
; lda .decrunch_hi+1
; sbc #$00
; sta .decrunch_hi+1
;
; lda .decrunch_hi
; clc
; adc #$01
; sta .copylen+1
;
;
; ldy #$00
;.0
;.copysrc
; lda $2000,y
;.copydst
; sta $1000,y
; iny
; bne .0
; inc .copysrc+2
; inc .copydst+2
; lda .copydst+2
;.copylen
; cmp #$00
; bne .0
;
;
;.decrunch_lo
; ldx #$00
;.decrunch_hi
; ldy #$00
; jsr decrunch
;
;.runpart
; jmp $1ffd
|
examples/uptodate/C.agda | cruhland/agda | 1,989 | 10651 | <gh_stars>1000+
-- This module contains various line-ending characters in order
-- to test that they don't affect module source hash calculation.
module C where
-- CR --
--
-- LF --
--
-- CRLF --
--
-- LFCR --
--
-- FF ----
-- NEXT LINE --
--
-- LINE SEPARATOR --
--
-- PARAGRAPH SEPARATOR --
--
|
oeis/024/A024903.asm | neoneye/loda-programs | 11 | 14346 | <reponame>neoneye/loda-programs<gh_stars>10-100
; A024903: Numbers k such that 7*k - 4 is prime.
; Submitted by <NAME>(s4)
; 1,3,5,9,11,15,23,29,33,35,39,41,45,51,53,59,69,75,81,83,89,93,95,111,113,119,123,135,141,143,149,159,161,165,171,179,183,185,189,195,209,213,221,225,231,233,239,243,251,261,269,273,279,299,305,321,335,341,345,353,365,369,371,375,381,383,389,399,401,413,423,425,429,435,441,453,455,459,465,473,485,491,495,503,509,521,525,533,539,543,551,555,561,573,575,579,585,591,603,605
mov $1,2
mov $2,$0
pow $2,2
lpb $2
mov $3,$1
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,14
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,1
lpe
mov $0,$1
div $0,7
add $0,1
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c35a05d.ada | best08618/asylo | 7 | 14057 | -- C35A05D.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT FOR FIXED POINT TYPES THE FORE AND AFT ATTRIBUTES YIELD
-- THE CORRECT VALUES.
-- CASE D: TYPES TYPICAL OF APPLICATIONS USING FIXED POINT ARITHMETIC.
-- WRG 8/14/86
WITH REPORT; USE REPORT;
PROCEDURE C35A05D IS
PI : CONSTANT := 3.14159_26535_89793_23846;
TWO_PI : CONSTANT := 2 * PI;
HALF_PI : CONSTANT := PI / 2;
MM : CONSTANT := 23;
-- THE NAME OF EACH TYPE OR SUBTYPE ENDS WITH THAT TYPE'S
-- 'MANTISSA VALUE.
TYPE MICRO_ANGLE_ERROR_M15 IS
DELTA 16.0 RANGE -(2.0 ** 19) .. 2.0 ** 19;
TYPE TRACK_RANGE_M15 IS
DELTA 0.125 RANGE -(2.0 ** 12) .. 2.0 ** 12;
TYPE SECONDS_MM IS
DELTA 2.0 ** (8 - MM) RANGE -(2.0 ** 8) .. 2.0 ** 8;
TYPE RANGE_CELL_MM IS
DELTA 2.0 ** (-5)
RANGE -(2.0 ** (MM - 5) ) .. 2.0 ** (MM - 5);
TYPE PIXEL_M10 IS DELTA 1.0 / 1024.0 RANGE 0.0 .. 1.0;
TYPE RULER_M8 IS DELTA 1.0 / 16.0 RANGE 0.0 .. 12.0;
TYPE HOURS_M16 IS DELTA 24.0 * 2.0 ** (-15) RANGE 0.0 .. 24.0;
TYPE MILES_M16 IS DELTA 3000.0 * 2.0 ** (-15) RANGE 0.0 .. 3000.0;
TYPE SYMMETRIC_DEGREES_M7 IS
DELTA 2.0 RANGE -180.0 .. 180.0;
TYPE NATURAL_DEGREES_M15 IS
DELTA 2.0 ** (-6) RANGE 0.0 .. 360.0;
TYPE SYMMETRIC_RADIANS_M16 IS
DELTA PI * 2.0 ** (-15) RANGE -PI .. PI;
TYPE NATURAL_RADIANS_M8 IS
DELTA TWO_PI * 2.0 ** ( -7) RANGE 0.0 .. TWO_PI;
-------------------------------------------------------------------
SUBTYPE ST_MILES_M8 IS MILES_M16
DELTA 3000.0 * 2.0 ** (-15) RANGE 0.0 .. 10.0;
SUBTYPE ST_NATURAL_DEGREES_M11 IS NATURAL_DEGREES_M15
DELTA 0.25 RANGE 0.0 .. 360.0;
SUBTYPE ST_SYMMETRIC_RADIANS_M8 IS SYMMETRIC_RADIANS_M16
DELTA HALF_PI * 2.0 ** (-7) RANGE -HALF_PI .. HALF_PI;
-------------------------------------------------------------------
PROCEDURE CHECK_FORE_AND_AFT
(NAME : STRING;
ACTUAL_FORE : INTEGER; CORRECT_FORE : POSITIVE;
ACTUAL_AFT : INTEGER; CORRECT_AFT : POSITIVE) IS
BEGIN
IF ACTUAL_FORE /= IDENT_INT (CORRECT_FORE) THEN
FAILED (NAME & "'FORE =" & INTEGER'IMAGE(ACTUAL_FORE) );
END IF;
IF ACTUAL_AFT /= IDENT_INT (CORRECT_AFT) THEN
FAILED (NAME & "'AFT =" & INTEGER'IMAGE(ACTUAL_AFT) );
END IF;
END CHECK_FORE_AND_AFT;
BEGIN
TEST ("C35A05D", "CHECK THAT FOR FIXED POINT TYPES THE FORE AND " &
"AFT ATTRIBUTES YIELD THE CORRECT VALUES - " &
"TYPICAL TYPES");
CHECK_FORE_AND_AFT ("MICRO_ANGLE_ERROR_M15",
MICRO_ANGLE_ERROR_M15'FORE, 7,
MICRO_ANGLE_ERROR_M15'AFT, 1);
CHECK_FORE_AND_AFT ("TRACK_RANGE_M15", TRACK_RANGE_M15'FORE, 5,
TRACK_RANGE_M15'AFT, 1);
CHECK_FORE_AND_AFT ("SECONDS_MM", SECONDS_MM'FORE, 4,
SECONDS_MM'AFT, 5);
CHECK_FORE_AND_AFT ("RANGE_CELL_MM", RANGE_CELL_MM'FORE, 7,
RANGE_CELL_MM'AFT, 2);
CHECK_FORE_AND_AFT ("PIXEL_M10", PIXEL_M10'FORE, 2,
PIXEL_M10'AFT, 4);
CHECK_FORE_AND_AFT ("RULER_M8", RULER_M8'FORE, 3,
RULER_M8'AFT, 2);
CHECK_FORE_AND_AFT ("HOURS_M16", HOURS_M16'FORE, 3,
HOURS_M16'AFT, 4);
CHECK_FORE_AND_AFT ("MILES_M16", MILES_M16'FORE, 5,
MILES_M16'AFT, 2);
CHECK_FORE_AND_AFT ("SYMMETRIC_DEGREES_M7",
SYMMETRIC_DEGREES_M7'FORE, 4,
SYMMETRIC_DEGREES_M7'AFT, 1);
CHECK_FORE_AND_AFT ("NATURAL_DEGREES_M15",
NATURAL_DEGREES_M15'FORE, 4,
NATURAL_DEGREES_M15'AFT, 2);
CHECK_FORE_AND_AFT ("SYMMETRIC_RADIANS_M16",
SYMMETRIC_RADIANS_M16'FORE, 2,
SYMMETRIC_RADIANS_M16'AFT, 5);
CHECK_FORE_AND_AFT ("NATURAL_RADIANS_M8",
NATURAL_RADIANS_M8'FORE, 2,
NATURAL_RADIANS_M8'AFT, 2);
CHECK_FORE_AND_AFT ("ST_MILES_M8", ST_MILES_M8'FORE, 3,
ST_MILES_M8'AFT, 2);
CHECK_FORE_AND_AFT ("ST_NATURAL_DEGREES_M11",
ST_NATURAL_DEGREES_M11'FORE, 4,
ST_NATURAL_DEGREES_M11'AFT, 1);
CHECK_FORE_AND_AFT ("ST_SYMMETRIC_RADIANS_M8",
ST_SYMMETRIC_RADIANS_M8'FORE, 2,
ST_SYMMETRIC_RADIANS_M8'AFT, 2);
RESULT;
END C35A05D;
|
src/Control/Monad/State.agda | L-TChen/agda-prelude | 111 | 6095 | <filename>src/Control/Monad/State.agda
module Control.Monad.State where
open import Prelude
open import Control.Monad.Zero
open import Control.Monad.Identity
open import Control.Monad.Transformer
record StateT {a} (S : Set a) (M : Set a → Set a) (A : Set a) : Set a where
no-eta-equality
constructor stateT
field runStateT : S → M (A × S)
open StateT public
-- Instances --
module _ {a} {S : Set a} {M : Set a → Set a} where
instance
FunctorStateT : {{_ : Functor M}} → Functor {a = a} (StateT S M)
runStateT (fmap {{FunctorStateT}} f m) s = first f <$> runStateT m s
FunctorZeroStateT : {{_ : FunctorZero M}} → FunctorZero {a = a} (StateT S M)
runStateT (empty {{FunctorZeroStateT}}) s = empty
AlternativeStateT : {{_ : Alternative M}} → Alternative {a = a} (StateT S M)
runStateT (_<|>_ {{AlternativeStateT}} x y) s = runStateT x s <|> runStateT y s
module _ {{_ : Monad M}} where
private
bindStateT : ∀ {A B} → StateT S M A → (A → StateT S M B) → StateT S M B
runStateT (bindStateT m f) s = runStateT m s >>= λ r → uncurry (runStateT ∘ f) r
instance
ApplicativeStateT : Applicative {a = a} (StateT S M)
runStateT (pure {{ApplicativeStateT}} x) s = pure (x , s)
_<*>_ {{ApplicativeStateT}} = monadAp bindStateT
MonadStateT : Monad {a = a} (StateT S M)
_>>=_ {{MonadStateT}} = bindStateT
liftStateT : {A : Set a} → M A → StateT S M A
runStateT (liftStateT m) s = m >>= λ x → return (x , s)
gets : {A : Set a} → (S → A) → StateT S M A
runStateT (gets f) s = return (f s , s)
modify : (S → S) → StateT S M S
runStateT (modify f) s = return (s , f s)
get : StateT S M S
get = gets id
put : S → StateT S M S
put s = modify (const s)
instance
TransformerStateT : ∀ {a} {S : Set a} → Transformer (StateT S)
lift {{TransformerStateT}} = liftStateT
State : ∀ {a} (S : Set a) (A : Set a) → Set a
State S = StateT S Identity
runState : ∀ {a} {S : Set a} {A : Set a} → State S A → S → A × S
runState m s = runIdentity (runStateT m s)
execState : ∀ {a} {S : Set a} {A : Set a} → State S A → S → S
execState m s = snd (runState m s)
|
alloy4fun_models/trashltl/models/17/qibeEAzYyikrNrE5s.als | Kaixi26/org.alloytools.alloy | 0 | 4495 | open main
pred idqibeEAzYyikrNrE5s_prop18 {
all f : Protected | always (f not in Protected since f in Trash)
}
pred __repair { idqibeEAzYyikrNrE5s_prop18 }
check __repair { idqibeEAzYyikrNrE5s_prop18 <=> prop18o } |
bb-runtimes/runtimes/ravenscar-full-stm32g474/gnat/s-memory.adb | JCGobbi/Nucleo-STM32G474RE | 0 | 10162 | <gh_stars>0
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . M E M O R Y --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2021, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the simplified implementation of this package, for use with a
-- configurable run-time library.
-- This implementation assumes that the underlying malloc/free/realloc
-- implementation is *not* thread safe, and thus, explicit lock is required.
with Ada.Exceptions;
with System.Soft_Links;
package body System.Memory is
use Ada.Exceptions;
use System.Soft_Links;
function c_malloc (Size : size_t) return System.Address;
pragma Import (C, c_malloc, "malloc");
procedure c_free (Ptr : System.Address);
pragma Import (C, c_free, "free");
function c_realloc
(Ptr : System.Address; Size : size_t) return System.Address;
pragma Import (C, c_realloc, "realloc");
-----------
-- Alloc --
-----------
function Alloc (Size : size_t) return System.Address is
Result : System.Address;
Actual_Size : size_t := Size;
begin
if Size = size_t'Last then
Raise_Exception (Storage_Error'Identity, "object too large");
end if;
-- Change size from zero to non-zero. We still want a proper pointer
-- for the zero case because pointers to zero length objects have to
-- be distinct, but we can't just go ahead and allocate zero bytes,
-- since some malloc's return zero for a zero argument.
if Size = 0 then
Actual_Size := 1;
end if;
Lock_Task.all;
Result := c_malloc (Actual_Size);
Unlock_Task.all;
if Result = System.Null_Address then
Raise_Exception (Storage_Error'Identity, "heap exhausted");
end if;
return Result;
end Alloc;
----------
-- Free --
----------
procedure Free (Ptr : System.Address) is
begin
Lock_Task.all;
c_free (Ptr);
Unlock_Task.all;
end Free;
-------------
-- Realloc --
-------------
function Realloc
(Ptr : System.Address;
Size : size_t)
return System.Address
is
Result : System.Address;
begin
if Size = size_t'Last then
Raise_Exception (Storage_Error'Identity, "object too large");
end if;
Lock_Task.all;
Result := c_realloc (Ptr, Size);
Unlock_Task.all;
if Result = System.Null_Address then
Raise_Exception (Storage_Error'Identity, "heap exhausted");
end if;
return Result;
end Realloc;
end System.Memory;
|
programs/oeis/206/A206373.asm | karttu/loda | 1 | 92036 | <reponame>karttu/loda
; A206373: (14*4^n + 1)/3.
; 5,19,75,299,1195,4779,19115,76459,305835,1223339,4893355,19573419,78293675,313174699,1252698795,5010795179,20043180715,80172722859,320690891435,1282763565739,5131054262955,20524217051819,82096868207275,328387472829099,1313549891316395
mov $1,4
pow $1,$0
div $1,3
mul $1,14
add $1,5
|
programs/oeis/036/A036918.asm | neoneye/loda | 22 | 21670 | ; A036918: a(n) = floor(e*(n-1)*(n-1)!)).
; 0,2,10,48,260,1630,11742,95900,876808,8877690,98641010,1193556232,15624736140,220048367318,3317652307270,53319412081140,909984632851472,16436597430879730,313262209859119578,6282647653285676000
sub $1,$0
mov $2,$0
lpb $2
mul $1,$2
sub $0,$1
sub $2,1
lpe
|
Cubical/Algebra/Group/Action.agda | Schippmunk/cubical | 0 | 327 | <gh_stars>0
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Group.Action where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Structure
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.Morphism
open import Cubical.Algebra.Group.Properties
open import Cubical.Algebra.Group.Notation
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Structures.LeftAction
open import Cubical.Structures.Axioms
open import Cubical.Structures.Macro
open import Cubical.Structures.Auto
open import Cubical.Data.Sigma
private
variable
ℓ ℓ' : Level
record IsGroupAction (G : Group {ℓ = ℓ})
(H : Group {ℓ = ℓ'})
(_α_ : LeftActionStructure ⟨ G ⟩ ⟨ H ⟩) : Type (ℓ-max ℓ ℓ') where
constructor isgroupaction
open GroupNotationG G
field
isHom : (g : ⟨ G ⟩) → isGroupHom H H (g α_)
identity : (h : ⟨ H ⟩) → 0ᴳ α h ≡ h
assoc : (g g' : ⟨ G ⟩) → (h : ⟨ H ⟩) → (g +ᴳ g') α h ≡ g α (g' α h)
record GroupAction (G : Group {ℓ}) (H : Group {ℓ'}): Type (ℓ-suc (ℓ-max ℓ ℓ')) where
constructor groupaction
field
_α_ : LeftActionStructure ⟨ G ⟩ ⟨ H ⟩
isGroupAction : IsGroupAction G H _α_
module ActionΣTheory {ℓ ℓ' : Level} where
module _ (G : Group {ℓ}) (H : Group {ℓ'}) (_α_ : LeftActionStructure ⟨ G ⟩ ⟨ H ⟩) where
open GroupNotationG G
IsGroupActionΣ : Type (ℓ-max ℓ ℓ')
IsGroupActionΣ = ((g : ⟨ G ⟩) → isGroupHom H H (g α_))
× ((h : ⟨ H ⟩) → 0ᴳ α h ≡ h)
× ((g g' : ⟨ G ⟩) → (h : ⟨ H ⟩) → (g +ᴳ g') α h ≡ g α (g' α h))
isPropIsGroupActionΣ : isProp IsGroupActionΣ
isPropIsGroupActionΣ = isPropΣ isPropIsHom λ _ → isPropΣ isPropIdentity λ _ → isPropAssoc
where
isPropIsHom = isPropΠ (λ g → isPropIsGroupHom H H)
isPropIdentity = isPropΠ (λ h → GroupStr.is-set (snd H) (0ᴳ α h) h)
isPropAssoc = isPropΠ3 (λ g g' h → GroupStr.is-set (snd H) ((g +ᴳ g') α h) (g α (g' α h)))
IsGroupAction→IsGroupActionΣ : IsGroupAction G H _α_ → IsGroupActionΣ
IsGroupAction→IsGroupActionΣ (isgroupaction isHom identity assoc) = isHom , identity , assoc
IsGroupActionΣ→IsGroupAction : IsGroupActionΣ → IsGroupAction G H _α_
IsGroupActionΣ→IsGroupAction (isHom , identity , assoc) = isgroupaction isHom identity assoc
IsGroupActionΣIso : Iso (IsGroupAction G H _α_) IsGroupActionΣ
Iso.fun IsGroupActionΣIso = IsGroupAction→IsGroupActionΣ
Iso.inv IsGroupActionΣIso = IsGroupActionΣ→IsGroupAction
Iso.rightInv IsGroupActionΣIso = λ _ → refl
Iso.leftInv IsGroupActionΣIso = λ _ → refl
open ActionΣTheory
isPropIsGroupAction : {ℓ ℓ' : Level }
(G : Group {ℓ}) (H : Group {ℓ'})
(_α_ : LeftActionStructure ⟨ G ⟩ ⟨ H ⟩)
→ isProp (IsGroupAction G H _α_)
isPropIsGroupAction G H _α_ = isOfHLevelRespectEquiv 1
(invEquiv (isoToEquiv (IsGroupActionΣIso G H _α_)))
(isPropIsGroupActionΣ G H _α_)
module ActionNotationα {N : Group {ℓ}} {H : Group {ℓ'}} (Act : GroupAction H N) where
_α_ = GroupAction._α_ Act
private
isGroupAction = GroupAction.isGroupAction Act
α-id = IsGroupAction.identity isGroupAction
α-hom = IsGroupAction.isHom isGroupAction
α-assoc = IsGroupAction.assoc isGroupAction
module ActionLemmas {G : Group {ℓ}} {H : Group {ℓ'}} (Act : GroupAction G H) where
open ActionNotationα {N = H} {H = G} Act
open GroupNotationᴴ H
open GroupNotationG G
open MorphismLemmas {G = H} {H = H}
open GroupLemmas
abstract
actOnUnit : (g : ⟨ G ⟩) → g α 0ᴴ ≡ 0ᴴ
actOnUnit g = mapId (grouphom (g α_) (α-hom g))
actOn-Unit : (g : ⟨ G ⟩) → g α (-ᴴ 0ᴴ) ≡ 0ᴴ
actOn-Unit g = (cong (g α_) (invId H)) ∙ actOnUnit g
actOn- : (g : ⟨ G ⟩) (h : ⟨ H ⟩) → g α (-ᴴ h) ≡ -ᴴ (g α h)
actOn- g h = mapInv (grouphom (g α_) (α-hom g)) h
-idAct : (h : ⟨ H ⟩) → (-ᴳ 0ᴳ) α h ≡ h
-idAct h = (cong (_α h) (invId G)) ∙ (α-id h)
-- Examples
-- left adjoint action of a group on a normal subgroup
|
programs/oeis/066/A066665.asm | neoneye/loda | 22 | 178086 | ; A066665: a(n) = #{(x,y) | 0<=y<=x<=n and x+y is prime}.
; 1,3,5,7,9,11,14,16,19,23,27,31,35,38,42,47,52,56,61,65,70,76,82,88,94,100,107,114,121,128,136,143,150,158,166,175,185,194,203,213,223,233,243,252,262,272,282,291,301,311,322,334,346
mov $2,$0
add $2,1
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,35250 ; Number of primes between n and 2n (inclusive).
add $1,$0
lpe
mov $0,$1
|
src/tests/norx_check_padding.adb | jhumphry/SPARK_NORX | 9 | 27521 | <filename>src/tests/norx_check_padding.adb
-- NORX_Check_Padding
-- Ensure that headers and trailers of different lengths are accepted
-- and messages of different lengths correctly decrypted (to check padding)
-- Copyright (c) 2016, <NAME> - see LICENSE file for details
with Ada.Text_IO;
use Ada.Text_IO;
with Test_Input_Lengths;
with NORX0841;
with NORX1641;
with NORX3241;
with NORX3261;
with NORX6441;
with NORX6461;
procedure NORX_Check_Padding is
procedure NORX0841_Test is new Test_Input_Lengths(Norx_Package => NORX0841);
procedure NORX1641_Test is new Test_Input_Lengths(Norx_Package => NORX1641);
procedure NORX3241_Test is new Test_Input_Lengths(Norx_Package => NORX3241);
procedure NORX3261_Test is new Test_Input_Lengths(Norx_Package => NORX3261);
procedure NORX6441_Test is new Test_Input_Lengths(Norx_Package => NORX6441);
procedure NORX6461_Test is new Test_Input_Lengths(Norx_Package => NORX6461);
begin
Put_Line("Checking padding and input-length flexibility for NORX routines");
New_Line;
Put("Header, message and trailer lengths from 0-2000 are checked for " &
"correct authenticated encryption and decryption. While the length " &
"of one input is being varied, the lengths of the others are held " &
"constant.");
New_Line;
Put_Line("----------");
Put_Line("NORX08-4-1");
Put_Line("----------");
NORX0841_Test;
Put_Line("----------");
Put_Line("NORX16-4-1");
Put_Line("----------");
NORX1641_Test;
Put_Line("----------");
Put_Line("NORX32-4-1");
Put_Line("----------");
NORX3241_Test;
Put_Line("----------");
Put_Line("NORX32-6-1");
Put_Line("----------");
NORX3261_Test;
Put_Line("----------");
Put_Line("NORX64-4-1");
Put_Line("----------");
NORX6441_Test;
Put_Line("----------");
Put_Line("NORX64-6-1");
Put_Line("----------");
NORX6461_Test;
end NORX_Check_Padding;
|
source/lexer/webidl-tokens.ads | reznikmm/webidl | 0 | 11789 | -- SPDX-FileCopyrightText: 2010-2021 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with League.Strings;
package WebIDL.Tokens is
pragma Preelaborate;
type Token_Kind is
('(', ')',
',', '-', '.', ':', ';',
'<', '=', '>',
'?',
'[', ']',
'{', '}',
Ellipsis_Token,
Any_Token,
Async_Token,
Attribute_Token,
Bigint_Token,
Boolean_Token,
Byte_Token,
Callback_Token,
Const_Token,
Constructor_Token,
Deleter_Token,
Dictionary_Token,
Double_Token,
Enum_Token,
False_Token,
Float_Token,
Getter_Token,
Includes_Token,
Inherit_Token,
Interface_Token,
Iterable_Token,
Long_Token,
Maplike_Token,
Mixin_Token,
Namespace_Token,
Null_Token,
Object_Token,
Octet_Token,
Optional_Token,
Or_Token,
Other_Token,
Partial_Token,
Readonly_Token,
Record_Token,
Required_Token,
Sequence_Token,
Setlike_Token,
Setter_Token,
Short_Token,
Static_Token,
Stringifier_Token,
Symbol_Token,
True_Token,
Typedef_Token,
Undefined_Token,
Unrestricted_Token,
Unsigned_Token,
ArrayBuffer_Token,
ByteString_Token,
DataView_Token,
DOMString_Token,
Float32Array_Token,
Float64Array_Token,
FrozenArray_Token,
Infinity_Token,
Int16Array_Token,
Int32Array_Token,
Int8Array_Token,
NaN_Token,
ObservableArray_Token,
Promise_Token,
Uint16Array_Token,
Uint32Array_Token,
Uint8Array_Token,
Uint8ClampedArray_Token,
USVString_Token,
Integer_Token,
Decimal_Token,
Identifier_Token,
String_Token,
End_Of_Stream_Token,
Error_Token);
type Token (Kind : Token_Kind := End_Of_Stream_Token) is record
Text : League.Strings.Universal_String;
end record;
end WebIDL.Tokens;
|
tests/src/reference_qoi.adb | joffreyhuguet/qoi-ada | 7 | 23545 | with System; use System;
with Interfaces.C; use Interfaces.C;
with Ada.Text_IO; use Ada.Text_IO;
package body Reference_QOI is
------------------
-- Check_Encode --
------------------
function Check_Encode (Pix : Storage_Array;
Desc : QOI.QOI_Desc;
Output : Storage_Array)
return Boolean
is
Ref_Output_Ptr : System.Address;
R_Desc : aliased Ref_Desc;
Ref_Out_Len : aliased Interfaces.C.int;
begin
R_Desc.Width := unsigned (Desc.Width);
R_Desc.height := unsigned (Desc.Height);
R_Desc.channels := char'Enum_Val (Desc.Channels);
R_Desc.colorspace := char'Enum_Val (Desc.Colorspace'Enum_Rep);
Ref_Output_Ptr := Encode (Data => Pix'Address,
Desc => R_Desc'Unrestricted_Access,
Out_Len => Ref_Out_Len'Access);
if Ref_Output_Ptr = System.Null_Address then
Put_Line ("Ref QOI failed to encode");
return False;
end if;
declare
Ref_Output : Storage_Array (1 .. Storage_Count (Ref_Out_Len))
with Address => Ref_Output_Ptr;
To_Compare : Storage_Count :=
Storage_Count'Min (Ref_Output'Length, Output'Length);
begin
if Ref_Output /= Output then
if Ref_Output'Length > Output'Length then
Put_Line ("Ref QOI output bigger (" &
Ref_Output'Length'Img & ")" &
" than ours (" & Output'Length'Img & ")");
elsif Ref_Output'Length < Output'Length then
Put_Line ("Ref QOI output smaller (" &
Ref_Output'Length'Img & ")" &
" than ours (" & Output'Length'Img & ")");
end if;
for Offset in 0 .. To_Compare - 1 loop
declare
A : constant Storage_Element :=
Ref_Output (Ref_Output'First + Offset);
B : constant Storage_Element :=
Output (Output'First + Offset);
begin
if A /= B then
Put_Line ("Byte diff" & Offset'Img &
" Ref:" & A'Img &
" Act:" & B'Img);
return False;
end if;
end;
end loop;
return False;
end if;
end;
return True;
end Check_Encode;
------------------
-- Check_Decode --
------------------
function Check_Decode (Data : Storage_Array;
Out_Desc : QOI.QOI_Desc;
Out_Data : Storage_Array)
return Boolean
is
Ref_Output_Ptr : System.Address;
R_Desc : aliased Ref_Desc;
begin
Ref_Output_Ptr := Decode (Data => Data'Address,
Size => Data'Length,
Desc => R_Desc'Unchecked_Access,
Channels => 0);
if Ref_Output_Ptr = System.Null_Address then
Put_Line ("Ref QOI failed to decode");
return False;
end if;
if R_Desc.width /= unsigned (Out_Desc.Width) then
Put_Line ("Ref width (" & R_Desc.width'Img & ") diff from ours " &
"(" & Out_Desc.Width'Img & ")");
return False;
end if;
if R_Desc.height /= unsigned (Out_Desc.Height) then
Put_Line ("Ref height (" & R_Desc.height'Img & ") diff from ours " &
"(" & Out_Desc.Height'Img & ")");
return False;
end if;
if R_Desc.channels /= char'Enum_Val (Out_Desc.Channels) then
Put_Line ("Ref channels (" & R_Desc.channels'Enum_Rep'Img &
") diff from ours " &
"(" & Out_Desc.Channels'Img & ")");
return False;
end if;
if R_Desc.colorspace /= char'Enum_Val (Out_Desc.Colorspace'Enum_Rep)
then
Put_Line ("Ref colorspace (" & R_Desc.colorspace'Enum_Rep'Img &
") diff from ours " &
"(" & Out_Desc.Colorspace'Enum_Rep'Img & ")");
return False;
end if;
declare
Ref_Out_Len : constant Storage_Count :=
Storage_Count (R_Desc.width *
R_Desc.height *
R_Desc.channels'Enum_Rep);
Ref_Output : Storage_Array (1 .. Storage_Count (Ref_Out_Len))
with Address => Ref_Output_Ptr;
To_Compare : Storage_Count :=
Storage_Count'Min (Ref_Output'Length, Out_Data'Length);
begin
if Ref_Output /= Out_Data then
if Ref_Output'Length > Out_Data'Length then
Put_Line ("Ref QOI decode output bigger (" &
Ref_Output'Length'Img & ")" &
" than ours (" & Out_Data'Length'Img & ")");
elsif Ref_Output'Length < Out_Data'Length then
Put_Line ("Ref QOI decode output smaller (" &
Ref_Output'Length'Img & ")" &
" than ours (" & Out_Data'Length'Img & ")");
end if;
for Offset in 0 .. To_Compare - 1 loop
declare
A : constant Storage_Element :=
Ref_Output (Ref_Output'First + Offset);
B : constant Storage_Element :=
Out_Data (Out_Data'First + Offset);
begin
if A /= B then
Put_Line ("Byte diff" & Offset'Img &
" Ref:" & A'Img &
" Act:" & B'Img);
return False;
end if;
end;
end loop;
return False;
end if;
end;
return True;
end Check_Decode;
end Reference_QOI;
|
examples/outdated-and-incorrect/Alonzo/PreludeShow.agda | asr/agda-kanso | 1 | 14002 |
module PreludeShow where
import RTP -- magic module
import AlonzoPrelude as Prelude
open import PreludeNat
open import PreludeString
import PreludeList
open import PreludeBool
open Prelude
-- open Data.Integer, using (Int, pos, neg)
open PreludeList hiding (_++_)
showInt : Int -> String
showInt = RTP.primShowInt
showNat : Nat -> String
showNat n = showInt (RTP.primNatToInt n)
{-
showNat : Nat -> String
showNat zero = "0"
showNat n = reverseString $ show n
where
digit : Nat -> String
digit 0 = "0"
digit 1 = "1"
digit 2 = "2"
digit 3 = "3"
digit 4 = "4"
digit 5 = "5"
digit 6 = "6"
digit 7 = "7"
digit 8 = "8"
digit 9 = "9"
digit _ = "?"
show : Nat -> String
show zero = ""
show n = digit (mod n 10) ++ show (div n 10)
-}
{-
showInt : Int -> String
showInt (pos n) = showNat n
showInt (neg n) = "-" ++ showNat (suc n)
-}
showChar : Char -> String
showChar = RTP.primShowChar
showBool : Bool -> String
showBool true = "true"
showBool false = "false"
primitive
primShowFloat : Float -> String
showFloat : Float -> String
showFloat = primShowFloat |
oeis/115/A115048.asm | neoneye/loda-programs | 11 | 95753 | <reponame>neoneye/loda-programs
; A115048: Count backwards from 100 in steps modulo n.
; Submitted by <NAME>
; 100,100,99,96,95,90,84,80,72,70,66,60,52,42,30,16,0
mov $1,100
mov $2,1
lpb $0
mov $3,$2
add $2,1
lpb $3
gcd $4,$2
div $1,$4
mov $3,$5
lpe
sub $0,1
mul $1,$2
cmp $4,$5
lpe
mov $0,$1
|
stage2/graphics_line_bresenham.asm | amrwc/8086-graphics | 5 | 86857 | <filename>stage2/graphics_line_bresenham.asm
; 8086 Assembly Bresenham’s line drawing algorithm implementation.
; Pseudo-code:
;
; function drawLine(x0, y0, x1, y1, colour)
; dx = abs(x1 - x0)
; dy = abs(y1 - y0)
; (x0 < x1) ? sx = 1 : sx = -1
; (y0 < y1) ? sx = 1 : sx = -1
; err = dx - dy
; loop
; printPixel(x0, y0, colour)
; if (x0 = x1) and (y0 = y1) exit loop
; e2 = 2 * err
; if (e2 > -dy) then
; err = err - dy
; x0 = x0 + sx
; end if
; if (e2 < dx) then
; err = err + dx
; y0 = y0 + sy
; end if
; end loop
;
; Input:
; x0: [bp + 12] -> [bp + x0]
; y0: [bp + 10] -> [bp + y0]
; x1: [bp + 8] -> [bp + x1]
; y1: [bp + 6] -> [bp + y1]
; px: [bp + 4] -> [bp + px_set]
%assign x0 12
%assign y0 10
%assign x1 8
%assign y1 6
%assign px_set 4
; Local variables:
%assign straight 2 ; [bp - straight]
%assign sx 4 ; [bp - sx] ; Direction variables
%assign sy 6 ; [bp - sy]
%assign delta_x 8 ; [bp - delta_x]
%assign delta_y 10 ; [bp - delta_y]
%assign err 12 ; [bp - err]
%assign e2 14 ; [bp - e2]
%include "graphics_line_test_boundaries.asm"
%include "graphics_line_test_straight.asm"
%include "graphics_line_straight.asm"
Bresenham_Main:
push bp
mov bp, sp
sub sp, 14
push ax
push cx
push dx
push si
; Tests
mov [bp - straight], word 0
call Graphics_Line_Test_Boundaries
call Graphics_Line_Test_Straight
cmp [bp - straight], word 1d
jl Draw_Bresenham
je Draw_Horizontal
;Draw_Vertical:
call Graphics_Line_Vertical
jmp end_draw_line
Draw_Horizontal:
call Graphics_Line_Horizontal
jmp end_draw_line
Draw_Bresenham:
mov [bp - sx], word 1d ; Set direction variables
mov [bp - sy], word 1d
;____________________
; Delta X
mov ax, word [bp + x1]
sub ax, word [bp + x0]
; Instead of doing '(x0 < x1) ? sx=1 : sx=-1',
; the program does '(x1 >= x0) ? sx=1 : sx=-1' by using the subtraction in place.
jge Skip_Direction_X
mov [bp - sx], word -1d
Skip_Direction_X:
; cwd -- Convert word to doubleword, i.e. extend the sign bit of AX into DX.
cwd ; abs(dx)
xor ax, dx
sub ax, dx
mov [bp - delta_x], ax ; Store delta X
;____________________
; Delta Y
mov ax, word [bp + y1]
sub ax, word [bp + y0]
jge Skip_Direction_Y ; (y1 >= y0) ? sy=1 : sy=-1
mov [bp - sy], word -1d
Skip_Direction_Y:
cwd ; abs(dy)
xor ax, dx
sub ax, dx
mov [bp - delta_y], ax ; Store delta Y
;____________________
; Err
mov ax, word [bp - delta_x] ; err = dx - dy
sub ax, word [bp - delta_y]
mov [bp - err], ax
; Setup
mov cx, word [bp + x0] ; Column start
mov dx, word [bp + y0] ; Row start
mov ax, word [bp + px_set] ; AH: 0Ch, AL: colour
;____________________
Draw_Line_Loop_Repeat:
int 10h ; Print pixel
cmp cx, word [bp + x1] ; if (x0==x1 && y0==y1) break;
jne Loop_Continue
cmp dx, word [bp + y1]
jne Loop_Continue
end_draw_line: ; break
pop si
pop dx
pop cx
pop ax
leave
ret 10
Loop_Continue:
mov si, word [bp - err] ; e2 = 2 * err
add si, word [bp - err]
mov [bp - e2], si
;Update_Row
mov si, word [bp - delta_y] ; if (e2 > -dy)
neg si
cmp word [bp - e2], si
jle Update_Column
mov si, word [bp - err] ; err -= dy
sub si, word [bp - delta_y]
mov [bp - err], si
add cx, word [bp - sx] ; x0 += sx
Update_Column:
mov si, word [bp - delta_x]
cmp word [bp - e2], si
jge Draw_Line_Loop_Repeat
mov si, word [bp - err] ; err += dx
add si, word [bp - delta_x]
mov [bp - err], si
add dx, word [bp - sy] ; y0 += sy
jmp Draw_Line_Loop_Repeat |
test/Succeed/Issue2629.agda | cruhland/agda | 1,989 | 1833 | <filename>test/Succeed/Issue2629.agda
{-# OPTIONS --exact-split #-}
open import Agda.Builtin.Nat
data IsZero : Nat → Set where
isZero : IsZero 0
test : (n m : Nat) → IsZero n → IsZero m → Nat
test zero zero _ _ = zero
test (suc _) _ () _
test _ (suc _) _ ()
|
oeis/235/A235282.asm | neoneye/loda-programs | 11 | 12981 | ; A235282: Number of (n+1) X (1+1) 0..3 arrays with every 2 X 2 subblock having its diagonal sum differing from its antidiagonal sum by 4 (constant stress 1 X 1 tilings).
; Submitted by <NAME>
; 20,40,68,136,236,472,836,1672,3020,6040,11108,22216,41516,83032,157316,314632,603020,1206040,2333348,4666696,9097196,18194392,35680196,71360392,140595020,281190040,556002788,1112005576,2204879276,4409758552,8762121476,17524242952,34876299020,69752598040,138988635428,277977270856,554404859756,1108809719512,2212970393156,4425940786312,8837934435020,17675868870040,35309896327268,70619792654536,141114061070636,282228122141272,564079671567236,1128159343134472,2255188968123020,4510377936246040
mov $1,2
pow $1,$0
add $0,2
seq $0,18311 ; Divisors of 162.
mul $1,2
add $1,$0
mov $0,$1
mul $0,4
|
draw.asm | rodolfovalentim/sistemb2016-1 | 0 | 22240 | segment code
..start:
mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov sp,stacktop
; salvar modo corrente de video(vendo como esta o modo de video da maquina)
mov ah, 0Fh
int 10h
mov [modo_anterior], al
; alterar modo de video para grafico 640x480 16 cores
mov al, 12h
mov ah, 0
int 10h
mov ax, 15h
int 33h
mov ax, 16h
mov [size_mouse], bx
mov dx, status_mouse
int 33h
mov ax,0
int 33h ; mouse interrupt
; (ifi AX=FFFFh mouse is installed, if 0000 not, DX - number of mouse buttons)
cmp ax,0
ja pmouse ; if AX > 0 lets start!
mov ax, 01
int 33h
jmp pmouse
mov ah,4ch
int 21h ;else just exit
pmouse:
mov ax,03 ; function to get mouse position and buttons
int 33h
mov ax,dx ; Y coord to AX
mov dx,320
mul dx ; multiply AX by 320
add ax,cx ; add X coord
; (Now currsor position is in AX, lets draw the pixel there)
mov di,ax
mov ax,0A000h
mov es,ax
mov dl,12 ; red color ;)
mov [di],dl ; and we have the pixel drawn
;By default mouse resolution is 640x200, lets set it to c (monitor height is already set, lets just set the width)
mov ax, 7
mov cx,0 ; min pos
mov dx,320 ; max pos
int 33h
;And height can be set:
mov ax, 8
mov cx,0
mov dx,200
int 33h
segment data
modo_anterior db 0
status_mouse dw 0
size_mouse dw 0
segment stack stack
resb 256
stacktop:
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/opt61.adb | best08618/asylo | 7 | 11160 | -- { dg-do run }
-- { dg-options "-O2" }
with Interfaces;
with Opt61_Pkg; use Opt61_Pkg;
procedure Opt61 is
use type Interfaces.Integer_64;
X : constant Int64 := 3125;
Y : constant Int64 := 5;
Z : constant Int64 := 10;
Q, R: Int64;
begin
Double_Divide (X, Y, Z, Q, R, False);
if R /= 25 then
raise Program_Error;
end if;
end;
|
Light/system_changes.applescript | tomas-ramos21/macOS-Themes | 0 | 3823 | on run argv
tell application "System Events"
tell appearance preferences
set dark mode to false
set highlight color to blue
end tell
tell current desktop
set p to item 1 of argv
set img to p & ".jpg"
set picture to img
end tell
end tell
end run
|
P6/data_P6_2/cal_R_test32.asm | alxzzhou/BUAA_CO_2020 | 1 | 14967 | <reponame>alxzzhou/BUAA_CO_2020
lui $1,65327
ori $1,$1,35829
lui $2,32538
ori $2,$2,56991
lui $3,56670
ori $3,$3,36131
lui $4,26785
ori $4,$4,33803
lui $5,56277
ori $5,$5,10749
lui $6,60796
ori $6,$6,29939
mthi $1
mtlo $2
sec0:
nop
nop
nop
addu $5,$6,$2
sec1:
nop
nop
nor $6,$2,$5
addu $3,$6,$2
sec2:
nop
nop
sltiu $6,$3,-28552
addu $3,$6,$2
sec3:
nop
nop
mfhi $6
addu $0,$6,$2
sec4:
nop
nop
lhu $6,10($0)
addu $3,$6,$2
sec5:
nop
subu $6,$2,$6
nop
addu $1,$6,$2
sec6:
nop
or $6,$1,$2
subu $6,$5,$3
addu $3,$6,$2
sec7:
nop
subu $6,$3,$5
lui $6,18545
addu $2,$6,$2
sec8:
nop
nor $6,$3,$0
mflo $6
addu $1,$6,$2
sec9:
nop
addu $6,$4,$5
lh $6,14($0)
addu $3,$6,$2
sec10:
nop
ori $6,$5,51427
nop
addu $3,$6,$2
sec11:
nop
ori $6,$1,14799
or $6,$2,$2
addu $5,$6,$2
sec12:
nop
addiu $6,$2,2100
addiu $6,$6,14463
addu $3,$6,$2
sec13:
nop
xori $6,$4,278
mflo $6
addu $3,$6,$2
sec14:
nop
sltiu $6,$3,7479
lb $6,15($0)
addu $3,$6,$2
sec15:
nop
mfhi $6
nop
addu $1,$6,$2
sec16:
nop
mfhi $6
and $6,$3,$2
addu $5,$6,$2
sec17:
nop
mfhi $6
andi $6,$3,13305
addu $3,$6,$2
sec18:
nop
mflo $6
mfhi $6
addu $6,$6,$2
sec19:
nop
mflo $6
lb $6,12($0)
addu $5,$6,$2
sec20:
nop
lhu $6,6($0)
nop
addu $4,$6,$2
sec21:
nop
lh $6,0($0)
or $6,$3,$2
addu $6,$6,$2
sec22:
nop
lhu $6,10($0)
xori $6,$5,61692
addu $2,$6,$2
sec23:
nop
lh $6,0($0)
mflo $6
addu $4,$6,$2
sec24:
nop
lbu $6,5($0)
lb $6,0($0)
addu $2,$6,$2
sec25:
subu $2,$1,$1
nop
nop
addu $2,$6,$2
sec26:
subu $2,$2,$3
nop
or $6,$2,$2
addu $4,$6,$2
sec27:
or $2,$5,$0
nop
ori $6,$2,36747
addu $4,$6,$2
sec28:
and $2,$4,$5
nop
mfhi $6
addu $6,$6,$2
sec29:
sltu $2,$6,$3
nop
lhu $6,2($0)
addu $2,$6,$2
sec30:
and $2,$3,$2
addu $6,$3,$3
nop
addu $3,$6,$2
sec31:
subu $2,$3,$4
xor $6,$3,$1
and $6,$2,$2
addu $3,$6,$2
sec32:
slt $2,$4,$3
nor $6,$4,$1
xori $6,$5,16723
addu $2,$6,$2
sec33:
subu $2,$4,$5
addu $6,$4,$4
mfhi $6
addu $5,$6,$2
sec34:
or $2,$6,$3
and $6,$0,$3
lbu $6,3($0)
addu $3,$6,$2
sec35:
slt $2,$4,$3
slti $6,$4,8627
nop
addu $1,$6,$2
sec36:
and $2,$0,$4
lui $6,42362
sltu $6,$3,$2
addu $4,$6,$2
sec37:
addu $2,$1,$4
xori $6,$4,42430
sltiu $6,$4,-3030
addu $2,$6,$2
sec38:
subu $2,$4,$3
andi $6,$3,30719
mfhi $6
addu $2,$6,$2
sec39:
addu $2,$5,$5
sltiu $6,$4,32026
lbu $6,14($0)
addu $2,$6,$2
sec40:
subu $2,$3,$5
mflo $6
nop
addu $4,$6,$2
sec41:
addu $2,$4,$4
mflo $6
addu $6,$4,$5
addu $6,$6,$2
sec42:
xor $2,$2,$3
mfhi $6
andi $6,$3,6340
addu $1,$6,$2
sec43:
sltu $2,$2,$6
mfhi $6
mfhi $6
addu $2,$6,$2
sec44:
xor $2,$1,$2
mflo $6
lbu $6,9($0)
addu $1,$6,$2
sec45:
xor $2,$4,$4
lb $6,6($0)
nop
addu $3,$6,$2
sec46:
and $2,$2,$5
lh $6,2($0)
sltu $6,$2,$2
addu $3,$6,$2
sec47:
or $2,$0,$6
lh $6,14($0)
ori $6,$2,46198
addu $2,$6,$2
sec48:
sltu $2,$5,$3
lw $6,0($0)
mfhi $6
addu $5,$6,$2
sec49:
xor $2,$5,$2
lw $6,0($0)
lh $6,4($0)
addu $3,$6,$2
sec50:
ori $2,$4,50973
nop
nop
addu $5,$6,$2
sec51:
andi $2,$4,19807
nop
or $6,$6,$0
addu $2,$6,$2
sec52:
sltiu $2,$1,14975
nop
ori $6,$5,20803
addu $2,$6,$2
sec53:
slti $2,$3,12966
nop
mflo $6
addu $2,$6,$2
sec54:
slti $2,$5,3215
nop
lhu $6,10($0)
addu $3,$6,$2
sec55:
andi $2,$4,16063
subu $6,$3,$4
nop
addu $3,$6,$2
sec56:
xori $2,$2,33830
sltu $6,$5,$4
or $6,$3,$6
addu $4,$6,$2
sec57:
xori $2,$5,39399
and $6,$2,$4
addiu $6,$4,-28102
addu $3,$6,$2
sec58:
xori $2,$2,9307
or $6,$2,$6
mflo $6
addu $3,$6,$2
sec59:
xori $2,$3,55594
and $6,$2,$4
lhu $6,16($0)
addu $3,$6,$2
sec60:
sltiu $2,$2,23786
sltiu $6,$3,-19226
nop
addu $5,$6,$2
sec61:
xori $2,$1,57735
addiu $6,$3,2637
and $6,$5,$5
addu $1,$6,$2
sec62:
sltiu $2,$4,-1032
sltiu $6,$5,18753
sltiu $6,$4,2817
addu $2,$6,$2
sec63:
slti $2,$4,27353
addiu $6,$1,4586
mfhi $6
addu $3,$6,$2
sec64:
andi $2,$1,9569
lui $6,22221
lh $6,6($0)
addu $5,$6,$2
sec65:
sltiu $2,$3,-27945
mflo $6
nop
addu $1,$6,$2
sec66:
ori $2,$3,16116
mflo $6
nor $6,$4,$4
addu $5,$6,$2
sec67:
sltiu $2,$1,27451
mfhi $6
addiu $6,$1,31534
addu $5,$6,$2
sec68:
sltiu $2,$5,-4939
mflo $6
mfhi $6
addu $5,$6,$2
sec69:
slti $2,$3,3574
mfhi $6
lh $6,0($0)
addu $6,$6,$2
sec70:
addiu $2,$1,-21568
lhu $6,4($0)
nop
addu $4,$6,$2
sec71:
lui $2,60447
lh $6,14($0)
sltu $6,$5,$6
addu $3,$6,$2
sec72:
xori $2,$2,2752
lbu $6,12($0)
ori $6,$2,774
addu $4,$6,$2
sec73:
slti $2,$6,10213
lbu $6,13($0)
mflo $6
addu $3,$6,$2
sec74:
xori $2,$2,63311
lw $6,16($0)
lbu $6,8($0)
addu $4,$6,$2
sec75:
mflo $2
nop
nop
addu $1,$6,$2
sec76:
mflo $2
nop
nor $6,$5,$1
addu $2,$6,$2
sec77:
mfhi $2
nop
sltiu $6,$5,-15842
addu $0,$6,$2
sec78:
mfhi $2
nop
mfhi $6
addu $1,$6,$2
sec79:
mfhi $2
nop
lhu $6,12($0)
addu $4,$6,$2
sec80:
mfhi $2
xor $6,$4,$3
nop
addu $5,$6,$2
sec81:
mflo $2
or $6,$1,$4
subu $6,$2,$3
addu $5,$6,$2
sec82:
mfhi $2
addu $6,$0,$6
addiu $6,$5,9952
addu $3,$6,$2
sec83:
mflo $2
slt $6,$6,$3
mfhi $6
addu $3,$6,$2
sec84:
mflo $2
subu $6,$2,$4
lhu $6,2($0)
addu $0,$6,$2
sec85:
mflo $2
slti $6,$2,-31082
nop
addu $4,$6,$2
sec86:
mflo $2
andi $6,$1,28886
or $6,$3,$1
addu $4,$6,$2
sec87:
mflo $2
sltiu $6,$5,-11320
andi $6,$6,15556
addu $3,$6,$2
sec88:
mflo $2
andi $6,$2,27206
mflo $6
addu $3,$6,$2
sec89:
mflo $2
slti $6,$4,32667
lbu $6,1($0)
addu $4,$6,$2
sec90:
mfhi $2
mflo $6
nop
addu $2,$6,$2
sec91:
mfhi $2
mfhi $6
sltu $6,$0,$5
addu $3,$6,$2
sec92:
mflo $2
mfhi $6
sltiu $6,$5,-9881
addu $4,$6,$2
sec93:
mfhi $2
mflo $6
mflo $6
addu $4,$6,$2
sec94:
mflo $2
mflo $6
lh $6,16($0)
addu $3,$6,$2
sec95:
mflo $2
lh $6,14($0)
nop
addu $3,$6,$2
sec96:
mfhi $2
lhu $6,14($0)
nor $6,$1,$3
addu $0,$6,$2
sec97:
mfhi $2
lh $6,14($0)
sltiu $6,$6,20100
addu $3,$6,$2
sec98:
mflo $2
lh $6,4($0)
mflo $6
addu $4,$6,$2
sec99:
mfhi $2
lhu $6,12($0)
lw $6,0($0)
addu $0,$6,$2
sec100:
lbu $2,9($0)
nop
nop
addu $3,$6,$2
sec101:
lw $2,12($0)
nop
xor $6,$4,$5
addu $3,$6,$2
sec102:
lh $2,16($0)
nop
slti $6,$4,17185
addu $0,$6,$2
sec103:
lhu $2,16($0)
nop
mflo $6
addu $0,$6,$2
sec104:
lhu $2,14($0)
nop
lbu $6,10($0)
addu $1,$6,$2
sec105:
lb $2,16($0)
subu $6,$5,$2
nop
addu $2,$6,$2
sec106:
lhu $2,4($0)
subu $6,$5,$3
or $6,$1,$3
addu $2,$6,$2
sec107:
lhu $2,4($0)
addu $6,$1,$0
andi $6,$6,27694
addu $3,$6,$2
sec108:
lw $2,4($0)
and $6,$2,$1
mflo $6
addu $3,$6,$2
sec109:
lw $2,8($0)
sltu $6,$2,$3
lw $6,4($0)
addu $2,$6,$2
sec110:
lb $2,7($0)
lui $6,48536
nop
addu $4,$6,$2
sec111:
lhu $2,4($0)
ori $6,$4,31707
xor $6,$5,$5
addu $3,$6,$2
sec112:
lhu $2,8($0)
ori $6,$1,51520
slti $6,$6,-10947
addu $3,$6,$2
sec113:
lh $2,10($0)
ori $6,$0,53605
mflo $6
addu $1,$6,$2
sec114:
lw $2,12($0)
sltiu $6,$6,-15867
lb $6,15($0)
addu $5,$6,$2
sec115:
lh $2,14($0)
mflo $6
nop
addu $3,$6,$2
sec116:
lbu $2,12($0)
mfhi $6
and $6,$5,$3
addu $2,$6,$2
sec117:
lh $2,10($0)
mflo $6
ori $6,$5,14291
addu $0,$6,$2
sec118:
lbu $2,11($0)
mflo $6
mfhi $6
addu $1,$6,$2
sec119:
lhu $2,10($0)
mflo $6
lbu $6,10($0)
addu $3,$6,$2
sec120:
lbu $2,12($0)
lh $6,4($0)
nop
addu $4,$6,$2
sec121:
lhu $2,0($0)
lh $6,0($0)
or $6,$5,$5
addu $4,$6,$2
sec122:
lbu $2,9($0)
lh $6,6($0)
sltiu $6,$2,24364
addu $3,$6,$2
sec123:
lw $2,16($0)
lw $6,0($0)
mfhi $6
addu $4,$6,$2
sec124:
lh $2,10($0)
lhu $6,2($0)
lhu $6,10($0)
addu $2,$6,$2
|
Levels/LBZ/Misc Object Data/Map - Unused Unknown 2.asm | NatsumiFox/AMPS-Sonic-3-Knuckles | 5 | 27828 | dc.w word_26A04-Map_LBZUnusedUnknown_2
dc.w word_26A1E-Map_LBZUnusedUnknown_2
dc.w word_26A38-Map_LBZUnusedUnknown_2
dc.w word_26A58-Map_LBZUnusedUnknown_2
dc.w word_26A72-Map_LBZUnusedUnknown_2
word_26A04: dc.w 4
dc.b $E8, 7, 0, $10, $FF, $F0
dc.b $E8, 7, 8, $10, 0, 0
dc.b 8, 4, 0, $18, $FF, $F0
dc.b 8, 4, 8, $18, 0, 0
word_26A1E: dc.w 4
dc.b $F0, 6, 0, $1A, $FF, $F0
dc.b $E8, 7, 0, $20, 0, 0
dc.b 8, 4, 0, $18, $FF, $F0
dc.b 8, 4, 8, $18, 0, 0
word_26A38: dc.w 5
dc.b $E8, 4, 0, $28, 0, 8
dc.b $F0, 6, 0, $2A, $FF, $F0
dc.b 8, 4, 0, $18, $FF, $F0
dc.b $F0, 7, 0, $30, 0, 0
dc.b $F0, 0, 0, $38, 0, $10
word_26A58: dc.w 4
dc.b $F0, 6, 8, $1A, 0, 0
dc.b $E8, 7, 8, $20, $FF, $F0
dc.b 8, 4, 8, $18, 0, 0
dc.b 8, 4, 0, $18, $FF, $F0
word_26A72: dc.w 5
dc.b $E8, 4, 8, $28, $FF, $E8
dc.b $F0, 6, 8, $2A, 0, 0
dc.b 8, 4, 8, $18, 0, 0
dc.b $F0, 7, 8, $30, $FF, $F0
dc.b $F0, 0, 8, $38, $FF, $E8
|
libsrc/msx/msx_type.asm | dex4er/deb-z88dk | 1 | 173792 | <reponame>dex4er/deb-z88dk
;
; MSX specific routines
; by <NAME>, 08/11/2007
;
; int msx_type();
;
; The int result is 1 or two, depending on the MSX hardware being used
;
; $Id: msx_type.asm,v 1.2 2007/12/03 07:29:40 stefano Exp $
;
XLIB msx_type
msx_type:
ld a,($FAF8) ; running on MSX1?
and a
ld hl,1
jr z,is_msx1 ; yes
inc l ; side effect: non zero FLAG if MSX2
is_msx1:
ret
|
bead/bead2/2/Garden_Pkg.adb | balintsoos/LearnAda | 0 | 20360 | with Ada.Text_IO, tools;
use Ada.Text_IO;
package body Garden_Pkg is
package Position_Generator is new tools.Random_Generator(Position);
function GetRandPos return Position is
begin
return Position_Generator.GetRandom;
end GetRandPos;
function GetField(pos : Position) return Boolean is
begin
return Garden(pos);
end GetField;
procedure SprayField(pos : Position) is
begin
Garden(pos) := true;
end SprayField;
procedure SprayAbsorbed is
begin
Garden := (1..10 => false);
end SprayAbsorbed;
end Garden_Pkg;
|
programs/oeis/276/A276087.asm | neoneye/loda | 22 | 84318 | ; A276087: a(n) = A276086(A276086(n)).
; 2,3,6,5,30,125,18,45,150,7,1050,343,1250,2625,7350,16807,1650,847,43218,3465,27731550,3195731,1183724850,435930295269007,17794411250,7105308412125,3782866198615350,2709490941157,6237907125450,161696170950365051,10,75,750,175,294,12005,126,2205,51450,11,565950,1331,21008750,9904125,6225450,161051,1002614947950,190333,1844766,472661332605,7357350,224939,1654954951650,11381363136448019,643987936192851250,424028420324383875,372263911869199350,26239020329095717,24980878650,2593207962059,1750,5145,9003750,336875,90750,2562175,1386,266805,68479950,19487171,1334480495721450,337186519813,3383480196250,11704875,1184908574850,265837,314992540812399450,18786517513731253,414959819274,1089691117515,83736672071945832589650,74518220878673,284316451383191354671894350,859082878918489166513,43214998750,41906819002125,54184319632061850,555895286377717,1372430723177404240350,179773108370713,1320550,17469375,51674970270,4953753355329625,155791886250,100858289406875,27009219006,4616526915,1052101050,4599777611
seq $0,276086 ; Prime product form of primorial base expansion of n: digits in primorial base representation of n become the exponents of successive prime factors whose product a(n) is.
seq $0,276086 ; Prime product form of primorial base expansion of n: digits in primorial base representation of n become the exponents of successive prime factors whose product a(n) is.
|
programs/oeis/033/A033423.asm | karttu/loda | 1 | 27094 | ; A033423: [ 10^9/n ].
; 1000000000,500000000,333333333,250000000,200000000,166666666,142857142,125000000,111111111,100000000,90909090,83333333,76923076,71428571,66666666,62500000,58823529,55555555,52631578,50000000
add $0,1
mov $1,1000000000
div $1,$0
|
src/Fragment/Equational/Model.agda | yallop/agda-fragment | 18 | 17531 | <reponame>yallop/agda-fragment
{-# OPTIONS --without-K --exact-split --safe #-}
open import Fragment.Equational.Theory
module Fragment.Equational.Model (Θ : Theory) where
open import Fragment.Equational.Model.Base Θ public
open import Fragment.Equational.Model.Synthetic Θ public
open import Fragment.Equational.Model.Properties Θ public
open import Fragment.Equational.Model.Satisfaction public
|
Transynther/x86/_processed/NC/_st_sm_/i7-8650U_0xd2_notsx.log_7_232.asm | ljhsiun2/medusa | 9 | 166463 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r8
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x1a0b1, %rcx
nop
xor $8908, %rbp
mov (%rcx), %r9d
add %rax, %rax
lea addresses_A_ht+0x2171, %r10
clflush (%r10)
nop
nop
nop
and %r8, %r8
movl $0x61626364, (%r10)
nop
nop
nop
nop
nop
cmp $9664, %rbp
lea addresses_WT_ht+0x1bbd1, %r10
nop
nop
nop
nop
nop
sub %rbp, %rbp
movl $0x61626364, (%r10)
nop
nop
nop
nop
and %rbp, %rbp
lea addresses_UC_ht+0xe2b1, %rdi
cmp $12297, %r8
movb (%rdi), %cl
nop
xor %rax, %rax
lea addresses_WC_ht+0x16131, %rdi
nop
nop
nop
nop
nop
xor %r8, %r8
movw $0x6162, (%rdi)
nop
add %rdi, %rdi
lea addresses_UC_ht+0x16291, %rdi
clflush (%rdi)
nop
nop
nop
cmp %r10, %r10
mov (%rdi), %rax
and %rcx, %rcx
lea addresses_normal_ht+0x106b1, %rdi
nop
nop
nop
dec %r10
mov (%rdi), %r8w
nop
nop
nop
nop
nop
xor %rbp, %rbp
lea addresses_A_ht+0x14d49, %rsi
lea addresses_normal_ht+0x86b1, %rdi
nop
nop
nop
nop
nop
lfence
mov $92, %rcx
rep movsb
nop
and %rbp, %rbp
lea addresses_A_ht+0x7bb1, %rsi
nop
nop
nop
nop
nop
and $10078, %rcx
mov (%rsi), %r8d
nop
nop
nop
nop
sub %r10, %r10
lea addresses_WC_ht+0xc7e1, %rdi
nop
nop
nop
nop
and $54170, %rcx
movl $0x61626364, (%rdi)
nop
nop
nop
nop
xor $40677, %r8
lea addresses_WC_ht+0x1b1b1, %rsi
lea addresses_D_ht+0xef81, %rdi
clflush (%rsi)
and $25304, %r9
mov $124, %rcx
rep movsb
nop
nop
nop
nop
xor %r10, %r10
lea addresses_A_ht+0xd7d, %r9
nop
nop
nop
nop
nop
inc %rsi
movb $0x61, (%r9)
sub %r8, %r8
lea addresses_WT_ht+0x156b1, %rdi
nop
nop
and %rbp, %rbp
movw $0x6162, (%rdi)
nop
nop
nop
nop
nop
inc %r8
lea addresses_WT_ht+0x1a8b1, %rcx
clflush (%rcx)
nop
nop
nop
nop
sub %rdi, %rdi
mov (%rcx), %r10d
nop
nop
nop
and %rcx, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r8
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r8
push %r9
push %rax
push %rbx
push %rcx
push %rdi
// Store
lea addresses_D+0xafb1, %r8
nop
nop
add $43572, %r11
movl $0x51525354, (%r8)
nop
nop
nop
nop
nop
sub %r9, %r9
// Store
mov $0xab1, %r8
nop
nop
and $34179, %rax
movl $0x51525354, (%r8)
nop
nop
and %rdi, %rdi
// Store
mov $0x374d3c0000000ab1, %rdi
clflush (%rdi)
nop
nop
nop
add %r8, %r8
mov $0x5152535455565758, %r11
movq %r11, (%rdi)
nop
dec %r9
// Store
lea addresses_WC+0x6dd5, %rcx
nop
nop
nop
nop
nop
sub %r9, %r9
movl $0x51525354, (%rcx)
add %rdi, %rdi
// Load
lea addresses_US+0x4eb1, %rax
nop
nop
nop
nop
nop
sub $24314, %r9
mov (%rax), %r11
// Exception!!!
mov (0), %r11
nop
and $28381, %r9
// Faulty Load
mov $0x374d3c0000000ab1, %r8
cmp %r11, %r11
mov (%r8), %r9
lea oracles, %r11
and $0xff, %r9
shlq $12, %r9
mov (%r11,%r9,1), %r9
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r8
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 10, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 3, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'58': 7}
58 58 58 58 58 58 58
*/
|
oeis/145/A145718.asm | neoneye/loda-programs | 11 | 244181 | ; A145718: Numbers x such that there exists n in N with (x+127)^3-x^3=n^2.
; Submitted by <NAME>(s1)
; 762,1676527,3403477826,6909058439031,14025385227883882,28471525103545970207,57797181934813091765106,117328250856145472737323751,238176291440793374843675578202,483497754296559694787188686555087,981500203045724739624618190031377186,1992444928685066924878280138575009261271,4044662223730482811778169056689078769131722,8210662321727951422842758306798691326328263167,16667640468445517657887987584632286703367605226066,33835301940282079117561191954045235209144912280779591
mov $3,1
lpb $0
sub $0,$3
add $4,1
mov $1,$4
mul $1,2028
add $2,$1
add $4,$2
add $4,1
lpe
mov $0,$4
div $0,2
mul $0,1651
add $0,762
|
antlr/TestExpr.g4 | zhaoweilong007/freedao | 1 | 1660 | grammar TestExpr;
stat: expr EOF;
expr
: simpleExpr
| '(' expr ')'
| expr LOGICAL_OP expr
;
// (a.g == b ) && c > 1L && (b && d && e <= -1.2) && (f == null) && g || true && (c.1."uaoe-_u".c.2424 > 1)
// (a.g == b ) and c > 1L and (b and d and e <= -1.2) and (f == null) and g or true and (c.1."uaoe-_u".c.2424 > 1)
simpleExpr
:INVOKE_CHAIN op=(EQUAL_OP|COMPARISON_OP) right=(NUMBER|TEXT|CHAR) #literalComparisonOperation
|INVOKE_CHAIN op=(EQUAL_OP|COMPARISON_OP|LOGICAL_OP) INVOKE_CHAIN #varOperation
|INVOKE_CHAIN EQUAL_OP NULL #nullCheck
|INVOKE_CHAIN LOGICAL_OP BOOLEAN #literalLogicalOperation
;
EQUAL_OP:('=='|'!=');
COMPARISON_OP:('>'|'>='|'<'|'<=');
LOGICAL_OP:('and'|'or');
NULL: 'null';
NUMBER:([1-9][0-9]*|'0')'L'?
| [1-9][0-9]* '.' [0-9]+
| [0-9] '.' [0-9]+
| '-' NUMBER
;
CHAR: '\'' ~[\\'] '\''
|'\'' '\\\\' '\''
|'\'' '\\'~[\\] '\''
;
TEXT:'""'
| '"' '\\\\'+ '"'
| '"' .*? ~[\\]('\\\\')+ '"'
| '"' .*? ~[\\] '"'
;
BOOLEAN: 'true'
|'false'
;
//INVOKE_CHAIN:([a-zA-Z][a-zA-Z0-9_]*('["'[0-9a-zA-Z]*'"]'|'['[0-9][0-9]*']')?)('.'[a-zA-Z][a-zA-Z0-9_]*('["'[0-9a-zA-Z]*'"]'|'['[0-9][0-9]*']')?)*;
INVOKE_CHAIN:([a-zA-Z][a-zA-Z0-9_]*)('.'([a-zA-Z][a-zA-Z0-9_]*|'"'[a-zA-Z0-9_-]*'"'|[0-9][0-9]*))*;
WS:[ \t]+ -> skip; |
asm/doorrando.asm | oobitydoo/ALttPDoorRandomizer | 0 | 240936 | <reponame>oobitydoo/ALttPDoorRandomizer
!add = "clc : adc"
!sub = "sec : sbc"
!bge = "bcs"
!blt = "bcc"
; Free RAM notes
; Normal doors use $AB-AC for scrolling indicator
; Normal doors use $FE to store the trap door indicator
; Spiral doors use $045e to store stair type
; Gfx uses $b1 to for sub-sub-sub-module thing
; Hooks into various routines
incsrc drhooks.asm
;Main Code
org $278000 ;138000
incsrc normal.asm
incsrc spiral.asm
incsrc gfx.asm
incsrc keydoors.asm
incsrc overrides.asm
;incsrc edges.asm
;incsrc math.asm
warnpc $279000
; Data Section
org $279000
OffsetTable:
dw -8, 8
DRMode:
dw 0
DRFlags:
dw 0
DRScroll:
db 0
; Vert 0,6,0 Horz 2,0,8
org $279010
CoordIndex: ; Horizontal 1st
db 2, 0 ; Coordinate Index $20-$23
OppCoordIndex:
db 0, 2 ; Swapped coordinate Index $20-$23 (minor optimization)
CameraIndex: ; Horizontal 1st
db 0, 6 ; Camera Index $e2-$ea
CamQuadIndex: ; Horizontal 1st
db 8, 0 ; Camera quadrants $600-$60f
ShiftQuadIndex:
db 2, 1 ; see ShiftQuad func (relates to $a9,$aa)
CamBoundIndex: ; Horizontal 1st
db 0, 4 ; Camera Bounds $0618-$61f
OppCamBoundIndex: ; Horizontal 1st
db 4, 0 ; Camera Bounds $0618-$61f
CamBoundBaseLine: ; X camera stuff is 1st column todo Y camera needs more testing
dw $007f, $0077 ; Left/Top camera bounds when at edge or layout frozen
dw $0007, $000b ; Left/Top camera bounds when not frozen + appropriate low byte $22/$20 (preadj. by #$78/#$6c)
dw $00ff, $010b ; Right/Bot camera bounds when not frozen + appropriate low byte $20/$22
dw $017f, $0187 ; Right/Bot camera bound when at edge or layout frozen
incsrc doortables.asm
|
alloy4fun_models/trashltl/models/7/queSmDyZsr8DrmiKD.als | Kaixi26/org.alloytools.alloy | 0 | 4851 | <reponame>Kaixi26/org.alloytools.alloy
open main
pred idqueSmDyZsr8DrmiKD_prop8 {
eventually all f:File | f in f.link implies f in Trash
}
pred __repair { idqueSmDyZsr8DrmiKD_prop8 }
check __repair { idqueSmDyZsr8DrmiKD_prop8 <=> prop8o } |
32.asm | aroxby/mbr-code | 0 | 22664 | org 0x7C00
use16
cli
mov bp, sp
jmp boot
my_gdtr:
dw 24
dd my_gdt
my_gdt:
dq 0
dw 0ffffh
dw 0
db 0
db 10011010b
db 0cfh
db 0
dw 0ffffh
dw 0
db 0
db 10010010b
db 0cfh
db 0
boot:
lgdt [my_gdtr]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 8:Boot32
use32
Boot32:
mov al, '*'
mov ah, 7
mov [0b8000h], ax
Quit32:
hlt
jmp Quit32
times 510-($-$$) db 90h
dw 0AA55h
;times 1509949-($-$$) db 0 |
oeis/325/A325401.asm | neoneye/loda-programs | 11 | 9795 | <gh_stars>10-100
; A325401: minflip(n) = min(n, r(n)) where r(n) is the binary reverse of n.
; 0,1,1,3,1,5,3,7,1,9,5,11,3,11,7,15,1,17,9,19,5,21,13,23,3,19,11,27,7,23,15,31,1,33,17,35,9,37,25,39,5,37,21,43,13,45,29,47,3,35,19,51,11,43,27,55,7,39,23,55,15,47,31,63,1,65,33,67,17,69,49,71,9,73,41,75,25,77,57,79,5,69,37,83,21,85,53,87,13,77,45,91,29,93,61,95,3,67,35,99
mov $1,$0
seq $0,30101 ; a(n) is the number produced when n is converted to binary digits, the binary digits are reversed and then converted back into a decimal number.
lpb $0
mov $0,$1
lpe
|
data/mapObjects/ViridianForestSouthGate.asm | AmateurPanda92/pokemon-rby-dx | 9 | 89712 | <filename>data/mapObjects/ViridianForestSouthGate.asm
ViridianForestSouthGate_Object:
db $a ; border block
db 4 ; warps
warp 4, 0, 3, VIRIDIAN_FOREST
warp 5, 0, 4, VIRIDIAN_FOREST
warp 4, 7, 5, -1
warp 5, 7, 5, -1
db 0 ; signs
db 2 ; objects
object SPRITE_GIRL, 8, 4, STAY, LEFT, 1 ; person
object SPRITE_LITTLE_GIRL, 2, 4, WALK, 1, 2 ; person
; warp-to
warp_to 4, 0, VIRIDIAN_FOREST_SOUTH_GATE_WIDTH ; VIRIDIAN_FOREST
warp_to 5, 0, VIRIDIAN_FOREST_SOUTH_GATE_WIDTH ; VIRIDIAN_FOREST
warp_to 4, 7, VIRIDIAN_FOREST_SOUTH_GATE_WIDTH
warp_to 5, 7, VIRIDIAN_FOREST_SOUTH_GATE_WIDTH
|
krakensvm/ia32e/segment_intrins.asm | fengjixuchui/krakensvm-mg | 45 | 19096 | ; got this Semantics idea from Daax & XEROXZ
; XEROXZ - (https://githacks.org/_xeroxz/bluepill/-/blob/master/segment_intrin.asm)
; Daax - 7 Days virtualization
.code
__reades proc
mov rax, es
ret
__reades endp
__readcs proc
mov rax, cs
ret
__readcs endp
__readss proc
mov rax, ss
ret
__readss endp
__readds proc
mov rax, ds
ret
__readds endp
__readfs proc
mov rax, fs
ret
__readfs endp
__readgs proc
mov rax, gs
ret
__readgs endp
__readtr proc
str ax
ret
__readtr endp
__readldt proc
sldt ax
ret
__readldt endp
__readrsp proc
mov rax, rsp
add rax, 8
ret
__readrsp endp
__readrip proc
mov rax, [rsp]
ret
__readrip endp
__readrflags proc
pushfq
pop rax
popfq
ret
__readrflags endp
END
|
kernel.asm | Roflcoffel/AnzuOS | 0 | 245093 | <gh_stars>0
BITS 16
start:
mov ax, 07C0h ; 4K stack space after bootloader
add ax, 288 ; (4096 + 512) / 16 bytes per paragraph
mov ss, ax
mov sp, 4096
mov ax, 07C0h ; set data segment
mov ds, ax
mov si, my_text
call clear
call print_string
call prompt
call handle_keystroke
jmp $
my_text db 'Welcome to AnzuOS!', 0
print_char:
mov ah, 0Eh ; Prints character stored in AL
int 10h ; Display Interrupt
ret
print_string: ; Ouput string in SI to screen
mov ah, 0Eh
.repeat:
lodsb ; Load byte from si to al and increment si
cmp al, 0h
je .newline
int 10h
jmp .repeat
.newline:
mov al, 0Ah ; (10 = \n) New Line Character
int 10h
mov al, 0Dh ; (13 = \r) Carriage return
int 10h
ret
prompt:
mov al, 3Eh ; (62 = >) Greater than sign
int 10h
mov ah, 01h ; Change Cursor to Block Shaped
mov cl, 07h
mov ch, 00h
int 10h
ret
clear:
mov ah, 00h ; Set Video mode
mov al, 03h ; 80x25 Video Mode
int 10h
mov ax, 0600h ; Scroll up
mov bh, 1Fh ; 1h = blue, background, fh = White, foreground
mov cx, 0000h ; CH=00H TOP , CL=00h LEFT
mov dx, 1950h ; DH=19h BOTTOM, DL=50h RIGHT;
int 10h
ret
%include "keyboard.asm"
times 510-($-$$) db 0 ; Pad boot sector with 0s
dw 0xAA55 ; PC boot signature
;Color Map
;0 0000 black
;1 0001 blue
;2 0010 green
;3 0011 cyan
;4 0100 red
;5 0101 magenta
;6 0110 brown
;7 0111 light gray
;8 1000 dark gray
;9 1001 light blue
;A 1010 light green
;B 1011 light cyan
;C 1100 light red
;D 1101 light magenta
;E 1110 yellow
;F 1111 white
;Ledger for Interrups
; int 10h - Display
; int 16h - Keyboard
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48_notsx.log_21829_725.asm | ljhsiun2/medusa | 9 | 246569 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r12
push %r13
push %r8
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0xa414, %r13
nop
nop
xor %rbx, %rbx
movw $0x6162, (%r13)
nop
nop
nop
xor %r8, %r8
lea addresses_normal_ht+0xf964, %r13
xor %r12, %r12
movb $0x61, (%r13)
nop
sub %r8, %r8
lea addresses_normal_ht+0xf46c, %r10
nop
nop
nop
xor $30902, %r11
mov (%r10), %rbx
dec %r8
lea addresses_UC_ht+0x18d84, %rbx
nop
nop
cmp $5414, %r11
vmovups (%rbx), %ymm5
vextracti128 $1, %ymm5, %xmm5
vpextrq $0, %xmm5, %r13
nop
nop
add $37074, %r12
lea addresses_A_ht+0x4cf4, %r12
clflush (%r12)
sub $5398, %r8
mov (%r12), %edx
nop
sub %r13, %r13
lea addresses_normal_ht+0xd294, %r12
nop
nop
sub %r10, %r10
movl $0x61626364, (%r12)
inc %rbx
lea addresses_WC_ht+0xe94, %rsi
lea addresses_UC_ht+0x32ec, %rdi
nop
nop
nop
add %r8, %r8
mov $14, %rcx
rep movsw
nop
nop
nop
and $15441, %r10
lea addresses_normal_ht+0xc214, %r11
nop
nop
nop
nop
sub %rbx, %rbx
mov (%r11), %dx
nop
nop
nop
nop
nop
inc %rdi
lea addresses_WT_ht+0x17434, %rdi
nop
nop
nop
cmp %r13, %r13
movl $0x61626364, (%rdi)
dec %r12
lea addresses_UC_ht+0x11f94, %rdi
nop
nop
nop
and %r8, %r8
mov $0x6162636465666768, %rsi
movq %rsi, (%rdi)
nop
nop
nop
nop
xor $62137, %rcx
lea addresses_normal_ht+0x7454, %r8
nop
nop
dec %rsi
movups (%r8), %xmm2
vpextrq $0, %xmm2, %rdx
nop
nop
nop
inc %rdi
lea addresses_A_ht+0x5f18, %rdx
nop
add $14961, %r12
mov $0x6162636465666768, %r13
movq %r13, %xmm3
vmovups %ymm3, (%rdx)
nop
nop
nop
dec %r12
lea addresses_normal_ht+0x4394, %rsi
lea addresses_UC_ht+0x13dd4, %rdi
nop
dec %r11
mov $110, %rcx
rep movsl
nop
nop
nop
nop
nop
xor $46841, %rcx
lea addresses_normal_ht+0x4ad4, %rsi
lea addresses_UC_ht+0x1510c, %rdi
nop
nop
sub %r12, %r12
mov $13, %rcx
rep movsw
nop
and %rsi, %rsi
lea addresses_A_ht+0x1d694, %r11
nop
xor $24180, %rcx
movb (%r11), %dl
sub $30748, %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r13
pop %r12
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %r8
push %rax
push %rbp
push %rbx
// Faulty Load
lea addresses_RW+0x1f294, %r13
cmp %r8, %r8
mov (%r13), %rbp
lea oracles, %rbx
and $0xff, %rbp
shlq $12, %rbp
mov (%rbx,%rbp,1), %rbp
pop %rbx
pop %rbp
pop %rax
pop %r8
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_RW', 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_RW', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal_ht', 'congruent': 7}, 'OP': 'STOR'}
{'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 3}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_normal_ht', 'congruent': 2}}
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_UC_ht', 'congruent': 4}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A_ht', 'congruent': 5}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_normal_ht', 'congruent': 10}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 2, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_WC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal_ht', 'congruent': 5}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WT_ht', 'congruent': 5}, 'OP': 'STOR'}
{'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC_ht', 'congruent': 8}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 3}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A_ht', 'congruent': 2}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}}
{'dst': {'same': False, 'congruent': 3, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_normal_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_A_ht', 'congruent': 8}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
libsrc/target/trs80/graphics_eg2000/cpoint_callee.asm | ahjelm/z88dk | 640 | 83088 | ;*****************************************************
;
; EG2000 colour graphics library library for z88dk
;
; <NAME> - May 2018
;
;*****************************************************
; ----- int __CALLEE__ cpoint_callee(int x, int y)
SECTION code_clib
PUBLIC cpoint_callee
PUBLIC _cpoint_callee
PUBLIC asm_cpoint
.cpoint_callee
._cpoint_callee
pop af
pop hl
pop de
push af
.asm_cpoint
ld h,e
ld a,l
cp 102
ret nc
ld a,h
cp 160
ret nc
;push bc
and $03 ; pixel offset
inc a
ld c,a
ld a,h
; push af
rra
rra
and @00111111
ld b,l
ld hl,$4800 ; pointer to base of graphics area
ld l,a
xor a
or b
jr z,zeroline
ld de,40
.adder add hl,de
djnz adder
.zeroline
; ld d,h
; ld e,l
; pop af
ld a,(hl)
ld b,c ; pixel offset
.pset1
rlca
rlca
djnz pset1
and 3
ld h,0
ld l,a
ret
|
src/gl/implementation/gl-enums-indexes.ads | Roldak/OpenGLAda | 79 | 25538 | -- part of OpenGLAda, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "COPYING"
with GL.Types;
with GL.Enums.Getter;
generic
Min_Representation : Types.Int;
Getter_Param : Enums.Getter.Parameter;
package GL.Enums.Indexes is
pragma Preelaborate;
use GL.Types;
Max : constant Int := Getter.Get_Max (Getter_Param);
subtype Index is Int range 0 .. Max;
function Representation (Value : Index) return Int;
function Value (Representation : Int) return Index;
end GL.Enums.Indexes; |
sholan/Language/SLang.g4 | redxdev/shogun | 0 | 502 | <gh_stars>0
grammar SLang;
@parser::header
{
#pragma warning disable 3021
using System;
using System.Diagnostics;
using System.Threading;
using sholan.Compiler;
using sholan.Compiler.Nodes;
}
@parser::members
{
protected const int EOF = Eof;
}
@lexer::header
{
#pragma warning disable 3021
}
@lexer::members
{
protected const int EOF = Eof;
protected const int HIDDEN = Hidden;
}
/*
* Parser Rules
*/
compileUnit returns [ICompileNode rootNode]
: stms=statements EOF { $rootNode = $stms.node; }
;
statements returns [TreeNode node]
:
{
$node = new TreeNode(-1, -1)
{
Children = new LinkedList<ICompileNode>()
};
}
(
stm=statement
{
$node.Children.AddLast(
$stm.node
);
}
)*
;
statement returns [ICompileNode node]
:
(
stm_directive { $node = $stm_directive.node; }
| stm_import_file { $node = $stm_import_file.node; }
| stm_extern_func { $node = $stm_extern_func.node; }
| stm_call_func { $node = $stm_call_func.node; }
| stm_define_func { $node = $stm_define_func.node; }
| stm_define_entry { $node = $stm_define_entry.node; }
| stm_return { $node = $stm_return.node; }
| stm_break { $node = $stm_break.node; }
| stm_variable_def { $node = $stm_variable_def.node; }
| stm_assembly { $node = $stm_assembly.node; }
| stm_assembly_var { $node = $stm_assembly_var.node; }
| stm_halt { $node = $stm_halt.node; }
| stm_variable_set { $node = $stm_variable_set.node; }
| stm_if { $node = $stm_if.node; }
| stm_for_loop { $node = $stm_for_loop.node; }
| stm_while_loop { $node = $stm_while_loop.node; }
| stm_do_while_loop { $node = $stm_do_while_loop.node; }
)
;
stm_directive returns [ICompileNode node]
:
(
directive_debug_compiler { $node = new PlaceholderNode($directive_debug_compiler.start.Line, $directive_debug_compiler.start.Column); }
| directive_debug_break { $node = $directive_debug_break.node; }
| directive_compiler_break { $node = $directive_compiler_break.node; }
| directive_build_exports { $node = new BuildExportsNode($directive_build_exports.start.Line, $directive_build_exports.start.Column); }
)
;
directive_debug_compiler
: DIRECTIVE DEBUG_COMPILER { Console.WriteLine("Waiting for debugger..."); while(!Debugger.IsAttached) { Thread.Sleep(100); } Console.WriteLine("Debugger Attached"); }
;
directive_debug_break returns [DebugBreakNode node]
: DIRECTIVE BREAK { $node = new DebugBreakNode(($DIRECTIVE).Line, ($DIRECTIVE).Column); }
;
directive_compiler_break returns [CompilerBreakNode node]
: DIRECTIVE COMPILER_BREAK { $node = new CompilerBreakNode(($DIRECTIVE).Line, ($DIRECTIVE).Column); }
;
directive_build_exports
: DIRECTIVE BUILD_EXPORTS
;
stm_import_file returns [ImportFileNode node]
: IMPORT STRING
{
$node = new ImportFileNode(($IMPORT).Line, ($IMPORT).Column)
{
Filepath = $STRING.text.Substring(1, $STRING.text.Length - 2),
Mode = ImportMode.Inherit
};
}
(
EXPORT { $node.Mode = ImportMode.Export; }
| LIB { $node.Mode = ImportMode.Library; }
)?
;
stm_extern_func returns [ExternalFunctionNode node]
:
EXTERN FUNCTION func=IDENT
{
$node = new ExternalFunctionNode(($EXTERN).Line, ($EXTERN).Column)
{
SymbolName = $func.text,
Line = $func.line,
Arguments = new List<string>()
};
}
GROUP_START
(
arg1=IDENT { $node.Arguments.Add($arg1.text); }
(
',' arg=IDENT { $node.Arguments.Add($arg.text); }
)*
)?
GROUP_END
;
stm_call_func returns [FunctionCallNode node]
:
IDENT
{
$node = new FunctionCallNode(($IDENT).Line, ($IDENT).Column)
{
Function = $IDENT.text,
Arguments = new List<ICompileNode>()
};
}
GROUP_START
(
arg1=expression { $node.Arguments.Add($arg1.node); }
(
',' arg=expression { $node.Arguments.Add($arg.node); }
)*
)?
GROUP_END
;
stm_define_func returns [InternalFunctionNode node]
: FUNCTION name=IDENT
{
$node = new InternalFunctionNode(($FUNCTION).Line, ($FUNCTION).Column)
{
Function = $name.text,
Arguments = new List<string>()
};
}
GROUP_START
(
arg1=IDENT { $node.Arguments.Add($arg1.text); }
(
',' arg=IDENT { $node.Arguments.Add($arg.text); }
)*
)?
GROUP_END
BLOCK_START
stms=statements { $node.Body = $stms.node; }
BLOCK_END
;
stm_define_entry returns [InternalFunctionNode node]
: ENTRY
{
$node = new InternalFunctionNode(($ENTRY).Line, ($ENTRY).Column)
{
Function = "+entry",
Arguments = new List<string>()
};
}
BLOCK_START
stms=statements
BLOCK_END { $stms.node.Children.AddLast(new HaltNode(($BLOCK_END).Line, ($BLOCK_END).Column)); $node.Body = $stms.node; }
;
stm_return returns [ReturnNode node]
:
RETURN { $node = new ReturnNode(($RETURN).Line, ($RETURN).Column); }
(
expression { $node.Value = $expression.node; }
)?
;
stm_break returns [BreakNode node]
: BREAK { $node = new BreakNode(($BREAK).Line, ($BREAK).Column); }
;
stm_variable_def returns [DefineVariableNode node]
: VAR_DEF IDENT { $node = new DefineVariableNode(($VAR_DEF).Line, ($VAR_DEF).Column) { VariableName = $IDENT.text }; }
(
EQUAL
expression { $node.Value = $expression.node; }
)?
;
stm_assembly returns [RawAssemblyNode node]
: ASSEMBLY STRING_EXT { $node = new RawAssemblyNode(($ASSEMBLY).Line, ($ASSEMBLY).Column) { Assembly = $STRING_EXT.text.Substring(2, $STRING_EXT.text.Length - 4) }; }
| ASSEMBLY VALUE STRING_EXT { $node = new RawAssemblyNode(($ASSEMBLY).Line, ($ASSEMBLY).Column) { Assembly = $STRING_EXT.text.Substring(2, $STRING_EXT.text.Length - 4) }; $node.Attributes.Has("value"); }
;
stm_assembly_var returns [RetrieveVariableNode node]
: ASSEMBLY VAR_DEF IDENT { $node = new RetrieveVariableNode(($ASSEMBLY).Line, ($ASSEMBLY).Column) { VariableName = $IDENT.text }; }
;
stm_halt returns [HaltNode node]
: HALT { $node = new HaltNode(($HALT).Line, ($HALT).Column); }
;
stm_variable_set returns [SetVariableNode node]
: IDENT EQUAL expression { $node = new SetVariableNode(($IDENT).Line, ($IDENT).Column) { VariableName = $IDENT.text, Value = $expression.node }; }
;
stm_if returns [IfNode node]
: S_IF GROUP_START expression GROUP_END { $node = new IfNode(($S_IF).Line, ($S_IF).Column) { Check = $expression.node }; }
(
stm=statement { $node.BranchTrue = $stm.node; }
| BLOCK_START
stms=statements { $node.BranchTrue = $stms.node; }
BLOCK_END
)
(
S_ELSE
(
estm=statement { $node.BranchFalse = $estm.node; }
| BLOCK_START
estms=statements { $node.BranchFalse = $estms.node; }
BLOCK_END
)
)?
;
stm_for_loop returns [ForLoopNode node]
: S_FOR GROUP_START init=statements SECTION check=expression SECTION incr=statements GROUP_END
{
$node = new ForLoopNode(($S_FOR).Line, ($S_FOR).Column)
{
Init = $init.node,
Check = $check.node,
Increment = $incr.node
};
}
(
stm=statement { $node.Body = $stm.node; }
| BLOCK_START
body=statements { $node.Body = $body.node; }
BLOCK_END
)
;
stm_while_loop returns [WhileLoopNode node]
: S_WHILE GROUP_START check=expression GROUP_END
{
$node = new WhileLoopNode(($S_WHILE).Line, ($S_WHILE).Column)
{
Check = $check.node
};
}
(
stm=statement { $node.Body = $stm.node; }
| BLOCK_START
body=statements { $node.Body = $body.node; }
BLOCK_END
)
;
stm_do_while_loop returns [DoWhileLoopNode node]
: S_DO
{
$node = new DoWhileLoopNode(($S_DO).Line, ($S_DO).Column);
}
(
stm=statement { $node.Body = $stm.node; }
| BLOCK_START
body=statements { $node.Body = $body.node; }
BLOCK_END
)
S_WHILE GROUP_START check=expression GROUP_END
{ $node.Check = $check.node; }
;
expression returns [ICompileNode node]
: orExpr { $node = $orExpr.node; }
;
orExpr returns [ExpressionNode node]
:
a=andExpr
{
$node = new ExpressionNode($a.start.Column, $a.start.Line) { Values = new List<ICompileNode>(), Ops = new List<Opcode>() };
$node.Values.Add($a.node);
}
(
OR OR b=andExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.OR); }
)*
;
andExpr returns [ExpressionNode node]
:
a=equalityExpr
{
$node = new ExpressionNode($a.start.Column, $a.start.Line) { Values = new List<ICompileNode>(), Ops = new List<Opcode>() };
$node.Values.Add($a.node);
}
(
AND AND b=equalityExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.AND); }
)*
;
equalityExpr returns [ExpressionNode node]
:
a=concatExpr
{
$node = new ExpressionNode($a.start.Column, $a.start.Line) { Values = new List<ICompileNode>(), Ops = new List<Opcode>() };
$node.Values.Add($a.node);
}
(
EQUAL EQUAL b=concatExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.EQ); }
| EQUAL EQUAL EQUAL b=concatExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.TEQ); }
| NOT EQUAL b=concatExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.NEQ); }
| NOT EQUAL EQUAL b=concatExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.NTEQ); }
| GREATER b=concatExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.GT); }
| GREATER EQUAL b=concatExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.GTEQ); }
| LESS b=concatExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.LT); }
| LESS EQUAL b=concatExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.LTEQ); }
)*
;
concatExpr returns [ExpressionNode node]
:
a=addExpr
{
$node = new ExpressionNode($a.start.Column, $a.start.Line) { Values = new List<ICompileNode>(), Ops = new List<Opcode>() };
$node.Values.Add($a.node);
}
(
DOT DOT b=addExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.CONCAT); }
)*
;
addExpr returns [ExpressionNode node]
:
a=mulExpr
{
$node = new ExpressionNode($a.start.Column, $a.start.Line) { Values = new List<ICompileNode>(), Ops = new List<Opcode>() };
$node.Values.Add($a.node);
}
(
PLUS b=mulExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.ADD); }
| MINUS b=mulExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.SUB); }
)*
;
mulExpr returns [ExpressionNode node]
:
a=notExpr
{
$node = new ExpressionNode($a.start.Column, $a.start.Line) { Values = new List<ICompileNode>(), Ops = new List<Opcode>() };
$node.Values.Add($a.node);
}
(
MUL b=notExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.MUL); }
| DIV b=notExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.DIV); }
| MOD b=notExpr { $node.Values.Add($b.node); $node.Ops.Add(Opcode.MOD); }
)*
;
notExpr returns [ICompileNode node]
: NOT atom { $node = new NotNode(($NOT).Line, ($NOT).Column) { Value = $atom.node }; }
| atom { $node = $atom.node; }
;
atom returns [ICompileNode node]
:
NIL { $node = new NilValueNode(($NIL).Line, ($NIL).Column); }
| STRING { $node = new ConstantNode(($STRING).Line, ($STRING).Column) { Value = $STRING.text }; }
| NUMBER { $node = new ConstantNode(($NUMBER).Line, ($NUMBER).Column) { Value = $NUMBER.text }; }
| B_TRUE { $node = new ConstantBoolNode(($B_TRUE).Line, ($B_TRUE).Column) { Value = true }; }
| B_FALSE { $node = new ConstantBoolNode(($B_FALSE).Line, ($B_FALSE).Column) { Value = false }; }
| IDENT { $node = new RetrieveVariableNode(($IDENT).Line, ($IDENT).Column) { VariableName = $IDENT.text }; }
| GROUP_START expression GROUP_END { $node = $expression.node; }
| statement { $node = $statement.node; $node.UseReturn = true; }
;
/*
* Lexer Rules
*/
EXTERN
: 'extern'
;
EXPORT
: 'export'
;
LIB
: 'lib'
;
FUNCTION
: 'func'
;
ENTRY
: 'entry'
;
RETURN
: 'return'
;
BREAK
: 'break'
;
IMPORT
: 'import'
;
VAR_DEF
: 'var'
;
ASSEMBLY
: 'asm'
;
VALUE
: 'value'
;
HALT
: 'halt'
;
EQUAL
: '='
;
NOT
: '!'
;
GREATER
: '>'
;
LESS
: '<'
;
NIL
: 'nil'
;
B_TRUE
: 'true'
;
B_FALSE
: 'false'
;
S_IF
: 'if'
;
S_ELSE
: 'else'
;
S_FOR
: 'for'
;
S_WHILE
: 'while'
;
S_DO
: 'do'
;
SECTION
: ';'
;
SPEC
: ':'
;
PLUS
: '+'
;
MINUS
: '-'
;
MUL
: '*'
;
DIV
: '/'
;
MOD
: '%'
;
AND
: '&'
;
OR
: '|'
;
DOT
: '.'
;
DIRECTIVE
: '#'
;
DEBUG_COMPILER
: 'debug-compiler'
;
COMPILER_BREAK
: 'cbreak'
;
BUILD_EXPORTS
: 'build-exports'
;
fragment ESCAPE_SEQUENCE
: '\\'
(
'\\'
| '"'
| '\''
)
;
STRING
:
(
'"' ( ESCAPE_SEQUENCE | . )*? '"'
| '\'' ( ESCAPE_SEQUENCE | . )*? '\''
)
;
STRING_EXT
: '[[' .*? ']]'
;
NUMBER
: '-'?
(
[0-9]* '.' [0-9]+
| [0-9]+
)
;
BLOCK_START
: '{'
;
BLOCK_END
: '}'
;
GROUP_START
: '('
;
GROUP_END
: ')'
;
IDENT
: ([a-zA-Z]) ([0-9a-zA-Z] | '_')*
;
WS
: [ \n\t\r] -> channel(HIDDEN)
;
COMMENT
: ('//' ~[\r\n]*
| '/*' .*? '*/') -> channel(HIDDEN)
; |
libsrc/target/homelab2/input/in_Inkey.asm | Frodevan/z88dk | 640 | 178767 | ; uint in_Inkey(void)
; Read current state of keyboard
SECTION code_clib
PUBLIC in_Inkey
PUBLIC _in_Inkey
EXTERN in_keytranstbl
; exit : carry set and HL = 0 for no keys registered
; else HL = ASCII character code
; uses : AF,BC,DE,HL
.in_Inkey
._in_Inkey
ld c,0
ld hl,$38fd
loop:
ld a,(hl)
xor 255
jr nz,gotkey
continue:
rlc l
ld a,c
add 8
ld c,a
cp 56
jr nz,loop
nokey:
ld hl,0
scf
ret
gotkey:
; c = offset
ld l,8
hitkey_loop:
rrca
jr c,doneinc
inc c
dec l
jr nz,hitkey_loop
doneinc:
ld b,0
ld a,($38fe)
bit 0,a
ld hl,56
jr z,got_modifier
ld hl,112
bit 1,a
jr z,got_modifier
ld hl,0
got_modifier:
add hl,bc
ld bc,in_keytranstbl
add hl,bc
ld a,(hl)
cp 255
jr z,nokey
ld l,a
ld h,0
and a
ret
|
samples/client/petstore/ada/src/model/samples-petstore-models.adb | derBiggi/swagger-codegen | 7 | 26899 | <gh_stars>1-10
-- Swagger Petstore
-- This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special_key` to test the authorization filters.
--
-- OpenAPI spec version: 1.0.0
-- Contact: <EMAIL>
--
-- NOTE: This package is auto generated by the swagger code generator 2.4.0-SNAPSHOT.
-- https://github.com/swagger-api/swagger-codegen.git
-- Do not edit the class manually.
package body Samples.Petstore.Models is
use Swagger.Streams;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in ApiResponse_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("code", Value.Code);
Into.Write_Entity ("type", Value.P_Type);
Into.Write_Entity ("message", Value.Message);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in ApiResponse_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out ApiResponse_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "code", Value.Code);
Swagger.Streams.Deserialize (Object, "type", Value.P_Type);
Swagger.Streams.Deserialize (Object, "message", Value.Message);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out ApiResponse_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : ApiResponse_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Tag_Type) is
begin
Into.Start_Entity (Name);
Serialize (Into, "id", Value.Id);
Into.Write_Entity ("name", Value.Name);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Tag_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Tag_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "id", Value.Id);
Swagger.Streams.Deserialize (Object, "name", Value.Name);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Tag_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Tag_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Category_Type) is
begin
Into.Start_Entity (Name);
Serialize (Into, "id", Value.Id);
Into.Write_Entity ("name", Value.Name);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Category_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Category_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "id", Value.Id);
Swagger.Streams.Deserialize (Object, "name", Value.Name);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Category_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Category_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Pet_Type) is
begin
Into.Start_Entity (Name);
Serialize (Into, "id", Value.Id);
Serialize (Into, "category", Value.Category);
Into.Write_Entity ("name", Value.Name);
Serialize (Into, "photoUrls", Value.Photo_Urls);
Serialize (Into, "tags", Value.Tags);
Into.Write_Entity ("status", Value.Status);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Pet_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Pet_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "id", Value.Id);
Deserialize (Object, "category", Value.Category);
Swagger.Streams.Deserialize (Object, "name", Value.Name);
Swagger.Streams.Deserialize (Object, "photoUrls", Value.Photo_Urls);
Deserialize (Object, "tags", Value.Tags);
Swagger.Streams.Deserialize (Object, "status", Value.Status);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Pet_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Pet_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in User_Type) is
begin
Into.Start_Entity (Name);
Serialize (Into, "id", Value.Id);
Into.Write_Entity ("username", Value.Username);
Into.Write_Entity ("firstName", Value.First_Name);
Into.Write_Entity ("lastName", Value.Last_Name);
Into.Write_Entity ("email", Value.Email);
Into.Write_Entity ("password", Value.Password);
Into.Write_Entity ("phone", Value.Phone);
Into.Write_Entity ("userStatus", Value.User_Status);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in User_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out User_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "id", Value.Id);
Swagger.Streams.Deserialize (Object, "username", Value.Username);
Swagger.Streams.Deserialize (Object, "firstName", Value.First_Name);
Swagger.Streams.Deserialize (Object, "lastName", Value.Last_Name);
Swagger.Streams.Deserialize (Object, "email", Value.Email);
Swagger.Streams.Deserialize (Object, "password", Value.Password);
Swagger.Streams.Deserialize (Object, "phone", Value.Phone);
Swagger.Streams.Deserialize (Object, "userStatus", Value.User_Status);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out User_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : User_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Order_Type) is
begin
Into.Start_Entity (Name);
Serialize (Into, "id", Value.Id);
Serialize (Into, "petId", Value.Pet_Id);
Into.Write_Entity ("quantity", Value.Quantity);
Into.Write_Entity ("shipDate", Value.Ship_Date);
Into.Write_Entity ("status", Value.Status);
Into.Write_Entity ("complete", Value.Complete);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Order_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Order_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "id", Value.Id);
Swagger.Streams.Deserialize (Object, "petId", Value.Pet_Id);
Swagger.Streams.Deserialize (Object, "quantity", Value.Quantity);
Deserialize (Object, "shipDate", Value.Ship_Date);
Swagger.Streams.Deserialize (Object, "status", Value.Status);
Swagger.Streams.Deserialize (Object, "complete", Value.Complete);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Order_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Order_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
end Samples.Petstore.Models;
|
oeis/022/A022783.asm | neoneye/loda-programs | 11 | 89800 | <gh_stars>10-100
; A022783: Place where n-th 1 occurs in A023121.
; Submitted by <NAME>(s2)
; 1,2,4,7,11,16,21,27,34,42,51,60,70,81,93,106,120,134,149,165,182,200,218,237,257,278,300,323,346,370,395,421,448,475,503,532,562,593,625,657,690,724,759,795,831,868,906,945,985,1026,1067,1109
mov $1,9
mul $1,$0
add $1,19
mul $1,$0
div $1,2
add $1,721
div $1,11
mov $0,$1
sub $0,64
|
regtests/ado-queries-tests.adb | My-Colaborations/ada-ado | 0 | 710 | <filename>regtests/ado-queries-tests.adb
-----------------------------------------------------------------------
-- ado-queries-tests -- Test loading of database queries
-- Copyright (C) 2011, 2012, 2013, 2014, 2015, 2017, 2018, 2019, 2020 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
with ADO.Connections;
with ADO.Queries.Loaders;
package body ADO.Queries.Tests is
use Util.Tests;
package Caller is new Util.Test_Caller (Test, "ADO.Queries");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test ADO.Queries.Read_Query",
Test_Load_Queries'Access);
Caller.Add_Test (Suite, "Test ADO.Queries.Find_Query",
Test_Find_Query'Access);
Caller.Add_Test (Suite, "Test ADO.Queries.Initialize",
Test_Initialize'Access);
Caller.Add_Test (Suite, "Test ADO.Queries.Read_Query (reload)",
Test_Reload_Queries'Access);
Caller.Add_Test (Suite, "Test ADO.Queries.Set_Query",
Test_Set_Query'Access);
Caller.Add_Test (Suite, "Test ADO.Queries.Set_Limit",
Test_Set_Limit'Access);
Caller.Add_Test (Suite, "Test ADO.Queries.Get_SQL (raise Query_Error)",
Test_Missing_Query'Access);
end Add_Tests;
package Simple_Query_File is
new ADO.Queries.Loaders.File (Path => "regtests/files/simple-query.xml",
Sha1 => "");
package Multi_Query_File is
new ADO.Queries.Loaders.File (Path => "regtests/files/multi-query.xml",
Sha1 => "");
package Missing_Query_File is
new ADO.Queries.Loaders.File (Path => "regtests/files/missing-query.xml",
Sha1 => "");
package Simple_Query is
new ADO.Queries.Loaders.Query (Name => "simple-query",
File => Simple_Query_File.File'Access);
package Simple_Query_2 is
new ADO.Queries.Loaders.Query (Name => "simple-query",
File => Multi_Query_File.File'Access);
package Index_Query is
new ADO.Queries.Loaders.Query (Name => "index",
File => Multi_Query_File.File'Access);
package Value_Query is
new ADO.Queries.Loaders.Query (Name => "value",
File => Multi_Query_File.File'Access);
package Missing_Query_SQLite is
new ADO.Queries.Loaders.Query (Name => "missing-query-sqlite",
File => Missing_Query_File.File'Access);
package Missing_Query_MySQL is
new ADO.Queries.Loaders.Query (Name => "missing-query-mysql",
File => Missing_Query_File.File'Access);
package Missing_Query_Postgresql is
new ADO.Queries.Loaders.Query (Name => "missing-query-postgresql",
File => Missing_Query_File.File'Access);
package Missing_Query is
new ADO.Queries.Loaders.Query (Name => "missing-query",
File => Missing_Query_File.File'Access);
pragma Warnings (Off, Simple_Query_2);
pragma Warnings (Off, Value_Query);
pragma Warnings (Off, Missing_Query);
pragma Warnings (Off, Missing_Query_SQLite);
pragma Warnings (Off, Missing_Query_MySQL);
pragma Warnings (Off, Missing_Query_Postgresql);
procedure Test_Load_Queries (T : in out Test) is
use ADO.Connections;
use type ADO.Configs.Driver_Index;
Mysql_Driver : constant Driver_Access := ADO.Connections.Get_Driver ("mysql");
Sqlite_Driver : constant Driver_Access := ADO.Connections.Get_Driver ("sqlite");
Psql_Driver : constant Driver_Access := ADO.Connections.Get_Driver ("postgresql");
Config : ADO.Connections.Configuration;
Manager : Query_Manager;
Config_URL : constant String := Util.Tests.Get_Parameter ("test.database",
"sqlite:///regtests.db");
begin
-- Configure the XML query loader.
Config.Set_Connection (Config_URL);
ADO.Queries.Loaders.Initialize (Manager, Config);
declare
SQL : constant String := ADO.Queries.Get_SQL (Simple_Query.Query'Access, Manager, False);
begin
Assert_Equals (T, "select count(*) from user", SQL, "Invalid query for 'simple-query'");
end;
declare
SQL : constant String := ADO.Queries.Get_SQL (Index_Query.Query'Access, Manager, False);
begin
if Mysql_Driver /= null and then Manager.Driver = Mysql_Driver.Get_Driver_Index then
Assert_Equals (T, "select 1", SQL, "Invalid query for 'index'");
elsif Psql_Driver /= null and then Manager.Driver = Psql_Driver.Get_Driver_Index then
Assert_Equals (T, "select 3", SQL, "Invalid query for 'index'");
else
Assert_Equals (T, "select 0", SQL, "Invalid query for 'index'");
end if;
end;
if Mysql_Driver /= null and then Manager.Driver = Mysql_Driver.Get_Driver_Index then
declare
SQL : constant String := ADO.Queries.Get_SQL (Index_Query.Query'Access,
Manager,
False);
begin
Assert_Equals (T, "select 1", SQL, "Invalid query for 'index' (MySQL driver)");
end;
end if;
if Sqlite_Driver /= null and then Manager.Driver = Sqlite_Driver.Get_Driver_Index then
declare
SQL : constant String := ADO.Queries.Get_SQL (Index_Query.Query'Access,
Manager, False);
begin
Assert_Equals (T, "select 0", SQL, "Invalid query for 'index' (SQLite driver)");
end;
end if;
if Psql_Driver /= null and then Manager.Driver = Psql_Driver.Get_Driver_Index
then
declare
SQL : constant String := ADO.Queries.Get_SQL (Index_Query.Query'Access,
Manager,
False);
begin
Assert_Equals (T, "select 3", SQL, "Invalid query for 'index' (PostgreSQL driver)");
end;
end if;
end Test_Load_Queries;
-- ------------------------------
-- Test re-loading queries.
-- ------------------------------
procedure Test_Reload_Queries (T : in out Test) is
Config : ADO.Connections.Configuration;
Manager : Query_Manager;
Query : ADO.Queries.Context;
Config_URL : constant String := Util.Tests.Get_Parameter ("test.database",
"sqlite:///regtests.db");
begin
-- Configure the XML query loader.
Config.Set_Connection (Config_URL);
ADO.Queries.Loaders.Initialize (Manager, Config);
for I in 1 .. 10 loop
Query.Set_Query ("simple-query");
declare
SQL : constant String := Query.Get_SQL (Manager);
begin
Assert_Equals (T, "select count(*) from user", SQL,
"Invalid query for 'simple-query'");
end;
for J in Manager.Files'Range loop
Manager.Files (J).Next_Check := 0;
end loop;
end loop;
end Test_Reload_Queries;
-- ------------------------------
-- Test the Initialize operation called several times
-- ------------------------------
procedure Test_Initialize (T : in out Test) is
Config : ADO.Connections.Configuration;
Manager : Query_Manager;
Pos : Query_Index;
Config_URL : constant String := Util.Tests.Get_Parameter ("test.database",
"sqlite:///regtests.db");
begin
Config.Set_Connection (Config_URL);
-- Configure and load the XML queries.
for Pass in 1 .. 10 loop
Config.Set_Property ("ado.queries.load", (if Pass = 1 then "false" else "true"));
ADO.Queries.Loaders.Initialize (Manager, Config);
T.Assert (Manager.Queries /= null, "The queries table is allocated");
T.Assert (Manager.Files /= null, "The files table is allocated");
Pos := 1;
for Query of Manager.Queries.all loop
if Pass = 1 then
T.Assert (Query.Is_Null, "Query must not be loaded");
elsif Missing_Query.Query.Query /= Pos then
T.Assert (not Query.Is_Null, "Query must have been loaded");
else
T.Assert (Query.Is_Null, "Query must not be loaded (not found)");
end if;
Pos := Pos + 1;
end loop;
end loop;
end Test_Initialize;
-- ------------------------------
-- Test the Set_Query operation.
-- ------------------------------
procedure Test_Set_Query (T : in out Test) is
Query : ADO.Queries.Context;
Manager : Query_Manager;
Config : ADO.Connections.Configuration;
Config_URL : constant String := Util.Tests.Get_Parameter ("test.database",
"sqlite:///regtests.db");
begin
Config.Set_Connection (Config_URL);
ADO.Queries.Loaders.Initialize (Manager, Config);
Query.Set_Query ("simple-query");
declare
SQL : constant String := Query.Get_SQL (Manager);
begin
Assert_Equals (T, "select count(*) from user", SQL, "Invalid query for 'simple-query'");
end;
end Test_Set_Query;
-- ------------------------------
-- Test the Set_Limit operation.
-- ------------------------------
procedure Test_Set_Limit (T : in out Test) is
Query : ADO.Queries.Context;
begin
Query.Set_Query ("index");
Query.Set_Limit (0, 10);
Assert_Equals (T, 0, Query.Get_First_Row_Index, "Invalid first row index");
Assert_Equals (T, 10, Query.Get_Last_Row_Index, "Invalid last row index");
end Test_Set_Limit;
-- ------------------------------
-- Test the Find_Query operation.
-- ------------------------------
procedure Test_Find_Query (T : in out Test) is
Q : Query_Definition_Access;
begin
Q := ADO.Queries.Loaders.Find_Query ("this query does not exist");
T.Assert (Q = null, "Find_Query should return null for unkown query");
end Test_Find_Query;
-- ------------------------------
-- Test the missing query.
-- ------------------------------
procedure Test_Missing_Query (T : in out Test) is
Query : ADO.Queries.Context;
Manager : Query_Manager;
Config : ADO.Connections.Configuration;
Count : Natural := 0;
Config_URL : constant String := Util.Tests.Get_Parameter ("test.database",
"sqlite:///regtests.db");
begin
Config.Set_Connection (Config_URL);
ADO.Queries.Loaders.Initialize (Manager, Config);
Query.Set_Query ("missing-query");
begin
Assert_Equals (T, "?", Query.Get_SQL (Manager));
T.Fail ("No ADO.Queries.Query_Error exception was raised");
exception
when ADO.Queries.Query_Error =>
null;
end;
begin
Query.Set_Query ("missing-query-sqlite");
Assert_Equals (T, "select count(*) from user", Query.Get_SQL (Manager));
exception
when ADO.Queries.Query_Error =>
Count := Count + 1;
end;
begin
Query.Set_Query ("missing-query-mysql");
Assert_Equals (T, "select count(*) from user", Query.Get_SQL (Manager));
exception
when ADO.Queries.Query_Error =>
Count := Count + 1;
end;
begin
Query.Set_Query ("missing-query-postgresql");
Assert_Equals (T, "select count(*) from user", Query.Get_SQL (Manager));
exception
when ADO.Queries.Query_Error =>
Count := Count + 1;
end;
T.Assert (Count > 0, "No Query_Error exception was raised");
end Test_Missing_Query;
end ADO.Queries.Tests;
|
timers/tac_set_disabled/main.asm | AntonioND/gbc-hw-tests | 6 | 1366 |
INCLUDE "hardware.inc"
INCLUDE "header.inc"
SECTION "var",BSS
repeat_loop: DS 1
current_test: DS 1
SECTION "Main",HOME
;--------------------------------------------------------------------------
;- Main() -
;--------------------------------------------------------------------------
Main:
ld a,-1
ld [current_test],a
; -------------------------------------------------------
ld a,$0A
ld [$0000],a ; enable ram
ld a,$00
ld [$4000],a ; ram bank change
ld d,0
ld hl,$A000
ld bc,$2000
call memset
ld a,$01
ld [$4000],a ; ram bank change
ld d,0
ld hl,$A000
ld bc,$2000
call memset
ld a,$02
ld [$4000],a ; ram bank change
ld d,0
ld hl,$A000
ld bc,$2000
call memset
ld a,$03
ld [$4000],a ; ram bank change
ld d,0
ld hl,$A000
ld bc,$2000
call memset
; -------------------------------------------------------
ld a,[Init_Reg_A]
cp a,$11
jr nz,.skipchange1
ld a,0
ld [repeat_loop],a
call CPU_slow
.skipchange1:
.repeat_all:
; -------------------------------------------------------
ld d,0
.loopram:
ld a,[current_test]
inc a
ld [current_test],a
srl a
ld [$4000],a
ld a,[current_test]
and a,1
jr nz,.skip
ld hl,$A000
.skip:
ld c,251
.loopout:
ld b,0
.loop:
REPETITIONS SET 0
REPT 16
ld a,d
ld [rTAC],a
ld a,0
ld [rTMA],a
ld [rDIV],a
ld [rIF],a
ld a,c
ld [rTIMA],a
ld a,b
ld [rDIV],a ; sync
REPT REPETITIONS
nop
ENDR
ld [rTAC],a
ld a,[rTIMA]
ld [hl+],a
ld a,[rIF]
and a,4
ld [hl+],a
REPETITIONS SET REPETITIONS+1
ENDR
inc b
ld a,16
cp a,b
jp nz,.loop
inc c
ld a,2
cp a,c
jp nz,.loopout
push hl ; magic number
ld [hl],$12
inc hl
ld [hl],$34
inc hl
ld [hl],$56
inc hl
ld [hl],$78
pop hl
inc d
ld a,4
cp a,d
jp nz,.loopram
; -------------------------------------------------------
ld a,[Init_Reg_A]
cp a,$11
jr nz,.skipchange2
ld a,[repeat_loop]
and a,a
jr nz,.endloop
; -------------------------------------------------------
call CPU_fast
ld a,1
ld [repeat_loop],a
jp .repeat_all
.skipchange2:
ld a,$00
ld [$0000],a ; disable ram
.endloop:
halt
jr .endloop
|
Transynther/x86/_processed/US/_zr_/i7-7700_9_0x48_notsx.log_5_1697.asm | ljhsiun2/medusa | 9 | 172205 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %rax
push %rdx
push %rsi
// Faulty Load
lea addresses_US+0x9c81, %r11
nop
cmp %rax, %rax
mov (%r11), %rsi
lea oracles, %r14
and $0xff, %rsi
shlq $12, %rsi
mov (%r14,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %rax
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_US', 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_US', 'congruent': 0}}
<gen_prepare_buffer>
{'00': 5}
00 00 00 00 00
*/
|
alice1/rom1.asm | lkesteloot/alice | 63 | 3449 | OB1 EQU 0C0H
OB2 EQU 00DH
OB3 EQU 0DEH
OB4 EQU 0E1H
OB5 EQU 015H
OB6 EQU 05CH
OB7 EQU 0C0H
OB8 EQU 00DH
OB9 EQU 0DEH
LD A, OB1
OUT (0), A
LD A, OB2
OUT (0), A
LD A, OB3
OUT (0), A
LD A, OB4
OUT (0), A
LD A, OB5
OUT (0), A
LD A, OB6
OUT (0), A
LD A, OB7
OUT (0), A
LD A, OB8
OUT (0), A
LD A, OB9
OUT (0), A
OUT (0), A
OUT (0), A
OUT (0), A
OUT (0), A
LD A, 0
LOOP
OUT (0), A
INC A
JP LOOP
HALT
END
|
BTA3.agda | luminousfennell/polybta | 1 | 14081 | <reponame>luminousfennell/polybta
module BTA3 where
open import Data.Nat
open import Data.Bool
open import Data.List
-- Binding times
data BT : Set where
S : BT
D : BT
-- defining a data type [BT],where two members are
-- [S] standing for "static" and [D] standing for dynamic.
-- ``subsumption'' binding times; static can be treated as dynamic,
-- but not vice versa
_≼_ : BT → BT → Bool
_≼_ D S = false
_≼_ _ _ = true
-- note that the above function can also be specified as follows,
-- _≼_ : BT → BT → Bool
-- D ≼ S = false
-- _ ≼ _ = true
-- note that the function [≼] specifies that a "static",S, can be treated
-- as a "dynamic",D, and not the other way round
-- since in Agda, pattern matching is conducted in a sequencial fashion,
-- the above specification makes sure that it returns [false] when the
-- first argument is [D] and the second [S] and returns [true] in all
-- the other three cases.
-- BEGIN: stuff that is also in the standard library
-- Standard propositional equality, see also Relation.Binary.PropositionalEquality
data _==_ {A : Set} (x : A) : A → Set where
refl : x == x
-- [_==_] defines an equality proposition
-- it takes two identical elements of one type as arguments and gives one
-- evidence,[refl],for the proposition
-- subst lemma
subst : {A B : Set}{x x' : A} {C : A → B} → x == x' → C x == C x'
subst{A}{B}{x}{.x} refl = refl
-- or being defined in the following manner...
-- my_subst : {A B : Set}{x x' : A}{C : A → B} → x == x' → C x == C x'
-- my_subst refl = refl
-- the above function further helps to construct evidence for equality
-- proposition
-- it says that if two elements are identical then two new elements obtained
-- by applying the former to a function should also be identical
record True : Set where
data False : Set where
-- note that the above is regarding two simple proposition [True] and [False]
-- regarding [True],
-- it is defined as empty record with a single element of type [True],[record{}]
-- the trick here is that the type checker knows this and fills in any implicit
-- arguments of [True] with this element
-- another way of defining [True] as follows,
-- record True : Set where
-- trivial : True
-- trivial = _
-- regarding [False],
-- it is defined as a proposition without any evidence corresponding well to
-- what a [False] proposition really means
isTrue : Bool → Set
isTrue true = True
isTrue false = False
-- note the isTrue b,given b as boolean, is the type of proof that b is equal to
-- true since if it is the case, [isTrue b] returns type [True] where its
-- evidence is automatically filled in by the type checker while if it is not
-- the case there is no way to supply for the evidence due to the way how
-- [false] is constructed
-- END standard library
----------------------
-- Sublists
----------------------
data _cx-≤_ {A : Set} : List A → List A → Set where
cxle-eq : (l : List A) → l cx-≤ l
cxle-lt : ∀ {l₁ l₂} x → l₁ cx-≤ l₂ → l₁ cx-≤ (x ∷ l₂)
lem-cx-≤-trans : {A : Set} → {l₁ : List A} {l₂ : List A} {l₃ : List A} →
l₁ cx-≤ l₂ → l₂ cx-≤ l₃ → l₁ cx-≤ l₃
lem-cx-≤-trans le1 (cxle-eq l) = le1
lem-cx-≤-trans (cxle-eq l) (cxle-lt x e) = cxle-lt x e
lem-cx-≤-trans (cxle-lt x e) (cxle-lt x' e') = cxle-lt x' (lem-cx-≤-trans (cxle-lt x e) e')
_cxle-∷_ : {A : Set} (x : A) (l : List A) → l cx-≤ (x ∷ l)
x cxle-∷ l = cxle-lt x (cxle-eq l)
data _⊆_ {A : Set} : List A → List A → Set where
refl-⊆ : ∀ {l} → l ⊆ l
step-⊆ : ∀ {l} x l₁ l₂ → l ⊆ (l₁ ++ l₂) → l ⊆ (l₁ ++ (x ∷ l₂))
lem-⊆-trans : {A : Set} → {l₁ : List A} {l₂ : List A} {l₃ : List A} →
l₁ ⊆ l₂ → l₂ ⊆ l₃ → l₁ ⊆ l₃
lem-⊆-trans e (refl-⊆ {l}) = e
lem-⊆-trans (refl-⊆ {l}) (step-⊆ x l₁ l₂ e) = step-⊆ x l₁ l₂ e
lem-⊆-trans (step-⊆ x l₁ l₂ e) (step-⊆ x' l₁' l₂' e') = step-⊆ x' l₁' l₂' (lem-⊆-trans (step-⊆ x l₁ l₂ e) e')
-- data _≤1_ {A : Set} : List A → List A → Set where
-- cxle1-eq : (l : List A) → l ≤1 l
-- cxle1-lt : ∀ x (l : List A) → l ≤1 (x ∷ l)
-- data _?∷_ {A : Set} (x : A): List A → Set where
-- yes∷ : (l : List A) → x ?∷ (x ∷ l)
-- no∷ : (l : List A) → x ?∷ l
-- getList : ∀ {A} {x : A} {l : List A} → x ?∷ l → List A
-- getList {x = x} (yes∷ l) = x ∷ l
-- getList {_} {_} {l} (no∷ .l) = l
-- end sublists
-- some lemmas about BT subsumption
lem-bt≼S : {bt : BT} → isTrue (bt ≼ S) → bt == S
lem-bt≼S {S} bt≼S = refl
lem-bt≼S {D} ()
-- which can also be defined as follows,
-- my_lem-bt≼S : {bt : BT} → isTrue (bt ≼ S) → bt == S
-- my_lem-bt≼S {S} _ = refl
-- my_lem-bt≼S {D} ()
lem-D≼bt : {bt : BT} → isTrue (D ≼ bt) → bt == D
lem-D≼bt {S} ()
lem-D≼bt {D} D≼bt = refl
-- Types of the calculus
mutual
-- s ^ BT
data AType : Set where
Ann : BT → SType → AType
-- int | t -> t
data SType : Set where
SInt : SType
SFun : AType → AType → SType
-- aux definitions
ATInt : BT → AType
ATInt bt = Ann bt SInt
ATFun : BT → AType → AType → AType
ATFun bt at1 at2 = Ann bt (SFun at1 at2)
-- note that the above function labels a ground type with annotations [S] or
-- [D],sort of a labelling function
-- projection: get the BT from a type
btof : AType → BT
btof (Ann bt _) = bt
-- a related function which takes an annotated type as argument and returns
-- the annotation of that type
-- "constraint on types: functions have to be at least as dynamic as their component" should be corrected as follows,
-- arguments of function should be as dynamic as the function
data wft : AType → Set where
wf-int : ∀ {bt} → wft (Ann bt SInt)
wf-fun : ∀ {bt at1 at2} → wft at1 → wft at2
→ isTrue (bt ≼ btof at1) → isTrue (bt ≼ btof at2) → wft (Ann bt (SFun at1 at2))
-- the above proposition specifies a set of well-formed [AType]s,
-- any annotated [SInt]s are well-formed, wft (Ann bt SInt) forall bt ∈ BT
-- in case of functional type with annotation, the following two criteria have
-- to be satisfied to be a well form,
-- a. each of its arguments is well-formed
-- b. the annotation of the function and the annotations of its arguments must
-- satisfy [_≼_] relation
-- for instance, the functional type defined above is well-formed while
-- the following is not,
-- Ann D (
-- SFun (Ann S SInt) (Ann D SInt)
-- )
-- in conclusion,for functional type with annotation to be well-formed,
-- each of its arguments annotations has to be [D] when that of the function
-- is [D] while there is no constraint upon the annotations of its arguments
-- when that of the function is [S]
lem-force-bt : ∀ {bt at} → isTrue (bt ≼ btof at) → D == bt → D == btof at
lem-force-bt {S} bt≼at ()
lem-force-bt {D} {Ann S y'} () D=bt
lem-force-bt {D} {Ann D y'} bt≼at D=bt = refl
-- note the above function takes an element[bt] of type [BT] and a type with
-- annotation,
-- if both
-- a. the type is at least as dynamic as [bt]
-- b. [bt == D]
-- then we know that the annotation of the type must be [D] as well
-- and the function in that case returns evidence for that
-- Low-level types; types wihtout binding information
data Type : Set where
TInt : Type
TFun : Type → Type → Type
-- translation from ATypes to low-level types
mutual
strip : AType → Type
strip (Ann _ σ) = strip' σ
strip' : SType → Type
strip' SInt = TInt
strip' (SFun y y') = TFun (strip y) (strip y')
-- note that the above function [strip] converts a type with annotation [AType]
-- to a low-level type [Type],
-- for instance,
-- strip (Ann D SInt)
-- = strip' SInt
-- = TInt
-- strip (Ann S
-- SFun (Ann S SInt) (Ann D SInt)
-- )
-- = strip' (SFun (Ann S SInt) (Ann D SInt))
-- = TFun (strip (Ann S SInt)) (strip (Ann D SInt))
-- = TFun (strip' SInt) (strip' SInt)
-- = TFun TInt TInt^
-- More general purpose definitions (should also be in standard library)
-- list membership
infix 4 _∈_
data _∈_ {A : Set} : A → List A → Set where
hd : ∀ {x xs} → x ∈ (x ∷ xs)
tl : ∀ {x y xs} → x ∈ xs → x ∈ (y ∷ xs)
-- note the above proposition gives us two constructors for getting
-- evidences for an element being a member of one list
-- end general purpose definitions
-- Typing context
Ctx = List Type
--data Exp' (Γ Γ' : Ctx) : Type → Set where
-- EVar' :
-- Typed expression
data Exp (Γ : Ctx) : Type → Set where
-- [EVar] corresponds to the bounded variables in [AExp]
EVar : ∀ {τ} → τ ∈ Γ → Exp Γ τ
EInt : ℕ → Exp Γ TInt
EFun : ∀ {τ₁ τ₂} → Exp (τ₂ ∷ Γ) τ₁ → Exp Γ (TFun τ₂ τ₁)
EApp : ∀ {τ₁ τ₂} → Exp Γ (TFun τ₂ τ₁) → Exp Γ τ₂ → Exp Γ τ₁
-- one additional term,
count_tl : ∀ {A Γ Γ'} {τ : A } → τ ∈ Γ → Γ cx-≤ Γ' → τ ∈ Γ'
count_tl x (cxle-eq Γ) = x
count_tl x (cxle-lt T e) = tl (count_tl x e)
data _cx=≤_ {A : Set} : List A → List A → Set where
cxle-peq : ∀ {l₁ l₂} { x } → l₁ cx-≤ l₂ → (x ∷ l₁) cx=≤ (x ∷ l₂)
cxle-plt : ∀ {l₁ l₂} { x } → l₁ cx=≤ l₂ → (x ∷ l₁) cx=≤ (x ∷ l₂)
count_tl' : ∀ {A Γ Γ'} {τ : A } → τ ∈ Γ → Γ cx=≤ Γ' → τ ∈ Γ'
count_tl' hd (cxle-plt e) = hd
count_tl' hd (cxle-peq e) = hd
count_tl' (tl xid) (cxle-plt e) = tl (count_tl' xid e)
count_tl' (tl xid) (cxle-peq e) = tl (count_tl xid e)
lem-Exp-weakening' : ∀ {τ₂ τ₁ Γ Γ'} → Exp (τ₂ ∷ Γ) τ₁ → (τ₂ ∷ Γ) cx=≤ (τ₂ ∷ Γ') → Exp (τ₂ ∷ Γ') τ₁
lem-Exp-weakening' (EVar x) e = EVar (count_tl' x e)
lem-Exp-weakening' (EInt n) e = EInt n
lem-Exp-weakening' (EFun t) e = EFun (lem-Exp-weakening' t (cxle-plt e))
lem-Exp-weakening' (EApp t1 t2) e = EApp (lem-Exp-weakening' t1 e) (lem-Exp-weakening' t2 e)
lem-Exp-weakening : ∀ {τ Γ Γ'} → Exp Γ τ → Γ cx-≤ Γ' → Exp Γ' τ
lem-Exp-weakening t (cxle-eq Γ) = t
lem-Exp-weakening (EInt n) e = EInt n
lem-Exp-weakening (EVar x) e = EVar (count_tl x e)
lem-Exp-weakening (EFun t) (cxle-lt T e) = EFun (lem-Exp-weakening' t (cxle-peq (cxle-lt T e)))
lem-Exp-weakening (EApp t1 t2) e = EApp (lem-Exp-weakening t1 e) (lem-Exp-weakening t2 e)
-- typed annotated expressions
ACtx = List AType
data AExp (Δ : ACtx) : AType → Set where
AVar : ∀ {α} → α ∈ Δ → AExp Δ α
AInt : (bt : BT) → ℕ → AExp Δ (ATInt bt)
AFun : ∀ {α₁ α₂} (bt : BT) → wft (ATFun bt α₂ α₁) → AExp (α₂ ∷ Δ) α₁ → AExp Δ (ATFun bt α₂ α₁)
AApp : ∀ {α₁ α₂} (bt : BT) → wft (ATFun bt α₂ α₁) → AExp Δ (ATFun bt α₂ α₁) → AExp Δ α₂ → AExp Δ α₁
-- stripping of contexts
residual : ACtx → Ctx
residual [] = []
residual (Ann S _ ∷ xs) = residual xs
residual (Ann D σ ∷ xs) = strip' σ ∷ residual xs
-- ``semantic domain'' for partially evaluated AExp-terms:
-- - AExp-terms of dynamic type evaluate to Exp-terms
-- - AExp-terms of static type evaluate to agda terms, where SFun
-- are functions and SInt are natural numbers
mutual
impTA : Ctx → AType → Set
impTA Γ (Ann S σ) = impTA' Γ σ
impTA Γ (Ann D σ) = Exp Γ (strip' σ)
impTA' : Ctx → SType → Set
impTA' Γ SInt = ℕ
-- impTA' Γ (SFun y y') = impTA Γ y → impTA Γ y'
impTA' Γ (SFun y y') = ∀ {Γ'} → Γ cx-≤ Γ' → impTA Γ' y → impTA Γ' y'
lem-impTA-weakening : ∀ {α Γ Γ'} →
impTA Γ α →
Γ cx-≤ Γ' →
impTA Γ' α
lem-impTA-weakening {Ann S SInt} v _ = v
lem-impTA-weakening {Ann S (SFun x x₁)} f prf = λ prf' → f (lem-cx-≤-trans prf prf')
lem-impTA-weakening {Ann D x₁} v prf = lem-Exp-weakening v prf
-- mutual
-- impTA-try : Ctx → AType → Set
-- impTA-try Γ (Ann S σ) = impTA-try' Γ σ
-- impTA-try Γ (Ann D σ) = Exp Γ (strip' σ)
-- impTA-try' : Ctx → SType → Set
-- impTA-try' Γ SInt = ℕ
-- impTA-try' Γ (SFun y y') = impTA-try Γ y → impTA-try Γ y'
-- lem-impTA-try-weakening : ∀ {α Γ Γ'} →
-- impTA-try Γ α →
-- Γ cx-≤ Γ' →
-- impTA-try Γ' α
-- lem-impTA-try-weakening {Ann S SInt} v _ = v
-- lem-impTA-try-weakening {Ann S (SFun α x₁)} {Γ} {Γ'} f prf = {! λ (v : impTA-try Γ' α) → f v!}
-- lem-impTA-try-weakening {Ann D x₁} v prf = lem-Exp-weakening v prf
data AEnv : Ctx → ACtx → Set where
env[] : ∀ {Γ} → AEnv Γ []
envS:: : ∀ {Γ Δ} {α} →
impTA Γ α →
AEnv Γ Δ →
AEnv Γ (α ∷ Δ)
envD:: : ∀ {Γ Δ} →
(σ : SType) →
impTA (strip' σ ∷ Γ) (Ann D σ) →
AEnv Γ Δ →
AEnv (strip' σ ∷ Γ) (Ann D σ ∷ Δ)
lem-AEnv-weakening : ∀ {Γ Γ' Δ} → AEnv Γ Δ → Γ cx-≤ Γ' → AEnv Γ' Δ
lem-AEnv-weakening env[] prf = env[]
lem-AEnv-weakening (envS:: {α = α} x env) prf = envS:: (lem-impTA-weakening {α} x prf) (lem-AEnv-weakening env prf)
lem-AEnv-weakening (envD:: {Γ} σ x env) prf = envS:: (lem-impTA-weakening {Ann D σ} x prf) (lem-AEnv-weakening env (lem-cx-≤-trans (cxle-lt (strip' σ) (cxle-eq Γ)) prf)) -- non-primitive recursion... this should be fixable by extending Γ in the middle, rather than in the end
lookup : ∀ {Γ Δ α} → AEnv Γ Δ → (o : α ∈ Δ ) → impTA Γ α
lookup env[] ()
lookup (envS:: x env) hd = x
lookup (envS:: x env) (tl idx) = lookup env idx
lookup (envD:: σ x env) hd = x
lookup {α = α} (envD:: {Γ} σ x env) (tl idx) = lem-impTA-weakening {α} (lookup env idx) (strip' σ cxle-∷ Γ)
data IsDynamic : AType → Set where
is-dyn : ∀ σ → IsDynamic (Ann D σ)
lem-IsDynamic-by-wf : ∀ α → isTrue (D ≼ btof α) → IsDynamic α
lem-IsDynamic-by-wf (Ann S σ) ()
lem-IsDynamic-by-wf (Ann D σ) _ = is-dyn σ
-- TODO: Do we need additional assurance in the type signature (or as
-- an aux. lemma) that Γ is the residue of Δ?
pe : ∀ {Δ Γ α} → AEnv Γ Δ → AExp Δ α → impTA Γ α
pe env (AVar idx) = lookup env idx
pe env (AInt S i) = i
pe env (AInt D i) = EInt i
pe {Γ = Γ} env (AFun {α₁} {α₂} S prf exp) = λ {Γ'} (prf₁ : Γ cx-≤ Γ') (v : impTA Γ' α₂) →
pe (envS:: v (lem-AEnv-weakening env prf₁)) exp
pe env (AFun {α₁} {α₂} D (wf-fun _ _ prf-2 prf-1) e)
with lem-IsDynamic-by-wf α₁ prf-1 | lem-IsDynamic-by-wf α₂ prf-2
pe {Γ = Γ} env (AFun {.(Ann D σ₁)} {.(Ann D σ₂)} D (wf-fun _ _ prf-1 prf-2) e)
| is-dyn σ₁ | is-dyn σ₂ =
EFun (pe (envD:: σ₂ (EVar hd) env) e)
pe {Γ = Γ} env (AApp S _ f e) = (pe env f (cxle-eq Γ)) (pe env e)
pe env (AApp {α₁} {α₂} D (wf-fun _ _ prf-2 prf-1) f e)
with lem-IsDynamic-by-wf α₁ prf-1 | lem-IsDynamic-by-wf α₂ prf-2
pe env (AApp {.(Ann D σ₁)}{.(Ann D σ₂)} D (wf-fun _ _ prf-2 prf-1) f e)
| is-dyn σ₁ | is-dyn σ₂ =
EApp (pe env f) (pe env e) -- construct an Exp-application using the proof that argument and results are dynamic and thus pe yields Exp-terms for them
|
test/Succeed/Issue1227.agda | hborum/agda | 3 | 10174 | <gh_stars>1-10
open import Common.Prelude hiding (pred)
open import Common.Reflection
open import Common.Equality
un-function : Definition → FunDef
un-function (funDef cs) = funDef unknown cs
un-function _ = funDef unknown []
data Is-suc : Nat → Set where
is-suc : ∀ n → Is-suc (suc n)
pred : (n : Nat) → Is-suc n → Nat
pred ._ (is-suc n) = n
pred-def : FunDef
pred-def =
funDef (quoteTerm ((n : Nat) → Is-suc n → Nat))
(clause (vArg dot ∷ vArg (con (quote is-suc) (vArg (var "n") ∷ [])) ∷ [])
(var 0 []) ∷ [])
data Is-zero : Nat → Set where
is-zero : Is-zero zero
f : (n : Nat) → Is-zero n → Nat
f ._ is-zero = zero
f-def : FunDef
f-def =
funDef (quoteTerm ((n : Nat) → Is-zero n → Nat))
(clause (vArg dot ∷ vArg (con (quote is-zero) []) ∷ [])
(con (quote zero) []) ∷ [])
unquoteDecl pred' = define (vArg pred') pred-def
unquoteDecl f' = define (vArg f') f-def
check-pred : pred' 4 (is-suc _) ≡ 3
check-pred = refl
check-f : f' 0 is-zero ≡ 0
check-f = refl
|
libsrc/_DEVELOPMENT/arch/zx/display/z80/asm_zx_aaddrcleft.asm | jpoikela/z88dk | 640 | 95366 |
; ===============================================================
; Jun 2007
; ===============================================================
;
; void *zx_aaddrcleft(void *attraddr)
;
; Modify attribute address to move left one character square.
; Movement wraps from column 0 to column 31 of previous row.
;
; ===============================================================
INCLUDE "config_private.inc"
SECTION code_clib
SECTION code_arch
PUBLIC asm_zx_aaddrcleft
asm_zx_aaddrcleft:
; enter : hl = valid attribute address
;
; exit : hl = new attribute address moved left one char square
; carry set if new attribute address is off screen
;
; uses : af, hl
dec hl
ld a,h
IF __USE_SPECTRUM_128_SECOND_DFILE
cp $d8
ELSE
cp $58
ENDIF
ret
|
alloy4fun_models/trashltl/models/12/BkvemgeCjLk8XcY8m.als | Kaixi26/org.alloytools.alloy | 0 | 2903 | open main
pred idBkvemgeCjLk8XcY8m_prop13 {
always all f: File | f not in Trash until f in Trash
}
pred __repair { idBkvemgeCjLk8XcY8m_prop13 }
check __repair { idBkvemgeCjLk8XcY8m_prop13 <=> prop13o } |
test/Fail/Cumulativity-bad-meta-solution.agda | cruhland/agda | 1,989 | 10652 | <filename>test/Fail/Cumulativity-bad-meta-solution.agda
{-# OPTIONS --cumulativity #-}
postulate
F : (X : Set) → X → Set
X : Set₁
a : X
shouldfail : F _ a
|
FormalAnalyzer/models/meta/cap_odorSensor.als | Mohannadcse/IoTCOM_BehavioralRuleExtractor | 0 | 4838 | <gh_stars>0
// filename: cap_odorSensor.als
module cap_odorSensor
open IoTBottomUp
one sig cap_odorSensor extends Capability {}
{
attributes = cap_odorSensor_attr
}
abstract sig cap_odorSensor_attr extends Attribute {}
one sig cap_odorSensor_attr_odorLevel extends cap_odorSensor_attr {}
{
values = cap_odorSensor_attr_odorLevel_val
}
abstract sig cap_odorSensor_attr_odorLevel_val extends AttrValue {}
|
source/function/graphics/pixel.asm | mega65dev/rom-assembler | 0 | 18778 | <reponame>mega65dev/rom-assembler
; ********************************************************************************************
; ********************************************************************************************
;
; Name : pixel.asm
; Purpose : ..
; Created : 15th Nov 1991
; Updated : 4th Jan 2021
; Authors : <NAME>
;
; ********************************************************************************************
; ********************************************************************************************
; Return the color of a given X,Y pixel location on the drawscreen [910801]
; PIXEL (x,y)
pixel jsr CheckGraphicMode ; verify screen open
jsr PushParms ; preserve Graphics parameters & LINNUM [910820]
jsr getsad ; get x
sty GKI__parm1
sta GKI__parm2
jsr comsad ; get y
sty GKI__parm3
sta GKI__parm4
jsr chkcls ; check for closing parens
jsr ($8032) ; get Bitplane data at pixel (x,y), returned in .y
jsr sngflt ; go float 1 byte arg in .Y
jsr PopParms ; restore graphics parameters
rts
; ********************************************************************************************
;
; Date Changes
; ==== =======
;
; ********************************************************************************************
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/pack6.adb | best08618/asylo | 7 | 26354 | <reponame>best08618/asylo<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/pack6.adb
-- { dg-do compile }
-- { dg-options "-gnatws" }
procedure Pack6 is
type R is record
I : Integer;
a, b, c, d, e : Character;
end record;
type Ar1 is array (1..4) of R;
type Ar2 is array (1..4) of R;
pragma Pack (Ar2);
type R2 is record
A : Ar2;
end record;
for R2 use record
A at 0 range 0 .. 72*4-1;
end record;
X : Ar1;
Y : Ar2;
begin
Y (1) := X (1);
end;
|
test/Succeed/PiInSet.agda | shlevy/agda | 1,989 | 7368 |
module PiInSet where
Rel : Set -> Set1
Rel A = A -> A -> Set
Reflexive : {A : Set} -> Rel A -> Set
Reflexive {A} _R_ = forall x -> x R x
Symmetric : {A : Set} -> Rel A -> Set
Symmetric {A} _R_ = forall x y -> x R y -> y R x
data True : Set where
tt : True
data False : Set where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
_==_ : Rel Nat
zero == zero = True
zero == suc _ = False
suc _ == zero = False
suc n == suc m = n == m
refl== : Reflexive _==_
refl== zero = tt
refl== (suc n) = refl== n
sym== : Symmetric _==_
sym== zero zero tt = tt
sym== zero (suc _) ()
sym== (suc _) zero ()
sym== (suc n) (suc m) n==m = sym== n m n==m
|
programs/oeis/070/A070441.asm | neoneye/loda | 22 | 160219 | ; A070441: n^2 mod 19.
; 0,1,4,9,16,6,17,11,7,5,5,7,11,17,6,16,9,4,1,0,1,4,9,16,6,17,11,7,5,5,7,11,17,6,16,9,4,1,0,1,4,9,16,6,17,11,7,5,5,7,11,17,6,16,9,4,1,0,1,4,9,16,6,17,11,7,5,5,7,11,17,6,16,9,4,1,0,1,4,9,16,6,17,11,7,5,5,7,11,17,6,16,9,4,1,0,1,4,9,16
pow $0,2
mod $0,19
|
Engines/Win32/badf00d.asm | Mingzhi5/MalwareRepository | 0 | 5196 | <reponame>Mingzhi5/MalwareRepository<gh_stars>0
M0_EAX equ 0
M0_ECX equ 1
M0_EDX equ 2
M0_EBX equ 3
M0_ESI equ 4
M0_EDI equ 5
M1_EAX equ 0
M1_ECX equ 1
M1_EDX equ 2
M1_EBX equ 3
M1_ESI equ 6
M1_EDI equ 7
M2_EAX equ 0 shl 3
M2_ECX equ 1 shl 3
M2_EDX equ 2 shl 3
M2_EBX equ 3 shl 3
M2_ESI equ 6 shl 3
M2_EDI equ 7 shl 3
; -------------- MAIN REGISTERS TABLES ----------------------------------------
x1_table: db M1_EAX
db M1_ECX
db M1_EDX
db M1_EBX
db M1_ESI
db M1_EDI
x1_tbl_size = $ - offset x1_table
x2_table: db M2_EAX
db M2_ECX
db M2_EDX
db M2_EBX
db M2_ESI
db M2_EDI
x2_tbl_size = $ - offset x2_table
; -------------- INSTRUCTION TABLES -------------------------------------------
; FORMAT: (1 BYTE) (BYTE) (BYTE) (BYTE)
; <OPCODE> <MODRM> <LEN> <CSET>
;
; if there is no MODRM, MODRM must be set to 2Dh (temp)
NO_M equ 02dh
C_NONE equ 0
C_SRC equ 1
C_DST equ 2
C_BOTH equ 3
allowed_regs: db M0_EAX, M0_ECX, M0_EDX, M0_EBX, M0_ESI, M0_EDI
instr_table: db 0f9h, NO_M, 1h, C_NONE ; stc
db 0EBh, NO_M, 2h, C_NONE ; jmp $+1
db 0c7h, 0c0h, 6h, C_SRC ; mov reg(EAX),NUM
db 08bh, 0c0h, 2h, C_BOTH ; mov reg(EAX),reg(EAX)
db 081h, 0c0h, 6h, C_SRC ; add reg(EAX),NUM
db 003h, 0c0h, 2h, C_BOTH ; add reg(EAX),reg(EAX)
db 081h, 0e8h, 6h, C_SRC ; sub reg(EAX),NUM
db 02bh, 0c0h, 2h, C_BOTH ; sub reg(EAX),reg(EAX)
db 040h, NO_M, 1h, C_SRC ; inc reg(EAX)
db 048h, NO_M, 1h, C_SRC ; dec reg(EAX)
_i_xor_r db 033h, 0c0h, 2h, C_BOTH ; xor reg(EAX),reg(EAX)
db 009h, 0c0h, 2h, C_BOTH ; or reg(EAX),reg(EAX)
db 081h, 0c8h, 6h, C_SRC ; or reg(EAX),NUM
db 03bh, 0c0h, 2h, C_BOTH
db 085h, 0c0h, 2h, C_BOTH
db 01bh, 0c0h, 2h, C_BOTH ; sbb reg(EAX),reg(EAX)
db 011h, 0c0h, 2h, C_BOTH ; adc reg(EAX),reg(EAX)
db 0f7h, 0d0h, 2h, C_SRC ; not reg(EAX)
db 0f7h, 0d8h, 2h, C_SRC ; neg reg(EAX)
db 0d1h, 0f8h, 2h, C_SRC ; sar reg(EAX),1
db 0d1h, 0d8h, 2h, C_SRC ; rcr reg(EAX),1
db 0d1h, 0d0h, 2h, C_SRC ; rcl reg(EAX),1
db 091h, NO_M, 1h, C_SRC ; xchg reg(EAX),reg(ECX)
db 090h, NO_M, 1h, C_NONE ; nop
db 0fch, NO_M, 1h, C_NONE ; cld
db 0f8h, NO_M, 1h, C_NONE ; clc
db 0fdh, NO_M, 1h, C_NONE ; std
db 09bh, NO_M, 1h, C_NONE ; wait
db 050h, NO_M, 1h, C_SRC ; push reg(eax)
_i_pop db 058h, NO_M, 1h, C_SRC ; pop reg(eax) (must be last one)
ENTRY_TABLE_SIZE = 4
instr_table_size = (($-offset instr_table)/4)
dd 0
push_number dd 0
do_push db 1 ; should we process pushs?
O_JMP equ 0EBh
O_PUSH equ 050h
O_POP equ 058h
i_jmp: db 0EBh, NO_M, 2h ; jmp $+1
; -------------- GARBAGE GENERATOR (SAFE) ------------------------------------
; EDI = where
; ----------------------------------------------------------------------------
gen_garbage_i:
pushad
garbage_again:
mov eax,instr_table_size
call random_eax
lea esi,instr_table
mov ecx,ENTRY_TABLE_SIZE
mul ecx ; eax=member from table to use
add esi,eax
jmp garbage_co
garbage_hand: pushad
garbage_co: lodsw ; ah = modrm value / al=opcode
cmp ah,NO_M
je no_modrm
stosb ; store opcode
xor edx,edx
mov dl,ah
cmp byte ptr [esi+1],C_BOTH ; what registers to mutate
je p_01
cmp byte ptr [esi+1],C_SRC
jne t_01
p_01: and dl,0F8h
mov eax,x1_tbl_size
call random_eax
mov al,byte ptr [allowed_regs[eax]]
mov al,byte ptr [x1_table[eax]]
or dl,al
mov byte ptr [edi],dl
t_01: cmp byte ptr [esi+1],C_BOTH ; what registers to mutate
je p_02
cmp byte ptr [esi+1],C_DST
jne finish_i
p_02: and dl,0C7h
mov eax,x2_tbl_size
call random_eax
mov al,byte ptr [allowed_regs[eax]]
mov al,byte ptr [x2_table[eax]]
or dl,al ; update modrm value
mov byte ptr [edi],dl
finish_i: mov cl,byte ptr [esi]
sub cl,2
inc edi
cmp cl,0
jle garbage_done
store_op: mov eax,12345678h
call random_eax
stosb
loop store_op
garbage_done: xor eax,eax
mov al,byte ptr [esi]
mov [esp+PUSHA_STRUCT._EAX],eax
popad
ret
; ----------------------------------------------------
; NO MOD-RMs
; ----------------------------------------------------
no_modrm: xor edx,edx
mov dl,al
cmp byte ptr [esi+1],C_NONE
je t_none
cmp dl,O_PUSH
je t_push
cmp dl,O_POP
je t_pop
go_nomodrm: mov eax,x1_tbl_size
call random_eax
mov al,byte ptr [allowed_regs[eax]]
mov al,byte ptr [x1_table[eax]]
and dl,0F8h
or dl,al
mov byte ptr [edi],dl
inc edi
jmp finish_i
t_none: mov byte ptr [edi],dl
inc edi
cmp dl,O_JMP
jne finish_i
mov byte ptr [edi],0
inc edi
jmp finish_i
t_push: cmp byte ptr [do_push],1
jne garbage_again
inc dword ptr [push_number]
jmp go_nomodrm
t_pop: cmp byte ptr [do_push],1
jne garbage_again
cmp dword ptr [push_number],0
jle garbage_again
dec dword ptr [push_number]
jmp go_nomodrm
t_normalize_pops:
pushad
xor ebx,ebx
mov ecx,dword ptr [push_number]
test ecx,ecx
jz t_opsexit
t_givepops: lea esi,_i_pop
call garbage_hand
add edi,eax
add ebx,eax
loop t_givepops
t_opsexit: mov [esp+PUSHA_STRUCT._EAX],ebx
popad
ret
; ---------------------------------------------------------------------------
; HARDCORE GARBAGER
; ---------------------------------------------------------------------------
; EDI = where to store
;
; This one generates code like this:
; jmp over_garbage
; <totally random generated garbage>
; <normal garbage>
; max: up to 20 "instructions"
; ---------------------------------------------------------------------------
hardcode_garbage_i:
pushad
mov ebx,edi
lea edi,hardcore_temp
mov eax,20
call random_eax
mov ecx,eax
add ecx,4
h_fill: mov eax,2
call random_eax
test eax,eax
jnz h_hard
call gen_garbage_i
jmp h_cont
h_hard: mov eax,5
call random_eax
mov edx,eax
inc edx
xor esi,esi
h_hard_fill: mov eax,0FFFFh
call random_eax
stosb
inc esi
dec edx
jnz h_hard_fill
loop h_fill
jmp h_done
h_cont: add edi,eax
loop h_fill
h_done: lea ecx,hardcore_temp
sub edi,ecx
mov ecx,edi
mov byte ptr [ebx],O_JMP
inc ebx
mov byte ptr [ebx],cl
inc ebx
push ecx
mov edi,ebx
lea esi,hardcore_temp
rep movsb
pop eax
add eax,2
mov [esp+PUSHA_STRUCT._EAX],eax
popad
ret
; -------------------------------------------------------------
; Generates backwards jumps
; -------------------------------------------------------------
; EDI = buffor
gen_bjumps:
pushad
mov ebx,edi
mov byte ptr [jmp_flag],0
mov byte ptr [jmp_flag_b],0
mov dword ptr [count_jmp],0
mov dword ptr [where_where],0
mov dword ptr [jmp_bytes],0
mov byte ptr [do_push],0
mov byte ptr [where_losed],0
mov byte ptr [ebx],O_JMP
mov dword ptr [where_start],ebx
add dword ptr [where_start],2
inc ebx
xor esi,esi
add edi,2
add dword ptr [jmp_bytes],2
gen_gar_i: mov eax,20
call random_eax
mov ecx,eax
add ecx,10
gen_gar_ii: call gen_garbage_i
add dword ptr [jmp_bytes],eax
add esi,eax
add edi,eax
cmp byte ptr [jmp_flag],1
jne gen_gari_ix
add dword ptr [count_jmp],eax
jmp gen_gari_ixx
gen_gari_ix: push eax
mov eax,2
call random_eax
mov edx,eax
pop eax
cmp byte ptr [where_losed],1
je gen_gari_ixx
add dword ptr [where_start],eax
cmp edx,1
je gen_gari_ixx
mov byte ptr [where_losed],1
gen_gari_ixx: mov eax,3
call random_eax
cmp eax,2
jne cont_gari
cmp byte ptr [jmp_flag],1
je cont_gari
mov byte ptr [jmp_flag],1
mov byte ptr [edi],O_JMP
inc edi
mov dword ptr [where_jmp],edi
inc edi
add esi,2
cont_gari: loop gen_gar_ii
mov eax,esi
mov byte ptr [ebx],al
cmp byte ptr [jmp_flag],1
je cont_gari2
mov byte ptr [edi],O_JMP
inc edi
mov dword ptr [where_jmp],edi
inc edi
cont_gari2: mov dword ptr [where_where],edi
add dword ptr [jmp_bytes],2
mov eax,5
call random_eax
inc eax
mov ecx,eax
cont_gari3: call gen_garbage_i
add dword ptr [jmp_bytes],eax
add edi,eax
add dword ptr [count_jmp],eax
loop cont_gari3
mov byte ptr [edi],O_JMP
mov eax,edi
sub eax,dword ptr [where_start]
add eax,2
neg eax
pushad
add edi,2
mov eax,4
call random_eax
mov ecx,eax
test ecx,ecx
jz cont_gari4
place_gar: mov eax,0FFh
call random_eax
inc dword ptr [count_jmp]
inc dword ptr [jmp_bytes]
stosb
loop place_gar
cont_gari4: add dword ptr [count_jmp],2
mov eax,dword ptr [count_jmp]
mov edx,dword ptr [where_jmp]
mov byte ptr [edx],al
popad
mov byte ptr [edi+1],al
add dword ptr [jmp_bytes],2
mov edx,dword ptr [where_where]
sub edx,dword ptr [where_jmp]
dec edx
mov ecx,edx
mov edx,dword ptr [where_jmp]
inc edx
cmp ecx,0
jle cont_no_xor
cont_xor: mov eax,0FFh
call random_eax
xor byte ptr [edx],al
inc edx
loop cont_xor
cont_no_xor: mov byte ptr [do_push],1
mov edx,dword ptr [jmp_bytes]
mov [esp+PUSHA_STRUCT._EAX],edx
popad
ret
jmp_bytes dd 0
where_losed db 0
where_where dd 0
where_start dd 0
count_jmp dd 0
where_jmp dd 0
jmp_flag db 0
jmp_flag_b db 0
; -------------------------------------------------------------
; Generates SEH frames/exceptions/etc.
; -------------------------------------------------------------
; EDI = buffor
FS_PREFIX equ 064h
seh_push_fs db 0ffh, 030h, 2h, C_SRC
seh_mov_fs db 089h, 020h, 2h, C_SRC
seh_pop_fs db 08fh, 000h, 2h, C_SRC
_mov_reg_esp db 08bh, 0c4h, 2h, C_DST ; mov reg,ESP
_add_reg_num db 081h, 0c0h, 2h, C_SRC ; add reg,NUM (we must typo NUM by hand: 4) LEN=6
_mov_reg_oreg db 08bh, 000h, 2h, C_BOTH ; mov reg,[REG]
_mov_dreg_num db 0c7h, 080h, 2h, C_SRC ; mov [reg+NUM],0 (add NUM by hand) LEN: A
_add_dreg_num db 081h, 080h, 2h, C_SRC
exception_table:
db 0CCh ; int 3
db 0fah ; cli
db 0fbh ; sti
exception_table_size = $-offset exception_table
gen_seh:
pushad
xor edx,edx
mov ebx,edi
mov byte ptr [edi],0E8h
mov dword ptr [edi+1],0
add edx,5
add edi,5
push edi
lea esi,allowed_regs
mov ecx,x1_tbl_size
push esi
push ecx
lea edi,allowed_regs_temp
rep movsb
pop ecx
pop edi
pushad
mov eax,x1_tbl_size
call random_eax
cmp eax,M0_EAX
jne reg_p
inc eax ; somehow :) EAX usage results with invalid disposition error
reg_p: rep stosb
mov edi,[esp+PUSHA_STRUCT_SIZE]
lea esi,_mov_reg_esp
call garbage_hand
add dword ptr [esp+PUSHA_STRUCT._EDX],eax
add [esp+PUSHA_STRUCT_SIZE],eax
add edi,eax
lea esi,_add_reg_num
call garbage_hand
add edi,2
mov dword ptr [edi],0Ch
add dword ptr [esp+PUSHA_STRUCT._EDX],6
add [esp+PUSHA_STRUCT_SIZE],6
add edi,4
lea esi,_mov_reg_oreg
call garbage_hand
add dword ptr [esp+PUSHA_STRUCT._EDX],eax
add [esp+PUSHA_STRUCT_SIZE],eax
add edi,eax
lea esi,_mov_dreg_num
call garbage_hand
add dword ptr [esp+PUSHA_STRUCT._EDX],0ah
add [esp+PUSHA_STRUCT_SIZE],0ah
add edi,2
mov dword ptr [edi],04h
mov dword ptr [edi+4],0h
add edi,0ah-2
lea esi,_mov_dreg_num
call garbage_hand
add dword ptr [esp+PUSHA_STRUCT._EDX],0ah
add [esp+PUSHA_STRUCT_SIZE],0ah
add edi,2
mov dword ptr [edi],08h
mov dword ptr [edi+4],0h
add edi,0ah-2
lea esi,_mov_dreg_num
call garbage_hand
add dword ptr [esp+PUSHA_STRUCT._EDX],0ah
add [esp+PUSHA_STRUCT_SIZE],0ah
add edi,2
mov dword ptr [edi],12h
mov dword ptr [edi+4],0h
add edi,0ah-2
lea esi,_mov_dreg_num
call garbage_hand
add dword ptr [esp+PUSHA_STRUCT._EDX],0ah
add [esp+PUSHA_STRUCT_SIZE],0ah
add edi,2
mov dword ptr [edi],16h
mov dword ptr [edi+4],0h
add edi,0ah-2
lea esi,_add_dreg_num
call garbage_hand
add dword ptr [esp+PUSHA_STRUCT._EDX],0ah+1
add [esp+PUSHA_STRUCT_SIZE],0ah+1
add edi,2
mov dword ptr [edi],0b8h
add edi,4
mov dword ptr [where_over],edi
add edi,0ah-6
mov byte ptr [edi],0C3h ; ret
inc edi
popad
mov byte ptr [ebx+1],dl
sub byte ptr [ebx+1],5
mov eax,x1_tbl_size
call random_eax
rep stosb
pop edi
lea esi,_i_xor_r
call garbage_hand
add edi,eax
add edx,eax
mov byte ptr [edi],FS_PREFIX
inc edi
inc edx
lea esi,seh_push_fs
call garbage_hand
add edi,eax
add edx,eax
mov byte ptr [edi],FS_PREFIX
inc edi
inc edx
lea esi,seh_mov_fs
call garbage_hand
add edi,eax
add edx,eax
call reset_regs
xor ebx,ebx
mov eax,exception_table_size
call random_eax
mov cl,byte ptr exception_table[eax]
mov byte ptr [edi],cl
inc edx
inc edi
inc ebx
call fill_trash
add edx,eax
add ebx,eax
add edi,eax
push edi
mov edi,dword ptr [where_over]
mov dword ptr [edi],ebx
pop edi
call finalize_seh
add edx,eax
mov [esp+PUSHA_STRUCT._EAX],edx
popad
ret
where_over dd 0
allowed_regs_temp db x1_tbl_size dup (0)
finalize_seh:
pushad
call gen_regs
xor edx,edx
lea esi,_i_xor_r
call garbage_hand
add edi,eax
add edx,eax
mov byte ptr [edi],FS_PREFIX
inc edi
inc edx
lea esi,seh_pop_fs
call garbage_hand
add edi,eax
add edx,eax
call reset_regs
inc dword ptr [push_number]
lea esi,_i_pop
call garbage_hand
add edx,eax
add edi,eax
mov [esp+PUSHA_STRUCT._EAX],edx
popad
ret
fill_trash: pushad
xor ebx,ebx
mov eax,20
call random_eax
mov ecx,eax
test eax,eax
jz done_fill_trash
fill_trash_x: mov eax,0FFh
call random_eax
stosb
inc ebx
loop fill_trash_x
done_fill_trash:
mov [esp+PUSHA_STRUCT._EAX],ebx
popad
ret
reset_regs:
pushad
lea esi,allowed_regs_temp
mov ecx,x1_tbl_size
lea edi,allowed_regs
rep movsb
popad
ret
gen_regs: pushad
mov eax,x1_tbl_size
call random_eax
lea edi,allowed_regs
mov ecx,x1_tbl_size
rep stosb
popad
ret
set_random: pushad
mov eax,6
call random_eax
cmp eax,5
jne not_set
call gen_bjumps
jmp le_set
not_set: xor eax,eax
le_set: mov [esp+PUSHA_STRUCT._EAX],eax
popad
ret
random_setup proc
@callx GetTickCount
mov Random_Seed,eax
ret
random_setup endp
Random_Seed dd 0
random_eax proc
PUSH ECX
PUSH EDX
PUSH EAX
db 0Fh, 31h ; RDTSC
MOV ECX, Random_Seed
ADD EAX, ECX
ROL ECX, 1
ADD ECX, 666h
MOV Random_Seed, ECX
PUSH 32
POP ECX
CRC_Bit: SHR EAX, 1
JNC Loop_CRC_Bit
XOR EAX, 0EDB88320h
Loop_CRC_Bit: LOOP CRC_Bit
POP ECX
XOR EDX, EDX
DIV ECX
XCHG EDX, EAX
OR EAX, EAX
POP EDX
POP ECX
RETN
random_eax endp
|
autovectorization-tests/results/msvc19.28.29333-avx512/replace.asm | clayne/toys | 0 | 13494 | <gh_stars>0
_v$ = 8 ; size = 4
void replace_epi32(std::vector<int,std::allocator<int> > &) PROC ; replace_epi32, COMDAT
mov eax, DWORD PTR _v$[esp-4]
mov ecx, DWORD PTR [eax+4]
mov eax, DWORD PTR [eax]
cmp eax, ecx
je SHORT $LN17@replace_ep
npad 3
$LL23@replace_ep:
cmp DWORD PTR [eax], 13 ; 0000000dH
jne SHORT $LN29@replace_ep
mov DWORD PTR [eax], 42 ; 0000002aH
$LN29@replace_ep:
add eax, 4
cmp eax, ecx
jne SHORT $LL23@replace_ep
$LN17@replace_ep:
ret 0
void replace_epi32(std::vector<int,std::allocator<int> > &) ENDP ; replace_epi32
_v$ = 8 ; size = 4
void replace_epi8(std::vector<signed char,std::allocator<signed char> > &) PROC ; replace_epi8, COMDAT
mov eax, DWORD PTR _v$[esp-4]
mov ecx, DWORD PTR [eax+4]
mov eax, DWORD PTR [eax]
cmp eax, ecx
je SHORT $LN17@replace_ep
npad 3
$LL23@replace_ep:
cmp BYTE PTR [eax], 13 ; 0000000dH
jne SHORT $LN29@replace_ep
mov BYTE PTR [eax], 42 ; 0000002aH
$LN29@replace_ep:
inc eax
cmp eax, ecx
jne SHORT $LL23@replace_ep
$LN17@replace_ep:
ret 0
void replace_epi8(std::vector<signed char,std::allocator<signed char> > &) ENDP ; replace_epi8
|
libsrc/target/radio86/stdio/getk.asm | ahjelm/z88dk | 640 | 164869 |
SECTION code_clib
PUBLIC getk
PUBLIC _getk
INCLUDE "target/radio86/def/monitor.def"
getk:
_getk:
call QUERYKEY
ld hl,0
and a
ret z
call WAITKEY
ld l,a
ret
|
pwnlib/shellcraft/templates/aarch64/linux/linkat.asm | IMULMUL/python3-pwntools | 325 | 96512 | <%
from pwnlib.shellcraft.aarch64.linux import syscall
%>
<%page args="fromfd, from_, tofd, to, flags"/>
<%docstring>
Invokes the syscall linkat. See 'man 2 linkat' for more information.
Arguments:
fromfd(int): fromfd
from(char): from
tofd(int): tofd
to(char): to
flags(int): flags
</%docstring>
${syscall('SYS_linkat', fromfd, from_, tofd, to, flags)}
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca_notsx.log_12_1569.asm | ljhsiun2/medusa | 9 | 166976 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r14
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0xe84f, %rsi
lea addresses_normal_ht+0x24f, %rdi
clflush (%rdi)
nop
nop
cmp %r12, %r12
mov $27, %rcx
rep movsl
sub %r14, %r14
lea addresses_WC_ht+0xfe57, %rsi
lea addresses_D_ht+0x1b6cf, %rdi
nop
nop
nop
cmp $46136, %rax
mov $104, %rcx
rep movsb
nop
nop
nop
nop
nop
cmp $59370, %rdi
lea addresses_A_ht+0x1709f, %rsi
lea addresses_WC_ht+0x1ab5f, %rdi
sub $33307, %r10
mov $16, %rcx
rep movsl
nop
nop
nop
nop
sub $31882, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r14
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %rax
push %rbx
push %rdi
push %rdx
// Store
lea addresses_WT+0x1624f, %rax
and $368, %rdi
mov $0x5152535455565758, %rbx
movq %rbx, %xmm0
vmovups %ymm0, (%rax)
sub $43489, %r14
// Store
mov $0x7e66cc0000000c73, %r13
clflush (%r13)
nop
nop
nop
nop
xor $45777, %rbx
mov $0x5152535455565758, %rdx
movq %rdx, (%r13)
nop
nop
sub $49747, %r13
// Faulty Load
lea addresses_PSE+0x724f, %r14
clflush (%r14)
nop
nop
nop
and %r13, %r13
mov (%r14), %rax
lea oracles, %r14
and $0xff, %rax
shlq $12, %rax
mov (%r14,%rax,1), %rax
pop %rdx
pop %rdi
pop %rbx
pop %rax
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': True, 'congruent': 9, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_normal_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_D_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_WC_ht'}}
{'33': 12}
33 33 33 33 33 33 33 33 33 33 33 33
*/
|
arpserv.asm | jahzielv/xv6-net | 0 | 99080 |
_arpserv: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "types.h"
#include "user.h"
int main(void) {
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 51 push %ecx
e: 83 ec 14 sub $0x14,%esp
while (1) {
int status = arpserv("mynet0");
11: 83 ec 0c sub $0xc,%esp
14: 68 60 10 00 00 push $0x1060
19: e8 72 03 00 00 call 390 <arpserv>
1e: 83 c4 10 add $0x10,%esp
21: 89 45 f4 mov %eax,-0xc(%ebp)
printf(1, "Served ARP request!\n");
24: 83 ec 08 sub $0x8,%esp
27: 68 67 10 00 00 push $0x1067
2c: 6a 01 push $0x1
2e: e8 40 04 00 00 call 473 <printf>
33: 83 c4 10 add $0x10,%esp
if(status < 0)
36: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
3a: 78 17 js 53 <main+0x53>
break;
else
printf(1, "Status: %d\n", status);
3c: 83 ec 04 sub $0x4,%esp
3f: ff 75 f4 pushl -0xc(%ebp)
42: 68 7c 10 00 00 push $0x107c
47: 6a 01 push $0x1
49: e8 25 04 00 00 call 473 <printf>
4e: 83 c4 10 add $0x10,%esp
while (1) {
51: eb be jmp 11 <main+0x11>
break;
53: 90 nop
}
exit();
54: e8 87 02 00 00 call 2e0 <exit>
00000059 <stosb>:
asm volatile("outl %0,%w1" : : "a" (data), "d" (port));
}
static inline void
stosb(void *addr, int data, int cnt)
{
59: 55 push %ebp
5a: 89 e5 mov %esp,%ebp
5c: 57 push %edi
5d: 53 push %ebx
asm volatile("cld; rep stosb" :
5e: 8b 4d 08 mov 0x8(%ebp),%ecx
61: 8b 55 10 mov 0x10(%ebp),%edx
64: 8b 45 0c mov 0xc(%ebp),%eax
67: 89 cb mov %ecx,%ebx
69: 89 df mov %ebx,%edi
6b: 89 d1 mov %edx,%ecx
6d: fc cld
6e: f3 aa rep stos %al,%es:(%edi)
70: 89 ca mov %ecx,%edx
72: 89 fb mov %edi,%ebx
74: 89 5d 08 mov %ebx,0x8(%ebp)
77: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
7a: 90 nop
7b: 5b pop %ebx
7c: 5f pop %edi
7d: 5d pop %ebp
7e: c3 ret
0000007f <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
7f: 55 push %ebp
80: 89 e5 mov %esp,%ebp
82: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
85: 8b 45 08 mov 0x8(%ebp),%eax
88: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
8b: 90 nop
8c: 8b 55 0c mov 0xc(%ebp),%edx
8f: 8d 42 01 lea 0x1(%edx),%eax
92: 89 45 0c mov %eax,0xc(%ebp)
95: 8b 45 08 mov 0x8(%ebp),%eax
98: 8d 48 01 lea 0x1(%eax),%ecx
9b: 89 4d 08 mov %ecx,0x8(%ebp)
9e: 0f b6 12 movzbl (%edx),%edx
a1: 88 10 mov %dl,(%eax)
a3: 0f b6 00 movzbl (%eax),%eax
a6: 84 c0 test %al,%al
a8: 75 e2 jne 8c <strcpy+0xd>
;
return os;
aa: 8b 45 fc mov -0x4(%ebp),%eax
}
ad: c9 leave
ae: c3 ret
000000af <strcmp>:
int
strcmp(const char *p, const char *q)
{
af: 55 push %ebp
b0: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
b2: eb 08 jmp bc <strcmp+0xd>
p++, q++;
b4: 83 45 08 01 addl $0x1,0x8(%ebp)
b8: 83 45 0c 01 addl $0x1,0xc(%ebp)
while(*p && *p == *q)
bc: 8b 45 08 mov 0x8(%ebp),%eax
bf: 0f b6 00 movzbl (%eax),%eax
c2: 84 c0 test %al,%al
c4: 74 10 je d6 <strcmp+0x27>
c6: 8b 45 08 mov 0x8(%ebp),%eax
c9: 0f b6 10 movzbl (%eax),%edx
cc: 8b 45 0c mov 0xc(%ebp),%eax
cf: 0f b6 00 movzbl (%eax),%eax
d2: 38 c2 cmp %al,%dl
d4: 74 de je b4 <strcmp+0x5>
return (uchar)*p - (uchar)*q;
d6: 8b 45 08 mov 0x8(%ebp),%eax
d9: 0f b6 00 movzbl (%eax),%eax
dc: 0f b6 d0 movzbl %al,%edx
df: 8b 45 0c mov 0xc(%ebp),%eax
e2: 0f b6 00 movzbl (%eax),%eax
e5: 0f b6 c0 movzbl %al,%eax
e8: 29 c2 sub %eax,%edx
ea: 89 d0 mov %edx,%eax
}
ec: 5d pop %ebp
ed: c3 ret
000000ee <strlen>:
uint
strlen(char *s)
{
ee: 55 push %ebp
ef: 89 e5 mov %esp,%ebp
f1: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
f4: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
fb: eb 04 jmp 101 <strlen+0x13>
fd: 83 45 fc 01 addl $0x1,-0x4(%ebp)
101: 8b 55 fc mov -0x4(%ebp),%edx
104: 8b 45 08 mov 0x8(%ebp),%eax
107: 01 d0 add %edx,%eax
109: 0f b6 00 movzbl (%eax),%eax
10c: 84 c0 test %al,%al
10e: 75 ed jne fd <strlen+0xf>
;
return n;
110: 8b 45 fc mov -0x4(%ebp),%eax
}
113: c9 leave
114: c3 ret
00000115 <strnlen>:
int
strnlen(const char *s, uint size)
{
115: 55 push %ebp
116: 89 e5 mov %esp,%ebp
118: 83 ec 10 sub $0x10,%esp
int n;
for (n = 0; size > 0 && *s != '\0'; s++, size--)
11b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
122: eb 0c jmp 130 <strnlen+0x1b>
n++;
124: 83 45 fc 01 addl $0x1,-0x4(%ebp)
for (n = 0; size > 0 && *s != '\0'; s++, size--)
128: 83 45 08 01 addl $0x1,0x8(%ebp)
12c: 83 6d 0c 01 subl $0x1,0xc(%ebp)
130: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
134: 74 0a je 140 <strnlen+0x2b>
136: 8b 45 08 mov 0x8(%ebp),%eax
139: 0f b6 00 movzbl (%eax),%eax
13c: 84 c0 test %al,%al
13e: 75 e4 jne 124 <strnlen+0xf>
return n;
140: 8b 45 fc mov -0x4(%ebp),%eax
}
143: c9 leave
144: c3 ret
00000145 <memset>:
void*
memset(void *dst, int c, uint n)
{
145: 55 push %ebp
146: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
148: 8b 45 10 mov 0x10(%ebp),%eax
14b: 50 push %eax
14c: ff 75 0c pushl 0xc(%ebp)
14f: ff 75 08 pushl 0x8(%ebp)
152: e8 02 ff ff ff call 59 <stosb>
157: 83 c4 0c add $0xc,%esp
return dst;
15a: 8b 45 08 mov 0x8(%ebp),%eax
}
15d: c9 leave
15e: c3 ret
0000015f <strchr>:
char*
strchr(const char *s, char c)
{
15f: 55 push %ebp
160: 89 e5 mov %esp,%ebp
162: 83 ec 04 sub $0x4,%esp
165: 8b 45 0c mov 0xc(%ebp),%eax
168: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
16b: eb 14 jmp 181 <strchr+0x22>
if(*s == c)
16d: 8b 45 08 mov 0x8(%ebp),%eax
170: 0f b6 00 movzbl (%eax),%eax
173: 38 45 fc cmp %al,-0x4(%ebp)
176: 75 05 jne 17d <strchr+0x1e>
return (char*)s;
178: 8b 45 08 mov 0x8(%ebp),%eax
17b: eb 13 jmp 190 <strchr+0x31>
for(; *s; s++)
17d: 83 45 08 01 addl $0x1,0x8(%ebp)
181: 8b 45 08 mov 0x8(%ebp),%eax
184: 0f b6 00 movzbl (%eax),%eax
187: 84 c0 test %al,%al
189: 75 e2 jne 16d <strchr+0xe>
return 0;
18b: b8 00 00 00 00 mov $0x0,%eax
}
190: c9 leave
191: c3 ret
00000192 <gets>:
char*
gets(char *buf, int max)
{
192: 55 push %ebp
193: 89 e5 mov %esp,%ebp
195: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
198: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
19f: eb 42 jmp 1e3 <gets+0x51>
cc = read(0, &c, 1);
1a1: 83 ec 04 sub $0x4,%esp
1a4: 6a 01 push $0x1
1a6: 8d 45 ef lea -0x11(%ebp),%eax
1a9: 50 push %eax
1aa: 6a 00 push $0x0
1ac: e8 47 01 00 00 call 2f8 <read>
1b1: 83 c4 10 add $0x10,%esp
1b4: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
1b7: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1bb: 7e 33 jle 1f0 <gets+0x5e>
break;
buf[i++] = c;
1bd: 8b 45 f4 mov -0xc(%ebp),%eax
1c0: 8d 50 01 lea 0x1(%eax),%edx
1c3: 89 55 f4 mov %edx,-0xc(%ebp)
1c6: 89 c2 mov %eax,%edx
1c8: 8b 45 08 mov 0x8(%ebp),%eax
1cb: 01 c2 add %eax,%edx
1cd: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1d1: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
1d3: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1d7: 3c 0a cmp $0xa,%al
1d9: 74 16 je 1f1 <gets+0x5f>
1db: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1df: 3c 0d cmp $0xd,%al
1e1: 74 0e je 1f1 <gets+0x5f>
for(i=0; i+1 < max; ){
1e3: 8b 45 f4 mov -0xc(%ebp),%eax
1e6: 83 c0 01 add $0x1,%eax
1e9: 39 45 0c cmp %eax,0xc(%ebp)
1ec: 7f b3 jg 1a1 <gets+0xf>
1ee: eb 01 jmp 1f1 <gets+0x5f>
break;
1f0: 90 nop
break;
}
buf[i] = '\0';
1f1: 8b 55 f4 mov -0xc(%ebp),%edx
1f4: 8b 45 08 mov 0x8(%ebp),%eax
1f7: 01 d0 add %edx,%eax
1f9: c6 00 00 movb $0x0,(%eax)
return buf;
1fc: 8b 45 08 mov 0x8(%ebp),%eax
}
1ff: c9 leave
200: c3 ret
00000201 <stat>:
int
stat(char *n, struct stat *st)
{
201: 55 push %ebp
202: 89 e5 mov %esp,%ebp
204: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
207: 83 ec 08 sub $0x8,%esp
20a: 6a 00 push $0x0
20c: ff 75 08 pushl 0x8(%ebp)
20f: e8 0c 01 00 00 call 320 <open>
214: 83 c4 10 add $0x10,%esp
217: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
21a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
21e: 79 07 jns 227 <stat+0x26>
return -1;
220: b8 ff ff ff ff mov $0xffffffff,%eax
225: eb 25 jmp 24c <stat+0x4b>
r = fstat(fd, st);
227: 83 ec 08 sub $0x8,%esp
22a: ff 75 0c pushl 0xc(%ebp)
22d: ff 75 f4 pushl -0xc(%ebp)
230: e8 03 01 00 00 call 338 <fstat>
235: 83 c4 10 add $0x10,%esp
238: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
23b: 83 ec 0c sub $0xc,%esp
23e: ff 75 f4 pushl -0xc(%ebp)
241: e8 c2 00 00 00 call 308 <close>
246: 83 c4 10 add $0x10,%esp
return r;
249: 8b 45 f0 mov -0x10(%ebp),%eax
}
24c: c9 leave
24d: c3 ret
0000024e <atoi>:
int
atoi(const char *s)
{
24e: 55 push %ebp
24f: 89 e5 mov %esp,%ebp
251: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
254: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
25b: eb 25 jmp 282 <atoi+0x34>
n = n*10 + *s++ - '0';
25d: 8b 55 fc mov -0x4(%ebp),%edx
260: 89 d0 mov %edx,%eax
262: c1 e0 02 shl $0x2,%eax
265: 01 d0 add %edx,%eax
267: 01 c0 add %eax,%eax
269: 89 c1 mov %eax,%ecx
26b: 8b 45 08 mov 0x8(%ebp),%eax
26e: 8d 50 01 lea 0x1(%eax),%edx
271: 89 55 08 mov %edx,0x8(%ebp)
274: 0f b6 00 movzbl (%eax),%eax
277: 0f be c0 movsbl %al,%eax
27a: 01 c8 add %ecx,%eax
27c: 83 e8 30 sub $0x30,%eax
27f: 89 45 fc mov %eax,-0x4(%ebp)
while('0' <= *s && *s <= '9')
282: 8b 45 08 mov 0x8(%ebp),%eax
285: 0f b6 00 movzbl (%eax),%eax
288: 3c 2f cmp $0x2f,%al
28a: 7e 0a jle 296 <atoi+0x48>
28c: 8b 45 08 mov 0x8(%ebp),%eax
28f: 0f b6 00 movzbl (%eax),%eax
292: 3c 39 cmp $0x39,%al
294: 7e c7 jle 25d <atoi+0xf>
return n;
296: 8b 45 fc mov -0x4(%ebp),%eax
}
299: c9 leave
29a: c3 ret
0000029b <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
29b: 55 push %ebp
29c: 89 e5 mov %esp,%ebp
29e: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
2a1: 8b 45 08 mov 0x8(%ebp),%eax
2a4: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
2a7: 8b 45 0c mov 0xc(%ebp),%eax
2aa: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
2ad: eb 17 jmp 2c6 <memmove+0x2b>
*dst++ = *src++;
2af: 8b 55 f8 mov -0x8(%ebp),%edx
2b2: 8d 42 01 lea 0x1(%edx),%eax
2b5: 89 45 f8 mov %eax,-0x8(%ebp)
2b8: 8b 45 fc mov -0x4(%ebp),%eax
2bb: 8d 48 01 lea 0x1(%eax),%ecx
2be: 89 4d fc mov %ecx,-0x4(%ebp)
2c1: 0f b6 12 movzbl (%edx),%edx
2c4: 88 10 mov %dl,(%eax)
while(n-- > 0)
2c6: 8b 45 10 mov 0x10(%ebp),%eax
2c9: 8d 50 ff lea -0x1(%eax),%edx
2cc: 89 55 10 mov %edx,0x10(%ebp)
2cf: 85 c0 test %eax,%eax
2d1: 7f dc jg 2af <memmove+0x14>
return vdst;
2d3: 8b 45 08 mov 0x8(%ebp),%eax
}
2d6: c9 leave
2d7: c3 ret
000002d8 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2d8: b8 01 00 00 00 mov $0x1,%eax
2dd: cd 40 int $0x40
2df: c3 ret
000002e0 <exit>:
SYSCALL(exit)
2e0: b8 02 00 00 00 mov $0x2,%eax
2e5: cd 40 int $0x40
2e7: c3 ret
000002e8 <wait>:
SYSCALL(wait)
2e8: b8 03 00 00 00 mov $0x3,%eax
2ed: cd 40 int $0x40
2ef: c3 ret
000002f0 <pipe>:
SYSCALL(pipe)
2f0: b8 04 00 00 00 mov $0x4,%eax
2f5: cd 40 int $0x40
2f7: c3 ret
000002f8 <read>:
SYSCALL(read)
2f8: b8 05 00 00 00 mov $0x5,%eax
2fd: cd 40 int $0x40
2ff: c3 ret
00000300 <write>:
SYSCALL(write)
300: b8 10 00 00 00 mov $0x10,%eax
305: cd 40 int $0x40
307: c3 ret
00000308 <close>:
SYSCALL(close)
308: b8 15 00 00 00 mov $0x15,%eax
30d: cd 40 int $0x40
30f: c3 ret
00000310 <kill>:
SYSCALL(kill)
310: b8 06 00 00 00 mov $0x6,%eax
315: cd 40 int $0x40
317: c3 ret
00000318 <exec>:
SYSCALL(exec)
318: b8 07 00 00 00 mov $0x7,%eax
31d: cd 40 int $0x40
31f: c3 ret
00000320 <open>:
SYSCALL(open)
320: b8 0f 00 00 00 mov $0xf,%eax
325: cd 40 int $0x40
327: c3 ret
00000328 <mknod>:
SYSCALL(mknod)
328: b8 11 00 00 00 mov $0x11,%eax
32d: cd 40 int $0x40
32f: c3 ret
00000330 <unlink>:
SYSCALL(unlink)
330: b8 12 00 00 00 mov $0x12,%eax
335: cd 40 int $0x40
337: c3 ret
00000338 <fstat>:
SYSCALL(fstat)
338: b8 08 00 00 00 mov $0x8,%eax
33d: cd 40 int $0x40
33f: c3 ret
00000340 <link>:
SYSCALL(link)
340: b8 13 00 00 00 mov $0x13,%eax
345: cd 40 int $0x40
347: c3 ret
00000348 <mkdir>:
SYSCALL(mkdir)
348: b8 14 00 00 00 mov $0x14,%eax
34d: cd 40 int $0x40
34f: c3 ret
00000350 <chdir>:
SYSCALL(chdir)
350: b8 09 00 00 00 mov $0x9,%eax
355: cd 40 int $0x40
357: c3 ret
00000358 <dup>:
SYSCALL(dup)
358: b8 0a 00 00 00 mov $0xa,%eax
35d: cd 40 int $0x40
35f: c3 ret
00000360 <getpid>:
SYSCALL(getpid)
360: b8 0b 00 00 00 mov $0xb,%eax
365: cd 40 int $0x40
367: c3 ret
00000368 <sbrk>:
SYSCALL(sbrk)
368: b8 0c 00 00 00 mov $0xc,%eax
36d: cd 40 int $0x40
36f: c3 ret
00000370 <sleep>:
SYSCALL(sleep)
370: b8 0d 00 00 00 mov $0xd,%eax
375: cd 40 int $0x40
377: c3 ret
00000378 <uptime>:
SYSCALL(uptime)
378: b8 0e 00 00 00 mov $0xe,%eax
37d: cd 40 int $0x40
37f: c3 ret
00000380 <select>:
SYSCALL(select)
380: b8 16 00 00 00 mov $0x16,%eax
385: cd 40 int $0x40
387: c3 ret
00000388 <arp>:
SYSCALL(arp)
388: b8 17 00 00 00 mov $0x17,%eax
38d: cd 40 int $0x40
38f: c3 ret
00000390 <arpserv>:
SYSCALL(arpserv)
390: b8 18 00 00 00 mov $0x18,%eax
395: cd 40 int $0x40
397: c3 ret
00000398 <arp_receive>:
SYSCALL(arp_receive)
398: b8 19 00 00 00 mov $0x19,%eax
39d: cd 40 int $0x40
39f: c3 ret
000003a0 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
3a0: 55 push %ebp
3a1: 89 e5 mov %esp,%ebp
3a3: 83 ec 18 sub $0x18,%esp
3a6: 8b 45 0c mov 0xc(%ebp),%eax
3a9: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
3ac: 83 ec 04 sub $0x4,%esp
3af: 6a 01 push $0x1
3b1: 8d 45 f4 lea -0xc(%ebp),%eax
3b4: 50 push %eax
3b5: ff 75 08 pushl 0x8(%ebp)
3b8: e8 43 ff ff ff call 300 <write>
3bd: 83 c4 10 add $0x10,%esp
}
3c0: 90 nop
3c1: c9 leave
3c2: c3 ret
000003c3 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
3c3: 55 push %ebp
3c4: 89 e5 mov %esp,%ebp
3c6: 83 ec 28 sub $0x28,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
3c9: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
3d0: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
3d4: 74 17 je 3ed <printint+0x2a>
3d6: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
3da: 79 11 jns 3ed <printint+0x2a>
neg = 1;
3dc: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
3e3: 8b 45 0c mov 0xc(%ebp),%eax
3e6: f7 d8 neg %eax
3e8: 89 45 ec mov %eax,-0x14(%ebp)
3eb: eb 06 jmp 3f3 <printint+0x30>
} else {
x = xx;
3ed: 8b 45 0c mov 0xc(%ebp),%eax
3f0: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
3f3: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
3fa: 8b 4d 10 mov 0x10(%ebp),%ecx
3fd: 8b 45 ec mov -0x14(%ebp),%eax
400: ba 00 00 00 00 mov $0x0,%edx
405: f7 f1 div %ecx
407: 89 d1 mov %edx,%ecx
409: 8b 45 f4 mov -0xc(%ebp),%eax
40c: 8d 50 01 lea 0x1(%eax),%edx
40f: 89 55 f4 mov %edx,-0xc(%ebp)
412: 0f b6 91 2c 17 00 00 movzbl 0x172c(%ecx),%edx
419: 88 54 05 dc mov %dl,-0x24(%ebp,%eax,1)
}while((x /= base) != 0);
41d: 8b 4d 10 mov 0x10(%ebp),%ecx
420: 8b 45 ec mov -0x14(%ebp),%eax
423: ba 00 00 00 00 mov $0x0,%edx
428: f7 f1 div %ecx
42a: 89 45 ec mov %eax,-0x14(%ebp)
42d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
431: 75 c7 jne 3fa <printint+0x37>
if(neg)
433: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
437: 74 2d je 466 <printint+0xa3>
buf[i++] = '-';
439: 8b 45 f4 mov -0xc(%ebp),%eax
43c: 8d 50 01 lea 0x1(%eax),%edx
43f: 89 55 f4 mov %edx,-0xc(%ebp)
442: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
447: eb 1d jmp 466 <printint+0xa3>
putc(fd, buf[i]);
449: 8d 55 dc lea -0x24(%ebp),%edx
44c: 8b 45 f4 mov -0xc(%ebp),%eax
44f: 01 d0 add %edx,%eax
451: 0f b6 00 movzbl (%eax),%eax
454: 0f be c0 movsbl %al,%eax
457: 83 ec 08 sub $0x8,%esp
45a: 50 push %eax
45b: ff 75 08 pushl 0x8(%ebp)
45e: e8 3d ff ff ff call 3a0 <putc>
463: 83 c4 10 add $0x10,%esp
while(--i >= 0)
466: 83 6d f4 01 subl $0x1,-0xc(%ebp)
46a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
46e: 79 d9 jns 449 <printint+0x86>
}
470: 90 nop
471: c9 leave
472: c3 ret
00000473 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
473: 55 push %ebp
474: 89 e5 mov %esp,%ebp
476: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
479: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
480: 8d 45 0c lea 0xc(%ebp),%eax
483: 83 c0 04 add $0x4,%eax
486: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
489: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
490: e9 59 01 00 00 jmp 5ee <printf+0x17b>
c = fmt[i] & 0xff;
495: 8b 55 0c mov 0xc(%ebp),%edx
498: 8b 45 f0 mov -0x10(%ebp),%eax
49b: 01 d0 add %edx,%eax
49d: 0f b6 00 movzbl (%eax),%eax
4a0: 0f be c0 movsbl %al,%eax
4a3: 25 ff 00 00 00 and $0xff,%eax
4a8: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
4ab: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
4af: 75 2c jne 4dd <printf+0x6a>
if(c == '%'){
4b1: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
4b5: 75 0c jne 4c3 <printf+0x50>
state = '%';
4b7: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
4be: e9 27 01 00 00 jmp 5ea <printf+0x177>
} else {
putc(fd, c);
4c3: 8b 45 e4 mov -0x1c(%ebp),%eax
4c6: 0f be c0 movsbl %al,%eax
4c9: 83 ec 08 sub $0x8,%esp
4cc: 50 push %eax
4cd: ff 75 08 pushl 0x8(%ebp)
4d0: e8 cb fe ff ff call 3a0 <putc>
4d5: 83 c4 10 add $0x10,%esp
4d8: e9 0d 01 00 00 jmp 5ea <printf+0x177>
}
} else if(state == '%'){
4dd: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
4e1: 0f 85 03 01 00 00 jne 5ea <printf+0x177>
if(c == 'd'){
4e7: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
4eb: 75 1e jne 50b <printf+0x98>
printint(fd, *ap, 10, 1);
4ed: 8b 45 e8 mov -0x18(%ebp),%eax
4f0: 8b 00 mov (%eax),%eax
4f2: 6a 01 push $0x1
4f4: 6a 0a push $0xa
4f6: 50 push %eax
4f7: ff 75 08 pushl 0x8(%ebp)
4fa: e8 c4 fe ff ff call 3c3 <printint>
4ff: 83 c4 10 add $0x10,%esp
ap++;
502: 83 45 e8 04 addl $0x4,-0x18(%ebp)
506: e9 d8 00 00 00 jmp 5e3 <printf+0x170>
} else if(c == 'x' || c == 'p'){
50b: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
50f: 74 06 je 517 <printf+0xa4>
511: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
515: 75 1e jne 535 <printf+0xc2>
printint(fd, *ap, 16, 0);
517: 8b 45 e8 mov -0x18(%ebp),%eax
51a: 8b 00 mov (%eax),%eax
51c: 6a 00 push $0x0
51e: 6a 10 push $0x10
520: 50 push %eax
521: ff 75 08 pushl 0x8(%ebp)
524: e8 9a fe ff ff call 3c3 <printint>
529: 83 c4 10 add $0x10,%esp
ap++;
52c: 83 45 e8 04 addl $0x4,-0x18(%ebp)
530: e9 ae 00 00 00 jmp 5e3 <printf+0x170>
} else if(c == 's'){
535: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
539: 75 43 jne 57e <printf+0x10b>
s = (char*)*ap;
53b: 8b 45 e8 mov -0x18(%ebp),%eax
53e: 8b 00 mov (%eax),%eax
540: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
543: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
547: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
54b: 75 25 jne 572 <printf+0xff>
s = "(null)";
54d: c7 45 f4 88 10 00 00 movl $0x1088,-0xc(%ebp)
while(*s != 0){
554: eb 1c jmp 572 <printf+0xff>
putc(fd, *s);
556: 8b 45 f4 mov -0xc(%ebp),%eax
559: 0f b6 00 movzbl (%eax),%eax
55c: 0f be c0 movsbl %al,%eax
55f: 83 ec 08 sub $0x8,%esp
562: 50 push %eax
563: ff 75 08 pushl 0x8(%ebp)
566: e8 35 fe ff ff call 3a0 <putc>
56b: 83 c4 10 add $0x10,%esp
s++;
56e: 83 45 f4 01 addl $0x1,-0xc(%ebp)
while(*s != 0){
572: 8b 45 f4 mov -0xc(%ebp),%eax
575: 0f b6 00 movzbl (%eax),%eax
578: 84 c0 test %al,%al
57a: 75 da jne 556 <printf+0xe3>
57c: eb 65 jmp 5e3 <printf+0x170>
}
} else if(c == 'c'){
57e: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
582: 75 1d jne 5a1 <printf+0x12e>
putc(fd, *ap);
584: 8b 45 e8 mov -0x18(%ebp),%eax
587: 8b 00 mov (%eax),%eax
589: 0f be c0 movsbl %al,%eax
58c: 83 ec 08 sub $0x8,%esp
58f: 50 push %eax
590: ff 75 08 pushl 0x8(%ebp)
593: e8 08 fe ff ff call 3a0 <putc>
598: 83 c4 10 add $0x10,%esp
ap++;
59b: 83 45 e8 04 addl $0x4,-0x18(%ebp)
59f: eb 42 jmp 5e3 <printf+0x170>
} else if(c == '%'){
5a1: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
5a5: 75 17 jne 5be <printf+0x14b>
putc(fd, c);
5a7: 8b 45 e4 mov -0x1c(%ebp),%eax
5aa: 0f be c0 movsbl %al,%eax
5ad: 83 ec 08 sub $0x8,%esp
5b0: 50 push %eax
5b1: ff 75 08 pushl 0x8(%ebp)
5b4: e8 e7 fd ff ff call 3a0 <putc>
5b9: 83 c4 10 add $0x10,%esp
5bc: eb 25 jmp 5e3 <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
5be: 83 ec 08 sub $0x8,%esp
5c1: 6a 25 push $0x25
5c3: ff 75 08 pushl 0x8(%ebp)
5c6: e8 d5 fd ff ff call 3a0 <putc>
5cb: 83 c4 10 add $0x10,%esp
putc(fd, c);
5ce: 8b 45 e4 mov -0x1c(%ebp),%eax
5d1: 0f be c0 movsbl %al,%eax
5d4: 83 ec 08 sub $0x8,%esp
5d7: 50 push %eax
5d8: ff 75 08 pushl 0x8(%ebp)
5db: e8 c0 fd ff ff call 3a0 <putc>
5e0: 83 c4 10 add $0x10,%esp
}
state = 0;
5e3: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
for(i = 0; fmt[i]; i++){
5ea: 83 45 f0 01 addl $0x1,-0x10(%ebp)
5ee: 8b 55 0c mov 0xc(%ebp),%edx
5f1: 8b 45 f0 mov -0x10(%ebp),%eax
5f4: 01 d0 add %edx,%eax
5f6: 0f b6 00 movzbl (%eax),%eax
5f9: 84 c0 test %al,%al
5fb: 0f 85 94 fe ff ff jne 495 <printf+0x22>
}
}
}
601: 90 nop
602: c9 leave
603: c3 ret
00000604 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
604: 55 push %ebp
605: 89 e5 mov %esp,%ebp
607: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
60a: 8b 45 08 mov 0x8(%ebp),%eax
60d: 83 e8 08 sub $0x8,%eax
610: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
613: a1 48 17 00 00 mov 0x1748,%eax
618: 89 45 fc mov %eax,-0x4(%ebp)
61b: eb 24 jmp 641 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
61d: 8b 45 fc mov -0x4(%ebp),%eax
620: 8b 00 mov (%eax),%eax
622: 39 45 fc cmp %eax,-0x4(%ebp)
625: 72 12 jb 639 <free+0x35>
627: 8b 45 f8 mov -0x8(%ebp),%eax
62a: 3b 45 fc cmp -0x4(%ebp),%eax
62d: 77 24 ja 653 <free+0x4f>
62f: 8b 45 fc mov -0x4(%ebp),%eax
632: 8b 00 mov (%eax),%eax
634: 39 45 f8 cmp %eax,-0x8(%ebp)
637: 72 1a jb 653 <free+0x4f>
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
639: 8b 45 fc mov -0x4(%ebp),%eax
63c: 8b 00 mov (%eax),%eax
63e: 89 45 fc mov %eax,-0x4(%ebp)
641: 8b 45 f8 mov -0x8(%ebp),%eax
644: 3b 45 fc cmp -0x4(%ebp),%eax
647: 76 d4 jbe 61d <free+0x19>
649: 8b 45 fc mov -0x4(%ebp),%eax
64c: 8b 00 mov (%eax),%eax
64e: 39 45 f8 cmp %eax,-0x8(%ebp)
651: 73 ca jae 61d <free+0x19>
break;
if(bp + bp->s.size == p->s.ptr){
653: 8b 45 f8 mov -0x8(%ebp),%eax
656: 8b 40 04 mov 0x4(%eax),%eax
659: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
660: 8b 45 f8 mov -0x8(%ebp),%eax
663: 01 c2 add %eax,%edx
665: 8b 45 fc mov -0x4(%ebp),%eax
668: 8b 00 mov (%eax),%eax
66a: 39 c2 cmp %eax,%edx
66c: 75 24 jne 692 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
66e: 8b 45 f8 mov -0x8(%ebp),%eax
671: 8b 50 04 mov 0x4(%eax),%edx
674: 8b 45 fc mov -0x4(%ebp),%eax
677: 8b 00 mov (%eax),%eax
679: 8b 40 04 mov 0x4(%eax),%eax
67c: 01 c2 add %eax,%edx
67e: 8b 45 f8 mov -0x8(%ebp),%eax
681: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
684: 8b 45 fc mov -0x4(%ebp),%eax
687: 8b 00 mov (%eax),%eax
689: 8b 10 mov (%eax),%edx
68b: 8b 45 f8 mov -0x8(%ebp),%eax
68e: 89 10 mov %edx,(%eax)
690: eb 0a jmp 69c <free+0x98>
} else
bp->s.ptr = p->s.ptr;
692: 8b 45 fc mov -0x4(%ebp),%eax
695: 8b 10 mov (%eax),%edx
697: 8b 45 f8 mov -0x8(%ebp),%eax
69a: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
69c: 8b 45 fc mov -0x4(%ebp),%eax
69f: 8b 40 04 mov 0x4(%eax),%eax
6a2: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
6a9: 8b 45 fc mov -0x4(%ebp),%eax
6ac: 01 d0 add %edx,%eax
6ae: 39 45 f8 cmp %eax,-0x8(%ebp)
6b1: 75 20 jne 6d3 <free+0xcf>
p->s.size += bp->s.size;
6b3: 8b 45 fc mov -0x4(%ebp),%eax
6b6: 8b 50 04 mov 0x4(%eax),%edx
6b9: 8b 45 f8 mov -0x8(%ebp),%eax
6bc: 8b 40 04 mov 0x4(%eax),%eax
6bf: 01 c2 add %eax,%edx
6c1: 8b 45 fc mov -0x4(%ebp),%eax
6c4: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
6c7: 8b 45 f8 mov -0x8(%ebp),%eax
6ca: 8b 10 mov (%eax),%edx
6cc: 8b 45 fc mov -0x4(%ebp),%eax
6cf: 89 10 mov %edx,(%eax)
6d1: eb 08 jmp 6db <free+0xd7>
} else
p->s.ptr = bp;
6d3: 8b 45 fc mov -0x4(%ebp),%eax
6d6: 8b 55 f8 mov -0x8(%ebp),%edx
6d9: 89 10 mov %edx,(%eax)
freep = p;
6db: 8b 45 fc mov -0x4(%ebp),%eax
6de: a3 48 17 00 00 mov %eax,0x1748
}
6e3: 90 nop
6e4: c9 leave
6e5: c3 ret
000006e6 <morecore>:
static Header*
morecore(uint nu)
{
6e6: 55 push %ebp
6e7: 89 e5 mov %esp,%ebp
6e9: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
6ec: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
6f3: 77 07 ja 6fc <morecore+0x16>
nu = 4096;
6f5: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
6fc: 8b 45 08 mov 0x8(%ebp),%eax
6ff: c1 e0 03 shl $0x3,%eax
702: 83 ec 0c sub $0xc,%esp
705: 50 push %eax
706: e8 5d fc ff ff call 368 <sbrk>
70b: 83 c4 10 add $0x10,%esp
70e: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
711: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
715: 75 07 jne 71e <morecore+0x38>
return 0;
717: b8 00 00 00 00 mov $0x0,%eax
71c: eb 26 jmp 744 <morecore+0x5e>
hp = (Header*)p;
71e: 8b 45 f4 mov -0xc(%ebp),%eax
721: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
724: 8b 45 f0 mov -0x10(%ebp),%eax
727: 8b 55 08 mov 0x8(%ebp),%edx
72a: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
72d: 8b 45 f0 mov -0x10(%ebp),%eax
730: 83 c0 08 add $0x8,%eax
733: 83 ec 0c sub $0xc,%esp
736: 50 push %eax
737: e8 c8 fe ff ff call 604 <free>
73c: 83 c4 10 add $0x10,%esp
return freep;
73f: a1 48 17 00 00 mov 0x1748,%eax
}
744: c9 leave
745: c3 ret
00000746 <malloc>:
void*
malloc(uint nbytes)
{
746: 55 push %ebp
747: 89 e5 mov %esp,%ebp
749: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
74c: 8b 45 08 mov 0x8(%ebp),%eax
74f: 83 c0 07 add $0x7,%eax
752: c1 e8 03 shr $0x3,%eax
755: 83 c0 01 add $0x1,%eax
758: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
75b: a1 48 17 00 00 mov 0x1748,%eax
760: 89 45 f0 mov %eax,-0x10(%ebp)
763: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
767: 75 23 jne 78c <malloc+0x46>
base.s.ptr = freep = prevp = &base;
769: c7 45 f0 40 17 00 00 movl $0x1740,-0x10(%ebp)
770: 8b 45 f0 mov -0x10(%ebp),%eax
773: a3 48 17 00 00 mov %eax,0x1748
778: a1 48 17 00 00 mov 0x1748,%eax
77d: a3 40 17 00 00 mov %eax,0x1740
base.s.size = 0;
782: c7 05 44 17 00 00 00 movl $0x0,0x1744
789: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
78c: 8b 45 f0 mov -0x10(%ebp),%eax
78f: 8b 00 mov (%eax),%eax
791: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
794: 8b 45 f4 mov -0xc(%ebp),%eax
797: 8b 40 04 mov 0x4(%eax),%eax
79a: 39 45 ec cmp %eax,-0x14(%ebp)
79d: 77 4d ja 7ec <malloc+0xa6>
if(p->s.size == nunits)
79f: 8b 45 f4 mov -0xc(%ebp),%eax
7a2: 8b 40 04 mov 0x4(%eax),%eax
7a5: 39 45 ec cmp %eax,-0x14(%ebp)
7a8: 75 0c jne 7b6 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
7aa: 8b 45 f4 mov -0xc(%ebp),%eax
7ad: 8b 10 mov (%eax),%edx
7af: 8b 45 f0 mov -0x10(%ebp),%eax
7b2: 89 10 mov %edx,(%eax)
7b4: eb 26 jmp 7dc <malloc+0x96>
else {
p->s.size -= nunits;
7b6: 8b 45 f4 mov -0xc(%ebp),%eax
7b9: 8b 40 04 mov 0x4(%eax),%eax
7bc: 2b 45 ec sub -0x14(%ebp),%eax
7bf: 89 c2 mov %eax,%edx
7c1: 8b 45 f4 mov -0xc(%ebp),%eax
7c4: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
7c7: 8b 45 f4 mov -0xc(%ebp),%eax
7ca: 8b 40 04 mov 0x4(%eax),%eax
7cd: c1 e0 03 shl $0x3,%eax
7d0: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
7d3: 8b 45 f4 mov -0xc(%ebp),%eax
7d6: 8b 55 ec mov -0x14(%ebp),%edx
7d9: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
7dc: 8b 45 f0 mov -0x10(%ebp),%eax
7df: a3 48 17 00 00 mov %eax,0x1748
return (void*)(p + 1);
7e4: 8b 45 f4 mov -0xc(%ebp),%eax
7e7: 83 c0 08 add $0x8,%eax
7ea: eb 3b jmp 827 <malloc+0xe1>
}
if(p == freep)
7ec: a1 48 17 00 00 mov 0x1748,%eax
7f1: 39 45 f4 cmp %eax,-0xc(%ebp)
7f4: 75 1e jne 814 <malloc+0xce>
if((p = morecore(nunits)) == 0)
7f6: 83 ec 0c sub $0xc,%esp
7f9: ff 75 ec pushl -0x14(%ebp)
7fc: e8 e5 fe ff ff call 6e6 <morecore>
801: 83 c4 10 add $0x10,%esp
804: 89 45 f4 mov %eax,-0xc(%ebp)
807: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
80b: 75 07 jne 814 <malloc+0xce>
return 0;
80d: b8 00 00 00 00 mov $0x0,%eax
812: eb 13 jmp 827 <malloc+0xe1>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
814: 8b 45 f4 mov -0xc(%ebp),%eax
817: 89 45 f0 mov %eax,-0x10(%ebp)
81a: 8b 45 f4 mov -0xc(%ebp),%eax
81d: 8b 00 mov (%eax),%eax
81f: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
822: e9 6d ff ff ff jmp 794 <malloc+0x4e>
}
}
827: c9 leave
828: c3 ret
00000829 <printnum>:
* using specified putch function and associated pointer putdat.
*/
static void
printnum(void (*putch)(int, void*), void *putdat,
unsigned long long num, unsigned base, int width, int padc)
{
829: 55 push %ebp
82a: 89 e5 mov %esp,%ebp
82c: 53 push %ebx
82d: 83 ec 14 sub $0x14,%esp
830: 8b 45 10 mov 0x10(%ebp),%eax
833: 89 45 f0 mov %eax,-0x10(%ebp)
836: 8b 45 14 mov 0x14(%ebp),%eax
839: 89 45 f4 mov %eax,-0xc(%ebp)
// first recursively print all preceding (more significant) digits
if (num >= base)
83c: 8b 45 18 mov 0x18(%ebp),%eax
83f: ba 00 00 00 00 mov $0x0,%edx
844: 39 55 f4 cmp %edx,-0xc(%ebp)
847: 72 55 jb 89e <printnum+0x75>
849: 39 55 f4 cmp %edx,-0xc(%ebp)
84c: 77 05 ja 853 <printnum+0x2a>
84e: 39 45 f0 cmp %eax,-0x10(%ebp)
851: 72 4b jb 89e <printnum+0x75>
printnum(putch, putdat, num / base, base, width - 1, padc);
853: 8b 45 1c mov 0x1c(%ebp),%eax
856: 8d 58 ff lea -0x1(%eax),%ebx
859: 8b 45 18 mov 0x18(%ebp),%eax
85c: ba 00 00 00 00 mov $0x0,%edx
861: 52 push %edx
862: 50 push %eax
863: ff 75 f4 pushl -0xc(%ebp)
866: ff 75 f0 pushl -0x10(%ebp)
869: e8 a2 05 00 00 call e10 <__udivdi3>
86e: 83 c4 10 add $0x10,%esp
871: 83 ec 04 sub $0x4,%esp
874: ff 75 20 pushl 0x20(%ebp)
877: 53 push %ebx
878: ff 75 18 pushl 0x18(%ebp)
87b: 52 push %edx
87c: 50 push %eax
87d: ff 75 0c pushl 0xc(%ebp)
880: ff 75 08 pushl 0x8(%ebp)
883: e8 a1 ff ff ff call 829 <printnum>
888: 83 c4 20 add $0x20,%esp
88b: eb 1b jmp 8a8 <printnum+0x7f>
else {
// print any needed pad characters before first digit
while (--width > 0)
putch(padc, putdat);
88d: 83 ec 08 sub $0x8,%esp
890: ff 75 0c pushl 0xc(%ebp)
893: ff 75 20 pushl 0x20(%ebp)
896: 8b 45 08 mov 0x8(%ebp),%eax
899: ff d0 call *%eax
89b: 83 c4 10 add $0x10,%esp
while (--width > 0)
89e: 83 6d 1c 01 subl $0x1,0x1c(%ebp)
8a2: 83 7d 1c 00 cmpl $0x0,0x1c(%ebp)
8a6: 7f e5 jg 88d <printnum+0x64>
}
// then print this (the least significant) digit
putch("0123456789abcdef"[num % base], putdat);
8a8: 8b 4d 18 mov 0x18(%ebp),%ecx
8ab: bb 00 00 00 00 mov $0x0,%ebx
8b0: 8b 45 f0 mov -0x10(%ebp),%eax
8b3: 8b 55 f4 mov -0xc(%ebp),%edx
8b6: 53 push %ebx
8b7: 51 push %ecx
8b8: 52 push %edx
8b9: 50 push %eax
8ba: e8 71 06 00 00 call f30 <__umoddi3>
8bf: 83 c4 10 add $0x10,%esp
8c2: 05 60 11 00 00 add $0x1160,%eax
8c7: 0f b6 00 movzbl (%eax),%eax
8ca: 0f be c0 movsbl %al,%eax
8cd: 83 ec 08 sub $0x8,%esp
8d0: ff 75 0c pushl 0xc(%ebp)
8d3: 50 push %eax
8d4: 8b 45 08 mov 0x8(%ebp),%eax
8d7: ff d0 call *%eax
8d9: 83 c4 10 add $0x10,%esp
}
8dc: 90 nop
8dd: 8b 5d fc mov -0x4(%ebp),%ebx
8e0: c9 leave
8e1: c3 ret
000008e2 <getuint>:
// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
8e2: 55 push %ebp
8e3: 89 e5 mov %esp,%ebp
if (lflag >= 2)
8e5: 83 7d 0c 01 cmpl $0x1,0xc(%ebp)
8e9: 7e 14 jle 8ff <getuint+0x1d>
return va_arg(*ap, unsigned long long);
8eb: 8b 45 08 mov 0x8(%ebp),%eax
8ee: 8b 00 mov (%eax),%eax
8f0: 8d 48 08 lea 0x8(%eax),%ecx
8f3: 8b 55 08 mov 0x8(%ebp),%edx
8f6: 89 0a mov %ecx,(%edx)
8f8: 8b 50 04 mov 0x4(%eax),%edx
8fb: 8b 00 mov (%eax),%eax
8fd: eb 30 jmp 92f <getuint+0x4d>
else if (lflag)
8ff: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
903: 74 16 je 91b <getuint+0x39>
return va_arg(*ap, unsigned long);
905: 8b 45 08 mov 0x8(%ebp),%eax
908: 8b 00 mov (%eax),%eax
90a: 8d 48 04 lea 0x4(%eax),%ecx
90d: 8b 55 08 mov 0x8(%ebp),%edx
910: 89 0a mov %ecx,(%edx)
912: 8b 00 mov (%eax),%eax
914: ba 00 00 00 00 mov $0x0,%edx
919: eb 14 jmp 92f <getuint+0x4d>
else
return va_arg(*ap, unsigned int);
91b: 8b 45 08 mov 0x8(%ebp),%eax
91e: 8b 00 mov (%eax),%eax
920: 8d 48 04 lea 0x4(%eax),%ecx
923: 8b 55 08 mov 0x8(%ebp),%edx
926: 89 0a mov %ecx,(%edx)
928: 8b 00 mov (%eax),%eax
92a: ba 00 00 00 00 mov $0x0,%edx
}
92f: 5d pop %ebp
930: c3 ret
00000931 <getint>:
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
931: 55 push %ebp
932: 89 e5 mov %esp,%ebp
if (lflag >= 2)
934: 83 7d 0c 01 cmpl $0x1,0xc(%ebp)
938: 7e 14 jle 94e <getint+0x1d>
return va_arg(*ap, long long);
93a: 8b 45 08 mov 0x8(%ebp),%eax
93d: 8b 00 mov (%eax),%eax
93f: 8d 48 08 lea 0x8(%eax),%ecx
942: 8b 55 08 mov 0x8(%ebp),%edx
945: 89 0a mov %ecx,(%edx)
947: 8b 50 04 mov 0x4(%eax),%edx
94a: 8b 00 mov (%eax),%eax
94c: eb 28 jmp 976 <getint+0x45>
else if (lflag)
94e: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
952: 74 12 je 966 <getint+0x35>
return va_arg(*ap, long);
954: 8b 45 08 mov 0x8(%ebp),%eax
957: 8b 00 mov (%eax),%eax
959: 8d 48 04 lea 0x4(%eax),%ecx
95c: 8b 55 08 mov 0x8(%ebp),%edx
95f: 89 0a mov %ecx,(%edx)
961: 8b 00 mov (%eax),%eax
963: 99 cltd
964: eb 10 jmp 976 <getint+0x45>
else
return va_arg(*ap, int);
966: 8b 45 08 mov 0x8(%ebp),%eax
969: 8b 00 mov (%eax),%eax
96b: 8d 48 04 lea 0x4(%eax),%ecx
96e: 8b 55 08 mov 0x8(%ebp),%edx
971: 89 0a mov %ecx,(%edx)
973: 8b 00 mov (%eax),%eax
975: 99 cltd
}
976: 5d pop %ebp
977: c3 ret
00000978 <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);
void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
978: 55 push %ebp
979: 89 e5 mov %esp,%ebp
97b: 56 push %esi
97c: 53 push %ebx
97d: 83 ec 20 sub $0x20,%esp
unsigned long long num;
int base, lflag, width, precision, altflag;
char padc;
while (1) {
while ((ch = *(unsigned char*)fmt++) != '%') {
980: eb 17 jmp 999 <vprintfmt+0x21>
if (ch == '\0')
982: 85 db test %ebx,%ebx
984: 0f 84 a0 03 00 00 je d2a <vprintfmt+0x3b2>
return;
putch(ch, putdat);
98a: 83 ec 08 sub $0x8,%esp
98d: ff 75 0c pushl 0xc(%ebp)
990: 53 push %ebx
991: 8b 45 08 mov 0x8(%ebp),%eax
994: ff d0 call *%eax
996: 83 c4 10 add $0x10,%esp
while ((ch = *(unsigned char*)fmt++) != '%') {
999: 8b 45 10 mov 0x10(%ebp),%eax
99c: 8d 50 01 lea 0x1(%eax),%edx
99f: 89 55 10 mov %edx,0x10(%ebp)
9a2: 0f b6 00 movzbl (%eax),%eax
9a5: 0f b6 d8 movzbl %al,%ebx
9a8: 83 fb 25 cmp $0x25,%ebx
9ab: 75 d5 jne 982 <vprintfmt+0xa>
}
// Process a %-escape sequence
padc = ' ';
9ad: c6 45 db 20 movb $0x20,-0x25(%ebp)
width = -1;
9b1: c7 45 e4 ff ff ff ff movl $0xffffffff,-0x1c(%ebp)
precision = -1;
9b8: c7 45 e0 ff ff ff ff movl $0xffffffff,-0x20(%ebp)
lflag = 0;
9bf: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp)
altflag = 0;
9c6: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
reswitch:
switch (ch = *(unsigned char*)fmt++) {
9cd: 8b 45 10 mov 0x10(%ebp),%eax
9d0: 8d 50 01 lea 0x1(%eax),%edx
9d3: 89 55 10 mov %edx,0x10(%ebp)
9d6: 0f b6 00 movzbl (%eax),%eax
9d9: 0f b6 d8 movzbl %al,%ebx
9dc: 8d 43 dd lea -0x23(%ebx),%eax
9df: 83 f8 55 cmp $0x55,%eax
9e2: 0f 87 15 03 00 00 ja cfd <vprintfmt+0x385>
9e8: 8b 04 85 84 11 00 00 mov 0x1184(,%eax,4),%eax
9ef: ff e0 jmp *%eax
// flag to pad on the right
case '-':
padc = '-';
9f1: c6 45 db 2d movb $0x2d,-0x25(%ebp)
goto reswitch;
9f5: eb d6 jmp 9cd <vprintfmt+0x55>
// flag to pad with 0's instead of spaces
case '0':
padc = '0';
9f7: c6 45 db 30 movb $0x30,-0x25(%ebp)
goto reswitch;
9fb: eb d0 jmp 9cd <vprintfmt+0x55>
case '5':
case '6':
case '7':
case '8':
case '9':
for (precision = 0;; ++fmt) {
9fd: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp)
precision = precision * 10 + ch - '0';
a04: 8b 55 e0 mov -0x20(%ebp),%edx
a07: 89 d0 mov %edx,%eax
a09: c1 e0 02 shl $0x2,%eax
a0c: 01 d0 add %edx,%eax
a0e: 01 c0 add %eax,%eax
a10: 01 d8 add %ebx,%eax
a12: 83 e8 30 sub $0x30,%eax
a15: 89 45 e0 mov %eax,-0x20(%ebp)
ch = *fmt;
a18: 8b 45 10 mov 0x10(%ebp),%eax
a1b: 0f b6 00 movzbl (%eax),%eax
a1e: 0f be d8 movsbl %al,%ebx
if (ch < '0' || ch > '9')
a21: 83 fb 2f cmp $0x2f,%ebx
a24: 7e 39 jle a5f <vprintfmt+0xe7>
a26: 83 fb 39 cmp $0x39,%ebx
a29: 7f 34 jg a5f <vprintfmt+0xe7>
for (precision = 0;; ++fmt) {
a2b: 83 45 10 01 addl $0x1,0x10(%ebp)
precision = precision * 10 + ch - '0';
a2f: eb d3 jmp a04 <vprintfmt+0x8c>
break;
}
goto process_precision;
case '*':
precision = va_arg(ap, int);
a31: 8b 45 14 mov 0x14(%ebp),%eax
a34: 8d 50 04 lea 0x4(%eax),%edx
a37: 89 55 14 mov %edx,0x14(%ebp)
a3a: 8b 00 mov (%eax),%eax
a3c: 89 45 e0 mov %eax,-0x20(%ebp)
goto process_precision;
a3f: eb 1f jmp a60 <vprintfmt+0xe8>
case '.':
if (width < 0)
a41: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
a45: 79 86 jns 9cd <vprintfmt+0x55>
width = 0;
a47: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
goto reswitch;
a4e: e9 7a ff ff ff jmp 9cd <vprintfmt+0x55>
case '#':
altflag = 1;
a53: c7 45 dc 01 00 00 00 movl $0x1,-0x24(%ebp)
goto reswitch;
a5a: e9 6e ff ff ff jmp 9cd <vprintfmt+0x55>
goto process_precision;
a5f: 90 nop
process_precision:
if (width < 0)
a60: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
a64: 0f 89 63 ff ff ff jns 9cd <vprintfmt+0x55>
width = precision, precision = -1;
a6a: 8b 45 e0 mov -0x20(%ebp),%eax
a6d: 89 45 e4 mov %eax,-0x1c(%ebp)
a70: c7 45 e0 ff ff ff ff movl $0xffffffff,-0x20(%ebp)
goto reswitch;
a77: e9 51 ff ff ff jmp 9cd <vprintfmt+0x55>
// long flag (doubled for long long)
case 'l':
lflag++;
a7c: 83 45 e8 01 addl $0x1,-0x18(%ebp)
goto reswitch;
a80: e9 48 ff ff ff jmp 9cd <vprintfmt+0x55>
// character
case 'c':
putch(va_arg(ap, int), putdat);
a85: 8b 45 14 mov 0x14(%ebp),%eax
a88: 8d 50 04 lea 0x4(%eax),%edx
a8b: 89 55 14 mov %edx,0x14(%ebp)
a8e: 8b 00 mov (%eax),%eax
a90: 83 ec 08 sub $0x8,%esp
a93: ff 75 0c pushl 0xc(%ebp)
a96: 50 push %eax
a97: 8b 45 08 mov 0x8(%ebp),%eax
a9a: ff d0 call *%eax
a9c: 83 c4 10 add $0x10,%esp
break;
a9f: e9 81 02 00 00 jmp d25 <vprintfmt+0x3ad>
// error message
case 'e':
err = va_arg(ap, int);
aa4: 8b 45 14 mov 0x14(%ebp),%eax
aa7: 8d 50 04 lea 0x4(%eax),%edx
aaa: 89 55 14 mov %edx,0x14(%ebp)
aad: 8b 18 mov (%eax),%ebx
if (err < 0)
aaf: 85 db test %ebx,%ebx
ab1: 79 02 jns ab5 <vprintfmt+0x13d>
err = -err;
ab3: f7 db neg %ebx
if (err >= MAXERROR || (p = error_string[err]) == NULL)
ab5: 83 fb 0f cmp $0xf,%ebx
ab8: 7f 0b jg ac5 <vprintfmt+0x14d>
aba: 8b 34 9d 20 11 00 00 mov 0x1120(,%ebx,4),%esi
ac1: 85 f6 test %esi,%esi
ac3: 75 19 jne ade <vprintfmt+0x166>
printfmt(putch, putdat, "error %d", err);
ac5: 53 push %ebx
ac6: 68 71 11 00 00 push $0x1171
acb: ff 75 0c pushl 0xc(%ebp)
ace: ff 75 08 pushl 0x8(%ebp)
ad1: e8 5c 02 00 00 call d32 <printfmt>
ad6: 83 c4 10 add $0x10,%esp
else
printfmt(putch, putdat, "%s", p);
break;
ad9: e9 47 02 00 00 jmp d25 <vprintfmt+0x3ad>
printfmt(putch, putdat, "%s", p);
ade: 56 push %esi
adf: 68 7a 11 00 00 push $0x117a
ae4: ff 75 0c pushl 0xc(%ebp)
ae7: ff 75 08 pushl 0x8(%ebp)
aea: e8 43 02 00 00 call d32 <printfmt>
aef: 83 c4 10 add $0x10,%esp
break;
af2: e9 2e 02 00 00 jmp d25 <vprintfmt+0x3ad>
// string
case 's':
if ((p = va_arg(ap, char *)) == NULL)
af7: 8b 45 14 mov 0x14(%ebp),%eax
afa: 8d 50 04 lea 0x4(%eax),%edx
afd: 89 55 14 mov %edx,0x14(%ebp)
b00: 8b 30 mov (%eax),%esi
b02: 85 f6 test %esi,%esi
b04: 75 05 jne b0b <vprintfmt+0x193>
p = "(null)";
b06: be 7d 11 00 00 mov $0x117d,%esi
if (width > 0 && padc != '-')
b0b: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
b0f: 7e 6f jle b80 <vprintfmt+0x208>
b11: 80 7d db 2d cmpb $0x2d,-0x25(%ebp)
b15: 74 69 je b80 <vprintfmt+0x208>
for (width -= strnlen(p, precision); width > 0; width--)
b17: 8b 45 e0 mov -0x20(%ebp),%eax
b1a: 83 ec 08 sub $0x8,%esp
b1d: 50 push %eax
b1e: 56 push %esi
b1f: e8 f1 f5 ff ff call 115 <strnlen>
b24: 83 c4 10 add $0x10,%esp
b27: 29 45 e4 sub %eax,-0x1c(%ebp)
b2a: eb 17 jmp b43 <vprintfmt+0x1cb>
putch(padc, putdat);
b2c: 0f be 45 db movsbl -0x25(%ebp),%eax
b30: 83 ec 08 sub $0x8,%esp
b33: ff 75 0c pushl 0xc(%ebp)
b36: 50 push %eax
b37: 8b 45 08 mov 0x8(%ebp),%eax
b3a: ff d0 call *%eax
b3c: 83 c4 10 add $0x10,%esp
for (width -= strnlen(p, precision); width > 0; width--)
b3f: 83 6d e4 01 subl $0x1,-0x1c(%ebp)
b43: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
b47: 7f e3 jg b2c <vprintfmt+0x1b4>
for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
b49: eb 35 jmp b80 <vprintfmt+0x208>
if (altflag && (ch < ' ' || ch > '~'))
b4b: 83 7d dc 00 cmpl $0x0,-0x24(%ebp)
b4f: 74 1c je b6d <vprintfmt+0x1f5>
b51: 83 fb 1f cmp $0x1f,%ebx
b54: 7e 05 jle b5b <vprintfmt+0x1e3>
b56: 83 fb 7e cmp $0x7e,%ebx
b59: 7e 12 jle b6d <vprintfmt+0x1f5>
putch('?', putdat);
b5b: 83 ec 08 sub $0x8,%esp
b5e: ff 75 0c pushl 0xc(%ebp)
b61: 6a 3f push $0x3f
b63: 8b 45 08 mov 0x8(%ebp),%eax
b66: ff d0 call *%eax
b68: 83 c4 10 add $0x10,%esp
b6b: eb 0f jmp b7c <vprintfmt+0x204>
else
putch(ch, putdat);
b6d: 83 ec 08 sub $0x8,%esp
b70: ff 75 0c pushl 0xc(%ebp)
b73: 53 push %ebx
b74: 8b 45 08 mov 0x8(%ebp),%eax
b77: ff d0 call *%eax
b79: 83 c4 10 add $0x10,%esp
for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
b7c: 83 6d e4 01 subl $0x1,-0x1c(%ebp)
b80: 89 f0 mov %esi,%eax
b82: 8d 70 01 lea 0x1(%eax),%esi
b85: 0f b6 00 movzbl (%eax),%eax
b88: 0f be d8 movsbl %al,%ebx
b8b: 85 db test %ebx,%ebx
b8d: 74 26 je bb5 <vprintfmt+0x23d>
b8f: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
b93: 78 b6 js b4b <vprintfmt+0x1d3>
b95: 83 6d e0 01 subl $0x1,-0x20(%ebp)
b99: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
b9d: 79 ac jns b4b <vprintfmt+0x1d3>
for (; width > 0; width--)
b9f: eb 14 jmp bb5 <vprintfmt+0x23d>
putch(' ', putdat);
ba1: 83 ec 08 sub $0x8,%esp
ba4: ff 75 0c pushl 0xc(%ebp)
ba7: 6a 20 push $0x20
ba9: 8b 45 08 mov 0x8(%ebp),%eax
bac: ff d0 call *%eax
bae: 83 c4 10 add $0x10,%esp
for (; width > 0; width--)
bb1: 83 6d e4 01 subl $0x1,-0x1c(%ebp)
bb5: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
bb9: 7f e6 jg ba1 <vprintfmt+0x229>
break;
bbb: e9 65 01 00 00 jmp d25 <vprintfmt+0x3ad>
// (signed) decimal
case 'd':
num = getint(&ap, lflag);
bc0: 83 ec 08 sub $0x8,%esp
bc3: ff 75 e8 pushl -0x18(%ebp)
bc6: 8d 45 14 lea 0x14(%ebp),%eax
bc9: 50 push %eax
bca: e8 62 fd ff ff call 931 <getint>
bcf: 83 c4 10 add $0x10,%esp
bd2: 89 45 f0 mov %eax,-0x10(%ebp)
bd5: 89 55 f4 mov %edx,-0xc(%ebp)
if ((long long)num < 0) {
bd8: 8b 45 f0 mov -0x10(%ebp),%eax
bdb: 8b 55 f4 mov -0xc(%ebp),%edx
bde: 85 d2 test %edx,%edx
be0: 79 23 jns c05 <vprintfmt+0x28d>
putch('-', putdat);
be2: 83 ec 08 sub $0x8,%esp
be5: ff 75 0c pushl 0xc(%ebp)
be8: 6a 2d push $0x2d
bea: 8b 45 08 mov 0x8(%ebp),%eax
bed: ff d0 call *%eax
bef: 83 c4 10 add $0x10,%esp
num = -(long long)num;
bf2: 8b 45 f0 mov -0x10(%ebp),%eax
bf5: 8b 55 f4 mov -0xc(%ebp),%edx
bf8: f7 d8 neg %eax
bfa: 83 d2 00 adc $0x0,%edx
bfd: f7 da neg %edx
bff: 89 45 f0 mov %eax,-0x10(%ebp)
c02: 89 55 f4 mov %edx,-0xc(%ebp)
}
base = 10;
c05: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp)
goto number;
c0c: e9 b6 00 00 00 jmp cc7 <vprintfmt+0x34f>
// unsigned decimal
case 'u':
num = getuint(&ap, lflag);
c11: 83 ec 08 sub $0x8,%esp
c14: ff 75 e8 pushl -0x18(%ebp)
c17: 8d 45 14 lea 0x14(%ebp),%eax
c1a: 50 push %eax
c1b: e8 c2 fc ff ff call 8e2 <getuint>
c20: 83 c4 10 add $0x10,%esp
c23: 89 45 f0 mov %eax,-0x10(%ebp)
c26: 89 55 f4 mov %edx,-0xc(%ebp)
base = 10;
c29: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp)
goto number;
c30: e9 92 00 00 00 jmp cc7 <vprintfmt+0x34f>
// (unsigned) octal
case 'o':
// Replace this with your code
putch('X', putdat);
c35: 83 ec 08 sub $0x8,%esp
c38: ff 75 0c pushl 0xc(%ebp)
c3b: 6a 58 push $0x58
c3d: 8b 45 08 mov 0x8(%ebp),%eax
c40: ff d0 call *%eax
c42: 83 c4 10 add $0x10,%esp
putch('X', putdat);
c45: 83 ec 08 sub $0x8,%esp
c48: ff 75 0c pushl 0xc(%ebp)
c4b: 6a 58 push $0x58
c4d: 8b 45 08 mov 0x8(%ebp),%eax
c50: ff d0 call *%eax
c52: 83 c4 10 add $0x10,%esp
putch('X', putdat);
c55: 83 ec 08 sub $0x8,%esp
c58: ff 75 0c pushl 0xc(%ebp)
c5b: 6a 58 push $0x58
c5d: 8b 45 08 mov 0x8(%ebp),%eax
c60: ff d0 call *%eax
c62: 83 c4 10 add $0x10,%esp
break;
c65: e9 bb 00 00 00 jmp d25 <vprintfmt+0x3ad>
// pointer
case 'p':
putch('0', putdat);
c6a: 83 ec 08 sub $0x8,%esp
c6d: ff 75 0c pushl 0xc(%ebp)
c70: 6a 30 push $0x30
c72: 8b 45 08 mov 0x8(%ebp),%eax
c75: ff d0 call *%eax
c77: 83 c4 10 add $0x10,%esp
putch('x', putdat);
c7a: 83 ec 08 sub $0x8,%esp
c7d: ff 75 0c pushl 0xc(%ebp)
c80: 6a 78 push $0x78
c82: 8b 45 08 mov 0x8(%ebp),%eax
c85: ff d0 call *%eax
c87: 83 c4 10 add $0x10,%esp
num = (unsigned long long)
(uint)va_arg(ap, void *);
c8a: 8b 45 14 mov 0x14(%ebp),%eax
c8d: 8d 50 04 lea 0x4(%eax),%edx
c90: 89 55 14 mov %edx,0x14(%ebp)
c93: 8b 00 mov (%eax),%eax
num = (unsigned long long)
c95: 89 45 f0 mov %eax,-0x10(%ebp)
c98: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
base = 16;
c9f: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp)
goto number;
ca6: eb 1f jmp cc7 <vprintfmt+0x34f>
// (unsigned) hexadecimal
case 'x':
num = getuint(&ap, lflag);
ca8: 83 ec 08 sub $0x8,%esp
cab: ff 75 e8 pushl -0x18(%ebp)
cae: 8d 45 14 lea 0x14(%ebp),%eax
cb1: 50 push %eax
cb2: e8 2b fc ff ff call 8e2 <getuint>
cb7: 83 c4 10 add $0x10,%esp
cba: 89 45 f0 mov %eax,-0x10(%ebp)
cbd: 89 55 f4 mov %edx,-0xc(%ebp)
base = 16;
cc0: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp)
number:
printnum(putch, putdat, num, base, width, padc);
cc7: 0f be 55 db movsbl -0x25(%ebp),%edx
ccb: 8b 45 ec mov -0x14(%ebp),%eax
cce: 83 ec 04 sub $0x4,%esp
cd1: 52 push %edx
cd2: ff 75 e4 pushl -0x1c(%ebp)
cd5: 50 push %eax
cd6: ff 75 f4 pushl -0xc(%ebp)
cd9: ff 75 f0 pushl -0x10(%ebp)
cdc: ff 75 0c pushl 0xc(%ebp)
cdf: ff 75 08 pushl 0x8(%ebp)
ce2: e8 42 fb ff ff call 829 <printnum>
ce7: 83 c4 20 add $0x20,%esp
break;
cea: eb 39 jmp d25 <vprintfmt+0x3ad>
// escaped '%' character
case '%':
putch(ch, putdat);
cec: 83 ec 08 sub $0x8,%esp
cef: ff 75 0c pushl 0xc(%ebp)
cf2: 53 push %ebx
cf3: 8b 45 08 mov 0x8(%ebp),%eax
cf6: ff d0 call *%eax
cf8: 83 c4 10 add $0x10,%esp
break;
cfb: eb 28 jmp d25 <vprintfmt+0x3ad>
// unrecognized escape sequence - just print it literally
default:
putch('%', putdat);
cfd: 83 ec 08 sub $0x8,%esp
d00: ff 75 0c pushl 0xc(%ebp)
d03: 6a 25 push $0x25
d05: 8b 45 08 mov 0x8(%ebp),%eax
d08: ff d0 call *%eax
d0a: 83 c4 10 add $0x10,%esp
for (fmt--; fmt[-1] != '%'; fmt--)
d0d: 83 6d 10 01 subl $0x1,0x10(%ebp)
d11: eb 04 jmp d17 <vprintfmt+0x39f>
d13: 83 6d 10 01 subl $0x1,0x10(%ebp)
d17: 8b 45 10 mov 0x10(%ebp),%eax
d1a: 83 e8 01 sub $0x1,%eax
d1d: 0f b6 00 movzbl (%eax),%eax
d20: 3c 25 cmp $0x25,%al
d22: 75 ef jne d13 <vprintfmt+0x39b>
/* do nothing */;
break;
d24: 90 nop
while ((ch = *(unsigned char*)fmt++) != '%') {
d25: e9 6f fc ff ff jmp 999 <vprintfmt+0x21>
return;
d2a: 90 nop
}
}
}
d2b: 8d 65 f8 lea -0x8(%ebp),%esp
d2e: 5b pop %ebx
d2f: 5e pop %esi
d30: 5d pop %ebp
d31: c3 ret
00000d32 <printfmt>:
void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
d32: 55 push %ebp
d33: 89 e5 mov %esp,%ebp
d35: 83 ec 18 sub $0x18,%esp
va_list ap;
va_start(ap, fmt);
d38: 8d 45 14 lea 0x14(%ebp),%eax
d3b: 89 45 f4 mov %eax,-0xc(%ebp)
vprintfmt(putch, putdat, fmt, ap);
d3e: 8b 45 f4 mov -0xc(%ebp),%eax
d41: 50 push %eax
d42: ff 75 10 pushl 0x10(%ebp)
d45: ff 75 0c pushl 0xc(%ebp)
d48: ff 75 08 pushl 0x8(%ebp)
d4b: e8 28 fc ff ff call 978 <vprintfmt>
d50: 83 c4 10 add $0x10,%esp
va_end(ap);
}
d53: 90 nop
d54: c9 leave
d55: c3 ret
00000d56 <sprintputch>:
int cnt;
};
static void
sprintputch(int ch, struct sprintbuf *b)
{
d56: 55 push %ebp
d57: 89 e5 mov %esp,%ebp
b->cnt++;
d59: 8b 45 0c mov 0xc(%ebp),%eax
d5c: 8b 40 08 mov 0x8(%eax),%eax
d5f: 8d 50 01 lea 0x1(%eax),%edx
d62: 8b 45 0c mov 0xc(%ebp),%eax
d65: 89 50 08 mov %edx,0x8(%eax)
if (b->buf < b->ebuf)
d68: 8b 45 0c mov 0xc(%ebp),%eax
d6b: 8b 10 mov (%eax),%edx
d6d: 8b 45 0c mov 0xc(%ebp),%eax
d70: 8b 40 04 mov 0x4(%eax),%eax
d73: 39 c2 cmp %eax,%edx
d75: 73 12 jae d89 <sprintputch+0x33>
*b->buf++ = ch;
d77: 8b 45 0c mov 0xc(%ebp),%eax
d7a: 8b 00 mov (%eax),%eax
d7c: 8d 48 01 lea 0x1(%eax),%ecx
d7f: 8b 55 0c mov 0xc(%ebp),%edx
d82: 89 0a mov %ecx,(%edx)
d84: 8b 55 08 mov 0x8(%ebp),%edx
d87: 88 10 mov %dl,(%eax)
}
d89: 90 nop
d8a: 5d pop %ebp
d8b: c3 ret
00000d8c <vsnprintf>:
int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
d8c: 55 push %ebp
d8d: 89 e5 mov %esp,%ebp
d8f: 83 ec 18 sub $0x18,%esp
struct sprintbuf b = { buf, buf+n-1, 0 };
d92: 8b 45 08 mov 0x8(%ebp),%eax
d95: 89 45 ec mov %eax,-0x14(%ebp)
d98: 8b 45 0c mov 0xc(%ebp),%eax
d9b: 8d 50 ff lea -0x1(%eax),%edx
d9e: 8b 45 08 mov 0x8(%ebp),%eax
da1: 01 d0 add %edx,%eax
da3: 89 45 f0 mov %eax,-0x10(%ebp)
da6: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
if (buf == NULL || n < 1)
dad: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
db1: 74 06 je db9 <vsnprintf+0x2d>
db3: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
db7: 7f 07 jg dc0 <vsnprintf+0x34>
return -E_INVAL;
db9: b8 fd ff ff ff mov $0xfffffffd,%eax
dbe: eb 20 jmp de0 <vsnprintf+0x54>
// print the string to the buffer
vprintfmt((void*)sprintputch, &b, fmt, ap);
dc0: ff 75 14 pushl 0x14(%ebp)
dc3: ff 75 10 pushl 0x10(%ebp)
dc6: 8d 45 ec lea -0x14(%ebp),%eax
dc9: 50 push %eax
dca: 68 56 0d 00 00 push $0xd56
dcf: e8 a4 fb ff ff call 978 <vprintfmt>
dd4: 83 c4 10 add $0x10,%esp
// null terminate the buffer
*b.buf = '\0';
dd7: 8b 45 ec mov -0x14(%ebp),%eax
dda: c6 00 00 movb $0x0,(%eax)
return b.cnt;
ddd: 8b 45 f4 mov -0xc(%ebp),%eax
}
de0: c9 leave
de1: c3 ret
00000de2 <snprintf>:
int
snprintf(char *buf, int n, const char *fmt, ...)
{
de2: 55 push %ebp
de3: 89 e5 mov %esp,%ebp
de5: 83 ec 18 sub $0x18,%esp
va_list ap;
int rc;
va_start(ap, fmt);
de8: 8d 45 14 lea 0x14(%ebp),%eax
deb: 89 45 f0 mov %eax,-0x10(%ebp)
rc = vsnprintf(buf, n, fmt, ap);
dee: 8b 45 f0 mov -0x10(%ebp),%eax
df1: 50 push %eax
df2: ff 75 10 pushl 0x10(%ebp)
df5: ff 75 0c pushl 0xc(%ebp)
df8: ff 75 08 pushl 0x8(%ebp)
dfb: e8 8c ff ff ff call d8c <vsnprintf>
e00: 83 c4 10 add $0x10,%esp
e03: 89 45 f4 mov %eax,-0xc(%ebp)
va_end(ap);
return rc;
e06: 8b 45 f4 mov -0xc(%ebp),%eax
}
e09: c9 leave
e0a: c3 ret
e0b: 66 90 xchg %ax,%ax
e0d: 66 90 xchg %ax,%ax
e0f: 90 nop
00000e10 <__udivdi3>:
e10: 55 push %ebp
e11: 57 push %edi
e12: 56 push %esi
e13: 53 push %ebx
e14: 83 ec 1c sub $0x1c,%esp
e17: 8b 54 24 3c mov 0x3c(%esp),%edx
e1b: 8b 6c 24 30 mov 0x30(%esp),%ebp
e1f: 8b 74 24 34 mov 0x34(%esp),%esi
e23: 8b 5c 24 38 mov 0x38(%esp),%ebx
e27: 85 d2 test %edx,%edx
e29: 75 35 jne e60 <__udivdi3+0x50>
e2b: 39 f3 cmp %esi,%ebx
e2d: 0f 87 bd 00 00 00 ja ef0 <__udivdi3+0xe0>
e33: 85 db test %ebx,%ebx
e35: 89 d9 mov %ebx,%ecx
e37: 75 0b jne e44 <__udivdi3+0x34>
e39: b8 01 00 00 00 mov $0x1,%eax
e3e: 31 d2 xor %edx,%edx
e40: f7 f3 div %ebx
e42: 89 c1 mov %eax,%ecx
e44: 31 d2 xor %edx,%edx
e46: 89 f0 mov %esi,%eax
e48: f7 f1 div %ecx
e4a: 89 c6 mov %eax,%esi
e4c: 89 e8 mov %ebp,%eax
e4e: 89 f7 mov %esi,%edi
e50: f7 f1 div %ecx
e52: 89 fa mov %edi,%edx
e54: 83 c4 1c add $0x1c,%esp
e57: 5b pop %ebx
e58: 5e pop %esi
e59: 5f pop %edi
e5a: 5d pop %ebp
e5b: c3 ret
e5c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
e60: 39 f2 cmp %esi,%edx
e62: 77 7c ja ee0 <__udivdi3+0xd0>
e64: 0f bd fa bsr %edx,%edi
e67: 83 f7 1f xor $0x1f,%edi
e6a: 0f 84 98 00 00 00 je f08 <__udivdi3+0xf8>
e70: 89 f9 mov %edi,%ecx
e72: b8 20 00 00 00 mov $0x20,%eax
e77: 29 f8 sub %edi,%eax
e79: d3 e2 shl %cl,%edx
e7b: 89 54 24 08 mov %edx,0x8(%esp)
e7f: 89 c1 mov %eax,%ecx
e81: 89 da mov %ebx,%edx
e83: d3 ea shr %cl,%edx
e85: 8b 4c 24 08 mov 0x8(%esp),%ecx
e89: 09 d1 or %edx,%ecx
e8b: 89 f2 mov %esi,%edx
e8d: 89 4c 24 08 mov %ecx,0x8(%esp)
e91: 89 f9 mov %edi,%ecx
e93: d3 e3 shl %cl,%ebx
e95: 89 c1 mov %eax,%ecx
e97: d3 ea shr %cl,%edx
e99: 89 f9 mov %edi,%ecx
e9b: 89 5c 24 0c mov %ebx,0xc(%esp)
e9f: d3 e6 shl %cl,%esi
ea1: 89 eb mov %ebp,%ebx
ea3: 89 c1 mov %eax,%ecx
ea5: d3 eb shr %cl,%ebx
ea7: 09 de or %ebx,%esi
ea9: 89 f0 mov %esi,%eax
eab: f7 74 24 08 divl 0x8(%esp)
eaf: 89 d6 mov %edx,%esi
eb1: 89 c3 mov %eax,%ebx
eb3: f7 64 24 0c mull 0xc(%esp)
eb7: 39 d6 cmp %edx,%esi
eb9: 72 0c jb ec7 <__udivdi3+0xb7>
ebb: 89 f9 mov %edi,%ecx
ebd: d3 e5 shl %cl,%ebp
ebf: 39 c5 cmp %eax,%ebp
ec1: 73 5d jae f20 <__udivdi3+0x110>
ec3: 39 d6 cmp %edx,%esi
ec5: 75 59 jne f20 <__udivdi3+0x110>
ec7: 8d 43 ff lea -0x1(%ebx),%eax
eca: 31 ff xor %edi,%edi
ecc: 89 fa mov %edi,%edx
ece: 83 c4 1c add $0x1c,%esp
ed1: 5b pop %ebx
ed2: 5e pop %esi
ed3: 5f pop %edi
ed4: 5d pop %ebp
ed5: c3 ret
ed6: 8d 76 00 lea 0x0(%esi),%esi
ed9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
ee0: 31 ff xor %edi,%edi
ee2: 31 c0 xor %eax,%eax
ee4: 89 fa mov %edi,%edx
ee6: 83 c4 1c add $0x1c,%esp
ee9: 5b pop %ebx
eea: 5e pop %esi
eeb: 5f pop %edi
eec: 5d pop %ebp
eed: c3 ret
eee: 66 90 xchg %ax,%ax
ef0: 31 ff xor %edi,%edi
ef2: 89 e8 mov %ebp,%eax
ef4: 89 f2 mov %esi,%edx
ef6: f7 f3 div %ebx
ef8: 89 fa mov %edi,%edx
efa: 83 c4 1c add $0x1c,%esp
efd: 5b pop %ebx
efe: 5e pop %esi
eff: 5f pop %edi
f00: 5d pop %ebp
f01: c3 ret
f02: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
f08: 39 f2 cmp %esi,%edx
f0a: 72 06 jb f12 <__udivdi3+0x102>
f0c: 31 c0 xor %eax,%eax
f0e: 39 eb cmp %ebp,%ebx
f10: 77 d2 ja ee4 <__udivdi3+0xd4>
f12: b8 01 00 00 00 mov $0x1,%eax
f17: eb cb jmp ee4 <__udivdi3+0xd4>
f19: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
f20: 89 d8 mov %ebx,%eax
f22: 31 ff xor %edi,%edi
f24: eb be jmp ee4 <__udivdi3+0xd4>
f26: 66 90 xchg %ax,%ax
f28: 66 90 xchg %ax,%ax
f2a: 66 90 xchg %ax,%ax
f2c: 66 90 xchg %ax,%ax
f2e: 66 90 xchg %ax,%ax
00000f30 <__umoddi3>:
f30: 55 push %ebp
f31: 57 push %edi
f32: 56 push %esi
f33: 53 push %ebx
f34: 83 ec 1c sub $0x1c,%esp
f37: 8b 6c 24 3c mov 0x3c(%esp),%ebp
f3b: 8b 74 24 30 mov 0x30(%esp),%esi
f3f: 8b 5c 24 34 mov 0x34(%esp),%ebx
f43: 8b 7c 24 38 mov 0x38(%esp),%edi
f47: 85 ed test %ebp,%ebp
f49: 89 f0 mov %esi,%eax
f4b: 89 da mov %ebx,%edx
f4d: 75 19 jne f68 <__umoddi3+0x38>
f4f: 39 df cmp %ebx,%edi
f51: 0f 86 b1 00 00 00 jbe 1008 <__umoddi3+0xd8>
f57: f7 f7 div %edi
f59: 89 d0 mov %edx,%eax
f5b: 31 d2 xor %edx,%edx
f5d: 83 c4 1c add $0x1c,%esp
f60: 5b pop %ebx
f61: 5e pop %esi
f62: 5f pop %edi
f63: 5d pop %ebp
f64: c3 ret
f65: 8d 76 00 lea 0x0(%esi),%esi
f68: 39 dd cmp %ebx,%ebp
f6a: 77 f1 ja f5d <__umoddi3+0x2d>
f6c: 0f bd cd bsr %ebp,%ecx
f6f: 83 f1 1f xor $0x1f,%ecx
f72: 89 4c 24 04 mov %ecx,0x4(%esp)
f76: 0f 84 b4 00 00 00 je 1030 <__umoddi3+0x100>
f7c: b8 20 00 00 00 mov $0x20,%eax
f81: 89 c2 mov %eax,%edx
f83: 8b 44 24 04 mov 0x4(%esp),%eax
f87: 29 c2 sub %eax,%edx
f89: 89 c1 mov %eax,%ecx
f8b: 89 f8 mov %edi,%eax
f8d: d3 e5 shl %cl,%ebp
f8f: 89 d1 mov %edx,%ecx
f91: 89 54 24 0c mov %edx,0xc(%esp)
f95: d3 e8 shr %cl,%eax
f97: 09 c5 or %eax,%ebp
f99: 8b 44 24 04 mov 0x4(%esp),%eax
f9d: 89 c1 mov %eax,%ecx
f9f: d3 e7 shl %cl,%edi
fa1: 89 d1 mov %edx,%ecx
fa3: 89 7c 24 08 mov %edi,0x8(%esp)
fa7: 89 df mov %ebx,%edi
fa9: d3 ef shr %cl,%edi
fab: 89 c1 mov %eax,%ecx
fad: 89 f0 mov %esi,%eax
faf: d3 e3 shl %cl,%ebx
fb1: 89 d1 mov %edx,%ecx
fb3: 89 fa mov %edi,%edx
fb5: d3 e8 shr %cl,%eax
fb7: 0f b6 4c 24 04 movzbl 0x4(%esp),%ecx
fbc: 09 d8 or %ebx,%eax
fbe: f7 f5 div %ebp
fc0: d3 e6 shl %cl,%esi
fc2: 89 d1 mov %edx,%ecx
fc4: f7 64 24 08 mull 0x8(%esp)
fc8: 39 d1 cmp %edx,%ecx
fca: 89 c3 mov %eax,%ebx
fcc: 89 d7 mov %edx,%edi
fce: 72 06 jb fd6 <__umoddi3+0xa6>
fd0: 75 0e jne fe0 <__umoddi3+0xb0>
fd2: 39 c6 cmp %eax,%esi
fd4: 73 0a jae fe0 <__umoddi3+0xb0>
fd6: 2b 44 24 08 sub 0x8(%esp),%eax
fda: 19 ea sbb %ebp,%edx
fdc: 89 d7 mov %edx,%edi
fde: 89 c3 mov %eax,%ebx
fe0: 89 ca mov %ecx,%edx
fe2: 0f b6 4c 24 0c movzbl 0xc(%esp),%ecx
fe7: 29 de sub %ebx,%esi
fe9: 19 fa sbb %edi,%edx
feb: 8b 5c 24 04 mov 0x4(%esp),%ebx
fef: 89 d0 mov %edx,%eax
ff1: d3 e0 shl %cl,%eax
ff3: 89 d9 mov %ebx,%ecx
ff5: d3 ee shr %cl,%esi
ff7: d3 ea shr %cl,%edx
ff9: 09 f0 or %esi,%eax
ffb: 83 c4 1c add $0x1c,%esp
ffe: 5b pop %ebx
fff: 5e pop %esi
1000: 5f pop %edi
1001: 5d pop %ebp
1002: c3 ret
1003: 90 nop
1004: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1008: 85 ff test %edi,%edi
100a: 89 f9 mov %edi,%ecx
100c: 75 0b jne 1019 <__umoddi3+0xe9>
100e: b8 01 00 00 00 mov $0x1,%eax
1013: 31 d2 xor %edx,%edx
1015: f7 f7 div %edi
1017: 89 c1 mov %eax,%ecx
1019: 89 d8 mov %ebx,%eax
101b: 31 d2 xor %edx,%edx
101d: f7 f1 div %ecx
101f: 89 f0 mov %esi,%eax
1021: f7 f1 div %ecx
1023: e9 31 ff ff ff jmp f59 <__umoddi3+0x29>
1028: 90 nop
1029: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1030: 39 dd cmp %ebx,%ebp
1032: 72 08 jb 103c <__umoddi3+0x10c>
1034: 39 f7 cmp %esi,%edi
1036: 0f 87 21 ff ff ff ja f5d <__umoddi3+0x2d>
103c: 89 da mov %ebx,%edx
103e: 89 f0 mov %esi,%eax
1040: 29 f8 sub %edi,%eax
1042: 19 ea sbb %ebp,%edx
1044: e9 14 ff ff ff jmp f5d <__umoddi3+0x2d>
|
3-mid/impact/source/3d/collision/shapes/impact-d3-striding_mesh.ads | charlie5/lace | 20 | 22052 | with interfaces.c;
with impact.d3.triangle_Callback;
with swig.Pointers;
with impact.d3.Containers;
-- #include "LinearMath/impact.d3.Vector.h"
-- #include "impact.d3.triangle_Callback.h"
-- #include "impact.d3.Shape.concave.h"
package impact.d3.striding_Mesh
--
-- The impact.d3.striding_Mesh is the interface class for high performance generic access to triangle meshes, used
-- in combination with impact.d3.Shape.concave.triangle_mesh.bvh and some other collision shapes.
--
-- Using index striding of 3*sizeof(integer) it can use triangle arrays, using index striding of 1*sizeof(integer) it can handle triangle strips.
--
-- It allows for sharing graphics and collision meshes. Also it provides locking/unlocking of graphics meshes that are in gpu memory.
--
is
type Item is abstract tagged private;
type View is access all Item'Class;
procedure destruct (Self : in out Item);
procedure InternalProcessAllTriangles (Self : in Item; callback : access impact.d3.triangle_Callback.btInternalTriangleIndexCallback'Class;
aabbMin, aabbMax : in math.Vector_3);
procedure calculateAabbBruteForce (Self : in Item; aabbMin, aabbMax : out math.Vector_3);
--
-- Brute force method to calculate aabb.
-- type unsigned_char_Pointer is access all interfaces.c.unsigned_char;
-- type unsigned_char_Pointers is array (Positive range <>) of unsigned_char_Pointer;
procedure getLockedVertexIndexBase (Self : in out Item; vertexbase : out impact.d3.Containers.real_Pointer;
stride : in out Integer;
indexbase : out swig.Pointers.unsigned_Pointer;
indexstride : in out Integer;
numfaces : in out Integer;
subpart : in Integer := 0)
is abstract;
--
-- Get read and write access to a subpart of a triangle mesh.
--
-- This subpart has a continuous array of vertices and indices
-- in this way the mesh can be handled as chunks of memory with striding
-- very similar to OpenGL vertexarray support
-- make a call to unLockVertexBase when the read and write access is finished.
-- virtual void getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts, PHY_ScalarType& type, int& stride,
-- unsigned char **indexbase, int& indexstride, int& numfaces, PHY_ScalarType& indicestype,int subpart=0)=0;
procedure getLockedReadOnlyVertexIndexBase (Self : in Item; vertexbase : out impact.d3.Containers.real_Pointer;
numverts : out Integer;
stride : out Integer;
indexbase : out swig.Pointers.unsigned_Pointer; -- unsigned_char_Pointer;
indexstride : out Integer;
numfaces : out Integer;
subpart : in Integer := 0)
is abstract;
-- virtual void getLockedReadOnlyVertexIndexBase (const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,
-- const unsigned char **indexbase,int & indexstride,int& numfaces,
-- PHY_ScalarType& indicestype,int subpart=0) const=0;
procedure unLockVertexBase (Self : in out Item; subpart : in Integer)
is abstract;
--
-- Finishes the access to a subpart of the triangle mesh.
-- Make a call to unLockVertexBase when the read and write access (using getLockedVertexIndexBase) is finished.
procedure unLockReadOnlyVertexBase (Self : in Item; subpart : in Integer)
is abstract;
function getNumSubParts (Self : in Item) return Natural
is abstract;
--
-- getNumSubParts returns the number of seperate subparts.
-- Each subpart has a continuous array of vertices and indices.
procedure preallocateVertices (Self : in out Item; numverts : in Integer)
is abstract;
procedure preallocateIndices (Self : in out Item; numindices : in Integer)
is abstract;
function hasPremadeAabb (Self : in Item) return Boolean;
-- virtual bool hasPremadeAabb() const { return false; }
procedure setPremadeAabb (Self : in out Item; aabbMin, aabbMax : in math.Vector_3) is null;
procedure getPremadeAabb (Self : in Item; aabbMin, aabbMax : out math.Vector_3) is null;
function getScaling (Self : in Item) return math.Vector_3;
procedure setScaling (Self : out Item; scaling : in math.Vector_3);
-- const impact.d3.Vector& getScaling() const {
-- return m_scaling;
-- }
-- void setScaling(const impact.d3.Vector& scaling)
-- {
-- m_scaling = scaling;
-- }
type btIntIndexData is
record
m_value : Integer;
end record;
type btShortIntIndexData is
record
m_value : Short_Integer;
m_pad : String (1 .. 2);
end record;
type short_Integers is array (Positive range <>) of Short_Integer;
type btShortIntIndexTripletData is
record
m_values : short_Integers (1 .. 3);
m_pad : String (1 .. 2);
end record;
type unsigned_Chars is array (Positive range <>) of interfaces.C.unsigned_char;
type btCharIndexTripletData is
record
m_values : unsigned_Chars (1 .. 3);
m_pad : Character;
end record;
private
type Item is abstract tagged
record
m_scaling : math.Vector_3 := (1.0, 1.0, 1.0);
end record;
end impact.d3.striding_Mesh;
|
TotalParserCombinators/AsymmetricChoice.agda | nad/parser-combinators | 1 | 6517 | <reponame>nad/parser-combinators
------------------------------------------------------------------------
-- Asymmetric choice
------------------------------------------------------------------------
module TotalParserCombinators.AsymmetricChoice where
open import Data.Bool
open import Data.Empty
open import Data.List
open import Data.List.Membership.Propositional using (_∈_)
open import Data.List.Properties
open import Data.List.Relation.Binary.BagAndSetEquality
using () renaming (_∼[_]_ to _List-∼[_]_)
open import Data.List.Relation.Unary.Any using (here)
open import Data.Product
import Data.Product.Function.Dependent.Propositional as Σ
open import Data.Unit
open import Function.Base
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence as Equiv
using (module Equivalence; _⇔_)
open import Function.Inverse as Inv using (_↔_)
open import Function.Related as Related
open import Function.Related.TypeIsomorphisms
open import Relation.Binary.PropositionalEquality as P using (_≡_; _≢_)
open import Relation.Nullary
open import TotalParserCombinators.Congruence using (_∼[_]P_; _≅P_)
open import TotalParserCombinators.Derivative using (D)
open import TotalParserCombinators.Parser
import TotalParserCombinators.Pointwise as Pointwise
open import TotalParserCombinators.Semantics using (_∈_·_)
open import TotalParserCombinators.Semantics.Continuation as S
using (_⊕_∈_·_)
------------------------------------------------------------------------
-- An initial bag operator
-- first-nonempty returns the left-most non-empty initial bag, if any.
first-nonempty : {R : Set} → List R → List R → List R
first-nonempty [] ys = ys
first-nonempty xs ys = xs
-- first-nonempty preserves equality.
first-nonempty-cong :
∀ {k R} {xs₁ xs₁′ xs₂ xs₂′ : List R} →
xs₁ List-∼[ ⌊ k ⌋⇔ ] xs₁′ → xs₂ List-∼[ ⌊ k ⌋⇔ ] xs₂′ →
first-nonempty xs₁ xs₂ List-∼[ ⌊ k ⌋⇔ ] first-nonempty xs₁′ xs₂′
first-nonempty-cong {xs₁ = []} {[]} eq₁ eq₂ = eq₂
first-nonempty-cong {xs₁ = _ ∷ _} {_ ∷ _} eq₁ eq₂ = eq₁
first-nonempty-cong {xs₁ = []} {_ ∷ _} eq₁ eq₂
with Equivalence.from (⇒⇔ eq₁) ⟨$⟩ here P.refl
... | ()
first-nonempty-cong {xs₁ = _ ∷ _} {[]} eq₁ eq₂
with Equivalence.to (⇒⇔ eq₁) ⟨$⟩ here P.refl
... | ()
-- first-nonempty is correct.
first-nonempty-left :
∀ {k R} {xs₁ xs₂ : List R} →
(∃ λ y → y ∈ xs₁) → first-nonempty xs₁ xs₂ List-∼[ k ] xs₁
first-nonempty-left {xs₁ = []} (_ , ())
first-nonempty-left {xs₁ = _ ∷ _} _ = _ ∎
where open Related.EquationalReasoning
first-nonempty-right :
∀ {k R} {xs₁ xs₂ : List R} →
(∄ λ y → y ∈ xs₁) → first-nonempty xs₁ xs₂ List-∼[ k ] xs₂
first-nonempty-right {xs₁ = x ∷ _} ∉x∷ = ⊥-elim $ ∉x∷ (x , here P.refl)
first-nonempty-right {xs₁ = []} _ = _ ∎
where open Related.EquationalReasoning
------------------------------------------------------------------------
-- Asymmetric choice
-- _◃_ is defined as a pointwise lifting of first-nonempty. Note that
-- _◃_ preserves parser and language equality, but not the
-- sub-/superparser and sub-/superlanguage relations.
private
module AC {R} = Pointwise R R ⌊_⌋⇔ first-nonempty first-nonempty-cong
-- p₁ ◃ p₂ returns a result if either p₁ or p₂ does. For a given
-- string results are returned either from p₁ or from p₂, not both.
infixl 5 _◃_ _◃-cong_
_◃_ : ∀ {Tok R xs₁ xs₂} →
Parser Tok R xs₁ → Parser Tok R xs₂ →
Parser Tok R (first-nonempty xs₁ xs₂)
_◃_ = AC.lift
-- D distributes over _◃_.
D-◃ : ∀ {Tok R xs₁ xs₂ t}
(p₁ : Parser Tok R xs₁) (p₂ : Parser Tok R xs₂) →
D t (p₁ ◃ p₂) ≅P D t p₁ ◃ D t p₂
D-◃ = AC.D-lift
-- _◃_ preserves equality.
_◃-cong_ : ∀ {k Tok R xs₁ xs₁′ xs₂ xs₂′}
{p₁ : Parser Tok R xs₁} {p₁′ : Parser Tok R xs₁′}
{p₂ : Parser Tok R xs₂} {p₂′ : Parser Tok R xs₂′} →
p₁ ∼[ ⌊ k ⌋⇔ ]P p₁′ → p₂ ∼[ ⌊ k ⌋⇔ ]P p₂′ →
p₁ ◃ p₂ ∼[ ⌊ k ⌋⇔ ]P p₁′ ◃ p₂′
_◃-cong_ = AC.lift-cong
-- If p₁ accepts s, then p₁ ◃ p₂ behaves as p₁ when applied to s.
left : ∀ {Tok R xs₁ xs₂ x s}
(p₁ : Parser Tok R xs₁) (p₂ : Parser Tok R xs₂) →
(∃ λ y → y ∈ p₁ · s) → x ∈ p₁ ◃ p₂ · s ↔ x ∈ p₁ · s
left {x = x} =
AC.lift-property
(λ F _ H → ∃ F → H x ↔ F x)
(λ F↔F′ _ H↔H′ →
Σ.cong Inv.id (λ {x} → ↔⇒ (F↔F′ x))
→-cong-⇔
Related-cong (H↔H′ x) (F↔F′ x))
(λ ∈xs₁ → first-nonempty-left ∈xs₁)
-- If p₁ does not accept s, then p₁ ◃ p₂ behaves as p₂ when applied to
-- s.
right : ∀ {Tok R xs₁ xs₂ x s}
(p₁ : Parser Tok R xs₁) (p₂ : Parser Tok R xs₂) →
(∄ λ y → y ∈ p₁ · s) → x ∈ p₁ ◃ p₂ · s ↔ x ∈ p₂ · s
right {x = x} =
AC.lift-property
(λ F G H → ∄ F → H x ↔ G x)
(λ F↔F′ G↔G′ H↔H′ →
((Σ.cong Inv.id λ {x} → ↔⇒ (F↔F′ x)) →-cong-⇔ Equiv.id)
→-cong-⇔
Related-cong (H↔H′ x) (G↔G′ x))
(λ ∉xs₁ → first-nonempty-right ∉xs₁)
-- In "Parsing with First-Class Derivatives" Brachthäuser, Rendel and
-- Ostermann state that "[...] and biased alternative cannot be
-- expressed as user defined combinators". Here I give a formal proof
-- of a variant of this statement (in the present setting): it is not
-- possible to construct an asymmetric choice operator that, in a
-- certain sense, is more like the prioritised choice of parsing
-- expression grammars (see Ford's "Parsing Expression Grammars: A
-- Recognition-Based Syntactic Foundation") without changing the
-- interface of the parser combinator library.
not-PEG-choice :
¬ ∃₂ λ (_◅-bag_ : {R : Set} → List R → List R → List R)
(_◅_ : ∀ {Tok R xs₁ xs₂} →
Parser Tok R xs₁ → Parser Tok R xs₂ →
Parser Tok R (xs₁ ◅-bag xs₂)) →
∀ {Tok R xs₁ xs₂ s₁}
(p₁ : Parser Tok R xs₁)
(p₂ : Parser Tok R xs₂) →
((∃₂ λ y s₂ → y ⊕ s₂ ∈ p₁ · s₁) →
∀ {x s₂} → x ⊕ s₂ ∈ p₁ ◅ p₂ · s₁ ⇔ x ⊕ s₂ ∈ p₁ · s₁)
×
(¬ (∃₂ λ y s₂ → y ⊕ s₂ ∈ p₁ · s₁) →
∀ {x s₂} → x ⊕ s₂ ∈ p₁ ◅ p₂ · s₁ ⇔ x ⊕ s₂ ∈ p₂ · s₁)
not-PEG-choice (_ , _◅_ , correct) = false∉p₁⊛·[-] false∈p₁⊛·[-]
where
p₁ p₂ : Parser ⊤ Bool _
p₁ = const true <$> token
p₂ = return false
false∈p₂·[] : false ⊕ [] ∈ p₂ · []
false∈p₂·[] = S.return
∄∈p₁·[] : ¬ ∃₂ (λ b s → b ⊕ s ∈ p₁ · [])
∄∈p₁·[] (_ , _ , S.<$> ())
false∈p₁◅p₂·[] : false ⊕ [] ∈ p₁ ◅ p₂ · []
false∈p₁◅p₂·[] =
Equivalence.from (proj₂ (correct _ _) ∄∈p₁·[]) ⟨$⟩ false∈p₂·[]
false∈p₁◅p₂·[-] : false ⊕ [ _ ] ∈ p₁ ◅ p₂ · [ _ ]
false∈p₁◅p₂·[-] = S.extend false∈p₁◅p₂·[]
true∈p₁·[-] : true ⊕ [] ∈ p₁ · [ _ ]
true∈p₁·[-] = S.<$> S.token
false∈p₁·[-] : false ⊕ [ _ ] ∈ p₁ · [ _ ]
false∈p₁·[-] =
Equivalence.to (proj₁ (correct _ _) (-, -, true∈p₁·[-])) ⟨$⟩
false∈p₁◅p₂·[-]
false∈p₁⊛·[-] :
false ⊕ [] ∈ const <$> p₁ ⊛ (return _ ∣ token) · [ _ ]
false∈p₁⊛·[-] = S.[ _ - _ ] S.<$> false∈p₁·[-] ⊛ S.∣-right _ S.token
false∉p₁⊛·[-] :
¬ false ⊕ [] ∈ const <$> p₁ ⊛ (return _ ∣ token) · [ _ ]
false∉p₁⊛·[-] = flip lemma P.refl
where
lemma :
∀ {b} →
b ⊕ [] ∈ const <$> p₁ ⊛ (return _ ∣ token) · [ _ ] → b ≢ false
lemma (S.[ _ - _ ] S.<$> (S.<$> S.token) ⊛ _) ()
|
programs/oeis/069/A069513.asm | neoneye/loda | 22 | 242916 | ; A069513: Characteristic function of the prime powers p^k, k >= 1.
; 0,1,1,1,1,0,1,1,1,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,1,0,1,0,1,0,1,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0
mov $2,1
max $2,$0
seq $0,28233 ; If n = p_1^e_1 * ... * p_k^e_k, p_1 < ... < p_k primes, then a(n) = p_1^e_1, with a(1) = 1.
trn $0,$2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.