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
programs/oeis/258/A258632.asm
neoneye/loda
22
25078
; A258632: Number of length 1 1..(n+1) arrays with every leading partial sum divisible by 2, 3, 5 or 7 ; 1,2,3,4,5,6,7,8,9,9,10,10,11,12,13,13,14,14,15,16,17,17,18,19,20,21,22,22,23,23,24,25,26,27,28,28,29,30,31,31,32,32,33,34,35,35,36,37,38,39,40,40,41,42,43,44,45,45,46,46,47,48,49,50,51,51,52,53,54,54,55,55,56,57,58,59,60,60,61,62,63,63,64,65,66,67,68,68,69,70,71,72,73,74,75,75,76,77,78,78 mov $2,$0 mov $4,$0 add $4,1 lpb $4 mov $0,$2 sub $4,1 sub $0,$4 add $0,2 gcd $0,40320 lpb $0 sub $0,7 gcd $0,2 pow $5,$3 mul $5,2 lpe div $5,2 add $1,$5 lpe mov $0,$1
Structure/Category/NaturalTransformation/Equiv.agda
Lolirofle/stuff-in-agda
6
2686
<gh_stars>1-10 module Structure.Category.NaturalTransformation.Equiv where import Function.Equals open Function.Equals.Dependent import Lvl open import Logic open import Logic.Predicate open import Structure.Category open import Structure.Category.Functor open import Structure.Category.NaturalTransformation open import Structure.Setoid open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Type module _ {ℓₗₒ ℓₗₘ ℓₗₑ ℓᵣₒ ℓᵣₘ ℓᵣₑ} {catₗ : CategoryObject{ℓₗₒ}{ℓₗₘ}{ℓₗₑ}} {catᵣ : CategoryObject{ℓᵣₒ}{ℓᵣₘ}{ℓᵣₑ}} {F₁ : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ} {F₂ : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ} where _≡ᴺᵀ_ : (F₁ →ᴺᵀ F₂) → (F₁ →ᴺᵀ F₂) → Stmt [∃]-intro N₁ ≡ᴺᵀ [∃]-intro N₂ = N₁ ⊜ N₂ instance [≡ᴺᵀ]-reflexivity : Reflexivity(_≡ᴺᵀ_) Reflexivity.proof [≡ᴺᵀ]-reflexivity = reflexivity(_⊜_) instance [≡ᴺᵀ]-symmetry : Symmetry(_≡ᴺᵀ_) Symmetry.proof [≡ᴺᵀ]-symmetry = symmetry(_⊜_) instance [≡ᴺᵀ]-transitivity : Transitivity(_≡ᴺᵀ_) Transitivity.proof [≡ᴺᵀ]-transitivity = transitivity(_⊜_) instance [≡ᴺᵀ]-equivalence : Equivalence(_≡ᴺᵀ_) [≡ᴺᵀ]-equivalence = intro instance [→ᴺᵀ]-equiv : Equiv(F₁ →ᴺᵀ F₂) [→ᴺᵀ]-equiv = intro(_≡ᴺᵀ_) ⦃ [≡ᴺᵀ]-equivalence ⦄
src/asf-events-faces.ads
jquorning/ada-asf
12
12977
<filename>src/asf-events-faces.ads ----------------------------------------------------------------------- -- asf-events -- ASF Events -- Copyright (C) 2010, 2012 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Events; with ASF.Lifecycles; with ASF.Components.Base; with ASF.Events.Phases; with Ada.Containers.Vectors; -- The <b>ASF.Events</b> package defines the application events that an ASF -- application can receive. Events are queued while processing the JSF phases -- (See UIComponent.Queue_Event). They are dispatched after each phase -- (See UIComponent.Broadcast). -- -- This package is an Ada adaptation for the Java Server Faces Specification -- JSR 314 - 3.4.2 Application Events. package ASF.Events.Faces is -- ------------------------------ -- Faces event -- ------------------------------ -- The <b>Faces_Event</b> represents the root type for ASF events. -- The event is associated with a component and a lifecycle phase after -- which it will be processed. type Faces_Event is new Util.Events.Event with private; -- Get the lifecycle phase where the event must be processed. function Get_Phase (Event : in Faces_Event) return ASF.Lifecycles.Phase_Type; -- Set the lifecycle phase when this event must be processed. procedure Set_Phase (Event : in out Faces_Event; Phase : in ASF.Lifecycles.Phase_Type); -- Get the component onto which the event was posted. function Get_Component (Event : in Faces_Event) return Components.Base.UIComponent_Access; private type Faces_Event_Access is access all Faces_Event'Class; package Event_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Faces_Event_Access); type Faces_Event is new Util.Events.Event with record Phase : ASF.Events.Phases.Phase_Type := ASF.Events.Phases.RESTORE_VIEW; Component : Components.Base.UIComponent_Access := null; end record; end ASF.Events.Faces;
Groups/Subgroups/Normal/Examples.agda
Smaug123/agdaproofs
4
2326
{-# OPTIONS --safe --warning=error --without-K #-} open import Groups.Definition open import Setoids.Setoids open import Sets.EquivalenceRelations open import Groups.Subgroups.Normal.Definition module Groups.Subgroups.Normal.Examples {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} (G : Group S _+_) where open import Groups.Subgroups.Examples G open Setoid S open Equivalence eq open Group G trivialSubgroupIsNormal : normalSubgroup G trivialSubgroup trivialSubgroupIsNormal {g} k=0 = transitive (+WellDefined reflexive (transitive (+WellDefined k=0 reflexive) identLeft)) (invRight {g}) improperSubgroupIsNormal : normalSubgroup G improperSubgroup improperSubgroupIsNormal _ = record {}
snippets/mod320.test.i.asm
ped7g/ZXSpectrumNextMisc
15
97789
<gh_stars>10-100 MODULE mod320 test: ld hl,0 ; value to "mod 320" ld de,0 ; expected result .loop: push hl push de ;call hlMod320 ;call hlMod320_unrolled ex de,hl ; LUT variant takes input in DE and returns result in DE call deMod320_lut ex de,hl pop de ; compare result with preserved DE or a sbc hl,de jr z,.hlIsOk ; return signalling error pop hl nextreg TILEMAP_DEFAULT_ATTR_NR_6C,2 ret .hlIsOk: inc de ; update DE to next result of mod320 ld hl,-320 add hl,de jr nc,.deIsOk ex de,hl .deIsOk pop hl ; update HL for next test inc hl ld a,h or l jr nz,.loop ; keep testing full 0..65535 range ret ; test finished ENDMODULE
programs/oeis/075/A075091.asm
neoneye/loda
22
10407
; A075091: Sum of Lucas numbers and reflected Lucas numbers (comment to A061084). ; 4,0,6,0,14,0,36,0,94,0,246,0,644,0,1686,0,4414,0,11556,0,30254,0,79206,0,207364,0,542886,0,1421294,0,3720996,0,9741694,0,25504086,0,66770564,0,174807606,0,457652254,0,1198149156,0,3136795214,0 mov $1,2 mov $2,1 lpb $0 sub $0,2 add $1,$2 add $2,$1 lpe lpb $0 bin $0,3 mov $1,$0 lpe mul $1,2 mov $0,$1
functions/compare.asm
perrada69/CalmCommander
28
21551
; Porovnání adresářů ; ; Porovnává dva adresáře - v levém a pravém panelu. Společné soubory se označují. compare_dirs call savescr call compare.deselect call prohod_okno call compare.deselect call prohod_okno ld hl,10 * 256 + 10 ld bc,60 * 256 + 1 ld a,16 call window ld hl,11*256+11 ld a,16 ld de,please_wait call print ld hl,ALLFILES call ROZHOD2 ld a,(hl) inc hl ld h,(hl) ld l,a comp0 push hl ld (primary_window+1),hl call find83 pop hl push hl dec hl call FINDLFN call prohod_okno ;Presun soubor do LFNNAME2 a hned skoc na porovnavani se soubory v druhém okně ld hl,LFNNAME ld de,LFNNAME2 ld bc,270 ldir call other_window call prohod_okno pop hl dec hl ld a,l or h jp nz,comp0 call invert_body call loadscr ld hl,adrl call ROZHOD2 ld a,(hl) inc hl ld h,(hl) ld l,a ld (adrs+1),hl call getroot_reload call showwin call prohod_okno call invert_body ld hl,adrl call ROZHOD2 ld a,(hl) inc hl ld h,(hl) ld l,a ld (adrs+1),hl call getroot_reload call showwin call prohod_okno ld a,32 call writecur call zobraz_nadpis jp loop0 PROO prohod_okno ld a,(OKNO) xor 16 ld (OKNO),a ret other_window ld hl,ALLFILES call ROZHOD2 ld a,(hl) inc hl ld h,(hl) ld l,a other0 push hl ld (second_window+1),hl call find83 pop hl push hl dec hl call FINDLFN call porovnej_dva_lfn pop hl jr z,second_window dec hl ld a,l or h jp nz,other0 ret second_window ld hl,0 call oznac_soubor_dle_pozice_v_hl call prohod_okno primary_window ld hl,0 call oznac_soubor_dle_pozice_v_hl call prohod_okno ret porovnej_dva_lfn ld hl,LFNNAME+260 por0 ld a,(hl) dec hl cp 32 jr z,por0 inc hl inc hl ld (hl),255 inc hl xor a ld (hl),a ld hl,LFNNAME2+260 por1 ld a,(hl) dec hl cp 32 jr z,por1 inc hl inc hl ld (hl),255 inc hl xor a ld (hl),a ld hl,LFNNAME ld de,LFNNAME2 ld a,0 call specific_search ret module compare deselect ;jp dfind_end ld a,255 ld (23296),a ld hl,ALLFILES call ROZHOD2 ld a,(hl) inc hl ld h,(hl) ld l,a ; dec hl dfind0 push hl call BUFF83 call find83 pop hl push hl dec hl call FINDLFN ld hl,23296 + 59 ;najdi poslední znak dfind1 dec hl ld a,(hl) cp 32 jr z,dfind1 inc hl ld a,255 ld (hl),a ld hl,LFNNAME + 261 ;najdi poslední znak dfind2 dec hl ld a,(hl) cp 32 jr z,dfind2 inc hl ld a,255 ld (hl),a ld de,23296 ld hl,LFNNAME call search jr nz,dnesouhlasi ld hl,(foundfile) call BUFF83 res 7,(hl) ld hl,numsel call ROZHOD2 ld (dadresasel+1),hl ld a,(hl) inc hl ld h,(hl) ld l,a inc hl ld a,l ld (dzvys+1),a ld a,h ld (dzvys2+1),a dadresasel ld hl,0 dzvys ld (hl),0 inc hl dzvys2 ld (hl),0 dnesouhlasi pop hl dec hl ld a,l or h jp nz,dfind0 dfind_end ret endmodule
sources/ippcp/asm_intel64/pcpbnusqrschoolm7as.asm
dongbinghua/ipp-crypto
233
167367
;=============================================================================== ; Copyright 2015-2021 Intel Corporation ; ; 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. ;=============================================================================== ; ; ; Purpose: Cryptography Primitive. ; Big Number Operations ; ; Content: ; cpSqrAdc_BNU_school() ; ; %include "asmdefs.inc" %include "ia_32e.inc" %include "pcpbnumulschool.inc" %include "pcpbnusqrschool.inc" %include "pcpvariant.inc" %if (_ADCOX_NI_ENABLING_ == _FEATURE_OFF_) || (_ADCOX_NI_ENABLING_ == _FEATURE_TICKTOCK_) %if (_IPP32E >= _IPP32E_M7) && (_IPP32E < _IPP32E_L9) ; acc:a1 = src * mem + a1 ; clobbers rax, rdx %macro MULADD0 4.nolist %xdefine %%acc %1 %xdefine %%a1 %2 %xdefine %%src %3 %xdefine %%mem %4 mov rax, %%mem mul %%src xor %%acc, %%acc add %%a1, rax adc %%acc, rdx %endmacro ; acc:a1 = src * mem + a1 + acc ; clobbers rax, rdx %macro MULADD 4.nolist %xdefine %%acc %1 %xdefine %%a1 %2 %xdefine %%src %3 %xdefine %%mem %4 mov rax, %%mem mul %%src add %%a1, rax adc rdx, 0 add %%a1, %%acc adc rdx, 0 mov %%acc, rdx %endmacro ; acc:a1 = src * mem + a1 ; clobbers rax, rdx %macro MULADD1 4.nolist %xdefine %%acc %1 %xdefine %%a1 %2 %xdefine %%src %3 %xdefine %%mem %4 mov rax, %%mem mul %%src add %%a1, rax adc rdx, 0 mov %%acc, rdx %endmacro ; Macro to allow us to do an adc as an adc_0/add pair %macro adc2 2.nolist %xdefine %%a1 %1 %xdefine %%a2 %2 %if 1 adc %%a1, %%a2 %else adc %%a2, 0 add %%a1, %%a2 %endif %endmacro ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This version does the first half of the off-diagonal terms, then adds ; in the first half of the diagonal terms, then does the second half. ; This is to avoid the writing and reading of the off-diagonal terms to mem. ; Due to extra overhead in the arithmetic, this may or may not be faster ; than the simple version (which follows) ; ; Input in memory [pA] and also in x7...x0 ; Uses all argument registers plus rax and rdx ; %macro SQR_512 13.nolist %xdefine %%pDst %1 %xdefine %%pA %2 %xdefine %%x7 %3 %xdefine %%x6 %4 %xdefine %%x5 %5 %xdefine %%x4 %6 %xdefine %%x3 %7 %xdefine %%x2 %8 %xdefine %%x1 %9 %xdefine %%x0 %10 %xdefine %%A %11 %xdefine %%x8 %12 %xdefine %%t0 %13 ;; ------------------ ;; first pass 01...07 ;; ------------------ mov %%A, %%x0 mov rax, %%x1 mul %%A mov %%x0, rax mov %%x1, rdx MULADD1 %%x2, %%x1, %%A, %%x2 MULADD1 %%x3, %%x2, %%A, %%x3 MULADD1 %%x4, %%x3, %%A, %%x4 MULADD1 %%x5, %%x4, %%A, %%x5 MULADD1 %%x6, %%x5, %%A, %%x6 MULADD1 %%x7, %%x6, %%A, %%x7 ;; ------------------ ;; second pass 12...16 ;; ------------------ mov %%A, [%%pA + 8*1] xor %%x8, %%x8 mov rax, [%%pA + 8*2] mul %%A add %%x2, rax adc rdx, 0 mov %%t0, rdx MULADD %%t0, %%x3, %%A, [%%pA + 8*3] MULADD %%t0, %%x4, %%A, [%%pA + 8*4] MULADD %%t0, %%x5, %%A, [%%pA + 8*5] MULADD %%t0, %%x6, %%A, [%%pA + 8*6] add %%x7, %%t0 adc %%x8, 0 ;; ------------------ ;; third pass 23...25 ;; ------------------ mov %%A, [%%pA + 8*2] mov rax, [%%pA + 8*3] mul %%A add %%x4, rax adc rdx, 0 mov %%t0, rdx MULADD %%t0, %%x5, %%A, [%%pA + 8*4] MULADD %%t0, %%x6, %%A, [%%pA + 8*5] add %%x7, %%t0 adc %%x8, 0 ;; ------------------ ;; fourth pass 34 ;; ------------------ mov rax, [%%pA + 8*3] mul qword [%%pA + 8*4] add %%x6, rax adc rdx, 0 add %%x7, rdx adc %%x8, 0 ;; --- double x0...x6 xor %%A, %%A add %%x0, %%x0 adc %%x1, %%x1 adc %%x2, %%x2 adc %%x3, %%x3 adc %%x4, %%x4 adc %%x5, %%x5 adc %%x6, %%x6 adc %%A, 0 mov rax, [%%pA + 8*0] mul rax mov [%%pDst + 8*0], rax mov %%t0, rdx mov rax, [%%pA + 8*1] mul rax add %%x0, %%t0 adc %%x1, rax mov [%%pDst + 8*1], %%x0 adc rdx, 0 mov [%%pDst + 8*2], %%x1 mov %%t0, rdx mov rax, [%%pA + 8*2] mul rax mov %%x0, rax mov %%x1, rdx mov rax, [%%pA + 8*3] mul rax add %%x2, %%t0 adc %%x3, %%x0 mov [%%pDst + 8*3], %%x2 adc2 %%x4, %%x1 mov [%%pDst + 8*4], %%x3 adc %%x5, rax mov [%%pDst + 8*5], %%x4 adc2 %%x6, rdx mov [%%pDst + 8*6], %%x5 adc %%A, 0 mov [%%pDst + 8*7], %%x6 ;; ------------------ ;; second pass 17 ;; ------------------ mov rax, [%%pA + 8*1] xor %%x0, %%x0 mul qword [%%pA + 8*7] add %%x7, rax adc rdx, 0 add %%x8, rdx adc %%x0, 0 ;; ------------------ ;; third pass 26...27 ;; ------------------ mov %%x6, [%%pA + 8*2] mov rax, [%%pA + 8*6] mul %%x6 add %%x7, rax adc rdx, 0 add %%x8, rdx adc %%x0, 0 mov rax, [%%pA + 8*7] xor %%x1, %%x1 mul %%x6 add %%x8, rax adc rdx, 0 add %%x0, rdx adc %%x1, 0 ;; ------------------ ;; fourth pass 35...37 ;; ------------------ mov %%x6, [%%pA + 8*3] mov rax, [%%pA + 8*5] mul %%x6 add %%x7, rax adc rdx, 0 add %%x8, rdx adc %%x0, 0 adc %%x1, 0 mov rax, [%%pA + 8*6] mul %%x6 add %%x8, rax adc rdx, 0 add %%x0, rdx adc %%x1, 0 mov rax, [%%pA + 8*7] mul %%x6 add %%x0, rax adc rdx, 0 add %%x1, rdx ;; carry out should be 0 ;; ------------------ ;; f%ifth pass 45...47 ;; ------------------ mov %%x6, [%%pA + 8*4] mov rax, [%%pA + 8*5] mul %%x6 add %%x8, rax adc rdx, 0 mov %%x2, rdx MULADD %%x2, %%x0, %%x6, [%%pA + 8*6] MULADD %%x2, %%x1, %%x6, [%%pA + 8*7] ;; ------------------ ;; sixth pass 56...57 & seventh pass 67 ;; ------------------ mov %%x6, [%%pA + 8*5] mov rax, [%%pA + 8*6] mul %%x6 add %%x1, rax adc rdx, 0 mov %%x3, rdx MULADD %%x3, %%x2, %%x6, [%%pA + 8*7] mov rax, [%%pA + 8*6] mul qword [%%pA + 8*7] add %%x3, rax adc rdx, 0 mov %%x4, rdx ;; --- double x7, x8, x0, ..., x4 xor %%x5, %%x5 add %%x7, %%x7 adc %%x8, %%x8 adc %%x0, %%x0 adc %%x1, %%x1 adc %%x2, %%x2 adc %%x3, %%x3 adc %%x4, %%x4 adc %%x5, 0 mov rax, [%%pA + 8*4] mul rax add rax, %%A adc rdx, 0 add rax, %%x7 adc rdx, 0 mov [%%pDst + 8*8], rax mov %%A, rdx mov rax, [%%pA + 8*5] mul rax add %%x8, %%A adc %%x0, rax mov [%%pDst + 8*9], %%x8 adc rdx, 0 mov [%%pDst + 8*10], %%x0 mov %%A, rdx mov rax, [%%pA + 8*6] mul rax mov %%x7, rax mov %%x8, rdx mov rax, [%%pA + 8*7] mul rax add %%x1, %%A adc %%x2, %%x7 mov [%%pDst + 8*11], %%x1 adc2 %%x3, %%x8 mov [%%pDst + 8*12], %%x2 adc %%x4, rax mov [%%pDst + 8*13], %%x3 adc2 %%x5, rdx mov [%%pDst + 8*14], %%x4 mov [%%pDst + 8*15], %%x5 %endmacro %macro SQR_448 13.nolist %xdefine %%rDst %1 %xdefine %%rSrc %2 %xdefine %%x7 %3 %xdefine %%x6 %4 %xdefine %%x5 %5 %xdefine %%x4 %6 %xdefine %%x3 %7 %xdefine %%x2 %8 %xdefine %%x1 %9 %xdefine %%x0 %10 %xdefine %%A %11 %xdefine %%x8 %12 %xdefine %%t0 %13 ;; ------------------ ;; first pass 01...06 ;; ------------------ mov %%A, %%x0 mov rax, %%x1 mul %%A mov %%x0, rax mov %%x1, rdx MULADD1 %%x2, %%x1, %%A, %%x2 MULADD1 %%x3, %%x2, %%A, %%x3 MULADD1 %%x4, %%x3, %%A, %%x4 MULADD1 %%x5, %%x4, %%A, %%x5 MULADD1 %%x6, %%x5, %%A, %%x6 ;; ------------------ ;; second pass 12...16 ;; ------------------ mov %%A, [%%rSrc + sizeof(qword)*1] mov rax, [%%rSrc+ sizeof(qword)*2] mul %%A add %%x2, rax adc rdx, 0 mov %%t0, rdx MULADD %%t0, %%x3, %%A, [%%rSrc + sizeof(qword)*3] MULADD %%t0, %%x4, %%A, [%%rSrc + sizeof(qword)*4] MULADD %%t0, %%x5, %%A, [%%rSrc + sizeof(qword)*5] MULADD %%t0, %%x6, %%A, [%%rSrc + sizeof(qword)*6] mov %%x7, %%t0 ;; ------------------ ;; third pass 23...25 ;; ------------------ mov %%A, [%%rSrc + sizeof(qword)*2] xor %%x8, %%x8 mov rax, [%%rSrc + sizeof(qword)*3] mul %%A add %%x4, rax adc rdx, 0 mov %%t0, rdx MULADD %%t0, %%x5, %%A, [%%rSrc+ sizeof(qword)*4] MULADD %%t0, %%x6, %%A, [%%rSrc+ sizeof(qword)*5] add %%x7, %%t0 adc %%x8, 0 ;; ------------------ ;; fourth pass 34 ;; ------------------ mov rax, [%%rSrc + sizeof(qword)*3] mul qword [%%rSrc + sizeof(qword)*4] add %%x6, rax adc rdx, 0 add %%x7, rdx adc %%x8, 0 mov rax, [%%rSrc + sizeof(qword)*0] ;; --- double x0...x6 xor %%A, %%A add %%x0, %%x0 adc %%x1, %%x1 adc %%x2, %%x2 adc %%x3, %%x3 adc %%x4, %%x4 adc %%x5, %%x5 adc %%x6, %%x6 adc %%A, 0 mul rax ; a[0]^2 mov [%%rDst + sizeof(qword)*0], rax mov rax, [%%rSrc + sizeof(qword)*1] mov %%t0, rdx mul rax ; a[1]^2 add %%x0, %%t0 adc %%x1, rax mov rax, [%%rSrc + sizeof(qword)*2] mov [%%rDst + sizeof(qword)*1], %%x0 adc rdx, 0 mov [%%rDst + sizeof(qword)*2], %%x1 mov %%t0, rdx mul rax ; a[2]^2 add %%x2, %%t0 adc %%x3, rax mov rax, [%%rSrc + sizeof(qword)*3] mov [%%rDst + sizeof(qword)*3], %%x2 adc rdx, 0 mov [%%rDst + sizeof(qword)*4], %%x3 mov %%t0, rdx mul rax ; a[3]^2 add %%x4, %%t0 adc %%x5, rax mov [%%rDst + sizeof(qword)*5], %%x4 adc %%x6, rdx mov [%%rDst + sizeof(qword)*6], %%x5 adc %%A, 0 mov [%%rDst + sizeof(qword)*7], %%x6 ;; ------------------ ;; third pass complete 26 ;; ------------------ mov rax, [%%rSrc + sizeof(qword)*2] xor %%x0, %%x0 mul qword [%%rSrc + sizeof(qword)*6] add %%x7, rax adc rdx, 0 add %%x8, rdx adc %%x0, 0 ;; ------------------ ;; forth pass complete 35...36 ;; ------------------ mov %%x6, [%%rSrc + sizeof(qword)*3] mov rax, [%%rSrc+ sizeof(qword)*5] mul %%x6 add %%x7, rax mov rax, [%%rSrc + sizeof(qword)*6] adc %%x8, rdx adc %%x0, 0 mul %%x6 add %%x8, rax adc %%x0, rdx ;; ------------------ ;; f%ifth pass 45...46 ;; ------------------ mov %%x6, [%%rSrc + sizeof(qword)*4] xor %%x1, %%x1 mov rax, [%%rSrc + sizeof(qword)*5] mul %%x6 add %%x8, rax mov rax, [%%rSrc + sizeof(qword)*6] adc %%x0, rdx adc %%x1, 0 mul %%x6 add %%x0, rax adc %%x1, rdx ;; ------------------ ;; six pass 56 ;; ------------------ mov %%x6, [%%rSrc + sizeof(qword)*5] xor %%x2, %%x2 mov rax, [%%rSrc + sizeof(qword)*6] mul %%x6 add %%x1, rax adc %%x2, rdx mov rax, [%%rSrc + sizeof(qword)*4] ;; --- double x7, x8, x0, x1, x2 xor %%x3, %%x3 add %%x7, %%x7 adc %%x8, %%x8 adc %%x0, %%x0 adc %%x1, %%x1 adc %%x2, %%x2 adc %%x3, 0 mul rax ; a[4]^2 add %%x7, %%A adc rdx, 0 xor %%A, %%A add %%x7, rax mov rax, [%%rSrc + sizeof(qword)*5] adc %%x8, rdx mov [%%rDst+ sizeof(qword)*8], %%x7 adc %%A, 0 mov [%%rDst + sizeof(qword)*9], %%x8 mul rax ; a[5]^2 add %%x0, %%A adc rdx, 0 xor %%A, %%A add %%x0, rax mov rax, [%%rSrc + sizeof(qword)*6] adc %%x1, rdx mov [%%rDst + sizeof(qword)*10], %%x0 adc %%A, 0 mov [%%rDst + sizeof(qword)*11], %%x1 mul rax ; a[6]^2 add %%x2, %%A adc rdx, 0 add %%x2, rax adc rdx, %%x3 mov [%%rDst + sizeof(qword)*12], %%x2 mov [%%rDst + sizeof(qword)*13], rdx %endmacro %macro SQR_384 13.nolist %xdefine %%rDst %1 %xdefine %%rSrc %2 %xdefine %%x7 %3 %xdefine %%x6 %4 %xdefine %%x5 %5 %xdefine %%x4 %6 %xdefine %%x3 %7 %xdefine %%x2 %8 %xdefine %%x1 %9 %xdefine %%x0 %10 %xdefine %%A %11 %xdefine %%x8 %12 %xdefine %%t0 %13 mov %%A, %%x0 mov rax, %%x1 mul %%A mov %%x0, rax mov %%x1, rdx MULADD1 %%x2, %%x1, %%A, %%x2 MULADD1 %%x3, %%x2, %%A, %%x3 MULADD1 %%x4, %%x3, %%A, %%x4 MULADD1 %%x5, %%x4, %%A, %%x5 mov %%A, qword [%%rSrc+ sizeof(qword)*1] mov rax, qword [%%rSrc+ sizeof(qword)*2] mul %%A add %%x2, rax adc rdx, 0 mov %%t0, rdx MULADD %%t0, %%x3, %%A, [%%rSrc + sizeof(qword)*3] MULADD %%t0, %%x4, %%A, [%%rSrc + sizeof(qword)*4] MULADD %%t0, %%x5, %%A, [%%rSrc + sizeof(qword)*5] mov %%x6, %%t0 mov %%A, qword [%%rSrc+ sizeof(qword)*2] mov rax, qword [%%rSrc+ sizeof(qword)*3] mul %%A add %%x4, rax adc rdx, 0 mov %%t0, rdx MULADD %%t0, %%x5, %%A, [%%rSrc + sizeof(qword)*4] MULADD %%t0, %%x6, %%A, [%%rSrc + sizeof(qword)*5] mov %%x7, %%t0 mov %%A, qword [%%rSrc+ sizeof(qword)*3] mov rax, qword [%%rSrc+ sizeof(qword)*4] mul %%A xor %%x8, %%x8 add %%x6, rax mov rax, qword [%%rSrc+ sizeof(qword)*5] adc %%x7, rdx adc %%x8, 0 mul %%A mov %%A, qword [%%rSrc+ sizeof(qword)*4] add %%x7, rax mov rax, qword [%%rSrc+ sizeof(qword)*5] adc %%x8, rdx mul %%A xor %%t0, %%t0 add %%x8, rax adc %%t0, rdx mov rax, [%%rSrc + sizeof(qword)*0] ;; --- double x0...x7,x8,t0 xor %%A, %%A add %%x0, %%x0 adc %%x1, %%x1 adc %%x2, %%x2 adc %%x3, %%x3 adc %%x4, %%x4 adc %%x5, %%x5 adc %%x6, %%x6 adc %%x7, %%x7 adc %%x8, %%x8 adc %%t0, %%t0 adc %%A, 0 mov qword [rsp], %%A mul rax mov [%%rDst + sizeof(qword)*0], rax mov rax, [%%rSrc + sizeof(qword)*1] ; a[1] mov %%A, rdx mul rax add %%x0, %%A adc %%x1, rax mov rax, [%%rSrc + sizeof(qword)*2] ; a[2] mov [%%rDst + sizeof(qword)*1], %%x0 adc rdx, 0 mov [%%rDst + sizeof(qword)*2], %%x1 mov %%A, rdx mul rax add %%x2, %%A adc %%x3, rax mov rax, [%%rSrc + sizeof(qword)*3] ; a[3] mov [%%rDst + sizeof(qword)*3], %%x2 adc rdx, 0 mov [%%rDst + sizeof(qword)*4], %%x3 mov %%A, rdx mul rax add %%x4, %%A adc %%x5, rax mov rax, [%%rSrc + sizeof(qword)*4] ; a[4] mov [%%rDst + sizeof(qword)*5], %%x4 adc rdx, 0 mov [%%rDst + sizeof(qword)*6], %%x5 mov %%A, rdx mul rax add %%x6, %%A adc %%x7, rax mov rax, [%%rSrc + sizeof(qword)*5] ; a[5] mov [%%rDst + sizeof(qword)*7], %%x6 adc rdx, 0 mov [%%rDst + sizeof(qword)*8], %%x7 mov %%A, rdx mul rax add %%x8, %%A adc %%t0, rax mov [%%rDst + sizeof(qword)*9], %%x8 adc rdx, qword [rsp] mov [%%rDst + sizeof(qword)*10], %%t0 mov [%%rDst + sizeof(qword)*11], rdx %endmacro %macro SQR_320 13.nolist %xdefine %%rDst %1 %xdefine %%rSrc %2 %xdefine %%x7 %3 %xdefine %%x6 %4 %xdefine %%x5 %5 %xdefine %%x4 %6 %xdefine %%x3 %7 %xdefine %%x2 %8 %xdefine %%x1 %9 %xdefine %%x0 %10 %xdefine %%A %11 %xdefine %%x8 %12 %xdefine %%t0 %13 mov %%A, %%x0 mov rax, %%x1 mul %%A mov %%x0, rax mov %%x1, rdx MULADD1 %%x2, %%x1, %%A, %%x2 MULADD1 %%x3, %%x2, %%A, %%x3 MULADD1 %%x4, %%x3, %%A, %%x4 mov %%A, qword [%%rSrc+ sizeof(qword)*1] mov rax, qword [%%rSrc+ sizeof(qword)*2] mul %%A add %%x2, rax adc rdx, 0 mov %%t0, rdx MULADD %%t0, %%x3, %%A, [%%rSrc + sizeof(qword)*3] MULADD %%t0, %%x4, %%A, [%%rSrc + sizeof(qword)*4] mov %%x5, %%t0 mov %%A, qword [%%rSrc+ sizeof(qword)*2] mov rax, qword [%%rSrc+ sizeof(qword)*3] mul %%A xor %%x6, %%x6 add %%x4, rax mov rax, qword [%%rSrc+ sizeof(qword)*4] adc %%x5, rdx adc %%x6, 0 mul %%A mov %%A, qword [%%rSrc+ sizeof(qword)*3] add %%x5, rax mov rax, qword [%%rSrc+ sizeof(qword)*4] adc %%x6, rdx mul %%A xor %%x7, %%x7 add %%x6, rax adc %%x7, rdx mov rax, [%%rSrc + sizeof(qword)*0] ;; --- double x0...x5 xor %%A, %%A add %%x0, %%x0 adc %%x1, %%x1 adc %%x2, %%x2 adc %%x3, %%x3 adc %%x4, %%x4 adc %%x5, %%x5 adc %%x6, %%x6 adc %%x7, %%x7 adc %%A, 0 mul rax mov [%%rDst + sizeof(qword)*0], rax mov rax, [%%rSrc + sizeof(qword)*1] mov %%t0, rdx mul rax add %%x0, %%t0 adc %%x1, rax mov rax, [%%rSrc + sizeof(qword)*2] mov [%%rDst + sizeof(qword)*1], %%x0 adc rdx, 0 mov [%%rDst + sizeof(qword)*2], %%x1 mov %%t0, rdx mul rax add %%x2, %%t0 adc %%x3, rax mov rax, [%%rSrc + sizeof(qword)*3] mov [%%rDst + sizeof(qword)*3], %%x2 adc rdx, 0 mov [%%rDst + sizeof(qword)*4], %%x3 mov %%t0, rdx mul rax add %%x4, %%t0 adc %%x5, rax mov rax, [%%rSrc + sizeof(qword)*4] mov [%%rDst + sizeof(qword)*5], %%x4 adc rdx, 0 mov [%%rDst + sizeof(qword)*6], %%x5 mov %%t0, rdx mul rax add %%x6, %%t0 adc %%x7, rax mov [%%rDst + sizeof(qword)*7], %%x6 adc rdx, 0 mov [%%rDst + sizeof(qword)*8], %%x7 add rdx, %%A mov [%%rDst + sizeof(qword)*9], rdx %endmacro %macro SQR_256 13.nolist %xdefine %%rDst %1 %xdefine %%rSrc %2 %xdefine %%x7 %3 %xdefine %%x6 %4 %xdefine %%x5 %5 %xdefine %%x4 %6 %xdefine %%x3 %7 %xdefine %%x2 %8 %xdefine %%x1 %9 %xdefine %%x0 %10 %xdefine %%A %11 %xdefine %%x8 %12 %xdefine %%t0 %13 ;; ------------------ ;; first pass 01...03 ;; ------------------ mov %%A, %%x0 mov rax, %%x1 mul %%A mov %%x0, rax mov %%x1, rdx MULADD1 %%x2, %%x1, %%A, %%x2 MULADD1 %%x3, %%x2, %%A, %%x3 ;; ------------------ ;; second pass 12, 13 ;; ------------------ mov %%A, qword [%%rSrc+ sizeof(qword)*1] mov rax, qword [%%rSrc+ sizeof(qword)*2] mul %%A xor %%x4, %%x4 add %%x2, rax mov rax, qword [%%rSrc+ sizeof(qword)*3] adc %%x3, rdx adc %%x4, 0 mul %%A mov %%A, qword [%%rSrc+ sizeof(qword)*2] add %%x3, rax mov rax, qword [%%rSrc+ sizeof(qword)*3] adc %%x4, rdx ;; ------------------ ;; third pass 23 ;; ------------------ mul %%A xor %%x5, %%x5 add %%x4, rax adc %%x5, rdx mov rax, [%%rSrc + sizeof(qword)*0] ;; --- double x0...x5 xor %%A, %%A add %%x0, %%x0 adc %%x1, %%x1 adc %%x2, %%x2 adc %%x3, %%x3 adc %%x4, %%x4 adc %%x5, %%x5 adc %%A, 0 mul rax mov [%%rDst + sizeof(qword)*0], rax mov rax, [%%rSrc + sizeof(qword)*1] mov %%t0, rdx mul rax add %%x0, %%t0 adc %%x1, rax mov rax, [%%rSrc + sizeof(qword)*2] mov [%%rDst + sizeof(qword)*1], %%x0 adc rdx, 0 mov [%%rDst + sizeof(qword)*2], %%x1 mov %%t0, rdx mul rax add %%x2, %%t0 adc %%x3, rax mov rax, [%%rSrc + sizeof(qword)*3] mov [%%rDst + sizeof(qword)*3], %%x2 adc rdx, 0 mov [%%rDst + sizeof(qword)*4], %%x3 mov %%t0, rdx mul rax add %%x4, %%t0 adc %%x5, rax mov [%%rDst + sizeof(qword)*5], %%x4 adc rdx, 0 mov [%%rDst + sizeof(qword)*6], %%x5 add rdx, %%A mov [%%rDst + sizeof(qword)*7], rdx %endmacro %macro SQR_192 13.nolist %xdefine %%rDst %1 %xdefine %%rSrc %2 %xdefine %%x7 %3 %xdefine %%x6 %4 %xdefine %%x5 %5 %xdefine %%x4 %6 %xdefine %%x3 %7 %xdefine %%x2 %8 %xdefine %%x1 %9 %xdefine %%x0 %10 %xdefine %%A %11 %xdefine %%x8 %12 %xdefine %%t0 %13 mov %%A, %%x0 mov rax, %%x1 mul %%A mov %%x0, rax mov %%x1, rdx MULADD1 %%x2, %%x1, %%A, %%x2 mov rax, qword [%%rSrc+ sizeof(qword)*1] mul qword [%%rSrc+ sizeof(qword)*2] xor %%x3, %%x3 add %%x2, rax adc %%x3, rdx xor %%A, %%A add %%x0, %%x0 adc %%x1, %%x1 adc %%x2, %%x2 adc %%x3, %%x3 adc %%A, %%A mov rax, qword [%%rSrc+ sizeof(qword)*0] mul rax mov %%x4, rax mov %%x5, rdx mov rax, qword [%%rSrc+ sizeof(qword)*1] mul rax mov %%x6, rax mov %%x7, rdx mov rax, qword [%%rSrc+ sizeof(qword)*2] mul rax mov qword [%%rDst+sizeof(qword)*0], %%x4 add %%x5, %%x0 mov qword [%%rDst+sizeof(qword)*1], %%x5 adc %%x6, %%x1 mov qword [%%rDst+sizeof(qword)*2], %%x6 adc %%x7, %%x2 mov qword [%%rDst+sizeof(qword)*3], %%x7 adc rax, %%x3 mov qword [%%rDst+sizeof(qword)*4], rax adc rdx, %%A mov qword [%%rDst+sizeof(qword)*5], rdx %endmacro segment .text align=IPP_ALIGN_FACTOR ;************************************************************* ;* Ipp64u cpSqrAdc_BNU_school(Ipp64u* pR; ;* const Ipp64u* pA, int aSize) ;* returns pR[aSize+aSize-1] ;* ;************************************************************* align IPP_ALIGN_FACTOR IPPASM cpSqrAdc_BNU_school,PUBLIC %assign LOCAL_FRAME (3*sizeof(qword)) USES_GPR rbx,rbp,rsi,rdi,r12,r13,r14,r15 USES_XMM COMP_ABI 3 ;; ;; assignment %xdefine rDst rdi %xdefine rSrc rsi %xdefine srcL rdx %xdefine A rcx %xdefine x0 r8 %xdefine x1 r9 %xdefine x2 r10 %xdefine x3 r11 %xdefine x4 r12 %xdefine x5 r13 %xdefine x6 r14 %xdefine x7 r15 %xdefine x8 rbx %xdefine t0 rbp cmp edx, 4 jg .more_then_4 cmp edx, 3 jg .SQR4 je .SQR3 jp .SQR2 align IPP_ALIGN_FACTOR .SQR1: ;; len=1 mov rax, qword [rsi] ; eax = a mul rax ; eax = rL edx = rH mov qword [rdi], rax ; mov rax, rdx ; mov qword [rdi+8], rdx ; mov rax, rdx REST_XMM REST_GPR ret align IPP_ALIGN_FACTOR .SQR2: ;; len=2 mov rax, qword [rsi] ; a[0] mul qword [rsi+sizeof(qword)*1] ; a[0]*a[1] xor A, A mov x2, rax mov x3, rdx mov rax, qword [rsi] ; a[0] mul rax ; (x1:x0) = a[1]^2 add x2, x2 ; (A:x3:x2) = 2*a[0]*a[1] adc x3, x3 adc A, 0 mov x0, rax mov x1, rdx mov rax, qword [rsi+sizeof(qword)*1]; a[1] mul rax ; (rdx:rax) = a[1]^2 mov qword [rdi+sizeof(qword)*0], x0 add x1, x2 mov qword [rdi+sizeof(qword)*1], x1 adc rax, x3 mov qword [rdi+sizeof(qword)*2], rax adc rdx, A mov qword [rdi+sizeof(qword)*3], rdx mov rax, rdx REST_XMM REST_GPR ret align IPP_ALIGN_FACTOR .SQR3: ;; len=3 mov x0, [rSrc+ sizeof(qword)*0] mov x1, [rSrc+ sizeof(qword)*1] mov x2, [rSrc+ sizeof(qword)*2] SQR_192 rDst, rSrc, x7, x6, x5, x4, x3, x2, x1, x0, A, x8, t0 mov rax, rdx REST_XMM REST_GPR ret align IPP_ALIGN_FACTOR .SQR4: ;; len=4 mov x0, [rSrc+ sizeof(qword)*0] mov x1, [rSrc+ sizeof(qword)*1] mov x2, [rSrc+ sizeof(qword)*2] mov x3, [rSrc+ sizeof(qword)*3] SQR_256 rDst, rSrc, x7, x6, x5, x4, x3, x2, x1, x0, A, x8, t0 mov rax, rdx REST_XMM REST_GPR ret align IPP_ALIGN_FACTOR .more_then_4: cmp edx, 8 jg .general_case cmp edx, 7 jg .SQR8 je .SQR7 jp .SQR6 align IPP_ALIGN_FACTOR .SQR5: ;; len=5 mov x0, [rSrc+ sizeof(qword)*0] mov x1, [rSrc+ sizeof(qword)*1] mov x2, [rSrc+ sizeof(qword)*2] mov x3, [rSrc+ sizeof(qword)*3] mov x4, [rSrc+ sizeof(qword)*4] SQR_320 rDst, rSrc, x7, x6, x5, x4, x3, x2, x1, x0, A, x8, t0 mov rax, rdx REST_XMM REST_GPR ret align IPP_ALIGN_FACTOR .SQR6: ;; len=6 mov x0, [rSrc+ sizeof(qword)*0] mov x1, [rSrc+ sizeof(qword)*1] mov x2, [rSrc+ sizeof(qword)*2] mov x3, [rSrc+ sizeof(qword)*3] mov x4, [rSrc+ sizeof(qword)*4] mov x5, [rSrc+ sizeof(qword)*5] SQR_384 rDst, rSrc, x7, x6, x5, x4, x3, x2, x1, x0, A, x8, t0 mov rax, rdx REST_XMM REST_GPR ret align IPP_ALIGN_FACTOR .SQR7: ;; len=7 mov x0, [rSrc+ sizeof(qword)*0] mov x1, [rSrc+ sizeof(qword)*1] mov x2, [rSrc+ sizeof(qword)*2] mov x3, [rSrc+ sizeof(qword)*3] mov x4, [rSrc+ sizeof(qword)*4] mov x5, [rSrc+ sizeof(qword)*5] mov x6, [rSrc+ sizeof(qword)*6] SQR_448 rDst, rSrc, x7, x6, x5, x4, x3, x2, x1, x0, A, x8, t0 mov rax, rdx REST_XMM REST_GPR ret align IPP_ALIGN_FACTOR .SQR8: ;; len=8 mov x0, [rSrc+ sizeof(qword)*0] mov x1, [rSrc+ sizeof(qword)*1] mov x2, [rSrc+ sizeof(qword)*2] mov x3, [rSrc+ sizeof(qword)*3] mov x4, [rSrc+ sizeof(qword)*4] mov x5, [rSrc+ sizeof(qword)*5] mov x6, [rSrc+ sizeof(qword)*6] mov x7, [rSrc+ sizeof(qword)*7] SQR_512 rDst, rSrc, x7, x6, x5, x4, x3, x2, x1, x0, A, x8, t0 mov rax, rdx REST_XMM REST_GPR ret ;********** lenSrcA > 8 ************************************** align IPP_ALIGN_FACTOR .general_case: ;; ;; stack structure: %assign pDst 0 %assign pSrc pDst+sizeof(qword) %assign len pSrc+sizeof(qword) ;; ;; assignment %xdefine B0 r10 ; a[i], a[i+1] %xdefine B1 r11 %xdefine T0 r12 ; temporary %xdefine T1 r13 %xdefine T2 r14 %xdefine T3 r15 %xdefine idx rcx ; indexs %xdefine idxt rbx %xdefine rSrc rsi %xdefine rDst rdi movsxd rdx, edx ; expand length mov [rsp+pDst], rdi ; save parameters mov [rsp+pSrc], rsi mov [rsp+len], rdx mov r8, rdx mov rax, dword 2 mov rbx, dword 1 test r8, 1 cmove rax, rbx ; delta = len&1? 2:1 sub rdx, rax ; len -= delta lea rsi, [rsi+rax*sizeof(qword)] ; A' = A+delta lea rdi, [rdi+rax*sizeof(qword)] ; R' = R+delta lea rsi, [rsi+rdx*sizeof(qword)-4*sizeof(qword)] ; rsi = &A'[len-4] lea rdi, [rdi+rdx*sizeof(qword)-4*sizeof(qword)] ; rdi = &R'[len-4] mov idx, dword 4 ; init sub idx, rdx ; negative index test r8, 1 jnz .init_odd_len_operation ;********** odd number of passes (multiply only) ********************* .init_even_len_operation: mov B0, qword [rsi+idx*sizeof(qword)-sizeof(qword)] ; B0 = a[0] mov rax, qword [rsi+idx*sizeof(qword)] ; a[1] xor T0, T0 cmp idx, 0 jge .skip_mul1 mov idxt, idx MULx1 rdi, rsi, idxt, B0, T0, T1, T2, T3 .skip_mul1: cmp idxt, 1 jne .fin_mulx1_3 ; idx=3 (effective len=4n+1) ; .fin_mulx1_1 ; idx=1 (effective len=4n+3) .fin_mulx1_1: sMULx1_4N_3_ELOG rdi, rsi, {add idx,2}, B0, T0,T1,T2,T3 jmp .odd_pass_pairs .fin_mulx1_3: sMULx1_4N_1_ELOG rdi, rsi, {add idx,2}, B0, T0,T1,T2,T3 jmp .even_pass_pairs ;********** even number of passes (multiply only) ********************* .init_odd_len_operation: mov B0, qword [rsi+idx*sizeof(qword)-2*sizeof(qword)] ; a[0] and a[1] mov B1, qword [rsi+idx*sizeof(qword)-sizeof(qword)] mov rax, B1 ; a[0]*a[1] mul B0 mov qword [rdi+idx*sizeof(qword)-sizeof(qword)], rax mov rax, qword [rsi+idx*sizeof(qword)] ; a[2] mov T0, rdx mul B0 ; a[0]*a[2] xor T1, T1 xor T2, T2 add T0, rax mov rax, qword [rsi+idx*sizeof(qword)] ; a[2] adc T1, rdx cmp idx, 0 jge .skip_mul_nx2 mov idxt, idx MULx2 rdi, rsi, idxt, B0,B1, T0,T1,T2,T3 .skip_mul_nx2: cmp idxt, 1 jnz .fin_mul2x_3 ; idx=3 (effective len=4n+3) ; .fin_mul2x_1 ; idx=1 (effective len=4n+1) .fin_mul2x_1: sMULx2_4N_3_ELOG rdi, rsi, {add idx,2}, B0,B1, T0,T1,T2,T3 add rdi, 2*sizeof(qword) jmp .odd_pass_pairs .fin_mul2x_3: sMULx2_4N_1_ELOG rdi, rsi, {add idx,2}, B0,B1, T0,T1,T2,T3 add rdi, 2*sizeof(qword) align IPP_ALIGN_FACTOR .even_pass_pairs: sMLAx2_PLOG {rdi+idx*sizeof(qword)}, {rsi+idx*sizeof(qword)}, B0,B1, T0,T1,T2,T3 cmp idx, 0 jge .skip1 mov idxt, idx MLAx2 rdi, rsi, idxt, B0,B1, T0,T1,T2,T3 .skip1: sMLAx2_4N_3_ELOG rdi, rsi, {add idx,2}, B0,B1, T0,T1,T2,T3 add rdi, 2*sizeof(qword) .odd_pass_pairs: sMLAx2_PLOG {rdi+idx*sizeof(qword)}, {rsi+idx*sizeof(qword)}, B0,B1, T0,T1,T2,T3 cmp idx, 0 jge .skip2 mov idxt, idx MLAx2 rdi, rsi, idxt, B0,B1, T0,T1,T2,T3 .skip2: sMLAx2_4N_1_ELOG rdi, rsi, {add idx,2}, B0,B1, T0,T1,T2,T3 add rdi, 2*sizeof(qword) cmp idx, 4 jl .even_pass_pairs .add_diag: mov rdi, [rsp+pDst] ; restore parameters mov rsi, [rsp+pSrc] mov rcx, [rsp+len] xor idxt, idxt xor T0, T0 xor T1, T1 lea rax, [rdi+rcx*sizeof(qword)] lea rsi, [rsi+rcx*sizeof(qword)] mov qword [rdi], T0 ; r[0] = 0 mov qword [rax+rcx*sizeof(qword)-sizeof(qword)], T0 ; r[2*len-1] = 0 neg rcx align IPP_ALIGN_FACTOR .add_diag_loop: mov rax, qword [rsi+rcx*sizeof(qword)] ; a[i] mul rax mov T2, qword [rdi] ; r[2*i] mov T3, qword [rdi+sizeof(qword)] ; r[2*i+1] add T0, 1 adc T2, T2 adc T3, T3 sbb T0, T0 add T1, 1 adc T2, rax adc T3, rdx sbb T1, T1 mov qword [rdi], T2 mov qword [rdi+sizeof(qword)], T3 add rdi, sizeof(qword)*2 add rcx, 1 jnz .add_diag_loop mov rax, T3 ; r[2*len-1] REST_XMM REST_GPR ret ENDFUNC cpSqrAdc_BNU_school %endif %endif ;; _ADCOX_NI_ENABLING_
source/required/s-stratt.ads
ytomino/drake
33
9236
pragma License (Unrestricted); -- implementation unit required by compiler with Ada.IO_Exceptions; with Ada.Streams; with System.Unsigned_Types; package System.Stream_Attributes is pragma Preelaborate; -- required for 'Read/'Write attributes by compiler (s-stratt.ads) type Thin_Pointer is record P1 : Address; end record; pragma Suppress_Initialization (Thin_Pointer); type Fat_Pointer is record P1 : Address; P2 : Address; end record; pragma Suppress_Initialization (Fat_Pointer); function I_AD (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Fat_Pointer; function I_AS (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Thin_Pointer; function I_B (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Boolean; function I_C (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Character; function I_F (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Float; function I_I (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Integer; function I_LF (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Long_Float; function I_LI (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Long_Integer; function I_LLF (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Long_Long_Float; function I_LLI (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Long_Long_Integer; function I_LLU (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Unsigned_Types.Long_Long_Unsigned; function I_LU (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Unsigned_Types.Long_Unsigned; function I_SF (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Short_Float; function I_SI (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Short_Integer; function I_SSI (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Short_Short_Integer; function I_SSU (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Unsigned_Types.Short_Short_Unsigned; function I_SU (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Unsigned_Types.Short_Unsigned; function I_U (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Unsigned_Types.Unsigned; function I_WC (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Wide_Character; function I_WWC (Stream : not null access Ada.Streams.Root_Stream_Type'Class) return Wide_Wide_Character; pragma Inline (I_AD); pragma Inline (I_AS); pragma Inline (I_B); pragma Inline (I_C); pragma Inline (I_F); pragma Inline (I_I); pragma Inline (I_LF); pragma Inline (I_LI); pragma Inline (I_LLF); pragma Inline (I_LLI); pragma Inline (I_LLU); pragma Inline (I_LU); pragma Inline (I_SF); pragma Inline (I_SI); pragma Inline (I_SSI); pragma Inline (I_SSU); pragma Inline (I_SU); pragma Inline (I_U); pragma Inline (I_WC); pragma Inline (I_WWC); procedure W_AD ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Fat_Pointer); procedure W_AS ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Thin_Pointer); procedure W_B ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Boolean); procedure W_C ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Character); procedure W_F ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Float); procedure W_I ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Integer); procedure W_LF ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Long_Float); procedure W_LI ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Long_Integer); procedure W_LLF ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Long_Long_Float); procedure W_LLI ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Long_Long_Integer); procedure W_LLU ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Unsigned_Types.Long_Long_Unsigned); procedure W_LU ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Unsigned_Types.Long_Unsigned); procedure W_SF ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Short_Float); procedure W_SI ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Short_Integer); procedure W_SSI ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Short_Short_Integer); procedure W_SSU ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Unsigned_Types.Short_Short_Unsigned); procedure W_SU ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Unsigned_Types.Short_Unsigned); procedure W_U ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Unsigned_Types.Unsigned); procedure W_WC ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Wide_Character); procedure W_WWC ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Wide_Wide_Character); pragma Inline (W_AD); pragma Inline (W_AS); pragma Inline (W_B); pragma Inline (W_C); pragma Inline (W_F); pragma Inline (W_I); pragma Inline (W_LF); pragma Inline (W_LI); pragma Inline (W_LLF); pragma Inline (W_LLI); pragma Inline (W_LLU); pragma Inline (W_LU); pragma Inline (W_SF); pragma Inline (W_SI); pragma Inline (W_SSI); pragma Inline (W_SSU); pragma Inline (W_SU); pragma Inline (W_U); pragma Inline (W_WC); pragma Inline (W_WWC); -- required for default 'Read/'Write attributes by compiler (s-stratt.ads) -- in original libgnat, Block_IO_OK is a function, but constant is ok (?) Block_IO_OK : constant Boolean := True; -- exceptions End_Error : exception renames Ada.IO_Exceptions.End_Error; end System.Stream_Attributes;
source/nodes/program-nodes-record_representation_clauses.adb
optikos/oasis
0
10968
-- Copyright (c) 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Record_Representation_Clauses is function Create (For_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Name : not null Program.Elements.Expressions .Expression_Access; Use_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Record_Token : not null Program.Lexical_Elements .Lexical_Element_Access; At_Token : Program.Lexical_Elements.Lexical_Element_Access; Mod_Token : Program.Lexical_Elements.Lexical_Element_Access; Mod_Clause_Expression : Program.Elements.Expressions.Expression_Access; Mod_Semicolon_Token : Program.Lexical_Elements.Lexical_Element_Access; Component_Clauses : not null Program.Elements.Component_Clauses .Component_Clause_Vector_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Record_Representation_Clause is begin return Result : Record_Representation_Clause := (For_Token => For_Token, Name => Name, Use_Token => Use_Token, Record_Token => Record_Token, At_Token => At_Token, Mod_Token => Mod_Token, Mod_Clause_Expression => Mod_Clause_Expression, Mod_Semicolon_Token => Mod_Semicolon_Token, Component_Clauses => Component_Clauses, Semicolon_Token => Semicolon_Token, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Name : not null Program.Elements.Expressions .Expression_Access; Mod_Clause_Expression : Program.Elements.Expressions.Expression_Access; Component_Clauses : not null Program.Elements.Component_Clauses .Component_Clause_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Record_Representation_Clause is begin return Result : Implicit_Record_Representation_Clause := (Name => Name, Mod_Clause_Expression => Mod_Clause_Expression, Component_Clauses => Component_Clauses, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Name (Self : Base_Record_Representation_Clause) return not null Program.Elements.Expressions.Expression_Access is begin return Self.Name; end Name; overriding function Mod_Clause_Expression (Self : Base_Record_Representation_Clause) return Program.Elements.Expressions.Expression_Access is begin return Self.Mod_Clause_Expression; end Mod_Clause_Expression; overriding function Component_Clauses (Self : Base_Record_Representation_Clause) return not null Program.Elements.Component_Clauses .Component_Clause_Vector_Access is begin return Self.Component_Clauses; end Component_Clauses; overriding function For_Token (Self : Record_Representation_Clause) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.For_Token; end For_Token; overriding function Use_Token (Self : Record_Representation_Clause) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Use_Token; end Use_Token; overriding function Record_Token (Self : Record_Representation_Clause) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Record_Token; end Record_Token; overriding function At_Token (Self : Record_Representation_Clause) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.At_Token; end At_Token; overriding function Mod_Token (Self : Record_Representation_Clause) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Mod_Token; end Mod_Token; overriding function Mod_Semicolon_Token (Self : Record_Representation_Clause) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Mod_Semicolon_Token; end Mod_Semicolon_Token; overriding function Semicolon_Token (Self : Record_Representation_Clause) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Semicolon_Token; end Semicolon_Token; overriding function Is_Part_Of_Implicit (Self : Implicit_Record_Representation_Clause) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Record_Representation_Clause) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Record_Representation_Clause) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; procedure Initialize (Self : aliased in out Base_Record_Representation_Clause'Class) is begin Set_Enclosing_Element (Self.Name, Self'Unchecked_Access); if Self.Mod_Clause_Expression.Assigned then Set_Enclosing_Element (Self.Mod_Clause_Expression, Self'Unchecked_Access); end if; for Item in Self.Component_Clauses.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; null; end Initialize; overriding function Is_Record_Representation_Clause_Element (Self : Base_Record_Representation_Clause) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Record_Representation_Clause_Element; overriding function Is_Representation_Clause_Element (Self : Base_Record_Representation_Clause) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Representation_Clause_Element; overriding function Is_Clause_Element (Self : Base_Record_Representation_Clause) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Clause_Element; overriding procedure Visit (Self : not null access Base_Record_Representation_Clause; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Record_Representation_Clause (Self); end Visit; overriding function To_Record_Representation_Clause_Text (Self : aliased in out Record_Representation_Clause) return Program.Elements.Record_Representation_Clauses .Record_Representation_Clause_Text_Access is begin return Self'Unchecked_Access; end To_Record_Representation_Clause_Text; overriding function To_Record_Representation_Clause_Text (Self : aliased in out Implicit_Record_Representation_Clause) return Program.Elements.Record_Representation_Clauses .Record_Representation_Clause_Text_Access is pragma Unreferenced (Self); begin return null; end To_Record_Representation_Clause_Text; end Program.Nodes.Record_Representation_Clauses;
programs/oeis/021/A021032.asm
neoneye/loda
22
171516
<gh_stars>10-100 ; A021032: Decimal expansion of 1/28. ; 0,3,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5,7,1,4,2,8,5 add $0,2 mov $1,10 pow $1,$0 mul $1,4 div $1,1120 mod $1,10 mov $0,$1
programs/oeis/312/A312895.asm
karttu/loda
1
91242
; A312895: Coordination sequence Gal.4.58.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; 1,4,9,13,17,21,26,30,34,39,43,47,51,56,60,64,69,73,77,81,86,90,94,99,103,107,111,116,120,124,129,133,137,141,146,150,154,159,163,167,171,176,180,184,189,193,197,201,206,210 mul $0,30 sub $0,4 div $0,7 mov $1,$0 add $1,1
Task/Bitmap-Bresenhams-line-algorithm/Ada/bitmap-bresenhams-line-algorithm-1.ada
LaudateCorpus1/RosettaCodeData
1
9634
procedure Line (Picture : in out Image; Start, Stop : Point; Color : Pixel) is DX : constant Float := abs Float (Stop.X - Start.X); DY : constant Float := abs Float (Stop.Y - Start.Y); Err : Float; X : Positive := Start.X; Y : Positive := Start.Y; Step_X : Integer := 1; Step_Y : Integer := 1; begin if Start.X > Stop.X then Step_X := -1; end if; if Start.Y > Stop.Y then Step_Y := -1; end if; if DX > DY then Err := DX / 2.0; while X /= Stop.X loop Picture (X, Y) := Color; Err := Err - DY; if Err < 0.0 then Y := Y + Step_Y; Err := Err + DX; end if; X := X + Step_X; end loop; else Err := DY / 2.0; while Y /= Stop.Y loop Picture (X, Y) := Color; Err := Err - DX; if Err < 0.0 then X := X + Step_X; Err := Err + DY; end if; Y := Y + Step_Y; end loop; end if; Picture (X, Y) := Color; -- Ensure dots to be drawn end Line;
test/Succeed/Issue2880.agda
cruhland/agda
1,989
11652
<reponame>cruhland/agda module Issue2880 where app : {A : Set} → (A → A) → (A → A) app f x = f x {-# COMPILE GHC app = \ A f x -> f (app A f x) #-} mutual id : {A : Set} → A → A id x = x {-# COMPILE GHC id = id' #-} id' : {A : Set} → A → A id' x = x {-# COMPILE GHC id' = id #-}
programs/oeis/040/A040200.asm
jmorken/loda
1
178565
<reponame>jmorken/loda<gh_stars>1-10 ; A040200: Continued fraction for sqrt(215). ; 14,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1,28,1,1,1 mov $1,5 mov $3,24 lpb $0 gcd $0,4 mov $3,9 sub $4,$0 div $0,3 mov $1,3 mul $4,$2 add $2,3 mul $3,$4 mov $4,3 lpe add $1,$3 sub $1,3 div $1,2 add $1,1
libsrc/_DEVELOPMENT/math/float/math48/z80/am48_double32.asm
meesokim/z88dk
0
16377
SECTION code_fp_math48 PUBLIC am48_double32 EXTERN am48_double32u, l_neg_dehl am48_double32: ; 32-bit signed long to double ; ; enter : DEHL = 32-bit integer n ; ; exit : AC = AC' (AC' saved) ; AC'= (double)(n) ; ; uses : af, bc, de, hl, af', bc', de', hl' ld a,d or a jp p, am48_double32u ; if n >= 0 call l_neg_dehl ; n = |n| call am48_double32u exx set 7,b exx ret
Univalence/SEquivSCPermEquiv.agda
JacquesCarette/pi-dual
14
8100
{-# OPTIONS --without-K #-} module SEquivSCPermEquiv where open import Level using (Level; _⊔_) open import Data.Fin using (Fin) open import Data.Product using (_,_; proj₁; proj₂) open import Data.Vec using (tabulate) open import Function using (_∘_; id) open import Data.Vec.Properties using (lookup∘tabulate) open import Relation.Binary using (Setoid) open import Function.Equality using (_⟨$⟩_; _⟶_) renaming (_∘_ to _⊚_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; module ≡-Reasoning) -- open import Proofs using (_!!_; finext) open import Equiv using (_≃_; qinv; module isqinv) open import EquivEquiv using (_S≃_; eq; _≋_; id≋) open import ConcretePermutation using (CPerm; cp; _∘̂_; 1C; cauchyext; SCPerm) open import ConcretePermutationProperties using (p≡) -- infix 4 _≃S_ ------------------------------------------------------------------------------ -- The big (semantic) theorem! -- On one side we have the setoid of permutations under ≡ -- On the other we have the setoid of equivalences under ≋ -- -- The regular equivalence ≃ relates sets. To relate the above two -- setoids, this regular equivalence is generalized to an equivalence -- ≃S that relates setoids each with its own equivalence relation. record _≃S_ {ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level} (A : Setoid ℓ₁ ℓ₂) (B : Setoid ℓ₃ ℓ₄) : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) where constructor equiv field f : A ⟶ B g : B ⟶ A α : ∀ {x y} → Setoid._≈_ B x y → Setoid._≈_ B ((f ⊚ g) ⟨$⟩ x) y β : ∀ {x y} → Setoid._≈_ A x y → Setoid._≈_ A ((g ⊚ f) ⟨$⟩ x) y -- Big theorem univalence : ∀ {m n} → (SCPerm m n) ≃S (Fin m S≃ Fin n) univalence {m} {n} = equiv fwd bwd α β where fwd' : (CPerm m n) → (Fin m ≃ Fin n) fwd' (cp π πᵒ αp βp) = (λ m → πᵒ !! m) , let index = (λ n → π !! n) in qinv index pf₁ pf₂ where open ≡-Reasoning pf₁ : ∀ m → πᵒ !! (π !! m) ≡ m pf₁ m = begin ( πᵒ !! (π !! m) ≡⟨ sym (lookup∘tabulate (λ x → πᵒ !! (π !! x)) m) ⟩ (π ∘̂ πᵒ) !! m ≡⟨ cong (λ x → x !! m) αp ⟩ 1C !! m ≡⟨ lookup∘tabulate id m ⟩ m ∎) pf₂ : ∀ m → π !! (πᵒ !! m) ≡ m pf₂ m = begin ( π !! (πᵒ !! m) ≡⟨ sym (lookup∘tabulate (λ x → π !! (πᵒ !! x)) m) ⟩ (πᵒ ∘̂ π) !! m ≡⟨ cong (λ x → x !! m) βp ⟩ 1C !! m ≡⟨ lookup∘tabulate id m ⟩ m ∎) bwd' : (Fin m ≃ Fin n) → (CPerm m n) bwd' (f , qinv g α β) = cp (tabulate g) (tabulate f) g∘̂f≡1C f∘̂g≡1C where open ≡-Reasoning g∘̂f≡1C : tabulate g ∘̂ tabulate f ≡ 1C g∘̂f≡1C = finext (λ i → begin ( tabulate f !! (tabulate g !! i) ≡⟨ lookup∘tabulate f (tabulate g !! i) ⟩ f (tabulate g !! i) ≡⟨ cong f (lookup∘tabulate g i) ⟩ f (g i) ≡⟨ α i ⟩ i ∎)) f∘̂g≡1C : tabulate f ∘̂ tabulate g ≡ 1C f∘̂g≡1C = finext (λ i → begin ( tabulate g !! (tabulate f !! i) ≡⟨ lookup∘tabulate g (tabulate f !! i) ⟩ g (tabulate f !! i) ≡⟨ cong g (lookup∘tabulate f i) ⟩ g (f i) ≡⟨ β i ⟩ i ∎)) fwd : (SCPerm m n) ⟶ (Fin m S≃ Fin n) fwd = record { _⟨$⟩_ = fwd' ; cong = λ { {π} {.π} refl → id≋ } } bwd : (Fin m S≃ Fin n) ⟶ (SCPerm m n) bwd = record { _⟨$⟩_ = bwd' ; cong = λ eq₁≋eq₂ → p≡ (finext (_≋_.g≡ eq₁≋eq₂)) } α : {eq₁ eq₂ : Fin m ≃ Fin n} → eq₁ ≋ eq₂ → (fwd ⊚ bwd ⟨$⟩ eq₁) ≋ eq₂ α {eq₁} {eq₂} eq₁≋eq₂ = eq (λ x → trans (lookup∘tabulate (proj₁ eq₁) x) (_≋_.f≡ eq₁≋eq₂ x)) (λ x → trans (lookup∘tabulate (isqinv.g (proj₂ eq₁)) x) (_≋_.g≡ eq₁≋eq₂ x)) β : {π₁ π₂ : CPerm m n} → π₁ ≡ π₂ → (bwd ⊚ fwd ⟨$⟩ π₁) ≡ π₂ β {π} {.π} refl = p≡ (cauchyext (CPerm.π π))
programs/oeis/313/A313538.asm
neoneye/loda
22
7754
<reponame>neoneye/loda<gh_stars>10-100 ; A313538: Coordination sequence Gal.5.110.4 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; 1,5,10,14,19,23,28,32,37,42,47,52,56,61,65,70,74,79,84,89,94,98,103,107,112,116,121,126,131,136,140,145,149,154,158,163,168,173,178,182,187,191,196,200,205,210,215,220,224,229 mov $2,$0 lpb $0 add $1,$0 add $0,$1 lpb $1 sub $0,1 div $1,3 mod $1,3 mov $4,$3 add $3,1 lpe sub $0,1 div $0,2 add $5,1 lpe add $4,$5 mov $1,$4 add $1,1 mov $6,$2 mul $6,3 add $1,$6 mov $0,$1
src/minirest.adb
mosteo/minirest
2
26695
with AAA.Processes; with Ada.Strings.Unbounded; with Ada.Integer_Text_IO; with GNAT.OS_Lib; package body Minirest is package OS renames GNAT.OS_Lib; ------------------ -- Code_To_Kind -- ------------------ function Code_To_Kind (Code : Integer) return Status_Kinds is (case Code is when 100 .. 199 => Informative, when 200 .. 299 => Success, when 300 .. 399 => Redirect, when 400 .. 499 => Client_Error, when 500 .. 599 => Server_Error, when others => raise Constraint_Error); -------------- -- Encoding -- -------------- function To_Hex (Char : Character) return String is Hex : String (1 .. 6); begin Ada.Integer_Text_IO.Put (Hex, Character'Pos (Char), Base => 16); return Hex (4 .. 5); end To_Hex; function Encoding (Char : Character) return String is (case Char is when '!' | '#' | '$' | '%' | '&' | ''' | '(' | ')' | '*' | '+' | ',' | '/' | ':' | ';' | '=' | '?' | '@' | '[' | ']' | ' ' => "%" & To_Hex (Char), when others => (1 => Char)); ------------ -- Encode -- ------------ function Encode (S : String) return String is use Ada.Strings.Unbounded; Result : Unbounded_String; begin for Char of S loop Append (Result, Encoding (Char)); end loop; return To_String (Result); end Encode; ----------- -- "and" -- ----------- function "and" (L : Parameters; R : Parameters) return Parameters is begin return Result : Parameters := L do for I in R.Data.Iterate loop Result.Data.Insert (AAA.Strings.Maps.Key (I), R.Data (I)); end loop; end return; end "and"; --------- -- "=" -- --------- function "=" (Key, Value : String) return Parameters is begin return P : Parameters do P.Data.Insert (Key, Value); end return; end "="; --------- -- Get -- --------- Curl : constant OS.String_Access := OS.Locate_Exec_On_Path ("curl"); function Get (URL : String; Arguments : Parameters := No_Arguments; Headers : Parameters := No_Arguments) return Response is function To_URL_Args (Map : AAA.Strings.Map) return String is use AAA.Strings.Maps; Flat : AAA.Strings.Vector; begin for I in Map.Iterate loop Flat.Append (Encode (Key (I)) & "=" & Encode (Map (I))); end loop; return Flat.Flatten ('&'); end To_URL_Args; Curl_Args : AAA.Strings.Vector := AAA.Strings .To_Vector ("curl") .Append ("-s") .Append ("-i"); begin if Curl in null then raise Rest_Error with "Could not find 'curl' tool in path"; end if; -- Add request headers for I in Headers.Data.Iterate loop Curl_Args.Append ("-H"); Curl_Args.Append (AAA.Strings.Maps.Key (I) & ": " & Headers.Data (I)); end loop; declare Raw : constant AAA.Processes.Result := AAA.Processes.Run (Curl_Args .Append (URL & (if Arguments.Data.Is_Empty then "" elsif (for some C of URL => C = '?') then "&" else "?") & To_URL_Args (Arguments.Data)), Raise_On_Error => False); begin if Raw.Exit_Code /= 0 then raise Rest_Error with "curl exited with non-zero error code:" & Raw.Exit_Code'Image; end if; declare Status_Line : constant String := Raw.Output.First_Element; Code : Integer := -1; In_Headers : Boolean := True; Skip : Boolean := False; begin -- Identify code for I in Status_Line'Range loop if Status_Line (I) = ' ' then Code := Integer'Value (Status_Line (I + 1 .. I + 4)); exit; end if; end loop; if Code = -1 then raise Rest_Error with "Malformed status line: " & Status_Line; end if; -- Fill response return R : Response (Code_To_Kind (Code), Status_Line'Length) do R.Status_Line := Status_Line; R.Status_Code := Code; for I in Raw.Output.First_Index + 1 .. Raw.Output.Last_Index loop declare Line : constant String := Raw.Output (I); begin if In_Headers and then Line = "" then In_Headers := False; Skip := True; end if; if In_Headers then R.Raw_Headers.Append (Line); R.Headers.Insert (AAA.Strings.Head (Line, ':'), AAA.Strings.Trim (AAA.Strings.Tail (Line, ':'))); elsif Skip then Skip := False; else R.Content.Append (Line); end if; end; end loop; end return; end; end; end Get; end Minirest;
programs/oeis/050/A050493.asm
jmorken/loda
1
5776
; A050493: a(n) = sum of binary digits of n-th triangular number. ; 0,1,2,2,2,4,3,3,2,4,5,2,4,5,4,4,2,4,5,6,4,6,7,3,4,4,7,6,5,6,5,5,2,4,5,6,5,8,6,4,5,7,6,6,8,4,5,4,4,5,8,6,5,7,7,3,6,7,8,7,6,7,6,6,2,4,5,6,5,8,7,8,4,6,8,5,8,9,4,5,5,8,7,8,8,7,8,8,7,8,12,5,6,5,6,5,4,5,8,7,8,7,5,7,6,9,7,6,10,9,9,4,6,6,8,6,5,10,9,8,7,8,9,8,7,8,7,7,2,4,5,6,5,8,7,8,5,8,9,4,7,8,8,5,5,7,9,9,6,9,8,7,8,6,10,9,10,7,5,6,5,8,8,7,8,11,7,8,9,7,8,8,8,9,10,6,8,8,10,11,9,6,5,5,7,7,10,6,7,6,7,6,4,5,8,7,8,8,9,9,6,9,6,6,8,9,7,5,7,9,8,10,6,7,10,8,8,8,11,8,11,11,6,5,6,7,7,7,10,11,9,7,7,10,10,7,10,9,9,4,8,9,10,10,7,11,10,9,8,9 mov $2,$0 pow $2,2 add $2,$0 mov $0,$2 lpb $2 div $2,2 sub $0,$2 lpe mov $1,$0
oeis/074/A074867.asm
neoneye/loda-programs
11
1020
; A074867: a(n) = M(a(n-1)) + M(a(n-2)) where a(1)=a(2)=1 and M(k) is the product of the digits of k in base 10. ; Submitted by <NAME> ; 1,1,2,3,5,8,13,11,4,5,9,14,13,7,10,7,7,14,11,5,6,11,7,8,15,13,8,11,9,10,9,9,18,17,15,12,7,9,16,15,11,6,7,13,10,3,3,6,9,15,14,9,13,12,5,7,12,9,11,10,1,1,2,3,5,8,13,11,4,5,9,14,13,7,10,7,7,14,11,5,6,11,7,8,15,13,8,11,9,10,9,9,18,17,15,12,7,9,16,15 mov $3,1 lpb $0 sub $0,1 mod $3,10 mov $2,$3 add $3,$1 mov $1,$2 lpe mov $0,$3
alloy4fun_models/trashltl/models/9/bFjffW9XTBkrfxBQq.als
Kaixi26/org.alloytools.alloy
0
4998
open main pred idbFjffW9XTBkrfxBQq_prop10 { always Protected in Protected' } pred __repair { idbFjffW9XTBkrfxBQq_prop10 } check __repair { idbFjffW9XTBkrfxBQq_prop10 <=> prop10o }
src/converter/cvt_string2int/src/cvt_string2int.asm
nikAizuddin/lib80386
4
24836
; 1 2 3 4 5 6 7 ;234567890123456789012345678901234567890123456789012345678901234567890 ;===================================================================== ; ; FUNCTION: cvt_string2int ; FUNCTION PURPOSE: <See doc/description file> ; ; AUTHOR: <NAME> <NAME> ; EMAIL: <EMAIL> ; DATE CREATED: 20/JAN/2015 ; ; CONTRIBUTORS: --- ; ; LANGUAGE: x86 Assembly Language ; SYNTAX: Intel ; ASSEMBLER: NASM ; ARCHITECTURE: i386 ; KERNEL: Linux 32-bit ; FORMAT: elf32 ; ; EXTERNAL FILES: pow_int.asm ; cvt_string2dec.asm ; cvt_dec2hex.asm ; ; VERSION: 0.1.20 ; STATUS: Alpha ; BUGS: --- <See doc/bugs/index file> ; ; REVISION HISTORY: <See doc/revision_history/index file> ; ; MIT Licensed. See /LICENSE file. ; ;===================================================================== extern pow_int extern cvt_string2dec extern cvt_dec2hex global cvt_string2int section .text cvt_string2int: ;parameter 1 = addr_instring:32bit ;parameter 2 = instrlen:32bit ;returns = the integer value .setup_stackframe: sub esp, 4 ;reserve 4 bytes to store ebp mov [esp], ebp ;store ebp to stack mov ebp, esp ;store current stack ptr to ebp .get_arguments: add ebp, 8 ;+8 offset to ebp, to get arguments mov eax, [ebp ] ;get addr_instring mov ebx, [ebp + 4] ;get instrlen .setup_localvariables: sub esp, 28 ;reserve 28 bytes mov [esp ], eax ;addr_instring mov [esp + 4], ebx ;instrlen mov dword [esp + 8], 0 ;decimal_num[0] mov dword [esp + 12], 0 ;decimal_num[1] mov dword [esp + 16], 0 ;decimal_digits mov dword [esp + 20], 0 ;hexadecimal_num[0] mov dword [esp + 24], 0 ;hexadecimal_num[1] ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; 001: cvt_string2dec( addr_instring, ; instrlen, ; @decimal_num, ; @decimal_digits ); ; ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sub esp, 16 ;reserve 16 bytes mov eax, [esp + 16 ] ;get addr_instring mov ebx, [esp + (16 + 4)] ;get instrlen lea ecx, [esp + (16 + 8)] ;get @decimal_num lea edx, [esp + (16 + 16)] ;get @decimal_digits mov [esp ], eax ;parameter 1 mov [esp + 4], ebx ;parameter 2 mov [esp + 8], ecx ;parameter 3 mov [esp + 12], edx ;parameter 4 call cvt_string2dec add esp, 16 ;restore 16 bytes .b1: ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; 002: hexadecimal_num[0] = cvt_dec2hex( decimal_num[0] ); ; ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sub esp, 4 ;reserve 4 bytes mov eax, [esp + (4 + 8)] ;get decimal_num[0] mov [esp ], eax ;parameter 1 call cvt_dec2hex add esp, 4 ;restore 4 bytes mov [esp + 20], eax ;hexadecimal_num[0] = eax ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; 003: if decimal_digits <= 8, then goto .digits_le_8; ; ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - mov eax, [esp + 16] ;eax = decimal_digits cmp eax, 8 jbe .digits_le_8 .digits_gt_8: ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; 004: hexadecimal_num[1] = cvt_dec2hex( decimal_num[1] ); ; ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sub esp, 4 ;reserve 4 bytes mov eax, [esp + (4 + 12)] ;get decimal_num[1] mov [esp ], eax ;parameter 1 call cvt_dec2hex add esp, 4 ;restore 4 bytes mov [esp + 24], eax ;hexadecimal_num[1] = eax ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; 005: hexadecimal_num[0] = (hexadecimal_num[1] * ; pow_int(10, 8) ) + ; hexadecimal_num[0]; ; ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sub esp, 8 ;reserve 8 bytes mov eax, 10 ;parameter1 = 10 mov ebx, 8 mov [esp ], eax ;parameter 1 mov [esp + 4], ebx ;parameter 2 call pow_int add esp, 8 ;restore 8 bytes ;NOTE: eax = result pow_int() mov ebx, [esp + 24] ;ebx = hexadecimal_num[1] xor edx, edx mul ebx ;eax *= ebx mov ebx, [esp + 20] ;ebx = hexadecimal_num[0] add eax, ebx ;eax += ebx mov [esp + 20], eax ;hexadecimal_num[0] = eax .digits_le_8: ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; 006: EAX = hexadecimal_num[0]; ; ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - mov eax, [esp + 20] ;eax = hexadecimal_num[0] .return: .clean_stackframe: sub ebp, 8 ;-8 offset to ebp mov esp, ebp ;restore stack ptr to initial value mov ebp, [esp] ;restore ebp to its initial value add esp, 4 ;restore 4 bytes ret
3-mid/impact/source/3d/collision/narrowphase/impact-d3-collision-convex_raycast-continuous_convex.adb
charlie5/lace
20
22374
with impact.d3.Transform; with impact.d3.Vector; with impact.d3.Transform_Util; with impact.d3.Scalar; with impact.d3.collision.Detector.discrete.gjk_pair; with impact.d3.collision.Detector.discrete; -- #include "impact.d3.collision.convex_Raycast.continuous_convex.h" -- #include "BulletCollision/CollisionShapes/impact.d3.Shape.convex.h" -- #include "BulletCollision/NarrowPhaseCollision/impact.d3.collision.simplex_Solver.h" -- #include "LinearMath/impact.d3.TransformUtil.h" -- #include "BulletCollision/CollisionShapes/impact.d3.Shape.convex.internal.sphere.h" -- -- #include "impact.d3.collision.Detector.discrete.gjk_pair.h" -- #include "impact.d3.collision.point_Collector.h" -- #include "BulletCollision/CollisionShapes/impact.d3.Shape.concave.static_plane.h" package body impact.d3.collision.convex_Raycast.continuous_convex is --- Forge -- function to_convex_Raycast (shapeA, shapeB : access impact.d3.Shape.convex.Item'Class; simplexSolver : access impact.d3.collision.simplex_Solver.item'Class; penetrationDepthSolver : access impact.d3.collision.convex_penetration_depth_Solver.item'Class) return Item is Self : Item; begin Self.m_simplexSolver := simplexSolver; Self.m_penetrationDepthSolver := penetrationDepthSolver; Self.m_convexA := shapeA; Self.m_convexB1 := shapeB; return Self; end to_convex_Raycast; -- impact.d3.collision.convex_Raycast.continuous_convex::impact.d3.collision.convex_Raycast.continuous_convex ( const impact.d3.Shape.convex* convexA,const impact.d3.Shape.convex* convexB,impact.d3.collision.simplex_Solver* simplexSolver, impact.d3.collision.convex_penetration_depth_Solver* penetrationDepthSolver) -- :m_simplexSolver(simplexSolver), -- m_penetrationDepthSolver(penetrationDepthSolver), -- m_convexA(convexA),m_convexB1(convexB),m_planeShape(0) -- { -- } -- -- impact.d3.collision.convex_Raycast.continuous_convex::impact.d3.collision.convex_Raycast.continuous_convex( const impact.d3.Shape.convex* convexA,const impact.d3.Shape.concave.static_plane* plane) -- :m_simplexSolver(0), -- m_penetrationDepthSolver(0), -- m_convexA(convexA),m_convexB1(0),m_planeShape(plane) -- { -- } function to_convex_Raycast (shapeA : access impact.d3.Shape.convex.Item'Class; plane : access impact.d3.Shape.concave.static_plane.item'Class) return Item is Self : Item; begin Self.m_convexA := shapeA; Self.m_planeShape := plane; return Self; end to_convex_Raycast; --- Attributes -- -- This maximum should not be necessary. It allows for untested/degenerate cases in production code. -- You don't want your game ever to lock-up. -- MAX_ITERATIONS : constant := 64; overriding function calcTimeOfImpact (Self : access Item; fromA, toA : in Transform_3d; fromB, toB : in Transform_3d; result : access impact.d3.collision.convex_Raycast.CastResult'Class) return Boolean is linVelA, angVelA, linVelB, angVelB : math.Vector_3; begin -- compute linear and angular velocity for this interval, to interpolate -- impact.d3.transform_Util.calculateVelocity (fromA, toA, 1.0, linVelA, angVelA); impact.d3.transform_Util.calculateVelocity (fromB, toB, 1.0, linVelB, angVelB); declare use impact.d3.Vector, math.Vectors; boundingRadiusA : math.Real := Self.m_convexA.getAngularMotionDisc; boundingRadiusB : constant math.Real := (if Self.m_convexB1 /= null then Self.m_convexB1.getAngularMotionDisc else 0.0); maxAngularProjectedVelocity : math.Real := length (angVelA) * boundingRadiusA + length (angVelB) * boundingRadiusB; relLinVel : constant math.Vector_3 := linVelB - linVelA; relLinVelocLength : constant math.Real := length (linVelB - linVelA); begin if relLinVelocLength + maxAngularProjectedVelocity = 0.0 then return False; end if; declare lambda : math.Real := 0.0; v : math.Vector_3 := (1.0, 0.0, 0.0); maxIter : constant Integer := MAX_ITERATIONS; n : math.Vector_3 := (0.0, 0.0, 0.0); hasResult : Boolean := False; c : math.Vector_3; lastLambda : math.Real := lambda; -- impact.d3.Scalar epsilon = impact.d3.Scalar(0.001); numIter : Integer := 0; -- first solution, using GJK radius : math.Real := 0.001; pointCollector1 : impact.d3.collision.point_Collector.Item; begin Self.computeClosestPoints (fromA, fromB, pointCollector1); hasResult := pointCollector1.m_hasResult; c := pointCollector1.m_pointInWorld; if hasResult then n := pointCollector1.m_normalOnBInWorld; declare dist : math.Real := pointCollector1.m_distance + result.m_allowedPenetration; projectedLinearVelocity : math.Real := dot (relLinVel, n); dLambda : math.Real; begin if projectedLinearVelocity + maxAngularProjectedVelocity <= impact.d3.Scalar.SIMD_EPSILON then return False; end if; -- not close enough -- while dist > radius loop dLambda := 0.0; projectedLinearVelocity := dot (relLinVel, n); -- don't report time of impact for motion away from the contact normal (or causes minor penetration) -- if projectedLinearVelocity + maxAngularProjectedVelocity <= impact.d3.Scalar.SIMD_EPSILON then return False; end if; dLambda := dist / (projectedLinearVelocity + maxAngularProjectedVelocity); lambda := lambda + dLambda; if lambda > 1.0 then return False; end if; if lambda < 0.0 then return False; end if; -- todo: next check with relative epsilon if lambda <= lastLambda then return False; -- n.setValue(0,0,0); exit; end if; lastLambda := lambda; -- Interpolate to next lambda. -- declare use impact.d3.Transform; interpolatedTransA, interpolatedTransB, relativeTrans : Transform_3d; pragma Unreferenced (relativeTrans); pointCollector : impact.d3.collision.point_Collector.item; begin impact.d3.transform_Util.integrateTransform (fromA, linVelA, angVelA, lambda, interpolatedTransA); impact.d3.transform_Util.integrateTransform (fromB, linVelB, angVelB, lambda, interpolatedTransB); relativeTrans := inverseTimes (interpolatedTransB, interpolatedTransA); Self.computeClosestPoints (interpolatedTransA, interpolatedTransB, pointCollector); if pointCollector.m_hasResult then dist := pointCollector.m_distance + result.m_allowedPenetration; c := pointCollector.m_pointInWorld; n := pointCollector.m_normalOnBInWorld; else result.reportFailure (-1, numIter); return False; end if; numIter := numIter + 1; if numIter > maxIter then result.reportFailure (-2, numIter); return False; end if; end; end loop; result.m_fraction := lambda; result.m_normal := n; result.m_hitPoint := c; return True; end; end if; return False; end; end; end calcTimeOfImpact; procedure computeClosestPoints (Self : in out Item; transA, transB : in Transform_3d; pointCollector : in out impact.d3.collision.point_Collector.item) is begin if Self.m_convexB1 /= null then Self.m_simplexSolver.reset; declare use impact.d3.collision.Detector.discrete.gjk_pair; gjk : impact.d3.collision.Detector.discrete.gjk_pair.item := to_gjk_pair_Detector (Self.m_convexA, Self.m_convexB1, Self.m_convexA.getShapeType, Self.m_convexB1.getShapeType, Self.m_convexA.getMargin, Self.m_convexB1.getMargin, Self.m_simplexSolver, Self.m_penetrationDepthSolver); input : impact.d3.collision.Detector.discrete.ClosestPointInput; begin input.m_transformA := transA; input.m_transformB := transB; gjk.getClosestPoints (input, pointCollector, False); end; else -- convex versus plane declare use linear_Algebra_3d, impact.d3.Transform, impact.d3.Vector, math.Vectors; convexShape : constant access impact.d3.Shape.convex .Item'Class := Self.m_convexA; planeShape : constant access impact.d3.Shape.concave.static_plane.Item'Class := Self.m_planeShape; hasCollision : Boolean := False; planeNormal : math.Vector_3 renames planeShape.getPlaneNormal; planeConstant : math.Real := planeShape.getPlaneConstant; convexWorldTransform : constant Transform_3d := transA; convexInPlaneTrans : constant Transform_3d := inverse (transB) * convexWorldTransform; planeInConvex : constant Transform_3d := inverse (convexWorldTransform) * transB; vtx : constant math.Vector_3 := convexShape.localGetSupportingVertex (getBasis (planeInConvex) * (-planeNormal)); vtxInPlane : constant math.Vector_3 := convexInPlaneTrans * vtx; distance : constant math.Real := dot (planeNormal, vtxInPlane) - planeConstant; vtxInPlaneProjected : constant math.Vector_3 := vtxInPlane - distance*planeNormal; vtxInPlaneWorld : constant math.Vector_3 := transB * vtxInPlaneProjected; normalOnSurfaceB : constant math.Vector_3 := getBasis (transB) * planeNormal; begin pointCollector.addContactPoint (normalOnSurfaceB, vtxInPlaneWorld, distance); end; end if; end computeClosestPoints; end impact.d3.collision.convex_Raycast.continuous_convex; -- bool impact.d3.collision.convex_Raycast.continuous_convex::calcTimeOfImpact( -- const impact.d3.Transform& fromA, -- const impact.d3.Transform& toA, -- const impact.d3.Transform& fromB, -- const impact.d3.Transform& toB, -- CastResult& result) -- { -- -- -- /// compute linear and angular velocity for this interval, to interpolate -- impact.d3.Vector linVelA,angVelA,linVelB,angVelB; -- impact.d3.TransformUtil::calculateVelocity(fromA,toA,impact.d3.Scalar(1.),linVelA,angVelA); -- impact.d3.TransformUtil::calculateVelocity(fromB,toB,impact.d3.Scalar(1.),linVelB,angVelB); -- -- -- impact.d3.Scalar boundingRadiusA = m_convexA->getAngularMotionDisc(); -- impact.d3.Scalar boundingRadiusB = m_convexB1?m_convexB1->getAngularMotionDisc():0.f; -- -- impact.d3.Scalar maxAngularProjectedVelocity = angVelA.length() * boundingRadiusA + angVelB.length() * boundingRadiusB; -- impact.d3.Vector relLinVel = (linVelB-linVelA); -- -- impact.d3.Scalar relLinVelocLength = (linVelB-linVelA).length(); -- -- if ((relLinVelocLength+maxAngularProjectedVelocity) == 0.f) -- return false; -- -- -- -- impact.d3.Scalar lambda = impact.d3.Scalar(0.); -- impact.d3.Vector v(1,0,0); -- -- int maxIter = MAX_ITERATIONS; -- -- impact.d3.Vector n; -- n.setValue(impact.d3.Scalar(0.),impact.d3.Scalar(0.),impact.d3.Scalar(0.)); -- bool hasResult = false; -- impact.d3.Vector c; -- -- impact.d3.Scalar lastLambda = lambda; -- //impact.d3.Scalar epsilon = impact.d3.Scalar(0.001); -- -- int numIter = 0; -- //first solution, using GJK -- -- -- impact.d3.Scalar radius = 0.001f; -- // result.drawCoordSystem(sphereTr); -- -- impact.d3.collision.point_Collector pointCollector1; -- -- { -- -- computeClosestPoints(fromA,fromB,pointCollector1); -- -- hasResult = pointCollector1.m_hasResult; -- c = pointCollector1.m_pointInWorld; -- } -- -- if (hasResult) -- { -- impact.d3.Scalar dist; -- dist = pointCollector1.m_distance + result.m_allowedPenetration; -- n = pointCollector1.m_normalOnBInWorld; -- impact.d3.Scalar projectedLinearVelocity = relLinVel.dot(n); -- if ((projectedLinearVelocity+ maxAngularProjectedVelocity)<=SIMD_EPSILON) -- return false; -- -- //not close enough -- while (dist > radius) -- { -- if (result.m_debugDrawer) -- { -- result.m_debugDrawer->drawSphere(c,0.2f,impact.d3.Vector(1,1,1)); -- } -- impact.d3.Scalar dLambda = impact.d3.Scalar(0.); -- -- projectedLinearVelocity = relLinVel.dot(n); -- -- -- //don't report time of impact for motion away from the contact normal (or causes minor penetration) -- if ((projectedLinearVelocity+ maxAngularProjectedVelocity)<=SIMD_EPSILON) -- return false; -- -- dLambda = dist / (projectedLinearVelocity+ maxAngularProjectedVelocity); -- -- -- -- lambda = lambda + dLambda; -- -- if (lambda > impact.d3.Scalar(1.)) -- return false; -- -- if (lambda < impact.d3.Scalar(0.)) -- return false; -- -- -- //todo: next check with relative epsilon -- if (lambda <= lastLambda) -- { -- return false; -- //n.setValue(0,0,0); -- break; -- } -- lastLambda = lambda; -- -- -- -- //interpolate to next lambda -- impact.d3.Transform interpolatedTransA,interpolatedTransB,relativeTrans; -- -- impact.d3.TransformUtil::integrateTransform(fromA,linVelA,angVelA,lambda,interpolatedTransA); -- impact.d3.TransformUtil::integrateTransform(fromB,linVelB,angVelB,lambda,interpolatedTransB); -- relativeTrans = interpolatedTransB.inverseTimes(interpolatedTransA); -- -- if (result.m_debugDrawer) -- { -- result.m_debugDrawer->drawSphere(interpolatedTransA.getOrigin(),0.2f,impact.d3.Vector(1,0,0)); -- } -- -- result.DebugDraw( lambda ); -- -- impact.d3.collision.point_Collector pointCollector; -- computeClosestPoints(interpolatedTransA,interpolatedTransB,pointCollector); -- -- if (pointCollector.m_hasResult) -- { -- dist = pointCollector.m_distance+result.m_allowedPenetration; -- c = pointCollector.m_pointInWorld; -- n = pointCollector.m_normalOnBInWorld; -- } else -- { -- result.reportFailure(-1, numIter); -- return false; -- } -- -- numIter++; -- if (numIter > maxIter) -- { -- result.reportFailure(-2, numIter); -- return false; -- } -- } -- -- result.m_fraction = lambda; -- result.m_normal = n; -- result.m_hitPoint = c; -- return true; -- } -- -- return false; -- -- }
Structure/Operator/Vector/Subspace/Proofs.agda
Lolirofle/stuff-in-agda
6
3835
import Lvl open import Structure.Operator.Vector open import Structure.Setoid open import Type module Structure.Operator.Vector.Subspace.Proofs {ℓᵥ ℓₛ ℓᵥₑ ℓₛₑ} {V : Type{ℓᵥ}} ⦃ equiv-V : Equiv{ℓᵥₑ}(V) ⦄ {S : Type{ℓₛ}} ⦃ equiv-S : Equiv{ℓₛₑ}(S) ⦄ {_+ᵥ_ : V → V → V} {_⋅ₛᵥ_ : S → V → V} {_+ₛ_ _⋅ₛ_ : S → S → S} ⦃ vectorSpace : VectorSpace(_+ᵥ_)(_⋅ₛᵥ_)(_+ₛ_)(_⋅ₛ_) ⦄ where open VectorSpace(vectorSpace) open import Logic.Predicate open import Logic.Propositional open import Numeral.CoordinateVector as Vec using () renaming (Vector to Vec) open import Numeral.Finite open import Numeral.Natural open import Sets.ExtensionalPredicateSet as PredSet using (PredSet ; _∈_ ; _∪_ ; ⋂ᵢ ; _⊇_ ; _⊆_) open import Structure.Container.SetLike using (SetElement) private open module SetLikeFunctionProperties{ℓ} = Structure.Container.SetLike.FunctionProperties{C = PredSet{ℓ}(V)}{E = V}(_∈_) open import Structure.Function.Multi open import Structure.Operator open import Structure.Operator.Vector.LinearCombination ⦃ vectorSpace = vectorSpace ⦄ open import Structure.Operator.Vector.LinearCombination.Proofs open import Structure.Operator.Vector.Subspace ⦃ vectorSpace = vectorSpace ⦄ open import Structure.Relator.Properties open import Syntax.Function open import Syntax.Transitivity private variable ℓ ℓ₁ ℓ₂ : Lvl.Level private variable I : Type{ℓ} private variable n : ℕ private variable vf : Vec(n)(V) private variable sf : Vec(n)(S) -- TODO [⋂ᵢ]-subspace : ∀{Vsf : I → PredSet{ℓ}(V)} → (∀{i} → Subspace(Vsf(i))) → Subspace(⋂ᵢ Vsf) [∪]-subspace : ∀{Vₛ₁ Vₛ₂} → Subspace{ℓ₁}(Vₛ₁) → Subspace{ℓ₂}(Vₛ₂) → (((Vₛ₁ ⊇ Vₛ₂) ∨ (Vₛ₁ ⊆ Vₛ₂)) ↔ Subspace(Vₛ₁ ∪ Vₛ₂))
deBruijn/Substitution/Data.agda
nad/dependently-typed-syntax
5
13657
<filename>deBruijn/Substitution/Data.agda ------------------------------------------------------------------------ -- Parallel substitutions (defined using an inductive family) ------------------------------------------------------------------------ open import Data.Universe.Indexed module deBruijn.Substitution.Data {i u e} {Uni : IndexedUniverse i u e} where import deBruijn.Context; open deBruijn.Context Uni open import Function as F using (_$_) open import Level using (_⊔_) import Relation.Binary.PropositionalEquality as P open P.≡-Reasoning -- This module reexports some other modules. open import deBruijn.Substitution.Data.Application public open import deBruijn.Substitution.Data.Basics public open import deBruijn.Substitution.Data.Map public open import deBruijn.Substitution.Data.Simple public ------------------------------------------------------------------------ -- Instantiations and code for facilitating instantiations -- Renamings (variable substitutions). module Renaming where -- Variables support all of the operations above. simple : Simple Var simple = record { weaken = weaken∋ ; var = [id] ; weaken-var = λ _ → P.refl } application : Application Var Var application = record { app = app∋ } application₁ : Application₁ Var application₁ = record { simple = simple ; application₂₂ = record { application₂₁ = record { application = application ; trans-weaken = λ _ → P.refl ; trans-var = λ _ → P.refl ; var-/⊢ = λ _ _ → P.refl } ; var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ = λ _ _ hyp → hyp ; /⊢-wk = Simple./∋-wk simple } } open Application₁ application₁ public hiding (simple; application) ≅-∋-⇒-≅-⊢ : ∀ {Γ₁ σ₁} {x₁ : Γ₁ ∋ σ₁} {Γ₂ σ₂} {x₂ : Γ₂ ∋ σ₂} → x₁ ≅-∋ x₂ → Term-like._≅-⊢_ Var x₁ x₂ ≅-∋-⇒-≅-⊢ P.refl = P.refl ≅-⊢-⇒-≅-∋ : ∀ {Γ₁ σ₁} {x₁ : Γ₁ ∋ σ₁} {Γ₂ σ₂} {x₂ : Γ₂ ∋ σ₂} → Term-like._≅-⊢_ Var x₁ x₂ → x₁ ≅-∋ x₂ ≅-⊢-⇒-≅-∋ P.refl = P.refl -- A translation of T₁'s to T₂'s, plus a bit more. record _↦_ {t₁} (T₁ : Term-like t₁) {t₂} (T₂ : Term-like t₂) : Set (i ⊔ u ⊔ e ⊔ t₁ ⊔ t₂) where field -- Translates T₁'s to T₂'s. trans : [ T₁ ⟶⁼ T₂ ] -- Simple substitutions for T₁'s. simple : Simple T₁ open Simple simple public open Term-like T₁ renaming (⟦_⟧ to ⟦_⟧₁) open Term-like T₂ renaming (⟦_⟧ to ⟦_⟧₂) /̂∋-⟦⟧⇨ : ∀ {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (x : Γ ∋ σ) (ρ : Sub T₁ ρ̂) → x /̂∋ ⟦ ρ ⟧⇨ ≅-Value ⟦ trans · (x /∋ ρ) ⟧₂ /̂∋-⟦⟧⇨ x ρ = begin [ x /̂∋ ⟦ ρ ⟧⇨ ] ≡⟨ corresponds (app∋ ρ) x ⟩ [ ⟦ x /∋ ρ ⟧₁ ] ≡⟨ corresponds trans (x /∋ ρ) ⟩ [ ⟦ trans · (x /∋ ρ) ⟧₂ ] ∎ -- "Term" substitutions. -- For simplicity I have chosen to use the universe level (i ⊔ u ⊔ e) -- here; this is the level of Var. The code could perhaps be made more -- general. record Substitution₁ (T : Term-like (i ⊔ u ⊔ e)) : Set (Level.suc (i ⊔ u ⊔ e)) where open Term-like T field -- Takes variables to terms. var : [ Var ⟶⁼ T ] -- Applies substitutions, which contain things which can be -- translated to terms, to terms. app′ : {T′ : Term-like (i ⊔ u ⊔ e)} → T′ ↦ T → ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Sub T′ ρ̂ → [ T ⟶ T ] ρ̂ -- A property relating app′ and var. app′-var : ∀ {T′ : Term-like (i ⊔ u ⊔ e)} {Γ Δ σ} {ρ̂ : Γ ⇨̂ Δ} (T′↦T : T′ ↦ T) (x : Γ ∋ σ) (ρ : Sub T′ ρ̂) → app′ T′↦T ρ · (var · x) ≅-⊢ _↦_.trans T′↦T · (x /∋ ρ) -- Variables can be translated into terms. private Var-↦′ : Var ↦ T Var-↦′ = record { trans = var ; simple = Renaming.simple } -- Renamings can be applied to terms. app-renaming : ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} → Sub Var ρ̂ → [ T ⟶ T ] ρ̂ app-renaming = app′ Var-↦′ -- This gives us a way to define the weakening operation. simple : Simple T simple = record { weaken = app-renaming Renaming.wk ; var = var ; weaken-var = weaken-var } where abstract weaken-var : ∀ {Γ σ τ} (x : Γ ∋ τ) → app-renaming (Renaming.wk[_] σ) · (var · x) ≅-⊢ var · suc[ σ ] x weaken-var x = begin [ app-renaming Renaming.wk · (var · x) ] ≡⟨ app′-var Var-↦′ x Renaming.wk ⟩ [ var · (x /∋ Renaming.wk) ] ≡⟨ ·-cong (var ∎-⟶) (Renaming./∋-wk x) ⟩ [ var · suc x ] ∎ -- A translation of T′'s to T's, plus a bit more. record Translation-from (T′ : Term-like (i ⊔ u ⊔ e)) : Set (i ⊔ u ⊔ e) where field translation : T′ ↦ T open _↦_ translation using (trans) renaming (simple to simple′; var to var′; weaken[_] to weaken′[_]) field trans-weaken : ∀ {Γ σ τ} (t : Term-like._⊢_ T′ Γ τ) → trans · (weaken′[ σ ] · t) ≅-⊢ Simple.weaken[_] simple σ · (trans · t) trans-var : ∀ {Γ σ} (x : Γ ∋ σ) → trans · (var′ · x) ≅-⊢ var · x -- An Application₂₁ record. application₂₁ : Application₂₁ simple′ simple trans application₂₁ = record { application = record { app = app′ translation } ; trans-weaken = trans-weaken ; trans-var = trans-var ; var-/⊢ = app′-var translation } open _↦_ translation public open Application₂₁ application₂₁ public hiding (trans-weaken; trans-var) -- Variables can be translated into terms. Var-↦ : Translation-from Var Var-↦ = record { translation = Var-↦′ ; trans-weaken = trans-weaken ; trans-var = λ _ → P.refl } where abstract trans-weaken : ∀ {Γ σ τ} (x : Γ ∋ τ) → var · suc[ σ ] x ≅-⊢ Simple.weaken[_] simple σ · (var · x) trans-weaken x = P.sym $ Simple.weaken-var simple x -- Terms can be translated into terms. no-translation : Translation-from T no-translation = record { translation = record { trans = [id]; simple = simple } ; trans-weaken = λ _ → P.refl ; trans-var = λ _ → P.refl } record Substitution₂ (T : Term-like (i ⊔ u ⊔ e)) : Set (Level.suc (i ⊔ u ⊔ e)) where open Term-like T field substitution₁ : Substitution₁ T open Substitution₁ substitution₁ field -- Lifts equalities valid for all variables and liftings to -- arbitrary terms. var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆′ : {T₁ T₂ : Term-like (i ⊔ u ⊔ e)} (T₁↦T : Translation-from T₁) (T₂↦T : Translation-from T₂) → let open Translation-from T₁↦T using () renaming (_↑⁺⋆_ to _↑⁺⋆₁_; _/⊢⋆_ to _/⊢⋆₁_) open Translation-from T₂↦T using () renaming (_↑⁺⋆_ to _↑⁺⋆₂_; _/⊢⋆_ to _/⊢⋆₂_) in ∀ {Γ Δ} {ρ̂ : Γ ⇨̂ Δ} (ρs₁ : Subs T₁ ρ̂) (ρs₂ : Subs T₂ ρ̂) → (∀ Γ⁺ {σ} (x : Γ ++⁺ Γ⁺ ∋ σ) → var · x /⊢⋆₁ ρs₁ ↑⁺⋆₁ Γ⁺ ≅-⊢ var · x /⊢⋆₂ ρs₂ ↑⁺⋆₂ Γ⁺) → ∀ Γ⁺ {σ} (t : Γ ++⁺ Γ⁺ ⊢ σ) → t /⊢⋆₁ ρs₁ ↑⁺⋆₁ Γ⁺ ≅-⊢ t /⊢⋆₂ ρs₂ ↑⁺⋆₂ Γ⁺ -- Given a well-behaved translation from something with simple -- substitutions one can define an Application₂₂ record. application₂₂ : {T′ : Term-like (i ⊔ u ⊔ e)} (T′↦T : Translation-from T′) → let open Translation-from T′↦T using (trans) renaming (simple to simple′) in Application₂₂ simple′ simple trans application₂₂ T′↦T = record { application₂₁ = Translation-from.application₂₁ T′↦T ; var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆ = var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆′ T′↦T T′↦T ; /⊢-wk = /⊢-wk } where open Translation-from T′↦T using () renaming ( _↑⁺_ to _↑⁺′_; _↑⁺⋆_ to _↑⁺⋆′_ ; wk to wk′; wk[_] to wk′[_] ; _/⊢_ to _/⊢′_; _/⊢⋆_ to _/⊢⋆′_ ) open Translation-from Var-↦ using () renaming ( _↑⁺_ to _↑⁺-renaming_; _↑⁺⋆_ to _↑⁺⋆-renaming_ ; _/⊢_ to _/⊢-renaming_; _/⊢⋆_ to _/⊢⋆-renaming_ ) abstract /⊢-wk : ∀ {Γ σ τ} (t : Γ ⊢ τ) → t /⊢′ wk′[ σ ] ≅-⊢ t /⊢-renaming Renaming.wk[_] σ /⊢-wk = var-/⊢⋆-↑⁺⋆-⇒-/⊢⋆-↑⁺⋆′ T′↦T Var-↦ (ε ▻ wk′) (ε ▻ Renaming.wk) (λ Γ⁺ x → begin [ var · x /⊢⋆′ (ε ▻ wk′) ↑⁺⋆′ Γ⁺ ] ≡⟨ Translation-from./⊢⋆-ε-▻-↑⁺⋆ T′↦T Γ⁺ (var · x) wk′ ⟩ [ var · x /⊢′ wk′ ↑⁺′ Γ⁺ ] ≡⟨ Translation-from.var-/⊢-wk-↑⁺ T′↦T Γ⁺ x ⟩ [ var · (lift weaken∋ Γ⁺ · x) ] ≡⟨ P.sym $ Translation-from.var-/⊢-wk-↑⁺ Var-↦ Γ⁺ x ⟩ [ var · x /⊢-renaming Renaming.wk ↑⁺-renaming Γ⁺ ] ≡⟨ P.sym $ Translation-from./⊢⋆-ε-▻-↑⁺⋆ Var-↦ Γ⁺ (var · x) Renaming.wk ⟩ [ var · x /⊢⋆-renaming (ε ▻ Renaming.wk) ↑⁺⋆-renaming Γ⁺ ] ∎) ε -- An Application₂₂ record for renamings. application₂₂-renaming : Application₂₂ Renaming.simple simple var application₂₂-renaming = application₂₂ Var-↦ -- We can apply substitutions to terms. application₁ : Application₁ T application₁ = record { simple = simple ; application₂₂ = application₂₂ no-translation } open Application₁ application₁ public hiding (var; simple; application₂₂) open Substitution₁ substitution₁ public
events.asm
kieranhj/stniccc-archie
3
11245
<gh_stars>1-10 ; ============================================================================ ; Events system ; ============================================================================ ;.equ TRACK_SPEED, 4 .macro do_event pattern, temp, func, data ; .long \temp*TRACK_SPEED+\pattern*64*TRACK_SPEED .long \temp+\pattern*256 .long \data b \func .endm events_update: ; read current tracker position mov r0, #-1 mov r1, #-1 swi QTM_Pos ldr r2, events_ptr ; load pattern/line for the next event ldr r3, [r2], #4 mov r4, r3, lsr #8 ; pattern cmp r0, r4 bne do_nothing and r4, r3, #0xff ; line cmp r1, r4 blt do_nothing ; if we miss a line still process this event ; call event function ldr r0, [r2], #4 add r3, r2, #4 str r3, events_ptr str lr, [sp, #-4]! ; push lr on stack adr lr, .2 mov pc, r2 ; call fn. .2: ldr lr, [sp], #4 ; pull lr from stack b events_update ; repeat until all events processed do_nothing: mov pc, lr show_pause: mov r0, #0 str r0, update_fn_id mov pc, lr events_ptr: .long events_data ; ============================================================================ ; Events data ; ; Available functions: ; show_image, data = image no. ; show_parser = STNICC sequence, clear screen if data = 1 (needed for restarting after image) ; parser_set_frame, data = STNICCC frame no. [0-1799] ; parser_set_speed, data = frame step (negative for backwards) ; parser_set_filter, colour if data = 0, b&w if data = 1 (STNICCC only), white flas = 2 (STNICCC only) ; show_text_block, data = text block no. ; ============================================================================ events_data: do_event 0, 0, show_image, 0 ; slide 1 'back by popular demand' do_event 0, 0x30, fade_to_black, 3 ; fade to black, speed = 2 do_event 1, 0, parser_set_frame, 1799 do_event 1, 0, parser_set_speed, -1 do_event 1, 0, show_parser, 1 ; STNICCC forwards do_event 1, 0x30, parser_set_speed, 1 ; forwards do_event 1, 0x34, parser_set_speed, -1 ; backwards do_event 1, 0x36, parser_set_speed, 1 ; forwards do_event 1, 0x38, parser_set_speed, -2 ; backwards do_event 2, 0, show_image, 1 ; slide 2 'recognise this?' do_event 2, 0x20, parser_set_frame, 1700 do_event 2, 0x20, show_parser, 1 ; STNICCC do_event 3, 0, show_image, 2 ; slide 3 'yeah?' do_event 3, 0x20, parser_set_frame, 1650 do_event 3, 0x20, show_parser, 1 ; STNICCC ;do_event 3, 0x2e, parser_set_speed, -1 ; backwards do_event 3, 0x30, parser_set_speed, 2 ; forwards do_event 3, 0x32, parser_set_speed, -2 ; backwards do_event 3, 0x34, parser_set_speed, 2 ; forwards do_event 3, 0x38, parser_set_speed, -2 ; backwards do_event 4, 0, show_image, 3 ; slide 4 'it's called' do_event 4, 0x20, show_parser, 1 ; STNICCC do_event 5, 0, show_image, 4 ; slide 5 'compo filler' ;do_event 5, 0x20, parser_set_filter, 1 ; b&w do_event 5, 0x20, parser_set_speed, -1 ; backwards do_event 5, 0x20, parser_set_frame, 1375 do_event 5, 0x20, show_parser, 1 ; STNICCC do_event 6, 0, show_image, 5 ; slide 6 'Remain calm' ;do_event 6, 32, parser_set_filter, 0 ; colour ;do_event 6, 32, parser_set_speed, 1 ; forwards do_event 6, 32, show_parser, 1 ; STNICCC do_event 7, 0, show_image, 6 ; slide 7 'This demo is short' ;do_event 7, 32, parser_set_filter, 0 ; colour ;do_event 7, 32, parser_set_speed, 1 ; forwards do_event 7, 0x20, show_parser, 1 ; STNICCC do_event 7, 0x30, parser_set_speed, 2 ; forwards do_event 7, 0x32, parser_set_speed, -2 ; backwards do_event 7, 0x34, parser_set_speed, 2 ; forwards do_event 7, 0x38, parser_set_speed, -2 ; backwards do_event 7, 0x3a, parser_set_speed, 2 ; forwards do_event 7, 0x3c, parser_set_speed, -2 ; backwards do_event 8, 0, show_image, 7 ; slide 8 'The End' do_event 8, 0x18, show_image, 8 ; slide 9 'Only Joking' do_event 9, 0, show_parser, 1 ; STNICCC ;do_event 9, 32, parser_set_filter, 1 ; b&w ;do_event 9, 32, parser_set_speed, -3 ; back ;do_event 9, 32, show_parser, 1 ; STNICCC do_event 9, 0x8, parser_set_filter, 2 ; flash white do_event 9, 0x18, parser_set_filter, 2 ; flash white do_event 9, 0x28, parser_set_filter, 2 ; flash white do_event 9, 0x38, parser_set_filter, 2 ; flash white do_event 0xa, 0, show_image, 10 ; slide 11 'Well this is fun' do_event 0xa, 0x20, show_parser, 1 ; STNICCC do_event 0xa, 0x28, parser_set_filter, 2 ; flash white do_event 0xa, 0x34, parser_set_filter, 2 ; flash white do_event 0xa, 0x3a, parser_set_filter, 2 ; flash white ;do_event 0xb, 0, show_image, 20 ; bitshifters logo do_event 0xb, 0, show_image, 11 ; slide 12 'black and white?' do_event 0xb, 0x20, parser_set_filter, 1 ; b@w do_event 0xb, 0x20, parser_set_frame, 300 do_event 0xb, 0x20, parser_set_speed, 2 ; forwards do_event 0xb, 0x20, show_parser, 1 ; STNICCC do_event 0xb, 0x28, parser_set_filter, 3 ; flash white to b&w do_event 0xb, 0x38, parser_set_filter, 3 ; flash white to b&w do_event 0xc, 0, show_image, 21 ; patarty do_event 0xc, 0x20, parser_set_filter, 0 ; colour do_event 0xc, 0x20, parser_set_speed, 4 ; forwards do_event 0xc, 0x20, show_parser, 1 ; STNICCC do_event 0xc, 0x28, parser_set_filter, 2 ; flash white do_event 0xc, 0x34, parser_set_filter, 2 ; flash white do_event 0xc, 0x3a, parser_set_filter, 2 ; flash white do_event 0xd, 0, show_image, 22 ; pic gangster do_event 0xd, 0x20, parser_set_filter, 0 ; colour do_event 0xd, 0x20, parser_set_speed, 4 ; forwards do_event 0xd, 0x20, show_parser, 1 ; STNICCC do_event 0xd, 0x28, parser_set_filter, 2 ; flash white do_event 0xd, 0x38, parser_set_filter, 2 ; flash white do_event 0xe, 0, show_image, 9 ; slide 10 'avon' do_event 0xe, 0x20, parser_set_filter, 0 ; colour do_event 0xe, 0x20, parser_set_speed, 4 ; forwards do_event 0xe, 0x20, show_parser, 1 ; STNICCC do_event 0xe, 0x32, parser_set_filter, 2 ; flash white ;do_event 0xe, 0x35, parser_set_filter, 2 ; flash white do_event 0xe, 0x38, parser_set_filter, 2 ; flash white ;do_event 0xe, 0x3b, parser_set_filter, 2 ; flash white do_event 0xe, 0x3e, parser_set_filter, 2 ; flash white do_event 0xf, 0, show_image, 12 ; slide 13 'nearly done' do_event 0x10, 0, parser_set_frame, 0 do_event 0x10, 0, parser_set_filter, 0 ; colour do_event 0x10, 0, parser_set_speed, 4 ; forwards do_event 0x10, 0, show_parser, 1 ; STNICCC do_event 0x10, 0x8, parser_set_filter, 2 ; flash white do_event 0x10, 0x18, parser_set_filter, 2 ; flash white do_event 0x10, 0x20, show_image, 15 ; slide 16 'greets 1' do_event 0x11, 0, parser_set_frame, 450 do_event 0x11, 0, parser_set_filter, 0 ; colour do_event 0x11, 0, parser_set_speed, 4 ; forwards do_event 0x11, 0, show_parser, 1 ; STNICCC do_event 0x11, 0x8, parser_set_filter, 2 ; flash white do_event 0x11, 0x18, parser_set_filter, 2 ; flash white do_event 0x11, 0x20, show_image, 16 ; slide 17 'greets 2' do_event 0x12, 0, parser_set_frame, 900 do_event 0x12, 0, parser_set_filter, 0 ; colour do_event 0x12, 0, parser_set_speed, 4 ; forwards do_event 0x12, 0, show_parser, 1 ; STNICCC do_event 0x12, 0x8, parser_set_filter, 2 ; flash white do_event 0x12, 0x18, parser_set_filter, 2 ; flash white do_event 0x12, 0x20, show_image, 17 ; slide 18 'greets 3' do_event 0x13, 0, parser_set_frame, 1350 do_event 0x13, 0, parser_set_filter, 0 ; colour do_event 0x13, 0, parser_set_speed, 4 ; forwards do_event 0x13, 0, show_parser, 1 ; STNICCC do_event 0x13, 0x8, parser_set_filter, 2 ; flash white do_event 0x13, 0x18, parser_set_filter, 2 ; flash white do_event 0x13, 0x20, show_image, 23 ; credits do_event 0x14, 0, show_image, 13 ; slide 14 'the end again' do_event 0x14, 0x18, fade_to_black, 3 ; fade to black, speed = 2 do_event 0x15, 0, show_image, 14 ; slide 15 'no, really' do_event 0x15, 0x18, fade_to_black, 3 ; fade to black, speed = 2 do_event 0x16, 0, show_image, 20 ; bitshifters logo' do_event 0x16, 0x28, fade_to_black, 2 ; fade to black, speed = 2 ;do_event 16, 0, show_image, 23 ; Credits ;do_event 16, 32, show_parser, 1 ; STNICCC ; When Tracker module loops around we'll get back to pattern 0 do_event 0, 0, exit, 0 ; end ; ============================================================================ ; IF YOU GET THE FOLLOWING ERROR MESSAGE WHEN BUILDING: ; fatal error 8: cannot resolve section <seg8000>, maximum number of passes reached ; Just keep adding 4 to the number below until it works! (Stupid assembler bug.) ; ============================================================================ .skip 32
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_475.asm
ljhsiun2/medusa
9
88722
<reponame>ljhsiun2/medusa<filename>Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_475.asm<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r8 push %r9 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_UC_ht+0x15b71, %r14 nop cmp %rax, %rax movw $0x6162, (%r14) xor %r10, %r10 lea addresses_D_ht+0x1c421, %r14 add $36905, %rbp and $0xffffffffffffffc0, %r14 vmovntdqa (%r14), %ymm7 vextracti128 $1, %ymm7, %xmm7 vpextrq $1, %xmm7, %r9 cmp $51470, %rbp lea addresses_D_ht+0xf395, %r8 clflush (%r8) nop nop nop nop nop add %r14, %r14 movl $0x61626364, (%r8) nop and %r9, %r9 lea addresses_UC_ht+0x1e2f1, %r9 clflush (%r9) nop nop add %rdi, %rdi movl $0x61626364, (%r9) nop nop nop nop xor %rbp, %rbp lea addresses_UC_ht+0x1aae9, %rsi lea addresses_normal_ht+0x77f1, %rdi nop nop nop inc %r14 mov $32, %rcx rep movsq nop nop nop nop cmp %r9, %r9 lea addresses_normal_ht+0x18371, %rax clflush (%rax) nop nop nop nop nop and $15773, %rsi movb $0x61, (%rax) nop nop nop nop add $64423, %r9 lea addresses_WT_ht+0x15dad, %rdi nop sub %rax, %rax movb $0x61, (%rdi) nop dec %rdi lea addresses_WT_ht+0x11371, %rbp clflush (%rbp) nop inc %rsi movw $0x6162, (%rbp) nop sub %rsi, %rsi lea addresses_WC_ht+0xbcf1, %r10 nop nop nop inc %rax movw $0x6162, (%r10) nop and $59189, %rcx lea addresses_D_ht+0x13a11, %rdi nop nop nop nop nop xor $21008, %r10 vmovups (%rdi), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $0, %xmm0, %rbp and %rsi, %rsi lea addresses_WT_ht+0xed2c, %rcx xor %rsi, %rsi movl $0x61626364, (%rcx) nop nop nop nop xor $39982, %rax lea addresses_normal_ht+0x18f71, %r10 nop nop nop nop nop xor %rdi, %rdi mov (%r10), %r8w nop nop sub %rax, %rax lea addresses_WC_ht+0x175f1, %rsi lea addresses_WC_ht+0x18b71, %rdi clflush (%rdi) nop and %r9, %r9 mov $32, %rcx rep movsq cmp $22069, %rcx lea addresses_WC_ht+0x16478, %r10 nop nop nop nop dec %rsi mov (%r10), %ebp nop cmp $63720, %rsi lea addresses_UC_ht+0x1cd81, %rax nop nop nop nop add $41338, %r9 mov (%rax), %r14d nop nop nop nop nop dec %r8 pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r9 pop %r8 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r14 push %r15 push %rax push %rbx push %rsi // Load lea addresses_US+0x1d8b7, %r14 nop nop nop dec %rax movb (%r14), %r10b nop nop nop nop nop add %r15, %r15 // Store lea addresses_D+0x13fbd, %rsi nop nop nop nop xor %rbx, %rbx movw $0x5152, (%rsi) inc %r14 // Store lea addresses_PSE+0x1af71, %rax nop nop nop cmp $22691, %r15 movw $0x5152, (%rax) nop and %r15, %r15 // Load lea addresses_D+0x1bb71, %rax nop nop nop nop and %rsi, %rsi vmovups (%rax), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $1, %xmm2, %r10 nop nop nop add $47532, %rbx // Faulty Load lea addresses_D+0x1bb71, %r11 nop nop nop nop sub %rax, %rax vmovups (%r11), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $1, %xmm2, %rbx lea oracles, %r11 and $0xff, %rbx shlq $12, %rbx mov (%r11,%rbx,1), %rbx pop %rsi pop %rbx pop %rax pop %r15 pop %r14 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1, 'same': False, 'type': 'addresses_US'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 2, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'} {'src': {'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'} {'src': {'congruent': 0, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 2, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 6, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 6, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
Transynther/x86/_processed/US/_ht_st_zr_un_/i7-7700_9_0xca.log_21829_1403.asm
ljhsiun2/medusa
9
7739
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r15 push %r8 push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0xd70f, %rsi lea addresses_UC_ht+0x103bf, %rdi nop nop nop sub %r13, %r13 mov $6, %rcx rep movsl nop nop nop and %r10, %r10 lea addresses_D_ht+0x93bf, %rbx nop nop nop and $24889, %r8 mov (%rbx), %cx nop cmp %rdi, %rdi lea addresses_WT_ht+0x7597, %rsi lea addresses_normal_ht+0x19bbf, %rdi nop nop nop nop and $48979, %r15 mov $123, %rcx rep movsq nop nop nop nop cmp $59082, %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %r8 pop %r15 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r15 push %r9 push %rcx push %rdi push %rdx push %rsi // Store lea addresses_WC+0xd6a9, %rsi nop nop nop nop nop sub $38983, %r15 movb $0x51, (%rsi) nop dec %r13 // Store lea addresses_normal+0x528f, %rdx nop nop nop dec %r15 mov $0x5152535455565758, %r13 movq %r13, %xmm6 movups %xmm6, (%rdx) nop add $7442, %rdi // Store lea addresses_A+0x15896, %rdi nop nop nop nop cmp $5853, %r9 mov $0x5152535455565758, %r15 movq %r15, %xmm5 vmovups %ymm5, (%rdi) nop nop nop nop xor %rdx, %rdx // Faulty Load lea addresses_US+0x43bf, %rcx nop xor %rdx, %rdx mov (%rcx), %r13w lea oracles, %rsi and $0xff, %r13 shlq $12, %r13 mov (%rsi,%r13,1), %r13 pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r15 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_US'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WC'}} {'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_normal'}} {'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_A'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 2, 'NT': False, 'type': 'addresses_US'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 4, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 11, 'AVXalign': True, 'same': False, 'size': 2, 'NT': True, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 3, 'same': True, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}} {'46': 1, '48': 1681, '47': 5714, '00': 5622, 'ff': 7062, '53': 1371, '49': 378} ff ff 00 00 49 47 ff 53 47 ff 00 00 00 00 ff 53 47 47 47 47 47 47 00 00 00 49 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 ff ff ff ff ff 00 ff 00 ff ff ff ff ff ff ff 00 00 ff ff 00 ff 00 00 ff ff 48 00 00 53 47 53 47 47 53 47 47 47 47 00 48 53 47 47 47 47 47 47 47 00 ff ff 00 53 ff 48 00 00 48 ff ff ff 48 ff ff 00 00 ff ff ff ff 00 ff 53 47 47 47 47 47 47 47 48 53 47 47 00 ff ff 53 ff 53 47 00 ff ff 00 00 48 ff ff ff 00 48 ff ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 00 ff ff ff 00 00 ff ff 00 00 ff 48 ff ff 00 ff ff 00 47 47 47 ff 48 00 00 00 48 ff 47 47 47 47 47 47 47 47 ff 00 00 00 ff ff ff ff ff 48 48 00 00 ff 48 ff ff ff 48 ff 00 00 ff ff 00 ff ff 00 ff 00 ff 00 53 47 47 47 47 47 47 47 49 47 53 00 ff 53 47 47 47 48 ff ff ff ff 00 48 53 47 47 47 47 47 47 47 47 53 47 00 00 48 ff ff 48 48 ff ff ff 49 47 47 47 48 ff 00 ff 00 48 00 00 48 ff ff ff 00 ff ff 00 ff 00 00 00 00 00 48 00 ff 00 53 00 00 00 00 ff ff ff ff ff ff 00 ff 00 00 ff 48 ff ff 00 ff ff 48 ff 00 ff 00 53 47 47 47 47 47 47 47 47 47 00 ff 00 00 00 ff 00 00 ff 00 00 ff 00 ff ff ff 00 00 00 53 47 47 47 ff 00 ff ff 00 ff 00 ff 53 47 47 47 47 47 47 47 47 47 47 47 47 47 ff ff ff 53 00 ff 49 ff ff 00 47 ff ff 00 00 00 00 ff 53 47 ff 00 ff 00 ff 00 48 00 00 00 ff ff ff 00 ff ff 00 00 ff ff 00 00 ff ff 00 ff ff 00 00 ff 48 47 47 47 47 47 47 47 47 47 47 47 47 47 47 ff 00 ff 00 ff 00 00 00 48 00 00 ff ff 48 00 00 ff 00 53 00 00 ff ff 00 00 48 ff 48 ff 00 ff ff 00 ff ff ff 00 ff 53 ff ff ff 00 47 47 ff ff 48 ff ff 00 ff 00 ff ff ff 00 00 ff 00 ff ff 00 00 ff 48 00 00 ff ff ff 48 00 ff 00 00 ff 48 ff ff ff ff ff ff ff ff 00 00 ff 47 47 47 47 ff ff ff 48 48 ff ff 00 ff ff 00 00 00 48 00 ff ff ff 00 53 47 47 00 ff 48 ff 00 ff ff 48 53 ff ff ff 00 00 ff ff 49 47 47 48 ff ff 00 ff ff 00 53 47 47 47 47 47 47 47 47 47 47 47 47 53 47 47 47 00 ff 48 53 ff 53 47 47 ff 00 00 ff 00 49 47 48 00 53 47 47 47 47 47 47 00 49 47 47 47 47 47 47 ff 48 49 00 48 00 00 ff ff 49 47 00 00 53 47 00 ff 53 47 47 ff 00 ff ff 53 47 47 ff 48 49 00 00 ff 00 00 ff ff ff ff ff ff ff 48 00 00 ff ff ff 00 00 00 53 47 ff 48 53 47 47 47 47 47 47 47 47 ff ff ff 53 47 47 47 00 47 47 00 48 ff ff ff ff ff 53 47 47 47 47 00 ff ff 00 00 ff ff 00 48 ff 00 53 47 ff 00 48 48 ff 00 ff ff ff 48 00 00 48 ff 48 00 48 ff 48 00 00 47 53 47 47 47 47 47 53 47 00 ff 53 00 00 ff ff 00 00 ff 00 53 47 47 00 ff 00 ff 48 ff 48 00 53 47 47 47 ff 00 00 ff ff 00 ff ff 00 00 00 ff 00 00 48 00 00 ff 00 ff ff 00 ff 00 00 00 48 00 ff 00 ff 00 ff 48 ff 49 47 47 47 47 47 00 ff ff ff 00 ff ff 53 47 47 47 47 47 47 ff 00 ff 49 47 47 47 49 47 47 47 47 47 00 00 ff ff 00 00 ff 00 ff 00 ff ff ff 00 00 47 47 ff 53 47 47 47 ff 00 00 ff ff 00 00 00 48 ff 48 48 ff 00 ff 48 00 00 49 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 00 48 00 00 ff 48 ff 48 ff 00 00 00 53 ff 48 00 ff 00 ff 00 ff ff ff 00 ff ff 49 00 ff 00 48 49 47 47 47 47 ff 53 47 47 47 47 53 48 ff 48 00 ff 00 ff ff ff ff ff ff 48 00 47 47 47 ff 00 53 48 */
programs/oeis/011/A011930.asm
karttu/loda
1
176052
<filename>programs/oeis/011/A011930.asm ; A011930: a(n) = floor(n(n-1)(n-2)(n-3)/20). ; 0,0,0,0,1,6,18,42,84,151,252,396,594,858,1201,1638,2184,2856,3672,4651,5814,7182,8778,10626,12751,15180,17940,21060,24570,28501,32886,37758,43152,49104,55651,62832,70686,79254,88578,98701,109668,121524,134316,148092,162901,178794,195822,214038,233496,254251,276360,299880,324870,351390,379501,409266,440748,474012,509124,546151,585162,626226,669414,714798,762451,812448,864864,919776,977262,1037401,1100274,1165962,1234548,1306116,1380751,1458540,1539570,1623930,1711710,1803001,1897896,1996488,2098872,2205144,2315401,2429742,2548266,2671074,2798268,2929951,3066228,3207204,3352986,3503682,3659401,3820254,3986352,4157808,4334736,4517251,4705470,4899510,5099490,5305530,5517751,5736276,5961228,6192732,6430914,6675901,6927822,7186806,7452984,7726488,8007451,8296008,8592294,8896446,9208602,9528901,9857484,10194492,10540068,10894356,11257501,11629650,12010950,12401550,12801600,13211251,13630656,14059968,14499342,14948934,15408901,15879402,16360596,16852644,17355708,17869951,18395538,18932634,19481406,20042022,20614651,21199464,21796632,22406328,23028726,23664001,24312330,24973890,25648860,26337420,27039751,27756036,28486458,29231202,29990454,30764401,31553232,32357136,33176304,34010928,34861201,35727318,36609474,37507866,38422692,39354151,40302444,41267772,42250338,43250346,44268001,45303510,46357080,47428920,48519240,49628251,50756166,51903198,53069562,54255474,55461151,56686812,57932676,59198964,60485898,61793701,63122598,64472814,65844576,67238112,68653651,70091424,71551662,73034598,74540466,76069501,77621940,79198020,80797980,82422060,84070501,85743546,87441438,89164422,90912744,92686651,94486392,96312216,98164374,100043118,101948701,103881378,105841404,107829036,109844532,111888151,113960154,116060802,118190358,120349086,122537251,124755120,127002960,129281040,131589630,133929001,136299426,138701178,141134532,143599764,146097151,148626972,151189506,153785034,156413838,159076201,161772408,164502744,167267496,170066952,172901401,175771134,178676442,181617618,184594956,187608751 mov $1,$0 bin $1,4 mul $1,6 div $1,5
test/interaction/Issue2183.agda
pthariensflame/agda
3
3464
<reponame>pthariensflame/agda<gh_stars>1-10 -- Andreas, 2016-09-22, issue #2183, issue reported by Ulf open import Agda.Builtin.Nat open import Agda.Builtin.Equality module _ (n : Nat) where foo : (m : Nat) → n ≡ m → Nat foo m refl = {!m!} -- Splitting on m fails currently, as it internally is .n -- We may be doing something about this in the future.
test/src/basic_test_window.adb
Fabien-Chouteau/Giza
7
21595
<reponame>Fabien-Chouteau/Giza with Giza.Colors; use Giza.Colors; with Giza.Window; use Giza.Window; with Giza.Widget.Button; use Giza.Widget.Button; with Giza.GUI; use Giza; package body Basic_Test_Window is ------------- -- On_Init -- ------------- overriding procedure On_Init (This : in out Test_Window) is -- Our real size Size : constant Size_T := Get_Size (Parent (This)); begin -- Add a back button at the bottom of the window This.Back := new Button.Instance; This.Back.Set_Text ("Back"); This.Back.Set_Size ((Size.W, Size.H / 10 - 1)); This.Back.Set_Foreground (Red); This.Add_Child (Widget.Reference (This.Back), (0, Size.H - Size.H / 10 + 1)); end On_Init; ----------------------- -- On_Position_Event -- ----------------------- overriding function On_Position_Event (This : in out Test_Window; Evt : Position_Event_Ref; Pos : Point_T) return Boolean is Res : Boolean; begin Res := On_Position_Event (Parent (This), Evt, Pos); if Res and then This.Back /= null and then This.Back.Active then This.Back.Set_Active (False); Giza.GUI.Pop; end if; return Res; end On_Position_Event; overriding function Get_Size (This : Test_Window) return Size_T is -- Our real size Size : constant Size_T := Get_Size (Parent (This)); begin -- Remove the size of "back" button return Size - (0, Size.H / 10); end Get_Size; end Basic_Test_Window;
programs/oeis/022/A022334.asm
jmorken/loda
1
174941
<filename>programs/oeis/022/A022334.asm ; A022334: Index of 5^n within sequence of numbers of form 2^i * 5^j. ; 1,4,9,16,26,38,52,69,88,109,133,159,187,218,251,286,324,364,406,451,498,547,599,653,709,768,829,892,958,1026,1096,1168,1243,1320,1399,1481,1565,1651,1740,1831,1924,2020,2118,2218,2321,2426,2533,2643,2755,2869,2986 mov $1,$0 mov $2,$0 mov $7,$0 mov $0,3 lpb $2 add $0,5 add $0,$2 add $0,1 add $5,1 lpb $5 sub $0,4 add $5,$1 add $1,$2 sub $2,2 sub $5,$0 trn $5,$3 lpe trn $2,1 mov $3,5 lpe add $1,1 mov $6,$7 mov $8,$7 lpb $6 sub $6,1 add $9,$8 lpe mov $4,1 mov $8,$9 lpb $4 add $1,$8 sub $4,1 lpe
data/wildPokemon/pokemontower3.asm
etdv-thevoid/pokemon-rgb-enhanced
9
27681
TowerMons3: db $0A db 20,GASTLY db 21,GASTLY db 22,GASTLY db 23,GASTLY db 19,GASTLY db 18,GASTLY db 24,GASTLY db 20,CUBONE db 22,CUBONE db 25,HAUNTER db $00
programs/oeis/092/A092807.asm
neoneye/loda
22
98397
<filename>programs/oeis/092/A092807.asm ; A092807: Expansion of (1-6*x+4*x^2)/((1-2*x)*(1-6*x)). ; 1,2,8,40,224,1312,7808,46720,280064,1679872,10078208,60467200,362799104,2176786432,13060702208,78364180480,470185017344,2821109972992,16926659575808,101559956930560,609359740534784 mov $1,$0 seq $0,181565 ; a(n) = 3*2^n + 1. mov $2,6 pow $2,$1 add $0,$2 sub $0,5 div $0,6 add $0,1
source/league/regexp/matreshka-internals-regexps-compiler-parser.adb
svn2github/matreshka
24
18761
<reponame>svn2github/matreshka<gh_stars>10-100 ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-2011, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.Internals.Regexps.Compiler.Parser.Tables; with Matreshka.Internals.Regexps.Compiler.Scanner; package body Matreshka.Internals.Regexps.Compiler.Parser is use Matreshka.Internals.Regexps.Compiler.Parser.Tables; use Matreshka.Internals.Regexps.Compiler.Scanner; use Matreshka.Internals.Unicode.Ucd; function Process_Alternation (Pattern : not null Shared_Pattern_Access; Alternative_1 : Positive; Alternative_2 : Positive) return Positive; function Process_Multiplicity (Pattern : not null Shared_Pattern_Access; Expression : Positive; Lower : Natural; Upper : Natural; Greedy : Boolean) return Positive; function Process_Match_Any (Pattern : not null Shared_Pattern_Access) return Positive; function Process_Code_Point (Pattern : not null Shared_Pattern_Access; Character : Wide_Wide_Character) return Positive; function Process_Negate_Character_Class (Pattern : not null Shared_Pattern_Access; Class : Positive) return Positive; function Process_Character_Class_Range (Pattern : not null Shared_Pattern_Access; Class : Positive; Low : Wide_Wide_Character; High : Wide_Wide_Character) return Positive; function Process_Character_Class_Code_Point (Pattern : not null Shared_Pattern_Access; Class : Positive; Code : Wide_Wide_Character) return Positive; function Process_New_Character_Class (Pattern : not null Shared_Pattern_Access) return Positive; function Process_Subexpression (Pattern : not null Shared_Pattern_Access; Expression : Positive; Capture : Boolean) return Positive; function Process_Binary_Property (Pattern : not null Shared_Pattern_Access; Keyword : Property_Specification_Keyword; Negative : Boolean) return Positive; function Process_Character_Class_Binary_Property (Pattern : not null Shared_Pattern_Access; Class : Positive; Keyword : Property_Specification_Keyword; Negative : Boolean) return Positive; function Process_Start_Of_Line (Pattern : not null Shared_Pattern_Access) return Positive; function Process_End_Of_Line (Pattern : not null Shared_Pattern_Access) return Positive; procedure Process_Expression (Pattern : not null Shared_Pattern_Access; Expression : Positive); Binary_To_Ucd : constant array (Property_Specification_Keyword range <>) of Boolean_Properties := (ASCII_Hex_Digit => ASCII_Hex_Digit, Alphabetic => Alphabetic, Bidi_Control => Bidi_Control, -- Bidi_Mirrored => Bidi_Mirrored, Composition_Exclusion => Composition_Exclusion, Cased => Cased, Case_Ignorable => Case_Ignorable, Changes_When_Lowercased => Changes_When_Lowercased, Changes_When_Uppercased => Changes_When_Uppercased, Changes_When_Titlecased => Changes_When_Titlecased, Changes_When_Casefolded => Changes_When_Casefolded, Changes_When_Casemapped => Changes_When_Casemapped, Changes_When_NFKC_Casefolded => Changes_When_NFKC_Casefolded, Full_Composition_Exclusion => Full_Composition_Exclusion, Dash => Dash, Deprecated => Deprecated, Default_Ignorable_Code_Point => Default_Ignorable_Code_Point, Diacritic => Diacritic, Extender => Extender, Grapheme_Base => Grapheme_Base, Grapheme_Extend => Grapheme_Extend, Grapheme_Link => Grapheme_Link, Hex_Digit => Hex_Digit, Hyphen => Hyphen, ID_Continue => ID_Continue, Ideographic => Ideographic, ID_Start => ID_Start, IDS_Binary_Operator => IDS_Binary_Operator, IDS_Trinary_Operator => IDS_Trinary_Operator, Join_Control => Join_Control, Logical_Order_Exception => Logical_Order_Exception, Lowercase => Lowercase, Math => Math, Noncharacter_Code_Point => Noncharacter_Code_Point, Other_Alphabetic => Other_Alphabetic, Other_Default_Ignorable_Code_Point => Other_Default_Ignorable_Code_Point, Other_Grapheme_Extend => Other_Grapheme_Extend, Other_ID_Continue => Other_ID_Continue, Other_ID_Start => Other_ID_Start, Other_Lowercase => Other_Lowercase, Other_Math => Other_Math, Other_Uppercase => Other_Uppercase, Pattern_Syntax => Pattern_Syntax, Pattern_White_Space => Pattern_White_Space, Quotation_Mark => Quotation_Mark, Radical => Radical, Soft_Dotted => Soft_Dotted, STerm => STerm, Terminal_Punctuation => Terminal_Punctuation, Unified_Ideograph => Unified_Ideograph, Uppercase => Uppercase, Variation_Selector => Variation_Selector, White_Space => White_Space, XID_Continue => XID_Continue, XID_Start => XID_Start, Expands_On_NFC => Expands_On_NFC, Expands_On_NFD => Expands_On_NFD, Expands_On_NFKC => Expands_On_NFKC, Expands_On_NFKD => Expands_On_NFKD); GC_To_Ucd : constant array (Property_Specification_Keyword range <>) of General_Category_Flags := (Other => (Control | Format | Unassigned | Private_Use | Surrogate => True, others => False), Control => (Control => True, others => False), Format => (Format => True, others => False), Unassigned => (Unassigned => True, others => False), Private_Use => (Private_Use => True, others => False), Surrogate => (Surrogate => True, others => False), Letter => (Lowercase_Letter | Modifier_Letter | Other_Letter | Titlecase_Letter | Uppercase_Letter => True, others => False), Cased_Letter => (Lowercase_Letter | Titlecase_Letter | Uppercase_Letter => True, others => False), Lowercase_Letter => (Lowercase_Letter => True, others => False), Modifier_Letter => (Modifier_Letter => True, others => False), Other_Letter => (Other_Letter => True, others => False), Titlecase_Letter => (Titlecase_Letter => True, others => False), Uppercase_Letter => (Uppercase_Letter => True, others => False), Mark => (Spacing_Mark | Enclosing_Mark | Nonspacing_Mark => True, others => False), Spacing_Mark => (Spacing_Mark => True, others => False), Enclosing_Mark => (Enclosing_Mark => True, others => False), Nonspacing_Mark => (Nonspacing_Mark => True, others => False), Number => (Decimal_Number | Letter_Number | Other_Number => True, others => False), Decimal_Number => (Decimal_Number => True, others => False), Letter_Number => (Letter_Number => True, others => False), Other_Number => (Other_Number => True, others => False), Punctuation => (Connector_Punctuation | Dash_Punctuation | Close_Punctuation | Final_Punctuation | Initial_Punctuation | Other_Punctuation | Open_Punctuation => True, others => False), Connector_Punctuation => (Connector_Punctuation => True, others => False), Dash_Punctuation => (Dash_Punctuation => True, others => False), Close_Punctuation => (Close_Punctuation => True, others => False), Final_Punctuation => (Final_Punctuation => True, others => False), Initial_Punctuation => (Initial_Punctuation => True, others => False), Other_Punctuation => (Other_Punctuation => True, others => False), Open_Punctuation => (Open_Punctuation => True, others => False), Symbol => (Currency_Symbol | Modifier_Symbol | Math_Symbol | Other_Symbol => True, others => False), Currency_Symbol => (Currency_Symbol => True, others => False), Modifier_Symbol => (Modifier_Symbol => True, others => False), Math_Symbol => (Math_Symbol => True, others => False), Other_Symbol => (Other_Symbol => True, others => False), Separator => (Line_Separator | Paragraph_Separator | Space_Separator => True, others => False), Line_Separator => (Line_Separator => True, others => False), Paragraph_Separator => (Paragraph_Separator => True, others => False), Space_Separator => (Space_Separator => True, others => False)); ------------------------- -- Process_Alternation -- ------------------------- function Process_Alternation (Pattern : not null Shared_Pattern_Access; Alternative_1 : Positive; Alternative_2 : Positive) return Positive is begin return Create_Alternative (Pattern, Alternative_1, Alternative_2); end Process_Alternation; ----------------------------- -- Process_Binary_Property -- ----------------------------- function Process_Binary_Property (Pattern : not null Shared_Pattern_Access; Keyword : Property_Specification_Keyword; Negative : Boolean) return Positive is begin if Keyword in Binary_To_Ucd'Range then return Create_Match_Property (Pattern, Binary_To_Ucd (Keyword), Negative); elsif Keyword in GC_To_Ucd'Range then return Create_Match_Property (Pattern, GC_To_Ucd (Keyword), Negative); else raise Program_Error; end if; end Process_Binary_Property; --------------------------------------------- -- Process_Character_Class_Binary_Property -- --------------------------------------------- function Process_Character_Class_Binary_Property (Pattern : not null Shared_Pattern_Access; Class : Positive; Keyword : Property_Specification_Keyword; Negative : Boolean) return Positive is begin if Keyword in Binary_To_Ucd'Range then Create_Member_Property (Pattern, Class, Binary_To_Ucd (Keyword), Negative); elsif Keyword in GC_To_Ucd'Range then Create_Member_Property (Pattern, Class, GC_To_Ucd (Keyword), Negative); else raise Program_Error; end if; return Class; end Process_Character_Class_Binary_Property; ---------------------------------------- -- Process_Character_Class_Code_Point -- ---------------------------------------- function Process_Character_Class_Code_Point (Pattern : not null Shared_Pattern_Access; Class : Positive; Code : Wide_Wide_Character) return Positive is begin Create_Member_Character (Pattern, Class, Wide_Wide_Character'Pos (Code)); return Class; end Process_Character_Class_Code_Point; ----------------------------------- -- Process_Character_Class_Range -- ----------------------------------- function Process_Character_Class_Range (Pattern : not null Shared_Pattern_Access; Class : Positive; Low : Wide_Wide_Character; High : Wide_Wide_Character) return Positive is begin Create_Member_Range (Pattern, Class, Wide_Wide_Character'Pos (Low), Wide_Wide_Character'Pos (High)); return Class; end Process_Character_Class_Range; ------------------------ -- Process_Code_Point -- ------------------------ function Process_Code_Point (Pattern : not null Shared_Pattern_Access; Character : Wide_Wide_Character) return Positive is begin return Create_Match_Character (Pattern, Wide_Wide_Character'Pos (Character)); end Process_Code_Point; ------------------------- -- Process_End_Of_Line -- ------------------------- function Process_End_Of_Line (Pattern : not null Shared_Pattern_Access) return Positive is begin return Create_Anchor_End_Of_Line (Pattern); end Process_End_Of_Line; ------------------------ -- Process_Expression -- ------------------------ procedure Process_Expression (Pattern : not null Shared_Pattern_Access; Expression : Positive) is begin if Pattern.AST (Expression).List = 0 then Pattern.Last_List := Pattern.Last_List + 1; Pattern.List (Pattern.Last_List) := (0, Expression, Expression); Pattern.Start := Pattern.Last_List; Pattern.AST (Expression).List := Pattern.Last_List; else Pattern.Start := Pattern.AST (Expression).List; end if; end Process_Expression; ----------------------- -- Process_Match_Any -- ----------------------- function Process_Match_Any (Pattern : not null Shared_Pattern_Access) return Positive is begin return Create_Match_Any (Pattern); end Process_Match_Any; -------------------------- -- Process_Multiplicity -- -------------------------- function Process_Multiplicity (Pattern : not null Shared_Pattern_Access; Expression : Positive; Lower : Natural; Upper : Natural; Greedy : Boolean) return Positive is begin return Create_Repetition (Pattern, Expression, Lower, Upper, Greedy); end Process_Multiplicity; ------------------------------------ -- Process_Negate_Character_Class -- ------------------------------------ function Process_Negate_Character_Class (Pattern : not null Shared_Pattern_Access; Class : Positive) return Positive is begin Pattern.AST (Class).Negated := True; return Class; end Process_Negate_Character_Class; --------------------------------- -- Process_New_Character_Class -- --------------------------------- function Process_New_Character_Class (Pattern : not null Shared_Pattern_Access) return Positive is begin return Create_Character_Class (Pattern); end Process_New_Character_Class; --------------------------- -- Process_Start_Of_Line -- --------------------------- function Process_Start_Of_Line (Pattern : not null Shared_Pattern_Access) return Positive is begin return Create_Anchor_Start_Of_Line (Pattern); end Process_Start_Of_Line; --------------------------- -- Process_Subexpression -- --------------------------- function Process_Subexpression (Pattern : not null Shared_Pattern_Access; Expression : Positive; Capture : Boolean) return Positive is begin return Create_Subexpression (Pattern, Expression, Capture); end Process_Subexpression; ------------- -- YYParse -- ------------- function YYParse (Self : not null access Compiler_State) return not null Shared_Pattern_Access is -- The size of the value and state stacks YY_Stack_Size : constant Natural := 300; package YY is -- Stack data used by the parser TOS : Natural := 0; Value_Stack : array (0 .. YY_Stack_Size) of YYSType; State_Stack : array (0 .. YY_Stack_Size) of Integer; -- Current input symbol and action the parser is on Input_Symbol : Token; Look_Ahead : Boolean := True; end YY; YYVal : YYSType renames Self.YYVal; YY_Action : Integer; YY_Rule_Id : Integer; YY_Index : Integer; Pattern : Shared_Pattern_Access := new Shared_Pattern (Self.Data.Length, Node_List_Count (Self.Data.Length)); begin YY.TOS := 0; -- Initialize by pushing state 0 and getting the first input symbol YY.State_Stack (YY.TOS) := 0; YY.Look_Ahead := True; loop YY_Index := YY_Shift_Reduce_Offset (YY.State_Stack (YY.TOS)); if YY_Shift_Reduce_Matrix (YY_Index).T = YY_Default then YY_Action := YY_Shift_Reduce_Matrix (YY_Index).Act; else if YY.Look_Ahead then YY.Input_Symbol := YYLex (Self); YY.Look_Ahead := False; end if; YY_Index := YY_Shift_Reduce_Offset (YY.State_Stack (YY.TOS)); while YY_Shift_Reduce_Matrix (YY_Index).T /= Token'Pos (YY.Input_Symbol) and then YY_Shift_Reduce_Matrix (YY_Index).T /= YY_Default loop YY_Index := YY_Index + 1; end loop; YY_Action := YY_Shift_Reduce_Matrix (YY_Index).Act; end if; if YY_Action >= YY_First_Shift_Entry then -- SHIFT -- Enter new state YY.TOS := YY.TOS + 1; YY.State_Stack (YY.TOS) := YY_Action; YY.Value_Stack (YY.TOS) := Self.YYLVal; -- Advance lookahead YY.Look_Ahead := True; elsif YY_Action = YY_Error_Code then -- ERROR Dereference (Pattern); raise Constraint_Error with "Syntax error: " & YY_Errors'Image (Self.YY_Error.Error) & " at" & Integer'Image (Self.YY_Error.Index); elsif YY_Action = YY_Accept_Code then -- Grammar is accepted return Pattern; else -- Reduce Action -- Convert action into a rule YY_Rule_Id := -1 * YY_Action; -- Execute User Action case YY_Rule_Id is pragma Style_Checks ("M127"); when 1 => Process_Expression (Pattern, YY.Value_Stack (YY.TOS).Node); when 2 => -- Alternation YYVal := (AST_Node, Process_Alternation (Pattern, YY.Value_Stack (YY.TOS - 2).Node, YY.Value_Stack (YY.TOS).Node)); when 3 => YYVal := YY.Value_Stack (YY.TOS); when 4 => Matreshka.Internals.Regexps.Compiler.Attach (Pattern.all, YY.Value_Stack (YY.TOS - 1).Node, YY.Value_Stack (YY.TOS).Node); YYVal := YY.Value_Stack (YY.TOS - 1); when 5 => YYVal := YY.Value_Stack (YY.TOS); when 6 => -- Optional, greedy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 1).Node, 0, 1, True)); when 7 => -- Optional, lazy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 1).Node, 0, 1, False)); when 8 => -- Zero or more, greedy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 1).Node, 0, Natural'Last, True)); when 9 => -- Zero or more, lazy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 1).Node, 0, Natural'Last, False)); when 10 => -- One or more, greedy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 1).Node, 1, Natural'Last, True)); when 11 => -- One or more, lazy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 1).Node, 1, Natural'Last, False)); when 12 => -- Multiplicity range, greedy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 5).Node, YY.Value_Stack (YY.TOS - 3).Value, YY.Value_Stack (YY.TOS - 1).Value, True)); when 13 => -- Multiplicity range, lazy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 5).Node, YY.Value_Stack (YY.TOS - 3).Value, YY.Value_Stack (YY.TOS - 1).Value, False)); when 14 => -- Multiplicity zero .. upper, greedy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 4).Node, 0, YY.Value_Stack (YY.TOS - 1).Value, True)); when 15 => -- Multiplicity zero .. upper, lazy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 4).Node, 0, YY.Value_Stack (YY.TOS - 1).Value, False)); when 16 => -- Multiplicity lower .. infinity, greedy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 4).Node, YY.Value_Stack (YY.TOS - 2).Value, Integer'Last, True)); when 17 => -- Multiplicity lower .. infinity, lazy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 4).Node, YY.Value_Stack (YY.TOS - 2).Value, Integer'Last, False)); when 18 => -- Multiplicity, greedy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 3).Node, YY.Value_Stack (YY.TOS - 1).Value, YY.Value_Stack (YY.TOS - 1).Value, True)); when 19 => -- Multiplicity, lazy YYVal := (AST_Node, Process_Multiplicity (Pattern, YY.Value_Stack (YY.TOS - 3).Node, YY.Value_Stack (YY.TOS - 1).Value, YY.Value_Stack (YY.TOS - 1).Value, False)); when 20 => YYVal := (AST_Node, Process_Subexpression (Pattern, YY.Value_Stack (YY.TOS - 1).Node, True)); when 21 => YYVal := (AST_Node, Process_Subexpression (Pattern, YY.Value_Stack (YY.TOS - 1).Node, False)); when 22 => -- Any code point YYVal := (AST_Node, Process_Match_Any (Pattern)); when 23 => -- Code point YYVal := (AST_Node, Process_Code_Point (Pattern, YY.Value_Stack (YY.TOS).Code)); when 24 => -- Character with binary property YYVal := (AST_Node, Process_Binary_Property (Pattern, YY.Value_Stack (YY.TOS - 1).Keyword, False)); when 25 => -- Character with binary property, negative YYVal := (AST_Node, Process_Binary_Property (Pattern, YY.Value_Stack (YY.TOS - 1).Keyword, True)); when 26 => -- Character class YYVal := YY.Value_Stack (YY.TOS); when 27 => -- Start of line anchor YYVal := (AST_Node, Process_Start_Of_Line (Pattern)); when 28 => -- End of line anchor YYVal := (AST_Node, Process_End_Of_Line (Pattern)); when 29 => YYVal := YY.Value_Stack (YY.TOS - 1); when 30 => YYVal := (AST_Node, Process_Negate_Character_Class (Pattern, YY.Value_Stack (YY.TOS - 1).Node)); when 31 => -- Add range of code points to character class YYVal := (AST_Node, Process_Character_Class_Range (Pattern, YY.Value_Stack (YY.TOS - 3).Node, YY.Value_Stack (YY.TOS - 2).Code, YY.Value_Stack (YY.TOS).Code)); when 32 => -- Add code point to character class YYVal := (AST_Node, Process_Character_Class_Code_Point (Pattern, YY.Value_Stack (YY.TOS - 1).Node, YY.Value_Stack (YY.TOS).Code)); when 33 => -- Character with binary property YYVal := (AST_Node, Process_Character_Class_Binary_Property (Pattern, YY.Value_Stack (YY.TOS - 3).Node, YY.Value_Stack (YY.TOS - 1).Keyword, False)); when 34 => -- Character with binary property, negative YYVal := (AST_Node, Process_Character_Class_Binary_Property (Pattern, YY.Value_Stack (YY.TOS - 3).Node, YY.Value_Stack (YY.TOS - 1).Keyword, True)); when 35 => -- Initialize new character class node YYVal := (AST_Node, Process_New_Character_Class (Pattern)); pragma Style_Checks ("M79"); when others => Dereference (Pattern); raise Program_Error; end case; -- Pop RHS states and goto next state YY.TOS := YY.TOS - YY_Rule_Length (YY_Rule_Id) + 1; YY_Index := YY_Goto_Offset (YY.State_Stack (YY.TOS - 1)); while YY_Goto_Matrix (YY_Index).Nonterm /= YY_Get_LHS_Rule (YY_Rule_Id) loop YY_Index := YY_Index + 1; end loop; YY.State_Stack (YY.TOS) := YY_Goto_Matrix (YY_Index).Newstate; YY.Value_Stack (YY.TOS) := YYVal; end if; end loop; end YYParse; end Matreshka.Internals.Regexps.Compiler.Parser;
sbsext/ed/modi.asm
olifink/smsqe
0
104893
* ED - start, end and abort modification  1985 <NAME> QJUMP * section ed * xdef ed_sttmd xdef ed_endmd xdef ed_abtmd xdef ed_getln * xref ed_fline xref ed_xplin xref ed_rewrt xref ed_wrall xref ed_snorm xref ed_shigh xref ed_putln xref ed_dline xref ed_dscr xref ed_trap3 * include dev8_sbsext_ed_keys include dev8_sbsext_ed_data * * get line (for move left by word) * ed_getln tst.b ed_chang(a5) is line already modified? bmi.s edm_rts2 ... yes, do nought * move.w edr_lnr(a5,d5.w),d4 is it a real line? bgt.s edm_getl ... yes, get a line st edr_lnr(a5,d5.w) ... no, make sure that it is neg line nr move.l bv_bfbas(a6),bv_bfp(a6) clear buffer clr.l ed_cline(a5) edm_rts2 rts * edm_getl cmp.w ed_cline(a5),d4 is current line the one we want beq.s edm_rts2 ... yes, we've got it bsr.l ed_fline ... no, find line bsr.l ed_xplin and expand it move.w d4,ed_cline(a5) set current line rts * * abort modification of line * ed_abtmd tst.b ed_chang(a5) is line modified? beq.s edm_rts1 ... no, give up bsr.s edm_norm ... yes, reset to normal edm_rest move.w edr_lnr(a5,d5.w),d4 get current line bgt.s edm_fget jmp ed_dscr ... nothing there before * * start modification of line * ed_sttmd tas ed_chang(a5) is line already modified? bne.s edm_rts1 ... yes, do nought bsr.l ed_shigh * move.w edr_lnr(a5,d5.w),d4 is it a real line? bgt.s edm_get ... yes, get a line st edr_lnr(a5,d5.w) ... no, make sure that it is neg line nr move.l bv_bfbas(a6),bv_bfp(a6) clear buffer clr.l ed_cline(a5) moveq #sd.clrln,d0 and line bra.l ed_trap3 edm_rts1 rts * edm_get cmp.w ed_cline(a5),d4 is current line the one we want beq.s edsm_wlin ... yes, write line edm_fget bsr.l ed_fline ... no, find line bsr.l ed_xplin and expand it edm_scl move.w d4,ed_cline(a5) set current line edsm_wlin bra.l ed_rewrt and write line edm_norm bra.l ed_snorm clear change flag, set normal colours * * end modification of line * ed_endmd tst.b ed_chang(a5) is line modified? beq.s edm_rts1 ... no, give up bsr.l ed_putln put line back blt.s edm_rts ... oops move.w d0,d4 get actual line number move.w d4,ed_cline(a5) this is current line bsr.s edm_norm ... empty, set normal colours, no change tst.w d4 line? ble.l ed_dscr ... none, delete from screen move.w ed_nrows(a5),d2 set end row pointer lsl.w #3,d2 move.w edr_lnr(a5,d5.w),d0 and set old line number here ble.s edm_newl ... was zero, a new line cmp.w d0,d4 ... not zero, the same? beq.s edm_fget ... yes, get the new version of the line * bsr.s edm_wind check if new line in window blt.s edm_rest ... no, restore bra.s edm_redraw ... yes, redraw complete window * edm_newl move.w d6,d1 look for previous line sub.w edr_rno(a5,d5.w),d1 ... first row of this one subq.w #1,d1 last of previous blt.s edm_tnext ... off top, test the next line lsl.w #3,d1 beq.s edm_cpln ... top line tst.w edr_lnr(a5,d1.w) is previous line blank? beq.s edm_nwind ... yes edm_cpln cmp.w edr_lnr(a5,d1.w),d4 is this line after the previous ble.s edm_nwind ... no, test if new line in window * edm_tnext move.w d5,d1 get pointer to table edm_tnloop addq.w #edr.len,d1 next row cmp.w d2,d1 off end? bgt.s edm_fget ... yes, line is in order tst.w edr_rno(a5,d1.w) ... no, is it a first row? bne.s edm_tnloop ... no, carry on move.w edr_lnr(a5,d1.w),d0 is this end of file? beq.s edm_fget ... yes, in order cmp.w d0,d4 is new line before this one? blt.s edm_fget ... yes, in order * edm_nwind bsr.s edm_wind is new line in window? blt ed_dscr ... no, just delete this line from scree * edm_redraw moveq #-edr.len,d0 find top most non zero line edm_ftop addq.l #edr.len,d0 move.w edr_lnr(a5,d0.w),d4 set top of screen pointer ble.s edm_ftop move.w edr_rno(a5),d3 bra.l ed_wrall and write all of screen * edm_wind cmp.w edr_lnr(a5),d4 new line off the top? blt.s edm_rts ... yes move.w edr_lnr(a5,d2.w),d0 beq.s edm_rts bottom is end of file cmp.w d4,d0 off the bottom edm_rts rts * end
data/mapObjects/PowerPlant.asm
AmateurPanda92/pokemon-rby-dx
9
29606
<filename>data/mapObjects/PowerPlant.asm PowerPlant_Object: db $2e ; border block db 3 ; warps warp 4, 35, 3, -1 warp 5, 35, 3, -1 warp 0, 11, 3, -1 db 0 ; signs db 14 ; objects object SPRITE_BALL, 9, 20, STAY, NONE, 1, VOLTORB, 40 object SPRITE_BALL, 32, 18, STAY, NONE, 2, VOLTORB, 40 object SPRITE_BALL, 21, 25, STAY, NONE, 3, VOLTORB, 40 object SPRITE_BALL, 25, 18, STAY, NONE, 4, ELECTRODE, 43 object SPRITE_BALL, 23, 34, STAY, NONE, 5, VOLTORB, 40 object SPRITE_BALL, 26, 28, STAY, NONE, 6, VOLTORB, 40 object SPRITE_BALL, 21, 14, STAY, NONE, 7, ELECTRODE, 43 object SPRITE_BALL, 37, 32, STAY, NONE, 8, VOLTORB, 40 object SPRITE_BIRD, 4, 9, STAY, UP, 9, ZAPDOS, 50 object SPRITE_BALL, 7, 25, STAY, NONE, 10, CARBOS object SPRITE_BALL, 28, 3, STAY, NONE, 11, HP_UP object SPRITE_BALL, 34, 3, STAY, NONE, 12, RARE_CANDY object SPRITE_BALL, 26, 32, STAY, NONE, 13, TM_25 object SPRITE_BALL, 20, 32, STAY, NONE, 14, TM_33 ; warp-to warp_to 4, 35, POWER_PLANT_WIDTH warp_to 5, 35, POWER_PLANT_WIDTH warp_to 0, 11, POWER_PLANT_WIDTH
libsrc/_DEVELOPMENT/arch/ts2068/display/z80/asm_tshc_aaddrpup.asm
jpoikela/z88dk
640
85224
; =============================================================== ; May 2017 ; =============================================================== ; ; void *tshc_aaddrpup(void *aaddr) ; ; Modify attribute address to move up one pixel. ; ; =============================================================== SECTION code_clib SECTION code_arch PUBLIC asm_tshc_aaddrpup EXTERN asm_zx_saddrpup defc asm_tshc_aaddrpup = asm_zx_saddrpup
src/gen/gstreamer-gst_low_level-gstreamer_0_10_gst_interfaces_videoorientation_h.ads
persan/A-gst
1
15446
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; with glib; with glib.Values; with System; with glib; with System; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_interfaces_videoorientation_h is -- unsupported macro: GST_TYPE_VIDEO_ORIENTATION (gst_video_orientation_get_type ()) -- arg-macro: function GST_VIDEO_ORIENTATION (obj) -- return GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VIDEO_ORIENTATION, GstVideoOrientation); -- arg-macro: function GST_IS_VIDEO_ORIENTATION (obj) -- return GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VIDEO_ORIENTATION); -- arg-macro: function GST_VIDEO_ORIENTATION_GET_IFACE (inst) -- return G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_VIDEO_ORIENTATION, GstVideoOrientationInterface); -- GStreamer -- * Copyright (C) 2006 Nokia <<EMAIL> -- * -- * videoorientation.h: video flipping and centering interface -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Library General Public -- * License as published by the Free Software Foundation; either -- * version 2 of the License, or (at your option) any later version. -- * -- * This library is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * Library General Public License for more details. -- * -- * You should have received a copy of the GNU Library General Public -- * License along with this library; if not, write to the -- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- * Boston, MA 02111-1307, USA. -- --* -- * GstVideoOrientation: -- * -- * Opaque #GstVideoOrientation data structure. -- -- skipped empty struct u_GstVideoOrientation -- skipped empty struct GstVideoOrientation type GstVideoOrientationInterface; type u_GstVideoOrientationInterface_u_gst_reserved_array is array (0 .. 3) of System.Address; --subtype GstVideoOrientationInterface is u_GstVideoOrientationInterface; -- gst/interfaces/videoorientation.h:45 --* -- * GstVideoOrientationInterface: -- * @parent: parent interface type. -- * @get_hflip: virtual method to get horizontal flipping state -- * @get_vflip: virtual method to get vertical flipping state -- * @get_hcenter: virtual method to get horizontal centering state -- * @get_vcenter: virtual method to get vertical centering state -- * @set_hflip: virtual method to set horizontal flipping state -- * @set_vflip: virtual method to set vertical flipping state -- * @set_hcenter: virtual method to set horizontal centering state -- * @set_vcenter: virtual method to set vertical centering state -- * -- * #GstVideoOrientationInterface interface. -- type GstVideoOrientationInterface is record parent : aliased GStreamer.GST_Low_Level.glib_2_0_gobject_gtype_h.GTypeInterface; -- gst/interfaces/videoorientation.h:62 get_hflip : access function (arg1 : System.Address; arg2 : access GLIB.gboolean) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:65 get_vflip : access function (arg1 : System.Address; arg2 : access GLIB.gboolean) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:66 get_hcenter : access function (arg1 : System.Address; arg2 : access GLIB.gint) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:67 get_vcenter : access function (arg1 : System.Address; arg2 : access GLIB.gint) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:68 set_hflip : access function (arg1 : System.Address; arg2 : GLIB.gboolean) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:70 set_vflip : access function (arg1 : System.Address; arg2 : GLIB.gboolean) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:71 set_hcenter : access function (arg1 : System.Address; arg2 : GLIB.gint) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:72 set_vcenter : access function (arg1 : System.Address; arg2 : GLIB.gint) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:73 u_gst_reserved : u_GstVideoOrientationInterface_u_gst_reserved_array; -- gst/interfaces/videoorientation.h:76 end record; pragma Convention (C_Pass_By_Copy, GstVideoOrientationInterface); -- gst/interfaces/videoorientation.h:61 -- virtual functions --< private > function gst_video_orientation_get_type return GLIB.GType; -- gst/interfaces/videoorientation.h:79 pragma Import (C, gst_video_orientation_get_type, "gst_video_orientation_get_type"); -- virtual class function wrappers function gst_video_orientation_get_hflip (video_orientation : System.Address; flip : access GLIB.gboolean) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:82 pragma Import (C, gst_video_orientation_get_hflip, "gst_video_orientation_get_hflip"); function gst_video_orientation_get_vflip (video_orientation : System.Address; flip : access GLIB.gboolean) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:83 pragma Import (C, gst_video_orientation_get_vflip, "gst_video_orientation_get_vflip"); function gst_video_orientation_get_hcenter (video_orientation : System.Address; center : access GLIB.gint) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:84 pragma Import (C, gst_video_orientation_get_hcenter, "gst_video_orientation_get_hcenter"); function gst_video_orientation_get_vcenter (video_orientation : System.Address; center : access GLIB.gint) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:85 pragma Import (C, gst_video_orientation_get_vcenter, "gst_video_orientation_get_vcenter"); function gst_video_orientation_set_hflip (video_orientation : System.Address; flip : GLIB.gboolean) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:87 pragma Import (C, gst_video_orientation_set_hflip, "gst_video_orientation_set_hflip"); function gst_video_orientation_set_vflip (video_orientation : System.Address; flip : GLIB.gboolean) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:88 pragma Import (C, gst_video_orientation_set_vflip, "gst_video_orientation_set_vflip"); function gst_video_orientation_set_hcenter (video_orientation : System.Address; center : GLIB.gint) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:89 pragma Import (C, gst_video_orientation_set_hcenter, "gst_video_orientation_set_hcenter"); function gst_video_orientation_set_vcenter (video_orientation : System.Address; center : GLIB.gint) return GLIB.gboolean; -- gst/interfaces/videoorientation.h:90 pragma Import (C, gst_video_orientation_set_vcenter, "gst_video_orientation_set_vcenter"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_interfaces_videoorientation_h;
_lessons/06-dynamic/code/family-state.als
HanielB/2021.1-fm
0
1781
sig State { successor : set State } abstract sig Person { spouse: Person lone -> State, } sig Man, Woman extends Person {} pred getMarried [p,q: Person, s,s': State] { -- Pre-condition -- they must not be married no (p+q).spouse.s -- Post-condition -- After marriage they are each other's spouses q in p.spouse.s' p in q.spouse.s' } run {some p,q : Person | some s,s' : State | getMarried[p,q,s,s'] } -- run {some p,q : Person | some s,s' : State | getMarried[p,q,s,s'] and no s : State | s in s.successor} for exactly 2 Person, 2 State
source/features/screen - 1k bug.asm
shoaib-jamal/MichalOS
0
164943
<filename>source/features/screen - 1k bug.asm ; ================================================================== ; SCREEN HANDLING SYSTEM CALLS ; ================================================================== ; ------------------------------------------------------------------ ; os_putchar -- Puts a character on the screen ; IN: AL = character ; OUT: Nothing (registers preserved) os_putchar: pusha mov ah, 0Eh int 10h popa ret ; ------------------------------------------------------------------ ; os_put_chars -- Puts up to a set amount of characters on the screen ; IN: BL = terminator, SI = location, CX = character count ; OUT: Nothing (registers preserved) os_put_chars: pusha .loop: lodsb cmp al, bl je .done call os_putchar loop .loop .done: popa ret ; ------------------------------------------------------------------ ; os_print_string -- Displays text ; IN: SI = message location (zero-terminated string) ; OUT: Nothing (registers preserved) os_print_string: pusha .repeat: lodsb ; Get char from string cmp al, 0 je .done ; If char is zero, end of string call os_putchar jmp .repeat ; And move on to next char .done: popa ret ; ------------------------------------------------------------------ ; os_print_string_box -- Displays text inside a text-box. ; IN: SI = message location (zero-terminated string), DL = left alignment ; OUT: Nothing (registers preserved) os_print_string_box: pusha mov cl, dl .repeat: lodsb ; Get char from string cmp al, 0 je .done ; If char is zero, end of string cmp al, 13 je .cr call os_putchar jmp .repeat ; And move on to next char .done: popa ret .cr: call os_get_cursor_pos mov dl, cl call os_move_cursor jmp .repeat ; ------------------------------------------------------------------ ; os_format_string -- Displays colored text ; IN: BL/SI = text color/message location (zero-terminated string) ; OUT: Nothing (registers preserved) os_format_string: pusha mov ah, 09h ; int 09h mov bh, 0 mov cx, 1 call os_get_cursor_pos .repeat: lodsb ; Get char from string cmp al, 13 je .cr cmp al, 10 je .lf cmp al, 0 je .done ; If char is zero, end of string int 10h ; Otherwise, print it inc dl call os_move_cursor jmp .repeat ; And move on to next char .cr: mov dl, 0 call os_move_cursor jmp .repeat .lf: inc dh call os_move_cursor jmp .repeat .done: popa ret ; ------------------------------------------------------------------ ; os_clear_screen -- Clears the screen to background ; IN/OUT: Nothing (registers preserved) os_clear_screen: pusha mov dx, 0 ; Position cursor at top-left call os_move_cursor mov16 ax, 0, 6 ; Scroll full-screen mov bh, 7 mov16 cx, 0, 0 ; Top-left mov16 dx, 79, 24 ; Bottom-right int 10h popa ret ; ------------------------------------------------------------------ ; os_move_cursor -- Moves cursor in text mode ; IN: DH, DL = row, column; OUT: Nothing (registers preserved) os_move_cursor: pusha mov bh, 0 mov ah, 2 int 10h ; BIOS interrupt to move cursor popa ret ; ------------------------------------------------------------------ ; os_get_cursor_pos -- Return position of text cursor ; OUT: DH, DL = row, column os_get_cursor_pos: pusha mov bh, 0 mov ah, 3 int 10h ; BIOS interrupt to get cursor position mov [.tmp], dx popa mov dx, [.tmp] ret .tmp dw 0 ; ------------------------------------------------------------------ ; os_print_horiz_line -- Draw a horizontal line on the screen ; IN: AX = line type (1 for double (-), otherwise single (=)) ; OUT: Nothing (registers preserved) os_print_horiz_line: pusha mov cx, ax ; Store line type param mov al, 196 ; Default is single-line code cmp cx, 1 ; Was double-line specified in AX? jne .ready mov al, 205 ; If so, here's the code .ready: mov cx, 80 ; Counter mov ah, 0Eh ; BIOS output char routine mov bh, 0 .loop: int 10h loop .loop popa ret ; ------------------------------------------------------------------ ; os_show_cursor -- Turns on cursor in text mode ; IN/OUT: Nothing os_show_cursor: pusha mov16 cx, 7, 6 mov16 ax, 3, 1 int 10h popa ret ; ------------------------------------------------------------------ ; os_hide_cursor -- Turns off cursor in text mode ; IN/OUT: Nothing os_hide_cursor: pusha mov ch, 32 mov16 ax, 3, 1 ; AL must be video mode for buggy BIOSes! int 10h popa ret ; ------------------------------------------------------------------ ; os_draw_block -- Render block of specified colour ; IN: BL/DL/DH/SI/DI = colour/start X pos/start Y pos/width/finish Y pos os_draw_block: pusha .more: call os_move_cursor ; Move to block starting position mov16 ax, ' ', 09h ; Draw colour section mov bh, 0 mov cx, si int 10h inc dh ; Get ready for next line movzx ax, dh ; Get current Y position into DL cmp ax, di ; Reached finishing point (DI)? jne .more ; If not, keep drawing popa ret ; ------------------------------------------------------------------ ; os_file_selector -- Show a file selection dialog ; IN: If [0087h] = 1, then BX = location of file extension list ; OUT: AX = location of filename string (or carry set if Esc pressed) os_file_selector: ; Get volume name pusha mov cx, 1 ; Load first disk sector into RAM movzx dx, byte [0084h] mov bx, disk_buffer mov16 ax, 1, 2 stc int 13h ; BIOS load sector call mov si, disk_buffer + 2Bh ; Disk label starts here mov di, .volname mov cx, 11 ; Copy 11 chars of it rep movsb popa pusha mov word [.filename], 0 ; Terminate string in case user leaves without choosing call os_report_free_space shr ax, 1 ; Sectors -> kB mov [.freespace], ax mov ax, 64512 ; Get comma-separated list of filenames call os_get_file_list mov di, 0051h mov byte [di], 0 cmp byte [0087h], 1 jne .no_filter mov si, .filter_msg mov di, 0051h call os_string_copy pusha mov di, 0051h + 9 mov si, bx mov bl, [si] inc si mov cl, 0 .filter_loop: call os_string_copy mov byte [di + 3], ' ' add di, 4 add si, 4 inc cl cmp cl, bl jne .filter_loop mov byte [di], 0 popa .no_filter: mov ax, 64512 ; Show those filenames in a list dialog box mov bx, .root mov cx, 0051h mov si, .callback mov byte [.file_selector_calling], 1 call os_list_dialog_tooltip mov byte [.file_selector_calling], 0 jc .esc_pressed call .get_filename popa mov ax, .filename clc ret .esc_pressed: ; Set carry flag if Escape was pressed popa stc ret .get_filename: dec ax ; Result from os_list_dialog starts from 1, but ; for our file list offset we want to start from 0 mov cx, ax mov bx, 0 mov si, 64512 ; Get our filename from the list .loop1: cmp bx, cx je .got_our_filename lodsb cmp al, ',' je .comma_found jmp .loop1 .comma_found: inc bx jmp .loop1 .got_our_filename: ; Now copy the filename string mov di, .filename .loop2: lodsb cmp al, ',' je .finished_copying cmp al, 0 je .finished_copying stosb jmp .loop2 .finished_copying: mov byte [di], 0 ; Zero terminate the filename string ret .callback: ; Draw the icon's background mov bl, 0F0h mov16 dx, 50, 3 mov si, 19 ; Width mov di, 13 ; Finish Y position call os_draw_block ; Draw option selector window ; Draw the icon mov16 dx, 52, 4 call os_move_cursor mov si, filelogo call os_draw_icon ; Display the filename mov16 dx, 42, 14 call os_move_cursor call .get_filename mov si, .filename call os_print_string ; Find the correct directory entry for this file mov ax, si call int_filename_convert mov di, disk_buffer call disk_get_root_entry mov si, di push si ; Display the file size mov eax, [si + 28] call os_32int_to_string mov si, ax mov di, .filename call os_string_copy mov ax, .filename mov bx, .byte_msg call os_string_add call os_string_length mov dl, 77 sub dl, al call os_move_cursor mov si, .filename call os_print_string ; Display the file write date/time mov byte [.filename], 0 pop si mov bx, [si + 14] mov cx, [si + 16] push bx mov ax, cx ; Days and ax, 11111b mov dx, .dateseparator call .cb_add_num mov ax, cx ; Months shr ax, 5 and ax, 1111b call .cb_add_num mov ax, cx ; Years shr ax, 9 add ax, 1980 mov dx, .whiteseparator call .cb_add_num pop cx mov ax, cx ; Hours shr ax, 11 mov dx, .timeseparator call .cb_add_num mov ax, cx ; Minutes shr ax, 5 and ax, 111111b call .cb_add_num mov ax, cx ; Seconds and ax, 11111b shl ax, 1 mov dx, .help_msg2 call .cb_add_num mov16 dx, 42, 16 call os_move_cursor mov si, .time_msg call os_print_string ; Display volume information mov16 dx, 42, 20 call os_move_cursor mov ax, 09C4h movzx bx, byte [57001] mov cx, 35 int 10h inc dh call os_move_cursor mov si, .vol_msg call os_print_string mov ax, [.freespace] call os_int_to_string mov si, ax call os_string_length add dl, 27 sub dl, al call os_move_cursor call os_print_string mov si, .free_msg call os_print_string ret .cb_add_num: cmp ax, 10 jge .no_zero push ax mov bx, .zerofill mov ax, .filename call os_string_add pop ax .no_zero: call os_int_to_string mov bx, ax mov ax, .filename call os_string_add mov bx, dx call os_string_add ret .help_msg2 db 0 .filter_msg db 'Filters: ', 0 .byte_msg db ' bytes', 0 .free_msg db ' kB free', 0 .timeseparator db ':', 0 .dateseparator db '/', 0 .whiteseparator db ' ', 0 .root db 'A:/', 0 .zerofill db '0', 0 .time_msg db 'Written to on: ' .filename times 20 db 0 .vol_msg db 'Volume ' .volname times 12 db 0 .freespace dw 0 .file_selector_calling db 0 .file_selector_cursorpos db 0 .file_selector_skipnum db 0 .file_selector_numofentries db 0 ; ------------------------------------------------------------------ ; os_list_dialog_tooltip -- Show a dialog with a list of options and a tooltip. ; That means, when the user changes the selection, the application will be called back ; to change the tooltip's contents. ; IN: AX = comma-separated list of strings to show (zero-terminated), ; BX = first help string, CX = second help string ; SI = callback pointer ; OUT: AX = number (starts from 1) of entry selected; carry set if Esc pressed os_list_dialog_tooltip: mov word [0089h], 37 mov [.callbackaddr], si mov word [os_list_dialog.callback], .callback call os_list_dialog mov word [os_list_dialog.callback], 0 mov word [0089h], 76 ret .callback: ; Draw the box on the right mov bl, [57001] ; Color from RAM mov16 dx, 41, 2 ; Start X/Y position mov si, 37 ; Width mov di, 23 ; Finish Y position call os_draw_block ; Draw option selector window mov16 dx, 42, 3 call os_move_cursor call [.callbackaddr] ret .callbackaddr dw 0 ; ------------------------------------------------------------------ ; os_list_dialog -- Show a dialog with a list of options ; IN: AX = comma-separated list of strings to show (zero-terminated), ; BX = first help string, CX = second help string ; OUT: AX = number (starts from 1) of entry selected; carry set if Esc pressed os_list_dialog: pusha push ax ; Store string list for now push cx ; And help strings push bx call os_hide_cursor mov si, ax cmp byte [si], 0 jne .count_entries add sp, 6 popa mov ax, .empty call os_list_dialog ret .count_entries: mov cl, 0 ; Count the number of entries in the list .count_loop: mov al, [es:si] inc si cmp al, 0 je .done_count cmp al, ',' jne .count_loop inc cl jmp .count_loop .done_count: inc cl mov byte [.num_of_entries], cl mov bl, [57001] ; Color from RAM mov16 dx, 2, 2 ; Start X/Y position mov si, [0089h] ; Width mov di, 23 ; Finish Y position call os_draw_block ; Draw option selector window mov16 dx, 3, 3 ; Show first line of help text... call os_move_cursor pop si ; Get back first string call os_print_string inc dh call os_move_cursor pop si ; ...and the second call os_print_string pop si ; SI = location of option list string (pushed earlier) mov word [.list_string], si ; Now that we've drawn the list, highlight the currently selected ; entry and let the user move up and down using the cursor keys mov byte [.skip_num], 0 ; Not skipping any lines at first showing mov16 dx, 25, 6 ; Set up starting position for selector cmp byte [os_file_selector.file_selector_calling], 1 jne .no_load_position cmp cl, [os_file_selector.file_selector_numofentries] jne .no_load_position mov dh, [os_file_selector.file_selector_cursorpos] mov al, [os_file_selector.file_selector_skipnum] mov [.skip_num], al .no_load_position: call os_move_cursor .more_select: pusha mov bl, 11110000b ; Black on white for option list box mov16 dx, 3, 5 mov si, [0089h] sub si, byte 2 mov di, 22 call os_draw_block popa call .draw_black_bar mov word si, [.list_string] call .draw_list .another_key: call os_wait_for_key ; Move / select option cmp ah, 48h ; Up pressed? je .go_up cmp ah, 50h ; Down pressed? je .go_down cmp al, 13 ; Enter pressed? je .option_selected cmp al, 27 ; Esc pressed? je .esc_pressed cmp al, 9 ; Tab pressed? je .tab_pressed jmp .more_select ; If not, wait for another key .tab_pressed: mov dh, 6 mov byte [.skip_num], 0 jmp .more_select .go_up: cmp dh, 6 ; Already at top? jle .hit_top call .draw_white_bar mov dl, 25 call os_move_cursor dec dh ; Row to select (increasing down) jmp .more_select .go_down: ; Already at bottom of list? cmp dh, 20 je .hit_bottom clr cx mov byte cl, dh sub cl, 6 inc cl add byte cl, [.skip_num] mov byte al, [.num_of_entries] cmp cl, al je .hit_bottom call .draw_white_bar mov dl, 25 call os_move_cursor inc dh jmp .more_select .hit_top: mov byte cl, [.skip_num] ; Any lines to scroll up? cmp cl, 0 je .skip_to_bottom ; If not, wait for another key dec byte [.skip_num] ; If so, decrement lines to skip jmp .more_select .hit_bottom: ; See if there's more to scroll clr cx mov byte cl, dh sub cl, 6 inc cl add byte cl, [.skip_num] mov byte al, [.num_of_entries] cmp cl, al je .skip_to_top inc byte [.skip_num] ; If so, increment lines to skip jmp .more_select .skip_to_top: mov byte [.skip_num], 0 mov dh, 6 jmp .more_select .skip_to_bottom: mov al, [.num_of_entries] cmp al, 15 jle .basic_skip .no_basic_skip: mov dh, 20 sub al, 15 mov [.skip_num], al jmp .more_select .basic_skip: cmp al, 0 jl .no_basic_skip mov dh, al add dh, 5 jmp .more_select .option_selected: call os_show_cursor cmp byte [os_file_selector.file_selector_calling], 1 jne .no_store_position mov [os_file_selector.file_selector_cursorpos], dh mov al, [.skip_num] mov [os_file_selector.file_selector_skipnum], al mov al, [.num_of_entries] mov [os_file_selector.file_selector_numofentries], al .no_store_position: sub dh, 6 movzx ax, dh inc al ; Options start from 1 add byte al, [.skip_num] ; Add any lines skipped from scrolling mov word [.tmp], ax ; Store option number before restoring all other regs popa mov word ax, [.tmp] clc ; Clear carry as Esc wasn't pressed ret .esc_pressed: call os_show_cursor cmp byte [os_file_selector.file_selector_calling], 1 jne .no_store_position_on_exit mov [os_file_selector.file_selector_cursorpos], dh mov al, [.skip_num] mov [os_file_selector.file_selector_skipnum], al mov al, [.num_of_entries] mov [os_file_selector.file_selector_numofentries], al .no_store_position_on_exit: popa stc ; Set carry for Esc ret .draw_list: pusha mov16 dx, 5, 6 ; Get into position for option list text call os_move_cursor mov cx, 0 ; Skip lines scrolled off the top of the dialog mov byte cl, [.skip_num] .skip_loop: cmp cx, 0 je .skip_loop_finished .more_lodsb: mov al, [es:si] inc si cmp al, ',' jne .more_lodsb dec cx jmp .skip_loop .skip_loop_finished: mov bx, 0 ; Counter for total number of options .more: mov al, [es:si] ; Get next character in file name, increment pointer inc si cmp al, 0 ; End of string? je .done_list cmp al, ',' ; Next option? (String is comma-separated) je .newline mov ah, 0Eh int 10h jmp .more .newline: mov dl, 5 ; Go back to starting X position inc dh ; But jump down a line call os_move_cursor inc bx ; Update the number-of-options counter cmp bx, 15 ; Limit to one screen of options jl .more .done_list: popa call os_move_cursor pusha push dx mov16 dx, 5, 22 call os_move_cursor mov si, .string1 call os_print_string pop dx mov al, [.skip_num] add al, dh sub al, 5 movzx ax, al call os_int_to_string mov si, ax call os_print_string mov si, .string2 call os_print_string movzx ax, byte [.num_of_entries] call os_int_to_string mov si, ax call os_print_string mov si, .string3 call os_print_string mov al, [.skip_num] add al, dh sub al, 5 movzx ax, al call [.callback] popa ret .draw_black_bar: pusha mov dl, 4 call os_move_cursor mov16 ax, ' ', 09h ; Draw white bar at top mov16 bx, 00001111b, 0 ; White text on black background mov cx, [0089h] sub cx, byte 4 int 10h popa ret .draw_white_bar: pusha mov dl, 4 call os_move_cursor mov16 ax, ' ', 09h ; Draw white bar at top mov16 bx, 11110000b, 0 ; White text on black background mov cx, [0089h] sub cx, byte 4 int 10h popa ret .tmp dw 0 .num_of_entries db 0 .skip_num db 0 .list_string dw 0 .string1 db '(', 0 .string2 db '/', 0 .string3 db ') ', 0 .empty db '< The list is empty. >', 0 .callback dw 0 ; ------------------------------------------------------------------ ; os_draw_background -- Clear screen with white top and bottom bars ; containing text, and a coloured middle section. ; IN: AX/BX = top/bottom string locations, CX = colour (256 if the app wants to display the default background) os_draw_background: pusha push ax ; Store params to pop out later push bx push cx mov dx, 0 call os_move_cursor mov ax, 0920h ; Draw white bar at top mov cx, 80 mov bx, 01110000b int 10h mov dx, 256 call os_move_cursor pop bx ; Get colour param (originally in CX) cmp bx, 256 je .draw_default_background mov ax, 0920h ; Draw colour section mov cx, 1840 mov bh, 0 int 10h .bg_drawn: mov16 dx, 0, 24 call os_move_cursor mov ax, 0920h ; Draw white bar at top mov cx, 80 mov bx, 01110000b int 10h mov16 dx, 1, 24 call os_move_cursor pop si ; Get bottom string param call os_print_string mov dx, 1 call os_move_cursor pop si ; Get top string param call os_print_string mov bx, tmp_string call os_get_date_string mov dx, 69 ; Display date call os_move_cursor mov si, bx call os_print_string mov bx, tmp_string call os_get_time_string mov dx, 63 ; Display time call os_move_cursor mov si, bx call os_print_string mov dl, 79 ; Print the little speaker icon call os_move_cursor mov ax, 0E17h sub al, [0083h] mov bh, 0 int 10h mov16 dx, 0, 1 ; Ready for app text call os_move_cursor popa ret .draw_default_background: cmp byte [fs:DESKTOP_BACKGROUND], 0 je .fill_color push ds push es mov ds, [driversgmt] mov si, DESKTOP_BACKGROUND mov ax, 0B800h mov es, ax mov di, 160 mov cx, 80 * 23 * 2 rep movsb pop es pop ds jmp .bg_drawn .fill_color: movzx bx, byte [57000] mov ax, 0920h mov cx, 1840 int 10h jmp .bg_drawn tmp_string times 15 db 0 ; ------------------------------------------------------------------ ; os_print_newline -- Reset cursor to start of next line ; IN/OUT: Nothing (registers preserved) os_print_newline: pusha mov ah, 0Eh ; BIOS output char code mov al, 13 int 10h mov al, 10 int 10h popa ret ; ------------------------------------------------------------------ ; os_dump_registers -- Displays register contents in hex on the screen ; IN/OUT: EAX/EBX/ECX/EDX/ESI/EDI = registers to show os_dump_registers: pushad push edi push .di_string push esi push .si_string push edx push .dx_string push ecx push .cx_string push ebx push .bx_string push eax push .ax_string mov cx, 6 .loop: pop si call os_print_string pop eax call os_print_8hex loop .loop call os_print_newline popad ret .ax_string db 'EAX:', 0 .bx_string db ' EBX:', 0 .cx_string db ' ECX:', 0 .dx_string db ' EDX:', 0 .si_string db ' ESI:', 0 .di_string db ' EDI:', 0 ; ------------------------------------------------------------------ ; os_input_dialog -- Get text string from user via a dialog box ; IN: AX = string location, BX = message to show; OUT: AX = string location os_input_dialog: pusha push ax ; Save string location push bx ; Save message to show mov16 dx, 12, 10 ; First, draw red background box .redbox: ; Loop to draw all lines of box call os_move_cursor pusha mov16 ax, ' ', 09h mov cx, 55 movzx bx, byte [57001] ; Color from RAM int 10h popa inc dh cmp dh, 16 je .boxdone jmp .redbox .boxdone: mov16 dx, 14, 14 call os_move_cursor mov16 ax, ' ', 09h mov bx, 240 mov cx, 51 int 10h mov16 dx, 14, 11 call os_move_cursor pop bx ; Get message back and display it mov si, bx call os_print_string mov16 dx, 14, 14 call os_move_cursor pop ax ; Get input string back call os_input_string popa ret ; ------------------------------------------------------------------ ; os_password_dialog -- Get a password from user via a dialog box ; IN: AX = string location, BX = message to show; OUT: AX = string location os_password_dialog: pusha push ax ; Save string location push bx ; Save message to show mov16 dx, 12, 10 ; First, draw red background box .redbox: ; Loop to draw all lines of box call os_move_cursor pusha mov16 ax, ' ', 09h mov cx, 55 movzx bx, byte [57001] ; Color from RAM int 10h popa inc dh cmp dh, 16 je .boxdone jmp .redbox .boxdone: mov16 dx, 14, 14 call os_move_cursor mov16 ax, ' ', 09h mov bx, 240 mov cx, 51 int 10h mov16 dx, 14, 11 call os_move_cursor pop bx ; Get message back and display it mov si, bx call os_print_string mov16 dx, 14, 14 call os_move_cursor pop ax ; Get input string back mov bl, 240 call os_input_password popa ret ; ------------------------------------------------------------------ ; os_dialog_box -- Print dialog box in middle of screen, with button(s) ; IN: AX, BX, CX = string locations (set registers to 0 for no display), ; IN: DX = 0 for single 'OK' dialog, 1 for two-button 'OK' and 'Cancel' ; IN: [0085h] = Default button for 2-button dialog (0 or 1) ; OUT: If two-button mode, AX = 0 for OK and 1 for cancel ; NOTE: Each string is limited to 40 characters os_dialog_box: pusha push dx push cx push bx push ax call os_hide_cursor pusha mov bl, [57001] ; Color from RAM mov16 dx, 19, 9 ; First, draw red background box mov si, 42 mov di, 16 call os_draw_block popa mov16 dx, 20, 9 mov cx, 3 .loop: inc dh call os_move_cursor pop si cmp si, 0 je .no_string call os_print_string .no_string: loop .loop pop dx cmp dx, 1 je .two_button .one_button: mov bl, 11110000b ; Black on white mov16 dx, 35, 14 mov si, 8 mov di, 15 call os_draw_block mov16 dx, 38, 14 ; OK button, centred at bottom of box call os_move_cursor mov si, .ok_button_string call os_print_string .one_button_wait: call os_wait_for_key cmp al, 13 ; Wait for enter key (13) to be pressed jne .one_button_wait call os_show_cursor popa ret .two_button: mov bl, 11110000b ; Black on white mov16 dx, 27, 14 mov si, 8 mov di, 15 call os_draw_block mov16 dx, 30, 14 ; OK button call os_move_cursor mov si, .ok_button_string call os_print_string mov16 dx, 44, 14 ; Cancel button call os_move_cursor mov si, .cancel_button_string call os_print_string cmp byte [0085h], 1 je .draw_right jne .draw_left .two_button_wait: call os_wait_for_key cmp ah, 75 ; Left cursor key pressed? je .draw_left cmp ah, 77 ; Right cursor key pressed? je .draw_right cmp al, 27 ; Escape, automatically select "Cancel" je .cancel cmp al, 13 ; Wait for enter key (13) to be pressed jne .two_button_wait call os_show_cursor mov [.tmp], cx ; Keep result after restoring all regs popa mov ax, [.tmp] ret .cancel: call os_show_cursor popa mov ax, 1 ret .draw_left: mov bl, 11110000b ; Black on white mov16 dx, 27, 14 mov si, 8 mov di, 15 call os_draw_block mov16 dx, 30, 14 ; OK button call os_move_cursor mov si, .ok_button_string call os_print_string mov bl, [57001] mov16 dx, 42, 14 mov si, 9 mov di, 15 call os_draw_block mov16 dx, 44, 14 ; Cancel button call os_move_cursor mov si, .cancel_button_string call os_print_string mov cx, 0 ; And update result we'll return jmp .two_button_wait .draw_right: mov bl, [57001] mov16 dx, 27, 14 mov si, 8 mov di, 15 call os_draw_block mov16 dx, 30, 14 ; OK button call os_move_cursor mov si, .ok_button_string call os_print_string mov bl, 11110000b mov16 dx, 43, 14 mov si, 8 mov di, 15 call os_draw_block mov16 dx, 44, 14 ; Cancel button call os_move_cursor mov si, .cancel_button_string call os_print_string mov cx, 1 ; And update result we'll return jmp .two_button_wait .ok_button_string db 'OK', 0 .cancel_button_string db 'Cancel', 0 .tmp dw 0 ; ------------------------------------------------------------------ ; os_print_space -- Print a space to the screen ; IN/OUT: Nothing os_print_space: pusha mov ax, 0E20h ; BIOS teletype function int 10h popa ret ; ------------------------------------------------------------------ ; os_print_digit -- Displays contents of AX as a single digit ; Works up to base 37, ie digits 0-Z ; IN: AX = "digit" to format and print os_print_digit: pusha cmp ax, 9 ; There is a break in ASCII table between 9 and A jle .digit_format add ax, 'A'-'9'-1 ; Correct for the skipped punctuation .digit_format: add ax, '0' ; 0 will display as '0', etc. mov ah, 0Eh ; May modify other registers int 10h popa ret ; ------------------------------------------------------------------ ; os_print_1hex -- Displays low nibble of AL in hex format ; IN: AL = number to format and print os_print_1hex: pusha and ax, 0Fh ; Mask off data to display call os_print_digit popa ret ; ------------------------------------------------------------------ ; os_print_2hex -- Displays AL in hex format ; IN: AL = number to format and print os_print_2hex: pusha push ax ; Output high nibble shr ax, 4 call os_print_1hex pop ax ; Output low nibble call os_print_1hex popa ret ; ------------------------------------------------------------------ ; os_print_4hex -- Displays AX in hex format ; IN: AX = number to format and print os_print_4hex: pusha push ax ; Output high byte mov al, ah call os_print_2hex pop ax ; Output low byte call os_print_2hex popa ret ; ------------------------------------------------------------------ ; os_input_string -- Take string from keyboard entry ; IN/OUT: AX = location of string, other regs preserved ; (Location will contain up to [0088h] characters, zero-terminated) os_input_string: pusha call os_show_cursor mov di, ax ; DI is where we'll store input (buffer) mov cx, 0 ; Character received counter for backspace .more: ; Now onto string getting call os_wait_for_key cmp al, 13 ; If Enter key pressed, finish je .done cmp al, 8 ; Backspace pressed? je .backspace ; If not, skip following checks cmp al, ' ' ; In ASCII range (32 - 127)? jl .more ; Ignore most non-printing characters jmp .nobackspace .backspace: cmp cx, 0 ; Backspace at start of string? je .more ; Ignore it if so call os_get_cursor_pos ; Backspace at start of screen line? cmp dl, 0 je .backspace_linestart pusha mov ax, 0E08h ; If not, write space and move cursor back int 10h ; Backspace twice, to clear space mov al, 32 int 10h mov al, 8 int 10h popa dec di ; Character position will be overwritten by new ; character or terminator at end dec cx ; Step back counter jmp .more .backspace_linestart: dec dh ; Jump back to end of previous line mov dl, 79 call os_move_cursor mov ax, 0E20h ; Print space there int 10h mov dl, 79 ; And jump back before the space call os_move_cursor dec di ; Step back position in string dec cx ; Step back counter jmp .more .nobackspace: movzx bx, byte [0088h] cmp cx, bx ; Make sure we don't exhaust buffer jge near .more pusha mov ah, 0Eh ; Output entered, printable character int 10h popa stosb ; Store character in designated buffer inc cx ; Characters processed += 1 jmp near .more ; Still room for more .done: mov al, 0 stosb popa ret ; Input password(displays it as *s) ; IN: AX = location of string, other regs preserved, BL = color ; OUT: nothing ; (Location will contain up to [0088h] characters, zero-terminated) os_input_password: pusha call os_get_cursor_pos ; Store the cursor position mov [.cursor], dx mov di, ax ; DI is where we'll store input (buffer) mov cx, 0 ; Character received counter for backspace .more: ; Now onto string getting call os_wait_for_key cmp al, 13 ; If Enter key pressed, finish je .done cmp al, 8 ; Backspace pressed? je .backspace ; If not, skip following checks cmp al, ' ' ; In ASCII range (32 - 126)? jge .nobackspace ; Ignore most non-printing characters cmp al, 0 jl .nobackspace jmp .more .backspace: cmp cx, 0 ; Backspace at start of string? je .more ; Ignore it if so dec di ; Character position will be overwritten by new ; character or terminator at end dec cx ; Step back counter call .update jmp near .more .nobackspace: movzx dx, byte [0088h] cmp cx, dx ; Make sure we don't exhaust buffer jge near .more stosb ; Store character in designated buffer inc cx ; Characters processed += 1 call .update jmp near .more ; Still room for more .done: mov al, 0 stosb popa clc ret .update: pusha mov dx, [.cursor] call os_move_cursor mov ax, 0920h ; Clear the line mov bh, 0 mov cx, 32 int 10h popa pusha mov dx, [.cursor] call os_move_cursor mov ax, 092Ah ; Print *s(amount in CX) mov bh, 0 int 10h add dl, cl call os_move_cursor popa ret .cursor dw 0 ; Opens up os_list_dialog with color. ; IN: nothing ; OUT: color number(0-15) os_color_selector: pusha mov ax, .colorlist ; Call os_list_dialog with colors mov bx, .colormsg0 mov cx, .colormsg1 call os_list_dialog dec ax ; Output from os_list_dialog starts with 1, so decrement it mov [.tmp_word], ax popa mov al, [.tmp_word] ret .colorlist db 'Black,Blue,Green,Cyan,Red,Magenta,Brown,Light Gray,Dark Gray,Light Blue,Light Green,Light Cyan,Light Red,Pink,Yellow,White', 0 .colormsg0 db 'Choose a color...', 0 .colormsg1 db 0 .tmp_word dw 0 ; Displays EAX in hex format ; IN: EAX = unsigned integer ; OUT: nothing os_print_8hex: pushad pushad shr eax, 16 call os_print_4hex popad call os_print_4hex popad ret ; Displays a dialog similar to os_dialog_box, but without the buttons. ; IN: SI/AX/BX/CX/DX = string locations(or 0 for no display) ; OUT: nothing os_temp_box: pusha push dx push cx push bx push ax push si call os_hide_cursor mov16 dx, 19, 9 ; First, draw red background box .redbox: ; Loop to draw all lines of box call os_move_cursor pusha mov ax, 0920h movzx bx, byte [57001] ; Color from RAM mov cx, 42 int 10h popa inc dh cmp dh, 16 je .boxdone jmp .redbox .boxdone: mov16 dx, 20, 9 mov cx, 5 .loop: inc dh call os_move_cursor pop si cmp si, 0 ; Skip string params if zero je .no_string call os_print_string .no_string: loop .loop popa ret ; Prints a message on the footer. ; IN: SI = Message location(if 0, then it restores the previous message) ; OUT: nothing os_print_footer: pusha mov al, [0082h] cmp al, 1 je near .exit call os_get_cursor_pos push dx mov di, 1 cmp si, 0 je near .restore mov16 dx, 0, 24 .loop: call os_move_cursor mov ah, 08h mov bh, 0 int 10h stosb inc dl cmp di, 81 jnge near .loop mov byte [80], 0 mov16 dx, 0, 24 call os_move_cursor mov ax, 0920h mov bx, 70h mov cx, 80 int 10h mov16 dx, 0, 24 call os_move_cursor call os_print_string pop dx call os_move_cursor .exit: popa ret .restore: mov16 dx, 0, 24 call os_move_cursor mov si, 1 call os_print_string pop dx call os_move_cursor popa ret ; Resets the font to the selected default. ; IN = nothing ; OUT = nothing os_reset_font: pusha cmp byte [57073], 1 je near .bios push es mov ax, 1100h mov bx, 1000h mov cx, 0100h clr dx mov es, [driversgmt] mov bp, SYSTEM_FONT int 10h pop es popa ret .bios: popa ret ; Draws the MichalOS logo. ; IN: nothing ; OUT: a very beautiful logo :-) os_draw_logo: pusha mov16 dx, 0, 2 call os_move_cursor mov ax, 0920h mov bx, 00000100b mov cx, 560 int 10h mov si, logo call os_draw_icon popa ret ; Draws an icon (in the MichalOS format). ; IN: SI = address of the icon ; OUT: nothing os_draw_icon: pusha call os_get_cursor_pos mov [.cursor], dx lodsw mov [.size], ax clr cx .loop: lodsb mov ah, 0Eh push cx mov cl, al movzx bx, cl and bl, 11000000b shr bl, 6 mov al, [.chars + bx] int 10h movzx bx, cl and bl, 110000b shr bl, 4 mov al, [.chars + bx] int 10h movzx bx, cl and bl, 1100b shr bl, 2 mov al, [.chars + bx] int 10h movzx bx, cl and bl, 11b mov al, [.chars + bx] int 10h pop cx inc cl cmp cl, [.size] jne .loop inc byte [.cursor + 1] mov dx, [.cursor] call os_move_cursor mov cl, 0 inc ch cmp ch, [.size + 1] jne .loop popa ret .cursor dw 0 .chars db 32, 220, 223, 219 .size dw 0 ; ------------------------------------------------------------------ ; os_option_menu -- Show a menu with a list of options ; IN: AX = comma-separated list of strings to show (zero-terminated), BX = menu width ; OUT: AX = number (starts from 1) of entry selected; carry set if Esc, left or right pressed os_option_menu: pusha cmp byte [57071], 0 je .skip mov16 dx, 0, 1 call os_move_cursor mov ah, 08h mov bh, 0 int 10h ; Get the character's attribute (X = 0, Y = 1) and ah, 0F0h ; Keep only the background, set foreground to 0 movzx bx, ah mov ax, 09B1h mov cx, 1840 int 10h popa pusha .skip: mov [.width], bx push ax ; Store string list for now call os_hide_cursor mov cl, 0 ; Count the number of entries in the list mov si, ax .count_loop: lodsb cmp al, 0 je .done_count cmp al, ',' jne .count_loop inc cl jmp .count_loop .done_count: inc cl mov byte [.num_of_entries], cl pop si ; SI = location of option list string (pushed earlier) mov word [.list_string], si ; Now that we've drawn the list, highlight the currently selected ; entry and let the user move up and down using the cursor keys mov byte [.skip_num], 0 ; Not skipping any lines at first showing mov16 dx, 25, 2 ; Set up starting position for selector call os_move_cursor .more_select: pusha mov bl, [57072] ; Black on white for option list box mov16 dx, 1, 1 mov si, [.width] movzx di, [.num_of_entries] add di, 3 call os_draw_block popa call .draw_black_bar mov word si, [.list_string] call .draw_list .another_key: call os_wait_for_key ; Move / select option cmp ah, 48h ; Up pressed? je .go_up cmp ah, 50h ; Down pressed? je .go_down cmp al, 13 ; Enter pressed? je .option_selected cmp al, 27 ; Esc pressed? je .esc_pressed cmp ah, 75 ; Left pressed? je .left_pressed cmp ah, 77 ; Right pressed? je .right_pressed jmp .another_key ; If not, wait for another key .go_up: cmp dh, 2 ; Already at top? jle .hit_top call .draw_white_bar mov dl, 25 call os_move_cursor dec dh ; Row to select (increasing down) jmp .more_select .go_down: ; Already at bottom of list? mov bl, [.num_of_entries] inc bl cmp dh, bl je .hit_bottom mov cx, 0 mov byte cl, dh sub cl, 6 inc cl add byte cl, [.skip_num] mov byte al, [.num_of_entries] cmp cl, al je .another_key call .draw_white_bar mov dl, 25 call os_move_cursor inc dh jmp .more_select .hit_top: mov dh, 1 add dh, [.num_of_entries] jmp .more_select .hit_bottom: mov dh, 2 jmp .more_select .option_selected: call os_show_cursor sub dh, 2 mov ax, 0 mov al, dh inc al ; Options start from 1 add byte al, [.skip_num] ; Add any lines skipped from scrolling mov word [.tmp], ax ; Store option number before restoring all other regs popa mov word ax, [.tmp] clc ; Clear carry as Esc wasn't pressed ret .esc_pressed: call os_show_cursor popa mov ax, 0 stc ret .left_pressed: call os_show_cursor popa mov ax, 1 stc ret .right_pressed: call os_show_cursor popa mov ax, 2 stc ret .draw_list: pusha mov16 dx, 3, 2 ; Get into position for option list text call os_move_cursor mov cx, 0 ; Skip lines scrolled off the top of the dialog mov byte cl, [.skip_num] .skip_loop: cmp cx, 0 je .skip_loop_finished .more_lodsb: lodsb cmp al, ',' jne .more_lodsb dec cx jmp .skip_loop .skip_loop_finished: mov bx, 0 ; Counter for total number of options .more: lodsb ; Get next character in file name, increment pointer cmp al, 0 ; End of string? je .done_list cmp al, ',' ; Next option? (String is comma-separated) je .newline mov ah, 0Eh int 10h jmp .more .newline: mov dl, 3 ; Go back to starting X position inc dh ; But jump down a line call os_move_cursor inc bx ; Update the number-of-options counter movzx di, [.num_of_entries] ; Low 8 bits of DI = [.items], high 8 bits = 0 cmp bx, di ; Limit to one screen of options jl .more .done_list: popa call os_move_cursor ret .draw_black_bar: pusha mov dl, 2 call os_move_cursor mov ax, 0920h ; Draw white bar at top mov cx, [.width] sub cx, 2 mov bx, 00001111b ; White text on black background int 10h popa ret .draw_white_bar: pusha mov dl, 2 call os_move_cursor mov ax, 0920h ; Draw white bar at top mov cx, [.width] sub cx, 2 movzx bx, byte [57072] ; Black text on white background int 10h popa ret .tmp dw 0 .num_of_entries db 0 .skip_num db 0 .list_string dw 0 .width dw 0 ; ==================================================================
oeis/021/A021380.asm
neoneye/loda-programs
11
19030
<filename>oeis/021/A021380.asm ; A021380: Decimal expansion of 1/376. ; 0,0,2,6,5,9,5,7,4,4,6,8,0,8,5,1,0,6,3,8,2,9,7,8,7,2,3,4,0,4,2,5,5,3,1,9,1,4,8,9,3,6,1,7,0,2,1,2,7,6,5,9,5,7,4,4,6,8,0,8,5,1,0,6,3,8,2,9,7,8,7,2,3,4,0,4,2,5,5,3,1,9,1,4,8,9,3,6,1,7,0,2,1,2,7,6,5,9,5 seq $0,173833 ; 10^n - 3. div $0,376 mod $0,10
computer architecture/ProjOrgArq/in/teste2.asm
MarceloHeredia/College
0
173863
.text .globl main main: lui $1,0x00001001 ori $8 , $1, 0x00000000 lw $9,0x00000000($8) beq $8,$9,L_1 j L_1 addu $12,$9,$11 lui $1,0x00001001 ori $13,$1,0x00000008 L_4:sw $12,0x00000000($13) beq $9, $10, main and $21,$20,$19 L_5:sll $22,$23,0x00000005 srl $24,$25,0x00000009 sll $24,$25,0x00000009 slt $14,$15,$16 L_1:addiu $5,$3,0xfffffffb andi $14,$0,0x0000000f xor $9,$10,$11 L_2: j L_2 L_3:bne $21,$2,L_3 bne $21,$2,L_4 sw $2,0xfffffffc($20) j main j L_5 jr $31
agda/Heapsort/Impl1/Correctness/Order.agda
bgbianchi/sorting
6
8024
open import Relation.Binary.Core module Heapsort.Impl1.Correctness.Order {A : Set} (_≤_ : A → A → Set) (tot≤ : Total _≤_) (trans≤ : Transitive _≤_) where open import Data.List open import Function using (_∘_) open import Heapsort.Impl1 _≤_ tot≤ trans≤ open import List.Sorted _≤_ open import OList _≤_ open import OList.Properties _≤_ theorem-heapsort-sorted : (xs : List A) → Sorted (forget (heapsort xs)) theorem-heapsort-sorted = lemma-olist-sorted ∘ heapsort
8088/demo/popcorn/popcorn.asm
reenigne/reenigne
92
93113
<reponame>reenigne/reenigne org 0x100 %include "../../defaults_common.asm"
src/Section3.agda
mietek/coquand
4
5699
<filename>src/Section3.agda module Section3 where open import Section1 public -- 3. The calculus of proof trees -- ============================== -- -- We define the set of proof trees of implicational logic in the ordinary style à la Church, -- except that we use explicit substitutions. -- 3.1. Definition of types -- ------------------------ -- -- The types we have are base type and function types. The set of types `𝒯 : Set` is introduced -- by: infixr 7 _⊃_ data 𝒯 : Set where • : 𝒯 _⊃_ : 𝒯 → 𝒯 → 𝒯 -- Types are denoted by `A`, `B`. (…) -- -- We write `•` for the base type and `A ⊃ B` for the function type. module _ where inj₁⊃ : ∀ {A A′ B B′} → A ⊃ B ≡ A′ ⊃ B′ → A ≡ A′ inj₁⊃ refl = refl inj₂⊃ : ∀ {A A′ B B′} → A ⊃ B ≡ A′ ⊃ B′ → B ≡ B′ inj₂⊃ refl = refl _≟𝒯_ : (A A′ : 𝒯) → Dec (A ≡ A′) • ≟𝒯 • = yes refl • ≟𝒯 (A′ ⊃ B′) = no λ () (A ⊃ B) ≟𝒯 • = no λ () (A ⊃ B) ≟𝒯 (A′ ⊃ B′) with A ≟𝒯 A′ | B ≟𝒯 B′ … | yes refl | yes refl = yes refl … | yes refl | no B≢B′ = no (λ p → inj₂⊃ p ↯ B≢B′) … | no A≢A′ | _ = no (λ p → inj₁⊃ p ↯ A≢A′) -- 3.2. Definition of contexts -- --------------------------- -- -- Suppose a countably infinite set, `Name`, with names together with a decidable equality on it. -- The set of contexts `𝒞` is mutually defined with a boolean-valued function `fresh` which describes -- when a name is fresh in a context. (…) -- -- Ordinarily, the freshness condition is written as a side-condition, but since we are to -- formalise the proof trees, this information must be represented, too. -- -- We write `[]` for the empty context and `[ Γ , x ∷ A ]` for adding an element to a context, -- hence when we write `[ Γ , x ∷ A ]` -- it is implicit that we also have a proof that `x` is fresh in `Γ` (when `[ Γ , x ∷ A ]` occurs in the -- conclusion of a statement, then it is implicit that `T (fresh x Γ)` is an assumption.) The -- function `fresh` is defined by induction on the context as: mutual data 𝒞 : Set where [] : 𝒞 [_,_∷_] : (Γ : 𝒞) (x : Name) {{_ : T (fresh x Γ)}} → 𝒯 → 𝒞 fresh : Name → 𝒞 → Bool fresh x [] = true fresh x [ Γ , y ∷ A ] = and (x ≠ y) (fresh x Γ) -- We use `Γ`, `Δ` and `Θ` for contexts. -- -- The predicate `Γ ∋ x ∷ A` is true when a name with its type occurs in a context. -- -- The introduction rules are: data _∋_∷_ : 𝒞 → Name → 𝒯 → Set where zero : ∀ {Γ A x} {{_ : T (fresh x Γ)}} → [ Γ , x ∷ A ] ∋ x ∷ A suc : ∀ {Γ A B x y} {{_ : T (fresh y Γ)}} → Γ ∋ x ∷ A → [ Γ , y ∷ B ] ∋ x ∷ A module _ where injsuc : ∀ {Γ A B x y} {{_ : T (fresh y Γ)}} {i i′ : Γ ∋ x ∷ A} → suc {B = B} {y = y} i ≡ suc i′ → i ≡ i′ injsuc refl = refl _≟∋_ : ∀ {Γ A x} → (i i′ : Γ ∋ x ∷ A) → Dec (i ≡ i′) zero ≟∋ zero = yes refl zero ≟∋ suc i′ = no (λ ()) suc i ≟∋ zero = no (λ ()) suc i ≟∋ suc i′ with i ≟∋ i′ … | yes refl = yes refl … | no i≢i′ = no (λ p → injsuc p ↯ i≢i′) module _ where _∌_∷_ : 𝒞 → Name → 𝒯 → Set Γ ∌ x ∷ A = ¬ (Γ ∋ x ∷ A) fresh→∌ : ∀ {x Γ A} {{_ : T (fresh x Γ)}} → Γ ∌ x ∷ A fresh→∌ {x} {{φ}} zero with x ≟ x fresh→∌ {x} {{()}} zero | yes refl fresh→∌ {x} {{φ}} zero | no x≢x = refl ↯ x≢x fresh→∌ {x} {{φ}} (suc {y = y} i) with x ≟ y fresh→∌ {x} {{()}} (suc {y = .x} i) | yes refl fresh→∌ {x} {{φ}} (suc {y = y} i) | no x≢y = i ↯ fresh→∌ freshlem₁ : ∀ {b′} → (x : Name) → ¬ (T (and (x ≠ x) b′)) freshlem₁ x p with x ≟ x … | yes refl = p … | no x≢x = refl ↯ x≢x freshlem₂ : ∀ {b′} → (x {y} : Name) → T (and (x ≠ y) b′) → T b′ freshlem₂ x {y} p with x ≟ y … | yes refl = elim⊥ p … | no x≢y = p -- We also define the relation that describes when a context contains another. -- -- We use the notational convention `Γ ⊇ Δ` for `Γ` being greater than `Δ`. -- The set `_⊇_` has the constructors: infix 3 _⊇_ data _⊇_ : 𝒞 → 𝒞 → Set where done : ∀ {Γ} → Γ ⊇ [] step : ∀ {Γ Δ A x} {{_ : T (fresh x Δ)}} → Γ ⊇ Δ → Γ ∋ x ∷ A → Γ ⊇ [ Δ , x ∷ A ] module _ where inj₁step : ∀ {Γ Δ A x} {{_ : T (fresh x Δ)}} {c c′ : Γ ⊇ Δ} {i i′ : Γ ∋ x ∷ A} → step c i ≡ step c′ i′ → c ≡ c′ inj₁step refl = refl inj₂step : ∀ {Γ Δ A x} {{_ : T (fresh x Δ)}} {c c′ : Γ ⊇ Δ} {i i′ : Γ ∋ x ∷ A} → step c i ≡ step c′ i′ → i ≡ i′ inj₂step refl = refl _≟⊇_ : ∀ {Γ Δ} → (c c′ : Γ ⊇ Δ) → Dec (c ≡ c′) done ≟⊇ done = yes refl step c i ≟⊇ step c′ i′ with c ≟⊇ c′ | i ≟∋ i′ … | yes refl | yes refl = yes refl … | yes refl | no i≢i′ = no (λ p → inj₂step p ↯ i≢i′) … | no c≢c′ | _ = no (λ p → inj₁step p ↯ c≢c′) -- The following lemmas are easy to prove: -- Lemma 1. ext⊇ : ∀ {Δ Γ} → (∀ {A x} → Δ ∋ x ∷ A → Γ ∋ x ∷ A) → Γ ⊇ Δ ext⊇ {[]} f = done ext⊇ {[ Δ , x ∷ A ]} f = step (ext⊇ (λ i → f (suc i))) (f zero) -- Lemma 2. module _ where ↑⟨_⟩∋ : ∀ {Γ Δ A x} → Δ ⊇ Γ → Γ ∋ x ∷ A → Δ ∋ x ∷ A ↑⟨ done ⟩∋ () ↑⟨ step c i ⟩∋ zero = i ↑⟨ step c i ⟩∋ (suc j) = ↑⟨ c ⟩∋ j instance raise∋ : ∀ {A x} → Raiseable (_∋ x ∷ A) raise∋ = record { ↑⟨_⟩ = ↑⟨_⟩∋ } -- Lemma 3. refl⊇ : ∀ {Γ} → Γ ⊇ Γ refl⊇ = ext⊇ id -- Lemma 4. module _ where _○_ : ∀ {Γ Δ Θ} → Γ ⊇ Δ → Θ ⊇ Γ → Θ ⊇ Δ c ○ c′ = ext⊇ (λ i → ↑⟨ c′ ⟩ (↑⟨ c ⟩ i)) trans⊇ : ∀ {Γ Δ Θ} → Θ ⊇ Γ → Γ ⊇ Δ → Θ ⊇ Δ trans⊇ = flip _○_ -- Lemma 5. weak⊇ : ∀ {Γ A x} {{_ : T (fresh x Γ)}} → [ Γ , x ∷ A ] ⊇ Γ weak⊇ = ext⊇ suc -- Lemma 6. uniq∋ : ∀ {Γ A x} → (i i′ : Γ ∋ x ∷ A) → i ≡ i′ uniq∋ zero zero = refl uniq∋ zero (suc i′) = i′ ↯ fresh→∌ uniq∋ (suc i) zero = i ↯ fresh→∌ uniq∋ (suc i) (suc i′) = cong suc (uniq∋ i i′) -- Lemma 7. uniq⊇ : ∀ {Γ Δ} → (c c′ : Γ ⊇ Δ) → c ≡ c′ uniq⊇ done done = refl uniq⊇ (step c i) (step c′ i′) = cong² step (uniq⊇ c c′) (uniq∋ i i′) -- `ext⊇`, `↑⟨_⟩∋` and `uniq⊇` are proven by induction on `Δ` and `uniq∋` is proven by -- induction on `Γ`. `refl⊇` and `weak⊇` are direct consequences of `ext⊇` and for `trans⊇` -- we also use `↑⟨_⟩∋`. (…) -- -- The last two lemmas may seem slightly strange: they are used for guaranteeing independence -- of the proofs of `_∋_∷_` and `_⊇_`. For example, `uniq∋` says that if it can be shown that -- `x ∷ A` occurs in a context `Γ`, then there is a unique proof of this fact. The need to prove -- independence of proofs might point to a problem in using type theory for formalising proofs. On -- the other hand, as we shall see, proof objects can also be useful: the present formalisation -- heavily uses the possibilities to perform case analysis on proof objects, which reduces the -- number of cases to consider. module _ where id₁○ : ∀ {Γ Δ} → (c : Γ ⊇ Γ) (c′ : Δ ⊇ Γ) → c ○ c′ ≡ c′ id₁○ c c′ = uniq⊇ (c ○ c′) c′ id₂○ : ∀ {Γ Δ} → (c : Δ ⊇ Γ) (c′ : Δ ⊇ Δ) → c ○ c′ ≡ c id₂○ c c′ = uniq⊇ (c ○ c′) c assoc○ : ∀ {Γ Δ Θ Ω} → (c : Δ ⊇ Γ) (c′ : Θ ⊇ Δ) (c″ : Ω ⊇ Θ) → c ○ (c′ ○ c″) ≡ (c ○ c′) ○ c″ assoc○ c c′ c″ = uniq⊇ (c ○ (c′ ○ c″)) ((c ○ c′) ○ c″) comp○ : ∀ {Γ Δ Θ} → (c : Δ ⊇ Γ) (c′ : Θ ⊇ Δ) (c″ : Θ ⊇ Γ) → c ○ c′ ≡ c″ comp○ c c′ c″ = uniq⊇ (c ○ c′) c″ -- 3.3. Definition of proof trees -- ------------------------------ -- -- Proof trees and substitutions are mutually inductively defined. (…) -- -- We use the notational convention `Γ ⊢ A` and `Δ ⋙ Γ` for a proof of `A` in context `Γ` and -- a substitution of `Γ` by `Δ`, respectively. -- -- A substitution of type `Δ ⋙ Γ` intuitively is a list that associates to each `x ∷ A` in `Γ` a unique -- proof tree of type `Δ ⊢ A`. -- -- The proof trees are defined by the following rules. -- -- We recall that hidden assumptions in the definition above are implicitly universally defined -- and that the notation `[ Γ , x ∷ A ]` implies that `x` is fresh in `Γ`. (…) -- -- In the definition of variables we can see that a proof of occurrence is part of the proof -- tree. The advantage is that we can do case-analysis on this proof to find out where in the -- context `x ∷ A` occurs. The disadvantage is that we need to prove that two variables are the -- same even if they have two possibly different proofs of occurrence of `x ∷ A` (by Lemma 6 we -- know that the proofs are the same). mutual infix 3 _⊢_ data _⊢_ : 𝒞 → 𝒯 → Set where ν : ∀ {Γ A} → (x : Name) → Γ ∋ x ∷ A → Γ ⊢ A ƛ : ∀ {Γ A B} → (x : Name) {{_ : T (fresh x Γ)}} → [ Γ , x ∷ A ] ⊢ B → Γ ⊢ A ⊃ B _∙_ : ∀ {Γ A B} → Γ ⊢ A ⊃ B → Γ ⊢ A → Γ ⊢ B _▶_ : ∀ {Γ Δ A} → Γ ⊢ A → Δ ⋙ Γ → Δ ⊢ A infix 3 _⋙_ data _⋙_ : 𝒞 → 𝒞 → Set where π⟨_⟩ : ∀ {Γ Δ} → Δ ⊇ Γ → Δ ⋙ Γ _●_ : ∀ {Γ Δ Θ} → Γ ⋙ Δ → Θ ⋙ Γ → Θ ⋙ Δ [_,_≔_] : ∀ {Γ Δ A} → Δ ⋙ Γ → (x : Name) {{_ : T (fresh x Γ)}} → Δ ⊢ A → Δ ⋙ [ Γ , x ∷ A ] -- Explicit substitutions are built from a projection map, update and composition (see below -- for a discussion on the projection map). -- -- We use the following notational conventions: -- -- - `ν x` for referencing the occurrence `x`, where `x : Γ ∋ x ∷ A` -- - `M ▶ γ` for applying the substitution `γ` to the term `M` -- - `ƛ x M` for abstracting the occurrence `x` from the term `M`, where `M : [ Γ , x ∷ A ] ⊢ B` -- - `M ∙ N` for applying the term `M` to the term `N` -- - `π⟨ c ⟩` for projecting the inclusion `c` as a substitution -- - `[ γ , x ≔ M ]` for updating the substitution `γ` with the term `M` for the occurrence `x` -- - `γ ● δ` for composing the substitution `δ` with the substitution `γ` -- -- Proof trees and substitutions are named `M, N` and `γ, δ, θ` respectively. -- -- The substitution `π⟨_⟩` is not a standard primitive for explicit substitutions. Often one rather -- has an identity substitution (in `Γ ⋙ Γ`) [1, 13] or the empty substitution (in `Γ ⋙ []`) [5]. -- Instead we have taken `π⟨_⟩` as primitive. If `c : Γ ⊇ Γ`, then `π⟨ c ⟩` is the identity substitution and -- if `c : Γ ⊇ []`, then `π⟨ c ⟩` is the empty substitution. Abadi et al. [1] use a substitution `↑` that -- corresponds to a shift on substitutions; the same substitution is here defined as `π⟨ c ⟩` where -- `c : [ Γ , x ∷ A ] ⊇ Γ`. In Martin-Löf’s substitution calculus [13, 20] we have as primitives also -- thinning rules (i.e., if a term is well-typed in a given context, then it is also well-typed in a -- larger context and likewise for substitutions.) Here, thinning is achieved using `π⟨_⟩`, since if, -- for example, `M : Γ ⊢ A` and `c : Δ ⊇ Γ`, then `M ▶ π⟨ c ⟩ : Δ ⊢ A`. -- -- The first version of our work used combinators for the thinning rules, since we wanted it to -- be a start for a complete mechanical analysis of Martin-Löf’s substitution calculus [13, 20]. -- The set of conversion rules we obtained using these combinators suggested the use of `π⟨_⟩`, -- which gives fewer conversion rules. There might be other advantages in using `π⟨_⟩`: if a proof -- tree is of the form `M ▶ π⟨_⟩` we know which are the possible free variables of the term `M`, -- information that might be used in a computation. module _ where ↑⟨_⟩⊢ : ∀ {Γ Δ A} → Δ ⊇ Γ → Γ ⊢ A → Δ ⊢ A ↑⟨ c ⟩⊢ M = M ▶ π⟨ c ⟩ ↑⟨_⟩⋙ : ∀ {Γ Δ Θ} → Δ ⊇ Γ → Γ ⋙ Θ → Δ ⋙ Θ ↑⟨ c ⟩⋙ δ = δ ● π⟨ c ⟩ ↓⟨_⟩⋙ : ∀ {Γ Δ Θ} → Δ ⊇ Γ → Θ ⋙ Δ → Θ ⋙ Γ ↓⟨ c ⟩⋙ δ = π⟨ c ⟩ ● δ refl⋙ : ∀ {Γ} → Γ ⋙ Γ refl⋙ = π⟨ refl⊇ ⟩ trans⋙ : ∀ {Γ Δ Θ} → Θ ⋙ Γ → Γ ⋙ Δ → Θ ⋙ Δ trans⋙ = flip _●_ weak⋙ : ∀ {Γ A x} {{_ : T (fresh x Γ)}} → [ Γ , x ∷ A ] ⋙ Γ weak⋙ = π⟨ weak⊇ ⟩ instance raise⊢ : ∀ {A} → Raiseable (_⊢ A) raise⊢ = record { ↑⟨_⟩ = ↑⟨_⟩⊢ } raise⋙ : ∀ {Γ} → Raiseable (_⋙ Γ) raise⋙ = record { ↑⟨_⟩ = ↑⟨_⟩⋙ } lower⋙ : ∀ {Δ} → Lowerable (Δ ⋙_) lower⋙ = record { ↓⟨_⟩ = ↓⟨_⟩⋙ } -- 3.4. Convertibility of proof trees -- ---------------------------------- -- -- The rules for conversion between proof trees and substitutions are inductively defined. -- -- We use the notational convention `M ≅ N` and `γ ≅ₛ δ` for convertibility on proof trees and -- on substitutions respectively. (…) -- -- The conversion rules for proof trees are the reflexivity, symmetry, transitivity, congruence -- rules and the following rules: mutual infix 3 _≅_ data _≅_ : ∀ {Γ A} → Γ ⊢ A → Γ ⊢ A → Set where refl≅ : ∀ {Γ A} {M : Γ ⊢ A} → M ≅ M sym≅ : ∀ {Γ A} {M M′ : Γ ⊢ A} → M ≅ M′ → M′ ≅ M trans≅ : ∀ {Γ A} {M M′ M″ : Γ ⊢ A} → M ≅ M′ → M′ ≅ M″ → M ≅ M″ congƛ≅ : ∀ {Γ A B x} {{_ : T (fresh x Γ)}} {M M′ : [ Γ , x ∷ A ] ⊢ B} → M ≅ M′ → ƛ x M ≅ ƛ x M′ cong∙≅ : ∀ {Γ A B} {M M′ : Γ ⊢ A ⊃ B} {N N′ : Γ ⊢ A} → M ≅ M′ → N ≅ N′ → M ∙ N ≅ M′ ∙ N′ cong▶≅ : ∀ {Γ Δ A} {M M′ : Γ ⊢ A} {γ γ′ : Δ ⋙ Γ} → M ≅ M′ → γ ≅ₛ γ′ → M ▶ γ ≅ M′ ▶ γ′ conv₁≅ : ∀ {Γ Δ A B x} {{_ : T (fresh x Γ)}} → (M : [ Γ , x ∷ A ] ⊢ B) (N : Δ ⊢ A) (γ : Δ ⋙ Γ) → (ƛ x M ▶ γ) ∙ N ≅ M ▶ [ γ , x ≔ N ] conv₂≅ : ∀ {Γ A B x} {{_ : T (fresh x Γ)}} → (c : [ Γ , x ∷ A ] ⊇ Γ) (M : Γ ⊢ A ⊃ B) → M ≅ ƛ x ((M ▶ π⟨ c ⟩) ∙ ν x zero) conv₃≅ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} → (M : Δ ⊢ A) (γ : Δ ⋙ Γ) → ν x zero ▶ [ γ , x ≔ M ] ≅ M conv₄≅ : ∀ {Γ Δ A x} → (c : Δ ⊇ Γ) (i : Γ ∋ x ∷ A) (j : Δ ∋ x ∷ A) → ν x i ▶ π⟨ c ⟩ ≅ ν x j conv₅≅ : ∀ {Γ A} → (c : Γ ⊇ Γ) (M : Γ ⊢ A) → M ▶ π⟨ c ⟩ ≅ M conv₆≅ : ∀ {Γ Δ A B} → (M : Γ ⊢ A ⊃ B) (N : Γ ⊢ A) (γ : Δ ⋙ Γ) → (M ∙ N) ▶ γ ≅ (M ▶ γ) ∙ (N ▶ γ) conv₇≅ : ∀ {Γ Δ Θ A} → (M : Γ ⊢ A) (γ : Δ ⋙ Γ) (δ : Θ ⋙ Δ) → (M ▶ γ) ▶ δ ≅ M ▶ (γ ● δ) infix 3 _≅ₛ_ data _≅ₛ_ : ∀ {Γ Δ} → Δ ⋙ Γ → Δ ⋙ Γ → Set where refl≅ₛ : ∀ {Γ Δ} {γ : Δ ⋙ Γ} → γ ≅ₛ γ sym≅ₛ : ∀ {Γ Δ} {γ γ′ : Δ ⋙ Γ} → γ ≅ₛ γ′ → γ′ ≅ₛ γ trans≅ₛ : ∀ {Γ Δ} {γ γ′ γ″ : Δ ⋙ Γ} → γ ≅ₛ γ′ → γ′ ≅ₛ γ″ → γ ≅ₛ γ″ cong●≅ₛ : ∀ {Γ Δ Θ} {γ γ′ : Δ ⋙ Γ} {δ δ′ : Θ ⋙ Δ} → γ ≅ₛ γ′ → δ ≅ₛ δ′ → γ ● δ ≅ₛ γ′ ● δ′ cong≔≅ₛ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} {γ γ′ : Δ ⋙ Γ} {M M′ : Δ ⊢ A} → γ ≅ₛ γ′ → M ≅ M′ → [ γ , x ≔ M ] ≅ₛ [ γ′ , x ≔ M′ ] conv₁≅ₛ : ∀ {Γ Δ Θ Ω} → (γ : Δ ⋙ Γ) (δ : Θ ⋙ Δ) (θ : Ω ⋙ Θ) → (γ ● δ) ● θ ≅ₛ γ ● (δ ● θ) conv₂≅ₛ : ∀ {Γ Δ Θ A x} {{_ : T (fresh x Γ)}} → (M : Δ ⊢ A) (γ : Δ ⋙ Γ) (δ : Θ ⋙ Δ) → [ γ , x ≔ M ] ● δ ≅ₛ [ γ ● δ , x ≔ M ▶ δ ] conv₃≅ₛ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} → (c : [ Γ , x ∷ A ] ⊇ Γ) (M : Δ ⊢ A) (γ : Δ ⋙ Γ) → π⟨ c ⟩ ● [ γ , x ≔ M ] ≅ₛ γ conv₄≅ₛ : ∀ {Γ Δ Θ} → (c : Θ ⊇ Γ) (c′ : Δ ⊇ Γ) (c″ : Θ ⊇ Δ) → π⟨ c′ ⟩ ● π⟨ c″ ⟩ ≅ₛ π⟨ c ⟩ conv₅≅ₛ : ∀ {Γ Δ} → (c : Δ ⊇ Δ) (γ : Δ ⋙ Γ) → γ ● π⟨ c ⟩ ≅ₛ γ conv₆≅ₛ : ∀ {Γ} → (c : Γ ⊇ []) (γ : Γ ⋙ []) → γ ≅ₛ π⟨ c ⟩ conv₇≅ₛ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} → (c : [ Γ , x ∷ A ] ⊇ Γ) (γ : Δ ⋙ [ Γ , x ∷ A ]) (i : [ Γ , x ∷ A ] ∋ x ∷ A) → γ ≅ₛ [ π⟨ c ⟩ ● γ , x ≔ ν x i ▶ γ ] -- The first two `conv≅` rules correspond to the ordinary β- and η-rules, the next three define the effect -- of substitutions and the last two rules can be seen as the correspondence of the η-rule for -- substitutions. The remaining `conv≅ₛ` rules define how the substitutions distribute. module _ where ≡→≅ : ∀ {Γ A} {M M′ : Γ ⊢ A} → M ≡ M′ → M ≅ M′ ≡→≅ refl = refl≅ module ≅-Reasoning where infix 1 begin_ begin_ : ∀ {Γ A} {M M′ : Γ ⊢ A} → M ≅ M′ → M ≅ M′ begin p = p infixr 2 _≅⟨⟩_ _≅⟨⟩_ : ∀ {Γ A} (M {M′} : Γ ⊢ A) → M ≅ M′ → M ≅ M′ M ≅⟨⟩ p = p infixr 2 _≅⟨_⟩_ _≅⟨_⟩_ : ∀ {Γ A} (M {M′ M″} : Γ ⊢ A) → M ≅ M′ → M′ ≅ M″ → M ≅ M″ M ≅⟨ p ⟩ p′ = trans≅ p p′ infixr 2 _≡⟨⟩_ _≡⟨⟩_ : ∀ {Γ A} (M {M′} : Γ ⊢ A) → M ≅ M′ → M ≅ M′ M ≡⟨⟩ p = p infixr 2 _≡⟨_⟩_ _≡⟨_⟩_ : ∀ {Γ A} (M {M′ M″} : Γ ⊢ A) → M ≡ M′ → M′ ≅ M″ → M ≅ M″ M ≡⟨ p ⟩ p′ = trans≅ (≡→≅ p) p′ infix 3 _∎ _∎ : ∀ {Γ A} (M : Γ ⊢ A) → M ≅ M M ∎ = refl≅ ≡→≅ₛ : ∀ {Γ Δ} {γ γ′ : Δ ⋙ Γ} → γ ≡ γ′ → γ ≅ₛ γ′ ≡→≅ₛ refl = refl≅ₛ module ≅ₛ-Reasoning where infix 1 begin_ begin_ : ∀ {Γ Δ} {γ γ′ : Δ ⋙ Γ} → γ ≅ₛ γ′ → γ ≅ₛ γ′ begin p = p infixr 2 _≅ₛ⟨⟩_ _≅ₛ⟨⟩_ : ∀ {Γ Δ} (γ {γ′} : Δ ⋙ Γ) → γ ≅ₛ γ′ → γ ≅ₛ γ′ γ ≅ₛ⟨⟩ p = p infixr 2 _≅ₛ⟨_⟩_ _≅ₛ⟨_⟩_ : ∀ {Γ Δ} (γ {γ′ γ″} : Δ ⋙ Γ) → γ ≅ₛ γ′ → γ′ ≅ₛ γ″ → γ ≅ₛ γ″ γ ≅ₛ⟨ p ⟩ p′ = trans≅ₛ p p′ infixr 2 _≡⟨⟩_ _≡⟨⟩_ : ∀ {Γ Δ} (γ {γ′} : Δ ⋙ Γ) → γ ≅ₛ γ′ → γ ≅ₛ γ′ γ ≡⟨⟩ p = p infixr 2 _≡⟨_⟩_ _≡⟨_⟩_ : ∀ {Γ Δ} (γ {γ′ γ″} : Δ ⋙ Γ) → γ ≡ γ′ → γ′ ≅ₛ γ″ → γ ≅ₛ γ″ γ ≡⟨ p ⟩ p′ = trans≅ₛ (≡→≅ₛ p) p′ infix 3 _∎ _∎ : ∀ {Γ Δ} (γ : Δ ⋙ Γ) → γ ≅ₛ γ γ ∎ = refl≅ₛ
src/keystore-passwords-files.ads
thierr26/ada-keystore
25
16384
<reponame>thierr26/ada-keystore ----------------------------------------------------------------------- -- keystore-passwords-files -- File based password provider -- Copyright (C) 2019 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Keystore.Passwords.Keys; package Keystore.Passwords.Files is MAX_FILE_SIZE : constant := 1024; DEFAULT_KEY_FILE_LENGTH : constant := 32 + 16 + 32; -- Create a password provider that reads the file to build the password. -- The file must have the mode rw------- (600) and its owning directory -- the mode rwx------ (700). The Bad_Password exception is raised if -- these rules are not verified. function Create (Path : in String) return Provider_Access; -- Create a key provider that reads the file. The file is split in three parts -- the key, the IV, the signature which are extracted by using `Get_Keys`. function Create (Path : in String) return Keys.Key_Provider_Access; -- Generate a file that contains the keys. Keys are generated using a random generator. -- The file is created with the mode rw------- (600) and the owning directory is forced -- to the mode rwx------ (700). function Generate (Path : in String; Length : in Key_Length := DEFAULT_KEY_FILE_LENGTH) return Keys.Key_Provider_Access; end Keystore.Passwords.Files;
1A/S5/PIM/projet/src/test_arbre_genealogique.adb
MOUDDENEHamza/ENSEEIHT
4
25718
-------------------------------------------------------------------------------- -- Fichier : display_shell.adb -- Auteur : <NAME> & <NAME> -- Objectif : Test du module Arbre_Genealogique -- Crée : Dimanche Nov 10 2019 -------------------------------------------------------------------------------- with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; with Ada.Text_IO; use Ada.Text_IO; with Arbre_Genealogique; use Arbre_Genealogique; procedure Test_Arbre_Genealogique is procedure Tester_Creer_Arbre_Minimal is Ab : T_ABG; Data : T_Node; begin Initialize_Data (Data, 1); Creer_Arbre_Minimal (Ab, Data); pragma assert (Nombre_Ancetres (Ab, 1) = 1); Supprimer (Ab, 1); New_Line; Put_Line (ESC & "[32m" & "RÉUSSI : " & ESC & "[0m" & "Procedure Creer_Arbre_Minimal est testée avec succés."); New_Line; end Tester_Creer_Arbre_Minimal; procedure Tester_ajouter_parent is Ab : T_ABG; Data : T_Node; begin Initialize_Data (Data, 1); Creer_Arbre_Minimal (Ab, Data); pragma assert (Nombre_Ancetres (Ab, 1) = 1); Initialize_Data (Data, 2); ajouter_parent (Ab, Data, 1, 0); pragma assert (Nombre_Ancetres (Ab, 1) = 2); Initialize_Data (Data, 3); ajouter_parent (Ab, Data, 1, 1); pragma assert (Nombre_Ancetres (Ab, 1) = 3); Initialize_Data (Data, 4); ajouter_parent (Ab, Data, 2, 0); pragma assert (Nombre_Ancetres (Ab, 1) = 4); Initialize_Data (Data, 5); ajouter_parent (Ab, Data, 2, 1); pragma assert (Nombre_Ancetres (Ab, 1) = 5); Initialize_Data (Data, 6); ajouter_parent (Ab, Data, 3, 0); pragma assert (Nombre_Ancetres (Ab, 1) = 6); Initialize_Data (Data, 7); ajouter_parent (Ab, Data, 3, 1); pragma assert (Nombre_Ancetres (Ab, 1) = 7); Initialize_Data (Data, 8); ajouter_parent (Ab, Data, 4, 0); pragma assert (Nombre_Ancetres (Ab, 1) = 8); Supprimer (Ab, 1); New_Line; Put_Line (ESC & "[32m" & "RÉUSSI : " & ESC & "[0m" & "Procedure ajouter_parent est testée avec succés."); New_Line; end Tester_ajouter_parent; procedure Tester_Nombre_Ancetres is Ab : T_ABG; Data : T_Node; begin Initialize_Data (Data, 1); Creer_Arbre_Minimal (Ab, Data); pragma assert (Nombre_Ancetres (Ab, 1) = 1); Initialize_Data (Data, 2); ajouter_parent (Ab, Data, 1, 0); pragma assert (Nombre_Ancetres (Ab, 1) = 2); Initialize_Data (Data, 4); ajouter_parent (Ab, Data, 2, 0); pragma assert (Nombre_Ancetres (Ab, 2) = 2); Supprimer (Ab, 1); New_Line; Put_Line (ESC & "[32m" & "RÉUSSI : " & ESC & "[0m" & "Procedure Nombre_Ancetres est testée avec succés."); New_Line; end Tester_Nombre_Ancetres; procedure Test_Supprimer is Ab : T_ABG; Data : T_Node; begin Initialize_Data (Data, 1); Creer_Arbre_Minimal (Ab, Data); pragma assert (Nombre_Ancetres (Ab, 1) = 1); Initialize_Data (Data, 2); ajouter_parent (Ab, Data, 1, 0); pragma assert (Nombre_Ancetres (Ab, 1) = 2); Initialize_Data (Data, 3); ajouter_parent (Ab, Data, 1, 1); pragma assert (Nombre_Ancetres (Ab, 1) = 3); Initialize_Data (Data, 4); ajouter_parent (Ab, Data, 2, 1); pragma assert (Nombre_Ancetres (Ab, 1) = 4); Initialize_Data (Data, 5); ajouter_parent (Ab, Data, 3, 0); pragma assert (Nombre_Ancetres (Ab, 1) = 5); Supprimer (Ab, 2); pragma assert (Nombre_Ancetres (Ab, 1) = 3); Supprimer (Ab, 5); pragma assert (Nombre_Ancetres (Ab, 1) = 2); Supprimer (Ab, 1); New_Line; Put_Line (ESC & "[32m" & "RÉUSSI : " & ESC & "[0m" & "Procedure Supprimer est testée avec succés."); New_Line; end Test_Supprimer; procedure Tester_Ancetres_N_Generation is Ab : T_ABG; Data : T_Node; begin Initialize_Data (Data, 1); Creer_Arbre_Minimal (Ab, Data); pragma assert (Nombre_Ancetres (Ab, 1) = 1); Initialize_Data (Data, 2); ajouter_parent (Ab, Data, 1, 0); Initialize_Data (Data, 3); ajouter_parent (Ab, Data, 1, 1); Supprimer (Ab, 1); New_Line; Put_Line (ESC & "[32m" & "RÉUSSI : " & ESC & "[0m" & "Procedure Ancetres_N_Generations est testée avec succés."); New_Line; end Tester_Ancetres_N_Generation; procedure Tester_Individus_1_Parent_Connu is Ab : T_ABG; Data : T_Node; begin Initialize_Data (Data, 1); Creer_Arbre_Minimal (Ab, Data); Initialize_Data (Data, 2); ajouter_parent (Ab, Data, 1, 0); Initialize_Data (Data, 3); ajouter_parent (Ab, Data, 1, 1); Initialize_Data (Data, 4); ajouter_parent (Ab, Data, 2, 0); Supprimer (Ab, 1); New_Line; Put_Line (ESC & "[32m" & "RÉUSSI : " & ESC & "[0m" & "Procedure Individus_1_Parent_Connu est testée avec succés."); New_Line; end Tester_Individus_1_Parent_Connu; procedure Tester_Individus_2_Parent_Connu is Ab : T_ABG; Data : T_Node; begin Initialize_Data (Data, 1); Creer_Arbre_Minimal (Ab, Data); Initialize_Data (Data, 2); ajouter_parent (Ab, Data, 1, 0); Initialize_Data (Data, 3); ajouter_parent (Ab, Data, 1, 1); Initialize_Data (Data, 4); ajouter_parent (Ab, Data, 2, 0); Supprimer (Ab, 1); New_Line; Put_Line (ESC & "[32m" & "RÉUSSI : " & ESC & "[0m" & "Procedure Individus_2_Parent_Connu est testée avec succés."); New_Line; end Tester_Individus_2_Parent_Connu; procedure Tester_Ensemble_Feuilles is Ab : T_ABG; Data : T_Node; begin Initialize_Data (Data, 1); Creer_Arbre_Minimal (Ab, Data); Initialize_Data (Data, 2); ajouter_parent (Ab, Data, 1, 0); Initialize_Data (Data, 3); ajouter_parent (Ab, Data, 1, 1); Initialize_Data (Data, 4); ajouter_parent (Ab, Data, 2, 0); Supprimer (Ab, 1); New_Line; Put_Line (ESC & "[32m" & "RÉUSSI : " & ESC & "[0m" & "Procedure Ensemble_Feuilles est testée avec succés."); New_Line; end Tester_Ensemble_Feuilles; begin New_Line; Put_Line("*************************** Début ****************************"); New_Line; -- Tester Creer_Arbre_Minimal. Tester_Creer_Arbre_Minimal; -- Tester Ajouter_Parent. Tester_Ajouter_Parent; -- Tester Nombre_Ancetres. Tester_Nombre_Ancetres; -- Tester Supprimer. Test_Supprimer; -- TesterAncetres_N_Generation. Tester_Ancetres_N_Generation; -- Tester Individus_1_Parent_Connu. Tester_Individus_1_Parent_Connu; -- Tester Individus_2_Parent_Connu. Tester_Individus_2_Parent_Connu; -- Tester_Ensemble_Feuilles. Tester_Ensemble_Feuilles; New_Line; Put_Line("***************************** Fin ****************************"); New_Line; end Test_Arbre_Genealogique;
Cypress/PSoC/USER_COMPONENTS/LED_SegDriver/TestBench.cydsn/codegentemp/KeilStart.a51
RyanTruran/EmbeddedSystems.Playground
26
160031
;******************************************************************************* ; FILENAME: KeilStart.a51 ; Version 2.40 ; ; DESCRIPTION: ; Bootup Code for PSoC3 chips using the Keil toolchain. ; ; NOTE: ; ; ; ;******************************************************************************* ; Copyright 2008-2011, Cypress Semiconductor Corporation. All rights reserved. ; You may use this file only in accordance with the license, terms, conditions, ; disclaimers, and limitations in the end user license agreement accompanying ; the software package with which this file was provided. ;******************************************************************************* ;* We will supply our own register definitions. $NOMOD51 ;* PSoC Register definitions. $INCLUDE (PSoC3_8051.inc) $INCLUDE (cydevicekeil_trm.inc) ;* Application-specific definitions. $INCLUDE (cyfitterkeil.inc) EXTERN XDATA:BYTE (CyResetStatus) ZERO_REG EQU CYREG_PHUB_CFGMEM23_CFG1 SIZEOF_IDATA EQU 100h _CyResetStatus EQU CYDEV_SRAM_SIZE - 1 ;Keeps track of the RESET_SRO status across induced reset _CyResetInduced EQU CYDEV_SRAM_SIZE - 2 ;Keeps track of whether we manually induced a reset IBPSTACK EQU 0 XBPSTACK EQU 1 XBPSTACKTOP EQU CYDEV_SRAM_SIZE PBPSTACK EQU 0 ?C?XPAGE1SFR DATA 093h ?C?XPAGE1RST EQU 0 ;******************************************************************************* ;* Placement. ;******************************************************************************* NAME ?C_STARTUP ?C_C51STARTUP SEGMENT CODE ?STACK SEGMENT IDATA RSEG ?STACK DS 1 ; Declare some data so the assembler will keep the labeled segment. EXTRN CODE (?C_START) EXTRN CODE (cyfitter_cfg) EXTRN CODE (CyDmacConfigure) IF CYDEV_BOOTLOADER_ENABLE <> 0 EXTRN CODE (CyBtldr_CheckLaunch) ENDIF PUBLIC ?C_STARTUP, ?C?XPAGE1SFR, ?C?XPAGE1RST PUBLIC STARTUP1 ; include STARTUP1 for bootloader ;******************************************************************************* ;* Reset vector. ;******************************************************************************* CSEG AT 0 ?C_STARTUP: ljmp STARTUP1 ; 3 bytes ;******************************************************************************* ;* Aligned routines ;******************************************************************************* ; The following routines require alignment to avoid crossing an 8-byte ; boundary in an inner loop. ; dma_wait ; Arguments: ; R6:R7 Address of BASIC_STATUS ; Waits for the CHAIN_ACTIVE bit to be cleared by the DMA controller. nop ; 1 byte PUBLIC _dma_wait _dma_wait: mov DPL, R7 ; 2 bytes mov DPH, R6 ; 2 bytes ; The loop needs to be aligned to an 8-byte boundary _dma_wait_loop: movx A, @DPTR ; 1 byte anl A, #01h ; 2 bytes CHAIN_ACTIVE nop ; 1 byte nop ; 1 byte nop ; 1 byte jnz _dma_wait_loop ; 2 bytes ret ; 1 byte ; clear_idata ; Arguments: None ; Writes zeros to IDATA. ; This code should not be called because it overwrites the call stack. clear_idata: mov R0, #SIZEOF_IDATA - 1 ; 2 bytes clr A ; 1 byte ; The loop needs to be aligned to a 4-byte boundary clear_idata_loop: mov @R0, A ; 1 byte djnz R0, clear_idata_loop ; 2 bytes ljmp clear_idata_done ; 3 bytes ;******************************************************************************* ;* Startup entry Point. ;******************************************************************************* RSEG ?C_C51STARTUP STARTUP1: mov ?C?XPAGE1SFR, #?C?XPAGE1RST ; Set XDATA page mov R0, #000 ; Set by debugger when attached to indicate not to perform reset IF CYDEV_DEBUGGING_ENABLE <> 0 mov DPH, #HIGH (CYDEV_DEBUG_ENABLE_REGISTER) mov DPL, #LOW (CYDEV_DEBUG_ENABLE_REGISTER) movx A, @DPTR orl A, #CYDEV_DEBUG_ENABLE_MASK movx @DPTR, A nop debugEnabled: ENDIF IF (CYDEV_CHIP_REVISION_USED > CYDEV_CHIP_REVISION_3A_ES2) IF (CYDEV_PROJ_TYPE <> CYDEV_PROJ_TYPE_LOADABLE) ; Handle case where Software Reset is needed in order to ensure NVLs have been setup properly on TO5 ; R0 - Used to indicate Debugger Attached ; R1 - Used to hold CYREG_MLOGIC_REV_ID value ; R2 - Used to hold CYREG_RESET_SR0 value (saved in CyResetStatus after clear RAM), ; also used by cybtldrhelper.a51 mov DPTR, #CYREG_MLOGIC_REV_ID movx A, @DPTR mov R1, A mov DPTR, #CYREG_RESET_SR0 movx A, @DPTR mov R2, A cjne R1, #003h, PERFORM_STARTUP ; Only reset on TO5 (rev=3) anl A, #020h cjne A, #000h, RESTORE_RESET_DATA ; If software reset, jump cjne R0, #000h, PERFORM_STARTUP ; Set by debugger when attached PERFORM_SW_RESET: mov A, R2 ; Save the Reset information mov DPTR, #_CyResetStatus movx @DPTR, A mov A, #001h mov DPTR, #_CyResetInduced movx @DPTR, A mov DPTR, #CYREG_RESET_CR2 ; Perform the Reset movx @DPTR, A RESTORE_RESET_DATA: ; Restore original Reset data mov DPTR, #_CyResetInduced movx A, @DPTR jz PERFORM_STARTUP mov DPTR, #_CyResetStatus movx A, @DPTR mov R2, A ; R2 used after SRAM clear, do not use!!! PERFORM_STARTUP: ENDIF ENDIF mov DPTR, #CYREG_CACHE_CR IF (CYDEV_CHIP_REVISION_USED == CYDEV_CHIP_REVISION_3A_ES1 OR CYDEV_CHIP_REVISION_USED == CYDEV_CHIP_REVISION_3A_ES2) IF (CYDEV_CONFIGURATION_IMOENABLED <> 0) mov A, #(02h SHL 6) ; FLASH_CYCLES = 2 (3 cycles, up to 48MHz) ELSE mov A, #(01h SHL 6) ; FLASH_CYCLES = 1 (2 cycles, up to 24MHz) ENDIF ELSE IF (CYDEV_CONFIGURATION_IMOENABLED <> 0) mov A, #(03h SHL 6) ; FLASH_CYCLES = 3 (3 cycles, up to 67MHz) ELSE mov A, #(01h SHL 6) ; FLASH_CYCLES = 1 (1 cycle, up to 22MHz) ENDIF ENDIF movx @DPTR, A mov sp, #?STACK-1 ; Set the stack pointer. IF CYDEV_BOOTLOADER_ENABLE <> 0 ;* check if need to start loadable application, bootloaders always do this check first so ;* that the device does not get configured before we launch the user application which ;* has its own unique configuration lcall CyBtldr_CheckLaunch Btldr_NoLaunch: ENDIF IF (CYDEV_CONFIGURATION_CLEAR_SRAM <> 0) IF (CYDEV_CONFIGURATION_DMA == 0) ;* Clear SRAM using CPU mov DPTR, #CYDEV_SRAM_BASE mov R0, #LOW (CYDEV_SRAM_SIZE) mov R1, #HIGH (CYDEV_SRAM_SIZE) clr A INIT_SRAM: movx @DPTR, A inc DPTR djnz R0, INIT_SRAM djnz R1, INIT_SRAM ; Assumes CYDEV_SRAM_SIZE is at least 256 bytes ELSE ;* Clear SRAM using DMA mov DPTR, #ZERO_REG clr A movx @DPTR, A inc DPTR movx @DPTR, A inc DPTR movx @DPTR, A inc DPTR movx @DPTR, A mov DPTR, #CYREG_PHUB_CH0_BASIC_CFG movx @DPTR, A ; Make sure channel is disabled mov DPTR, #(CYREG_PHUB_CH0_BASIC_STATUS + 1) movx @DPTR, A ; Initial TD 0 mov DPTR, #CYREG_PHUB_CH1_BASIC_CFG movx @DPTR, A ; Disable channel ;* CFGMEM0 Setup mov DPTR, #CYREG_PHUB_CFGMEM0_CFG0 mov A, #010h ; burstcnt movx @DPTR, A mov DPTR, #CYREG_PHUB_CFGMEM0_CFG1 clr A movx @DPTR, A ; src_base_adr low inc DPTR movx @DPTR, A ; src_base_adr high inc DPTR movx @DPTR, A ; dst_base_adr low inc DPTR movx @DPTR, A ; dst_base_adr high ;* TD configuration mov DPTR, #CYREG_PHUB_TDMEM0_ORIG_TD0 mov R0, #000h ; R0 tracks next TD SETUP_TD: inc R0 mov A, #000h movx @DPTR, A ; Set TD count (lower byte) inc DPTR mov A, #08h movx @DPTR, A ; Set TD count (upper byte) mov A, R0 cjne R0, #((CYDEV_SRAM_SIZE + 2047) / 2048), SETUP_ADDR mov A, #0FFh SETUP_ADDR: inc DPTR movx @DPTR, A ; Set Next TD inc DPTR mov A, #022h ; auto_exec_next, inc_dst_adr movx @DPTR, A ; Set TD Configuration inc DPTR mov A, #LOW ZERO_REG movx @DPTR, A ; Set Source Addr Low inc DPTR mov A, #HIGH ZERO_REG movx @DPTR, A ; Set Source Addr High inc DPTR clr A movx @DPTR, A ; Set Destination Addr Low inc DPTR mov A, R0 dec A mov B, #008h mul AB movx @DPTR, A ; Set Destination Addr High inc DPTR cjne R0, #((CYDEV_SRAM_SIZE + 2047) / 2048), SETUP_TD ;* Start DMA mov DPTR, #CYREG_PHUB_CH0_BASIC_CFG mov A, #01h movx @DPTR, A mov DPTR, #CYREG_PHUB_CH0_ACTION movx @DPTR, A ENDIF ENDIF IF (CYDEV_CHIP_MEMBER_USED == CYDEV_CHIP_MEMBER_3A AND CYDEV_ECC_ENABLE <> 0) ;* Workaround for an issue that could cause a false ECC interrupt at startup mov DPTR, #CYREG_CACHE_INT_LOG3 movx A, @DPTR ; clear CACHE_INT_LOG3 (clear on read) mov DPTR, #CYREG_CACHE_INT_LOG4 movx A, @DPTR ; clear CACHE_INT_LOG4 (clear on read) mov DPTR, #CYREG_INTC_CLR_PD0 mov A, #02h movx @DPTR, A ; clear interrupt 1 ENDIF IF ((CYDEV_CONFIGURATION_CLEAR_SRAM <> 0) AND (CYDEV_CONFIGURATION_DMA <> 0)) ;* Wait for DMA to finish mov R6, #HIGH CYREG_PHUB_CH0_BASIC_STATUS mov R7, #LOW CYREG_PHUB_CH0_BASIC_STATUS lcall _dma_wait mov DPTR, #CYREG_PHUB_CH0_BASIC_CFG movx @DPTR, A ; Disable channel ENDIF ; Save the RESET_SR0 register in the CyResetStatus variable mov A, R2 ; R2 set prior to SRAM clearing mov DPTR, #CyResetStatus movx @DPTR, A ;* Clear idata. ljmp clear_idata clear_idata_done: IF IBPSTACK <> 0 EXTRN DATA (?C_IBP) ;* ?C_IBP acts as a base pointer to the reentrant stack for the SMALL model. mov ?C_IBP, #LOW IBPSTACKTOP ENDIF IF XBPSTACK <> 0 EXTRN DATA (?C_XBP) ;* ?C_XBP acts as a base pointer to the reentrant stack for the LARGE model. mov ?C_XBP, #HIGH XBPSTACKTOP mov ?C_XBP+1, #LOW XBPSTACKTOP ENDIF IF PBPSTACK <> 0 EXTRN DATA (?C_PBP) ;* ?C_XBP acts as a base pointer to the reentrant stack for the COMPACT model. mov ?C_PBP, #LOW PBPSTACKTOP ENDIF ;* Initialize the configuration registers. lcall cyfitter_cfg ;* Setup DMA. lcall CyDmacConfigure ;* Jump to Keil's variable initialization and then main. ljmp ?C_START ;******************************************************************************* ;* End of startup code. ;******************************************************************************* END
test/Succeed/LocalOpenImplicit.agda
shlevy/agda
1,989
7535
module LocalOpenImplicit where record Id (a : Set) : Set where field id : a -> a foo : {a b : Set} -> Id a -> Id b -> (a -> b) -> a -> b foo id1 id2 f x = id id2 (f (id id1 x)) where open Id
src/opencl/opencl_api_spec.ads
sebsgit/textproc
0
14986
<gh_stars>0 with System; with Interfaces.C; with dl_loader; package opencl_api_spec is pragma Elaborate_Body; function Load_From(h: dl_loader.Handle) return Boolean; clGetPlatformIDs: System.Address; clGetPlatformInfo: System.Address; clGetDeviceIDs: System.Address; clGetDeviceInfo: System.Address; clCreateContext: System.Address; clReleaseContext: System.Address; clCreateProgramWithSource: System.Address; clBuildProgram: System.Address; clGetProgramBuildInfo: System.Address; clReleaseProgram: System.Address; clCreateKernel: System.Address; clReleaseKernel: System.Address; clSetKernelArg: System.Address; clEnqueueNDRangeKernel: System.Address; clReleaseMemObject: System.Address; clCreateBuffer: System.Address; clEnqueueReadBuffer: System.Address; clEnqueueWriteBuffer: System.Address; clCreateCommandQueueWithProperties: System.Address; clReleaseCommandQueue: System.Address; clWaitForEvents: System.Address; clRetainEvent: System.Address; clReleaseEvent: System.Address; clFinish: System.Address; end opencl_api_spec;
libsrc/stdio/ansi/x1/f_ansi_scrollup.asm
jpoikela/z88dk
0
161080
<reponame>jpoikela/z88dk<filename>libsrc/stdio/ansi/x1/f_ansi_scrollup.asm ; ; ANSI Video handling for the Commodore 128 (Z80 mode) ; By <NAME> - 22/08/2001 ; ; Scrollup ; ; ; $Id: f_ansi_scrollup.asm,v 1.6 2016-07-20 05:45:02 stefano Exp $ ; SECTION code_clib PUBLIC ansi_SCROLLUP EXTERN __x1_attr EXTERN ansicolumns .ansi_SCROLLUP ld de,$3000 ld bc,ansicolumns*24 ld a,ansicolumns ld h,d ld l,a push af cp 80 jr nz,outldir1 rl c rl b .outldir1 push bc ld b,h ld c,l in a,(c) ld b,d ld c,e out (c),a ld b,h ld c,l res 4,b in a,(c) ld b,d ld c,e res 4,b out (c),a pop bc inc hl inc de dec bc ld a,b or c jr nz,outldir1 ld h,d ld l,e pop af ld b,a .reslloop push bc ld b,h ld c,l ld a,32 out (c),a res 4,b ld a,(__x1_attr) out (c),a pop bc inc hl djnz reslloop ret
Ada/src/Problem_74.adb
Tim-Tom/project-euler
0
2669
<gh_stars>0 with Ada.Text_IO; package body Problem_74 is package IO renames Ada.Text_IO; factorial_cache : constant Array(0 .. 9) of Integer := (1, 1, 2, 6, 24, 120, 720, 5_040, 40_320, 362_880); type count is new Integer range -1 .. 127; for count'size use 8; type count_cache_array is Array(Positive range <>) of count; max : constant := 999_999; cache_size : constant := 362_880 * 6; count_cache : count_cache_array(1 .. cache_size) := (169 => 3, 871 => 2, 872 => 2, 1454 => 3, 363_601 => 3, 45_361 => 2, 45362 => 2, others => -1); sixty_count : Integer := 0; -- Dynamic programming brute force. Make a 2 megabyte array of counts with sentinal value (-1) -- for values we haven't seen before. Then just go through all the numbers and get their -- count. We were told in the problem description that the the longest chain is 60, so we know -- our stack won't die under the recursion. procedure Solve is function next(num : Positive) return Positive is f : Natural := 0; r : Natural range 0 .. 9; d : Positive := num; begin loop r := d mod 10; f := f + factorial_cache(r); exit when d < 10; d := d / 10; end loop; return f; end next; function fill(num : Positive) return count is next_num : constant Positive := next(num); begin if count_cache(num) = -1 then if next_num = num then count_cache(num) := 1; else count_cache(num) := 0; count_cache(num) := fill(next_num) + 1; end if; end if; return count_cache(num); end fill; begin for n in 2 .. max loop if fill(n) = 60 then sixty_count := sixty_count + 1; end if; end loop; IO.Put_Line(Integer'Image(sixty_count)); end Solve; end Problem_74;
tests/support/usb_testing-udc_stub.adb
JeremyGrosser/usb_embedded
0
1721
<gh_stars>0 ------------------------------------------------------------------------------ -- -- -- Copyright (C) 2018, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Hex_Dump; with System; use System; package body USB_Testing.UDC_Stub is procedure Check_Event (This : Controller'Class; Evt : UDC_Event); -- Raise an exception if the UDC event is not valid given the current -- configuration of the controller (e.g. data on stalled EP) procedure Do_Out_Transfer (This : in out Controller'Class; Ep : EP_Id; Len : UInt11); ----------------- -- Check_Event -- ----------------- procedure Check_Event (This : Controller'Class; Evt : UDC_Event) is Prefix : constant String := "UDC_Event error: "; begin case Evt.Kind is when Setup_Request => if Evt.Req_EP not in This.EPs'Range then raise Program_Error with Prefix & "Invalid EP id in Setup_Request"; end if; if not This.EPs (Evt.Req_EP) (EP_Out).Setup then raise Program_Error with Prefix & "EP not setup for Setup_Request"; end if; if This.EPs (Evt.Req_EP) (EP_Out).Typ /= Control then raise Program_Error with Prefix & "EP not in control mode for Setup_Request"; end if; if This.EPs (Evt.Req_EP) (EP_Out).Stall then raise Program_Error with Prefix & "EP stalled for Setup_Request"; end if; if This.EPs (Evt.Req_EP) (EP_Out).Max_Size < 8 then raise Program_Error with Prefix & "EP Max_Size too small for Setup_Request"; end if; when Transfer_Complete => if Evt.EP.Num not in This.EPs'Range then raise Program_Error with Prefix & "Invalid EP id in Transfer_Complete"; end if; if not This.EPs (Evt.EP.Num) (Evt.EP.Dir).Setup then raise Program_Error with Prefix & "EP not setup for Transfer_Complete"; end if; if This.EPs (Evt.EP.Num) (Evt.EP.Dir).Stall then raise Program_Error with Prefix & "EP stalled for Transfer_Complete"; end if; when None | Reset => null; -- Nothing to check end case; end Check_Event; --------------------- -- Do_Out_Transfer -- --------------------- procedure Do_Out_Transfer (This : in out Controller'Class; Ep : EP_Id; Len : UInt11) is begin if Len = 0 then return; end if; This.Put_Line ("UDC OUT Transfer " & Img (EP_Addr'(Ep, EP_Out)) & Len'Img & " bytes"); if Ep not in This.EPs'Range then raise Program_Error with "UDC Error: invalid EP number in EP_Read_Packet"; end if; if not This.EPs (Ep) (EP_In).Setup then raise Program_Error with "UDC Error: EP not setup in EP_Read_Packet"; end if; if This.EPs (Ep) (EP_In).Stall then raise Program_Error with "UDC Error: EP stalled in EP_Read_Packet"; end if; if Len > This.EPs (Ep) (EP_Out).Buf_Len then raise Program_Error with "UDC Error: Trying to write " & Len'Img & " byte(s) to a" & This.EPs (Ep) (EP_Out).Buf_Len'Img & " byte(s) EP OUT buffer"; end if; if This.EPs (EP) (EP_Out).Buf = System.Null_Address then raise Program_Error with "UDC Error: Trying to write to a null EP OUT buffer"; end if; declare Data : UInt8_Array (1 .. Natural (Len)) with Address => This.EPs (EP) (EP_Out).Buf; begin for Elt of Data loop if This.RX_Index in This.RX_Data'Range then Elt := This.RX_Data (This.RX_Index); This.RX_Index := This.RX_Index + 1; else raise Program_Error with "UDC Error: Not enough data in RX_Data"; end if; end loop; This.Hex_Dump (Data); end; end Do_Out_Transfer; --------------------- -- End_Of_Scenario -- --------------------- function End_Of_Scenario (This : Controller) return Boolean is (This.Stack.Is_Empty); ---------------- -- Initialize -- ---------------- overriding procedure Initialize (This : in out Controller) is begin for Elt of This.Scenario.all loop This.Stack.Prepend (Elt); end loop; This.Put_Line ("UDC Initialize"); for EP_Couple of This.EPs loop for EP of EP_Couple loop EP := (others => <>); end loop; end loop; end Initialize; -------------------- -- Request_Buffer -- -------------------- overriding function Request_Buffer (This : in out Controller; Ep : EP_Addr; Len : UInt11; Min_Alignment : UInt8 := 1) return System.Address is begin This.Put_Line ("UDC Request_Buffer (" & Img (EP) & ", Align =>" & Min_Alignment'Img & ", Len =>" & Len'Img & ")"); return Standard.USB.Utils.Allocate (This.Alloc, Alignment => Min_Alignment, Len => Len); end Request_Buffer; ----------- -- Start -- ----------- overriding procedure Start (This : in out Controller) is begin This.Put_Line ("UDC Start"); end Start; ----------- -- Reset -- ----------- overriding procedure Reset (This : in out Controller) is begin This.Put_Line ("UDC Reset"); end Reset; ---------- -- Poll -- ---------- overriding function Poll (This : in out Controller) return UDC_Event is Ret : UDC_Event; begin loop if This.Stack.Is_Empty then Ret := No_Event; exit; end if; declare Step : Scenario_Event renames This.Pop; begin case Step.Kind is when Set_Verbose => if Step.Verbose /= This.Verbose then This.Verbose := not This.Verbose; Ada.Text_IO.Put_Line ("UDC Verbose " & (if This.Verbose then "on" else "off")); end if; when Transfer_Out => null; when Transfer_In => This.EPs (Step.EP_In) (EP_In).Scenario_Waiting_For_Data := True; when UDC_Event_E => Ret := Step.Evt; exit; end case; end; end loop; This.Put_Line ("UDC Poll -> " & Img (Ret)); Check_Event (This, Ret); if Ret.Kind = Reset then Reset (This); end if; if Ret.Kind = Transfer_Complete and then Ret.EP.Dir = EP_Out then Do_Out_Transfer (This, Ret.EP.Num, Ret.BCNT); end if; return Ret; end Poll; --------------------- -- EP_Write_Packet -- --------------------- overriding procedure EP_Write_Packet (This : in out Controller; Ep : EP_Id; Addr : System.Address; Len : UInt32) is Data : UInt8_Array (1 .. Natural (Len)) with Address => Addr; begin This.Put_Line ("UDC EP_Write_Packet " & Img (EP_Addr'(Ep, EP_In)) & (if Len = 0 then " ZLP" else Len'Img & " bytes")); if Ep not in This.EPs'Range then raise Program_Error with "UDC Error: invalid EP number in EP_Write"; end if; if not This.EPs (Ep) (EP_In).Setup then raise Program_Error with "UDC Error: EP not setup in EP_Write_Packet"; end if; if This.EPs (Ep) (EP_In).Stall then raise Program_Error with "UDC Error: EP stalled in EP_Write_Packet"; end if; if Len > UInt32 (This.EPs (Ep) (EP_In).Max_Size) then raise Program_Error with "UDC Error: Packet too big in EP_Write_Packet"; end if; This.Hex_Dump (Data); This.Push ((Kind => UDC_Event_E, Evt => (Kind => Transfer_Complete, EP => (Ep, EP_In), BCNT => UInt11 (Len)))); end EP_Write_Packet; -------------- -- EP_Setup -- -------------- overriding procedure EP_Setup (This : in out Controller; EP : EP_Addr; Typ : EP_Type; Max_Size : UInt16) is begin This.Put_Line ("UDC EP_Setup " & Img (EP) & " Type: " & Typ'Img & " Max_Size:" & Max_Size'Img); if EP.Num not in This.EPs'Range then raise Program_Error with "UDC Error: invalid EP number in EP_Setup"; end if; This.EPs (EP.Num) (EP.Dir).Setup := True; This.EPs (EP.Num) (EP.Dir).Typ := Typ; This.EPs (EP.Num) (EP.Dir).Max_Size := Max_Size; end EP_Setup; ----------------------- -- EP_Ready_For_Data -- ----------------------- overriding procedure EP_Ready_For_Data (This : in out Controller; EP : EP_Id; Addr : System.Address; Size : UInt32; Ready : Boolean := True) is begin This.Put_Line ("UDC EP_Ready_For_Data " & Img (EP_Addr'(EP, EP_Out)) & " " & Ready'Img); if EP not in This.EPs'Range then raise Program_Error with "UDC Error: invalid EP number in EP_Ready_For_Data"; end if; This.EPs (EP) (EP_Out).NAK := not Ready; This.EPs (EP) (EP_Out).Buf_Len := UInt11 (Size); This.EPs (EP) (EP_Out).Buf := Addr; end EP_Ready_For_Data; -------------- -- EP_Stall -- -------------- overriding procedure EP_Stall (This : in out Controller; EP : EP_Addr; Set : Boolean) is begin This.Put_Line ("UDC EP_Stall " & Img (EP) & " " & Set'Img); if EP.Num not in This.EPs'Range then raise Program_Error with "UDC Error: invalid EP number in EP_Stall"; end if; This.EPs (EP.Num) (EP.Dir).Stall := Set; end EP_Stall; ----------------- -- Set_Address -- ----------------- overriding procedure Set_Address (This : in out Controller; Addr : UInt7) is begin This.Put_Line ("UDC Set_Address" & Addr'Img); end Set_Address; --------- -- Pop -- --------- function Pop (This : in out Controller) return Scenario_Event is Ret : Scenario_Event := This.Stack.Last_Element; begin This.Stack.Delete_Last; return Ret; end Pop; ---------- -- Push -- ---------- procedure Push (This : in out Controller; Evt : Scenario_Event) is begin This.Stack.Append (Evt); end Push; -------------- -- Put_Line -- -------------- procedure Put_Line (This : Controller; Str : String) is begin if This.Verbose then Ada.Text_IO.Put_Line (Str); end if; end Put_Line; --------- -- Put -- --------- procedure Put (This : Controller; Str : String) is begin if This.Verbose then Ada.Text_IO.Put (Str); end if; end Put; -------------- -- Hex_Dump -- -------------- procedure Hex_Dump (This : Controller; Data : HAL.UInt8_Array) is begin if This.Verbose then Standard.Hex_Dump.Hex_Dump (Data, Ada.Text_IO.Put_Line'Access); end if; end Hex_Dump; end USB_Testing.UDC_Stub;
src/drivers/oscctrl_u2401/sam-oscillators_controller.adb
Fabien-Chouteau/samd51-hal
1
22176
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2019, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with SAM_SVD.OSCCTRL; use SAM_SVD.OSCCTRL; package body SAM.Oscillators_Controller is -------------------- -- Configure_DFLL -- -------------------- procedure Configure_DFLL (On_Demand_Control : Boolean; Run_On_Standby : Boolean; USB_Clock_Recovery : Boolean; Wait_Lock : Boolean; Bypass_Coarse_Lock : Boolean; Quick_Lock_Disable : Boolean; Chill_Cycle_Disable : Boolean; Lose_Lock_After_Wake : Boolean; Stable_DFLL_Frequency : Boolean; Operating_Mode : DFLL_Operating_Mode; Coarse_Maximum_Step : HAL.UInt6; Fine_Maximum_Step : HAL.UInt8; Multiply_Factor : HAL.UInt16) is Tmp : OSCCTRL_DFLLVAL_Register with Volatile; begin -- Disable DFLL OSCCTRL_Periph.DFLLCTRLA := (ENABLE => False, RUNSTDBY => False, ONDEMAND => False, others => <>); -- Set MUL and wait sync OSCCTRL_Periph.DFLLMUL := (MUL => Multiply_Factor, FSTEP => Fine_Maximum_Step, CSTEP => Coarse_Maximum_Step, others => <>); while OSCCTRL_Periph.DFLLSYNC.DFLLMUL loop null; end loop; -- Reset CTRLB register and wait sync OSCCTRL_Periph.DFLLCTRLB := (others => False); while OSCCTRL_Periph.DFLLSYNC.DFLLCTRLB loop null; end loop; -- Enable and wait sync OSCCTRL_Periph.DFLLCTRLA := (ENABLE => True, RUNSTDBY => Run_On_Standby, ONDEMAND => False, others => <>); while OSCCTRL_Periph.DFLLSYNC.ENABLE loop null; end loop; -- Use the calibration after reset values Tmp := OSCCTRL_Periph.DFLLVAL; OSCCTRL_Periph.DFLLVAL := Tmp; -- Set CTRLB values and wait sync OSCCTRL_Periph.DFLLCTRLB := (MODE => (case Operating_Mode is when Open_Loop_Mode => False, when Closed_Loop_Mode => True), STABLE => Stable_DFLL_Frequency, LLAW => Lose_Lock_After_Wake, USBCRM => USB_Clock_Recovery, CCDIS => Chill_Cycle_Disable, QLDIS => Quick_Lock_Disable, BPLCKC => Bypass_Coarse_Lock, WAITLOCK => Wait_Lock); while OSCCTRL_Periph.DFLLSYNC.DFLLCTRLB loop null; end loop; -- Wait for DFLL ready signal case Operating_Mode is when Closed_Loop_Mode => while not OSCCTRL_Periph.STATUS.DFLLRDY and then not OSCCTRL_Periph.STATUS.DFLLLCKC loop null; end loop; when Open_Loop_Mode => while not OSCCTRL_Periph.STATUS.DFLLRDY loop null; end loop; end case; -- Set On demand config if necessary if On_Demand_Control then OSCCTRL_Periph.DFLLCTRLA.ONDEMAND := True; end if; end Configure_DFLL; ------------------------- -- Configure_DPLL_GCLK -- ------------------------- procedure Configure_DPLL (DPLL : HAL.Bit; On_Demand_Control : Boolean; Run_On_Standby : Boolean; Loop_Divider_Fractional : HAL.UInt5; Loop_Divider_Integer : HAL.UInt13; Clock_Divider : HAL.UInt11; DCO_Filter_Enable : Boolean; Sigma_Delta_DCO_Filter : HAL.UInt3; Lock_Bypass : Boolean; Lock_Time : DPLL_Lock_Time; Reference_Clock : DPLL_Reference_Clock; Wakeup_Fast : Boolean; Prop_Integral_Filter : HAL.UInt4) is RATIO : constant DPLLRATIO_Register := (LDR => Loop_Divider_Integer, LDRFRAC => Loop_Divider_Fractional, others => <>); CTRLB : constant DPLLCTRLB_Register := (FILTER => Prop_Integral_Filter, WUF => Wakeup_Fast, REFCLK => (case Reference_Clock is when GCLK_Ref => Gclk, when XOSC32K_Ref => Xosc32, when XOSC0_Ref => Xosc0, when XOSC1_Ref => Xosc1), LTIME => DPLLCTRLB0_LTIMESelect'Enum_Val (Lock_Time'Enum_Rep), LBYPASS => Lock_Bypass, DCOFILTER => Sigma_Delta_DCO_Filter, DCOEN => DCO_Filter_Enable, DIV => Clock_Divider, others => <>); CTRLA : constant DPLLCTRLA_Register := (ENABLE => True, RUNSTDBY => Run_On_Standby, ONDEMAND => False, others => <>); begin case DPLL is when 0 => OSCCTRL_Periph.DPLLRATIO0 := RATIO; OSCCTRL_Periph.DPLLCTRLB0 := CTRLB; OSCCTRL_Periph.DPLLCTRLA0 := CTRLA; while not OSCCTRL_Periph.DPLLSTATUS0.LOCK and then not OSCCTRL_Periph.DPLLSTATUS0.CLKRDY loop null; end loop; if On_Demand_Control then OSCCTRL_Periph.DPLLCTRLA0.ONDEMAND := True; end if; when 1 => OSCCTRL_Periph.DPLLRATIO1 := RATIO; OSCCTRL_Periph.DPLLCTRLB1 := CTRLB; OSCCTRL_Periph.DPLLCTRLA1 := CTRLA; while not OSCCTRL_Periph.DPLLSTATUS1.LOCK and then not OSCCTRL_Periph.DPLLSTATUS1.CLKRDY loop null; end loop; if On_Demand_Control then OSCCTRL_Periph.DPLLCTRLA1.ONDEMAND := True; end if; end case; end Configure_DPLL; end SAM.Oscillators_Controller;
Task/Old-lady-swallowed-a-fly/Ada/old-lady-swallowed-a-fly.ada
LaudateCorpus1/RosettaCodeData
1
6845
with Ada.Text_IO, Ada.Containers.Indefinite_Doubly_Linked_Lists; use Ada.Text_IO; procedure Swallow_Fly is package Strings is new Ada.Containers.Indefinite_Doubly_Linked_Lists(String); Lines, Animals: Strings.List; procedure Swallow(Animal: String; Second_Line: String; Permanent_Second_Line: Boolean := True) is procedure Print(C: Strings.Cursor) is begin Put_Line(Strings.Element(C)); end Print; begin Put_Line("There was an old lady who swallowed a " & Animal & ","); Put_Line(Second_Line); if not Animals.Is_Empty then Lines.Prepend("She swallowed the " & Animal & " to catch the " & Animals.Last_Element & ","); end if; Lines.Iterate(Print'Access); New_Line; if Permanent_Second_Line then Lines.Prepend(Second_Line); end if; Animals.Append(Animal); -- you need "to catch the " most recent animal end Swallow; procedure Swallow_TSA(Animal: String; Part_Of_Line_2: String) is begin Swallow(Animal, Part_Of_Line_2 &", to swallow a " & Animal & ";", False); end Swallow_TSA; procedure Swallow_SSA(Animal: String; Part_Of_Line_2: String) is begin Swallow(Animal, Part_Of_Line_2 &" she swallowed a " & Animal & ";", False); end Swallow_SSA; begin Lines.Append("Perhaps she'll die!"); Swallow("fly", "But I don't know why she swallowed the fly,"); Swallow("spider", "That wriggled and jiggled and tickled inside her;"); Swallow_TSA("bird", "Quite absurd"); Swallow_TSA("cat", "Fancy that"); Swallow_TSA("dog", "What a hog"); Swallow_TSA("pig", "Her mouth was so big"); Swallow_TSA("goat","She just opened her throat"); Swallow_SSA("cow", "I don't know how"); Swallow_TSA("donkey", "It was rather wonky"); Put_Line("There was an old lady who swallowed a horse ..."); Put_Line("She's dead, of course!"); end Swallow_Fly;
Scripts Pack Source Items/Scripts Pack/Dock/Dock Window Suck Effect.applescript
Phorofor/ScriptsPack.macOS
1
2337
# Scripts Pack - Tweak various preference variables in macOS # <Phorofor, https://github.com/Phorofor/> -- Change to the hidden 'Suck' effect for the Dock -- Versions compatible: -- Preference Identifier: com.apple.dock -- Preference Key: mineffect -- Preference location: ~/Library/Preferences/com.apple.dock.plist -- Default value (string): genie tell application "Finder" set defaultHD to (get name of startup disk) as string end tell set pIcon to defaultHD & ":System:Library:CoreServices:Dock.app:Contents:Resources:Dock.icns" display alert "Set Dock Minimize Animation." message "Would you like to set the Dock animation when minimizing windows to the Dock? You are able to use the hidden 'Suck' effect that doesn't appear in the Dock preferences." buttons ["Cancel", "Set Animation"] cancel button 1 set tValue to "defaults write com.apple.dock mineffect -string " as string set pValue to (choose from list ["Suck", "Genie", "Scale"] with prompt "Which effect would you like to use when minimizing windows to the Dock?" with title "Dock - Minimize Effect") as string if pValue is equal to "false" then display alert "Dock - Action Canceled" message "No changes were made to the Dock minimize effect." buttons ["OK"] cancel button 1 end if if pValue is equal to ["Suck"] then do shell script tValue & pValue end if if pValue is equal to ["Genie"] then do shell script tValue & pValue else do shell script tValue & pValue display dialog "You've set the effect to: " & pValue & return & "Restart the Dock to see changes?" buttons ["Don't restart", "Restart Dock now"] cancel button 1 default button 2 with title "Dock - Changes Applied" with icon file pIcon do shell script "killall Dock" end if
user/sleep.asm
joshiamey/xv6-riscv-fall19
1
15206
<filename>user/sleep.asm user/_sleep: file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <main>: #include "user/user.h" int main(int argc, char *argv[]) { 0: 1101 addi sp,sp,-32 2: ec06 sd ra,24(sp) 4: e822 sd s0,16(sp) 6: e426 sd s1,8(sp) 8: 1000 addi s0,sp,32 int time_to_sleep; if(argc < 2){ a: 4785 li a5,1 c: 02a7dc63 bge a5,a0,44 <main+0x44> fprintf(2, "Usage: sleep <time> \n"); exit(1); } time_to_sleep = atoi(argv[1]); 10: 6588 ld a0,8(a1) 12: 00000097 auipc ra,0x0 16: 1c4080e7 jalr 452(ra) # 1d6 <atoi> 1a: 84aa mv s1,a0 fprintf(1,"User sleep for %d \n", time_to_sleep); 1c: 862a mv a2,a0 1e: 00000597 auipc a1,0x0 22: 7f258593 addi a1,a1,2034 # 810 <malloc+0xfc> 26: 4505 li a0,1 28: 00000097 auipc ra,0x0 2c: 600080e7 jalr 1536(ra) # 628 <fprintf> sleep(time_to_sleep); 30: 8526 mv a0,s1 32: 00000097 auipc ra,0x0 36: 334080e7 jalr 820(ra) # 366 <sleep> exit(0); 3a: 4501 li a0,0 3c: 00000097 auipc ra,0x0 40: 29a080e7 jalr 666(ra) # 2d6 <exit> fprintf(2, "Usage: sleep <time> \n"); 44: 00000597 auipc a1,0x0 48: 7b458593 addi a1,a1,1972 # 7f8 <malloc+0xe4> 4c: 4509 li a0,2 4e: 00000097 auipc ra,0x0 52: 5da080e7 jalr 1498(ra) # 628 <fprintf> exit(1); 56: 4505 li a0,1 58: 00000097 auipc ra,0x0 5c: 27e080e7 jalr 638(ra) # 2d6 <exit> 0000000000000060 <strcpy>: #include "kernel/fcntl.h" #include "user/user.h" char* strcpy(char *s, const char *t) { 60: 1141 addi sp,sp,-16 62: e422 sd s0,8(sp) 64: 0800 addi s0,sp,16 char *os; os = s; while((*s++ = *t++) != 0) 66: 87aa mv a5,a0 68: 0585 addi a1,a1,1 6a: 0785 addi a5,a5,1 6c: fff5c703 lbu a4,-1(a1) 70: fee78fa3 sb a4,-1(a5) 74: fb75 bnez a4,68 <strcpy+0x8> ; return os; } 76: 6422 ld s0,8(sp) 78: 0141 addi sp,sp,16 7a: 8082 ret 000000000000007c <strcmp>: int strcmp(const char *p, const char *q) { 7c: 1141 addi sp,sp,-16 7e: e422 sd s0,8(sp) 80: 0800 addi s0,sp,16 while(*p && *p == *q) 82: 00054783 lbu a5,0(a0) 86: cb91 beqz a5,9a <strcmp+0x1e> 88: 0005c703 lbu a4,0(a1) 8c: 00f71763 bne a4,a5,9a <strcmp+0x1e> p++, q++; 90: 0505 addi a0,a0,1 92: 0585 addi a1,a1,1 while(*p && *p == *q) 94: 00054783 lbu a5,0(a0) 98: fbe5 bnez a5,88 <strcmp+0xc> return (uchar)*p - (uchar)*q; 9a: 0005c503 lbu a0,0(a1) } 9e: 40a7853b subw a0,a5,a0 a2: 6422 ld s0,8(sp) a4: 0141 addi sp,sp,16 a6: 8082 ret 00000000000000a8 <strlen>: uint strlen(const char *s) { a8: 1141 addi sp,sp,-16 aa: e422 sd s0,8(sp) ac: 0800 addi s0,sp,16 int n; for(n = 0; s[n]; n++) ae: 00054783 lbu a5,0(a0) b2: cf91 beqz a5,ce <strlen+0x26> b4: 0505 addi a0,a0,1 b6: 87aa mv a5,a0 b8: 4685 li a3,1 ba: 9e89 subw a3,a3,a0 bc: 00f6853b addw a0,a3,a5 c0: 0785 addi a5,a5,1 c2: fff7c703 lbu a4,-1(a5) c6: fb7d bnez a4,bc <strlen+0x14> ; return n; } c8: 6422 ld s0,8(sp) ca: 0141 addi sp,sp,16 cc: 8082 ret for(n = 0; s[n]; n++) ce: 4501 li a0,0 d0: bfe5 j c8 <strlen+0x20> 00000000000000d2 <memset>: void* memset(void *dst, int c, uint n) { d2: 1141 addi sp,sp,-16 d4: e422 sd s0,8(sp) d6: 0800 addi s0,sp,16 char *cdst = (char *) dst; int i; for(i = 0; i < n; i++){ d8: ce09 beqz a2,f2 <memset+0x20> da: 87aa mv a5,a0 dc: fff6071b addiw a4,a2,-1 e0: 1702 slli a4,a4,0x20 e2: 9301 srli a4,a4,0x20 e4: 0705 addi a4,a4,1 e6: 972a add a4,a4,a0 cdst[i] = c; e8: 00b78023 sb a1,0(a5) for(i = 0; i < n; i++){ ec: 0785 addi a5,a5,1 ee: fee79de3 bne a5,a4,e8 <memset+0x16> } return dst; } f2: 6422 ld s0,8(sp) f4: 0141 addi sp,sp,16 f6: 8082 ret 00000000000000f8 <strchr>: char* strchr(const char *s, char c) { f8: 1141 addi sp,sp,-16 fa: e422 sd s0,8(sp) fc: 0800 addi s0,sp,16 for(; *s; s++) fe: 00054783 lbu a5,0(a0) 102: cb99 beqz a5,118 <strchr+0x20> if(*s == c) 104: 00f58763 beq a1,a5,112 <strchr+0x1a> for(; *s; s++) 108: 0505 addi a0,a0,1 10a: 00054783 lbu a5,0(a0) 10e: fbfd bnez a5,104 <strchr+0xc> return (char*)s; return 0; 110: 4501 li a0,0 } 112: 6422 ld s0,8(sp) 114: 0141 addi sp,sp,16 116: 8082 ret return 0; 118: 4501 li a0,0 11a: bfe5 j 112 <strchr+0x1a> 000000000000011c <gets>: char* gets(char *buf, int max) { 11c: 711d addi sp,sp,-96 11e: ec86 sd ra,88(sp) 120: e8a2 sd s0,80(sp) 122: e4a6 sd s1,72(sp) 124: e0ca sd s2,64(sp) 126: fc4e sd s3,56(sp) 128: f852 sd s4,48(sp) 12a: f456 sd s5,40(sp) 12c: f05a sd s6,32(sp) 12e: ec5e sd s7,24(sp) 130: 1080 addi s0,sp,96 132: 8baa mv s7,a0 134: 8a2e mv s4,a1 int i, cc; char c; for(i=0; i+1 < max; ){ 136: 892a mv s2,a0 138: 4481 li s1,0 cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; if(c == '\n' || c == '\r') 13a: 4aa9 li s5,10 13c: 4b35 li s6,13 for(i=0; i+1 < max; ){ 13e: 89a6 mv s3,s1 140: 2485 addiw s1,s1,1 142: 0344d863 bge s1,s4,172 <gets+0x56> cc = read(0, &c, 1); 146: 4605 li a2,1 148: faf40593 addi a1,s0,-81 14c: 4501 li a0,0 14e: 00000097 auipc ra,0x0 152: 1a0080e7 jalr 416(ra) # 2ee <read> if(cc < 1) 156: 00a05e63 blez a0,172 <gets+0x56> buf[i++] = c; 15a: faf44783 lbu a5,-81(s0) 15e: 00f90023 sb a5,0(s2) if(c == '\n' || c == '\r') 162: 01578763 beq a5,s5,170 <gets+0x54> 166: 0905 addi s2,s2,1 168: fd679be3 bne a5,s6,13e <gets+0x22> for(i=0; i+1 < max; ){ 16c: 89a6 mv s3,s1 16e: a011 j 172 <gets+0x56> 170: 89a6 mv s3,s1 break; } buf[i] = '\0'; 172: 99de add s3,s3,s7 174: 00098023 sb zero,0(s3) return buf; } 178: 855e mv a0,s7 17a: 60e6 ld ra,88(sp) 17c: 6446 ld s0,80(sp) 17e: 64a6 ld s1,72(sp) 180: 6906 ld s2,64(sp) 182: 79e2 ld s3,56(sp) 184: 7a42 ld s4,48(sp) 186: 7aa2 ld s5,40(sp) 188: 7b02 ld s6,32(sp) 18a: 6be2 ld s7,24(sp) 18c: 6125 addi sp,sp,96 18e: 8082 ret 0000000000000190 <stat>: int stat(const char *n, struct stat *st) { 190: 1101 addi sp,sp,-32 192: ec06 sd ra,24(sp) 194: e822 sd s0,16(sp) 196: e426 sd s1,8(sp) 198: e04a sd s2,0(sp) 19a: 1000 addi s0,sp,32 19c: 892e mv s2,a1 int fd; int r; fd = open(n, O_RDONLY); 19e: 4581 li a1,0 1a0: 00000097 auipc ra,0x0 1a4: 176080e7 jalr 374(ra) # 316 <open> if(fd < 0) 1a8: 02054563 bltz a0,1d2 <stat+0x42> 1ac: 84aa mv s1,a0 return -1; r = fstat(fd, st); 1ae: 85ca mv a1,s2 1b0: 00000097 auipc ra,0x0 1b4: 17e080e7 jalr 382(ra) # 32e <fstat> 1b8: 892a mv s2,a0 close(fd); 1ba: 8526 mv a0,s1 1bc: 00000097 auipc ra,0x0 1c0: 142080e7 jalr 322(ra) # 2fe <close> return r; } 1c4: 854a mv a0,s2 1c6: 60e2 ld ra,24(sp) 1c8: 6442 ld s0,16(sp) 1ca: 64a2 ld s1,8(sp) 1cc: 6902 ld s2,0(sp) 1ce: 6105 addi sp,sp,32 1d0: 8082 ret return -1; 1d2: 597d li s2,-1 1d4: bfc5 j 1c4 <stat+0x34> 00000000000001d6 <atoi>: int atoi(const char *s) { 1d6: 1141 addi sp,sp,-16 1d8: e422 sd s0,8(sp) 1da: 0800 addi s0,sp,16 int n; n = 0; while('0' <= *s && *s <= '9') 1dc: 00054603 lbu a2,0(a0) 1e0: fd06079b addiw a5,a2,-48 1e4: 0ff7f793 andi a5,a5,255 1e8: 4725 li a4,9 1ea: 02f76963 bltu a4,a5,21c <atoi+0x46> 1ee: 86aa mv a3,a0 n = 0; 1f0: 4501 li a0,0 while('0' <= *s && *s <= '9') 1f2: 45a5 li a1,9 n = n*10 + *s++ - '0'; 1f4: 0685 addi a3,a3,1 1f6: 0025179b slliw a5,a0,0x2 1fa: 9fa9 addw a5,a5,a0 1fc: 0017979b slliw a5,a5,0x1 200: 9fb1 addw a5,a5,a2 202: fd07851b addiw a0,a5,-48 while('0' <= *s && *s <= '9') 206: 0006c603 lbu a2,0(a3) 20a: fd06071b addiw a4,a2,-48 20e: 0ff77713 andi a4,a4,255 212: fee5f1e3 bgeu a1,a4,1f4 <atoi+0x1e> return n; } 216: 6422 ld s0,8(sp) 218: 0141 addi sp,sp,16 21a: 8082 ret n = 0; 21c: 4501 li a0,0 21e: bfe5 j 216 <atoi+0x40> 0000000000000220 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 220: 1141 addi sp,sp,-16 222: e422 sd s0,8(sp) 224: 0800 addi s0,sp,16 char *dst; const char *src; dst = vdst; src = vsrc; if (src > dst) { 226: 02b57663 bgeu a0,a1,252 <memmove+0x32> while(n-- > 0) 22a: 02c05163 blez a2,24c <memmove+0x2c> 22e: fff6079b addiw a5,a2,-1 232: 1782 slli a5,a5,0x20 234: 9381 srli a5,a5,0x20 236: 0785 addi a5,a5,1 238: 97aa add a5,a5,a0 dst = vdst; 23a: 872a mv a4,a0 *dst++ = *src++; 23c: 0585 addi a1,a1,1 23e: 0705 addi a4,a4,1 240: fff5c683 lbu a3,-1(a1) 244: fed70fa3 sb a3,-1(a4) while(n-- > 0) 248: fee79ae3 bne a5,a4,23c <memmove+0x1c> src += n; while(n-- > 0) *--dst = *--src; } return vdst; } 24c: 6422 ld s0,8(sp) 24e: 0141 addi sp,sp,16 250: 8082 ret dst += n; 252: 00c50733 add a4,a0,a2 src += n; 256: 95b2 add a1,a1,a2 while(n-- > 0) 258: fec05ae3 blez a2,24c <memmove+0x2c> 25c: fff6079b addiw a5,a2,-1 260: 1782 slli a5,a5,0x20 262: 9381 srli a5,a5,0x20 264: fff7c793 not a5,a5 268: 97ba add a5,a5,a4 *--dst = *--src; 26a: 15fd addi a1,a1,-1 26c: 177d addi a4,a4,-1 26e: 0005c683 lbu a3,0(a1) 272: 00d70023 sb a3,0(a4) while(n-- > 0) 276: fee79ae3 bne a5,a4,26a <memmove+0x4a> 27a: bfc9 j 24c <memmove+0x2c> 000000000000027c <memcmp>: int memcmp(const void *s1, const void *s2, uint n) { 27c: 1141 addi sp,sp,-16 27e: e422 sd s0,8(sp) 280: 0800 addi s0,sp,16 const char *p1 = s1, *p2 = s2; while (n-- > 0) { 282: ca05 beqz a2,2b2 <memcmp+0x36> 284: fff6069b addiw a3,a2,-1 288: 1682 slli a3,a3,0x20 28a: 9281 srli a3,a3,0x20 28c: 0685 addi a3,a3,1 28e: 96aa add a3,a3,a0 if (*p1 != *p2) { 290: 00054783 lbu a5,0(a0) 294: 0005c703 lbu a4,0(a1) 298: 00e79863 bne a5,a4,2a8 <memcmp+0x2c> return *p1 - *p2; } p1++; 29c: 0505 addi a0,a0,1 p2++; 29e: 0585 addi a1,a1,1 while (n-- > 0) { 2a0: fed518e3 bne a0,a3,290 <memcmp+0x14> } return 0; 2a4: 4501 li a0,0 2a6: a019 j 2ac <memcmp+0x30> return *p1 - *p2; 2a8: 40e7853b subw a0,a5,a4 } 2ac: 6422 ld s0,8(sp) 2ae: 0141 addi sp,sp,16 2b0: 8082 ret return 0; 2b2: 4501 li a0,0 2b4: bfe5 j 2ac <memcmp+0x30> 00000000000002b6 <memcpy>: void * memcpy(void *dst, const void *src, uint n) { 2b6: 1141 addi sp,sp,-16 2b8: e406 sd ra,8(sp) 2ba: e022 sd s0,0(sp) 2bc: 0800 addi s0,sp,16 return memmove(dst, src, n); 2be: 00000097 auipc ra,0x0 2c2: f62080e7 jalr -158(ra) # 220 <memmove> } 2c6: 60a2 ld ra,8(sp) 2c8: 6402 ld s0,0(sp) 2ca: 0141 addi sp,sp,16 2cc: 8082 ret 00000000000002ce <fork>: # generated by usys.pl - do not edit #include "kernel/syscall.h" .global fork fork: li a7, SYS_fork 2ce: 4885 li a7,1 ecall 2d0: 00000073 ecall ret 2d4: 8082 ret 00000000000002d6 <exit>: .global exit exit: li a7, SYS_exit 2d6: 4889 li a7,2 ecall 2d8: 00000073 ecall ret 2dc: 8082 ret 00000000000002de <wait>: .global wait wait: li a7, SYS_wait 2de: 488d li a7,3 ecall 2e0: 00000073 ecall ret 2e4: 8082 ret 00000000000002e6 <pipe>: .global pipe pipe: li a7, SYS_pipe 2e6: 4891 li a7,4 ecall 2e8: 00000073 ecall ret 2ec: 8082 ret 00000000000002ee <read>: .global read read: li a7, SYS_read 2ee: 4895 li a7,5 ecall 2f0: 00000073 ecall ret 2f4: 8082 ret 00000000000002f6 <write>: .global write write: li a7, SYS_write 2f6: 48c1 li a7,16 ecall 2f8: 00000073 ecall ret 2fc: 8082 ret 00000000000002fe <close>: .global close close: li a7, SYS_close 2fe: 48d5 li a7,21 ecall 300: 00000073 ecall ret 304: 8082 ret 0000000000000306 <kill>: .global kill kill: li a7, SYS_kill 306: 4899 li a7,6 ecall 308: 00000073 ecall ret 30c: 8082 ret 000000000000030e <exec>: .global exec exec: li a7, SYS_exec 30e: 489d li a7,7 ecall 310: 00000073 ecall ret 314: 8082 ret 0000000000000316 <open>: .global open open: li a7, SYS_open 316: 48bd li a7,15 ecall 318: 00000073 ecall ret 31c: 8082 ret 000000000000031e <mknod>: .global mknod mknod: li a7, SYS_mknod 31e: 48c5 li a7,17 ecall 320: 00000073 ecall ret 324: 8082 ret 0000000000000326 <unlink>: .global unlink unlink: li a7, SYS_unlink 326: 48c9 li a7,18 ecall 328: 00000073 ecall ret 32c: 8082 ret 000000000000032e <fstat>: .global fstat fstat: li a7, SYS_fstat 32e: 48a1 li a7,8 ecall 330: 00000073 ecall ret 334: 8082 ret 0000000000000336 <link>: .global link link: li a7, SYS_link 336: 48cd li a7,19 ecall 338: 00000073 ecall ret 33c: 8082 ret 000000000000033e <mkdir>: .global mkdir mkdir: li a7, SYS_mkdir 33e: 48d1 li a7,20 ecall 340: 00000073 ecall ret 344: 8082 ret 0000000000000346 <chdir>: .global chdir chdir: li a7, SYS_chdir 346: 48a5 li a7,9 ecall 348: 00000073 ecall ret 34c: 8082 ret 000000000000034e <dup>: .global dup dup: li a7, SYS_dup 34e: 48a9 li a7,10 ecall 350: 00000073 ecall ret 354: 8082 ret 0000000000000356 <getpid>: .global getpid getpid: li a7, SYS_getpid 356: 48ad li a7,11 ecall 358: 00000073 ecall ret 35c: 8082 ret 000000000000035e <sbrk>: .global sbrk sbrk: li a7, SYS_sbrk 35e: 48b1 li a7,12 ecall 360: 00000073 ecall ret 364: 8082 ret 0000000000000366 <sleep>: .global sleep sleep: li a7, SYS_sleep 366: 48b5 li a7,13 ecall 368: 00000073 ecall ret 36c: 8082 ret 000000000000036e <uptime>: .global uptime uptime: li a7, SYS_uptime 36e: 48b9 li a7,14 ecall 370: 00000073 ecall ret 374: 8082 ret 0000000000000376 <ntas>: .global ntas ntas: li a7, SYS_ntas 376: 48d9 li a7,22 ecall 378: 00000073 ecall ret 37c: 8082 ret 000000000000037e <putc>: static char digits[] = "0123456789ABCDEF"; static void putc(int fd, char c) { 37e: 1101 addi sp,sp,-32 380: ec06 sd ra,24(sp) 382: e822 sd s0,16(sp) 384: 1000 addi s0,sp,32 386: feb407a3 sb a1,-17(s0) write(fd, &c, 1); 38a: 4605 li a2,1 38c: fef40593 addi a1,s0,-17 390: 00000097 auipc ra,0x0 394: f66080e7 jalr -154(ra) # 2f6 <write> } 398: 60e2 ld ra,24(sp) 39a: 6442 ld s0,16(sp) 39c: 6105 addi sp,sp,32 39e: 8082 ret 00000000000003a0 <printint>: static void printint(int fd, int xx, int base, int sgn) { 3a0: 7139 addi sp,sp,-64 3a2: fc06 sd ra,56(sp) 3a4: f822 sd s0,48(sp) 3a6: f426 sd s1,40(sp) 3a8: f04a sd s2,32(sp) 3aa: ec4e sd s3,24(sp) 3ac: 0080 addi s0,sp,64 3ae: 84aa mv s1,a0 char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 3b0: c299 beqz a3,3b6 <printint+0x16> 3b2: 0805c863 bltz a1,442 <printint+0xa2> neg = 1; x = -xx; } else { x = xx; 3b6: 2581 sext.w a1,a1 neg = 0; 3b8: 4881 li a7,0 3ba: fc040693 addi a3,s0,-64 } i = 0; 3be: 4701 li a4,0 do{ buf[i++] = digits[x % base]; 3c0: 2601 sext.w a2,a2 3c2: 00000517 auipc a0,0x0 3c6: 46e50513 addi a0,a0,1134 # 830 <digits> 3ca: 883a mv a6,a4 3cc: 2705 addiw a4,a4,1 3ce: 02c5f7bb remuw a5,a1,a2 3d2: 1782 slli a5,a5,0x20 3d4: 9381 srli a5,a5,0x20 3d6: 97aa add a5,a5,a0 3d8: 0007c783 lbu a5,0(a5) 3dc: 00f68023 sb a5,0(a3) }while((x /= base) != 0); 3e0: 0005879b sext.w a5,a1 3e4: 02c5d5bb divuw a1,a1,a2 3e8: 0685 addi a3,a3,1 3ea: fec7f0e3 bgeu a5,a2,3ca <printint+0x2a> if(neg) 3ee: 00088b63 beqz a7,404 <printint+0x64> buf[i++] = '-'; 3f2: fd040793 addi a5,s0,-48 3f6: 973e add a4,a4,a5 3f8: 02d00793 li a5,45 3fc: fef70823 sb a5,-16(a4) 400: 0028071b addiw a4,a6,2 while(--i >= 0) 404: 02e05863 blez a4,434 <printint+0x94> 408: fc040793 addi a5,s0,-64 40c: 00e78933 add s2,a5,a4 410: fff78993 addi s3,a5,-1 414: 99ba add s3,s3,a4 416: 377d addiw a4,a4,-1 418: 1702 slli a4,a4,0x20 41a: 9301 srli a4,a4,0x20 41c: 40e989b3 sub s3,s3,a4 putc(fd, buf[i]); 420: fff94583 lbu a1,-1(s2) 424: 8526 mv a0,s1 426: 00000097 auipc ra,0x0 42a: f58080e7 jalr -168(ra) # 37e <putc> while(--i >= 0) 42e: 197d addi s2,s2,-1 430: ff3918e3 bne s2,s3,420 <printint+0x80> } 434: 70e2 ld ra,56(sp) 436: 7442 ld s0,48(sp) 438: 74a2 ld s1,40(sp) 43a: 7902 ld s2,32(sp) 43c: 69e2 ld s3,24(sp) 43e: 6121 addi sp,sp,64 440: 8082 ret x = -xx; 442: 40b005bb negw a1,a1 neg = 1; 446: 4885 li a7,1 x = -xx; 448: bf8d j 3ba <printint+0x1a> 000000000000044a <vprintf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void vprintf(int fd, const char *fmt, va_list ap) { 44a: 7119 addi sp,sp,-128 44c: fc86 sd ra,120(sp) 44e: f8a2 sd s0,112(sp) 450: f4a6 sd s1,104(sp) 452: f0ca sd s2,96(sp) 454: ecce sd s3,88(sp) 456: e8d2 sd s4,80(sp) 458: e4d6 sd s5,72(sp) 45a: e0da sd s6,64(sp) 45c: fc5e sd s7,56(sp) 45e: f862 sd s8,48(sp) 460: f466 sd s9,40(sp) 462: f06a sd s10,32(sp) 464: ec6e sd s11,24(sp) 466: 0100 addi s0,sp,128 char *s; int c, i, state; state = 0; for(i = 0; fmt[i]; i++){ 468: 0005c903 lbu s2,0(a1) 46c: 18090f63 beqz s2,60a <vprintf+0x1c0> 470: 8aaa mv s5,a0 472: 8b32 mv s6,a2 474: 00158493 addi s1,a1,1 state = 0; 478: 4981 li s3,0 if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 47a: 02500a13 li s4,37 if(c == 'd'){ 47e: 06400c13 li s8,100 printint(fd, va_arg(ap, int), 10, 1); } else if(c == 'l') { 482: 06c00c93 li s9,108 printint(fd, va_arg(ap, uint64), 10, 0); } else if(c == 'x') { 486: 07800d13 li s10,120 printint(fd, va_arg(ap, int), 16, 0); } else if(c == 'p') { 48a: 07000d93 li s11,112 putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]); 48e: 00000b97 auipc s7,0x0 492: 3a2b8b93 addi s7,s7,930 # 830 <digits> 496: a839 j 4b4 <vprintf+0x6a> putc(fd, c); 498: 85ca mv a1,s2 49a: 8556 mv a0,s5 49c: 00000097 auipc ra,0x0 4a0: ee2080e7 jalr -286(ra) # 37e <putc> 4a4: a019 j 4aa <vprintf+0x60> } else if(state == '%'){ 4a6: 01498f63 beq s3,s4,4c4 <vprintf+0x7a> for(i = 0; fmt[i]; i++){ 4aa: 0485 addi s1,s1,1 4ac: fff4c903 lbu s2,-1(s1) 4b0: 14090d63 beqz s2,60a <vprintf+0x1c0> c = fmt[i] & 0xff; 4b4: 0009079b sext.w a5,s2 if(state == 0){ 4b8: fe0997e3 bnez s3,4a6 <vprintf+0x5c> if(c == '%'){ 4bc: fd479ee3 bne a5,s4,498 <vprintf+0x4e> state = '%'; 4c0: 89be mv s3,a5 4c2: b7e5 j 4aa <vprintf+0x60> if(c == 'd'){ 4c4: 05878063 beq a5,s8,504 <vprintf+0xba> } else if(c == 'l') { 4c8: 05978c63 beq a5,s9,520 <vprintf+0xd6> } else if(c == 'x') { 4cc: 07a78863 beq a5,s10,53c <vprintf+0xf2> } else if(c == 'p') { 4d0: 09b78463 beq a5,s11,558 <vprintf+0x10e> printptr(fd, va_arg(ap, uint64)); } else if(c == 's'){ 4d4: 07300713 li a4,115 4d8: 0ce78663 beq a5,a4,5a4 <vprintf+0x15a> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 4dc: 06300713 li a4,99 4e0: 0ee78e63 beq a5,a4,5dc <vprintf+0x192> putc(fd, va_arg(ap, uint)); } else if(c == '%'){ 4e4: 11478863 beq a5,s4,5f4 <vprintf+0x1aa> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 4e8: 85d2 mv a1,s4 4ea: 8556 mv a0,s5 4ec: 00000097 auipc ra,0x0 4f0: e92080e7 jalr -366(ra) # 37e <putc> putc(fd, c); 4f4: 85ca mv a1,s2 4f6: 8556 mv a0,s5 4f8: 00000097 auipc ra,0x0 4fc: e86080e7 jalr -378(ra) # 37e <putc> } state = 0; 500: 4981 li s3,0 502: b765 j 4aa <vprintf+0x60> printint(fd, va_arg(ap, int), 10, 1); 504: 008b0913 addi s2,s6,8 508: 4685 li a3,1 50a: 4629 li a2,10 50c: 000b2583 lw a1,0(s6) 510: 8556 mv a0,s5 512: 00000097 auipc ra,0x0 516: e8e080e7 jalr -370(ra) # 3a0 <printint> 51a: 8b4a mv s6,s2 state = 0; 51c: 4981 li s3,0 51e: b771 j 4aa <vprintf+0x60> printint(fd, va_arg(ap, uint64), 10, 0); 520: 008b0913 addi s2,s6,8 524: 4681 li a3,0 526: 4629 li a2,10 528: 000b2583 lw a1,0(s6) 52c: 8556 mv a0,s5 52e: 00000097 auipc ra,0x0 532: e72080e7 jalr -398(ra) # 3a0 <printint> 536: 8b4a mv s6,s2 state = 0; 538: 4981 li s3,0 53a: bf85 j 4aa <vprintf+0x60> printint(fd, va_arg(ap, int), 16, 0); 53c: 008b0913 addi s2,s6,8 540: 4681 li a3,0 542: 4641 li a2,16 544: 000b2583 lw a1,0(s6) 548: 8556 mv a0,s5 54a: 00000097 auipc ra,0x0 54e: e56080e7 jalr -426(ra) # 3a0 <printint> 552: 8b4a mv s6,s2 state = 0; 554: 4981 li s3,0 556: bf91 j 4aa <vprintf+0x60> printptr(fd, va_arg(ap, uint64)); 558: 008b0793 addi a5,s6,8 55c: f8f43423 sd a5,-120(s0) 560: 000b3983 ld s3,0(s6) putc(fd, '0'); 564: 03000593 li a1,48 568: 8556 mv a0,s5 56a: 00000097 auipc ra,0x0 56e: e14080e7 jalr -492(ra) # 37e <putc> putc(fd, 'x'); 572: 85ea mv a1,s10 574: 8556 mv a0,s5 576: 00000097 auipc ra,0x0 57a: e08080e7 jalr -504(ra) # 37e <putc> 57e: 4941 li s2,16 putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]); 580: 03c9d793 srli a5,s3,0x3c 584: 97de add a5,a5,s7 586: 0007c583 lbu a1,0(a5) 58a: 8556 mv a0,s5 58c: 00000097 auipc ra,0x0 590: df2080e7 jalr -526(ra) # 37e <putc> for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4) 594: 0992 slli s3,s3,0x4 596: 397d addiw s2,s2,-1 598: fe0914e3 bnez s2,580 <vprintf+0x136> printptr(fd, va_arg(ap, uint64)); 59c: f8843b03 ld s6,-120(s0) state = 0; 5a0: 4981 li s3,0 5a2: b721 j 4aa <vprintf+0x60> s = va_arg(ap, char*); 5a4: 008b0993 addi s3,s6,8 5a8: 000b3903 ld s2,0(s6) if(s == 0) 5ac: 02090163 beqz s2,5ce <vprintf+0x184> while(*s != 0){ 5b0: 00094583 lbu a1,0(s2) 5b4: c9a1 beqz a1,604 <vprintf+0x1ba> putc(fd, *s); 5b6: 8556 mv a0,s5 5b8: 00000097 auipc ra,0x0 5bc: dc6080e7 jalr -570(ra) # 37e <putc> s++; 5c0: 0905 addi s2,s2,1 while(*s != 0){ 5c2: 00094583 lbu a1,0(s2) 5c6: f9e5 bnez a1,5b6 <vprintf+0x16c> s = va_arg(ap, char*); 5c8: 8b4e mv s6,s3 state = 0; 5ca: 4981 li s3,0 5cc: bdf9 j 4aa <vprintf+0x60> s = "(null)"; 5ce: 00000917 auipc s2,0x0 5d2: 25a90913 addi s2,s2,602 # 828 <malloc+0x114> while(*s != 0){ 5d6: 02800593 li a1,40 5da: bff1 j 5b6 <vprintf+0x16c> putc(fd, va_arg(ap, uint)); 5dc: 008b0913 addi s2,s6,8 5e0: 000b4583 lbu a1,0(s6) 5e4: 8556 mv a0,s5 5e6: 00000097 auipc ra,0x0 5ea: d98080e7 jalr -616(ra) # 37e <putc> 5ee: 8b4a mv s6,s2 state = 0; 5f0: 4981 li s3,0 5f2: bd65 j 4aa <vprintf+0x60> putc(fd, c); 5f4: 85d2 mv a1,s4 5f6: 8556 mv a0,s5 5f8: 00000097 auipc ra,0x0 5fc: d86080e7 jalr -634(ra) # 37e <putc> state = 0; 600: 4981 li s3,0 602: b565 j 4aa <vprintf+0x60> s = va_arg(ap, char*); 604: 8b4e mv s6,s3 state = 0; 606: 4981 li s3,0 608: b54d j 4aa <vprintf+0x60> } } } 60a: 70e6 ld ra,120(sp) 60c: 7446 ld s0,112(sp) 60e: 74a6 ld s1,104(sp) 610: 7906 ld s2,96(sp) 612: 69e6 ld s3,88(sp) 614: 6a46 ld s4,80(sp) 616: 6aa6 ld s5,72(sp) 618: 6b06 ld s6,64(sp) 61a: 7be2 ld s7,56(sp) 61c: 7c42 ld s8,48(sp) 61e: 7ca2 ld s9,40(sp) 620: 7d02 ld s10,32(sp) 622: 6de2 ld s11,24(sp) 624: 6109 addi sp,sp,128 626: 8082 ret 0000000000000628 <fprintf>: void fprintf(int fd, const char *fmt, ...) { 628: 715d addi sp,sp,-80 62a: ec06 sd ra,24(sp) 62c: e822 sd s0,16(sp) 62e: 1000 addi s0,sp,32 630: e010 sd a2,0(s0) 632: e414 sd a3,8(s0) 634: e818 sd a4,16(s0) 636: ec1c sd a5,24(s0) 638: 03043023 sd a6,32(s0) 63c: 03143423 sd a7,40(s0) va_list ap; va_start(ap, fmt); 640: fe843423 sd s0,-24(s0) vprintf(fd, fmt, ap); 644: 8622 mv a2,s0 646: 00000097 auipc ra,0x0 64a: e04080e7 jalr -508(ra) # 44a <vprintf> } 64e: 60e2 ld ra,24(sp) 650: 6442 ld s0,16(sp) 652: 6161 addi sp,sp,80 654: 8082 ret 0000000000000656 <printf>: void printf(const char *fmt, ...) { 656: 711d addi sp,sp,-96 658: ec06 sd ra,24(sp) 65a: e822 sd s0,16(sp) 65c: 1000 addi s0,sp,32 65e: e40c sd a1,8(s0) 660: e810 sd a2,16(s0) 662: ec14 sd a3,24(s0) 664: f018 sd a4,32(s0) 666: f41c sd a5,40(s0) 668: 03043823 sd a6,48(s0) 66c: 03143c23 sd a7,56(s0) va_list ap; va_start(ap, fmt); 670: 00840613 addi a2,s0,8 674: fec43423 sd a2,-24(s0) vprintf(1, fmt, ap); 678: 85aa mv a1,a0 67a: 4505 li a0,1 67c: 00000097 auipc ra,0x0 680: dce080e7 jalr -562(ra) # 44a <vprintf> } 684: 60e2 ld ra,24(sp) 686: 6442 ld s0,16(sp) 688: 6125 addi sp,sp,96 68a: 8082 ret 000000000000068c <free>: static Header base; static Header *freep; void free(void *ap) { 68c: 1141 addi sp,sp,-16 68e: e422 sd s0,8(sp) 690: 0800 addi s0,sp,16 Header *bp, *p; bp = (Header*)ap - 1; 692: ff050693 addi a3,a0,-16 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 696: 00000797 auipc a5,0x0 69a: 1b27b783 ld a5,434(a5) # 848 <freep> 69e: a805 j 6ce <free+0x42> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 6a0: 4618 lw a4,8(a2) 6a2: 9db9 addw a1,a1,a4 6a4: feb52c23 sw a1,-8(a0) bp->s.ptr = p->s.ptr->s.ptr; 6a8: 6398 ld a4,0(a5) 6aa: 6318 ld a4,0(a4) 6ac: fee53823 sd a4,-16(a0) 6b0: a091 j 6f4 <free+0x68> } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 6b2: ff852703 lw a4,-8(a0) 6b6: 9e39 addw a2,a2,a4 6b8: c790 sw a2,8(a5) p->s.ptr = bp->s.ptr; 6ba: ff053703 ld a4,-16(a0) 6be: e398 sd a4,0(a5) 6c0: a099 j 706 <free+0x7a> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6c2: 6398 ld a4,0(a5) 6c4: 00e7e463 bltu a5,a4,6cc <free+0x40> 6c8: 00e6ea63 bltu a3,a4,6dc <free+0x50> { 6cc: 87ba mv a5,a4 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6ce: fed7fae3 bgeu a5,a3,6c2 <free+0x36> 6d2: 6398 ld a4,0(a5) 6d4: 00e6e463 bltu a3,a4,6dc <free+0x50> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6d8: fee7eae3 bltu a5,a4,6cc <free+0x40> if(bp + bp->s.size == p->s.ptr){ 6dc: ff852583 lw a1,-8(a0) 6e0: 6390 ld a2,0(a5) 6e2: 02059713 slli a4,a1,0x20 6e6: 9301 srli a4,a4,0x20 6e8: 0712 slli a4,a4,0x4 6ea: 9736 add a4,a4,a3 6ec: fae60ae3 beq a2,a4,6a0 <free+0x14> bp->s.ptr = p->s.ptr; 6f0: fec53823 sd a2,-16(a0) if(p + p->s.size == bp){ 6f4: 4790 lw a2,8(a5) 6f6: 02061713 slli a4,a2,0x20 6fa: 9301 srli a4,a4,0x20 6fc: 0712 slli a4,a4,0x4 6fe: 973e add a4,a4,a5 700: fae689e3 beq a3,a4,6b2 <free+0x26> } else p->s.ptr = bp; 704: e394 sd a3,0(a5) freep = p; 706: 00000717 auipc a4,0x0 70a: 14f73123 sd a5,322(a4) # 848 <freep> } 70e: 6422 ld s0,8(sp) 710: 0141 addi sp,sp,16 712: 8082 ret 0000000000000714 <malloc>: return freep; } void* malloc(uint nbytes) { 714: 7139 addi sp,sp,-64 716: fc06 sd ra,56(sp) 718: f822 sd s0,48(sp) 71a: f426 sd s1,40(sp) 71c: f04a sd s2,32(sp) 71e: ec4e sd s3,24(sp) 720: e852 sd s4,16(sp) 722: e456 sd s5,8(sp) 724: e05a sd s6,0(sp) 726: 0080 addi s0,sp,64 Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 728: 02051493 slli s1,a0,0x20 72c: 9081 srli s1,s1,0x20 72e: 04bd addi s1,s1,15 730: 8091 srli s1,s1,0x4 732: 0014899b addiw s3,s1,1 736: 0485 addi s1,s1,1 if((prevp = freep) == 0){ 738: 00000517 auipc a0,0x0 73c: 11053503 ld a0,272(a0) # 848 <freep> 740: c515 beqz a0,76c <malloc+0x58> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 742: 611c ld a5,0(a0) if(p->s.size >= nunits){ 744: 4798 lw a4,8(a5) 746: 02977f63 bgeu a4,s1,784 <malloc+0x70> 74a: 8a4e mv s4,s3 74c: 0009871b sext.w a4,s3 750: 6685 lui a3,0x1 752: 00d77363 bgeu a4,a3,758 <malloc+0x44> 756: 6a05 lui s4,0x1 758: 000a0b1b sext.w s6,s4 p = sbrk(nu * sizeof(Header)); 75c: 004a1a1b slliw s4,s4,0x4 p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 760: 00000917 auipc s2,0x0 764: 0e890913 addi s2,s2,232 # 848 <freep> if(p == (char*)-1) 768: 5afd li s5,-1 76a: a88d j 7dc <malloc+0xc8> base.s.ptr = freep = prevp = &base; 76c: 00000797 auipc a5,0x0 770: 0e478793 addi a5,a5,228 # 850 <base> 774: 00000717 auipc a4,0x0 778: 0cf73a23 sd a5,212(a4) # 848 <freep> 77c: e39c sd a5,0(a5) base.s.size = 0; 77e: 0007a423 sw zero,8(a5) if(p->s.size >= nunits){ 782: b7e1 j 74a <malloc+0x36> if(p->s.size == nunits) 784: 02e48b63 beq s1,a4,7ba <malloc+0xa6> p->s.size -= nunits; 788: 4137073b subw a4,a4,s3 78c: c798 sw a4,8(a5) p += p->s.size; 78e: 1702 slli a4,a4,0x20 790: 9301 srli a4,a4,0x20 792: 0712 slli a4,a4,0x4 794: 97ba add a5,a5,a4 p->s.size = nunits; 796: 0137a423 sw s3,8(a5) freep = prevp; 79a: 00000717 auipc a4,0x0 79e: 0aa73723 sd a0,174(a4) # 848 <freep> return (void*)(p + 1); 7a2: 01078513 addi a0,a5,16 if((p = morecore(nunits)) == 0) return 0; } } 7a6: 70e2 ld ra,56(sp) 7a8: 7442 ld s0,48(sp) 7aa: 74a2 ld s1,40(sp) 7ac: 7902 ld s2,32(sp) 7ae: 69e2 ld s3,24(sp) 7b0: 6a42 ld s4,16(sp) 7b2: 6aa2 ld s5,8(sp) 7b4: 6b02 ld s6,0(sp) 7b6: 6121 addi sp,sp,64 7b8: 8082 ret prevp->s.ptr = p->s.ptr; 7ba: 6398 ld a4,0(a5) 7bc: e118 sd a4,0(a0) 7be: bff1 j 79a <malloc+0x86> hp->s.size = nu; 7c0: 01652423 sw s6,8(a0) free((void*)(hp + 1)); 7c4: 0541 addi a0,a0,16 7c6: 00000097 auipc ra,0x0 7ca: ec6080e7 jalr -314(ra) # 68c <free> return freep; 7ce: 00093503 ld a0,0(s2) if((p = morecore(nunits)) == 0) 7d2: d971 beqz a0,7a6 <malloc+0x92> for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 7d4: 611c ld a5,0(a0) if(p->s.size >= nunits){ 7d6: 4798 lw a4,8(a5) 7d8: fa9776e3 bgeu a4,s1,784 <malloc+0x70> if(p == freep) 7dc: 00093703 ld a4,0(s2) 7e0: 853e mv a0,a5 7e2: fef719e3 bne a4,a5,7d4 <malloc+0xc0> p = sbrk(nu * sizeof(Header)); 7e6: 8552 mv a0,s4 7e8: 00000097 auipc ra,0x0 7ec: b76080e7 jalr -1162(ra) # 35e <sbrk> if(p == (char*)-1) 7f0: fd5518e3 bne a0,s5,7c0 <malloc+0xac> return 0; 7f4: 4501 li a0,0 7f6: bf45 j 7a6 <malloc+0x92>
rust.g4
adtac/testlr
0
7037
<filename>rust.g4<gh_stars>0 grammar rust; fragment XID_Start : '\u0041' .. '\u005a' | '_' | '\u0061' .. '\u007a' | '\u00aa' | '\u00b5' | '\u00ba' | '\u00c0' .. '\u00d6' | '\u00d8' .. '\u00f6' | '\u00f8' .. '\u0236' | '\u0250' .. '\u02c1' | '\u02c6' .. '\u02d1' | '\u02e0' .. '\u02e4' | '\u02ee' | '\u0386' | '\u0388' .. '\u038a' | '\u038c' | '\u038e' .. '\u03a1' | '\u03a3' .. '\u03ce' | '\u03d0' .. '\u03f5' | '\u03f7' .. '\u03fb' | '\u0400' .. '\u0481' | '\u048a' .. '\u04ce' | '\u04d0' .. '\u04f5' | '\u04f8' .. '\u04f9' | '\u0500' .. '\u050f' | '\u0531' .. '\u0556' | '\u0559' | '\u0561' .. '\u0587' | '\u05d0' .. '\u05ea' | '\u05f0' .. '\u05f2' | '\u0621' .. '\u063a' | '\u0640' .. '\u064a' | '\u066e' .. '\u066f' | '\u0671' .. '\u06d3' | '\u06d5' | '\u06e5' .. '\u06e6' | '\u06ee' .. '\u06ef' | '\u06fa' .. '\u06fc' | '\u06ff' | '\u0710' | '\u0712' .. '\u072f' | '\u074d' .. '\u074f' | '\u0780' .. '\u07a5' | '\u07b1' | '\u0904' .. '\u0939' | '\u093d' | '\u0950' | '\u0958' .. '\u0961' | '\u0985' .. '\u098c' | '\u098f' .. '\u0990' | '\u0993' .. '\u09a8' | '\u09aa' .. '\u09b0' | '\u09b2' | '\u09b6' .. '\u09b9' | '\u09bd' | '\u09dc' .. '\u09dd' | '\u09df' .. '\u09e1' | '\u09f0' .. '\u09f1' | '\u0a05' .. '\u0a0a' | '\u0a0f' .. '\u0a10' | '\u0a13' .. '\u0a28' | '\u0a2a' .. '\u0a30' | '\u0a32' .. '\u0a33' | '\u0a35' .. '\u0a36' | '\u0a38' .. '\u0a39' | '\u0a59' .. '\u0a5c' | '\u0a5e' | '\u0a72' .. '\u0a74' | '\u0a85' .. '\u0a8d' | '\u0a8f' .. '\u0a91' | '\u0a93' .. '\u0aa8' | '\u0aaa' .. '\u0ab0' | '\u0ab2' .. '\u0ab3' | '\u0ab5' .. '\u0ab9' | '\u0abd' | '\u0ad0' | '\u0ae0' .. '\u0ae1' | '\u0b05' .. '\u0b0c' | '\u0b0f' .. '\u0b10' | '\u0b13' .. '\u0b28' | '\u0b2a' .. '\u0b30' | '\u0b32' .. '\u0b33' | '\u0b35' .. '\u0b39' | '\u0b3d' | '\u0b5c' .. '\u0b5d' | '\u0b5f' .. '\u0b61' | '\u0b71' | '\u0b83' | '\u0b85' .. '\u0b8a' | '\u0b8e' .. '\u0b90' | '\u0b92' .. '\u0b95' | '\u0b99' .. '\u0b9a' | '\u0b9c' | '\u0b9e' .. '\u0b9f' | '\u0ba3' .. '\u0ba4' | '\u0ba8' .. '\u0baa' | '\u0bae' .. '\u0bb5' | '\u0bb7' .. '\u0bb9' | '\u0c05' .. '\u0c0c' | '\u0c0e' .. '\u0c10' | '\u0c12' .. '\u0c28' | '\u0c2a' .. '\u0c33' | '\u0c35' .. '\u0c39' | '\u0c60' .. '\u0c61' | '\u0c85' .. '\u0c8c' | '\u0c8e' .. '\u0c90' | '\u0c92' .. '\u0ca8' | '\u0caa' .. '\u0cb3' | '\u0cb5' .. '\u0cb9' | '\u0cbd' | '\u0cde' | '\u0ce0' .. '\u0ce1' | '\u0d05' .. '\u0d0c' | '\u0d0e' .. '\u0d10' | '\u0d12' .. '\u0d28' | '\u0d2a' .. '\u0d39' | '\u0d60' .. '\u0d61' | '\u0d85' .. '\u0d96' | '\u0d9a' .. '\u0db1' | '\u0db3' .. '\u0dbb' | '\u0dbd' | '\u0dc0' .. '\u0dc6' | '\u0e01' .. '\u0e30' | '\u0e32' | '\u0e40' .. '\u0e46' | '\u0e81' .. '\u0e82' | '\u0e84' | '\u0e87' .. '\u0e88' | '\u0e8a' | '\u0e8d' | '\u0e94' .. '\u0e97' | '\u0e99' .. '\u0e9f' | '\u0ea1' .. '\u0ea3' | '\u0ea5' | '\u0ea7' | '\u0eaa' .. '\u0eab' | '\u0ead' .. '\u0eb0' | '\u0eb2' | '\u0ebd' | '\u0ec0' .. '\u0ec4' | '\u0ec6' | '\u0edc' .. '\u0edd' | '\u0f00' | '\u0f40' .. '\u0f47' | '\u0f49' .. '\u0f6a' | '\u0f88' .. '\u0f8b' | '\u1000' .. '\u1021' | '\u1023' .. '\u1027' | '\u1029' .. '\u102a' | '\u1050' .. '\u1055' | '\u10a0' .. '\u10c5' | '\u10d0' .. '\u10f8' | '\u1100' .. '\u1159' | '\u115f' .. '\u11a2' | '\u11a8' .. '\u11f9' | '\u1200' .. '\u1206' | '\u1208' .. '\u1246' | '\u1248' | '\u124a' .. '\u124d' | '\u1250' .. '\u1256' | '\u1258' | '\u125a' .. '\u125d' | '\u1260' .. '\u1286' | '\u1288' | '\u128a' .. '\u128d' | '\u1290' .. '\u12ae' | '\u12b0' | '\u12b2' .. '\u12b5' | '\u12b8' .. '\u12be' | '\u12c0' | '\u12c2' .. '\u12c5' | '\u12c8' .. '\u12ce' | '\u12d0' .. '\u12d6' | '\u12d8' .. '\u12ee' | '\u12f0' .. '\u130e' | '\u1310' | '\u1312' .. '\u1315' | '\u1318' .. '\u131e' | '\u1320' .. '\u1346' | '\u1348' .. '\u135a' | '\u13a0' .. '\u13f4' | '\u1401' .. '\u166c' | '\u166f' .. '\u1676' | '\u1681' .. '\u169a' | '\u16a0' .. '\u16ea' | '\u16ee' .. '\u16f0' | '\u1700' .. '\u170c' | '\u170e' .. '\u1711' | '\u1720' .. '\u1731' | '\u1740' .. '\u1751' | '\u1760' .. '\u176c' | '\u176e' .. '\u1770' | '\u1780' .. '\u17b3' | '\u17d7' | '\u17dc' | '\u1820' .. '\u1877' | '\u1880' .. '\u18a8' | '\u1900' .. '\u191c' | '\u1950' .. '\u196d' | '\u1970' .. '\u1974' | '\u1d00' .. '\u1d6b' | '\u1e00' .. '\u1e9b' | '\u1ea0' .. '\u1ef9' | '\u1f00' .. '\u1f15' | '\u1f18' .. '\u1f1d' | '\u1f20' .. '\u1f45' | '\u1f48' .. '\u1f4d' | '\u1f50' .. '\u1f57' | '\u1f59' | '\u1f5b' | '\u1f5d' | '\u1f5f' .. '\u1f7d' | '\u1f80' .. '\u1fb4' | '\u1fb6' .. '\u1fbc' | '\u1fbe' | '\u1fc2' .. '\u1fc4' | '\u1fc6' .. '\u1fcc' | '\u1fd0' .. '\u1fd3' | '\u1fd6' .. '\u1fdb' | '\u1fe0' .. '\u1fec' | '\u1ff2' .. '\u1ff4' | '\u1ff6' .. '\u1ffc' | '\u2071' | '\u207f' | '\u2102' | '\u2107' | '\u210a' .. '\u2113' | '\u2115' | '\u2118' .. '\u211d' | '\u2124' | '\u2126' | '\u2128' | '\u212a' .. '\u2131' | '\u2133' .. '\u2139' | '\u213d' .. '\u213f' | '\u2145' .. '\u2149' | '\u2160' .. '\u2183' | '\u3005' .. '\u3007' | '\u3021' .. '\u3029' | '\u3031' .. '\u3035' | '\u3038' .. '\u303c' | '\u3041' .. '\u3096' | '\u309d' .. '\u309f' | '\u30a1' .. '\u30fa' | '\u30fc' .. '\u30ff' | '\u3105' .. '\u312c' | '\u3131' .. '\u318e' | '\u31a0' .. '\u31b7' | '\u31f0' .. '\u31ff' | '\u3400' .. '\u4db5' | '\u4e00' .. '\u9fa5' | '\ua000' .. '\ua48c' | '\uac00' .. '\ud7a3' | '\uf900' .. '\ufa2d' | '\ufa30' .. '\ufa6a' | '\ufb00' .. '\ufb06' | '\ufb13' .. '\ufb17' | '\ufb1d' | '\ufb1f' .. '\ufb28' | '\ufb2a' .. '\ufb36' | '\ufb38' .. '\ufb3c' | '\ufb3e' | '\ufb40' .. '\ufb41' | '\ufb43' .. '\ufb44' | '\ufb46' .. '\ufbb1' | '\ufbd3' .. '\ufc5d' | '\ufc64' .. '\ufd3d' | '\ufd50' .. '\ufd8f' | '\ufd92' .. '\ufdc7' | '\ufdf0' .. '\ufdf9' | '\ufe71' | '\ufe73' | '\ufe77' | '\ufe79' | '\ufe7b' | '\ufe7d' | '\ufe7f' .. '\ufefc' | '\uff21' .. '\uff3a' | '\uff41' .. '\uff5a' | '\uff66' .. '\uff9d' | '\uffa0' .. '\uffbe' | '\uffc2' .. '\uffc7' | '\uffca' .. '\uffcf' | '\uffd2' .. '\uffd7' | '\uffda' .. '\uffdc' | '\ud800' '\udc00' .. '\udc0a' | '\ud800' '\udc0d' .. '\udc25' | '\ud800' '\udc28' .. '\udc39' | '\ud800' '\udc3c' .. '\udc3c' | '\ud800' '\udc3f' .. '\udc4c' | '\ud800' '\udc50' .. '\udc5c' | '\ud800' '\udc80' .. '\udcf9' | '\ud800' '\udf00' .. '\udf1d' | '\ud800' '\udf30' .. '\udf49' | '\ud800' '\udf80' .. '\udf9c' | '\ud801' '\ue000' .. '\ue09c' | '\ud802' '\ue400' .. '\ue404' | '\ud802' '\u0808' | '\ud802' '\ue40a' .. '\ue434' | '\ud802' '\ue437' .. '\ue437' | '\ud802' '\u083c' | '\ud802' '\u083f' | '\ud835' '\ub000' .. '\ub053' | '\ud835' '\ub056' .. '\ub09b' | '\ud835' '\ub09e' .. '\ub09e' | '\ud835' '\ud4a2' | '\ud835' '\ub0a5' .. '\ub0a5' | '\ud835' '\ub0a9' .. '\ub0ab' | '\ud835' '\ub0ae' .. '\ub0b8' | '\ud835' '\ud4bb' | '\ud835' '\ub0bd' .. '\ub0c2' | '\ud835' '\ub0c5' .. '\ub104' | '\ud835' '\ub107' .. '\ub109' | '\ud835' '\ub10d' .. '\ub113' | '\ud835' '\ub116' .. '\ub11b' | '\ud835' '\ub11e' .. '\ub138' | '\ud835' '\ub13b' .. '\ub13d' | '\ud835' '\ub140' .. '\ub143' | '\ud835' '\ud546' | '\ud835' '\ub14a' .. '\ub14f' | '\ud835' '\ub152' .. '\ub2a2' | '\ud835' '\ub2a8' .. '\ub2bf' | '\ud835' '\ub2c2' .. '\ub2d9' | '\ud835' '\ub2dc' .. '\ub2f9' | '\ud835' '\ub2fc' .. '\ub313' | '\ud835' '\ub316' .. '\ub333' | '\ud835' '\ub336' .. '\ub34d' | '\ud835' '\ub350' .. '\ub36d' | '\ud835' '\ub370' .. '\ub387' | '\ud835' '\ub38a' .. '\ub3a7' | '\ud835' '\ub3aa' .. '\ub3c1' | '\ud835' '\ub3c4' .. '\ub3c8' | '\ud840' '\udc00' .. '\udffe' | '\ud841' '\ue000' .. '\ue3fe' | '\ud842' '\ue400' .. '\ue7fe' | '\ud843' '\ue800' .. '\uebfe' | '\ud844' '\uec00' .. '\ueffe' | '\ud845' '\uf000' .. '\uf3fe' | '\ud846' '\uf400' .. '\uf7fe' | '\ud847' '\uf800' .. '\ufbfe' | '\ud848' '\ufc00' .. '\ufffe' | '\ud849' '\u0000' .. '\u03fe' | '\ud84a' '\u0400' .. '\u07fe' | '\ud84b' '\u0800' .. '\u0bfe' | '\ud84c' '\u0c00' .. '\u0ffe' | '\ud84d' '\u1000' .. '\u13fe' | '\ud84e' '\u1400' .. '\u17fe' | '\ud84f' '\u1800' .. '\u1bfe' | '\ud850' '\u1c00' .. '\u1ffe' | '\ud851' '\u2000' .. '\u23fe' | '\ud852' '\u2400' .. '\u27fe' | '\ud853' '\u2800' .. '\u2bfe' | '\ud854' '\u2c00' .. '\u2ffe' | '\ud855' '\u3000' .. '\u33fe' | '\ud856' '\u3400' .. '\u37fe' | '\ud857' '\u3800' .. '\u3bfe' | '\ud858' '\u3c00' .. '\u3ffe' | '\ud859' '\u4000' .. '\u43fe' | '\ud85a' '\u4400' .. '\u47fe' | '\ud85b' '\u4800' .. '\u4bfe' | '\ud85c' '\u4c00' .. '\u4ffe' | '\ud85d' '\u5000' .. '\u53fe' | '\ud85e' '\u5400' .. '\u57fe' | '\ud85f' '\u5800' .. '\u5bfe' | '\ud860' '\u5c00' .. '\u5ffe' | '\ud861' '\u6000' .. '\u63fe' | '\ud862' '\u6400' .. '\u67fe' | '\ud863' '\u6800' .. '\u6bfe' | '\ud864' '\u6c00' .. '\u6ffe' | '\ud865' '\u7000' .. '\u73fe' | '\ud866' '\u7400' .. '\u77fe' | '\ud867' '\u7800' .. '\u7bfe' | '\ud868' '\u7c00' .. '\u7ffe' | '\ud869' '\u8000' .. '\u82d5' | '\ud87e' '\ud400' .. '\ud61c' ; fragment XID_Continue: '\u0030' .. '\u0039' | '\u0041' .. '\u005a' | '\u005f' | '\u0061' .. '\u007a' | '\u00aa' | '\u00b5' | '\u00b7' | '\u00ba' | '\u00c0' .. '\u00d6' | '\u00d8' .. '\u00f6' | '\u00f8' .. '\u0236' | '\u0250' .. '\u02c1' | '\u02c6' .. '\u02d1' | '\u02e0' .. '\u02e4' | '\u02ee' | '\u0300' .. '\u0357' | '\u035d' .. '\u036f' | '\u0386' | '\u0388' .. '\u038a' | '\u038c' | '\u038e' .. '\u03a1' | '\u03a3' .. '\u03ce' | '\u03d0' .. '\u03f5' | '\u03f7' .. '\u03fb' | '\u0400' .. '\u0481' | '\u0483' .. '\u0486' | '\u048a' .. '\u04ce' | '\u04d0' .. '\u04f5' | '\u04f8' .. '\u04f9' | '\u0500' .. '\u050f' | '\u0531' .. '\u0556' | '\u0559' | '\u0561' .. '\u0587' | '\u0591' .. '\u05a1' | '\u05a3' .. '\u05b9' | '\u05bb' .. '\u05bd' | '\u05bf' | '\u05c1' .. '\u05c2' | '\u05c4' | '\u05d0' .. '\u05ea' | '\u05f0' .. '\u05f2' | '\u0610' .. '\u0615' | '\u0621' .. '\u063a' | '\u0640' .. '\u0658' | '\u0660' .. '\u0669' | '\u066e' .. '\u06d3' | '\u06d5' .. '\u06dc' | '\u06df' .. '\u06e8' | '\u06ea' .. '\u06fc' | '\u06ff' | '\u0710' .. '\u074a' | '\u074d' .. '\u074f' | '\u0780' .. '\u07b1' | '\u0901' .. '\u0939' | '\u093c' .. '\u094d' | '\u0950' .. '\u0954' | '\u0958' .. '\u0963' | '\u0966' .. '\u096f' | '\u0981' .. '\u0983' | '\u0985' .. '\u098c' | '\u098f' .. '\u0990' | '\u0993' .. '\u09a8' | '\u09aa' .. '\u09b0' | '\u09b2' | '\u09b6' .. '\u09b9' | '\u09bc' .. '\u09c4' | '\u09c7' .. '\u09c8' | '\u09cb' .. '\u09cd' | '\u09d7' | '\u09dc' .. '\u09dd' | '\u09df' .. '\u09e3' | '\u09e6' .. '\u09f1' | '\u0a01' .. '\u0a03' | '\u0a05' .. '\u0a0a' | '\u0a0f' .. '\u0a10' | '\u0a13' .. '\u0a28' | '\u0a2a' .. '\u0a30' | '\u0a32' .. '\u0a33' | '\u0a35' .. '\u0a36' | '\u0a38' .. '\u0a39' | '\u0a3c' | '\u0a3e' .. '\u0a42' | '\u0a47' .. '\u0a48' | '\u0a4b' .. '\u0a4d' | '\u0a59' .. '\u0a5c' | '\u0a5e' | '\u0a66' .. '\u0a74' | '\u0a81' .. '\u0a83' | '\u0a85' .. '\u0a8d' | '\u0a8f' .. '\u0a91' | '\u0a93' .. '\u0aa8' | '\u0aaa' .. '\u0ab0' | '\u0ab2' .. '\u0ab3' | '\u0ab5' .. '\u0ab9' | '\u0abc' .. '\u0ac5' | '\u0ac7' .. '\u0ac9' | '\u0acb' .. '\u0acd' | '\u0ad0' | '\u0ae0' .. '\u0ae3' | '\u0ae6' .. '\u0aef' | '\u0b01' .. '\u0b03' | '\u0b05' .. '\u0b0c' | '\u0b0f' .. '\u0b10' | '\u0b13' .. '\u0b28' | '\u0b2a' .. '\u0b30' | '\u0b32' .. '\u0b33' | '\u0b35' .. '\u0b39' | '\u0b3c' .. '\u0b43' | '\u0b47' .. '\u0b48' | '\u0b4b' .. '\u0b4d' | '\u0b56' .. '\u0b57' | '\u0b5c' .. '\u0b5d' | '\u0b5f' .. '\u0b61' | '\u0b66' .. '\u0b6f' | '\u0b71' | '\u0b82' .. '\u0b83' | '\u0b85' .. '\u0b8a' | '\u0b8e' .. '\u0b90' | '\u0b92' .. '\u0b95' | '\u0b99' .. '\u0b9a' | '\u0b9c' | '\u0b9e' .. '\u0b9f' | '\u0ba3' .. '\u0ba4' | '\u0ba8' .. '\u0baa' | '\u0bae' .. '\u0bb5' | '\u0bb7' .. '\u0bb9' | '\u0bbe' .. '\u0bc2' | '\u0bc6' .. '\u0bc8' | '\u0bca' .. '\u0bcd' | '\u0bd7' | '\u0be7' .. '\u0bef' | '\u0c01' .. '\u0c03' | '\u0c05' .. '\u0c0c' | '\u0c0e' .. '\u0c10' | '\u0c12' .. '\u0c28' | '\u0c2a' .. '\u0c33' | '\u0c35' .. '\u0c39' | '\u0c3e' .. '\u0c44' | '\u0c46' .. '\u0c48' | '\u0c4a' .. '\u0c4d' | '\u0c55' .. '\u0c56' | '\u0c60' .. '\u0c61' | '\u0c66' .. '\u0c6f' | '\u0c82' .. '\u0c83' | '\u0c85' .. '\u0c8c' | '\u0c8e' .. '\u0c90' | '\u0c92' .. '\u0ca8' | '\u0caa' .. '\u0cb3' | '\u0cb5' .. '\u0cb9' | '\u0cbc' .. '\u0cc4' | '\u0cc6' .. '\u0cc8' | '\u0cca' .. '\u0ccd' | '\u0cd5' .. '\u0cd6' | '\u0cde' | '\u0ce0' .. '\u0ce1' | '\u0ce6' .. '\u0cef' | '\u0d02' .. '\u0d03' | '\u0d05' .. '\u0d0c' | '\u0d0e' .. '\u0d10' | '\u0d12' .. '\u0d28' | '\u0d2a' .. '\u0d39' | '\u0d3e' .. '\u0d43' | '\u0d46' .. '\u0d48' | '\u0d4a' .. '\u0d4d' | '\u0d57' | '\u0d60' .. '\u0d61' | '\u0d66' .. '\u0d6f' | '\u0d82' .. '\u0d83' | '\u0d85' .. '\u0d96' | '\u0d9a' .. '\u0db1' | '\u0db3' .. '\u0dbb' | '\u0dbd' | '\u0dc0' .. '\u0dc6' | '\u0dca' | '\u0dcf' .. '\u0dd4' | '\u0dd6' | '\u0dd8' .. '\u0ddf' | '\u0df2' .. '\u0df3' | '\u0e01' .. '\u0e3a' | '\u0e40' .. '\u0e4e' | '\u0e50' .. '\u0e59' | '\u0e81' .. '\u0e82' | '\u0e84' | '\u0e87' .. '\u0e88' | '\u0e8a' | '\u0e8d' | '\u0e94' .. '\u0e97' | '\u0e99' .. '\u0e9f' | '\u0ea1' .. '\u0ea3' | '\u0ea5' | '\u0ea7' | '\u0eaa' .. '\u0eab' | '\u0ead' .. '\u0eb9' | '\u0ebb' .. '\u0ebd' | '\u0ec0' .. '\u0ec4' | '\u0ec6' | '\u0ec8' .. '\u0ecd' | '\u0ed0' .. '\u0ed9' | '\u0edc' .. '\u0edd' | '\u0f00' | '\u0f18' .. '\u0f19' | '\u0f20' .. '\u0f29' | '\u0f35' | '\u0f37' | '\u0f39' | '\u0f3e' .. '\u0f47' | '\u0f49' .. '\u0f6a' | '\u0f71' .. '\u0f84' | '\u0f86' .. '\u0f8b' | '\u0f90' .. '\u0f97' | '\u0f99' .. '\u0fbc' | '\u0fc6' | '\u1000' .. '\u1021' | '\u1023' .. '\u1027' | '\u1029' .. '\u102a' | '\u102c' .. '\u1032' | '\u1036' .. '\u1039' | '\u1040' .. '\u1049' | '\u1050' .. '\u1059' | '\u10a0' .. '\u10c5' | '\u10d0' .. '\u10f8' | '\u1100' .. '\u1159' | '\u115f' .. '\u11a2' | '\u11a8' .. '\u11f9' | '\u1200' .. '\u1206' | '\u1208' .. '\u1246' | '\u1248' | '\u124a' .. '\u124d' | '\u1250' .. '\u1256' | '\u1258' | '\u125a' .. '\u125d' | '\u1260' .. '\u1286' | '\u1288' | '\u128a' .. '\u128d' | '\u1290' .. '\u12ae' | '\u12b0' | '\u12b2' .. '\u12b5' | '\u12b8' .. '\u12be' | '\u12c0' | '\u12c2' .. '\u12c5' | '\u12c8' .. '\u12ce' | '\u12d0' .. '\u12d6' | '\u12d8' .. '\u12ee' | '\u12f0' .. '\u130e' | '\u1310' | '\u1312' .. '\u1315' | '\u1318' .. '\u131e' | '\u1320' .. '\u1346' | '\u1348' .. '\u135a' | '\u1369' .. '\u1371' | '\u13a0' .. '\u13f4' | '\u1401' .. '\u166c' | '\u166f' .. '\u1676' | '\u1681' .. '\u169a' | '\u16a0' .. '\u16ea' | '\u16ee' .. '\u16f0' | '\u1700' .. '\u170c' | '\u170e' .. '\u1714' | '\u1720' .. '\u1734' | '\u1740' .. '\u1753' | '\u1760' .. '\u176c' | '\u176e' .. '\u1770' | '\u1772' .. '\u1773' | '\u1780' .. '\u17b3' | '\u17b6' .. '\u17d3' | '\u17d7' | '\u17dc' .. '\u17dd' | '\u17e0' .. '\u17e9' | '\u180b' .. '\u180d' | '\u1810' .. '\u1819' | '\u1820' .. '\u1877' | '\u1880' .. '\u18a9' | '\u1900' .. '\u191c' | '\u1920' .. '\u192b' | '\u1930' .. '\u193b' | '\u1946' .. '\u196d' | '\u1970' .. '\u1974' | '\u1d00' .. '\u1d6b' | '\u1e00' .. '\u1e9b' | '\u1ea0' .. '\u1ef9' | '\u1f00' .. '\u1f15' | '\u1f18' .. '\u1f1d' | '\u1f20' .. '\u1f45' | '\u1f48' .. '\u1f4d' | '\u1f50' .. '\u1f57' | '\u1f59' | '\u1f5b' | '\u1f5d' | '\u1f5f' .. '\u1f7d' | '\u1f80' .. '\u1fb4' | '\u1fb6' .. '\u1fbc' | '\u1fbe' | '\u1fc2' .. '\u1fc4' | '\u1fc6' .. '\u1fcc' | '\u1fd0' .. '\u1fd3' | '\u1fd6' .. '\u1fdb' | '\u1fe0' .. '\u1fec' | '\u1ff2' .. '\u1ff4' | '\u1ff6' .. '\u1ffc' | '\u203f' .. '\u2040' | '\u2054' | '\u2071' | '\u207f' | '\u20d0' .. '\u20dc' | '\u20e1' | '\u20e5' .. '\u20ea' | '\u2102' | '\u2107' | '\u210a' .. '\u2113' | '\u2115' | '\u2118' .. '\u211d' | '\u2124' | '\u2126' | '\u2128' | '\u212a' .. '\u2131' | '\u2133' .. '\u2139' | '\u213d' .. '\u213f' | '\u2145' .. '\u2149' | '\u2160' .. '\u2183' | '\u3005' .. '\u3007' | '\u3021' .. '\u302f' | '\u3031' .. '\u3035' | '\u3038' .. '\u303c' | '\u3041' .. '\u3096' | '\u3099' .. '\u309a' | '\u309d' .. '\u309f' | '\u30a1' .. '\u30ff' | '\u3105' .. '\u312c' | '\u3131' .. '\u318e' | '\u31a0' .. '\u31b7' | '\u31f0' .. '\u31ff' | '\u3400' .. '\u4db5' | '\u4e00' .. '\u9fa5' | '\ua000' .. '\ua48c' | '\uac00' .. '\ud7a3' | '\uf900' .. '\ufa2d' | '\ufa30' .. '\ufa6a' | '\ufb00' .. '\ufb06' | '\ufb13' .. '\ufb17' | '\ufb1d' .. '\ufb28' | '\ufb2a' .. '\ufb36' | '\ufb38' .. '\ufb3c' | '\ufb3e' | '\ufb40' .. '\ufb41' | '\ufb43' .. '\ufb44' | '\ufb46' .. '\ufbb1' | '\ufbd3' .. '\ufc5d' | '\ufc64' .. '\ufd3d' | '\ufd50' .. '\ufd8f' | '\ufd92' .. '\ufdc7' | '\ufdf0' .. '\ufdf9' | '\ufe00' .. '\ufe0f' | '\ufe20' .. '\ufe23' | '\ufe33' .. '\ufe34' | '\ufe4d' .. '\ufe4f' | '\ufe71' | '\ufe73' | '\ufe77' | '\ufe79' | '\ufe7b' | '\ufe7d' | '\ufe7f' .. '\ufefc' | '\uff10' .. '\uff19' | '\uff21' .. '\uff3a' | '\uff3f' | '\uff41' .. '\uff5a' | '\uff65' .. '\uffbe' | '\uffc2' .. '\uffc7' | '\uffca' .. '\uffcf' | '\uffd2' .. '\uffd7' | '\uffda' .. '\uffdc' | '\ud800' '\udc00' .. '\udc0a' | '\ud800' '\udc0d' .. '\udc25' | '\ud800' '\udc28' .. '\udc39' | '\ud800' '\udc3c' .. '\udc3c' | '\ud800' '\udc3f' .. '\udc4c' | '\ud800' '\udc50' .. '\udc5c' | '\ud800' '\udc80' .. '\udcf9' | '\ud800' '\udf00' .. '\udf1d' | '\ud800' '\udf30' .. '\udf49' | '\ud800' '\udf80' .. '\udf9c' | '\ud801' '\ue000' .. '\ue09c' | '\ud801' '\ue0a0' .. '\ue0a8' | '\ud802' '\ue400' .. '\ue404' | '\ud802' '\u0808' | '\ud802' '\ue40a' .. '\ue434' | '\ud802' '\ue437' .. '\ue437' | '\ud802' '\u083c' | '\ud802' '\u083f' | '\ud834' '\uad65' .. '\uad68' | '\ud834' '\uad6d' .. '\uad71' | '\ud834' '\uad7b' .. '\uad81' | '\ud834' '\uad85' .. '\uad8a' | '\ud834' '\uadaa' .. '\uadac' | '\ud835' '\ub000' .. '\ub053' | '\ud835' '\ub056' .. '\ub09b' | '\ud835' '\ub09e' .. '\ub09e' | '\ud835' '\ud4a2' | '\ud835' '\ub0a5' .. '\ub0a5' | '\ud835' '\ub0a9' .. '\ub0ab' | '\ud835' '\ub0ae' .. '\ub0b8' | '\ud835' '\ud4bb' | '\ud835' '\ub0bd' .. '\ub0c2' | '\ud835' '\ub0c5' .. '\ub104' | '\ud835' '\ub107' .. '\ub109' | '\ud835' '\ub10d' .. '\ub113' | '\ud835' '\ub116' .. '\ub11b' | '\ud835' '\ub11e' .. '\ub138' | '\ud835' '\ub13b' .. '\ub13d' | '\ud835' '\ub140' .. '\ub143' | '\ud835' '\ud546' | '\ud835' '\ub14a' .. '\ub14f' | '\ud835' '\ub152' .. '\ub2a2' | '\ud835' '\ub2a8' .. '\ub2bf' | '\ud835' '\ub2c2' .. '\ub2d9' | '\ud835' '\ub2dc' .. '\ub2f9' | '\ud835' '\ub2fc' .. '\ub313' | '\ud835' '\ub316' .. '\ub333' | '\ud835' '\ub336' .. '\ub34d' | '\ud835' '\ub350' .. '\ub36d' | '\ud835' '\ub370' .. '\ub387' | '\ud835' '\ub38a' .. '\ub3a7' | '\ud835' '\ub3aa' .. '\ub3c1' | '\ud835' '\ub3c4' .. '\ub3c8' | '\ud835' '\ub3ce' .. '\ub3fe' | '\ud840' '\udc00' .. '\udffe' | '\ud841' '\ue000' .. '\ue3fe' | '\ud842' '\ue400' .. '\ue7fe' | '\ud843' '\ue800' .. '\uebfe' | '\ud844' '\uec00' .. '\ueffe' | '\ud845' '\uf000' .. '\uf3fe' | '\ud846' '\uf400' .. '\uf7fe' | '\ud847' '\uf800' .. '\ufbfe' | '\ud848' '\ufc00' .. '\ufffe' | '\ud849' '\u0000' .. '\u03fe' | '\ud84a' '\u0400' .. '\u07fe' | '\ud84b' '\u0800' .. '\u0bfe' | '\ud84c' '\u0c00' .. '\u0ffe' | '\ud84d' '\u1000' .. '\u13fe' | '\ud84e' '\u1400' .. '\u17fe' | '\ud84f' '\u1800' .. '\u1bfe' | '\ud850' '\u1c00' .. '\u1ffe' | '\ud851' '\u2000' .. '\u23fe' | '\ud852' '\u2400' .. '\u27fe' | '\ud853' '\u2800' .. '\u2bfe' | '\ud854' '\u2c00' .. '\u2ffe' | '\ud855' '\u3000' .. '\u33fe' | '\ud856' '\u3400' .. '\u37fe' | '\ud857' '\u3800' .. '\u3bfe' | '\ud858' '\u3c00' .. '\u3ffe' | '\ud859' '\u4000' .. '\u43fe' | '\ud85a' '\u4400' .. '\u47fe' | '\ud85b' '\u4800' .. '\u4bfe' | '\ud85c' '\u4c00' .. '\u4ffe' | '\ud85d' '\u5000' .. '\u53fe' | '\ud85e' '\u5400' .. '\u57fe' | '\ud85f' '\u5800' .. '\u5bfe' | '\ud860' '\u5c00' .. '\u5ffe' | '\ud861' '\u6000' .. '\u63fe' | '\ud862' '\u6400' .. '\u67fe' | '\ud863' '\u6800' .. '\u6bfe' | '\ud864' '\u6c00' .. '\u6ffe' | '\ud865' '\u7000' .. '\u73fe' | '\ud866' '\u7400' .. '\u77fe' | '\ud867' '\u7800' .. '\u7bfe' | '\ud868' '\u7c00' .. '\u7ffe' | '\ud869' '\u8000' .. '\u82d5' | '\ud87e' '\ud400' .. '\ud61c' | '\udb40' '\udd00' .. '\uddee' ; // === Modules and items crate: mod_body EOF; mod_body: inner_attr* item*; visibility: 'pub' visibility_restriction?; // Note that `pub(` does not necessarily signal the beginning of a visibility // restriction! For example: // // struct T(i32, i32, pub(i32)); // // Here the `(` is part of the type `(i32)`. visibility_restriction: '(' 'crate' ')' | '(' 'super' ')' | '(' 'in' ident ')'; item: attr* visibility? pub_item | attr* impl_block | attr* extern_mod | attr* item_macro_use; pub_item: extern_crate // `pub extern crate` is deprecated but still allowed | use_decl | mod_decl_short | mod_decl | static_decl | const_decl | fn_decl | type_decl | struct_decl | enum_decl | union_decl | trait_decl; item_macro_use: item_macro_path '!' ident? item_macro_tail; item_macro_path: ident | item_macro_path_parent? '::' ident; // experimental `feature(use_extern_macros)` item_macro_path_parent: 'self' | item_macro_path_segment | '::' item_macro_path_segment | item_macro_path_parent '::' item_macro_path_segment; item_macro_path_segment: ident | 'super'; item_macro_tail: tt_parens ';' | tt_brackets ';' | tt_block; // --- extern crate extern_crate: 'extern' 'crate' ident rename? ';'; // --- use declarations use_decl: 'use' use_path ';'; use_path: '::'? '{' use_item_list '}' | '::'? any_ident ('::' any_ident)* use_suffix?; use_suffix: '::' '*' | '::' '{' use_item_list? '}' | rename; use_item: (any_ident | use_path | '*') rename?; use_item_list: use_item (',' use_item)* ','?; rename: 'as' ident; // --- Modules mod_decl_short: 'mod' ident ';'; mod_decl: 'mod' ident '{' mod_body '}'; // --- Foreign modules extern_mod: extern_abi '{' inner_attr* foreign_item* '}'; foreign_item: attr* visibility? foreign_item_tail | attr* item_macro_use; foreign_item_tail: 'static' 'mut'? ident ':' ty_sum ';' | 'type' ident ';' | foreign_fn_decl; // --- static and const declarations static_decl: 'static' 'mut'? ident ':' ty_sum '=' expr ';'; const_decl: 'const' ident ':' ty_sum '=' expr ';'; associated_const_decl: 'const' ident ':' ty_sum ';'; // --- Functions fn_decl: fn_head '(' param_list? ')' fn_rtype? where_clause? block_with_inner_attrs; method_decl: fn_head '(' method_param_list? ')' fn_rtype? where_clause? block_with_inner_attrs; trait_method_decl: fn_head '(' trait_method_param_list? ')' rtype? where_clause? (block_with_inner_attrs | ';'); foreign_fn_decl: fn_head '(' variadic_param_list? ')' rtype? where_clause? ';'; // Parts of a `fn` definition up to the type parameters. // // `const` and `extern` are incompatible on a `fn`, but this grammar // does not rule it out, holding that in a hypothetical Rust language // specification, it would be clearer to specify this as a semantic // rule, not a syntactic one. That is, not every rule that can be // enforced gramatically should be. fn_head: 'const'? 'unsafe'? extern_abi? 'fn' ident ty_params?; param: pat ':' param_ty; param_ty: ty_sum | 'impl' bound; // experimental: feature(universal_impl_trait) param_list: param (',' param)* ','?; variadic_param_list: param (',' param)* (',' '...')? ','?; variadic_param_list_names_optional: trait_method_param (',' trait_method_param)* (',' '...')? ','?; self_param: 'mut'? 'self' (':' ty_sum)? | '&' Lifetime? 'mut'? 'self'; method_param_list: (param | self_param) (',' param)* ','?; // Argument names are optional in traits. The ideal grammar here would be // `(pat ':')? ty_sum`, but parsing this would be unreasonably complicated. // Instead, the `pat` is restricted to a few short, simple cases. trait_method_param: restricted_pat ':' ty_sum | ty_sum; restricted_pat: ('&' | '&&' | 'mut')? ('_' | ident); trait_method_param_list: (trait_method_param | self_param) (',' trait_method_param)* ','?; // `ty_sum` is permitted in parameter types (although as a matter of semantics // an actual sum is always rejected later, as having no statically known size), // but only `ty` in return types. This means that in the where-clause // `where T: Fn() -> X + Clone`, we're saying that T implements both // `Fn() -> X` and `Clone`, not that its return type is `X + Clone`. rtype: '->' (ty | '!'); // Experimental `feature(conservative_impl_trait)`. fn_rtype: '->' (ty | '!' | 'impl' bound); // --- type, struct, and enum declarations type_decl: 'type' ident ty_params? where_clause? '=' ty_sum ';'; struct_decl: 'struct' ident ty_params? struct_tail; struct_tail: where_clause? ';' | '(' tuple_struct_field_list? ')' where_clause? ';' | where_clause? '{' field_decl_list? '}'; tuple_struct_field: attr* visibility? ty_sum; tuple_struct_field_list: tuple_struct_field (',' tuple_struct_field)* ','?; field_decl: attr* visibility? ident ':' ty_sum; field_decl_list: field_decl (',' field_decl)* ','?; enum_decl: 'enum' ident ty_params? where_clause? '{' enum_variant_list? '}'; enum_variant: attr* visibility? enum_variant_main; enum_variant_list: enum_variant (',' enum_variant)* ','?; enum_variant_main: ident '(' enum_tuple_field_list? ')' | ident '{' enum_field_decl_list? '}' | ident '=' expr | ident; // enum variants that are tuple-struct-like can't have `pub` on individual fields. enum_tuple_field: attr* ty_sum; enum_tuple_field_list: enum_tuple_field (',' enum_tuple_field)* ','?; // enum variants that are struct-like can't have `pub` on individual fields. enum_field_decl: ident ':' ty_sum; enum_field_decl_list: enum_field_decl (',' enum_field_decl)* ','?; union_decl: 'union' ident '{' field_decl_list '}'; // --- Traits // The `auto trait` syntax is an experimental feature, `optin_builtin_traits`, // also known as OIBIT. trait_decl: 'unsafe'? 'auto'? 'trait' ident ty_params? colon_bound? where_clause? '{' trait_item* '}'; trait_item: attr* 'type' ident colon_bound? ty_default? ';' | attr* 'const' ident ':' ty_sum const_default? ';' // experimental associated constants | attr* trait_method_decl | attr* item_macro_path '!' item_macro_tail; ty_default: '=' ty_sum; const_default: '=' expr; // --- impl blocks impl_block: 'unsafe'? 'impl' ty_params? impl_what where_clause? '{' impl_item* '}'; impl_what: '!' ty_sum 'for' ty_sum | ty_sum 'for' ty_sum | ty_sum 'for' '..' | ty_sum; impl_item: attr* visibility? impl_item_tail; impl_item_tail: 'default'? method_decl | 'type' ident '=' ty_sum ';' | (const_decl | associated_const_decl) | item_macro_path '!' item_macro_tail; // === Attributes and token trees attr: '#' '[' tt* ']'; inner_attr: '#' '!' '[' tt* ']'; tt: ~('(' | ')' | '{' | '}' | '[' | ']') | tt_delimited; tt_delimited: tt_parens | tt_brackets | tt_block; tt_parens: '(' tt* ')'; tt_brackets: '[' tt* ']'; tt_block: '{' tt* '}'; macro_tail: '!' tt_delimited; // === Paths // (forward references: ty_sum, ty_args) // This is very slightly different from the syntax read by rustc: // whitespace is permitted after `self` and `super` in paths. // // In rustc, `self::x` is an acceptable path, but `self :: x` is not, // because `self` is a strict keyword except when followed immediately // by the exact characters `::`. Same goes for `super`. Pretty weird. // // So instead, this grammar accepts that `self` is a keyword, and // permits it specially at the very front of a path. Whitespace is // ignored. `super` is OK anywhere except at the end. // // Separately and more tentatively: in rustc, qualified paths are // permitted in peculiarly constrained contexts. In this grammar, // qualified paths are just part of the syntax of paths (for now - // this is not clearly an OK change). path: path_segment_no_super | path_parent? '::' path_segment_no_super; path_parent: 'self' | '<' ty_sum as_trait? '>' | path_segment | '::' path_segment | path_parent '::' path_segment; as_trait: 'as' ty_sum; path_segment: path_segment_no_super | 'super'; path_segment_no_super: simple_path_segment ('::' ty_args)?; simple_path_segment: ident | 'Self'; // === Type paths // (forward references: rtype, ty_sum, ty_args) ty_path: for_lifetime? ('dyn' | 'impl')? ty_path_main; for_lifetime: 'for' '<' lifetime_def_list? '>'; lifetime_def_list: lifetime_def (',' lifetime_def)* ','?; lifetime_def: Lifetime (':' lifetime_bound)?; lifetime_bound: Lifetime | lifetime_bound '+' Lifetime; ty_path_main: ty_path_tail | ty_path_parent? '::' ty_path_tail; ty_path_tail: (ident | 'Self') '(' ty_sum_list? ')' rtype? | ty_path_segment_no_super; ty_path_parent: 'self' | '<' ty_sum as_trait? '>' | ty_path_segment | '::' ty_path_segment | ty_path_parent '::' ty_path_segment; ty_path_segment: ty_path_segment_no_super | 'super'; ty_path_segment_no_super: (ident | 'Self') ty_args?; // === Type bounds where_clause: 'where' where_bound_list; where_bound_list: where_bound (',' where_bound)* ','?; where_bound: Lifetime ':' lifetime_bound | for_lifetime? ty empty_ok_colon_bound; empty_ok_colon_bound: ':' bound?; colon_bound: ':' bound; bound: prim_bound | bound '+' prim_bound; prim_bound: ty_path | '?' ty_path | Lifetime; // === Types and type parameters ty: '_' // The next 3 productions match exactly `'(' ty_sum_list? ')'`, // but (i32) and (i32,) are distinct types, so parse them with different rules. | '(' ')' // unit | '(' ty_sum ')' // grouping (parens are ignored) | '(' ty_sum ',' ty_sum_list? ')' // tuple | '[' ty_sum (';' expr)? ']' | '&' Lifetime? 'mut'? ty | '&&' Lifetime? 'mut'? ty // meaning `& & ty` | '*' mut_or_const ty // pointer type | for_lifetime? 'unsafe'? extern_abi? 'fn' '(' variadic_param_list_names_optional? ')' rtype? | ty_path macro_tail?; mut_or_const: 'mut' | 'const'; extern_abi: 'extern' StringLit?; ty_args: '<' lifetime_list '>' | '<' (Lifetime ',')* ty_arg_list '>'; lifetime_list: Lifetime (',' Lifetime)* ','?; ty_sum: ty ('+' bound)?; ty_sum_list: ty_sum (',' ty_sum)* ','?; ty_arg: ident '=' ty_sum | ty_sum; ty_arg_list: ty_arg (',' ty_arg)* ','?; ty_params: '<' lifetime_param_list '>' | '<' (lifetime_param ',')* ty_param_list '>'; lifetime_param: attr* Lifetime (':' lifetime_bound)?; lifetime_param_list: lifetime_param (',' lifetime_param)* ','?; ty_param: attr* ident colon_bound? ty_default?; ty_param_list: ty_param (',' ty_param)* ','?; // === Patterns pat: pat_no_mut | 'mut' ident ('@' pat)?; pat_ident: ('_' | 'ref' ident); // A `pat_no_mut` is a pattern that does not start with `mut`. // It is distinct from `pat` to rule out ambiguity in parsing the // pattern `&mut x`, which must parse like `&mut (x)`, not `&(mut x)`. pat_no_mut: '_' | pat_lit | pat_range_end '...' pat_range_end | pat_range_end '..' pat_range_end // experimental `feature(exclusive_range_pattern)` | pat_range_end '..=' pat_range_end | path macro_tail | (pat_ident ',')* pat_ident ('@' pat)? | 'ref' 'mut' ident ('@' pat)? | path '(' pat_list_with_dots? ')' | path '{' pat_fields? '}' | path // BUG: ambiguity with bare ident case (above) | '(' pat_list_with_dots? ')' | '[' ((pat_ident ',')* pat_ident '@')? pat_elt_list? ']' | '&' pat_no_mut | '&' 'mut' pat | '&&' pat_no_mut // `&& pat` means the same as `& & pat` | '&&' 'mut' pat | 'box' pat; pat_range_end: path | pat_lit; pat_lit: '-'? lit; pat_list: pat (',' pat)* ','?; pat_list_with_dots: pat_list_dots_tail | pat (',' pat)* (',' pat_list_dots_tail?)?; pat_list_dots_tail: '..' (',' pat_list)?; // rustc does not accept `[1, 2, tail..,]` as a pattern, because of the // trailing comma, but I don't see how this is justifiable. The rest of the // language is *extremely* consistent in this regard, so I allow the trailing // comma here. // // This grammar does not enforce the rule that a given slice pattern must have // at most one `..`. pat_elt: pat '..'? | '..'; pat_elt_list: pat_elt (',' pat_elt)* ','?; pat_fields_left: (ident | BareIntLit | FullIntLit); pat_fields: '..' | pat_fields_left ':' pat_fields_left (',' pat_fields_left ':' pat_fields_left)* | pat_field (',' pat_field)* (',' '..' | ','?); pat_field: 'box'? 'ref'? 'mut'? ident | ident ':' pat; // === Expressions expr: assign_expr; expr_no_struct: assign_expr_no_struct; expr_list: expr (',' expr)* ','?; // --- Blocks // OK, this is super tricky. There is an ambiguity in the grammar for blocks, // `{ stmt* expr? }`, since there are strings that match both `{ stmt expr }` // and `{ expr }`. // // The rule in Rust is that the `{ stmt expr }` parse is preferred: the body // of the block `{ loop { break } - 1 }` is a `loop` statement followed by // the expression `-1`, not a single subtraction-expression. // // Agreeably, the rule to resolve such ambiguities in ANTLR4, as in JS regexps, // is the same. Earlier alternatives that match are preferred over later // alternatives that match longer sequences of source tokens. block: '{' stmt* expr? '}'; // Shared by blocky_expr and fn_body; in the latter case, any inner attributes // apply to the whole fn. block_with_inner_attrs: '{' inner_attr* stmt* expr? '}'; stmt: ';' | item // Statement macros are included here. | stmt_tail; // Attributes are supported on most statements. Let statements can have // attributes; block statements can have outer or inner attributes, like this: // // fn f() { // #[cfg(test)] // { // #![allow()] // println!("testing..."); // } // } // // Attributes on block expressions that appear anywhere else are an // experimental feature, `feature(stmt_expr_attributes)`. We support both. stmt_tail: attr* 'let' pat (':' ty)? ('=' expr)? ';' | attr* blocky_expr | expr ';'; // Inner attributes in `match`, `while`, `for`, `loop`, and `unsafe` blocks are // experimental, `feature(stmt_expr_attributes)`. blocky_expr: block_with_inner_attrs | 'if' cond_or_pat block ('else' 'if' cond_or_pat block)* ('else' block)? | 'match' expr_no_struct '{' expr_inner_attrs? match_arms? '}' | loop_label? 'while' cond_or_pat block_with_inner_attrs | loop_label? 'for' pat 'in' expr_no_struct block_with_inner_attrs | loop_label? 'loop' block_with_inner_attrs | 'unsafe' block_with_inner_attrs; cond_or_pat: expr_no_struct | 'let' pat '=' expr; loop_label: Lifetime ':'; match_arms: match_arm_intro blocky_expr ','? match_arms? | match_arm_intro expr (',' match_arms?)?; match_arm_intro: attr* match_pat match_if_clause? '=>'; match_pat: pat | match_pat '|' pat; match_if_clause: 'if' expr; // --- Primary expressions // Attributes on expressions are experimental. // Enable with `feature(stmt_expr_attributes)`. expr_attrs: attr attr*; // Inner attributes in array and struct expressions are experimental. // Enable with `feature(stmt_expr_attributes)`. expr_inner_attrs: inner_attr inner_attr*; prim_expr: prim_expr_no_struct | path '{' expr_inner_attrs? fields? '}'; prim_expr_no_struct: lit | 'self' | path macro_tail? // The next 3 productions match exactly `'(' expr_list ')'`, // but (e) and (e,) are distinct expressions, so match them separately | '(' expr_inner_attrs? ')' | '(' expr_inner_attrs? expr ')' | '(' expr_inner_attrs? expr ',' expr_list? ')' | '[' expr_inner_attrs? expr_list? ']' | '[' expr_inner_attrs? expr ';' expr ']' | 'move'? closure_params closure_tail | blocky_expr | 'break' lifetime_or_expr? | 'continue' Lifetime? | 'return' expr?; // this is IMO a rustc bug, should be expr_no_struct lit: 'true' | 'false' | BareIntLit | FullIntLit | ByteLit | ByteStringLit | FloatLit | CharLit | StringLit; closure_params: '||' | '|' closure_param_list? '|'; closure_param: pat (':' ty)?; closure_param_list: closure_param (',' closure_param)* ','?; closure_tail: rtype block | expr; lifetime_or_expr: Lifetime | expr_no_struct; fields: struct_update_base | field (',' field)* (',' struct_update_base | ','?); struct_update_base: '..' expr; // this is IMO a bug in the grammar. should be or_expr or something. field: ident // struct field shorthand (field and local variable have the same name) | field_name ':' expr; field_name: ident | BareIntLit; // Allowed for creating tuple struct values. // --- Operators post_expr: prim_expr | post_expr post_expr_tail; post_expr_tail: '?' | '[' expr ']' | '.' ident (('::' ty_args)? '(' expr_list? ')')? | '.' BareIntLit | '(' expr_list? ')'; pre_expr: post_expr | expr_attrs pre_expr | '-' pre_expr | '!' pre_expr | '&' 'mut'? pre_expr | '&&' 'mut'? pre_expr // meaning `& & expr` | '*' pre_expr | 'box' pre_expr | 'in' expr_no_struct block; // placement new - possibly not the final syntax cast_expr: pre_expr | cast_expr 'as' ty_sum | cast_expr ':' ty_sum; // experimental type ascription mul_expr: cast_expr | mul_expr '*' cast_expr | mul_expr '/' cast_expr | mul_expr '%' cast_expr; add_expr: mul_expr | add_expr '+' mul_expr | add_expr '-' mul_expr; shift_expr: add_expr | shift_expr '<' '<' add_expr | shift_expr '>' '>' add_expr; bit_and_expr: shift_expr | bit_and_expr '&' shift_expr; bit_xor_expr: bit_and_expr | bit_xor_expr '^' bit_and_expr; bit_or_expr: bit_xor_expr | bit_or_expr '|' bit_xor_expr; cmp_expr: bit_or_expr | bit_or_expr ('==' | '!=' | '<' | '<=' | '>' | '>' '=') bit_or_expr; and_expr: cmp_expr | and_expr '&&' cmp_expr; or_expr: and_expr | or_expr '||' and_expr; range_expr: or_expr | or_expr '..' or_expr? | or_expr '..=' or_expr? | '..' or_expr? | '..=' or_expr?; assign_expr: range_expr | range_expr ('=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>' '>' '=' | '&=' | '^=' | '|=' ) assign_expr; // --- Copy of the operator expression syntax but without structs post_expr_no_struct: prim_expr_no_struct | post_expr_no_struct post_expr_tail; pre_expr_no_struct: post_expr_no_struct | expr_attrs pre_expr_no_struct | '-' pre_expr_no_struct | '!' pre_expr_no_struct | '&' 'mut'? pre_expr_no_struct | '&&' 'mut'? pre_expr_no_struct // meaning `& & expr` | '*' pre_expr_no_struct | 'box' pre_expr_no_struct; cast_expr_no_struct: pre_expr_no_struct | cast_expr_no_struct 'as' ty_sum | cast_expr_no_struct ':' ty_sum; // experimental type ascription mul_expr_no_struct: cast_expr_no_struct | mul_expr_no_struct '*' cast_expr_no_struct | mul_expr_no_struct '/' cast_expr_no_struct | mul_expr_no_struct '%' cast_expr_no_struct; add_expr_no_struct: mul_expr_no_struct | add_expr_no_struct '+' mul_expr_no_struct | add_expr_no_struct '-' mul_expr_no_struct; shift_expr_no_struct: add_expr_no_struct | shift_expr_no_struct '<' '<' add_expr_no_struct | shift_expr_no_struct '>' '>' add_expr_no_struct; bit_and_expr_no_struct: shift_expr_no_struct | bit_and_expr_no_struct '&' shift_expr_no_struct; bit_xor_expr_no_struct: bit_and_expr_no_struct | bit_xor_expr_no_struct '^' bit_and_expr_no_struct; bit_or_expr_no_struct: bit_xor_expr_no_struct | bit_or_expr_no_struct '|' bit_xor_expr_no_struct; cmp_expr_no_struct: bit_or_expr_no_struct | bit_or_expr_no_struct ('==' | '!=' | '<' | '<=' | '>' | '>' '=') bit_or_expr_no_struct; and_expr_no_struct: cmp_expr_no_struct | and_expr_no_struct '&&' cmp_expr_no_struct; or_expr_no_struct: and_expr_no_struct | or_expr_no_struct '||' and_expr_no_struct; range_expr_no_struct: or_expr_no_struct | or_expr_no_struct '..' or_expr_no_struct? | or_expr_no_struct '..=' or_expr_no_struct? | '..' or_expr_no_struct? | '..=' or_expr_no_struct?; assign_expr_no_struct: range_expr_no_struct | range_expr_no_struct ('=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>' '>' '=' | '&=' | '^=' | '|=' ) assign_expr_no_struct; // === Tokens // `auto`, `default`, and 'union' are identifiers, but in certain places // they're specially recognized as keywords. ident: Ident | 'auto' | 'default' | 'union'; any_ident: ident | 'Self' | 'self' | 'static' | 'super'; // `$` is recognized as a token, so it may be present in token trees, // and `macro_rules!` makes use of it. But it is not mentioned anywhere // else in this grammar. CashMoney: '$'; fragment IDENT: XID_Start XID_Continue*; Lifetime: [']IDENT; Ident: IDENT; fragment SIMPLE_ESCAPE: '\\' [0nrt'"\\]; fragment CHAR: ~['"\r\n\\\ud800-\udfff] // a single BMP character other than a backslash, newline, or quote | [\ud800-\udbff][\udc00-\udfff] // a single non-BMP character (hack for Java) | SIMPLE_ESCAPE | '\\x' [0-7] [0-9a-fA-F] | '\\u{' [0-9a-fA-F]+ '}'; CharLit: '\'' (CHAR | '"') '\''; fragment OTHER_STRING_ELEMENT: '\'' | '\\' '\r'? '\n' [ \t]* | '\r' | '\n'; fragment STRING_ELEMENT: CHAR | OTHER_STRING_ELEMENT; fragment RAW_CHAR: ~[\ud800-\udfff] // any BMP character | [\ud800-\udbff][\udc00-\udfff]; // any non-BMP character (hack for Java) // Here we use a non-greedy match to implement the // (non-regular) rules about raw string syntax. fragment RAW_STRING_BODY: '"' RAW_CHAR*? '"' | '#' RAW_STRING_BODY '#'; StringLit: '"' STRING_ELEMENT* '"' | 'r' RAW_STRING_BODY; fragment BYTE: ' ' // any ASCII character from 32 (space) to 126 (`~`), | '!' // except 34 (double quote), 39 (single quote), and 92 (backslash) | [#-&] | [(-[] | ']' | '^' | [_-~] | SIMPLE_ESCAPE | '\\x' [0-9a-fA-F][0-9a-fA-F]; ByteLit: 'b\'' (BYTE | '"') '\''; fragment BYTE_STRING_ELEMENT: BYTE | OTHER_STRING_ELEMENT; fragment RAW_BYTE_STRING_BODY: '"' [\t\r\n -~]*? '"' | '#' RAW_BYTE_STRING_BODY '#'; ByteStringLit: 'b"' BYTE_STRING_ELEMENT* '"' | 'br' RAW_BYTE_STRING_BODY; fragment DEC_DIGITS: [0-9][0-9_]*; // BareIntLit and FullIntLit both match '123'; BareIntLit wins by virtue of // appearing first in the file. (This comment is to point out the dependency on // a less-than-obvious ANTLR rule.) BareIntLit: DEC_DIGITS; fragment INT_SUFFIX: [ui] ('8'|'16'|'32'|'64'|'size'); FullIntLit: DEC_DIGITS INT_SUFFIX? | '0x' '_'* [0-9a-fA-F] [0-9a-fA-F_]* INT_SUFFIX? | '0o' '_'* [0-7] [0-7_]* INT_SUFFIX? | '0b' '_'* [01] [01_]* INT_SUFFIX?; fragment EXPONENT: [Ee] [+-]? '_'* [0-9] [0-9_]*; fragment FLOAT_SUFFIX: 'f32' | 'f64'; // Some lookahead is required here. ANTLR does not support this // except by injecting some Java code into the middle of the pattern. // // A floating-point literal may end with a dot, but: // // * `100..f()` is parsed as `100 .. f()`, not `100. .f()`, // contrary to the usual rule that lexers are greedy. // // * Similarly, but less important, a letter or underscore after `.` // causes the dot to be interpreted as a separate token by itself, // so that `1.abs()` parses a method call. The type checker will // later reject it, though. // FloatLit: DEC_DIGITS '.' [0-9] [0-9_]* EXPONENT? FLOAT_SUFFIX? | DEC_DIGITS ('.' { /* dot followed by another dot is a range, not a float */ _input.LA(1) != '.' && /* dot followed by an identifier is an integer with a function call, not a float */ _input.LA(1) != '_' && !(_input.LA(1) >= 'a' && _input.LA(1) <= 'z') && !(_input.LA(1) >= 'A' && _input.LA(1) <= 'Z') }?) | DEC_DIGITS EXPONENT FLOAT_SUFFIX? | DEC_DIGITS FLOAT_SUFFIX; Whitespace: [ \t\r\n]+ -> skip; LineComment: '//' ~[\r\n]* -> skip; BlockComment: '/*' (~[*/] | '/'* BlockComment | '/'+ (~[*/]) | '*'+ ~[*/])* '*'+ '/' -> skip; Shebang: '#!/' ~[\r\n]* -> skip; // BUG: only ascii identifiers are permitted // BUG: doc comments are ignored // BUG: associated constants are not supported // BUG: rename `lit` -> `literal` // BUG: probably inner attributes are allowed in many more places // BUG: refactor `use_path` syntax to be like `path`, remove `any_ident` // BUG: `let [a, xs.., d] = out;` does not parse // BUG: ambiguity between expression macros, stmt macros, item macros
proglangs-learning/Agda/general-exercises/RunningHaskellCode.agda
helq/old_code
0
8063
module general-exercises.RunningHaskellCode where -- To compile code: stack exec -- agda general-exercises/RunningHaskellCode.agda -c open import Data.String using (String) open import Agda.Builtin.Unit using (⊤) -- Working directly with Haskell code, kinda dangerous stuff -- -- This didn't actually work because all Agda stuff is wrapped around colists -- and there is even more wrapping around printError to make it work. It is not -- that it is impossible, it is just a matter of copying the code from -- `IO.Primitive`, which I don't want to do right now -- --open import Agda.Builtin.IO using (IO) -- --{-# FOREIGN GHC import qualified System.IO as SIO #-} --{-# FOREIGN GHC import qualified Data.Text #-} -- --postulate printError : String → IO ⊤ -- --{-# COMPILE GHC printError = SIO.hPutStrLn SIO.stderr $ Data.Text.unpack #-} -- --main = printError "Printing to stderr!" -- Using the Standard Library open import IO using (run; putStrLn) main = run (putStrLn "Hello freaking World!") -- Exporting Agda binaries to use in Haskell code --open import Data.Nat using (ℕ; suc; zero) -- --double : ℕ → ℕ --double zero = zero --double (suc n) = suc (suc (double n)) --{-# COMPILE GHC double as doubleNat #-}
programs/oeis/036/A036741.asm
neoneye/loda
22
83375
<gh_stars>10-100 ; A036741: Values increase, Roman numerals increase lexicographically. ; 1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,20,21,22,23,24,25,26,27,28,30,31,32,33,34,35,36,37,38 add $0,1 mov $1,20 mul $1,$0 div $1,18 mov $0,$1
Working Disassembly/General/Sprites/Tails/Anim - Tails Tail.asm
TeamASM-Blur/Sonic-3-Blue-Balls-Edition
0
23750
<reponame>TeamASM-Blur/Sonic-3-Blue-Balls-Edition dc.w AniTails_Tail00-AniTails_Tail dc.w AniTails_Tail01-AniTails_Tail dc.w AniTails_Tail02-AniTails_Tail dc.w AniTails_Tail03-AniTails_Tail dc.w AniTails_Tail04-AniTails_Tail dc.w AniTails_Tail05-AniTails_Tail dc.w AniTails_Tail06-AniTails_Tail dc.w AniTails_Tail07-AniTails_Tail dc.w AniTails_Tail08-AniTails_Tail dc.w AniTails_Tail09-AniTails_Tail dc.w AniTails_Tail0A-AniTails_Tail dc.w AniTails_Tail0B-AniTails_Tail dc.w AniTails_Tail0C-AniTails_Tail AniTails_Tail00:dc.b $20, 0, $FF AniTails_Tail01:dc.b 7, $22, $23, $24, $25, $26, $FF AniTails_Tail02:dc.b 3, $22, $23, $24, $25, $26, $FD, 1 AniTails_Tail03:dc.b $FC, 5, 6, 7, 8, $FF ; ROM:00016196o AniTails_Tail04:dc.b 3, 9, $A, $B, $C, $FF AniTails_Tail05:dc.b 3, $D, $E, $F, $10, $FF AniTails_Tail06:dc.b 3, $11, $12, $13, $14, $FF AniTails_Tail07:dc.b 2, 1, 2, 3, 4, $FF AniTails_Tail08:dc.b 2, $1A, $1B, $1C, $1D, $FF AniTails_Tail09:dc.b 9, $1E, $1F, $20, $21, $FF AniTails_Tail0A:dc.b 9, $29, $2A, $2B, $2C, $FF AniTails_Tail0B:dc.b 1, $27, $28, $FF AniTails_Tail0C:dc.b 0, $27, $28, $FF even
test/Succeed/Issue2260.agda
cruhland/agda
1,989
10316
-- Andreas, 2016-10-14, issue #2260 testcase by Nisse -- {-# OPTIONS -v tc.meta:40 #-} data D : Set → Set₁ where d : (A : Set) → D A postulate A : Set f : (A : Set) → D A → D A B : Set₁ B = Set where abstract A′ : Set A′ = A x : D A′ x = f _ (d A′) -- WAS: internal error -- should check
oeis/246/A246930.asm
neoneye/loda-programs
11
22568
; A246930: Prime(12*n). ; 37,89,151,223,281,359,433,503,593,659,743,827,911,997,1069,1163,1249,1321,1439,1511,1601,1693,1783,1877,1987,2069,2143,2267,2347,2423,2543,2657,2713,2801,2903,3011,3119,3221,3323,3413,3527,3607,3697,3797,3907,4003,4093,4211,4283,4409,4513,4621,4721,4813,4937,5011,5113,5233,5351,5443,5531,5653,5743,5849,5939,6073,6173,6271,6359,6473,6581,6701,6803,6907,6997,7121,7229,7349,7487,7561,7669,7757,7879,8009,8111,8231,8317,8443,8573,8677,8753,8861,8971,9091,9199,9311,9413,9491,9623,9733 mul $0,2 add $0,1 mul $0,3 add $0,2 mul $0,2 seq $0,98090 ; Numbers k such that 2k-3 is prime. sub $0,5 mul $0,2 add $0,7
PROGS/relativo.asm
carlos-santiago-2017/HC12-MicrocontrollerNotes
0
16675
ORG $0100 UNO BRA TRES DOS BRA UNO TRES BRA CUATRO CUATRO BRA DOS 
test/asset/agda-stdlib-1.0/Data/Nat/DivMod.agda
omega12345/agda-mode
0
99
------------------------------------------------------------------------ -- The Agda standard library -- -- Natural number division ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Nat.DivMod where open import Agda.Builtin.Nat using (div-helper; mod-helper) open import Data.Fin using (Fin; toℕ; fromℕ≤) open import Data.Fin.Properties using (toℕ-fromℕ≤) open import Data.Nat as Nat open import Data.Nat.DivMod.Core open import Data.Nat.Properties using (≤⇒≤″; +-assoc; +-comm; +-identityʳ) open import Function using (_$_) open import Relation.Nullary.Decidable using (False) open import Relation.Binary.PropositionalEquality open ≡-Reasoning ------------------------------------------------------------------------ -- Basic operations infixl 7 _div_ _%_ -- Integer division _div_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → ℕ (a div 0) {} (a div suc n) = div-helper 0 n a n -- Integer remainder (mod) _%_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → ℕ (a % 0) {} (a % suc n) = mod-helper 0 n a n ------------------------------------------------------------------------ -- Properties a≡a%n+[a/n]*n : ∀ a n → a ≡ a % suc n + (a div (suc n)) * suc n a≡a%n+[a/n]*n a n = division-lemma 0 0 a n a%1≡0 : ∀ a → a % 1 ≡ 0 a%1≡0 = a[modₕ]1≡0 a%n<n : ∀ a n → a % suc n < suc n a%n<n a n = s≤s (a[modₕ]n<n 0 a n) n%n≡0 : ∀ n → suc n % suc n ≡ 0 n%n≡0 n = n[modₕ]n≡0 0 n a%n%n≡a%n : ∀ a n → a % suc n % suc n ≡ a % suc n a%n%n≡a%n a n = modₕ-idem 0 a n [a+n]%n≡a%n : ∀ a n → (a + suc n) % suc n ≡ a % suc n [a+n]%n≡a%n a n = a+n[modₕ]n≡a[modₕ]n 0 a n [a+kn]%n≡a%n : ∀ a k n → (a + k * (suc n)) % suc n ≡ a % suc n [a+kn]%n≡a%n a zero n = cong (_% suc n) (+-identityʳ a) [a+kn]%n≡a%n a (suc k) n = begin (a + (m + k * m)) % m ≡⟨ cong (_% m) (sym (+-assoc a m (k * m))) ⟩ (a + m + k * m) % m ≡⟨ [a+kn]%n≡a%n (a + m) k n ⟩ (a + m) % m ≡⟨ [a+n]%n≡a%n a n ⟩ a % m ∎ where m = suc n kn%n≡0 : ∀ k n → k * (suc n) % suc n ≡ 0 kn%n≡0 = [a+kn]%n≡a%n 0 %-distribˡ-+ : ∀ a b n → (a + b) % suc n ≡ (a % suc n + b % suc n) % suc n %-distribˡ-+ a b n = begin (a + b) % m ≡⟨ cong (λ v → (v + b) % m) (a≡a%n+[a/n]*n a n) ⟩ (a % m + a div m * m + b) % m ≡⟨ cong (_% m) (+-assoc (a % m) _ b) ⟩ (a % m + (a div m * m + b)) % m ≡⟨ cong (λ v → (a % m + v) % m) (+-comm _ b) ⟩ (a % m + (b + a div m * m)) % m ≡⟨ cong (_% m) (sym (+-assoc (a % m) b _)) ⟩ (a % m + b + a div m * m) % m ≡⟨ [a+kn]%n≡a%n (a % m + b) (a div m) n ⟩ (a % m + b) % m ≡⟨ cong (λ v → (a % m + v) % m) (a≡a%n+[a/n]*n b n) ⟩ (a % m + (b % m + (b div m) * m)) % m ≡⟨ sym (cong (_% m) (+-assoc (a % m) (b % m) _)) ⟩ (a % m + b % m + (b div m) * m) % m ≡⟨ [a+kn]%n≡a%n (a % m + b % m) (b div m) n ⟩ (a % m + b % m) % m ∎ where m = suc n ------------------------------------------------------------------------ -- A specification of integer division. record DivMod (dividend divisor : ℕ) : Set where constructor result field quotient : ℕ remainder : Fin divisor property : dividend ≡ toℕ remainder + quotient * divisor _mod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → Fin divisor (a mod 0) {} (a mod suc n) = fromℕ≤ (a%n<n a n) _divMod_ : (dividend divisor : ℕ) {≢0 : False (divisor ≟ 0)} → DivMod dividend divisor (a divMod 0) {} (a divMod suc n) = result (a div suc n) (a mod suc n) $ begin a ≡⟨ a≡a%n+[a/n]*n a n ⟩ a % suc n + [a/n]*n ≡⟨ cong (_+ [a/n]*n) (sym (toℕ-fromℕ≤ (a%n<n a n))) ⟩ toℕ (fromℕ≤ (a%n<n a n)) + [a/n]*n ∎ where [a/n]*n = a div suc n * suc n
libsrc/_DEVELOPMENT/string/c/sdcc_iy/index.asm
meesokim/z88dk
0
176941
<filename>libsrc/_DEVELOPMENT/string/c/sdcc_iy/index.asm ; BSD ; char *index(const char *s, int c) SECTION code_string PUBLIC _index EXTERN _strchr defc _index = _strchr
src/imagethresholds.adb
sebsgit/textproc
0
7286
with PixelArray; with Ada.Containers.Vectors; with Ada.Text_IO; package body ImageThresholds is function isBinary(image: PixelArray.ImagePlane) return Boolean is function checkPixel(px: Pixel) return Boolean is begin return (px = 255 or px = 0); end checkPixel; begin return image.allPixels(checkPixel'Access); end isBinary; procedure simple(image: in out PixelArray.ImagePlane; threshold: PixelArray.Pixel) is begin for y in 0 .. image.width - 1 loop for x in 0 .. image.height - 1 loop image.set(x, y, (if image.get(x, y) > threshold then 255 else 0)); end loop; end loop; end simple; function simple(image: PixelArray.ImagePlane; threshold: PixelArray.Pixel) return PixelArray.ImagePlane is begin return result: ImagePlane := PixelArray.allocate(width => image.width, height => image.height) do simple(result, threshold); end return; end simple; function circleMinMax(image: PixelArray.ImagePlane; x, y: Natural; radius: Positive) return MinMaxIntensity is result: MinMaxIntensity; begin result.max := 0; result.min := 255; for px in x - radius .. x + radius loop if px > 0 and px < image.width then for py in y - radius .. y + radius loop if py > 0 and py < image.height then if abs((x - px) ** 2 + (y - py) ** 2) < radius * radius then result.min := PixelArray.Pixel'Min(result.min, image.get(px, py)); result.max := PixelArray.Pixel'Max(result.max, image.get(px, py)); end if; end if; end loop; end if; end loop; return result; end circleMinMax; function bernsenAdaptative(image: PixelArray.ImagePlane; radius: Positive; c_min: PixelArray.Pixel) return PixelArray.ImagePlane is minMax: MinMaxIntensity; threshold: PixelArray.Pixel; begin return result: PixelArray.ImagePlane := PixelArray.allocate(image.width, image.height) do for py in 0 .. image.height - 1 loop for px in 0 .. image.width - 1 loop minMax := circleMinMax(image => image, x => px, y => py, radius => radius); threshold := (if minMax.max - minMax.min >= c_min then (minMax.min + minMax.max) / 2 else 0); result.set(px, py, (if image.get(px, py) > threshold then 255 else 0)); end loop; end loop; end return; end bernsenAdaptative; end ImageThresholds;
solutions/67 - Decimal Doubler/size-20_speed-219.asm
michaelgundlach/7billionhumans
45
19081
-- 7 Billion Humans (2053) -- -- 67: Decimal Doubler -- -- Author: Tiza59 -- Size: 20 -- Speed: 219 step s if s != button: pickup c mem3 = set myitem step s a: drop step se step nw mem3 = calc mem3 x 2 if e >= 5: mem3 = calc mem3 + 1 else: mem3 = calc mem3 + 0 endif if mem3 >= 10: mem3 = calc mem3 - 10 else: mem1 = calc 0 + 0 endif pickup c write mem3 jump a endif
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca_notsx.log_21829_1375.asm
ljhsiun2/medusa
9
174597
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r14 push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x43f8, %r11 clflush (%r11) nop nop nop nop nop add %rbp, %rbp movl $0x61626364, (%r11) nop nop nop sub %r14, %r14 lea addresses_UC_ht+0xfea0, %rsi lea addresses_D_ht+0x137e8, %rdi nop nop nop nop nop cmp $8998, %rdx mov $75, %rcx rep movsq nop nop nop nop nop add %rcx, %rcx lea addresses_normal_ht+0xe558, %rbp nop nop nop add %rdx, %rdx mov $0x6162636465666768, %r14 movq %r14, %xmm0 and $0xffffffffffffffc0, %rbp vmovaps %ymm0, (%rbp) nop nop nop inc %rcx lea addresses_A_ht+0x158, %rcx nop nop nop nop add $56365, %r11 and $0xffffffffffffffc0, %rcx movaps (%rcx), %xmm6 vpextrq $0, %xmm6, %rsi nop nop nop xor $45445, %rsi lea addresses_D_ht+0xc958, %rcx nop nop and %r11, %r11 movb (%rcx), %r14b nop nop nop sub %rcx, %rcx lea addresses_WC_ht+0x140d4, %rsi nop nop nop add $15664, %r11 movb $0x61, (%rsi) nop nop cmp %r14, %r14 lea addresses_D_ht+0x15b58, %rsi lea addresses_D_ht+0x2b60, %rdi xor $8308, %r14 mov $119, %rcx rep movsb nop and %rbx, %rbx lea addresses_A_ht+0xabd8, %rsi lea addresses_A_ht+0x12518, %rdi nop nop nop nop nop inc %rbp mov $76, %rcx rep movsb nop nop nop nop nop xor %r11, %r11 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %r14 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r9 push %rax push %rcx push %rdi push %rdx push %rsi // REPMOV lea addresses_UC+0x1a558, %rsi lea addresses_RW+0xd726, %rdi clflush (%rsi) nop nop nop nop nop sub $50359, %rdx mov $2, %rcx rep movsq nop nop add $5351, %rcx // Store lea addresses_WT+0x15bf6, %rcx sub %r9, %r9 mov $0x5152535455565758, %rax movq %rax, %xmm5 movaps %xmm5, (%rcx) nop and %rax, %rax // Faulty Load lea addresses_RW+0x15558, %rdx add $35719, %r11 movups (%rdx), %xmm2 vpextrq $1, %xmm2, %rcx lea oracles, %rdx and $0xff, %rcx shlq $12, %rcx mov (%rdx,%rcx,1), %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r9 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_UC'}, 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_RW'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 1}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 11}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 8}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 2}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_D_ht'}, 'dst': {'same': True, 'congruent': 1, 'type': 'addresses_D_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_A_ht'}} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
0x24.asm
SpeedStepper/XchgRaxRax
53
28357
; ; $Id: 0x24.asm,v 1.1.1.1 2016/03/27 08:40:13 raptor Exp $ ; ; 0x24 explanation - from xchg rax,rax by <EMAIL> ; Copyright (c) 2016 <NAME> <<EMAIL>> ; ; This snippet is similar to the previous snippet 0x23. It ; illustrates a clever/convoluted way to determine if the ; value contained in rax is even or odd. If the result in ; rcx is 0, rax is even; if the result in rcx is 1, rax is ; odd. As a bonus, the original input value is preserved in ; the rbx register. ; BITS 64 SECTION .text global main main: ;mov rax,150 ; added for the analysis mov rbx,rax ; rbx = rax mov rsi,rax ; rsi = rax .loop: mul rbx ; rdx:rax = rax * rbx ; i.e. rdx:rax = rax * rax = pow(rax, 2) mov rcx,rax ; rcx = rax ; i.e. rcx = pow(rax, 2) sub rax,2 ; rax = rax - 2 ; i.e. rax = pow(rax, 2) - 2 neg rax ; rax = ~rax + 1 ; i.e. rax = ~(pow(rax, 2) - 2) + 1 mul rsi ; rdx:rax = rax * rsi ; i.e. (~(pow(rax, 2) - 2) + 1) * rax mov rsi,rax ; rsi = rax ; i.e. rsi = (~(pow(rax, 2) - 2) + 1) * rax cmp rcx,1 ; if (pow(rax, 2) <= 1) exit ja .loop ; else keep looping .exit_loop:
test/asm/logic_full.asm
xdrie/irre-tools
1
163333
<reponame>xdrie/irre-tools<filename>test/asm/logic_full.asm %entry: main s4: set r0 #4 ; progress ret ; done s3: ; test != set r0 #3 ; progress set r1 #2 set r2 #3 cmp r1 r2 bne ::s4 s2: ; test > set r0 #2 ; progress set r1 #5 set r2 #2 cmp r1 r2 bgt ::s3 s1: ; test >= set r0 #1 ; progress set r1 #4 set r2 #4 cmp r1 r2 bge ::s2 main: set r0 #0 ; progress ; test == set r1 #5 set r2 #5 cmp r1 r2 beq ::s1
tests/add_2_numbers.asm
AverageAssemblyProgrammer/Hustle
1
98785
global _start section .text _start: section .data number: db "69", 10 ; hardcoded newlines as newlines not supported yet section .text mov rax, 1 ; syscall for write mov rdi, 1 ; file handle 1 is stdout mov rsi, number ; ardress of the string to output mov rdx, 4 ; numbers of bytes for the memory of the variable value syscall ; invoke the operating system to do a write mov rax, 60 ; system call for exit xor rdi, rdi ; exit code 0 syscall ; system call for exit
source/league/league-base_codecs.adb
svn2github/matreshka
24
9051
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-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$ ------------------------------------------------------------------------------ with Ada.Streams; with League.Stream_Element_Vectors.Internals; with League.Strings.Internals; with Matreshka.Internals.Stream_Element_Vectors; with Matreshka.Internals.Strings.Configuration; with Matreshka.Internals.Utf16; package body League.Base_Codecs is use type Ada.Streams.Stream_Element; use type Ada.Streams.Stream_Element_Offset; use type Matreshka.Internals.Utf16.Utf16_Code_Unit; use type Matreshka.Internals.Utf16.Utf16_String_Index; procedure Decode_64 (Item : Matreshka.Internals.Utf16.Utf16_Code_Unit; Value : out Ada.Streams.Stream_Element; Success : out Boolean); procedure Decode_64_URL (Item : Matreshka.Internals.Utf16.Utf16_Code_Unit; Value : out Ada.Streams.Stream_Element; Success : out Boolean); Encode_64 : constant array (Ada.Streams.Stream_Element range 0 .. 63) of Matreshka.Internals.Utf16.Utf16_Code_Unit := (Character'Pos ('A'), Character'Pos ('B'), Character'Pos ('C'), Character'Pos ('D'), Character'Pos ('E'), Character'Pos ('F'), Character'Pos ('G'), Character'Pos ('H'), Character'Pos ('I'), Character'Pos ('J'), Character'Pos ('K'), Character'Pos ('L'), Character'Pos ('M'), Character'Pos ('N'), Character'Pos ('O'), Character'Pos ('P'), Character'Pos ('Q'), Character'Pos ('R'), Character'Pos ('S'), Character'Pos ('T'), Character'Pos ('U'), Character'Pos ('V'), Character'Pos ('W'), Character'Pos ('X'), Character'Pos ('Y'), Character'Pos ('Z'), Character'Pos ('a'), Character'Pos ('b'), Character'Pos ('c'), Character'Pos ('d'), Character'Pos ('e'), Character'Pos ('f'), Character'Pos ('g'), Character'Pos ('h'), Character'Pos ('i'), Character'Pos ('j'), Character'Pos ('k'), Character'Pos ('l'), Character'Pos ('m'), Character'Pos ('n'), Character'Pos ('o'), Character'Pos ('p'), Character'Pos ('q'), Character'Pos ('r'), Character'Pos ('s'), Character'Pos ('t'), Character'Pos ('u'), Character'Pos ('v'), Character'Pos ('w'), Character'Pos ('x'), Character'Pos ('y'), Character'Pos ('z'), Character'Pos ('0'), Character'Pos ('1'), Character'Pos ('2'), Character'Pos ('3'), Character'Pos ('4'), Character'Pos ('5'), Character'Pos ('6'), Character'Pos ('7'), Character'Pos ('8'), Character'Pos ('9'), Character'Pos ('+'), Character'Pos ('/')); Encode_64_URL : constant array (Ada.Streams.Stream_Element range 0 .. 63) of Matreshka.Internals.Utf16.Utf16_Code_Unit := (Character'Pos ('A'), Character'Pos ('B'), Character'Pos ('C'), Character'Pos ('D'), Character'Pos ('E'), Character'Pos ('F'), Character'Pos ('G'), Character'Pos ('H'), Character'Pos ('I'), Character'Pos ('J'), Character'Pos ('K'), Character'Pos ('L'), Character'Pos ('M'), Character'Pos ('N'), Character'Pos ('O'), Character'Pos ('P'), Character'Pos ('Q'), Character'Pos ('R'), Character'Pos ('S'), Character'Pos ('T'), Character'Pos ('U'), Character'Pos ('V'), Character'Pos ('W'), Character'Pos ('X'), Character'Pos ('Y'), Character'Pos ('Z'), Character'Pos ('a'), Character'Pos ('b'), Character'Pos ('c'), Character'Pos ('d'), Character'Pos ('e'), Character'Pos ('f'), Character'Pos ('g'), Character'Pos ('h'), Character'Pos ('i'), Character'Pos ('j'), Character'Pos ('k'), Character'Pos ('l'), Character'Pos ('m'), Character'Pos ('n'), Character'Pos ('o'), Character'Pos ('p'), Character'Pos ('q'), Character'Pos ('r'), Character'Pos ('s'), Character'Pos ('t'), Character'Pos ('u'), Character'Pos ('v'), Character'Pos ('w'), Character'Pos ('x'), Character'Pos ('y'), Character'Pos ('z'), Character'Pos ('0'), Character'Pos ('1'), Character'Pos ('2'), Character'Pos ('3'), Character'Pos ('4'), Character'Pos ('5'), Character'Pos ('6'), Character'Pos ('7'), Character'Pos ('8'), Character'Pos ('9'), Character'Pos ('-'), Character'Pos ('_')); --------------- -- Decode_64 -- --------------- procedure Decode_64 (Item : Matreshka.Internals.Utf16.Utf16_Code_Unit; Value : out Ada.Streams.Stream_Element; Success : out Boolean) is begin Success := True; case Item is when Character'Pos ('A') .. Character'Pos ('Z') => Value := Ada.Streams.Stream_Element (Item) - Character'Pos ('A'); when Character'Pos ('a') .. Character'Pos ('z') => Value := Ada.Streams.Stream_Element (Item) - Character'Pos ('a') + 26; when Character'Pos ('0') .. Character'Pos ('9') => Value := Ada.Streams.Stream_Element (Item) - Character'Pos ('0') + 52; when Character'Pos ('+') => Value := 62; when Character'Pos ('/') => Value := 63; when Character'Pos ('=') => Value := 0; when others => Success := False; end case; end Decode_64; ------------------- -- Decode_64_URL -- ------------------- procedure Decode_64_URL (Item : Matreshka.Internals.Utf16.Utf16_Code_Unit; Value : out Ada.Streams.Stream_Element; Success : out Boolean) is begin Success := True; case Item is when Character'Pos ('A') .. Character'Pos ('Z') => Value := Ada.Streams.Stream_Element (Item) - Character'Pos ('A'); when Character'Pos ('a') .. Character'Pos ('z') => Value := Ada.Streams.Stream_Element (Item) - Character'Pos ('a') + 26; when Character'Pos ('0') .. Character'Pos ('9') => Value := Ada.Streams.Stream_Element (Item) - Character'Pos ('0') + 52; when Character'Pos ('-') => Value := 62; when Character'Pos ('_') => Value := 63; when Character'Pos ('=') => Value := 0; when others => Success := False; end case; end Decode_64_URL; ------------------ -- From_Base_64 -- ------------------ function From_Base_64 (Data : League.Strings.Universal_String) return League.Stream_Element_Vectors.Stream_Element_Vector is Aux : League.Stream_Element_Vectors.Stream_Element_Vector; Success : Boolean; begin From_Base_64 (Data, Aux, Success); if Success then return Aux; else raise Constraint_Error with "Mailformed base64 data"; end if; end From_Base_64; ------------------ -- From_Base_64 -- ------------------ procedure From_Base_64 (Data : League.Strings.Universal_String; Value : in out League.Stream_Element_Vectors.Stream_Element_Vector; Success : out Boolean) is Source : constant Matreshka.Internals.Strings.Shared_String_Access := League.Strings.Internals.Internal (Data); Size : constant Ada.Streams.Stream_Element_Offset := Ada.Streams.Stream_Element_Offset (Source.Length) / 4 * 3; Target : Matreshka.Internals.Stream_Element_Vectors .Shared_Stream_Element_Vector_Access := League.Stream_Element_Vectors.Internals.Internal (Value); Unused : Ada.Streams.Stream_Element_Offset := 0; First : Matreshka.Internals.Utf16.Utf16_String_Index := 0; begin if Source.Length = 0 then Value.Clear; Success := True; return; end if; if Source.Length mod 4 /= 0 then Value.Clear; Success := False; return; end if; -- Check whether storage of passed internal object can be reused, and -- create new shared object if can't. if not Matreshka.Internals.Stream_Element_Vectors.Can_Be_Reused (Target, Size) then Target := Matreshka.Internals.Stream_Element_Vectors.Allocate (Size); League.Stream_Element_Vectors.Internals.Replace (Value, Target); end if; while Source.Unused > First loop declare S1 : constant Matreshka.Internals.Utf16.Utf16_Code_Unit := Source.Value (First); S2 : constant Matreshka.Internals.Utf16.Utf16_Code_Unit := Source.Value (First + 1); S3 : constant Matreshka.Internals.Utf16.Utf16_Code_Unit := Source.Value (First + 2); S4 : constant Matreshka.Internals.Utf16.Utf16_Code_Unit := Source.Value (First + 3); A1 : Ada.Streams.Stream_Element; A2 : Ada.Streams.Stream_Element; A3 : Ada.Streams.Stream_Element; A4 : Ada.Streams.Stream_Element; begin Decode_64 (S1, A1, Success); exit when not Success; Decode_64 (S2, A2, Success); exit when not Success; Target.Value (Unused) := (A1 * 4) or ((A2 and 2#0011_0000#) / 16); Unused := Unused + 1; if S3 /= Character'Pos ('=') then Decode_64 (S3, A3, Success); exit when not Success; Target.Value (Unused) := ((A2 and 2#0000_1111#) * 16) or ((A3 and 2#0011_1100#) / 4); Unused := Unused + 1; if S4 /= Character'Pos ('=') then Decode_64 (S4, A4, Success); exit when not Success; Target.Value (Unused) := ((A3 and 2#0000_0011#) * 64) or A4; Unused := Unused + 1; end if; end if; First := First + 4; end; end loop; Target.Length := Unused; end From_Base_64; ---------------------- -- From_Base_64_URL -- ---------------------- function From_Base_64_URL (Data : League.Strings.Universal_String) return League.Stream_Element_Vectors.Stream_Element_Vector is Aux : League.Stream_Element_Vectors.Stream_Element_Vector; Success : Boolean; begin From_Base_64_URL (Data, Aux, Success); if Success then return Aux; else raise Constraint_Error with "Mailformed base64url data"; end if; end From_Base_64_URL; ---------------------- -- From_Base_64_URL -- ---------------------- procedure From_Base_64_URL (Data : League.Strings.Universal_String; Value : in out League.Stream_Element_Vectors.Stream_Element_Vector; Success : out Boolean) is Source : constant Matreshka.Internals.Strings.Shared_String_Access := League.Strings.Internals.Internal (Data); Size : constant Ada.Streams.Stream_Element_Offset := Ada.Streams.Stream_Element_Offset (Source.Length) / 4 * 3; Target : Matreshka.Internals.Stream_Element_Vectors .Shared_Stream_Element_Vector_Access := League.Stream_Element_Vectors.Internals.Internal (Value); Unused : Ada.Streams.Stream_Element_Offset := 0; First : Matreshka.Internals.Utf16.Utf16_String_Index := 0; begin if Source.Length = 0 then Value.Clear; Success := True; return; end if; if Source.Length mod 4 = 0 then -- Check whether storage of passed internal object can be reused, and -- create new shared object if can't. if not Matreshka.Internals.Stream_Element_Vectors.Can_Be_Reused (Target, Size) then Target := Matreshka.Internals.Stream_Element_Vectors.Allocate (Size); League.Stream_Element_Vectors.Internals.Replace (Value, Target); end if; while Source.Unused > First loop declare S1 : constant Matreshka.Internals.Utf16.Utf16_Code_Unit := Source.Value (First); S2 : constant Matreshka.Internals.Utf16.Utf16_Code_Unit := Source.Value (First + 1); S3 : constant Matreshka.Internals.Utf16.Utf16_Code_Unit := Source.Value (First + 2); S4 : constant Matreshka.Internals.Utf16.Utf16_Code_Unit := Source.Value (First + 3); A1 : Ada.Streams.Stream_Element; A2 : Ada.Streams.Stream_Element; A3 : Ada.Streams.Stream_Element; A4 : Ada.Streams.Stream_Element; begin Decode_64_URL (S1, A1, Success); exit when not Success; Decode_64_URL (S2, A2, Success); exit when not Success; Target.Value (Unused) := (A1 * 4) or ((A2 and 2#0011_0000#) / 16); Unused := Unused + 1; if S3 /= Character'Pos ('=') then Decode_64_URL (S3, A3, Success); exit when not Success; Target.Value (Unused) := ((A2 and 2#0000_1111#) * 16) or ((A3 and 2#0011_1100#) / 4); Unused := Unused + 1; if S4 /= Character'Pos ('=') then Decode_64_URL (S4, A4, Success); exit when not Success; Target.Value (Unused) := ((A3 and 2#0000_0011#) * 64) or A4; Unused := Unused + 1; end if; end if; First := First + 4; end; end loop; Target.Length := Unused; if Target.Length = 0 then Value.Clear; end if; else Value.Clear; Success := False; end if; end From_Base_64_URL; ---------------- -- To_Base_64 -- ---------------- function To_Base_64 (Data : League.Stream_Element_Vectors.Stream_Element_Vector) return League.Strings.Universal_String is Source : constant Matreshka.Internals.Stream_Element_Vectors .Shared_Stream_Element_Vector_Access := League.Stream_Element_Vectors.Internals.Internal (Data); Target : Matreshka.Internals.Strings.Shared_String_Access; First : Ada.Streams.Stream_Element_Offset := 0; Unused : Matreshka.Internals.Utf16.Utf16_String_Index := 0; Aux : Ada.Streams.Stream_Element; begin -- Return empty string when data is empty. if Source.Length = 0 then return League.Strings.Empty_Universal_String; end if; -- Allocate string for result. (Length + 2) / 3 * 4 is exact required -- length for the result. Target := Matreshka.Internals.Strings.Allocate (Matreshka.Internals.Utf16.Utf16_String_Index ((Source.Length + 2) / 3 * 4)); -- Encode each triplet of bytes when available. while Source.Length - First >= 3 loop declare S1 : constant Ada.Streams.Stream_Element := Source.Value (First); S2 : constant Ada.Streams.Stream_Element := Source.Value (First + 1); S3 : constant Ada.Streams.Stream_Element := Source.Value (First + 2); begin Aux := (S1 and 2#1111_1100#) / 4; Target.Value (Unused) := Encode_64 (Aux); Unused := Unused + 1; Aux := ((S1 and 2#0000_0011#) * 16) or ((S2 and 2#1111_0000#) / 16); Target.Value (Unused) := Encode_64 (Aux); Unused := Unused + 1; Aux := ((S2 and 2#0000_1111#) * 4) or ((S3 and 2#1100_0000#) / 64); Target.Value (Unused) := Encode_64 (Aux); Unused := Unused + 1; Aux := S3 and 2#0011_1111#; Target.Value (Unused) := Encode_64 (Aux); Unused := Unused + 1; end; First := First + 3; end loop; if Source.Length - First = 1 then declare S1 : constant Ada.Streams.Stream_Element := Source.Value (First); begin Aux := (S1 and 2#1111_1100#) / 4; Target.Value (Unused) := Encode_64 (Aux); Unused := Unused + 1; Aux := (S1 and 2#0000_0011#) * 16; Target.Value (Unused) := Encode_64 (Aux); Unused := Unused + 1; Target.Value (Unused) := Character'Pos ('='); Unused := Unused + 1; Target.Value (Unused) := Character'Pos ('='); Unused := Unused + 1; end; elsif Source.Length - First = 2 then declare S1 : constant Ada.Streams.Stream_Element := Source.Value (First); S2 : constant Ada.Streams.Stream_Element := Source.Value (First + 1); begin Aux := (S1 and 2#1111_1100#) / 4; Target.Value (Unused) := Encode_64 (Aux); Unused := Unused + 1; Aux := ((S1 and 2#0000_0011#) * 16) or ((S2 and 2#1111_0000#) / 16); Target.Value (Unused) := Encode_64 (Aux); Unused := Unused + 1; Aux := (S2 and 2#0000_1111#) * 4; Target.Value (Unused) := Encode_64 (Aux); Unused := Unused + 1; Target.Value (Unused) := Character'Pos ('='); Unused := Unused + 1; end; end if; Target.Unused := Unused; Target.Length := Integer (Target.Unused); -- All characters of base64 character set occupy one code unit, thus -- length of the string is always equal to the number of used code -- units. Matreshka.Internals.Strings.Configuration.String_Handler .Fill_Null_Terminator (Target); return League.Strings.Internals.Wrap (Target); exception when others => Matreshka.Internals.Strings.Dereference (Target); raise; end To_Base_64; -------------------- -- To_Base_64_URL -- -------------------- function To_Base_64_URL (Data : League.Stream_Element_Vectors.Stream_Element_Vector) return League.Strings.Universal_String is Source : constant Matreshka.Internals.Stream_Element_Vectors .Shared_Stream_Element_Vector_Access := League.Stream_Element_Vectors.Internals.Internal (Data); Target : Matreshka.Internals.Strings.Shared_String_Access; First : Ada.Streams.Stream_Element_Offset := 0; Unused : Matreshka.Internals.Utf16.Utf16_String_Index := 0; Aux : Ada.Streams.Stream_Element; begin -- Return empty string when data is empty. if Source.Length = 0 then return League.Strings.Empty_Universal_String; end if; -- Allocate string for result. (Length + 2) / 3 * 4 is exact required -- length for the result. Target := Matreshka.Internals.Strings.Allocate (Matreshka.Internals.Utf16.Utf16_String_Index ((Source.Length + 2) / 3 * 4)); -- Encode each triplet of bytes when available. while Source.Length - First >= 3 loop declare S1 : constant Ada.Streams.Stream_Element := Source.Value (First); S2 : constant Ada.Streams.Stream_Element := Source.Value (First + 1); S3 : constant Ada.Streams.Stream_Element := Source.Value (First + 2); begin Aux := (S1 and 2#1111_1100#) / 4; Target.Value (Unused) := Encode_64_URL (Aux); Unused := Unused + 1; Aux := ((S1 and 2#0000_0011#) * 16) or ((S2 and 2#1111_0000#) / 16); Target.Value (Unused) := Encode_64_URL (Aux); Unused := Unused + 1; Aux := ((S2 and 2#0000_1111#) * 4) or ((S3 and 2#1100_0000#) / 64); Target.Value (Unused) := Encode_64_URL (Aux); Unused := Unused + 1; Aux := S3 and 2#0011_1111#; Target.Value (Unused) := Encode_64_URL (Aux); Unused := Unused + 1; end; First := First + 3; end loop; if Source.Length - First = 1 then declare S1 : constant Ada.Streams.Stream_Element := Source.Value (First); begin Aux := (S1 and 2#1111_1100#) / 4; Target.Value (Unused) := Encode_64_URL (Aux); Unused := Unused + 1; Aux := (S1 and 2#0000_0011#) * 16; Target.Value (Unused) := Encode_64_URL (Aux); Unused := Unused + 1; Target.Value (Unused) := Character'Pos ('='); Unused := Unused + 1; Target.Value (Unused) := Character'Pos ('='); Unused := Unused + 1; end; elsif Source.Length - First = 2 then declare S1 : constant Ada.Streams.Stream_Element := Source.Value (First); S2 : constant Ada.Streams.Stream_Element := Source.Value (First + 1); begin Aux := (S1 and 2#1111_1100#) / 4; Target.Value (Unused) := Encode_64_URL (Aux); Unused := Unused + 1; Aux := ((S1 and 2#0000_0011#) * 16) or ((S2 and 2#1111_0000#) / 16); Target.Value (Unused) := Encode_64_URL (Aux); Unused := Unused + 1; Aux := (S2 and 2#0000_1111#) * 4; Target.Value (Unused) := Encode_64_URL (Aux); Unused := Unused + 1; Target.Value (Unused) := Character'Pos ('='); Unused := Unused + 1; end; end if; Target.Unused := Unused; Target.Length := Integer (Target.Unused); -- All characters of base64 character set occupy one code unit, thus -- length of the string is always equal to the number of used code -- units. Matreshka.Internals.Strings.Configuration.String_Handler .Fill_Null_Terminator (Target); return League.Strings.Internals.Wrap (Target); exception when others => Matreshka.Internals.Strings.Dereference (Target); raise; end To_Base_64_URL; end League.Base_Codecs;
src/hitbox.asm
howprice/specnext-invaders
17
99196
<filename>src/hitbox.asm STRUCT Hitbox x0 BYTE 0 ; min X x1 BYTE 0 ; max X (inclusive) y0 BYTE 0 ; min Y y1 BYTE 0 ; max Y (inclusive) ENDS ; ; Transform a sprite's hitbox from pattern space to screenspace ; IX = address of sprite attributes struct ; DE = address of pattern-space hitbox ; HL = address of screen-space hitbox ; Modifies: AF, B, DE, HL ; CalculateSpriteScreenSpaceHitbox: ; x0 (min x) ld a,(ix+SpriteAttributes.x) ; A = spriteX ld b,a ; B = spriteX (for subsequent x1 calculation) ex de,hl ; DE = &hitboxScreenSpace.x0; HL = &hitboxPatternSpace.x0 add (hl) ; A = spriteX + hitboxPatternSpace.x0 = hitboxScreenSpace.x0 (transform to screen space) ex de,hl ; DE = &hitboxPatternSpace.x0; HL = &hitboxScreenSpace.x0 ld (hl),a ; hitboxScreenSpace.x0 <- A ; x1 (max x) ld a,b ; A = spriteX inc de ; DE = &hitboxPatternSpace.x1 inc hl ; HL = &hitboxScreenSpace.x1 ex de,hl ; DE = &hitboxScreenSpace.x1; HL = &hitboxPatternSpace.x1 add (hl) ; A = spriteX + hitboxPatternSpace.x1 = hitboxScreenSpace.x1 (transform to screen space) ex de,hl ; DE = &hitboxPatternSpace.x1; HL = &hitboxScreenSpace.x1 ld (hl),a ; hitboxScreenSpace.x1 <- A ; y0 (min y) ld a,(ix+SpriteAttributes.y) ; A = spriteY ld b,a ; B = spriteY (for subsequent y1 calcultion) inc de ; DE = &hitboxPatternSpace.y0 inc hl ; HL = &hitboxScreenSpace.y0 ex de,hl ; DE = &hitboxScreenSpace.y0; HL = &hitboxPatternSpace.y0 add (hl) ; A = A + hitboxPatternSpace.y0 = hitboxScreenSpace.y0 (transform to screen space) ex de,hl ; DE = &hitboxPatternSpace.y0; HL = &hitboxScreenSpace.y0 ld (hl),a ; hitboxScreenSpace.y0 <- A ; y1 (max y) ld a,b ; A = spriteY inc de ; DE = &hitboxPatternSpace.y1 inc hl ; HL = &hitboxScreenSpace.y1 ex de,hl ; DE = &hitboxScreenSpace.y1; HL = &hitboxPatternSpace.y1 add (hl) ; A = A + hitboxPatternSpace.y0 = hitboxScreenSpace.y1 (transform to screen space) ex de,hl ; DE = &hitboxPatternSpace.y1; HL = &hitboxScreenSpace.y1 ld (hl),a ; hitboxScreenSpace.y1 <- A ret ; ; Collides two hitboxes (bounding boxes) ; DE = address of hitbox A ; HL = address of hitbox B ; CF <- 0 if boxes are overlapping ; Modifies: AF, BC, DE, HL ; CollideHitboxes: ; x-axis ; n.b. Max x pos < 256 so we get away with 8-bit arithmetic here ld a,(de) ; A = ax0 ld b,a ; B = ax0 (for subsequent test) inc de ; DE = &a.x1 ld a,(de) ; A = ax1 cp (hl) ; ax1 - bx0 ret c ; if CF set then bx0 > ax1 i.e. left of B is to the right of the right of A so not overlapping inc hl ; HL = &b.x1 ld a,(hl) ; A = bx1 cp b ; bx1 - ax0 ret c ; if CF set then ax0 > bx1 i.e. left of A is to the right of the right of B so not overlapping ; y-axis inc de ; DE = &a.y0 inc hl ; HL = &b.y0 ld a,(de) ; A = ay0 ld b,a ; B = ay0 (for subsequent test) inc de ; DE = &a.y1 ld a,(de) ; A = ay1 cp (hl) ; ay1 - by0 ret c ; if CF set then by0 > ay1 i.e. top of B is below of bottom of A so not overlapping inc hl ; HL = &b.y1 ld a,(hl) ; A = by1 cp b ; by1 - ay0 ret ; return with CF set if ay0 > by1 i.e. top of A below the bottom of B so not overlapping
src/frontend/Experimental_Ada_ROSE_Connection/parser/asis_adapter/source/asis_adapter-element-associations.ads
ouankou/rose
488
9868
<gh_stars>100-1000 package Asis_Adapter.Element.Associations is procedure Do_Pre_Child_Processing (Element : in Asis.Element; State : in out Class); private -- For debuggng: Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & "Associations"; end Asis_Adapter.Element.Associations;
src/botio.ads
Hamster-Furtif/JeremyPlusPlus
0
6578
with ada.Strings.Unbounded, utils, montecarlo, ada.Integer_Text_IO, opstrat; use ada.Strings.Unbounded, utils, montecarlo, ada.Integer_Text_IO, opstrat; package botIO is type T_prefix is (settings, update_game, update_hand, action); type T_params is Array(0..7) of Unbounded_String; type T_command is record prefix : T_prefix; pars : T_params; size : Integer; end record; --Decoupe une chaine envoyee par le launcher au niveau des espaces et des guillements, et renvoie une commande function splitLine(line : String; line_length : Integer) return T_command; --Permet d'interpreter des commandes de type settings, update_game et update_hand procedure readSettings(command : T_command; game : in out T_game); procedure readUpdateGame(command : T_command; game : in out T_game); procedure readUpdateHand(command : T_command; game : in out T_game; logic : in out T_logic); --Affiche la valeur et la couleur d'une carte dans la console (sert a debugger) procedure printCard(card : in T_card); --Permet de lire une carte selon le formalisme du launcher function parseCard(str : in String) return T_card; end botIO;
asm/subtitles/originais/020f126c_eu.asm
Iemnur/megaman-zx-traducao-ptbr
10
93085
01FF8ECC B410 push r4 01FF8ECE B081 add sp,-4h 01FF8ED0 4817 ldr r0,=27E00FCh ; ok 01FF8ED2 6800 ldr r0,[r0] 01FF8ED4 2802 cmp r0,2h 01FF8ED6 D127 bne 1FF8F28h 01FF8ED8 4B16 ldr r3,=27E029Ch ; ok 01FF8EDA 7E99 ldrb r1,[r3,1Ah] 01FF8EDC 7E58 ldrb r0,[r3,19h] 01FF8EDE 4281 cmp r1,r0 01FF8EE0 D022 beq 1FF8F28h 01FF8EE2 7E58 ldrb r0,[r3,19h] 01FF8EE4 7698 strb r0,[r3,1Ah] 01FF8EE6 7E58 ldrb r0,[r3,19h] 01FF8EE8 4A13 ldr r2,=20F89B0h ; na jp, apontar para 20F87F0h 01FF8EEA 6811 ldr r1,[r2] 01FF8EEC 2000 mov r0,0h 01FF8EEE 6010 str r0,[r2] 01FF8EF0 4C12 ldr r4,=20F8930h ; na jp, apontar para 20F8770h 01FF8EF2 0180 lsl r0,r0,6h 01FF8EF4 1820 add r0,r4,r0 01FF8EF6 6050 str r0,[r2,4h] 01FF8EF8 7E5A ldrb r2,[r3,19h] 01FF8EFA 2A00 cmp r2,0h 01FF8EFC D006 beq 1FF8F0Ch 01FF8EFE 8983 ldrh r3,[r0,0Ch] 01FF8F00 4A0F ldr r2,=0FFFFE0FFh 01FF8F02 4013 and r3,r2 01FF8F04 4A0F ldr r2,=600h 01FF8F06 4313 orr r3,r2 01FF8F08 8183 strh r3,[r0,0Ch] 01FF8F0A E003 b 1FF8F14h 01FF8F0C 8983 ldrh r3,[r0,0Ch] 01FF8F0E 4A0C ldr r2,=0FFFFE0FFh 01FF8F10 4013 and r3,r2 01FF8F12 8183 strh r3,[r0,0Ch] 01FF8F14 4808 ldr r0,=20F89B0h ; na jp, apontar para 20F87F0h 01FF8F16 6842 ldr r2,[r0,4h] 01FF8F18 8993 ldrh r3,[r2,0Ch] 01FF8F1A 4A0B ldr r2,=400000Ch 01FF8F1C 8013 strh r3,[r2] 01FF8F1E 6001 str r1,[r0] 01FF8F20 4A06 ldr r2,=20F8930h ; na jp, apontar para 20F8770h 01FF8F22 0189 lsl r1,r1,6h 01FF8F24 1851 add r1,r2,r1 01FF8F26 6041 str r1,[r0,4h] 01FF8F28 B001 add sp,4h 01FF8F2A BC10 pop r4 01FF8F2C 4770 bx r14 .pool 01FF8F2E 46C0 nop 01FF8F30 00FC lsl r4,r7,3h 01FF8F32 027E lsl r6,r7,9h 01FF8F34 029C lsl r4,r3,0Ah 01FF8F36 027E lsl r6,r7,9h 01FF8F38 89B0 ldrh r0,[r6,0Ch] 01FF8F3A 020F lsl r7,r1,8h 01FF8F3C 8930 ldrh r0,[r6,8h] 01FF8F3E 020F lsl r7,r1,8h 01FF8F40 E0FF b 1FF9142h 01FF8F42 FFFF bl lr+0FFEh 01FF8F44 0600 lsl r0,r0,18h 01FF8F46 0000 lsl r0,r0,0h 01FF8F48 000C lsl r4,r1,0h 01FF8F4A 0400 lsl r0,r0,10h
oeis/165/A165148.asm
neoneye/loda-programs
11
83416
; A165148: a(n) = (3*8^n-4^n)/2. ; Submitted by <NAME>(s2.) ; 1,10,88,736,6016,48640,391168,3137536,25133056,201195520,1610088448,12882804736,103070826496,824600166400,6596935548928,52776021262336,422210317582336,3377691130593280,27021563404484608,216172644674830336,1729381707154456576,13835055856258908160,110680455646164287488,885443680353686388736,7083549583566979465216,56668397231485789143040,453347180103686126829568,3626777449836688269377536,29014219634722303173984256,232113757221893613467729920,1856910058351609660045262848 mov $1,2 pow $1,$0 mul $1,3 mov $0,$1 bin $1,2 div $1,3 mul $1,$0 mov $0,$1 div $0,3
src/SlimShader.Tests/Shaders/HlslCrossCompiler/vs5/mad_imm.asm
tgjones/slimshader
125
161369
<reponame>tgjones/slimshader // // Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20714 // // /// // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // POSITION 0 xyzw 0 NONE float xyzw // TEXCOORD 0 xyzw 1 NONE float xyzw // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Position 0 xyzw 0 POS float xyzw // vs_5_0 dcl_globalFlags refactoringAllowed dcl_input v0.xyzw dcl_input v1.xyzw dcl_output_siv o0.xyzw, position mad o0.xyzw, v1.xyzw, l(0.100000, 0.200000, 0.300000, 0.400000), v0.xyzw ret // Approximately 2 instruction slots used
wc.asm
monamansouri/os2-1
0
166455
<reponame>monamansouri/os2-1<filename>wc.asm _wc: file format elf32-i386 Disassembly of section .text: 00000000 <main>: printf(1, "%d %d %d %s\n", l, w, c, name); } int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 57 push %edi e: 56 push %esi f: be 01 00 00 00 mov $0x1,%esi 14: 53 push %ebx 15: 51 push %ecx 16: 83 ec 18 sub $0x18,%esp 19: 8b 01 mov (%ecx),%eax 1b: 8b 59 04 mov 0x4(%ecx),%ebx 1e: 89 45 e4 mov %eax,-0x1c(%ebp) 21: 83 c3 04 add $0x4,%ebx int fd, i; if(argc <= 1){ 24: 83 f8 01 cmp $0x1,%eax 27: 7e 56 jle 7f <main+0x7f> 29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi wc(0, ""); exit(); } for(i = 1; i < argc; i++){ if((fd = open(argv[i], 0)) < 0){ 30: 83 ec 08 sub $0x8,%esp 33: 6a 00 push $0x0 35: ff 33 pushl (%ebx) 37: e8 c5 03 00 00 call 401 <open> 3c: 83 c4 10 add $0x10,%esp 3f: 89 c7 mov %eax,%edi 41: 85 c0 test %eax,%eax 43: 78 26 js 6b <main+0x6b> printf(1, "wc: cannot open %s\n", argv[i]); exit(); } wc(fd, argv[i]); 45: 83 ec 08 sub $0x8,%esp 48: ff 33 pushl (%ebx) for(i = 1; i < argc; i++){ 4a: 83 c6 01 add $0x1,%esi 4d: 83 c3 04 add $0x4,%ebx wc(fd, argv[i]); 50: 50 push %eax 51: e8 4a 00 00 00 call a0 <wc> close(fd); 56: 89 3c 24 mov %edi,(%esp) 59: e8 8b 03 00 00 call 3e9 <close> for(i = 1; i < argc; i++){ 5e: 83 c4 10 add $0x10,%esp 61: 39 75 e4 cmp %esi,-0x1c(%ebp) 64: 75 ca jne 30 <main+0x30> } exit(); 66: e8 56 03 00 00 call 3c1 <exit> printf(1, "wc: cannot open %s\n", argv[i]); 6b: 50 push %eax 6c: ff 33 pushl (%ebx) 6e: 68 db 08 00 00 push $0x8db 73: 6a 01 push $0x1 75: e8 d6 04 00 00 call 550 <printf> exit(); 7a: e8 42 03 00 00 call 3c1 <exit> wc(0, ""); 7f: 52 push %edx 80: 52 push %edx 81: 68 cd 08 00 00 push $0x8cd 86: 6a 00 push $0x0 88: e8 13 00 00 00 call a0 <wc> exit(); 8d: e8 2f 03 00 00 call 3c1 <exit> 92: 66 90 xchg %ax,%ax 94: 66 90 xchg %ax,%ax 96: 66 90 xchg %ax,%ax 98: 66 90 xchg %ax,%ax 9a: 66 90 xchg %ax,%ax 9c: 66 90 xchg %ax,%ax 9e: 66 90 xchg %ax,%ax 000000a0 <wc>: { a0: 55 push %ebp a1: 89 e5 mov %esp,%ebp a3: 57 push %edi a4: 56 push %esi a5: 53 push %ebx l = w = c = 0; a6: 31 db xor %ebx,%ebx { a8: 83 ec 1c sub $0x1c,%esp inword = 0; ab: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) l = w = c = 0; b2: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) b9: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) while((n = read(fd, buf, sizeof(buf))) > 0){ c0: 83 ec 04 sub $0x4,%esp c3: 68 00 02 00 00 push $0x200 c8: 68 00 0c 00 00 push $0xc00 cd: ff 75 08 pushl 0x8(%ebp) d0: e8 04 03 00 00 call 3d9 <read> d5: 83 c4 10 add $0x10,%esp d8: 89 c6 mov %eax,%esi da: 85 c0 test %eax,%eax dc: 7e 62 jle 140 <wc+0xa0> for(i=0; i<n; i++){ de: 31 ff xor %edi,%edi e0: eb 14 jmp f6 <wc+0x56> e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi inword = 0; e8: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) for(i=0; i<n; i++){ ef: 83 c7 01 add $0x1,%edi f2: 39 fe cmp %edi,%esi f4: 74 42 je 138 <wc+0x98> if(buf[i] == '\n') f6: 0f be 87 00 0c 00 00 movsbl 0xc00(%edi),%eax l++; fd: 31 c9 xor %ecx,%ecx ff: 3c 0a cmp $0xa,%al 101: 0f 94 c1 sete %cl if(strchr(" \r\t\n\v", buf[i])) 104: 83 ec 08 sub $0x8,%esp 107: 50 push %eax l++; 108: 01 cb add %ecx,%ebx if(strchr(" \r\t\n\v", buf[i])) 10a: 68 b8 08 00 00 push $0x8b8 10f: e8 2c 01 00 00 call 240 <strchr> 114: 83 c4 10 add $0x10,%esp 117: 85 c0 test %eax,%eax 119: 75 cd jne e8 <wc+0x48> else if(!inword){ 11b: 8b 55 e4 mov -0x1c(%ebp),%edx 11e: 85 d2 test %edx,%edx 120: 75 cd jne ef <wc+0x4f> for(i=0; i<n; i++){ 122: 83 c7 01 add $0x1,%edi w++; 125: 83 45 e0 01 addl $0x1,-0x20(%ebp) inword = 1; 129: c7 45 e4 01 00 00 00 movl $0x1,-0x1c(%ebp) for(i=0; i<n; i++){ 130: 39 fe cmp %edi,%esi 132: 75 c2 jne f6 <wc+0x56> 134: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 138: 01 75 dc add %esi,-0x24(%ebp) 13b: eb 83 jmp c0 <wc+0x20> 13d: 8d 76 00 lea 0x0(%esi),%esi if(n < 0){ 140: 75 24 jne 166 <wc+0xc6> printf(1, "%d %d %d %s\n", l, w, c, name); 142: 83 ec 08 sub $0x8,%esp 145: ff 75 0c pushl 0xc(%ebp) 148: ff 75 dc pushl -0x24(%ebp) 14b: ff 75 e0 pushl -0x20(%ebp) 14e: 53 push %ebx 14f: 68 ce 08 00 00 push $0x8ce 154: 6a 01 push $0x1 156: e8 f5 03 00 00 call 550 <printf> } 15b: 83 c4 20 add $0x20,%esp 15e: 8d 65 f4 lea -0xc(%ebp),%esp 161: 5b pop %ebx 162: 5e pop %esi 163: 5f pop %edi 164: 5d pop %ebp 165: c3 ret printf(1, "wc: read error\n"); 166: 50 push %eax 167: 50 push %eax 168: 68 be 08 00 00 push $0x8be 16d: 6a 01 push $0x1 16f: e8 dc 03 00 00 call 550 <printf> exit(); 174: e8 48 02 00 00 call 3c1 <exit> 179: 66 90 xchg %ax,%ax 17b: 66 90 xchg %ax,%ax 17d: 66 90 xchg %ax,%ax 17f: 90 nop 00000180 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 180: 55 push %ebp char *os; os = s; while((*s++ = *t++) != 0) 181: 31 d2 xor %edx,%edx { 183: 89 e5 mov %esp,%ebp 185: 53 push %ebx 186: 8b 45 08 mov 0x8(%ebp),%eax 189: 8b 5d 0c mov 0xc(%ebp),%ebx 18c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while((*s++ = *t++) != 0) 190: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx 194: 88 0c 10 mov %cl,(%eax,%edx,1) 197: 83 c2 01 add $0x1,%edx 19a: 84 c9 test %cl,%cl 19c: 75 f2 jne 190 <strcpy+0x10> ; return os; } 19e: 5b pop %ebx 19f: 5d pop %ebp 1a0: c3 ret 1a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1a8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1af: 90 nop 000001b0 <strcmp>: int strcmp(const char *p, const char *q) { 1b0: 55 push %ebp 1b1: 89 e5 mov %esp,%ebp 1b3: 56 push %esi 1b4: 53 push %ebx 1b5: 8b 5d 08 mov 0x8(%ebp),%ebx 1b8: 8b 75 0c mov 0xc(%ebp),%esi while(*p && *p == *q) 1bb: 0f b6 13 movzbl (%ebx),%edx 1be: 0f b6 0e movzbl (%esi),%ecx 1c1: 84 d2 test %dl,%dl 1c3: 74 1e je 1e3 <strcmp+0x33> 1c5: b8 01 00 00 00 mov $0x1,%eax 1ca: 38 ca cmp %cl,%dl 1cc: 74 09 je 1d7 <strcmp+0x27> 1ce: eb 20 jmp 1f0 <strcmp+0x40> 1d0: 83 c0 01 add $0x1,%eax 1d3: 38 ca cmp %cl,%dl 1d5: 75 19 jne 1f0 <strcmp+0x40> 1d7: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx 1db: 0f b6 0c 06 movzbl (%esi,%eax,1),%ecx 1df: 84 d2 test %dl,%dl 1e1: 75 ed jne 1d0 <strcmp+0x20> 1e3: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; } 1e5: 5b pop %ebx 1e6: 5e pop %esi return (uchar)*p - (uchar)*q; 1e7: 29 c8 sub %ecx,%eax } 1e9: 5d pop %ebp 1ea: c3 ret 1eb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1ef: 90 nop 1f0: 0f b6 c2 movzbl %dl,%eax 1f3: 5b pop %ebx 1f4: 5e pop %esi return (uchar)*p - (uchar)*q; 1f5: 29 c8 sub %ecx,%eax } 1f7: 5d pop %ebp 1f8: c3 ret 1f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000200 <strlen>: int strlen(const char *s) { 200: 55 push %ebp int n; for(n = 0; s[n]; n++) 201: 31 c0 xor %eax,%eax { 203: 89 e5 mov %esp,%ebp 205: 8b 55 08 mov 0x8(%ebp),%edx for(n = 0; s[n]; n++) 208: 80 3a 00 cmpb $0x0,(%edx) 20b: 74 0c je 219 <strlen+0x19> 20d: 8d 76 00 lea 0x0(%esi),%esi 210: 83 c0 01 add $0x1,%eax 213: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) 217: 75 f7 jne 210 <strlen+0x10> ; return n; } 219: 5d pop %ebp 21a: c3 ret 21b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 21f: 90 nop 00000220 <memset>: void* memset(void *dst, int c, int n) { 220: 55 push %ebp 221: 89 e5 mov %esp,%ebp 223: 57 push %edi 224: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 227: 8b 4d 10 mov 0x10(%ebp),%ecx 22a: 8b 45 0c mov 0xc(%ebp),%eax 22d: 89 d7 mov %edx,%edi 22f: fc cld 230: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 232: 89 d0 mov %edx,%eax 234: 5f pop %edi 235: 5d pop %ebp 236: c3 ret 237: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 23e: 66 90 xchg %ax,%ax 00000240 <strchr>: char* strchr(const char *s, char c) { 240: 55 push %ebp 241: 89 e5 mov %esp,%ebp 243: 53 push %ebx 244: 8b 45 08 mov 0x8(%ebp),%eax 247: 8b 55 0c mov 0xc(%ebp),%edx for(; *s; s++) 24a: 0f b6 18 movzbl (%eax),%ebx 24d: 84 db test %bl,%bl 24f: 74 1d je 26e <strchr+0x2e> 251: 89 d1 mov %edx,%ecx if(*s == c) 253: 38 d3 cmp %dl,%bl 255: 75 0d jne 264 <strchr+0x24> 257: eb 17 jmp 270 <strchr+0x30> 259: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 260: 38 ca cmp %cl,%dl 262: 74 0c je 270 <strchr+0x30> for(; *s; s++) 264: 83 c0 01 add $0x1,%eax 267: 0f b6 10 movzbl (%eax),%edx 26a: 84 d2 test %dl,%dl 26c: 75 f2 jne 260 <strchr+0x20> return (char*)s; return 0; 26e: 31 c0 xor %eax,%eax } 270: 5b pop %ebx 271: 5d pop %ebp 272: c3 ret 273: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 27a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000280 <gets>: char* gets(char *buf, int max) { 280: 55 push %ebp 281: 89 e5 mov %esp,%ebp 283: 57 push %edi 284: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 285: 31 f6 xor %esi,%esi { 287: 53 push %ebx 288: 89 f3 mov %esi,%ebx 28a: 83 ec 1c sub $0x1c,%esp 28d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 290: eb 2f jmp 2c1 <gets+0x41> 292: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 298: 83 ec 04 sub $0x4,%esp 29b: 8d 45 e7 lea -0x19(%ebp),%eax 29e: 6a 01 push $0x1 2a0: 50 push %eax 2a1: 6a 00 push $0x0 2a3: e8 31 01 00 00 call 3d9 <read> if(cc < 1) 2a8: 83 c4 10 add $0x10,%esp 2ab: 85 c0 test %eax,%eax 2ad: 7e 1c jle 2cb <gets+0x4b> break; buf[i++] = c; 2af: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 2b3: 83 c7 01 add $0x1,%edi 2b6: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 2b9: 3c 0a cmp $0xa,%al 2bb: 74 23 je 2e0 <gets+0x60> 2bd: 3c 0d cmp $0xd,%al 2bf: 74 1f je 2e0 <gets+0x60> for(i=0; i+1 < max; ){ 2c1: 83 c3 01 add $0x1,%ebx 2c4: 89 fe mov %edi,%esi 2c6: 3b 5d 0c cmp 0xc(%ebp),%ebx 2c9: 7c cd jl 298 <gets+0x18> 2cb: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 2cd: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 2d0: c6 03 00 movb $0x0,(%ebx) } 2d3: 8d 65 f4 lea -0xc(%ebp),%esp 2d6: 5b pop %ebx 2d7: 5e pop %esi 2d8: 5f pop %edi 2d9: 5d pop %ebp 2da: c3 ret 2db: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 2df: 90 nop 2e0: 8b 75 08 mov 0x8(%ebp),%esi 2e3: 8b 45 08 mov 0x8(%ebp),%eax 2e6: 01 de add %ebx,%esi 2e8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 2ea: c6 03 00 movb $0x0,(%ebx) } 2ed: 8d 65 f4 lea -0xc(%ebp),%esp 2f0: 5b pop %ebx 2f1: 5e pop %esi 2f2: 5f pop %edi 2f3: 5d pop %ebp 2f4: c3 ret 2f5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 2fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000300 <stat>: int stat(const char *n, struct stat *st) { 300: 55 push %ebp 301: 89 e5 mov %esp,%ebp 303: 56 push %esi 304: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 305: 83 ec 08 sub $0x8,%esp 308: 6a 00 push $0x0 30a: ff 75 08 pushl 0x8(%ebp) 30d: e8 ef 00 00 00 call 401 <open> if(fd < 0) 312: 83 c4 10 add $0x10,%esp 315: 85 c0 test %eax,%eax 317: 78 27 js 340 <stat+0x40> return -1; r = fstat(fd, st); 319: 83 ec 08 sub $0x8,%esp 31c: ff 75 0c pushl 0xc(%ebp) 31f: 89 c3 mov %eax,%ebx 321: 50 push %eax 322: e8 f2 00 00 00 call 419 <fstat> close(fd); 327: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 32a: 89 c6 mov %eax,%esi close(fd); 32c: e8 b8 00 00 00 call 3e9 <close> return r; 331: 83 c4 10 add $0x10,%esp } 334: 8d 65 f8 lea -0x8(%ebp),%esp 337: 89 f0 mov %esi,%eax 339: 5b pop %ebx 33a: 5e pop %esi 33b: 5d pop %ebp 33c: c3 ret 33d: 8d 76 00 lea 0x0(%esi),%esi return -1; 340: be ff ff ff ff mov $0xffffffff,%esi 345: eb ed jmp 334 <stat+0x34> 347: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 34e: 66 90 xchg %ax,%ax 00000350 <atoi>: int atoi(const char *s) { 350: 55 push %ebp 351: 89 e5 mov %esp,%ebp 353: 53 push %ebx 354: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 357: 0f be 11 movsbl (%ecx),%edx 35a: 8d 42 d0 lea -0x30(%edx),%eax 35d: 3c 09 cmp $0x9,%al n = 0; 35f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 364: 77 1f ja 385 <atoi+0x35> 366: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 36d: 8d 76 00 lea 0x0(%esi),%esi n = n*10 + *s++ - '0'; 370: 83 c1 01 add $0x1,%ecx 373: 8d 04 80 lea (%eax,%eax,4),%eax 376: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 37a: 0f be 11 movsbl (%ecx),%edx 37d: 8d 5a d0 lea -0x30(%edx),%ebx 380: 80 fb 09 cmp $0x9,%bl 383: 76 eb jbe 370 <atoi+0x20> return n; } 385: 5b pop %ebx 386: 5d pop %ebp 387: c3 ret 388: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 38f: 90 nop 00000390 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 390: 55 push %ebp 391: 89 e5 mov %esp,%ebp 393: 57 push %edi 394: 8b 55 10 mov 0x10(%ebp),%edx 397: 8b 45 08 mov 0x8(%ebp),%eax 39a: 56 push %esi 39b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 39e: 85 d2 test %edx,%edx 3a0: 7e 13 jle 3b5 <memmove+0x25> 3a2: 01 c2 add %eax,%edx dst = vdst; 3a4: 89 c7 mov %eax,%edi 3a6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3ad: 8d 76 00 lea 0x0(%esi),%esi *dst++ = *src++; 3b0: a4 movsb %ds:(%esi),%es:(%edi) while(n-- > 0) 3b1: 39 fa cmp %edi,%edx 3b3: 75 fb jne 3b0 <memmove+0x20> return vdst; } 3b5: 5e pop %esi 3b6: 5f pop %edi 3b7: 5d pop %ebp 3b8: c3 ret 000003b9 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 3b9: b8 01 00 00 00 mov $0x1,%eax 3be: cd 40 int $0x40 3c0: c3 ret 000003c1 <exit>: SYSCALL(exit) 3c1: b8 02 00 00 00 mov $0x2,%eax 3c6: cd 40 int $0x40 3c8: c3 ret 000003c9 <wait>: SYSCALL(wait) 3c9: b8 03 00 00 00 mov $0x3,%eax 3ce: cd 40 int $0x40 3d0: c3 ret 000003d1 <pipe>: SYSCALL(pipe) 3d1: b8 04 00 00 00 mov $0x4,%eax 3d6: cd 40 int $0x40 3d8: c3 ret 000003d9 <read>: SYSCALL(read) 3d9: b8 05 00 00 00 mov $0x5,%eax 3de: cd 40 int $0x40 3e0: c3 ret 000003e1 <write>: SYSCALL(write) 3e1: b8 10 00 00 00 mov $0x10,%eax 3e6: cd 40 int $0x40 3e8: c3 ret 000003e9 <close>: SYSCALL(close) 3e9: b8 15 00 00 00 mov $0x15,%eax 3ee: cd 40 int $0x40 3f0: c3 ret 000003f1 <kill>: SYSCALL(kill) 3f1: b8 06 00 00 00 mov $0x6,%eax 3f6: cd 40 int $0x40 3f8: c3 ret 000003f9 <exec>: SYSCALL(exec) 3f9: b8 07 00 00 00 mov $0x7,%eax 3fe: cd 40 int $0x40 400: c3 ret 00000401 <open>: SYSCALL(open) 401: b8 0f 00 00 00 mov $0xf,%eax 406: cd 40 int $0x40 408: c3 ret 00000409 <mknod>: SYSCALL(mknod) 409: b8 11 00 00 00 mov $0x11,%eax 40e: cd 40 int $0x40 410: c3 ret 00000411 <unlink>: SYSCALL(unlink) 411: b8 12 00 00 00 mov $0x12,%eax 416: cd 40 int $0x40 418: c3 ret 00000419 <fstat>: SYSCALL(fstat) 419: b8 08 00 00 00 mov $0x8,%eax 41e: cd 40 int $0x40 420: c3 ret 00000421 <link>: SYSCALL(link) 421: b8 13 00 00 00 mov $0x13,%eax 426: cd 40 int $0x40 428: c3 ret 00000429 <mkdir>: SYSCALL(mkdir) 429: b8 14 00 00 00 mov $0x14,%eax 42e: cd 40 int $0x40 430: c3 ret 00000431 <chdir>: SYSCALL(chdir) 431: b8 09 00 00 00 mov $0x9,%eax 436: cd 40 int $0x40 438: c3 ret 00000439 <dup>: SYSCALL(dup) 439: b8 0a 00 00 00 mov $0xa,%eax 43e: cd 40 int $0x40 440: c3 ret 00000441 <getpid>: SYSCALL(getpid) 441: b8 0b 00 00 00 mov $0xb,%eax 446: cd 40 int $0x40 448: c3 ret 00000449 <sbrk>: SYSCALL(sbrk) 449: b8 0c 00 00 00 mov $0xc,%eax 44e: cd 40 int $0x40 450: c3 ret 00000451 <sleep>: SYSCALL(sleep) 451: b8 0d 00 00 00 mov $0xd,%eax 456: cd 40 int $0x40 458: c3 ret 00000459 <uptime>: SYSCALL(uptime) 459: b8 0e 00 00 00 mov $0xe,%eax 45e: cd 40 int $0x40 460: c3 ret 00000461 <getChild>: SYSCALL(getChild) 461: b8 16 00 00 00 mov $0x16,%eax 466: cd 40 int $0x40 468: c3 ret 00000469 <getCount>: SYSCALL(getCount) 469: b8 17 00 00 00 mov $0x17,%eax 46e: cd 40 int $0x40 470: c3 ret 00000471 <getppid>: SYSCALL(getppid) 471: b8 18 00 00 00 mov $0x18,%eax 476: cd 40 int $0x40 478: c3 ret 00000479 <changePolicy>: SYSCALL(changePolicy) 479: b8 19 00 00 00 mov $0x19,%eax 47e: cd 40 int $0x40 480: c3 ret 481: 66 90 xchg %ax,%ax 483: 66 90 xchg %ax,%ax 485: 66 90 xchg %ax,%ax 487: 66 90 xchg %ax,%ax 489: 66 90 xchg %ax,%ax 48b: 66 90 xchg %ax,%ax 48d: 66 90 xchg %ax,%ax 48f: 90 nop 00000490 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 490: 55 push %ebp 491: 89 e5 mov %esp,%ebp 493: 57 push %edi 494: 56 push %esi 495: 53 push %ebx uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 496: 89 d3 mov %edx,%ebx { 498: 83 ec 3c sub $0x3c,%esp 49b: 89 45 bc mov %eax,-0x44(%ebp) if(sgn && xx < 0){ 49e: 85 d2 test %edx,%edx 4a0: 0f 89 92 00 00 00 jns 538 <printint+0xa8> 4a6: f6 45 08 01 testb $0x1,0x8(%ebp) 4aa: 0f 84 88 00 00 00 je 538 <printint+0xa8> neg = 1; 4b0: c7 45 c0 01 00 00 00 movl $0x1,-0x40(%ebp) x = -xx; 4b7: f7 db neg %ebx } else { x = xx; } i = 0; 4b9: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 4c0: 8d 75 d7 lea -0x29(%ebp),%esi 4c3: eb 08 jmp 4cd <printint+0x3d> 4c5: 8d 76 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 4c8: 89 7d c4 mov %edi,-0x3c(%ebp) }while((x /= base) != 0); 4cb: 89 c3 mov %eax,%ebx buf[i++] = digits[x % base]; 4cd: 89 d8 mov %ebx,%eax 4cf: 31 d2 xor %edx,%edx 4d1: 8b 7d c4 mov -0x3c(%ebp),%edi 4d4: f7 f1 div %ecx 4d6: 83 c7 01 add $0x1,%edi 4d9: 0f b6 92 f8 08 00 00 movzbl 0x8f8(%edx),%edx 4e0: 88 14 3e mov %dl,(%esi,%edi,1) }while((x /= base) != 0); 4e3: 39 d9 cmp %ebx,%ecx 4e5: 76 e1 jbe 4c8 <printint+0x38> if(neg) 4e7: 8b 45 c0 mov -0x40(%ebp),%eax 4ea: 85 c0 test %eax,%eax 4ec: 74 0d je 4fb <printint+0x6b> buf[i++] = '-'; 4ee: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 4f3: ba 2d 00 00 00 mov $0x2d,%edx buf[i++] = digits[x % base]; 4f8: 89 7d c4 mov %edi,-0x3c(%ebp) 4fb: 8b 45 c4 mov -0x3c(%ebp),%eax 4fe: 8b 7d bc mov -0x44(%ebp),%edi 501: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx 505: eb 0f jmp 516 <printint+0x86> 507: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 50e: 66 90 xchg %ax,%ax 510: 0f b6 13 movzbl (%ebx),%edx 513: 83 eb 01 sub $0x1,%ebx write(fd, &c, 1); 516: 83 ec 04 sub $0x4,%esp 519: 88 55 d7 mov %dl,-0x29(%ebp) 51c: 6a 01 push $0x1 51e: 56 push %esi 51f: 57 push %edi 520: e8 bc fe ff ff call 3e1 <write> while(--i >= 0) 525: 83 c4 10 add $0x10,%esp 528: 39 de cmp %ebx,%esi 52a: 75 e4 jne 510 <printint+0x80> putc(fd, buf[i]); } 52c: 8d 65 f4 lea -0xc(%ebp),%esp 52f: 5b pop %ebx 530: 5e pop %esi 531: 5f pop %edi 532: 5d pop %ebp 533: c3 ret 534: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 538: c7 45 c0 00 00 00 00 movl $0x0,-0x40(%ebp) 53f: e9 75 ff ff ff jmp 4b9 <printint+0x29> 544: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 54b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 54f: 90 nop 00000550 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 550: 55 push %ebp 551: 89 e5 mov %esp,%ebp 553: 57 push %edi 554: 56 push %esi 555: 53 push %ebx 556: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 559: 8b 75 0c mov 0xc(%ebp),%esi 55c: 0f b6 1e movzbl (%esi),%ebx 55f: 84 db test %bl,%bl 561: 0f 84 b9 00 00 00 je 620 <printf+0xd0> ap = (uint*)(void*)&fmt + 1; 567: 8d 45 10 lea 0x10(%ebp),%eax 56a: 83 c6 01 add $0x1,%esi write(fd, &c, 1); 56d: 8d 7d e7 lea -0x19(%ebp),%edi state = 0; 570: 31 d2 xor %edx,%edx ap = (uint*)(void*)&fmt + 1; 572: 89 45 d0 mov %eax,-0x30(%ebp) 575: eb 38 jmp 5af <printf+0x5f> 577: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 57e: 66 90 xchg %ax,%ax 580: 89 55 d4 mov %edx,-0x2c(%ebp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 583: ba 25 00 00 00 mov $0x25,%edx if(c == '%'){ 588: 83 f8 25 cmp $0x25,%eax 58b: 74 17 je 5a4 <printf+0x54> write(fd, &c, 1); 58d: 83 ec 04 sub $0x4,%esp 590: 88 5d e7 mov %bl,-0x19(%ebp) 593: 6a 01 push $0x1 595: 57 push %edi 596: ff 75 08 pushl 0x8(%ebp) 599: e8 43 fe ff ff call 3e1 <write> 59e: 8b 55 d4 mov -0x2c(%ebp),%edx } else { putc(fd, c); 5a1: 83 c4 10 add $0x10,%esp 5a4: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 5a7: 0f b6 5e ff movzbl -0x1(%esi),%ebx 5ab: 84 db test %bl,%bl 5ad: 74 71 je 620 <printf+0xd0> c = fmt[i] & 0xff; 5af: 0f be cb movsbl %bl,%ecx 5b2: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 5b5: 85 d2 test %edx,%edx 5b7: 74 c7 je 580 <printf+0x30> } } else if(state == '%'){ 5b9: 83 fa 25 cmp $0x25,%edx 5bc: 75 e6 jne 5a4 <printf+0x54> if(c == 'd'){ 5be: 83 f8 64 cmp $0x64,%eax 5c1: 0f 84 99 00 00 00 je 660 <printf+0x110> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 5c7: 81 e1 f7 00 00 00 and $0xf7,%ecx 5cd: 83 f9 70 cmp $0x70,%ecx 5d0: 74 5e je 630 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 5d2: 83 f8 73 cmp $0x73,%eax 5d5: 0f 84 d5 00 00 00 je 6b0 <printf+0x160> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 5db: 83 f8 63 cmp $0x63,%eax 5de: 0f 84 8c 00 00 00 je 670 <printf+0x120> putc(fd, *ap); ap++; } else if(c == '%'){ 5e4: 83 f8 25 cmp $0x25,%eax 5e7: 0f 84 b3 00 00 00 je 6a0 <printf+0x150> write(fd, &c, 1); 5ed: 83 ec 04 sub $0x4,%esp 5f0: c6 45 e7 25 movb $0x25,-0x19(%ebp) 5f4: 6a 01 push $0x1 5f6: 57 push %edi 5f7: ff 75 08 pushl 0x8(%ebp) 5fa: e8 e2 fd ff ff call 3e1 <write> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 5ff: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 602: 83 c4 0c add $0xc,%esp 605: 6a 01 push $0x1 607: 83 c6 01 add $0x1,%esi 60a: 57 push %edi 60b: ff 75 08 pushl 0x8(%ebp) 60e: e8 ce fd ff ff call 3e1 <write> for(i = 0; fmt[i]; i++){ 613: 0f b6 5e ff movzbl -0x1(%esi),%ebx putc(fd, c); 617: 83 c4 10 add $0x10,%esp } state = 0; 61a: 31 d2 xor %edx,%edx for(i = 0; fmt[i]; i++){ 61c: 84 db test %bl,%bl 61e: 75 8f jne 5af <printf+0x5f> } } } 620: 8d 65 f4 lea -0xc(%ebp),%esp 623: 5b pop %ebx 624: 5e pop %esi 625: 5f pop %edi 626: 5d pop %ebp 627: c3 ret 628: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 62f: 90 nop printint(fd, *ap, 16, 0); 630: 83 ec 0c sub $0xc,%esp 633: b9 10 00 00 00 mov $0x10,%ecx 638: 6a 00 push $0x0 63a: 8b 5d d0 mov -0x30(%ebp),%ebx 63d: 8b 45 08 mov 0x8(%ebp),%eax 640: 8b 13 mov (%ebx),%edx 642: e8 49 fe ff ff call 490 <printint> ap++; 647: 89 d8 mov %ebx,%eax 649: 83 c4 10 add $0x10,%esp state = 0; 64c: 31 d2 xor %edx,%edx ap++; 64e: 83 c0 04 add $0x4,%eax 651: 89 45 d0 mov %eax,-0x30(%ebp) 654: e9 4b ff ff ff jmp 5a4 <printf+0x54> 659: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printint(fd, *ap, 10, 1); 660: 83 ec 0c sub $0xc,%esp 663: b9 0a 00 00 00 mov $0xa,%ecx 668: 6a 01 push $0x1 66a: eb ce jmp 63a <printf+0xea> 66c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, *ap); 670: 8b 5d d0 mov -0x30(%ebp),%ebx write(fd, &c, 1); 673: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 676: 8b 03 mov (%ebx),%eax write(fd, &c, 1); 678: 6a 01 push $0x1 ap++; 67a: 83 c3 04 add $0x4,%ebx write(fd, &c, 1); 67d: 57 push %edi 67e: ff 75 08 pushl 0x8(%ebp) putc(fd, *ap); 681: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 684: e8 58 fd ff ff call 3e1 <write> ap++; 689: 89 5d d0 mov %ebx,-0x30(%ebp) 68c: 83 c4 10 add $0x10,%esp state = 0; 68f: 31 d2 xor %edx,%edx 691: e9 0e ff ff ff jmp 5a4 <printf+0x54> 696: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 69d: 8d 76 00 lea 0x0(%esi),%esi putc(fd, c); 6a0: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 6a3: 83 ec 04 sub $0x4,%esp 6a6: e9 5a ff ff ff jmp 605 <printf+0xb5> 6ab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 6af: 90 nop s = (char*)*ap; 6b0: 8b 45 d0 mov -0x30(%ebp),%eax 6b3: 8b 18 mov (%eax),%ebx ap++; 6b5: 83 c0 04 add $0x4,%eax 6b8: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) 6bb: 85 db test %ebx,%ebx 6bd: 74 17 je 6d6 <printf+0x186> while(*s != 0){ 6bf: 0f b6 03 movzbl (%ebx),%eax state = 0; 6c2: 31 d2 xor %edx,%edx while(*s != 0){ 6c4: 84 c0 test %al,%al 6c6: 0f 84 d8 fe ff ff je 5a4 <printf+0x54> 6cc: 89 75 d4 mov %esi,-0x2c(%ebp) 6cf: 89 de mov %ebx,%esi 6d1: 8b 5d 08 mov 0x8(%ebp),%ebx 6d4: eb 1a jmp 6f0 <printf+0x1a0> s = "(null)"; 6d6: bb ef 08 00 00 mov $0x8ef,%ebx while(*s != 0){ 6db: 89 75 d4 mov %esi,-0x2c(%ebp) 6de: b8 28 00 00 00 mov $0x28,%eax 6e3: 89 de mov %ebx,%esi 6e5: 8b 5d 08 mov 0x8(%ebp),%ebx 6e8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 6ef: 90 nop write(fd, &c, 1); 6f0: 83 ec 04 sub $0x4,%esp s++; 6f3: 83 c6 01 add $0x1,%esi 6f6: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 6f9: 6a 01 push $0x1 6fb: 57 push %edi 6fc: 53 push %ebx 6fd: e8 df fc ff ff call 3e1 <write> while(*s != 0){ 702: 0f b6 06 movzbl (%esi),%eax 705: 83 c4 10 add $0x10,%esp 708: 84 c0 test %al,%al 70a: 75 e4 jne 6f0 <printf+0x1a0> 70c: 8b 75 d4 mov -0x2c(%ebp),%esi state = 0; 70f: 31 d2 xor %edx,%edx 711: e9 8e fe ff ff jmp 5a4 <printf+0x54> 716: 66 90 xchg %ax,%ax 718: 66 90 xchg %ax,%ax 71a: 66 90 xchg %ax,%ax 71c: 66 90 xchg %ax,%ax 71e: 66 90 xchg %ax,%ax 00000720 <free>: static Header base; static Header *freep; void free(void *ap) { 720: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 721: a1 e0 0b 00 00 mov 0xbe0,%eax { 726: 89 e5 mov %esp,%ebp 728: 57 push %edi 729: 56 push %esi 72a: 53 push %ebx 72b: 8b 5d 08 mov 0x8(%ebp),%ebx 72e: 8b 10 mov (%eax),%edx bp = (Header*)ap - 1; 730: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 733: 39 c8 cmp %ecx,%eax 735: 73 19 jae 750 <free+0x30> 737: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 73e: 66 90 xchg %ax,%ax 740: 39 d1 cmp %edx,%ecx 742: 72 14 jb 758 <free+0x38> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 744: 39 d0 cmp %edx,%eax 746: 73 10 jae 758 <free+0x38> { 748: 89 d0 mov %edx,%eax 74a: 8b 10 mov (%eax),%edx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 74c: 39 c8 cmp %ecx,%eax 74e: 72 f0 jb 740 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 750: 39 d0 cmp %edx,%eax 752: 72 f4 jb 748 <free+0x28> 754: 39 d1 cmp %edx,%ecx 756: 73 f0 jae 748 <free+0x28> break; if(bp + bp->s.size == p->s.ptr){ 758: 8b 73 fc mov -0x4(%ebx),%esi 75b: 8d 3c f1 lea (%ecx,%esi,8),%edi 75e: 39 fa cmp %edi,%edx 760: 74 1e je 780 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 762: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 765: 8b 50 04 mov 0x4(%eax),%edx 768: 8d 34 d0 lea (%eax,%edx,8),%esi 76b: 39 f1 cmp %esi,%ecx 76d: 74 28 je 797 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 76f: 89 08 mov %ecx,(%eax) freep = p; } 771: 5b pop %ebx freep = p; 772: a3 e0 0b 00 00 mov %eax,0xbe0 } 777: 5e pop %esi 778: 5f pop %edi 779: 5d pop %ebp 77a: c3 ret 77b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 77f: 90 nop bp->s.size += p->s.ptr->s.size; 780: 03 72 04 add 0x4(%edx),%esi 783: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 786: 8b 10 mov (%eax),%edx 788: 8b 12 mov (%edx),%edx 78a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 78d: 8b 50 04 mov 0x4(%eax),%edx 790: 8d 34 d0 lea (%eax,%edx,8),%esi 793: 39 f1 cmp %esi,%ecx 795: 75 d8 jne 76f <free+0x4f> p->s.size += bp->s.size; 797: 03 53 fc add -0x4(%ebx),%edx freep = p; 79a: a3 e0 0b 00 00 mov %eax,0xbe0 p->s.size += bp->s.size; 79f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 7a2: 8b 53 f8 mov -0x8(%ebx),%edx 7a5: 89 10 mov %edx,(%eax) } 7a7: 5b pop %ebx 7a8: 5e pop %esi 7a9: 5f pop %edi 7aa: 5d pop %ebp 7ab: c3 ret 7ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000007b0 <malloc>: return freep; } void* malloc(int nbytes) { 7b0: 55 push %ebp 7b1: 89 e5 mov %esp,%ebp 7b3: 57 push %edi 7b4: 56 push %esi 7b5: 53 push %ebx 7b6: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 7b9: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 7bc: 8b 3d e0 0b 00 00 mov 0xbe0,%edi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 7c2: 8d 70 07 lea 0x7(%eax),%esi 7c5: c1 ee 03 shr $0x3,%esi 7c8: 83 c6 01 add $0x1,%esi if((prevp = freep) == 0){ 7cb: 85 ff test %edi,%edi 7cd: 0f 84 ad 00 00 00 je 880 <malloc+0xd0> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 7d3: 8b 17 mov (%edi),%edx if(p->s.size >= nunits){ 7d5: 8b 4a 04 mov 0x4(%edx),%ecx 7d8: 39 f1 cmp %esi,%ecx 7da: 73 72 jae 84e <malloc+0x9e> 7dc: 81 fe 00 10 00 00 cmp $0x1000,%esi 7e2: bb 00 10 00 00 mov $0x1000,%ebx 7e7: 0f 43 de cmovae %esi,%ebx p = sbrk(nu * sizeof(Header)); 7ea: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax 7f1: 89 45 e4 mov %eax,-0x1c(%ebp) 7f4: eb 1b jmp 811 <malloc+0x61> 7f6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 7fd: 8d 76 00 lea 0x0(%esi),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 800: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 802: 8b 48 04 mov 0x4(%eax),%ecx 805: 39 f1 cmp %esi,%ecx 807: 73 4f jae 858 <malloc+0xa8> 809: 8b 3d e0 0b 00 00 mov 0xbe0,%edi 80f: 89 c2 mov %eax,%edx p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 811: 39 d7 cmp %edx,%edi 813: 75 eb jne 800 <malloc+0x50> p = sbrk(nu * sizeof(Header)); 815: 83 ec 0c sub $0xc,%esp 818: ff 75 e4 pushl -0x1c(%ebp) 81b: e8 29 fc ff ff call 449 <sbrk> if(p == (char*)-1) 820: 83 c4 10 add $0x10,%esp 823: 83 f8 ff cmp $0xffffffff,%eax 826: 74 1c je 844 <malloc+0x94> hp->s.size = nu; 828: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 82b: 83 ec 0c sub $0xc,%esp 82e: 83 c0 08 add $0x8,%eax 831: 50 push %eax 832: e8 e9 fe ff ff call 720 <free> return freep; 837: 8b 15 e0 0b 00 00 mov 0xbe0,%edx if((p = morecore(nunits)) == 0) 83d: 83 c4 10 add $0x10,%esp 840: 85 d2 test %edx,%edx 842: 75 bc jne 800 <malloc+0x50> return 0; } } 844: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 847: 31 c0 xor %eax,%eax } 849: 5b pop %ebx 84a: 5e pop %esi 84b: 5f pop %edi 84c: 5d pop %ebp 84d: c3 ret if(p->s.size >= nunits){ 84e: 89 d0 mov %edx,%eax 850: 89 fa mov %edi,%edx 852: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 858: 39 ce cmp %ecx,%esi 85a: 74 54 je 8b0 <malloc+0x100> p->s.size -= nunits; 85c: 29 f1 sub %esi,%ecx 85e: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 861: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 864: 89 70 04 mov %esi,0x4(%eax) freep = prevp; 867: 89 15 e0 0b 00 00 mov %edx,0xbe0 } 86d: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 870: 83 c0 08 add $0x8,%eax } 873: 5b pop %ebx 874: 5e pop %esi 875: 5f pop %edi 876: 5d pop %ebp 877: c3 ret 878: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 87f: 90 nop base.s.ptr = freep = prevp = &base; 880: c7 05 e0 0b 00 00 e4 movl $0xbe4,0xbe0 887: 0b 00 00 base.s.size = 0; 88a: bf e4 0b 00 00 mov $0xbe4,%edi base.s.ptr = freep = prevp = &base; 88f: c7 05 e4 0b 00 00 e4 movl $0xbe4,0xbe4 896: 0b 00 00 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 899: 89 fa mov %edi,%edx base.s.size = 0; 89b: c7 05 e8 0b 00 00 00 movl $0x0,0xbe8 8a2: 00 00 00 if(p->s.size >= nunits){ 8a5: e9 32 ff ff ff jmp 7dc <malloc+0x2c> 8aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi prevp->s.ptr = p->s.ptr; 8b0: 8b 08 mov (%eax),%ecx 8b2: 89 0a mov %ecx,(%edx) 8b4: eb b1 jmp 867 <malloc+0xb7>
oeis/209/A209267.asm
neoneye/loda-programs
11
105306
; A209267: 1 + 2*n^2 + 3*n^3 + 4*n^4 + 5*n^5 + 6*n^6 + 7*n^7 + 8*n^8. ; 1,36,3585,73810,669921,3784176,15721201,52683870,150652545,381367036,876543201,1862778666,3709924705,6996023880,12592235601,21771494326,36344967681,58830704340,92659184065,142420804866,214160664801,315726318496,457174511025,651243214350,913895614081,1264943016876,1728753971361,2335057218010,3119846405985,4126394837496,5406388822801,7021188551526,9043225708545,11557547385220,14663516159361,18476676539826,23130798294241,28780107500880,35601716488305,43798264148926,53600778435201,65271773169756 mov $2,8 lpb $2 add $1,$2 mul $1,$0 sub $2,1 lpe sub $1,$0 add $1,1 mov $0,$1
programs/oeis/248/A248423.asm
neoneye/loda
22
245398
; A248423: Multiples of 4 with digits backwards. ; 0,4,8,21,61,2,42,82,23,63,4,44,84,25,65,6,46,86,27,67,8,48,88,29,69,1,401,801,211,611,21,421,821,231,631,41,441,841,251,651,61,461,861,271,671,81,481,881,291,691,2 mul $0,4 seq $0,4086 ; Read n backwards (referred to as R(n) in many sequences).
programs/oeis/173/A173173.asm
neoneye/loda
22
13213
; A173173: a(n) = ceiling(Fibonacci(n)/2). ; 0,1,1,1,2,3,4,7,11,17,28,45,72,117,189,305,494,799,1292,2091,3383,5473,8856,14329,23184,37513,60697,98209,158906,257115,416020,673135,1089155,1762289,2851444,4613733,7465176,12078909,19544085,31622993,51167078,82790071,133957148,216747219,350704367,567451585,918155952,1485607537,2403763488,3889371025,6293134513,10182505537,16475640050,26658145587,43133785636,69791931223,112925716859,182717648081,295643364940,478361013021,774004377960,1252365390981,2026369768941,3278735159921,5305104928862,8583840088783,13888945017644,22472785106427,36361730124071,58834515230497,95196245354568,154030760585065,249227005939632,403257766524697,652484772464329,1055742538989025,1708227311453354,2763969850442379,4472197161895732,7236167012338111,11708364174233843,18944531186571953,30652895360805796,49597426547377749,80250321908183544,129847748455561293,210098070363744837,339945818819306129,550043889183050966,889989708002357095,1440033597185408060,2330023305187765155,3770056902373173215,6100080207560938369,9870137109934111584,15970217317495049953,25840354427429161536,41810571744924211489,67650926172353373025,109461497917277584513 seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1. add $0,1 div $0,2
Lab01/Ex2.asm
frr0/Assembly-MIPS
0
87954
<filename>Lab01/Ex2.asm .data var1: .byte 'm' var2: .byte 'i' var3: .byte 'p' var4: .byte 's' var5: .byte 0 .text .globl main .ent main main: lb $t1, var1 # caricamento dati lb $t2, var2 lb $t3, var3 lb $t4, var4 lb $t5, var5 sub $t1, $t1, 32 #a -> A t1-32 sub $t2, $t2, 32 #b -> B t2-32 sub $t3, $t3, 32 #c -> C t3-32 sub $t4, $t4, 32 #d -> D t4-32 li $v0, 4 # syscall 4 (print_str) la $a0, var1 # argomento: stringa syscall # stampa intero # li $v0, 1 # syscall sb $t1, var1 # salvataggio del risultato in memoria sb $t2, var2 # salvataggio del risultato in memoria sb $t3, var3 # salvataggio del risultato in memoria sb $t4, var4 # salvataggio del risultato in memoria li $v0, 4 # syscall 4 (print_str) la $a0, var1 # argomento: stringa syscall # stampa intero # li $v0, 1 # syscall # termina il programma li $v0, 10 # syscall syscall # fine .end main
asm (HLQ.RIFASM)/rifwait.asm
jcnnrts/RIF
0
81133
*********************************************************************** * Project: FMT * * * * This program is an assembler module that will issue a WAIT SVC on * * an ECB list. The ECBs should be pre-allocated and cleared to * * binary zeroes before calling this module. This assembler program is * * LE compliant, and as a result is callable from Enterprise PL/1 * * programs. * * * * We do this because we want to be able to use the POST / WAIT * * syncronisation method provided by the z/Architecture, but which is * * not available to us in standard Enterprise PL/1. * * * * !!! THE ECBs HAVE TO BE FULLWORD ALIGNED !!! * * * * This program WILL NOT clean up the ECB that is WAITed upon, after * * it has been POSTed. * * * ******************************************************************[v]** * Registers upon entry; * * R1 - Points to caller's parameter list. * * R12 - Points to LE CAA (automatic from PL/1) * * R13 - Points to caller's DSA on entry. * * R14 - Return address. * * R15 - Entry address. * * * * * * Touched registers; * * R0 - Number of ECBs to wait on. * * R1 - Pointer to ECB. * * R12 - Used as a base register. * * R15 - Return code upon exit. * * * * * ******************************************************************[v]** * Parameter list; * * * * R1 -> [Pointer to first parameter] * * +-> [Pointer to ECBLIST to WAIT on.] * * +-> [Pointer to first ECB to WAIT on.] * * +-> [Pointer to second ECB to WAIT on.] * * +-> [Pointer to ... ECB to WAIT on.] * ******************************************************************[v]** TITLE 'RIFWAIT' LCLC &MODULE &MODULE SETC 'RIFWAIT' &MODULE CSECT &MODULE AMODE 31 &MODULE RMODE 31 * R0 EQU 0 R1 EQU 1 R2 EQU 2 R3 EQU 3 R4 EQU 4 R5 EQU 5 R6 EQU 6 R7 EQU 7 R8 EQU 8 R9 EQU 9 R10 EQU 10 R11 EQU 11 R12 EQU 12 R13 EQU 13 R14 EQU 14 R15 EQU 15 * STM r14,r12,12(r13) Store registers in prev DSA save area. USING RIFWAIT,r12 Use r12 as our base. LR r12,r15 Load r12 with r15 (addr of this module) * LA r0,1(0,r0) Load 1 in to r0, amount of ECBs to wait on. L r1,0(,r1) Load addr of first parm in r1. L r1,0(,r1) Load addr of ECB List in r1. * SVC 1 SVC 1 = WAIT WAIT 1,ECBLIST=(1),LONG=YES * LM r14,r12,12(r13) Restore registers. SR r15,r15 Retcode = 0 BR r14 Return from whence we came. * END
AllocParser/grammar/Alloc.g4
CassieEllen/AllocTools
0
6485
/* * @author "<NAME>" */ grammar Alloc; // Define a grammar called Hello /* * By default, Antlr puts generated java files into the default java package. * That's not really best practice and makes */ @header { package com.cenicol.antlr4.alloc.parser; //import com.cenicol.mainframe.alloc.*; //import org.apache.commons.logging.Log; //import org.apache.commons.logging.LogFactory; } /* ------------------------------------------------------------------------ */ @parser::members { //private Log log = LogFactory.getLog(AllocParser.class); } @lexer::members { //private Log log = LogFactory.getLog(AllocLexer.class); public Token nextToken() { Token token = super.nextToken(); if(token.getType() == Token.EOF) { com.cenicol.mainframe.alloc.TokenStreamStack tss = com.cenicol.mainframe.alloc.TokenStreamStack.instance(); if( tss.empty() ) { return token; } //log.info("detected EOF"); tss.popTS(); } return token; } } script : (stat)+ ; stat : set | write | exit | call | block | filtlist | ifstat | copybook ; set : 'SET' ID EQ expr ; write : 'WRITE' expr ; exit : EXIT (CODE '(' INT ')' )? ; call : 'CALL' (VDSEXIT | QUOTACHK) ; block : 'DO' stat+ 'END' ; filtlist : 'FILTLIST' ID 'INCLUDE' list (EXCLUDE list)? ; list : '(' path (',' path )* ')' ; path : STRING # PathSTRING | GLOB # PathGLOB ; ifstat : 'IF' bexpr 'THEN' stat (ELSE stat)? ; copybook : 'COPYBOOK' STRING { Token t = $STRING; String name = t.getText(); String filename = name.substring(1,name.length()-1) + ".txt"; //log.info("COPYBOOK " + $STRING.getText() ); System.out.println("\nCOPYBOOK " + filename); com.cenicol.mainframe.alloc.TokenStreamStack tss = com.cenicol.mainframe.alloc.TokenStreamStack.instance(); tss.pushTS(filename); } ; /* ------------------------------------------------------------------------ */ CODE : 'CODE' ; ELSE : 'ELSE' ; EXIT : 'EXIT' ; EXCLUDE : 'EXCLUDE' ; VDSEXIT : 'VDSEXIT' DIGIT; QUOTACHK : 'QUOTACHK' ; /* ------------------------------------------------------------------------ */ expr: expr op=('*'|'/') expr # MulDiv | expr op=('+'|'-') expr # AddSub | INT # int | ID # id | STRING # string | GLOB # glob | '(' expr ')' # parens ; bexpr : bexpr AND bexpr # Band | bexpr OR bexpr # Bor | boolval # Bval ; boolval : expr op=( EQ | SEQ | NE | '!=' | LT | '<' | GT | '>' | LE | '<=' | GE | '>=' ) expr # cexpr ; /* ------------------------------------------------------------------------ */ AND : 'AND' | '&&' ; OR : 'OR' | '|' ; EQ : '=' ; SEQ : 'EQ' ; NE : 'NE' | '!=' ; LT : '<' ; GT : '>' ; LE : '<=' ; GE : '>=' ; MUL : '*' ; // assigns token name to '*' used above in grammar DIV : '/' ; ADD : '+' ; SUB : '-' ; ID : '&' [A-Z][A-Z0-9_]* ; // match identifiers INT : DIGIT+ ; // match integers fragment DIGIT: [0-9]; STRING : '\'' ('\'\''|~'\'')* '\'' ; GLOB : [A-Z0-9.*?]+ ; WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines, \r (Windows) COMMENT : '/*' .*? '*/' -> skip ; // skip comments
src/ada/src/comms/uxas-comms-transport-zeromq_fabric.ads
VVCAS-Sean/OpenUxAS
88
17144
<filename>src/ada/src/comms/uxas-comms-transport-zeromq_fabric.ads<gh_stars>10-100 -- see OpenUxAS\src\Communications\ZeroMqFabric.h with UxAS.Comms.Transport.ZeroMQ_Socket_Configurations; use UxAS.Comms.Transport.ZeroMQ_Socket_Configurations; with ZMQ.Sockets; use ZMQ.Sockets; with ZMQ.Contexts; use ZMQ.Contexts; package UxAS.Comms.Transport.ZeroMQ_Fabric is type ZMQ_Fabric (<>) is tagged limited private; type Any_Manager is access all ZMQ_Fabric'Class; type ZMQ_Fabric_Reference is access all ZMQ_Fabric; function Instance return not null ZMQ_Fabric_Reference; procedure Destroy; -- TODO: the C++ version uses pointers to the context and result -- -- std::unique_ptr<zmq::socket_t> -- createSocket(ZeroMqSocketConfiguration& socketConfiguration); procedure Create_Socket (This : ZMQ_Fabric_Reference; Config : ZeroMq_Socket_Configuration; Result : out Socket); private type ZMQ_Fabric is tagged limited record -- std::unique_ptr<zmq::context_t> m_zmqContext; zmQContext : Context; end record; The_Instance : ZMQ_Fabric_Reference; -- we use lazy allocation... end UxAS.Comms.Transport.ZeroMQ_Fabric;
alloy4fun_models/trashltl/models/7/7frH28yQHsJtwe4Jx.als
Kaixi26/org.alloytools.alloy
0
3535
open main pred id7frH28yQHsJtwe4Jx_prop8 { all f,g: File| f->g in link implies eventually always f in Trash } pred __repair { id7frH28yQHsJtwe4Jx_prop8 } check __repair { id7frH28yQHsJtwe4Jx_prop8 <=> prop8o }
stm32f1/stm32gd-i2c-peripheral.adb
ekoeppen/STM32_Generic_Ada_Drivers
1
2247
<gh_stars>1-10 package body STM32GD.I2C.Peripheral is procedure Init is begin null; end Init; function Master_Transmit (Address : I2C_Address; Data : Byte; Restart : Boolean := False) return Boolean is begin return False; end Master_Transmit; function Master_Receive (Address : I2C_Address; Data : out Byte) return Boolean is begin return True; end Master_Receive; function Master_Receive (Address : I2C_Address; Data : out I2C_Data) return Boolean is begin return True; end Master_Receive; function Write_Register (Address : I2C_Address; Register : Byte; Data : Byte) return Boolean is begin return True; end Write_Register; function Read_Register (Address : I2C_Address; Register : Byte; Data : out Byte) return Boolean is begin return True; end Read_Register; end STM32GD.I2C.Peripheral;
legend-engine-xt-persistence-grammar/src/main/antlr4/org/finos/legend/engine/language/pure/grammar/from/antlr4/PersistenceLexerGrammar.g4
PrateekGarg-gs/legend-engine
0
6918
lexer grammar PersistenceLexerGrammar; import M3LexerGrammar; // -------------------------------------- KEYWORD -------------------------------------- // COMMON TRUE: 'true'; FALSE: 'false'; IMPORT: 'import'; DERIVATION: 'derivation'; NONE: 'None'; DATE_TIME: 'DateTime'; //********** // PERSISTENCE //********** PERSISTENCE: 'Persistence'; PERSISTENCE_DOC: 'doc'; PERSISTENCE_TRIGGER: 'trigger'; PERSISTENCE_SERVICE: 'service'; PERSISTENCE_PERSISTER: 'persister'; PERSISTENCE_NOTIFIER: 'notifier'; // TRIGGER TRIGGER_MANUAL: 'Manual'; TRIGGER_CRON: 'Cron'; // PERSISTER PERSISTER_STREAMING: 'Streaming'; PERSISTER_BATCH: 'Batch'; PERSISTER_SINK: 'sink'; PERSISTER_TARGET_SHAPE: 'targetShape'; PERSISTER_INGEST_MODE: 'ingestMode'; // NOTIFIER NOTIFIER: 'Notifier'; NOTIFIER_NOTIFYEES: 'notifyees'; NOTIFYEE_EMAIL: 'Email'; NOTIFYEE_EMAIL_ADDRESS: 'address'; NOTIFYEE_PAGER_DUTY: 'PagerDuty'; NOTIFYEE_PAGER_DUTY_URL: 'url'; //********** // SINK //********** SINK_RELATIONAL: 'Relational'; SINK_OBJECT_STORAGE: 'ObjectStorage'; SINK_CONNECTION: 'connection'; SINK_BINDING: 'binding'; //********** // TARGET SHAPE //********** TARGET_SHAPE_MODEL_CLASS: 'modelClass'; TARGET_SHAPE_NAME: 'targetName'; TARGET_SHAPE_PARTITION_FIELDS: 'partitionFields'; TARGET_SHAPE_DEDUPLICATION: 'deduplicationStrategy'; // FLAT TARGET_SHAPE_FLAT: 'Flat'; // MULTI-FLAT TARGET_SHAPE_MULTI: 'MultiFlat'; TARGET_SHAPE_MULTI_TXN_SCOPE: 'transactionScope'; TARGET_SHAPE_MULTI_PARTS: 'parts'; TARGET_PART_MODEL_PROPERTY: 'modelProperty'; TXN_SCOPE_SINGLE: 'SINGLE_TARGET'; TXN_SCOPE_ALL: 'ALL_TARGETS'; // DEDUPLICATION VALUES DEDUPLICATION_ANY_VERSION: 'AnyVersion'; DEDUPLICATION_MAX_VERSION: 'MaxVersion'; DEDUPLICATION_MAX_VERSION_FIELD: 'versionField'; DEDUPLICATION_DUPLICATE_COUNT: 'DuplicateCount'; DEDUPLICATION_DUPLICATE_COUNT_NAME: 'duplicateCountName'; //********** // INGEST MODE //********** INGEST_MODE_NONTEMPORAL_SNAPSHOT: 'NontemporalSnapshot'; INGEST_MODE_UNITEMPORAL_SNAPSHOT: 'UnitemporalSnapshot'; INGEST_MODE_BITEMPORAL_SNAPSHOT: 'BitemporalSnapshot'; INGEST_MODE_NONTEMPORAL_DELTA: 'NontemporalDelta'; INGEST_MODE_UNITEMPORAL_DELTA: 'UnitemporalDelta'; INGEST_MODE_BITEMPORAL_DELTA: 'BitemporalDelta'; INGEST_MODE_APPEND_ONLY: 'AppendOnly'; //********** // INGEST MODE MIX-INS //********** FILTER_DUPLICATES: 'filterDuplicates'; AUDITING: 'auditing'; AUDITING_DATE_TIME_NAME: 'dateTimeName'; TXN_MILESTONING: 'transactionMilestoning'; TXN_MILESTONING_BATCH_ID: 'BatchId'; TXN_MILESTONING_BOTH: 'BatchIdAndDateTime'; BATCH_ID_IN_NAME: 'batchIdInName'; BATCH_ID_OUT_NAME: 'batchIdOutName'; DATE_TIME_IN_NAME: 'dateTimeInName'; DATE_TIME_OUT_NAME: 'dateTimeOutName'; TRANSACTION_DERIVATION_SOURCE_IN: 'SourceSpecifiesInDateTime'; TRANSACTION_DERIVATION_SOURCE_IN_OUT: 'SourceSpecifiesInAndOutDateTime'; SOURCE_DATE_TIME_IN_FIELD: 'sourceDateTimeInField'; SOURCE_DATE_TIME_OUT_FIELD: 'sourceDateTimeOutField'; VALIDITY_MILESTONING: 'validityMilestoning'; DATE_TIME_FROM_NAME: 'dateTimeFromName'; DATE_TIME_THRU_NAME: 'dateTimeThruName'; VALIDITY_DERIVATION_SOURCE_FROM: 'SourceSpecifiesFromDateTime'; VALIDITY_DERIVATION_SOURCE_FROM_THRU: 'SourceSpecifiesFromAndThruDateTime'; SOURCE_DATE_TIME_FROM_FIELD: 'sourceDateTimeFromField'; SOURCE_DATE_TIME_THRU_FIELD: 'sourceDateTimeThruField'; MERGE_STRATEGY: 'mergeStrategy'; MERGE_STRATEGY_NO_DELETES: 'NoDeletes'; MERGE_STRATEGY_DELETE_INDICATOR: 'DeleteIndicator'; MERGE_STRATEGY_DELETE_INDICATOR_FIELD: 'deleteField'; MERGE_STRATEGY_DELETE_INDICATOR_VALUES: 'deleteValues';
OpenWebpage.scpt
hascong/ExerciseForAppleScript
0
4654
<filename>OpenWebpage.scpt -- Open web page given as input argument -- Example of usage: osascript OpenWebpage.scpt "http://www.google.com" on run arg tell application "Safari" if not (exists document 1) then reopen set URL of document 1 to item 1 of arg delay 5 close window 1 end tell end run
Projects/Shark/I386/CmpI386.asm
Sankds03/Shark
740
241873
; ; ; Copyright (c) 2015 - 2021 by blindtiger. All rights reserved. ; ; The contents of this file are subject to the Mozilla Public 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.mozilla.org/MPL/ ; ; Software distributed under the License is distributed on an "AS IS" basis, ; WITHOUT WARRANTY OF ANY KIND, either express or implied. SEe the License ; for the specific language governing rights and limitations under the ; License. ; ; The Initial Developer of the Original Code is blindtiger. ; ; .686 .xlist include callconv.inc .list _TEXT$00 SEGMENT PAGE 'CODE' ; b ; NTAPI ; _cmpbyte( ; __in s8 b1, ; __in s8 b2 ; ); cPublicProc __cmpbyte, 2 mov cl, [esp + 4] mov dl, [esp + 8] cmp cl, dl setnz al stdRET __cmpbyte stdENDP __cmpbyte ; b ; NTAPI ; _cmpword( ; __in s16 s1, ; __in s16 s2 ; ); cPublicProc __cmpword, 2 mov cx, [esp + 4] mov dx, [esp + 8] cmp cx, dx setnz al stdRET __cmpword stdENDP __cmpword ; b ; NTAPI ; _cmpdword( ; __in s32 l1, ; __in s32 l2 ; ); cPublicProc __cmpdword, 2 mov ecx, [esp + 4] mov edx, [esp + 8] cmp ecx, edx setnz al stdRET __cmpdword stdENDP __cmpdword ; b ; NTAPI ; _cmpqword( ; __in s64 ll1, ; __in s64 ll2 ; ); cPublicProc __cmpqword, 4 mov ecx, [esp + 4] mov edx, [esp + 0ch] cmp ecx, edx jnz @f mov ecx, [esp + 8h] mov edx, [esp + 10h] cmp ecx, edx @@ : setnz al stdRET __cmpqword stdENDP __cmpqword _TEXT$00 ends end
libsrc/_DEVELOPMENT/alloc/malloc/c/sccz80/heap_free_unlocked_callee.asm
jpoikela/z88dk
640
86923
; void heap_free_unlocked_callee(void *heap, void *p) SECTION code_clib SECTION code_alloc_malloc PUBLIC heap_free_unlocked_callee EXTERN asm_heap_free_unlocked heap_free_unlocked_callee: pop af pop hl pop de push af jp asm_heap_free_unlocked
Definition/Typed/Consequences/Injectivity.agda
loic-p/logrel-mltt
0
16855
<gh_stars>0 {-# OPTIONS --without-K --safe #-} module Definition.Typed.Consequences.Injectivity where open import Definition.Untyped hiding (wk) import Definition.Untyped as U open import Definition.Untyped.Properties open import Definition.Typed open import Definition.Typed.Weakening open import Definition.Typed.Properties open import Definition.Typed.EqRelInstance open import Definition.LogicalRelation open import Definition.LogicalRelation.Irrelevance open import Definition.LogicalRelation.ShapeView open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Fundamental.Reducibility open import Tools.Embedding open import Tools.Product import Tools.PropositionalEquality as PE -- Helper function of injectivity for specific reducible Π-types injectivity′ : ∀ {F G H E Γ l} ([ΠFG] : Γ ⊩⟨ l ⟩Π Π F ▹ G) → Γ ⊩⟨ l ⟩ Π F ▹ G ≡ Π H ▹ E / Π-intr [ΠFG] → Γ ⊢ F ≡ H × Γ ∙ F ⊢ G ≡ E injectivity′ (noemb (Πᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext)) (Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = let F≡F₁ , G≡G₁ = Π-PE-injectivity (whnfRed* (red D) Πₙ) H≡F′ , E≡G′ = Π-PE-injectivity (whnfRed* D′ Πₙ) ⊢Γ = wf ⊢F [F]₁ = [F] id ⊢Γ [F]′ = irrelevance′ (PE.trans (wk-id _) (PE.sym F≡F₁)) [F]₁ [x∷F] = neuTerm ([F] (step id) (⊢Γ ∙ ⊢F)) (var 0) (var (⊢Γ ∙ ⊢F) here) (refl (var (⊢Γ ∙ ⊢F) here)) [G]₁ = [G] (step id) (⊢Γ ∙ ⊢F) [x∷F] [G]′ = PE.subst₂ (λ x y → _ ∙ y ⊩⟨ _ ⟩ x) (PE.trans (wkSingleSubstId _) (PE.sym G≡G₁)) (PE.sym F≡F₁) [G]₁ [F≡H]₁ = [F≡F′] id ⊢Γ [F≡H]′ = irrelevanceEq″ (PE.trans (wk-id _) (PE.sym F≡F₁)) (PE.trans (wk-id _) (PE.sym H≡F′)) [F]₁ [F]′ [F≡H]₁ [G≡E]₁ = [G≡G′] (step id) (⊢Γ ∙ ⊢F) [x∷F] [G≡E]′ = irrelevanceEqLift″ (PE.trans (wkSingleSubstId _) (PE.sym G≡G₁)) (PE.trans (wkSingleSubstId _) (PE.sym E≡G′)) (PE.sym F≡F₁) [G]₁ [G]′ [G≡E]₁ in escapeEq [F]′ [F≡H]′ , escapeEq [G]′ [G≡E]′ injectivity′ (emb 0<1 x) (ιx [ΠFG≡ΠHE]) = injectivity′ x [ΠFG≡ΠHE] -- Injectivity of Π injectivity : ∀ {Γ F G H E} → Γ ⊢ Π F ▹ G ≡ Π H ▹ E → Γ ⊢ F ≡ H × Γ ∙ F ⊢ G ≡ E injectivity ⊢ΠFG≡ΠHE = let [ΠFG] , _ , [ΠFG≡ΠHE] = reducibleEq ⊢ΠFG≡ΠHE in injectivity′ (Π-elim [ΠFG]) (irrelevanceEq [ΠFG] (Π-intr (Π-elim [ΠFG])) [ΠFG≡ΠHE])
src/spread/monitor.asm
olifink/qspread
0
244313
* Spreadsheet 28/12-91 * - monitor cell operations section prog include win1_keys_wman include win1_keys_wstatus include win1_keys_wwork include win1_keys_err include win1_keys_jcb include win1_keys_qdos_sms include win1_keys_qdos_io include win1_mac_oli include win1_spread_keys xdef mon_strt xdef mon_stop xref.l mli.goto mon_strt subr a0-a2/d0-d4 clr.l da_moncl(a6) move.l da_wmvec(a6),a2 moveq #mli.goto,d1 ; set window to goto item moveq #wsi.slct,d2 jsr wm.swlit(a2) tst.l d0 bne.s strt_exit moveq #$20,d2 ; code space move.l #$200,d3 ; data space moveq #0,d4 ; do not start at all lea mon_job,a1 lea mon_name,a2 xjsr ut_crjob tst.l d0 bne.s strt_exit move.l d1,da_monid(a6) move.l jcb_a6(a0),a1 ; get data space area add.l jcb_a4(a0),a1 move.l a6,(a1) ; hello, I am here moveq #sms.spjb,d0 moveq #2,d2 ; priority trap #do.sms2 strt_exit subend * * our own little monitor job mon_name qstrg {Monitor} mon_job lea 0(a4,a6.l),a6 move.l (a6),a5 ; owner jobs data area move.l da_chan(a5),a0 move.l da_wwork(a5),a4 moveq #iow.spap,d0 move.w ww_lattr+wwa_selc+wwa_back(a4),d1 moveq #forever,d3 move.l da_wmvec(a6),a2 jsr wm.trap3(a2) tst.l d0 bne.s mon_kill moveq #iow.sstr,d0 jsr wm.trap3(a2) tst.l d0 bne.s mon_kill moveq #iow.sink,d0 move.w ww_lattr+wwa_selc+wwa_ink(a4),d1 jsr wm.trap3(a2) tst.l d0 bne.s mon_kill mon_lp move.l da_chan(a5),a0 moveq #iow.clra,d0 moveq #forever,d3 trap #do.io tst.l d0 bne.s mon_kill moveq #iow.spix,d0 moveq #1,d1 moveq #0,d2 trap #do.io tst.l d0 bne.s mon_kill move.l da_moncl(a5),d1 ; convert cell number to string lea 4(a6),a1 xjsr con_cstr moveq #iob.smul,d0 move.w (a1)+,d2 moveq #forever,d3 trap #do.io tst.l d0 bne.s mon_kill moveq #sms.ssjb,d0 ; sleep for a while moveq #sms.myjb,d1 moveq #20,d3 suba.l a1,a1 trap #do.sms2 bra mon_lp mon_kill clr.l da_monid(a5) move.l d0,d3 moveq #sms.frjb,d0 moveq #sms.myjb,d1 trap #do.sms2 mon_stop subr d0-d3/a0-a3 moveq #sms.frjb,d0 move.l da_monid(a6),d1 beq.s stop_rdw moveq #0,d3 trap #do.sms2 clr.l da_monid(a6) stop_rdw move.l da_chan(a6),a0 move.l da_wwork(a6),a4 moveq #mli.goto,d1 xjsr rdw_mkav subend end
commands/apps/notes/create-note.applescript
daviddzhou/script-commands
3,305
4348
#!/usr/bin/osascript # Required parameters: # @raycast.schemaVersion 1 # @raycast.title Create Note # @raycast.mode silent # Optional parameters: # @raycast.icon ./images/notes.png # @raycast.argument1 { "type": "text", "placeholder": "Note Name" } # @raycast.argument2 { "type": "text", "placeholder": "Text" } # @raycast.packageName Notes # Documentation: # @raycast.description Create a new Note # @raycast.author <NAME> # @raycast.authorURL https://github.com/commai on run argv set content to "<body><h1 style=\"color:black;\"> " & (item 1 of argv) & "</h1> <p style=\"color:black;\" >" & (item 2 of argv) & "</p> </body>" tell application "Notes" activate make new note at folder "Notes" with properties {name: "", body:content} end tell end run
alloy4fun_models/trashltl/models/11/ZeSAzM38CHxhyaZNr.als
Kaixi26/org.alloytools.alloy
0
1710
<gh_stars>0 open main pred idZeSAzM38CHxhyaZNr_prop12 { always all f: File | f not in Trash until f in Trash } pred __repair { idZeSAzM38CHxhyaZNr_prop12 } check __repair { idZeSAzM38CHxhyaZNr_prop12 <=> prop12o }
oeis/128/A128971.asm
neoneye/loda-programs
11
179409
<filename>oeis/128/A128971.asm<gh_stars>10-100 ; A128971: A130125 * A000012. ; Submitted by <NAME> ; 1,2,2,5,4,4,10,10,8,8,21,20,20,16,16,42,42,40,40,32,32,85,84,84,80,80,64,64,170,170,168,168,160,160,128 seq $0,130328 ; Triangle of differences between powers of 2, read by rows. seq $0,265263 ; Change every other 1 bit in binary expansion of n to 0.