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 |
|---|---|---|---|---|
compiler/ProjectQ.g4 | czhao39/xacc-projectq | 1 | 7609 | <reponame>czhao39/xacc-projectq<gh_stars>1-10
/***********************************************************************************
* Copyright (c) 2018, UT-Battelle
* 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 xacc 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 <COPYRIGHT HOLDER> 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.
*
* Originally developed by:
* H. <NAME>, Oak Ridge National Laboratory, July 2018
*
**********************************************************************************/
grammar ProjectQ;
/* This part of the grammar is particular to XACC */
/**********************************************************************************/
xaccsrc : (NEWLINE* xacckernel NEWLINE*)* ;
xacckernel : '__qpu__' kernelname=IDENTIFIER '(' 'AcceleratorBuffer' acceleratorbuffer=IDENTIFIER (',' typedparam)* ')' '{' projectqprog '}' ;
kernelcall : kernelname=IDENTIFIER '(' IDENTIFIER? (',' IDENTIFIER)* ')' ;
typedparam : TYPE IDENTIFIER ;
TYPE : INTTYPE | DOUBLETYPE | FLOATTYPE ;
fragment INTTYPE : 'int' ;
fragment DOUBLETYPE : 'double';
fragment FLOATTYPE : 'float' ;
/**********************************************************************************/
/********************
* Parser *
*******************/
projectqprog : instr? (NEWLINE+ instr)* NEWLINE* ;
instr : gate
| allocate
| measure
| kernelcall
;
gate : gatename paramlist? '|' qbitarglist ;
gatename : IDENTIFIER ;
allocate : ALLOCATE '|' qbit ;
measure : MEASURE '|' qbit ;
paramlist : '(' param (',' param)* ')' ;
param : expr ;
qbitarglist : qbit
| '(' qbit (',' qbit)* ')'
;
qbit : qreg '[' INT ('-' INT)? ']' ;
qreg : QREG ;
expr : '(' expr ')'
| '-' expr
| expr POWER expr
| expr (TIMES | DIVIDE) expr
| expr (PLUS | MINUS) expr
| real
| IDENTIFIER
;
real : INT
| FLOAT
;
/********************
* Lexer *
*******************/
QREG : 'Qureg' ;
ALLOCATE : 'Allocate' ;
MEASURE : 'Measure' ;
IDENTIFIER : [A-Za-z_] [A-Za-z0-9_]* ;
INT : DIGIT+ ;
FLOAT : INT EXPONENT
| DIGIT* '.' DIGIT+ EXPONENT?
;
PLUS : '+' ;
MINUS : '-' ;
TIMES : '*' ;
DIVIDE : '/' ;
POWER : '^' ;
NEWLINE : ('\r'? '\n') ;
SPACE : ' ' -> skip ;
TAB : '\t' -> skip ;
fragment SIGN : '+' | '-' ;
fragment DIGIT : [0-9]+ ;
fragment EXPONENT : ('e' | 'E') SIGN? [0-9]+ ;
|
rot13.asm | Ciremun/practice | 1 | 24501 | global main
extern malloc, puts, exit
rot13:
push r13
push r12
push rbp
push rbx
sub rsp, 8
cmp BYTE [rdi], 0
je .malloc_str
mov rbx, rdi
mov eax, 1
.strlen:
mov edi, eax
lea ebp, [rax-1]
mov r13d, eax
mov r12, rax
add rax, 1
cmp BYTE [rbx-1+rax], 0
jne .strlen
add edi, 1
movsx rdi, edi
call malloc WRT ..plt
mov r8, rax
test r13d, r13d
jle .rot13_return
mov rsi, rax
mov rdx, rbx
jmp .if_lower
.set_sub_char:
mov BYTE [rsi], dil
.for_loop:
add rdx, 1
add rsi, 1
mov eax, edx
sub eax, ebx
sub eax, 1
cmp eax, ebp
jge .rot13_return
.if_lower:
movzx eax, BYTE [rdx]
movsx ecx, al
lea edi, [rcx-97]
cmp edi, 25
ja .if_upper
lea edi, [rax-13]
movsx ecx, dil
sub ecx, 97
cmp ecx, 25
jbe .set_sub_char
add eax, 13
mov BYTE [rsi], al
jmp .for_loop
.if_upper:
sub ecx, 65
cmp ecx, 25
ja .set_add_char_and_loop
lea edi, [rax-13]
movsx ecx, dil
sub ecx, 65
cmp ecx, 25
jbe .set_sub_char_and_loop
add eax, 13
mov BYTE [rsi], al
jmp .for_loop
.set_sub_char_and_loop:
mov BYTE [rsi], dil
jmp .for_loop
.set_add_char_and_loop:
mov BYTE [rsi], al
jmp .for_loop
.malloc_str:
mov edi, 1
call malloc WRT ..plt
mov r8, rax
mov r12d, 0
.rot13_return:
mov BYTE [r8+r12], 0
mov rax, r8
add rsp, 8
pop rbx
pop rbp
pop r12
pop r13
ret
main:
sub rsp, 8 ; align stack
cmp edi, 1 ; rdi/edi = 1st arg, rsi = 2nd arg
jle .exit
mov rdi, QWORD [rsi+8] ; rdi <- argv[1], qword = uint64
call rot13
mov rdi, rax
call puts WRT ..plt
mov eax, 0
add rsp, 8 ; restore stack
ret
.exit:
mov edi, 1 ; set exit code
call exit WRT ..plt
|
oeis/165/A165829.asm | neoneye/loda-programs | 11 | 241786 | <reponame>neoneye/loda-programs
; A165829: Totally multiplicative sequence with a(p) = 8.
; Submitted by <NAME>
; 1,8,8,64,8,64,8,512,64,64,8,512,8,64,64,4096,8,512,8,512,64,64,8,4096,64,64,512,512,8,512,8,32768,64,64,64,4096,8,64,64,4096,8,512,8,512,512,64,8,32768,64,512,64,512,8,4096,64,4096,64,64,8,4096,8,64,512,262144,64,512,8,512,64,512,8,32768,8,64,512,512,64,512,8,32768,4096,64,8,4096,64,64,64,4096,8,4096,64,512,64,64,64,262144,8,512,512,4096
seq $0,1222 ; Number of prime divisors of n counted with multiplicity (also called bigomega(n) or Omega(n)).
mov $2,8
pow $2,$0
mov $0,$2
|
zfp-gba/gnat_user/s-allare.adb | 98devin/ada-gba-dev | 7 | 19591 | <filename>zfp-gba/gnat_user/s-allare.adb<gh_stars>1-10
-- Copyright (c) 2021 <NAME>
-- zlib License -- see LICENSE for details.
with System.Parameters;
package body System.Allocation.Arenas is
use SSE;
use all type System.Parameters.Size_Type;
procedure Allocate
(Pool : in out Heap_Arena;
Storage_Address : out System.Address;
Storage_Size : Storage_Count;
Alignment : Storage_Count) is
Align_Mask : constant Address := Address (Alignment - 1);
Aligned_Address : constant Address :=
(Pool.Top_Address + Align_Mask) and not Align_Mask;
begin
Storage_Address := Aligned_Address;
Pool.Top_Address := Aligned_Address + Storage_Size;
if Pool.Top_Address > Pool.End_Address then
raise Storage_Error;
end if;
end Allocate;
function Storage_Size (Pool : Heap_Arena) return Storage_Count is
(Storage_Count'(Pool.End_Address - Pool.Start_Address));
function Mark (Pool : Heap_Arena) return Marker is
(Marker (Pool.Top_Address));
procedure Release (Pool : in out Heap_Arena; Mark : Marker) is
begin
Pool.Top_Address := Address (Mark);
end Release;
procedure Allocate
(Pool : in out Local_Arena;
Storage_Address : out System.Address;
Storage_Size : Storage_Count;
Alignment : Storage_Count) is
begin
Allocate (Pool.Heap, Storage_Address, Storage_Size, Alignment);
end Allocate;
function Storage_Size (Pool : Local_Arena) return Storage_Count is
(Storage_Size (Pool.Heap));
function Mark (Pool : Local_Arena) return Marker is
(Mark (Pool.Heap));
procedure Release (Pool : in out Local_Arena; Mark : Marker) is
begin
Release (Pool.Heap, Mark);
end Release;
function Create_Arena (Start_Address, End_Address : Address)
return Heap_Arena
is
pragma Assert (End_Address >= Start_Address);
begin
return Heap_Arena'
(Top_Address | Start_Address => Start_Address,
End_Address => End_Address);
end Create_Arena;
function Create_Arena (Local_Size : Storage_Count) return Local_Arena is
begin
return A : Local_Arena (Local_Size) do
Init_Arena (A);
end return;
end Create_Arena;
procedure Init_Arena (Pool : in out Local_Arena) is
begin
Pool.Heap.Top_Address := Pool.Storage'Address;
Pool.Heap.Start_Address := Pool.Storage'Address;
Pool.Heap.End_Address := Pool.Storage'Address + Pool.Size;
end Init_Arena;
end System.Allocation.Arenas; |
programs/oeis/132/A132369.asm | neoneye/loda | 22 | 165001 | ; A132369: PrimePi(n)!.
; 1,1,2,2,6,6,24,24,24,24,120,120,720,720,720,720,5040,5040,40320,40320,40320,40320,362880,362880,362880,362880,362880,362880,3628800,3628800,39916800,39916800,39916800,39916800,39916800,39916800,479001600
add $0,1
seq $0,230980 ; Number of primes <= n, starting at n=0.
seq $0,142 ; Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n, number of permutations of n letters).
|
unittests/ASM/TwoByte/0F_0E.asm | cobalt2727/FEX | 628 | 26279 | %ifdef CONFIG
{
"RegData": {
},
"MemoryRegions": {
"0x100000000": "4096"
}
}
%endif
femms ; Just ensure it runs
hlt
|
test/src/yaml-dumping_tests-suite.adb | robdaemon/AdaYaml | 32 | 21734 | <filename>test/src/yaml-dumping_tests-suite.adb
-- part of AdaYaml, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "copying.txt"
with Yaml.Dom.Dumping.Test;
package body Yaml.Dumping_Tests.Suite is
Result : aliased AUnit.Test_Suites.Test_Suite;
Dom_Dumping_TC : aliased Dom.Dumping.Test.TC;
function Suite return AUnit.Test_Suites.Access_Test_Suite is
begin
AUnit.Test_Suites.Add_Test (Result'Access, Dom_Dumping_TC'Access);
return Result'Access;
end Suite;
end Yaml.Dumping_Tests.Suite;
|
libsrc/cpc/cpc_GetScrAddress_callee.asm | jpoikela/z88dk | 640 | 160772 | ;
; Amstrad CPC library
; ******************************************************
; ** Librería de rutinas para Amstrad CPC **
; ** <NAME>, Artaburu 2009 **
; ******************************************************
;
; cpc_GetScrAddress(int x, int y) __smallc ;
;
; $Id: cpc_GetScrAddress_callee.asm $
;
SECTION code_clib
PUBLIC cpc_GetScrAddress_callee
EXTERN cpc_GetScrAddress0
.cpc_GetScrAddress_callee
; coordinates are in (A,L)
pop hl
pop bc ; y
ex (sp),hl ; x
ld a,l
ld l,c
jp cpc_GetScrAddress0
|
src/main/java/org/q2p0/jw4a/parser/jw4a.g4 | q2p0/jw4a | 5 | 2709 | grammar jw4a;
//@header {
// TODO: 4 Future usage
//}
definitions: description+;
description: entity BRACKET_OPEN method* BRACKET_CLOSE;
method: ( entity | PRIMITIVE_TYPE | VOID ) ID PARENTHESIS_OPEN parameter* PARENTHESIS_CLOSE;
parameter: ( entity | PRIMITIVE_TYPE ) ID;
entity: package_expr ID;
package_expr : (ID DOT)+;
PRIMITIVE_TYPE : 'byte' | 'short' | 'int' | 'long' | 'float' | 'double' | 'char' | 'boolean';
VOID: 'void';
DOT: '.';
BRACKET_OPEN: '{';
BRACKET_CLOSE: '}';
SEMICOLON: ';';
PARENTHESIS_OPEN: '(';
PARENTHESIS_CLOSE: ')';
ID: [a-zA-Z_][a-zA-Z0-9_]*;
WS: [ \t\n\r]+ -> skip;
|
test/Succeed/Squash.agda | cruhland/agda | 1,989 | 6570 | module Squash where
data _==_ {A : Set}(a : A) : A -> Set where
refl : a == a
data Wrap (A : Set) : Set where
wrap : A -> Wrap A
data Squash (A : Set) : Set where
squash : .A -> Squash A
postulate
A : Set
a1 a2 : A
irr : squash a1 == squash a2
irr = refl
|
source_cpc/Source/EG_Sprites_Laser.asm | kieranhj/edge-beeb | 0 | 14592 | <reponame>kieranhj/edge-beeb
.LaserFrame0
; defb 0,0,0,0,0,0,0,0,0,0,0,0
; ld e,(ix+0)
; inc ixl
; ld d,(ix+0)
; inc ixl
; defb 0,0,0,0,64,0,44,0,44,0,8,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),64
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),8
; res 3,h
; ld (hl),0
; defb 0,64,0,148,64,148,44,73,44,73,8,134
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
; ld (hl),0
res 3,h
ld (hl),64
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),64
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),73
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),73
inc hl
set 3,h
ld (hl),8
res 3,h
ld (hl),134
; defb 0,0,0,0,0,0,0,0,0,0,0,0
; ld l,(ix+0)
inc ixl
; ld h,(ix+0)
inc ixl
; defb 192,0,44,192,194,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
ld (hl),192
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),192
inc hl
set 3,h
ld (hl),194
res 3,h
ld (hl),128
; defb 192,0,44,192,194,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
ld (hl),192
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),192
inc hl
set 3,h
ld (hl),194
res 3,h
ld (hl),128
; defb 0,0,0,192,0,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),192
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),128
; defb 0,0,0,0,64,0,44,0,44,0,8,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),64
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),8
; res 3,h
; ld (hl),0
; defb 0,64,0,148,64,148,44,73,44,73,8,134
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
; ld (hl),0
res 3,h
ld (hl),64
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),64
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),73
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),73
inc hl
set 3,h
ld (hl),8
res 3,h
ld (hl),134
jp (iy)
.LaserFrame5
; defb 0,0,0,0,64,0,44,0,44,0,8,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),64
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
; defb 0,64,0,148,64,148,44,73,44,73,8,134
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
ld (hl),64
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),64
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),73
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),73
; defb 0,0,0,0,0,0,0,0,0,0,0,0
; ld l,(ix+0)
inc ixl
; ld h,(ix+0)
inc ixl
; defb 192,0,44,192,194,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
ld (hl),192
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),192
inc hl
set 3,h
ld (hl),194
res 3,h
ld (hl),128
; defb 192,0,44,192,194,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
ld (hl),192
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),192
inc hl
set 3,h
ld (hl),194
res 3,h
ld (hl),128
; defb 0,0,0,192,0,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),192
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),128
; defb 0,0,0,0,64,0,44,0,44,0,8,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),64
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
; defb 0,64,0,148,64,148,44,73,44,73,8,134
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
ld (hl),64
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),64
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),73
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),73
jp (iy)
.LaserFrame4
; defb 0,0,0,0,64,0,44,0,44,0,8,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),64
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
; defb 0,64,0,148,64,148,44,73,44,73,8,134
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
ld (hl),64
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),64
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),73
; defb 0,0,0,0,0,0,0,0,0,0,0,0
; ld l,(ix+0)
inc ixl
; ld h,(ix+0)
inc ixl
; defb 192,0,44,192,194,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
ld (hl),192
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),192
inc hl
set 3,h
ld (hl),194
res 3,h
ld (hl),128
; defb 192,0,44,192,194,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
ld (hl),192
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),192
inc hl
set 3,h
ld (hl),194
res 3,h
ld (hl),128
; defb 0,0,0,192,0,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),192
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),128
; defb 0,0,0,0,64,0,44,0,44,0,8,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),64
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
; defb 0,64,0,148,64,148,44,73,44,73,8,134
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
ld (hl),64
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),64
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),73
jp (iy)
.LaserFrame3
; defb 0,0,0,0,64,0,44,0,44,0,8,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),64
; defb 0,64,0,148,64,148,44,73,44,73,8,134
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
ld (hl),64
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),64
res 3,h
ld (hl),148
; defb 0,0,0,0,0,0,0,0,0,0,0,0
; ld l,(ix+0)
inc ixl
; ld h,(ix+0)
inc ixl
; defb 192,0,44,192,194,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
ld (hl),192
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),192
inc hl
set 3,h
ld (hl),194
res 3,h
ld (hl),128
; defb 192,0,44,192,194,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
ld (hl),192
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),192
inc hl
set 3,h
ld (hl),194
res 3,h
ld (hl),128
; defb 0,0,0,192,0,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),192
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),128
; defb 0,0,0,0,64,0,44,0,44,0,8,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),64
; defb 0,64,0,148,64,148,44,73,44,73,8,134
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
ld (hl),64
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),148
inc hl
set 3,h
ld (hl),64
res 3,h
ld (hl),148
jp (iy)
.LaserFrame2
; defb 0,0,0,0,64,0,44,0,44,0,8,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
; defb 0,64,0,148,64,148,44,73,44,73,8,134
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
ld (hl),64
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),148
; defb 0,0,0,0,0,0,0,0,0,0,0,0
; ld l,(ix+0)
inc ixl
; ld h,(ix+0)
inc ixl
; defb 192,0,44,192,194,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
ld (hl),192
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),192
; defb 192,0,44,192,194,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
ld (hl),192
res 3,h
; ld (hl),0
inc hl
set 3,h
ld (hl),44
res 3,h
ld (hl),192
; defb 0,0,0,192,0,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
; ld (hl),0
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),192
; defb 0,0,0,0,64,0,44,0,44,0,8,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
; defb 0,64,0,148,64,148,44,73,44,73,8,134
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
ld (hl),64
inc hl
set 3,h
; ld (hl),0
res 3,h
ld (hl),148
jp (iy)
.LaserFrame1
; defb 0,0,0,0,64,0,44,0,44,0,8,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
; defb 0,64,0,148,64,148,44,73,44,73,8,134
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
ld (hl),64
; defb 0,0,0,0,0,0,0,0,0,0,0,0
; ld l,(ix+0)
inc ixl
; ld h,(ix+0)
inc ixl
; defb 192,0,44,192,194,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
ld (hl),192
; defb 192,0,44,192,194,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
ld (hl),192
; defb 0,0,0,192,0,128,0,0,0,0,0,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
; defb 0,0,0,0,64,0,44,0,44,0,8,0
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
; defb 0,64,0,148,64,148,44,73,44,73,8,134
ld l,(ix+0)
inc ixl
ld h,(ix+0)
inc ixl
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
res 3,h
inc hl
set 3,h
;
; ld (hl),0
res 3,h
ld (hl),64
jp (iy)
|
rts/gcc-9/adainclude/a-cgcaso.ads | letsbyteit/build-avr-ada-toolchain | 7 | 30350 | <filename>rts/gcc-9/adainclude/a-cgcaso.ads
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.GENERIC_CONSTRAINED_ARRAY_SORT --
-- --
-- S p e c --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. In accordance with the copyright of that document, you can freely --
-- copy and modify this specification, provided that if you redistribute a --
-- modified version, any changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
generic
type Index_Type is (<>);
type Element_Type is private;
type Array_Type is array (Index_Type) of Element_Type;
with function "<" (Left, Right : Element_Type)
return Boolean is <>;
procedure Ada.Containers.Generic_Constrained_Array_Sort
(Container : in out Array_Type);
pragma Pure (Ada.Containers.Generic_Constrained_Array_Sort);
|
testsuite/tests/virtual_file_system/src/tc_nested_mount.adb | morbos/Ada_Drivers_Library | 2 | 16186 | <filename>testsuite/tests/virtual_file_system/src/tc_nested_mount.adb
with Ada.Text_IO; use Ada.Text_IO;
with Native.Filesystem; use Native.Filesystem;
with Virtual_File_System; use Virtual_File_System;
with Helpers; use Helpers;
procedure TC_Nested_Mount is
Strict_Mode : constant Boolean := False;
-- Debug switch to enable strict mode. Currently, non-strict mode avoids
-- calls that are more or less expected to fail.
Root_VFS : Virtual_File_System.VFS;
Child_VFS : Virtual_File_System.Any_VFS := new Virtual_File_System.VFS;
Empty_FS : Native_FS_Driver_Ref :=
Create ("empty", Create_If_Missing => True);
Subdirs_FS : Native_FS_Driver_Ref := Create ("subdirs");
begin
Test (Root_VFS.Mount ("empty", Empty_FS.all'Access));
Test (Root_VFS.Mount ("child_vfs", Child_VFS.all'Access));
Test (Child_VFS.Mount ("subdirs", Subdirs_FS.all'Access));
Dump (Root_VFS, "/");
-- Unmounting is not implemented yet
if Strict_Mode then
Test (Root_VFS.Umount ("empty"));
Test (Root_VFS.Umount ("child_vfs"));
Test (Child_VFS.Umount ("subdirs"));
end if;
Destroy (Child_VFS);
Destroy (Empty_FS);
Destroy (Subdirs_FS);
Put_Line ("Done.");
end TC_Nested_Mount;
|
LAB1/LAB1_2_2.asm | m4hi2/microprocessor-lab-codes | 0 | 7856 | ;LAB_1
;PROBLEM 2: WRITE A 8086 ASSEMBLY PROGRAM TO CHANGE THE CASE OF
;A UPPER CASE LETTER TO LOWER CASE
.MODEL SMALL
.STACK 100H
.DATA
MSG1 DB 'ENTER A UPPER CASE LETTER: $'
MSG2 DB 0DH, 0AH, 'IN LOWER CASE THE LETTER IS: '
CHAR DB ?, '$'
.CODE
MAIN PROC
;INITIALIZE DATA SEGMENT
MOV AX, @DATA ;GET DATA SEGMENT
MOV DS, AX ;PUT THE DATA SEGMENT VALUE INTO DS REGISTER
;PRINT THE STRING
LEA DX, MSG1 ;LOADING THE ADDRESS OF MSG1 INTO DX
MOV AH, 09
INT 21H
;TAKING THE INPUT
MOV AH, 01
INT 21H
ADD AL, 20H ;CONVERTING INTO LOWER CASE
MOV CHAR, AL ;SAVING THE VALUE CONVERTED INTO LOWER CASE INTO VARIABLE CHAR
;DISPLAY ON THE NEXT LINE
LEA DX, MSG2
MOV AH, 09
INT 21H
;EXIT
MOV AH, 4CH ;EXIT PROGRAM FUNCTION
INT 21H
MAIN ENDP
END MAIN |
source/strings/a-suwsfu.ads | ytomino/drake | 33 | 14650 | <filename>source/strings/a-suwsfu.ads
pragma License (Unrestricted);
-- extended unit
with Ada.Strings.Generic_Unbounded.Generic_Functions;
with Ada.Strings.Wide_Functions;
package Ada.Strings.Unbounded_Wide_Strings.Functions is
new Generic_Functions (Wide_Functions);
pragma Preelaborate (Ada.Strings.Unbounded_Wide_Strings.Functions);
|
chapter7/improve/lib/kernel/print.asm | liulinboyi/os | 6 | 24381 | <reponame>liulinboyi/os
; 内核打印功能实现
TI_GDT equ 0
RPL0 equ 0
SELECTOR_VIDEO equ (0x0003 << 3) + TI_GDT + RPL0
section .data
put_int_buffer dd 0, 0
[bits 32]
section .text
; put_char,将栈中的一个字符写入光标所在处
global put_char
global put_str
global put_int
put_int:
pushad
mov ebp, esp
mov eax, [ebp + 4 * 9]
mov edx, eax
mov edi, 7
mov ecx, 8
mov ebx, put_int_buffer
.16based_4bits:
and edx, 0x0000000F
cmp edx, 9
jg .is_A2F
add edx, '0'
jmp .store
.is_A2F:
sub edx, 10
add edx, 'A'
.store:
mov [ebx + edi], dl
dec edi
shr eax, 4
mov edx, eax
loop .16based_4bits
.ready_print:
inc edi
.skip_prefix_0:
cmp edi, 8
je .full0
.go_on_skip:
mov cl, [put_int_buffer + edi]
inc edi
cmp cl, '0'
je .skip_prefix_0
dec edi
jmp .put_each_num
.full0:
mov cl, '0'
.put_each_num:
push ecx
call put_char
add esp, 4
inc edi
mov cl, [put_int_buffer + edi]
cmp edi, 8
jl .put_each_num
popad
ret
; 字符串打印函数,基于put_char封装
put_str:
push ebx
push ecx
xor ecx, ecx
mov ebx, [esp + 12]
.go_on:
mov cl, [ebx]
cmp cl, 0
jz .str_over
push ecx
call put_char
add esp, 4
inc ebx
jmp .go_on
.str_over:
pop ecx
pop ebx
ret
put_char:
pushad
mov ax, SELECTOR_VIDEO
mov gs, ax
; 获取当前光标位置
mov dx, 0x03d4
mov al, 0x0e
out dx, al
mov dx, 0x03d5
in al, dx
mov ah, al
mov dx, 0x03d4
mov al, 0x0f
out dx, al
mov dx, 0x03d5
in al, dx
mov bx, ax
mov ecx, [esp + 36]
cmp cl, 0xd
jz .is_carriage_return
cmp cl, 0xa
jz .is_line_feed
cmp cl, 0x8
jz .is_backspace
jmp .put_other
.is_backspace:
dec bx
shl bx, 1
mov byte [gs:bx], 0x20
inc bx
mov byte [gs:bx], 0x07
shr bx, 1
jmp .set_cursor
.put_other:
shl bx, 1
mov [gs:bx], cl
inc bx
mov byte [gs:bx], 0x07
shr bx, 1
inc bx
cmp bx, 2000
jl .set_cursor
.is_line_feed:
.is_carriage_return:
xor dx, dx
mov ax, bx
mov si, 80
div si
sub bx, dx
.is_carriage_return_end:
add bx, 80
cmp bx, 2000
.is_line_feed_end:
jl .set_cursor
.roll_screeen:
cld
mov ecx, 960
mov esi, 0xc00b80a0
mov edi, 0xc00b8000
rep movsd
mov ebx, 3840
mov ecx, 80
.cls:
mov word [gs:ebx], 0x0720
add ebx, 2
loop .cls
mov bx, 1920
.set_cursor:
mov dx, 0x03d4
mov al, 0x0e
out dx, al
mov dx, 0x03d5
mov al, bh
out dx, al
mov dx, 0x03d4
mov al, 0x0f
out dx, al
mov dx, 0x03d5
mov al, bl
out dx, al
.put_char_done:
popad
ret |
io.asm | maikmerten/tinyload | 5 | 164552 | <filename>io.asm
IOBASE = $FFD1 ; register to read/write data from ACIA
IOSTATUS = $FFD0 ; location of status register
IOCMD = $FFD0 ; location of command register
IOCMD_INIT = $15; ; init value for ACIA
IOSTATUS_RXFULL = $01;
IOSTATUS_TXEMPTY = $02;
SDDATA = $FFD8
SDSTATUS = $FFD9
SDCONTROL = $FFD9
SDLBA0 = $FFDA
SDLBA1 = $FFDB
SDLBA2 = $FFDC
;;
;; initialize input/output
;;
.proc io_init
;; initialize ACIA
lda #IOCMD_INIT
sta IOCMD
rts
.endproc
;;
;; Transmit single character to ACIA output device
;; a-register contains argument
;;
.proc io_write_char
pha
readstatus:
lda IOSTATUS ; load status register
and #IOSTATUS_TXEMPTY ; Is the tx register empty?
beq readstatus ; busy waiting till ready
pla ; get character
sta IOBASE ; write to output
rts ; end subroutine
.endproc
;;
;; read a 512-byte block from the SD card.
;; (ARG1,ARG1+1,ARG1+2): block index on SD card
;; (ARG2) and (ARG2)+1: pages to write data into
;;
.proc io_sd_read_block
push_axy
wait:
lda SDSTATUS
cmp #128
bne wait
lda ARG1
sta SDLBA0
lda ARG1+1
sta SDLBA1
lda ARG1+2
sta SDLBA2
lda #0
sta ARG1
sta SDCONTROL ; issue read command
ldx ARG2 ; dump into page (ARG2) and following page
ldy #2 ; read two chunks of 256 bytes
read_to_page:
stx ARG1+1
inx
jsr io_sd_read_to_page
dey
bne read_to_page
pull_axy
rts
.endproc
;;
;; read 256 bytes and put it into page designated by (ARG1,ARG1+1)
;;
.proc io_sd_read_to_page
push_ay
ldy #0
loop:
lda SDSTATUS
cmp #224
bne loop
lda SDDATA
sta (ARG1),y
iny
bne loop ; we're done once we wrap around to zero again
pull_ay
rts
.endproc
|
libsrc/msx/gen_vwrite_direct.asm | Toysoft/z88dk | 0 | 173827 | <reponame>Toysoft/z88dk<filename>libsrc/msx/gen_vwrite_direct.asm
;
; z88dk library: Generic VDP support code
;
; extern void msx_vwrite_direct(void *source, u_int dest, u_int count)
;
; Transfer count bytes from RAM (current memory page) to VRAM
;
; $Id: gen_vwrite_direct.asm,v 1.3 2016-06-16 19:30:25 dom Exp $
;
SECTION code_clib
PUBLIC msx_vwrite_direct
PUBLIC _msx_vwrite_direct
IF FORm5
INCLUDE "target/m5/def/m5bios.def"
ELSE
EXTERN SETWRT
ENDIF
INCLUDE "msx/vdp.inc"
msx_vwrite_direct:
_msx_vwrite_direct:
push ix ;save callers
ld ix,4
add ix,sp
ld l, (ix+2) ; dest
ld h, (ix+3)
call SETWRT
ld l, (ix+0) ; count
ld h, (ix+1)
ld e, (ix+4) ; source
ld d, (ix+5)
IF VDP_DATA >= 0
ld bc,VDP_DATA
ENDIF
wrtloop:
ld a,(de)
IF VDP_DATA < 0
ld (-VDP_DATA),a
ELSE
out (c),a
ENDIF
inc de
dec hl
ld a,h
or l
jr nz,wrtloop
pop ix ;restore callers
ret
|
src/misc/Rejuvenation_Lib_Generator/src/generator-match_pattern_specific.adb | Fabien-Chouteau/Renaissance-Ada | 0 | 9079 | with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Text_IO; use Ada.Text_IO;
with Libadalang.Analysis; use Libadalang.Analysis;
with Libadalang.Common; use Libadalang.Common;
with Rejuvenation.Finder;
with Rejuvenation.Utils;
package body Generator.Match_Pattern_Specific is
use Rejuvenation.Node_List;
function Equivalent_Key (Left, Right : String) return Boolean is
begin
return Left = Right;
end Equivalent_Key;
function Equivalent_Value (Left, Right : List_String.Vector) return Boolean
is
use List_String;
begin
return Left = Right;
end Equivalent_Value;
Type_Decls : constant Rejuvenation.Node_List.Vector :=
Rejuvenation.Finder.Find (Unit_LAL_Ads.Root, Ada_Type_Decl);
Subp_Decls : constant Rejuvenation.Node_List.Vector :=
Rejuvenation.Finder.Find (Unit_LAL_Ads.Root, Ada_Subp_Spec);
Type_Decls2 : constant Rejuvenation.Node_List.Vector :=
Rejuvenation.Finder.Find (Unit_LALCO_Ads.Root, Ada_Type_Decl);
Kinds : List_String.Vector;
Type_To_Direct_Children, Type_To_All_Fields : Mapping_Single_Map.Map;
procedure Append
(Map : in out Mapping_Single_Map.Map; Key : String; Value : String)
is
begin
if not Map.Contains (Key) then
declare
List : List_String.Vector;
begin
Map.Include (Key, List);
end;
end if;
declare
List : List_String.Vector := Map.Element (Key);
UValue : constant Unbounded_String := To_Unbounded_String (Value);
begin
if not List.Contains (UValue) then
List.Append (UValue);
Map.Include (Key, List);
end if;
end;
end Append;
procedure Process_Node_Kinds is
begin
for Type_Decl of Type_Decls2 loop
declare
Name : constant Libadalang.Analysis.Name :=
Type_Decl.As_Type_Decl.F_Name.F_Name;
Str_Name : constant String :=
Rejuvenation.Utils.Raw_Signature (Name);
Def : constant Type_Def := Type_Decl.As_Type_Decl.F_Type_Def;
begin
if Str_Name = "Ada_Node_Kind_Type" then
for E of Def.As_Enum_Type_Def.F_Enum_Literals loop
Kinds.Append
(To_Unbounded_String
(Rejuvenation.Utils.Raw_Signature (E)));
end loop;
end if;
end;
end loop;
end Process_Node_Kinds;
procedure Process_Type_Decl is
begin
for Type_Decl of Type_Decls loop
declare
Name : constant Libadalang.Analysis.Name :=
Type_Decl.As_Type_Decl.F_Name.F_Name;
Str_Name : constant String :=
Rejuvenation.Utils.Raw_Signature (Name);
TypeDef : constant Type_Def := Type_Decl.As_Type_Decl.F_Type_Def;
begin
if TypeDef.Kind = Ada_Derived_Type_Def then
if not TypeDef.As_Derived_Type_Def.F_Record_Extension.Is_Null
then
declare
Sub_Type : constant Subtype_Indication :=
TypeDef.As_Derived_Type_Def.F_Subtype_Indication;
Sub_Type_Name : constant Libadalang.Analysis.Name :=
Sub_Type.F_Name;
Str_Sub_Type_Name : constant String :=
Rejuvenation.Utils.Raw_Signature (Sub_Type_Name);
begin
-- Put_Line(Str_Name & " -> " & Str_Sub_Type_Name);
Append (Type_To_Direct_Children,
Str_Sub_Type_Name,
Str_Name);
end;
end if;
end if;
end;
end loop;
end Process_Type_Decl;
procedure Process_Subp is
procedure Add_Recursive (Name : String; Type_Name : String);
procedure Add_Recursive (Name : String; Type_Name : String) is
begin
if Type_To_Direct_Children.Contains (Type_Name) then
for N of Type_To_Direct_Children (Type_Name) loop
-- Put_Line(" -> " & To_String(N));
Append (Type_To_All_Fields, To_String (N), Name);
Add_Recursive (Name, To_String (N));
end loop;
end if;
end Add_Recursive;
begin
for Subp_Decl of Subp_Decls loop
declare
Subp_Name : constant Defining_Name :=
Subp_Decl.As_Subp_Spec.F_Subp_Name;
Name : constant String :=
Rejuvenation.Utils.Raw_Signature (Subp_Name);
begin
if Index (Name, "F_") = 1 then
declare
First_Param : constant Param_Spec :=
Subp_Decl.As_Subp_Spec.F_Subp_Params
.F_Params.Child (1).As_Param_Spec;
First_Param_Type : constant Subtype_Indication :=
First_Param.F_Type_Expr.As_Subtype_Indication;
First_Param_Type_Name : constant Libadalang.Analysis.Name :=
First_Param_Type.F_Name.As_Attribute_Ref.F_Prefix;
Str_First_Param_Type_Name : constant String :=
Rejuvenation.Utils.Raw_Signature (First_Param_Type_Name);
begin
-- Put_Line(Name & " / " & Str_First_Param_Type_Name);
Append (Type_To_All_Fields, Str_First_Param_Type_Name, Name);
Add_Recursive (Name, Str_First_Param_Type_Name);
end;
end if;
end;
end loop;
end Process_Subp;
procedure Generate_Match_Specific is
begin
for E in Type_To_All_Fields.Iterate loop
if Kinds.Contains
(To_Unbounded_String ("Ada_" & Mapping_Single_Map.Key (E)))
then
Put_Line ("elsif Pattern.Kind = Ada_"
& Mapping_Single_Map.Key (E) & " then");
Put_Line (" declare");
Put_Line (" Pattern2 : constant " & Mapping_Single_Map.Key (E)
& " := Pattern.As_" & Mapping_Single_Map.Key (E) & ";");
Put_Line (" Instance2 : constant " & Mapping_Single_Map.Key (E)
& " := Instance.As_" & Mapping_Single_Map.Key (E) & ";");
Put_Line (" begin");
for N of Mapping_Single_Map.Element (E) loop
declare
Prefix : Unbounded_String;
Postfix : Unbounded_String;
begin
if N = Mapping_Single_Map.Element (E).First_Element then
Prefix := To_Unbounded_String (" return ");
else
Prefix := To_Unbounded_String (" ");
end if;
if N = Mapping_Single_Map.Element (E).Last_Element then
Postfix := To_Unbounded_String (";");
else
Postfix := To_Unbounded_String (" and then");
end if;
Put_Line (To_String (Prefix) & "MP.Match (Pattern2."
& To_String (N) & ", Instance2."
& To_String (N) & ")" & To_String (Postfix));
end;
end loop;
Put_Line (" end;");
end if;
end loop;
end Generate_Match_Specific;
procedure Main is
begin
Process_Node_Kinds;
Process_Type_Decl;
Process_Subp;
Generate_Match_Specific;
end Main;
end Generator.Match_Pattern_Specific;
|
Projetos/F-Assembly/src/nasm/mod.nasm | gabrielvf1/Z01---Grupo-H | 0 | 13758 | leaw $R1,%A
movw (%A),%D
leaw $R3,%A
movw %D,(%A) ;valor R0 salvo em R3.
leaw $R2,%A
movw (%A),%D ; d com valor de R1
leaw $R4,%A
movw %D,(%A) ; R1 em R4
while1:
leaw $R3, %A
movw (%A),%D
leaw $R4, %A
subw %D,(%A),%S
leaw $R3,%A
movw %S,(%A)
leaw $R5,%A
movw (%A),%D
incw %D
leaw $R5,%A
movw %D,(%A)
leaw $RESULT0,%A
je %S
nop
leaw $RESULTNEG,%A
jl %S
nop
leaw $while1,%A
jmp
nop
RESULTNEG:
leaw $R2, %A
addw %S,(%A),%D
leaw $R0,%A
movw %D,(%A)
leaw $END,%A
jmp
nop
RESULT0:
leaw $R0,%A
movw %S,(%A)
END:
nop
|
src/camera/pixy/src/misc/gcc/m0/Release/exec_m0.asm | wowHollis/SmartCart | 0 | 84149 | <filename>src/camera/pixy/src/misc/gcc/m0/Release/exec_m0.asm<gh_stars>0
1 .syntax unified
2 .cpu cortex-m0
3 .fpu softvfp
4 .eabi_attribute 20, 1
5 .eabi_attribute 21, 1
6 .eabi_attribute 23, 3
7 .eabi_attribute 24, 1
8 .eabi_attribute 25, 1
9 .eabi_attribute 26, 1
10 .eabi_attribute 30, 6
11 .eabi_attribute 34, 0
12 .eabi_attribute 18, 4
13 .thumb
14 .syntax unified
15 .file "exec_m0.c"
16 .text
17 .Ltext0:
18 .cfi_sections .debug_frame
19 .global g_running
20 .section .bss.g_running,"aw",%nobits
23 g_running:
24 0000 00 .space 1
25 .global g_run
26 .section .bss.g_run,"aw",%nobits
29 g_run:
30 0000 00 .space 1
31 .global g_program
32 .section .data.g_program,"aw",%progbits
35 g_program:
36 0000 FF .byte -1
37 .section .rodata
38 .align 2
39 .LC1:
40 0000 72756E00 .ascii "run\000"
41 .align 2
42 .LC4:
43 0004 73746F70 .ascii "stop\000"
43 00
44 0009 000000 .align 2
45 .LC7:
46 000c 72756E6E .ascii "running\000"
46 696E6700
47 .section .text.exec_init,"ax",%progbits
48 .align 2
49 .global exec_init
50 .code 16
51 .thumb_func
53 exec_init:
54 .LFB0:
55 .file 1 "../src/exec_m0.c"
1:../src/exec_m0.c **** //
2:../src/exec_m0.c **** // begin license header
3:../src/exec_m0.c **** //
4:../src/exec_m0.c **** // This file is part of Pixy CMUcam5 or "Pixy" for short
5:../src/exec_m0.c **** //
6:../src/exec_m0.c **** // All Pixy source code is provided under the terms of the
7:../src/exec_m0.c **** // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html).
8:../src/exec_m0.c **** // Those wishing to use Pixy source code, software and/or
9:../src/exec_m0.c **** // technologies under different licensing terms should contact us at
10:../src/exec_m0.c **** // <EMAIL>. Such licensing terms are available for
11:../src/exec_m0.c **** // all portions of the Pixy codebase presented here.
12:../src/exec_m0.c **** //
13:../src/exec_m0.c **** // end license header
14:../src/exec_m0.c **** //
15:../src/exec_m0.c ****
16:../src/exec_m0.c **** #include <pixyvals.h>
17:../src/exec_m0.c **** #include "chirp.h"
18:../src/exec_m0.c **** #include "exec_m0.h"
19:../src/exec_m0.c **** #include "rls_m0.h"
20:../src/exec_m0.c ****
21:../src/exec_m0.c **** uint8_t g_running = 0;
22:../src/exec_m0.c **** uint8_t g_run = 0;
23:../src/exec_m0.c **** int8_t g_program = -1;
24:../src/exec_m0.c ****
25:../src/exec_m0.c **** int exec_init(void)
26:../src/exec_m0.c **** {
56 .loc 1 26 0
57 .cfi_startproc
58 0000 80B5 push {r7, lr}
59 .cfi_def_cfa_offset 8
60 .cfi_offset 7, -8
61 .cfi_offset 14, -4
62 0002 00AF add r7, sp, #0
63 .cfi_def_cfa_register 7
27:../src/exec_m0.c **** chirpSetProc("run", (ProcPtr)exec_run);
64 .loc 1 27 0
65 0004 0A4A ldr r2, .L3
66 0006 0B4B ldr r3, .L3+4
67 0008 1100 movs r1, r2
68 000a 1800 movs r0, r3
69 000c FFF7FEFF bl chirpSetProc
28:../src/exec_m0.c **** chirpSetProc("stop", (ProcPtr)exec_stop);
70 .loc 1 28 0
71 0010 094A ldr r2, .L3+8
72 0012 0A4B ldr r3, .L3+12
73 0014 1100 movs r1, r2
74 0016 1800 movs r0, r3
75 0018 FFF7FEFF bl chirpSetProc
29:../src/exec_m0.c **** chirpSetProc("running", (ProcPtr)exec_running);
76 .loc 1 29 0
77 001c 084A ldr r2, .L3+16
78 001e 094B ldr r3, .L3+20
79 0020 1100 movs r1, r2
80 0022 1800 movs r0, r3
81 0024 FFF7FEFF bl chirpSetProc
30:../src/exec_m0.c ****
31:../src/exec_m0.c **** return 0;
82 .loc 1 31 0
83 0028 0023 movs r3, #0
32:../src/exec_m0.c **** }
84 .loc 1 32 0
85 002a 1800 movs r0, r3
86 002c BD46 mov sp, r7
87 @ sp needed
88 002e 80BD pop {r7, pc}
89 .L4:
90 .align 2
91 .L3:
92 0030 00000000 .word exec_run
93 0034 00000000 .word .LC1
94 0038 00000000 .word exec_stop
95 003c 04000000 .word .LC4
96 0040 00000000 .word exec_running
97 0044 0C000000 .word .LC7
98 .cfi_endproc
99 .LFE0:
101 .section .text.exec_running,"ax",%progbits
102 .align 2
103 .global exec_running
104 .code 16
105 .thumb_func
107 exec_running:
108 .LFB1:
33:../src/exec_m0.c ****
34:../src/exec_m0.c **** uint32_t exec_running(void)
35:../src/exec_m0.c **** {
109 .loc 1 35 0
110 .cfi_startproc
111 0000 80B5 push {r7, lr}
112 .cfi_def_cfa_offset 8
113 .cfi_offset 7, -8
114 .cfi_offset 14, -4
115 0002 00AF add r7, sp, #0
116 .cfi_def_cfa_register 7
36:../src/exec_m0.c **** return (uint32_t)g_running;
117 .loc 1 36 0
118 0004 024B ldr r3, .L7
119 0006 1B78 ldrb r3, [r3]
37:../src/exec_m0.c **** }
120 .loc 1 37 0
121 0008 1800 movs r0, r3
122 000a BD46 mov sp, r7
123 @ sp needed
124 000c 80BD pop {r7, pc}
125 .L8:
126 000e C046 .align 2
127 .L7:
128 0010 00000000 .word g_running
129 .cfi_endproc
130 .LFE1:
132 .section .text.exec_stop,"ax",%progbits
133 .align 2
134 .global exec_stop
135 .code 16
136 .thumb_func
138 exec_stop:
139 .LFB2:
38:../src/exec_m0.c ****
39:../src/exec_m0.c **** int32_t exec_stop(void)
40:../src/exec_m0.c **** {
140 .loc 1 40 0
141 .cfi_startproc
142 0000 80B5 push {r7, lr}
143 .cfi_def_cfa_offset 8
144 .cfi_offset 7, -8
145 .cfi_offset 14, -4
146 0002 00AF add r7, sp, #0
147 .cfi_def_cfa_register 7
41:../src/exec_m0.c **** g_run = 0;
148 .loc 1 41 0
149 0004 034B ldr r3, .L11
150 0006 0022 movs r2, #0
151 0008 1A70 strb r2, [r3]
42:../src/exec_m0.c **** return 0;
152 .loc 1 42 0
153 000a 0023 movs r3, #0
43:../src/exec_m0.c **** }
154 .loc 1 43 0
155 000c 1800 movs r0, r3
156 000e BD46 mov sp, r7
157 @ sp needed
158 0010 80BD pop {r7, pc}
159 .L12:
160 0012 C046 .align 2
161 .L11:
162 0014 00000000 .word g_run
163 .cfi_endproc
164 .LFE2:
166 .section .text.exec_run,"ax",%progbits
167 .align 2
168 .global exec_run
169 .code 16
170 .thumb_func
172 exec_run:
173 .LFB3:
44:../src/exec_m0.c ****
45:../src/exec_m0.c **** int32_t exec_run(uint8_t *prog)
46:../src/exec_m0.c **** {
174 .loc 1 46 0
175 .cfi_startproc
176 0000 80B5 push {r7, lr}
177 .cfi_def_cfa_offset 8
178 .cfi_offset 7, -8
179 .cfi_offset 14, -4
180 0002 82B0 sub sp, sp, #8
181 .cfi_def_cfa_offset 16
182 0004 00AF add r7, sp, #0
183 .cfi_def_cfa_register 7
184 0006 7860 str r0, [r7, #4]
47:../src/exec_m0.c **** g_program = *prog;
185 .loc 1 47 0
186 0008 7B68 ldr r3, [r7, #4]
187 000a 1B78 ldrb r3, [r3]
188 000c DAB2 uxtb r2, r3
189 000e 064B ldr r3, .L15
190 0010 1A70 strb r2, [r3]
48:../src/exec_m0.c **** g_run = 1;
191 .loc 1 48 0
192 0012 064B ldr r3, .L15+4
193 0014 0122 movs r2, #1
194 0016 1A70 strb r2, [r3]
49:../src/exec_m0.c **** g_running = 1;
195 .loc 1 49 0
196 0018 054B ldr r3, .L15+8
197 001a 0122 movs r2, #1
198 001c 1A70 strb r2, [r3]
50:../src/exec_m0.c **** return 0;
199 .loc 1 50 0
200 001e 0023 movs r3, #0
51:../src/exec_m0.c **** }
201 .loc 1 51 0
202 0020 1800 movs r0, r3
203 0022 BD46 mov sp, r7
204 0024 02B0 add sp, sp, #8
205 @ sp needed
206 0026 80BD pop {r7, pc}
207 .L16:
208 .align 2
209 .L15:
210 0028 00000000 .word g_program
211 002c 00000000 .word g_run
212 0030 00000000 .word g_running
213 .cfi_endproc
214 .LFE3:
216 .section .text.setup0,"ax",%progbits
217 .align 2
218 .global setup0
219 .code 16
220 .thumb_func
222 setup0:
223 .LFB4:
52:../src/exec_m0.c ****
53:../src/exec_m0.c **** #define LUT_MEMORY_SIZE 0x10000 // bytes
54:../src/exec_m0.c ****
55:../src/exec_m0.c **** void setup0()
56:../src/exec_m0.c **** {
224 .loc 1 56 0
225 .cfi_startproc
226 0000 80B5 push {r7, lr}
227 .cfi_def_cfa_offset 8
228 .cfi_offset 7, -8
229 .cfi_offset 14, -4
230 0002 00AF add r7, sp, #0
231 .cfi_def_cfa_register 7
57:../src/exec_m0.c **** }
232 .loc 1 57 0
233 0004 C046 nop
234 0006 BD46 mov sp, r7
235 @ sp needed
236 0008 80BD pop {r7, pc}
237 .cfi_endproc
238 .LFE4:
240 .global g_m0mem
241 000a C046 .section .data.g_m0mem,"aw",%progbits
242 .align 2
245 g_m0mem:
246 0000 00000810 .word 268959744
247 .global g_lut
248 .section .data.g_lut,"aw",%progbits
249 .align 2
252 g_lut:
253 0000 00200810 .word 268967936
254 .section .text.loop0,"ax",%progbits
255 .align 2
256 .global loop0
257 .code 16
258 .thumb_func
260 loop0:
261 .LFB5:
58:../src/exec_m0.c ****
59:../src/exec_m0.c **** uint32_t g_m0mem = SRAM1_LOC;
60:../src/exec_m0.c **** uint32_t g_lut = SRAM1_LOC + SRAM1_SIZE-LUT_MEMORY_SIZE;
61:../src/exec_m0.c ****
62:../src/exec_m0.c **** void loop0()
63:../src/exec_m0.c **** {
262 .loc 1 63 0
263 .cfi_startproc
264 0000 80B5 push {r7, lr}
265 .cfi_def_cfa_offset 8
266 .cfi_offset 7, -8
267 .cfi_offset 14, -4
268 0002 00AF add r7, sp, #0
269 .cfi_def_cfa_register 7
64:../src/exec_m0.c **** getRLSFrame(&g_m0mem, &g_lut);
270 .loc 1 64 0
271 0004 044A ldr r2, .L19
272 0006 054B ldr r3, .L19+4
273 0008 1100 movs r1, r2
274 000a 1800 movs r0, r3
275 000c FFF7FEFF bl getRLSFrame
65:../src/exec_m0.c **** }
276 .loc 1 65 0
277 0010 C046 nop
278 0012 BD46 mov sp, r7
279 @ sp needed
280 0014 80BD pop {r7, pc}
281 .L20:
282 0016 C046 .align 2
283 .L19:
284 0018 00000000 .word g_lut
285 001c 00000000 .word g_m0mem
286 .cfi_endproc
287 .LFE5:
289 .section .text.exec_loop,"ax",%progbits
290 .align 2
291 .global exec_loop
292 .code 16
293 .thumb_func
295 exec_loop:
296 .LFB6:
66:../src/exec_m0.c ****
67:../src/exec_m0.c ****
68:../src/exec_m0.c **** void exec_loop(void)
69:../src/exec_m0.c **** {
297 .loc 1 69 0
298 .cfi_startproc
299 0000 80B5 push {r7, lr}
300 .cfi_def_cfa_offset 8
301 .cfi_offset 7, -8
302 .cfi_offset 14, -4
303 0002 00AF add r7, sp, #0
304 .cfi_def_cfa_register 7
305 .L26:
70:../src/exec_m0.c **** while(1)
71:../src/exec_m0.c **** {
72:../src/exec_m0.c **** while(!g_run)
306 .loc 1 72 0
307 0004 01E0 b .L22
308 .L23:
73:../src/exec_m0.c **** chirpService();
309 .loc 1 73 0
310 0006 FFF7FEFF bl chirpService
311 .L22:
72:../src/exec_m0.c **** chirpService();
312 .loc 1 72 0
313 000a 094B ldr r3, .L27
314 000c 1B78 ldrb r3, [r3]
315 000e 002B cmp r3, #0
316 0010 F9D0 beq .L23
74:../src/exec_m0.c ****
75:../src/exec_m0.c **** setup0();
317 .loc 1 75 0
318 0012 FFF7FEFF bl setup0
76:../src/exec_m0.c **** while(g_run)
319 .loc 1 76 0
320 0016 03E0 b .L24
321 .L25:
77:../src/exec_m0.c **** {
78:../src/exec_m0.c **** loop0();
322 .loc 1 78 0
323 0018 FFF7FEFF bl loop0
79:../src/exec_m0.c **** chirpService();
324 .loc 1 79 0
325 001c FFF7FEFF bl chirpService
326 .L24:
76:../src/exec_m0.c **** while(g_run)
327 .loc 1 76 0
328 0020 034B ldr r3, .L27
329 0022 1B78 ldrb r3, [r3]
330 0024 002B cmp r3, #0
331 0026 F7D1 bne .L25
80:../src/exec_m0.c **** }
81:../src/exec_m0.c **** // set variable to indicate we've stopped
82:../src/exec_m0.c **** g_running = 0;
332 .loc 1 82 0
333 0028 024B ldr r3, .L27+4
334 002a 0022 movs r2, #0
335 002c 1A70 strb r2, [r3]
83:../src/exec_m0.c **** }
336 .loc 1 83 0
337 002e E9E7 b .L26
338 .L28:
339 .align 2
340 .L27:
341 0030 00000000 .word g_run
342 0034 00000000 .word g_running
343 .cfi_endproc
344 .LFE6:
346 .text
347 .Letext0:
348 .file 2 "/usr/local/lpcxpresso_8.1.4_606/lpcxpresso/tools/redlib/include/stdint.h"
349 .file 3 "/home/weyoui/PROJECTS/SmartCart/Pixy/pixy/misc/gcc/m0/inc/chirp.h"
DEFINED SYMBOLS
*ABS*:00000000 exec_m0.c
/tmp/ccMJG3fO.s:23 .bss.g_running:00000000 g_running
/tmp/ccMJG3fO.s:24 .bss.g_running:00000000 $d
/tmp/ccMJG3fO.s:29 .bss.g_run:00000000 g_run
/tmp/ccMJG3fO.s:30 .bss.g_run:00000000 $d
/tmp/ccMJG3fO.s:35 .data.g_program:00000000 g_program
/tmp/ccMJG3fO.s:38 .rodata:00000000 $d
/tmp/ccMJG3fO.s:48 .text.exec_init:00000000 $t
/tmp/ccMJG3fO.s:53 .text.exec_init:00000000 exec_init
/tmp/ccMJG3fO.s:92 .text.exec_init:00000030 $d
/tmp/ccMJG3fO.s:172 .text.exec_run:00000000 exec_run
/tmp/ccMJG3fO.s:138 .text.exec_stop:00000000 exec_stop
/tmp/ccMJG3fO.s:107 .text.exec_running:00000000 exec_running
/tmp/ccMJG3fO.s:102 .text.exec_running:00000000 $t
/tmp/ccMJG3fO.s:128 .text.exec_running:00000010 $d
/tmp/ccMJG3fO.s:133 .text.exec_stop:00000000 $t
/tmp/ccMJG3fO.s:162 .text.exec_stop:00000014 $d
/tmp/ccMJG3fO.s:167 .text.exec_run:00000000 $t
/tmp/ccMJG3fO.s:210 .text.exec_run:00000028 $d
/tmp/ccMJG3fO.s:217 .text.setup0:00000000 $t
/tmp/ccMJG3fO.s:222 .text.setup0:00000000 setup0
/tmp/ccMJG3fO.s:245 .data.g_m0mem:00000000 g_m0mem
/tmp/ccMJG3fO.s:242 .data.g_m0mem:00000000 $d
/tmp/ccMJG3fO.s:252 .data.g_lut:00000000 g_lut
/tmp/ccMJG3fO.s:249 .data.g_lut:00000000 $d
/tmp/ccMJG3fO.s:255 .text.loop0:00000000 $t
/tmp/ccMJG3fO.s:260 .text.loop0:00000000 loop0
/tmp/ccMJG3fO.s:284 .text.loop0:00000018 $d
/tmp/ccMJG3fO.s:290 .text.exec_loop:00000000 $t
/tmp/ccMJG3fO.s:295 .text.exec_loop:00000000 exec_loop
/tmp/ccMJG3fO.s:341 .text.exec_loop:00000030 $d
.debug_frame:00000010 $d
UNDEFINED SYMBOLS
chirpSetProc
getRLSFrame
chirpService
|
input_tests.asm | jwestfall69/ddragon-diag | 0 | 176607 | <reponame>jwestfall69/ddragon-diag<gh_stars>0
include "ddragon.inc"
include "ddragon_diag.inc"
include "error_codes.inc"
include "macros.inc"
global manual_input_tests
global STR_INPUT_TESTS
section text
g_start_b_pressed equ g_local_vars_start
g_vblank_pulses equ g_local_vars_start+1
manual_input_tests:
clrd
sta g_start_b_pressed
std g_vblank_pulses
std g_nmi_count
std g_irq_count
std g_firq_count
std g_swi_count
jsr print_static_text
.loop_input:
lda REG_EXTRA_INPUT
ldx #g_extra_input_raw
ldy #g_extra_input_edge
jsr input_refresh
lda g_extra_input_edge
bita #VBLANK
beq .vblank_not_pulse
ldd g_vblank_pulses
incd
std g_vblank_pulses
.vblank_not_pulse:
jsr print_dynamic_text
ldb REG_P1_INPUT
comb
tfr b,a
; only send the nmi to mcu on newly
; pressed p1 start + b button, and
; not constantly sending it while
; pressed
anda #(P1_START + B_BUTTON)
cmpa #(P1_START + B_BUTTON)
bne .p1_start_b_not_pressed
tst g_start_b_pressed
bne .skip_clr_start_b_pressed
lda #0
sta REG_MCU
lda #1
sta g_start_b_pressed
jmp .skip_clr_start_b_pressed
.p1_start_b_not_pressed:
clr g_start_b_pressed
.skip_clr_start_b_pressed:
tfr b,a
anda #(P1_START + A_BUTTON)
cmpa #(P1_START + A_BUTTON)
bne .loop_input
rts
print_static_text:
FG_XY 10,4
ldy #STR_INPUT_TESTS
JRU fg_print_string
FG_XY 6,6
ldy #STR_7_0_BITS
JRU fg_print_string
FG_XY 0,7
ldy #STR_P1
JRU fg_print_string
FG_XY 0,8
ldy #STR_P2
JRU fg_print_string
FG_XY 0,9
ldy #STR_EXTRA
JRU fg_print_string
FG_XY 0,10
ldy #STR_DSW0
JRU fg_print_string
FG_XY 0,11
ldy #STR_DSW1
JRU fg_print_string
FG_XY 16,7
ldy #STR_NMI
JRU fg_print_string
FG_XY 16,8
ldy #STR_IRQ
JRU fg_print_string
FG_XY 16,9
ldy #STR_FIRQ
JRU fg_print_string
FG_XY 16,10
ldy #STR_VBP
JRU fg_print_string
FG_XY 5,25
ldy #STR_A_START_MAIN_MENU
JRU fg_print_string
FG_XY 5,26
ldy #STR_B_START_NMI_TO_MCU
JRU fg_print_string
rts
print_dynamic_text:
FG_XY 6,7
lda REG_P1_INPUT
coma
JRU fg_print_bits_byte
FG_XY 6,8
lda REG_P2_INPUT
coma
JRU fg_print_bits_byte
FG_XY 6,9
lda REG_EXTRA_INPUT
coma
JRU fg_print_bits_byte
FG_XY 6,10
lda REG_DSW0
coma
JRU fg_print_bits_byte
FG_XY 6,11
lda REG_DSW1
coma
JRU fg_print_bits_byte
FG_XY 21,7
ldd g_nmi_count
JRU fg_print_hex_word
FG_XY 21,8
ldd g_irq_count
JRU fg_print_hex_word
FG_XY 21,9
ldd g_firq_count
JRU fg_print_hex_word
FG_XY 21,10
ldd g_vblank_pulses
JRU fg_print_hex_word
rts
STR_INPUT_TESTS: string "INPUT TESTS"
STR_7_0_BITS: string "76543210"
STR_P1: string " P1"
STR_P2: string " P2"
STR_EXTRA: string "EXTRA"
STR_DSW0: string " DSW0"
STR_DSW1: string " DSW1"
STR_NMI: string " NMI"
STR_IRQ: string " IRQ"
STR_FIRQ: string "FIRQ"
STR_VBP: string " VBP"
STR_A_START_MAIN_MENU: string "A+P1 START - MAIN MENU"
STR_B_START_NMI_TO_MCU: string "B+P1 START - NMI TO MCU"
|
programs/oeis/077/A077648.asm | neoneye/loda | 22 | 84187 | ; A077648: Initial digits of prime numbers.
; 2,3,5,7,1,1,1,1,2,2,3,3,4,4,4,5,5,6,6,7,7,7,8,8,9,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5
seq $0,40 ; The prime numbers.
mov $1,$0
lpb $1
div $0,10
sub $1,$0
lpe
|
Cubical/HITs/Truncation/Properties.agda | borsiemir/cubical | 0 | 1427 | {-# OPTIONS --cubical --safe #-}
module Cubical.HITs.Truncation.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.PathSplitEquiv
open isPathSplitEquiv
open import Cubical.Modalities.Everything
open Modality
open import Cubical.Data.Empty as ⊥ using (⊥)
open import Cubical.Data.Nat hiding (elim)
open import Cubical.Data.NatMinusOne as ℕ₋₁ hiding (1+_)
open import Cubical.Data.NatMinusTwo as ℕ₋₂ hiding (-1+_)
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.Nullification as Null hiding (rec; elim)
open import Cubical.HITs.Truncation.Base
open import Cubical.HITs.PropositionalTruncation as PropTrunc
renaming (∥_∥ to ∥_∥₋₁; ∣_∣ to ∣_∣₋₁; squash to squash₋₁) using ()
open import Cubical.HITs.SetTruncation as SetTrunc using (∥_∥₀; ∣_∣₀; squash₀)
open import Cubical.HITs.GroupoidTruncation as GpdTrunc using (∥_∥₁; ∣_∣₁; squash₁)
open import Cubical.HITs.2GroupoidTruncation as 2GpdTrunc using (∥_∥₂; ∣_∣₂; squash₂)
private
variable
ℓ ℓ' : Level
A : Type ℓ
sphereFill : (n : ℕ₋₁) (f : S n → A) → Type _
sphereFill {A = A} n f = Σ[ top ∈ A ] ((x : S n) → top ≡ f x)
isSphereFilled : ℕ₋₁ → Type ℓ → Type ℓ
isSphereFilled n A = (f : S n → A) → sphereFill n f
isSphereFilledTrunc : {n : ℕ} → isSphereFilled (-1+ n) (hLevelTrunc n A)
isSphereFilledTrunc {n = zero} f = hub f , ⊥.elim
isSphereFilledTrunc {n = suc n} f = hub f , spoke f
isSphereFilled→isOfHLevelSuc : {n : ℕ} → isSphereFilled (ℕ→ℕ₋₁ n) A → isOfHLevel (suc n) A
isSphereFilled→isOfHLevelSuc {A = A} {zero} h x y = sym (snd (h f) north) ∙ snd (h f) south
where
f : Susp ⊥ → A
f north = x
f south = y
f (merid () i)
isSphereFilled→isOfHLevelSuc {A = A} {suc n} h x y = isSphereFilled→isOfHLevelSuc (helper h x y)
where
helper : isSphereFilled (ℕ→ℕ₋₁ (suc n)) A → (x y : A) → isSphereFilled (ℕ→ℕ₋₁ n) (x ≡ y)
helper h x y f = l , r
where
f' : Susp (S (ℕ→ℕ₋₁ n)) → A
f' north = x
f' south = y
f' (merid u i) = f u i
u : sphereFill (ℕ→ℕ₋₁ (suc n)) f'
u = h f'
z : A
z = fst u
p : z ≡ x
p = snd u north
q : z ≡ y
q = snd u south
l : x ≡ y
l = sym p ∙ q
r : (s : S (ℕ→ℕ₋₁ n)) → l ≡ f s
r s i j = hcomp
(λ k →
λ { (i = i0) → compPath-filler (sym p) q k j
; (i = i1) → snd u (merid s j) k
; (j = i0) → p (k ∨ (~ i))
; (j = i1) → q k
})
(p ((~ i) ∧ (~ j)))
isOfHLevel→isSphereFilled : {n : ℕ} → isOfHLevel n A → isSphereFilled (-1+ n) A
isOfHLevel→isSphereFilled {A = A} {zero} h f = fst h , λ _ → snd h _
isOfHLevel→isSphereFilled {A = A} {suc zero} h f = f north , λ _ → h _ _
isOfHLevel→isSphereFilled {A = A} {suc (suc n)} h = helper λ x y → isOfHLevel→isSphereFilled (h x y)
where
helper : {n : ℕ} → ((x y : A) → isSphereFilled (-1+ n) (x ≡ y)) → isSphereFilled (suc₋₁ (-1+ n)) A
helper {n = n} h f = l , r
where
l : A
l = f north
f' : S (-1+ n) → f north ≡ f south
f' x i = f (merid x i)
h' : sphereFill (-1+ n) f'
h' = h (f north) (f south) f'
r : (x : S (suc₋₁ (-1+ n))) → l ≡ f x
r north = refl
r south = h' .fst
r (merid x i) j = hcomp (λ k → λ { (i = i0) → f north
; (i = i1) → h' .snd x (~ k) j
; (j = i0) → f north
; (j = i1) → f (merid x i) }) (f (merid x (i ∧ j)))
-- isNull (S n) A ≃ (isSphereFilled n A) × (∀ (x y : A) → isSphereFilled n (x ≡ y))
isOfHLevel→isSnNull : {n : ℕ} → isOfHLevel n A → isNull (S (-1+ n)) A
fst (sec (isOfHLevel→isSnNull h)) f = fst (isOfHLevel→isSphereFilled h f)
snd (sec (isOfHLevel→isSnNull h)) f i s = snd (isOfHLevel→isSphereFilled h f) s i
fst (secCong (isOfHLevel→isSnNull h) x y) p = fst (isOfHLevel→isSphereFilled (isOfHLevelPath _ h x y) (funExt⁻ p))
snd (secCong (isOfHLevel→isSnNull h) x y) p i j s = snd (isOfHLevel→isSphereFilled (isOfHLevelPath _ h x y) (funExt⁻ p)) s i j
isSnNull→isOfHLevel : {n : ℕ} → isNull (S (-1+ n)) A → isOfHLevel n A
isSnNull→isOfHLevel {n = zero} nA = fst (sec nA) ⊥.rec , λ y → fst (secCong nA _ y) (funExt ⊥.elim)
isSnNull→isOfHLevel {n = suc n} nA = isSphereFilled→isOfHLevelSuc (λ f → fst (sec nA) f , λ s i → snd (sec nA) f i s)
isOfHLevelTrunc : (n : ℕ) → isOfHLevel n (hLevelTrunc n A)
isOfHLevelTrunc zero = hub ⊥.rec , λ _ → ≡hub ⊥.rec
isOfHLevelTrunc (suc n) = isSphereFilled→isOfHLevelSuc isSphereFilledTrunc
-- isOfHLevelTrunc n = isSnNull→isOfHLevel isNull-Null
-- hLevelTrunc n is a modality
rec : {n : ℕ}
{B : Type ℓ'} →
(isOfHLevel n B) →
(g : (a : A) → B) →
(hLevelTrunc n A → B)
rec {B = B} h = Null.elim {B = λ _ → B} λ x → isOfHLevel→isSnNull h
elim : {n : ℕ}
{B : hLevelTrunc n A → Type ℓ'}
(hB : (x : hLevelTrunc n A) → isOfHLevel n (B x))
(g : (a : A) → B (∣ a ∣))
(x : hLevelTrunc n A) →
B x
elim hB = Null.elim (λ x → isOfHLevel→isSnNull (hB x))
elim2 : {n : ℕ}
{B : hLevelTrunc n A → hLevelTrunc n A → Type ℓ'}
(hB : ((x y : hLevelTrunc n A) → isOfHLevel n (B x y)))
(g : (a b : A) → B ∣ a ∣ ∣ b ∣)
(x y : hLevelTrunc n A) →
B x y
elim2 {n = n} hB g =
elim (λ _ → isOfHLevelPi n (λ _ → hB _ _))
(λ a → elim (λ _ → hB _ _) (λ b → g a b))
elim3 : {n : ℕ}
{B : (x y z : hLevelTrunc n A) → Type ℓ'}
(hB : ((x y z : hLevelTrunc n A) → isOfHLevel n (B x y z)))
(g : (a b c : A) → B (∣ a ∣) ∣ b ∣ ∣ c ∣)
(x y z : hLevelTrunc n A) →
B x y z
elim3 {n = n} hB g =
elim2 (λ _ _ → isOfHLevelPi n (hB _ _))
(λ a b → elim (λ _ → hB _ _ _) (λ c → g a b c))
HLevelTruncModality : ∀ {ℓ} (n : ℕ) → Modality ℓ
isModal (HLevelTruncModality n) = isOfHLevel n
isModalIsProp (HLevelTruncModality n) = isPropIsOfHLevel n
◯ (HLevelTruncModality n) = hLevelTrunc n
◯-isModal (HLevelTruncModality n) = isOfHLevelTrunc n
η (HLevelTruncModality n) = ∣_∣
◯-elim (HLevelTruncModality n) = elim
◯-elim-β (HLevelTruncModality n) = λ _ _ _ → refl
◯-=-isModal (HLevelTruncModality n) = isOfHLevelPath n (isOfHLevelTrunc n)
idemTrunc : (n : ℕ) → isOfHLevel n A → A ≃ (hLevelTrunc n A)
idemTrunc n hA = ∣_∣ , isModalToIsEquiv (HLevelTruncModality n) hA
-- equivalences to prop/set/groupoid truncations
propTrunc≃Trunc-1 : ∥ A ∥₋₁ ≃ ∥ A ∥ -1
propTrunc≃Trunc-1 =
isoToEquiv
(iso
(PropTrunc.elim (λ _ → isOfHLevelTrunc 1) ∣_∣)
(elim (λ _ → squash₋₁) ∣_∣₋₁)
(elim (λ _ → isOfHLevelPath 1 (isOfHLevelTrunc 1) _ _) (λ _ → refl))
(PropTrunc.elim (λ _ → isOfHLevelPath 1 squash₋₁ _ _) (λ _ → refl)))
setTrunc≃Trunc0 : ∥ A ∥₀ ≃ ∥ A ∥ 0
setTrunc≃Trunc0 =
isoToEquiv
(iso
(SetTrunc.elim (λ _ → isOfHLevelTrunc 2) ∣_∣)
(elim (λ _ → squash₀) ∣_∣₀)
(elim (λ _ → isOfHLevelPath 2 (isOfHLevelTrunc 2) _ _) (λ _ → refl))
(SetTrunc.elim (λ _ → isOfHLevelPath 2 squash₀ _ _) (λ _ → refl)))
groupoidTrunc≃Trunc1 : ∥ A ∥₁ ≃ ∥ A ∥ 1
groupoidTrunc≃Trunc1 =
isoToEquiv
(iso
(GpdTrunc.elim (λ _ → isOfHLevelTrunc 3) ∣_∣)
(elim (λ _ → squash₁) ∣_∣₁)
(elim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) (λ _ → refl))
(GpdTrunc.elim (λ _ → isOfHLevelPath 3 squash₁ _ _) (λ _ → refl)))
2GroupoidTrunc≃Trunc2 : ∥ A ∥₂ ≃ ∥ A ∥ 2
2GroupoidTrunc≃Trunc2 =
isoToEquiv
(iso
(2GpdTrunc.elim (λ _ → isOfHLevelTrunc 4) ∣_∣)
(elim (λ _ → squash₂) ∣_∣₂)
(elim (λ _ → isOfHLevelPath 4 (isOfHLevelTrunc 4) _ _) (λ _ → refl))
(2GpdTrunc.elim (λ _ → isOfHLevelPath 4 squash₂ _ _) (λ _ → refl)))
---- ∥ Ω A ∥ ₙ ≡ Ω ∥ A ∥ₙ₊₁ ----
{- Proofs of Theorem 7.3.12. and Corollary 7.3.13. in the HoTT book -}
private
{- We define the fibration P to show a more general result -}
P : ∀ {ℓ} {B : Type ℓ}{n : ℕ₋₂} → ∥ B ∥ (suc₋₂ n) → ∥ B ∥ (suc₋₂ n) → Type ℓ
P x y = fst (P₁ x y)
where
P₁ : ∀ {ℓ} {B : Type ℓ} {n : ℕ₋₂} → ∥ B ∥ (suc₋₂ n) → ∥ B ∥ (suc₋₂ n) → (HLevel ℓ (2+ n))
P₁ {ℓ} {n = n} x y =
elim2 (λ _ _ → isOfHLevelHLevel (2+ n)) (λ a b → ∥ a ≡ b ∥ n , isOfHLevelTrunc (2+ n)) x y
{- We will need P to be of hLevel n + 3 -}
hLevelP : ∀{ℓ} {n : ℕ₋₂} {B : Type ℓ} (a b : ∥ B ∥ (suc₋₂ n)) → isOfHLevel (2+ (suc₋₂ n)) (P a b )
hLevelP {n = n} =
elim2
(λ x y → isProp→isOfHLevelSuc (2+ n) (isPropIsOfHLevel (2+ suc₋₂ n)) )
(λ a b → isOfHLevelSuc (2+ n) (isOfHLevelTrunc (2+ n)))
{- decode function from P x y to x ≡ y -}
decode-fun : ∀ {ℓ} {B : Type ℓ} {n : ℕ₋₂} (x y : ∥ B ∥ (suc₋₂ n)) → P x y → x ≡ y
decode-fun {B = B} {n = n} =
elim2
(λ u v → isOfHLevelPi
(2+ suc₋₂ n)
(λ _ → isOfHLevelSuc (2+ suc₋₂ n) (isOfHLevelTrunc (2+ suc₋₂ n)) u v))
decode*
where
decode* : ∀ {ℓ} {B : Type ℓ} {n : ℕ₋₂}(u v : B)
→ (P {n = n} ∣ u ∣ ∣ v ∣) → _≡_ {A = ∥ B ∥ (suc₋₂ n)} ∣ u ∣ ∣ v ∣
decode* {B = B} {n = neg2} u v =
rec
( isOfHLevelTrunc (suc zero) ∣ u ∣ ∣ v ∣
, λ _ →
isOfHLevelSuc (suc zero) (isOfHLevelTrunc (suc zero)) _ _ _ _
)
(λ p → cong (λ z → ∣ z ∣) p)
decode* {n = ℕ₋₂.-1+ n} u v =
rec (isOfHLevelTrunc (suc (suc n)) ∣ u ∣ ∣ v ∣) (λ p → cong (λ z → ∣ z ∣) p)
{- auxilliary function r used to define encode -}
r : ∀ {ℓ} {B : Type ℓ} {m : ℕ₋₂} (u : ∥ B ∥ (suc₋₂ m)) → P u u
r {m = m} = elim (λ x → hLevelP x x) (λ a → ∣ refl ∣)
{- encode function from x ≡ y to P x y -}
encode-fun : ∀ {ℓ} {B : Type ℓ} {n : ℕ₋₂} (x y : ∥ B ∥ (suc₋₂ n)) → x ≡ y → P x y
encode-fun x y p = transport (λ i → P x (p i)) (r x)
{- We need the following two lemmas on the functions behaviour for refl -}
dec-refl : ∀ {ℓ} {B : Type ℓ} {n : ℕ₋₂}
(x : ∥ B ∥ (suc₋₂ n)) → decode-fun x x (r x) ≡ refl {x = x}
dec-refl {B = B} {n = neg2} =
elim
(λ x →
isOfHLevelSuc (suc zero)
(isOfHLevelSuc (suc zero) (isOfHLevelTrunc (suc zero)) x x)
_ _)
(λ a → refl)
dec-refl {n = ℕ₋₂.-1+ n} =
elim
(λ x →
isOfHLevelSuc (suc n)
(isOfHLevelSuc (suc n)
(isOfHLevelTrunc (suc (suc n)) x x)
(decode-fun x x (r x)) refl))
(λ c → refl)
enc-refl : ∀ {ℓ} {B : Type ℓ} {n : ℕ₋₂}
(x : ∥ B ∥ (suc₋₂ n)) → encode-fun x x refl ≡ r x
enc-refl x j = transp (λ i → P x (refl {x = x} i)) j (r x)
{- decode-fun is a right-inverse -}
P-rinv : ∀ {ℓ} {B : Type ℓ} {n : ℕ₋₂} (u v : ∥ B ∥ (suc₋₂ n)) →
(x : _≡_ {A = ∥ B ∥ (suc₋₂ n)} u v) → decode-fun u v (encode-fun u v x) ≡ x
P-rinv {ℓ = ℓ} {B = B} {n = n} u v =
J (λ y p → decode-fun u y (encode-fun u y p) ≡ p)
((λ i → (decode-fun u u (enc-refl u i))) ∙ dec-refl u)
{- decode-fun is a left-inverse -}
P-linv : ∀ {ℓ} {B : Type ℓ} {n : ℕ₋₂} (u v : ∥ B ∥ (suc₋₂ n )) →
(x : P u v) → encode-fun u v (decode-fun u v x) ≡ x
P-linv {n = n} =
elim2
(λ x y → isOfHLevelPi (2+ suc₋₂ n)
(λ z → isOfHLevelSuc (2+ suc₋₂ n) (hLevelP x y) _ _))
helper
where
helper : ∀ {ℓ} {B : Type ℓ} {n : ℕ₋₂} (a b : B) (x : P {n = n} ∣ a ∣ ∣ b ∣)
→ encode-fun ∣ a ∣ ∣ b ∣ (decode-fun ∣ a ∣ ∣ b ∣ x) ≡ x
helper {n = neg2} a b =
elim
(λ x →
( sym (isOfHLevelTrunc zero .snd (encode-fun ∣ a ∣ ∣ b ∣ (decode-fun ∣ a ∣ ∣ b ∣ x)))
∙ (isOfHLevelTrunc zero .snd x)
, λ y →
isOfHLevelSuc (suc zero)
(isOfHLevelSuc zero (isOfHLevelTrunc {A = a ≡ b} zero))
_ _ _ _
))
(J
(λ y p → encode-fun ∣ a ∣ ∣ y ∣ ((decode-fun ∣ a ∣ ∣ y ∣) ∣ p ∣) ≡ ∣ p ∣)
(enc-refl ∣ a ∣))
helper {n = ℕ₋₂.-1+ n} a b =
elim
(λ x → hLevelP {n = ℕ₋₂.-1+ n} ∣ a ∣ ∣ b ∣ _ _)
(J (λ y p → encode-fun {n = ℕ₋₂.-1+ n} ∣ a ∣ ∣ y ∣ ((decode-fun ∣ a ∣ ∣ y ∣) ∣ p ∣) ≡ ∣ p ∣)
(enc-refl ∣ a ∣))
{- The final Iso established -}
IsoFinal : ∀ {ℓ} {B : Type ℓ} {n : ℕ₋₂} (x y : ∥ B ∥ (suc₋₂ n)) → Iso (x ≡ y) (P x y)
IsoFinal x y = iso (encode-fun x y ) (decode-fun x y) (P-linv x y) (P-rinv x y)
PathIdTrunc : {a b : A} (n : ℕ₋₂) → (_≡_ {A = ∥ A ∥ (suc₋₂ n)} ∣ a ∣ ∣ b ∣) ≡ (∥ a ≡ b ∥ n)
PathIdTrunc {a = a} {b = b} n = isoToPath (IsoFinal {n = n} ∣ a ∣ ∣ b ∣)
PathΩ : {a : A} (n : ℕ₋₂) → (_≡_ {A = ∥ A ∥ (suc₋₂ n)} ∣ a ∣ ∣ a ∣) ≡ (∥ a ≡ a ∥ n)
PathΩ {a = a} n = PathIdTrunc {a = a} {b = a} n
|
libsrc/_DEVELOPMENT/math/float/math32/lm32/c/sccz80/inv.asm | jpoikela/z88dk | 0 | 166059 | <reponame>jpoikela/z88dk<filename>libsrc/_DEVELOPMENT/math/float/math32/lm32/c/sccz80/inv.asm
SECTION code_fp_math32
PUBLIC inv
EXTERN cm32_sccz80_fsinv
defc inv = cm32_sccz80_fsinv
; SDCC bridge for Classic
IF __CLASSIC
PUBLIC _inv
defc _inv = inv
ENDIF
|
oeis/028/A028362.asm | neoneye/loda-programs | 11 | 89984 | <reponame>neoneye/loda-programs<filename>oeis/028/A028362.asm
; A028362: Total number of self-dual binary codes of length 2n. Totally isotropic spaces of index n in symplectic geometry of dimension 2n.
; Submitted by <NAME>
; 1,3,15,135,2295,75735,4922775,635037975,163204759575,83724041661975,85817142703524375,175839325399521444375,720413716161839357604375,5902349576513949856852644375,96709997811181068404530578084375,3169089918274592430548062513246884375,207692645973961964120828372930661061284375,27222898185745116523209337325140537285726884375,7136346644902153570976711733098966146766874104484375,3741508046109105193573809217834723862122257657366008484375
mov $2,1
mov $3,2
mov $4,1
lpb $0
sub $0,1
add $3,$2
mul $2,2
mul $4,$3
lpe
mov $0,$4
|
tools-src/gnu/gcc/gcc/ada/gnatlink.adb | enfoTek/tomato.linksys.e2000.nvram-mod | 80 | 18102 | <filename>tools-src/gnu/gcc/gcc/ada/gnatlink.adb
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T L I N K --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1996-2001 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Gnatlink usage: please consult the gnat documentation
with Gnatvsn; use Gnatvsn;
with Hostparm;
with Osint; use Osint;
with Output; use Output;
with System; use System;
with Table;
with Ada.Command_Line; use Ada.Command_Line;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with Interfaces.C_Streams; use Interfaces.C_Streams;
procedure Gnatlink is
pragma Ident (Gnat_Version_String);
package Gcc_Linker_Options is new Table.Table (
Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Gnatlink.Gcc_Linker_Options");
-- Comments needed ???
package Libpath is new Table.Table (
Table_Component_Type => Character,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 4096,
Table_Increment => 2,
Table_Name => "Gnatlink.Libpath");
-- Comments needed ???
package Linker_Options is new Table.Table (
Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Gnatlink.Linker_Options");
-- Comments needed ???
package Linker_Objects is new Table.Table (
Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Gnatlink.Linker_Objects");
-- This table collects the objects file to be passed to the linker. In the
-- case where the linker command line is too long then programs objects
-- are put on the Response_File_Objects table. Note that the binder object
-- file and the user's objects remain in this table. This is very
-- important because on the GNU linker command line the -L switch is not
-- used to look for objects files but -L switch is used to look for
-- objects listed in the response file. This is not a problem with the
-- applications objects as they are specified with a fullname.
package Response_File_Objects is new Table.Table (
Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Gnatlink.Response_File_Objects");
-- This table collects the objects file that are to be put in the response
-- file. Only application objects are collected there (see details in
-- Linker_Objects table comments)
package Binder_Options is new Table.Table (
Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1, -- equals low bound of Argument_List for Spawn
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Gnatlink.Binder_Options");
-- This table collects the arguments to be passed to compile the binder
-- generated file.
subtype chars_ptr is System.Address;
Gcc : String_Access := Program_Name ("gcc");
Read_Mode : constant String := "r" & ASCII.Nul;
Begin_Info : String := "-- BEGIN Object file/option list";
End_Info : String := "-- END Object file/option list ";
-- Note: above lines are modified in C mode, see option processing
Gcc_Path : String_Access;
Linker_Path : String_Access;
Output_File_Name : String_Access;
Ali_File_Name : String_Access;
Binder_Spec_Src_File : String_Access;
Binder_Body_Src_File : String_Access;
Binder_Ali_File : String_Access;
Binder_Obj_File : String_Access;
Tname : Temp_File_Name;
Tname_FD : File_Descriptor := Invalid_FD;
-- Temporary file used by linker to pass list of object files on
-- certain systems with limitations on size of arguments.
Debug_Flag_Present : Boolean := False;
Verbose_Mode : Boolean := False;
Very_Verbose_Mode : Boolean := False;
Ada_Bind_File : Boolean := True;
-- Set to True if bind file is generated in Ada
Compile_Bind_File : Boolean := True;
-- Set to False if bind file is not to be compiled
Object_List_File_Supported : Boolean;
pragma Import (C, Object_List_File_Supported, "objlist_file_supported");
-- Predicate indicating whether the linker has an option whereby the
-- names of object files can be passed to the linker in a file.
Object_List_File_Required : Boolean := False;
-- Set to True to force generation of a response file
function Base_Name (File_Name : in String) return String;
-- Return just the file name part without the extension (if present).
procedure Delete (Name : in String);
-- Wrapper to unlink as status is ignored by this application.
procedure Error_Msg (Message : in String);
-- Output the error or warning Message
procedure Exit_With_Error (Error : in String);
-- Output Error and exit program with a fatal condition.
procedure Process_Args;
-- Go through all the arguments and build option tables.
procedure Process_Binder_File (Name : in String);
-- Reads the binder file and extracts linker arguments.
function Value (chars : chars_ptr) return String;
-- Return NUL-terminated string chars as an Ada string.
procedure Write_Usage;
-- Show user the program options.
---------------
-- Base_Name --
---------------
function Base_Name (File_Name : in String) return String is
Findex1 : Natural;
Findex2 : Natural;
begin
Findex1 := File_Name'First;
-- The file might be specified by a full path name. However,
-- we want the path to be stripped away.
for J in reverse File_Name'Range loop
if Is_Directory_Separator (File_Name (J)) then
Findex1 := J + 1;
exit;
end if;
end loop;
Findex2 := File_Name'Last;
while Findex2 > Findex1
and then File_Name (Findex2) /= '.'
loop
Findex2 := Findex2 - 1;
end loop;
if Findex2 = Findex1 then
Findex2 := File_Name'Last + 1;
end if;
return File_Name (Findex1 .. Findex2 - 1);
end Base_Name;
------------
-- Delete --
------------
procedure Delete (Name : in String) is
Status : int;
begin
Status := unlink (Name'Address);
end Delete;
---------------
-- Error_Msg --
---------------
procedure Error_Msg (Message : in String) is
begin
Write_Str (Base_Name (Command_Name));
Write_Str (": ");
Write_Str (Message);
Write_Eol;
end Error_Msg;
---------------------
-- Exit_With_Error --
---------------------
procedure Exit_With_Error (Error : in String) is
begin
Error_Msg (Error);
Exit_Program (E_Fatal);
end Exit_With_Error;
------------------
-- Process_Args --
------------------
procedure Process_Args is
Next_Arg : Integer;
begin
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) := new String'("-c");
-- If the main program is in Ada it is compiled with the following
-- switches:
-- -gnatA stops reading gnat.adc, since we don't know what
-- pagmas would work, and we do not need it anyway.
-- -gnatWb allows brackets coding for wide characters
-- -gnatiw allows wide characters in identifiers. This is needed
-- because bindgen uses brackets encoding for all upper
-- half and wide characters in identifier names.
if Ada_Bind_File then
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) := new String'("-gnatA");
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) := new String'("-gnatWb");
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) := new String'("-gnatiw");
end if;
-- Loop through arguments of gnatlink command
Next_Arg := 1;
loop
exit when Next_Arg > Argument_Count;
Process_One_Arg : declare
Arg : String := Argument (Next_Arg);
begin
-- Case of argument which is a switch
-- We definitely need section by section comments here ???
if Arg'Length /= 0
and then (Arg (1) = Switch_Character or else Arg (1) = '-')
then
if Arg'Length > 4
and then Arg (2 .. 5) = "gnat"
then
Exit_With_Error
("invalid switch: """ & Arg & """ (gnat not needed here)");
end if;
if Arg (2) = 'g'
and then (Arg'Length < 5 or else Arg (2 .. 5) /= "gnat")
then
Debug_Flag_Present := True;
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) :=
Linker_Options.Table (Linker_Options.Last);
elsif Arg'Length = 2 then
case Arg (2) is
when 'A' =>
Ada_Bind_File := True;
Begin_Info := "-- BEGIN Object file/option list";
End_Info := "-- END Object file/option list ";
when 'b' =>
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) :=
Linker_Options.Table (Linker_Options.Last);
Next_Arg := Next_Arg + 1;
if Next_Arg > Argument_Count then
Exit_With_Error ("Missing argument for -b");
end if;
Get_Machine_Name : declare
Name_Arg : String_Access :=
new String'(Argument (Next_Arg));
begin
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
Name_Arg;
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) :=
Name_Arg;
end Get_Machine_Name;
when 'C' =>
Ada_Bind_File := False;
Begin_Info := "/* BEGIN Object file/option list";
End_Info := " END Object file/option list */";
when 'f' =>
if Object_List_File_Supported then
Object_List_File_Required := True;
else
Exit_With_Error
("Object list file not supported on this target");
end if;
when 'n' =>
Compile_Bind_File := False;
when 'o' =>
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
Next_Arg := Next_Arg + 1;
if Next_Arg > Argument_Count then
Exit_With_Error ("Missing argument for -o");
end if;
Output_File_Name := new String'(Argument (Next_Arg));
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
Output_File_Name;
when 'v' =>
-- Support "double" verbose mode. Second -v
-- gets sent to the linker and binder phases.
if Verbose_Mode then
Very_Verbose_Mode := True;
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) :=
Linker_Options.Table (Linker_Options.Last);
else
Verbose_Mode := True;
end if;
when others =>
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
end case;
elsif Arg (2) = 'B' then
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) :=
Linker_Options.Table (Linker_Options.Last);
elsif Arg'Length >= 7 and then Arg (1 .. 7) = "--LINK=" then
if Arg'Length = 7 then
Exit_With_Error ("Missing argument for --LINK=");
end if;
Linker_Path :=
GNAT.OS_Lib.Locate_Exec_On_Path (Arg (8 .. Arg'Last));
if Linker_Path = null then
Exit_With_Error
("Could not locate linker: " & Arg (8 .. Arg'Last));
end if;
elsif Arg'Length > 6 and then Arg (1 .. 6) = "--GCC=" then
declare
Program_Args : Argument_List_Access :=
Argument_String_To_List
(Arg (7 .. Arg'Last));
begin
Gcc := new String'(Program_Args.all (1).all);
-- Set appropriate flags for switches passed
for J in 2 .. Program_Args.all'Last loop
declare
Arg : String := Program_Args.all (J).all;
AF : Integer := Arg'First;
begin
if Arg'Length /= 0
and then (Arg (AF) = Switch_Character
or else Arg (AF) = '-')
then
if Arg (AF + 1) = 'g'
and then (Arg'Length = 2
or else Arg (AF + 2) in '0' .. '3'
or else Arg (AF + 2 .. Arg'Last) = "coff")
then
Debug_Flag_Present := True;
end if;
end if;
-- Pass to gcc for compiling binder generated file
-- No use passing libraries, it will just generate
-- a warning
if not (Arg (AF .. AF + 1) = "-l"
or else Arg (AF .. AF + 1) = "-L")
then
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) :=
new String'(Arg);
end if;
-- Pass to gcc for linking program.
Gcc_Linker_Options.Increment_Last;
Gcc_Linker_Options.Table
(Gcc_Linker_Options.Last) := new String'(Arg);
end;
end loop;
end;
-- Send all multi-character switches not recognized as
-- a special case by gnatlink to the linker/loader stage.
else
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
end if;
-- Here if argument is a file name rather than a switch
else
if Arg'Length > 4
and then Arg (Arg'Last - 3 .. Arg'Last) = ".ali"
then
if Ali_File_Name = null then
Ali_File_Name := new String'(Arg);
else
Exit_With_Error ("cannot handle more than one ALI file");
end if;
elsif Is_Regular_File (Arg & ".ali")
and then Ali_File_Name = null
then
Ali_File_Name := new String'(Arg & ".ali");
elsif Arg'Length > Get_Object_Suffix.all'Length
and then Arg
(Arg'Last - Get_Object_Suffix.all'Length + 1 .. Arg'Last)
= Get_Object_Suffix.all
then
Linker_Objects.Increment_Last;
Linker_Objects.Table (Linker_Objects.Last) :=
new String'(Arg);
else
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Arg);
end if;
end if;
end Process_One_Arg;
Next_Arg := Next_Arg + 1;
end loop;
-- If Ada bind file, then compile it with warnings suppressed, because
-- otherwise the with of the main program may cause junk warnings.
if Ada_Bind_File then
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) := new String'("-gnatws");
end if;
end Process_Args;
-------------------------
-- Process_Binder_File --
-------------------------
procedure Process_Binder_File (Name : in String) is
Fd : FILEs;
Link_Bytes : Integer := 0;
Link_Max : Integer;
pragma Import (C, Link_Max, "link_max");
Next_Line : String (1 .. 1000);
Nlast : Integer;
Nfirst : Integer;
Objs_Begin : Integer := 0;
Objs_End : Integer := 0;
Status : int;
N : Integer;
GNAT_Static : Boolean := False;
-- Save state of -static option.
GNAT_Shared : Boolean := False;
-- Save state of -shared option.
Run_Path_Option_Ptr : Address;
pragma Import (C, Run_Path_Option_Ptr, "run_path_option");
-- Pointer to string representing the native linker option which
-- specifies the path where the dynamic loader should find shared
-- libraries. Equal to null string if this system doesn't support it.
Object_Library_Ext_Ptr : Address;
pragma Import (C, Object_Library_Ext_Ptr, "object_library_extension");
-- Pointer to string specifying the default extension for
-- object libraries, e.g. Unix uses ".a", VMS uses ".olb".
Object_File_Option_Ptr : Address;
pragma Import (C, Object_File_Option_Ptr, "object_file_option");
-- Pointer to a string representing the linker option which specifies
-- the response file.
Using_GNU_Linker : Boolean;
pragma Import (C, Using_GNU_Linker, "using_gnu_linker");
-- Predicate indicating whether this target uses the GNU linker. In
-- this case we must output a GNU linker compatible response file.
procedure Get_Next_Line;
-- Read the next line from the binder file without the line
-- terminator.
function Is_Option_Present (Opt : in String) return Boolean;
-- Return true if the option Opt is already present in
-- Linker_Options table.
procedure Get_Next_Line is
Fchars : chars;
begin
Fchars := fgets (Next_Line'Address, Next_Line'Length, Fd);
if Fchars = System.Null_Address then
Exit_With_Error ("Error reading binder output");
end if;
Nfirst := Next_Line'First;
Nlast := Nfirst;
while Nlast <= Next_Line'Last
and then Next_Line (Nlast) /= ASCII.LF
and then Next_Line (Nlast) /= ASCII.CR
loop
Nlast := Nlast + 1;
end loop;
Nlast := Nlast - 1;
end Get_Next_Line;
function Is_Option_Present (Opt : in String) return Boolean is
begin
for I in 1 .. Linker_Options.Last loop
if Linker_Options.Table (I).all = Opt then
return True;
end if;
end loop;
return False;
end Is_Option_Present;
-- Start of processing for Process_Binder_File
begin
Fd := fopen (Name'Address, Read_Mode'Address);
if Fd = NULL_Stream then
Exit_With_Error ("Failed to open binder output");
end if;
-- Skip up to the Begin Info line
loop
Get_Next_Line;
exit when Next_Line (Nfirst .. Nlast) = Begin_Info;
end loop;
loop
Get_Next_Line;
-- Go to end when end line is reached (this will happen in
-- No_Run_Time mode where no -L switches are generated)
exit when Next_Line (Nfirst .. Nlast) = End_Info;
if Ada_Bind_File then
Next_Line (Nfirst .. Nlast - 8) :=
Next_Line (Nfirst + 8 .. Nlast);
Nlast := Nlast - 8;
end if;
-- Go to next section when switches are reached
exit when Next_Line (1) = '-';
-- Otherwise we have another object file to collect
Linker_Objects.Increment_Last;
-- Mark the positions of first and last object files in case
-- they need to be placed with a named file on systems having
-- linker line limitations.
if Objs_Begin = 0 then
Objs_Begin := Linker_Objects.Last;
end if;
Linker_Objects.Table (Linker_Objects.Last) :=
new String'(Next_Line (Nfirst .. Nlast));
Link_Bytes := Link_Bytes + Nlast - Nfirst;
end loop;
Objs_End := Linker_Objects.Last;
-- On systems that have limitations on handling very long linker lines
-- we make use of the system linker option which takes a list of object
-- file names from a file instead of the command line itself. What we do
-- is to replace the list of object files by the special linker option
-- which then reads the object file list from a file instead. The option
-- to read from a file instead of the command line is only triggered if
-- a conservative threshold is passed.
if Object_List_File_Required
or else (Object_List_File_Supported
and then Link_Bytes > Link_Max)
then
-- Create a temporary file containing the Ada user object files
-- needed by the link. This list is taken from the bind file
-- and is output one object per line for maximal compatibility with
-- linkers supporting this option.
Create_Temp_File (Tname_FD, Tname);
-- If target is using the GNU linker we must add a special header
-- and footer in the response file.
-- The syntax is : INPUT (object1.o object2.o ... )
if Using_GNU_Linker then
declare
GNU_Header : aliased constant String := "INPUT (";
begin
Status := Write (Tname_FD, GNU_Header'Address,
GNU_Header'Length);
end;
end if;
for J in Objs_Begin .. Objs_End loop
Status := Write (Tname_FD, Linker_Objects.Table (J).all'Address,
Linker_Objects.Table (J).all'Length);
Status := Write (Tname_FD, ASCII.LF'Address, 1);
Response_File_Objects.Increment_Last;
Response_File_Objects.Table (Response_File_Objects.Last) :=
Linker_Objects.Table (J);
end loop;
-- handle GNU linker response file footer.
if Using_GNU_Linker then
declare
GNU_Footer : aliased constant String := ")";
begin
Status := Write (Tname_FD, GNU_Footer'Address,
GNU_Footer'Length);
end;
end if;
Close (Tname_FD);
-- Add the special objects list file option together with the name
-- of the temporary file (removing the null character) to the objects
-- file table.
Linker_Objects.Table (Objs_Begin) :=
new String'(Value (Object_File_Option_Ptr) &
Tname (Tname'First .. Tname'Last - 1));
-- The slots containing these object file names are then removed
-- from the objects table so they do not appear in the link. They
-- are removed by moving up the linker options and non-Ada object
-- files appearing after the Ada object list in the table.
N := Objs_End - Objs_Begin + 1;
for J in Objs_End + 1 .. Linker_Objects.Last loop
Linker_Objects.Table (J - N + 1) := Linker_Objects.Table (J);
end loop;
Linker_Objects.Set_Last (Linker_Objects.Last - N + 1);
end if;
-- Process switches and options
if Next_Line (Nfirst .. Nlast) /= End_Info then
loop
-- Add binder options only if not already set on the command
-- line. This rule is a way to control the linker options order.
if not Is_Option_Present
(Next_Line (Nfirst .. Nlast))
then
if Next_Line (Nfirst .. Nlast) = "-static" then
GNAT_Static := True;
elsif Next_Line (Nfirst .. Nlast) = "-shared" then
GNAT_Shared := True;
else
if Nlast > Nfirst + 2 and then
Next_Line (Nfirst .. Nfirst + 1) = "-L"
then
-- Construct a library search path for use later
-- to locate static gnatlib libraries.
if Libpath.Last > 1 then
Libpath.Increment_Last;
Libpath.Table (Libpath.Last) := Path_Separator;
end if;
for I in Nfirst + 2 .. Nlast loop
Libpath.Increment_Last;
Libpath.Table (Libpath.Last) := Next_Line (I);
end loop;
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Next_Line (Nfirst .. Nlast));
elsif Next_Line (Nfirst .. Nlast) = "-ldecgnat"
or else Next_Line (Nfirst .. Nlast) = "-lgnarl"
or else Next_Line (Nfirst .. Nlast) = "-lgnat"
then
-- Given a Gnat standard library, search the
-- library path to find the library location
declare
File_Path : String_Access;
Object_Lib_Extension : constant String :=
Value
(Object_Library_Ext_Ptr);
File_Name : String :=
"lib" &
Next_Line (Nfirst + 2 .. Nlast) &
Object_Lib_Extension;
begin
File_Path :=
Locate_Regular_File
(File_Name,
String (Libpath.Table (1 .. Libpath.Last)));
if File_Path /= null then
if GNAT_Static then
-- If static gnatlib found, explicitly
-- specify to overcome possible linker
-- default usage of shared version.
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(File_Path.all);
elsif GNAT_Shared then
-- If shared gnatlib desired, add the
-- appropriate system specific switch
-- so that it can be located at runtime.
declare
Run_Path_Opt : constant String :=
Value
(Run_Path_Option_Ptr);
begin
if Run_Path_Opt'Length /= 0 then
-- Output the system specific linker
-- command that allows the image
-- activator to find the shared library
-- at runtime.
Linker_Options.Increment_Last;
Linker_Options.Table
(Linker_Options.Last) :=
new String'(Run_Path_Opt
& File_Path
(1 .. File_Path'Length
- File_Name'Length));
end if;
Linker_Options.Increment_Last;
Linker_Options.Table
(Linker_Options.Last) :=
new String'(Next_Line
(Nfirst .. Nlast));
end;
end if;
else
-- If gnatlib library not found, then
-- add it anyway in case some other
-- mechanimsm may find it.
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Next_Line (Nfirst .. Nlast));
end if;
end;
else
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Next_Line (Nfirst .. Nlast));
end if;
end if;
end if;
Get_Next_Line;
exit when Next_Line (Nfirst .. Nlast) = End_Info;
if Ada_Bind_File then
Next_Line (Nfirst .. Nlast - 8) :=
Next_Line (Nfirst + 8 .. Nlast);
Nlast := Nlast - 8;
end if;
end loop;
end if;
Status := fclose (Fd);
end Process_Binder_File;
-----------
-- Value --
-----------
function Value (chars : chars_ptr) return String is
function Strlen (chars : chars_ptr) return Natural;
pragma Import (C, Strlen);
begin
if chars = Null_Address then
return "";
else
declare
subtype Result_Type is String (1 .. Strlen (chars));
Result : Result_Type;
for Result'Address use chars;
begin
return Result;
end;
end if;
end Value;
-----------------
-- Write_Usage --
-----------------
procedure Write_Usage is
begin
Write_Str ("Usage: ");
Write_Str (Base_Name (Command_Name));
Write_Str (" switches mainprog.ali [non-Ada-objects] [linker-options]");
Write_Eol;
Write_Eol;
Write_Line (" mainprog.ali the ALI file of the main program");
Write_Eol;
Write_Line (" -A Binder generated source file is in Ada (default)");
Write_Line (" -C Binder generated source file is in C");
Write_Line (" -f force object file list to be generated");
Write_Line (" -g Compile binder source file with debug information");
Write_Line (" -n Do not compile the binder source file");
Write_Line (" -v verbose mode");
Write_Line (" -v -v very verbose mode");
Write_Eol;
Write_Line (" -o nam Use 'nam' as the name of the executable");
Write_Line (" -b target Compile the binder source to run on target");
Write_Line (" -Bdir Load compiler executables from dir");
Write_Line (" --GCC=comp Use comp as the compiler");
Write_Line (" --LINK=nam Use 'nam' for the linking rather than 'gcc'");
Write_Eol;
Write_Line (" [non-Ada-objects] list of non Ada object files");
Write_Line (" [linker-options] other options for the linker");
end Write_Usage;
-- Start of processing for Gnatlink
begin
if Argument_Count = 0 then
Write_Usage;
Exit_Program (E_Fatal);
end if;
if Hostparm.Java_VM then
Gcc := new String'("jgnat");
Ada_Bind_File := True;
Begin_Info := "-- BEGIN Object file/option list";
End_Info := "-- END Object file/option list ";
end if;
Process_Args;
-- Locate all the necessary programs and verify required files are present
Gcc_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Gcc.all);
if Gcc_Path = null then
Exit_With_Error ("Couldn't locate " & Gcc.all);
end if;
if Linker_Path = null then
Linker_Path := Gcc_Path;
end if;
if Ali_File_Name = null then
Exit_With_Error ("Required 'name'.ali not present.");
end if;
if not Is_Regular_File (Ali_File_Name.all) then
Exit_With_Error (Ali_File_Name.all & " not found.");
end if;
if Verbose_Mode then
Write_Eol;
Write_Str ("GNATLINK ");
Write_Str (Gnat_Version_String);
Write_Str (" Copyright 1996-2001 Free Software Foundation, Inc.");
Write_Eol;
end if;
-- If there wasn't an output specified, then use the base name of
-- the .ali file name.
if Output_File_Name = null then
Output_File_Name :=
new String'(Base_Name (Ali_File_Name.all)
& Get_Debuggable_Suffix.all);
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'("-o");
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Output_File_Name.all);
end if;
-- Warn if main program is called "test", as that may be a built-in command
-- on Unix. On non-Unix systems executables have a suffix, so the warning
-- will not appear. However, do not warn in the case of a cross compiler.
-- Assume that if the executable name is not gnatlink, this is a cross
-- tool.
if Base_Name (Command_Name) = "gnatlink"
and then Output_File_Name.all = "test"
then
Error_Msg ("warning: executable name """ & Output_File_Name.all
& """ may conflict with shell command");
end if;
-- Perform consistency checks
-- Transform the .ali file name into the binder output file name.
Make_Binder_File_Names : declare
Fname : String := Base_Name (Ali_File_Name.all);
Fname_Len : Integer := Fname'Length;
function Get_Maximum_File_Name_Length return Integer;
pragma Import (C, Get_Maximum_File_Name_Length,
"__gnat_get_maximum_file_name_length");
Maximum_File_Name_Length : Integer := Get_Maximum_File_Name_Length;
Second_Char : Character;
-- Second character of name of files
begin
-- Set proper second character of file name
if not Ada_Bind_File then
Second_Char := '_';
elsif Hostparm.OpenVMS then
Second_Char := '$';
else
Second_Char := '~';
end if;
-- If the length of the binder file becomes too long due to
-- the addition of the "b?" prefix, then truncate it.
if Maximum_File_Name_Length > 0 then
while Fname_Len > Maximum_File_Name_Length - 2 loop
Fname_Len := Fname_Len - 1;
end loop;
end if;
if Ada_Bind_File then
Binder_Spec_Src_File :=
new String'('b'
& Second_Char
& Fname (Fname'First .. Fname'First + Fname_Len - 1)
& ".ads");
Binder_Body_Src_File :=
new String'('b'
& Second_Char
& Fname (Fname'First .. Fname'First + Fname_Len - 1)
& ".adb");
Binder_Ali_File :=
new String'('b'
& Second_Char
& Fname (Fname'First .. Fname'First + Fname_Len - 1)
& ".ali");
else
Binder_Body_Src_File :=
new String'('b'
& Second_Char
& Fname (Fname'First .. Fname'First + Fname_Len - 1)
& ".c");
end if;
Binder_Obj_File :=
new String'('b'
& Second_Char
& Fname (Fname'First .. Fname'First + Fname_Len - 1)
& Get_Object_Suffix.all);
if Fname_Len /= Fname'Length then
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) := new String'("-o");
Binder_Options.Increment_Last;
Binder_Options.Table (Binder_Options.Last) := Binder_Obj_File;
end if;
end Make_Binder_File_Names;
Process_Binder_File (Binder_Body_Src_File.all & ASCII.NUL);
-- Compile the binder file. This is fast, so we always do it, unless
-- specifically told not to by the -n switch
if Compile_Bind_File then
Bind_Step : declare
Success : Boolean;
Args : Argument_List (1 .. Binder_Options.Last + 1);
begin
for J in Binder_Options.First .. Binder_Options.Last loop
Args (J) := Binder_Options.Table (J);
end loop;
Args (Args'Last) := Binder_Body_Src_File;
if Verbose_Mode then
Write_Str (Base_Name (Gcc_Path.all));
for J in Args'Range loop
Write_Str (" ");
Write_Str (Args (J).all);
end loop;
Write_Eol;
end if;
GNAT.OS_Lib.Spawn (Gcc_Path.all, Args, Success);
if not Success then
Exit_Program (E_Fatal);
end if;
end Bind_Step;
end if;
-- Now, actually link the program.
-- Skip this step for now on the JVM since the Java interpreter will do
-- the actual link at run time. We might consider packing all class files
-- in a .zip file during this step.
if not Hostparm.Java_VM then
Link_Step : declare
Num_Args : Natural :=
(Linker_Options.Last - Linker_Options.First + 1) +
(Gcc_Linker_Options.Last - Gcc_Linker_Options.First + 1) +
(Linker_Objects.Last - Linker_Objects.First + 1);
Stack_Op : Boolean := False;
IDENT_Op : Boolean := False;
begin
-- Remove duplicate stack size setting from the Linker_Options
-- table. The stack setting option "-Xlinker --stack=R,C" can be
-- found in one line when set by a pragma Linker_Options or in two
-- lines ("-Xlinker" then "--stack=R,C") when set on the command
-- line. We also check for the "-Wl,--stack=R" style option.
-- We must remove the second stack setting option instance
-- because the one on the command line will always be the first
-- one. And any subsequent stack setting option will overwrite the
-- previous one. This is done especially for GNAT/NT where we set
-- the stack size for tasking programs by a pragma in the NT
-- specific tasking package System.Task_Primitives.Oparations.
for J in Linker_Options.First .. Linker_Options.Last loop
if Linker_Options.Table (J).all = "-Xlinker"
and then J < Linker_Options.Last
and then Linker_Options.Table (J + 1)'Length > 8
and then Linker_Options.Table (J + 1) (1 .. 8) = "--stack="
then
if Stack_Op then
Linker_Options.Table (J .. Linker_Options.Last - 2) :=
Linker_Options.Table (J + 2 .. Linker_Options.Last);
Linker_Options.Decrement_Last;
Linker_Options.Decrement_Last;
Num_Args := Num_Args - 2;
else
Stack_Op := True;
end if;
end if;
-- Here we just check for a canonical form that matches the
-- pragma Linker_Options set in the NT runtime.
if (Linker_Options.Table (J)'Length > 17
and then Linker_Options.Table (J) (1 .. 17)
= "-Xlinker --stack=")
or else
(Linker_Options.Table (J)'Length > 12
and then Linker_Options.Table (J) (1 .. 12)
= "-Wl,--stack=")
then
if Stack_Op then
Linker_Options.Table (J .. Linker_Options.Last - 1) :=
Linker_Options.Table (J + 1 .. Linker_Options.Last);
Linker_Options.Decrement_Last;
Num_Args := Num_Args - 1;
else
Stack_Op := True;
end if;
end if;
-- Remove duplicate IDENTIFICATION directives (VMS)
if Linker_Options.Table (J)'Length > 27
and then Linker_Options.Table (J) (1 .. 27)
= "--for-linker=IDENTIFICATION="
then
if IDENT_Op then
Linker_Options.Table (J .. Linker_Options.Last - 1) :=
Linker_Options.Table (J + 1 .. Linker_Options.Last);
Linker_Options.Decrement_Last;
Num_Args := Num_Args - 1;
else
IDENT_Op := True;
end if;
end if;
end loop;
-- Prepare arguments for call to linker
Call_Linker : declare
Success : Boolean;
Args : Argument_List (1 .. Num_Args + 1);
Index : Integer := Args'First;
begin
Args (Index) := Binder_Obj_File;
-- Add the object files and any -largs libraries
for J in Linker_Objects.First .. Linker_Objects.Last loop
Index := Index + 1;
Args (Index) := Linker_Objects.Table (J);
end loop;
-- Add the linker options from the binder file
for J in Linker_Options.First .. Linker_Options.Last loop
Index := Index + 1;
Args (Index) := Linker_Options.Table (J);
end loop;
-- Finally add the libraries from the --GCC= switch
for J in Gcc_Linker_Options.First .. Gcc_Linker_Options.Last loop
Index := Index + 1;
Args (Index) := Gcc_Linker_Options.Table (J);
end loop;
if Verbose_Mode then
Write_Str (Linker_Path.all);
for J in Args'Range loop
Write_Str (" ");
Write_Str (Args (J).all);
end loop;
Write_Eol;
-- If we are on very verbose mode (-v -v) and a response file
-- is used we display its content.
if Very_Verbose_Mode and then Tname_FD /= Invalid_FD then
Write_Eol;
Write_Str ("Response file (" &
Tname (Tname'First .. Tname'Last - 1) &
") content : ");
Write_Eol;
for J in
Response_File_Objects.First ..
Response_File_Objects.Last
loop
Write_Str (Response_File_Objects.Table (J).all);
Write_Eol;
end loop;
Write_Eol;
end if;
end if;
GNAT.OS_Lib.Spawn (Linker_Path.all, Args, Success);
-- Delete the temporary file used in conjuction with linking if
-- one was created. See Process_Bind_File for details.
if Tname_FD /= Invalid_FD then
Delete (Tname);
end if;
if not Success then
Error_Msg ("cannot call " & Linker_Path.all);
Exit_Program (E_Fatal);
end if;
end Call_Linker;
end Link_Step;
end if;
-- Only keep the binder output file and it's associated object
-- file if compiling with the -g option. These files are only
-- useful if debugging.
if not Debug_Flag_Present then
if Binder_Ali_File /= null then
Delete (Binder_Ali_File.all & ASCII.NUL);
end if;
if Binder_Spec_Src_File /= null then
Delete (Binder_Spec_Src_File.all & ASCII.NUL);
end if;
Delete (Binder_Body_Src_File.all & ASCII.NUL);
if not Hostparm.Java_VM then
Delete (Binder_Obj_File.all & ASCII.NUL);
end if;
end if;
Exit_Program (E_Success);
exception
when others =>
Exit_With_Error ("INTERNAL ERROR. Please report.");
end Gnatlink;
|
programs/oeis/278/A278481.asm | neoneye/loda | 22 | 22389 | ; A278481: Number of neighbors of the n-th term in a full isosceles triangle read by rows.
; 2,4,4,4,6,4,4,6,6,4,4,6,6,6,4,4,6,6,6,6,4,4,6,6,6,6,6,4,4,6,6,6,6,6,6,4,4,6,6,6,6,6,6,6,4,4,6,6,6,6,6,6,6,6,4,4,6,6,6,6,6,6,6,6,6,4,4,6,6,6,6,6,6,6,6,6,6,4,4,6,6,6,6,6,6,6,6,6,6,6,4
mov $1,$0
lpb $0
mov $0,2
lpe
seq $1,7318 ; Pascal's triangle read by rows: C(n,k) = binomial(n,k) = n!/(k!*(n-k)!), 0 <= k <= n.
lpb $0
mov $0,$1
lpe
mul $0,2
add $0,2
|
examples/outdated-and-incorrect/Termination/comb.agda | shlevy/agda | 1,989 | 13611 | module comb where
infixr 50 _⟶_
data Ty : Set where
ι : Ty
_⟶_ : Ty -> Ty -> Ty
data Tm : Ty -> Set where
K : {σ τ : Ty} -> Tm (σ ⟶ τ ⟶ σ)
S : {σ τ ρ : Ty} -> Tm ((σ ⟶ τ ⟶ ρ) ⟶ (σ ⟶ τ) ⟶ σ ⟶ ρ)
_$_ : {σ τ : Ty} -> Tm (σ ⟶ τ) -> Tm σ -> Tm τ
data Nf : Ty -> Set where
Kⁿ : {σ τ : Ty} -> Nf (σ ⟶ τ ⟶ σ)
Kⁿ¹ : {σ τ : Ty} -> Nf σ -> Nf (τ ⟶ σ)
Sⁿ : {σ τ ρ : Ty} -> Nf ((σ ⟶ τ ⟶ ρ) ⟶ (σ ⟶ τ) ⟶ σ ⟶ ρ)
Sⁿ¹ : {σ τ ρ : Ty} -> Nf (σ ⟶ τ ⟶ ρ) -> Nf ((σ ⟶ τ) ⟶ σ ⟶ ρ)
Sⁿ² : {σ τ ρ : Ty} -> Nf (σ ⟶ τ ⟶ ρ) -> Nf (σ ⟶ τ) -> Nf (σ ⟶ ρ)
_$$_ : {σ τ : Ty} -> Nf (σ ⟶ τ) -> Nf σ -> Nf τ
Kⁿ $$ x = Kⁿ¹ x
Kⁿ¹ x $$ y = x
Sⁿ $$ x = Sⁿ¹ x
Sⁿ¹ x $$ y = Sⁿ² x y
Sⁿ² x y $$ z = (x $$ z) $$ (y $$ z)
nf : {σ : Ty} -> Tm σ -> Nf σ
nf K = Kⁿ
nf S = Sⁿ
nf (t $ u) = nf t $$ nf u
data _$ⁿ_⇓_ : {σ τ : Ty} -> Nf (σ ⟶ τ) -> Nf σ -> Nf τ -> Set where
rKⁿ : {σ τ : Ty} -> {x : Nf σ} -> Kⁿ {σ} {τ} $ⁿ x ⇓ Kⁿ¹ x
rKⁿ¹ : {σ τ : Ty} -> {x : Nf σ} -> {y : Nf τ} -> Kⁿ¹ x $ⁿ y ⇓ x
rSⁿ : {σ τ ρ : Ty} -> {x : Nf (σ ⟶ τ ⟶ ρ)} -> Sⁿ $ⁿ x ⇓ Sⁿ¹ x
rSⁿ¹ : {σ τ ρ : Ty} -> {x : Nf (σ ⟶ τ ⟶ ρ)} -> {y : Nf (σ ⟶ τ)} ->
Sⁿ¹ x $ⁿ y ⇓ Sⁿ² x y
rSⁿ² : {σ τ ρ : Ty} -> {x : Nf (σ ⟶ τ ⟶ ρ)} -> {y : Nf (σ ⟶ τ)} ->
{z : Nf σ} -> {u : Nf (τ ⟶ ρ)} -> x $ⁿ z ⇓ u -> {v : Nf τ} ->
y $ⁿ z ⇓ v -> {w : Nf ρ} -> u $ⁿ v ⇓ w -> Sⁿ² x y $ⁿ z ⇓ w
data _⇓_ : {σ : Ty} -> Tm σ -> Nf σ -> Set where
rK : {σ τ : Ty} -> K {σ} {τ} ⇓ Kⁿ
rS : {σ τ ρ : Ty} -> S {σ} {τ} {ρ} ⇓ Sⁿ
r$ : {σ τ : Ty} -> {t : Tm (σ ⟶ τ)} -> {f : Nf (σ ⟶ τ)} -> t ⇓ f ->
{u : Tm σ} -> {a : Nf σ} -> u ⇓ a -> {v : Nf τ} -> f $ⁿ a ⇓ v ->
t $ u ⇓ v
data _==_ {A : Set}(a : A) : {B : Set} -> (b : B) -> Set where
refl : a == a
data Σ {A : Set}(B : A -> Set) : Set where
sig : (a : A) -> (b : B a) -> Σ B
σ₀ : {A : Set} -> {B : A -> Set} -> Σ B -> A
σ₀ (sig x _) = x
σ₁ : {A : Set} -> {B : A -> Set} -> (s : Σ B) -> B (σ₀ s)
σ₁ (sig _ y) = y
_$$⁼_&_ : {σ τ : Ty} -> (f : Nf (σ ⟶ τ)) -> (a : Nf σ) -> {n : Nf τ} ->
f $ⁿ a ⇓ n -> Σ \(n' : Nf τ) -> n' == n
Kⁿ $$⁼ x & rKⁿ = sig (Kⁿ¹ x) refl
Kⁿ¹ x $$⁼ y & rKⁿ¹ = sig x refl
Sⁿ $$⁼ x & rSⁿ = sig (Sⁿ¹ x) refl
Sⁿ¹ x $$⁼ y & rSⁿ¹ = sig (Sⁿ² x y) refl
Sⁿ² x y $$⁼ z & (rSⁿ² p q r) with x $$⁼ z & p | y $$⁼ z & q
Sⁿ² x y $$⁼ z & (rSⁿ² p q r) | sig u refl | sig v refl with u $$⁼ v & r
Sⁿ² x y $$⁼ z & (rSⁿ² p q r) | sig u refl | sig v refl | sig w refl =
sig w refl
nf⁼ : {σ : Ty} -> (t : Tm σ) -> {n : Nf σ} -> t ⇓ n ->
Σ \(n' : Nf σ) -> n' == n
nf⁼ K rK = sig Kⁿ refl
nf⁼ S rS = sig Sⁿ refl
nf⁼ (t $ u) (r$ p q r) with nf⁼ t p | nf⁼ u q
nf⁼ (t $ u) (r$ p q r) | sig f refl | sig a refl with f $$⁼ a & r
nf⁼ (t $ u) (r$ p q r) | sig f refl | sig a refl | sig v refl =
sig v refl
proof : {σ : Ty} -> (t : Tm σ) -> Σ \(n : Nf σ) -> t ⇓ n
proof = {! !}
nf⇓ : {σ : Ty} -> Tm σ -> Nf σ
nf⇓ t = σ₀ (nf⁼ t (σ₁ (proof t)))
|
src/main/antlr4/imports/Items.g4 | Yucukof/edu-antlr4-toy-parser-to-nbc | 0 | 316 | lexer grammar Items;
MAP: 'map'|'MAP';
RADAR: 'radar'|'RADAR';
RADIO: 'radio'|'RADIO';
FRUITS: 'fruits'|'FRUITS';
SODA: 'soda'|'SODA';
AMMO: 'ammo'|'AMMO';
GRAAL: 'graal'|'GRAAL';
DIRT: 'dirt'|'DIRT';
ROCK: 'rock'|'ROCK';
VINES: 'vines'|'VINES';
ZOMBIE: 'zombie'|'ZOMBIE';
PLAYER: 'player'|'PLAYER';
ENNEMI: 'ennemi'|'ENNEMI';
LIFE: 'life'|'LIFE';
LATITUDE: 'latitude'|'LATITUDE';
LONGITUDE: 'longitude'|'LONGITUDE';
GRID: 'grid'|'GRID';
SIZE: 'size'|'SIZE';
COUNT: 'count'|'COUNT'; |
oeis/028/A028004.asm | neoneye/loda-programs | 11 | 82457 | ; A028004: Expansion of 1/((1-2x)(1-6x)(1-11x)(1-12x)).
; Submitted by <NAME>
; 1,31,633,10787,166481,2416827,33681481,456072739,6046236801,78876961163,1016157547769,12960408919731,163959874019761,2060322716086939,25744836645629097,320169349603453763
mov $1,1
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,16309 ; Expansion of 1/((1-2*x)*(1-6*x)*(1-12*x)).
mul $1,11
add $1,$0
lpe
mov $0,$1
|
inst/scripts/list-master-slides.applescript | gaborcsardi/keynote | 27 | 3333 |
on run argv
set out to "["
tell document id (item 1 of argv) of application "Keynote"
set nms to name of every master slide
repeat with i from 1 to the count of nms
set rec to "{" & ¬
"\"name\": \"" & item i of nms & "\"" & ¬
"}"
if i > 1 then
set out to out & ", "
end if
set out to out & rec
end repeat
end tell
set out to out & "]"
out
end run
|
programs/oeis/005/A005183.asm | neoneye/loda | 22 | 16257 | ; A005183: a(n) = n*2^(n-1) + 1.
; 1,2,5,13,33,81,193,449,1025,2305,5121,11265,24577,53249,114689,245761,524289,1114113,2359297,4980737,10485761,22020097,46137345,96468993,201326593,419430401,872415233,1811939329,3758096385,7784628225,16106127361,33285996545,68719476737,141733920769,292057776129,601295421441,1236950581249,2542620639233,5222680231937,10720238370817,21990232555521,45079976738817,92358976733185,189115999977473,387028092977153,791648371998721,1618481116086273,3307330976350209,6755399441055745,13792273858822145,28147497671065601,57420895248973825,117093590311632897,238690780250636289,486388759756013569,990791918021509121,2017612633061982209,4107282860161892353,8358680908399640577,17005592192950992897,34587645138205409281,70328211781017665537,142962266571249025025,290536219160925437953,590295810358705651713,1199038364791120855041,2434970217729660813313,4943727411754159833089,10035028776097996079105,20365205457375344984065,41320706725109395619841,83822005070936202543105,170005193383307227693057,344732753249484100599809,698910239464707491627009,1416709944860893564108801,2871198821584744289927169,5817955506895402903273473,11787026741242634453385217,23876284937388926200446977,48357032784585166988247041,97922991388784963151200257,198263834416799184651812865,401363372112056886002450433,812398150781030805402550273,1644139114675895677600399361,3326963855579459488791396353,6731298963614255244763987969,13617340432139183023890366465,27544165874099711116505513985,55707301767842112370460590081,112652543574969605015820304385,227780967228509970581438857217,460513694614161462262474211329,930930909542605966724141416449,1881668859713778017846668820481,3802951800684688204490109616129,7685131763883640746573763182593,15528719852795810168334614265857,31374352355648677687043404333057
mov $1,2
pow $1,$0
mul $1,$0
div $1,2
add $1,1
mov $0,$1
|
Numeral/Finite/Conversions.agda | Lolirofle/stuff-in-agda | 6 | 1987 | module Numeral.Finite.Conversions where
import Lvl
open import Data using (Empty ; Unit ; <>)
open import Data.Boolean using (Bool ; 𝐹 ; 𝑇)
open import Data.Tuple using (_,_)
open import Logic.Propositional using (_↔_)
open import Numeral.Finite
open import Numeral.Natural
open import Syntax.Number
private variable ℓ : Lvl.Level
empty : 𝕟(0) ↔ Empty{ℓ}
empty = (\()) , (\())
unit : 𝕟(1) ↔ Unit{ℓ}
unit = (\{<> → 0}) , (\{𝟎 → <>})
bool : 𝕟(2) ↔ Bool
bool = (\{𝐹 → 0 ; 𝑇 → 1}) , (\{𝟎 → 𝐹 ; (𝐒(𝟎)) → 𝑇})
|
Cubical/Data/Int/Properties.agda | ecavallo/cubical | 0 | 4204 | <reponame>ecavallo/cubical
{-# OPTIONS --safe #-}
module Cubical.Data.Int.Properties where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Transport
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Data.Empty
open import Cubical.Data.Nat
hiding (+-assoc ; +-comm ; ·-comm)
renaming (_·_ to _·ℕ_; _+_ to _+ℕ_ ; ·-assoc to ·ℕ-assoc)
open import Cubical.Data.Bool
open import Cubical.Data.Sum
open import Cubical.Data.Int.Base
open import Cubical.Relation.Nullary
open import Cubical.Relation.Nullary.DecidableEq
sucPred : ∀ i → sucℤ (predℤ i) ≡ i
sucPred (pos zero) = refl
sucPred (pos (suc n)) = refl
sucPred (negsuc n) = refl
predSuc : ∀ i → predℤ (sucℤ i) ≡ i
predSuc (pos n) = refl
predSuc (negsuc zero) = refl
predSuc (negsuc (suc n)) = refl
injPos : ∀ {a b : ℕ} → pos a ≡ pos b → a ≡ b
injPos {a} h = subst T h refl
where
T : ℤ → Type₀
T (pos x) = a ≡ x
T (negsuc _) = ⊥
injNegsuc : ∀ {a b : ℕ} → negsuc a ≡ negsuc b → a ≡ b
injNegsuc {a} h = subst T h refl
where
T : ℤ → Type₀
T (pos _) = ⊥
T (negsuc x) = a ≡ x
posNotnegsuc : ∀ (a b : ℕ) → ¬ (pos a ≡ negsuc b)
posNotnegsuc a b h = subst T h 0
where
T : ℤ → Type₀
T (pos _) = ℕ
T (negsuc _) = ⊥
negsucNotpos : ∀ (a b : ℕ) → ¬ (negsuc a ≡ pos b)
negsucNotpos a b h = subst T h 0
where
T : ℤ → Type₀
T (pos _) = ⊥
T (negsuc _) = ℕ
discreteℤ : Discrete ℤ
discreteℤ (pos n) (pos m) with discreteℕ n m
... | yes p = yes (cong pos p)
... | no p = no (λ x → p (injPos x))
discreteℤ (pos n) (negsuc m) = no (posNotnegsuc n m)
discreteℤ (negsuc n) (pos m) = no (negsucNotpos n m)
discreteℤ (negsuc n) (negsuc m) with discreteℕ n m
... | yes p = yes (cong negsuc p)
... | no p = no (λ x → p (injNegsuc x))
isSetℤ : isSet ℤ
isSetℤ = Discrete→isSet discreteℤ
-pos : ∀ n → - (pos n) ≡ neg n
-pos zero = refl
-pos (suc n) = refl
-neg : ∀ n → - (neg n) ≡ pos n
-neg zero = refl
-neg (suc n) = refl
-Involutive : ∀ z → - (- z) ≡ z
-Involutive (pos n) = cong -_ (-pos n) ∙ -neg n
-Involutive (negsuc n) = refl
sucℤ+pos : ∀ n m → sucℤ (m +pos n) ≡ (sucℤ m) +pos n
sucℤ+pos zero m = refl
sucℤ+pos (suc n) m = cong sucℤ (sucℤ+pos n m)
predℤ+negsuc : ∀ n m → predℤ (m +negsuc n) ≡ (predℤ m) +negsuc n
predℤ+negsuc zero m = refl
predℤ+negsuc (suc n) m = cong predℤ (predℤ+negsuc n m)
sucℤ+negsuc : ∀ n m → sucℤ (m +negsuc n) ≡ (sucℤ m) +negsuc n
sucℤ+negsuc zero m = (sucPred _) ∙ (sym (predSuc _))
sucℤ+negsuc (suc n) m = _ ≡⟨ sucPred _ ⟩
m +negsuc n ≡[ i ]⟨ predSuc m (~ i) +negsuc n ⟩
(predℤ (sucℤ m)) +negsuc n ≡⟨ sym (predℤ+negsuc n (sucℤ m)) ⟩
predℤ (sucℤ m +negsuc n) ∎
predℤ+pos : ∀ n m → predℤ (m +pos n) ≡ (predℤ m) +pos n
predℤ+pos zero m = refl
predℤ+pos (suc n) m = _ ≡⟨ predSuc _ ⟩
m +pos n ≡[ i ]⟨ sucPred m (~ i) + pos n ⟩
(sucℤ (predℤ m)) +pos n ≡⟨ sym (sucℤ+pos n (predℤ m))⟩
(predℤ m) +pos (suc n) ∎
predℤ-pos : ∀ n → predℤ(- (pos n)) ≡ negsuc n
predℤ-pos zero = refl
predℤ-pos (suc n) = refl
predℤ+ : ∀ m n → predℤ (m + n) ≡ (predℤ m) + n
predℤ+ m (pos n) = predℤ+pos n m
predℤ+ m (negsuc n) = predℤ+negsuc n m
+predℤ : ∀ m n → predℤ (m + n) ≡ m + (predℤ n)
+predℤ m (pos zero) = refl
+predℤ m (pos (suc n)) = (predSuc (m + pos n)) ∙ (cong (_+_ m) (sym (predSuc (pos n))))
+predℤ m (negsuc n) = refl
sucℤ+ : ∀ m n → sucℤ (m + n) ≡ (sucℤ m) + n
sucℤ+ m (pos n) = sucℤ+pos n m
sucℤ+ m (negsuc n) = sucℤ+negsuc n m
+sucℤ : ∀ m n → sucℤ (m + n) ≡ m + (sucℤ n)
+sucℤ m (pos n) = refl
+sucℤ m (negsuc zero) = sucPred _
+sucℤ m (negsuc (suc n)) = (sucPred (m +negsuc n)) ∙ (cong (_+_ m) (sym (sucPred (negsuc n))))
pos0+ : ∀ z → z ≡ pos 0 + z
pos0+ (pos zero) = refl
pos0+ (pos (suc n)) = cong sucℤ (pos0+ (pos n))
pos0+ (negsuc zero) = refl
pos0+ (negsuc (suc n)) = cong predℤ (pos0+ (negsuc n))
negsuc0+ : ∀ z → predℤ z ≡ negsuc 0 + z
negsuc0+ (pos zero) = refl
negsuc0+ (pos (suc n)) = (sym (sucPred (pos n))) ∙ (cong sucℤ (negsuc0+ _))
negsuc0+ (negsuc zero) = refl
negsuc0+ (negsuc (suc n)) = cong predℤ (negsuc0+ (negsuc n))
ind-comm : {A : Type₀} (_∙_ : A → A → A) (f : ℕ → A) (g : A → A)
(p : ∀ {n} → f (suc n) ≡ g (f n))
(g∙ : ∀ a b → g (a ∙ b) ≡ g a ∙ b)
(∙g : ∀ a b → g (a ∙ b) ≡ a ∙ g b)
(base : ∀ z → z ∙ f 0 ≡ f 0 ∙ z)
→ ∀ z n → z ∙ f n ≡ f n ∙ z
ind-comm _∙_ f g p g∙ ∙g base z 0 = base z
ind-comm _∙_ f g p g∙ ∙g base z (suc n) =
z ∙ f (suc n) ≡[ i ]⟨ z ∙ p {n} i ⟩
z ∙ g (f n) ≡⟨ sym ( ∙g z (f n)) ⟩
g (z ∙ f n) ≡⟨ cong g IH ⟩
g (f n ∙ z) ≡⟨ g∙ (f n) z ⟩
g (f n) ∙ z ≡[ i ]⟨ p {n} (~ i) ∙ z ⟩
f (suc n) ∙ z ∎
where
IH = ind-comm _∙_ f g p g∙ ∙g base z n
ind-assoc : {A : Type₀} (_·_ : A → A → A) (f : ℕ → A)
(g : A → A) (p : ∀ a b → g (a · b) ≡ a · (g b))
(q : ∀ {c} → f (suc c) ≡ g (f c))
(base : ∀ m n → (m · n) · (f 0) ≡ m · (n · (f 0)))
(m n : A) (o : ℕ)
→ m · (n · (f o)) ≡ (m · n) · (f o)
ind-assoc _·_ f g p q base m n 0 = sym (base m n)
ind-assoc _·_ f g p q base m n (suc o) =
m · (n · (f (suc o))) ≡[ i ]⟨ m · (n · q {o} i) ⟩
m · (n · (g (f o))) ≡[ i ]⟨ m · (p n (f o) (~ i)) ⟩
m · (g (n · (f o))) ≡⟨ sym (p m (n · (f o)))⟩
g (m · (n · (f o))) ≡⟨ cong g IH ⟩
g ((m · n) · (f o)) ≡⟨ p (m · n) (f o) ⟩
(m · n) · (g (f o)) ≡[ i ]⟨ (m · n) · q {o} (~ i) ⟩
(m · n) · (f (suc o)) ∎
where
IH = ind-assoc _·_ f g p q base m n o
+Comm : ∀ m n → m + n ≡ n + m
+Comm m (pos n) = ind-comm _+_ pos sucℤ refl sucℤ+ +sucℤ pos0+ m n
+Comm m (negsuc n) = ind-comm _+_ negsuc predℤ refl predℤ+ +predℤ negsuc0+ m n
+Assoc : ∀ m n o → m + (n + o) ≡ (m + n) + o
+Assoc m n (pos o) = ind-assoc _+_ pos sucℤ +sucℤ refl (λ _ _ → refl) m n o
+Assoc m n (negsuc o) = ind-assoc _+_ negsuc predℤ +predℤ refl +predℤ m n o
-- Compose sucPathℤ with itself n times. Transporting along this
-- will be addition, transporting with it backwards will be subtraction.
-- Use this to define _+'_ for which is easier to prove
-- isEquiv (λ n → n +' m) since _+'_ is defined by transport
sucPathℤ : ℤ ≡ ℤ
sucPathℤ = ua (sucℤ , isoToIsEquiv (iso sucℤ predℤ sucPred predSuc))
addEq : ℕ → ℤ ≡ ℤ
addEq zero = refl
addEq (suc n) = (addEq n) ∙ sucPathℤ
predPathℤ : ℤ ≡ ℤ
predPathℤ = ua (predℤ , isoToIsEquiv (iso predℤ sucℤ predSuc sucPred))
subEq : ℕ → ℤ ≡ ℤ
subEq zero = refl
subEq (suc n) = (subEq n) ∙ predPathℤ
_+'_ : ℤ → ℤ → ℤ
m +' pos n = transport (addEq n) m
m +' negsuc n = transport (subEq (suc n)) m
+'≡+ : _+'_ ≡ _+_
+'≡+ i m (pos zero) = m
+'≡+ i m (pos (suc n)) = sucℤ (+'≡+ i m (pos n))
+'≡+ i m (negsuc zero) = predℤ m
+'≡+ i m (negsuc (suc n)) = predℤ (+'≡+ i m (negsuc n)) --
-- compPath (λ i → (+'≡+ i (predℤ m) (negsuc n))) (sym (predℤ+negsuc n m)) i
isEquivAddℤ' : (m : ℤ) → isEquiv (λ n → n +' m)
isEquivAddℤ' (pos n) = isEquivTransport (addEq n)
isEquivAddℤ' (negsuc n) = isEquivTransport (subEq (suc n))
isEquivAddℤ : (m : ℤ) → isEquiv (λ n → n + m)
isEquivAddℤ = subst (λ add → (m : ℤ) → isEquiv (λ n → add n m)) +'≡+ isEquivAddℤ'
-- below is an alternate proof of isEquivAddℤ for comparison
-- We also have two useful lemma here.
minusPlus : ∀ m n → (n - m) + m ≡ n
minusPlus (pos zero) n = refl
minusPlus (pos 1) = sucPred
minusPlus (pos (suc (suc m))) n =
sucℤ ((n +negsuc (suc m)) +pos (suc m)) ≡⟨ sucℤ+pos (suc m) _ ⟩
sucℤ (n +negsuc (suc m)) +pos (suc m) ≡[ i ]⟨ sucPred (n +negsuc m) i +pos (suc m) ⟩
(n - pos (suc m)) +pos (suc m) ≡⟨ minusPlus (pos (suc m)) n ⟩
n ∎
minusPlus (negsuc zero) = predSuc
minusPlus (negsuc (suc m)) n =
predℤ (sucℤ (sucℤ (n +pos m)) +negsuc m) ≡⟨ predℤ+negsuc m _ ⟩
predℤ (sucℤ (sucℤ (n +pos m))) +negsuc m ≡[ i ]⟨ predSuc (sucℤ (n +pos m)) i +negsuc m ⟩
sucℤ (n +pos m) +negsuc m ≡⟨ minusPlus (negsuc m) n ⟩
n ∎
plusMinus : ∀ m n → (n + m) - m ≡ n
plusMinus (pos zero) n = refl
plusMinus (pos (suc m)) = minusPlus (negsuc m)
plusMinus (negsuc m) = minusPlus (pos (suc m))
private
alternateProof : (m : ℤ) → isEquiv (λ n → n + m)
alternateProof m = isoToIsEquiv (iso (λ n → n + m)
(λ n → n - m)
(minusPlus m)
(plusMinus m))
-Cancel : ∀ z → z - z ≡ 0
-Cancel z = cong (_- z) (pos0+ z) ∙ plusMinus z (pos zero)
pos+ : ∀ m n → pos (m +ℕ n) ≡ pos m + pos n
pos+ zero zero = refl
pos+ zero (suc n) =
pos (zero +ℕ suc n) ≡⟨ +Comm (pos (suc n)) (pos zero) ⟩
pos zero + pos (suc n) ∎
pos+ (suc m) zero =
pos (suc (m +ℕ zero)) ≡⟨ cong pos (cong suc (+-zero m)) ⟩
pos (suc m) + pos zero ∎
pos+ (suc m) (suc n) =
pos (suc m +ℕ suc n) ≡⟨ cong pos (cong suc (+-suc m n)) ⟩
sucℤ (pos (suc (m +ℕ n))) ≡⟨ cong sucℤ (cong sucℤ (pos+ m n)) ⟩
sucℤ (sucℤ (pos m + pos n)) ≡⟨ sucℤ+ (pos m) (sucℤ (pos n)) ⟩
pos (suc m) + pos (suc n) ∎
negsuc+ : ∀ m n → negsuc (m +ℕ n) ≡ negsuc m - pos n
negsuc+ zero zero = refl
negsuc+ zero (suc n) =
negsuc (zero +ℕ suc n) ≡⟨ negsuc0+ (negsuc n) ⟩
negsuc zero + negsuc n ≡⟨ cong (negsuc zero +_) (-pos (suc n)) ⟩
negsuc zero - pos (suc n) ∎
negsuc+ (suc m) zero =
negsuc (suc m +ℕ zero) ≡⟨ cong negsuc (cong suc (+-zero m)) ⟩
negsuc (suc m) - pos zero ∎
negsuc+ (suc m) (suc n) =
negsuc (suc m +ℕ suc n) ≡⟨ cong negsuc (sym (+-suc m (suc n))) ⟩
negsuc (m +ℕ suc (suc n)) ≡⟨ negsuc+ m (suc (suc n)) ⟩
negsuc m - pos (suc (suc n)) ≡⟨ sym (+predℤ (negsuc m) (negsuc n)) ⟩
predℤ (negsuc m + negsuc n ) ≡⟨ predℤ+ (negsuc m) (negsuc n) ⟩
negsuc (suc m) - pos (suc n) ∎
neg+ : ∀ m n → neg (m +ℕ n) ≡ neg m + neg n
neg+ zero zero = refl
neg+ zero (suc n) = neg (zero +ℕ suc n) ≡⟨ +Comm (neg (suc n)) (pos zero) ⟩
neg zero + neg (suc n) ∎
neg+ (suc m) zero = neg (suc (m +ℕ zero)) ≡⟨ cong neg (cong suc (+-zero m)) ⟩
neg (suc m) + neg zero ∎
neg+ (suc m) (suc n) = neg (suc m +ℕ suc n) ≡⟨ negsuc+ m (suc n) ⟩
neg (suc m) + neg (suc n) ∎
ℕ-AntiComm : ∀ m n → m ℕ- n ≡ - (n ℕ- m)
ℕ-AntiComm zero zero = refl
ℕ-AntiComm zero (suc n) = refl
ℕ-AntiComm (suc m) zero = refl
ℕ-AntiComm (suc m) (suc n) = suc m ℕ- suc n ≡⟨ ℕ-AntiComm m n ⟩
- (suc n ℕ- suc m) ∎
pos- : ∀ m n → m ℕ- n ≡ pos m - pos n
pos- zero zero = refl
pos- zero (suc n) = zero ℕ- suc n ≡⟨ +Comm (negsuc n) (pos zero) ⟩
pos zero - pos (suc n) ∎
pos- (suc m) zero = refl
pos- (suc m) (suc n) =
suc m ℕ- suc n ≡⟨ pos- m n ⟩
pos m - pos n ≡⟨ sym (sucPred (pos m - pos n)) ⟩
sucℤ (predℤ (pos m - pos n)) ≡⟨ cong sucℤ (+predℤ (pos m) (- pos n)) ⟩
sucℤ (pos m + predℤ (- (pos n))) ≡⟨ cong sucℤ (cong (pos m +_) (predℤ-pos n)) ⟩
sucℤ (pos m + negsuc n) ≡⟨ sucℤ+negsuc n (pos m) ⟩
pos (suc m) - pos (suc n) ∎
-AntiComm : ∀ m n → m - n ≡ - (n - m)
-AntiComm (pos n) (pos m) = pos n - pos m ≡⟨ sym (pos- n m) ⟩
n ℕ- m ≡⟨ ℕ-AntiComm n m ⟩
- (m ℕ- n) ≡⟨ cong -_ (pos- m n) ⟩
- (pos m - pos n) ∎
-AntiComm (pos n) (negsuc m) =
pos n - negsuc m ≡⟨ +Comm (pos n) (pos (suc m)) ⟩
pos (suc m) + pos n ≡⟨ sym (pos+ (suc m) n) ⟩
pos (suc m +ℕ n) ≡⟨ sym (-neg (suc m +ℕ n)) ⟩
- neg (suc m +ℕ n) ≡⟨ cong -_ (neg+ (suc m) n) ⟩
- (neg (suc m) + neg n) ≡⟨ cong -_ (cong (negsuc m +_) (sym (-pos n))) ⟩
- (negsuc m - pos n) ∎
-AntiComm (negsuc n) (pos m) =
negsuc n - pos m ≡⟨ sym (negsuc+ n m) ⟩
negsuc (n +ℕ m) ≡⟨ cong -_ (pos+ (suc n) m) ⟩
- (pos (suc n) + pos m) ≡⟨ cong -_ (+Comm (pos (suc n)) (pos m)) ⟩
- (pos m - negsuc n) ∎
-AntiComm (negsuc n) (negsuc m) =
negsuc n - negsuc m ≡⟨ +Comm (negsuc n) (pos (suc m)) ⟩
pos (suc m) + negsuc n ≡⟨ sym (pos- (suc m) (suc n)) ⟩
suc m ℕ- suc n ≡⟨ ℕ-AntiComm (suc m) (suc n) ⟩
- (suc n ℕ- suc m) ≡⟨ cong -_ (pos- (suc n) (suc m)) ⟩
- (pos (suc n) - pos (suc m)) ≡⟨ cong -_ (+Comm (pos (suc n)) (negsuc m)) ⟩
- (negsuc m - negsuc n) ∎
-Dist+ : ∀ m n → - (m + n) ≡ (- m) + (- n)
-Dist+ (pos n) (pos m) =
- (pos n + pos m) ≡⟨ cong -_ (sym (pos+ n m)) ⟩
- pos (n +ℕ m) ≡⟨ -pos (n +ℕ m) ⟩
neg (n +ℕ m) ≡⟨ neg+ n m ⟩
neg n + neg m ≡⟨ cong (neg n +_) (sym (-pos m)) ⟩
neg n + (- pos m) ≡⟨ cong (_+ (- pos m)) (sym (-pos n)) ⟩
(- pos n) + (- pos m) ∎
-Dist+ (pos n) (negsuc m) =
- (pos n + negsuc m) ≡⟨ sym (-AntiComm (pos (suc m)) (pos n)) ⟩
pos (suc m) - pos n ≡⟨ +Comm (pos (suc m)) (- pos n) ⟩
(- pos n) + (- negsuc m) ∎
-Dist+ (negsuc n) (pos m) =
- (negsuc n + pos m) ≡⟨ cong -_ (+Comm (negsuc n) (pos m)) ⟩
- (pos m + negsuc n) ≡⟨ sym (-AntiComm (- negsuc n) (pos m)) ⟩
(- negsuc n) + (- pos m) ∎
-Dist+ (negsuc n) (negsuc m) =
- (negsuc n + negsuc m) ≡⟨ cong -_ (sym (neg+ (suc n) (suc m))) ⟩
- neg (suc n +ℕ suc m) ≡⟨ pos+ (suc n) (suc m) ⟩
(- negsuc n) + (- negsuc m) ∎
-- multiplication
pos·negsuc : (n m : ℕ) → pos n · negsuc m ≡ - (pos n · pos (suc m))
pos·negsuc zero m = refl
pos·negsuc (suc n) m =
(λ i → negsuc m + (pos·negsuc n m i))
∙ sym (-Dist+ (pos (suc m)) (pos n · pos (suc m)))
negsuc·pos : (n m : ℕ) → negsuc n · pos m ≡ - (pos (suc n) · pos m)
negsuc·pos zero m = refl
negsuc·pos (suc n) m =
cong ((- pos m) +_) (negsuc·pos n m)
∙ sym (-Dist+ (pos m) (pos m + (pos n · pos m)))
negsuc·negsuc : (n m : ℕ) → negsuc n · negsuc m ≡ pos (suc n) · pos (suc m)
negsuc·negsuc zero m = refl
negsuc·negsuc (suc n) m = cong (pos (suc m) +_) (negsuc·negsuc n m)
·Comm : (x y : ℤ) → x · y ≡ y · x
·Comm (pos n) (pos m) = lem n m
where
lem : (n m : ℕ) → (pos n · pos m) ≡ (pos m · pos n)
lem zero zero = refl
lem zero (suc m) i = +Comm (lem zero m i) (pos zero) i
lem (suc n) zero i = +Comm (pos zero) (lem n zero i) i
lem (suc n) (suc m) =
(λ i → pos (suc m) + (lem n (suc m) i))
∙∙ +Assoc (pos (suc m)) (pos n) (pos m · pos n)
∙∙ (λ i → sucℤ+ (pos m) (pos n) (~ i) + (pos m · pos n))
∙∙ (λ i → +Comm (pos m) (pos (suc n)) i + (pos m · pos n))
∙∙ sym (+Assoc (pos (suc n)) (pos m) (pos m · pos n))
∙∙ (λ i → pos (suc n) + (pos m + (lem n m (~ i))))
∙∙ λ i → pos (suc n) + (lem (suc n) m i)
·Comm (pos n) (negsuc m) =
pos·negsuc n m
∙∙ cong -_ (·Comm (pos n) (pos (suc m)))
∙∙ sym (negsuc·pos m n)
·Comm (negsuc n) (pos m) =
sym (pos·negsuc m n
∙∙ cong -_ (·Comm (pos m) (pos (suc n)))
∙∙ sym (negsuc·pos n m))
·Comm (negsuc n) (negsuc m) =
negsuc·negsuc n m ∙∙ ·Comm (pos (suc n)) (pos (suc m)) ∙∙ sym (negsuc·negsuc m n)
·Rid : (x : ℤ) → x · 1 ≡ x
·Rid x = ·Comm x 1
private
distrHelper : (x y z w : ℤ) → (x + y) + (z + w) ≡ ((x + z) + (y + w))
distrHelper x y z w =
+Assoc (x + y) z w
∙∙ cong (_+ w) (sym (+Assoc x y z) ∙∙ cong (x +_) (+Comm y z) ∙∙ +Assoc x z y)
∙∙ sym (+Assoc (x + z) y w)
·DistR+ : (x y z : ℤ) → x · (y + z) ≡ x · y + x · z
·DistR+ (pos zero) y z = refl
·DistR+ (pos (suc n)) y z =
cong ((y + z) +_) (·DistR+ (pos n) y z)
∙ distrHelper y z (pos n · y) (pos n · z)
·DistR+ (negsuc zero) y z = -Dist+ y z
·DistR+ (negsuc (suc n)) y z =
cong₂ _+_ (-Dist+ y z) (·DistR+ (negsuc n) y z)
∙ distrHelper (- y) (- z) (negsuc n · y) (negsuc n · z)
·DistL+ : (x y z : ℤ) → (x + y) · z ≡ x · z + y · z
·DistL+ x y z = ·Comm (x + y) z ∙∙ ·DistR+ z x y ∙∙ cong₂ _+_ (·Comm z x) (·Comm z y)
-DistL· : (b c : ℤ) → - (b · c) ≡ - b · c
-DistL· (pos zero) c = refl
-DistL· (pos (suc n)) (pos m) = sym (negsuc·pos n m)
-DistL· (pos (suc zero)) (negsuc m) =
-Dist+ (negsuc m) (pos zero · negsuc m)
∙ cong (pos (suc m) +_) (-DistL· (pos zero) (negsuc m))
-DistL· (pos (suc (suc n))) (negsuc m) =
-Dist+ (negsuc m) (pos (suc n) · negsuc m)
∙ cong (pos (suc m) +_) (-DistL· (pos (suc n)) (negsuc m))
-DistL· (negsuc zero) c = -Involutive c
-DistL· (negsuc (suc n)) c =
-Dist+ (- c) (negsuc n · c)
∙∙ cong (_+ (- (negsuc n · c))) (-Involutive c)
∙∙ cong (c +_) (-DistL· (negsuc n) c)
-DistR· : (b c : ℤ) → - (b · c) ≡ b · - c
-DistR· b c = cong (-_) (·Comm b c) ∙∙ -DistL· c b ∙∙ ·Comm (- c) b
·Assoc : (a b c : ℤ) → (a · (b · c)) ≡ ((a · b) · c)
·Assoc (pos zero) b c = refl
·Assoc (pos (suc n)) b c =
cong ((b · c) +_) (·Assoc (pos n) b c)
∙∙ cong₂ _+_ (·Comm b c) (·Comm (pos n · b) c)
∙∙ sym (·DistR+ c b (pos n · b))
∙ sym (·Comm _ c)
·Assoc (negsuc zero) = -DistL·
·Assoc (negsuc (suc n)) b c =
cong ((- (b · c)) +_) (·Assoc (negsuc n) b c)
∙∙ cong (_+ ((negsuc n · b) · c)) (-DistL· b c)
∙∙ sym (·DistL+ (- b) (negsuc n · b) c)
minus≡0- : (x : ℤ) → - x ≡ (0 - x)
minus≡0- x = +Comm (- x) 0
-- Absolute values
abs→⊎ : (x : ℤ) (n : ℕ) → abs x ≡ n → (x ≡ pos n) ⊎ (x ≡ - pos n)
abs→⊎ x n = J (λ n _ → (x ≡ pos n) ⊎ (x ≡ - pos n)) (help x)
where
help : (x : ℤ) → (x ≡ pos (abs x)) ⊎ (x ≡ - pos (abs x))
help (pos n) = inl refl
help (negsuc n) = inr refl
⊎→abs : (x : ℤ) (n : ℕ) → (x ≡ pos n) ⊎ (x ≡ - pos n) → abs x ≡ n
⊎→abs (pos n₁) n (inl x₁) = cong abs x₁
⊎→abs (negsuc n₁) n (inl x₁) = cong abs x₁
⊎→abs x zero (inr x₁) = cong abs x₁
⊎→abs x (suc n) (inr x₁) = cong abs x₁
|
src/ado-sessions-factory.ads | Letractively/ada-ado | 0 | 5371 | -----------------------------------------------------------------------
-- factory -- Session Factory
-- Copyright (C) 2009, 2010, 2011, 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 ADO.Databases;
with ADO.Schemas.Entities;
with ADO.Sequences;
-- The <b>ADO.Sessions.Factory</b> package defines the factory for creating
-- sessions.
package ADO.Sessions.Factory is
pragma Elaborate_Body;
-- ------------------------------
-- Session factory
-- ------------------------------
type Session_Factory is tagged limited private;
type Session_Factory_Access is access all Session_Factory'Class;
-- Get a read-only session from the factory.
function Get_Session (Factory : in Session_Factory) return Session;
-- Get a read-write session from the factory.
function Get_Master_Session (Factory : in Session_Factory) return Master_Session;
-- Open a session
procedure Open_Session (Factory : in out Session_Factory;
Database : out Session);
-- Open a session
procedure Open_Session (Factory : in Session_Factory;
Database : out Master_Session);
-- Create the session factory to connect to the database represented
-- by the data source.
procedure Create (Factory : out Session_Factory;
Source : in ADO.Databases.DataSource);
-- Create the session factory to connect to the database identified
-- by the URI.
procedure Create (Factory : out Session_Factory;
URI : in String);
-- Get a read-only session from the session proxy.
-- If the session has been invalidated, raise the SESSION_EXPIRED exception.
function Get_Session (Proxy : in Session_Record_Access) return Session;
private
-- The session factory holds the necessary information to obtain a master or slave
-- database connection. The sequence factory is shared by all sessions of the same
-- factory (implementation is thread-safe). The factory also contains the entity type
-- cache which is initialized when the factory is created.
type Session_Factory is tagged limited record
Source : ADO.Databases.DataSource;
Sequences : Factory_Access := null;
Seq_Factory : aliased ADO.Sequences.Factory;
Entity_Cache : aliased ADO.Schemas.Entities.Entity_Cache;
Entities : ADO.Sessions.Entity_Cache_Access := null;
end record;
-- Initialize the sequence factory associated with the session factory.
procedure Initialize_Sequences (Factory : in out Session_Factory);
end ADO.Sessions.Factory;
|
src/security-oauth-clients.ads | Letractively/ada-security | 0 | 22322 | -----------------------------------------------------------------------
-- security-oauth -- OAuth Security
-- Copyright (C) 2012, 2013 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
-- The <b>Security.OAuth.Clients</b> package implements the client OAuth 2.0 authorization.
--
-- Note: OAuth 1.0 could be implemented but since it's being deprecated it's not worth doing it.
package Security.OAuth.Clients is
-- ------------------------------
-- Access Token
-- ------------------------------
-- Access tokens are credentials used to access protected resources.
-- The access token is represented as a <b>Principal</b>. This is an opaque
-- value for an application.
type Access_Token (Len : Natural) is new Security.Principal with private;
type Access_Token_Access is access all Access_Token'Class;
-- Get the principal name. This is the OAuth access token.
function Get_Name (From : in Access_Token) return String;
type OpenID_Token (Len, Id_Len, Refresh_Len : Natural) is new Access_Token with private;
type OpenID_Token_Access is access all OpenID_Token'Class;
-- Get the id_token that was returned by the authentication process.
function Get_Id_Token (From : in OpenID_Token) return String;
-- Generate a random nonce with at last the number of random bits.
-- The number of bits is rounded up to a multiple of 32.
-- The random bits are then converted to base64url in the returned string.
function Create_Nonce (Bits : in Positive := 256) return String;
-- ------------------------------
-- Application
-- ------------------------------
-- The <b>Application</b> holds the necessary information to let a user
-- grant access to its protected resources on the resource server. It contains
-- information that allows the OAuth authorization server to identify the
-- application (client id and secret key).
type Application is tagged private;
-- Get the application identifier.
function Get_Application_Identifier (App : in Application) return String;
-- Set the application identifier used by the OAuth authorization server
-- to identify the application (for example, the App ID in Facebook).
procedure Set_Application_Identifier (App : in out Application;
Client : in String);
-- Set the application secret defined in the OAuth authorization server
-- for the application (for example, the App Secret in Facebook).
procedure Set_Application_Secret (App : in out Application;
Secret : in String);
-- Set the redirection callback that will be used to redirect the user
-- back to the application after the OAuth authorization is finished.
procedure Set_Application_Callback (App : in out Application;
URI : in String);
-- Set the OAuth authorization server URI that the application must use
-- to exchange the OAuth code into an access token.
procedure Set_Provider_URI (App : in out Application;
URI : in String);
-- OAuth 2.0 Section 4.1.1 Authorization Request
-- Build a unique opaque value used to prevent cross-site request forgery.
-- The <b>Nonce</b> parameters is an optional but recommended unique value
-- used only once. The state value will be returned back by the OAuth provider.
-- This protects the <tt>client_id</tt> and <tt>redirect_uri</tt> parameters.
function Get_State (App : in Application;
Nonce : in String) return String;
-- Get the authenticate parameters to build the URI to redirect the user to
-- the OAuth authorization form.
function Get_Auth_Params (App : in Application;
State : in String;
Scope : in String := "") return String;
-- OAuth 2.0 Section 4.1.2 Authorization Response
-- Verify that the <b>State</b> opaque value was created by the <b>Get_State</b>
-- operation with the given client and redirect URL.
function Is_Valid_State (App : in Application;
Nonce : in String;
State : in String) return Boolean;
-- OAuth 2.0 Section 4.1.3. Access Token Request
-- Section 4.1.4. Access Token Response
-- Exchange the OAuth code into an access token.
function Request_Access_Token (App : in Application;
Code : in String) return Access_Token_Access;
-- Create the access token
function Create_Access_Token (App : in Application;
Token : in String;
Refresh : in String;
Id_Token : in String;
Expires : in Natural) return Access_Token_Access;
private
type Access_Token (Len : Natural) is new Security.Principal with record
Access_Id : String (1 .. Len);
end record;
type OpenID_Token (Len, Id_Len, Refresh_Len : Natural) is new Access_Token (Len) with record
Id_Token : String (1 .. Id_Len);
Refresh_Token : String (1 .. Refresh_Len);
end record;
type Application is tagged record
Client_Id : Ada.Strings.Unbounded.Unbounded_String;
Secret : Ada.Strings.Unbounded.Unbounded_String;
Callback : Ada.Strings.Unbounded.Unbounded_String;
Request_URI : Ada.Strings.Unbounded.Unbounded_String;
Protect : Ada.Strings.Unbounded.Unbounded_String;
Key : Ada.Strings.Unbounded.Unbounded_String;
end record;
end Security.OAuth.Clients;
|
src/rand.asm | howprice/specnext-invaders | 17 | 12802 |
;
; Ion pseudo random number generator
; 123 T-states
; A <- random number in range [0,255]
; Modifies: AF
;
; See https://wikiti.brandonw.net/index.php?title=Z80_Routines:Math:Random#Ion_Random
;
; TODO: Optimise this by pre-calulating a 256 array of random numbers and just iterating through
CalcRandomByte: ; call 17 T-states
push hl ; 11
push de ; 11
ld hl,(randomSeed) ; 16
ld a,r ; 9
ld d,a ; 4
ld e,(hl) ; 7
add hl,de ; 11
add a,l ; 4
xor h ; 4
ld (randomSeed),hl ; 16
pop de ; 10
pop hl ; 10
ret ; 10
; Total: 123 T-states
randomSeed DB $9f
|
test/succeed/Test1.agda | UlrikBuchholtz/HoTT-Agda | 1 | 1012 | <filename>test/succeed/Test1.agda
{-# OPTIONS --without-K #-}
open import lib.Base
module test.succeed.Test1 where
module _ where
private
data #I : Type₀ where
#zero : #I
#one : #I
I : Type₀
I = #I
zero : I
zero = #zero
one : I
one = #one
postulate
seg : zero == one
absurd : zero ≠ one
absurd ()
|
Parametric/Change/Correctness.agda | inc-lc/ilc-agda | 10 | 6509 | ------------------------------------------------------------------------
-- INCREMENTAL λ-CALCULUS
--
-- Correctness of differentiation (Lemma 3.10 and Theorem 3.11).
------------------------------------------------------------------------
import Parametric.Syntax.Type as Type
import Parametric.Syntax.Term as Term
import Parametric.Denotation.Value as Value
import Parametric.Denotation.Evaluation as Evaluation
import Parametric.Change.Validity as Validity
import Parametric.Change.Specification as Specification
import Parametric.Change.Type as ChangeType
import Parametric.Change.Term as ChangeTerm
import Parametric.Change.Value as ChangeValue
import Parametric.Change.Evaluation as ChangeEvaluation
import Parametric.Change.Derive as Derive
import Parametric.Change.Implementation as Implementation
module Parametric.Change.Correctness
{Base : Type.Structure}
(Const : Term.Structure Base)
(⟦_⟧Base : Value.Structure Base)
(⟦_⟧Const : Evaluation.Structure Const ⟦_⟧Base)
(ΔBase : ChangeType.Structure Base)
(apply-base : ChangeTerm.ApplyStructure Const ΔBase)
(diff-base : ChangeTerm.DiffStructure Const ΔBase)
(nil-base : ChangeTerm.NilStructure Const ΔBase)
(⟦apply-base⟧ : ChangeValue.ApplyStructure Const ⟦_⟧Base ΔBase)
(⟦diff-base⟧ : ChangeValue.DiffStructure Const ⟦_⟧Base ΔBase)
(⟦nil-base⟧ : ChangeValue.NilStructure Const ⟦_⟧Base ΔBase)
(meaning-⊕-base : ChangeEvaluation.ApplyStructure
⟦_⟧Base ⟦_⟧Const ΔBase apply-base diff-base nil-base ⟦apply-base⟧ ⟦diff-base⟧ ⟦nil-base⟧)
(meaning-⊝-base : ChangeEvaluation.DiffStructure
⟦_⟧Base ⟦_⟧Const ΔBase apply-base diff-base nil-base ⟦apply-base⟧ ⟦diff-base⟧ ⟦nil-base⟧)
(meaning-onil-base : ChangeEvaluation.NilStructure
⟦_⟧Base ⟦_⟧Const ΔBase apply-base diff-base nil-base ⟦apply-base⟧ ⟦diff-base⟧ ⟦nil-base⟧)
{{validity-structure : Validity.Structure ⟦_⟧Base}}
(derive-const : Derive.Structure Const ΔBase)
(implementation-structure : Implementation.Structure
Const ⟦_⟧Base ⟦_⟧Const ΔBase
⟦apply-base⟧ ⟦diff-base⟧ ⟦nil-base⟧ derive-const)
where
open Type.Structure Base
open Term.Structure Base Const
open Value.Structure Base ⟦_⟧Base
open Evaluation.Structure Const ⟦_⟧Base ⟦_⟧Const
open Validity.Structure ⟦_⟧Base {{validity-structure}}
open Specification.Structure Const ⟦_⟧Base ⟦_⟧Const
open ChangeType.Structure Base ΔBase
open ChangeTerm.Structure Const ΔBase apply-base diff-base nil-base
open ChangeValue.Structure Const ⟦_⟧Base ΔBase ⟦apply-base⟧ ⟦diff-base⟧ ⟦nil-base⟧
open ChangeEvaluation.Structure
⟦_⟧Base ⟦_⟧Const ΔBase
apply-base diff-base nil-base
⟦apply-base⟧ ⟦diff-base⟧ ⟦nil-base⟧
meaning-⊕-base meaning-⊝-base meaning-onil-base
open Derive.Structure Const ΔBase derive-const
open Implementation.Structure implementation-structure
-- The denotational properties of the `derive` transformation.
-- In particular, the main theorem about it producing the correct
-- incremental behavior.
open import Base.Denotation.Notation
open import Relation.Binary.PropositionalEquality
open import Postulate.Extensionality
-- Extension point: A proof that change evaluation for a
-- primitive is related to the value of incrementalizing
-- this primitive.
Structure : Set
Structure = ∀ {τ} (c : Const τ) →
nil₍ τ ₎ ⟦ c ⟧Const ≈₍ τ ₎ ⟦ derive-const c ⟧Term ∅
module Structure (derive-const-correct : Structure) where
deriveVar-correct : ∀ {τ Γ} (x : Var Γ τ)
(ρ : ⟦ Γ ⟧) (dρ : Δ₍ Γ ₎ ρ) (ρ′ : ⟦ mapContext ΔType Γ ⟧) (dρ≈ρ′ : implements-env Γ dρ ρ′) →
⟦ x ⟧ΔVar ρ dρ ≈₍ τ ₎ ⟦ deriveVar x ⟧ (alternate ρ ρ′)
deriveVar-correct this (v • ρ) (dv • dρ) (dv′ • dρ′) (dv≈dv′ • dρ≈dρ′) = dv≈dv′
deriveVar-correct (that x) (v • ρ) (dv • dρ) (dv′ • dρ′) (dv≈dv′ • dρ≈dρ′) = deriveVar-correct x ρ dρ dρ′ dρ≈dρ′
derive-const-env-irrelevant : ∀ {Γ τ} (c : Const τ) → (ρ : ⟦ ΔContext Γ ⟧) → ⟦ weaken ∅≼Γ (derive-const c) ⟧Term ρ ≡
⟦ derive-const c ⟧Term ∅
derive-const-env-irrelevant {Γ} c ρ =
trans
(weaken-sound {Γ₁≼Γ₂ = (∅≼Γ {ΔContext Γ})} (derive-const c) ρ)
(cong ⟦ derive-const c ⟧Term (⟦∅≼Γ⟧-∅ ρ))
-- We provide: A variant of Lemma 3.10 for arbitrary contexts.
derive-correct : ∀ {τ Γ} (t : Term Γ τ)
(ρ : ⟦ Γ ⟧) (dρ : Δ₍ Γ ₎ ρ) (ρ′ : ⟦ mapContext ΔType Γ ⟧) (dρ≈ρ′ : implements-env Γ dρ ρ′) →
⟦ t ⟧Δ ρ dρ ≈₍ τ ₎ ⟦ derive t ⟧ (alternate ρ ρ′)
derive-correct {τ} {Γ} (const c) ρ dρ ρ′ dρ≈ρ′ =
subst (implements τ (nil₍ τ ₎ ⟦ c ⟧Const))
(sym (derive-const-env-irrelevant c (alternate ρ ρ′)))
(derive-const-correct c)
derive-correct (var x) ρ dρ ρ′ dρ≈ρ′ =
deriveVar-correct x ρ dρ ρ′ dρ≈ρ′
derive-correct (app {σ} {τ} s t) ρ dρ ρ′ dρ≈ρ′
= subst (λ ⟦t⟧ → ⟦ app s t ⟧Δ ρ dρ ≈₍ τ ₎ (⟦ derive s ⟧Term (alternate ρ ρ′)) ⟦t⟧ (⟦ derive t ⟧Term (alternate ρ ρ′))) (⟦fit⟧ t ρ ρ′)
(derive-correct {σ ⇒ τ} s ρ dρ ρ′ dρ≈ρ′
(⟦ t ⟧ ρ) (⟦ t ⟧Δ ρ dρ) (⟦ derive t ⟧ (alternate ρ ρ′)) (derive-correct {σ} t ρ dρ ρ′ dρ≈ρ′))
derive-correct (abs {σ} {τ} t) ρ dρ ρ′ dρ≈ρ′ =
λ w dw w′ dw≈w′ →
derive-correct t (w • ρ) (dw • dρ) (w′ • ρ′) (dw≈w′ • dρ≈ρ′)
derive-correct-closed : ∀ {τ} (t : Term ∅ τ) →
⟦ t ⟧Δ ∅ ∅ ≈₍ τ ₎ ⟦ derive t ⟧ ∅
derive-correct-closed t = derive-correct t ∅ ∅ ∅ ∅
-- And we proof Theorem 3.11, finally.
main-theorem : ∀ {σ τ}
{f : Term ∅ (σ ⇒ τ)} {s : Term ∅ σ} {ds : Term ∅ (ΔType σ)} →
{dv : Δ₍ σ ₎ (⟦ s ⟧ ∅)} {erasure : dv ≈₍ σ ₎ (⟦ ds ⟧ ∅)} →
⟦ app f (s ⊕₍ σ ₎ ds) ⟧ ≡ ⟦ app f s ⊕₍ τ ₎ app (app (derive f) s) ds ⟧
main-theorem {σ} {τ} {f} {s} {ds} {dv} {erasure} =
let
g = ⟦ f ⟧ ∅
Δg = ⟦ f ⟧Δ ∅ ∅
Δg′ = ⟦ derive f ⟧ ∅
v = ⟦ s ⟧ ∅
dv′ = ⟦ ds ⟧ ∅
u = ⟦ s ⊕₍ σ ₎ ds ⟧ ∅
-- Δoutput-term = app (app (derive f) x) (y ⊝ x)
in
ext {A = ⟦ ∅ ⟧Context} (λ { ∅ →
begin
g u
≡⟨ cong g (sym (meaning-⊕ {t = s} {Δt = ds})) ⟩
g (v ⟦⊕₍ σ ₎⟧ dv′)
≡⟨ cong g (sym (carry-over {σ} dv erasure)) ⟩
g (v ⊞₍ σ ₎ dv)
≡⟨ corollary-closed {σ} {τ} f v dv ⟩
g v ⊞₍ τ ₎ call-change {σ} {τ} Δg v dv
≡⟨ carry-over {τ} (call-change {σ} {τ} Δg v dv)
(derive-correct-closed f v dv dv′ erasure) ⟩
g v ⟦⊕₍ τ ₎⟧ Δg′ v dv′
≡⟨ meaning-⊕ {t = app f s} {Δt = app (app (derive f) s) ds} ⟩
⟦ app f s ⊕₍ τ ₎ app (app (derive f) s) ds ⟧ ∅
∎}) where open ≡-Reasoning
|
oeis/339/A339051.asm | neoneye/loda-programs | 11 | 178981 | <filename>oeis/339/A339051.asm
; A339051: Even bisection of the infinite Fibonacci word A096270.
; Submitted by <NAME>
; 0,0,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,1,1,0
add $0,1
trn $0,2
mul $0,2
add $0,1
seq $0,159917 ; Fixed point of the morphism 0 -> 01, 1 -> 2, 2 -> 01, starting from a(0) = 0.
add $0,5
mod $0,2
|
src/lumen-image.ads | darkestkhan/lumen | 8 | 18234 |
-- Lumen.Image -- Load and save image data
--
-- <NAME>, NiEstu, Phoenix AZ, Spring 2010
-- This code is covered by the ISC License:
--
-- Copyright © 2010, NiEstu
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- The software is provided "as is" and the author disclaims all warranties
-- with regard to this software including all implied warranties of
-- merchantability and fitness. In no event shall the author be liable for any
-- special, direct, indirect, or consequential damages or any damages
-- whatsoever resulting from loss of use, data or profits, whether in an
-- action of contract, negligence or other tortious action, arising out of or
-- in connection with the use or performance of this software.
-- Environment
with Lumen.Binary;
package Lumen.Image is
---------------------------------------------------------------------------
-- Exceptions added by this package
Unknown_Format : exception; -- can't recognize the file's data
Invalid_Format : exception; -- thought we did, but encountered bad values
---------------------------------------------------------------------------
-- Lumen.Image uses 8-bit RGBA, thank you.
-- (red, green, blue, alpha (transparency)).
-- One RGBA pixel, an array of them, and some pointers to pixels
type Pixel is record
R : Binary.Byte;
G : Binary.Byte;
B : Binary.Byte;
A : Binary.Byte;
end record;
type Pixels is array (Natural range <>) of Pixel;
type Pixel_Ptr is access Pixel;
type Pixels_Ptr is access Pixels;
-- A matrix of RGBA pixels, and a pointer to it
type Pixel_Matrix is array (Natural range <>, Natural range <>) of Pixel;
type Pixel_Matrix_Ptr is access Pixel_Matrix;
-- Two types of image data info records
pragma Warnings (Off); -- yes, we know it might be big if declared wrong
type Data (Width, Height : Natural := 0) is record
Complete : Boolean := False;
Values : Pixel_Matrix (1 .. Width, 1 .. Height);
end record;
pragma Warnings (On);
type Descriptor is record
Complete : Boolean := False;
Width : Natural := 0;
Height : Natural := 0;
Values : Pixel_Matrix_Ptr := null;
end record;
---------------------------------------------------------------------------
-- Three fairly useful pixel values
Black_Pixel : constant Pixel := (R => Binary.Byte'First,
G => Binary.Byte'First,
B => Binary.Byte'First,
A => Binary.Byte'Last);
White_Pixel : constant Pixel := (R => Binary.Byte'Last,
G => Binary.Byte'Last,
B => Binary.Byte'Last,
A => Binary.Byte'Last);
Transparent_Pixel : constant Pixel := (R => Binary.Byte'First,
G => Binary.Byte'First,
B => Binary.Byte'First,
A => Binary.Byte'First);
---------------------------------------------------------------------------
-- Read image data from a file
function From_File (Pathname : String) return Descriptor;
---------------------------------------------------------------------------
end Lumen.Image;
|
programs/oeis/280/A280193.asm | neoneye/loda | 22 | 161937 | <filename>programs/oeis/280/A280193.asm
; A280193: a(2*n) = 2, a(2*n + 1) = -1, a(0) = 1.
; 1,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1,2,-1
sub $0,1
mod $0,2
mul $0,10
add $0,1
pow $0,2
sub $0,79
div $0,39
add $0,1
|
src/asm/esxDOS.asm | Threetwosevensixseven/espupdate | 8 | 169249 | <reponame>Threetwosevensixseven/espupdate<filename>src/asm/esxDOS.asm
; esxDOS.asm
; Copyright 2020 <NAME>
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
; NOTE: File paths use the slash character ('/') as directory separator (UNIX style)
esxDOS proc
M_DOSVERSION equ $88
M_GETSETDRV equ $89
M_P3DOS equ $94
M_GETHANDLE equ $8D
M_GETDATE equ $8E
M_ERRH equ $95
F_OPEN equ $9A
F_CLOSE equ $9B
F_SYNC equ $9C
F_READ equ $9D
F_WRITE equ $9E
F_SEEK equ $9F
F_GET_DIR equ $A8
F_SET_DIR equ $A9
FA_READ equ $01
FA_APPEND equ $06
FA_OVERWRITE equ $0C
esx_seek_set equ $00 ; set the fileposition to BCDE
esx_seek_fwd equ $01 ; add BCDE to the fileposition
esx_seek_bwd equ $02 ; subtract BCDE from the fileposition
DefaultDrive db 0
Handle db 255
; Function: Get the file handle of the currently running dot command
; In: None
; Out: A = file handle
; Carry = clear
; Notes: This call allows dot commands which are >8K to read further data direct
; from their own file (for loading into another memory area, or overlaying
; as required into the normal 8K dot command area currently in use).
; On entry to a dot command, the file is left open with the file pointer
; positioned directly after the first 8K.
; This call returns meaningless results if not called from a dot command.
GetHandle: Rst8(esxDOS.M_GETHANDLE) ; Get handle
ld (Handle), a ; Save handle
ret ; Returns a file handler in 'A' register.
; Function: Open file
; In: HL = pointer to file name (ASCIIZ) (IX for non-dot commands)
; B = open mode
; A = Drive
; Out: A = file handle
; On error: Carry set
; A = 5 File not found
; A = 7 Name error - not 8.3?
; A = 11 Drive not found
;
fOpen: ld a, '*' ; get drive we're on
ld b, FA_READ ; b = open mode
Rst8(esxDOS.F_OPEN) ; open read mode
ld (Handle), a
ret ; Returns a file handler in 'A' register.
; Function: Read bytes from a file
; In: A = file handle
; HL = address to load into (IX for non-dot commands)
; BC = number of bytes to read
; Out: Carry flag is set if read fails.
;
fRead: ld a, (Handle) ; file handle
Rst8(esxDOS.F_READ) ; read file
ret
; Function: Close file
; In: A = file handle
; Out: Carry flag active if error when closing
;
fClose: ld a, (Handle)
Rst8(esxDOS.F_CLOSE) ; close file
ret
; Function: Seek into file
; In: A = file handle
; L = mode: 0 - from start of file
; 1 - forward from current position
; 2 - back from current position
; BCDE = bytes to seek
; Out: BCDE = Current file pointer. (*does not return this yet)
;
/*fSeek: ld a, (Handle) ; file handle
or a ; is it zero?
ret z ; if so return
Rst8(esxDOS.F_SEEK) ; seek into file
ret
pend*/
|
Transynther/x86/_processed/AVXALIGN/_st_sm_/i9-9900K_12_0xa0_notsx.log_21829_1387.asm | ljhsiun2/medusa | 9 | 98022 | <reponame>ljhsiun2/medusa<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r9
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x1e47c, %rsi
lea addresses_A_ht+0x605c, %rdi
inc %r13
mov $44, %rcx
rep movsl
inc %rbp
lea addresses_UC_ht+0x1de02, %r9
clflush (%r9)
nop
and %rdx, %rdx
movb (%r9), %r13b
nop
nop
nop
nop
dec %rbp
lea addresses_A_ht+0x1253c, %r9
nop
and %rsi, %rsi
movups (%r9), %xmm1
vpextrq $1, %xmm1, %rdi
nop
nop
nop
add $46468, %r13
lea addresses_normal_ht+0xde9c, %rdx
nop
nop
cmp $13113, %rbp
mov $0x6162636465666768, %r9
movq %r9, %xmm4
vmovups %ymm4, (%rdx)
sub %rbp, %rbp
lea addresses_A_ht+0x26fc, %rcx
nop
nop
nop
nop
xor $30442, %rdi
mov (%rcx), %r13w
nop
nop
nop
nop
nop
cmp $21098, %rcx
lea addresses_A_ht+0x1967c, %rcx
nop
xor %rdi, %rdi
movl $0x61626364, (%rcx)
nop
nop
add $25633, %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r14
push %r15
push %r9
push %rax
push %rdx
// Store
lea addresses_WT+0x1acdc, %r14
clflush (%r14)
inc %rax
movl $0x51525354, (%r14)
nop
nop
nop
xor %rax, %rax
// Load
lea addresses_PSE+0xf4dc, %r9
sub %r11, %r11
vmovups (%r9), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $0, %xmm0, %r14
nop
nop
and $30659, %r12
// Store
lea addresses_WT+0xa07c, %r9
nop
nop
add %r12, %r12
movl $0x51525354, (%r9)
nop
nop
nop
inc %rax
// Store
mov $0x7fc, %r14
clflush (%r14)
nop
nop
and %r11, %r11
mov $0x5152535455565758, %r12
movq %r12, %xmm7
vmovups %ymm7, (%r14)
nop
nop
xor $27679, %r11
// Store
lea addresses_RW+0x18aac, %r9
nop
nop
add %r15, %r15
movw $0x5152, (%r9)
nop
nop
nop
and %r11, %r11
// Store
lea addresses_RW+0xd87c, %r11
and %r9, %r9
movb $0x51, (%r11)
nop
nop
nop
nop
nop
sub $39742, %r15
// Store
mov $0x4f2d700000000068, %rdx
nop
nop
xor $26632, %r15
movw $0x5152, (%rdx)
nop
nop
nop
nop
nop
xor %rdx, %rdx
// Store
lea addresses_WC+0xdf7c, %r9
nop
nop
sub $63691, %r12
movb $0x51, (%r9)
xor $17105, %r9
// Faulty Load
lea addresses_RW+0xd87c, %rdx
nop
nop
inc %r12
movb (%rdx), %r11b
lea oracles, %r12
and $0xff, %r11
shlq $12, %r11
mov (%r12,%r11,1), %r11
pop %rdx
pop %rax
pop %r9
pop %r15
pop %r14
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_RW', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 3}}
{'src': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 4}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'size': 2, 'NT': True, 'same': False, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'AVXalign': False, 'size': 2, 'NT': True, 'same': False, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'size': 1, 'NT': True, 'same': False, 'congruent': 8}}
[Faulty Load]
{'src': {'type': 'addresses_RW', 'AVXalign': True, 'size': 1, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 1}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 5}}
{'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 7}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 9}}
{'51': 21829}
51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51
*/
|
SLAE_assignments/assignment6/execve_poly.nasm | RomainLanglois/SLAE_x86 | 0 | 168419 | <gh_stars>0
;Shellcode size: 33 bytes
global _start
_start:
xor eax, eax ;Initialize eax to NULL
push eax ;Push a NULL Byte on the stack
mov edx, 0xb6de91c0 ;Move 0xb6de91c0 into edx
xor edx, 0xdeadbeef ;Xor 0xb6de91c0 with 0xdeadbeef
push edx ;Push '//sh' on the stack
push 0x6e69622f ;Push '/bin' on the stack
mov ebx, esp ;Initilialize ebx to "/bin/sh%00"
push 0x1 ;Push 0x1 on the stack
pop ecx ;Pop 0x1 inside ecx
dec ecx ;Decrement ecx by one
;Initialize ecx to NULL
xor edx, edx ;Initialize edx to NULL
push 0xb ;Push 0xb on the stack
pop eax ;Pop the execve systemcall number inside eax
;Systemcall details:
; --> execve("/bin/sh%00", NULL, NULL);
int 0x80 ;Execute systemcall |
src/fot/FOTC/Data/List/Consistency/Axioms.agda | asr/fotc | 11 | 648 | ------------------------------------------------------------------------------
-- Test the consistency of FOTC.Data.List
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- In the module FOTC.Data.List we declare Agda postulates as FOL
-- axioms. We test if it is possible to prove an unprovable theorem
-- from these axioms.
module FOTC.Data.List.Consistency.Axioms where
open import FOTC.Base
open import FOTC.Data.List
------------------------------------------------------------------------------
postulate impossible : ∀ d e → d ≡ e
{-# ATP prove impossible #-}
|
libtool/src/gmp-6.1.2/mpn/powerpc32/750/lshift.asm | kroggen/aergo | 1,602 | 18788 | <reponame>kroggen/aergo
dnl PowerPC 750 mpn_lshift -- mpn left shift.
dnl Copyright 2002, 2003 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C 750: 3.0
C 7400: 3.0
C mp_limb_t mpn_lshift (mp_ptr dst, mp_srcptr src, mp_size_t size,
C unsigned shift);
C
C This code is the same per-limb speed as mpn/powerpc32/lshift.asm, but
C smaller and saving about 30 or so cycles of overhead.
ASM_START()
PROLOGUE(mpn_lshift)
C r3 dst
C r4 src
C r5 size
C r6 shift
mtctr r5 C size
slwi r5, r5, 2 C 4*size
subfic r7, r6, 32 C 32-shift
add r4, r4, r5 C &src[size]
add r5, r3, r5 C &dst[size]
lwz r8, -4(r4) C src[size-1]
bdz L(one)
lwzu r9, -8(r4) C src[size-2]
srw r3, r8, r7 C return value
slw r8, r8, r6 C src[size-1] << shift
bdz L(two)
L(top):
C r3 return value
C r4 src, incrementing
C r5 dst, incrementing
C r6 lshift
C r7 32-shift
C r8 src[i+1] << shift
C r9 src[i]
C r10
lwzu r10, -4(r4)
srw r11, r9, r7
or r8, r8, r11
stwu r8, -4(r5)
slw r8, r9, r6
bdz L(odd)
C r8 src[i+1] << shift
C r9
C r10 src[i]
lwzu r9, -4(r4)
srw r11, r10, r7
or r8, r8, r11
stwu r8, -4(r5)
slw r8, r10, r6
bdnz L(top)
L(two):
C r3 return value
C r4
C r5 &dst[2]
C r6 shift
C r7 32-shift
C r8 src[1] << shift
C r9 src[0]
C r10
srw r11, r9, r7
slw r12, r9, r6 C src[0] << shift
or r8, r8, r11
stw r12, -8(r5) C dst[0]
stw r8, -4(r5) C dst[1]
blr
L(odd):
C r3 return value
C r4
C r5 &dst[2]
C r6 shift
C r7 32-shift
C r8 src[1] << shift
C r9
C r10 src[0]
srw r11, r10, r7
slw r12, r10, r6
or r8, r8, r11
stw r12, -8(r5) C dst[0]
stw r8, -4(r5) C dst[1]
blr
L(one):
C r5 &dst[1]
C r6 shift
C r7 32-shift
C r8 src[0]
srw r3, r8, r7 C return value
slw r8, r8, r6 C src[size-1] << shift
stw r8, -4(r5) C dst[0]
blr
EPILOGUE(mpn_lshift)
|
pwnlib/shellcraft/templates/arm/linux/ptrace.asm | IMULMUL/python3-pwntools | 325 | 28813 | <reponame>IMULMUL/python3-pwntools
<%
from pwnlib.shellcraft.arm.linux import syscall
%>
<%page args="request, vararg"/>
<%docstring>
Invokes the syscall ptrace. See 'man 2 ptrace' for more information.
Arguments:
request(ptrace_request): request
vararg(int): vararg
</%docstring>
${syscall('SYS_ptrace', request, vararg)}
|
gfx/tilesets/viridian_forest_palette_map.asm | Ebernacher90/pokecrystal-allworld | 0 | 242215 | tilepal 0, BROWN, BROWN, WATER, WATER, GREEN, GREEN, GREEN, GREEN
tilepal 0, WATER, WATER, BROWN, BROWN, WATER, WATER, BROWN, GREEN
tilepal 0, RED, RED, WATER, WATER, GREEN, GREEN, GREEN, GREEN
tilepal 0, WATER, WATER, BROWN, BROWN, WATER, GREEN, GREEN, GREEN
tilepal 0, WATER, RED, RED, WATER, GREEN, GREEN, GREEN, GREEN
tilepal 0, WATER, WATER, WATER, WATER, WATER, GREEN, GREEN, GREEN
tilepal 0, WATER, GRAY, GRAY, GREEN, WATER, GREEN, GREEN, WATER
tilepal 0, WATER, WATER, WATER, WATER, WATER, BROWN, BROWN, GREEN
tilepal 0, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN
tilepal 0, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN
tilepal 0, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN
tilepal 0, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN
tilepal 0, BROWN, BROWN, BROWN, RED, YELLOW, GREEN, BROWN, YELLOW
tilepal 0, YELLOW, BROWN, BROWN, BROWN, GREEN, GREEN, BROWN, BROWN
tilepal 0, BROWN, BROWN, BROWN, RED, WATER, BROWN, BROWN, BROWN
tilepal 0, BROWN, BROWN, BROWN, BROWN, GREEN, GREEN, BROWN, BROWN
tilepal 1, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, GREEN, GREEN
tilepal 1, GREEN, BROWN, BROWN, BROWN, GREEN, GREEN, GREEN, GREEN
tilepal 1, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, GREEN, GREEN
tilepal 1, GREEN, GREEN, GREEN, BROWN, GREEN, BROWN, BROWN, GREEN
tilepal 1, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN
tilepal 1, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN
tilepal 1, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN
tilepal 1, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN, BROWN
|
src/tests/display_norx_traces.adb | jhumphry/SPARK_NORX | 9 | 18720 | <filename>src/tests/display_norx_traces.adb
-- Display_NORX_Traces
-- A utility to display traces of the encryption process for the test vectors
-- suggested in Appendix A of the NORX specification
-- Copyright (c) 2016, <NAME> - see LICENSE file for details
with Ada.Text_IO;
use Ada.Text_IO;
with System.Storage_Elements;
use System.Storage_Elements;
with NORX.Access_Internals;
with NORX.Utils;
procedure Display_NORX_Traces is
package NORX_Internals is new NORX_Package.Access_Internals;
use NORX_Internals;
package NORX_Utils is new NORX_Package.Utils;
use NORX_Utils;
Init_Constants : constant State := Get_Initialisation_Constants;
State_Trace : State := Make_State;
K : NORX_Package.Key_Type;
N : NORX_Package.Nonce_Type;
A, M, Z : Storage_Array(0..Test_Message_Length-1);
C : Storage_Array(0..Test_Message_Length-1);
T : NORX_Package.Tag_Type;
M2 : Storage_Array(0..Test_Message_Length-1);
T2 : NORX_Package.Tag_Type;
begin
for I in K'Range loop
K(I) := Storage_Element(I);
end loop;
for I in N'Range loop
N(I) := 32 + Storage_Element(I);
end loop;
for I in A'Range loop
A(I) := Storage_Element(I);
M(I) := Storage_Element(I);
Z(I) := Storage_Element(I);
end loop;
New_Line;
Put_Line("Check initialisation constants:");
Put_State(Init_Constants);
New_Line;
Put_Line("ENCRYPTION");
New_Line;
State_Trace := Initialise(K, N);
Put_Line("State after initialisation (with key and nonce):");
Put_State(State_Trace);
New_Line;
Absorb(State_Trace, A, 16#01#);
Put_Line("State after header processing:");
Put_State(State_Trace);
New_Line;
Encrypt(State_Trace, M, C, 16#02#);
Put_Line("State after message encryption:");
Put_State(State_Trace);
New_Line;
Absorb(State_Trace, Z, 16#04#);
Put_Line("State after trailer processing:");
Put_State(State_Trace);
New_Line;
Finalise(State_Trace, K, T, 16#08#);
Put_Line("State after finalisation:");
Put_State(State_Trace);
New_Line;
Put_Line("Ciphertext:");
Put_Storage_Array(C);
Put_Line("Tag:");
Put_Storage_Array(T);
New_Line;
New_Line;
Put_Line("DECRYPTION");
New_Line;
State_Trace := Initialise(K, N);
Put_Line("Initialise state with key and nonce");
Absorb(State_Trace, A, 16#01#);
Put_Line("Absorbing header into state");
Decrypt(State_Trace, C, M2, 16#02#);
Put_Line("Decrypting message");
Absorb(State_Trace, Z, 16#04#);
Put_Line("Absorbing trailer into state");
Finalise(State_Trace, K, T2, 16#08#);
Put_Line("Finalising state");
New_Line;
Put_Line("Recovered plaintext:");
Put_Storage_Array(M2);
Put_Line("Recovered Tag:");
Put_Storage_Array(T2);
New_Line;
Put_Line((if M /= M2
then "ERROR :Plaintexts don't match"
else "Plaintexts match"));
Put_Line((if T /= T2
then "ERROR: Tags don't match"
else "Tags match"));
New_Line;
end Display_NORX_Traces;
|
src/backends/output_backend.ads | kqr/qweyboard | 33 | 26200 | private with Logging;
package Output_Backend is
task Output is
entry Ready_Wait;
entry Enter (Text : Wide_Wide_String; Continues_Word : Boolean);
entry Erase (Amount : Positive);
entry Shut_Down;
end Output;
private
use Logging;
end Output_Backend;
|
src/firmware/Platform/Arithmetic32/Divide.asm | pete-restall/Cluck2Sesame-Prototype | 1 | 175203 | <filename>src/firmware/Platform/Arithmetic32/Divide.asm<gh_stars>1-10
#include "Platform.inc"
#include "GeneralPurposeRegisters.inc"
radix decimal
Arithmetic32 code
global div32x16
div32x16:
.safelySetBankFor RBC
movf RBC, W
iorwf RBD, W
btfsc STATUS, Z
goto divideByZero
call setCarryIfDividendMostSignificantWordIsGreaterThanDivisor
btfsc STATUS, C
goto overflow
movlw 16
movwf RZA
subtractionLoop:
bcf STATUS, C
rlf RAD
rlf RAC
rlf RAB
rlf RAA
btfsc STATUS, C
goto doSubtraction
call setCarryIfDividendMostSignificantWordIsGreaterThanDivisor
btfss STATUS, C
goto nextIteration
doSubtraction:
call subtractDivisorFromDividendMostSignificantWord
bsf RAD, 0
nextIteration:
decfsz RZA
goto subtractionLoop
adjustFlagsAndReturn:
bcf STATUS, C
bcf STATUS, DC
adjustZeroFlag:
movf RAA, W
iorwf RAB, W
iorwf RAC, W
iorwf RAD, W
return
divideByZero:
bcf STATUS, C
bsf STATUS, DC
bcf STATUS, Z
return
overflow:
bsf STATUS, C
bcf STATUS, DC
bcf STATUS, Z
return
setCarryIfDividendMostSignificantWordIsGreaterThanDivisor:
movf RBD, W
subwf RAB, W
movf RBC, W
btfss STATUS, C
incfsz RBC, W
subwf RAA, W
return
subtractDivisorFromDividendMostSignificantWord:
movf RBD, W
subwf RAB
movf RBC, W
btfss STATUS, C
incfsz RBC, W
subwf RAA
return
end
|
src/windows/xdg-defaults.ads | darkestkhan/xdg | 2 | 24517 | <reponame>darkestkhan/xdg<gh_stars>1-10
------------------------------------------------------------------------------
-- EMAIL: <<EMAIL>> --
-- License: ISC License (see COPYING file) --
-- --
-- Copyright © 2015 darkestkhan --
------------------------------------------------------------------------------
-- Permission to use, copy, modify, and/or distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- The software is provided "as is" and the author disclaims all warranties --
-- with regard to this software including all implied warranties of --
-- merchantability and fitness. In no event shall the author be liable for --
-- any special, direct, indirect, or consequential damages or any damages --
-- whatsoever resulting from loss of use, data or profits, whether in an --
-- action of contract, negligence or other tortious action, arising out of --
-- or in connection with the use or performance of this software. --
------------------------------------------------------------------------------
private package XDG.Defaults is
-- Directory separator character.
Separator: constant Character := '\';
Home : constant String := "_local\share\";
Config: constant String := "_config\";
Cache : constant String := "_cache\";
Data_Dirs : constant String := "";
Config_Dirs : constant String := "";
end XDG.Defaults;
|
Build/Interpreters/beebOzmoo/asm/disk.asm | polluks/Puddle-BuildTools | 38 | 87720 | <gh_stars>10-100
first_unavailable_save_slot_charcode !byte 0
current_disks !byte $ff, $ff, $ff, $ff
boot_device !byte 0
ask_for_save_device !byte $ff
!ifndef VMEM {
disk_info
!byte 0, 0, 1 ; Interleave, save slots, # of disks
!byte 8, 8, 0, 0, 0, 130, 131, 0
} else {
device_map !byte 0,0,0,0
nonstored_blocks !byte 0
readblocks_numblocks !byte 0
readblocks_currentblock !byte 0,0 ; 257 = ff 1
readblocks_currentblock_adjusted !byte 0,0 ; 257 = ff 1
readblocks_mempos !byte 0,0 ; $2000 = 00 20
disk_info
!ifdef Z3 {
!fill 71
}
!ifdef Z4 {
!fill 94
}
!ifdef Z5 {
!fill 94
}
!ifdef Z8 {
!fill 120
}
readblocks
; read <n> blocks (each 256 bytes) from disc to memory
; set values in readblocks_* before calling this function
; register: a,x,y
!ifdef TRACE_FLOPPY {
jsr newline
jsr print_following_string
!pet "readblocks (n,zp,c64) ",0
lda readblocks_numblocks
jsr printa
jsr comma
lda readblocks_currentblock + 1
jsr print_byte_as_hex
lda readblocks_currentblock
jsr print_byte_as_hex
jsr comma
lda readblocks_mempos + 1
jsr print_byte_as_hex
lda readblocks_mempos
jsr print_byte_as_hex
jsr newline
}
- jsr readblock ; read block
inc readblocks_mempos + 1 ; update mempos,block for next iteration
inc readblocks_currentblock
bne +
inc readblocks_currentblock + 1
+ dec readblocks_numblocks ; loop
bne -
rts
.readblock_from_reu
ldx readblocks_currentblock_adjusted
ldy readblocks_currentblock_adjusted + 1
inx
bne +
iny
+ tya
ldy readblocks_mempos + 1 ; Assuming lowbyte is always 0 (which it should be)
jmp copy_page_from_reu
readblock
; read 1 block from floppy
; $mempos (contains address to store in) [in]
; set values in readblocks_* before calling this function
; register a,x,y
!ifdef TRACE_FLOPPY {
jsr print_following_string
!pet "Readblock: ",0
lda readblocks_currentblock + 1
jsr print_byte_as_hex
lda readblocks_currentblock
jsr print_byte_as_hex
}
lda readblocks_currentblock
sec
sbc nonstored_blocks
sta readblocks_currentblock_adjusted
sta .blocks_to_go
lda readblocks_currentblock + 1
sbc #0
sta readblocks_currentblock_adjusted + 1
sta .blocks_to_go + 1
; Check if game has been cached to REU
bit use_reu
bvs .readblock_from_reu
; convert block to track/sector
lda disk_info + 2 ; Number of disks
ldx #0 ; Memory index
ldy #0 ; Disk id
.check_next_disk
txa
clc
adc disk_info + 3,x
sta .next_disk_index ; x-value where next disk starts
; Check if the block we are looking for is on this disk
lda readblocks_currentblock_adjusted
sec
sbc disk_info + 6,x
sta .blocks_to_go_tmp + 1
lda readblocks_currentblock_adjusted + 1
sbc disk_info + 5,x
sta .blocks_to_go_tmp
bcc .right_disk_found ; Found the right disk!
; This is not the right disk. Save # of blocks to go into next disk.
lda .blocks_to_go_tmp
sta .blocks_to_go
lda .blocks_to_go_tmp + 1
sta .blocks_to_go + 1
jmp .next_disk ; Not the right disk, keep looking!
; Found the right disk
.right_disk_found
lda disk_info + 4,x
sta .device
lda disk_info + 7,x
sta .disk_tracks ; # of tracks which have entries
lda #1
sta .track
.check_track
lda disk_info + 8,x
beq .next_track
and #%00111111
sta .sector
lda .blocks_to_go + 1
sec
sbc .sector
sta .blocks_to_go_tmp + 1
lda .blocks_to_go
sbc #0
sta .blocks_to_go_tmp
bcc .right_track_found ; Found the right track
sta .blocks_to_go
lda .blocks_to_go_tmp + 1
sta .blocks_to_go + 1
.next_track
inx
inc .track
dec .disk_tracks
bne .check_track
!ifndef UNSAFE {
; Broken config
lda #ERROR_CONFIG ; Config info must be incorrect if we get here
jmp fatalerror
}
.next_disk
ldx .next_disk_index
iny
!ifdef UNSAFE {
jmp .check_next_disk
} else {
cpy disk_info + 2 ; # of disks
bcs +
jmp .check_next_disk
+ lda #ERROR_OUT_OF_MEMORY ; Meaning request for Z-machine memory > EOF. Bad message?
jmp fatalerror
}
.right_track_found
; Add sectors not used at beginning of track
; .blocks_to_go + 1: logical sector#
; disk_info + 8,x: # of sectors skipped / 2 (2 bits), # of sectors used (6 bits)
sty .temp_y
!ifdef TRACE_FLOPPY {
jsr arrow
lda .track
jsr print_byte_as_hex
jsr comma
lda .blocks_to_go + 1
jsr print_byte_as_hex
}
lda disk_info + 8,x
lsr
lsr
lsr
lsr
lsr
and #%00000110; a now holds # of sectors at start of track not in use
sta .skip_sectors
; Initialize track map. Write 0 for sectors not yet used, $ff for sectors used
lda disk_info + 8,x
and #%00111111
clc
adc .skip_sectors
sta .sector_count
tay
dey
lda #0
- cpy .skip_sectors
bcs +
lda #$ff
+ sta .track_map,y
dey
bpl -
; Find right sector.
; 1. Start at 0
; 2. Find next free sector
; 3. Decrease blocks to go. If < 0, we are done
; 4. Mark sector as used.
; 5. Add interleave, go back to 2
; 1
lda #0
; 2
- tay
lda .track_map,y
beq +
iny
tya
cpy .sector_count
bcc -
lda #0
beq - ; Always branch
; 3
+ dec .blocks_to_go + 1
bmi +
; 4
lda #$ff
sta .track_map,y
; 5
tya
clc
adc disk_info ; #SECTOR_INTERLEAVE
.check_sector_range
cmp .sector_count
bcc -
sbc .sector_count ; c is already set
bcs .check_sector_range ; Always branch
+ sty .sector
!ifdef TRACE_FLOPPY {
jsr comma
tya
jsr print_byte_as_hex
}
; Restore old value of y
ldy .temp_y
jmp .have_set_device_track_sector
.track_map !fill 40 ; Holds a map of the sectors in a single track
.sector_count !byte 0
.skip_sectors !byte 0
.temp_y !byte 0
; convert track/sector to ascii and update drive command
read_track_sector
; input: a: track, x: sector, y: device#, Word at readblocks_mempos holds storage address
sta .track
stx .sector
sty .device
.have_set_device_track_sector
lda .track
jsr conv2dec
stx .uname_track
sta .uname_track + 1
lda .sector
jsr conv2dec
stx .uname_sector
sta .uname_sector + 1
!ifdef TRACE_FLOPPY_VERBOSE {
jsr space
jsr dollar
lda readblocks_mempos + 1
jsr print_byte_as_hex
lda readblocks_mempos
jsr print_byte_as_hex
jsr comma
ldx readblocks_currentblock
jsr printx
;jsr comma
;lda #<.uname
;ldy #>.uname
;jsr printstring
jsr newline
}
; open the channel file
lda #cname_len
ldx #<.cname
ldy #>.cname
jsr kernal_setnam ; call SETNAM
lda #$02 ; file number 2
ldx .device
tay ; secondary address 2
jsr kernal_setlfs ; call SETLFS
jsr kernal_open ; call OPEN
bcs .error ; if carry set, the file could not be opened
; open the command channel
lda #uname_len
ldx #<.uname
ldy #>.uname
jsr kernal_setnam ; call SETNAM
lda #$0F ; file number 15
ldx .device
tay ; secondary address 15
jsr kernal_setlfs ; call SETLFS
jsr kernal_open ; call OPEN (open command channel and send U1 command)
bcs .error ; if carry set, the file could not be opened
; check drive error channel here to test for
; FILE NOT FOUND error etc.
ldx #$02 ; filenumber 2
jsr kernal_chkin ; call CHKIN (file 2 now used as input)
lda readblocks_mempos
sta zp_mempos
lda readblocks_mempos+1
sta zp_mempos + 1
ldy #$00
- jsr kernal_readchar ; call CHRIN (get a byte from file)
sta (zp_mempos),Y ; write byte to memory
iny
bne - ; next byte, end when 256 bytes are read
jmp close_io
.error
; accumulator contains BASIC error code
; most likely errors:
; A = $05 (DEVICE NOT PRESENT)
jsr close_io ; even if OPEN failed, the file has to be closed
lda #ERROR_FLOPPY_READ_ERROR
jsr fatalerror
.cname !text "#"
cname_len = * - .cname
.uname !text "U1 2 0 "
.uname_track !text "18 "
.uname_sector !text "00"
!byte 0 ; end of string, so we can print debug messages
uname_len = * - .uname
.track !byte 0
.sector !byte 0
.device !byte 0
.blocks_to_go !byte 0, 0
.blocks_to_go_tmp !byte 0, 0
.next_disk_index !byte 0
.disk_tracks !byte 0
} ; End of !ifdef VMEM
close_io
lda #$0F ; filenumber 15
jsr kernal_close ; call CLOSE
lda #$02 ; filenumber 2
jsr kernal_close ; call CLOSE
jmp kernal_clrchn ; call CLRCHN
!zone disk_messages {
prepare_for_disk_msgs
rts
print_insert_disk_msg
; Parameters: y: memory index to start of info for disk in disk_info
sty .save_y
; ldx .print_row
; ldy #2
; jsr set_cursor
lda #>insert_msg_1
ldx #<insert_msg_1
jsr printstring_raw
ldy .save_y
; Print disk name
lda disk_info + 7,y ; Number of tracks
clc
adc .save_y
tay
- lda disk_info + 8,y
beq .disk_name_done
bmi .special_string
jsr printchar_raw
iny
bne - ; Always branch
.special_string
and #%00000111
tax
lda .special_string_low,x
sta .save_x
lda .special_string_high,x
ldx .save_x
jsr printstring_raw
iny
bne - ; Always branch
.disk_name_done
lda #>insert_msg_2
ldx #<insert_msg_2
jsr printstring_raw
ldy .save_y
lda disk_info + 4,y
tax
cmp #10
bcc +
lda #$31
jsr printchar_raw
txa
sec
sbc #10
+ clc
adc #$30
jsr printchar_raw
lda #>insert_msg_3
ldx #<insert_msg_3
jsr printstring_raw
;jsr kernal_readchar ; this shows the standard kernal prompt (not good)
- jsr kernal_getchar
beq -
; lda .print_row
; clc
; adc #3
; sta .print_row
ldy .save_y
rts
.save_x !byte 0
.save_y !byte 0
.print_row !byte 14
;.device_no !byte 0
.special_string_128
!pet "Boot ",0
.special_string_129
!pet "Story ",0
.special_string_130
!pet "Save ",0
.special_string_131
!pet "disk ",0
.special_string_low !byte <.special_string_128, <.special_string_129, <.special_string_130, <.special_string_131
.special_string_high !byte >.special_string_128, >.special_string_129, >.special_string_130, >.special_string_131
insert_msg_1
!pet 13," Please insert ",0
insert_msg_2
!pet 13," in drive ",0
insert_msg_3
!pet " [ENTER] ",0
}
!ifdef VMEM {
WANT_RESTART = 1
z_ins_restart
; Find right device# for boot disk
ldx disk_info + 3
lda disk_info + 4,x
cmp #10
bcc +
inc .restart_code_string + 12
sec
sbc #10
+ ora #$30
sta .restart_code_string + 13
; Check if disk is in drive
lda disk_info + 4,x
tay
txa
cmp current_disks - 8,y
beq +
jsr print_insert_disk_msg
+
; Copy restart code
ldx #.restart_code_end - .restart_code_begin
- lda .restart_code_begin - 1,x
sta .restart_code_address - 1,x
dex
bne -
; Setup key sequence
ldx #0
- lda .restart_keys,x
beq +
sta 631,x
inx
bne - ; Always branch
+ stx 198
jsr clear_screen_raw
; lda #147
; jsr $ffd2
lda #z_exe_mode_exit
sta z_exe_mode
rts
.restart_keys
; !pet "lO",34,":*",34,",08:",131,0
!pet "sY3e4",13,0
.restart_code_address = 30000
.restart_code_begin
.restart_code_string_final_pos = .restart_code_string - .restart_code_begin + .restart_code_address
ldx #0
- lda .restart_code_string_final_pos,x
beq +
jsr $ffd2
inx
bne -
; Setup key sequence
+ lda #131
sta 631
lda #1
sta 198
rts
.restart_code_string
!pet 147,17,17," ",34,":*",34,",08",19,0
; .restart_code_keys
; !pet 131,0
.restart_code_end
}
z_ins_restore
!ifdef Z3 {
jsr restore_game
beq +
jmp make_branch_true
+ jmp make_branch_false
}
!ifdef Z4 {
jsr restore_game
beq +
inx
+ jmp z_store_result
}
!ifdef Z5PLUS {
jsr restore_game
beq +
inx
+ jmp z_store_result
}
z_ins_save
!ifdef Z3 {
jsr save_game
beq +
jmp make_branch_true
+ jmp make_branch_false
}
!ifdef Z4 {
jsr save_game
jmp z_store_result
}
!ifdef Z5PLUS {
jsr save_game
jmp z_store_result
}
!zone save_restore {
.inputlen !byte 0
.filename !pet "!0" ; 0 is changed to slot number
.inputstring !fill 15 ; filename max 16 chars (fileprefix + 14)
.input_alphanum
; read a string with only alphanumeric characters into .inputstring
; return: x = number of characters read
; .inputstring: null terminated string read (max 20 characters)
; modifies a,x,y
jsr turn_on_cursor
lda #0
sta .inputlen
- jsr kernal_getchar
cmp #$14 ; delete
bne +
ldx .inputlen
beq -
dec .inputlen
pha
jsr turn_off_cursor
pla
jsr s_printchar
jsr turn_on_cursor
jmp -
+ cmp #$0d ; enter
beq .input_done
cmp #$20
beq .char_is_ok
sec
sbc #$30
cmp #$5B-$30
bcs -
sbc #$09 ;actually -$0a because C=0
cmp #$41-$3a
bcc -
adc #$39 ;actually +$3a because C=1
.char_is_ok
ldx .inputlen
cpx #14
bcs -
sta .inputstring,x
inc .inputlen
jsr s_printchar
jsr update_cursor
jmp -
.input_done
pha
jsr turn_off_cursor
pla
jsr s_printchar ; return
ldx .inputlen
lda #0
sta .inputstring,x
rts
.error
; accumulator contains BASIC error code
; most likely errors:
; A = $05 (DEVICE NOT PRESENT)
sta zp_temp + 1 ; Store error code for printing
jsr close_io ; even if OPEN failed, the file has to be closed
lda #>.disk_error_msg
ldx #<.disk_error_msg
jsr printstring_raw
; Add code to print error code!
lda #0
rts
list_save_files
lda #13
jsr s_printchar
ldx first_unavailable_save_slot_charcode
dex
stx .saveslot_msg + 9
ldx disk_info + 1 ; # of save slots
lda #0
- sta .occupied_slots - 1,x
dex
bne -
; Remember address of row where first entry is printed
lda zp_screenline
sta .base_screen_pos
lda zp_screenline + 1
sta .base_screen_pos + 1
; open the channel file
lda #1
ldx #<.dirname
ldy #>.dirname
jsr kernal_setnam ; call SETNAM
lda #2 ; file number 2
ldx disk_info + 4 ; Device# for save disk
+ ldy #0 ; secondary address 2
jsr kernal_setlfs ; call SETLFS
jsr kernal_open ; call OPEN
bcs .error ; if carry set, the file could not be opened
ldx #2 ; filenumber 2
jsr kernal_chkin ; call CHKIN (file 2 now used as input)
; Skip load address and disk title
ldy #32
- jsr kernal_readchar
dey
bne -
.read_next_line
lda #0
sta zp_temp + 1
; Read row pointer
jsr kernal_readchar
sta zp_temp
jsr kernal_readchar
ora zp_temp
beq .end_of_dir
jsr kernal_readchar
jsr kernal_readchar
- jsr kernal_readchar
cmp #0
beq .read_next_line
cmp #$22 ; Charcode for "
bne -
jsr kernal_readchar
cmp #$21 ; charcode for !
bne .not_a_save_file
jsr kernal_readchar
cmp #$30 ; charcode for 0
bcc .not_a_save_file
cmp first_unavailable_save_slot_charcode
; cmp #$3a ; (charcode for 9) + 1
bcs .not_a_save_file
tax
lda .occupied_slots - $30,x
bne .not_a_save_file ; Since there is another save file with the same number, we ignore this file.
txa
sta .occupied_slots - $30,x
jsr printchar_raw
lda #58
jsr printchar_raw
lda #32
jsr printchar_raw
dec zp_temp + 1
- jsr kernal_readchar
.not_a_save_file
cmp #$22 ; Charcode for "
beq .end_of_name
bit zp_temp + 1
bpl - ; Skip printing if not a save file
jsr printchar_raw
bne - ; Always branch
.end_of_name
- jsr kernal_readchar
cmp #0 ; EOL
bne -
bit zp_temp + 1
bpl .read_next_line ; Skip printing if not a save file
lda #13
jsr printchar_raw
bne .read_next_line
.end_of_dir
jsr close_io
; Fill in blanks
ldx #0
- lda .occupied_slots,x
bne +
txa
ora #$30
jsr printchar_raw
lda #58
jsr printchar_raw
lda #13
jsr printchar_raw
+ inx
cpx disk_info + 1 ; # of save slots
bcc -
; Sort list
ldx #1
stx .sort_item
- jsr .insertion_sort_item
inc .sort_item
ldx .sort_item
cpx disk_info + 1; # of save slots
bcc -
lda #1 ; Signal success
rts
.insertion_sort_item
; Parameters: x, .sort_item: item (1-9)
stx .current_item
-- jsr .calc_screen_address
stx zp_temp + 2
sta zp_temp + 3
ldx .current_item
dex
jsr .calc_screen_address
stx zp_temp
sta zp_temp + 1
ldy #0
lda (zp_temp + 2),y
cmp (zp_temp),y
bcs .done_sort
; Swap items
ldy #17
- lda (zp_temp),y
pha
lda (zp_temp + 2),y
sta (zp_temp),y
pla
sta (zp_temp + 2),y
dey
bpl -
dec .current_item
ldx .current_item
bne --
.done_sort
rts
.calc_screen_address
lda .base_screen_pos
ldy .base_screen_pos + 1
stx .counter
clc
- dec .counter
bmi +
adc #40
tax
tya
adc #0
tay
txa
bcc - ; Always branch
+ tax
tya
rts
.dirname
!pet "$"
.occupied_slots
!fill 10,0
.disk_error_msg
!pet 13,"Disk error #",0
.sort_item
!byte 0
.current_item
!byte 0
.counter
!byte 0
.base_screen_pos
!byte 0,0
.insert_save_disk
ldx disk_info + 4 ; Device# for save disk
lda current_disks - 8,x
sta .last_disk
beq .dont_print_insert_save_disk ; Save disk is already in drive.
jsr prepare_for_disk_msgs
ldy #0
jsr print_insert_disk_msg
ldx disk_info + 4 ; Device# for save disk
lda #0
sta current_disks - 8,x
beq .insert_done
.dont_print_insert_save_disk
ldx #0
ldy #5
- jsr kernal_delay_1ms
dex
bne -
dey
bne -
.insert_done
ldx #0
!ifdef Z5PLUS {
jmp erase_window
} else {
jsr erase_window
ldx window_start_row + 1 ; First line in lower window
ldy #0
jmp set_cursor
}
.insert_story_disk
ldy .last_disk
beq + ; Save disk was in drive before, no need to change
bmi + ; The drive was empty before, no need to change disk now
jsr print_insert_disk_msg
tya
ldx disk_info + 4 ; Device# for save disk
sta current_disks - 8,x
+ ldx #0
jmp erase_window
maybe_ask_for_save_device
lda ask_for_save_device
beq .dont_ask
lda #0
sta ask_for_save_device
.ask_again
lda #>.save_device_msg ; high
ldx #<.save_device_msg ; low
jsr printstring_raw
jsr .input_alphanum
cpx #0
beq .dont_ask
cpx #3
bcs .ask_again
; One or two digits
cpx #1
bne .two_digits
lda .inputstring
and #1
ora #8
bne .store_device ; Always jump
.two_digits
lda .inputstring + 1
and #1
ora #10
.store_device
sta disk_info + 4
.dont_ask
rts
restore_game
jsr maybe_ask_for_save_device
jsr .insert_save_disk
; List files on disk
jsr list_save_files
beq .restore_failed
; Pick a slot#
lda #>.saveslot_msg_restore ; high
ldx #<.saveslot_msg_restore ; low
jsr printstring_raw
lda #>.saveslot_msg ; high
ldx #<.saveslot_msg ; low
jsr printstring_raw
jsr .input_alphanum
cpx #1
bne .restore_failed
lda .inputstring
cmp first_unavailable_save_slot_charcode
bpl .restore_failed ; not a number (0-9)
tax
lda .occupied_slots - $30,x
beq .restore_failed ; If the slot is unoccupied, fail.
sta .restore_filename + 1
; Print "Restoring..."
lda #>.restore_msg
ldx #<.restore_msg
jsr printstring_raw
jsr .swap_pointers_for_save
; Perform restore
jsr do_restore
bcs .restore_failed ; if carry set, a file error has happened
; Swap in z_pc and stack_ptr
jsr .swap_pointers_for_save
lda use_reu
bmi +
jsr .insert_story_disk
+ jsr get_page_at_z_pc
lda #0
ldx #1
rts
.restore_failed
lda use_reu
bmi +
jsr .insert_story_disk
; Return failed status
+ lda #0
tax
rts
save_game
jsr maybe_ask_for_save_device
jsr .insert_save_disk
; List files on disk
jsr list_save_files
beq .restore_failed
; Pick a slot#
lda #>.saveslot_msg_save ; high
ldx #<.saveslot_msg_save ; low
jsr printstring_raw
lda #>.saveslot_msg ; high
ldx #<.saveslot_msg ; low
jsr printstring_raw
jsr .input_alphanum
cpx #1
bne .restore_failed
lda .inputstring
cmp first_unavailable_save_slot_charcode
bpl .restore_failed ; not a number (0-9)
sta .filename + 1
sta .erase_cmd + 3
; Enter a name
lda #>.savename_msg ; high
ldx #<.savename_msg ; low
jsr printstring_raw
jsr .input_alphanum
cpx #0
beq .restore_failed
; Print "Saving..."
lda #>.save_msg
ldx #<.save_msg
jsr printstring_raw
; Erase old file, if any
lda #5
ldx #<.erase_cmd
ldy #>.erase_cmd
jsr kernal_setnam
lda #$0f ; file number 15
ldx disk_info + 4 ; Device# for save disk
ldy #$0f ; secondary address 15
jsr kernal_setlfs
jsr kernal_open ; open command channel and send delete command)
bcs .restore_failed ; if carry set, the file could not be opened
lda #$0f ; filenumber 15
jsr kernal_close
; Swap in z_pc and stack_ptr
jsr .swap_pointers_for_save
; Perform save
jsr do_save
bcs .restore_failed ; if carry set, a save error has happened
; Swap out z_pc and stack_ptr
jsr .swap_pointers_for_save
lda use_reu
bmi +
jsr .insert_story_disk
+ lda #0
ldx #1
rts
do_restore
lda #3
ldx #<.restore_filename
ldy #>.restore_filename
jsr kernal_setnam
lda #1 ; file number
ldx disk_info + 4 ; Device# for save disk
ldy #1 ; not $01 means: load to address stored in file
jsr kernal_setlfs
lda #$00 ; $00 means: load to memory (not verify)
jsr kernal_load
php ; store c flag so error can be checked by calling routine
lda #1
jsr kernal_close
plp ; restore c flag
rts
do_save
lda .inputlen
clc
adc #2 ; add 2 bytes for prefix
ldx #<.filename
ldy #>.filename
jsr kernal_setnam
lda #1 ; file# 1
ldx disk_info + 4 ; Device# for save disk
ldy #1
jsr kernal_setlfs
lda #<(stack_start - zp_bytes_to_save)
sta $c1
lda #>(stack_start - zp_bytes_to_save)
sta $c2
ldx story_start + header_static_mem + 1
lda story_start + header_static_mem
clc
adc #>story_start
tay
lda #$c1 ; start address located in $C1/$C2
jsr kernal_save
php ; store c flag so error can be checked by calling routine
lda #1
jsr kernal_close
plp ; restore c flag
rts
.last_disk !byte 0
.saveslot !byte 0
.saveslot_msg_save !pet 13,"Save to",0 ; Will be modified to say highest available slot #
.saveslot_msg_restore !pet 13,"Restore from",0 ; Will be modified to say highest available slot #
.saveslot_msg !pet " slot (0-9, RETURN=cancel): ",0 ; Will be modified to say highest available slot #
.savename_msg !pet "Comment (RETURN=cancel): ",0
.save_msg !pet 13,"Saving...",13,0
.restore_msg !pet 13,"Restoring...",13,0
.save_device_msg !pet 13,"Device# (8-11, RETURN=default): ",0
.restore_filename !pet "!0*" ; 0 will be changed to selected slot
.erase_cmd !pet "s:!0*" ; 0 will be changed to selected slot
.swap_pointers_for_save
ldx #zp_bytes_to_save - 1
- lda zp_save_start,x
ldy stack_start - zp_bytes_to_save,x
sta stack_start - zp_bytes_to_save,x
sty zp_save_start,x
dex
bpl -
rts
}
|
src/kernel/arch/x86/irq-stubs.asm | narke/Aragveli | 4 | 165785 | <reponame>narke/Aragveli
; Copyright (c) 2017, 2020 <NAME>.
; All rights reserved.
; Use of this source code is governed by a MIT license that can be
; found in the LICENSE file.
; Interrupt Requests (IRQs)
section .text
; The address of the table of handlers (defined in irq.c)
[extern x86_irq_handler_array]
; The address of the table of wrappers (defined below, and shared with irq.c)
[global x86_irq_wrapper_array]
;
[extern g_pit_ticks]
[extern g_localApicAddr]
[global pit_interrupt]
[global spurious_interrupt_handler]
%macro SAVE_REGISTERS 0
push edi
push esi
push edx
push ecx
push ebx
push eax
sub esp, 2
push word ss
push word ds
push word es
push word fs
push word gs
%endmacro
%macro RESTORE_REGISTERS 0
pop word gs
pop word fs
pop word es
pop word ds
pop word ss
add esp, 2
pop eax
pop ebx
pop ecx
pop edx
pop esi
pop edi
pop ebp
%endmacro
; These pre-handlers are for IRQ (Master PIC)
%macro X86_IRQ_WRAPPER_MASTER 1
align 4
x86_irq_wrapper_%1:
; Fake error code
push 0
; Backup the actual context
push ebp
mov ebp, esp
SAVE_REGISTERS
; Call the handler with IRQ number as argument
push %1
lea edi, [x86_irq_handler_array]
call [edi+4*%1]
add esp, 4
; Send EOI to PIC. See Intel 8259 datasheet
mov al, 0x20
out byte 0x20, al
RESTORE_REGISTERS
; Remove fake error code
add esp, 4
iret
%endmacro
; These pre-handlers are for IRQ (Slave PIC)
%macro X86_IRQ_WRAPPER_SLAVE 1
align 4
x86_irq_wrapper_%1:
; Fake error code
push 0
; Backup the actual context
push ebp
mov ebp, esp
SAVE_REGISTERS
; Call the handler with IRQ number as argument
push %1
lea edi, [x86_irq_handler_array]
call [edi+4*%1]
add esp, 4
; Send EOI to PIC. See Intel 8259 datasheet
mov byte al, 0x20
out byte 0xa0, al
out byte 0x20, al
RESTORE_REGISTERS
; Remove fake error code
add esp, 4
iret
%endmacro
X86_IRQ_WRAPPER_MASTER 0
X86_IRQ_WRAPPER_MASTER 1
X86_IRQ_WRAPPER_MASTER 2
X86_IRQ_WRAPPER_MASTER 3
X86_IRQ_WRAPPER_MASTER 4
X86_IRQ_WRAPPER_MASTER 5
X86_IRQ_WRAPPER_MASTER 6
X86_IRQ_WRAPPER_MASTER 7
X86_IRQ_WRAPPER_SLAVE 8
X86_IRQ_WRAPPER_SLAVE 9
X86_IRQ_WRAPPER_SLAVE 10
X86_IRQ_WRAPPER_SLAVE 11
X86_IRQ_WRAPPER_SLAVE 12
X86_IRQ_WRAPPER_SLAVE 13
X86_IRQ_WRAPPER_SLAVE 14
X86_IRQ_WRAPPER_SLAVE 15
; PIT interrupt
pit_interrupt:
push eax
push edi
mov eax, dword [g_pit_ticks]
inc eax
mov dword [g_pit_ticks], eax
mov edi, [g_localApicAddr]
add edi, 0xb0 ; Write to the register with offset 0xB0...
xor eax, eax ; ...using the value 0 to signal an end of interrupt.
stosd
pop eax
pop edi
iret
; Spurious interrupt
spurious_interrupt_handler:
iret
section .rodata
; Build the x86_irq_wrapper_array, shared with irq.c
align 32, db 0
x86_irq_wrapper_array:
dd x86_irq_wrapper_0
dd x86_irq_wrapper_1
dd x86_irq_wrapper_2
dd x86_irq_wrapper_3
dd x86_irq_wrapper_4
dd x86_irq_wrapper_5
dd x86_irq_wrapper_6
dd x86_irq_wrapper_7
dd x86_irq_wrapper_8
dd x86_irq_wrapper_9
dd x86_irq_wrapper_10
dd x86_irq_wrapper_11
dd x86_irq_wrapper_12
dd x86_irq_wrapper_13
dd x86_irq_wrapper_14
dd x86_irq_wrapper_15
|
source/soundengine.asm | tragicmuffin/untitledarpg-nes | 0 | 175820 | <reponame>tragicmuffin/untitledarpg-nes
;;;; Sound Engine ;;;;
;; Based on Nerdy Nights Sound tutorial (http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=23452)
; Sound is organized into 6 streams, including 4 dedicated music streams, and two SFX streams.
; Music/SFX streams are listed by priority.
; Streams with higher indices have higher priority and will overwrite the data coming in from lower priority streams.
; SFX have highest priority so they will always play above music.
; When an SFX stream takes over a sound channel, music streams will continue but that channel's music stream will be overtaken by the SFX.
; Songs and SFX will be loaded from .i files.
; TODO: Implement last features of http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=26247
;;; Approximate tempo chart ;;;;
; Equation: Y = (17/30)*BPM + (2/3)
; 110 BPM = $3F
; 140 BPM = $50
; 450 BPM = $FF
; Store sound engine variables starting at $0300
.rsset $0300
;;; Variables ;;;
sound_disable_flag .rs 1 ; state of sound engine (0=on, 1=off)
sound_temp1 .rs 1 ; temporary variables
sound_temp2 .rs 1
sound_sq1_old .rs 1 ; last value written to $4003 (used to avoid crackling in squares)
sound_sq2_old .rs 1 ; last value written to $4007 (used to avoid crackling in squares)
jmp_ptr .rs 2 ; pointer used for indirect jumping
pause_flag .rs 1 ; flag set on pause to force lower volume envelopes on music streams
pause_temp .rs 1 ; temp variable to store duty and counter settings during pause filter
;; Data streams
stream_curr_sound .rs 6 ; song/sfx currently playing on stream
stream_status .rs 6 ; status byte (Bit0: 0=stream disabled, 1=stream enabled; Bit1: 0=not resting, 1=resting)
stream_channel .rs 6 ; channel that stream is playing on
stream_duty .rs 6 ; initial duty settings for this stream (volume overwritten by envelope)
stream_volenv .rs 6 ; current volume envelope
stream_volenv_index .rs 6 ; current position within the volume envelope
stream_ptr_LO .rs 6 ; low byte of pointer to data stream
stream_ptr_HI .rs 6 ; high byte of pointer to data stream
stream_tempo .rs 6 ; the value to add to our ticker total each frame
stream_note_LO .rs 6 ; low 8 bits of period for the current note playing on the stream
stream_note_HI .rs 6 ; high 3 bits of the note period
stream_ticker_total .rs 6 ; our running ticker total.
stream_note_length_counter .rs 6 ; how long a note should be played (next note will be loaded and played when this reaches 0)
stream_note_length .rs 6 ; keeps track of last note length encountered in stream (this way, several notes can follow one note length)
stream_loop1_counter .rs 6 ; finite looping counter for loop 1
stream_loop1_address .rs 6 ; finite looping address for loop 1
stream_loop2_counter .rs 6 ; finite looping counter for loop 2
stream_loop2_address .rs 6 ; finite looping address for loop 2
;; APU buffering
; Bytes 0-3: Square 1 ports ($4000-$4003)
; Bytes 4-7: Square 2 ports ($4004-$4007)
; Bytes 8-11: Triangle ports ($4008-$400B)
; Bytes 12-15: Noise ports ($400C-$400F)
soft_apu_ports .rs 16 ; reserve 16 bytes for APU buffering
;;; Constants ;;;
NUMSTREAMS = 6 ; number of streams allocated
; Stream aliases
MUSIC_SQ1 = $00 ; Music square wave 1 channel
MUSIC_SQ2 = $01 ; Music square wave 2 channel
MUSIC_TRI = $02 ; Music triangle wave channel
MUSIC_NOI = $03 ; Music noise channel
SFX_1 = $04 ; SFX channel 1 (can be set to any sound channel)
SFX_2 = $05 ; SFX channel 2 (can be set to any sound channel)
; Channel aliases
SQUARE_1 = $00
SQUARE_2 = $01
TRIANGLE = $02
NOISE = $03
;; Note length lookup table (order must match note length aliases)
note_length_table:
.db $01 ; 32nd note (shortest)
.db $02 ; 16th note
.db $04 ; Eighth note
.db $08 ; Quarter note
.db $10 ; Half note
.db $20 ; Whole note
.db $03 ; Dotted 16th note
.db $06 ; Dotted 8th note
.db $0C ; Dotted quarter note
.db $18 ; Dotted half note
.db $30 ; Dotted whole note
.db $05 ; Swing note: 5/32
.db $0A ; Swing note: 5/16 = 10/32
.db $0E ; Swing note: 7/16 = 14/32
.db $07 ; Swing note: 7/32
.db $0B ; Swing note: 11/32
.db $16 ; Swing note: 11/16 = 22/32
; Note length aliases (order must match note lookup table)
n_32 = $80 ; 32nd note
n_16 = $81 ; 16th note
n_8 = $82 ; Eighth note
n_4 = $83 ; Quarter note
n_2 = $84 ; Half note
n_1 = $85 ; Whole note
n_d16 = $86 ; Dotted 16th note
n_d8 = $87 ; Dotted Eighth note
n_d4 = $88 ; Dotted Quarter note
n_d2 = $89 ; Dotted Half note
n_d1 = $8A ; Dotted Whole note
n_s5_32 = $8B ; Swing note: 5/32
n_s5_16 = $8C ; Swing note: 5/16 = 10/32
n_s7_16 = $8D ; Swing note: 7/16 = 14/32
n_s7_32 = $8E ; Swing note: 7/32
n_s11_32 = $8F ; Swing note: 11/32
n_s11_16 = $90 ; Swing note: 11/16 = 22/32
; Volume envelope pointer table
volume_envelopes:
.dw se_ve_muted
.dw se_ve_constant
.dw se_ve_stac1
.dw se_ve_stac2
.dw se_ve_fadein
.dw se_ve_fadeout1
.dw se_ve_fadeout2
.dw se_ve_stac_echo
.dw se_ve_tri1
.dw se_ve_drumkick
.dw se_ve_drumsnare1
.dw se_ve_drumsnare2
.dw se_ve_drumhat
.dw se_ve_drumhat2
.dw se_ve_drumhat3
.dw se_ve_drumhat4
.dw se_ve_drumcrash1
; Volume envelope aliases
ve_muted = $00
ve_constant = $01
ve_stac1 = $02
ve_stac2 = $03
ve_fadein = $04
ve_fadeout1 = $05
ve_fadeout2 = $06
ve_stac_echo = $07
ve_tri1 = $08
ve_drumkick = $09
ve_drumsnare1 = $0A
ve_drumsnare2 = $0B
ve_drumhat = $0C
ve_drumhat2 = $0D
ve_drumhat3 = $0E
ve_drumhat4 = $0F
ve_drumcrash1 = $10
; Opcode jump table
sound_opcodes:
.dw se_op_endsound ; should be $A0
.dw se_op_change_ve ; should be $A1
.dw se_op_change_duty ; should be $A2
.dw se_op_change_tempo ; should be $A3
.dw se_op_inf_loop ; should be $A4
.dw se_op_loop1_set_counter ; should be $A5
.dw se_op_loop1_set_address ; should be $A6
.dw se_op_loop2_set_counter ; should be $A7
.dw se_op_loop2_set_address ; should be $A8
; Opcode aliases
endsound = $A0
change_ve = $A1
change_duty = $A2
change_tempo = $A3
inf_loopto = $A4
loop1for = $A5
loop1to = $A6
loop2for = $A7
loop2to = $A8
; Alternate opcode aliases
loopfor = $A5
loopto = $A6
;;; Entrances (sound engine accessor functions) ;;;
sound_init:
LDA #%00001111
STA $4015
LDA #$00
STA sound_disable_flag ; clear disable flag
LDA #$FF
STA sound_sq1_old
STA sound_sq2_old
se_silence:
LDA #$30
STA soft_apu_ports+0 ; set SQ1 volume to 0
STA soft_apu_ports+4 ; set SQ2 volume to 0
STA soft_apu_ports+12 ; set NOISE volume to 0
LDA #$80
STA soft_apu_ports+8 ; silence TRIANGLE
RTS ; end of sound_init
sound_disable:
LDA #$00
STA $4015 ; disable all sound channels
LDA #$01
STA sound_disable_flag ; set disable flag
RTS
; sound_load will prepare the sound engine to play a song or sfx.
; input A: song/sfx number to play
sound_load:
STA sound_temp1 ; save song number
ASL A ; multiply by 2. we are indexing into a table of pointers (words)
TAY
LDA song_headers, y ; setup the pointer to our song header
STA sound_ptr
LDA song_headers+1, y
STA sound_ptr+1
LDY #$00
LDA [sound_ptr], y ; read byte: # streams
STA sound_temp2 ; store in a temp variable. we will use this as a loop counter: how many streams to read stream headers for
INY
.loop:
LDA [sound_ptr], y ; read byte: stream number
TAX ; stream number acts as our variable index
INY
LDA [sound_ptr], y ; read byte: status (1=enable, 0=disable)
STA stream_status, x
BEQ .next_stream ; if status byte is 0, stream disabled, so we are done
INY
LDA [sound_ptr], y ; read byte: channel number
STA stream_channel, x
INY
LDA [sound_ptr], y ; read byte: initial duty settings
STA stream_duty, x
INY
LDA [sound_ptr], y ; read byte: volume envelope
STA stream_volenv, x
INY
LDA [sound_ptr], y ; read byte: pointer to stream data, LO byte (little endian, so low byte first)
STA stream_ptr_LO, x
INY
LDA [sound_ptr], y ; read byte: pointer to stream data, HI byte (little endian, so high byte last)
STA stream_ptr_HI, x
INY
LDA [sound_ptr], y ; read byte: initial tempo
STA stream_tempo, x
; Initializations for stream variables not passed through header
LDA #$00 ; initialize volume envelope index (start of envelope)
STA stream_volenv_index, x
LDA #$FF ; initialize ticker counters (large value so first tick will happen quickly)
STA stream_ticker_total, x
LDA #$01 ; initialize note length counters
STA stream_note_length_counter, x
LDA #$00 ; initialize finite loop counters
STA stream_loop1_counter, x
LDA #$00 ; initialize finite loop counters
STA stream_loop2_counter, x
.next_stream:
INY
LDA sound_temp1 ; song number
STA stream_curr_sound, x
DEC sound_temp2 ; our loop counter
BNE .loop
RTS
; sound_play_frame advances the sound engine by one frame
sound_play_frame:
LDA sound_disable_flag
BNE .done ; if disable flag is set, don't advance a frame
LDX #$00
.loop:
LDA stream_status, x
AND #$01 ; check whether the stream is active
BEQ .nextstream ; if not, skip it
LDA stream_ticker_total, x
CLC
ADC stream_tempo, x ; add the tempo to the ticker total. a "tick" will happen on overflow.
STA stream_ticker_total, x
BCC .nextstream ; if no overflow occured, there was no tick. we're done with this stream.
.tick
DEC stream_note_length_counter, x ; also decrement the note length counter
BNE .tick_update ; if counter is non-zero, our note isn't finished playing yet, end
.note_finished
LDA stream_note_length, x ; else our note is finished. reload the note length counter
STA stream_note_length_counter, x
JSR se_fetch_byte ; if the note is finished, advance the stream
.tick_update
JSR se_set_temp_ports ; populate port buffers with new stream data (happens on every tick)
.nextstream:
INX
CPX #NUMSTREAMS ; check if there is another stream
BNE .loop ; end after all streams have been checked and/or played
.endloop
JSR se_set_apu ; write data to APU (streams are buffered above and written all at once)
.done:
RTS
sound_pause:
; Runs when game is paused
LDA #$01
STA pause_flag ; set pause flag to activate volume filter
RTS
sound_unpause:
; Runs when game is unpaused
LDA #$00
STA pause_flag ; clear pause flag to deactivate volume filter
RTS
;;; Internal Subroutines ;;;
; se_fetch_byte reads one byte from a sound data stream and handles it.
; input X: stream number
se_fetch_byte:
LDA stream_ptr_LO, x ; get LO byte of pointer to note data stream
STA sound_ptr
LDA stream_ptr_HI, x ; get HI byte of pointer to note data stream
STA sound_ptr+1
LDY #$00
.fetch:
LDA [sound_ptr], y ; check next byte and determine whether it is Note, Note Length, or Opcode data
BPL .note ; if < $80, it's a Note
CMP #$A0
BCC .note_length ; else if < $A0, it's a Note Length
.opcode: ; else it's an Opcode
JSR se_opcode_launcher ; run opcode launcher (once opcode is run, it will RTS back here)
INY ; next position in the data stream
LDA stream_status, x
AND #%00000001
BNE .fetch ; after our opcode is done, grab another byte unless the stream is disabled
JMP .end ; if the stream is disabled, quit (otherwise, fetch next note).
.note_length:
AND #%01111111 ; zero out Bit7 (subtracts $80 to align note length aliases with lookup table offsets)
STY sound_temp1 ; save Y because we are about to destroy it
TAY
LDA note_length_table, y ; get the note length count value
STA stream_note_length, x ; save the note length in RAM so we can use it to refill the counter
STA stream_note_length_counter, x ; stick it in our note length counter
LDY sound_temp1 ; restore Y
INY ; set index to next byte in the stream
JMP .fetch ; since this was a Note Length, fetch the next byte to get the Note
.note:
STY sound_temp1 ; save our index into the data stream
ASL A ; muliply by 2
TAY
LDA note_table, y
STA stream_note_LO, x
LDA note_table+1, y
STA stream_note_HI, x
LDY sound_temp1 ; restore data stream index
LDA #$00 ; reset volume envelope for next note
STA stream_volenv_index, x
JSR se_check_rest ; check for a rest
.update_pointer:
INY
TYA
CLC
ADC stream_ptr_LO, x ; increment LO byte of pointer
STA stream_ptr_LO, x
BCC .end
INC stream_ptr_HI, x ; if LO byte wrapped, increment HI byte
.end:
RTS
se_opcode_launcher:
STY sound_temp1 ; save y register, because we are about to destroy it
SEC
SBC #$A0 ; turn our opcode byte into a table index by subtracting $A0 ($A0->$00, $A1->$01, $A2->$02, etc. Tables index from $00.)
ASL A ; multiply by 2 because we index into a table of addresses (words)
TAY
LDA sound_opcodes, y ; get low byte of subroutine address
STA jmp_ptr
LDA sound_opcodes+1, y ; get high byte
STA jmp_ptr+1
LDY sound_temp1 ; restore our y register
INY ; set to next position in data stream (assume an argument)
JMP [jmp_ptr] ; indirect jump to our opcode subroutine
; The opcode subroutine will RTS, returning to the JSR call in se_fetch_byte.
; se_check_rest reads the last note byte to see if it is our dummy "rest" note
se_check_rest:
LDA [sound_ptr], y ; read the last note byte again
CMP #rest ; is it a rest ($5E)?
BNE .not_rest
LDA stream_status, x
ORA #%00000010 ; if so, set the rest bit in the status byte
BNE .store ; (this will always branch, but BNE is cheaper than a JMP)
.not_rest:
LDA stream_status, x
AND #%11111101 ; if not, clear the rest bit in the status byte
.store:
STA stream_status, x
RTS
; se_set_apu writes buffered stream data to the APU ports.
; To avoid crackling generated by writing to square ports $4003 and $4007 too often, we only write if there was a note change.
se_set_apu:
.square1:
LDA soft_apu_ports+0
STA $4000
LDA soft_apu_ports+1
STA $4001
LDA soft_apu_ports+2
STA $4002
LDA soft_apu_ports+3
CMP sound_sq1_old ; compare to value last written to $4003
BEQ .square2 ; don't write this frame if it's unchanged
STA $4003
STA sound_sq1_old ; save the value we just wrote to $4003
.square2:
LDA soft_apu_ports+4
STA $4004
LDA soft_apu_ports+5
STA $4005
LDA soft_apu_ports+6
STA $4006
LDA soft_apu_ports+7
CMP sound_sq2_old ; compare to value last written to $4007
BEQ .triangle ; don't write this frame if it's unchanged
STA $4007
STA sound_sq2_old ; save the value we just wrote to $4007
.triangle:
LDA soft_apu_ports+8
STA $4008
LDA soft_apu_ports+10 ; $4009 is unused, so we skip it
STA $400A
LDA soft_apu_ports+11
STA $400B
.noise:
LDA soft_apu_ports+12
STA $400C
LDA soft_apu_ports+14 ; $400D is unused, so we skip it
STA $400E
LDA soft_apu_ports+15
STA $400F;$81E9
RTS
; se_set_temp_ports populates port buffers (soft_apu_ports) with stream data
se_set_temp_ports:
LDA stream_channel, x ; load the channel number of the stream and use it find the soft_apu_ports index for that channel
ASL A
ASL A
TAY
JSR se_set_stream_volume
LDA #$08 ; *disable sweep
STA soft_apu_ports+1, y ; sweep
LDA stream_note_LO, x
STA soft_apu_ports+2, y ; period LO
LDA stream_note_HI, x
STA soft_apu_ports+3, y ; period HI
RTS
; se_set_stream_volume modifies a stream's volume data using its volume envelope
se_set_stream_volume:
STY sound_temp1 ; save our index into soft_apu_ports (we are about to destroy Y)
LDA stream_volenv, x ; which volume envelope?
ASL A ; multiply by 2 because we are indexing into a table of addresses (words)
TAY
LDA volume_envelopes, y ; get the low byte of the address from the pointer table
STA sound_ptr ; put it into our pointer variable
LDA volume_envelopes+1, y ; get the high byte of the address
STA sound_ptr+1
.read_ve:
LDY stream_volenv_index, x ; our current position within the volume envelope.
LDA [sound_ptr], y ; grab the value.
CMP #$FF
BNE .set_vol ; if not FF, set the volume
DEC stream_volenv_index, x ; else if FF, go back one and read again
JMP .read_ve ; ($FF essentially tells us to repeat the last volume value for the remainder of the note)
.set_vol:
STA sound_temp2 ; save our new volume value (about to destroy A)
CPX #TRIANGLE ; triangle needs to be handled specially (a $00 in envelope should clear bits 0-6, not just 0-3)
BNE .squares ; if not triangle channel, go ahead
LDA sound_temp2
BNE .squares ; else if volume not zero, go ahead (treat same as squares)
LDA #$80
BMI .store_vol ; else silence the channel with #$80
.squares:
LDA stream_duty, x ; get current vol/duty settings
AND #$F0 ; zero out the old volume (preserving duty setting)
ORA sound_temp2 ; OR our new volume in
.store_vol:
JSR se_pause_filter ; if a pause state is active, lower volume before writing
LDY sound_temp1 ; get our index into soft_apu_ports
STA soft_apu_ports, y ; store the volume in our temp port
INC stream_volenv_index, x ; set our volume envelop index to the next position
.rest_check
; Check the rest flag. If set, overwrite the volume data we just loaded into buffer with a silence value.
LDA stream_status, x
AND #%00000010 ; check rest flag
BEQ .done ; if clear, no rest, so quit
LDA stream_channel, x
CMP #TRIANGLE ; if triangle, silence with #$80
BEQ .rest_tri
LDA #$30 ; else, silence with #$30
BNE .rest_store ; (this will always branch, but BNE is cheaper than a JMP)
.rest_tri:
LDA #$80
.rest_store:
STA soft_apu_ports, y
.done
RTS
; When a pause state is active, se_pause_filter decreases the incoming volume before a write to soft_apu_ports.
se_pause_filter:
PHA ; save incoming volume to stack
AND #$0F ; clear all duty and counter data from A, leaving only last 4 volume bits
STA pause_temp ; store volume-only data
LDA pause_flag ; check pause flag
BEQ .nopause ; if flag is not set, just return incoming volume
CPX #SFX_1 ; check which stream we're on. we only want to lower music streams.
BCS .nopause ; if X >= SFX_1, just return incoming volume
; SQ_1 usually functions as the bass. Lower this only a little.
LDA stream_channel, x
CMP #SQUARE_1
BNE .sq1_done ; not SQ_1
LDA pause_temp ; load volume-only data
TAY ; copy volume to Y for lookup
SEC
SBC VolumeScaling_SQ1, y ; subtract scaling in lookup table from A
STA pause_temp ; store the new volume
PLA ; retrieve original incoming volume
AND #$F0 ; clear volume bits
ORA pause_temp ; and replace with new volume
JMP .done ; return scaled volume in A
.sq1_done:
; SQ_2 usually functions as treble. Lower this a lot.
LDA stream_channel, x
CMP #SQUARE_2
BNE .sq2_done ; not SQ_2
LDA pause_temp ; load volume-only data
TAY ; copy volume to Y for lookup
SEC
SBC VolumeScaling_SQ2, y ; subtract scaling in lookup table from A
STA pause_temp ; store the new volume
PLA ; retrieve original incoming volume
AND #$F0 ; clear volume bits
ORA pause_temp ; and replace with new volume
JMP .done ; return scaled volume in A
.sq2_done:
; TRI cannot be lowered, so mute it.
LDA stream_channel, x
CMP #TRIANGLE
BNE .tri_done ; not TRI
PLA ; retrieve incoming volume just to get it off the stack
LDA #$80 ; overwrite volume with $80 to mute triangle
JMP .done ; return
.tri_done:
; NOI functions as percussion. Lower this only a little.
LDA stream_channel, x
CMP #NOISE
BNE .noi_done ; not NOI
LDA pause_temp ; load volume-only data
TAY ; copy volume to Y for lookup
SEC
SBC VolumeScaling_NOI, y ; subtract scaling in lookup table from A
STA pause_temp ; store the new volume
PLA ; retrieve original incoming volume
AND #$F0 ; clear volume bits
ORA pause_temp ; and replace with new volume
JMP .done ; return scaled volume in A
.noi_done:
.nopause
PLA ; retrieve original volume from stack and end
.done:
RTS
; Volume scaling lookup tables. If incoming volume is A ($00-$0F), volume will be decreased by byte with index A.
;; $00, $01, $02, $03, $04, $05, $06, $07, $08, $09, $0A, $0B, $0C, $0D, $0E, $0F ; input
VolumeScaling_SQ1:
.db $00, $00, $00, $01, $02, $03, $04, $04, $05, $06, $06, $07, $07, $07, $08, $08 ; subtraction
VolumeScaling_SQ2:
.db $00, $01, $01, $02, $02, $03, $04, $05, $06, $07, $08, $08, $09, $09, $0A, $0A ; subtraction
VolumeScaling_NOI:
.db $00, $00, $00, $01, $01, $02, $02, $03, $03, $04, $05, $06, $06, $07, $07, $08 ; subtraction
;; Opcode handlers
se_op_endsound:
; Ends all reading of the stream.
; Argument byte(s): N/A
; Usage:
; .db n_4, C4, D4, E4, F4
; .db endsound
LDA stream_status, x ; we've reached end of stream, so disable it and silence
AND #%11111110
STA stream_status, x ; clear enable flag in status byte
LDA stream_channel, x
CMP #TRIANGLE
BEQ .silence_tri ; triangle is silenced differently from squares and noise
LDA #$30 ; squares and noise silenced with $30
BNE .silence
.silence_tri:
LDA #$80 ; triangle silenced with $80
.silence:
STA stream_duty, x ; store silence value in the stream's volume variable.
RTS
se_op_change_ve:
; Changes the volume envelope used by subsequent notes.
; Argument byte(s): [1] Volume envelope number/alias
; Usage:
; .db n_4, C4, D4, E4, F4
; .db change_ve
; .db ve_stac1
; .db n_4, C4, D4, E4, F4
LDA [sound_ptr], y ; read the argument
STA stream_volenv, x ; store it in our volume envelope variable
LDA #$00
STA stream_volenv_index, x ; reset volume envelope index to the beginning
RTS
se_op_change_duty:
; Changes the duty cycle used by subsequent notes.
; Argument byte(s): [1] New duty cycle byte
; Usage:
; .db n_4, C4, D4, E4, F4
; .db change_duty
; .db $B7
; .db n_4, C4, D4, E4, F4
LDA [sound_ptr], y ; read the argument (which duty cycle to change to)
STA stream_duty, x ; store it.
RTS
se_op_change_tempo:
; Changes the tempo used by subsequent notes.
; Argument byte(s): [1] New tempo
; Usage:
; .db n_4, C4, D4, E4, F4
; .db change_tempo
; .db $80
; .db n_4, C4, D4, E4, F4
LDA [sound_ptr], y ; read the argument
STA stream_tempo, x ; store it in our tempo variable
RTS
se_op_inf_loop:
; Loops to a label to repeat a segment of notes (indefinitely).
; Argument byte(s): [1] Loop address (LO byte), [2] Loop address (HI byte)
; Usage:
; .db n_4, C4, D4, E4, F4
; .loop_point
; .db n_4, C5, D5, E5, F5
; .db inf_loopto
; .dw .loop_point
LDA [sound_ptr], y ; read LO byte of the address argument from the data stream
STA stream_ptr_LO, x ; save as our new data stream position
INY
LDA [sound_ptr], y ; read HI byte of the address argument from the data stream
STA stream_ptr_HI, x ; save as our new data stream position data stream position
STA sound_ptr+1 ; update the pointer to reflect the new position.
LDA stream_ptr_LO, x
STA sound_ptr
LDY #$FF ; After opcodes return, we do an INY. Since we reset the stream buffer position, we will want y to start out at $00 again.
RTS
se_op_loop1_set_counter:
; Sets the counter for how many times we should loop. Must be done before label used as finite looping address.
; Argument byte(s): [1] Number of times to loop
; Usage:
; .db n_4, C4, D4, E4, F4
; .db loopfor, $08
; .loop_point
; .db n_4, C5, D5, E5, F5
; ... (see below)
LDA [sound_ptr], y ; read the argument (# times to loop)
STA stream_loop1_counter, x ; store it in the loop counter variable
RTS
se_op_loop1_set_address:
; Sets the address where we will loop to. Loop counter must be set before the label of this address.
; Argument byte(s): [1] Loop address (LO byte), [2] Loop address (HI byte)
; Usage:
; .db n_4, C4, D4, E4, F4
; .db loopfor, $08
; .loop_point
; .db n_4, C5, D5, E5, F5
; .db loopto
; .dw .loop_point
DEC stream_loop1_counter, x ; decrement the counter
LDA stream_loop1_counter, x ; check the counter
BEQ .last_iteration ; if zero, we are done looping
JMP se_op_inf_loop ; if not zero, run a loop
.last_iteration:
INY ; skip the first byte of the address argument. the second byte will be skipped automatically upon return.
RTS
se_op_loop2_set_counter:
; Sets the counter for how many times we should loop. Must be done before label used as finite looping address.
; Argument byte(s): [1] Number of times to loop
; Usage: (Same as se_op_loop1_set_counter)
LDA [sound_ptr], y ; read the argument (# times to loop)
STA stream_loop2_counter, x ; store it in the loop counter variable
RTS
se_op_loop2_set_address:
; Sets the address where we will loop to. Loop counter must be set before the label of this address.
; Argument byte(s): [1] Loop address (LO byte), [2] Loop address (HI byte)
; Usage: (Same as se_op_loop1_set_address)
DEC stream_loop2_counter, x ; decrement the counter
LDA stream_loop2_counter, x ; check the counter
BEQ .last_iteration ; if zero, we are done looping
JMP se_op_inf_loop ; if not zero, run a loop
.last_iteration:
INY ; skip the first byte of the address argument. the second byte will be skipped automatically upon return.
RTS
;;; Tables and Includes ;;;
;; Note period lookup table
.include "se_note_table.i"
;; Constants for percussion noise samples
.include "se_percussion.i"
;; Volume envelopes (aliases and pointers at top)
.include "se_envelopes.i"
;; Pointers and song data
; Song pointer table (each entry is a pointer to a song header)
song_headers:
.dw silence_header ; Music: silence
; Song files
.include "s_silence.i"
; Song aliases
sng_Silence = $00
|
programs/oeis/017/A017520.asm | neoneye/loda | 22 | 82439 | ; A017520: a(n) = (11*n + 10)^12.
; 1000000000000,7355827511386641,1152921504606846976,39959630797262576401,614787626176508399616,5688009063105712890625,37133262473195501387776,188031682201497672618081,784716723734800033386496,2812664781782894485727281,8916100448256000000000000,25542038069936263923006961,67214060505664762405851136,164549728404324620728411041,378552550483148382977130496,825005006849765777587890625,1714570434475502278801821696,3416604542324232545384738641,6557827967253220516257857536,12171087315874829579909431761,21914624432020321000000000000,38388797722185519065061084481,65585296971568246764230148096,109513833574845676773925608481,179063370050426074779119128576,287169505347519450195556640625,452377017219528840630098722816,700907174940351875150276622001,1069363705188756702611733221376,1608239688021097644574300393441,2386420683693101056000000000000,3496917589577226791795034339201,5064106685657562460643248377856,7252804675881436727210363928721,10279563944029090291760398073856,14426638435467322602890869140625,20059144316135212607058101211136,27646022662045948876583015308161,37785504761378948674749271638016,51235885083508853935305470692321,68952523554931640625000000000000,92132128505596173454447158291121,122265515591462830613214753980416,161200197298760918827871799931761,211214333490219270978877298446336,275103767122062920083301025390625,356284082063617120106689547206656,458909853273506385605676338637121,588013514877506214979375506067456,749666550469685041251761511208401,951166013805414055936000000000000,1201249718626740564963180019260241,1510343795383404815625408037195776,1890846701885093112349176364977601,2357454196315301139084779261526016,2927530236503150951433769775390625,3621529260912667230872398707429376,4463475836574164471582877087248881,5481508229334608701193166778269696,6708493064609970874779564967621681,8182718904632857144561000000000000,9948677273438057188906683618366561,12057940416038372864241080977063936,14570145886022259902582039813226241,17554098918851829908191735901392896,21089004469243826925754547119140625,25265841773058837812630033369399296,30188895340080564350696045756583441,35977457397008146941567923346804736,42767717983077781278078137896412161,50714860157241037295616000000000000,59995379109122034297528468395530081,70809645379520944647233906953424896,83384733893597028275871820289637681,97977542094724722452195922700926976,114878222143151253631343789306640625,134413953914881178729961850101436416,156953087406668433326571213168880801,182909685126716452300646822315032576,212748497131890182639460265000859841,246990403565262140303521000000000000,286218361857094751614277009933470801,331083898182466113108272263678918656,382314185324356924030920417017971921,440719751776932991117418498387808256,507202869744901554493542558837890625,582766672656234298171280011596660736,668525055912402737052504143865180961,765713417857855552832345379679113216,875700301364202115174052402047044721
mul $0,11
add $0,10
pow $0,12
|
registrar-registration.adb | annexi-strayline/AURA | 13 | 8049 | <reponame>annexi-strayline/AURA<gh_stars>10-100
------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Core --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * <NAME> (ANNEXI-STRAYLINE) --
-- --
-- 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 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 --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Assertions;
with Workers;
with Registrar.Registry;
with Registrar.Executive.Unit_Entry;
with Registrar.Registration.Unchecked_Deregister_Unit;
package body Registrar.Registration is
--
-- All Enter_Units simply fill and submit Work_Orders to the worker pool
--
----------------
-- Enter_Unit --
----------------
procedure Set_File_Name
(Order: out Executive.Unit_Entry.Unit_Entry_Order;
File : in Ada.Directories.Directory_Entry_Type)
is
begin
Executive.Unit_Entry.UBS.Set_Unbounded_String
(Target => Order.File_Full_Name,
Source => Ada.Directories.Full_Name (File));
end Set_File_Name;
----------------------------------------------------------------------------
-- Non-AURA units
procedure Enter_Unit (File: in Ada.Directories.Directory_Entry_Type) is
Order: Executive.Unit_Entry.Unit_Entry_Order
:= (Tracker => Entry_Progress'Access,
AURA => False,
others => <>);
begin
Set_File_Name (Order => Order, File => File);
Entry_Progress.Increment_Total_Items;
Workers.Enqueue_Order (Order);
end Enter_Unit;
----------------------------------------------------------------------------
-- AURA units
procedure Enter_Unit
(File : in Ada.Directories.Directory_Entry_Type;
AURA_Subsystem: in Registrar.Subsystems.Subsystem)
is
Order: Executive.Unit_Entry.Unit_Entry_Order
:= (Tracker => Entry_Progress'Access,
AURA => True,
AURA_Subsystem => AURA_Subsystem,
others => <>);
begin
Set_File_Name (Order => Order, File => File);
Entry_Progress.Increment_Total_Items;
Workers.Enqueue_Order (Order);
end Enter_Unit;
---------------------
-- Enter_Directory --
---------------------
procedure Enter_Directory
(Directory_Path: in String;
Order_Template: in Executive.Unit_Entry.Unit_Entry_Order)
is
use Ada.Directories;
Search: Search_Type;
File : Directory_Entry_Type;
Order: Executive.Unit_Entry.Unit_Entry_Order := Order_Template;
procedure Enter_Extension (Extension: in String) is
begin
Start_Search (Search => Search,
Directory => Directory_Path,
Pattern => "*." & Extension,
Filter => (Ordinary_File => True, others => False));
while More_Entries (Search) loop
Get_Next_Entry (Search => Search, Directory_Entry => File);
Set_File_Name (Order, File);
Entry_Progress.Increment_Total_Items;
Workers.Enqueue_Order (Order);
end loop;
End_Search (Search);
end Enter_Extension;
begin
Order.Tracker := Entry_Progress'Access;
Enter_Extension ("ads");
Enter_Extension ("adb");
Enter_Extension ("c");
end Enter_Directory;
--------------------------------------------------
procedure Enter_Directory
(Directory : in Ada.Directories.Directory_Entry_Type;
AURA_Subsystem: in Subsystems.Subsystem)
is
use Ada.Directories;
begin
Enter_Directory (Directory_Path => Full_Name (Directory),
Order_Template => (AURA => True,
AURA_Subsystem => AURA_Subsystem,
others => <>));
end Enter_Directory;
----------------
-- Enter_Root --
----------------
procedure Enter_Root is
use Ada.Directories;
begin
Enter_Directory (Directory_Path => Full_Name (Current_Directory),
Order_Template => (AURA => False,
others => <>));
end Enter_Root;
----------------------------
-- Request_AURA_Subsystem --
----------------------------
procedure Request_AURA_Subsystem (Name: in Unit_Names.Unit_Name;
OK : out Boolean)
is
use Subsystems;
package All_Subsystems renames Registry.All_Subsystems;
Requested_Subsys: constant Subsystem
:= (AURA => True,
Name => Name.Subsystem_Name,
State => Requested,
others => <>);
begin
if All_Subsystems.Contains_Element (Requested_Subsys) then
OK := All_Subsystems.Extract_Element(Requested_Subsys).AURA;
-- The registry already contains this subsystem. If it is not AURA
-- then that means the Root Project is already claiming this subsystem,
-- and therefore we can't aquire it.
--
-- Otherwise it's already been requested or aquired, and so no action
-- needs to be taken
else
-- Add it
All_Subsystems.Insert (New_Item => Requested_Subsys,
Inserted => OK);
pragma Assert (OK);
-- There are no cases where OK should be False. First of all, we
-- have already determined that it doesn't already exist in the set.
-- So if OK is False, this should mean it was inserted sometime between
-- that check and our attempt. That shouldn't happen because
-- Request_AURA_Subsystem should only be called from the CLI driver
-- before any work orders are executing.
end if;
end Request_AURA_Subsystem;
----------------------
-- Update_Subsystem --
----------------------
procedure Update_Subsystem (Update: Subsystems.Subsystem) is
begin
Registry.All_Subsystems.Replace (Update);
end Update_Subsystem;
-------------------------
-- Update_Library_Unit --
-------------------------
procedure Update_Library_Unit (Update: in Library_Units.Library_Unit) is
begin
Registry.All_Library_Units.Replace (Update);
end Update_Library_Unit;
--------------------------------
-- Update_Library_Unit_Subset --
--------------------------------
procedure Update_Library_Unit_Subset
(Update: in Library_Units.Library_Unit_Sets.Set) is
begin
if not Registry.All_Library_Units.Is_Subset (Update) then
raise Constraint_Error with
"Update_Library_Unit_Subset cannot add new units";
end if;
Registry.All_Library_Units.Include_Subset (Update);
end Update_Library_Unit_Subset;
-----------------------
-- Exclude_Manifests --
-----------------------
procedure Exclude_Manifests is
use Unit_Names;
use Library_Units;
Manifest: Library_Unit;
begin
for Subsys of Registry.All_Subsystems.Extract_Set loop
Manifest.Name := Subsys.Name & ".aura";
if Registry.All_Library_Units.Contains_Element (Manifest) then
Manifest := Registry.All_Library_Units.Extract_Element (Manifest);
Registrar.Registration.Unchecked_Deregister_Unit (Manifest);
end if;
end loop;
end Exclude_Manifests;
end Registrar.Registration;
|
Swapping Numbers/swapNums.asm | KyleErwin/Assembly | 0 | 100384 | segment .data
fmt db "The correct order is %.2f, %.2f, %.2f", 0xa, 0
segment .text
global swapNums
extern printf
;An assembly function to
; 1. Accept references to 3 foating point inputs.
; 2. The method must rearrange the numbers from smallest to largest.
;And is called by a c program
swapNums:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GET PARAMETERS ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
push rbp
movss xmm0, [rdi]
movss xmm1, [rsi]
movss xmm2, [rdx]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SORT ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;We need to do four comparisons, we'll compare the 1st
;number in our list with the 2nd. Swap if necessary. Compare 2nd
;with 3rd. Swap if necessary. Compare 1st with 3rd.
;Swap if necessary. And lastly compare the 1st and 2nd once more
compareFirstAndSecond:
ucomisd xmm0, xmm1
ja swapFirstAndSecond
jb compareSecondAndThird
swapFirstAndSecond:
movsd xmm15, xmm0
movsd xmm0, xmm1
movsd xmm1, xmm15
compareSecondAndThird:
ucomisd xmm1, xmm2
ja swapSecondAndThird
jb compareFirstAndThird
swapSecondAndThird:
movsd xmm15, xmm1
movsd xmm1, xmm2
movsd xmm2, xmm15
compareFirstAndThird:
ucomisd xmm0, xmm2
ja swapFirstAndThird
jb compareFirstAndSecond2
swapFirstAndThird:
movsd xmm15, xmm0
movsd xmm0, xmm2
movsd xmm2, xmm15
compareFirstAndSecond2:
ucomisd xmm0, xmm1
ja swapFirstAndSecond2
jb return
swapFirstAndSecond2:
movsd xmm15, xmm0
movsd xmm0, xmm1
movsd xmm1, xmm15
return:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; RETURN ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
movss [rdi], xmm0
movss [rsi], xmm1
movss [rdx], xmm2
pop rbp
ret |
oeis/017/A017738.asm | neoneye/loda-programs | 11 | 19813 | <reponame>neoneye/loda-programs<filename>oeis/017/A017738.asm
; A017738: Binomial coefficients C(n,74).
; 1,75,2850,73150,1426425,22537515,300500200,3477216600,35641470150,328693558050,2761025887620,21335200040700,152902266958350,1023269017336650,6431976680401800,38163061637050680,214667221708410075,1149101010321489225,5873182941643167150,28747684924884976050,135114119146959387435,611230538998149609825,2667187806537380115600,11248574662353298748400,45931679871275969889300,181889452290252840761628,699574816500972464467800,2616928017281415515231400,9533094920096585091200100,33858923336894767737710700
add $0,74
bin $0,74
|
libsrc/_DEVELOPMENT/stdio/z80/input_helpers/__stdio_scanf_sm_format.asm | jpoikela/z88dk | 640 | 240788 | <filename>libsrc/_DEVELOPMENT/stdio/z80/input_helpers/__stdio_scanf_sm_format.asm
SECTION code_clib
SECTION code_stdio
PUBLIC __stdio_scanf_sm_format
PUBLIC __stdio_scanf_sm_format_pct
EXTERN asm_isspace, asm_strstrip
__stdio_scanf_sm_format:
; FORMAT STRING STATE MACHINE
; match stream chars against format string
;
; Qualify function for STDIO_MSG_EATC
;
; set-up: hl = state machine function address
; de = void *format
;
; return: de = void *format_ptr (address of char rejected)
ld c,a ; c = stream char
ld a,(de) ; a = *format
call asm_isspace
jr nc, state_1t ; start matching whitespace
or a
scf
ret z ; stop at *format == '\0'
cp '%'
scf
ret z ; stop at *format == '%'
inc de ; format++
cp c
ret z ; if match, continue
dec de
scf ; reject mismatch
ret
state_1t:
; advance format string past whitespace
ex de,hl
inc hl
call asm_strstrip
ex de,hl
ld hl,state_1
ld a,c ; a = stream char
state_1:
; consume whitespace chars from the stream
call asm_isspace
ret nc ; consume stream whitespace
ld hl,__stdio_scanf_sm_format
jp (hl)
__stdio_scanf_sm_format_pct:
; must consume a % from the stream
dec b ; indicate to caller % seen
ld hl,__stdio_scanf_sm_format ; next time back to normal
cp '%'
ret z ; if required % is read
inc b
scf ; otherwise reject
ret
|
alloy4fun_models/trainstlt/models/1/y7ZtAGLfWdWZAjpaB.als | Kaixi26/org.alloytools.alloy | 0 | 5179 | <reponame>Kaixi26/org.alloytools.alloy
open main
pred idy7ZtAGLfWdWZAjpaB_prop2 {
always all s : Signal | eventually s in Green
}
pred __repair { idy7ZtAGLfWdWZAjpaB_prop2 }
check __repair { idy7ZtAGLfWdWZAjpaB_prop2 <=> prop2o } |
programs/oeis/229/A229093.asm | neoneye/loda | 22 | 92881 | ; A229093: The clubs patterns appearing in n X n coins.
; 0,0,1,2,4,6,9,12,17,22,27,34,41,48,57,66,75,86,97,108,121,134,147,162,177,192,209,226,243,262,281,300,321,342,363,386,409,432,457,482,507,534,561,588,617,646,675,706,737,768,801,834,867,902,937,972,1009,1046,1083,1122,1161,1200,1241,1282,1323,1366,1409,1452,1497,1542,1587,1634,1681,1728,1777,1826,1875,1926,1977,2028,2081,2134,2187,2242,2297,2352,2409,2466,2523,2582,2641,2700,2761,2822,2883,2946,3009,3072,3137,3202
mov $2,$0
lpb $0
mov $0,$2
sub $0,2
add $1,1
mul $2,$0
div $2,3
add $1,$2
lpe
mov $0,$1
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/in_out_parameter.adb | best08618/asylo | 7 | 20657 | -- { dg-do run }
with Ada.Streams.Stream_IO;
procedure In_Out_Parameter is
use Ada.Streams; use Stream_IO;
File : Stream_IO.File_Type;
type Bitmap is array (Natural range <>) of Boolean;
for Bitmap'Component_Size use 1;
type Message is record
B : Bitmap (0 .. 14);
end record;
for Message use record
B at 0 range 2 .. 16;
end record;
TX, RX : Message;
begin
TX.B := (others => False);
Stream_IO.Create (File => File, Mode => Out_File, Name => "data");
Message'Output (Stream (File), TX);
Stream_IO.Close (File);
--
Stream_IO.Open (File => File, Mode => In_File, Name => "data");
RX := Message'Input (Stream (File));
Stream_IO.Close (File);
if RX /= TX then
raise Program_Error;
end if;
end In_Out_Parameter;
|
src/macros.asm | YuYen/mips_2048 | 3 | 89740 | <reponame>YuYen/mips_2048<filename>src/macros.asm<gh_stars>1-10
# make sound based on the current maximum
.macro MAKE_SOUND(%val)
li $a0, 0
move $a1, %val
beq $a1, $zero, MAKE_SOUND_return
MAKE_SOUND_loopx:
srl $a1, $a1, 1
addi $a0, $a0, 1
and $a2, $a1, 1
bne $a2, 1, MAKE_SOUND_loopx
MAKE_SOUND_return:
mul $a2, $a0, 8
addi $a0, $a0, 60
li $a1, 2000
li $a3, 100
li $v0, 31
syscall
.end_macro
# get color & size based on the current maximum
.macro GET_COLOR_SIZE(%val, %color, %size)
li $a0, 2
li $a2, 0
GET_COLOR_SIZE_loop:
and $a1, $a0, %val
sll $a0, $a0, 1
addi $a2, $a2, 1
beq $a1, $zero, GET_COLOR_SIZE_loop
addi $a2, $a2, -1
lw $a0, level_count
divu $a2, $a0
mfhi %size
mflo %color
la $a1, level_size
LOAD_ARRAY_ELEMENT($a1, %size, %size)
la $a1, level_color
LOAD_ARRAY_ELEMENT($a1, %color, %color)
.end_macro
# convert x, y axis to plot address
.macro GET_PLOT_ADDRESS(%x, %y, %addr)
lw $a0, display_width
mulu %addr, %y, $a0
addu %addr, %addr, %x
sll %addr, %addr, 2
addu %addr, %addr, $gp
.end_macro
# draw a segment which starts from (x, y)
.macro DRAW_SEGMENT_BY_POINT(%x, %y, %len, %color)
GET_PLOT_ADDRESS(%x, %y, $a1)
li $a0, 0
move $a2, %len
DRAW_SEGMENT_loop:
sw %color, ($a1)
addi $a0, $a0, 1
addi $a1, $a1, 4
blt $a0, $a2, DRAW_SEGMENT_loop
.end_macro
# draw a segment which starts from the address
.macro DRAW_SEGMENT_BY_ADDR(%addr, %len, %color)
li $a0, 0
move $a1, %addr
move $a2, %len
DRAW_SEGMENT_loop:
sw %color, ($a1)
addi $a0, $a0, 1
addi $a1, $a1, 4
blt $a0, $a2, DRAW_SEGMENT_loop
.end_macro
# copy sequence from src to tar
.macro COPY_SEQ(%tar, %src, %len)
li $a0, 0
move $a1, %tar
move $a2, %src
COPY_SEQ_next:
lw $a3, ($a2)
sw $a3, ($a1)
addi $a0, $a0, 1
addi $a1, $a1, 4
addi $a2, $a2, 4
blt $a0, %len, COPY_SEQ_next
.end_macro
# sleep implement with nop loop
.macro SLEEP(%val)
li $a0, 0
SLEEP_loopx:
nop
addi $a0, $a0, 1
blt $a0, %val, SLEEP_loopx
.end_macro
# wait next key from keybroad simulator
.macro WAIT_NEXT_KEY(%val)
lw $a1, keybroad_addr
WAIT_NEXT_KEY_wait:
SLEEP(1000)
lw %val, ($a1)
beq %val, $zero, WAIT_NEXT_KEY_wait
lw %val, 4($a1)
.end_macro
# shift address in unit of word
.macro SHIFT_WORD(%add, %pos, %res)
sll $a0, %pos, 2
add %res, %add, $a0
.end_macro
# load a word from an array
.macro LOAD_ARRAY_ELEMENT(%add, %pos, %res)
SHIFT_WORD(%add, %pos, %res)
lw %res, (%res)
.end_macro
# store a word into an array
.macro STORE_ARRAY_ELEMENT(%add, %pos, %val)
SHIFT_WORD(%add, %pos, $a1)
sw %val, ($a1)
.end_macro
# push $ra into stack
.macro STORE_RA
addi $sp, $sp, -4
sw $ra, 0($sp)
.end_macro
# pop $ra from stack
.macro RESTORE_RA
lw $ra, 0($sp)
addi $sp, $sp, 4
.end_macro
.macro PRINT_INT (%val)
li $v0, 1
move $a0, %val
syscall
.end_macro
.macro PRINT_CHARI (%val)
li $v0, 11
li $a0, %val
syscall
.end_macro
.macro PRINT_CHAR (%val)
li $v0, 11
move $a0, %val
syscall
.end_macro
.macro PRINT_STR (%val)
li $v0, 4
move $a0, %val
syscall
.end_macro
|
src/commands/makestem.adb | lenzomj/whitakers-words | 204 | 3363 | <filename>src/commands/makestem.adb
-- WORDS, a Latin dictionary, by <NAME> (USAF, Retired)
--
-- Copyright <NAME> (1936–2010)
--
-- This is a free program, which means it is proper to copy it and pass
-- it on to your friends. Consider it a developmental item for which
-- there is no charge. However, just for form, it is Copyrighted
-- (c). Permission is hereby freely given for any and all use of program
-- and data. You can sell it as your own, but at least tell me.
--
-- This version is distributed without obligation, but the developer
-- would appreciate comments and suggestions.
--
-- All parts of the WORDS system, source code and data files, are made freely
-- available to anyone who wishes to use them, for whatever purpose.
with Ada.Text_IO;
with Latin_Utils.Config;
with Latin_Utils.Strings_Package; use Latin_Utils.Strings_Package;
with Latin_Utils.Latin_File_Names; use Latin_Utils.Latin_File_Names;
with Latin_Utils.Inflections_Package; use Latin_Utils.Inflections_Package;
with Latin_Utils.Dictionary_Package; use Latin_Utils.Dictionary_Package;
with Support_Utils.Word_Support_Package; use Support_Utils.Word_Support_Package;
with Support_Utils.Char_Utils;
with Latin_Utils.General;
procedure Makestem is
use Stem_Key_Type_IO;
use Count_Io;
use Ada.Text_IO;
use Stem_Io;
use MNPC_IO;
use Part_Entry_IO;
D_K : Dictionary_Kind := Xxx; -- ######################
I : Stem_Io.Count := 0;
Line : String (1 .. 200) := (others => ' ');
Blanks : constant String (1 .. 200) := (others => ' ');
Last, Ll : Integer := 0;
Ds : Dictionary_Stem;
Fc, Ofc : Character := ' ';
Sc, Osc : Character := ' ';
procedure Put_Indices (Ch : String;
D_K : Dictionary_Kind) is
Wd : constant String (1 .. 2) := Ch (Ch'First .. Ch'First + 1);
begin
--Put_Line ("Put_Indices");
if Ch = " " then
if (Bblf (Ch (Ch'First), Ch (Ch'First + 1), D_K) > 0) and then
(Bbll (Ch (Ch'First), Ch (Ch'First + 1), D_K) >=
Bblf (Ch (Ch'First), Ch (Ch'First + 1), D_K))
then
Put ("CH = ("); Put (Ch); Put (") index is of range ");
Put (Bblf (Ch (Ch'First), Ch (Ch'First + 1), D_K));
Put (" .. "); Put (Bbll (Ch (Ch'First), Ch (Ch'First + 1), D_K));
Put (" number ");
Put
(Bbll (Ch (Ch'First), Ch (Ch'First + 1), D_K) -
Bblf (Ch (Ch'First), Ch (Ch'First + 1), D_K) + 1);
New_Line;
end if;
elsif Ch (Ch'First + 1) = ' ' then
if (Bdlf (Ch (Ch'First), Ch (Ch'First + 1), D_K) > 0) and then
(Bdll (Ch (Ch'First), Ch (Ch'First + 1), D_K) >=
Bdlf (Ch (Ch'First), Ch (Ch'First + 1), D_K))
then
Put ("CH = ("); Put (Ch); Put (") index is of range ");
Put (Bdlf (Ch (Ch'First), Ch (Ch'First + 1), D_K));
Put (" .. "); Put (Bdll (Ch (Ch'First), Ch (Ch'First + 1), D_K));
Put (" number ");
Put (Bdll (Ch (Ch'First), Ch (Ch'First + 1), D_K) -
Bdlf (Ch (Ch'First), Ch (Ch'First + 1), D_K) + 1);
New_Line;
end if;
else
if (First_Index (Wd, D_K) > 0) and then
(Last_Index (Wd, D_K) >= First_Index (Wd, D_K))
then
Put ("CH = ("); Put (Wd); Put (") index is of range ");
Put (First_Index (Wd, D_K));
Put (" .. "); Put (Last_Index (Wd, D_K));
Put (" number ");
Put (Last_Index (Wd, D_K) - First_Index (Wd, D_K) + 1);
New_Line;
end if;
end if;
end Put_Indices;
begin
Put_Line ("Creates STEMFILE.D_K and INDXFILE.D_K from STEMLIST.D_K");
Latin_Utils.General.Load_Dictionary (Line, Last, D_K);
Open (Stem_List (D_K), In_File,
Latin_Utils.Config.Path (Stem_List_Name & '.' & Ext (D_K)));
Create (Stem_File (D_K), Inout_File, Stem_File_Name & '.' & Ext (D_K));
Create (Indx_File (D_K), Out_File, Indx_File_Name & '.' & Ext (D_K));
------------------------------------------------------------------
-- This section assumes the blank ESSE stem is first - D_K GENERAL
if D_K = General then
I := I + 1;
Bblf (' ', ' ', General) := I;
Bbll (' ', ' ', General) := 0;
Line := Blanks;
Get_Line (Stem_List (D_K), Line, Last);
Put_Line (Line (1 .. Last));
Fc := Line (1);
Sc := Line (2);
Ds.Stem := Line (1 .. Max_Stem_Size);
Get (Line (Max_Stem_Size + 1 .. Last), Ds.Part, Ll);
Get (Line (Ll + 1 .. Last), Ds.Key, Ll);
Get (Line (Ll + 1 .. Last), Ds.MNPC, Ll);
Write (Stem_File (D_K), Ds);
Bbll (Fc, Sc, General) := I; -- 1
Put (Indx_File (D_K), " ");
Put (Indx_File (D_K), ' ');
Put (Indx_File (D_K), Bblf (' ', ' ', General));
Put (Indx_File (D_K), ' ');
Put (Indx_File (D_K), Bbll (' ', ' ', General));
Put (Indx_File (D_K), ' ');
New_Line (Indx_File (D_K));
Put_Indices (" ", General);
end if;
------------------------------------------------------------------
Fc := 'a';
Ofc := 'a';
Sc := ' ';
Osc := ' ';
Bdlf (Ofc, ' ', D_K) := I + 1;
--DEBUG.PUT (" bf1 BDLF ("); DEBUG.PUT (OFC);
--DEBUG.PUT (' '); DEBUG.PUT (") "); DEBUG.PUT (BDLF (OFC, ' ', D_K));
--DEBUG.NEW_LINE;
First_Character_Loop : while not End_Of_File (Stem_List (D_K)) loop
Osc := Sc;
Second_Character_Loop : while not End_Of_File (Stem_List (D_K)) loop
Inner_Loop : while not End_Of_File (Stem_List (D_K)) loop
Line := Blanks;
Get_Line (Stem_List (D_K), Line, Last);
--Put_Line ("* " & Line (1 .. Last));
if Trim (Line (1 .. Last)) = "" then
Put_Line ("Trim (Line (1 .. Last)) BLANK");
end if;
exit First_Character_Loop when Trim (Line (1 .. Last)) = "";
Fc := Lower_Case (Line (1));
Sc := Lower_Case (Line (2));
--------------------------------------------------------------------
Support_Utils.Char_Utils.V_To_U_And_J_To_I (Fc);
Support_Utils.Char_Utils.V_To_U_And_J_To_I (Sc);
--------------------------------------------------------------------
I := I + 1;
if Sc = ' ' then
--Put ("BDL I -> "); Put (I ); New_Line;
if Fc /= Ofc then
Bdlf (Fc, ' ', D_K) := I;
--Put (" bf2 BDLF ("); Put (Fc);Put (' '); Put (") ");
--Put (Bdlf (Fc, ' ', D_K)); New_Line;
end if;
else
null;
--Put ("I -> "); Put (I); New_Line;
end if;
Ds.Stem := Line (1 .. Max_Stem_Size);
Get (Line (Max_Stem_Size + 1 .. Last), Ds.Part, Ll);
Get (Line (Ll + 1 .. Last), Ds.Key, Ll);
Get (Line (Ll + 1 .. Last), Ds.MNPC, Ll);
-- FIXME: code above is duplicated in another file
Write (Stem_File (D_K), Ds);
--Put_Line ("Wrote STEMfile");
if Fc /= Ofc then
-- Jumped FC, effectively must have jumped a SC
--Put_Line ("Jumped FC");
if Osc = ' ' then
Bdll (Ofc, Osc, D_K) := I - 1;
else
Ddll (Ofc, Osc, D_K) := I - 1;
end if;
if Sc = ' ' then
--Put ("BDLF "); Put (Bdlf (Fc, Sc, D_K)); New_Line;
Bdlf (Fc, Sc, D_K) := I;
else
Ddlf (Fc, Sc, D_K) := I;
end if;
--Put_Line ("if Sc done");
--Put ("Ofc = '"); Put (Ofc);
Put ("' Osc = '"); Put (Osc); Put_Line ("'");
Put_Indices (Ofc & Osc, D_K);
Ofc := Fc;
Osc := Sc;
--Put_Line ("exit Second_Character_Loop");
exit Second_Character_Loop;
else
if Sc /= Osc then -- Jumped a SC, but not a FC
if Osc = ' ' then -- Jumped a SC from ' ' to something
Bdll (Fc, Osc, D_K) := I - 1; -- So set BDLL
Ddlf (Fc, Sc, D_K) := I;
Put_Indices (Fc & Osc, D_K);
Osc := Sc;
exit Inner_Loop;
else -- Jumped a SL from something, not ' '
Ddll (Fc, Osc, D_K) := I - 1; -- So set DDLL
Ddlf (Fc, Sc, D_K) := I;
Put_Indices (Fc & Osc, D_K);
Osc := Sc;
exit Inner_Loop;
end if;
end if;
end if;
end loop Inner_Loop;
--Put_Line ("Exitted Inner_Loop");
end loop Second_Character_Loop;
--Put_Line ("Exitted Second_Character_Loop");
end loop First_Character_Loop;
--Put_Line ("Exitted First_Character_Loop");
Ddll (Ofc, Osc, D_K) := I;
-- To reprint correctly the last letter information
--Put_Line ("-- To reprint correctly the last letter information");
Put_Indices (Ofc & Osc, D_K);
Close (Stem_File (D_K));
for I in Character'('a') .. Character'('z') loop
for J in Character'(' ') .. Character'(' ') loop
Ada.Text_IO.Put (Indx_File (D_K), (I, J));
Put (Indx_File (D_K), ' ');
Put (Indx_File (D_K), Bdlf (I, J, D_K));
Put (Indx_File (D_K), ' ');
Put (Indx_File (D_K), Bdll (I, J, D_K));
Put (Indx_File (D_K), ' ');
New_Line (Indx_File (D_K));
end loop;
end loop;
for I in Character'('a') .. Character'('z') loop
for J in Character'('a') .. Character'('z') loop
Ada.Text_IO.Put (Indx_File (D_K), (I, J));
Put (Indx_File (D_K), ' ');
Put (Indx_File (D_K), Ddlf (I, J, D_K));
Put (Indx_File (D_K), ' ');
Put (Indx_File (D_K), Ddll (I, J, D_K));
Put (Indx_File (D_K), ' ');
New_Line (Indx_File (D_K));
end loop;
end loop;
Close (Indx_File (D_K));
end Makestem;
|
src/arch/socs/stm32f439/soc-usart.adb | PThierry/ewok-kernel | 65 | 2462 | --
-- Copyright 2018 The wookey project team <<EMAIL>>
-- - <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with soc.rcc;
with soc.rcc.default;
package body soc.usart
with spark_mode => off
is
procedure set_baudrate
(usart : in t_USART_peripheral_access;
baudrate : in unsigned_32)
is
APB_clock : unsigned_32;
mantissa : unsigned_32;
fraction : unsigned_32;
begin
-- Configuring the baud rate is a tricky part. See RM0090 p. 982-983
-- for further informations
if usart = USART1'access or
usart = USART6'access
then
APB_clock := soc.rcc.default.CLOCK_APB2;
else
APB_clock := soc.rcc.default.CLOCK_APB1;
end if;
mantissa := APB_clock / (16 * baudrate);
fraction := ((APB_clock * 25) / (4 * baudrate)) - mantissa * 100;
fraction := (fraction * 16) / 100;
usart.all.BRR.DIV_MANTISSA := bits_12 (mantissa);
usart.all.BRR.DIV_FRACTION := bits_4 (fraction);
end set_baudrate;
procedure transmit
(usart : in t_USART_peripheral_access;
data : in t_USART_DR)
is
begin
loop
exit when usart.all.SR.TXE;
end loop;
usart.all.DR := data;
end transmit;
procedure receive
(usart : in t_USART_peripheral_access;
data : out t_USART_DR)
is
begin
loop
exit when usart.all.SR.RXNE;
end loop;
data := usart.all.DR;
end receive;
end soc.usart;
|
programs/oeis/157/A157423.asm | neoneye/loda | 22 | 247573 | <gh_stars>10-100
; A157423: Triangle read by rows, T(n,k) = 0 if (n-k+1) is prime, else 1.
; 1,0,1,0,0,1,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,1,0,1,0,1,0,0,1,1,1,1,0,1,0,1,0,0,1,0,1,1,1,0,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,1
seq $0,25676 ; Exponent of 8 (value of i) in n-th number of form 8^i*9^j.
seq $0,5171 ; Characteristic function of nonprimes: 0 if n is prime, else 1.
|
reference/04/mult/mult.asm | ITFS777/n2t | 2,011 | 85546 | <filename>reference/04/mult/mult.asm
// Multiplies R0 and R1 and stores the result in R2.
// (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[2], respectively.)
// 3*2 换算成 2个3相加
// 初始化
@2
M = 0
// 判断是否小于0
@0
D = M
@END
D;JLT
(LOOP)
@1
M = M - 1
D = M
@END
D;JLT
@0
D = M
@2
M = M + D
@LOOP
0;JMP
(END)
@END
0;JMP |
src/main/antlr4/Cryptator.g4 | arnaud-m/cryptator | 1 | 3917 | grammar Cryptator;
@header{
package cryptator.parser;
import cryptator.specs.ICryptaNode;
import cryptator.tree.CryptaNode;
import cryptator.tree.CryptaLeaf;
}
// Parser Rules
program : equation EOF{}; //additional token to simplify the passage in parameter
equation returns [ICryptaNode node]: //create a node of the tree corresponding to an equation and return this node
'(' equation ')' {$node=$equation.node;}
| left=expression COMPARATOR right=expression {$node=new CryptaNode($COMPARATOR.getText(), $left.node, $right.node);};
expression returns [ICryptaNode node]: //create recursively the tree of expressions with priority and return the root of the tree
word {$node=new CryptaLeaf($word.text);} //create a node of the tree corresponding to a leaf and return this node
| '(' expression ')' {$node=$expression.node;}
| e1=expression modORpow e2=expression {$node=new CryptaNode($modORpow.text, $e1.node, $e2.node);} //create a node of the tree corresponding to an operation and return this node
| sub expression {$node=new CryptaNode($sub.text, new CryptaLeaf(), $expression.node);}
| e1=expression divORmul e2=expression {$node=new CryptaNode($divORmul.text, $e1.node, $e2.node);}
| e1=expression addORsub e2=expression {$node=new CryptaNode($addORsub.text, $e1.node, $e2.node);};
word : //additional token to simplify the passage in parameter
(SYMBOL)+;
modORpow : '%' | '^';
divORmul : '/' | '//' | '*';
addORsub : '+' | sub;
sub : '-';
// Lexer Rules
COMPARATOR : '=' | '!=' | '<' | '>' | '<=' | '>=';
SYMBOL : [a-zA-Z0-9\u0080-\uFFFF] {};
WHITESPACE : ( '\t' | ' ' | '\r' | '\n'| '\u000C' )+ -> skip ;
|
day-01/solve.adb | stevancorre/advent-of-code-2021 | 0 | 4658 | <filename>day-01/solve.adb
package body Solve is
function Get_Line_Integer (File : File_Type) return Integer is
Line_Buffer : Unbounded_String;
Result : Integer;
begin
Line_Buffer := Get_Line (File);
Result := Integer'Value (To_String (Line_Buffer));
return Result;
end Get_Line_Integer;
end Solve;
|
programs/oeis/066/A066560.asm | neoneye/loda | 22 | 10728 | ; A066560: Smallest composite number divisible by n.
; 4,4,6,4,10,6,14,8,9,10,22,12,26,14,15,16,34,18,38,20,21,22,46,24,25,26,27,28,58,30,62,32,33,34,35,36,74,38,39,40,82,42,86,44,45,46,94,48,49,50,51,52,106,54,55,56,57,58,118,60,122,62,63,64,65,66,134,68,69,70,142,72,146,74,75,76,77,78,158,80,81,82,166,84,85,86,87,88,178,90,91,92,93,94,95,96,194,98,99,100
seq $0,143545 ; a(n) = n unless n is a prime, in which case a(n) = 2n.
mov $1,4
max $1,$0
mov $0,$1
|
2020/06/day06.asm | winny-/aoc | 6 | 164147 | <gh_stars>1-10
section .data
answers: times 26 dq 0
sum1: dq 0
sum2: dq 0
nl: db `\n`
section .bss
char1: resb 1
char2: resb 2
section .text
global _start
_start:
B_read_record:
xor r12, r12 ; Zero # of persons read for this record.
mov rcx, 26
L_zero:
mov rdx, rcx
dec rdx
mov qword [answers+8*rdx], 0 ; Some reason [answers+8*rcx-1] does not work...
loop L_zero
L_answer:
call getc
mov r14, rax ; Save retval for later use.
cmp rax, 0
jle B_group_end ; Finished input or error.
mov rax, [char1] ; Get the character read.
cmp rax, `\n`
jne B_character ; NOT a NL -> character counting logic.
cmp r15, `\n`
je B_group_end ; Double NL -> finished with record.
inc r12 ; New person, but not new record, so incr count.
mov r15, rax ; Save the character for checking double NL.
jmp L_answer
B_character:
mov r15, rax ; Save the character for checking double NL.
sub rax, 'a'
inc qword [answers+8*rax]
jmp L_answer
B_group_end:
mov rcx, 26
L_count:
mov rdx, rcx
dec rdx
mov rax, qword [answers+8*rdx]
cmp rax, 0
je B_no_incr ; If no occurrence -> skip counting this letter.
inc qword [sum1]
cmp rax, r12
jne B_no_incr ; If person count != occurrence count -> skip part2 incr.
inc qword [sum2]
B_no_incr:
loop L_count
cmp r14, 0
jg B_read_record ; If the retval from the read was ok, continue reading.
B_end:
mov rax, qword [sum1] ; Part 1
call printi
mov rax, qword [sum2] ; Part 2
call printi
mov rax, 60 ; Exit
mov rdi, 0
syscall
;; Is not reached.
getc:
;; Read input from stdin on character at a time, store result in
;; `char1'.
mov rax, 0
mov rdi, 0
mov rsi, char1
mov rdx, 1
syscall
ret
printi:
;; Print number in RAX as decimal. Probably still has bugs in
;; it... but it works.
xor r11, r11 ; Zero out count of digits.
L_n2s:
xor rdx, rdx ; Zero out upper half of dividend
mov rbx, 10 ; Divisor
div rbx ; RDX:RAX / RBX -> Q:RAX R:RDX
cmp rax, 0
je B_final_digit
inc r11
push rdx
jmp L_n2s
B_final_digit:
cmp rdx, 0
je B_is_zero
inc r11
push rdx
jmp B_do_print
B_is_zero:
cmp r11, 0
jne B_do_print
inc r11
push qword 0
B_do_print:
mov rcx, r11
L_do_print:
pop rbx
add rbx, '0'
push rcx ; Save rcx which can be messed up by syscalls.
mov [char2], rbx
mov rax, 1
mov rdi, 1
mov rsi, char2
mov rdx, 1
syscall
pop rcx
loop L_do_print
;; Print NL
mov rax, 1,
mov rdi, 1
mov rsi, nl
mov rdx, 1
syscall
ret
;; Local Variables:
;; compile-command: "nasm -g -f elf64 day06.asm && ld day06.o -o day06 && ./day06 < input.txt"
;; End:
|
disorderly/disorderly-random.ads | jscparker/math_packages | 30 | 1621 |
-------------------------------------------------------------------------------
-- package Disorderly.Random, Non-linear Random Number Generator
-- Copyright (C) 1995-2018 <NAME>
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-------------------------------------------------------------------------------
-- PACKAGE Disorderly.Random
--
-- Procedure Disorderly.Random.Get_Random is a non-linear pseudo random number
-- generator designed to be task-safe, and optimized for high statistical quality.
--
-- 1. Uniform output in the range 0 .. 2**61-1.
-- (ie, 61 random bits per call.)
-- (2**61-1 is a Mersenne Prime; explanation below.)
-- 2. Period > 2^246. (Actually, period is about 1.813381 * 2^246.)
-- 3. Period is the product of 4 large (19 decimal digit) prime numbers:
-- 4192767015302299403 * 3625455516735504383 * 5866200191975030783 * (2^61-1).
-- 4. Generator is non-linear.
-- 5. Generator is full-period, and 2 of the 3 component generators are
-- full-period. (The 3rd, the non-linear one, is optionally full-period.)
-- 6. Generator is pure (the package is stateless) for convenient use
-- in multi-tasking simulations.
-- 7. CPU time per call is constant (again for multi-tasking simulations).
-- 8. Size of state per generator is 4 x 64 bits.
-- 9. Speed: Typical benchmarks (on a 64-bit intel PC) measure CPU time per
-- call at around 1/2 to 2/3 that of a call to a 64-bit Sin(x).
-- 10. The State can be initialized by a version of procedure Reset that calls
-- Ada.Calendar.Clock. This version of Reset is confined to a child package,
-- since its not pure. The child package is called Random.Clock_Entropy.
--
-- Items 1-5 are general characteristics of good generators.
-- Items 6-8 are attributes that are desirable in a language with built-in
-- concurrency.
--
-- For a general RATIONALE, see the parent package: Disorderly.ads
--
package Disorderly.Random
with Spark_Mode => On
is
pragma Pure (Disorderly.Random);
type Parent_Random_Int is mod 2**64;
-- Internally, all arithmetic is done on this type. The generator
-- is designed for machines with efficient 64-bit integer arithmetic.
Bits_per_Random_Number : constant := 61;
subtype Random_Int is Parent_Random_Int range 0 .. 2**Bits_per_Random_Number-1;
-- The random number generator returns Ints of this type. Its
-- best to think of these Ints as 61 bins, each containing a random bit.
-- Notice that it is *not* a mod 2**61 type.
--
-- The number p = 61 is a special kind of prime that makes 2**p-1 a
-- prime number. Primality of 2**p-1 is a basic requirement of the
-- algorithm that generates the random numbers.
--
-- The number of bits returned by a RNG is rarely the actual
-- number required by a particular application. Additional
-- work is necessary to put the random stream into the desired range
-- and numeric type.
subtype Seed_Random_Int is Random_Int range 1 .. Random_Int'Last;
-- Seeds (Initiators) must never be 0.
type State is private;
procedure Get_Random
(Random_x : out Random_Int;
S : in out State);
procedure Reset
(S : out State;
Initiator1 : in Seed_Random_Int := 1111;
Initiator2 : in Seed_Random_Int := 2222;
Initiator3 : in Seed_Random_Int := 3333;
Initiator4 : in Seed_Random_Int := 4444);
-- procedure Reset initializes State S.
-- There are no calls to Calendar, so it is reproducible: use the same
-- seeds each time and you get the same state S each time.
-- The following routines translate state S into text, and back again.
-- Useful for saving state S on HD in text format.
No_Of_Seeds : constant := 4;
Rand_Image_Width : constant := 20; -- 2^64-1 = 1.8446744073709551615 * 10^19
Max_Image_Width : constant := Rand_Image_Width * No_Of_Seeds;
subtype State_String is String(1 .. Max_Image_Width);
function Value (Coded_State : State_String) return State with
Pre => (for all i in State_String'Range => Coded_State(i) in '0' .. '9');
function Image (Of_State : State) return State_String;
-- Detect invalid States, for example after input from HDD.
function Valid_State (S : in State) return Boolean;
-- Make an easier to read version of State_String by putting a space in front
-- of each of the 20 digit numbers: Formatted_Image().
Leading_Spaces : constant := 1;
Formatted_State_String_Width : constant := (Rand_Image_Width + Leading_Spaces)*No_Of_Seeds;
subtype Formatted_State_String is String(1 .. Formatted_State_String_Width);
function Formatted_Image (Of_State : State) return Formatted_State_String;
function Are_Equal (State_1, State_2 : State) return Boolean;
private
subtype State_Index is Integer range 0..No_Of_Seeds-1;
type Vals is array(State_Index) of Parent_Random_Int;
type State is record
X : Vals := (others => 701);
end Record;
end Disorderly.Random;
|
test/succeed/Issue124.agda | asr/agda-kanso | 1 | 13090 | <filename>test/succeed/Issue124.agda
module Issue124 where
module A where
data A : Set where
c : A
module B where
data B : Set where
c : B
module C where
open A public
open B public
open C
f : B → B
f c = c |
robozonky-strategy-natural/src/main/antlr4/imports/Defaults.g4 | liry/robozonky | 0 | 4885 | <reponame>liry/robozonky<gh_stars>0
grammar Defaults;
import Tokens;
@header {
import com.github.robozonky.api.strategies.*;
import com.github.robozonky.strategy.natural.*;
import com.github.robozonky.strategy.natural.conditions.*;
}
defaultExpression returns [DefaultValues result]:
(
{
org.apache.logging.log4j.LogManager.getLogger(getClass())
.warn("Using a deprecated strategy format. Please upgrade.");
}
r1=portfolioExpression { $result = new DefaultValues($r1.result); }
(v1=reservationExpression { $result.setReservationMode($v1.result); })
(e1=exitDateExpression { $result.setExitProperties($e1.result); })?
(p1=targetPortfolioSizeExpression { $result.setTargetPortfolioSize($p1.result); })?
(d1=legacyDefaultInvestmentSizeExpression { $result.setInvestmentSize($d1.result); })?
(s1=defaultInvestmentShareExpression { $result.setInvestmentShare($s1.result); })?
) | (
r2=portfolioExpression { $result = new DefaultValues($r2.result); }
(v2=reservationExpression { $result.setReservationMode($v2.result); })
(i2=defaultInvestmentSizeExpression { $result.setInvestmentSize($i2.result); })?
(b2=defaultPurchaseSizeExpression { $result.setPurchaseSize($b2.result); })?
(p2=targetPortfolioSizeExpression { $result.setTargetPortfolioSize($p2.result); })?
(e2=exitDateExpression { $result.setExitProperties($e2.result); })?
)
;
portfolioExpression returns [DefaultPortfolio result] :
'Robot má udržovat ' (
( 'konzervativní' { $result = DefaultPortfolio.CONSERVATIVE; } )
| ( 'balancované' { $result = DefaultPortfolio.BALANCED; } )
| ( 'progresivní' { $result = DefaultPortfolio.PROGRESSIVE; } )
| ( 'uživatelem definované' { $result = DefaultPortfolio.EMPTY; } )
) ' portfolio' DOT
;
exitDateExpression returns [ExitProperties result]:
'Opustit Zonky k ' termination=dateExpr (
( { $result = new ExitProperties($termination.result); } )
| (
OR_COMMA 'výprodej zahájit ' selloff=dateExpr {
$result = new ExitProperties($termination.result, $selloff.result);
}
)
) DOT
;
legacyDefaultInvestmentSizeExpression returns [MoneyRange result] :
'Běžná výše investice je ' i=investmentSizeRatingSubExpression {
$result = $i.result;
}
;
defaultInvestmentSizeExpression returns [int result] :
'Robot má investovat do půjček po ' amount=intExpr KC '.' { $result = $amount.result; }
;
defaultPurchaseSizeExpression returns [int result] :
'Robot má nakupovat participace nejvýše za ' amount=intExpr KC '.' { $result = $amount.result; }
;
defaultInvestmentShareExpression returns [DefaultInvestmentShare result] :
'Investovat maximálně '
maximumInvestmentInCzk=intExpr
{ $result = new DefaultInvestmentShare($maximumInvestmentInCzk.result); }
' % výše úvěru' DOT
;
reservationExpression returns [ReservationMode result] :
(
'Robot má pravidelně kontrolovat rezervační systém a přijímat rezervace půjček odpovídajících této strategii.' {
$result = ReservationMode.ACCEPT_MATCHING;
}
) | (
'Robot má převzít kontrolu nad rezervačním systémem a přijímat rezervace půjček odpovídajících této strategii.' {
$result = ReservationMode.FULL_OWNERSHIP;
}
) | (
'Robot má zcela ignorovat rezervační systém.' {
$result = null;
}
)
;
|
src/ada/src/services/atbb/assignment_tree_branch_bound.ads | manthonyaiello/OpenUxAS | 0 | 25934 | <gh_stars>0
with Ada.Containers.Formal_Hashed_Maps;
with Ada.Containers.Functional_Maps;
with Assignment_Tree_Branch_Bound_Communication; use Assignment_Tree_Branch_Bound_Communication;
with Common; use Common;
with LMCP_Messages; use LMCP_Messages;
package Assignment_Tree_Branch_Bound with SPARK_Mode is
type Cost_Function_Kind is (Minmax, Cumulative);
package Int64_UAR_Maps is new Ada.Containers.Formal_Hashed_Maps
(Key_Type => Int64,
Element_Type => UniqueAutomationRequest,
Hash => Int64_Hash);
subtype Int64_UniqueAutomationRequest_Map is
Int64_UAR_Maps.Map (200, Int64_UAR_Maps.Default_Modulus (200));
use Int64_UAR_Maps;
package Int64_TaskPlanOptions_Maps is new Ada.Containers.Functional_Maps
(Key_Type => Int64,
Element_Type => TaskPlanOptions);
type Int64_TPO_Map is new Int64_TaskPlanOptions_Maps.Map;
package Int64_TPO_Map_Maps is new Ada.Containers.Formal_Hashed_Maps
(Key_Type => Int64,
Element_Type => Int64_TPO_Map,
Hash => Int64_Hash);
subtype Int64_TaskPlanOptions_Map_Map is
Int64_TPO_Map_Maps.Map (200, Int64_TPO_Map_Maps.Default_Modulus (200));
use Int64_TPO_Map_Maps;
package Int64_ACM_Maps is new Ada.Containers.Formal_Hashed_Maps
(Key_Type => Int64,
Element_Type => AssignmentCostMatrix,
Hash => Int64_Hash);
subtype Int64_AssignmentCostMatrix_Map is
Int64_ACM_Maps.Map (200, Int64_ACM_Maps.Default_Modulus (200));
use Int64_ACM_Maps;
----------------------------
-- Annotation subprograms --
----------------------------
function Valid_TaskPlanOptions
(TaskPlanOptions_Map : Int64_TPO_Map)
return Boolean;
function Valid_AssignmentCostMatrix
(Assignment_Cost_Matrix : AssignmentCostMatrix)
return Boolean;
----------------------------------------
-- Assignment Tree Branch Bound types --
----------------------------------------
type Assignment_Tree_Branch_Bound_Configuration_Data is record
Cost_Function : Cost_Function_Kind := Minmax;
Number_Nodes_Maximum : Int64 := 0;
end record;
type Assignment_Tree_Branch_Bound_State is record
m_uniqueAutomationRequests : Int64_UniqueAutomationRequest_Map;
m_taskPlanOptions : Int64_TaskPlanOptions_Map_Map;
m_assignmentCostMatrixes : Int64_AssignmentCostMatrix_Map;
end record with
Predicate =>
(for all ReqId of m_taskPlanOptions =>
Valid_TaskPlanOptions (Element (m_taskPlanOptions, ReqId)))
and then
(for all ReqId of m_assignmentCostMatrixes =>
Valid_AssignmentCostMatrix (Element (m_assignmentCostMatrixes, ReqId)));
---------------------------
-- Service functionality --
---------------------------
procedure Handle_Unique_Automation_Request
(Mailbox : in out Assignment_Tree_Branch_Bound_Mailbox;
Data : Assignment_Tree_Branch_Bound_Configuration_Data;
State : in out Assignment_Tree_Branch_Bound_State;
Areq : UniqueAutomationRequest)
with
Pre => not Contains (State.m_uniqueAutomationRequests, Areq.RequestID);
procedure Handle_Task_Plan_Options
(Mailbox : in out Assignment_Tree_Branch_Bound_Mailbox;
Data : Assignment_Tree_Branch_Bound_Configuration_Data;
State : in out Assignment_Tree_Branch_Bound_State;
Options : TaskPlanOptions)
with
Pre =>
(for all TaskOption of Options.Options =>
(TaskOption.Cost >= 0
and then Options.TaskID = TaskOption.TaskID))
and then
(not Contains (State.m_taskPlanOptions, Options.CorrespondingAutomationRequestID)
or else
not Has_Key (Element (State.m_taskPlanOptions, Options.CorrespondingAutomationRequestID), Options.TaskID));
procedure Handle_Assignment_Cost_Matrix
(Mailbox : in out Assignment_Tree_Branch_Bound_Mailbox;
Data : Assignment_Tree_Branch_Bound_Configuration_Data;
State : in out Assignment_Tree_Branch_Bound_State;
Matrix : AssignmentCostMatrix)
with Pre =>
not Contains (State.m_assignmentCostMatrixes, Matrix.CorrespondingAutomationRequestID)
and then Valid_AssignmentCostMatrix (Matrix);
procedure Check_Assignment_Ready
(Mailbox : in out Assignment_Tree_Branch_Bound_Mailbox;
Data : Assignment_Tree_Branch_Bound_Configuration_Data;
State : in out Assignment_Tree_Branch_Bound_State;
ReqId : Int64);
procedure Send_TaskAssignmentSummary
(Mailbox : in out Assignment_Tree_Branch_Bound_Mailbox;
Data : Assignment_Tree_Branch_Bound_Configuration_Data;
State : in out Assignment_Tree_Branch_Bound_State;
ReqId : Int64)
with
Pre =>
Contains (State.m_uniqueAutomationRequests, ReqId)
and then Contains (State.m_assignmentCostMatrixes, ReqId)
and then Contains (State.m_taskPlanOptions, ReqId)
and then
(for all TaskId of Element (State.m_uniqueAutomationRequests, ReqId).TaskList =>
Has_Key (Element (State.m_taskPlanOptions, ReqId), TaskId))
and then
Valid_TaskPlanOptions (Element (State.m_taskPlanOptions, ReqId));
procedure Run_Calculate_Assignment
(Data : Assignment_Tree_Branch_Bound_Configuration_Data;
Automation_Request : UniqueAutomationRequest;
Assignment_Cost_Matrix : AssignmentCostMatrix;
TaskPlanOptions_Map : Int64_TPO_Map;
Summary : out TaskAssignmentSummary)
with
Pre =>
Valid_AssignmentCostMatrix (Assignment_Cost_Matrix)
and then
Valid_TaskPlanOptions (TaskPlanOptions_Map)
and then
(for all TaskId of Automation_Request.TaskList =>
Has_Key (TaskPlanOptions_Map, TaskId))
and then
(for all Id of TaskPlanOptions_Map =>
(for all TaskOption of Get (TaskPlanOptions_Map, Id).Options => TaskOption.TaskID = Id));
-- Returns the assignment that minimizes the cost.
private
function Valid_TaskPlanOptions
(TaskPlanOptions_Map : Int64_TPO_Map)
return Boolean
is
(for all TaskId of TaskPlanOptions_Map =>
(TaskId = Get (TaskPlanOptions_Map, TaskId).TaskID
and then
(for all TaskOption of Get (TaskPlanOptions_Map, TaskId).Options =>
(TaskId = TaskOption.TaskID
and then TaskOption.Cost >= 0))));
function Valid_AssignmentCostMatrix
(Assignment_Cost_Matrix : AssignmentCostMatrix)
return Boolean
is
(for all TOC of Assignment_Cost_Matrix.CostMatrix => TOC.TimeToGo >= 0);
end Assignment_Tree_Branch_Bound;
|
PMOO/EXAMEN/1516O/Bombilla.ads | usainzg/EHU | 0 | 2874 | package Bombilla is
procedure Crear (
id: in String;
potencia_nominal: in Float;
luminosidad_nominal: in Float;
es_regulable: in Boolean;
bomb: out Bombilla;
);
function Potencia(B: in Bombilla) return Float;
function Esta_Encendida(B: in Bombilla) return Boolean;
procedure Encender(B: in out Bombilla);
procedure Actualizar_Luminosidades (B: in out Bombilla; vector: in Vectores_Luminosidad.Vector);
function Eficacia(B: in Bombilla) return Float;
private
type Bombilla is record
identificador: String(1..4);
potencia_nominal: Float;
luminosidad_nominal: Float;
esta_encendida: Boolean;
es_regulable: Boolean;
niveles_potencia_arr: Vectores_Luminosidad.Vector;
end record;
end Bombilla; |
data/tilesets/pallet_collision.asm | Trap-Master/spacworld97-thingy | 0 | 10663 | <reponame>Trap-Master/spacworld97-thingy
tilecoll WALL, WALL, WALL, WALL ; 00
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 01
tilecoll FLOOR, FLOOR, FLOOR, WALL ; 02
tilecoll FLOOR, FLOOR, FLOOR, WALL ; 03
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 04
tilecoll HOP_DOWN, HOP_DOWN, WALL, WALL ; 05
tilecoll HOP_DOWN, FLOOR, WALL, WALL ; 06
tilecoll HOP_DOWN, HOP_DOWN, WALL, WALL ; 07
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 08
tilecoll WALL, WALL, FLOOR, FLOOR ; 09
tilecoll WARP_CARPET_UP, WARP_CARPET_UP, WARP_CARPET_DOWN, WARP_CARPET_DOWN ; 0a
tilecoll TALL_GRASS, TALL_GRASS, TALL_GRASS, TALL_GRASS ; 0b
tilecoll WALL, WALL, WALL, WALL ; 0c
tilecoll WALL, WALL, WALL, WALL ; 0d
tilecoll WALL, WALL, WALL, WALL ; 0e
tilecoll WALL, WALL, WALL, WALL ; 0f
tilecoll WALL, WALL, WALL, WALL ; 10
tilecoll WALL, TALL_GRASS, WALL, TALL_GRASS ; 11
tilecoll FLOOR, FLOOR, FLOOR, TALL_GRASS ; 12
tilecoll WALL, WALL, WALL, WALL ; 13
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 14
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 15
tilecoll FLOOR, FLOOR, WALL, WALL ; 16
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 17
tilecoll FLOOR, FLOOR, WALL, WALL ; 18
tilecoll FLOOR, FLOOR, WALL, WALL ; 19
tilecoll FLOOR, FLOOR, WALL, WALL ; 1a
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 1b
tilecoll WALL, WALL, WALL, WALL ; 1c
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 1d
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 1e
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 1f
tilecoll WALL, WALL, WALL, WALL ; 20
tilecoll WALL, WALL, WALL, WALL ; 21
tilecoll WALL, WALL, WALL, WALL ; 22
tilecoll WALL, WALL, WALL, WALL ; 23
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 24
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 25
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 26
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 27
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 28
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 29
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 2a
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 2b
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 2c
tilecoll WALL, WALL, WALL, WALL ; 2d
tilecoll WALL, FLOOR, WALL, FLOOR ; 2e
tilecoll FLOOR, WALL, FLOOR, WALL ; 2f
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 30
tilecoll FLOOR, TALL_GRASS, FLOOR, TALL_GRASS ; 31
tilecoll TALL_GRASS, FLOOR, TALL_GRASS, FLOOR ; 32
tilecoll TALL_GRASS, FLOOR, TALL_GRASS, FLOOR ; 33
tilecoll TALL_GRASS, FLOOR, TALL_GRASS, FLOOR ; 34
tilecoll TALL_GRASS, TALL_GRASS, TALL_GRASS, TALL_GRASS ; 35
tilecoll FLOOR, FLOOR, TALL_GRASS, TALL_GRASS ; 36
tilecoll TALL_GRASS, FLOOR, TALL_GRASS, FLOOR ; 37
tilecoll WALL, WALL, WALL, WALL ; 38
tilecoll WALL, WALL, WALL, WALL ; 39
tilecoll WALL, WALL, DOOR, WALL ; 3a
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 3b
tilecoll WALL, WALL, WALL, DOOR ; 3c
tilecoll WALL, WALL, WALL, WALL ; 3d
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 3e
tilecoll FLOOR, FLOOR, WALL, WALL ; 3f
tilecoll FLOOR, FLOOR, WALL, WALL ; 40
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 41
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 42
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 43
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 44
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 45
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 46
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 47
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 48
tilecoll FLOOR, FLOOR, HOP_DOWN, HOP_DOWN ; 49
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 4a
tilecoll FLOOR, TALL_GRASS, FLOOR, TALL_GRASS ; 4b
tilecoll TALL_GRASS, FLOOR, TALL_GRASS, FLOOR ; 4c
tilecoll WALL, WALL, WALL, WALL ; 4d
tilecoll WALL, WALL, WALL, WALL ; 4e
tilecoll WALL, WALL, WALL, WALL ; 4f
tilecoll WALL, WALL, WALL, WALL ; 50
tilecoll WALL, WALL, WALL, WALL ; 51
tilecoll WALL, WALL, WALL, WALL ; 52
tilecoll WALL, WALL, WALL, WALL ; 53
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 54
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 55
tilecoll FLOOR, FLOOR, WALL, WALL ; 56
tilecoll FLOOR, FLOOR, WALL, WALL ; 57
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 58
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 59
tilecoll WALL, TALL_GRASS, WALL, WALL ; 5a
tilecoll WALL, FLOOR, WALL, FLOOR ; 5b
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 5c
tilecoll TALL_GRASS, TALL_GRASS, WALL, WALL ; 5d
tilecoll TALL_GRASS, TALL_GRASS, HOP_DOWN, HOP_DOWN ; 5e
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 5f
tilecoll WALL, WALL, WALL, WALL ; 60
tilecoll WALL, WALL, WALL, WALL ; 61
tilecoll WALL, WALL, WALL, WALL ; 62
tilecoll WALL, WALL, WALL, WALL ; 63
tilecoll WALL, WALL, FLOOR, FLOOR ; 64
tilecoll FLOOR, FLOOR, WALL, FLOOR ; 65
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 66
tilecoll HOP_DOWN, FLOOR, WALL, FLOOR ; 67
tilecoll FLOOR, FLOOR, HOP_DOWN, WALL ; 68
tilecoll FLOOR, FLOOR, FLOOR, WALL ; 69
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 6a
tilecoll WALL, WALL, WALL, WALL ; 6b
tilecoll WALL, WALL, FLOOR, FLOOR ; 6c
tilecoll WALL, FLOOR, WALL, FLOOR ; 6d
tilecoll FLOOR, WALL, FLOOR, WALL ; 6e
tilecoll FLOOR, FLOOR, WALL, WALL ; 6f
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 70
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 71
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 72
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 73
tilecoll WALL, WALL, WALL, WALL ; 74
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 75
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 76
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 77
tilecoll FLOOR, TALL_GRASS, FLOOR, TALL_GRASS ; 78
tilecoll FLOOR, TALL_GRASS, FLOOR, TALL_GRASS ; 79
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 7a
tilecoll FLOOR, TALL_GRASS, WALL, WALL ; 7b
tilecoll WALL, WALL, WALL, DOOR ; 7c
tilecoll WALL, WALL, WALL, WALL ; 7d
tilecoll WALL, WALL, WALL, WALL ; 7e
tilecoll WALL, WALL, WALL, WALL ; 7f
tilecoll TALL_GRASS, TALL_GRASS, FLOOR, FLOOR ; 80
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 81
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 82
tilecoll HOP_DOWN, HOP_DOWN, WALL, WALL ; 83
tilecoll HOP_DOWN, HOP_DOWN, WALL, WALL ; 84
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 85
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 86
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 87
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 88
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 89
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8a
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8b
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8c
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8d
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8e
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 8f
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 90
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 91
tilecoll FLOOR, FLOOR, WALL, WALL ; 92
tilecoll FLOOR, FLOOR, WALL, WALL ; 93
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 94
tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 95
|
alloy4fun_models/trashltl/models/11/rwAKBXJD5gCoA9cxm.als | Kaixi26/org.alloytools.alloy | 0 | 692 | open main
pred idrwAKBXJD5gCoA9cxm_prop12 {
eventually always all f : File | f not in Trash implies f in Trash'
}
pred __repair { idrwAKBXJD5gCoA9cxm_prop12 }
check __repair { idrwAKBXJD5gCoA9cxm_prop12 <=> prop12o } |
programs/oeis/287/A287555.asm | jmorken/loda | 1 | 244771 | ; A287555: Positions of 3 in A053839.
; 4,7,10,13,19,22,25,32,34,37,44,47,49,56,59,62,67,70,73,80,82,85,92,95,97,104,107,110,116,119,122,125,130,133,140,143,145,152,155,158,164,167,170,173,179,182,185,192,193,200,203,206,212,215,218,221,227,230,233,240,242,245,252,255,259,262,265,272,274,277,284,287,289,296,299,302,308,311,314,317,322,325,332,335,337,344,347,350,356,359,362,365,371,374,377,384,385,392,395,398,404,407,410,413,419,422,425,432,434,437,444,447,452,455,458,461,467,470,473,480,482,485,492,495,497,504,507,510,514,517,524,527,529,536,539,542,548,551,554,557,563,566,569,576,577,584,587,590,596,599,602,605,611,614,617,624,626,629,636,639,644,647,650,653,659,662,665,672,674,677,684,687,689,696,699,702,707,710,713,720,722,725,732,735,737,744,747,750,756,759,762,765,769,776,779,782,788,791,794,797,803,806,809,816,818,821,828,831,836,839,842,845,851,854,857,864,866,869,876,879,881,888,891,894,899,902,905,912,914,917,924,927,929,936,939,942,948,951,954,957,962,965,972,975,977,984,987,990,996,999
mov $2,$0
mov $3,$0
mul $3,8
mov $0,$3
mov $5,$3
lpb $0
add $0,$5
lpb $0
add $3,$0
div $0,4
lpe
lpe
sub $0,1
mov $1,$0
lpb $3
mod $3,4
lpe
mul $1,$3
add $1,4
mov $4,$2
mul $4,4
add $1,$4
|
programs/oeis/024/A024403.asm | jmorken/loda | 1 | 173765 | <reponame>jmorken/loda<filename>programs/oeis/024/A024403.asm
; A024403: [ (4th elementary symmetric function of S(n))/(3rd elementary symmetric function of S(n)) ], where S(n) = {first n+3 positive integers congruent to 2 mod 3}.
; 1,3,5,9,13,18,24,30,37,45,54,64,74,85,97,109,122,136,151,167,183,200,218,236,255,275,296,318,340,363,387,411,436,462,489,517,545,574,604,634,665,697,730,764,798,833,869,905,942,980,1019,1059,1099,1140,1182,1224,1267,1311,1356,1402,1448,1495,1543,1591,1640,1690,1741,1793,1845,1898,1952,2006,2061,2117,2174,2232,2290,2349,2409,2469,2530,2592,2655,2719,2783,2848,2914,2980,3047,3115,3184,3254,3324,3395,3467,3539,3612,3686,3761,3837,3913,3990,4068,4146,4225,4305,4386,4468,4550,4633,4717,4801,4886,4972,5059,5147,5235,5324,5414,5504,5595,5687,5780,5874,5968,6063,6159,6255,6352,6450,6549,6649,6749,6850,6952,7054,7157,7261,7366,7472,7578,7685,7793,7901,8010,8120,8231,8343,8455,8568,8682,8796,8911,9027,9144,9262,9380,9499,9619,9739,9860,9982,10105,10229,10353,10478,10604,10730,10857,10985,11114,11244,11374,11505,11637,11769,11902,12036,12171,12307,12443,12580,12718,12856,12995,13135,13276,13418,13560,13703,13847,13991,14136,14282,14429,14577,14725,14874,15024,15174,15325,15477,15630,15784,15938,16093,16249,16405,16562,16720,16879,17039,17199,17360,17522,17684,17847,18011,18176,18342,18508,18675,18843,19011,19180,19350,19521,19693,19865,20038,20212,20386,20561,20737,20914,21092,21270,21449,21629,21809,21990,22172,22355,22539,22723,22908,23094,23280,23467,23655
mov $4,$0
lpb $0
sub $0,1
add $2,$0
lpe
mul $2,6
add $2,1
mov $5,$2
trn $5,3
add $5,8
div $5,8
mov $1,$5
mov $3,$4
mul $3,2
add $1,$3
|
smsq/atari/kbd/tables.asm | olifink/smsqe | 0 | 25166 | <reponame>olifink/smsqe
; Atari keyboard tables 1988 / 2000 <NAME>
section kbd
xdef kbd_krtab
xdef kbd_atab
include 'dev8_smsq_kbd_keys'
; KEYROW table high nibble: bit, low nibble: row
kbd_krtab
dc.b $08,$31,$34,$16 ; 00
dc.b $14,$60,$20,$26 ; 04
dc.b $70,$06,$05,$56 ; 08
dc.b $55,$53,$18,$35 ; 0c
dc.b $36,$15,$46,$45 ; 10
dc.b $66,$65,$76,$25 ; 14
dc.b $75,$54,$03,$02 ; 18
dc.b $01,$17,$44,$33 ; 1c
dc.b $64,$43,$63,$24 ; 20
dc.b $74,$23,$04,$73 ; 24
dc.b $72,$52,$07,$08 ; 28
dc.b $12,$37,$32,$47 ; 2c
dc.b $42,$67,$62,$77 ; 30
dc.b $22,$57,$07,$28 ; 34
dc.b $27,$61,$13,$10 ; 38
dc.b $30,$40,$00,$50 ; 3c
dc.b $38,$48,$58,$68 ; 40
dc.b $78,$09,$19,$29 ; 44
dc.b $21,$39,$49,$11 ; 48
dc.b $59,$41,$69,$79 ; 4c
dc.b $71,$0a,$1a,$2a ; 50
dc.b $3a,$4a,$5a,$6a ; 54
dc.b $7a,$0b,$1b,$2b ; 58
dc.b $3b,$4b,$5b,$6b ; 5c
dc.b $7b,$0c,$1c,$2c ; 60
dc.b $3c,$4c,$5c,$6c ; 64
dc.b $7c,$0d,$1d,$2d ; 68
dc.b $3d,$4d,$5d,$6d ; 6c
dc.b $7d,$0e,$1e,$2e ; 70
. equ kba.norm normal key
s equ kba.shift shift action
c equ kba.ctrl control action
a equ kba.alt alt action
g equ kba.altgr alt gr action
k equ kba.caps caps
l equ kba.slock scroll lock
y equ kba.sys system request
u equ kba.undo undo (and hard reset)
b equ kba.break pause / break action (and hard reset)
t equ kba.tab tab (and soft reset)
kbd_atab
dc.b .,.,.,.,.,.,.,.,.,.,.,.,.,.,.,T
dc.b .,.,.,.,.,.,.,.,.,.,.,.,.,C,.,.
dc.b .,.,.,.,.,.,.,.,.,.,S,.,.,.,.,.
dc.b .,.,.,.,.,.,S,.,A,.,K,.,.,.,.,.
dc.b .,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
dc.b .,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
dc.b .,U,.,.,.,.,.,.,.,.,.,.,.,.,.,.
dc.b .,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
end
|
ga_ref_impl/test_general_inverse/src/general_inverse_test.adb | rogermc2/GA_Ada | 3 | 6159 | <filename>ga_ref_impl/test_general_inverse/src/general_inverse_test.adb
with Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
with Blade;
with Blade_Types;
with GA_Maths;
with GA_Utilities;
with Metric;
with Multivectors; use Multivectors;
with Multivector_Type;
procedure General_Inverse_Test is
use Blade.Names_Package;
BV_Names : Blade.Basis_Vector_Names;
C3_Met_Matrix : constant Metric.Metric_Matrix (1 .. 5, 1 .. 5) :=
((0.0, 0.0, 0.0, 0.0, -1.0),
(0.0, 1.0, 0.0, 0.0, 0.0),
(0.0, 0.0, 1.0, 0.0, 0.0),
(0.0, 0.0, 0.0 ,1.0, 0.0),
(-1.0, 0.0, 0.0 , 0.0, 0.0));
C3_Metric : constant Metric.Metric_Record := Metric.New_Metric (C3_Met_Matrix);
no_bv : Multivector := Basis_Vector (Blade_Types.C3_no);
e1_bv : Multivector := Basis_Vector (Blade_Types.C3_e1);
e2_bv : Multivector := Basis_Vector (Blade_Types.C3_e2);
e3_bv : Multivector := Basis_Vector (Blade_Types.C3_e3);
ni_bv : Multivector := Basis_Vector (Blade_Types.C3_ni);
MV_A1 : Multivector;
MV_A2 : Multivector;
MV_A : Multivector;
MV_A_Inv : Multivector;
NP_1 : constant Multivector := New_Normalized_Point (-0.356756, -0.881980, 0.0);
NP_1_OP : Multivector;
NP_1_IP : Multivector;
NP_1_GP_Met : Multivector;
NP_1_IP_Met : Multivector;
NP_1_Inv : Multivector;
NP_1_GP : Multivector;
begin
BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("no"));
BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("e1"));
BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("e2"));
BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("e3"));
BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("ni"));
MV_A1 := Outer_Product (e2_bv, e3_bv);
MV_A2 := e1_bv + Outer_Product (e2_bv, e3_bv);
MV_A := e1_bv + Outer_Product (Outer_Product (e2_bv, e3_bv), e1_bv);
GA_Utilities.Print_Multivector ("General_Inverse_Test MV_A1", MV_A1);
GA_Utilities.Print_Multivector ("General_Inverse_Test MV_A2", MV_A2);
GA_Utilities.Print_Multivector ("General_Inverse_Test MV_A", MV_A);
MV_A_Inv := General_Inverse (MV_A);
GA_Utilities.Print_Multivector ("General_Inverse_Test MV_A_Inv", MV_A_Inv);
GA_Utilities.Print_Multivector ("General_Inverse_Test NP_1", NP_1);
NP_1_OP := Outer_Product (NP_1, NP_1);
GA_Utilities.Print_Multivector ("General_Inverse_Test NP_1_OP", NP_1_OP);
-- GA_Utilities.Print_Multivector ("General_Inverse_Test MV_A", MV_A);
-- MV_A_GP := Geometric_Product (MV_A, MV_A);
-- GA_Utilities.Print_Multivector ("General_Inverse_Test MV_A_GP", MV_A_GP);
-- MV_A_GP_Met := Geometric_Product (MV_A, MV_A, C3_Metric);
-- GA_Utilities.Print_Multivector ("General_Inverse_Test MV_A_GP_Met", MV_A_GP_Met);
-- MV_A_Inv := General_Inverse (MV_A, C3_Metric);
GA_Utilities.Print_Multivector ("General_Inverse_Test NP_1", NP_1);
NP_1_OP := Outer_Product (NP_1, NP_1);
GA_Utilities.Print_Multivector ("General_Inverse_Test NP_1_OP", NP_1_OP);
NP_1_GP := Geometric_Product (NP_1, NP_1);
GA_Utilities.Print_Multivector ("General_Inverse_Test NP_1_GP", NP_1_GP);
NP_1_GP_Met := Geometric_Product (NP_1, NP_1, C3_Metric);
GA_Utilities.Print_Multivector ("General_Inverse_Test NP_1_GP_Met", NP_1_GP_Met);
NP_1_IP := Inner_Product (NP_1, NP_1,Blade.Left_Contraction);
GA_Utilities.Print_Multivector ("General_Inverse_Test NP_1_IP", NP_1_IP);
NP_1_IP_Met := Geometric_Product (NP_1, NP_1, C3_Metric);
GA_Utilities.Print_Multivector ("General_Inverse_Test NP_1_IP_Met", NP_1_IP_Met);
NP_1_Inv := General_Inverse (NP_1, C3_Metric);
GA_Utilities.Print_Multivector ("General_Inverse_Test NP_1_Inv", NP_1_Inv);
exception
when anError : others =>
Put_Line ("An exception occurred in General_Inverse_Test.");
raise;
end General_Inverse_Test;
|
Univalence/PiIter.agda | JacquesCarette/pi-dual | 14 | 15985 | {-# OPTIONS --without-K #-}
module PiIter where
open import Level using (_⊔_) renaming (zero to l0; suc to lsuc)
open import Universe using (Universe)
open import Categories.Category using (Category)
open import Categories.Groupoid using (Groupoid)
open import Categories.Functor using (Functor)
open import Data.Empty using (⊥)
open import Data.Unit using (⊤; tt)
open import Data.Sum hiding ([_,_])
open import Data.Product
open import Relation.Binary.PropositionalEquality as P
open import Function using (flip)
open import Data.Nat using (ℕ; zero; suc)
open import Data.Nat.Properties.Simple using (+-right-identity)
open import Data.Integer using (ℤ;+_;-[1+_]) renaming (suc to ℤsuc; -_ to ℤ-; _+_ to _ℤ+_)
open import PiU using (U; ZERO; ONE; PLUS; TIMES; toℕ)
open import PiLevel0
open import PiLevel1
open import PiEquiv renaming (eval to ap; evalB to apB)
open import Equiv
infix 40 _^_
_^_ : {τ : U} → (p : τ ⟷ τ) → (k : ℤ) → (τ ⟷ τ)
p ^ (+ 0) = id⟷
p ^ (+ (suc k)) = p ◎ (p ^ (+ k))
p ^ -[1+ 0 ] = ! p
p ^ (-[1+ (suc k) ]) = (! p) ◎ (p ^ -[1+ k ])
-- useful properties of ^
-- because ^ is iterated composition of the same thing,
-- then by associativity, we can hive off compositions
-- from left or right
assoc1 : {τ : U} → {p : τ ⟷ τ} → (m : ℕ) →
(p ◎ (p ^ (+ m))) ⇔ ((p ^ (+ m)) ◎ p)
assoc1 ℕ.zero = trans⇔ idr◎l idl◎r
assoc1 (suc m) = trans⇔ (id⇔ ⊡ assoc1 m) assoc◎l
assoc1- : {τ : U} → {p : τ ⟷ τ} → (m : ℕ) →
((! p) ◎ (p ^ -[1+ m ])) ⇔ ((p ^ -[1+ m ]) ◎ (! p))
assoc1- ℕ.zero = id⇔
assoc1- (suc m) = trans⇔ (id⇔ ⊡ assoc1- m) assoc◎l
-- more generally
assoc1g : {τ : U} → {p : τ ⟷ τ} → (i : ℤ) →
(p ◎ (p ^ i)) ⇔ ((p ^ i) ◎ p)
assoc1g (+_ n) = assoc1 n
assoc1g (-[1+_] zero) = trans⇔ linv◎l rinv◎r
assoc1g (-[1+_] (suc n)) = trans⇔ assoc◎l (trans⇔ (linv◎l ⊡ id⇔) (
trans⇔ idl◎l (2! (trans⇔ (assoc1- n ⊡ id⇔) (trans⇔ assoc◎r
(trans⇔ (id⇔ ⊡ rinv◎l) idr◎l))))))
-- Property of ^: negating exponent is same as
-- composing in the other direction, then reversing.
^⇔! : {τ : U} → {p : τ ⟷ τ} → (k : ℤ) →
(p ^ (ℤ- k)) ⇔ ! (p ^ k)
^⇔! (+_ ℕ.zero) = id⇔
-- need to dig deeper, as we end up negating
^⇔! (+_ (suc ℕ.zero)) = idl◎r
^⇔! (+_ (suc (suc n))) = trans⇔ (assoc1- n) (^⇔! (+ suc n) ⊡ id⇔)
^⇔! {p = p} (-[1+_] ℕ.zero) = trans⇔ idr◎l (2! !!⇔id) -- (!!⇔id {c = p})
^⇔! {p = p} (-[1+_] (suc n)) =
trans⇔ (assoc1 (suc n)) ((^⇔! -[1+ n ]) ⊡ 2! !!⇔id) -- (!!⇔id p))
-- first match on m, n, then proof is purely PiLevel1
lower : {τ : U} {p : τ ⟷ τ} (m n : ℤ) →
p ^ (m ℤ+ n) ⇔ ((p ^ m) ◎ (p ^ n))
lower (+_ ℕ.zero) (+_ n) = idl◎r
lower (+_ ℕ.zero) (-[1+_] n) = idl◎r
lower (+_ (suc m)) (+_ n) =
trans⇔ (id⇔ ⊡ lower (+ m) (+ n)) assoc◎l
lower {p = p} (+_ (suc m)) (-[1+_] ℕ.zero) =
trans⇔ idr◎r (trans⇔ (id⇔ ⊡ linv◎r) (
trans⇔ assoc◎l (2! (assoc1 m) ⊡ id⇔))) -- p ^ ((m + 1) -1)
lower (+_ (suc m)) (-[1+_] (suc n)) = -- p ^ ((m + 1) -(1+1+n)
trans⇔ (lower (+ m) (-[1+ n ])) (
trans⇔ ((trans⇔ idr◎r (id⇔ ⊡ linv◎r)) ⊡ id⇔) (
trans⇔ assoc◎r (trans⇔ (id⇔ ⊡ assoc◎r) (
trans⇔ assoc◎l (2! (assoc1 m) ⊡ id⇔)))))
lower (-[1+_] m) (+_ ℕ.zero) = idr◎r
lower (-[1+_] ℕ.zero) (+_ (suc n)) = 2! (trans⇔ assoc◎l (
trans⇔ (rinv◎l ⊡ id⇔) idl◎l))
lower (-[1+_] (suc m)) (+_ (suc n)) = -- p ^ (-(1+m) + (n+1))
trans⇔ (lower (-[1+ m ]) (+ n)) (
trans⇔ ((trans⇔ idr◎r (id⇔ ⊡ rinv◎r)) ⊡ id⇔) (
trans⇔ assoc◎r (trans⇔ (id⇔ ⊡ assoc◎r) (
trans⇔ assoc◎l ((2! (assoc1- m)) ⊡ id⇔)))))
lower (-[1+_] ℕ.zero) (-[1+_] n) = id⇔
lower (-[1+_] (suc m)) (-[1+_] n) = -- p ^ (-(1+1+m) - (1+n))
trans⇔ (id⇔ ⊡ lower (-[1+ m ]) (-[1+ n ])) assoc◎l
-- i.e. Iter is: for all i, any p' such that
-- p' ⇔ p ^ i
record Iter {τ : U} (p : τ ⟷ τ) : Set where
constructor iter
field
i : ℤ
p' : τ ⟷ τ
p'⇔p^i : p' ⇔ (p ^ i)
-- Equality of Iter.
record _≡c_ {τ : U} {p : τ ⟷ τ} (q r : Iter p) : Set where
constructor eqc
field
iter≡ : Iter.i q ≡ Iter.i r
p⇔ : Iter.p' q ⇔ Iter.p' r
-- Iterates of id⟷
id^i≡id : {t : U} (i : ℤ) → (id⟷ ^ i) ⇔ (id⟷ {t})
id^i≡id (+_ zero) = id⇔
id^i≡id (+_ (suc n)) = trans⇔ idl◎l (id^i≡id (+ n))
id^i≡id (-[1+_] zero) = id⇔
id^i≡id (-[1+_] (suc n)) = trans⇔ idl◎l (id^i≡id -[1+ n ])
|
oeis/288/A288937.asm | neoneye/loda-programs | 11 | 25305 | <gh_stars>10-100
; A288937: Positions of 0 in A288936; complement of A288938.
; Submitted by <NAME>
; 1,2,4,5,8,11,15,20,26,33,41,50,60,71,83,96,110,125,141,158,176,195,215,236,258,281,305,330,356,383,411,440,470,501,533,566,600,635,671,708,746,785,825,866,908,951,995,1040,1086,1133,1181,1230,1280,1331,1383,1436,1490,1545,1601,1658,1716,1775,1835,1896,1958,2021,2085,2150,2216,2283,2351,2420,2490,2561,2633,2706,2780,2855,2931,3008,3086,3165,3245,3326,3408,3491,3575,3660,3746,3833,3921,4010,4100,4191,4283,4376,4470,4565,4661,4758
lpb $0
add $2,$0
add $1,$2
div $1,2
add $1,$0
sub $0,1
sub $2,2
lpe
mov $0,$1
add $0,1
|
lang/src/main/antlr/FusionParser.g4 | sandstorm/fusion4j | 2 | 6290 | /*
* MIT License
*
* Copyright (c) 2022 Sandstorm Media GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* - <NAME>
*/
/*
Path assignments (root and inside of a body)
- a path may be nested
- a prototype(XYZ) declaration/configuration can be a path segment
- a prototype(XYZ) assignment can be a path segment, but never the last
*/
parser grammar FusionParser;
options { tokenVocab=FusionLexer; }
/*
--------- path only parser rule
*/
fusionPath
: rootFusionConfigurationPathReference
EOF
;
/*
--------- main parser rule (fragmented)
*/
fusionFile
: rootFragment* EOF
;
rootFragment
: rootPrototypeErasure
| rootFusionConfigurationErasure
| rootPrototypeDecl
| rootFusionAssign
| rootFusionConfiguration
| rootFusionConfigurationCopy
| codeComment
| namespaceAlias
| fileInclude
| whitespace
;
fusionFragment
: fusionAssign
| fusionConfiguration
| fusionConfigurationCopy
| fusionConfigurationErasure
| codeComment
| whitespace
;
/*
--------- comments / whitespaces
*/
whitespace
: WHITESPACE
| BODY_WHITESPACE
;
codeComment
: ROOT_CODE_COMMENT
| CODE_COMMENT
;
/*
--------- file includes
*/
fileInclude
: FILE_INCLUDE_KEYWORD_AND_OPERATOR
fileIncludePattern
;
fileIncludePattern
: FILE_INCLUDE_FILE_PATTERN
| INVALID_FILE_INCLUDE_PATTERN {notifyErrorListeners("file include pattern does not allow whitespaces");}
;
/*
--------- namespace aliases
*/
namespaceAlias
: NAMESPACE_ALIAS_KEYWORD_AND_OPERATOR
NAMESPACE_ALIAS_NAMESPACE
NAMESPACE_ALIAS_OPERATOR
NAMESPACE_ALIAS_TARGET_NAMESPACE
;
/*
--------- root fusion declaration
For now, this is just boiler plate to support
the recursive push/pop mecanics of the lexer,
since there is no difference between root and
inner path declarations.
*/
rootFusionAssign
: rootFusionAssignPath
ROOT_FUSION_PATH_DECLARE_OPERATOR
rootFusionValueDecl
;
rootFusionAssignPath
: (rootPrototypeCall | rootFusionMetaPropPathSegment | rootFusionPathSegment)
(
(ROOT_FUSION_PATH_NESTING_SEPARATOR (rootPrototypeCall | rootFusionMetaPropPathSegment | rootFusionPathSegment))*
ROOT_FUSION_PATH_NESTING_SEPARATOR (rootFusionMetaPropPathSegment | rootFusionPathSegment)
)?
;
rootPrototypeCall
: ROOT_PROTOTYPE_KEYWORD ROOT_PROTOTYPE_CALL_START PROTOTYPE_NAME PROTOTYPE_CALL_END WHITESPACE_NO_BR*
;
rootFusionConfiguration
: rootFusionConfigurationPath
rootFusionConfigurationBody
;
rootFusionConfigurationBody
: ROOT_FUSION_BODY_START
fusionFragment*
FUSION_BODY_END
;
rootFusionConfigurationErasure
: rootFusionConfigurationPath
ROOT_FUSION_ERASURE
;
rootFusionConfigurationPath
: (rootPrototypeCall | rootFusionMetaPropPathSegment | rootFusionPathSegment)
(ROOT_FUSION_PATH_NESTING_SEPARATOR (rootPrototypeCall | rootFusionMetaPropPathSegment | rootFusionPathSegment))*
;
rootFusionPathSegment
: ROOT_FUSION_PATH_SEGMENT
;
rootFusionMetaPropPathSegment
: ROOT_FUSION_META_PROP_PREFIX ROOT_FUSION_PATH_SEGMENT
;
rootFusionConfigurationCopy
: rootFusionConfigurationPath
ROOT_COPY_OPERATOR
rootFusionConfigurationPathReference
rootFusionConfigurationBody?
;
rootFusionConfigurationPathReference
: ROOT_FUSION_PATH_NESTING_SEPARATOR? rootFusionConfigurationPath
;
/*
--------- root prototype declarations
*/
rootPrototypeDecl
: rootPrototypeCall
prototypeInheritance?
prototypeBody?
;
rootPrototypeErasure
: rootPrototypeCall ROOT_FUSION_ERASURE
;
prototypeBody
: ROOT_FUSION_BODY_START
fusionFragment*
FUSION_BODY_END
;
prototypeInheritance
: ROOT_COPY_OPERATOR rootPrototypeCall
;
/*
--------- Fusion path declarations
*/
// everything with 'path = ...'
fusionAssign
: fusionAssignPath
FUSION_PATH_ASSIGN_OPERATOR
fusionValueDecl
;
fusionAssignPath
: (prototypeCall | fusionMetaPropPathSegment | fusionPathSegment)
(
(FUSION_PATH_NESTING_SEPARATOR (prototypeCall | fusionMetaPropPathSegment | fusionPathSegment))*
FUSION_PATH_NESTING_SEPARATOR (fusionMetaPropPathSegment | fusionPathSegment)
)?
;
prototypeCall
: PROTOTYPE_KEYWORD PROTOTYPE_CALL_START PROTOTYPE_NAME PROTOTYPE_CALL_END WHITESPACE_NO_BR*
;
fusionConfigurationErasure
: fusionConfigurationPath
FUSION_ERASURE
;
// configuration declaration of a fusion path 'path { ... }'
fusionConfiguration
: fusionConfigurationPath
fusionConfigurationBody
;
fusionConfigurationBody
: FUSION_BODY_START
fusionFragment*
FUSION_BODY_END
;
fusionConfigurationPath
: (prototypeCall | fusionMetaPropPathSegment | fusionPathSegment)
(FUSION_PATH_NESTING_SEPARATOR (prototypeCall | fusionMetaPropPathSegment | fusionPathSegment))*
;
fusionPathSegment
: FUSION_PATH_SEGMENT
;
fusionMetaPropPathSegment
: FUSION_META_PROP_PREFIX FUSION_PATH_SEGMENT
;
fusionConfigurationCopy
: fusionConfigurationPath
COPY_OPERATOR
fusionConfigurationPathReference
fusionConfigurationBody?
;
fusionConfigurationPathReference
: FUSION_PATH_NESTING_SEPARATOR? fusionConfigurationPath
;
/*
--------- Fusion values
*/
rootFusionValueDecl
: fusionValueLiteralDecl
rootFusionValueBody?
;
fusionValueDecl
: fusionValueLiteralDecl
fusionValueBody?
;
rootFusionValueBody
: ROOT_FUSION_BODY_START
fusionFragment*
FUSION_BODY_END
;
fusionValueBody
: FUSION_BODY_START
fusionFragment*
FUSION_BODY_END
;
fusionValueLiteralDecl
: fusionValueNull
| fusionValueStringSingleQuote
| fusionValueStringDoubleQuote
| fusionValueNumber
| fusionValueBoolean
| fusionValueExpression
| fusionValueDslDelegate
| fusionValueObject
;
fusionValueNull: FUSION_VALUE_LITERAL_NULL;
fusionValueStringSingleQuote: FUSION_VALUE_STRING_SQUOTE;
fusionValueStringDoubleQuote: FUSION_VALUE_STRING_DQUOTE;
fusionValueNumber: FUSION_VALUE_NUMBER;
fusionValueBoolean: FUSION_VALUE_BOOLEAN;
fusionValueDslDelegate: FUSION_VALUE_DSL_DELEGATE;
fusionValueObject: FUSION_VALUE_OBJECT;
fusionValueExpression
: FUSION_VALUE_EXPRESSION_START
(EL_CODE_START_BLOCK | EL_CODE_END_BLOCK | EL_STRING | EL_CODE_FRAGMENT)*
EL_CODE_END_BLOCK
;
|
Task/Bitwise-IO/Ada/bitwise-io-3.ada | LaudateCorpus1/RosettaCodeData | 1 | 14412 | <reponame>LaudateCorpus1/RosettaCodeData<gh_stars>1-10
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
with Bit_Streams; use Bit_Streams;
procedure Test_Bit_Streams is
File : File_Type;
ABACUS : Bit_Array :=
( 1,0,0,0,0,0,1, -- A, big endian
1,0,0,0,0,1,0, -- B
1,0,0,0,0,0,1, -- A
1,0,0,0,0,1,1, -- C
1,0,1,0,1,0,1, -- U
1,0,1,0,0,1,1 -- S
);
Data : Bit_Array (ABACUS'Range);
begin
Create (File, Out_File, "abacus.dat");
declare
Bits : Bit_Stream (Stream (File));
begin
Write (Bits, ABACUS);
end;
Close (File);
Open (File, In_File, "abacus.dat");
declare
Bits : Bit_Stream (Stream (File));
begin
Read (Bits, Data);
end;
Close (File);
if Data /= ABACUS then
raise Data_Error;
end if;
end Test_Bit_Streams;
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca_notsx.log_21829_1130.asm | ljhsiun2/medusa | 9 | 247671 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r15
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x7013, %rsi
lea addresses_UC_ht+0x1cdd3, %rdi
nop
nop
nop
nop
nop
inc %rax
mov $111, %rcx
rep movsl
nop
xor $46813, %r15
lea addresses_D_ht+0xec83, %rbx
cmp %rax, %rax
mov (%rbx), %si
nop
cmp %r15, %r15
lea addresses_WC_ht+0x18e77, %r15
nop
nop
nop
nop
sub $20037, %r11
mov $0x6162636465666768, %rcx
movq %rcx, %xmm5
and $0xffffffffffffffc0, %r15
movntdq %xmm5, (%r15)
nop
nop
nop
nop
and %r15, %r15
lea addresses_D_ht+0x1ed13, %rsi
lea addresses_normal_ht+0xf113, %rdi
nop
nop
nop
inc %rdx
mov $8, %rcx
rep movsb
nop
nop
dec %r11
lea addresses_D_ht+0x1d5d3, %rsi
lea addresses_WT_ht+0x12413, %rdi
nop
nop
nop
nop
nop
cmp %r11, %r11
mov $112, %rcx
rep movsb
nop
nop
nop
nop
cmp $65148, %rcx
lea addresses_normal_ht+0x1e783, %rsi
lea addresses_normal_ht+0x15f43, %rdi
nop
nop
nop
nop
xor %r15, %r15
mov $124, %rcx
rep movsl
cmp %rbx, %rbx
lea addresses_UC_ht+0x42c3, %rsi
lea addresses_D_ht+0x17edf, %rdi
clflush (%rdi)
nop
nop
nop
cmp %r15, %r15
mov $21, %rcx
rep movsb
nop
nop
nop
sub $10381, %r15
lea addresses_UC_ht+0xf513, %rsi
lea addresses_D_ht+0x12333, %rdi
nop
nop
and %rdx, %rdx
mov $15, %rcx
rep movsb
nop
nop
nop
nop
nop
dec %r15
lea addresses_A_ht+0x40a9, %r11
nop
nop
nop
dec %rcx
and $0xffffffffffffffc0, %r11
vmovntdqa (%r11), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $1, %xmm2, %rdi
nop
nop
add %rbx, %rbx
lea addresses_WC_ht+0x17153, %r11
nop
nop
nop
nop
xor $57426, %rax
mov (%r11), %rdi
nop
nop
nop
sub %rdi, %rdi
lea addresses_WC_ht+0x1da13, %rdi
nop
nop
nop
nop
nop
add $57948, %rbx
movups (%rdi), %xmm4
vpextrq $1, %xmm4, %rsi
nop
xor %rdi, %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r15
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r14
push %r9
push %rax
push %rbx
push %rdi
// Store
lea addresses_PSE+0xc78f, %r14
clflush (%r14)
nop
nop
nop
sub %r13, %r13
mov $0x5152535455565758, %r12
movq %r12, (%r14)
nop
cmp $8082, %rbx
// Store
lea addresses_A+0x13d13, %rbx
nop
nop
nop
nop
nop
cmp $61134, %r9
movb $0x51, (%rbx)
nop
nop
nop
nop
add $43238, %r14
// Faulty Load
lea addresses_UC+0x8513, %rbx
nop
nop
nop
nop
and $28148, %rax
mov (%rbx), %r9d
lea oracles, %r12
and $0xff, %r9
shlq $12, %r9
mov (%r12,%r9,1), %r9
pop %rdi
pop %rbx
pop %rax
pop %r9
pop %r14
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 2}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_normal_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}, 'dst': {'same': True, 'congruent': 2, 'type': 'addresses_D_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_D_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 1}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 8}}
{'37': 21829}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
oeis/173/A173205.asm | neoneye/loda-programs | 11 | 173319 | ; A173205: a(n) = 98*a(n-1)-a(n-2) for n>2, a(1)=1, a(2)=98.
; Submitted by <NAME>(s3)
; 1,98,9603,940996,92208005,9035443494,885381254407,86758327488392,8501430712608009,833053451508096490,81630736817080848011,7998979154622415008588,783818326416179589993613,76806197009630977404365486,7526223488617419606037824015,737493095687497490414302387984,72266797153886136640995596198417,7081408627985153893327154125056882,693905778745391195409420108659376019,67995684908420351996229843494493792980,6662883215246449104435115242351732336021,652894559409243591882645063906975275137078
mul $0,2
add $0,2
seq $0,1078 ; a(n) = 10*a(n-1) - a(n-2) with a(0) = 0, a(1) = 2.
div $0,20
|
clear_notification/clear.applescript | tomorrowkey/alfred-workflows | 4 | 2455 | <reponame>tomorrowkey/alfred-workflows<filename>clear_notification/clear.applescript<gh_stars>1-10
log "Script begin"
tell application "System Events"
tell process "NotificationCenter"
repeat while ((count windows) > 0)
try
set numwins to (count windows)
repeat with i from 0 to numwins by 1
click button "Close" of window i
end repeat
error
-- noop
end try
end repeat
end tell
end tell
log "Script end"
|
memsim-master/src/parser-parse_trace.adb | strenkml/EE368 | 0 | 1641 | <filename>memsim-master/src/parser-parse_trace.adb
with Memory.Trace;
separate (Parser)
procedure Parse_Trace(parser : in out Parser_Type;
result : out Memory_Pointer) is
mem : Memory_Pointer := null;
begin
if Get_Type(parser) = Open then
Parse_Memory(parser, mem);
end if;
result := Memory_Pointer(Trace.Create_Trace(mem));
end Parse_Trace;
|
JSON.g4 | AILab-FOI/APi | 0 | 7597 | <reponame>AILab-FOI/APi
/** Taken from "The Definitive ANTLR 4 Reference" by <NAME> */
// Derived from http://json.org
// Tweaked a bit for awkward π-nguin
grammar JSON;
json
: value
;
obj
: '{' pair (',' pair)* '}'
| '{' '}'
;
pair
: STRING ':' value
| VARIABLE ':' value
;
arr
: '[' value (',' value)* ']'
| '[' ']'
;
value
: VARIABLE
| STRING
| NUMBER
| SPEC_CHAR
| obj
| arr
| 'true'
| 'false'
| 'null'
; // TODO: find out why SPEC_CHAR is here
SPEC_CHAR : ~('a'..'z' | 'A' .. 'Z' | '0' .. '9' | ':' | '.' | '-' | '>' | '<' | '/' | ' ' ) ;
VARIABLE : '?' IDENT ;
IDENT : NameStartChar1 NameChar1* ; //[a-zA-Z_] [a-zA-Z0-9]*;
fragment
NameChar1 : NameStartChar1
| '-' | '_' | INT
| '\u00B7'
| '\u0300'..'\u036F'
| '\u203F'..'\u2040'
;
fragment
NameStartChar1
: [a-zA-Z]
| '\u2070'..'\u218F'
| '\u2C00'..'\u2FEF'
| '\u3001'..'\uD7FF'
| '\uF900'..'\uFDCF'
| '\uFDF0'..'\uFFFD'
;
STRING
: '"' (ESC1 | SAFECODEPOINT1)* '"'
| '\'' (ESC2 | SAFECODEPOINT2)* '\''
;
fragment ESC1
: '\\' (["\\/bfnrt] | UNICODE)
;
fragment ESC2
: '\\' (['\\/bfnrt] | UNICODE)
;
fragment UNICODE
: 'u' HEX HEX HEX HEX
;
fragment HEX
: [0-9a-fA-F]
;
fragment SAFECODEPOINT1
: ~ ["\\\u0000-\u001F]
;
fragment SAFECODEPOINT2
: ~ ['\\\u0000-\u001F]
;
NUMBER
: '-'? INT ('.' [0-9] +)? EXP?
;
fragment INT
: '0' | [1-9] [0-9]*
;
// no leading zeros
fragment EXP
: [Ee] [+\-]? INT
;
// \- since - means "range" inside [...]
SPACE
: [ \r]+ -> skip
; |
oeis/199/A199757.asm | neoneye/loda-programs | 11 | 84794 | ; A199757: (7*11^n+1)/2.
; Submitted by <NAME>
; 4,39,424,4659,51244,563679,6200464,68205099,750256084,8252816919,90780986104,998590847139,10984499318524,120829492503759,1329124417541344,14620368592954779,160824054522502564,1769064599747528199,19459710597222810184,214056816569450912019,2354624982263960032204,25900874804903560354239,284909622853939163896624,3134005851393330802862859,34474064365326638831491444,379214708018593027146405879,4171361788204523298610464664,45884979670249756284715111299,504734776372747319131866224284
mov $2,11
pow $2,$0
mov $0,$2
mul $0,4
div $0,40
mul $0,70
add $0,8
div $0,2
|
Library/Text/Text/textEntry.asm | steakknife/pcgeos | 504 | 8128 | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1993 -- All Rights Reserved
PROJECT: PC/GEOS
MODULE: Text Library
FILE: textEntry.asm
AUTHOR: <NAME>, Sep 13, 1993
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
VM 9/13/93 Initial revision
DESCRIPTION:
Library entry point routines.
$Id: textEntry.asm,v 1.4 98/03/24 23:16:20 gene Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ForceRef TextLibraryEntry
ifdef USE_FEP
udata segment
fepStrategy fptr.far 0 ; Pointer to FEP
; strategy function.
fepDrHandle hptr.GeodeHeader
udata ends
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TextLibraryEntry
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Text Library Init/Deinit.
CALLED BY: INTERNAL ()
PASS: di = LibraryCallType
RETURN: carry = set if error
DESTROYED: si, di
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
When the text library is initially loaded, check the
INI file for FEP driver. If one is listed, load it. Upon
exiting the text library, unload the FEP driver.
REVISION HISTORY:
Name Date Description
---- ---- -----------
VM 9/13/93 Initial version
eca 3/14/97 added localized smart quotes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
TextInit segment resource
ifdef USE_FEP
FEP_DRIVER_NAME_LENGTH equ 12
fepCategory char "fep",0
fepDriverKey char "driver",0
LocalDefNLString fepDirectory <"FEP",0>
endif ; USE_FEP
quoteCategory char "localization",0
quoteKey char "quotes",0
TextLibraryEntry proc far
uses ax,bx,cx,dx,ds,es,di,si,bp
.enter
;
; ds <- Segment address of dgroup.
;
segmov ds, dgroup, ax
;
; Call appropriate routine based on LibraryCallType.
;
shl di
call cs:[libraryEntryTable][di]
.leave
ret
libraryEntryTable nptr.near \
loadFep, ; LCT_ATTACH
unloadFep, ; LCT_DETACH
doNothing, ; LCT_NEW_CLIENT
doNothing, ; LCT_NEW_CLIENT_THREAD
doNothing, ; LCT_CLIENT_THREAD_EXIT
doNothing ; LCT_CLIENT_EXIT
.assert length libraryEntryTable eq LibraryCallType
loadFep:
;
; read the quotes set in the GEOS.INI file, if any
;
push ds
segmov ds, cs, cx
mov si, offset quoteCategory ;ds:si <- category
mov dx, offset quoteKey ;cx:dx <- key
mov bp, InitFileReadFlags<IFCC_INTACT, 0, 0, (size TCHAR)*4>
;bp <- InitFileReadFlags
segmov es, dgroup, ax
mov di, offset uisqOpenSingle ;es:di <- buffer
call InitFileReadData
pop ds
ifdef USE_FEP
;
; LCT_ATTACH
; ----------
; Check for FEP driver in the INI file. Load any listed
; driver and store the corresponding strategy function in
; fepStrategy. If no FEP driver is listed clear fepStrategy.
;
push ds, bp
;
; Set parameters for InitFileReadString.
; ds:si = FEP category name
; cx:dx = FEP driver key name
; bp = 0
;
segmov ds, cs, cx
mov si, offset fepCategory
mov dx, offset fepDriverKey
clr bp
call InitFileReadString ; CF = 1 iff no driver
jc loadDone
;
; Switch to the FEP driver directory
;
push bx, dx
call FilePushDir
mov bx, SP_SYSTEM ; bx <- StandardPath
mov dx, offset fepDirectory ; ds:dx <- ptr to path
call FileSetCurrentPath
pop bx, dx
jc popDir ; branch if error
;
; FEP Driver is listed. bx = handle of driver name.
; Load the driver and obtain a pointer to its strategy.
;
push bx
call MemLock
mov ds, ax
clr si, ax, bx
call GeodeUseDriver ; Load the driver.
jc popExit ; branch if error.
mov bp, bx ; bp = driver handle
call GeodeInfoDriver ; Get the strategy pointer.
pop bx
call MemFree
;
; Store strategy pointer in local variable (fepStrategy).
;
mov ax, ds:[si].DIS_strategy.segment
mov si, ds:[si].DIS_strategy.offset
segmov ds, dgroup, bx
mov ds:fepStrategy.segment, ax
mov ds:fepStrategy.offset, si
mov ds:fepDrHandle, bp
;
; Return to whence we came
;
popDir:
call FilePopDir
loadDone:
clc
pop ds, bp
retn
popExit:
pop bx
call MemFree
jmp popDir
unloadFep:
;
; LCT_DETACH
; ----------
; If FEP Driver is loaded, unload it.
;
mov bx, ds:[fepDrHandle]
tst bx
jz doNothing
call GeodeFreeDriver
else ; !USE_FEP
unloadFep:
endif ; USE_FEP
doNothing:
clc
retn
TextLibraryEntry endp
ForceRef TextLibraryEntry
TextInit ends
|
src/asf-views-nodes-factory.adb | jquorning/ada-asf | 12 | 6310 | <filename>src/asf-views-nodes-factory.adb
-----------------------------------------------------------------------
-- nodes-core -- Tag Factory
-- Copyright (C) 2009, 2010 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with EL.Functions.Default;
package body ASF.Views.Nodes.Factory is
Function_Mapper : aliased EL.Functions.Default.Default_Function_Mapper;
function Functions return EL.Functions.Function_Mapper_Access is
begin
return Function_Mapper'Access;
end Functions;
begin
Function_Mapper.Set_Function (Name => "truncate",
Namespace => "http://code.google.com/p/ada-el",
Func => EL.Functions.Default.Truncate'Access);
end ASF.Views.Nodes.Factory;
|
PythonParser.g4 | RobEin/tiny-python | 0 | 3004 | <reponame>RobEin/tiny-python
/*
Python grammar
The MIT License (MIT)
Copyright (c) 2021 <NAME>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
* Project : an ANTLR4 parser grammar based on the official Python 3.8.12 grammar
* https://github.com/RobEin/tiny-python
* Developed by : <NAME>, <EMAIL>
*/
parser grammar PythonParser; // Tiny Python based on: https://docs.python.org/3.8/reference/grammar.html
options { tokenVocab=PythonLexer; superClass=PythonParserBase; }
// ANTLR4 grammar for Tiny Python
file_input: (NEWLINE | stmt)* EOF; // start rule
stmt: simple_stmt | compound_stmt;
simple_stmt: small_stmt NEWLINE;
small_stmt: expr_stmt | flow_stmt;
expr_stmt: NAME '=' expr;
flow_stmt: break_stmt | continue_stmt;
break_stmt: 'break';
continue_stmt: 'continue';
compound_stmt: if_stmt | while_stmt;
if_stmt: 'if' namedexpr_test ':' suite ('elif' namedexpr_test ':' suite)* ('else' ':' suite)?;
while_stmt: 'while' namedexpr_test ':';
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT;
namedexpr_test: test;
test: expr (comp_op expr)*;
comp_op: '<'|'>'|'=='|'>='|'<='|'!=';
expr: expr (( '+' | '-' ) expr)+
| NAME
| NUMBER
| '(' expr ')'
;
|
oeis/224/A224882.asm | neoneye/loda-programs | 11 | 7248 | <gh_stars>10-100
; A224882: G.f.: 1/(1 - 32*x)^(1/16).
; Submitted by <NAME>
; 1,2,34,748,18326,476476,12864852,356540184,10072260198,288738125676,8373405644604,245112419778408,7230816383463036,214699624924363992,6410317372741724904,192309521182251747120,5793324325615333881990,175162864903898918549580
mov $1,1
mov $2,1
mov $3,$0
mul $3,2
lpb $3
mul $1,$3
mul $1,8
mul $2,15
sub $1,$2
mov $2,$1
sub $3,1
cmp $4,0
add $5,$4
div $1,$5
div $2,$5
add $2,$1
mul $1,2
sub $3,1
mov $4,2
add $5,1
lpe
mov $0,$1
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/overriding_ops.ads | best08618/asylo | 7 | 1133 | <filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/overriding_ops.ads
with overriding_ops_p; use overriding_ops_p;
package overriding_ops is
task type Light_Programmer is new Device with
overriding entry Set_Name (Name : Name_Type);
end Light_Programmer;
-- Object that represents a light
protected type Light is new Device with
overriding procedure Set_Name (Name : Name_Type);
private
L_Name : Name_Type;
end Light;
end overriding_ops;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.