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
Mid-Term/Solution/4.asm
AhnafNSU/CSE331L-Section-1-Fall20-NSU
0
13279
<filename>Mid-Term/Solution/4.asm .MODEL SMALL .STACK 100H .CODE MAIN PROC MOV BX,4 MOV CX,3 L1: PUSH CX MOV AH,2 L2: INT 21H LOOP L2 MOV CX,BX MOV DL,'*' L3: INT 21H LOOP L3 MOV AH,2 MOV DL,10 INT 21H MOV DL,13 INT 21H INC BX INC BX POP CX LOOP L1 MOV AH,4CH INT 21H MAIN ENDP END MAIN
components/src/touch_panel/ft5336/ft5336.adb
rocher/Ada_Drivers_Library
192
22492
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Conversion; package body FT5336 is pragma Warnings (Off, "* is not referenced"); --------------------------------------%---------------------- -- Definitions for FT5336 I2C register addresses on 8 bit -- ------------------------------------------------------------ -- Current mode register of the FT5336 (R/W) FT5336_DEV_MODE_REG : constant UInt8 := 16#00#; -- Possible values of FT5336_DEV_MODE_REG FT5336_DEV_MODE_WORKING : constant UInt8 := 16#00#; FT5336_DEV_MODE_FACTORY : constant UInt8 := 16#04#; FT5336_DEV_MODE_MASK : constant UInt8 := 16#07#; FT5336_DEV_MODE_SHIFT : constant UInt8 := 16#04#; -- Gesture ID register FT5336_GEST_ID_REG : constant UInt8 := 16#01#; -- Possible values of FT5336_GEST_ID_REG FT5336_GEST_ID_NO_GESTURE : constant UInt8 := 16#00#; FT5336_GEST_ID_MOVE_UP : constant UInt8 := 16#10#; FT5336_GEST_ID_MOVE_RIGHT : constant UInt8 := 16#14#; FT5336_GEST_ID_MOVE_DOWN : constant UInt8 := 16#18#; FT5336_GEST_ID_MOVE_LEFT : constant UInt8 := 16#1C#; FT5336_GEST_ID_SINGLE_CLICK : constant UInt8 := 16#20#; FT5336_GEST_ID_DOUBLE_CLICK : constant UInt8 := 16#22#; FT5336_GEST_ID_ROTATE_CLOCKWISE : constant UInt8 := 16#28#; FT5336_GEST_ID_ROTATE_C_CLOCKWISE : constant UInt8 := 16#29#; FT5336_GEST_ID_ZOOM_IN : constant UInt8 := 16#40#; FT5336_GEST_ID_ZOOM_OUT : constant UInt8 := 16#49#; -- Touch Data Status register : gives number of active touch points (0..5) FT5336_TD_STAT_REG : constant UInt8 := 16#02#; -- Values related to FT5336_TD_STAT_REG FT5336_TD_STAT_MASK : constant UInt8 := 16#0F#; FT5336_TD_STAT_SHIFT : constant UInt8 := 16#00#; -- Values Pn_XH and Pn_YH related FT5336_TOUCH_EVT_FLAG_PRESS_DOWN : constant UInt8 := 16#00#; FT5336_TOUCH_EVT_FLAG_LIFT_UP : constant UInt8 := 16#01#; FT5336_TOUCH_EVT_FLAG_CONTACT : constant UInt8 := 16#02#; FT5336_TOUCH_EVT_FLAG_NO_EVENT : constant UInt8 := 16#03#; FT5336_TOUCH_EVT_FLAG_SHIFT : constant UInt8 := 16#06#; FT5336_TOUCH_EVT_FLAG_MASK : constant UInt8 := 2#1100_0000#; FT5336_TOUCH_POS_MSB_MASK : constant UInt8 := 16#0F#; FT5336_TOUCH_POS_MSB_SHIFT : constant UInt8 := 16#00#; -- Values Pn_XL and Pn_YL related FT5336_TOUCH_POS_LSB_MASK : constant UInt8 := 16#FF#; FT5336_TOUCH_POS_LSB_SHIFT : constant UInt8 := 16#00#; -- Values Pn_WEIGHT related FT5336_TOUCH_WEIGHT_MASK : constant UInt8 := 16#FF#; FT5336_TOUCH_WEIGHT_SHIFT : constant UInt8 := 16#00#; -- Values related to FT5336_Pn_MISC_REG FT5336_TOUCH_AREA_MASK : constant UInt8 := 2#0100_0000#; FT5336_TOUCH_AREA_SHIFT : constant UInt8 := 16#04#; type FT5336_Pressure_Registers is record XH_Reg : UInt8; XL_Reg : UInt8; YH_Reg : UInt8; YL_Reg : UInt8; -- Touch Pressure register value (R) Weight_Reg : UInt8; -- Touch area register Misc_Reg : UInt8; end record; FT5336_Px_Regs : constant array (Positive range <>) of FT5336_Pressure_Registers := (1 => (XH_Reg => 16#03#, XL_Reg => 16#04#, YH_Reg => 16#05#, YL_Reg => 16#06#, Weight_Reg => 16#07#, Misc_Reg => 16#08#), 2 => (XH_Reg => 16#09#, XL_Reg => 16#0A#, YH_Reg => 16#0B#, YL_Reg => 16#0C#, Weight_Reg => 16#0D#, Misc_Reg => 16#0E#), 3 => (XH_Reg => 16#0F#, XL_Reg => 16#10#, YH_Reg => 16#11#, YL_Reg => 16#12#, Weight_Reg => 16#13#, Misc_Reg => 16#14#), 4 => (XH_Reg => 16#15#, XL_Reg => 16#16#, YH_Reg => 16#17#, YL_Reg => 16#18#, Weight_Reg => 16#19#, Misc_Reg => 16#1A#), 5 => (XH_Reg => 16#1B#, XL_Reg => 16#1C#, YH_Reg => 16#1D#, YL_Reg => 16#1E#, Weight_Reg => 16#1F#, Misc_Reg => 16#20#), 6 => (XH_Reg => 16#21#, XL_Reg => 16#22#, YH_Reg => 16#23#, YL_Reg => 16#24#, Weight_Reg => 16#25#, Misc_Reg => 16#26#), 7 => (XH_Reg => 16#27#, XL_Reg => 16#28#, YH_Reg => 16#29#, YL_Reg => 16#2A#, Weight_Reg => 16#2B#, Misc_Reg => 16#2C#), 8 => (XH_Reg => 16#2D#, XL_Reg => 16#2E#, YH_Reg => 16#2F#, YL_Reg => 16#30#, Weight_Reg => 16#31#, Misc_Reg => 16#32#), 9 => (XH_Reg => 16#33#, XL_Reg => 16#34#, YH_Reg => 16#35#, YL_Reg => 16#36#, Weight_Reg => 16#37#, Misc_Reg => 16#38#), 10 => (XH_Reg => 16#39#, XL_Reg => 16#3A#, YH_Reg => 16#3B#, YL_Reg => 16#3C#, Weight_Reg => 16#3D#, Misc_Reg => 16#3E#)); -- Threshold for touch detection FT5336_TH_GROUP_REG : constant UInt8 := 16#80#; -- Values FT5336_TH_GROUP_REG : threshold related FT5336_THRESHOLD_MASK : constant UInt8 := 16#FF#; FT5336_THRESHOLD_SHIFT : constant UInt8 := 16#00#; -- Filter function coefficients FT5336_TH_DIFF_REG : constant UInt8 := 16#85#; -- Control register FT5336_CTRL_REG : constant UInt8 := 16#86#; -- Values related to FT5336_CTRL_REG -- Will keep the Active mode when there is no touching FT5336_CTRL_KEEP_ACTIVE_MODE : constant UInt8 := 16#00#; -- Switching from Active mode to Monitor mode automatically when there -- is no touching FT5336_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE : constant UInt8 := 16#01#; -- The time period of switching from Active mode to Monitor mode when -- there is no touching FT5336_TIMEENTERMONITOR_REG : constant UInt8 := 16#87#; -- Report rate in Active mode FT5336_PERIODACTIVE_REG : constant UInt8 := 16#88#; -- Report rate in Monitor mode FT5336_PERIODMONITOR_REG : constant UInt8 := 16#89#; -- The value of the minimum allowed angle while Rotating gesture mode FT5336_RADIAN_VALUE_REG : constant UInt8 := 16#91#; -- Maximum offset while Moving Left and Moving Right gesture FT5336_OFFSET_LEFT_RIGHT_REG : constant UInt8 := 16#92#; -- Maximum offset while Moving Up and Moving Down gesture FT5336_OFFSET_UP_DOWN_REG : constant UInt8 := 16#93#; -- Minimum distance while Moving Left and Moving Right gesture FT5336_DISTANCE_LEFT_RIGHT_REG : constant UInt8 := 16#94#; -- Minimum distance while Moving Up and Moving Down gesture FT5336_DISTANCE_UP_DOWN_REG : constant UInt8 := 16#95#; -- Maximum distance while Zoom In and Zoom Out gesture FT5336_DISTANCE_ZOOM_REG : constant UInt8 := 16#96#; -- High 8-bit of LIB Version info FT5336_LIB_VER_H_REG : constant UInt8 := 16#A1#; -- Low 8-bit of LIB Version info FT5336_LIB_VER_L_REG : constant UInt8 := 16#A2#; -- Chip Selecting FT5336_CIPHER_REG : constant UInt8 := 16#A3#; -- Interrupt mode register (used when in interrupt mode) FT5336_GMODE_REG : constant UInt8 := 16#A4#; FT5336_G_MODE_INTERRUPT_MASK : constant UInt8 := 16#03#; -- Possible values of FT5336_GMODE_REG FT5336_G_MODE_INTERRUPT_POLLING : constant UInt8 := 16#00#; FT5336_G_MODE_INTERRUPT_TRIGGER : constant UInt8 := 16#01#; -- Current power mode the FT5336 system is in (R) FT5336_PWR_MODE_REG : constant UInt8 := 16#A5#; -- FT5336 firmware version FT5336_FIRMID_REG : constant UInt8 := 16#A6#; -- FT5336 Chip identification register FT5336_CHIP_ID_REG : constant UInt8 := 16#A8#; -- Possible values of FT5336_CHIP_ID_REG FT5336_ID_VALUE : constant UInt8 := 16#51#; -- Release code version FT5336_RELEASE_CODE_ID_REG : constant UInt8 := 16#AF#; -- Current operating mode the FT5336 system is in (R) FT5336_STATE_REG : constant UInt8 := 16#BC#; pragma Warnings (On, "* is not referenced"); -------------- -- I2C_Read -- -------------- function I2C_Read (This : in out FT5336_Device; Reg : UInt8; Status : out Boolean) return UInt8 is Ret : I2C_Data (1 .. 1); Tmp_Status : I2C_Status; begin This.Port.Mem_Read (This.I2C_Addr, UInt16 (Reg), Memory_Size_8b, Ret, Tmp_Status, 1000); Status := Tmp_Status = Ok; return Ret (1); end I2C_Read; --------------- -- I2C_Write -- --------------- procedure I2C_Write (This : in out FT5336_Device; Reg : UInt8; Data : UInt8; Status : out Boolean) is Tmp_Status : I2C_Status; begin This.Port.Mem_Write (This.I2C_Addr, UInt16 (Reg), Memory_Size_8b, (1 => Data), Tmp_Status, 1000); Status := Tmp_Status = Ok; end I2C_Write; ------------- -- Read_Id -- ------------- function Check_Id (This : in out FT5336_Device) return Boolean is Id : UInt8; Status : Boolean; begin for J in 1 .. 3 loop Id := This.I2C_Read (FT5336_CHIP_ID_REG, Status); if Id = FT5336_ID_VALUE then return True; end if; if not Status then return False; end if; end loop; return False; end Check_Id; --------------------------- -- TP_Set_Use_Interrupts -- --------------------------- procedure TP_Set_Use_Interrupts (This : in out FT5336_Device; Enabled : Boolean) is Reg_Value : UInt8 := 0; Status : Boolean with Unreferenced; begin if Enabled then Reg_Value := FT5336_G_MODE_INTERRUPT_TRIGGER; else Reg_Value := FT5336_G_MODE_INTERRUPT_POLLING; end if; This.I2C_Write (FT5336_GMODE_REG, Reg_Value, Status); end TP_Set_Use_Interrupts; ---------------- -- Set_Bounds -- ---------------- overriding procedure Set_Bounds (This : in out FT5336_Device; Width : Natural; Height : Natural; Swap : HAL.Touch_Panel.Swap_State) is begin This.LCD_Natural_Width := Width; This.LCD_Natural_Height := Height; This.Swap := Swap; end Set_Bounds; ------------------------- -- Active_Touch_Points -- ------------------------- overriding function Active_Touch_Points (This : in out FT5336_Device) return Touch_Identifier is Status : Boolean; Nb_Touch : UInt8 := 0; begin Nb_Touch := This.I2C_Read (FT5336_TD_STAT_REG, Status); if not Status then return 0; end if; Nb_Touch := Nb_Touch and FT5336_TD_STAT_MASK; if Natural (Nb_Touch) > FT5336_Px_Regs'Last then -- Overflow: set to 0 Nb_Touch := 0; end if; return Natural (Nb_Touch); end Active_Touch_Points; --------------------- -- Get_Touch_Point -- --------------------- overriding function Get_Touch_Point (This : in out FT5336_Device; Touch_Id : Touch_Identifier) return TP_Touch_State is type UInt16_HL_Type is record High, Low : UInt8; end record with Size => 16; for UInt16_HL_Type use record High at 1 range 0 .. 7; Low at 0 range 0 .. 7; end record; function To_UInt16 is new Ada.Unchecked_Conversion (UInt16_HL_Type, UInt16); Ret : TP_Touch_State; Regs : FT5336_Pressure_Registers; Tmp : UInt16_HL_Type; Status : Boolean; begin -- X/Y are swaped from the screen coordinates if Touch_Id not in FT5336_Px_Regs'Range or else Touch_Id > This.Active_Touch_Points then return (0, 0, 0); end if; Regs := FT5336_Px_Regs (Touch_Id); Tmp.Low := This.I2C_Read (Regs.XL_Reg, Status); if not Status then return (0, 0, 0); end if; Tmp.High := This.I2C_Read (Regs.XH_Reg, Status) and FT5336_TOUCH_POS_MSB_MASK; if not Status then return (0, 0, 0); end if; Ret.Y := Natural (To_UInt16 (Tmp)); Tmp.Low := This.I2C_Read (Regs.YL_Reg, Status); if not Status then return (0, 0, 0); end if; Tmp.High := This.I2C_Read (Regs.YH_Reg, Status) and FT5336_TOUCH_POS_MSB_MASK; if not Status then return (0, 0, 0); end if; Ret.X := Natural (To_UInt16 (Tmp)); Ret.Weight := Natural (This.I2C_Read (Regs.Weight_Reg, Status)); if not Status then Ret.Weight := 0; end if; Ret.X := Natural'Min (Natural'Max (0, Ret.X), This.LCD_Natural_Width - 1); Ret.Y := Natural'Min (Natural'Max (0, Ret.Y), This.LCD_Natural_Height - 1); if (This.Swap and Invert_X) /= 0 then Ret.X := This.LCD_Natural_Width - Ret.X - 1; end if; if (This.Swap and Invert_Y) /= 0 then Ret.Y := This.LCD_Natural_Height - Ret.Y - 1; end if; if (This.Swap and Swap_XY) /= 0 then declare Tmp_X : constant Integer := Ret.X; begin Ret.X := Ret.Y; Ret.Y := Tmp_X; end; end if; return Ret; end Get_Touch_Point; -------------------------- -- Get_All_Touch_Points -- -------------------------- overriding function Get_All_Touch_Points (This : in out FT5336_Device) return HAL.Touch_Panel.TP_State is N_Touch : constant Natural := This.Active_Touch_Points; State : TP_State (1 .. N_Touch); begin if N_Touch = 0 then return (1 .. 0 => <>); end if; for J in State'Range loop State (J) := This.Get_Touch_Point (J); end loop; return State; end Get_All_Touch_Points; end FT5336;
Project/stackmachine/MVaP.g4
hanzopgp/CalcANTLR
0
2915
grammar MVaP; @header { import java.util.HashMap; } @members { /** La map pour mémoriser les addresses des étiquettes */ private HashMap<String, Integer> labels = new HashMap<String, Integer>(); /** adresse instruction */ private int instrAddress = 0; /** Récupère le dictionnaire des étiquettes */ public HashMap<String, Integer> getLabels() { return labels; } public int getProgramSize() { return instrAddress; } } // axiom program : instr+ ; // lexer WS : (' '|'\t')+ -> skip; ENTIER : ('+'|'-')? ('0'..'9')+ ; FLOAT : ('0'..'9')+ '.' ('0'..'9')* EXPONENT? | '.' ('0'..'9')+ EXPONENT? | ('0'..'9')+ EXPONENT ; fragment EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ; ADD : 'ADD'; SUB : 'SUB'; MUL : 'MUL'; DIV : 'DIV'; INF : 'INF'; INFEQ : 'INFEQ'; SUP : 'SUP'; SUPEQ : 'SUPEQ'; EQUAL : 'EQUAL'; NEQ : 'NEQ'; FADD : 'FADD'; FSUB : 'FSUB'; FMUL : 'FMUL'; FDIV : 'FDIV'; FINF : 'FINF'; FINFEQ : 'FINFEQ'; FSUP : 'FSUP'; FSUPEQ : 'FSUPEQ'; FEQUAL : 'FEQUAL'; FNEQ : 'FNEQ'; ITOF : 'ITOF'; FTOI : 'FTOI'; RETURN: 'RETURN'; POP : 'POP'; POPF : 'POPF'; READ : 'READ'; READF : 'READF'; WRITE : 'WRITE'; WRITEF : 'WRITEF'; PADD : 'PADD'; PUSHGP : 'PUSHGP'; PUSHFP : 'PUSHFP'; DUP : 'DUP'; PUSHI : 'PUSHI'; PUSHG : 'PUSHG'; STOREG : 'STOREG'; PUSHL : 'PUSHL'; STOREL : 'STOREL'; PUSHR : 'PUSHR'; STORER : 'STORER'; FREE : 'FREE'; ALLOC : 'ALLOC'; PUSHF : 'PUSHF'; CALL : 'CALL'; JUMP : 'JUMP '; JUMPF : 'JUMPF'; JUMPI : 'JUMPI'; HALT : 'HALT'; LABEL : 'LABEL'; IDENTIFIANT : ('a'..'z' | 'A'..'Z' | '_')('a'..'z' | 'A'..'Z' | '_' | '0'..'9')*; NEWLINE : ('#' ~('\n'|'\r')*)? '\r'? '\n' ; // and Comment // parser instr : instr1 NEWLINE | instr2 NEWLINE | instr2f NEWLINE | label NEWLINE | saut NEWLINE | NEWLINE ; commande1 : ADD | SUB | MUL | DIV | INF | INFEQ | SUP | SUPEQ | EQUAL | NEQ | FADD | FSUB | FMUL | FDIV | FINF | FINFEQ | FSUP | FSUPEQ | FEQUAL | FNEQ | ITOF | FTOI | RETURN | POP | POPF | READ | READF | WRITE | WRITEF | PADD | PUSHGP | PUSHFP | DUP | HALT; instr1 : c=commande1 { instrAddress++; } ; commande2 : PUSHI | PUSHG | STOREG | PUSHL | STOREL | PUSHR | STORER | FREE | ALLOC; instr2 : commande2 ENTIER { instrAddress+=2; /* 2 entiers pour stocker l'instruction */ } ; instr2f : PUSHF FLOAT { instrAddress+=3; /* 1 entier pour le code op et 2 pour le flottant */ } ; commandeSaut : JUMP | JUMPF | JUMPI | CALL; saut : commandeSaut IDENTIFIANT { instrAddress+=2; /* 2 entiers pour stocker l'instruction */ } ; label : LABEL IDENTIFIANT { labels.put($IDENTIFIANT.text, instrAddress); } ;
tests/simpleOO/src/dds-request_reply-tests-simple-driver.adb
persan/dds-requestreply
0
5572
------------------------------------------------------------------------------- -- -- This file is only for conviniece to be able to build and run with -- one click -- ------------------------------------------------------------------------------- with GNAT.OS_Lib; with Ada.Text_IO; use Ada.Text_IO; procedure DDS.Request_Reply.Tests.Simple.Driver is Args : GNAT.OS_Lib.Argument_List (1 .. 0); procedure Non_Blocking_Spawn (Name : Standard.String) is Full_Name : constant Standard.String := "bin/dds-request_reply-tests-simple-" & Name; Pid : GNAT.OS_Lib.Process_Id; begin Put ("Spawning:" & Full_Name); Pid := GNAT.OS_Lib.Non_Blocking_Spawn (Full_Name, Args); Put_Line (" | Pid ->" & GNAT.OS_Lib.Pid_To_Integer (Pid)'Img); delay 0.4; end; Gprbuild : constant GNAT.OS_Lib.String_Access := GNAT.OS_Lib.Locate_Exec_On_Path ("gprbuild"); begin if GNAT.OS_Lib.Spawn (Gprbuild.all, Args) = 0 then -- Dont try to run if the build fails Non_Blocking_Spawn ("replier_main"); Non_Blocking_Spawn ("requester_main"); end if; end;
programs/oeis/010/A010711.asm
neoneye/loda
22
25676
<filename>programs/oeis/010/A010711.asm ; A010711: Period 2: repeat (4,6). ; 4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4,6,4 mul $0,2 mod $0,4 add $0,4
models/mondex/b.als
transclosure/Amalgam
4
3581
<filename>models/mondex/b.als module mondex/b open mondex/cw as mondexCW open mondex/c as mondexC open mondex/common as mondexCOMMON fun allLogs (c : ConWorld) : ConPurse -> PayDetails { c.archive + (c.conAuthPurse <: exLog.c) } fun authenticFrom (c : ConWorld) : set TransferDetails { from.(c.conAuthPurse) } fun authenticTo (c : ConWorld) : set TransferDetails { to.(c.conAuthPurse) } fun fromLogged (c : ConWorld) : set PayDetails { authenticFrom [c] & ConPurse.(allLogs [c] & ~from) } fun toLogged (c : ConWorld) : set PayDetails { authenticTo [c] & ConPurse.(allLogs [c] & ~to) } fun toInEpv (c : ConWorld) : set TransferDetails { authenticTo [c] & to.status.c.epv & (iden & to.(pdAuth.c)).PayDetails } fun fromInEpr (c : ConWorld) : set TransferDetails { authenticFrom [c] & from.status.c.epr & (iden & from.(pdAuth.c)).PayDetails } fun fromInEpa (c : ConWorld) : set TransferDetails { authenticFrom [c] & from.status.c.epa & (iden & from.(pdAuth.c)).PayDetails } fun definitelyLost (c : ConWorld) : set PayDetails { toLogged [c] & (fromLogged [c] + fromInEpa [c]) } fun maybeLost (c : ConWorld) : set TransferDetails { (fromInEpa [c] + fromLogged [c]) & toInEpv [c] } assert auxworld_identity { all c : ConWorld | Concrete [c] implies definitelyLost [c] + maybeLost [c] = (fromInEpa [c] + fromLogged [c]) & (toInEpv [c] + toLogged [c]) } check auxworld_identity for 6 pred Between1 (c : ConWorld) { (c.ether & req).details in authenticTo [c] } pred Between2 (c : ConWorld) { all r : req | r in c.ether implies Lt [r.details.toSeqNo, r.details.to.nextSeqNo.c] } pred Between3 (c : ConWorld) { all v : val | v in c.ether implies { Lt [v.details.toSeqNo, v.details.to.nextSeqNo.c] Lt [v.details.fromSeqNo, v.details.from.nextSeqNo.c] } } pred Between4 (c : ConWorld) { all v : ack | v in c.ether implies { Lt [v.details.toSeqNo, v.details.to.nextSeqNo.c] Lt [v.details.fromSeqNo, v.details.from.nextSeqNo.c] } } pred Between5 (c : ConWorld) { all p : PayDetails | p in fromLogged [c] implies Lt [p.fromSeqNo, p.from.nextSeqNo.c] } pred Between6 (c : ConWorld) { all p : PayDetails | p in toLogged [c] implies Lt [p.toSeqNo, p.to.nextSeqNo.c] } pred Between7 (c : ConWorld) { all p : PayDetails | { p in fromLogged [c] p.from.status.c in epr + epa } implies Lt [p.fromSeqNo, p.from.pdAuth.c.fromSeqNo] } pred Between8 (c : ConWorld) { all p : PayDetails | { p in toLogged [c] p.to.status.c in epv } implies Lt [p.toSeqNo, p.to.pdAuth.c.toSeqNo] } pred Between9 (c : ConWorld) { no c.ether.(val <: details + ack <: details) & fromInEpr [c] } pred Between10 (c : ConWorld) { -- all p : PayDetails | { -- some c.ether & (req <: details.p) -- no c.ether & (ack <: details.p) -- } iff -- p in toInEpv [c] + toLogged [c] toInEpv [c] + toLogged [c] = c.ether.(req <: details) - c.ether.(ack <: details) } pred Between11 (c : ConWorld) { c.ether.(val <: details) & toInEpv [c] in fromInEpa [c] + fromLogged [c] } pred Between12 (c : ConWorld) { fromInEpa [c] + fromLogged [c] in c.ether.(req <: details) } pred Between13 (c : ConWorld) { -- IGNORED : toLogged finite } pred Between14 (c : ConWorld) { ~((c.ether & exceptionLogResult) <: name).details in allLogs [c] } pred Between15 (c : ConWorld) { ~((c.ether & exceptionLogClear) <: name).pds in c.archive } pred Between16 (c : ConWorld) { fromLogged [c] + toLogged [c] in c.ether.(req <: details) } pred Between_MISSING (c : ConWorld) { -- authenticity of pdAuth hold by an epv purse ((c.conAuthPurse & status.c.epv) <: pdAuth.c.to) + ((c.conAuthPurse & status.c.epa) <: pdAuth.c.from) in iden -- authenticity of val and ack messages c.ether.(val <: details + ack <: details).(from + to) in c.conAuthPurse -- bottom in ether (needed to consider compositions for operations that first abort) bottom in c.ether } -- Contrary to multiplicity issues, which are part of the original specification and added as predicates -- rather than enforced in the ConWorld definition, Coin sharing issues are due to the choice of the -- representation of the amounts, which is a data issue, hence consisting in a change from the original -- spec which used to use integers. pred Between_Coin (s : ConWorld) { -- coin sharing -- Purses cannot log money still in their balances -- i.e. a balance coin cannot be logged lost -- either in the local (exLog) or global (archive) lost journal -- Those constraints appear to be too strong -- no s.conAuthPurse.(exLog.s.value & balance.s) -- no s.conAuthPurse.balance.s & s.conAuthPurse.(s.archive).value -- Yes, but I have something to express that. no s.conAuthPurse.balance.s & (definitelyLost[s] + maybeLost[s]).value -- Purses have their own balances -- i.e. a coin cannot be owned by different purse balances s.conAuthPurse <: balance.s in ConPurse lone -> Coin -- A purse in epv cannot receive its own money -- i.e. a coin cannot be received twice into balance no (s.conAuthPurse & status.s.epv).(pdAuth.s.value & balance.s) -- The values of transfers maybe lost are disjoint -- i.e. a coin cannot be lost twice (maybeLost [s] + definitelyLost [s]) <: value in PayDetails lone -> Coin } -- Here are the original constraints (proper to the Between world, additional to the Concrete) pred Between0 (c : ConWorld) { Between1 [c] Between2 [c] Between3 [c] Between4 [c] Between5 [c] Between6 [c] Between7 [c] Between8 [c] Between9 [c] Between10 [c] Between11 [c] Between12 [c] Between13 [c] Between14 [c] Between15 [c] Between16 [c] } -- They are summed up with added constraints : -- missing ones (lack in the Z spec) -- coin sharing (added due to spec change) -- BUT NOT multiplicity (language issue) pred Between (c : ConWorld) { Concrete [c] Between0 [c] Between_MISSING [c] Between_Coin [c] }
examples/BUG-THINGOUTOFCXT.agda
andreasabel/miniagda
85
1215
module Acc where data Acc ( A : Set ) ( Lt : A -> A -> Set) : A -> Set where acc : ( b : A ) -> ( ( a : A ) -> Lt a b -> Acc A Lt a ) -> ( Acc A Lt b ) data Nat : Set where zero : Nat succ : Nat -> Nat data Lt : Nat -> Nat -> Set where ltzero : ( x : Nat ) -> Lt zero (succ x) ltsucc : ( x : Nat ) -> (y : Nat) -> Lt x y -> Lt (succ x) (succ y) ltcase : ( x : Nat ) -> ( y : Nat ) -> Lt x (succ y) -> ( P : Nat -> Set ) -> ( (x' : Nat ) -> Lt x' y -> P x') -> P y -> P x ltcase zero zero _ P hx' hy = hy ltcase zero (succ y') _ P hx' hy = hx' zero (ltzero y') ltcase (succ x') zero (ltsucc .x' .zero ()) _ _ _ ltcase (succ x') (succ y') (ltsucc ._ ._ p) P hx' hy = ltcase x' y' p (\ n -> P (succ n)) (\ x'' p' -> hx' (succ x'') (ltsucc _ _ p')) hy accSucc : (x : Nat) -> Acc Nat Lt x -> Acc Nat Lt (succ x) accSucc x a@(acc .x h) = acc (succ x) (\ y p -> ltcase y x p (Acc Nat Lt) h a)
examples/src/psenvpub.adb
sonneveld/adazmq
0
17634
-- Pubsub envelope publisher with Ada.Command_Line; with Ada.Text_IO; with GNAT.Formatted_String; with ZMQ; use type GNAT.Formatted_String.Formatted_String; procedure PSEnvPub is function Main return Ada.Command_Line.Exit_Status is -- Prepare our context and publisher Context : ZMQ.Context_Type := ZMQ.New_Context; Publisher : ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_PUB); begin Publisher.Bind ("tcp://*:5563"); loop -- Write two messages, each with an envelope and content Publisher.Send ("A", Send_More => True); Publisher.Send ("We don't want to see this"); Publisher.Send ("B", Send_More => True); Publisher.Send ("We would like to see this"); delay 1.0; end loop; -- We never get here, but clean up anyhow Publisher.Close; Context.Term; return 0; end Main; begin Ada.Command_Line.Set_Exit_Status (Main); end PSEnvPub;
Transynther/x86/_processed/AVXALIGN/_st_/i7-7700_9_0x48.log_21829_805.asm
ljhsiun2/medusa
9
168990
<reponame>ljhsiun2/medusa<filename>Transynther/x86/_processed/AVXALIGN/_st_/i7-7700_9_0x48.log_21829_805.asm .global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r15 push %r8 push %rcx push %rdi push %rsi lea addresses_A_ht+0x1d7d2, %rdi nop dec %r10 mov $0x6162636465666768, %rsi movq %rsi, %xmm0 movups %xmm0, (%rdi) nop nop nop xor %r14, %r14 lea addresses_normal_ht+0xdf16, %rsi lea addresses_UC_ht+0x2416, %rdi nop nop nop nop add $48965, %r15 mov $82, %rcx rep movsw nop nop nop and $57216, %rdi lea addresses_WT_ht+0x59f6, %r10 nop nop nop cmp $40637, %r8 movups (%r10), %xmm5 vpextrq $0, %xmm5, %r15 nop nop nop nop xor %r15, %r15 lea addresses_A_ht+0x19096, %rdi nop nop nop nop and $8077, %rsi movb $0x61, (%rdi) nop sub %rsi, %rsi lea addresses_WT_ht+0xb416, %r10 nop nop nop add %r8, %r8 movups (%r10), %xmm0 vpextrq $0, %xmm0, %rcx nop nop cmp %rcx, %rcx lea addresses_normal_ht+0x9f16, %r8 nop nop nop add $18124, %rsi movb (%r8), %r15b nop nop nop nop cmp %rsi, %rsi lea addresses_normal_ht+0x14b06, %rcx clflush (%rcx) nop nop xor $34671, %r10 movb $0x61, (%rcx) nop nop and $54803, %r14 lea addresses_UC_ht+0x87f6, %rcx clflush (%rcx) nop nop nop add $19531, %r14 movb (%rcx), %r10b nop nop sub %rcx, %rcx pop %rsi pop %rdi pop %rcx pop %r8 pop %r15 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r9 push %rbp push %rdx push %rsi // Faulty Load lea addresses_RW+0x15c16, %rdx nop nop nop inc %r9 mov (%rdx), %bp lea oracles, %rdx and $0xff, %rbp shlq $12, %rbp mov (%rdx,%rbp,1), %rbp pop %rsi pop %rdx pop %rbp pop %r9 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': True, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 1, 'size': 16, 'same': True, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 4, 'size': 16, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 2, 'size': 1, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 11, 'size': 16, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 7, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 4, 'size': 1, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 5, 'size': 1, 'same': True, 'NT': True}} {'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 */
oeis/106/A106515.asm
neoneye/loda-programs
11
243616
<gh_stars>10-100 ; A106515: A Fibonacci-Pell convolution. ; Submitted by <NAME> ; 1,2,6,15,38,94,231,564,1372,3329,8064,19512,47177,114010,275430,665247,1606534,3879302,9366735,22615356,54601628,131825377,318263328,768369744,1855031473,4478479058,10812064614,26102729679,63017720390,152138488270,367295211159,886729742628,2140756042684,5168244006305,12477247579872,30122744868936,72722746545209,175568252889706,423859276482438,1023286844942751,2470433029613926,5964153006504758,14398739208203583,34761631690826220,83922003023350460,202605638438935873,489133281036125376 mov $5,1 lpb $0 sub $0,1 mov $2,$1 add $1,$3 add $1,1 sub $4,2 sub $3,$4 add $3,$5 mov $4,$2 mov $2,$3 add $5,$4 mov $3,$5 add $4,$1 add $5,$2 lpe add $3,1 mov $0,$3
programs/oeis/157/A157652.asm
neoneye/loda
22
23069
; A157652: a(n) = 40*(200*n - 49). ; 6040,14040,22040,30040,38040,46040,54040,62040,70040,78040,86040,94040,102040,110040,118040,126040,134040,142040,150040,158040,166040,174040,182040,190040,198040,206040,214040,222040,230040,238040,246040,254040,262040,270040,278040,286040,294040,302040,310040,318040,326040,334040,342040,350040,358040,366040,374040,382040,390040,398040,406040,414040,422040,430040,438040,446040,454040,462040,470040,478040,486040,494040,502040,510040,518040,526040,534040,542040,550040,558040,566040,574040,582040,590040,598040,606040,614040,622040,630040,638040,646040,654040,662040,670040,678040,686040,694040,702040,710040,718040,726040,734040,742040,750040,758040,766040,774040,782040,790040,798040 mul $0,8000 add $0,6040
programs/oeis/286/A286584.asm
neoneye/loda
22
100012
; A286584: a(n) = A048673(n) mod 4. ; 1,2,3,1,0,0,2,2,1,3,3,3,1,1,2,1,2,2,0,0,0,0,3,0,1,2,3,2,0,1,3,2,1,1,3,1,1,3,3,3,2,3,0,3,0,0,3,3,1,2,0,1,2,0,2,1,2,3,3,2,2,0,2,1,0,2,0,2,1,0,1,2,0,2,3,0,0,0,2,0,1,1,1,0,3,3,2,0,1,3,2,3,1,0,1,0,3,2,3,1 seq $0,3961 ; Completely multiplicative with a(prime(k)) = prime(k+1). add $0,1 mod $0,8 div $0,2
zombie.asm
Ankitchan/xv6OS
0
96051
<gh_stars>0 _zombie: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(void) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 51 push %ecx e: 83 ec 04 sub $0x4,%esp if(fork() > 0) 11: e8 65 02 00 00 call 27b <fork> 16: 85 c0 test %eax,%eax 18: 7e 0d jle 27 <main+0x27> sleep(5); // Let child exit before parent. 1a: 83 ec 0c sub $0xc,%esp 1d: 6a 05 push $0x5 1f: e8 ef 02 00 00 call 313 <sleep> 24: 83 c4 10 add $0x10,%esp exit(); 27: e8 57 02 00 00 call 283 <exit> 0000002c <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 2c: 55 push %ebp 2d: 89 e5 mov %esp,%ebp 2f: 57 push %edi 30: 53 push %ebx asm volatile("cld; rep stosb" : 31: 8b 4d 08 mov 0x8(%ebp),%ecx 34: 8b 55 10 mov 0x10(%ebp),%edx 37: 8b 45 0c mov 0xc(%ebp),%eax 3a: 89 cb mov %ecx,%ebx 3c: 89 df mov %ebx,%edi 3e: 89 d1 mov %edx,%ecx 40: fc cld 41: f3 aa rep stos %al,%es:(%edi) 43: 89 ca mov %ecx,%edx 45: 89 fb mov %edi,%ebx 47: 89 5d 08 mov %ebx,0x8(%ebp) 4a: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 4d: 90 nop 4e: 5b pop %ebx 4f: 5f pop %edi 50: 5d pop %ebp 51: c3 ret 00000052 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 52: 55 push %ebp 53: 89 e5 mov %esp,%ebp 55: 83 ec 10 sub $0x10,%esp char *os; os = s; 58: 8b 45 08 mov 0x8(%ebp),%eax 5b: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 5e: 90 nop 5f: 8b 45 08 mov 0x8(%ebp),%eax 62: 8d 50 01 lea 0x1(%eax),%edx 65: 89 55 08 mov %edx,0x8(%ebp) 68: 8b 55 0c mov 0xc(%ebp),%edx 6b: 8d 4a 01 lea 0x1(%edx),%ecx 6e: 89 4d 0c mov %ecx,0xc(%ebp) 71: 0f b6 12 movzbl (%edx),%edx 74: 88 10 mov %dl,(%eax) 76: 0f b6 00 movzbl (%eax),%eax 79: 84 c0 test %al,%al 7b: 75 e2 jne 5f <strcpy+0xd> ; return os; 7d: 8b 45 fc mov -0x4(%ebp),%eax } 80: c9 leave 81: c3 ret 00000082 <strcmp>: int strcmp(const char *p, const char *q) { 82: 55 push %ebp 83: 89 e5 mov %esp,%ebp while(*p && *p == *q) 85: eb 08 jmp 8f <strcmp+0xd> p++, q++; 87: 83 45 08 01 addl $0x1,0x8(%ebp) 8b: 83 45 0c 01 addl $0x1,0xc(%ebp) while(*p && *p == *q) 8f: 8b 45 08 mov 0x8(%ebp),%eax 92: 0f b6 00 movzbl (%eax),%eax 95: 84 c0 test %al,%al 97: 74 10 je a9 <strcmp+0x27> 99: 8b 45 08 mov 0x8(%ebp),%eax 9c: 0f b6 10 movzbl (%eax),%edx 9f: 8b 45 0c mov 0xc(%ebp),%eax a2: 0f b6 00 movzbl (%eax),%eax a5: 38 c2 cmp %al,%dl a7: 74 de je 87 <strcmp+0x5> return (uchar)*p - (uchar)*q; a9: 8b 45 08 mov 0x8(%ebp),%eax ac: 0f b6 00 movzbl (%eax),%eax af: 0f b6 d0 movzbl %al,%edx b2: 8b 45 0c mov 0xc(%ebp),%eax b5: 0f b6 00 movzbl (%eax),%eax b8: 0f b6 c0 movzbl %al,%eax bb: 29 c2 sub %eax,%edx bd: 89 d0 mov %edx,%eax } bf: 5d pop %ebp c0: c3 ret 000000c1 <strlen>: uint strlen(char *s) { c1: 55 push %ebp c2: 89 e5 mov %esp,%ebp c4: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) c7: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) ce: eb 04 jmp d4 <strlen+0x13> d0: 83 45 fc 01 addl $0x1,-0x4(%ebp) d4: 8b 55 fc mov -0x4(%ebp),%edx d7: 8b 45 08 mov 0x8(%ebp),%eax da: 01 d0 add %edx,%eax dc: 0f b6 00 movzbl (%eax),%eax df: 84 c0 test %al,%al e1: 75 ed jne d0 <strlen+0xf> ; return n; e3: 8b 45 fc mov -0x4(%ebp),%eax } e6: c9 leave e7: c3 ret 000000e8 <memset>: void* memset(void *dst, int c, uint n) { e8: 55 push %ebp e9: 89 e5 mov %esp,%ebp stosb(dst, c, n); eb: 8b 45 10 mov 0x10(%ebp),%eax ee: 50 push %eax ef: ff 75 0c pushl 0xc(%ebp) f2: ff 75 08 pushl 0x8(%ebp) f5: e8 32 ff ff ff call 2c <stosb> fa: 83 c4 0c add $0xc,%esp return dst; fd: 8b 45 08 mov 0x8(%ebp),%eax } 100: c9 leave 101: c3 ret 00000102 <strchr>: char* strchr(const char *s, char c) { 102: 55 push %ebp 103: 89 e5 mov %esp,%ebp 105: 83 ec 04 sub $0x4,%esp 108: 8b 45 0c mov 0xc(%ebp),%eax 10b: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 10e: eb 14 jmp 124 <strchr+0x22> if(*s == c) 110: 8b 45 08 mov 0x8(%ebp),%eax 113: 0f b6 00 movzbl (%eax),%eax 116: 3a 45 fc cmp -0x4(%ebp),%al 119: 75 05 jne 120 <strchr+0x1e> return (char*)s; 11b: 8b 45 08 mov 0x8(%ebp),%eax 11e: eb 13 jmp 133 <strchr+0x31> for(; *s; s++) 120: 83 45 08 01 addl $0x1,0x8(%ebp) 124: 8b 45 08 mov 0x8(%ebp),%eax 127: 0f b6 00 movzbl (%eax),%eax 12a: 84 c0 test %al,%al 12c: 75 e2 jne 110 <strchr+0xe> return 0; 12e: b8 00 00 00 00 mov $0x0,%eax } 133: c9 leave 134: c3 ret 00000135 <gets>: char* gets(char *buf, int max) { 135: 55 push %ebp 136: 89 e5 mov %esp,%ebp 138: 83 ec 18 sub $0x18,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 13b: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 142: eb 42 jmp 186 <gets+0x51> cc = read(0, &c, 1); 144: 83 ec 04 sub $0x4,%esp 147: 6a 01 push $0x1 149: 8d 45 ef lea -0x11(%ebp),%eax 14c: 50 push %eax 14d: 6a 00 push $0x0 14f: e8 47 01 00 00 call 29b <read> 154: 83 c4 10 add $0x10,%esp 157: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 15a: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 15e: 7e 33 jle 193 <gets+0x5e> break; buf[i++] = c; 160: 8b 45 f4 mov -0xc(%ebp),%eax 163: 8d 50 01 lea 0x1(%eax),%edx 166: 89 55 f4 mov %edx,-0xc(%ebp) 169: 89 c2 mov %eax,%edx 16b: 8b 45 08 mov 0x8(%ebp),%eax 16e: 01 c2 add %eax,%edx 170: 0f b6 45 ef movzbl -0x11(%ebp),%eax 174: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 176: 0f b6 45 ef movzbl -0x11(%ebp),%eax 17a: 3c 0a cmp $0xa,%al 17c: 74 16 je 194 <gets+0x5f> 17e: 0f b6 45 ef movzbl -0x11(%ebp),%eax 182: 3c 0d cmp $0xd,%al 184: 74 0e je 194 <gets+0x5f> for(i=0; i+1 < max; ){ 186: 8b 45 f4 mov -0xc(%ebp),%eax 189: 83 c0 01 add $0x1,%eax 18c: 3b 45 0c cmp 0xc(%ebp),%eax 18f: 7c b3 jl 144 <gets+0xf> 191: eb 01 jmp 194 <gets+0x5f> break; 193: 90 nop break; } buf[i] = '\0'; 194: 8b 55 f4 mov -0xc(%ebp),%edx 197: 8b 45 08 mov 0x8(%ebp),%eax 19a: 01 d0 add %edx,%eax 19c: c6 00 00 movb $0x0,(%eax) return buf; 19f: 8b 45 08 mov 0x8(%ebp),%eax } 1a2: c9 leave 1a3: c3 ret 000001a4 <stat>: int stat(char *n, struct stat *st) { 1a4: 55 push %ebp 1a5: 89 e5 mov %esp,%ebp 1a7: 83 ec 18 sub $0x18,%esp int fd; int r; fd = open(n, O_RDONLY); 1aa: 83 ec 08 sub $0x8,%esp 1ad: 6a 00 push $0x0 1af: ff 75 08 pushl 0x8(%ebp) 1b2: e8 0c 01 00 00 call 2c3 <open> 1b7: 83 c4 10 add $0x10,%esp 1ba: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 1bd: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1c1: 79 07 jns 1ca <stat+0x26> return -1; 1c3: b8 ff ff ff ff mov $0xffffffff,%eax 1c8: eb 25 jmp 1ef <stat+0x4b> r = fstat(fd, st); 1ca: 83 ec 08 sub $0x8,%esp 1cd: ff 75 0c pushl 0xc(%ebp) 1d0: ff 75 f4 pushl -0xc(%ebp) 1d3: e8 03 01 00 00 call 2db <fstat> 1d8: 83 c4 10 add $0x10,%esp 1db: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 1de: 83 ec 0c sub $0xc,%esp 1e1: ff 75 f4 pushl -0xc(%ebp) 1e4: e8 c2 00 00 00 call 2ab <close> 1e9: 83 c4 10 add $0x10,%esp return r; 1ec: 8b 45 f0 mov -0x10(%ebp),%eax } 1ef: c9 leave 1f0: c3 ret 000001f1 <atoi>: int atoi(const char *s) { 1f1: 55 push %ebp 1f2: 89 e5 mov %esp,%ebp 1f4: 83 ec 10 sub $0x10,%esp int n; n = 0; 1f7: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 1fe: eb 25 jmp 225 <atoi+0x34> n = n*10 + *s++ - '0'; 200: 8b 55 fc mov -0x4(%ebp),%edx 203: 89 d0 mov %edx,%eax 205: c1 e0 02 shl $0x2,%eax 208: 01 d0 add %edx,%eax 20a: 01 c0 add %eax,%eax 20c: 89 c1 mov %eax,%ecx 20e: 8b 45 08 mov 0x8(%ebp),%eax 211: 8d 50 01 lea 0x1(%eax),%edx 214: 89 55 08 mov %edx,0x8(%ebp) 217: 0f b6 00 movzbl (%eax),%eax 21a: 0f be c0 movsbl %al,%eax 21d: 01 c8 add %ecx,%eax 21f: 83 e8 30 sub $0x30,%eax 222: 89 45 fc mov %eax,-0x4(%ebp) while('0' <= *s && *s <= '9') 225: 8b 45 08 mov 0x8(%ebp),%eax 228: 0f b6 00 movzbl (%eax),%eax 22b: 3c 2f cmp $0x2f,%al 22d: 7e 0a jle 239 <atoi+0x48> 22f: 8b 45 08 mov 0x8(%ebp),%eax 232: 0f b6 00 movzbl (%eax),%eax 235: 3c 39 cmp $0x39,%al 237: 7e c7 jle 200 <atoi+0xf> return n; 239: 8b 45 fc mov -0x4(%ebp),%eax } 23c: c9 leave 23d: c3 ret 0000023e <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 23e: 55 push %ebp 23f: 89 e5 mov %esp,%ebp 241: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 244: 8b 45 08 mov 0x8(%ebp),%eax 247: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 24a: 8b 45 0c mov 0xc(%ebp),%eax 24d: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 250: eb 17 jmp 269 <memmove+0x2b> *dst++ = *src++; 252: 8b 45 fc mov -0x4(%ebp),%eax 255: 8d 50 01 lea 0x1(%eax),%edx 258: 89 55 fc mov %edx,-0x4(%ebp) 25b: 8b 55 f8 mov -0x8(%ebp),%edx 25e: 8d 4a 01 lea 0x1(%edx),%ecx 261: 89 4d f8 mov %ecx,-0x8(%ebp) 264: 0f b6 12 movzbl (%edx),%edx 267: 88 10 mov %dl,(%eax) while(n-- > 0) 269: 8b 45 10 mov 0x10(%ebp),%eax 26c: 8d 50 ff lea -0x1(%eax),%edx 26f: 89 55 10 mov %edx,0x10(%ebp) 272: 85 c0 test %eax,%eax 274: 7f dc jg 252 <memmove+0x14> return vdst; 276: 8b 45 08 mov 0x8(%ebp),%eax } 279: c9 leave 27a: c3 ret 0000027b <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 27b: b8 01 00 00 00 mov $0x1,%eax 280: cd 40 int $0x40 282: c3 ret 00000283 <exit>: SYSCALL(exit) 283: b8 02 00 00 00 mov $0x2,%eax 288: cd 40 int $0x40 28a: c3 ret 0000028b <wait>: SYSCALL(wait) 28b: b8 03 00 00 00 mov $0x3,%eax 290: cd 40 int $0x40 292: c3 ret 00000293 <pipe>: SYSCALL(pipe) 293: b8 04 00 00 00 mov $0x4,%eax 298: cd 40 int $0x40 29a: c3 ret 0000029b <read>: SYSCALL(read) 29b: b8 05 00 00 00 mov $0x5,%eax 2a0: cd 40 int $0x40 2a2: c3 ret 000002a3 <write>: SYSCALL(write) 2a3: b8 10 00 00 00 mov $0x10,%eax 2a8: cd 40 int $0x40 2aa: c3 ret 000002ab <close>: SYSCALL(close) 2ab: b8 15 00 00 00 mov $0x15,%eax 2b0: cd 40 int $0x40 2b2: c3 ret 000002b3 <kill>: SYSCALL(kill) 2b3: b8 06 00 00 00 mov $0x6,%eax 2b8: cd 40 int $0x40 2ba: c3 ret 000002bb <exec>: SYSCALL(exec) 2bb: b8 07 00 00 00 mov $0x7,%eax 2c0: cd 40 int $0x40 2c2: c3 ret 000002c3 <open>: SYSCALL(open) 2c3: b8 0f 00 00 00 mov $0xf,%eax 2c8: cd 40 int $0x40 2ca: c3 ret 000002cb <mknod>: SYSCALL(mknod) 2cb: b8 11 00 00 00 mov $0x11,%eax 2d0: cd 40 int $0x40 2d2: c3 ret 000002d3 <unlink>: SYSCALL(unlink) 2d3: b8 12 00 00 00 mov $0x12,%eax 2d8: cd 40 int $0x40 2da: c3 ret 000002db <fstat>: SYSCALL(fstat) 2db: b8 08 00 00 00 mov $0x8,%eax 2e0: cd 40 int $0x40 2e2: c3 ret 000002e3 <link>: SYSCALL(link) 2e3: b8 13 00 00 00 mov $0x13,%eax 2e8: cd 40 int $0x40 2ea: c3 ret 000002eb <mkdir>: SYSCALL(mkdir) 2eb: b8 14 00 00 00 mov $0x14,%eax 2f0: cd 40 int $0x40 2f2: c3 ret 000002f3 <chdir>: SYSCALL(chdir) 2f3: b8 09 00 00 00 mov $0x9,%eax 2f8: cd 40 int $0x40 2fa: c3 ret 000002fb <dup>: SYSCALL(dup) 2fb: b8 0a 00 00 00 mov $0xa,%eax 300: cd 40 int $0x40 302: c3 ret 00000303 <getpid>: SYSCALL(getpid) 303: b8 0b 00 00 00 mov $0xb,%eax 308: cd 40 int $0x40 30a: c3 ret 0000030b <sbrk>: SYSCALL(sbrk) 30b: b8 0c 00 00 00 mov $0xc,%eax 310: cd 40 int $0x40 312: c3 ret 00000313 <sleep>: SYSCALL(sleep) 313: b8 0d 00 00 00 mov $0xd,%eax 318: cd 40 int $0x40 31a: c3 ret 0000031b <uptime>: SYSCALL(uptime) 31b: b8 0e 00 00 00 mov $0xe,%eax 320: cd 40 int $0x40 322: c3 ret 00000323 <gettime>: SYSCALL(gettime) 323: b8 16 00 00 00 mov $0x16,%eax 328: cd 40 int $0x40 32a: c3 ret 0000032b <settickets>: SYSCALL(settickets) 32b: b8 17 00 00 00 mov $0x17,%eax 330: cd 40 int $0x40 332: c3 ret 00000333 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 333: 55 push %ebp 334: 89 e5 mov %esp,%ebp 336: 83 ec 18 sub $0x18,%esp 339: 8b 45 0c mov 0xc(%ebp),%eax 33c: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 33f: 83 ec 04 sub $0x4,%esp 342: 6a 01 push $0x1 344: 8d 45 f4 lea -0xc(%ebp),%eax 347: 50 push %eax 348: ff 75 08 pushl 0x8(%ebp) 34b: e8 53 ff ff ff call 2a3 <write> 350: 83 c4 10 add $0x10,%esp } 353: 90 nop 354: c9 leave 355: c3 ret 00000356 <printint>: static void printint(int fd, int xx, int base, int sgn) { 356: 55 push %ebp 357: 89 e5 mov %esp,%ebp 359: 53 push %ebx 35a: 83 ec 24 sub $0x24,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 35d: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 364: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 368: 74 17 je 381 <printint+0x2b> 36a: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 36e: 79 11 jns 381 <printint+0x2b> neg = 1; 370: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 377: 8b 45 0c mov 0xc(%ebp),%eax 37a: f7 d8 neg %eax 37c: 89 45 ec mov %eax,-0x14(%ebp) 37f: eb 06 jmp 387 <printint+0x31> } else { x = xx; 381: 8b 45 0c mov 0xc(%ebp),%eax 384: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 387: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 38e: 8b 4d f4 mov -0xc(%ebp),%ecx 391: 8d 41 01 lea 0x1(%ecx),%eax 394: 89 45 f4 mov %eax,-0xc(%ebp) 397: 8b 5d 10 mov 0x10(%ebp),%ebx 39a: 8b 45 ec mov -0x14(%ebp),%eax 39d: ba 00 00 00 00 mov $0x0,%edx 3a2: f7 f3 div %ebx 3a4: 89 d0 mov %edx,%eax 3a6: 0f b6 80 b4 0a 00 00 movzbl 0xab4(%eax),%eax 3ad: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 3b1: 8b 5d 10 mov 0x10(%ebp),%ebx 3b4: 8b 45 ec mov -0x14(%ebp),%eax 3b7: ba 00 00 00 00 mov $0x0,%edx 3bc: f7 f3 div %ebx 3be: 89 45 ec mov %eax,-0x14(%ebp) 3c1: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 3c5: 75 c7 jne 38e <printint+0x38> if(neg) 3c7: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 3cb: 74 2d je 3fa <printint+0xa4> buf[i++] = '-'; 3cd: 8b 45 f4 mov -0xc(%ebp),%eax 3d0: 8d 50 01 lea 0x1(%eax),%edx 3d3: 89 55 f4 mov %edx,-0xc(%ebp) 3d6: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 3db: eb 1d jmp 3fa <printint+0xa4> putc(fd, buf[i]); 3dd: 8d 55 dc lea -0x24(%ebp),%edx 3e0: 8b 45 f4 mov -0xc(%ebp),%eax 3e3: 01 d0 add %edx,%eax 3e5: 0f b6 00 movzbl (%eax),%eax 3e8: 0f be c0 movsbl %al,%eax 3eb: 83 ec 08 sub $0x8,%esp 3ee: 50 push %eax 3ef: ff 75 08 pushl 0x8(%ebp) 3f2: e8 3c ff ff ff call 333 <putc> 3f7: 83 c4 10 add $0x10,%esp while(--i >= 0) 3fa: 83 6d f4 01 subl $0x1,-0xc(%ebp) 3fe: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 402: 79 d9 jns 3dd <printint+0x87> } 404: 90 nop 405: 8b 5d fc mov -0x4(%ebp),%ebx 408: c9 leave 409: c3 ret 0000040a <printlong>: static void printlong(int fd, unsigned long long xx, int base, int sgn) { 40a: 55 push %ebp 40b: 89 e5 mov %esp,%ebp 40d: 83 ec 28 sub $0x28,%esp 410: 8b 45 0c mov 0xc(%ebp),%eax 413: 89 45 e0 mov %eax,-0x20(%ebp) 416: 8b 45 10 mov 0x10(%ebp),%eax 419: 89 45 e4 mov %eax,-0x1c(%ebp) // Force hexadecimal uint upper, lower; upper = xx >> 32; 41c: 8b 45 e0 mov -0x20(%ebp),%eax 41f: 8b 55 e4 mov -0x1c(%ebp),%edx 422: 89 d0 mov %edx,%eax 424: 31 d2 xor %edx,%edx 426: 89 45 f4 mov %eax,-0xc(%ebp) lower = xx & 0xffffffff; 429: 8b 45 e0 mov -0x20(%ebp),%eax 42c: 89 45 f0 mov %eax,-0x10(%ebp) if(upper) printint(fd, upper, 16, 0); 42f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 433: 74 13 je 448 <printlong+0x3e> 435: 8b 45 f4 mov -0xc(%ebp),%eax 438: 6a 00 push $0x0 43a: 6a 10 push $0x10 43c: 50 push %eax 43d: ff 75 08 pushl 0x8(%ebp) 440: e8 11 ff ff ff call 356 <printint> 445: 83 c4 10 add $0x10,%esp printint(fd, lower, 16, 0); 448: 8b 45 f0 mov -0x10(%ebp),%eax 44b: 6a 00 push $0x0 44d: 6a 10 push $0x10 44f: 50 push %eax 450: ff 75 08 pushl 0x8(%ebp) 453: e8 fe fe ff ff call 356 <printint> 458: 83 c4 10 add $0x10,%esp } 45b: 90 nop 45c: c9 leave 45d: c3 ret 0000045e <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. // bdg 10/05/2015: Add %l void printf(int fd, char *fmt, ...) { 45e: 55 push %ebp 45f: 89 e5 mov %esp,%ebp 461: 83 ec 28 sub $0x28,%esp char *s; int c, i, state; uint *ap; state = 0; 464: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 46b: 8d 45 0c lea 0xc(%ebp),%eax 46e: 83 c0 04 add $0x4,%eax 471: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 474: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 47b: e9 88 01 00 00 jmp 608 <printf+0x1aa> c = fmt[i] & 0xff; 480: 8b 55 0c mov 0xc(%ebp),%edx 483: 8b 45 f0 mov -0x10(%ebp),%eax 486: 01 d0 add %edx,%eax 488: 0f b6 00 movzbl (%eax),%eax 48b: 0f be c0 movsbl %al,%eax 48e: 25 ff 00 00 00 and $0xff,%eax 493: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 496: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 49a: 75 2c jne 4c8 <printf+0x6a> if(c == '%'){ 49c: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 4a0: 75 0c jne 4ae <printf+0x50> state = '%'; 4a2: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 4a9: e9 56 01 00 00 jmp 604 <printf+0x1a6> } else { putc(fd, c); 4ae: 8b 45 e4 mov -0x1c(%ebp),%eax 4b1: 0f be c0 movsbl %al,%eax 4b4: 83 ec 08 sub $0x8,%esp 4b7: 50 push %eax 4b8: ff 75 08 pushl 0x8(%ebp) 4bb: e8 73 fe ff ff call 333 <putc> 4c0: 83 c4 10 add $0x10,%esp 4c3: e9 3c 01 00 00 jmp 604 <printf+0x1a6> } } else if(state == '%'){ 4c8: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 4cc: 0f 85 32 01 00 00 jne 604 <printf+0x1a6> if(c == 'd'){ 4d2: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 4d6: 75 1e jne 4f6 <printf+0x98> printint(fd, *ap, 10, 1); 4d8: 8b 45 e8 mov -0x18(%ebp),%eax 4db: 8b 00 mov (%eax),%eax 4dd: 6a 01 push $0x1 4df: 6a 0a push $0xa 4e1: 50 push %eax 4e2: ff 75 08 pushl 0x8(%ebp) 4e5: e8 6c fe ff ff call 356 <printint> 4ea: 83 c4 10 add $0x10,%esp ap++; 4ed: 83 45 e8 04 addl $0x4,-0x18(%ebp) 4f1: e9 07 01 00 00 jmp 5fd <printf+0x19f> } else if(c == 'l') { 4f6: 83 7d e4 6c cmpl $0x6c,-0x1c(%ebp) 4fa: 75 29 jne 525 <printf+0xc7> printlong(fd, *(unsigned long long *)ap, 10, 0); 4fc: 8b 45 e8 mov -0x18(%ebp),%eax 4ff: 8b 50 04 mov 0x4(%eax),%edx 502: 8b 00 mov (%eax),%eax 504: 83 ec 0c sub $0xc,%esp 507: 6a 00 push $0x0 509: 6a 0a push $0xa 50b: 52 push %edx 50c: 50 push %eax 50d: ff 75 08 pushl 0x8(%ebp) 510: e8 f5 fe ff ff call 40a <printlong> 515: 83 c4 20 add $0x20,%esp // long longs take up 2 argument slots ap++; 518: 83 45 e8 04 addl $0x4,-0x18(%ebp) ap++; 51c: 83 45 e8 04 addl $0x4,-0x18(%ebp) 520: e9 d8 00 00 00 jmp 5fd <printf+0x19f> } else if(c == 'x' || c == 'p'){ 525: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 529: 74 06 je 531 <printf+0xd3> 52b: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 52f: 75 1e jne 54f <printf+0xf1> printint(fd, *ap, 16, 0); 531: 8b 45 e8 mov -0x18(%ebp),%eax 534: 8b 00 mov (%eax),%eax 536: 6a 00 push $0x0 538: 6a 10 push $0x10 53a: 50 push %eax 53b: ff 75 08 pushl 0x8(%ebp) 53e: e8 13 fe ff ff call 356 <printint> 543: 83 c4 10 add $0x10,%esp ap++; 546: 83 45 e8 04 addl $0x4,-0x18(%ebp) 54a: e9 ae 00 00 00 jmp 5fd <printf+0x19f> } else if(c == 's'){ 54f: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 553: 75 43 jne 598 <printf+0x13a> s = (char*)*ap; 555: 8b 45 e8 mov -0x18(%ebp),%eax 558: 8b 00 mov (%eax),%eax 55a: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 55d: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 561: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 565: 75 25 jne 58c <printf+0x12e> s = "(null)"; 567: c7 45 f4 43 08 00 00 movl $0x843,-0xc(%ebp) while(*s != 0){ 56e: eb 1c jmp 58c <printf+0x12e> putc(fd, *s); 570: 8b 45 f4 mov -0xc(%ebp),%eax 573: 0f b6 00 movzbl (%eax),%eax 576: 0f be c0 movsbl %al,%eax 579: 83 ec 08 sub $0x8,%esp 57c: 50 push %eax 57d: ff 75 08 pushl 0x8(%ebp) 580: e8 ae fd ff ff call 333 <putc> 585: 83 c4 10 add $0x10,%esp s++; 588: 83 45 f4 01 addl $0x1,-0xc(%ebp) while(*s != 0){ 58c: 8b 45 f4 mov -0xc(%ebp),%eax 58f: 0f b6 00 movzbl (%eax),%eax 592: 84 c0 test %al,%al 594: 75 da jne 570 <printf+0x112> 596: eb 65 jmp 5fd <printf+0x19f> } } else if(c == 'c'){ 598: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 59c: 75 1d jne 5bb <printf+0x15d> putc(fd, *ap); 59e: 8b 45 e8 mov -0x18(%ebp),%eax 5a1: 8b 00 mov (%eax),%eax 5a3: 0f be c0 movsbl %al,%eax 5a6: 83 ec 08 sub $0x8,%esp 5a9: 50 push %eax 5aa: ff 75 08 pushl 0x8(%ebp) 5ad: e8 81 fd ff ff call 333 <putc> 5b2: 83 c4 10 add $0x10,%esp ap++; 5b5: 83 45 e8 04 addl $0x4,-0x18(%ebp) 5b9: eb 42 jmp 5fd <printf+0x19f> } else if(c == '%'){ 5bb: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 5bf: 75 17 jne 5d8 <printf+0x17a> putc(fd, c); 5c1: 8b 45 e4 mov -0x1c(%ebp),%eax 5c4: 0f be c0 movsbl %al,%eax 5c7: 83 ec 08 sub $0x8,%esp 5ca: 50 push %eax 5cb: ff 75 08 pushl 0x8(%ebp) 5ce: e8 60 fd ff ff call 333 <putc> 5d3: 83 c4 10 add $0x10,%esp 5d6: eb 25 jmp 5fd <printf+0x19f> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 5d8: 83 ec 08 sub $0x8,%esp 5db: 6a 25 push $0x25 5dd: ff 75 08 pushl 0x8(%ebp) 5e0: e8 4e fd ff ff call 333 <putc> 5e5: 83 c4 10 add $0x10,%esp putc(fd, c); 5e8: 8b 45 e4 mov -0x1c(%ebp),%eax 5eb: 0f be c0 movsbl %al,%eax 5ee: 83 ec 08 sub $0x8,%esp 5f1: 50 push %eax 5f2: ff 75 08 pushl 0x8(%ebp) 5f5: e8 39 fd ff ff call 333 <putc> 5fa: 83 c4 10 add $0x10,%esp } state = 0; 5fd: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) for(i = 0; fmt[i]; i++){ 604: 83 45 f0 01 addl $0x1,-0x10(%ebp) 608: 8b 55 0c mov 0xc(%ebp),%edx 60b: 8b 45 f0 mov -0x10(%ebp),%eax 60e: 01 d0 add %edx,%eax 610: 0f b6 00 movzbl (%eax),%eax 613: 84 c0 test %al,%al 615: 0f 85 65 fe ff ff jne 480 <printf+0x22> } } } 61b: 90 nop 61c: c9 leave 61d: c3 ret 0000061e <free>: static Header base; static Header *freep; void free(void *ap) { 61e: 55 push %ebp 61f: 89 e5 mov %esp,%ebp 621: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 624: 8b 45 08 mov 0x8(%ebp),%eax 627: 83 e8 08 sub $0x8,%eax 62a: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 62d: a1 d0 0a 00 00 mov 0xad0,%eax 632: 89 45 fc mov %eax,-0x4(%ebp) 635: eb 24 jmp 65b <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 637: 8b 45 fc mov -0x4(%ebp),%eax 63a: 8b 00 mov (%eax),%eax 63c: 3b 45 fc cmp -0x4(%ebp),%eax 63f: 77 12 ja 653 <free+0x35> 641: 8b 45 f8 mov -0x8(%ebp),%eax 644: 3b 45 fc cmp -0x4(%ebp),%eax 647: 77 24 ja 66d <free+0x4f> 649: 8b 45 fc mov -0x4(%ebp),%eax 64c: 8b 00 mov (%eax),%eax 64e: 3b 45 f8 cmp -0x8(%ebp),%eax 651: 77 1a ja 66d <free+0x4f> for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 653: 8b 45 fc mov -0x4(%ebp),%eax 656: 8b 00 mov (%eax),%eax 658: 89 45 fc mov %eax,-0x4(%ebp) 65b: 8b 45 f8 mov -0x8(%ebp),%eax 65e: 3b 45 fc cmp -0x4(%ebp),%eax 661: 76 d4 jbe 637 <free+0x19> 663: 8b 45 fc mov -0x4(%ebp),%eax 666: 8b 00 mov (%eax),%eax 668: 3b 45 f8 cmp -0x8(%ebp),%eax 66b: 76 ca jbe 637 <free+0x19> break; if(bp + bp->s.size == p->s.ptr){ 66d: 8b 45 f8 mov -0x8(%ebp),%eax 670: 8b 40 04 mov 0x4(%eax),%eax 673: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 67a: 8b 45 f8 mov -0x8(%ebp),%eax 67d: 01 c2 add %eax,%edx 67f: 8b 45 fc mov -0x4(%ebp),%eax 682: 8b 00 mov (%eax),%eax 684: 39 c2 cmp %eax,%edx 686: 75 24 jne 6ac <free+0x8e> bp->s.size += p->s.ptr->s.size; 688: 8b 45 f8 mov -0x8(%ebp),%eax 68b: 8b 50 04 mov 0x4(%eax),%edx 68e: 8b 45 fc mov -0x4(%ebp),%eax 691: 8b 00 mov (%eax),%eax 693: 8b 40 04 mov 0x4(%eax),%eax 696: 01 c2 add %eax,%edx 698: 8b 45 f8 mov -0x8(%ebp),%eax 69b: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 69e: 8b 45 fc mov -0x4(%ebp),%eax 6a1: 8b 00 mov (%eax),%eax 6a3: 8b 10 mov (%eax),%edx 6a5: 8b 45 f8 mov -0x8(%ebp),%eax 6a8: 89 10 mov %edx,(%eax) 6aa: eb 0a jmp 6b6 <free+0x98> } else bp->s.ptr = p->s.ptr; 6ac: 8b 45 fc mov -0x4(%ebp),%eax 6af: 8b 10 mov (%eax),%edx 6b1: 8b 45 f8 mov -0x8(%ebp),%eax 6b4: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 6b6: 8b 45 fc mov -0x4(%ebp),%eax 6b9: 8b 40 04 mov 0x4(%eax),%eax 6bc: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 6c3: 8b 45 fc mov -0x4(%ebp),%eax 6c6: 01 d0 add %edx,%eax 6c8: 3b 45 f8 cmp -0x8(%ebp),%eax 6cb: 75 20 jne 6ed <free+0xcf> p->s.size += bp->s.size; 6cd: 8b 45 fc mov -0x4(%ebp),%eax 6d0: 8b 50 04 mov 0x4(%eax),%edx 6d3: 8b 45 f8 mov -0x8(%ebp),%eax 6d6: 8b 40 04 mov 0x4(%eax),%eax 6d9: 01 c2 add %eax,%edx 6db: 8b 45 fc mov -0x4(%ebp),%eax 6de: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 6e1: 8b 45 f8 mov -0x8(%ebp),%eax 6e4: 8b 10 mov (%eax),%edx 6e6: 8b 45 fc mov -0x4(%ebp),%eax 6e9: 89 10 mov %edx,(%eax) 6eb: eb 08 jmp 6f5 <free+0xd7> } else p->s.ptr = bp; 6ed: 8b 45 fc mov -0x4(%ebp),%eax 6f0: 8b 55 f8 mov -0x8(%ebp),%edx 6f3: 89 10 mov %edx,(%eax) freep = p; 6f5: 8b 45 fc mov -0x4(%ebp),%eax 6f8: a3 d0 0a 00 00 mov %eax,0xad0 } 6fd: 90 nop 6fe: c9 leave 6ff: c3 ret 00000700 <morecore>: static Header* morecore(uint nu) { 700: 55 push %ebp 701: 89 e5 mov %esp,%ebp 703: 83 ec 18 sub $0x18,%esp char *p; Header *hp; if(nu < 4096) 706: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 70d: 77 07 ja 716 <morecore+0x16> nu = 4096; 70f: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 716: 8b 45 08 mov 0x8(%ebp),%eax 719: c1 e0 03 shl $0x3,%eax 71c: 83 ec 0c sub $0xc,%esp 71f: 50 push %eax 720: e8 e6 fb ff ff call 30b <sbrk> 725: 83 c4 10 add $0x10,%esp 728: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 72b: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 72f: 75 07 jne 738 <morecore+0x38> return 0; 731: b8 00 00 00 00 mov $0x0,%eax 736: eb 26 jmp 75e <morecore+0x5e> hp = (Header*)p; 738: 8b 45 f4 mov -0xc(%ebp),%eax 73b: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 73e: 8b 45 f0 mov -0x10(%ebp),%eax 741: 8b 55 08 mov 0x8(%ebp),%edx 744: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 747: 8b 45 f0 mov -0x10(%ebp),%eax 74a: 83 c0 08 add $0x8,%eax 74d: 83 ec 0c sub $0xc,%esp 750: 50 push %eax 751: e8 c8 fe ff ff call 61e <free> 756: 83 c4 10 add $0x10,%esp return freep; 759: a1 d0 0a 00 00 mov 0xad0,%eax } 75e: c9 leave 75f: c3 ret 00000760 <malloc>: void* malloc(uint nbytes) { 760: 55 push %ebp 761: 89 e5 mov %esp,%ebp 763: 83 ec 18 sub $0x18,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 766: 8b 45 08 mov 0x8(%ebp),%eax 769: 83 c0 07 add $0x7,%eax 76c: c1 e8 03 shr $0x3,%eax 76f: 83 c0 01 add $0x1,%eax 772: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 775: a1 d0 0a 00 00 mov 0xad0,%eax 77a: 89 45 f0 mov %eax,-0x10(%ebp) 77d: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 781: 75 23 jne 7a6 <malloc+0x46> base.s.ptr = freep = prevp = &base; 783: c7 45 f0 c8 0a 00 00 movl $0xac8,-0x10(%ebp) 78a: 8b 45 f0 mov -0x10(%ebp),%eax 78d: a3 d0 0a 00 00 mov %eax,0xad0 792: a1 d0 0a 00 00 mov 0xad0,%eax 797: a3 c8 0a 00 00 mov %eax,0xac8 base.s.size = 0; 79c: c7 05 cc 0a 00 00 00 movl $0x0,0xacc 7a3: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 7a6: 8b 45 f0 mov -0x10(%ebp),%eax 7a9: 8b 00 mov (%eax),%eax 7ab: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 7ae: 8b 45 f4 mov -0xc(%ebp),%eax 7b1: 8b 40 04 mov 0x4(%eax),%eax 7b4: 3b 45 ec cmp -0x14(%ebp),%eax 7b7: 72 4d jb 806 <malloc+0xa6> if(p->s.size == nunits) 7b9: 8b 45 f4 mov -0xc(%ebp),%eax 7bc: 8b 40 04 mov 0x4(%eax),%eax 7bf: 3b 45 ec cmp -0x14(%ebp),%eax 7c2: 75 0c jne 7d0 <malloc+0x70> prevp->s.ptr = p->s.ptr; 7c4: 8b 45 f4 mov -0xc(%ebp),%eax 7c7: 8b 10 mov (%eax),%edx 7c9: 8b 45 f0 mov -0x10(%ebp),%eax 7cc: 89 10 mov %edx,(%eax) 7ce: eb 26 jmp 7f6 <malloc+0x96> else { p->s.size -= nunits; 7d0: 8b 45 f4 mov -0xc(%ebp),%eax 7d3: 8b 40 04 mov 0x4(%eax),%eax 7d6: 2b 45 ec sub -0x14(%ebp),%eax 7d9: 89 c2 mov %eax,%edx 7db: 8b 45 f4 mov -0xc(%ebp),%eax 7de: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 7e1: 8b 45 f4 mov -0xc(%ebp),%eax 7e4: 8b 40 04 mov 0x4(%eax),%eax 7e7: c1 e0 03 shl $0x3,%eax 7ea: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 7ed: 8b 45 f4 mov -0xc(%ebp),%eax 7f0: 8b 55 ec mov -0x14(%ebp),%edx 7f3: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 7f6: 8b 45 f0 mov -0x10(%ebp),%eax 7f9: a3 d0 0a 00 00 mov %eax,0xad0 return (void*)(p + 1); 7fe: 8b 45 f4 mov -0xc(%ebp),%eax 801: 83 c0 08 add $0x8,%eax 804: eb 3b jmp 841 <malloc+0xe1> } if(p == freep) 806: a1 d0 0a 00 00 mov 0xad0,%eax 80b: 39 45 f4 cmp %eax,-0xc(%ebp) 80e: 75 1e jne 82e <malloc+0xce> if((p = morecore(nunits)) == 0) 810: 83 ec 0c sub $0xc,%esp 813: ff 75 ec pushl -0x14(%ebp) 816: e8 e5 fe ff ff call 700 <morecore> 81b: 83 c4 10 add $0x10,%esp 81e: 89 45 f4 mov %eax,-0xc(%ebp) 821: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 825: 75 07 jne 82e <malloc+0xce> return 0; 827: b8 00 00 00 00 mov $0x0,%eax 82c: eb 13 jmp 841 <malloc+0xe1> for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 82e: 8b 45 f4 mov -0xc(%ebp),%eax 831: 89 45 f0 mov %eax,-0x10(%ebp) 834: 8b 45 f4 mov -0xc(%ebp),%eax 837: 8b 00 mov (%eax),%eax 839: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 83c: e9 6d ff ff ff jmp 7ae <malloc+0x4e> } } 841: c9 leave 842: c3 ret
core/src/main/antlr4/NumericExpression.g4
pantheon/pantheon
1
4709
grammar NumericExpression; fragment DIGIT : [0-9] ; NUMBER: MINUS? (DIGIT+('.' DIGIT+)?| DIGIT* '.' DIGIT+); PLUS:'+'; MINUS:'-'; DIVIDE: '/'; MULTIPLY: '*'; fragment LETTER : [a-zA-Z$_] // these are the "java letters" below 0x7F | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate | [\uD800-\uDBFF] [\uDC00-\uDFFF] // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF ; fragment LETTERORDIGIT : LETTER | DIGIT ; IDENTIFIER: LETTER LETTERORDIGIT*; WS: [ \t\r\n\u000C]+ -> channel(HIDDEN); expression: body EOF; body : body (DIVIDE| MULTIPLY) body | body (PLUS | MINUS) body | '('body')' | identWithDot | NUMBER; identWithDot: '_'?IDENTIFIER('.'IDENTIFIER)*;
libsrc/_DEVELOPMENT/adt/b_vector/c/sdcc_iy/b_vector_clear.asm
meesokim/z88dk
0
177729
; void b_vector_clear(b_vector_t *v) SECTION code_adt_b_vector PUBLIC _b_vector_clear EXTERN _b_array_clear defc _b_vector_clear = _b_array_clear
libsrc/msx/msx_vread.asm
andydansby/z88dk-mk2
1
9091
; ; MSX specific routines ; ; GFX - a small graphics library ; Copyright (C) 2004 <NAME> ; ; extern void vread(unsigned int source, void* dest, unsigned int count); ; ; Transfer count bytes from VRAM to RAM ; ; $Id: msx_vread.asm,v 1.5 2009/06/22 21:44:17 dom Exp $ ; XLIB msx_vread LIB msxbios IF FORmsx INCLUDE "msxbios.def" INCLUDE "msx.def" ELSE INCLUDE "svibios.def" INCLUDE "svi.def" ENDIF msx_vread: ld ix,2 add ix,sp ld c, (ix+0) ; count ld b, (ix+1) ld e, (ix+2) ; dest ld d, (ix+3) ld l, (ix+4) ; source ld h, (ix+5) ;ld ix,LDIRMV ;jp msxbios ld ix,SETRD call msxbios ex (sp),hl ; VDP Timing ex (sp),hl ; VDP Timing rdloop: in a,(VDP_DATAIN) ld (de),a inc de dec bc ld a,c or b jr nz,rdloop ret
MP-CSE 4th Sem/10a.asm
MyCollegeForums/4thSemISE
0
94782
<reponame>MyCollegeForums/4thSemISE<filename>MP-CSE 4th Sem/10a.asm<gh_stars>0 PRESERVE8 THUMB AREA |.text|,CODE,READONLY EXPORT __main __main LDR R0,=0x20000000 LDR R1,=0x20000200 MOV R2,#0 swap LDRB R3,[R0,R2] STRB R3,[R1,R2] ADD R2,R2,#1 CMP R2,#10 BLT swap stop B stop END
U9200/CardFiles/Source/dp_test.asm
sboydlns/univacemulators
2
13403
*********************************************************** * * EXEC-1 tester * *********************************************************** E1TS START 0 USING *,0 DS 0H STRT EQU * * * Ask user for test number * LOOP MSG X'001',REPLY RSP1 EQU LOOP+7 CLI RSP1,1 BC 8,T1 CLI RSP1,2 BC 8,T2 BC 15,LOOP * * T1 - Divide no remainder * T1 ZAP RSLT,P10 DP RSLT,P5 CP RSLT(2),P2 BC 8,T1A MSG X'002' OOPS! QUOTIENT <> 2 BC 15,LOOP T1A CP RSLT+2(2),P0 BC 8,LOOP MSG X'003' OOPS! REMO <> 0 BC 15,LOOP * * T2 - Divide with remainder * T2 EQU * ZAP RSLT,P10 DP RSLT,P3 CP RSLT(2),P3 BC 8,T2A MSG X'004' OOPS! QUOTIENT <> 3 BC 15,LOOP T2A CP RSLT+2(2),P1 BC 8,LOOP MSG X'005' OOPS! REM <> 1 BC 15,LOOP RSLT DS CL4 P10 DC XL2'010C' P5 DC XL2'005C' P3 DC XL2'003C' P2 DC XL2'002C' P1 DC XL2'001C' P0 DC XL2'000C' END STRT
source/adam-exception_handler.adb
charlie5/aIDE
3
27773
<reponame>charlie5/aIDE<gh_stars>1-10 with AdaM.Block, AdaM.Factory; package body AdaM.exception_Handler is -- Storage Pool -- record_Version : constant := 1; max_Exceptions : constant := 5_000; package Pool is new AdaM.Factory.Pools (".adam-store", "exception_handlers", max_Exceptions, record_Version, exception_Handler.item, exception_Handler.view); -- Vector -- function to_Source (the_exception_Handlers : in Vector) return text_Vectors.Vector is the_Source : text_Vectors.Vector; begin for i in 1 .. the_exception_Handlers.Length loop the_Source.append (the_exception_Handlers.Element (Integer (i)).to_Source); end loop; return the_Source; end to_Source; -- Forge -- procedure define (Self : in out Item) is begin Self.Handler := Block_view (AdaM.Block.new_Block ("")); end define; procedure destruct (Self : in out Item) is begin Self.Parent.rid (Self'unchecked_Access); end destruct; function new_Handler (Parent : in AdaM.Block.view) return exception_Handler.view is new_Item : constant exception_Handler.view := Pool.new_Item; begin define (exception_Handler.item (new_Item.all)); new_Item.Parent := Block_view (Parent); return new_Item; end new_Handler; procedure free (Self : in out exception_Handler.view) is begin destruct (exception_Handler.item (Self.all)); Pool.free (Self); end free; -- Attributes -- overriding function Name (Self : in Item) return Identifier is pragma Unreferenced (Self); begin return "exception_Handler"; end Name; overriding function Id (Self : access Item) return AdaM.Id is begin return Pool.to_Id (Self); end Id; function my_Exception (Self : in Item; Id : in Positive) return AdaM.Declaration.of_exception.view is begin return Self.Exceptions.Element (Id); end my_Exception; procedure my_Exception_is (Self : in out Item; Id : in Positive; Now : in AdaM.Declaration.of_exception.view) is begin Self.Exceptions.Replace_Element (Id, Now); end my_Exception_is; function is_Free (Self : in Item; Slot : in Positive) return Boolean is use type Declaration.of_exception.view; begin return Self.Exceptions.Element (Slot) = null; end is_Free; procedure add_Exception (Self : in out Item; the_Exception : in AdaM.Declaration.of_exception.view) is begin Self.Exceptions.append (the_Exception); end add_Exception; function exception_Count (Self : in Item) return Natural is begin return Natural (Self.Exceptions.Length); end exception_Count; function Handler (Self : in Item) return access AdaM.Block.item'Class is begin return Self.Handler; end Handler; overriding function to_Source (Self : in Item) return text_Lines is use text_Vectors; use type AdaM.Declaration.of_exception.view; Lines : text_Lines; not_First : Boolean := False; begin Lines.append (+"when "); -- for i in 1 .. Integer (Self.Exceptions.Length) for i in 1 .. Integer (Self.Exceptions.Length) loop if not Self.is_Free (i) then if not_First then Lines.append (+" | "); end if; if Self.Exceptions.Element (i) = null then Lines.append (+"constraint_Error"); else Lines.append (+String (Self.Exceptions.Element (i).full_Name)); end if; not_First := True; end if; end loop; Lines.append (+" => "); Lines.append (Self.Handler.to_Source); return Lines; end to_Source; -- Streams -- procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View) renames Pool.View_write; procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View) renames Pool.View_read; procedure Block_view_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in Block_view) is begin Block.View_write (Stream, Block.view (Self)); end Block_view_write; procedure Block_view_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out Block_view) is begin Block.View_read (Stream, Block.view (Self)); end Block_view_read; end AdaM.exception_Handler;
Pactor.g4
kstrempel/pactor
1
7777
grammar Pactor; program : using* create_words* (statement|quote|array|dictionary)* EOF ; using : 'USING:' packages+=WORD* ';' # createUsing ; create_words : ':' name=WORD '(' params_in+=WORD* '--' params_out+=WORD* ')' block ';' # createWord | '::' name=WORD '(' params_in+=WORD* '--' params_out+=WORD* ')' block ';' # createVariableWord ; block : (statement|quote|block_commands|array|dictionary)* ; array : '(' statement* ')' # createArray ; dictionary : '{' dictionary_entry* '}' # createDictionary ; dictionary_entry : key_value (quote|statement) # createDictionaryEntry ; quote : '[' block ']' # createQuote ; block_commands : '->' variable=WORD # createLocalVars | '->' '(' variables+=WORD+ ')' # createLocalVars ; statement : non_key_value | key_value ; non_key_value : value=FLOAT # pushFloatToStack | value=EXPRESSIONS # pushExpressionToStack | value=BOOLEAN # pushBooleanToStack | value=(WORD|MATH_WORDS) # commandRun ; key_value : value=NUMBER # pushNumberToStack | value=STRING # pushStringToStack | ':' value=WORD # pushSymbolToStack ; COMMENT : '#'+ ~( '\r' | '\n' )* -> skip ; EXPRESSIONS : '=' | '<' | '>' | '<=' | '>=' | '!=' | 'not' | 'and' | 'or' ; NUMBER : ('0' .. '9') + (('e' | 'E') NUMBER)* ; FLOAT : ('0' .. '9')* '.' ('0' .. '9') + (('e' | 'E') ('0' .. '9') +)* ; STRING : '"' ( ~'"' | '\\' '"' )* '"' ; BOOLEAN : ('t'|'f') ; WORD : [a-z0-9_]+ ([a-z0-9_>])* '?'* ; MATH_WORDS : '+' | '-' | '*' | '/' ; WS : [ \n\r\t,]+ -> skip ;
core/lib/PathFunctor.agda
AntoineAllioux/HoTT-Agda
294
11188
{-# OPTIONS --without-K --rewriting #-} open import lib.Base open import lib.PathGroupoid module lib.PathFunctor where {- Nondependent stuff -} module _ {i j} {A : Type i} {B : Type j} (f : A → B) where !-ap : {x y : A} (p : x == y) → ! (ap f p) == ap f (! p) !-ap idp = idp ap-! : {x y : A} (p : x == y) → ap f (! p) == ! (ap f p) ap-! idp = idp ∙-ap : {x y z : A} (p : x == y) (q : y == z) → ap f p ∙ ap f q == ap f (p ∙ q) ∙-ap idp q = idp ap-∙ : {x y z : A} (p : x == y) (q : y == z) → ap f (p ∙ q) == ap f p ∙ ap f q ap-∙ idp q = idp !ap-∙=∙-ap : {x y z : A} (p : x == y) (q : y == z) → ! (ap-∙ p q) == ∙-ap p q !ap-∙=∙-ap idp q = idp ∙∙-ap : {x y z w : A} (p : x == y) (q : y == z) (r : z == w) → ap f p ∙ ap f q ∙ ap f r == ap f (p ∙ q ∙ r) ∙∙-ap idp idp r = idp ap-∙∙ : {x y z w : A} (p : x == y) (q : y == z) (r : z == w) → ap f (p ∙ q ∙ r) == ap f p ∙ ap f q ∙ ap f r ap-∙∙ idp idp r = idp ap-∙∙∙ : {x y z w t : A} (p : x == y) (q : y == z) (r : z == w) (s : w == t) → ap f (p ∙ q ∙ r ∙ s) == ap f p ∙ ap f q ∙ ap f r ∙ ap f s ap-∙∙∙ idp idp idp s = idp ∙'-ap : {x y z : A} (p : x == y) (q : y == z) → ap f p ∙' ap f q == ap f (p ∙' q) ∙'-ap p idp = idp -- note: ap-∙' is defined in PathGroupoid {- Dependent stuff -} module _ {i j} {A : Type i} {B : A → Type j} (f : Π A B) where apd-∙ : {x y z : A} (p : x == y) (q : y == z) → apd f (p ∙ q) == apd f p ∙ᵈ apd f q apd-∙ idp idp = idp apd-∙' : {x y z : A} (p : x == y) (q : y == z) → apd f (p ∙' q) == apd f p ∙'ᵈ apd f q apd-∙' idp idp = idp apd-! : {x y : A} (p : x == y) → apd f (! p) == !ᵈ (apd f p) apd-! idp = idp {- Over stuff -} module _ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} (f : {a : A} → B a → C a) where ap↓-◃ : {x y z : A} {u : B x} {v : B y} {w : B z} {p : x == y} {p' : y == z} (q : u == v [ B ↓ p ]) (r : v == w [ B ↓ p' ]) → ap↓ f (q ◃ r) == ap↓ f q ◃ ap↓ f r ap↓-◃ {p = idp} {p' = idp} idp idp = idp ap↓-▹! : {x y z : A} {u : B x} {v : B y} {w : B z} {p : x == y} {p' : z == y} (q : u == v [ B ↓ p ]) (r : w == v [ B ↓ p' ]) → ap↓ f (q ▹! r) == ap↓ f q ▹! ap↓ f r ap↓-▹! {p = idp} {p' = idp} idp idp = idp {- Fuse and unfuse -} module _ {i j k} {A : Type i} {B : Type j} {C : Type k} (g : B → C) (f : A → B) where ∘-ap : {x y : A} (p : x == y) → ap g (ap f p) == ap (g ∘ f) p ∘-ap idp = idp ap-∘ : {x y : A} (p : x == y) → ap (g ∘ f) p == ap g (ap f p) ap-∘ idp = idp !ap-∘=∘-ap : {x y : A} (p : x == y) → ! (ap-∘ p) == ∘-ap p !ap-∘=∘-ap idp = idp ap-idf : ∀ {i} {A : Type i} {u v : A} (p : u == v) → ap (idf A) p == p ap-idf idp = idp {- Functoriality of [coe] -} coe-∙ : ∀ {i} {A B C : Type i} (p : A == B) (q : B == C) (a : A) → coe (p ∙ q) a == coe q (coe p a) coe-∙ idp q a = idp coe-! : ∀ {i} {A B : Type i} (p : A == B) (b : B) → coe (! p) b == coe! p b coe-! idp b = idp coe!-inv-r : ∀ {i} {A B : Type i} (p : A == B) (b : B) → coe p (coe! p b) == b coe!-inv-r idp b = idp coe!-inv-l : ∀ {i} {A B : Type i} (p : A == B) (a : A) → coe! p (coe p a) == a coe!-inv-l idp a = idp coe-inv-adj : ∀ {i} {A B : Type i} (p : A == B) (a : A) → ap (coe p) (coe!-inv-l p a) == coe!-inv-r p (coe p a) coe-inv-adj idp a = idp coe!-inv-adj : ∀ {i} {A B : Type i} (p : A == B) (b : B) → ap (coe! p) (coe!-inv-r p b) == coe!-inv-l p (coe! p b) coe!-inv-adj idp b = idp coe-ap-! : ∀ {i j} {A : Type i} (P : A → Type j) {a b : A} (p : a == b) (x : P b) → coe (ap P (! p)) x == coe! (ap P p) x coe-ap-! P idp x = idp {- Functoriality of transport -} transp-∙ : ∀ {i j} {A : Type i} {B : A → Type j} {x y z : A} (p : x == y) (q : y == z) (b : B x) → transport B (p ∙ q) b == transport B q (transport B p b) transp-∙ idp _ _ = idp transp-∙' : ∀ {i j} {A : Type i} {B : A → Type j} {x y z : A} (p : x == y) (q : y == z) (b : B x) → transport B (p ∙' q) b == transport B q (transport B p b) transp-∙' _ idp _ = idp {- Naturality of transport -} transp-naturality : ∀ {i j k} {A : Type i} {B : A → Type j} {C : A → Type k} (u : {a : A} → B a → C a) {a₀ a₁ : A} (p : a₀ == a₁) → u ∘ transport B p == transport C p ∘ u transp-naturality f idp = idp transp-idp : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {x y : A} (p : x == y) → transport (λ a → f a == f a) p idp == idp transp-idp f idp = idp module _ {i j} {A : Type i} {B : Type j} where ap-transp : (f g : A → B) {a₀ a₁ : A} (p : a₀ == a₁) (h : f a₀ == g a₀) → h ∙ ap g p == ap f p ∙ transport (λ a → f a == g a) p h ap-transp f g p@idp h = ∙-unit-r h ap-transp-idp : (f : A → B) {a₀ a₁ : A} (p : a₀ == a₁) → ap-transp f f p idp ◃∙ ap (ap f p ∙_) (transp-idp f p) ◃∙ ∙-unit-r (ap f p) ◃∎ =ₛ [] ap-transp-idp f p@idp = =ₛ-in idp {- for functions with two arguments -} module _ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : A → B → C) where ap2 : {x y : A} {w z : B} → (x == y) → (w == z) → f x w == f y z ap2 idp idp = idp ap2-out : {x y : A} {w z : B} (p : x == y) (q : w == z) → ap2 p q ◃∎ =ₛ ap (λ u → f u w) p ◃∙ ap (λ v → f y v) q ◃∎ ap2-out idp idp = =ₛ-in idp ap2-out' : {x y : A} {w z : B} (p : x == y) (q : w == z) → ap2 p q ◃∎ =ₛ ap (λ u → f x u) q ◃∙ ap (λ v → f v z) p ◃∎ ap2-out' idp idp = =ₛ-in idp ap2-idp-l : {x : A} {w z : B} (q : w == z) → ap2 (idp {a = x}) q == ap (f x) q ap2-idp-l idp = idp ap2-idp-r : {x y : A} {w : B} (p : x == y) → ap2 p (idp {a = w}) == ap (λ z → f z w) p ap2-idp-r idp = idp ap2-! : {a a' : A} {b b' : B} (p : a == a') (q : b == b') → ap2 (! p) (! q) == ! (ap2 p q) ap2-! idp idp = idp !-ap2 : {a a' : A} {b b' : B} (p : a == a') (q : b == b') → ! (ap2 p q) == ap2 (! p) (! q) !-ap2 idp idp = idp ap2-∙ : {a a' a'' : A} {b b' b'' : B} (p : a == a') (p' : a' == a'') (q : b == b') (q' : b' == b'') → ap2 (p ∙ p') (q ∙ q') == ap2 p q ∙ ap2 p' q' ap2-∙ idp p' idp q' = idp ∙-ap2 : {a a' a'' : A} {b b' b'' : B} (p : a == a') (p' : a' == a'') (q : b == b') (q' : b' == b'') → ap2 p q ∙ ap2 p' q' == ap2 (p ∙ p') (q ∙ q') ∙-ap2 idp p' idp q' = idp {- ap2 lemmas -} module _ {i j} {A : Type i} {B : Type j} where ap2-fst : {x y : A} {w z : B} (p : x == y) (q : w == z) → ap2 (curry fst) p q == p ap2-fst idp idp = idp ap2-snd : {x y : A} {w z : B} (p : x == y) (q : w == z) → ap2 (curry snd) p q == q ap2-snd idp idp = idp ap-ap2 : ∀ {k l} {C : Type k} {D : Type l} (g : C → D) (f : A → B → C) {x y : A} {w z : B} (p : x == y) (q : w == z) → ap g (ap2 f p q) == ap2 (λ a b → g (f a b)) p q ap-ap2 g f idp idp = idp ap2-ap-l : ∀ {k l} {C : Type k} {D : Type l} (g : B → C → D) (f : A → B) {x y : A} {w z : C} (p : x == y) (q : w == z) → ap2 g (ap f p) q == ap2 (λ a c → g (f a) c) p q ap2-ap-l g f idp idp = idp ap2-ap-r : ∀ {k l} {C : Type k} {D : Type l} (g : A → C → D) (f : B → C) {x y : A} {w z : B} (p : x == y) (q : w == z) → ap2 g p (ap f q) == ap2 (λ a b → g a (f b)) p q ap2-ap-r g f idp idp = idp ap2-ap-lr : ∀ {k l m} {C : Type k} {D : Type l} {E : Type m} (g : C → D → E) (f : A → C) (h : B → D) {x y : A} {w z : B} (p : x == y) (q : w == z) → ap2 g (ap f p) (ap h q) == ap2 (λ a b → g (f a) (h b)) p q ap2-ap-lr g f h idp idp = idp ap2-diag : (f : A → A → B) {x y : A} (p : x == y) → ap2 f p p == ap (λ x → f x x) p ap2-diag f idp = idp module _ {i j k} {A : Type i} {B : Type j} {C : Type k} (g : B → C) (f : A → B) where module _ {a a' a'' : A} (p : a == a') (p' : a' == a'') where ap-∘-∙-coh-seq₁ : ap (g ∘ f) (p ∙ p') =-= ap g (ap f p) ∙ ap g (ap f p') ap-∘-∙-coh-seq₁ = ap (g ∘ f) (p ∙ p') =⟪ ap-∙ (g ∘ f) p p' ⟫ ap (g ∘ f) p ∙ ap (g ∘ f) p' =⟪ ap2 _∙_ (ap-∘ g f p) (ap-∘ g f p') ⟫ ap g (ap f p) ∙ ap g (ap f p') ∎∎ ap-∘-∙-coh-seq₂ : ap (g ∘ f) (p ∙ p') =-= ap g (ap f p) ∙ ap g (ap f p') ap-∘-∙-coh-seq₂ = ap (g ∘ f) (p ∙ p') =⟪ ap-∘ g f (p ∙ p') ⟫ ap g (ap f (p ∙ p')) =⟪ ap (ap g) (ap-∙ f p p') ⟫ ap g (ap f p ∙ ap f p') =⟪ ap-∙ g (ap f p) (ap f p') ⟫ ap g (ap f p) ∙ ap g (ap f p') ∎∎ ap-∘-∙-coh : {a a' a'' : A} (p : a == a') (p' : a' == a'') → ap-∘-∙-coh-seq₁ p p' =ₛ ap-∘-∙-coh-seq₂ p p' ap-∘-∙-coh idp idp = =ₛ-in idp module _ {i} {A : Type i} where ap-null-homotopic : ∀ {k} {B : Type k} (f : A → B) {b : B} (h : (x : A) → f x == b) {x y : A} (p : x == y) → ap f p == h x ∙ ! (h y) ap-null-homotopic f h {x} p@idp = ! (!-inv-r (h x)) module _ {i j} {A : Type i} {B : Type j} (b : B) where ap-cst : {x y : A} (p : x == y) → ap (cst b) p == idp ap-cst = ap-null-homotopic (cst b) (cst idp) ap-cst-coh : {x y z : A} (p : x == y) (q : y == z) → ap-cst (p ∙ q) ◃∎ =ₛ ap-∙ (cst b) p q ◃∙ ap2 _∙_ (ap-cst p) (ap-cst q) ◃∎ ap-cst-coh idp idp = =ₛ-in idp ap-∘-cst-coh : ∀ {i} {j} {k} {A : Type i} {B : Type j} {C : Type k} (g : B → C) (b : B) {x y : A} (p : x == y) → ∘-ap g (λ _ → b) p ◃∙ ap-cst (g b) p ◃∎ =ₛ ap (ap g) (ap-cst b p) ◃∎ ap-∘-cst-coh g b p@idp = =ₛ-in idp {- Naturality of homotopies -} module _ {i} {A : Type i} where homotopy-naturality : ∀ {k} {B : Type k} (f g : A → B) (h : (x : A) → f x == g x) {x y : A} (p : x == y) → ap f p ◃∙ h y ◃∎ =ₛ h x ◃∙ ap g p ◃∎ homotopy-naturality f g h {x} idp = =ₛ-in (! (∙-unit-r (h x))) homotopy-naturality-to-idf : (f : A → A) (h : (x : A) → f x == x) {x y : A} (p : x == y) → ap f p ◃∙ h y ◃∎ =ₛ h x ◃∙ p ◃∎ homotopy-naturality-to-idf f h {x} p = =ₛ-in $ =ₛ-out (homotopy-naturality f (λ a → a) h p) ∙ ap (λ w → h x ∙ w) (ap-idf p) homotopy-naturality-from-idf : (g : A → A) (h : (x : A) → x == g x) {x y : A} (p : x == y) → p ◃∙ h y ◃∎ =ₛ h x ◃∙ ap g p ◃∎ homotopy-naturality-from-idf g h {y = y} p = =ₛ-in $ ap (λ w → w ∙ h y) (! (ap-idf p)) ∙ =ₛ-out (homotopy-naturality (λ a → a) g h p) homotopy-naturality-to-cst : ∀ {k} {B : Type k} (f : A → B) (b : B) (h : (x : A) → f x == b) {x y : A} (p : x == y) → ap f p ◃∙ h y ◃∎ =ₛ h x ◃∎ homotopy-naturality-to-cst f b h p@idp = =ₛ-in idp ap-null-homotopic-cst : ∀ {k} {B : Type k} (b₀ b₁ : B) (h : A → b₀ == b₁) {x y : A} (p : x == y) → ap-null-homotopic (cst b₀) h p ◃∙ ap (λ v → h v ∙ ! (h y)) p ◃∙ !-inv-r (h y) ◃∎ =ₛ ap-cst b₀ p ◃∎ ap-null-homotopic-cst b₀ b₁ h {x} p@idp = =ₛ-in (!-inv-l (!-inv-r (h x))) module _ {i j k} {A : Type i} {B : Type j} {C : Type k} (f g : A → B → C) (h : ∀ a b → f a b == g a b) where homotopy-naturality2 : {a₀ a₁ : A} {b₀ b₁ : B} (p : a₀ == a₁) (q : b₀ == b₁) → ap2 f p q ◃∙ h a₁ b₁ ◃∎ =ₛ h a₀ b₀ ◃∙ ap2 g p q ◃∎ homotopy-naturality2 {a₀ = a} {b₀ = b} idp idp = =ₛ-in (! (∙-unit-r (h a b))) module _ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : A → B → C) where ap-comm : {a₀ a₁ : A} (p : a₀ == a₁) {b₀ b₁ : B} (q : b₀ == b₁) → ap (λ a → f a b₀) p ∙ ap (λ z → f a₁ z) q == ap (λ z → f a₀ z) q ∙ ap (λ a → f a b₁) p ap-comm p q = ! (=ₛ-out (ap2-out f p q)) ∙ =ₛ-out (ap2-out' f p q) ap-comm-=ₛ : {a₀ a₁ : A} (p : a₀ == a₁) {b₀ b₁ : B} (q : b₀ == b₁) → ap (λ a → f a b₀) p ◃∙ ap (λ z → f a₁ z) q ◃∎ =ₛ ap (λ z → f a₀ z) q ◃∙ ap (λ a → f a b₁) p ◃∎ ap-comm-=ₛ p q = =ₛ-in (ap-comm p q) ap-comm' : {a₀ a₁ : A} (p : a₀ == a₁) {b₀ b₁ : B} (q : b₀ == b₁) → ap (λ a → f a b₀) p ∙' ap (λ z → f a₁ z) q == ap (λ z → f a₀ z) q ∙ ap (λ a → f a b₁) p ap-comm' p idp = idp ap-comm-cst-seq : {a₀ a₁ : A} (p : a₀ == a₁) {b₀ b₁ : B} (q : b₀ == b₁) (c : C) (h₀ : ∀ b → f a₀ b == c) → ap (λ a → f a b₀) p ∙ ap (λ b → f a₁ b) q =-= ap (λ z → f a₀ z) q ∙ ap (λ a → f a b₁) p ap-comm-cst-seq {a₀} {a₁} p {b₀} {b₁} q c h₀ = ap (λ a → f a b₀) p ∙ ap (λ b → f a₁ b) q =⟪ ap (ap (λ a → f a b₀) p ∙_) $ ap-null-homotopic (λ b → f a₁ b) h₁ q ⟫ ap (λ a → f a b₀) p ∙ h₁ b₀ ∙ ! (h₁ b₁) =⟪ ap (ap (λ a → f a b₀) p ∙_) $ ap (λ k → k h₀) $ transp-naturality {B = λ a → ∀ b → f a b == c} (λ h → h b₀ ∙ ! (h b₁)) p ⟫ ap (λ a → f a b₀) p ∙ transport (λ a → f a b₀ == f a b₁) p (h₀ b₀ ∙ ! (h₀ b₁)) =⟪ ! (ap-transp (λ a → f a b₀) (λ a → f a b₁) p (h₀ b₀ ∙ ! (h₀ b₁))) ⟫ (h₀ b₀ ∙ ! (h₀ b₁)) ∙ ap (λ a → f a b₁) p =⟪ ! (ap (_∙ ap (λ a → f a b₁) p) $ (ap-null-homotopic (λ b → f a₀ b) h₀ q)) ⟫ ap (λ z → f a₀ z) q ∙ ap (λ a → f a b₁) p ∎∎ where h₁ : ∀ b → f a₁ b == c h₁ = transport (λ a → ∀ b → f a b == c) p h₀ ap-comm-cst-coh : {a₀ a₁ : A} (p : a₀ == a₁) {b₀ b₁ : B} (q : b₀ == b₁) (c : C) (h₀ : ∀ b → f a₀ b == c) → ap-comm p q ◃∎ =ₛ ap-comm-cst-seq p q c h₀ ap-comm-cst-coh p@idp {b₀} q@idp c h₀ = =ₛ-in $ ! $ ap (idp ∙_) (! (!-inv-r (h₀ b₀))) ∙ ! (∙-unit-r (h₀ b₀ ∙ ! (h₀ b₀))) ∙ ! (ap (_∙ idp) (! (!-inv-r (h₀ b₀)))) =⟨ ap (_∙ ! (∙-unit-r (h₀ b₀ ∙ ! (h₀ b₀))) ∙ ! (ap (_∙ idp) (! (!-inv-r (h₀ b₀))))) (ap-idf (! (!-inv-r (h₀ b₀)))) ⟩ ! (!-inv-r (h₀ b₀)) ∙ ! (∙-unit-r (h₀ b₀ ∙ ! (h₀ b₀))) ∙ ! (ap (_∙ idp) (! (!-inv-r (h₀ b₀)))) =⟨ ap (λ v → ! (!-inv-r (h₀ b₀)) ∙ ! (∙-unit-r (h₀ b₀ ∙ ! (h₀ b₀))) ∙ v) (!-ap (_∙ idp) (! (!-inv-r (h₀ b₀)))) ⟩ ! (!-inv-r (h₀ b₀)) ∙ ! (∙-unit-r (h₀ b₀ ∙ ! (h₀ b₀))) ∙ ap (_∙ idp) (! (! (!-inv-r (h₀ b₀)))) =⟨ ap (! (!-inv-r (h₀ b₀)) ∙_) $ ! $ =ₛ-out $ homotopy-naturality-from-idf (_∙ idp) (λ p → ! (∙-unit-r p)) (! (! (!-inv-r (h₀ b₀)))) ⟩ ! (!-inv-r (h₀ b₀)) ∙ ! (! (!-inv-r (h₀ b₀))) ∙ idp =⟨ ap (! (!-inv-r (h₀ b₀)) ∙_) (∙-unit-r (! (! (!-inv-r (h₀ b₀))))) ⟩ ! (!-inv-r (h₀ b₀)) ∙ ! (! (!-inv-r (h₀ b₀))) =⟨ !-inv-r (! (!-inv-r (h₀ b₀))) ⟩ idp =∎ module _ {i j k} {A : Type i} {B : Type j} {C : Type k} where ap-comm-comm : (f : A → B → C) {a₀ a₁ : A} (p : a₀ == a₁) {b₀ b₁ : B} (q : b₀ == b₁) → ap-comm f p q == ! (ap-comm (λ x y → f y x) q p) ap-comm-comm f p@idp q@idp = idp module _ {i} {A : Type i} where -- unsure where this belongs transp-cst=idf : {a x y : A} (p : x == y) (q : a == x) → transport (λ x → a == x) p q == q ∙ p transp-cst=idf idp q = ! (∙-unit-r q) transp-cst=idf-pentagon : {a x y z : A} (p : x == y) (q : y == z) (r : a == x) → transp-cst=idf (p ∙ q) r ◃∎ =ₛ transp-∙ p q r ◃∙ ap (transport (λ x → a == x) q) (transp-cst=idf p r) ◃∙ transp-cst=idf q (r ∙ p) ◃∙ ∙-assoc r p q ◃∎ transp-cst=idf-pentagon idp q idp = =ₛ-in (! (∙-unit-r (transp-cst=idf q idp))) {- for functions with more arguments -} module _ {i₀ i₁ i₂ j} {A₀ : Type i₀} {A₁ : Type i₁} {A₂ : Type i₂} {B : Type j} (f : A₀ → A₁ → A₂ → B) where ap3 : {x₀ y₀ : A₀} {x₁ y₁ : A₁} {x₂ y₂ : A₂} → (x₀ == y₀) → (x₁ == y₁) → (x₂ == y₂) → f x₀ x₁ x₂ == f y₀ y₁ y₂ ap3 idp idp idp = idp module _ {i₀ i₁ i₂ i₃ j} {A₀ : Type i₀} {A₁ : Type i₁} {A₂ : Type i₂} {A₃ : Type i₃} {B : Type j} (f : A₀ → A₁ → A₂ → A₃ → B) where ap4 : {x₀ y₀ : A₀} {x₁ y₁ : A₁} {x₂ y₂ : A₂} {x₃ y₃ : A₃} → (x₀ == y₀) → (x₁ == y₁) → (x₂ == y₂) → (x₃ == y₃) → f x₀ x₁ x₂ x₃ == f y₀ y₁ y₂ y₃ ap4 idp idp idp idp = idp module _ {i₀ i₁ i₂ i₃ i₄ j} {A₀ : Type i₀} {A₁ : Type i₁} {A₂ : Type i₂} {A₃ : Type i₃} {A₄ : Type i₄} {B : Type j} (f : A₀ → A₁ → A₂ → A₃ → A₄ → B) where ap5 : {x₀ y₀ : A₀} {x₁ y₁ : A₁} {x₂ y₂ : A₂} {x₃ y₃ : A₃} {x₄ y₄ : A₄} → (x₀ == y₀) → (x₁ == y₁) → (x₂ == y₂) → (x₃ == y₃) → (x₄ == y₄) → f x₀ x₁ x₂ x₃ x₄ == f y₀ y₁ y₂ y₃ y₄ ap5 idp idp idp idp idp = idp module _ {i₀ i₁ i₂ i₃ i₄ i₅ j} {A₀ : Type i₀} {A₁ : Type i₁} {A₂ : Type i₂} {A₃ : Type i₃} {A₄ : Type i₄} {A₅ : Type i₅} {B : Type j} (f : A₀ → A₁ → A₂ → A₃ → A₄ → A₅ → B) where ap6 : {x₀ y₀ : A₀} {x₁ y₁ : A₁} {x₂ y₂ : A₂} {x₃ y₃ : A₃} {x₄ y₄ : A₄} {x₅ y₅ : A₅} → (x₀ == y₀) → (x₁ == y₁) → (x₂ == y₂) → (x₃ == y₃) → (x₄ == y₄) → (x₅ == y₅) → f x₀ x₁ x₂ x₃ x₄ x₅ == f y₀ y₁ y₂ y₃ y₄ y₅ ap6 idp idp idp idp idp idp = idp
TP2/fun:average.asm
kuoa/assembly-misc
0
160257
<filename>TP2/fun:average.asm .data tab: .word 10, 20, 10, 10, -1 .text main: #prolog addiu $29, $29, -12 sw $31, 8($29) #body la $4, tab #&tab jal arimean or $4, $2, $0 #res ori $2, $0, 1 syscall #print rez ori $2, $0, 10 syscall #epilog lw $31, 8($29) addiu $29, $29, 12 jr $31 ################################################################ arimean: #WORKS! #epilog addiu $29, $29, -16 sw $31, 12($29) sw $11, 8($29) sw $12, 4($29) #body #$4 contains &t jal sizetab or $11, $2, $0 #$11 <- sizetab($4) jal sumtab or $12, $2, $0 #12 <- sumtab($4) div $12, $11 mflo $2 #take quotient #prolog lw $31, 12($29) lw $11, 8($29) lw $12, 4($29) addiu $29, $29, 16 jr $31 ################################################################ sizetab: #WORKS! #epilog addiu $29, $29, -16 sw $31, 12($29) sw $10, 8($29) sw $11, 4($29) #body #$4 contains &tab or $10, $4, $0 #&tab ++ ori $2, $0, 0 #index loop_stab: lw $11, 0($10) bltz $11 end_loop_stab #if <0 end addiu $2, $2, 1 addiu $10, $10, 4 # i++ j loop_stab end_loop_stab: #prolog lw $31, 12($29) lw $10, 8($29) lw $11, 4($29) addiu $29, $29, 16 jr $31 ################################################################ sumtab: #WORKS! addiu $29, $29, -20 sw $31, 16($29) sw $10, 12($29) sw $11, 8($29) #body #$4 contains &tab or $10, $4, $0 #&index ori $11, $0, 0 #t[index] ori $2, $0, 0 loop: lw $11, 0($10) bltz $11 end_loop #if <0 end addu $2, $2, $11 addiu $10, $10, 4 # i++ j loop end_loop: lw $31, 16($29) lw $10, 12($29) lw $11, 8($29) addiu $29, $29, 20 jr $31
division.asm
SuiGeneris01/emu8086
3
81572
<filename>division.asm org 100h INCLUDE "EMU8086.INC" MOV DX, OFFSET MAIN MOV AH, 9 INT 21H MOV DX, OFFSET MSG1 MOV AH, 9 INT 21H CALL SCAN_NUM MOV RADIUS, CX MOV AX, NUM MUL RADIUS MUL RADIUS MUL RADIUS MOV DX, 0 DIV DEN ; ax = (dx ax) / DEN. LEA SI, MSG3 CALL PRINT_STRING CALL PRINT_NUM MOV AH, 0 CMP DX, 0 JE EXIT MOV AX, DX ; DX CONTAINS THE REMAINDER OF THE DIVISION LEA SI, SPACE CALL PRINT_STRING CALL PRINT_NUM LEA SI, SLASH CALL PRINT_STRING MOV AX,DEN CALL PRINT_NUM JMP EXIT EXIT: ret NUM DW 22 RADIUS DW ? DEN DW 7 SPACE DB " ",0 SLASH DB "/",0 MAIN DB "THE PROGRAM CALUATES PIE * R^3. $" MSG1 DB 13,10, "ENTER THE NUMERATOR: $" MSG3 DB 13,10, "THE RESULT IS : ", 0 DEFINE_SCAN_NUM DEFINE_PRINT_NUM DEFINE_PRINT_NUM_UNS DEFINE_PRINT_STRING RET
src/Polynomial/NormalForm/Operations.agda
mckeankylej/agda-ring-solver
36
849
{-# OPTIONS --without-K --safe #-} open import Polynomial.Parameters open import Algebra module Polynomial.NormalForm.Operations {a ℓ} (coeffs : RawCoeff a ℓ) where open import Polynomial.Exponentiation (RawCoeff.coeffs coeffs) open import Data.Nat as ℕ using (ℕ; suc; zero; compare) open import Data.Nat.Properties using (z≤′n) open import Data.List using (_∷_; []) open import Data.Fin using (Fin) open import Data.Product using (_,_; map₁) open import Induction.WellFounded using (Acc; acc) open import Induction.Nat using (<′-wellFounded) open import Polynomial.NormalForm.InjectionIndex open import Polynomial.NormalForm.Definition coeffs open import Polynomial.NormalForm.Construction coeffs open RawCoeff coeffs ---------------------------------------------------------------------- -- Addition ---------------------------------------------------------------------- -- The reason the following code is so verbose is termination -- checking. For instance, in the third case for ⊞-coeffs, we call a -- helper function. Instead, you could conceivably use a with-block -- (on ℕ.compare p q): -- -- ⊞-coeffs ((x , p) ∷ xs) ((y , q) ∷ ys) with (ℕ.compare p q) -- ... | ℕ.less p k = (x , p) ∷ ⊞-coeffs xs ((y , k) ∷ ys) -- ... | ℕ.equal p = (fst~ x ⊞ fst~ y , p) ∷↓ ⊞-coeffs xs ys -- ... | ℕ.greater q k = (y , q) ∷ ⊞-coeffs ((x , k) ∷ xs) ys -- -- However, because the first and third recursive calls each rewrap -- a list that was already pattern-matched on, the recursive call -- does not strictly decrease the size of its argument. -- -- Interestingly, if --without-K is turned off, we don't need the -- helper function ⊞-coeffs; we could pattern match on _⊞_ directly. -- -- _⊞_ {zero} (lift x) (lift y) = lift (x + y) -- _⊞_ {suc n} [] ys = ys -- _⊞_ {suc n} (x ∷ xs) [] = x ∷ xs -- _⊞_ {suc n} ((x , p) ∷ xs) ((y , q) ∷ ys) = -- ⊞-zip (ℕ.compare p q) x xs y ys mutual infixl 6 _⊞_ _⊞_ : ∀ {n} → Poly n → Poly n → Poly n (xs Π i≤n) ⊞ (ys Π j≤n) = ⊞-match (inj-compare i≤n j≤n) xs ys ⊞-match : ∀ {i j n} → {i≤n : i ≤′ n} → {j≤n : j ≤′ n} → InjectionOrdering i≤n j≤n → FlatPoly i → FlatPoly j → Poly n ⊞-match (inj-eq i&j≤n) (Κ x) (Κ y) = Κ (x + y) Π i&j≤n ⊞-match (inj-eq i&j≤n) (Σ (x Δ i & xs)) (Σ (y Δ j & ys)) = ⊞-zip (compare i j) x xs y ys Π↓ i&j≤n ⊞-match (inj-lt i≤j-1 j≤n) xs (Σ ys) = ⊞-inj i≤j-1 xs ys Π↓ j≤n ⊞-match (inj-gt i≤n j≤i-1) (Σ xs) ys = ⊞-inj j≤i-1 ys xs Π↓ i≤n ⊞-inj : ∀ {i k} → (i ≤′ k) → FlatPoly i → Coeff k + → Coeff k * ⊞-inj i≤k xs (y Π j≤k ≠0 Δ zero & ys) = ⊞-match (inj-compare j≤k i≤k) y xs Δ zero ∷↓ ys ⊞-inj i≤k xs (y Δ suc j & ys) = xs Π i≤k Δ zero ∷↓ ∹ y Δ j & ys ⊞-coeffs : ∀ {n} → Coeff n * → Coeff n * → Coeff n * ⊞-coeffs (∹ x Δ i & xs) ys = ⊞-zip-r x i xs ys ⊞-coeffs [] ys = ys ⊞-zip : ∀ {p q n} → ℕ.Ordering p q → NonZero n → Coeff n * → NonZero n → Coeff n * → Coeff n * ⊞-zip (ℕ.less i k) x xs y ys = (∹ x Δ i & ⊞-zip-r y k ys xs) ⊞-zip (ℕ.greater j k) x xs y ys = (∹ y Δ j & ⊞-zip-r x k xs ys) ⊞-zip (ℕ.equal i ) x xs y ys = (x .poly ⊞ y .poly) Δ i ∷↓ ⊞-coeffs xs ys ⊞-zip-r : ∀ {n} → NonZero n → ℕ → Coeff n * → Coeff n * → Coeff n * ⊞-zip-r x i xs [] = ∹ x Δ i & xs ⊞-zip-r x i xs (∹ y Δ j & ys) = ⊞-zip (compare i j) x xs y ys {-# INLINE ⊞-zip #-} ---------------------------------------------------------------------- -- Negation ---------------------------------------------------------------------- -- recurse on acc directly -- https://github.com/agda/agda/issues/3190#issuecomment-416900716 ⊟-step : ∀ {n} → Acc _<′_ n → Poly n → Poly n ⊟-step (acc wf) (Κ x Π i≤n) = Κ (- x) Π i≤n ⊟-step (acc wf) (Σ xs Π i≤n) = poly-map (⊟-step (wf _ i≤n)) xs Π↓ i≤n ⊟_ : ∀ {n} → Poly n → Poly n ⊟_ = ⊟-step (<′-wellFounded _) {-# INLINE ⊟_ #-} ---------------------------------------------------------------------- -- Multiplication ---------------------------------------------------------------------- mutual ⊠-step′ : ∀ {n} → Acc _<′_ n → Poly n → Poly n → Poly n ⊠-step′ a (x Π i≤n) = ⊠-step a x i≤n ⊠-step : ∀ {i n} → Acc _<′_ n → FlatPoly i → i ≤′ n → Poly n → Poly n ⊠-step a (Κ x) _ = ⊠-Κ a x ⊠-step a (Σ xs) = ⊠-Σ a xs ⊠-Κ : ∀ {n} → Acc _<′_ n → Carrier → Poly n → Poly n ⊠-Κ (acc _ ) x (Κ y Π i≤n) = Κ (x * y) Π i≤n ⊠-Κ (acc wf) x (Σ xs Π i≤n) = ⊠-Κ-inj (wf _ i≤n) x xs Π↓ i≤n ⊠-Σ : ∀ {i n} → Acc _<′_ n → Coeff i + → i <′ n → Poly n → Poly n ⊠-Σ (acc wf) xs i≤n (Σ ys Π j≤n) = ⊠-match (acc wf) (inj-compare i≤n j≤n) xs ys ⊠-Σ (acc wf) xs i≤n (Κ y Π _) = ⊠-Κ-inj (wf _ i≤n) y xs Π↓ i≤n ⊠-Κ-inj : ∀ {i} → Acc _<′_ i → Carrier → Coeff i + → Coeff i * ⊠-Κ-inj a x xs = poly-map (⊠-Κ a x) (xs) ⊠-Σ-inj : ∀ {i k} → Acc _<′_ k → i <′ k → Coeff i + → Poly k → Poly k ⊠-Σ-inj (acc wf) i≤k x (Σ y Π j≤k) = ⊠-match (acc wf) (inj-compare i≤k j≤k) x y ⊠-Σ-inj (acc wf) i≤k x (Κ y Π j≤k) = ⊠-Κ-inj (wf _ i≤k) y x Π↓ i≤k ⊠-match : ∀ {i j n} → Acc _<′_ n → {i≤n : i <′ n} → {j≤n : j <′ n} → InjectionOrdering i≤n j≤n → Coeff i + → Coeff j + → Poly n ⊠-match (acc wf) (inj-eq i&j≤n) xs ys = ⊠-coeffs (wf _ i&j≤n) xs ys Π↓ i&j≤n ⊠-match (acc wf) (inj-lt i≤j-1 j≤n) xs ys = poly-map (⊠-Σ-inj (wf _ j≤n) i≤j-1 xs) (ys) Π↓ j≤n ⊠-match (acc wf) (inj-gt i≤n j≤i-1) xs ys = poly-map (⊠-Σ-inj (wf _ i≤n) j≤i-1 ys) (xs) Π↓ i≤n ⊠-coeffs : ∀ {n} → Acc _<′_ n → Coeff n + → Coeff n + → Coeff n * ⊠-coeffs a xs (y ≠0 Δ j & []) = poly-map (⊠-step′ a y) xs ⍓* j ⊠-coeffs a xs (y ≠0 Δ j & ∹ ys) = para (⊠-cons a y ys) xs ⍓* j ⊠-cons : ∀ {n} → Acc _<′_ n → Poly n → Coeff n + → Fold n -- ⊠-cons a y [] (x Π j≤n , xs) = ⊠-step a x j≤n y , xs ⊠-cons a y ys (x Π j≤n , xs) = ⊠-step a x j≤n y , ⊞-coeffs (poly-map (⊠-step a x j≤n) ys) xs {-# INLINE ⊠-Κ #-} {-# INLINE ⊠-coeffs #-} {-# INLINE ⊠-cons #-} infixl 7 _⊠_ _⊠_ : ∀ {n} → Poly n → Poly n → Poly n _⊠_ = ⊠-step′ (<′-wellFounded _) {-# INLINE _⊠_ #-} ---------------------------------------------------------------------- -- Constants and Variables ---------------------------------------------------------------------- -- The constant polynomial κ : ∀ {n} → Carrier → Poly n κ x = Κ x Π z≤′n {-# INLINE κ #-} -- A variable ι : ∀ {n} → Fin n → Poly n ι i = (κ 1# Δ 1 ∷↓ []) Π↓ Fin⇒≤ i {-# INLINE ι #-} ---------------------------------------------------------------------- -- Exponentiation ---------------------------------------------------------------------- -- We try very hard to never do things like multiply by 1 -- unnecessarily. That's what all the weirdness here is for. ⊡-mult : ∀ {n} → ℕ → Poly n → Poly n ⊡-mult zero xs = xs ⊡-mult (suc n) xs = ⊡-mult n xs ⊠ xs _⊡_+1 : ∀ {n} → Poly n → ℕ → Poly n (Κ x Π i≤n) ⊡ i +1 = Κ (x ^ i +1) Π i≤n (Σ (x Δ j & []) Π i≤n) ⊡ i +1 = x .poly ⊡ i +1 Δ (j ℕ.+ i ℕ.* j) ∷↓ [] Π↓ i≤n xs@(Σ (_ & ∹ _) Π i≤n) ⊡ i +1 = ⊡-mult i xs infixr 8 _⊡_ _⊡_ : ∀ {n} → Poly n → ℕ → Poly n _ ⊡ zero = κ 1# xs ⊡ suc i = xs ⊡ i +1 {-# INLINE _⊡_ #-}
Driver/Printer/Fax/FaxPrint/faxprintDeviceInfo.asm
steakknife/pcgeos
504
175300
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Geoworks 1994. All rights reserved. GEOWORKS CONFIDENTIAL PROJECT: Tiramisu MODULE: Fax 2.2 FILE: faxprintDeviceInfo.asm AUTHOR: <NAME>, Mar 10, 1993 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- jag 3/10/93 Initial revision AC 9/ 8/93 Changed for Group3 jdashe 10/19/94 Modified for tiramisu DESCRIPTION: $Id: faxprintDeviceInfo.asm,v 1.1 97/04/18 11:53:03 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ;---------------------------------------------------------------------------- ; Fax Print Device Info ;---------------------------------------------------------------------------- DeviceInfo segment resource faxPrintDeviceInfo PrinterInfo \ < ; ; PrinterType ; < PT_RASTER, BMF_MONO >, ; ; PrinterConnections ; < IC_NO_IEEE488, CC_CUSTOM, SC_NO_SCSI, RC_NO_RS232C, CC_NO_CENTRONICS, FC_NO_FILE, AC_NO_APPLETALK >, ; ; PrinterSmart ; PS_DUMB_RASTER, ; ; Custom entry routine ; NULL, ; ; Custom exit routine ; NULL, ; ; Mode info (GraphicsProperties) offsets ; offset faxStdRes, ; low NULL, ; med offset faxFineRes, ; high NULL, ; text draft NULL, ; text NLQ ; ; Font geometry ; NULL, ; ; Font symbol set list ; NULL, ; ; PaperMargins ; < PR_MARGIN_LEFT, ; Tractor PR_MARGIN_TRACTOR, PR_MARGIN_RIGHT, PR_MARGIN_TRACTOR >, < PR_MARGIN_LEFT, ; Tractor PR_MARGIN_TRACTOR, PR_MARGIN_RIGHT, PR_MARGIN_TRACTOR >, ; ; PaperInputOptions ; < MF_NO_MANUAL, TF_NO_TRACTOR, ASF_TRAY1>, ; ; PaperOutputOptions ; < OC_NO_COPIES, PS_REVERSE, OD_SIMPLEX, SO_NO_STAPLER, OS_NO_SORTER, OB_OUTPUTBIN1>, ; ; PI_paperWidth ; 612, ; max. paper size ; ; UI stuff ; NULL, ; Main UI NULL, ; Options UI NULL ; UI eval routine > public faxPrintDeviceInfo ;---------------------------------------------------------------------------- ; Graphics Modes Info ;---------------------------------------------------------------------------- faxStdRes GraphicsProperties < \ FAX_X_RES, ; xres FAX_STD_Y_RES, ; yres FAX_STD_RES_BAND_HEIGHT, FAX_STD_RES_BYTES_COLUMN, ; bytes/column FAX_STD_RES_INTERLEAVE_FACTOR, ; # interleaves BMF_MONO, ; color format NULL> ; color correction faxFineRes GraphicsProperties < \ FAX_X_RES, ; xres FAX_FINE_Y_RES, ; yres FAX_FINE_RES_BAND_HEIGHT, FAX_FINE_RES_BYTES_COLUMN, ; bytes/column FAX_FINE_RES_INTERLEAVE_FACTOR, ; # interleaves BMF_MONO, ; color format NULL> ; color correction DeviceInfo ends
oeis/164/A164412.asm
neoneye/loda-programs
11
10241
; A164412: Number of binary strings of length n with no substrings equal to 0000 0001 or 0111. ; Submitted by <NAME>(s2) ; 13,22,37,60,98,160,259,420,681,1102,1784,2888,4673,7562,12237,19800,32038,51840,83879,135720,219601,355322,574924,930248,1505173,2435422,3940597,6376020,10316618,16692640,27009259,43701900,70711161,114413062,185124224,299537288,484661513,784198802,1268860317,2053059120,3321919438,5374978560,8696897999,14071876560,22768774561,36840651122,59609425684,96450076808,156059502493,252509579302,408569081797,661078661100,1069647742898,1730726404000,2800374146899,4531100550900,7331474697801,11862575248702 add $0,6 seq $0,204 ; Lucas numbers (beginning with 1): L(n) = L(n-1) + L(n-2) with L(1) = 1, L(2) = 3. div $0,2 sub $0,1
Task/Variables/AppleScript/variables-4.applescript
LaudateCorpus1/RosettaCodeData
1
1197
<reponame>LaudateCorpus1/RosettaCodeData property x : 1
src/boot.asm
Qunapi/YesOS
6
9049
use16 org 0x7C00 LOAD_SEGMENT = 0x1010 FAT_SEGMENT = 0x0EE0 FAT_DATA_SEGMENT = 0x07E0 KERNEL_SEGMENT = 0x0900 main: jmp start bootsector: iOEM: db "YesOS " iSectSize: dw 0x200 iClustSize: db 1 iResSect: dw 1 iFatCnt: db 2 iRootSize: dw 224 iTotalSect: dw 2880 iMedia: db 0xF0 iFatSize: dw 9 iTrackSect: dw 18 iHeadCnt: dw 2 iHiddenSect: dd 0 iSect32: dd 0 iBootDrive: db 0 iReserved: db 0 iBootSign: db 0x29 iVolID: db "seri" acVolLabel: db "MYVOLUME " acFSType: db "FAT12 " include "macros.asm" start: ;=================================================================================== ; INIT SEGMENTS ;=================================================================================== cli mov [iBootDrive], dl mov sp, 0x7c00 sti mov ax, 42h mov dx, SetIntHandler pushf call 0x0000:SetIntHandler mov ax, 40h mov dx, loadFileByName int 42h mov ax, FAT_DATA_SEGMENT mov es, ax mWriteString loadmsg ;=================================================================================== ; LOAD FILES NAMES ;=================================================================================== mov ax, 32 xor dx, dx mul word [iRootSize] div word [iSectSize] mov cx, ax mov [root_sectors], cx xor ax, ax mov al, byte [iFatCnt] mov bx, word [iFatSize] mul bx add ax, word [iResSect] mov [root_start], ax xor bx, bx call ReadSector ;=================================================================================== ; LOAD KERNEL ;=================================================================================== mov [loadSegment], word KERNEL_SEGMENT mov ax, kernelName int 40h mov [loadSegment], word LOAD_SEGMENT jmp FAT_DATA_SEGMENT:1200;KERNEL_SEGMENT:0 ;=================================================================================== ; LOAD FILE NAME AX - LOAD FILE NAME ;=================================================================================== ;=================================================================================== ; SET FILE START ;=================================================================================== loadFileByName: push es mov si, ax mov ax, fileName mov di, ax mov cx, 11 xor ax, ax mov es, ax rep movsb pop es push es push ds xor ax, ax mov ds, ax xor bx, bx jmp check_entry read_next_sector: push cx push ax xor bx, bx call ReadSector check_entry: mov cx, 11 mov di, bx lea si, [fileName] repz cmpsb je found_file add bx, 32 cmp bx, word [iSectSize] jne check_entry pop ax inc ax pop cx loopnz read_next_sector jmp bootFailure found_file: mov ax, [es:bx+0x1a] mov [file_strt], ax ;=================================================================================== ; READ & LOAD FAT TABLE ;=================================================================================== mov ax, FAT_SEGMENT mov es, ax mov ax, word [iResSect] mov cx, word [iFatSize] xor bx, bx read_next_fat_sector: call ReadSector inc ax add bx, word [iSectSize] loopnz read_next_fat_sector ;=================================================================================== ; READ FILE ;=================================================================================== mov ax, [loadSegment] mov es, ax xor bx, bx mov cx, [file_strt] read_file_next_sector: mov ax, cx add ax, [root_start] add ax, [root_sectors] sub ax, 2 push cx call ReadSector pop cx add bx, [iSectSize] push ds mov dx, FAT_SEGMENT mov ds, dx mov si, cx mov dx, cx shr dx, 1 add si, dx mov dx, [ds:si] test dx, 1 jz read_next_file_even and dx, 0x0fff jmp read_next_file_cluster_done read_next_file_even: shr dx, 4 read_next_file_cluster_done: pop ds mov cx, dx cmp cx, 0xff8 jl read_file_next_sector pop ds pop es iret ;=================================================================================== ; GO KERNEL ;=================================================================================== SetIntHandler: push es xor bx, bx mov es, bx xor ah, ah shl ax, 2 mov di, ax mov [es:di], dx mov [es:di+2], ds pop es iret bootFailure: mWriteString diskerror call Reboot jmp $ include "functions.asm" kernelName: db "KERNEL IMG" diskerror: db "Disk error",0 loadmsg: db "Loading OS",0; fileName: db 11 dup ? loadSegment: dw ? root_start: db 0,0 root_sectors: db 0,0 file_strt: db 0,0 times 510-($-$$) db 0 BootMagic dw 0xAA55
mc-sema/validator/x86_64/tests/UCOMISSrm.asm
randolphwong/mcsema
2
175866
BITS 64 ;TEST_FILE_META_BEGIN ;TEST_TYPE=TEST_F ;TEST_IGNOREFLAGS= ;TEST_FILE_META_END ; put 2 into ecx for future load into xmm0 mov ecx, 2 cvtsi2ss xmm0, ecx mov ecx, 0 cvtsi2ss xmm1, ecx ;TEST_BEGIN_RECORDING lea rcx, [rsp-4] movss [rcx], xmm1 ucomiss xmm0, [rcx] mov ecx, 0 ;TEST_END_RECORDING cvtsi2ss xmm0, ecx cvtsi2ss xmm1, ecx
src/tests/bintoasc_suite-base16_tests.ads
jhumphry/Ada_BinToAsc
0
17071
<gh_stars>0 -- BinToAsc_Suite.Base16_Tests -- Unit tests for BinToAsc -- Copyright (c) 2015, <NAME> - see LICENSE file for details with AUnit; use AUnit; with AUnit.Test_Cases; use AUnit.Test_Cases; with RFC4648; with BinToAsc_Suite.Utils; package BinToAsc_Suite.Base16_Tests is Base16_Test_Vectors : constant Test_Vector_Array := ((TBS(""), TBS("")), (TBS("f"), TBS("66")), (TBS("fo"), TBS("666F")), (TBS("foo"), TBS("666F6F")), (TBS("foob"), TBS("666F6F62")), (TBS("fooba"), TBS("666F6F6261")), (TBS("foobar"), TBS("666F6F626172"))); type Base16_Test is new Test_Cases.Test_Case with null record; procedure Register_Tests (T: in out Base16_Test); function Name (T : Base16_Test) return Test_String; procedure Set_Up (T : in out Base16_Test); procedure Check_Symmetry is new BinToAsc_Suite.Utils.Check_Symmetry(BToA => RFC4648.BToA, Codec_To_String => RFC4648.Base16.Base16_To_String, Codec_To_Bin => RFC4648.Base16.Base16_To_Bin); procedure Check_Length is new BinToAsc_Suite.Utils.Check_Length(BToA => RFC4648.BToA, Codec_To_String => RFC4648.Base16.Base16_To_String, Codec_To_Bin => RFC4648.Base16.Base16_To_Bin); procedure Check_Test_Vectors_To_String is new BinToAsc_Suite.Utils.Check_Test_Vectors_To_String(Test_Vectors => Base16_Test_Vectors, Codec_To_String => RFC4648.Base16.Base16_To_String); procedure Check_Test_Vectors_To_Bin is new BinToAsc_Suite.Utils.Check_Test_Vectors_To_Bin(Test_Vectors => Base16_Test_Vectors, Codec_To_Bin => RFC4648.Base16.Base16_To_Bin); procedure Check_Test_Vectors_Incremental_To_String is new BinToAsc_Suite.Utils.Check_Test_Vectors_Incremental_To_String(Test_Vectors => Base16_Test_Vectors, Codec_To_String => RFC4648.Base16.Base16_To_String, Max_Buffer_Length => 20); procedure Check_Test_Vectors_Incremental_To_Bin is new BinToAsc_Suite.Utils.Check_Test_Vectors_Incremental_To_Bin(Test_Vectors => Base16_Test_Vectors, Codec_To_Bin => RFC4648.Base16.Base16_To_Bin, Max_Buffer_Length => 20); procedure Check_Test_Vectors_By_Char_To_String is new BinToAsc_Suite.Utils.Check_Test_Vectors_By_Char_To_String(Test_Vectors => Base16_Test_Vectors, Codec_To_String => RFC4648.Base16.Base16_To_String, Max_Buffer_Length => 20); procedure Check_Test_Vectors_By_Char_To_Bin is new BinToAsc_Suite.Utils.Check_Test_Vectors_By_Char_To_Bin(Test_Vectors => Base16_Test_Vectors, Codec_To_Bin => RFC4648.Base16.Base16_To_Bin, Max_Buffer_Length => 20); procedure Check_Junk_Rejection (T : in out Test_Cases.Test_Case'Class); procedure Check_Junk_Rejection_By_Char (T : in out Test_Cases.Test_Case'Class); procedure Check_Incomplete_Group_Rejection (T : in out Test_Cases.Test_Case'Class); procedure Check_Case_Insensitive (T : in out Test_Cases.Test_Case'Class); end BinToAsc_Suite.Base16_Tests;
base/mvdm/wow16/kernel31/enable.asm
npocmaka/Windows-Server-2003
17
84177
<gh_stars>10-100 .xlist include kernel.inc include pdb.inc include tdb.inc include newexe.inc ifdef WOW include vint.inc endif .list externFP KillLibraries ifndef WOW externFP WriteOutProfiles endif DataBegin externB PhantArray externB kernel_flags externB fBreak externB fInt21 ifndef WOW externB fProfileMaybeStale endif externW curTDB externW headPDB externW topPDB externD lpInt21 externD pSftLink externD lpWinSftLink externD pSysProc externD pMouseTermProc externD pKeyboardTermProc externD pSystemTermProc externW MyCSAlias externD myInt2F DataEnd sBegin CODE assumes CS,CODE assumes ds, nothing assumes es, nothing externD prevInt00Proc externD prevInt21Proc externD prevInt24Proc externD prevInt2FProc externD prevInt3FProc externD prevInt67Proc externD prevInt02Proc externD prevInt04Proc externD prevInt06Proc externD prevInt07Proc externD prevInt3EProc externD prevInt75Proc externD prevInt0CProc externD prevInt0DProc externD prevIntx6Proc externD prevInt0EProc ifdef WOW externD prevInt01proc externD prevInt03proc externD oldInt00proc endif externNP real_DOS externNP Enter_gmove_stack externNP TerminatePDB ;-----------------------------------------------------------------------; ; InternalEnableDOS ; ; ; Entry: ; none ; Returns: ; ; Registers Destroyed: ; ; History: ; Thu 21-Sep-1989 20:44:48 -by- <NAME> [davidw] ; Added this nifty comment block. ;-----------------------------------------------------------------------; SetWinVec MACRO vec externFP Int&vec&Handler mov dx, codeoffset Int&vec&Handler mov ax, 25&vec&h pushf call prevInt21Proc endm assumes ds, nothing assumes es, nothing cProc InternalEnableDOS,<PUBLIC,FAR> cBegin nogen push si push ds SetKernelDS mov al,1 xchg al,fInt21 ; set hook count to 1 or al,al ; was it zero? jz @f jmp ena21 ; no, just leave @@: ; now link back nodes to SFT if kernel had done it before. InternalDisableDOS ; saves the link in the DWORD variable lpWinSftLink. If this variable is NULL ; then either this is the first time InternalEnableDOS is being called or ; else the SFT had not been grown. cmp lpWinSftLink.sel,0 ;was it allocated ? jz @f ;no. push ds ;save mov cx,lpWinSftLink.sel ;get the selector mov dx,lpWinSftLink.off ;get the offset lds bx,[pSftLink] ;place where we hooked new entry mov word ptr ds:[bx][0],dx ;restore offset mov word ptr ds:[bx][2],cx ;restore segment pop ds ;restore data segment @@: ; WARNING!! The ^C setting diddle MUST BE FIRST IN HERE...... ; If you do some other INT 21 call before this you will have ; a "^C window", so don't do it.... mov ax,3301h ; disable ^C checking mov dl,0 call real_DOS mov bx,TopPDB mov ah,50h call real_DOS ; This way, or TDB_PDB gets set wrong ifndef WOW ends1: mov ah,6 ; clean out any pending keys mov dl,0FFh call real_DOS jnz ends1 endif mov es,curTDB mov bx,es:[TDB_PDB] mov ah,50h int 21h push ds lds dx,myInt2F mov ax,252Fh int 21h smov ds,cs ; Pick up executable sel/seg UnSetKernelDS SetWinVec 24 SetWinVec 00 SetWinVec 02 SetWinVec 04 SetWinVec 06 SetWinVec 07 SetWinVec 3E SetWinVec 75 pop ds ReSetKernelDS mov bx,2 ; 2 = Enable/Disable one drive logic xor ax,ax ; FALSE = Disable cCall [pSysProc],<bx,ax> ; NOTE: destroys ES if DOS < 3.20 ; Set up the PhantArray by calling inquire system for each drive letter mov bx,dataOffset PhantArray + 25 ; Array index mov cx,26 ; Drive # SetPhant: dec cx push cx push bx mov dx,1 ; InquireSystem cCall [pSysProc],<dx,cx> pop bx pop cx mov byte ptr [bx],0 ; Assume not Phantom cmp ax,2 jae NotPhant ; Assumption correct ; or dx,dx ; Drive just invalid? ; jz NotPhant ; Yes, assumption correct mov byte ptr [bx],dl ; Drive is phantom NotPhant: dec bx ; Next array element jcxz phant_done jmp SetPhant phant_done: lds dx,lpInt21 UnSetKernelDS mov ax,2521h int 21h ena21: pop ds pop si ret cEnd nogen ;-----------------------------------------------------------------------; ; InternalDisableDOS ; ; ; ; ; ; Arguments: ; ; ; ; Returns: ; ; ; ; Error Returns: ; ; ; ; Registers Preserved: ; ; ; ; Registers Destroyed: ; ; ; ; Calls: ; ; ; ; History: ; ; ; ; Mon Oct 16, 1989 11:04:50 -by- <NAME> [amitc] ; ; InternalDisableDOS now takes away any nodes that kernel would have ; ; added to the SFT. InternalEnableDOS puts the nodes backs. Previously ; ; the delinking was done by DisableKernel, but no one linked it back! ; ; ; ; Sat May 09, 1987 02:00:52p -by- <NAME> [davidw] ; ; Added this nifty comment block. ; ; ; ; Thu Apr 16, 1987 11:32:00p -by- <NAME> [-iris-] ; ; Changed InternalDisableDOS to use real dos for 52h function, since ; ; DosTrap3 doesn't have 52h defined and PassOnThrough will croak if the ; ; current TDB's signature is 0, as it is during exit after the last ; ; task has been deleted. ; ;-----------------------------------------------------------------------; ReSetDOSVec MACRO vec lds dx,PrevInt&vec&proc mov ax,25&vec&h int 21h endm assumes ds, nothing assumes es, nothing cProc InternalDisableDOS,<PUBLIC,FAR> cBegin SetKernelDS es xor ax,ax xchg al,fInt21 ; set hook count to zero or al,al ; was it non zero? jnz @F jmp dis21 ; no, just leave @@: mov bx,2 ; 2 = Enable/Disable one drive logic mov ax,1 ; TRUE = Enable push es cCall pSysProc,<bx,ax> pop es mov ax,3301h ; disable ^C checking mov dl,0 pushf call [prevInt21Proc] mov ax,2521h lds dx,prevInt21Proc pushf call [prevInt21Proc] push es mov ax,352Fh int 21h mov ax,es pop es mov myInt2F.sel,ax mov myInt2F.off,bx ReSetDOSVec 00 ; as a favor in win2 we restored this ReSetDOSVec 24 ReSetDOSVec 2F ReSetDOSVec 02 ReSetDOSVec 04 ReSetDOSVec 06 ReSetDOSVec 07 ReSetDOSVec 3E ReSetDOSVec 75 mov dl,fBreak ; return state of ^C checking mov ax,3301h int 21h dis21: cEnd ;------------------------------------------------------------------ ; ; Ancient WinOldAp hook. ; ;------------------------------------------------------------------ public EnableDOS EnableDOS Label Byte if kdebug krDebugOut DEB_WARN, "Don't call EnableDOS" endif retf ;------------------------------------------------------------------ ; ; Ancient WinOldAp hook. ; ;------------------------------------------------------------------ public DisableDOS DisableDOS Label Byte if kdebug krDebugOut DEB_WARN, "Don't call DisableDOS" endif retf ;------------------------------------------------------------------ ; ; Ancient WinOldAp hook. ; ;------------------------------------------------------------------ public EnableKernel EnableKernel Label Byte if kdebug krDebugOut DEB_WARN, "Don't call EnableKernel" endif retf ;-----------------------------------------------------------------------; ; DisableKernel ; ; ; ; This call is provided as a Kernel service to applications that ; ; wish to totally unhook Windows in order to do something radical ; ; such as save the state of the world and restore it at a later ; ; time. This is similar in many ways to the way OLDAPP support ; ; works, with the addition that it also unhooks the kernel. ; ; ; ; Arguments: ; ; ; ; Returns: ; ; ; ; Error Returns: ; ; ; ; Registers Preserved: ; ; DI,SI,DS ; ; ; ; Registers Destroyed: ; ; ; ; Calls: ; ; ; ; History: ; ; ; ; Sat May 09, 1987 02:34:35p -by- <NAME> [davidw] ; ; Merged changes in. Most of this came from ExitKernel. ; ; ; ; Tue Apr 28, 1987 11:12:00a -by- R.E.O. SpeedWagon [-????-] ; ; Changed to indirect thru PDB to get JFN under DOS 3.x. ; ; ; ; Mon Apr 20, 1987 11:34:00p -by- R.E.O. SpeedWagon [-????-] ; ; Set PDB to topPDB before final int 21/4C; we were sometimes exiting ; ; with a task's PDB, and thus we came back to ExitCall2 instead of ; ; going back to DOS! ; ;-----------------------------------------------------------------------; assumes ds, nothing assumes es, nothing cProc DisableKernel,<PUBLIC,FAR>,<si,di> cBegin SetKernelDS or Kernel_flags[2],KF2_WIN_EXIT ; prevent int 24h dialogs cmp prevInt21Proc.sel,0 je nodisable call InternalDisableDOS nodisable: SetKernelDS mov ax,0203h ; Reset not present fault. mov bl,0Bh mov cx,prevInt3Fproc.sel mov dx,prevInt3Fproc.off int 31h mov ax,0203h ; Reset stack fault. mov bl,0Ch mov cx,prevInt0Cproc.sel mov dx,prevInt0Cproc.off int 31h mov ax,0203h ; Reset GP fault. mov bl,0Dh mov cx,prevInt0Dproc.sel mov dx,prevInt0Dproc.off int 31h mov ax,0203h ; Reset invalid op-code exception. mov bl,06h mov cx,prevIntx6proc.sel mov dx,prevIntx6proc.off int 31h mov ax,0203h ; Reset page fault. mov bl,0Eh mov cx,prevInt0Eproc.sel mov dx,prevInt0Eproc.off int 31h ifdef WOW mov ax,0203h ; Reset divide overflow traps mov bl,00h mov cx,oldInt00proc.sel mov dx,oldInt00proc.off int 31h mov ax,0203h ; Reset single step traps mov bl,01h mov cx,prevInt01proc.sel mov dx,prevInt01proc.off int 31h mov ax,0203h ; Reset breakpoint traps mov bl,03h mov cx,prevInt03proc.sel mov dx,prevInt03proc.off int 31h endif mov dx, [HeadPDB] SetKernelDS es UnSetKernelDS exk1: mov ds,dx cmp dx, [topPDB] ; Skip KERNEL, he is about to get je exk3 ; a 4C stuffed down his throat push ds call TerminatePDB pop ds exk3: mov dx,ds:[PDB_Chain] ; move to next PDB in chain or dx,dx jnz exk1 mov bx,[topPDB] ; set to initial DOS task PDB mov ah,50h ; set PDB function int 21h and Kernel_flags[2],NOT KF2_WIN_EXIT ; prevent int 24h dialogs ; ; Close all files on Kernel's PSP, 'cause we're gonna shrink the SFT and ; quit ourselves afterwards. ; mov ds,[topPDB] mov cx,ds:[PDB_JFN_Length] exk4: mov bx,cx ; close all file handles dec bx cmp bx,5 ; console-related handle? jb exk5 ; yup, don't close it (AUX, etc.) mov ah,3eh int 21h exk5: loop exk4 ; kernel could have added some nodes to the SFT. Delink them by removing ; the link from the last DOS link in the chain. We need to remember the ; current pointer there so that InternalEnableDOS can put it back. lds bx,[pSftLink] ;place where we hooked new entry assumes ds,nothing mov cx,ds ;this could have been unitialized too jcxz exk6 ;if unitialized, nothing to do mov dx,ds:[bx].off ;get the current offset mov cx,ds:[bx].sel ;get the current segment mov ds:[bx].off,-1 ;remove windows SFT link mov ds:[bx].sel, 0 ;remove windows SFT link mov lpWinSftLink.off,dx ;save the offset mov lpWinSftLink.sel,cx ;save the segment exk6: UnSetKernelDS es cEnd ;------------------------------------------------------------------ ; ; ExitKernel -- Bye, bye. ; ;------------------------------------------------------------------ ifndef WOW ; If we are closing down WOW then we don't want to go back to the DOS Prompt ; We want to kill the NTVDM WOW Process - so we don't need/want this code. assumes ds, nothing assumes es, nothing cProc ExitKernel,<PUBLIC,FAR> ; parmW exitcode cBegin nogen SetKernelDS or Kernel_flags[2],KF2_WIN_EXIT ; prevent int 24h dialogs call KillLibraries ; Tell DLLs that the system is exiting mov si,sp mov si,ss:[si+4] ; get exit code ; Call driver termination procs, just to make sure that they have removed ; their interrupt vectors. push si mov ax,word ptr [pMouseTermProc] or ax,word ptr [pMouseTermProc+2] jz trm0 call [pMouseTermProc] CheckKernelDS trm0: mov ax,word ptr [pKeyboardTermProc] or ax,word ptr [pKeyboardTermProc+2] jz trm1 call [pKeyboardTermProc] CheckKernelDS trm1: mov ax,word ptr [pSystemTermProc] or ax,word ptr [pSystemTermProc+2] jz trm2 call [pSystemTermProc] CheckKernelDS trm2: pop si call WriteOutProfiles mov fProfileMaybeStale,1 ; Make sure we check the ; INI file next time around ;;; cCall CloseCachedFiles,<topPDB> ; Close open files and unhook kernel hooks ; get on a stack that's not in EMS land call Enter_gmove_stack cCall DisableKernel CheckKernelDS cmp si,EW_REBOOTSYSTEM ; Reboot windows? jnz exitToDos ifndef WOW mov ax,1600h int 2Fh test al,7Fh jz NotRunningEnhancedMode cmp al,1 je exitToDos ;RunningWindows3862x cmp al,-1 je exitToDos ;RunningWindows3862x xor di,di ; Zero return regs mov es,di mov bx,0009h ; Reboot device ID mov ax,1684h ; Get device API entry point int 2Fh mov ax,es or ax,di jz exitToDos ; Reboot vxd not loaded. Exit to dos ; Call the reboot function mov ax,0100h push es push di mov bx,sp call DWORD PTR ss:[bx] jmp short exitToDos ; Reboot didn't work just exit to dos NotRunningEnhancedMode: endif ; WOW mov ah, 0Dh ; Disk Reset so that Smartdrv etc buffers int 21h ; are written to disk mov ax, 0FE03h ; Flush Norton NCache mov si, "CF" mov di, "NU" stc ; Yes! Really set carry too! int 2Fh int 19h ; Reboot via int 19h exitToDos: mov ax,si mov ah,4Ch ; Leave Windows. int 21h cEnd nogen endif ; NOT WOW sEnd CODE end
sources/webgl/opengl-renderbuffers.adb
godunko/adagl
6
19859
<filename>sources/webgl/opengl-renderbuffers.adb ------------------------------------------------------------------------------ -- -- -- Ada binding for OpenGL/WebGL -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016-2018, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the <NAME>, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with OpenGL.Contexts.Internals; package body OpenGL.Renderbuffers is use type WebAPI.WebGL.Renderbuffers.WebGL_Renderbuffer_Access; use type WebAPI.WebGL.Rendering_Contexts.WebGL_Rendering_Context_Access; ---------- -- Bind -- ---------- function Bind (Self : in out OpenGL_Renderbuffer'Class) return Boolean is begin if Self.Context = null or Self.Context /= OpenGL.Contexts.Internals.Current_WebGL_Context or Self.Renderbuffer = null then return False; end if; Self.Context.Bind_Renderbuffer (WebAPI.WebGL.Rendering_Contexts.RENDERBUFFER, Self.Renderbuffer); return True; end Bind; ---------- -- Bind -- ---------- procedure Bind (Self : in out OpenGL_Renderbuffer'Class) is begin if not Self.Bind then raise Program_Error; end if; end Bind; ------------ -- Create -- ------------ function Create (Self : in out OpenGL_Renderbuffer'Class) return Boolean is begin if Self.Context = null then Self.Context := OpenGL.Contexts.Internals.Current_WebGL_Context; if Self.Context = null then return False; end if; end if; if Self.Renderbuffer = null then Self.Renderbuffer := Self.Context.Create_Renderbuffer; if Self.Renderbuffer = null then return False; end if; end if; return True; end Create; ------------ -- Create -- ------------ procedure Create (Self : in out OpenGL_Renderbuffer'Class) is begin if not Self.Create then raise Program_Error; end if; end Create; ------------ -- Delete -- ------------ procedure Delete (Self : in out OpenGL_Renderbuffer'Class) is begin if Self.Context = null or Self.Context /= OpenGL.Contexts.Internals.Current_WebGL_Context or Self.Renderbuffer = null then return; end if; Self.Context.Delete_Renderbuffer (Self.Renderbuffer); Self.Renderbuffer := null; Self.Context := null; end Delete; ------------- -- Release -- ------------- procedure Release (Self : in out OpenGL_Renderbuffer'Class) is begin if Self.Context = null or Self.Context /= OpenGL.Contexts.Internals.Current_WebGL_Context or Self.Renderbuffer = null then return; end if; Self.Context.Bind_Renderbuffer (WebAPI.WebGL.Rendering_Contexts.RENDERBUFFER, null); end Release; ------------- -- Storage -- ------------- procedure Storage (Self : in out OpenGL_Renderbuffer'Class; Format : OpenGL.GLenum; Width : OpenGL.GLsizei; Height : OpenGL.GLsizei) is begin if Self.Context = null or Self.Context /= OpenGL.Contexts.Internals.Current_WebGL_Context or Self.Renderbuffer = null then return; end if; Self.Context.Renderbuffer_Storage (WebAPI.WebGL.Rendering_Contexts.RENDERBUFFER, (case Format is when GL_RGBA4 => WebAPI.WebGL.Rendering_Contexts.RGBA4, when GL_RGB565 => WebAPI.WebGL.Rendering_Contexts.RGB565, when GL_RGB5_A1 => WebAPI.WebGL.Rendering_Contexts.RGB5_A1, when GL_DEPTH_COMPONENT16 => WebAPI.WebGL.Rendering_Contexts.DEPTH_COMPONENT16, when GL_STENCIL_INDEX8 => WebAPI.WebGL.Rendering_Contexts.STENCIL_INDEX8, when others => WebAPI.WebGL.Rendering_Contexts.RGBA4), -- raise Constraint_Error), WebAPI.WebGL.GLsizei (Width), WebAPI.WebGL.GLsizei (Height)); end Storage; end OpenGL.Renderbuffers;
alloy4fun_models/trashltl/models/10/gERX6QizjaKwqZMCJ.als
Kaixi26/org.alloytools.alloy
0
3545
<reponame>Kaixi26/org.alloytools.alloy open main pred idgERX6QizjaKwqZMCJ_prop11 { after File in Protected' } pred __repair { idgERX6QizjaKwqZMCJ_prop11 } check __repair { idgERX6QizjaKwqZMCJ_prop11 <=> prop11o }
oeis/066/A066294.asm
neoneye/loda-programs
11
25006
; A066294: a(n) = A000203(n)^2 - A001157(n) - 2n = sigma(n)^2 - sigma_2(n) - 2n. ; Submitted by <NAME>(s3) ; -2,0,0,20,0,82,0,124,60,174,0,550,0,298,286,588,0,1030,0,1178,482,642,0,2702,260,862,726,2030,0,3824,0,2540,1018,1398,934,6298,0,1714,1358,5810,0,6632,0,4406,3628,2442,0,11870,700,5294,2182,5930,0,10192,1902,10038,2666,3774,0,22644,0,4282,6140,10540,2506,14504,0,9650,3778,14096,0,30146,0,5998,8716,11846,2962,19568,0,25570,7098,7302,0,39508,3954,8002,5806,21854,0,42746,3862,16910,6578,9498,4798,49662,0,16790,13036,33218 mov $2,$0 seq $0,119616 ; Second elementary symmetric function of divisors of n. sub $0,$2 sub $0,1 mul $0,2
src/test/resources/PolymorphicDslMinimalParser.g4
google/polymorphicDSL
3
3495
parser grammar PolymorphicDslMinimalParser; options {tokenVocab=MinimalLexer;} import MinimalParser; polymorphicDslAllRules: minimal ;
Transynther/x86/_processed/AVXALIGN/_ht_/i7-8650U_0xd2_notsx.log_21829_427.asm
ljhsiun2/medusa
9
26065
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r15 push %r9 push %rbp push %rcx push %rdi push %rsi lea addresses_UC_ht+0x197e9, %r9 nop nop add %r11, %r11 mov (%r9), %ebp nop nop and %rcx, %rcx lea addresses_WC_ht+0x1cee9, %r15 nop nop nop inc %rdi mov $0x6162636465666768, %r12 movq %r12, %xmm0 movups %xmm0, (%r15) nop nop nop nop add %r15, %r15 lea addresses_WC_ht+0xc6e9, %r12 nop nop nop nop xor $41435, %rcx vmovups (%r12), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $0, %xmm4, %rbp nop dec %r12 lea addresses_D_ht+0x1c6e9, %rdi nop nop and $58153, %r15 mov (%rdi), %ebp nop add %r9, %r9 lea addresses_D_ht+0x73e9, %rsi lea addresses_A_ht+0x1a3e9, %rdi nop and %rbp, %rbp mov $48, %rcx rep movsq nop nop nop nop nop and $6623, %rcx pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r15 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r14 push %r8 push %rcx push %rdi push %rdx // Load lea addresses_D+0x1aee9, %rdi nop nop nop cmp %rcx, %rcx movb (%rdi), %r8b and %rdx, %rdx // Store lea addresses_WC+0xcd29, %r14 cmp $9918, %r10 mov $0x5152535455565758, %rcx movq %rcx, (%r14) dec %r14 // Store mov $0xf29, %r12 nop nop nop cmp %r14, %r14 mov $0x5152535455565758, %rcx movq %rcx, %xmm3 movups %xmm3, (%r12) nop nop nop nop cmp $7578, %r12 // Store lea addresses_RW+0x8a9, %r14 nop nop nop nop nop sub %r10, %r10 mov $0x5152535455565758, %rdi movq %rdi, %xmm2 movups %xmm2, (%r14) nop nop sub %rcx, %rcx // Store lea addresses_A+0x1f869, %r14 nop nop nop sub %r12, %r12 movl $0x51525354, (%r14) and %r10, %r10 // Store lea addresses_normal+0xd6e9, %rdx nop nop nop nop nop cmp %r14, %r14 mov $0x5152535455565758, %rdi movq %rdi, %xmm2 movups %xmm2, (%rdx) nop sub $56747, %r12 // Store lea addresses_WT+0x1fbe9, %r10 nop nop nop nop nop sub $50913, %r12 movl $0x51525354, (%r10) nop nop nop cmp $15892, %r12 // Store lea addresses_UC+0x1d2f1, %rdi nop add $58691, %rcx movl $0x51525354, (%rdi) nop nop and %r10, %r10 // Store lea addresses_PSE+0x6409, %rcx nop nop nop nop xor $31636, %r10 movw $0x5152, (%rcx) nop nop nop nop nop and %r12, %r12 // Faulty Load lea addresses_D+0x1aee9, %rdx nop nop nop nop sub %rdi, %rdi movaps (%rdx), %xmm0 vpextrq $1, %xmm0, %r10 lea oracles, %rdx and $0xff, %r10 shlq $12, %r10 mov (%rdx,%r10,1), %r10 pop %rdx pop %rdi pop %rcx pop %r8 pop %r14 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}} {'48': 6109, '46': 15720} 48 46 46 48 46 46 46 46 48 46 46 46 46 48 46 46 46 48 46 46 48 46 46 48 48 46 48 48 46 46 46 46 46 48 46 46 46 48 48 48 46 46 46 46 48 46 48 46 46 46 48 46 46 46 48 46 46 46 46 46 46 46 46 46 46 48 48 46 48 46 46 46 46 46 46 48 46 46 46 46 46 46 48 48 48 48 46 46 48 46 46 46 46 46 46 46 46 46 46 46 48 48 46 48 46 46 48 46 48 46 48 46 46 48 46 46 46 46 46 46 48 46 46 46 46 46 46 46 46 46 46 48 46 46 48 46 48 46 48 48 46 46 46 46 46 46 46 48 46 48 48 46 46 46 46 46 46 46 46 46 46 46 48 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 48 46 46 46 46 46 46 46 46 46 48 48 46 46 46 46 46 48 46 48 46 46 46 46 46 46 46 48 46 48 46 48 46 46 48 48 46 48 46 46 46 46 46 48 46 48 46 46 48 46 46 48 46 46 46 48 46 46 46 48 48 46 46 46 48 46 46 46 46 46 46 46 46 46 48 48 46 46 46 48 46 46 46 46 46 46 46 48 46 46 46 46 46 46 46 46 46 48 46 48 46 46 48 46 46 48 46 46 46 46 46 48 46 48 46 46 48 46 46 46 46 46 46 46 48 48 48 48 46 46 46 48 46 48 46 46 46 46 48 48 48 46 46 46 46 48 46 46 46 46 46 46 46 48 46 46 48 46 46 46 46 46 48 48 46 46 46 46 48 46 48 46 48 46 46 46 46 46 48 48 46 46 48 48 46 48 46 48 48 46 48 46 48 46 48 48 46 46 46 46 48 46 46 46 46 46 46 46 46 48 46 46 46 46 46 48 46 46 46 46 46 48 46 46 48 46 46 46 46 46 48 46 46 46 48 48 48 46 46 48 48 46 46 46 46 46 46 48 48 46 46 46 46 46 46 46 46 46 46 46 46 48 46 46 46 46 46 46 48 46 46 46 46 48 46 48 48 46 46 48 46 46 48 46 48 46 46 48 46 48 46 48 46 46 46 46 46 46 48 46 48 46 46 48 46 46 46 46 48 46 46 46 46 46 46 46 46 46 48 48 48 46 46 48 46 46 48 46 46 46 46 46 46 46 48 46 46 48 46 46 48 48 46 46 48 48 46 46 48 46 46 48 46 46 46 46 46 46 46 48 46 46 46 48 46 46 48 48 48 48 46 46 46 46 48 46 48 46 46 48 46 46 46 48 48 46 46 46 46 46 46 48 48 48 48 46 46 46 48 46 46 46 46 46 48 46 46 48 48 46 46 48 46 46 48 46 46 48 46 46 46 46 46 48 46 46 48 46 46 48 46 48 46 46 46 46 46 48 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 48 46 46 46 46 48 46 46 46 46 46 46 48 46 46 48 46 46 46 46 46 46 46 46 46 48 46 48 48 46 46 46 46 48 46 46 46 46 48 48 46 46 46 46 48 46 46 46 46 46 46 48 46 46 46 48 46 46 46 46 46 46 46 46 46 46 48 48 46 46 48 46 46 48 46 46 46 46 46 46 48 48 46 46 46 48 48 46 48 48 46 46 48 46 46 46 46 46 46 48 48 46 48 46 48 46 46 46 46 48 46 46 46 46 46 46 46 48 46 46 48 46 48 46 46 46 46 46 46 48 46 48 48 46 46 46 48 46 46 46 46 46 46 48 48 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 48 46 46 46 46 48 48 46 48 48 48 46 46 46 48 46 46 46 46 48 46 46 46 46 46 46 46 46 48 48 46 46 48 46 46 48 48 46 48 46 48 46 46 46 46 46 46 48 46 46 46 46 46 46 48 48 46 46 46 48 46 46 48 46 46 48 46 46 46 48 46 46 48 46 46 46 46 48 46 46 46 48 48 46 48 46 48 46 48 46 46 46 46 48 48 46 46 46 46 46 46 46 46 46 46 46 48 48 46 46 46 48 46 48 46 46 46 48 46 48 46 46 46 46 46 46 48 46 46 48 46 46 46 48 46 46 46 48 48 46 46 46 46 46 48 46 48 46 46 46 46 46 46 48 46 46 46 46 46 46 46 48 46 48 46 46 48 46 46 48 46 46 46 48 46 48 46 46 46 46 46 46 48 48 46 46 46 48 46 46 46 46 48 46 48 46 46 48 46 48 48 46 46 46 46 */
parser/src/main/antlr/com/github/bjansen/pebble/parser/PebbleParser.g4
lb321/pebble-intellij
0
6669
parser grammar PebbleParser; @header { package com.github.bjansen.pebble.parser; } @members { private void ideRecover(int ttype, String message) { CommonToken t = new CommonToken(ttype, message); _ctx.addErrorNode(t); } } // Use this when working with the IntelliJ plugin //options { tokenVocab=PebbleLexer; } // Use this when working with Gradle options { tokenVocab='com/github/bjansen/pebble/parser/PebbleLexer'; } pebbleTemplate : ( CONTENT | printDirective | commentDirective | tagDirective )* ; printDirective : PRINT_OPEN expression filters? PRINT_CLOSE ; commentDirective : COMMENT ; tagDirective : verbatimTag | genericTag ; verbatimTag : VERBATIM_TAG_OPEN CONTENT? VERBATIM_TAG_END ; genericTag : TAG_OPEN tagName expression? filters? TAG_CLOSE ; tagName : ID_NAME ; expression : assignment_expression | unary_op expression | parenthesized_expression | expression list_expression | expression WITH map_expression | expression OR expression | expression AND expression | expression ((IS test)|(CONTAINS expression)) | expression comparison_op expression | expression OP_TERNARY expression OP_COLON expression | expression additive_op expression | expression multiplicative_op expression | expression OP_CONCAT expression | expression OP_RANGE expression | list_expression | map_expression | in_expression | function_call_expression | qualified_expression | term ; assignment_expression : identifier OP_ASSIGN expression ; in_expression : identifier IN expression ; parenthesized_expression : LPAREN expression RPAREN ; list_expression : LBRACKET (expression (COMMA expression)*)? RBRACKET ; map_expression : LBRACE (map_element (COMMA map_element)*)? RBRACE ; map_element : string_literal OP_COLON (map_expression | expression) ; qualified_expression : (function_call_expression | identifier) (OP_MEMBER (function_call_expression | identifier))+ ; function_call_expression : identifier argument_list ; argument_list : LPAREN ( expression (COMMA expression)* (COMMA { ideRecover(ID_NAME, "expected expression"); })? )? RPAREN ; term : boolean_literal | NULL | NONE | string_literal | numeric_literal | identifier ; test : NOT? (NULL | identifier) ; unary_op : OP_PLUS | OP_MINUS | NOT ; multiplicative_op : OP_DIV | OP_MULT | OP_MOD ; additive_op : OP_PLUS | OP_MINUS ; comparison_op : OP_EQ | EQUALS | OP_NEQ | OP_LE | OP_LT | OP_GE | OP_GT ; boolean_literal : TRUE | FALSE ; string_literal : STRING_START (TEXT | (INTERPOLATED_STRING_START expression? INTERPOLATED_STRING_STOP))* STRING_END? | SINGLE_QUOTED_STRING ; numeric_literal : NUMERIC | LONG ; identifier : ID_NAME | WITH | IN | NONE // TODO NONE is a keyword ; filters : OP_PIPE filter (OP_PIPE filter)* ; filter : identifier argument_list? ;
src/MLib/Finite.agda
bch29/agda-matrices
0
94
module MLib.Finite where open import MLib.Prelude import MLib.Fin.Parts as P import MLib.Fin.Parts.Simple as PS open import MLib.Prelude.RelProps open import Data.List.All as All using (All; []; _∷_) hiding (module All) open import Data.List.Any as Any using (Any; here; there) hiding (module Any) import Data.List.Membership.Setoid as Membership import Data.List.Membership.Propositional as PropMembership import Relation.Binary.Indexed as I import Relation.Unary as U using (Decidable) open LeftInverse using () renaming (_∘_ to _ⁱ∘_) open FE using (_⇨_; cong) open import Function.Related using () renaming (module EquationalReasoning to RelReasoning) import Data.Product.Relation.SigmaPropositional as OverΣ open Algebra using (IdempotentCommutativeMonoid) -------------------------------------------------------------------------------- -- Main Definition -------------------------------------------------------------------------------- record IsFiniteSetoid {c ℓ} (setoid : Setoid c ℓ) (N : ℕ) : Set (c ⊔ˡ ℓ) where open Setoid setoid public open Setoid setoid using () renaming (Carrier to A) OntoFin : ℕ → Set _ OntoFin N = LeftInverse setoid (≡.setoid (Fin N)) field ontoFin : OntoFin N fromIx : Fin N → A fromIx i = LeftInverse.from ontoFin ⟨$⟩ i toIx : A → Fin N toIx x = LeftInverse.to ontoFin ⟨$⟩ x fromIx-toIx : ∀ x → fromIx (toIx x) ≈ x fromIx-toIx = LeftInverse.left-inverse-of ontoFin enumₜ : Table A N enumₜ = tabulate fromIx enumₗ : List A enumₗ = Table.toList enumₜ IsFiniteSet : ∀ {a} → Set a → ℕ → Set a IsFiniteSet = IsFiniteSetoid ∘ ≡.setoid record FiniteSet c ℓ : Set (sucˡ (c ⊔ˡ ℓ)) where field setoid : Setoid c ℓ N : ℕ isFiniteSetoid : IsFiniteSetoid setoid N open IsFiniteSetoid isFiniteSetoid public -------------------------------------------------------------------------------- -- Combinators -------------------------------------------------------------------------------- -- An enumerable setoid is finite module _ {c ℓ} (setoid : Setoid c ℓ) where open Setoid setoid open Membership setoid Any-cong : ∀ {xs} → (∀ x → x ∈ xs) → Set _ Any-cong f = ∀ {x y} → x ≈ y → Any.index (f x) ≡ Any.index (f y) private from : ∀ xs → Fin (List.length xs) → Carrier from List.[] () from (x List.∷ xs) Fin.zero = x from (x List.∷ xs) (Fin.suc i) = from xs i left-inverse-of : ∀ {xs} (f : ∀ x → x ∈ xs) x → from xs (Any.index (f x)) ≈ x left-inverse-of f x = go (f x) where go : ∀ {xs} (p : x ∈ xs) → from xs (Any.index p) ≈ x go (here px) = sym px go (there p) = go p enumerable-isFiniteSetoid : ∀ {xs} (f : ∀ x → x ∈ xs) → Any-cong f → IsFiniteSetoid setoid (List.length xs) enumerable-isFiniteSetoid {xs} f f-cong = record { ontoFin = record { to = record { _⟨$⟩_ = Any.index ∘ f ; cong = f-cong } ; from = ≡.→-to-⟶ (from xs) ; left-inverse-of = left-inverse-of f } } -- As a special case of the previous theorem requiring fewer conditions, an -- enumerable set is finite. module _ {a} {A : Set a} where open PropMembership enumerable-isFiniteSet : (xs : List A) (f : ∀ x → x ∈ xs) → IsFiniteSet A (List.length xs) enumerable-isFiniteSet _ f = enumerable-isFiniteSetoid (≡.setoid _) f (≡.cong (Any.index ∘ f)) -- Given a function with a left inverse from some 'A' to a finite set, 'A' must also be finite. extendedIsFinite : ∀ {c ℓ c′ ℓ′} {S : Setoid c ℓ} (F : FiniteSet c′ ℓ′) → LeftInverse S (FiniteSet.setoid F) → IsFiniteSetoid S (FiniteSet.N F) extendedIsFinite finiteSet ontoF = record { ontoFin = ontoFin ⁱ∘ ontoF } where open FiniteSet finiteSet using (ontoFin) extendFinite : ∀ {c ℓ c′ ℓ′} {S : Setoid c ℓ} (F : FiniteSet c′ ℓ′) → LeftInverse S (FiniteSet.setoid F) → FiniteSet c ℓ extendFinite finiteSet ontoF = record { isFiniteSetoid = extendedIsFinite finiteSet ontoF } module _ {c ℓ c′ ℓ′} {S : Setoid c ℓ} (F : FiniteSet c′ ℓ′) where extendedIsFinite′N : (¬ Setoid.Carrier S) ⊎ LeftInverse S (FiniteSet.setoid F) → ℕ extendedIsFinite′N (inj₁ x) = 0 extendedIsFinite′N (inj₂ y) = FiniteSet.N F extendedIsFinite′ : (inj : (¬ Setoid.Carrier S) ⊎ LeftInverse S (FiniteSet.setoid F)) → IsFiniteSetoid S (extendedIsFinite′N inj) extendedIsFinite′ (inj₂ f) = extendedIsFinite F f extendedIsFinite′ (inj₁ p) = record { ontoFin = record { to = record { _⟨$⟩_ = ⊥-elim ∘ p ; cong = λ {i} → ⊥-elim (p i) } ; from = ≡.→-to-⟶ λ () ; left-inverse-of = ⊥-elim ∘ p } } -- Given a family of finite sets, indexed by a finite set, the sum over the entire family is finite. module _ {c} {A : Set c} {N} (isFiniteSet : IsFiniteSet A N) where private finiteSet : FiniteSet c c finiteSet = record { isFiniteSetoid = isFiniteSet } module F = FiniteSet finiteSet Σᶠ : ∀ {p} → (A → Set p) → Set p Σᶠ P = ∃ (P ∘ lookup F.enumₜ) module _ {p ℓ} (finiteAt : A → FiniteSet p ℓ) where private module PW x = FiniteSet (finiteAt x) open PW using () renaming (Carrier to P) parts : P.Parts A PW.N parts = record { numParts = N ; parts = F.enumₜ } open P.Parts parts hiding (parts) Σ-isFiniteSetoid : IsFiniteSetoid (OverΣ.setoid PW.setoid) totalSize Σ-isFiniteSetoid = record { ontoFin = Inverse.left-inverse (Inverse.sym asParts) ⁱ∘ intoCoords ⁱ∘ Σ-↞′ {B-setoid = PW.setoid} F.ontoFin } where P-setoidᶠ : Fin N → Setoid _ _ P-setoidᶠ i = record { Carrier = P (F.fromIx i) ; _≈_ = PW._≈_ _ ; isEquivalence = record { refl = PW.refl _ ; sym = PW.sym _ ; trans = PW.trans _ } } ΣᶠP-setoid = OverΣ.setoid P-setoidᶠ open Setoid ΣᶠP-setoid using () renaming (_≈_ to _≈ᶠ_) to : Σᶠ P → Σ (Fin N) (Fin ∘ sizeAt) to (_ , px) = _ , PW.toIx _ px to-cong : ∀ {x y} → x ≈ᶠ y → to x ≡ to y to-cong (≡.refl , q) = OverΣ.to-≡ (≡.refl , cong (LeftInverse.to (PW.ontoFin _)) q) from : Σ (Fin N) (Fin ∘ sizeAt) → Σᶠ P from (i , j) = _ , PW.fromIx _ j left-inverse-of : ∀ x → from (to x) ≈ᶠ x left-inverse-of (i , x) = ≡.refl , PW.fromIx-toIx _ _ intoCoords : LeftInverse ΣᶠP-setoid (≡.setoid (Σ (Fin N) (Fin ∘ sizeAt))) intoCoords = record { to = record { _⟨$⟩_ = to ; cong = to-cong } ; from = ≡.→-to-⟶ from ; left-inverse-of = left-inverse-of } Σ-finiteSet : FiniteSet _ _ Σ-finiteSet = record { isFiniteSetoid = Σ-isFiniteSetoid } module All′ {a} {A : Set a} where module _ {p ℓ} (setoid : A → Setoid p ℓ) where module P′ x = Setoid (setoid x) module P′′ {x} = P′ x open P′ using () renaming (Carrier to P) open P′′ using (_≈_) data PW : {xs : List A} → All P xs → All P xs → Set (p ⊔ˡ ℓ) where [] : PW [] [] _∷_ : ∀ {x xs} {px py : P x} {apx apy : All P xs} → px ≈ py → PW apx apy → PW (px ∷ apx) (py ∷ apy) PW-setoid : List A → Setoid _ _ Setoid.Carrier (PW-setoid xs) = All P xs Setoid._≈_ (PW-setoid xs) = PW IsEquivalence.refl (Setoid.isEquivalence (PW-setoid .[])) {[]} = [] IsEquivalence.refl (Setoid.isEquivalence (PW-setoid .(_ ∷ _))) {px ∷ ap} = P′′.refl ∷ IsEquivalence.refl (Setoid.isEquivalence (PW-setoid _)) IsEquivalence.sym (Setoid.isEquivalence (PW-setoid .[])) [] = [] IsEquivalence.sym (Setoid.isEquivalence (PW-setoid .(_ ∷ _))) (p ∷ q) = P′′.sym p ∷ IsEquivalence.sym (Setoid.isEquivalence (PW-setoid _)) q IsEquivalence.trans (Setoid.isEquivalence (PW-setoid .[])) [] [] = [] IsEquivalence.trans (Setoid.isEquivalence (PW-setoid .(_ ∷ _))) (p ∷ q) (p′ ∷ q′) = P′′.trans p p′ ∷ IsEquivalence.trans (Setoid.isEquivalence (PW-setoid _)) q q′ module _ {p} (P : A → Set p) where PW-≡ : ∀ {xs} {apx apy : All P xs} → PW (≡.setoid ∘ P) apx apy → apx ≡ apy PW-≡ [] = ≡.refl PW-≡ (p ∷ q) = ≡.cong₂ _∷_ p (PW-≡ q) -- module _ {c ℓ} (finiteSet : FiniteSet c ℓ) where -- private -- module A = FiniteSet finiteSet -- open A using (_≈_) renaming (Carrier to A) -- open IsFiniteSetoid -- open LeftInverse -- private -- boolToFin : Bool → Fin 2 -- boolToFin false = Fin.zero -- boolToFin true = Fin.suc Fin.zero -- open Nat using (_^_; _+_; _*_) -- _ℕ+_ : ∀ {n} (m : ℕ) → Fin n → Fin (m + n) -- zero ℕ+ i = i -- suc m ℕ+ i = Fin.suc (m ℕ+ i) -- -- ℕ*-+ m "i" "k" = "i + m * k" -- ℕ*-+′ : ∀ {n} (m : ℕ) → Fin m → Fin n → Fin (n * m) -- ℕ*-+′ {zero} m i () -- ℕ*-+′ {suc n} m i Fin.zero = Fin.inject+ (n * m) i -- ℕ*-+′ {suc n} m i (Fin.suc k) = m ℕ+ (ℕ*-+′ m i k) -- -- ℕ*-+ m "i" "k" = "i + m * k" -- ℕ*-+ : ∀ {n} m → Fin m → Fin n → Fin (m * n) -- ℕ*-+ m i k = ≡.subst Fin (Nat.*-comm _ m) (ℕ*-+′ m i k) -- from-n-ary : ∀ {n m} → Table (Fin n) m → Fin (n ^ m) -- from-n-ary {m = zero} _ = Fin.zero -- an empty table represents an empty n-ary string -- from-n-ary {n} {suc m} t = ℕ*-+ n (Table.lookup t Fin.zero) (from-n-ary (Table.tail t)) -- from-n-ary-cong : ∀ {n m} (t t′ : Table (Fin n) m) → t Table.≗ t′ → from-n-ary t ≡ from-n-ary t′ -- from-n-ary-cong {m = zero} t t′ eq = ≡.refl -- from-n-ary-cong {n} {suc m} t t′ eq = ≡.cong₂ (ℕ*-+ n) (eq Fin.zero) (from-n-ary-cong (Table.tail t) (Table.tail t′) (eq ∘ Fin.suc)) -- -- div-rem m i = "i % m" , "i / m" -- div-rem : ∀ {n} m → Fin (m * n) → Fin m × Fin n -- div-rem zero () -- div-rem {zero} (suc m) i with ≡.subst Fin (Nat.*-zeroʳ m) i -- div-rem {zero} (suc m) i | () -- div-rem {suc n} (suc m) Fin.zero = Fin.zero , Fin.zero -- div-rem {suc n} (suc m) (Fin.suc i) = {!!} -- to-n-ary : ∀ {n m} → Fin (n ^ m) → Table (Fin n) m -- to-n-ary {m = zero} _ = tabulate λ () -- to-n-ary {n} {suc m} k = -- let r , d = div-rem n k -- ind = to-n-ary {n} {m} d -- in tabulate λ -- { Fin.zero → r -- ; (Fin.suc i) → lookup ind i -- } -- boolF-isFiniteSetoid : IsFiniteSetoid (A.setoid ⇨ ≡.setoid Bool) (2 Nat.^ A.N) -- _⟨$⟩_ (to (ontoFin boolF-isFiniteSetoid)) f = -- let digits = Table.map (boolToFin ∘ (f ⟨$⟩_)) A.enumₜ -- in from-n-ary digits -- cong (to (ontoFin boolF-isFiniteSetoid)) {f} {f′} p = -- let t = Table.map (boolToFin ∘ (f ⟨$⟩_)) A.enumₜ -- in from-n-ary-cong t _ λ _ → ≡.cong boolToFin (p A.refl) -- _⟨$⟩_ (_⟨$⟩_ (from (ontoFin boolF-isFiniteSetoid)) i) x = {!!} -- cong (_⟨$⟩_ (from (ontoFin boolF-isFiniteSetoid)) i) = {!!} -- cong (from (ontoFin boolF-isFiniteSetoid)) ≡.refl = {!≡.cong ?!} -- left-inverse-of (ontoFin boolF-isFiniteSetoid) = {!!} -- module _ {c₁ ℓ₁ c₂ ℓ₂} (A-finiteSet : FiniteSet c₁ ℓ₁) (B-finiteSet : FiniteSet c₂ ℓ₂) where -- private -- module A = FiniteSet A-finiteSet -- module B = FiniteSet B-finiteSet -- open A using (_≈_) renaming (Carrier to A) -- open B using () renaming (Carrier to B; _≈_ to _≈′_) -- open IsFiniteSetoid -- open LeftInverse -- function-isFiniteSetoid : IsFiniteSetoid (A.setoid ⇨ B.setoid) (B.N Nat.^ A.N) -- _⟨$⟩_ (to (ontoFin function-isFiniteSetoid)) f = {!!} -- cong (to (ontoFin function-isFiniteSetoid)) = {!!} -- _⟨$⟩_ (from (ontoFin function-isFiniteSetoid)) i = {!!} -- cong (from (ontoFin function-isFiniteSetoid)) = {!!} -- left-inverse-of (ontoFin function-isFiniteSetoid) = {!!} -- TODO: Prove dependent function spaces with finite domain and codomain are -- finite sets, and recast as an instance of that. module _ {a p ℓ} {A : Set a} (finiteAt : A → FiniteSet p ℓ) where private module PW x = FiniteSet (finiteAt x) module PW′ {x} = PW x open PW using () renaming (Carrier to P; N to boundAt) open PW′ using (_≈_) All≈ = All′.PW PW.setoid All-setoid = All′.PW-setoid PW.setoid open All′.PW PW.setoid finiteAllSize : List A → ℕ finiteAllSize = List.product ∘ List.map boundAt All-isFiniteSetoid : (xs : List A) → IsFiniteSetoid (All-setoid xs) _ All-isFiniteSetoid _ = record { ontoFin = record { to = record { _⟨$⟩_ = to ; cong = to-cong } ; from = ≡.→-to-⟶ from ; left-inverse-of = left-inverse-of } } where to : ∀ {xs} → All P xs → Fin (finiteAllSize xs) to [] = Fin.zero to (_∷_ {x} {xs} px ap) = PS.fromParts (PW.toIx _ px , to ap) to-cong : ∀ {xs}{apx apy : All P xs} → All≈ apx apy → to apx ≡ to apy to-cong [] = ≡.refl to-cong (p ∷ q) = ≡.cong₂ (curry PS.fromParts) (cong (LeftInverse.to PW′.ontoFin) p) (to-cong q) from : ∀ {xs} → Fin (finiteAllSize xs) → All P xs from {List.[]} _ = [] from {x List.∷ xs} i = (PW.fromIx _ (proj₁ (PS.toParts i))) ∷ from {xs} (proj₂ (PS.toParts {boundAt x} i)) left-inverse-of : ∀ {xs} (ap : All P xs) → All≈ (from (to ap)) ap left-inverse-of [] = Setoid.refl (All-setoid _) left-inverse-of (px ∷ ap) rewrite Inverse.right-inverse-of PS.asParts (PW.toIx _ px , to ap) = PW′.fromIx-toIx px ∷ left-inverse-of ap All-finiteSet : List A → FiniteSet _ _ All-finiteSet xs = record { isFiniteSetoid = All-isFiniteSetoid xs } 1-Truncate : ∀ {c ℓ} (setoid : Setoid c ℓ) → Setoid _ _ 1-Truncate setoid = record { Carrier = Carrier ; _≈_ = λ _ _ → ⊤ ; isEquivalence = record { refl = _ ; sym = _ ; trans = _ } } where open Setoid setoid module DecFinite {a p} {A : Set a} {P : A → Set p} (decP : U.Decidable P) where P-setoid : A → Setoid _ _ P-setoid = 1-Truncate ∘ ≡.setoid ∘ P P-size : A → ℕ P-size x = if ⌊ decP x ⌋ then 1 else 0 P-isFinite : ∀ x → IsFiniteSetoid (P-setoid x) (P-size x) P-isFinite x with decP x P-isFinite x | yes p = record { ontoFin = record { to = record { _⟨$⟩_ = λ _ → Fin.zero ; cong = λ _ → ≡.refl } ; from = ≡.→-to-⟶ λ _ → p ; left-inverse-of = _ } } P-isFinite x | no ¬p = record { ontoFin = record { to = record { _⟨$⟩_ = ⊥-elim ∘ ¬p ; cong = λ {x} → ⊥-elim (¬p x) } ; from = ≡.→-to-⟶ λ () ; left-inverse-of = _ } } Decidable-finite : A → FiniteSet p _ Decidable-finite x = record { isFiniteSetoid = P-isFinite x } module _ {c} {A : Set c} {N} (isFiniteSet : IsFiniteSet A N) {p} {P : A → Set p} (decP : U.Decidable P) where open IsFiniteSetoid isFiniteSet subsetFinite : FiniteSet _ _ subsetFinite = Σ-finiteSet isFiniteSet (DecFinite.Decidable-finite decP) subset-isFiniteSet : ∀ {a′} {A′ : Set a′} → LeftInverse (≡.setoid A′) (FiniteSet.setoid subsetFinite) → IsFiniteSet A′ _ subset-isFiniteSet = extendedIsFinite subsetFinite
programs/oeis/030/A030503.asm
karttu/loda
0
104129
; A030503: Graham-Sloane-type lower bound on the size of a ternary (n,3,3) constant-weight code. ; 2,4,8,13,19,27,36,46,58,71,85,101,118,136,156,177,199,223,248,274,302,331,361,393,426,460,496,533,571,611,652,694,738,783,829,877,926,976,1028,1081,1135,1191,1248,1306,1366,1427,1489,1553,1618 mov $1,$0 add $0,3 add $1,$0 bin $1,2 div $1,3 add $1,1
Levels/Misc/Object pointers - SK Set 2.asm
NatsumiFox/AMPS-Sonic-3-Knuckles
5
98539
dc.l Obj_Ring ; 0 dc.l Obj_Monitor ; 1 dc.l Obj_PathSwap ; 2 dc.l Obj_03_2 ; 3 dc.l Obj_CollapsingPlatform ; 4 dc.l Obj_AIZLRZEMZRock ; 5 dc.l Obj_MHZPulleyLift ; 6 dc.l Obj_Spring ; 7 dc.l Obj_Spikes ; 8 dc.l Obj_MHZCurledVine ; 9 dc.l Obj_MHZStickyVine ; 10 dc.l Obj_MHZSwingBarHorizontal ; 11 dc.l Obj_MHZSwingBarVertical ; 12 dc.l Obj_BreakableWall ; 13 dc.l Obj_0E ; 14 dc.l Obj_CollapsingBridge ; 15 dc.l Obj_MHZSwingVine ; 16 dc.l Obj_MHZMushroomPlatform ; 17 dc.l Obj_MHZMushroomParachute ; 18 dc.l Obj_MHZMushroomCatapult ; 19 dc.l Obj_14_2 ; 20 dc.l Obj_15_2 ; 21 dc.l Obj_16_2 ; 22 dc.l Obj_LRZSinkingRock ; 23 dc.l Obj_LRZFallingSpike ; 24 dc.l Obj_LRZDoor ; 25 dc.l Obj_LRZBigDoor ; 26 dc.l Obj_LRZFireballLauncher ; 27 dc.l Obj_LRZButtonHorizontal ; 28 dc.l Obj_LRZShootingTrigger ; 29 dc.l Obj_LRZDashElevator ; 30 dc.l Obj_LRZLavaFall ; 31 dc.l Obj_LRZSwingingSpikeBall ; 32 dc.l Obj_LRZSmashingSpikePlatform ; 33 dc.l Obj_LRZSpikeBall ; 34 dc.l Obj_MHZMushroomCap ; 35 dc.l Obj_AutomaticTunnel ; 36 dc.l Obj_LRZChainedPlatforms ; 37 dc.l Obj_26 ; 38 dc.l Obj_27 ; 39 dc.l Obj_28_Invisible_Barrier ; 40 dc.l Obj_LRZFlameThrower ; 41 dc.l Obj_CorkFloor ; 42 dc.l Obj_LRZOrbitingSpikeBallHorizontal ; 43 dc.l Obj_LRZOrbitingSpikeBallVertical ; 44 dc.l Obj_LRZSolidMovingPlatforms ; 45 dc.l Obj_LRZSolidRock ; 46 dc.l Obj_StillSprite ; 47 dc.l Obj_AnimatedStillSprite ; 48 dc.l Obj_LRZCollapsingBridge ; 49 dc.l Obj_LRZTurbineSprites ; 50 dc.l Obj_Button ; 51 dc.l Obj_StarPost ; 52 dc.l Obj_AIZForegroundPlant ; 53 dc.l Obj_BreakableBar ; 54 dc.l Obj_LRZSpikeBallLauncher ; 55 dc.l Obj_38_2 ; 56 dc.l Obj_SOZSpawningSandBlocks ; 57 dc.l Obj_3A_2 ; 58 dc.l Obj_3B_2 ; 59 dc.l Obj_Door ; 60 dc.l Obj_RetractingSpring ; 61 dc.l Obj_SOZPushableRock ; 62 dc.l Obj_SOZSpringVine ; 63 dc.l Obj_SOZRisingSandWall ; 64 dc.l Obj_SOZLightSwitch ; 65 dc.l Obj_SOZFloatingPillar ; 66 dc.l Obj_SOZSwingingPlatform ; 67 dc.l Obj_SOZBreakableSandRock ; 68 dc.l Obj_SOZPushSwitch ; 69 dc.l Obj_SOZDoor ; 70 dc.l Obj_SOZSandCork ; 71 dc.l Obj_SOZRapelWire ; 72 dc.l Obj_SOZSolidSprites ; 73 dc.l Obj_DEZFloatingPlatform ; 74 dc.l Obj_TiltingBridge ; 75 dc.l Obj_DEZHangCarrier ; 76 dc.l Obj_DEZTorpedoLauncher ; 77 dc.l Obj_DEZLiftPad ; 78 dc.l Obj_DEZStaircase ; 79 dc.l Obj_50_2 ; 80 dc.l Obj_FloatingPlatform ; 81 dc.l Obj_DEZLightning ; 82 dc.l Obj_DEZConveyorPad ; 83 dc.l Obj_Bubbler ; 84 dc.l Obj_DEZEnergyBridge ; 85 dc.l Obj_56_2 ; 86 dc.l Obj_DEZTunnelLauncher ; 87 dc.l Obj_DEZGravitySwitch ; 88 dc.l Obj_59_2 ; 89 dc.l Obj_5A_2 ; 90 dc.l Obj_5B_2 ; 91 dc.l Obj_5C_2 ; 92 dc.l Obj_DEZRetractingSpring ; 93 dc.l Obj_DEZHoverMachine ; 94 dc.l Obj_5F_2 ; 95 dc.l Obj_DEZBumperWall ; 96 dc.l Obj_DEZGravityPuzzle ; 97 dc.l Obj_Ring ; 98 dc.l Obj_Ring ; 99 dc.l Obj_Ring ; 100 dc.l Obj_Ring ; 101 dc.l Obj_Ring ; 102 dc.l Obj_Ring ; 103 dc.l Obj_Ring ; 104 dc.l Obj_Ring ; 105 dc.l Obj_InvisibleHurtBlockHorizontal ; 106 dc.l Obj_InvisibleHurtBlockVertical ; 107 dc.l Obj_TensionBridge ; 108 dc.l Obj_6D_2 ; 109 dc.l Obj_6E_2 ; 110 dc.l Obj_Ring ; 111 dc.l Obj_Ring ; 112 dc.l Obj_Ring ; 113 dc.l Obj_Ring ; 114 dc.l Obj_Ring ; 115 dc.l Obj_SSZRetractingSpring ; 116 dc.l Obj_SSZSwingingCarrier ; 117 dc.l Obj_SSZRotatingPlatform ; 118 dc.l Obj_77_2 ; 119 dc.l Obj_FBZDEZPlayerLauncher ; 120 dc.l Obj_SSZHPZTeleporter ; 121 dc.l Obj_SSZElevatorBar ; 122 dc.l Obj_SSZCollapsingBridgeDiagonal ; 123 dc.l Obj_SSZCollapsingBridge ; 124 dc.l Obj_SSZBouncyCloud ; 125 dc.l Obj_SSZCollapsingColumn ; 126 dc.l Obj_SSZFloatingPlatform ; 127 dc.l Obj_HiddenMonitor ; 128 dc.l Obj_81 ; 129 dc.l Obj_CutsceneKnuckles ; 130 dc.l Obj_83 ; 131 dc.l Obj_AIZPlaneIntro ; 132 dc.l Obj_SSEntryRing ; 133 dc.l Obj_86 ; 134 dc.l Obj_87 ; 135 dc.l Obj_88 ; 136 dc.l Obj_89 ; 137 dc.l Obj_8A ; 138 dc.l Obj_8B ; 139 dc.l Obj_Madmole ; 140 dc.l Obj_Mushmeanie ; 141 dc.l Obj_Dragonfly ; 142 dc.l Obj_Butterdroid ; 143 dc.l Obj_Cluckoid ; 144 dc.l Obj_91_2 ; 145 dc.l Obj_MHZ_Miniboss ; 146 dc.l Obj_MHZ_EndBoss ; 147 dc.l Obj_Skorp ; 148 dc.l Obj_Sandworm ; 149 dc.l Obj_Rockn ; 150 dc.l Obj_SOZ_Miniboss ; 151 dc.l Obj_SOZ_EndBoss ; 152 dc.l Obj_Fireworm ; 153 dc.l Obj_LRZExplodingRock ; 154 dc.l Obj_Toxomister ; 155 dc.l Obj_LRZRockCrusher ; 156 dc.l Obj_LRZ_Miniboss ; 157 dc.l Obj_9E_2 ; 158 dc.l Obj_Ring ; 159 dc.l Obj_EggRobo ; 160 dc.l Obj_SSZGHZBoss ; 161 dc.l Obj_SSZMTZBoss ; 162 dc.l Obj_A3_2 ; 163 dc.l Obj_Spikebonker ; 164 dc.l Obj_Chainspike ; 165 dc.l Obj_DEZ_Miniboss ; 166 dc.l Obj_DEZ_EndBoss ; 167 dc.l Obj_A8_2 ; 168 dc.l Obj_A9_2 ; 169 dc.l Obj_SOZ_Ghosts ; 170 dc.l Obj_AB_2 ; 171 dc.l Obj_AC_2_SOZ2_Ghost_Capsule ; 172 dc.l Obj_AD_2 ; 173 dc.l Obj_AE_2 ; 174 dc.l Obj_AF_2 ; 175 dc.l Obj_B0_2 ; 176 dc.l Obj_B1_2 ; 177 dc.l Obj_B2_2 ; 178 dc.l Obj_B3_2 ; 179 dc.l Obj_B4_2 ; 180 dc.l Obj_B5_2 ; 181 dc.l Obj_B6_2 ; 182 dc.l Obj_DDZAsteroid ; 183 dc.l Obj_DDZMissile ; 184
src/main/antlr4/com/brennaswitzer/cookbook/antlr/Number.g4
switzerb/cookbook
0
5267
grammar Number; start : d=DASH? a=atom (AND b=atom)* ; atom : number | name | fraction ; number : i=integer (AND? f=fraction)? | d=decimal ; integer : INTEGER ; decimal : DECIMAL ; fraction : n=integer SLASH d=integer | vf=vulgarFraction ; vulgarFraction returns [double val] : f=VULGAR_FRACTION { switch ($f.text) { case "¼": $val = 1.0 / 4.0; break; case "½": $val = 1.0 / 2.0; break; case "¾": $val = 3.0 / 4.0; break; case "⅐": $val = 1.0 / 7.0; break; case "⅑": $val = 1.0 / 9.0; break; case "⅒": $val = 1.0 / 10.0; break; case "⅓": $val = 1.0 / 3.0; break; case "⅔": $val = 2.0 / 3.0; break; case "⅕": $val = 1.0 / 5.0; break; case "⅖": $val = 2.0 / 5.0; break; case "⅗": $val = 3.0 / 5.0; break; case "⅘": $val = 4.0 / 5.0; break; case "⅙": $val = 1.0 / 6.0; break; case "⅚": $val = 5.0 / 6.0; break; case "⅛": $val = 1.0 / 8.0; break; case "⅜": $val = 3.0 / 8.0; break; case "⅝": $val = 5.0 / 8.0; break; case "⅞": $val = 7.0 / 8.0; break; } }; name returns [double val] : n=NAME { switch ($n.text.toLowerCase()) { case "a half" : case "one half" : $val = 0.5; break; case "half" : $val = 0.5; break; case "one" : $val = 1.0; break; case "two" : $val = 2.0; break; case "three" : $val = 3.0; break; case "four" : $val = 4.0; break; case "five" : $val = 5.0; break; case "six" : $val = 6.0; break; case "seven" : $val = 7.0; break; case "eight" : $val = 8.0; break; case "nine" : $val = 9.0; break; case "ten" : $val = 10.0; break; case "eleven" : $val = 11.0; break; case "twelve" : $val = 12.0; break; case "thirteen" : $val = 13.0; break; case "fourteen" : $val = 14.0; break; case "fifteen" : $val = 15.0; break; case "sixteen" : $val = 16.0; break; case "seventeen": $val = 17.0; break; case "eighteen" : $val = 18.0; break; case "nineteen" : $val = 19.0; break; case "twenty" : $val = 20.0; break; } }; fragment ZERO : '0' ; fragment NON_ZERO_DIGIT : [1-9] ; fragment DIGIT : ZERO | NON_ZERO_DIGIT ; INTEGER : NON_ZERO_DIGIT DIGIT* ; DECIMAL : ( INTEGER | ZERO )? DOT DIGIT+ ; NAME : 'a half' | 'one half' | 'half' | 'one' | 'two' | 'three' | 'four' | 'five' | 'six' | 'seven' | 'eight' | 'nine' | 'ten' | 'eleven' | 'twelve' | 'thirteen' | 'fourteen' | 'fifteen' | 'sixteen' | 'seventeen' | 'eighteen' | 'nineteen' | 'twenty' ; VULGAR_FRACTION : '¼' | '½' | '¾' | '⅐' | '⅑' | '⅒' | '⅓' | '⅔' | '⅕' | '⅖' | '⅗' | '⅘' | '⅙' | '⅚' | '⅛' | '⅜' | '⅝' | '⅞' ; AND : 'and' | '&' ; DASH : '-' ; DOT : '.' ; SLASH : '/' // normal slash (solidus) | '⁄' // U+2044 : FRACTION SLASH ; WHITESPACE : [ \t\n\r]+ -> skip ; // This is so the lexer can "soak up" anything, and all the error handling // happens at the parsing layer. Since we're running a boolean distinction for // recognition, differentiating the layers is irrelevant. ExtraGarbage : . ;
src/fot/FOTC/Relation/Binary/Bisimilarity/Consistency/Axioms.agda
asr/fotc
11
10002
------------------------------------------------------------------------------ -- Test the consistency of FOTC.Relation.Binary.Bisimilarity.Type ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- In the module FOTC.Relation.Binary.Bisimilarity.Type we declare -- Agda postulates as first-order logic axioms. We test if it is -- possible to prove unprovable theorems from these axioms. module FOTC.Relation.Binary.Bisimilarity.Consistency.Axioms where open import FOTC.Base open import FOTC.Relation.Binary.Bisimilarity.Type ------------------------------------------------------------------------------ postulate impossible : ∀ d e → d ≡ e {-# ATP prove impossible #-} postulate ≡→≈ : ∀ {xs ys} → xs ≡ ys → xs ≈ ys {-# ATP prove ≡→≈ #-} postulate ≈→≡ : ∀ {xs ys} → xs ≈ ys → xs ≡ ys {-# ATP prove ≈→≡ #-} postulate ≉→≢ : ∀ {xs ys} → xs ≉ ys → xs ≢ ys {-# ATP prove ≉→≢ #-}
TD6/Bool.agda
erwinkn/program-eq-proof
0
3458
<reponame>erwinkn/program-eq-proof {- 1. Booleans -} data Bool : Set where true : Bool false : Bool not : Bool → Bool not true = false not false = true _∧_ : Bool → Bool → Bool true ∧ true = true true ∧ false = false false ∧ true = false false ∧ false = false _∨_ : Bool → Bool → Bool true ∨ true = true true ∨ false = true false ∨ true = true false ∨ false = false {- 2. Equality -} data _≡_ {A : Set} (x : A) : (y : A) → Set where refl : x ≡ x infix 4 _≡_ not-inv : (b : Bool) → not (not b) ≡ b not-inv true = refl not-inv false = refl f : (b : Bool) → (not b) ∧ b ≡ false f true = refl f false = refl
src/test/resources/cpuTests/asmsrc/sub.asm
Sophos06/spice86
46
5470
use16 start: mov sp,160 ; sub word tests mov ax,00001h mov bx,00002h sub ax,bx mov word[0],ax mov word[2],bx pushf mov dx,0ffffh mov word[4],0ffffh sub word[4],dx mov word[6],dx pushf mov cx,0ffffh mov word[8],00001h sub cx,word[8] mov word[10],cx pushf mov ax,08000h sub ax,00001h mov word[12],ax pushf mov bp,08000h db 083h,0edh,0ffh mov word[14],bp pushf mov si,07f81h sub si,0903ch mov word[16],si pushf mov word[18],0efc3h sub word[18],0c664h pushf mov word[20],0e933h dw 02e83h, 00014h db 064h pushf ; sub byte tests mov byte[22],001h sub byte[22],002h pushf mov dh,0ffh sub dh,0ffh mov word[23],dx pushf mov al,0ffh sub al,001h mov word[25],ax pushf mov byte[27],080h mov ch,001h sub ch,byte[27] mov word[28],cx pushf mov bl,080h mov byte[30],07fh sub byte[30],bl mov word[31],bx pushf mov al,0bch mov ah,08eh sub ah,al mov word[33],ax pushf ; sbb word tests mov ax,00001h mov bx,00002h sbb bx,ax mov word[35],ax mov word[37],bx pushf mov dx,0ffffh mov word[39],0ffffh sbb word[39],dx mov word[41],dx pushf mov cx,0ffffh mov word[43],00001h sbb cx,word[43] mov word[45],cx pushf mov ax,08000h sbb ax,00001h mov word[47],ax pushf mov bp,08000h db 083h,0ddh,0ffh mov word[49],bp pushf mov si,052c3h sbb si,0e248h mov word[51],si pushf mov word[53],0e74ch sbb word[53],022c0h pushf mov word[55],0fd85h dw 01e83h, 00037h db 0f5h pushf ; sbb byte tests mov byte[57],001h sbb byte[57],002h pushf mov dh,0ffh sbb dh,0ffh mov word[58],dx pushf mov al,0ffh sbb al,001h mov word[60],ax pushf mov byte[62],080h mov ch,001h sbb ch,byte[62] mov word[63],cx pushf mov bl,080h mov byte[65],0ffh sbb byte[65],bl mov word[66],bx pushf mov al,0b9h mov ah,0d3h sbb ah,al mov word[68],ax pushf ; dec word tests mov di,00000h dec di mov word[70],di pushf mov bp,08000h db 0ffh, 0cdh mov word[72],bp pushf mov word[74],07412h dec word[74] pushf ; dec byte tests mov dl,000h dec dl mov word[76],dx pushf mov byte[77],080h dec byte[77] pushf mov byte[78],0b5h dec byte[78] pushf hlt rb 65520-$ jmp start rb 65535-$ db 0ffh
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c5/c54a42a.ada
best08618/asylo
7
9504
-- C54A42A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT A CASE_STATEMENT MAY HANDLE A LARGE NUMBER OF -- POTENTIAL VALUES GROUPED INTO A SMALL NUMBER OF ALTERNATIVES -- AND THAT EACH TIME THE APPROPRIATE ALTERNATIVE IS EXECUTED. -- (OPTIMIZATION TEST.) -- RM 03/24/81 -- PWN 11/30/94 SUBTYPE QUALIFIED LITERALS FOR ADA 9X. WITH REPORT; PROCEDURE C54A42A IS USE REPORT ; BEGIN TEST( "C54A42A" , "TEST THAT A CASE_STATEMENT HANDLES CORRECTLY" & " A LARGE NUMBER OF POTENTIAL VALUES GROUPED" & " INTO A SMALL NUMBER OF ALTERNATIVES" ); DECLARE STATCON : CONSTANT CHARACTER := 'B' ; STATVAR : CHARACTER := 'Q' ; DYNCON : CONSTANT CHARACTER := IDENT_CHAR( 'Y' ); DYNVAR : CHARACTER := IDENT_CHAR( 'Z' ); BEGIN CASE CHARACTER'('A') IS WHEN ASCII.NUL .. 'A' => NULL ; WHEN 'B' => FAILED( "WRONG ALTERN. A2" ); WHEN 'P' => FAILED( "WRONG ALTERN. A3" ); WHEN 'Y' => FAILED( "WRONG ALTERN. A4" ); WHEN 'Z' .. ASCII.DEL => FAILED( "WRONG ALTERN. A5" ); WHEN OTHERS => FAILED( "WRONG ALTERN. A6" ); END CASE; CASE STATCON IS WHEN ASCII.NUL .. 'A' => FAILED( "WRONG ALTERN. B1" ); WHEN 'B' => NULL ; WHEN 'P' => FAILED( "WRONG ALTERN. B3" ); WHEN 'Y' => FAILED( "WRONG ALTERN. B4" ); WHEN 'Z' .. ASCII.DEL => FAILED( "WRONG ALTERN. B5" ); WHEN OTHERS => FAILED( "WRONG ALTERN. B6" ); END CASE; CASE STATVAR IS WHEN ASCII.NUL .. 'A' => FAILED( "WRONG ALTERN. C1" ); WHEN 'B' => FAILED( "WRONG ALTERN. C2" ); WHEN 'P' => FAILED( "WRONG ALTERN. C3" ); WHEN 'Y' => FAILED( "WRONG ALTERN. C4" ); WHEN 'Z' .. ASCII.DEL => FAILED( "WRONG ALTERN. C5" ); WHEN OTHERS => NULL ; END CASE; CASE DYNCON IS WHEN ASCII.NUL .. 'A' => FAILED( "WRONG ALTERN. D1" ); WHEN 'B' => FAILED( "WRONG ALTERN. D2" ); WHEN 'P' => FAILED( "WRONG ALTERN. D3" ); WHEN 'Y' => NULL ; WHEN 'Z' .. ASCII.DEL => FAILED( "WRONG ALTERN. D5" ); WHEN OTHERS => FAILED( "WRONG ALTERN. D6" ); END CASE; CASE DYNVAR IS WHEN ASCII.NUL .. 'A' => FAILED( "WRONG ALTERN. E1" ); WHEN 'B' => FAILED( "WRONG ALTERN. E2" ); WHEN 'P' => FAILED( "WRONG ALTERN. E3" ); WHEN 'Y' => FAILED( "WRONG ALTERN. E4" ); WHEN 'Z' .. ASCII.DEL => NULL ; WHEN OTHERS => FAILED( "WRONG ALTERN. E6" ); END CASE; END ; DECLARE NUMBER : CONSTANT := -100 ; LITEXPR : CONSTANT := 0 * NUMBER + 16 ; STATCON : CONSTANT INTEGER := +100 ; DYNVAR : INTEGER := IDENT_INT( 102 ) ; DYNCON : CONSTANT INTEGER := IDENT_INT( 17 ) ; BEGIN CASE INTEGER'(-102) IS WHEN INTEGER'FIRST..-101 => NULL ; WHEN -100 => FAILED("WRONG ALTERN. F2"); WHEN 17 => FAILED("WRONG ALTERN. F2"); WHEN 100 => FAILED("WRONG ALTERN. F4"); WHEN 101..INTEGER'LAST => FAILED("WRONG ALTERN. F5"); WHEN OTHERS => FAILED("WRONG ALTERN. F6"); END CASE; CASE IDENT_INT(NUMBER) IS WHEN INTEGER'FIRST..-101 => FAILED("WRONG ALTERN. G1"); WHEN -100 => NULL ; WHEN 17 => FAILED("WRONG ALTERN. G3"); WHEN 100 => FAILED("WRONG ALTERN. G4"); WHEN 101..INTEGER'LAST => FAILED("WRONG ALTERN. G5"); WHEN OTHERS => FAILED("WRONG ALTERN. G6"); END CASE; CASE IDENT_INT(LITEXPR) IS WHEN INTEGER'FIRST..-101 => FAILED("WRONG ALTERN. H1"); WHEN -100 => FAILED("WRONG ALTERN. H2"); WHEN 17 => FAILED("WRONG ALTERN. H3"); WHEN 100 => FAILED("WRONG ALTERN. H4"); WHEN 101..INTEGER'LAST => FAILED("WRONG ALTERN. H5"); WHEN OTHERS => NULL ; END CASE; CASE STATCON IS WHEN INTEGER'FIRST..-101 => FAILED("WRONG ALTERN. I1"); WHEN -100 => FAILED("WRONG ALTERN. I2"); WHEN 17 => FAILED("WRONG ALTERN. I3"); WHEN 100 => NULL ; WHEN 101..INTEGER'LAST => FAILED("WRONG ALTERN. I5"); WHEN OTHERS => FAILED("WRONG ALTERN. I6"); END CASE; CASE DYNVAR IS WHEN INTEGER'FIRST..-101 => FAILED("WRONG ALTERN. J1"); WHEN -100 => FAILED("WRONG ALTERN. J2"); WHEN 17 => FAILED("WRONG ALTERN. J3"); WHEN 100 => FAILED("WRONG ALTERN. J4"); WHEN 101..INTEGER'LAST => NULL ; WHEN OTHERS => FAILED("WRONG ALTERN. J6"); END CASE; CASE DYNCON IS WHEN INTEGER'FIRST..-101 => FAILED("WRONG ALTERN. K1"); WHEN -100 => FAILED("WRONG ALTERN. K2"); WHEN 17 => NULL ; WHEN 100 => FAILED("WRONG ALTERN. K4"); WHEN 101..INTEGER'LAST => FAILED("WRONG ALTERN. K5"); WHEN OTHERS => FAILED("WRONG ALTERN. K6"); END CASE; END ; RESULT ; END C54A42A ;
test-code/tmp/GrammarProgram.g4
miho/VMF-Text-Tests
9
5167
grammar GrammarProgram; program: functions+=function* EOF; function: returnType=type name=IDENTIFIER '(' (arguments+=argument (',' arguments+=argument)*)? ')' '{' controlFlow=controlFlowScope '}' ; invocation: name=IDENTIFIER '(' ')' # methodInvocation | 'for' '(' condition=forCondition ')' '{' controlFlow=controlFlowScope '}' # scopeInvocation ; forCondition : decl = declaration ; declaration: declType = type varName = IDENTIFIER '=' assignment=invocation; controlFlowScope : (invocations+=invocation ';'?)*; argument: name=IDENTIFIER; type : name = IDENTIFIER; // NEWLINE : [\r\n]+ ; INT : [0-9]+ ; BINOP : ('*'|'/'|'+'|'-'); PREFIXUNARYOP : ('++'|'--'|'!'); POSTFIXUNARYOP : ('++'|'--'); BOOL : 'true' | 'false'; //STRING: '"' CHAR* '"'; IDENTIFIER: [a-zA-Z][a-zA-Z0-9]*; WS : [ \r\n\t]+ -> channel(HIDDEN);
src/dnscatcher/dns/processor/packet/dnscatcher-dns-processor-packet.adb
DNSCatcher/DNSCatcher
4
9617
-- Copyright 2019 <NAME> <<EMAIL>> -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to -- deal in the Software without restriction, including without limitation the -- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -- sell copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. with Ada.Strings; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with DNSCatcher.Utils; use DNSCatcher.Utils; with System; package body DNSCatcher.DNS.Processor.Packet is function Packet_Parser (Logger : Logger_Message_Packet_Ptr; Packet : Raw_Packet_Record_Ptr) return Parsed_DNS_Packet_Ptr is Parsed_Packet : Parsed_DNS_Packet_Ptr; Current_Offset : Stream_Element_Offset := 1; begin Parsed_Packet := new Parsed_DNS_Packet; Logger.Push_Component ("Packet Parser"); -- Copy the header as it's already parsed Parsed_Packet.Header := Packet.all.Raw_Data.Header; if Parsed_Packet.Header.Query_Response_Flag then Logger.Log_Message (DEBUG, "Client Requested DNS Packet"); else Logger.Log_Message (DEBUG, "Server Response DNS Packet"); end if; if Parsed_Packet.Header.Truncated then Logger.Log_Message (DEBUG, "Packet is truncated!"); end if; declare Found : Boolean := False; begin for RCode in RCodes loop if Integer (Parsed_Packet.Header.Response_Code) = RCode'Enum_Rep then Logger.Log_Message (DEBUG, "Response code: " & RCodes'Image (RCode)); Found := True; end if; exit when Found; end loop; if not Found then raise Unknown_RCode; end if; end; Logger.Log_Message (DEBUG, "Question Count:" & Parsed_Packet.Header.Question_Count'Image); Logger.Log_Message (DEBUG, "Answer Count:" & Parsed_Packet.Header.Answer_Record_Count'Image); Logger.Log_Message (DEBUG, "Authority Count:" & Parsed_Packet.Header.Authority_Record_Count'Image); Logger.Log_Message (DEBUG, "Additional Count:" & Parsed_Packet.Header.Additional_Record_Count'Image); for i in 1 .. Parsed_Packet.Header.Question_Count loop Parsed_Packet.Questions.Append (Parse_Question_Record (Logger, Packet.Raw_Data.Data, Current_Offset)); end loop; for i in 1 .. Parsed_Packet.Header.Answer_Record_Count loop Parsed_Packet.Answer.Append (Parse_Resource_Record_Response (Logger, Packet.Raw_Data, Current_Offset)); end loop; for i in 1 .. Parsed_Packet.Header.Authority_Record_Count loop Parsed_Packet.Authority.Append (Parse_Resource_Record_Response (Logger, Packet.Raw_Data, Current_Offset)); end loop; for i in 1 .. Parsed_Packet.Header.Additional_Record_Count loop Parsed_Packet.Additional.Append (Parse_Resource_Record_Response (Logger, Packet.Raw_Data, Current_Offset)); end loop; Logger.Pop_Component; return Parsed_Packet; end Packet_Parser; -- I apologize in advance, this function is a real mindfuck. function Parse_DNS_Packet_Name_Records (Raw_Data : Raw_DNS_Packet_Data_Ptr; Offset : in out Stream_Element_Offset) return Unbounded_String is Domain_Name : Unbounded_String; Section_Length : Unsigned_8; type Packer_Pointer is record Packet_Offset : Unsigned_16; end record; for Packer_Pointer'Bit_Order use System.High_Order_First; for Packer_Pointer'Scalar_Storage_Order use System.High_Order_First; pragma Pack (Packer_Pointer); Packet_Ptr : Packer_Pointer; begin -- This is fucked up. DNS basically defines the first octlet of the -- length of a level of a domain section, so we need to parse that, then -- build a proper domain string out of it. Also, shit can be compressed. -- Kill me now. Section_Length := Unsigned_8 (Raw_Data.all (Offset)); if Section_Length = 0 then -- It is possible for the section length to be zero for some record -- requests or dealing with the root. Thus just return blank Offset := Offset + 1; return To_Unbounded_String (""); end if; loop -- Records can be compressed, denoted by Section Length of leading -- binary bytes 11 so we need to handle both cases properly -- -- This is flipping bullshit, and I dunno if I should be pissed at the -- Ada guys or the DNS ones. Basically, the top two bits of the offset -- represent if its compressed or not, with the rest being used as an -- offset. Normally, you can handle that via byte order and shit, but -- Ada gets confused when doing this because you basically have you -- most significant bytes at the other end. -- -- Given we're already in the correct memory format, we'll just use -- bitwise ops because I've already raged hard enough here if (Section_Length and 16#c0#) = 0 -- Not compressed then Offset := Offset + 1; -- Move past the length declare subtype Domain_Section is String (1 .. Integer (Section_Length)); function To_Domain_Section is new Ada.Unchecked_Conversion (Source => Stream_Element_Array, Target => Domain_Section); begin Domain_Name := Domain_Name & To_Domain_Section (Raw_Data.all (Offset .. Stream_Element_Offset (Section_Length))); Offset := Offset + Stream_Element_Offset (Section_Length); end; elsif (Section_Length and 16#c0#) /= 0 then -- Standard compression is nuts. We have a pointer within the -- packet that basically contains a link to the string segment -- we need next. Let's see if we can grab it and decode it declare Decompressed_Domain_String : Unbounded_String; function Get_Byte_Fixed_Header is new Ada.Unchecked_Conversion (Source => Stream_Element_Array, Target => Packer_Pointer); begin -- Oh, and for more fuckery, the pointer is 16-bit ... Packet_Ptr := Get_Byte_Fixed_Header (Raw_Data.all (Offset .. Offset + 1)); -- Make the top bytes vanish -- We subtract 12-1 for the packet header Packet_Ptr.Packet_Offset := (Packet_Ptr.Packet_Offset and 16#3fff#) - 11; -- Sanity check ourselves if (Section_Length and 2#11#) /= 0 then -- Should never happen but you never know ... raise Unknown_Compression_Method; end if; -- Now we need to decode the whole old string ... ugh Decompressed_Domain_String := Parse_DNS_Packet_Name_Records (Raw_Data, Stream_Element_Offset (Packet_Ptr.Packet_Offset)); Offset := Offset + 2; return Domain_Name & Decompressed_Domain_String; end; else -- Welp, unknown compression, bail out raise Unknown_Compression_Method; end if; Section_Length := Unsigned_8 (Raw_Data.all (Offset)); exit when Section_Length = 0; -- Tack on the . if this isn't the last iteration Domain_Name := Domain_Name & "."; end loop; Offset := Offset + 1; return Domain_Name; end Parse_DNS_Packet_Name_Records; function Parse_DNS_RR_Type (Raw_Data : Raw_DNS_Packet_Data_Ptr; Offset : in out Stream_Element_Offset) return RR_Types is Found_RRType : RR_Types; RR_Type_Raw : Unsigned_16; begin declare Found : Boolean := False; begin RR_Type_Raw := Read_Unsigned_16 (Raw_Data, Offset); for RR_Type in RR_Types loop if RR_Type_Raw = RR_Type'Enum_Rep then Found_RRType := RR_Type; Found := True; end if; end loop; if not Found then raise Unknown_RR_Type; end if; end; return Found_RRType; end Parse_DNS_RR_Type; function Parse_DNS_Class (Raw_Data : Raw_DNS_Packet_Data_Ptr; Offset : in out Stream_Element_Offset) return Classes is Found_Class : Classes; Raw_Class : Unsigned_16; begin -- The last 32-bits is the type and class declare Found : Boolean := False; begin Raw_Class := Read_Unsigned_16 (Raw_Data, Offset); for Class in Classes loop if Raw_Class = Class'Enum_Rep then Found_Class := Class; Found := True; end if; end loop; if not Found then raise Unknown_Class; end if; end; return Found_Class; end Parse_DNS_Class; -- Parses the questions asked in a DNS record function Parse_Question_Record (Logger : Logger_Message_Packet_Ptr; Raw_Data : Raw_DNS_Packet_Data_Ptr; Offset : in out Stream_Element_Offset) return Parsed_DNS_Question is Parsed_Question : Parsed_DNS_Question; begin Logger.Push_Component ("Question Parser"); -- Get the QName Parsed_Question.QName := Parse_DNS_Packet_Name_Records (Raw_Data, Offset); Parsed_Question.QType := Parse_DNS_RR_Type (Raw_Data, Offset); Parsed_Question.QClass := Parse_DNS_Class (Raw_Data, Offset); -- Parsed_Question.QClass := DNS_Classes.DNS_Classes(Unsigned_16(Raw_Data(Offset+2..Offset+2))); Logger.Log_Message (DEBUG, "QName is " & To_String (Parsed_Question.QName)); Logger.Log_Message (DEBUG, "QType is " & To_String (Parsed_Question.QType)); Logger.Log_Message (DEBUG, "QClass is " & To_String (Parsed_Question.QClass)); Logger.Pop_Component; return Parsed_Question; end Parse_Question_Record; function Parse_Resource_Record_Response (Logger : Logger_Message_Packet_Ptr; Packet : Raw_DNS_Packet; Offset : in out Stream_Element_Offset) return Parsed_RData_Access is Parsed_Response : Parsed_DNS_Resource_Record; Raw_Data : Raw_DNS_Packet_Data_Ptr; RData_Length : Unsigned_16; Parsed_RData_Response : Parsed_RData_Access; begin -- Create direct reference to the raw data Raw_Data := Packet.Data; Logger.Push_Component ("RRecord Parser"); Parsed_Response.RName := Parse_DNS_Packet_Name_Records (Raw_Data, Offset); Parsed_Response.RType := Parse_DNS_RR_Type (Raw_Data, Offset); Parsed_Response.RClass := Read_Unsigned_16 (Raw_Data, Offset); Parsed_Response.TTL := Read_Unsigned_32 (Raw_Data, Offset); -- What follows is the length as a 16 bit integer, then the RData which -- needs an unchecked conversion RData_Length := Read_Unsigned_16 (Raw_Data, Offset); Logger.Log_Message (DEBUG, "RName is " & To_String (Parsed_Response.RName)); Logger.Log_Message (DEBUG, "RType is " & To_String (Parsed_Response.RType)); Logger.Log_Message (DEBUG, "RClass is" & Parsed_Response.RClass'Image); Logger.Log_Message (DEBUG, "TTL is" & Parsed_Response.TTL'Image); Logger.Log_Message (DEBUG, "RDLength is" & RData_Length'Image); -- RData parsing often needs the whole packet if DNS Compression is used, -- so give it a copy, and set the offset for them. Parsed_Response.Raw_Packet := new Stream_Element_Array (1 .. Raw_Data'Last); Parsed_Response.Raw_Packet.all := Raw_Data.all; Parsed_Response.RData_Offset := Offset; declare subtype RData is String (1 .. Integer (RData_Length)); function To_RData is new Ada.Unchecked_Conversion (Source => Stream_Element_Array, Target => RData); begin Parsed_Response.RData := To_Unbounded_String (To_RData (Raw_Data (Offset .. Stream_Element_Offset (RData_Length)))); Offset := Offset + Stream_Element_Offset (RData_Length); end; Parsed_RData_Response := To_Parsed_RData (Packet.Header, Parsed_Response); Logger.Log_Message (DEBUG, "RData is " & Parsed_RData_Response.RData_To_String); Logger.Pop_Component; return Parsed_RData_Response; end Parse_Resource_Record_Response; procedure Free_Parsed_DNS_Packet (Packet : in out Parsed_DNS_Packet_Ptr) is procedure Free_Ptr is new Ada.Unchecked_Deallocation (Object => Parsed_DNS_Packet, Name => Parsed_DNS_Packet_Ptr); begin Packet.Questions.Clear; for I of Packet.Answer loop I.Delete; end loop; for I of Packet.Authority loop I.Delete; end loop; for I of Packet.Additional loop I.Delete; end loop; Packet.Answer.Clear; Packet.Authority.Clear; Packet.Additional.Clear; Free_Ptr (Packet); end Free_Parsed_DNS_Packet; end DNSCatcher.DNS.Processor.Packet;
shardingsphere-rdl-parser/shardingsphere-rdl-parser-sql/src/main/antlr4/imports/RDLStatement.g4
meiavy/sharding-jdbc
0
6165
<reponame>meiavy/sharding-jdbc<gh_stars>0 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ grammar RDLStatement; import Keyword, Literals, Symbol; createDatasource : CREATE DATASOURCE datasource (COMMA datasource)* ; createShardingrule : CREATE SHARDINGRULE shardingrule (COMMA shardingrule)* ; shardingrule : key EQ shardingruleValue ; datasource : key EQ datasourceValue ; key : IDENTIFIER ; datasourceValue : hostName COLON port COLON dbName COLON user COLON password ; shardingruleValue : strategyType LP strategyValue RP ; strategyType : IDENTIFIER ; strategyValue : tableName COMMA columName COMMA strategyProps+ ; strategyProps : strategyProp (COMMA strategyProp)* ; strategyProp : IDENTIFIER | NUMBER | INT ; tableName : IDENTIFIER UL* IDENTIFIER* ; columName : IDENTIFIER UL* IDENTIFIER* ; hostName : ip | IDENTIFIER ; ip : NUMBER+ INT ; port : INT ; dbName : IDENTIFIER | NUMBER ; user : IDENTIFIER | NUMBER ; password : IDENTIFIER | NUMBER ;
libsrc/stdio/rcmx000/getk.asm
meesokim/z88dk
0
9398
<filename>libsrc/stdio/rcmx000/getk.asm ; ; RCM2/3000 Stdio ; ; $Id: getk.asm,v 1.2 2015/01/21 08:09:27 stefano Exp $ ; PUBLIC getk EXTERN rcmx000_cnvtab EXTERN __recvchar .getk ; extern int __LIB__ fgetc(FILE *fp); ; return result in HL, when done ; We ignore FILE* fp (in BC) for now call __recvchar ld h,0 ld l,a ret
projects/batfish/src/main/antlr4/org/batfish/grammar/arista/Arista_vlan.g4
ton31337/batfish
763
4769
<reponame>ton31337/batfish parser grammar Arista_vlan; import Legacy_common; options { tokenVocab = AristaLexer; } no_vlan: VLAN eos_vlan_id NEWLINE; s_vlan : VLAN eos_vlan_id NEWLINE vlan_inner* ; vlan_inner : vlan_default | vlan_name | vlan_no | vlan_state | vlan_trunk ; vlan_default : DEFAULT ( vlan_d_name | vlan_d_state | vlan_d_trunk ) ; vlan_d_name: NAME NEWLINE; vlan_d_state: STATE NEWLINE; vlan_d_trunk: TRUNK GROUP NEWLINE; vlan_name : NAME name = variable NEWLINE ; vlan_no : NO ( vlan_no_name | vlan_no_state | vlan_no_trunk ) ; vlan_no_name : NAME (name = variable)? NEWLINE ; vlan_no_state : STATE (ACTIVE | SUSPEND)? NEWLINE ; vlan_no_trunk : TRUNK GROUP (name = variable)? NEWLINE ; vlan_state : STATE (ACTIVE | SUSPEND) NEWLINE ; vlan_trunk : TRUNK GROUP name = variable NEWLINE ; default_vlan_internal : VLAN INTERNAL ALLOCATION POLICY (ASCENDING | DESCENDING)? (RANGE lo=dec hi=dec)? NEWLINE ; no_vlan_internal : VLAN INTERNAL ALLOCATION POLICY (ASCENDING | DESCENDING)? (RANGE lo=dec hi=dec)? NEWLINE ; s_vlan_internal : VLAN INTERNAL ALLOCATION POLICY (ASCENDING | DESCENDING) RANGE lo=dec hi=dec NEWLINE ;
PIM/TD4_Constructeurs_de_Types/robot_type_1.adb
Hathoute/ENSEEIHT
1
25747
-- Score PIXAL le 07/10/2020 à 14:33 : 100% with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure Robot_Type_1 is -- Direction type T_Direction is (NORD, EST, SUD, OUEST); -- Robot type 1 type T_Robot_1 is record Absc: Integer; -- Abscisse du robot Ord: Integer; -- Ordonnée du robot Orientation: T_Direction; -- Orientation du robot end record; -- Environnement: MAX_X: constant Integer := 10; MAX_Y: constant Integer := 10; type T_Environnement is array (-MAX_X..MAX_X, -MAX_Y..MAX_Y) of Boolean; --| Le programme principal |------------------------------------------------ R1: T_Robot_1; -- Robot 1 R2: T_Robot_1; -- Robot 2 E1: T_Environnement; -- L'Environnement begin -- Initialisation de R1 pour que son abscisse soit 4, son ordonnée 2 et sa direction ouest R1 := (Absc => 4, Ord => 2, Orientation => OUEST); -- Initialisation de R2 avec R1 R2 := R1; -- Modification de l'abscisse de R1 pour qu'elle devienne 3 R1.Absc := 3; -- Afficher l'abscisse de R1. La valeur affichée sera 3 Put ("Abscisse de R1 : "); Put (R1.Absc, 1); New_Line; -- Afficher l'abscisse de R2. La valeur affichée sera 4 Put ("Abscisse de R2 : "); Put (R2.Absc, 1); New_Line; -- Modifier l'environnement pour que la case de coordonnées (4,2) soit libre. E1(4, 2) := True; -- Afficher "OK" si le robot R1 est sur une case libre, "ERREUR" sinon if E1(R1.Absc, R1.Ord) then Put_Line ("OK"); else Put_Line ("ERREUR"); end if; --! Résponses aux questions: -- 1: T_Direction est Enum (NORD, EST, SUD, OUEST) -- T_Robot_1 est Enregistrement: X is Integer, Y is Integer, Direction is T_Direction. -- -- 2: T_Environnement est Matrice (minX..maxX, minY..maxY) de type Boolean -- -- 3: Obtenir son abscisse: x := robot.X -- robot.Direction := NORD -- environnement(robot.x, robot.y) (retourne un boolean) -- -- 4: Les sous-programmes à ajouter: Tourner_Droite, Avancer. end Robot_Type_1;
base/crts/fpw32/tran/i386/87ctrigh.asm
npocmaka/Windows-Server-2003
17
24971
page ,132 title 87ctrigh - C interfaces - sinh, cosh, tanh ;*** ;87ctrigh.asm - hyperbolic trig functions (8087/emulator version) ; ; Copyright (c) 1984-2001, Microsoft Corporation. All rights reserved. ; ;Purpose: ; C interfaces for sinh, cosh, tanh functions (8087/emulator version) ; ;Revision History: ; 07-04-84 GFW initial version ; 05-08-87 BCM added C intrinsic interface (_CI...) ; 10-12-87 BCM changes for OS/2 Support Library ; 11-24-87 BCM added _loadds under ifdef DLL ; 01-18-88 BCM eliminated IBMC20; ifos2,noos2 ==> ifmt,nomt ; 08-26-88 WAJ 386 version ; 11-20-89 WAJ Don't need pascal for MTHREAD 386. ; ;******************************************************************************* .xlist include cruntime.inc .list .data extrn _OP_SINHjmptab:word extrn _OP_COSHjmptab:word extrn _OP_TANHjmptab:word page CODESEG extrn _ctrandisp1:near extrn _ctrandisp2:near public sinh sinh proc mov rdx, OFFSET _OP_SINHjmptab disp1:: jmp _ctrandisp1 sinh endp public cosh cosh proc mov rdx, OFFSET _OP_COSHjmptab jmp disp1 cosh endp public tanh tanh proc mov rdx, OFFSET _OP_TANHjmptab jmp disp1 tanh endp extrn _cintrindisp1:near extrn _cintrindisp2:near public _CIsinh _CIsinh proc mov rdx, OFFSET _OP_SINHjmptab idisp1:: jmp _cintrindisp1 _CIsinh endp public _CIcosh _CIcosh proc mov rdx, OFFSET _OP_COSHjmptab jmp idisp1 _CIcosh endp public _CItanh _CItanh proc mov rdx, OFFSET _OP_TANHjmptab jmp idisp1 _CItanh endp end
tools/scitools/conf/understand/ada/ada05/a-cihama.ads
brucegua/moocos
1
4
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . C O N T A I N E R S . -- -- I N D E F I N I T E _ H A S H E D _ M A P S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2004-2006, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- This unit was originally developed by <NAME>. -- ------------------------------------------------------------------------------ with Ada.Containers.Hash_Tables; with Ada.Streams; with Ada.Finalization; generic type Key_Type (<>) is private; type Element_Type (<>) is private; with function Hash (Key : Key_Type) return Hash_Type; with function Equivalent_Keys (Left, Right : Key_Type) return Boolean; with function "=" (Left, Right : Element_Type) return Boolean is <>; package Ada.Containers.Indefinite_Hashed_Maps is pragma Preelaborate; type Map is tagged private; pragma Preelaborable_Initialization (Map); type Cursor is private; pragma Preelaborable_Initialization (Cursor); Empty_Map : constant Map; No_Element : constant Cursor; function "=" (Left, Right : Map) return Boolean; function Capacity (Container : Map) return Count_Type; procedure Reserve_Capacity (Container : in out Map; Capacity : Count_Type); function Length (Container : Map) return Count_Type; function Is_Empty (Container : Map) return Boolean; procedure Clear (Container : in out Map); function Key (Position : Cursor) return Key_Type; function Element (Position : Cursor) return Element_Type; procedure Replace_Element (Container : in out Map; Position : Cursor; New_Item : Element_Type); procedure Query_Element (Position : Cursor; Process : not null access procedure (Key : Key_Type; Element : Element_Type)); procedure Update_Element (Container : in out Map; Position : Cursor; Process : not null access procedure (Key : Key_Type; Element : in out Element_Type)); procedure Move (Target : in out Map; Source : in out Map); procedure Insert (Container : in out Map; Key : Key_Type; New_Item : Element_Type; Position : out Cursor; Inserted : out Boolean); procedure Insert (Container : in out Map; Key : Key_Type; New_Item : Element_Type); procedure Include (Container : in out Map; Key : Key_Type; New_Item : Element_Type); procedure Replace (Container : in out Map; Key : Key_Type; New_Item : Element_Type); procedure Exclude (Container : in out Map; Key : Key_Type); procedure Delete (Container : in out Map; Key : Key_Type); procedure Delete (Container : in out Map; Position : in out Cursor); function First (Container : Map) return Cursor; function Next (Position : Cursor) return Cursor; procedure Next (Position : in out Cursor); function Find (Container : Map; Key : Key_Type) return Cursor; function Contains (Container : Map; Key : Key_Type) return Boolean; function Element (Container : Map; Key : Key_Type) return Element_Type; function Has_Element (Position : Cursor) return Boolean; function Equivalent_Keys (Left, Right : Cursor) return Boolean; function Equivalent_Keys (Left : Cursor; Right : Key_Type) return Boolean; function Equivalent_Keys (Left : Key_Type; Right : Cursor) return Boolean; procedure Iterate (Container : Map; Process : not null access procedure (Position : Cursor)); private pragma Inline ("="); pragma Inline (Length); pragma Inline (Is_Empty); pragma Inline (Clear); pragma Inline (Key); pragma Inline (Element); pragma Inline (Move); pragma Inline (Contains); pragma Inline (Capacity); pragma Inline (Reserve_Capacity); pragma Inline (Has_Element); pragma Inline (Equivalent_Keys); type Node_Type; type Node_Access is access Node_Type; type Key_Access is access Key_Type; type Element_Access is access Element_Type; type Node_Type is limited record Key : Key_Access; Element : Element_Access; Next : Node_Access; end record; package HT_Types is new Hash_Tables.Generic_Hash_Table_Types (Node_Type, Node_Access); type Map is new Ada.Finalization.Controlled with record HT : HT_Types.Hash_Table_Type; end record; use HT_Types; use Ada.Finalization; use Ada.Streams; procedure Adjust (Container : in out Map); procedure Finalize (Container : in out Map); type Map_Access is access constant Map; for Map_Access'Storage_Size use 0; type Cursor is record Container : Map_Access; Node : Node_Access; end record; procedure Write (Stream : access Root_Stream_Type'Class; Item : Cursor); for Cursor'Write use Write; procedure Read (Stream : access Root_Stream_Type'Class; Item : out Cursor); for Cursor'Read use Read; No_Element : constant Cursor := (Container => null, Node => null); procedure Write (Stream : access Root_Stream_Type'Class; Container : Map); for Map'Write use Write; procedure Read (Stream : access Root_Stream_Type'Class; Container : out Map); for Map'Read use Read; Empty_Map : constant Map := (Controlled with HT => (null, 0, 0, 0)); end Ada.Containers.Indefinite_Hashed_Maps;
jvm_demo/java/expression/antlr/practice_myself/src/main/java/com/hwloser/simple/predicate/SimplePredicate.g4
Hwloser/untitled
0
2912
<gh_stars>0 grammar SimplePredicate; expression : LPAREN expression RPAREN #parenExpression | NOT expression #notExpression | left=expression op=operator right=expression #operatorExpression | left=expression op=comparator right=expression #comparatorExpression | left=expression op=binary right=expression #binaryExpression | IDENTIFIER #identifierExpression | DECIMAL #decimalExpression ; operator : Add | SUB | MUL | DIV ; comparator : GT | GE | LT | LE | EQ ; binary : AND | OR ; MUL : '*' ; DIV : '/' ; Add : '+' ; SUB : '-' ; AND : '&' ; OR : '|' ; NOT : '!' ; TRUE : 'TRUE' ; FALSE : 'FALSE' ; GT : '>' ; GE : '>=' ; LT : '<' ; LE : '<=' ; EQ : '=' ; LPAREN : '(' ; RPAREN : ')' ; DECIMAL : '-'? [0-9]+ ( '.' [0-9]+ )? ; IDENTIFIER : [a-zA-Z_] [a-zA-Z_0-9]* ; WS : [ \r\t\u000C\n]+ -> channel(HIDDEN);
libsrc/_DEVELOPMENT/arch/ts2068/display/c/sdcc/tshr_py2saddr_fastcall.asm
jpoikela/z88dk
640
85516
; void *tshr_py2saddr(uchar y) SECTION code_clib SECTION code_arch PUBLIC _tshr_py2saddr_fastcall EXTERN _zx_py2saddr_fastcall defc _tshr_py2saddr_fastcall = _zx_py2saddr_fastcall
src/osascripts/messages-conversations.applescript
jokajak/ki
83
3815
<filename>src/osascripts/messages-conversations.applescript<gh_stars>10-100 -- AppleScript to fetch a list of Messages conversations -- The return value is a list of strings, each of the contact's name, last message, and time last sent tell application "System Events" set conversations to {} tell table 1 of scroll area 1 of splitter group 1 of window 1 of application process "Messages" repeat with i from 1 to (count rows) set message to description of UI element 1 of row i set conversations to conversations & message end repeat end tell return conversations end tell
src/unix/system_random.adb
AntonMeep/system_random
0
3479
<filename>src/unix/system_random.adb<gh_stars>0 pragma Ada_2012; package body System_Random is -- Underlying libc function function getentropy (buffer : out Element_Array; length : size_t) return int with Import => True, Convention => C, External_Name => "getentropy"; procedure Random (Output : aliased out Element_Array) is Return_Code : int := 0; begin Return_Code := getentropy (Output, size_t (Output'Length)); -- We're okay with this as Ada should automagically pass an address -- of the first array element. Array is defined as aliased array of -- aliased Elements, so that no funny business occurs -- We already checked in contract that Output'Length is less or -- equal to size_t'Last, therefore Constraint_Error is not -- going to ever occur here if Return_Code /= 0 then raise System_Random_Error with "getentropy failed with status code " & Return_Code'Image; end if; end Random; end System_Random;
programs/oeis/094/A094977.asm
neoneye/loda
22
98248
; A094977: a(n) = floor(10^n/3^n). ; 1,3,11,37,123,411,1371,4572,15241,50805,169350,564502,1881676,6272254,20907515,69691719,232305731,774352437,2581174791,8603915972,28679719907,95599066359,318663554532,1062211848441,3540706161472,11802353871573,39341179571912,131137265239709,437124217465697,1457080724885658,4856935749618861,16189785832062870,53965952773542901,179886509245143005,599621697483810017,1998738991612700056,6662463305375666855,22208211017918889519,74027370059729631731,246757900199098772438,822526333996995908128,2741754446656653027094,9139181488855510090313,30463938296185033634377,101546460987283445447926,338488203290944818159755,1128294010969816060532518,3760980036566053535108394,12536600121886845117027981,41788667072956150390093270,139295556909853834633644234,464318523032846115445480781,1547728410109487051484935938,5159094700364956838283119794,17196982334549856127610399316,57323274448499520425367997720,191077581494998401417893325733,636925271649994671392977752444,2123084238833315571309925841482,7076947462777718571033086138273,23589824875925728570110287127578,78632749586419095233700957091928,262109165288063650779003190306429,873697217626878835930010634354766,2912324058756262786433368781182555,9707746862520875954777895937275184,32359156208402919849259653124250615,107863854028009732830865510414168716,359546180093365776102885034713895722 mov $1,10 pow $1,$0 mov $2,3 pow $2,$0 div $1,$2 mov $0,$1
programs/oeis/094/A094988.asm
neoneye/loda
22
102297
; A094988: a(n) = floor(7^n/6^n). ; 1,1,1,1,1,2,2,2,3,4,4,5,6,7,8,10,11,13,16,18,21,25,29,34,40,47,55,64,74,87,101,118,138,161,188,220,257,299,349,408,476,555,648,756,882,1029,1201,1401,1634,1907,2225,2595,3028,3533,4122,4809,5610,6545,7636,8909,10394,12127,14148,16506,19257,22466,26211,30579,35676,41622,48559,56652,66095,77110,89962,104956,122449,142857,166666,194444,226852,264661,308771,360233,420271,490317,572036,667376,778605,908373,1059768,1236396,1442462,1682873,1963352,2290577,2672340,3117730,3637352,4243577 mov $1,21 pow $1,$0 mov $2,18 pow $2,$0 div $1,$2 mov $0,$1
Ada/challenge_399_easy.adb
PyllrNL/Dailyprogrammer_Solutions
0
3888
<gh_stars>0 with Ada.Text_IO; use Ada.Text_IO; procedure Challenge_399_Easy is function Letter_Sum( A : String ) return Integer is Base : constant Integer := (Character'pos('a') - 1); Sum : Integer := 0; begin for I in A'Range loop Sum := Sum + Character'pos(A(I)) - Base; end loop; return Sum; end Letter_Sum; begin Put_Line(Integer'Image(Letter_Sum("microspectrophotometries"))); end Challenge_399_Easy;
Data/List/Relation/Sublist/Proofs.agda
Lolirofle/stuff-in-agda
6
9210
import Lvl open import Type module Data.List.Relation.Sublist.Proofs {ℓ} {T : Type{ℓ}} where open import Data.Boolean import Data.Either as Either open import Data.List as List open import Data.List.Functions as List hiding (skip) open import Data.List.Proofs open import Data.List.Relation.Sublist open import Data.Tuple as Tuple using (_,_) open import Functional open import Logic.Propositional open import Logic.Predicate open import Numeral.Natural open import Numeral.Natural.Inductions open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Proofs open import Relator.Equals open import Relator.Equals.Proofs open import Structure.Relator.Ordering open import Structure.Relator.Ordering.Proofs open import Structure.Relator.Properties private variable ℓ₂ : Lvl.Level private variable T₂ : Type{ℓ₂} private variable a x y : T private variable l l₁ l₂ l₃ : List(T) private variable n : ℕ [⊑]-reflexivity : (l ⊑ l) [⊑]-reflexivity {∅} = empty [⊑]-reflexivity {a ⊰ l} = use([⊑]-reflexivity{l}) [⊑]-prepend : (l ⊑ x ⊰ l) [⊑]-prepend {∅} = skip empty [⊑]-prepend {x ⊰ l} = skip [⊑]-reflexivity [⊑]-without-[⊰] : ((x ⊰ l₁) ⊑ (y ⊰ l₂)) → (l₁ ⊑ l₂) [⊑]-without-[⊰] (use p) = p [⊑]-without-[⊰] (skip(use p)) = skip p [⊑]-without-[⊰] {x = x}{y = y} (skip(skip p)) = skip([⊑]-without-[⊰] {x = x}{y = y} (skip p)) [⊑]-transitivity : (l₁ ⊑ l₂) → (l₂ ⊑ l₃) → (l₁ ⊑ l₃) [⊑]-transitivity empty empty = empty [⊑]-transitivity empty (skip l₂l₃) = skip l₂l₃ [⊑]-transitivity (use l₁l₂) (use l₂l₃) = use([⊑]-transitivity l₁l₂ l₂l₃) [⊑]-transitivity (use l₁l₂) (skip l₂l₃) = skip([⊑]-transitivity (use l₁l₂) l₂l₃) [⊑]-transitivity (skip l₁l₂) (use l₂l₃) = skip([⊑]-transitivity l₁l₂ l₂l₃) [⊑]-transitivity (skip l₁l₂) (skip l₂l₃) = skip([⊑]-transitivity (skip l₁l₂) l₂l₃) [⊑]-not-prepend : ¬((x ⊰ l) ⊑ l) [⊑]-not-prepend {x} {x ⊰ l₂} (use p) = [⊑]-not-prepend {x}{l₂} p [⊑]-not-prepend {x} {y ⊰ _} (skip p) = [⊑]-not-prepend([⊑]-without-[⊰] {y = y} (skip p)) [⊑]-antisymmetry : (l₂ ⊑ l₁) → (l₁ ⊑ l₂) → (l₁ ≡ l₂) [⊑]-antisymmetry {∅} {∅} l r = [≡]-intro [⊑]-antisymmetry {y ⊰ l₂} {.y ⊰ l₁} (use l) r = [≡]-with(y ⊰_) ([⊑]-antisymmetry l ([⊑]-without-[⊰] r)) [⊑]-antisymmetry {y ⊰ l₂} {.y ⊰ l₁} (skip l) (use r) = [≡]-with(y ⊰_) ([⊑]-antisymmetry ([⊑]-without-[⊰] {y = y} (skip l)) r) [⊑]-antisymmetry {y ⊰ l₂} {x ⊰ l₁} (skip l) (skip r) = [⊥]-elim ([⊑]-not-prepend ([⊑]-transitivity (skip r) l)) [⊑]-minimum : (∅ ⊑ l) [⊑]-minimum {∅} = empty [⊑]-minimum {a ⊰ l} = skip([⊑]-minimum{l}) [⊑]ᵣ-of-[++]ₗ : (l₁ ⊑ (l₂ ++ l₁)) [⊑]ᵣ-of-[++]ₗ {l₁}{∅} = [⊑]-reflexivity [⊑]ᵣ-of-[++]ₗ {l₁}{a ⊰ l₂} = skip{x = a}([⊑]ᵣ-of-[++]ₗ {l₁}{l₂}) [⊑]ᵣ-of-[++]ᵣ : (l₁ ⊑ (l₁ ++ l₂)) [⊑]ᵣ-of-[++]ᵣ {∅} {l₂} = [⊑]-minimum [⊑]ᵣ-of-[++]ᵣ {a ⊰ l₁}{l₂} = use([⊑]ᵣ-of-[++]ᵣ{l₁}{l₂}) [⊑]-tail : (tail l ⊑ l) [⊑]-tail {∅} = empty [⊑]-tail {a ⊰ l} = skip [⊑]-reflexivity [⊑]-map : ∀{f : T → T₂} → (l₁ ⊑ l₂) → (map f(l₁) ⊑ map f(l₂)) [⊑]-map empty = empty [⊑]-map (use p) = use ([⊑]-map p) [⊑]-map (skip p) = skip ([⊑]-map p) [⊑]-filter : ∀{f} → (filter f(l) ⊑ l) [⊑]-filter {∅} = empty [⊑]-filter {x ⊰ l} {f} with f(x) ... | 𝑇 = use ([⊑]-filter {l}) ... | 𝐹 = skip ([⊑]-filter {l}) [⊑]-separate₂ : let (l₁ , l₂) = separate₂(l) in (l₁ ⊑ l) ∧ (l₂ ⊑ l) Tuple.left ([⊑]-separate₂ {∅}) = empty Tuple.left ([⊑]-separate₂ {x ⊰ ∅}) = [⊑]-reflexivity Tuple.left ([⊑]-separate₂ {x ⊰ y ⊰ l}) = use (skip (Tuple.left [⊑]-separate₂)) Tuple.right ([⊑]-separate₂ {∅}) = empty Tuple.right ([⊑]-separate₂ {x ⊰ ∅}) = skip [⊑]-reflexivity Tuple.right ([⊑]-separate₂ {x ⊰ y ⊰ l}) = skip (use (Tuple.right [⊑]-separate₂)) [⊑]-postpend : (l ⊑ postpend a l) [⊑]-postpend {∅} = skip empty [⊑]-postpend {x ⊰ l} = use [⊑]-postpend [⊑]-withoutIndex : (withoutIndex n l ⊑ l) [⊑]-withoutIndex {𝟎} {∅} = empty [⊑]-withoutIndex {𝐒 n} {∅} = empty [⊑]-withoutIndex {𝟎} {x ⊰ l} = skip [⊑]-reflexivity [⊑]-withoutIndex {𝐒 n} {x ⊰ l} = use [⊑]-withoutIndex [⊑]-initial : (initial n l ⊑ l) [⊑]-initial {𝟎} {∅} = empty [⊑]-initial {𝐒 n} {∅} = empty [⊑]-initial {𝟎} {x ⊰ l} = [⊑]-minimum [⊑]-initial {𝐒 n} {x ⊰ l} = use [⊑]-initial [⊑]-skip : (List.skip n l ⊑ l) [⊑]-skip {𝟎} {∅} = empty [⊑]-skip {𝐒 n} {∅} = empty [⊑]-skip {𝟎} {x ⊰ l} = [⊑]-reflexivity [⊑]-skip {𝐒 n} {x ⊰ l} = skip [⊑]-skip [⊑]-empty : (l ⊑ ∅) → (l ≡ ∅) [⊑]-empty {∅} _ = [≡]-intro [⊑]-empty {_ ⊰ _} () [⊑]-length : (l₁ ⊑ l₂) → (length(l₁) ≤ length(l₂)) [⊑]-length empty = [≤]-minimum [⊑]-length (use p) = [≤]-with-[𝐒] ⦃ [⊑]-length p ⦄ [⊑]-length (skip p) = [≤]-predecessor ([≤]-with-[𝐒] ⦃ [⊑]-length p ⦄) [⊏]-without-[⊰] : ((x ⊰ l₁) ⊏ (y ⊰ l₂)) → (l₁ ⊏ l₂) [⊏]-without-[⊰] (use p) = p [⊏]-without-[⊰] (skip (use p)) = skip p [⊏]-without-[⊰] {x = x}{y = y} (skip (skip p)) = skip ([⊑]-without-[⊰] {x = x}{y = y} (skip p)) [⊏]-irreflexivity : ¬(l ⊏ l) [⊏]-irreflexivity {∅} () [⊏]-irreflexivity {x ⊰ l} p = [⊏]-irreflexivity {l} ([⊏]-without-[⊰] p) [⊏]-to-[⊑] : (l₁ ⊏ l₂) → (l₁ ⊑ l₂) [⊏]-to-[⊑] (use p) = use ([⊏]-to-[⊑] p) [⊏]-to-[⊑] (skip p) = skip p [⊏]-skip-[⊰] : (l₁ ⊏ l₂) → (l₁ ⊏ (x ⊰ l₂)) [⊏]-skip-[⊰] (use p) = skip ([⊏]-to-[⊑] (use p)) [⊏]-skip-[⊰] (skip x) = skip (skip x) [⊏]-transitivity : (l₁ ⊏ l₂) → (l₂ ⊏ l₃) → (l₁ ⊏ l₃) [⊏]-transitivity p (skip (skip q)) = skip(skip([⊑]-transitivity ([⊏]-to-[⊑] p) q)) [⊏]-transitivity (use p) (use q) = use ([⊏]-transitivity p q) [⊏]-transitivity (use p) (skip (use q)) = skip (use ([⊑]-transitivity ([⊏]-to-[⊑] p) q)) [⊏]-transitivity (skip p) (use q) = skip([⊑]-transitivity p ([⊏]-to-[⊑] q)) [⊏]-transitivity (skip p) (skip (use q)) = skip(skip([⊑]-transitivity p q)) [⊏]-asymmetry : (l₂ ⊏ l₁) → (l₁ ⊏ l₂) → ⊥ [⊏]-asymmetry p q = [⊏]-irreflexivity([⊏]-transitivity p q) [⊏]-minimum : (l ≡ ∅) ∨ (∅ ⊏ l) [⊏]-minimum {∅} = [∨]-introₗ [≡]-intro [⊏]-minimum {x ⊰ l} = [∨]-introᵣ (skip [⊑]-minimum) [⊏]-emptyₗ : (∅ ⊏ (x ⊰ l)) [⊏]-emptyₗ {l = ∅} = skip empty [⊏]-emptyₗ {l = x ⊰ l} = skip ([⊏]-to-[⊑] ([⊏]-emptyₗ {l = l})) [⊏]-emptyᵣ : ¬(l ⊏ ∅) [⊏]-emptyᵣ () [⊏]-length : (l₁ ⊏ l₂) → (length(l₁) < length(l₂)) [⊏]-length (use p) = [≤]-with-[𝐒] ⦃ [⊏]-length p ⦄ [⊏]-length (skip p) = [≤]-with-[𝐒] ⦃ [⊑]-length p ⦄ [⊏]-prepend : (l ⊏ x ⊰ l) [⊏]-prepend = skip [⊑]-reflexivity [⊏]-postpend : (l ⊏ postpend x l) [⊏]-postpend {∅} = skip empty [⊏]-postpend {a ⊰ l} = use ([⊏]-postpend {l}) [⊏]-map : ∀{f : T → T₂} → (l₁ ⊏ l₂) → (map f(l₁) ⊏ map f(l₂)) [⊏]-map (use p) = use ([⊏]-map p) [⊏]-map (skip p) = skip ([⊑]-map p) [⊏]-tail : (∅ ⊏ l) → (tail l ⊏ l) [⊏]-tail (skip _) = skip [⊑]-reflexivity [⊏]-initial : (n < length(l)) → (initial n l ⊏ l) [⊏]-initial {𝟎} {x ⊰ l} p = [⊏]-emptyₗ [⊏]-initial {𝐒 n} {x ⊰ l} p = use ([⊏]-initial {n} ([≤]-without-[𝐒] p)) [⊏]-skip : (𝟎 < n) → (n < length(l)) → (List.skip n l ⊏ l) [⊏]-skip {𝐒 n} {x ⊰ l} p q = skip [⊑]-skip [⊏]-withoutIndex : (n < length(l)) → (withoutIndex n l ⊏ l) [⊏]-withoutIndex {𝟎} {x ⊰ l} p = [⊏]-prepend [⊏]-withoutIndex {𝐒 n} {x ⊰ l} p = use ([⊏]-withoutIndex ([≤]-without-[𝐒] p)) [⊏]-separate₂ : let (l₁ , l₂) = separate₂(l) in (2 ≤ length(l)) → ((l₁ ⊏ l) ∧ (l₂ ⊏ l)) [⊏]-separate₂ {x ⊰ ∅} (succ()) Tuple.left ([⊏]-separate₂ {x ⊰ y ⊰ l} (succ (succ min))) = use (skip (Tuple.left [⊑]-separate₂)) Tuple.right ([⊏]-separate₂ {x ⊰ y ⊰ l} (succ (succ min))) = skip (use (Tuple.right [⊑]-separate₂)) [⊏]ᵣ-of-[++]ₗ : (∅ ⊏ l₂) → (l₁ ⊏ (l₂ ++ l₁)) [⊏]ᵣ-of-[++]ₗ {a ⊰ l₂} {l₁} (skip p) = skip([⊑]ᵣ-of-[++]ₗ {l₁}{l₂}) [⊏]ᵣ-of-[++]ᵣ : (∅ ⊏ l₂) → (l₁ ⊏ (l₁ ++ l₂)) [⊏]ᵣ-of-[++]ᵣ {a ⊰ l₂} {∅} (skip p) = skip p [⊏]ᵣ-of-[++]ᵣ {a ⊰ l₂} {b ⊰ l₁} (skip p) = use ([⊏]ᵣ-of-[++]ᵣ {a ⊰ l₂} {l₁} (skip p)) [⊑][⊏]-transitivity-like : (l₁ ⊑ l₂) → (l₂ ⊏ l₃) → (l₁ ⊏ l₃) [⊑][⊏]-transitivity-like p (skip q) = skip([⊑]-transitivity p q) [⊑][⊏]-transitivity-like (use p) (use q) = use ([⊑][⊏]-transitivity-like p q) [⊑][⊏]-transitivity-like (skip p) (use q) = [⊏]-skip-[⊰] ([⊑][⊏]-transitivity-like p q) instance [⊏][<]-on-length-sub : (_⊏_ {T = T}) ⊆₂ ((_<_) on₂ length) [⊏][<]-on-length-sub = intro [⊏]-length module _ where open Structure.Relator.Ordering.Strict.Properties instance [<]-on-length-well-founded : WellFounded((_<_) on₂ (length {T = T})) [<]-on-length-well-founded = wellfounded-image-by-trans instance [⊏]-well-founded : WellFounded(_⊏_ {T = T}) [⊏]-well-founded = accessibleₗ-sub₂ ⦃ [⊏][<]-on-length-sub ⦄ [⊑]-to-[⊏] : (l₁ ⊑ l₂) → ((l₁ ⊏ l₂) ∨ (length(l₁) ≡ length(l₂))) [⊑]-to-[⊏] empty = [∨]-introᵣ [≡]-intro [⊑]-to-[⊏] (use p) = Either.map use ([≡]-with(𝐒)) ([⊑]-to-[⊏] p) [⊑]-to-[⊏] (skip p) = [∨]-introₗ (skip p)
tools/uaflex/read_unicode.adb
faelys/gela-asis
4
29619
<gh_stars>1-10 ------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ -- Run this to generate symbols-unicode.adb file. -- It requires UnicodeData.txt and PropertyValueAliases.txt from Unicode.org with Ada.Text_IO; with Ada.Strings.Maps; with Ada.Strings.Fixed; with Ada.Strings.Unbounded; --with Ada.Text_IO.Integer_IO; with Ada.Containers.Vectors; procedure Read_Unicode is use Ada.Text_IO; use Ada.Strings; package U renames Ada.Strings.Unbounded; type Code_Point is range 0 .. 16#10FFFF#; package Code_Point_IO is new Ada.Text_IO.Integer_IO (Code_Point); Semicolumn : Maps.Character_Set := Maps.To_Set (";"); type Category is record Alias : String (1 .. 2); Name : U.Unbounded_String; Count : Natural := 0; end record; type Categories is array (Positive range <>) of Category; type Unicode_Data_Item is record From, To : Code_Point; Category : String (1 .. 2); end record; package Vectors is new Ada.Containers.Vectors (Positive, Unicode_Data_Item); function Read_Categories return Categories; procedure Read_Characters (Data : out Vectors.Vector); procedure Get_Field (Line : in String; From : out Positive; To : out Natural; Last : in out Natural); procedure P (Text : String); function Is_Range (Text : String) return Boolean; function Is_Last_Name (Name : String) return Boolean; function To_Code_Point (Text : String) return Code_Point; procedure To_Code_Points (Text : String; From : out Code_Point; To : out Code_Point); function Less_Category (Left, Right : Unicode_Data_Item) return Boolean; package Category_Sorting is new Vectors.Generic_Sorting (Less_Category); function "+" (Value : Natural) return String; function "+" (Value : Code_Point) return String; --------- -- "+" -- --------- function "+" (Value : Natural) return String is Image : constant String := Natural'Image (Value); begin return Image (2 .. Image'Last); end "+"; --------- -- "+" -- --------- function "+" (Value : Code_Point) return String is Text : String (1 .. 10); begin Code_Point_IO.Put (Text, Value, Base => 16); return Text; end "+"; --------------- -- Get_Field -- --------------- procedure Get_Field (Line : in String; From : out Positive; To : out Natural; Last : in out Natural) is use Ada.Strings.Fixed; begin Find_Token (Line (Last .. Line'Last), Semicolumn, Outside, From, To); if To = 0 then Last := 0; else Last := To + 1; From := Index_Non_Blank (Line (From .. To)); To := Index_Non_Blank (Line (From .. To), Backward); end if; end Get_Field; ------------------ -- Is_Last_Name -- ------------------ function Is_Last_Name (Name : String) return Boolean is begin return Fixed.Index (Name, ", Last>") > 0; end Is_Last_Name; -------------- -- Is_Range -- -------------- function Is_Range (Text : String) return Boolean is begin return Fixed.Index (Text, "..") > 0; end Is_Range; ------------------- -- Less_Category -- ------------------- function Less_Category (Left, Right : Unicode_Data_Item) return Boolean is begin return Left.Category < Right.Category or else (Left.Category = Right.Category and Left.From < Right.From); end Less_Category; ------- -- P -- ------- procedure P (Text : String) is begin Put_Line (Text); end P; -------------------- -- Print_Function -- -------------------- procedure Print_Function (List : Categories) is begin P (" function General_Category (Name : String) return Symbol_Set is"); P (" type General_Category is"); for J in List'Range loop if J = 1 then P (" (" & U.To_String (List (J).Name) & ","); elsif J = List'Last then P (" " & U.To_String (List (J).Name) & ");"); else P (" " & U.To_String (List (J).Name) & ","); end if; end loop; P (""); P (" Category : General_Category_Alias;"); P (" GC : General_Category;"); P (""); P (" begin"); P (" if Name'Length = 2 then"); P (" Category := General_Category_Alias'Value (Name);"); P (" else"); P (" GC := General_Category'Value (Name);"); P (" Category := General_Category_Alias'Val " & "(General_Category'Pos (GC));"); P (" end if;"); P (" return Values (Category);"); P (" end General_Category;"); P (""); P ("end Symbols.Unicode;"); end Print_Function; ------------------ -- Print_Header -- ------------------ procedure Print_Header is begin P ("-- This file is generated by read_unicode.adb. DON'T EDIT!"); P (""); P ("package body Symbols.Unicode is"); P (""); P (" type General_Category_Alias is"); end Print_Header; ------------------ -- Print_Values -- ------------------ procedure Print_Values (List : Categories) is begin P (" Values : constant array (General_Category_Alias) " & "of Symbol_Set :="); for J in List'Range loop if J = 1 then P (" (" & List (J).Alias & " => (F.Controlled with " & List (J).Alias & "_Node'Access),"); elsif J = List'Last then P (" " & List (J).Alias & " => (F.Controlled with " & List (J).Alias & "_Node'Access));"); else P (" " & List (J).Alias & " => (F.Controlled with " & List (J).Alias & "_Node'Access),"); end if; end loop; P (""); end Print_Values; --------------------- -- Read_Categories -- --------------------- function Read_Categories return Categories is Input : File_Type; Result : Categories (1 .. 30); Last : Natural := 0; begin Open (Input, In_File, "PropertyValueAliases.txt"); while not End_Of_File (Input) loop declare Line : constant String := Get_Line (Input); From : Positive; To : Natural; Pos : Natural := Line'First; begin Get_Field (Line, From, To, Pos); if Pos > 0 and then Line (From .. To) = "gc" then Get_Field (Line, From, To, Pos); if To - From = 1 and then Line (From .. To) /= "LC" then Last := Last + 1; Result (Last).Alias := Line (From .. To); Get_Field (Line, From, To, Pos); Result (Last).Name := U.To_Unbounded_String (Line (From .. To)); end if; end if; end; end loop; Close (Input); return Result (1 .. Last); end Read_Categories; procedure Read_Characters (Data : out Vectors.Vector) is Input : File_Type; begin Open (Input, In_File, "UnicodeData.txt"); Vectors.Reserve_Capacity (Data, 18_000); while not End_Of_File (Input) loop declare Item : Unicode_Data_Item; Text : constant String := Get_Line (Input); From : Positive; To : Natural; From2 : Positive; To2 : Natural; Last : Natural := Text'First; begin Get_Field (Text, From, To, Last); if Last > 0 then Get_Field (Text, From2, To2, Last); if Is_Range (Text (From .. To)) then To_Code_Points (Text (From .. To), Item.From, Item.To); elsif Is_Last_Name (Text (From2 .. To2)) then Item := Vectors.Last_Element (Data); Vectors.Delete_Last (Data); Item.To := To_Code_Point (Text (From .. To)); else Item.From := To_Code_Point (Text (From .. To)); Item.To := Item.From; end if; Get_Field (Text, From2, To2, Last); Item.Category := Text (From2 .. To2); Vectors.Append (Data, Item); end if; end; end loop; Close (Input); end Read_Characters; ------------------- -- To_Code_Point -- ------------------- function To_Code_Point (Text : String) return Code_Point is Image : constant String := "16#" & Text & "#"; begin return Code_Point'Value (Image); end To_Code_Point; -------------------- -- To_Code_Points -- -------------------- procedure To_Code_Points (Text : String; From : out Code_Point; To : out Code_Point) is Pos : constant Positive := Fixed.Index (Text, ".."); begin From := To_Code_Point (Text (Text'First .. Pos - 1)); To := To_Code_Point (Text (Pos + 2 .. Text'Last)); end To_Code_Points; List : Categories := Read_Categories; Data : Vectors.Vector; begin Print_Header; for J in List'Range loop if J = 1 then P (" (" & List (J).Alias & ","); elsif J = List'Last then P (" " & List (J).Alias & ");"); else P (" " & List (J).Alias & ","); end if; end loop; P (""); Read_Characters (Data); Category_Sorting.Sort (Data); declare Current : String (1 .. 2) := " "; Index : Positive; Last : Code_Point; procedure Count_Category (Position : Vectors.Cursor) is Item : constant Unicode_Data_Item := Vectors.Element (Position); begin if Current = Item.Category then if Item.From /= Last + 1 then List (Index).Count := List (Index).Count + 1; end if; Last := Item.To; else Current := Item.Category; for J in List'Range loop if List (J).Alias = Item.Category then Index := J; exit; end if; end loop; List (Index).Count := 1; Last := Item.To; end if; end Count_Category; begin Vectors.Iterate (Data, Count_Category'Access); end; declare Pos : Vectors.Cursor := Vectors.First (Data); From, To : Code_Point; First : Boolean; begin for J in List'Range loop if List (J).Count > 0 then P (" " & List (J).Alias & "_Node : aliased Set_Node :="); P (" (" & (+List (J).Count) & ", 2, ("); First := True; while Vectors.Has_Element (Pos) loop declare Item : Unicode_Data_Item := Vectors.Element (Pos); begin exit when Item.Category /= List (J).Alias; if First then From := Item.From; To := Item.To; First := False; elsif To + 1 = Item.From then To := Item.To; else P (" (" & (+From) & ", " & (+To) & "),"); From := Item.From; To := Item.To; end if; end; Pos := Vectors.Next (Pos); end loop; if List (J).Count = 1 then P (" 1 => (" & (+From) & ", " & (+To) & ")));"); else P (" (" & (+From) & ", " & (+To) & ")));"); end if; P (""); end if; end loop; end; P (" Cn_Node : aliased Set_Node :="); P (" (0, 2, (others => (Not_A_Symbol, Not_A_Symbol)));"); P (""); Print_Values (List); Print_Function (List); end Read_Unicode; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, <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: -- -- * 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 <NAME>, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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. ------------------------------------------------------------------------------
mac/app-scripts/url of Camino.scpt
albertz/foreground_app_info
2
4086
<filename>mac/app-scripts/url of Camino.scpt tell application "Camino" return URL of current tab of front browser window as text end tell
src/main/resources/Expr.g4
ghillert/antlr-demo
0
4965
grammar Expr; /* the grammar name and file name must match */ @header { package com.hillert.calculator.antlr; } // Start Variable prog: (decl | expr)+ EOF # Program ; decl: ID ':' INT_TYPE '=' NUM # Declaration ; /* ANTLR resolves ambiguities in favor of the alternative given first */ expr: expr '*' expr # Multiplication | expr '+' expr # Addition | ID # Variable | NUM # Number ; /* Tokens */ ID: [a-z][a-zA-Z0-9]*; // identifiers NUM: '0' | '-'?[1-9][0-9]*; INT_TYPE: 'INT'; COMMENT: '--' ~[\r\n]* -> skip; WS: [ \t\n]+ -> skip;
programs/oeis/099/A099921.asm
karttu/loda
0
168320
<reponame>karttu/loda ; A099921: a(n) = 5*Fibonacci(n)^2. ; 5,5,20,45,125,320,845,2205,5780,15125,39605,103680,271445,710645,1860500,4870845,12752045,33385280,87403805,228826125,599074580,1568397605,4106118245,10749957120,28143753125,73681302245,192900153620,505019158605,1322157322205,3461452808000,9062201101805,23725150497405,62113250390420,162614600673845,425730551631125,1114577054219520,2918000611027445,7639424778862805 mov $2,4 lpb $0,1 sub $0,1 add $1,$2 add $2,$1 add $2,3 lpe div $1,5 mul $1,5 add $1,5
oeis/093/A093275.asm
neoneye/loda-programs
11
23073
; A093275: a(n) is the largest number such that all of a(n)'s length-n substrings are distinct and divisible by 75. ; Submitted by <NAME>(s2) ; 0,75,9750,997500,99975000,9999750000,999997500000,99999975000000,9999999750000000,999999997500000000,99999999975000000000,9999999999750000000000,999999999997500000000000,99999999999975000000000000,9999999999999750000000000000 mov $1,10 pow $1,$0 div $1,5 mul $1,2 bin $1,2 mov $0,$1 div $0,6 mul $0,75
ShExDoc.g4
shexSpec/grammar
3
4874
// ANTLR4 Equivalent of accompanying bnf, developed in // http://www.w3.org/2005/01/yacker/uploads/ShEx3 // Updated to Jul 27 AM ShEx3 // Updated to Aug 23 AM ShEx3 (last change was EGP 20150820) // Sept 21 AM disallow single internal unary (e.g. {(:p .{2}){3}} // Change (non-standard) "codeLabel" to "productionName" // Oct 26 - change annotation predicate to include rdftype (how did this slip in to the production rules? // Dec 30 - update to match http://www.w3.org/2005/01/yacker/uploads/ShEx2/bnf with last change "EGP 20151120" // May 23, 2016 - Update to match http://www.w3.org/2005/01/yacker/uploads/ShEx2/bnf with last change "EGP20160520" AND ';' separator and '//' for annotations // May 24, 2016 - EGP20150424 // Aug 11, 2016 - EGP20160708 // Sep 14, 2016 - Revised to match Eric's latest reshuffle // Sep 24, 2016 - Switched to TT grammar (vs inner and outer shapes) // Sep 26, 2016 - Refactored to match https://raw.githubusercontent.com/shexSpec/shex.js/7eb770fe2b5bab9edfe9558dc07bb6f6dcdf5d23/doc/bnf // Oct 27, 2016 - Added comments to '*', '*' and '?' to facilitate parsing // Oct 27, 2016 - Added qualifier rule to be reused by shapeDefinition and inlineShapeDefinition // Oct 27, 2016 - Added negation rule // Mar 03, 2017 - removed ^^-style facet arguments per shex#41 // Mar 03, 2017 - switch to ~/regexp/ // Apr 09, 2017 - removed WS fragment (unused) // Apr 09, 2017 - revise REGEXP definition // Apr 09, 2017 - factor out REGEXP_FLAGS so we don't have to parse them out // Apr 09, 2017 - literalRange / languageRange additions // Apr 09, 2017 - factor out shapeRef to match spec // Apr 09, 2017 - update repeatRange to allow differentiation of {INTEGER} and {INTEGER,} // Apr 09, 2017 - add STEM_MARK and UNBOUNDED tokens to eliminate lex token parsingf // Apr 17, 2018 - add 2.1 rules -- extensions, restrictions and ABSTRACT // Aug 13, 2018 - Re-order rules to approximate Yakker BNF // Aug 13, 2018 - Remove '!' for NOT // Aug 13, 2018 - Add annotations and semanticActions to nodeconstraint grammar ShExDoc; shExDoc : directive* ((notStartAction | startActions) statement*)? EOF; // leading CODE directive : baseDecl | prefixDecl | importDecl ; baseDecl : KW_BASE IRIREF ; prefixDecl : KW_PREFIX PNAME_NS IRIREF ; importDecl : KW_IMPORT IRIREF ; notStartAction : start | shapeExprDecl ; start : KW_START '=' shapeExpression ; startActions : semanticAction+ ; statement : directive | notStartAction ; shapeExprDecl : KW_ABSTRACT? shapeExprLabel restrictions* (shapeExpression | KW_EXTERNAL) ; shapeExpression : shapeOr ; inlineShapeExpression : inlineShapeOr ; shapeOr : shapeAnd (KW_OR shapeAnd)* ; inlineShapeOr : inlineShapeAnd (KW_OR inlineShapeAnd)* ; shapeAnd : shapeNot (KW_AND shapeNot)* ; inlineShapeAnd : inlineShapeNot (KW_AND inlineShapeNot)* ; shapeNot : KW_NOT? shapeAtom ; inlineShapeNot : KW_NOT? inlineShapeAtom ; shapeAtom : nonLitNodeConstraint shapeOrRef? # shapeAtomNonLitNodeConstraint | litNodeConstraint # shapeAtomLitNodeConstraint | shapeOrRef nonLitNodeConstraint? # shapeAtomShapeOrRef | '(' shapeExpression ')' # shapeAtomShapeExpression | '.' # shapeAtomAny // no constraint ; inlineShapeAtom : inlineNonLitNodeConstraint inlineShapeOrRef? # inlineShapeAtomNonLitNodeConstraint | inlineLitNodeConstraint # inlineShapeAtomLitNodeConstraint | inlineShapeOrRef inlineNonLitNodeConstraint? # inlineShapeAtomShapeOrRef | '(' shapeExpression ')' # inlineShapeAtomShapeExpression | '.' # inlineShapeAtomAny // no constraint ; shapeOrRef : shapeDefinition | shapeRef ; inlineShapeOrRef : inlineShapeDefinition | shapeRef ; shapeRef : ATPNAME_LN | ATPNAME_NS | '@' shapeExprLabel ; inlineLitNodeConstraint : KW_LITERAL xsFacet* # nodeConstraintLiteral | nonLiteralKind stringFacet* # nodeConstraintNonLiteral | datatype xsFacet* # nodeConstraintDatatype | valueSet xsFacet* # nodeConstraintValueSet | numericFacet+ # nodeConstraintNumericFacet ; litNodeConstraint : inlineLitNodeConstraint annotation* semanticAction* ; inlineNonLitNodeConstraint : nonLiteralKind stringFacet* # litNodeConstraintLiteral | stringFacet+ # litNodeConstraintStringFacet ; nonLitNodeConstraint : inlineNonLitNodeConstraint annotation* semanticAction* ; nonLiteralKind : KW_IRI | KW_BNODE | KW_NONLITERAL ; xsFacet : stringFacet | numericFacet ; stringFacet : stringLength INTEGER | REGEXP REGEXP_FLAGS? ; stringLength : KW_LENGTH | KW_MINLENGTH | KW_MAXLENGTH ; numericFacet : numericRange rawNumeric | numericLength INTEGER ; numericRange : KW_MININCLUSIVE | KW_MINEXCLUSIVE | KW_MAXINCLUSIVE | KW_MAXEXCLUSIVE ; numericLength : KW_TOTALDIGITS | KW_FRACTIONDIGITS ; // rawNumeric is like numericLiteral but returns a JSON integer or float rawNumeric : INTEGER | DECIMAL | DOUBLE ; shapeDefinition : inlineShapeDefinition annotation* semanticAction* ; inlineShapeDefinition : qualifier* '{' tripleExpression? '}' ; qualifier : extension | extraPropertySet | KW_CLOSED ; extraPropertySet : KW_EXTRA predicate+ ; tripleExpression : oneOfTripleExpr ; oneOfTripleExpr : groupTripleExpr | multiElementOneOf ; multiElementOneOf : groupTripleExpr ( '|' groupTripleExpr )+ ; groupTripleExpr : singleElementGroup | multiElementGroup ; singleElementGroup : unaryTripleExpr ';'? ; multiElementGroup : unaryTripleExpr (';' unaryTripleExpr)+ ';'? ; unaryTripleExpr : ('$' tripleExprLabel)? (tripleConstraint | bracketedTripleExpr) | include ; bracketedTripleExpr : '(' tripleExpression ')' cardinality? annotation* semanticAction* ; tripleConstraint : senseFlags? predicate inlineShapeExpression cardinality? annotation* semanticAction* ; cardinality : '*' # starCardinality | '+' # plusCardinality | '?' # optionalCardinality | repeatRange # repeatCardinality ; // BNF: REPEAT_RANGE ::= '{' INTEGER (',' (INTEGER | '*')?)? '}' repeatRange : '{' INTEGER '}' # exactRange | '{' INTEGER ',' (INTEGER | UNBOUNDED)? '}' # minMaxRange ; senseFlags : '^' ; valueSet : '[' valueSetValue* ']' ; valueSetValue : iriRange | literalRange | languageRange | '.' (iriExclusion+ | literalExclusion+ | languageExclusion+) ; iriRange : iri (STEM_MARK iriExclusion*)? ; iriExclusion : '-' iri STEM_MARK? ; literalRange : literal (STEM_MARK literalExclusion*)? ; literalExclusion : '-' literal STEM_MARK? ; languageRange : LANGTAG (STEM_MARK languageExclusion*)? # languageRangeFull | '@' STEM_MARK languageExclusion* # languageRangeAt ; languageExclusion : '-' LANGTAG STEM_MARK? ; include : '&' tripleExprLabel ; annotation : '//' predicate (iri | literal) ; semanticAction : '%' iri (CODE | '%') ; literal : rdfLiteral | numericLiteral | booleanLiteral ; // BNF: predicate ::= iri | RDF_TYPE predicate : iri | rdfType ; rdfType : RDF_TYPE ; datatype : iri ; shapeExprLabel : iri | blankNode ; tripleExprLabel : iri | blankNode ; numericLiteral : INTEGER | DECIMAL | DOUBLE ; rdfLiteral : string (LANGTAG | '^^' datatype)? ; booleanLiteral : KW_TRUE | KW_FALSE ; string : STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2 | STRING_LITERAL1 | STRING_LITERAL2 ; iri : IRIREF | prefixedName ; prefixedName : PNAME_LN | PNAME_NS ; blankNode : BLANK_NODE_LABEL ; extension : KW_EXTENDS shapeExprLabel | '&' shapeExprLabel ; /* Not implemented yet, but reserved for future enhancement */ restrictions : KW_RESTRICTS shapeExprLabel | '-' shapeExprLabel ; // Keywords KW_ABSTRACT : A B S T R A C T ; KW_BASE : B A S E ; KW_EXTENDS : E X T E N D S ; KW_IMPORT : I M P O R T ; KW_RESTRICTS : R E S T R I C T S ; KW_EXTERNAL : E X T E R N A L ; KW_PREFIX : P R E F I X ; KW_START : S T A R T ; KW_VIRTUAL : V I R T U A L ; KW_CLOSED : C L O S E D ; KW_EXTRA : E X T R A ; KW_LITERAL : L I T E R A L ; KW_IRI : I R I ; KW_NONLITERAL : N O N L I T E R A L ; KW_BNODE : B N O D E ; KW_AND : A N D ; KW_OR : O R ; KW_MININCLUSIVE : M I N I N C L U S I V E ; KW_MINEXCLUSIVE : M I N E X C L U S I V E ; KW_MAXINCLUSIVE : M A X I N C L U S I V E ; KW_MAXEXCLUSIVE : M A X E X C L U S I V E ; KW_LENGTH : L E N G T H ; KW_MINLENGTH : M I N L E N G T H ; KW_MAXLENGTH : M A X L E N G T H ; KW_TOTALDIGITS : T O T A L D I G I T S ; KW_FRACTIONDIGITS : F R A C T I O N D I G I T S ; KW_NOT : N O T ; KW_TRUE : 'true' ; KW_FALSE : 'false' ; // terminals PASS : [ \t\r\n]+ -> skip; COMMENT : ('#' ~[\r\n]* | '/*' (~[*] | '*' ('\\/' | ~[/]))* '*/') -> skip; CODE : '{' (~[%\\] | '\\' [%\\] | UCHAR)* '%' '}' ; RDF_TYPE : 'a' ; IRIREF : '<' (~[\u0000-\u0020=<>"{}|^`\\] | UCHAR)* '>' ; /* #x00=NULL #01-#x1F=control codes #x20=space */ PNAME_NS : PN_PREFIX? ':' ; PNAME_LN : PNAME_NS PN_LOCAL ; ATPNAME_NS : '@' PN_PREFIX? ':' ; ATPNAME_LN : '@' PNAME_NS PN_LOCAL ; REGEXP : '/' (~[/\n\r\\] | '\\' [/nrt\\|.?*+(){}[\]$^-] | UCHAR)+ '/' ; REGEXP_FLAGS : [smix]+ ; BLANK_NODE_LABEL : '_:' (PN_CHARS_U | [0-9]) ((PN_CHARS | '.')* PN_CHARS)? ; LANGTAG : '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)* ; INTEGER : [+-]? [0-9]+ ; DECIMAL : [+-]? [0-9]* '.' [0-9]+ ; DOUBLE : [+-]? ([0-9]+ '.' [0-9]* EXPONENT | '.'? [0-9]+ EXPONENT) ; STEM_MARK : '~' ; UNBOUNDED : '*' ; fragment EXPONENT : [eE] [+-]? [0-9]+ ; STRING_LITERAL1 : '\'' (~[\u0027\u005C\u000A\u000D] | ECHAR | UCHAR)* '\'' ; /* #x27=' #x5C=\ #xA=new line #xD=carriage return */ STRING_LITERAL2 : '"' (~[\u0022\u005C\u000A\u000D] | ECHAR | UCHAR)* '"' ; /* #x22=" #x5C=\ #xA=new line #xD=carriage return */ STRING_LITERAL_LONG1 : '\'\'\'' (('\'' | '\'\'')? (~['\\] | ECHAR | UCHAR))* '\'\'\'' ; STRING_LITERAL_LONG2 : '"""' (('"' | '""')? (~["\\] | ECHAR | UCHAR))* '"""' ; fragment UCHAR : '\\u' HEX HEX HEX HEX | '\\U' HEX HEX HEX HEX HEX HEX HEX HEX ; fragment ECHAR : '\\' [tbnrf\\"'] ; fragment PN_CHARS_BASE : [A-Z] | [a-z] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D] | [\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] | [\u{10000}-\u{EFFFD}] ; fragment PN_CHARS_U : PN_CHARS_BASE | '_' ; fragment PN_CHARS : PN_CHARS_U | '-' | [0-9] | [\u00B7] | [\u0300-\u036F] | [\u203F-\u2040] ; fragment PN_PREFIX : PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)? ; fragment PN_LOCAL : (PN_CHARS_U | ':' | [0-9] | PLX) ((PN_CHARS | '.' | ':' | PLX)* (PN_CHARS | ':' | PLX))? ; fragment PLX : PERCENT | PN_LOCAL_ESC ; fragment PERCENT : '%' HEX HEX ; fragment HEX : [0-9] | [A-F] | [a-f] ; fragment PN_LOCAL_ESC : '\\' ('_' | '~' | '.' | '-' | '!' | '$' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%') ; fragment A:('a'|'A'); fragment B:('b'|'B'); fragment C:('c'|'C'); fragment D:('d'|'D'); fragment E:('e'|'E'); fragment F:('f'|'F'); fragment G:('g'|'G'); fragment H:('h'|'H'); fragment I:('i'|'I'); fragment J:('j'|'J'); fragment K:('k'|'K'); fragment L:('l'|'L'); fragment M:('m'|'M'); fragment N:('n'|'N'); fragment O:('o'|'O'); fragment P:('p'|'P'); fragment Q:('q'|'Q'); fragment R:('r'|'R'); fragment S:('s'|'S'); fragment T:('t'|'T'); fragment U:('u'|'U'); fragment V:('v'|'V'); fragment W:('w'|'W'); fragment X:('x'|'X'); fragment Y:('y'|'Y'); fragment Z:('z'|'Z');
src/Parsers/XML/project_processor-parsers-xml_parsers-basic_parsers.ads
fintatarta/eugen
0
15421
<filename>src/Parsers/XML/project_processor-parsers-xml_parsers-basic_parsers.ads with DOM.Core; private package Project_Processor.Parsers.XML_Parsers.Basic_Parsers is function Expect_ID (N : DOM.Core.Node; Name : String := "label") return EU_Projects.Dotted_Identifier; function Expect_Number (N : DOM.Core.Node; Name : String) return Natural; function Expect_Time (N : DOM.Core.Node; Name : String) return Symbolic_Instant; function Expect_Duration (N : DOM.Core.Node; Name : String) return Symbolic_Duration; procedure Get_End_And_Duration (N : DOM.Core.Node; Start_Time : in Symbolic_Instant; End_Time : out Symbolic_Instant; Duration : out Symbolic_Duration); end Project_Processor.Parsers.XML_Parsers.Basic_Parsers;
8086/3conver/bcd2hex.asm
iamvk1437k/mpmc
1
169601
<gh_stars>1-10 org 100h MOV AL, [1200] ; initialize AL with memory offset 1200 MOV AL,30h ; load the value in AL MOV AH,AL ; move the content of al to ah AND AH,0Fh ; AND 0Fh with AH MOV BL, AH ; move the content of AH to BL AND AL,0F0h ; AND F0h with AL MOV CL,04 ; load CL with 4 ROR AL, CL ; rotate AL to write 4 times MOV BH,0Ah ; load BH with 0Ah MUL BH ; multiply BH with AL ADD AL, BL ;add AL and BL MOV [1400], AL ;store AL into memory HLT
test/Succeed/Lambda.agda
redfish64/autonomic-agda
3
9356
{-# OPTIONS --no-termination-check #-} module Lambda where module Prelude where data Bool : Set where true : Bool false : Bool if_then_else_ : {A : Set} -> Bool -> A -> A -> A if true then x else y = x if false then x else y = y _∧_ : Bool -> Bool -> Bool true ∧ y = y false ∧ y = false _∨_ : Bool -> Bool -> Bool true ∨ y = true false ∨ y = y ¬_ : Bool -> Bool ¬ true = false ¬ false = true data List (A : Set) : Set where nil : List A _::_ : A -> List A -> List A _++_ : {A : Set} -> List A -> List A -> List A nil ++ ys = ys (x :: xs) ++ ys = x :: xs ++ ys filter : {A : Set} -> (A -> Bool) -> List A -> List A filter p nil = nil filter p (x :: xs) = if p x then x :: filter p xs else filter p xs postulate String : Set Char : Set {-# BUILTIN BOOL Bool #-} {-# BUILTIN FALSE false #-} {-# BUILTIN TRUE true #-} {-# BUILTIN STRING String #-} {-# BUILTIN CHAR Char #-} {-# BUILTIN LIST List #-} {-# BUILTIN NIL nil #-} {-# BUILTIN CONS _::_ #-} primitive primStringEquality : String -> String -> Bool _==_ = primStringEquality infix 10 if_then_else_ infixr 50 _::_ _++_ infixl 5 _∨_ infixl 7 _∧_ infix 50 ¬_ infix 15 _==_ open Prelude Name : Set Name = String data Exp : Set where var : Name -> Exp ƛ_⟶_ : Name -> Exp -> Exp _$_ : Exp -> Exp -> Exp infixl 50 _$_ infix 20 ƛ_⟶_ infix 80 _[_/_] infix 15 _∈_ _∈_ : Name -> List Name -> Bool x ∈ y :: ys = x == y ∨ x ∈ ys x ∈ nil = false -- Free variables FV : Exp -> List Name FV (var x) = x :: nil FV (s $ t) = FV s ++ FV t FV (ƛ x ⟶ t) = filter (\y -> ¬ (x == y)) (FV t) -- Fresh names fresh : Name -> Exp -> Name fresh x e = fresh' (FV e) where fresh' : List Name -> Name fresh' xs = "z" -- TODO -- Substitution _[_/_] : Exp -> Exp -> Name -> Exp var x [ r / z ] = if x == z then r else var x (s $ t) [ r / z ] = s [ r / z ] $ t [ r / z ] (ƛ x ⟶ t) [ r / z ] = if x == z then ƛ x ⟶ t else if x ∈ FV r then ( let y : Name y = fresh x r in ƛ y ⟶ t [ var y / x ] [ r / z ] ) else ƛ x ⟶ t [ r / z ]
flame32-libs/unit-tests/test-mul-1.asm
drako0812/flame32
2
90889
#include "../../flame32.asm" ; Tests MUL lod 2 ldl B, 3 mul A, B
programs/oeis/176/A176631.asm
neoneye/loda
22
8003
; A176631: Triangle T(n, k) = 22^(k*(n-k)), read by rows. ; 1,1,1,1,22,1,1,484,484,1,1,10648,234256,10648,1,1,234256,113379904,113379904,234256,1,1,5153632,54875873536,1207269217792,54875873536,5153632,1,1,113379904,26559922791424,12855002631049216,12855002631049216,26559922791424,113379904,1 seq $0,4247 ; Multiplication table read by antidiagonals: T(i,j) = ij (i>=0, j>=0). mov $1,22 pow $1,$0 mov $0,$1
src/fot/FOTC/Program/Collatz/PropertiesATP.agda
asr/fotc
11
6895
<gh_stars>10-100 ------------------------------------------------------------------------------ -- Properties of the Collatz function ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.Collatz.PropertiesATP where open import FOTC.Base open import FOTC.Data.Nat open import FOTC.Data.Nat.PropertiesATP using ( ∸-N ) open import FOTC.Data.Nat.UnaryNumbers open import FOTC.Data.Nat.UnaryNumbers.TotalityATP using ( 2-N ) open import FOTC.Program.Collatz.Collatz open import FOTC.Program.Collatz.Data.Nat open import FOTC.Program.Collatz.Data.Nat.PropertiesATP ------------------------------------------------------------------------------ helper : ∀ {n} → N n → collatz (2' ^ succ₁ n) ≡ collatz (2' ^ n) helper nzero = prf where postulate prf : collatz (2' ^ succ₁ zero) ≡ collatz (2' ^ zero) {-# ATP prove prf #-} helper (nsucc {n} Nn) = prf where postulate prf : collatz (2' ^ succ₁ (succ₁ n)) ≡ collatz (2' ^ succ₁ n) {-# ATP prove prf +∸2 ^-N 2-N 2^x≢0 2^[x+1]≢1 div-2^[x+1]-2≡2^x x-Even→SSx-Even ∸-N ∸-Even 2^[x+1]-Even 2-Even #-} collatz-2^x : ∀ {n} → N n → collatz (2' ^ n) ≡ 1' collatz-2^x nzero = prf where postulate prf : collatz (2' ^ 0') ≡ 1' {-# ATP prove prf #-} collatz-2^x (nsucc {n} Nn) = prf (collatz-2^x Nn) where postulate prf : collatz (2' ^ n) ≡ 1' → collatz (2' ^ succ₁ n) ≡ 1' {-# ATP prove prf helper #-}
src/_for_debug_purposes/apsepp-debug_trace_class-output.ads
thierr26/ada-apsepp
0
28353
<filename>src/_for_debug_purposes/apsepp-debug_trace_class-output.ads -- Copyright (C) 2019 <NAME> <<EMAIL>> -- MIT license. Please refer to the LICENSE file. with Apsepp.Debug_Trace_Class.Stub; use Apsepp.Debug_Trace_Class.Stub; package Apsepp.Debug_Trace_Class.Output is -- TODOC: Not implemented as a protected type (but Output sink may be). -- <2019-03-02> type Debug_Trace_Output is limited new Debug_Trace_Stub with private; overriding procedure Trace (Obj : in out Debug_Trace_Output; Message : String; Entity_Name : String := ""); private type Debug_Trace_Output is limited new Debug_Trace_Stub with null record; end Apsepp.Debug_Trace_Class.Output;
2011400_NguyenTuanKiet_Lab1/bt3.asm
alumica/KTMT
0
163311
<reponame>alumica/KTMT .model small .stack 100h .data tb1 db "Hay nhap mot ky tu: $" tb2 db 0Dh, 0Ah, "Ky tu dung truoc: $" tb3 db 0Dh, 0Ah, "Ky tu dung sau: $" kt db ? .code main proc mov ax, @data mov ds, ax lea dx, tb1 mov ah, 9 int 21h mov ah, 1 int 21h mov kt, al lea dx, tb2 mov ah, 9 int 21h mov ah, 2 mov dl, kt dec dl int 21h lea dx, tb3 mov ah, 9 int 21h mov ah, 2 mov dl, kt inc dl int 21h main endp end main
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/test_oconst.adb
best08618/asylo
7
13545
<reponame>best08618/asylo -- { dg-do run } with OCONST1, OCONST2, OCONST3, OCONST4, OCONST5; procedure Test_Oconst is begin OCONST1.check (OCONST1.My_R); OCONST2.check (OCONST2.My_R); OCONST3.check (OCONST3.My_R); OCONST4.check (OCONST4.My_R); OCONST5.check (OCONST5.My_R0, 0); OCONST5.check (OCONST5.My_R1, 1); end;
src/tcg-tilesets.ads
Fabien-Chouteau/tiled-code-gen
1
18835
<filename>src/tcg-tilesets.ads<gh_stars>1-10 ------------------------------------------------------------------------------ -- -- -- tiled-code-gen -- -- -- -- Copyright (C) 2018 <NAME> -- -- -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with TCG.Palette; private with Ada.Containers; private with Ada.Containers.Hashed_Maps; private with Ada.Containers.Vectors; private with TCG.Collision_Objects; package TCG.Tilesets is -- We can load multiple maps, each map can load multiple tile sets and -- potetially the same tile sets will be loaded by different maps. -- -- To simplify the generated data, we build a unique master tile set that -- contains all the tiles from all the tile sets of all the maps. The tiles -- from the master tile set are indentifiyed with the Master_Tile_Id type. -- -- During loading of the maps we have to be able to get the Master_Tile_Id -- of a tile from a specific tile set. For this the function Convert will -- return the Master_Tile_Id from the Tileset_Id and the Local_Tile_Id. type Master_Tile_Id is new Natural; -- Id of a tile in the unified master tile set No_Tile : constant Master_Tile_Id := 0; type Local_Tile_Id is new Natural; -- Id of a tile within a given tile set type Map_Tile_Id is new Natural; -- Id of a tile within a the layers of a map type Tileset_Id is private; -- Id of one of the loaded tile sets Invalid_Tileset : constant Tileset_Id; function Load (Path : String) return Tileset_Id; -- Load a tile set in the master tile set and return its Id. An exception -- will be raised of the the tile size is different than the previously -- loaded tile set(s). function Name (Id : Tileset_Id) return String with Pre => Id /= Invalid_Tileset; function Convert (Id : Tileset_Id; Loc : Local_Tile_Id) return Master_Tile_Id with Pre => Id /= Invalid_Tileset; -- Move a tile into the Master tileset and return its id function Number_Of_Tiles return Natural; -- Number of tiles in the master set function First_Id return Master_Tile_Id; -- Return the first valid Master_Tile_Id function Last_Id return Master_Tile_Id; -- Return the last valid Master_Tile_Id function Tile_Width return Positive; -- Width of tiles in the master set. Returns 0 if not tile set are loaded. function Tile_Height return Positive; -- Height of tiles in the master set. Returns 0 if not tile set are loaded. function Pix (T : Master_Tile_Id; X, Y : Positive) return Palette.ARGB_Color with Pre => T /= No_Tile and then X <= Tile_Width and then Y <= Tile_Height; function Pix (T : Master_Tile_Id; X, Y : Positive) return Palette.Color_Id with Pre => T /= No_Tile and then X <= Tile_Width and then Y <= Tile_Height; function Has_Collision (T : Master_Tile_Id) return Boolean with Pre => T /= No_Tile; function Collision (T : Master_Tile_Id; X, Y : Positive) return Boolean with Pre => T /= No_Tile and then X <= Tile_Width and then Y <= Tile_Height; procedure Fill_Master_Tileset (T : Tileset_Id); -- Fill the master tileset with all the tiles of this tileset private type String_Access is access all String; type Tile_Pix is array (Positive range <>, Positive range <>) of TCG.Palette.ARGB_Color; type Tile_Data (Width, Height : Positive) is record Pixels : Tile_Pix (1 .. Width, 1 .. Height); Collisions : TCG.Collision_Objects.Collisions; end record; type Tile_Data_Acc is access all Tile_Data; package Tile_Data_Vect is new Ada.Containers.Vectors (Index_Type => Local_Tile_Id, Element_Type => Tile_Data_Acc); type Local_Tileset is record Name : String_Access := null; Source : String_Access := null; Path : String_Access := null; Tiles : Tile_Data_Vect.Vector; Columns : Natural := 0; Number_Of_Tiles : Natural := 0; end record; package Tileset_Vect is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Local_Tileset); type Tileset_Id is new Tileset_Vect.Extended_Index; Invalid_Tileset : constant Tileset_Id := Tileset_Id (Tileset_Vect.No_Index); Local_Tilesets : Tileset_Vect.Vector; function Already_Loaded (Path : String) return Tileset_Id; type Tile_Id_Rec is record TS : Tileset_Id; Id : Local_Tile_Id; end record; use type Ada.Containers.Hash_Type; function Hash (Id : Tile_Id_Rec) return Ada.Containers.Hash_Type is (Ada.Containers.Hash_Type (Id.TS) xor Ada.Containers.Hash_Type (Id.Id)); function Equivalent_Keys (A, B : Tile_Id_Rec) return Boolean is (A.TS = B.TS and then A.Id = B.Id); package Master_Tile_Map is new Ada.Containers.Hashed_Maps (Key_Type => Tile_Id_Rec, Element_Type => Master_Tile_Id, Hash => Hash, Equivalent_Keys => Equivalent_Keys); package Master_Tile_Vect is new Ada.Containers.Vectors (Index_Type => Master_Tile_Id, Element_Type => Tile_Data_Acc); Master_Tileset : Master_Tile_Map.Map; Master_Tilevect : Master_Tile_Vect.Vector; Last_Master_Id : Master_Tile_Id := 0; M_Tile_Width : Natural := 0; M_Tile_Height : Natural := 0; end TCG.Tilesets;
src/test_led_rt.adb
JCGobbi/Nucleo-STM32G474RE
0
1361
with Ada.Real_Time; use Ada.Real_Time; with STM_Board; use STM_Board; procedure Test_LED_RT is -- This demonstration program only initializes the GPIOs and flash a LED -- with Ada.Real_Time. There is no initialization for PWM, ADC and timer. begin -- Initialize GPIO ports Initialize_GPIO; -- Enter steady state loop Set_Toggle (Green_LED); delay until Clock + Milliseconds (1000); -- arbitrary end loop; end Test_LED_RT;
programs/oeis/169/A169831.asm
neoneye/loda
22
170158
; A169831: a(n) = 5*2^(n+1) - 3*(n+3). ; 1,8,25,62,139,296,613,1250,2527,5084,10201,20438,40915,81872,163789,327626,655303,1310660,2621377,5242814,10485691,20971448,41942965,83886002,167772079,335544236,671088553,1342177190,2684354467,5368709024,10737418141,21474836378,42949672855,85899345812,171798691729,343597383566,687194767243,1374389534600,2748779069317,5497558138754,10995116277631,21990232555388,43980465110905,87960930221942,175921860444019,351843720888176,703687441776493,1407374883553130,2814749767106407,5629499534212964,11258999068426081,22517998136852318,45035996273704795,90071992547409752,180143985094819669,360287970189639506,720575940379279183,1441151880758558540,2882303761517117257,5764607523034234694,11529215046068469571,23058430092136939328,46116860184273878845,92233720368547757882,184467440737095515959,368934881474191032116,737869762948382064433,1475739525896764129070,2951479051793528258347,5902958103587056516904,11805916207174113034021,23611832414348226068258,47223664828696452136735,94447329657392904273692,188894659314785808547609,377789318629571617095446,755578637259143234191123,1511157274518286468382480,3022314549036572936765197,6044629098073145873530634,12089258196146291747061511,24178516392292583494123268,48357032784585166988246785,96714065569170333976493822,193428131138340667952987899,386856262276681335905976056,773712524553362671811952373,1547425049106725343623905010,3094850098213450687247810287,6189700196426901374495620844,12379400392853802748991241961,24758800785707605497982484198,49517601571415210995964968675,99035203142830421991929937632,198070406285660843983859875549,396140812571321687967719751386,792281625142643375935439503063,1584563250285286751870879006420,3169126500570573503741758013137,6338253001141147007483516026574 mov $2,4 lpb $0 sub $0,1 add $2,3 add $1,$2 mul $2,2 lpe add $1,1 mov $0,$1
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_626.asm
ljhsiun2/medusa
9
165279
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r8 push %r9 push %rcx push %rdi push %rsi // Store lea addresses_UC+0x11bcb, %rdi nop nop nop xor $22035, %r14 movl $0x51525354, (%rdi) add %rdi, %rdi // Faulty Load lea addresses_UC+0x129cb, %r9 nop nop and %rsi, %rsi vmovups (%r9), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $0, %xmm2, %r10 lea oracles, %r9 and $0xff, %r10 shlq $12, %r10 mov (%r9,%r10,1), %r10 pop %rsi pop %rdi pop %rcx pop %r9 pop %r8 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_UC', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 4, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_UC', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'37': 21829} 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 */
src/matharray.adb
kevinrosalesdev/MathArray-FormalVerification
2
27137
<reponame>kevinrosalesdev/MathArray-FormalVerification<filename>src/matharray.adb with Ada.Text_IO; use Ada.Text_IO; with Ada.Numerics.Elementary_Functions; package body MathArray with SPARK_Mode => On is function midpoint (point1 : vec; point2 : vec) return vec is result:vec (point1'Range):= (others => 0); begin for i in point1'Range loop result (i) := (point1(i)+point2(i))/2; pragma Loop_Invariant (for all j in result'First .. i => result (j) = (point1(j)+point2(j))/2); end loop; return result; end midpoint; procedure module (vec1 : vecFloat; res : out Float)is begin if vec1'Length = 2 then res:=Ada.Numerics.Elementary_Functions.Sqrt(abs(vec1(vec1'First)*vec1(vec1'First)) + abs(vec1(vec1'Last)*vec1(vec1'Last))); else res:=Ada.Numerics.Elementary_Functions.Sqrt(abs(vec1(vec1'First)*vec1(vec1'First)) + abs(vec1(vec1'First+1)*vec1(vec1'First+1)) + abs(vec1(vec1'Last)*vec1(vec1'Last))); end if; end module; function derivative (vec1 : vecFloat) return vecFloat is res : vecFloat(vec1'Range) := (others => 0.0); begin for i in res'Range loop res(i) := vec1(i)*Float(res'Length - (i - res'First + 1)); end loop; return res; end derivative; procedure get(a:in out vec; x:Integer; bool:out Boolean) is begin bool := false; for i in a'Range loop if a(i)=x then a(i):=0; bool := True; exit; end if; pragma Loop_Invariant((for all k in a'First..i => a(k) /= x) and then bool = false); end loop; end get; function perpendicular_vec (vec1 : vec; vec2 : vec) return Boolean is begin return (vec1(vec1'First)*vec2(vec2'First))+(vec1(vec1'Last)*vec2(vec2'Last)) = 0; end perpendicular_vec; end MathArray;
12_8BitMultiplication.asm
furkanisitan/ExampleProgramsFor8085Microprocessor
0
99604
MVI B, 14 ; B=14 MVI C, 9 ; C=9 LXI H, 0 ; HL=0 MOV E, B ; DE=B(14) LOOP: DAD D ; HL+=DE DCR C ; C-=1 JNZ LOOP ; 0 değilse atla HLT ; B ve C deki iki sayıyı çarpar, sonucu HL de tutar
kernel/kernel_entry.asm
sreejithnt/os
0
177959
<reponame>sreejithnt/os [bits 32] ; by the time we reach here it will be in 32-bit protected mode [extern main] ; define the external symbol (main here) to look for call main ; make a call to main, thus landing in the correct ; place in kernel jmp $
gfx/pokemon/krabby/anim.asm
Dev727/ancientplatinum
28
244113
<gh_stars>10-100 frame 5, 18 frame 0, 06 setrepeat 2 frame 0, 06 frame 1, 04 frame 2, 03 frame 3, 04 frame 4, 03 dorepeat 3 endanim
src/frontend/Experimental_Ada_ROSE_Connection/parser/lal_adapter/source/lal_adapter-context.adb
ouankou/rose
488
13209
<filename>src/frontend/Experimental_Ada_ROSE_Connection/parser/lal_adapter/source/lal_adapter-context.adb with GNAT.Directory_Operations; with GNATCOLL.Projects; with GNATCOLL.VFS; with Libadalang.Project_Provider; with Generic_Logging; with Lal_Adapter.Unit; package body Lal_Adapter.Context is -- Raises Internal_Error: procedure Parse_Input_File (This : in out Class; Input_File_Name : in String) is Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & ".Parse_Input_File"; package Logging is new Generic_Logging (Module_Name); use Logging; Auto : Logging.Auto_Logger; -- Logs BEGIN and END begin -- Parse the source file into an Analysis_Unit (tree): This.Top_Unit := This.Lal_Context.Get_From_File (Input_File_Name); -- Report parsing errors, if any if This.Top_Unit.Has_Diagnostics then Log ((1..50 => '*')); Log ("Unit.Has_Diagnostics returned True."); Log ("Diagnostics:"); for D of This.Top_Unit.Diagnostics loop Log (This.Top_Unit.Format_GNU_Diagnostic (D)); end loop; Log ("Raising External_Error"); Log ((1..50 => '*')); raise External_Error with "Parsing """ & Input_File_Name & """ failed."; end if; exception when X : External_Error | Internal_Error | Usage_Error => raise; when X: others => Log_Exception (X); Log ("No handler for this exception. Raising Internal_Error"); raise Internal_Error; end Parse_Input_File; procedure Process_Top_Unit (This : in out Class; Outputs : in Output_Accesses_Record) is Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & ".Process_Top_Unit"; package Logging is new Generic_Logging (Module_Name); use Logging; Auto : Logging.Auto_Logger; -- Logs BEGIN and END begin This.Top_Compilation_Unit := LAL.As_Compilation_Unit(This.Top_Unit.Root); declare Unit_Processor : Lal_Adapter.Unit.Class; -- Initialized begin Unit_Processor.Process (This.Top_Compilation_Unit, Outputs); end; end Process_Top_Unit; procedure Process_Dependencies (This : in out Class; Outputs : in Output_Accesses_Record) is Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & ".Process_Dependencies"; package Logging is new Generic_Logging (Module_Name); use Logging; Auto : Logging.Auto_Logger; -- Logs BEGIN and END begin declare Dependencies : constant LAL.Compilation_Unit_Array := LAL.P_Unit_Dependencies (This.Top_Compilation_Unit); begin for Dependency of Dependencies Loop declare Unit_Processor : Lal_Adapter.Unit.Class; -- Initialized begin Unit_Processor.Process (Dependency, Outputs); end; end loop; end; end Process_Dependencies; -- Load the project file: procedure Load_Project_And_Setup_Context (This : in out Class; Project_File_Name : in String) is package GPR renames GNATCOLL.Projects; package LAL_GPR renames Libadalang.Project_Provider; use type GNATCOLL.VFS.Filesystem_String; -- For "+" Env : GPR.Project_Environment_Access; -- Initialized Project_File : constant GNATCOLL.VFS.Virtual_File := GNATCOLL.VFS.Create (+Project_File_Name); Project : constant GPR.Project_Tree_Access := new GPR.Project_Tree; Unit_Provider : LAL.Unit_Provider_Reference := LAL.No_Unit_Provider_Reference; begin -- Load_Project_And_Setup_Context GPR.Initialize (Env); -- Use procedures in GNATCOLL.Projects to set scenario -- variables (Change_Environment), to set the target -- and the runtime (Set_Target_And_Runtime), etc. Project.Load (Project_File, Env); Unit_Provider := LAL_GPR.Create_Project_Unit_Provider (Tree => Project, Project => GPR.No_Project, Env => Env); This.Lal_Context := LAL.Create_Context (Unit_Provider => Unit_Provider); end Load_Project_And_Setup_Context; ------------ -- EXPORTED: ------------ procedure Process (This : in out Class; Input_File_Name : in String; Project_File_Name : in String; -- Unit_Options : in Unit.Options_Record; Outputs : in Output_Accesses_Record) is Parent_Name : constant String := Module_Name; Module_Name : constant String := Parent_Name & ".Process"; package Logging is new Generic_Logging (Module_Name); use Logging; Auto : Logging.Auto_Logger; -- Logs BEGIN and END begin -- Process Log ("Project_File_Name => """ & Project_File_Name & """"); Log ("Input_File_Name => """ & Input_File_Name & """"); Outputs.Graph.Set_ID ("""" & Input_File_Name & """"); Outputs.A_Nodes.Set (Context => (Name => To_Chars_Ptr (Project_File_Name), Parameters => To_Chars_Ptr (String'("")), Debug_Image => To_Chars_Ptr (String'("")))); This.Load_Project_And_Setup_Context (Project_File_Name); This.Parse_Input_File (Input_File_Name); -- Process dependencies first, so that declarations come before -- references? Actually, we don't know if the dependencies will be -- traversed in dependency order themselves! This.Process_Top_Unit (Outputs); This.Process_Dependencies (Outputs); exception when X : External_Error | Internal_Error | Usage_Error => raise; when X: others => Log_Exception (X); Log ("No handler for this exception. Raising Internal_Error"); raise Internal_Error; end Process; end Lal_Adapter.Context;
x86_assembly/tests/protect.asm
erhu666/computer
117
170831
[bits 32] extern exit section .text global main main: ; mov eax, cr0; 寄存器的保护 ; in al, 0x92; push 0 call exit
UNIT_TESTS/global_001.adb
io7m/coreland-openal-ada
1
7514
with Ada.Text_IO; with OpenAL.Context.Error; with OpenAL.Error; with OpenAL.Context; with OpenAL.Global; with Test; procedure global_001 is package ALC renames OpenAL.Context; package ALC_Error renames OpenAL.Context.Error; package AL_Error renames OpenAL.Error; Device : ALC.Device_t; Context : ALC.Context_t; OK : Boolean; TC : Test.Context_t; use type ALC.Device_t; use type ALC.Context_t; use type ALC_Error.Error_t; use type AL_Error.Error_t; procedure Finish is begin ALC.Destroy_Context (Context); ALC.Close_Device (Device); end Finish; procedure Init is begin Device := ALC.Open_Default_Device; pragma Assert (Device /= ALC.Invalid_Device); Context := ALC.Create_Context (Device); pragma Assert (Context /= ALC.Invalid_Context); OK := ALC.Make_Context_Current (Context); pragma Assert (OK); end Init; begin Test.Initialize (Test_Context => TC, Program => "global_001", Test_DB => "TEST_DB", Test_Results => "TEST_RESULTS"); Init; Ada.Text_IO.Put_Line ("VERSION : " & OpenAL.Global.Version); Test.Check (TC, 51, AL_Error.Get_Error = AL_Error.No_Error, "AL_Error.Get_Error = AL_Error.No_Error"); Ada.Text_IO.Put_Line ("RENDERER : " & OpenAL.Global.Renderer); Test.Check (TC, 52, AL_Error.Get_Error = AL_Error.No_Error, "AL_Error.Get_Error = AL_Error.No_Error"); Ada.Text_IO.Put_Line ("VENDOR : " & OpenAL.Global.Vendor); Test.Check (TC, 53, AL_Error.Get_Error = AL_Error.No_Error, "AL_Error.Get_Error = AL_Error.No_Error"); Ada.Text_IO.Put_Line ("EXTENSIONS : " & OpenAL.Global.Extensions); Test.Check (TC, 54, AL_Error.Get_Error = AL_Error.No_Error, "AL_Error.Get_Error = AL_Error.No_Error"); Finish; end global_001;
Transynther/x86/_processed/AVXALIGN/_st_sm_/i7-7700_9_0xca.log_21829_460.asm
ljhsiun2/medusa
9
86143
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r8 push %r9 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_A_ht+0x165b9, %rsi lea addresses_A_ht+0x13195, %rdi nop nop nop nop nop inc %rbp mov $123, %rcx rep movsw nop nop sub $3315, %r8 lea addresses_UC_ht+0x6b43, %rbx sub $52022, %r9 vmovups (%rbx), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %r8 nop inc %rbx lea addresses_normal_ht+0x7860, %rsi lea addresses_WC_ht+0x56f5, %rdi dec %rbp mov $45, %rcx rep movsl nop nop nop nop sub $10753, %r9 lea addresses_normal_ht+0x294a, %rsi lea addresses_normal_ht+0x7975, %rdi clflush (%rsi) clflush (%rdi) nop nop nop nop dec %r13 mov $100, %rcx rep movsb xor $51619, %rcx lea addresses_normal_ht+0xa875, %rbx nop nop nop dec %rsi movb $0x61, (%rbx) nop and %r8, %r8 lea addresses_WT_ht+0x7715, %rsi lea addresses_normal_ht+0x1aff3, %rdi nop nop nop inc %r8 mov $120, %rcx rep movsb xor $43882, %r9 lea addresses_D_ht+0x3175, %r9 nop nop nop nop nop dec %rbp mov $0x6162636465666768, %rcx movq %rcx, (%r9) sub %r9, %r9 lea addresses_WC_ht+0xc175, %r13 nop nop nop add %r9, %r9 movw $0x6162, (%r13) nop nop nop nop sub $46130, %r13 lea addresses_D_ht+0x16e75, %rsi lea addresses_WT_ht+0x6465, %rdi nop nop nop and $60122, %rbx mov $33, %rcx rep movsq nop nop nop add $47734, %rbp lea addresses_D_ht+0x17975, %r9 nop nop nop nop nop xor $21359, %rdi mov (%r9), %ecx nop and %rdi, %rdi lea addresses_normal_ht+0x13055, %rsi lea addresses_WT_ht+0xab55, %rdi nop nop and %r8, %r8 mov $92, %rcx rep movsl nop nop nop sub %rsi, %rsi lea addresses_WC_ht+0x13af5, %rdi add $49106, %r9 mov (%rdi), %rbp nop nop nop cmp $27886, %rbp lea addresses_D_ht+0x1d15, %r9 nop nop nop nop and $36264, %r13 mov (%r9), %bp nop nop nop nop nop sub $40824, %rdi pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r9 pop %r8 pop %r13 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r9 push %rax push %rdi push %rdx // Store lea addresses_WT+0x11d75, %r9 clflush (%r9) nop nop dec %rdi mov $0x5152535455565758, %r11 movq %r11, (%r9) // Exception!!! mov (0), %r11 nop nop nop nop xor %r14, %r14 // Store lea addresses_WT+0x11831, %r9 nop and $9735, %rdx mov $0x5152535455565758, %r11 movq %r11, %xmm7 vmovups %ymm7, (%r9) nop nop nop nop nop cmp $34640, %rdx // Faulty Load lea addresses_WT+0x11d75, %r9 nop nop nop nop nop and %rax, %rax mov (%r9), %r11 lea oracles, %rdi and $0xff, %r11 shlq $12, %r11 mov (%rdi,%r11,1), %r11 pop %rdx pop %rdi pop %rax pop %r9 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 8, 'NT': False, 'type': 'addresses_WT'}} {'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WT'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': True, 'same': True, 'size': 8, 'NT': True, 'type': 'addresses_WT'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 2, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_A_ht'}} {'src': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_WC_ht'}} {'src': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_normal_ht'}} {'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_normal_ht'}} {'src': {'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}} {'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WC_ht'}} {'src': {'congruent': 8, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 9, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 4, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'58': 21829} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
libsrc/_DEVELOPMENT/adt/p_forward_list/c/sccz80/p_forward_list_size.asm
teknoplop/z88dk
8
91137
; size_t p_forward_list_size(p_forward_list_t *list) SECTION code_clib SECTION code_adt_p_forward_list PUBLIC p_forward_list_size EXTERN asm_p_forward_list_size defc p_forward_list_size = asm_p_forward_list_size
mc-sema/validator/x86/tests/FCHS.asm
randolphwong/mcsema
2
90413
<reponame>randolphwong/mcsema<filename>mc-sema/validator/x86/tests/FCHS.asm BITS 32 ;TEST_FILE_META_BEGIN ;TEST_TYPE=TEST_F ;TEST_IGNOREFLAGS= ;TEST_FILE_META_END FLDPI ;TEST_BEGIN_RECORDING FCHS ;TEST_END_RECORDING
Driver/Printer/HP/Dj500c/dj500cDriverInfo.asm
steakknife/pcgeos
504
16642
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved PROJECT: PC GEOS MODULE: Deskjet CMY printer driver FILE: dj500cDriverInfo.asm AUTHOR: <NAME>, 27 Feb 1990 REVISION HISTORY: Name Date Description ---- ---- ----------- Dave 2/27/90 Initial revision Dave 6/22/92 Initial 2.0 revision DESCRIPTION: Driver info for the deskJet printer driver The file "printerDriver.def" should be included before this one $Id: dj500cDriverInfo.asm,v 1.1 97/09/10 14:02:57 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Driver Info Resource This part of the file contains the information that pertains to all device supported by the driver. It includes device names and a table of the resource handles for the specific device info. A pointer to this info is provided by the DriverInfo function. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DriverInfo segment lmem LMEM_TYPE_GENERAL ;---------------------------------------------------------------------------- ; Device Enumerations ;---------------------------------------------------------------------------- ifdef GPC_ONLY ; ; GlobalPC printer drivers (compatibility modes only) ; DefPrinter PD_EARLY_DESKJET_3C, "HP DeskJet 3-Color Compatible", dj500cInfo else ; ; Default printer driver list (all known supported devices) ; ; The following models need to be officially tested: ; HP670C HP672C HP692C HP810C HP895C HP895CSE HP895CXI ; HP970CXI HP1120C HP1120CSE HP1220C HP1220CSE ; ; DefPrinter PD_DESKJET_500_C, "HP DeskJet 500C (Color)", dj500cInfo DefPrinter PD_DESKJET_540_C, "HP DeskJet 540C (Color)", dj500cInfo DefPrinter PD_DESKJET_550_3C, "HP DeskJet 550C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_560_3C, "HP DeskJet 560C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_600_C, "HP DeskJet 600C (Color)", dj500cInfo DefPrinter PD_DESKJET_660_3C, "HP DeskJet 660C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_670_3C, "HP DeskJet 670C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_672_3C, "HP DeskJet 672C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_680_3C, "HP DeskJet 680C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_682_3C, "HP DeskJet 682C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_692_3C, "HP DeskJet 692C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_810_3C, "HP DeskJet 810C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_850_3C, "HP DeskJet 850C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_895_3C, "HP DeskJet 895C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_895_3CSE, "HP DeskJet 895Cse (3 Color)", dj500cInfo DefPrinter PD_DESKJET_895_3CXI, "HP DeskJet 895Cxi (3 Color)", dj500cInfo DefPrinter PD_DESKJET_970_3CXI, "HP DeskJet 970Cxi (3 Color)", dj500cInfo DefPrinter PD_DESKJET_1120_3C, "HP DeskJet 1120C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_1120_3CSE, "HP DeskJet 1120Cse (3 Color)", dj500cInfo DefPrinter PD_DESKJET_1220_3C, "HP DeskJet 1220C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_1220_3CSE, "HP DeskJet 1220Cse (3 Color)", dj500cInfo DefPrinter PD_DESKJET_1600_3C, "HP DeskJet 1600C (3 Color)", dj500cInfo DefPrinter PD_DESKJET_CMY_NCC, "HP DeskJet CMY Non Col-Corr", nccCMYInfo DefPrinter PD_HP_PJ_XL300_3C, "HP PaintJet XL300 (3 Color)", pjxl300Info endif ;---------------------------------------------------------------------------- ; Driver Info Header ;---------------------------------------------------------------------------- DriverExtendedInfoTable < {}, ; lmem hdr PrintDevice/2, ; # devices offset deviceStrings, ; devices offset deviceInfoTab ; info blocks > PrintDriverInfo < 30, ;device timout PR_RESEND, ; isoSubstitutions, ;ISO sub tab. asciiTransTable, PDT_PRINTER, TRUE > ;---------------------------------------------------------------------------- ; Device String Table and Strings ;---------------------------------------------------------------------------- isoSubstitutions chunk.word 0ffffh ;no ISO subs. ; ASCII Translation List for Foreign Language Versions asciiTransTable chunk.char ";;",0 ;create the tables... PrinterTables DriverInfo ends
src/ada/src/common_formal_containers.ads
pat-rogers/OpenUxAS
0
6856
<filename>src/ada/src/common_formal_containers.ads with Ada.Containers.Formal_Vectors; -- with Ada.Containers.Formal_Hashed_Sets; with Ada.Containers.Formal_Ordered_Sets; with AVTAS.LMCP.Types; use AVTAS.LMCP.Types; package Common_Formal_Containers with SPARK_Mode is package Int64_Vects is new Ada.Containers.Formal_Vectors (Index_Type => Natural, Element_Type => Int64); Int64_Vects_Common_Max_Capacity : constant := 200; -- arbitrary subtype Int64_Vect is Int64_Vects.Vector (Int64_Vects_Common_Max_Capacity); function Int64_Hash (X : Int64) return Ada.Containers.Hash_Type is (Ada.Containers.Hash_Type'Mod (X)); -- pragma Assertion_Policy (Post => Ignore); -- package Int64_Sets is new Ada.Containers.Formal_Hashed_Sets -- (Element_Type => Int64, -- Hash => Int64_Hash); package Int64_Sets is new Ada.Containers.Formal_Ordered_Sets (Element_Type => Int64); -- pragma Assertion_Policy (Post => Suppressible); Int64_Sets_Common_Max_Capacity : constant := 200; -- arbitrary, and shared among all instances but not necessarily -- subtype Int64_Set is Int64_Sets.Set -- (Int64_Sets_Common_Max_Capacity, Int64_Sets.Default_Modulus (Int64_Sets_Common_Max_Capacity)); subtype Int64_Set is Int64_Sets.Set (Int64_Sets_Common_Max_Capacity); end Common_Formal_Containers;
gwnum/hyperhlp.asm
Kasual/GIMPS
0
170671
; Copyright 2018 Mersenne Research, Inc. All rights reserved ; Author: <NAME> ; Email: <EMAIL> ; ; Helper routines for hyperthread prefetching ; TITLE hyperhlp IFNDEF X86_64 .686 .XMM .MODEL FLAT ENDIF INCLUDE unravel.mac _TEXT SEGMENT ;; Utility routines to help with hyperthread prefetching ; prefetchL2 (addr, cachelines) ; Prefetch into L2 cache from addr for the specified number of 64-byte cache lines ; Windows 32-bit (_prefetchL2) ; Linux 32-bit (prefetchL2) ; Parameter addr = [esp+4] ; Parameter cachelines = [esp+8] ; Windows 64-bit (prefetchL2) - leaf routine, no unwind info necessary ; Parameter addr = rcx ; Parameter cachelines = rdx ; Linux 64-bit (prefetchL2) ; Parameter addr = rdi ; Parameter cachelines = rsi PROCL prefetchL2 IFNDEF X86_64 mov edi, [esp+4] ; Load addr mov ecx, [esp+8] ; Load count pfloop: prefetcht1 [edi] ; Prefetch a 64-byte cache line ;;BUG? pause ; Pause between prefetches bump edi, 64 ; Next cache line dec ecx ; Test count jnz short pfloop ENDIF IFDEF WINDOWS64 pfloop: prefetcht1 [rcx] ; Prefetch a 64-byte cache line ;; pause ; Pause between prefetches bump rcx, 64 ; Next cache line dec rdx ; Test count jnz short pfloop ENDIF IFDEF LINUX64 pfloop: prefetcht1 [rdi] ; Prefetch a 64-byte cache line pause ; Pause between prefetches bump rdi, 64 ; Next cache line dec rsi ; Test count jnz short pfloop ENDIF ret prefetchL2 ENDP ; pause_for_count (count) ; Execute "count" pause ops so that hyperthread can wait for some prefetching to do ; without impacting the compute thread. ; Windows 32-bit (_pause_for_count) ; Linux 32-bit (pause_for_count) ; Parameter count = [esp+4] ; Windows 64-bit (pause_for_count) - leaf routine, no unwind info necessary ; Parameter count = rcx ; Linux 64-bit (pause_for_count) ; Parameter count = rdi PROCL pause_for_count IFNDEF X86_64 mov ecx, [esp+4] ; Load count ploop: pause ; Pause a few clocks dec ecx ; Test count jnz short ploop ENDIF IFDEF WINDOWS64 ploop: pause ; Pause a few clocks dec rcx ; Test count jnz short ploop ENDIF IFDEF LINUX64 ploop: pause ; Pause a few clocks dec rdi ; Test count jnz short ploop ENDIF ret pause_for_count ENDP _TEXT ENDS END
agda/course/2017-conor_mcbride_cs410/CS410-17-master/lectures/Lec1Done.agda
haroldcarr/learn-haskell-coq-ml-etc
36
3384
module Lec1Done where -- the -- mark introduces a "comment to end of line" ------------------------------------------------------------------------------ -- some basic "logical" types ------------------------------------------------------------------------------ data Zero : Set where -- to give a value in a data, choose one constructor -- there are no constructors -- so that's impossible record One : Set where -- to give a value in a record type, fill all its fields -- there are no fields -- so that's trivial -- (can we have a constructor, for convenience?) constructor <> {-# COMPILE GHC One = data () (()) #-} data _+_ (S : Set)(T : Set) : Set where -- "where" wants an indented block -- to offer a choice of constructors, list them with their types inl : S -> S + T -- constructors can pack up stuff inr : T -> S + T -- in Haskell, this was called "Either S T" {- record _*_ (S : Set)(T : Set) : Set where field -- introduces a bunch of fields, listed with their types fst : S snd : T -- in Haskell, this was called "(S, T)" -} -- _*_ IS GENERALIZED BY SIGMA record Sg (S : Set)(T : S -> Set) : Set where -- Sg is short for "Sigma" constructor _,_ field -- introduces a bunch of fields, listed with their types fst : S snd : T fst open Sg public -- brings fst and snd into scope hereafter unto all inheritors -- make _*_ from Sg ? _*_ : Set -> Set -> Set S * T = Sg S \ _ -> T infixr 4 _*_ _,_ ------------------------------------------------------------------------------ -- some simple proofs ------------------------------------------------------------------------------ comm-* : {A : Set}{B : Set} -> A * B -> B * A comm-* record { fst = a ; snd = b } = record { fst = b ; snd = a } assocLR-+ : {A B C : Set} -> (A + B) + C -> A + (B + C) assocLR-+ (inl (inl a)) = inl a assocLR-+ (inl (inr b)) = inr (inl b) assocLR-+ (inr c) = inr (inr c) _$*_ : {A A' B B' : Set} -> (A -> A') -> (B -> B') -> A * B -> A' * B' (f $* g) record { fst = a ; snd = b } = record { fst = f a ; snd = g b } -- record syntax is rather ugly for small stuff; can we have constructors? _$+_ : {A A' B B' : Set} -> (A -> A') -> (B -> B') -> A + B -> A' + B' (f $+ g) (inl a) = inl (f a) (f $+ g) (inr b) = inr (g b) combinatorK : {A E : Set} -> A -> E -> A combinatorK = \ a _ -> a combinatorS : {S T E : Set} -> (E -> S -> T) -> (E -> S) -> E -> T combinatorS = \ f s e -> (f e) (s e) id : {X : Set} -> X -> X -- id x = x -- is the easy way; let's do it a funny way to make a point id = combinatorS combinatorK (combinatorK {_} {Zero}) -- no choice for -^ ^^^^- could be anything naughtE : {X : Set} -> Zero -> X naughtE () -- standard composition: f << g is "f after g" _<<_ : {X Y Z : Set} -> (Y -> Z) -> (X -> Y) -> (X -> Z) (f << g) x = f (g x) -- diagrammatic composition: f >> g is "f then g" _>>_ : {X Y Z : Set} -> (X -> Y) -> (Y -> Z) -> (X -> Z) -- ^^^^^^^^ dominoes! (f >> g) x = g (f x) -- infix application _$_ : {S : Set}{T : S -> Set}(f : (x : S) -> T x)(s : S) -> T s f $ s = f s infixl 2 _$_ ------------------------------------------------------------------------------ -- from logic to data ------------------------------------------------------------------------------ data Nat : Set where zero : Nat suc : Nat -> Nat -- recursive data type {-# BUILTIN NATURAL Nat #-} -- ^^^^^^^^^^^^^^^^^^^ this pragma lets us use decimal notation _+N_ : Nat -> Nat -> Nat zero +N y = y suc x +N y = suc (x +N y) -- there are other choices four : Nat four = 2 +N 2 ------------------------------------------------------------------------------ -- and back to logic ------------------------------------------------------------------------------ data _==_ {X : Set} : X -> X -> Set where refl : (x : X) -> x == x -- the relation that's "only reflexive" {-# BUILTIN EQUALITY _==_ #-} -- we'll see what that's for, later _=$=_ : {X Y : Set}{f f' : X -> Y}{x x' : X} -> f == f' -> x == x' -> f x == f' x' refl f =$= refl x = refl (f x) infixl 2 _=$=_ zero-+N : (n : Nat) -> (zero +N n) == n zero-+N n = refl n +N-zero : (n : Nat) -> (n +N zero) == n +N-zero zero = refl zero +N-zero (suc n) = refl suc =$= +N-zero n assocLR-+N : (x y z : Nat) -> ((x +N y) +N z) == (x +N (y +N z)) assocLR-+N zero y z = refl (y +N z) assocLR-+N (suc x) y z = refl suc =$= assocLR-+N x y z ------------------------------------------------------------------------------ -- computing types ------------------------------------------------------------------------------ _>=_ : Nat -> Nat -> Set x >= zero = One zero >= suc y = Zero suc x >= suc y = x >= y refl->= : (n : Nat) -> n >= n refl->= zero = record {} refl->= (suc n) = refl->= n trans->= : (x y z : Nat) -> x >= y -> y >= z -> x >= z trans->= x y zero x>=y y>=z = record {} trans->= x zero (suc z) x>=y () trans->= zero (suc y) (suc z) () y>=z trans->= (suc x) (suc y) (suc z) x>=y y>=z = trans->= x y z x>=y y>=z ------------------------------------------------------------------------------ -- construction by proof ------------------------------------------------------------------------------ {- -- MOVED UP TO REPLACE _*_ record Sg (S : Set)(T : S -> Set) : Set where -- Sg is short for "Sigma" constructor _,_ field -- introduces a bunch of fields, listed with their types fst : S snd : T fst -- make _*_ from Sg ? _*_ : Set -> Set -> Set S * T = Sg S \ _ -> T -} difference : (m n : Nat) -> m >= n -> Sg Nat \ d -> m == (n +N d) -- ( ) difference m zero m>=n = m , refl m difference zero (suc n) () difference (suc m) (suc n) m>=n with difference m n m>=n difference (suc m) (suc n) m>=n | d , q = d , (refl suc =$= q) tryMe = difference 42 37 _ -- don'tTryMe = difference 37 42 {!!} ------------------------------------------------------------------------------ -- things to remember to say ------------------------------------------------------------------------------ -- why the single colon? -- what's with all the spaces? -- what's with identifiers mixing letters and symbols? -- what's with all the braces? -- what is Set? -- are there any lowercase/uppercase conventions? -- what's with all the underscores? -- (i) placeholders in mixfix operators -- (ii) don't care (on the left) -- (iii) go figure (on the right) -- why use arithmetic operators for types? -- what's the difference between = and == ? -- can't we leave out cases? -- can't we loop? -- the function type is both implication and universal quantification, -- but why is it called Pi? -- why is Sigma called Sigma? -- B or nor B?
programs/oeis/083/A083585.asm
jmorken/loda
1
171144
<reponame>jmorken/loda ; A083585: (8*5^n - 5*2^n)/3. ; 1,10,60,320,1640,8280,41560,208120,1041240,5207480,26039960,130204920,651034840,3255194680,16276014360,81380153720,406900932440,2034504989880,10172525604760,50862629334520,254313149294040 mov $1,1 mov $2,1 lpb $0 sub $0,1 mov $3,$1 add $1,3 sub $1,$2 mul $3,2 add $1,$3 mul $1,2 add $2,$3 lpe
libsrc/_DEVELOPMENT/adt/w_array/c/sccz80/w_array_at_callee.asm
teknoplop/z88dk
8
19152
<reponame>teknoplop/z88dk<filename>libsrc/_DEVELOPMENT/adt/w_array/c/sccz80/w_array_at_callee.asm ; void *w_array_at(w_array_t *a, size_t idx) SECTION code_clib SECTION code_adt_w_array PUBLIC w_array_at_callee EXTERN asm_w_array_at w_array_at_callee: pop hl pop bc ex (sp),hl jp asm_w_array_at
9 Division.asm
jpsxlr8/Microprocessor-Lab
0
8705
; Division of two 8-bit numbers ; can be done by repeated subtraction ; First Number: HL : 0250H = 125 = 0111 1101 ; Second Number: BC : 0251H = 004 = 0000 0100 ; result : 0260H = 031 = 0001 1111 ; 0261H = 001 = 0000 0001 MVI C, 00H ;initialise quotient LDA 0251H MOV B, A ;taking divisor LDA 0250H ;taking dividend LOOP: CMP B ;comparing if the dividend and divisor JNC NEXT ;if dividend > divisor JMP END ;if dividend < divisor, break loop, save result NEXT: SUB B ;repetitive subtraction INR C ;increase the quotient value JMP LOOP END: STA 0261H ; saving remainder MOV A, C STA 0260H ; saving quotient hlt
agda/book/Programming_Language_Foundations_in_Agda/x03relations.agda
haroldcarr/learn-haskell-coq-ml-etc
36
14356
<reponame>haroldcarr/learn-haskell-coq-ml-etc<gh_stars>10-100 module x03relations where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong; sym) open import Data.Nat using (ℕ; zero; suc; _+_; _*_) open import Data.Nat.Properties using (+-comm; +-identityʳ; *-comm; +-suc) {- ------------------------------------------------------------------------------ -- DEFINING RELATIONS : INEQUALITY ≤ z≤n -------- zero ≤ n m ≤ n s≤s ------------- suc m ≤ suc n -} -- INDEXED datatype : the type m ≤ n is indexed by two naturals, m and n data _≤_ : ℕ → ℕ → Set where -- base case holds for all naturals z≤n : ∀ {n : ℕ} -- IMPLICIT args -------- → zero ≤ n -- inductive case holds if m ≤ n s≤s : ∀ {m n : ℕ} -- IMPLICIT args → m ≤ n ------------- → suc m ≤ suc n {- proof 2 ≤ 4 z≤n ----- 0 ≤ 2 s≤s ------- 1 ≤ 3 s≤s --------- 2 ≤ 4 -} _ : 2 ≤ 4 _ = s≤s (s≤s z≤n) -- no explicit 'n' arg to z≤n because implicit -- no explicit 'm' 'n' args to s≤s because implicit -- can be explicit _ : 2 ≤ 4 -- with implicit args _ = s≤s {1} {3} (s≤s {0} {2} (z≤n {2})) _ : 2 ≤ 4 -- with named implicit args _ = s≤s {m = 1} {n = 3} (s≤s {m = 0} {n = 2} (z≤n {n = 2})) _ : 2 ≤ 4 -- with some implicit named args _ = s≤s {n = 3} (s≤s {n = 2} z≤n) -- infer explicit term via _ -- e.g., +-identityʳ variant with implicit arguments +-identityʳ′ : ∀ {m : ℕ} → m + zero ≡ m +-identityʳ′ = +-identityʳ _ -- agda infers _ from context (if it can) -- precedence infix 4 _≤_ ------------------------------------------------------------------------------ -- DECIDABILITY : can compute ≤ : see Chapter Decidable {- ------------------------------------------------------------------------------ -- INVERSION above def goes from smaller to larger things (e.g., m ≤ n to suc m ≤ suc n) sometimes go from bigger to smaller things. only one way to prove suc m ≤ suc n, for any m n use it to invert rule -} inv-s≤s : ∀ {m n : ℕ} → suc m ≤ suc n ------------- → m ≤ n inv-s≤s (s≤s m≤n) = m≤n {- ^ variable name (m ≤ n (with spaces) is a type) m≤n is of type m ≤ n convention : var name from type not every rule is invertible e.g., rule for z≤n has no non-implicit hypotheses, so nothing to invert another example inversion -} inv-z≤n : ∀ {m : ℕ} → m ≤ zero -------- → m ≡ zero -- only one way a number can be ≤ zero inv-z≤n z≤n = refl {- ------------------------------------------------------------------------------ -- PROPERTIES OF ORDERING RELATIONS - REFLEXIVE : ∀ n , n ≤ n - TRANSITIVE : ∀ m n p, if m ≤ n && n ≤ p then m ≤ p - ANTI-SYMMETRIC : ∀ m n , if m ≤ n && n ≤ m then m ≡ n - TOTAL : ∀ m n , either m ≤ n or n ≤ m _≤_ satisfies all 4 names for some combinations: PREORDER : reflexive and transitive PARTIAL ORDER : preorder that is also anti-symmetric TOTAL ORDER : partial order that is also total Exercise orderings (practice) preorder that is not a partial order: -- https://math.stackexchange.com/a/2217969 partial order that is not a total order: -- https://math.stackexchange.com/a/367590 -- other properties - SYMMETRIC : ∀ x y, if x R y then y R x ------------------------------------------------------------------------------ REFLEXIVITY -} -- proof is via induction on implicit arg n ≤-refl : ∀ {n : ℕ} -- implicit arg to make it easier to invoke ----- → n ≤ n ≤-refl {zero} = z≤n -- zero ≤ zero -- inductive case applies IH '≤-refl {n}' for a proof of n ≤ n to 's≤s' giving proof suc n ≤ suc n ≤-refl {suc n} = s≤s ≤-refl -- suc n ≤ suc n {- ------------------------------------------------------------------------------ TRANSITIVITY -} -- inductive proof using evidence m ≤ n ≤-trans : ∀ {m n p : ℕ} → m ≤ n → n ≤ p ----- → m ≤ p -- base -- 1st first inequality holds by z≤n -- v ≤-trans z≤n _ = z≤n {- ^ ^ | now must show zero ≤ p; follows by z≤n n ≤ p case is irrelevant (written _) -} {- inductive -- 1st inequality -- | 2nd inequality v v -} ≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p) {- 1st proves suc m ≤ suc n 2nd proves suc n ≤ suc p must now show suc m ≤ suc p IH '≤-trans m≤n n≤p' establishes m ≤ p goal follows by applying s≤s ≤-trans (s≤s m≤n) z≤n case cannot arise since - 1st inequality implies middle value is suc n - 2nd inequality implies that it is zero -} ≤-trans′ : ∀ (m n p : ℕ) -- ALTERNATIVE with explicit args → m ≤ n → n ≤ p ----- → m ≤ p ≤-trans′ zero _ _ z≤n _ = z≤n ≤-trans′ (suc m) (suc n) (suc p) (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans′ m n p m≤n n≤p) {- technique of induction on evidence that a property holds - e.g., inducting on evidence that m ≤ n rather than induction on values of which the property holds - e.g., inducting on m is often used ------------------------------------------------------------------------------ ANTI-SYMMETRY -} -- 842 -- proof via rewrite ≤-antisym' : ∀ {m n : ℕ} → m ≤ n → n ≤ m ----- → m ≡ n ≤-antisym' z≤n z≤n = refl ≤-antisym' (s≤s m≤n) (s≤s n≤m) rewrite ≤-antisym' m≤n n≤m = refl -- proof via induction over the evidence that m ≤ n and n ≤ m hold ≤-antisym : ∀ {m n : ℕ} → m ≤ n → n ≤ m ----- → m ≡ n ≤-antisym z≤n z≤n = refl ≤-antisym (s≤s m≤n) (s≤s n≤m) = cong suc (≤-antisym m≤n n≤m) {- base : both inequalities hold by z≤n - so given zero ≤ zero and zero ≤ zero - shows zero ≡ zero (via Reflexivity of equality) inductive - after using evidence for 1st and 2nd inequalities - have suc m ≤ suc n and suc n ≤ suc m - must show suc m ≡ suc n - IH '≤-antisym m≤n n≤m' establishes m ≡ n - goal follows by congruence Exercise ≤-antisym-cases (practice) TODO : describe why missing case OK The above proof omits cases where one argument is z≤n and one argument is s≤s. Why is it ok to omit them? -- Your code goes here ------------------------------------------------------------------------------ TOTAL -} -- datatype with PARAMETERS data Total (m n : ℕ) : Set where forward : m ≤ n --------- → Total m n flipped : n ≤ m --------- → Total m n {- Evidence that Total m n holds is either of the form - forward m≤n or - flipped n≤m where m≤n and n≤m are evidence of m ≤ n and n ≤ m respectively (above definition could also be written as a disjunction; see Chapter Connectives.) above data type uses PARAMETERS m n --- equivalent to following INDEXED datatype: -} data Total′ : ℕ → ℕ → Set where forward′ : ∀ {m n : ℕ} → m ≤ n ---------- → Total′ m n flipped′ : ∀ {m n : ℕ} → n ≤ m ---------- → Total′ m n {- Each parameter of the type translates as an implicit parameter of each constructor. Unlike an indexed datatype, where the indexes can vary (as in zero ≤ n and suc m ≤ suc n), in a parameterised datatype the parameters must always be the same (as in Total m n). Parameterised declarations are shorter, easier to read, and occasionally aid Agda’s termination checker. Use them in preference to indexed types when possible. ------------------------- show ≤ is a total order by induction over 1st and 2nd args uses WITH -} ≤-total : ∀ (m n : ℕ) → Total m n -- base : 1st arg zero so forward case holds with z≤n as evidence that zero ≤ n ≤-total zero n = forward z≤n -- base : 2nd arg zero so flipped case holds with z≤n as evidence that zero ≤ suc m ≤-total (suc m) zero = flipped z≤n -- inductive : IH establishes one of ≤-total (suc m) (suc n) with ≤-total m n -- forward case of IH with m≤n as evidence that m ≤ n -- follows that forward case of prop holds with s≤s m≤n as evidence that suc m ≤ suc n ... | forward m≤n = forward (s≤s m≤n) -- flipped case of IH with n≤m as evidence that n ≤ m -- follows that flipped case of prop holds with s≤s n≤m as evidence that suc n ≤ suc m ... | flipped n≤m = flipped (s≤s n≤m) {- WITH expression and one or more subsequent lines each line begins ... | followed by pattern and right-hand side WITH equivalent to defining a helper function: -} ≤-total′ : ∀ (m n : ℕ) → Total m n ≤-total′ zero n = forward z≤n ≤-total′ (suc m) zero = flipped z≤n ≤-total′ (suc m) (suc n) = helper (≤-total′ m n) where helper : Total m n → Total (suc m) (suc n) helper (forward m≤n) = forward (s≤s m≤n) helper (flipped n≤m) = flipped (s≤s n≤m) {- WHERE vars bound on the left-hand side of the preceding equation (e.g., m n) in scope in nested def any identifiers bound in nested definition (e.g., helper) in scope in right-hand side of preceding equation If both arguments are equal, then both cases hold and we could return evidence of either. In the code above we return the forward case, but there is a variant that returns the flipped case: -} ≤-total″ : ∀ (m n : ℕ) → Total m n ≤-total″ m zero = flipped z≤n ≤-total″ zero (suc n) = forward z≤n ≤-total″ (suc m) (suc n) with ≤-total″ m n ... | forward m≤n = forward (s≤s m≤n) ... | flipped n≤m = flipped (s≤s n≤m) -- differs from original : pattern matches on 2nd arg before 1st {- ------------------------------------------------------------------------------ MONOTONICITY ∀ {m n p q : ℕ} → m ≤ n → p ≤ q → m + p ≤ n + q addition is monotonic on the right proof by induction on 1st arg -} +-monoʳ-≤ : ∀ (n p q : ℕ) → p ≤ q ------------- → n + p ≤ n + q -- base : 1st is zero; zero + p ≤ zero + q -- def/eq p ≤ q -- evidence given by arg p≤q +-monoʳ-≤ zero p q p≤q = p≤q -- inductive : 1st is suc n; suc n + p ≤ suc n + q -- def/eq; suc (n + p) ≤ suc (n + q) -- IH +-monoʳ-≤ n p q p≤q establishes n + p ≤ n + q -- goal follows by applying s≤s +-monoʳ-≤ (suc n) p q p≤q = s≤s (+-monoʳ-≤ n p q p≤q) {- addition is monotonic on the left via previous result and commutativity of addition: -} +-monoˡ-≤ : ∀ (m n p : ℕ) → m ≤ n ------------- → m + p ≤ n + p +-monoˡ-≤ m n p m≤n -- m + p ≤ n + p rewrite +-comm m p -- p + m ≤ n + p | +-comm n p -- p + m ≤ p + n = +-monoʳ-≤ p m n m≤n -- combine above results: +-mono-≤ : ∀ (m n p q : ℕ) → m ≤ n → p ≤ q ------------- → m + p ≤ n + q +-mono-≤ m n p q m≤n p≤q = ≤-trans -- combining below via transitivity proves m + p ≤ n + q (+-monoˡ-≤ m n p m≤n) -- proves m + p ≤ n + p (+-monoʳ-≤ n p q p≤q) -- proves n + p ≤ n + q {- ------------------------------------------------------------------------------ Exercise *-mono-≤ (stretch) Show that multiplication is monotonic with regard to inequality. -} ------------------------- -- multiplication is monotonic on the right *-monoʳ-≤ : ∀ (n p q : ℕ) → p ≤ q ------------- → n * p ≤ n * q *-monoʳ-≤ zero p q p≤q -- zero * p ≤ zero * q -- zero ≤ zero = z≤n *-monoʳ-≤ n zero q p≤q -- n * zero ≤ n * q rewrite *-comm n zero -- 0 ≤ n * q = z≤n *-monoʳ-≤ n p zero p≤q -- n * p ≤ n * zero rewrite *-comm n zero -- n * p ≤ 0 | inv-z≤n p≤q -- n * 0 ≤ 0 | *-comm n zero -- 0 ≤ 0 = z≤n *-monoʳ-≤ n (suc p) (suc q) p≤q -- n * suc p ≤ n * suc q rewrite *-comm n (suc p) -- n + p * n ≤ n * suc q | *-comm n (suc q) -- n + p * n ≤ n + q * n | *-comm p n -- n + n * p ≤ n + q * n | *-comm q n -- n + n * p ≤ n + n * q = +-monoʳ-≤ n (n * p) (n * q) (*-monoʳ-≤ n p q (inv-s≤s p≤q)) ------------------------- -- multiplication is monotonic on the left *-monoˡ-≤ : ∀ (m n p : ℕ) → m ≤ n ------------- → m * p ≤ n * p *-monoˡ-≤ zero n p m≤n -- zero * p ≤ n * p -- zero ≤ n * p = z≤n *-monoˡ-≤ m zero p m≤n -- m * p ≤ zero * p -- m * p ≤ zero rewrite inv-z≤n m≤n -- 0 * p ≤ 0 -- zero ≤ 0 = z≤n *-monoˡ-≤ (suc m) (suc n) p m≤n -- suc m * p ≤ suc n * p -- p + m * p ≤ p + n * p = +-monoʳ-≤ p (m * p) (n * p) (*-monoˡ-≤ m n p (inv-s≤s m≤n)) ------------------------- *-mono-≤ : ∀ (m n p q : ℕ) → m ≤ n → p ≤ q ------------- → m * p ≤ n * q *-mono-≤ m n p q m≤n p≤q = ≤-trans (*-monoˡ-≤ m n p m≤n) (*-monoʳ-≤ n p q p≤q) {- ------------------------------------------------------------------------------ STRICT INEQUALITY < -} infix 4 _<_ data _<_ : ℕ → ℕ → Set where z<s : ∀ {n : ℕ} ------------ → zero < suc n -- diff from '≤' : 'zero ≤ n' s<s : ∀ {m n : ℕ} → m < n ------------- → suc m < suc n {- NOT REFLEXIVE IRREFLEXIVE : n < n never holds for any n TRANSITIVE NOT TOTAL TRICHOTOMY: ∀ m n, one of m < n, m ≡ n, or m > n holds - where m > n hold when n < m MONOTONIC with regards to ADDITION and MULTIPLICATION negation required to prove (so deferred to Chapter Negation) - irreflexivity - trichotomy case are mutually exclusive ------------------------------------------------------------------------------ show suc m ≤ n implies m < n (and conversely) -} m≤n→m<n : ∀ {m n : ℕ} → suc m ≤ n --------- → m < n m≤n→m<n {zero} {zero} () m≤n→m<n {zero} {suc n} m≤n = z<s m≤n→m<n {suc m} {suc n} m≤n = s<s (m≤n→m<n {m} {n} (inv-s≤s m≤n)) inv-s<s : ∀ {m n : ℕ} → suc m < suc n ------------- → m < n inv-s<s (s<s m<n) = m<n m<n→m≤n : ∀ {m n : ℕ} → m < n → m ≤ n m<n→m≤n {zero} {suc n} m<n = z≤n m<n→m≤n {suc m} {suc n} m<n = s≤s (m<n→m≤n {m} {n} (inv-s<s m<n)) {- can then give an alternative derivation of the properties of strict inequality (e.g., transitivity) by exploiting the corresponding properties of inequality ------------------------------------------------------------------------------ Exercise <-trans (recommended) : strict inequality is transitive. -} <-trans : ∀ {m n p : ℕ} → m < n → n < p ----- → m < p <-trans {zero} {n} {p} z<s (s<s n<p) = z<s <-trans {suc m} {suc n} {suc p} (s<s m<n) (s<s n<p) = s<s (<-trans {m} {n} {p} m<n n<p) <-trans' : ∀ {m n p : ℕ} → m < n → n < p ----- → m < p <-trans' z<s (s<s n<p) = z<s <-trans' (s<s m<n) (s<s n<p) = s<s (<-trans' m<n n<p) {- ------------------------------------------------------------------------------ Exercise trichotomy (practice) Show that strict inequality satisfies a weak version of trichotomy, in the sense that for any m and n that one of the following holds: - m < n - m ≡ n - m > n Define m > n to be the same as n < m. Need a data declaration, similar to that used for totality. (Later will show that the three cases are exclusive after negation is introduced.) -} -- from 842 data Trichotomy (m n : ℕ) : Set where is-< : m < n → Trichotomy m n is-≡ : m ≡ n → Trichotomy m n is-> : n < m → Trichotomy m n -- hc <-trichotomy : ∀ (m n : ℕ) → Trichotomy m n <-trichotomy zero zero = is-≡ refl <-trichotomy zero (suc n) = is-< z<s <-trichotomy (suc m) zero = is-> z<s <-trichotomy (suc m) (suc n) = helper (<-trichotomy m n) where helper : Trichotomy m n -> Trichotomy (suc m) (suc n) helper (is-< x) = is-< (s<s x) helper (is-≡ x) = is-≡ (cong suc x) helper (is-> x) = is-> (s<s x) {- ------------------------------------------------------------------------------ Exercise +-mono-< (practice) Show that addition is monotonic with respect to strict inequality. As with inequality, some additional definitions may be required. -} -- HC -- these proof are literal cut/paste/change '≤' to '<' -- no additional defs were required +-monoʳ-< : ∀ (n p q : ℕ) → p < q ------------- → n + p < n + q +-monoʳ-< zero p q p<q = p<q +-monoʳ-< (suc n) p q p<q = s<s (+-monoʳ-< n p q p<q) +-monoˡ-< : ∀ (m n p : ℕ) → m < n ------------- → m + p < n + p +-monoˡ-< m n p m<n rewrite +-comm m p | +-comm n p = +-monoʳ-< p m n m<n +-mono-< : ∀ (m n p q : ℕ) → m < n → p < q ------------- → m + p < n + q +-mono-< m n p q m<n p<q = <-trans (+-monoˡ-< m n p m<n) (+-monoʳ-< n p q p<q) {- ------------------------------------------------------------------------------ Exercise ≤-iff-< (recommended) : suc m ≤ n implies m < n, and conversely -} -- 842 exercise: LEtoLTS (1 point) ≤-<-to m≤n→m<sucn : ∀ {m n : ℕ} → m ≤ n → m < suc n m≤n→m<sucn {zero} m≤n = z<s m≤n→m<sucn {suc m} {suc n} m≤n = s<s (m≤n→m<sucn {m} {n} (inv-s≤s m≤n)) -- 842 exercise: LEStoLT (1 point) ≤-<--to′ sucm≤n→m<n : ∀ {m n : ℕ} → suc m ≤ n → m < n sucm≤n→m<n {zero} {suc n} sucm≤n = z<s sucm≤n→m<n {suc m} {suc n} sucm≤n = s<s (sucm≤n→m<n {m} {n} (inv-s≤s sucm≤n)) -- 842 exercise: LTtoSLE (1 point) ≤-<-from m<n→sucm≤n : ∀ {m n : ℕ} → m < n → suc m ≤ n m<n→sucm≤n {zero} {suc n} m<n = s≤s z≤n m<n→sucm≤n {suc m} {suc n} m<n = s≤s (m<n→sucm≤n {m} {n} (inv-s<s m<n)) -- 842 exercise: LTStoLE (1 point) ≤-<-from′ m<sucn→m≤n : ∀ {m n : ℕ} → m < suc n → m ≤ n m<sucn→m≤n {zero} z<n = z≤n m<sucn→m≤n {suc m} {suc n} (s<s m<n) = s≤s (m<sucn→m≤n {m} {n} m<n) -- ^ -- critical move {- ------------------------------------------------------------------------------ Exercise <-trans-revisited (practice) Give an alternative proof that strict inequality is transitive, using the relation between strict inequality and inequality and the fact that inequality is transitive. -- 842: use the above to give a proof of <-trans that uses ≤-trans -} n<p→n<sucp : ∀ {n p : ℕ} → n < p → n < suc p n<p→n<sucp z<s = z<s n<p→n<sucp {suc n} {suc p} n<p = s<s (n<p→n<sucp {n} {p} (inv-s<s n<p)) <-trans'' : ∀ {m n p : ℕ} → m < n → n < p ----- → m < p <-trans'' {zero} {suc n} {suc p} z<s _ = z<s <-trans'' {suc m} {suc n} {suc p} (s<s m<n) (s<s n<p) = sucm≤n→m<n (≤-trans (m<n→sucm≤n (s<s m<n)) (m<sucn→m≤n (s<s (n<p→n<sucp n<p)))) {- ------------------------------------------------------------------------------ EVEN and ODD : MUTUALLY RECURSIVE DATATYPE DECLARATION and OVERLOADED CONSTRUCTORS inequality and strict inequality are BINARY RELATIONS even and odd are UNARY RELATIONS, sometimes called PREDICATES -} -- identifier must be defined before it is used, so declare both before giving constructors. data even : ℕ → Set data odd : ℕ → Set data even where zero : -- overloaded with nat def --------- even zero suc : ∀ {n : ℕ} → odd n ------------ → even (suc n) data odd where suc : ∀ {n : ℕ} -- suc is overloaded with one above and nat def → even n ----------- → odd (suc n) {- overloading constructors is OK (handled by type inference overloading defined names NOT OK best practice : only overload related meanings -} -- mutually recursive proof functions : give types first, then impls -- sum of two even numbers is even e+e≡e : ∀ {m n : ℕ} → even m → even n ------------ → even (m + n) -- sum of even and odd is odd o+e≡o : ∀ {m n : ℕ} → odd m → even n ----------- → odd (m + n) -- given: zero is evidence that 1st is even -- given: 2nd is even -- result: even because 2nd is even e+e≡e zero en = en -- given: 1st is even because it is suc of odd -- given: 2nd is even -- result: even because it is suc of sum of odd and even number, which is odd e+e≡e (suc om) en = suc (o+e≡o om en) -- given: 1st odd because it is suc of even -- given: 2nd is event -- result: odd because it is suc of sum of two evens, which is even o+e≡o (suc em) en = suc (e+e≡e em en) ------------------------------------------------------------------------------ -- Exercise o+o≡e (stretch) : sum of two odd numbers is even -- 842 Hint: need to define another theorem and prove both by mutual induction -- sum of odd and even is odd e+o≡o : ∀ {m n : ℕ} → even m → odd n ----------- → odd (m + n) -- sum of odd and odd is even o+o≡e : ∀ {m n : ℕ} → odd m → odd n -------------- → even (m + n) e+o≡o zero on = on e+o≡o (suc em) on = suc (o+o≡e em on) o+o≡e (suc om) on = suc (e+o≡o om on) {- ------------------------------------------------------------------------------ Exercise Bin-predicates (stretch) representations not unique due to leading zeros eleven: ⟨⟩ I O I I -- canonical ⟨⟩ O O I O I I -- not canonical -} data Bin : Set where ⟨⟩ : Bin _O : Bin → Bin _I : Bin → Bin inc : Bin → Bin inc ⟨⟩ = ⟨⟩ I inc (b O) = b I inc (b I) = (inc b) O to : ℕ → Bin to zero = ⟨⟩ O to (suc m) = inc (to m) dbl : ℕ → ℕ dbl zero = zero dbl (suc m) = suc (suc (dbl m)) from : Bin → ℕ from ⟨⟩ = 0 from (b O) = dbl (from b) from (b I) = suc (dbl (from b)) -- httpS://www.reddit.com/r/agda/comments/hrvk07/plfa_quantifiers_help_with_binisomorphism/ -- holds if bitstring has a leading one data One : Bin → Set where one : One (⟨⟩ I) _withO : ∀ {b} → One b → One (b O) _withI : ∀ {b} → One b → One (b I) {- Hint: to prove below - first state/prove properties of One -} n≤1+n : ∀ (n : ℕ) → n ≤ 1 + n n≤1+n zero = z≤n n≤1+n (suc n) = s≤s (n≤1+n n) dbl-mono : ∀ (n : ℕ) → n ≤ dbl n dbl-mono zero = z≤n dbl-mono (suc n) = s≤s (≤-trans (dbl-mono n) (n≤1+n (dbl n))) -- not used; I thought it would be useful; first try n≤fromb→n≤dblfromb' : ∀ {n : ℕ} {b : Bin} → n ≤ from b → n ≤ dbl (from b) n≤fromb→n≤dblfromb' {zero} {b} p = z≤n n≤fromb→n≤dblfromb' {suc n} {b O} p = ≤-trans p (dbl-mono (from (b O))) n≤fromb→n≤dblfromb' {suc n} {b I} (s≤s p) = s≤s (≤-trans (≤-trans p (dbl-mono (dbl (from b)))) (n≤1+n (dbl (dbl (from b))))) -- not used; above cleaned up n≤fromb→n≤dblfromb : ∀ {n : ℕ} {b : Bin} → n ≤ from b → n ≤ dbl (from b) n≤fromb→n≤dblfromb {_} {b} p = ≤-trans p (dbl-mono (from b)) -- HINT: prove if One b then 1 is less or equal to the result of from b oneb→1≤fromb : ∀ {b : Bin} → One b → 1 ≤ from b oneb→1≤fromb {b I} _ = s≤s z≤n oneb→1≤fromb {b O} (p withO) = ≤-trans (oneb→1≤fromb p) (dbl-mono (from b)) oneb→0<fromb : ∀ {b : Bin} → One b → 0 < from b oneb→0<fromb p = m≤n→m<n (oneb→1≤fromb p) -- not used num-trailing-zeros : (b : Bin) {p : One b} → ℕ num-trailing-zeros (b I) = 0 num-trailing-zeros (b O) {p withO} = 1 + num-trailing-zeros b {p} -- not used do-dbls : ℕ -> ℕ do-dbls zero = suc zero do-dbls (suc n) = dbl (do-dbls n) {- xxx : {b : Bin} {n : ℕ} → (p : One b) → n ≡ num-trailing-zeros b {p} → do-dbls n ≤ from b xxx {⟨⟩ I} {zero} one ntz = s≤s z≤n xxx {b I} {zero} (ob withI) ntz = s≤s z≤n xxx {b O} {zero} (ob withO) ntz = ≤-trans (oneb→1≤fromb ob) (dbl-mono (from b)) xxx {b O} {suc n} (ob withO) ntz = {!!} -} -- bitstring is canonical if data Can : Bin → Set where czero : Can (⟨⟩ O) -- it consists of a single zero (representing zero) cone : ∀ {b : Bin} → One b -- it has a leading one (representing a positive number) ----- → Can b {- -------------------------------------------------- show that increment preserves canonical bitstrings -} oneb→one-incb : ∀ {b : Bin} → One b → One (inc b) oneb→one-incb one = one withO oneb→one-incb (p withO) = p withI oneb→one-incb (p withI) = oneb→one-incb p withO canb→canincb : ∀ {b : Bin} → Can b ---------- → Can (inc b) canb→canincb {.(⟨⟩ O)} czero = cone one canb→canincb {b} (cone p) = cone (oneb→one-incb p) {- -------------------------------------------------- show that converting a natural to a bitstring always yields a canonical bitstring -} can-to-n : ∀ {n : ℕ} → Can (to n) can-to-n {zero} = czero can-to-n {suc n} = canb→canincb (can-to-n {n}) {- -------------------------------------------------- show that converting a canonical bitstring to a natural and back is the identity TODO -} ob→obO : ∀ {b : Bin} → One b → One (b O) ob→obI : ∀ {b : Bin} → One b → One (b I) ob→obI {.(⟨⟩ I)} one = one withI ob→obI {.(_ O)} (p withO) = ob→obO p withI ob→obI {(b I)} (p withI) = ob→obI {b} p withI ob→obO {.(⟨⟩ I)} one = one withO ob→obO {.(_ O)} (p withO) = (ob→obO p) withO ob→obO {(b I)} (p withI) = ob→obI {b} p withO dblb : Bin → Bin dblb ⟨⟩ = ⟨⟩ dblb (⟨⟩ O) = ⟨⟩ O dblb b = b O dblbo : ∀ {b} → One b → Bin → Bin dblbo _ b = b O dblbc : ∀ {b} → Can b → Bin → Bin dblbc czero _ = ⟨⟩ O dblbc (cone _) b = b O xxxx : ∀ {b : Bin} {n : ℕ} → b ≡ (⟨⟩ I) → b ≡ to n → n ≡ 1 → (⟨⟩ I O) ≡ to (dbl n) xxxx p1 p2 p3 rewrite p3 = refl xx : ∀ {b : Bin} → One b -> to (dbl (from b)) ≡ b O xx one = refl xx {b O} (p withO) -- to (dbl (from (b O))) ≡ ((b O) O) -- to (dbl (dbl (from b))) ≡ ((b O) O) rewrite sym (xx p) -- to (dbl (dbl (from b))) ≡ (to (dbl (from b)) O) = {!!} xx {b I} (p withI) -- to (dbl (from (b I)) ≡ ((b I) O) -- inc (inc (to (dbl (dbl (from b))))) ≡ ((b I) O) = {!!} can-b→to-from-b≡b : ∀ {b : Bin} → Can b --------------- → to (from b) ≡ b can-b→to-from-b≡b czero = refl can-b→to-from-b≡b {.⟨⟩ I} (cone one) = refl can-b→to-from-b≡b {b O} (cone (p withO)) -- to (dbl (from b)) ≡ (b O) = xx p can-b→to-from-b≡b {b I} (cone (p withI)) -- inc (to (dbl (from b))) ≡ (b I) rewrite xx p -- (b I) ≡ (b I) = refl {- ------------------------------------------------------------------------------ Standard library defs in this chapter in standard library: import Data.Nat using (_≤_; z≤n; s≤s) import Data.Nat.Properties using (≤-refl; ≤-trans; ≤-antisym; ≤-total; +-monoʳ-≤; +-monoˡ-≤; +-mono-≤) ------------------------------------------------------------------------------ Unicode ≤ U+2264 LESS-THAN OR EQUAL TO (\<=, \le) ≥ U+2265 GREATER-THAN OR EQUAL TO (\>=, \ge) ˡ U+02E1 MODIFIER LETTER SMALL L (\^l) ʳ U+02B3 MODIFIER LETTER SMALL R (\^r) -}
programs/oeis/083/A083076.asm
neoneye/loda
22
93456
; A083076: Third row of number array A083075. ; 1,5,33,229,1601,11205,78433,549029,3843201,26902405,188316833,1318217829,9227524801,64592673605,452148715233,3165041006629,22155287046401,155087009324805,1085609065273633,7599263456915429,53194844198408001,372363909388856005,2606547365721992033,18245831560053944229,127720820920377609601,894045746442643267205,6258320225098502870433,43808241575689520093029,306657691029826640651201,2146603837208786484558405,15026226860461505391908833,105183588023230537743361829,736285116162613764203532801,5153995813138296349424729605,36077970691968074445973107233,252545794843776521121811750629,1767820563906435647852682254401,12374743947345049534968775780805,86623207631415346744781430465633,606362453419907427213470013259429,4244537173939351990494290092816001,29711760217575463933460030649712005,207982321523028247534220214547984033 mov $1,7 pow $1,$0 div $1,6 mul $1,4 add $1,1 mov $0,$1
MD407/Kap2/uppgift2.8.asm
konglobemeralt/DAT017
0
102322
<filename>MD407/Kap2/uppgift2.8.asm<gh_stars>0 @ @ mom7.asm @ start: @init port D och E som utportar LDR R6, =0X55555555 LDR R5, =0X40020C00 STR R6, [R5] LDR R5, =0X40021000 STR R6, [R5] @Adressen till port Ds ut data register till R5 LDR R5, =0X40020C14 @Adressen till port Es ut data register till R6 LDR R6, =0X40021014 main: @ R0 = R0 << R1 @ write register value before shift to bargraph LSR R2, R0, #16 STRH R2, [R5] STRH R0, [R6] @ Do the shift LSL R0, R1 @ Write register after shift to bargraph LSR R2, R0, #16 STRH R2, [R5] STRH R0, [R6] B main