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
boot/stage2/vetor.asm
nelsoncole/sirius-x86-64
10
16328
<gh_stars>1-10 bits 32 section .text global isr00,isr01,isr02,isr03,isr04,isr05,isr06,isr07,isr08,isr09 global isr10,isr11,isr12,isr13,isr14,isr15,isr16,isr17,isr18,isr19 global isr20,isr21,isr22,isr23,isr24,isr25,isr26,isr27,isr28,isr29 global isr30,isr31 extern fault_exception isr_jmp: pushad push ds push es push fs push gs push ss mov eax,[esp+52] ; pega vetor push eax mov eax,0x10 mov ds,ax mov es,ax mov fs,ax mov gs,ax call fault_exception pop eax pop ss pop gs pop fs pop es pop ds popad add esp,8 iretd isr00: push dword 0 push dword 0 jmp isr_jmp isr01: push dword 0 push dword 1 jmp isr_jmp isr02: push dword 0 push dword 2 jmp isr_jmp isr03: push dword 0 push dword 3 jmp isr_jmp isr04: push dword 0 push dword 4 jmp isr_jmp isr05: push dword 0 push dword 5 jmp isr_jmp isr06: push dword 0 push dword 6 jmp isr_jmp isr07: push dword 0 push dword 7 jmp isr_jmp isr08: ;error code push dword 8 jmp isr_jmp isr09: push dword 0 push dword 9 jmp isr_jmp isr10: ;error code push dword 10 jmp isr_jmp isr11: ;error code push dword 11 jmp isr_jmp isr12: ;error code push dword 12 jmp isr_jmp isr13: ;error code push dword 13 jmp isr_jmp isr14: ;error code push dword 14 jmp isr_jmp isr15: push dword 0 push dword 15 jmp isr_jmp isr16: push dword 0 push dword 16 jmp isr_jmp isr17: ;error code push dword 17 jmp isr_jmp isr18: push dword 0 push dword 18 jmp isr_jmp isr19: push dword 0 push dword 19 jmp isr_jmp isr20: push dword 0 push dword 20 jmp isr_jmp isr21: push dword 0 push dword 21 jmp isr_jmp isr22: push dword 0 push dword 22 jmp isr_jmp isr23: push dword 0 push dword 23 jmp isr_jmp isr24: push dword 0 push dword 24 jmp isr_jmp isr25: push dword 0 push dword 25 jmp isr_jmp isr26: push dword 0 push dword 26 jmp isr_jmp isr27: push dword 0 push dword 27 jmp isr_jmp isr28: push dword 0 push dword 28 jmp isr_jmp isr29: push dword 0 push dword 29 jmp isr_jmp isr30: push dword 0 push dword 30 jmp isr_jmp isr31: push dword 0 push dword 31 jmp isr_jmp global irq00,irq01,irq02,irq03,irq04,irq05,irq06,irq07,irq08,irq09 global irq10,irq11,irq12,irq13,irq14,irq15 extern irq_function irq00: push dword 0 push dword 32 irq_jmp: pushad push ds push es push ss push fs push gs mov eax,[esp+52] ; pega vetor push eax mov eax,0x10 mov ds,ax mov es,ax mov fs,ax mov gs,ax call irq_function pop eax pop gs pop fs pop ss pop es pop ds popad add esp,8 iretd irq01: push dword 0 push dword 33 jmp irq_jmp irq02: push dword 0 push dword 34 jmp irq_jmp irq03: push dword 0 push dword 35 jmp irq_jmp irq04: push dword 0 push dword 36 jmp irq_jmp irq05: push dword 0 push dword 37 jmp irq_jmp irq06: push BYTE 0 push BYTE 38 jmp irq_jmp irq07: push dword 0 push dword 39 jmp irq_jmp irq08: push dword 0 push dword 40 jmp irq_jmp irq09: push dword 0 push dword 41 jmp irq_jmp irq10: push dword 0 push dword 42 jmp irq_jmp irq11: push dword 0 push dword 43 jmp irq_jmp irq12: push dword 0 push dword 44 jmp irq_jmp irq13: push dword 0 push dword 45 jmp irq_jmp irq14: push dword 0 push dword 46 jmp irq_jmp irq15: push dword 0 push dword 47 jmp irq_jmp
programs/oeis/051/A051959.asm
neoneye/loda
22
19184
<reponame>neoneye/loda<gh_stars>10-100 ; A051959: Expansion of (1+6x)/( (1-2x-x^2)(1-x)^2). ; 1,10,36,104,273,686,1688,4112,9969,24114,58268,140728,339809,820438,1980784,4782112,11545121,27872474,67290196,162453000,392196337,946845822,2285888136,5518622256,13323132817,32164888066,77652909132,187470706520,452594322369,1092659351462,2637913025504,6368485402688,15374883831105,37118253065130,89611389961604,216341032988584,522293455939025,1260927944866894,3044149345673080,7349226636213328,17742602618100017,42834431872413650,103411466362927612,249657364598269176,602726195559466273,1455109755717202038,3512945706993870672,8481001169704943712,20474948046403758433,49430897262512460922,119336742571428680628,288104382405369822536,695545507382168326065,1679195397169706475038,4053936301721581276520,9787068000612869028464,23628072302947319333841,57043212606507507696546,137714497515962334727340,332472207638432177151640,802658912792826689031041,1937790033224085555214150,4678238979240997799459776,11294267991706081154134144,27266774962653160107728513,65827817917012401369591626,158922410796677962846912228,383672639510368327063416552,926267689817414616973745809,2236208019145197561010908654,5398683728107809738995563608,13033575475360817039002036368,31465834678829443816999636849,75965244833019704673001310578,183396324344868853163002258524,442757893522757410999005828152,1068912111390383675161013915361,2580582116303524761321033659414,6230076343997433197803081234736,15040734804298391156927196129440,36311545952594215511657473494177,87663826709486822180242143118362,211639199371567859872141759731476,510942225452622541924525662581896,1233523650276812943721193084895857,2977989526006248429366911832374206,7189502702289309802455016749644872,17356994930584868034276945331664560,41903492563459045871008907412974609,101163980057502959776294760157614402,244231452678464965423598427728204044,589626885414432890623491615614023128 lpb $0 mov $2,$0 sub $0,1 seq $2,48771 ; Partial sums of A048695. add $1,$2 lpe add $1,1 mov $0,$1
software/hal/boards/stm32_common/sdcard/media_reader-sdcard.adb
TUM-EI-RCS/StratoX
12
12420
<reponame>TUM-EI-RCS/StratoX -- Based on AdaCore's Ada Drivers Library, -- see https://github.com/AdaCore/Ada_Drivers_Library, -- checkout 93b5f269341f970698af18f9182fac82a0be66c3. -- Copyright (C) Adacore -- -- Tailored to StratoX project. -- Author: <NAME> (<EMAIL>) with STM32.Device; use STM32.Device; with STM32.DMA; use STM32.DMA; with STM32.GPIO; use STM32.GPIO; with STM32.SDMMC; use STM32.SDMMC; with Cortex_M.Cache; with HAL; with HIL.Devices; with Ada.Unchecked_Conversion; with Media_Reader.SDCard.Config; use Media_Reader.SDCard.Config; package body Media_Reader.SDCard is -- Tx_IRQ : constant Interrupt_ID := -- Ada.Interrupts.Names.DMA2_Stream6_Interrupt; Use_DMA : Boolean := True; procedure Ensure_Card_Informations (Controller : in out SDCard_Controller) with Inline_Always; procedure Set_DMA (on : Boolean) is begin Use_DMA := on; end Set_DMA; ------------ -- DMA_Rx -- ------------ -- on-chip DMA facility signals end of DMA transfer protected DMA_Interrupt_Handler is pragma Interrupt_Priority (HIL.Devices.IRQ_PRIO_SDIO); procedure Set_Transfer_State; -- Informes the DMA Int handler that a transfer is about to start procedure Clear_Transfer_State; function Buffer_Error return Boolean; entry Wait_Transfer (Status : out DMA_Error_Code); private procedure Interrupt_RX with Attach_Handler => Rx_IRQ, Unreferenced; procedure Interrupt_TX with Attach_Handler => Tx_IRQ, Unreferenced; Finished : Boolean := True; DMA_Status : DMA_Error_Code := DMA_No_Error; Had_Buffer_Error : Boolean := False; end DMA_Interrupt_Handler; ------------------ -- SDMMC_Status -- ------------------ -- on-chip SD controller signals 'data end' and flags protected SDMMC_Interrupt_Handler is pragma Interrupt_Priority (HIL.Devices.IRQ_PRIO_SDIO - 1); procedure Set_Transfer_State (Controller : SDCard_Controller); procedure Clear_Transfer_State; entry Wait_Transfer (Status : out SD_Error); private procedure Interrupt with Attach_Handler => SDCard.Config.SD_Interrupt, Unreferenced; Finished : Boolean := True; SD_Status : SD_Error; Device : SDMMC_Controller; end SDMMC_Interrupt_Handler; ---------------- -- Initialize -- ---------------- procedure Initialize (Controller : in out SDCard_Controller) is begin -- Enable the SDIO clock Enable_Clock_Device; Reset_Device; -- Enable the DMA2 clock Enable_Clock (SD_DMA); -- Enable the GPIOs Enable_Clock (SD_Pins); -- & SD_Detect_Pin); not every board has a pin -- GPIO configuration for the SDIO pins Configure_IO (SD_Pins, (Mode => Mode_AF, Output_Type => Push_Pull, Speed => Speed_High, Resistors => Pull_Up)); Configure_Alternate_Function (SD_Pins, GPIO_AF_SDIO); -- essential! -- GPIO configuration for the SD-Detect pin -- Configure_IO -- (SD_Detect_Pin, -- (Mode => Mode_In, -- Output_Type => Open_Drain, -- Speed => Speed_High, -- Resistors => Pull_Up)); Controller.Device := STM32.SDMMC.As_Controller (SD_Device'Access); Disable (SD_DMA, SD_DMA_Rx_Stream); -- see http://blog.frankvh.com/2011/12/30/stm32f2xx-stm32f4xx-sdio-interface-part-2/, comment 5+6. Configure (SD_DMA, SD_DMA_Rx_Stream, (Channel => SD_DMA_Rx_Channel, Direction => Peripheral_To_Memory, Increment_Peripheral_Address => False, Increment_Memory_Address => True, Peripheral_Data_Format => Words, -- essential: the memory buffer must be aligned to this setting. was words. Nothing helps. Memory_Data_Format => Words, Operation_Mode => Peripheral_Flow_Control_Mode, -- https://github.com/lvniqi/STM32F4xx_DSP_StdPeriph_Lib_V1.3.0 uses Normal Mode Priority => Priority_Medium, -- SD is not so important. FIFO_Enabled => True, -- datasheet recommends True. False doesn't help. FIFO_Threshold => FIFO_Threshold_Full_Configuration, -- was: FIFO_Threshold_Full_Configuration, Memory_Burst_Size => Memory_Burst_Inc4, -- was Inc4 Peripheral_Burst_Size => Peripheral_Burst_Inc4)); -- was Inc4. Single does not help Clear_All_Status (SD_DMA, SD_DMA_Rx_Stream); Disable (SD_DMA, SD_DMA_Tx_Stream); Configure (SD_DMA, SD_DMA_Tx_Stream, (Channel => SD_DMA_Tx_Channel, -- OK Direction => Memory_To_Peripheral, -- OK Increment_Peripheral_Address => False, -- OK Increment_Memory_Address => True, -- OK Peripheral_Data_Format => Words, -- was: Words Memory_Data_Format => Words, -- was: Words Operation_Mode => Peripheral_Flow_Control_Mode, -- was: periph. but technically 'Normal' seems better Priority => Priority_Very_High, -- OK FIFO_Enabled => True, -- OK FIFO_Threshold => FIFO_Threshold_Full_Configuration, -- only full allowed. see manual. Memory_Burst_Size => Memory_Burst_Inc4, -- OK Peripheral_Burst_Size => Peripheral_Burst_Inc4)); -- OK Clear_All_Status (SD_DMA, SD_DMA_Tx_Stream); end Initialize; ------------------ -- Card_Present -- ------------------ function Card_Present (Controller : in out SDCard_Controller) return Boolean is pragma Unreferenced (Controller); begin -- if STM32.GPIO.Set (SD_Detect_Pin) then -- -- No card -- Controller.Has_Info := False; -- Controller.Card_Detected := False; -- else -- -- Card detected. Just wait a bit to unbounce the signal from the -- -- detect pin -- if not Controller.Card_Detected then -- delay until Clock + Milliseconds (50); -- end if; -- -- Controller.Card_Detected := not STM32.GPIO.Set (SD_Detect_Pin); -- end if; -- -- return Controller.Card_Detected; return True; -- in general there is no detect pin. so assume it is there. end Card_Present; ------------------------------ -- Ensure_Card_Informations -- ------------------------------ procedure Ensure_Card_Informations (Controller : in out SDCard_Controller) is Ret : SD_Error; begin if Controller.Has_Info then return; end if; Ret := STM32.SDMMC.Initialize (Controller.Device, Controller.Info); if Ret = OK then Controller.Has_Info := True; else Controller.Has_Info := False; end if; end Ensure_Card_Informations; -------------------------- -- Get_Card_information -- -------------------------- function Get_Card_Information (Controller : in out SDCard_Controller) return STM32.SDMMC.Card_Information is begin Ensure_Card_Informations (Controller); if not Controller.Has_Info then -- Issue reading the SD-card information Ensure_Card_Informations (Controller); end if; if not Controller.Has_Info then raise Device_Error; -- TODO: remove end if; return Controller.Info; end Get_Card_Information; ---------------- -- Block_Size -- ---------------- overriding function Block_Size (Controller : in out SDCard_Controller) return Unsigned_32 is begin Ensure_Card_Informations (Controller); return Controller.Info.Card_Block_Size; end Block_Size; --------------------------- -- DMA_Interrupt_Handler -- --------------------------- protected body DMA_Interrupt_Handler is function Buffer_Error return Boolean is (Had_Buffer_Error); ------------------- -- Wait_Transfer -- ------------------- entry Wait_Transfer (Status : out DMA_Error_Code) when Finished is begin Status := DMA_Status; end Wait_Transfer; ------------------------ -- Set_Transfer_State -- ------------------------ procedure Set_Transfer_State is begin Finished := False; DMA_Status := DMA_No_Error; Had_Buffer_Error := False; end Set_Transfer_State; -------------------------- -- Clear_Transfer_State -- -------------------------- procedure Clear_Transfer_State is begin Finished := True; DMA_Status := DMA_Transfer_Error; end Clear_Transfer_State; --------------- -- Interrupt -- --------------- procedure Interrupt_RX is begin if Status (SD_DMA, SD_DMA_Rx_Stream, Transfer_Complete_Indicated) then Disable_Interrupt (SD_DMA, SD_DMA_Rx_Stream, Transfer_Complete_Interrupt); Clear_Status (SD_DMA, SD_DMA_Rx_Stream, Transfer_Complete_Indicated); DMA_Status := DMA_No_Error; Finished := True; end if; if Status (SD_DMA, SD_DMA_Rx_Stream, FIFO_Error_Indicated) then Disable_Interrupt (SD_DMA, SD_DMA_Rx_Stream, FIFO_Error_Interrupt); Clear_Status (SD_DMA, SD_DMA_Rx_Stream, FIFO_Error_Indicated); -- see Interrupt_TX Had_Buffer_Error := True; end if; if Status (SD_DMA, SD_DMA_Rx_Stream, Transfer_Error_Indicated) then Disable_Interrupt (SD_DMA, SD_DMA_Rx_Stream, Transfer_Error_Interrupt); Clear_Status (SD_DMA, SD_DMA_Rx_Stream, Transfer_Error_Indicated); DMA_Status := DMA_Transfer_Error; Finished := True; end if; if Finished then for Int in STM32.DMA.DMA_Interrupt loop Disable_Interrupt (SD_DMA, SD_DMA_Rx_Stream, Int); end loop; end if; end Interrupt_RX; procedure Interrupt_TX is begin if Status (SD_DMA, SD_DMA_Tx_Stream, Transfer_Complete_Indicated) then Disable_Interrupt (SD_DMA, SD_DMA_Tx_Stream, Transfer_Complete_Interrupt); Clear_Status (SD_DMA, SD_DMA_Tx_Stream, Transfer_Complete_Indicated); DMA_Status := DMA_No_Error; Finished := True; end if; if Status (SD_DMA, SD_DMA_Tx_Stream, FIFO_Error_Indicated) then -- this signal can be ignored when transfer is completed -- however, it comes before Transfer_Complete_Indicated and -- We cannot use the value of the NDT register either, because -- it's a race condition (the register lacks behind). -- As a result, we have to ignore it. Disable_Interrupt (SD_DMA, SD_DMA_Tx_Stream, FIFO_Error_Interrupt); Clear_Status (SD_DMA, SD_DMA_Tx_Stream, FIFO_Error_Indicated); Had_Buffer_Error := True; -- declare -- ndt : constant Unsigned_16 := Current_Counter (Unit => SD_DMA, Stream => SD_DMA_Tx_Stream); -- ctr : Unsigned_16; -- begin -- if Operating_Mode (Unit => SD_DMA, Stream => SD_DMA_Tx_Stream) = Peripheral_Flow_Control_Mode then -- ctr := 16#ffff# - ndt; -- else -- ctr := ndt; -- end if; -- if ctr /= Expected then -- DMA_Status := DMA_FIFO_Error; -- Finished := True; -- end if; -- end; end if; if Status (SD_DMA, SD_DMA_Tx_Stream, Transfer_Error_Indicated) then Disable_Interrupt (SD_DMA, SD_DMA_Tx_Stream, Transfer_Error_Interrupt); Clear_Status (SD_DMA, SD_DMA_Tx_Stream, Transfer_Error_Indicated); DMA_Status := DMA_Transfer_Error; Finished := True; end if; if Finished then for Int in STM32.DMA.DMA_Interrupt loop Disable_Interrupt (SD_DMA, SD_DMA_Tx_Stream, Int); end loop; end if; end Interrupt_TX; end DMA_Interrupt_Handler; ----------------------------- -- SDMMC_Interrupt_Handler -- ----------------------------- protected body SDMMC_Interrupt_Handler is ------------------- -- Wait_Transfer -- ------------------- entry Wait_Transfer (Status : out SD_Error) when Finished is begin Status := SD_Status; end Wait_Transfer; ---------------------- -- Set_Transferring -- ---------------------- procedure Set_Transfer_State (Controller : SDCard_Controller) is begin Finished := False; Device := Controller.Device; end Set_Transfer_State; -------------------------- -- Clear_Transfer_State -- -------------------------- procedure Clear_Transfer_State is begin Finished := True; SD_Status := Error; end Clear_Transfer_State; --------------- -- Interrupt -- --------------- procedure Interrupt is begin Finished := True; if Get_Flag (Device, Data_End) then Clear_Flag (Device, Data_End); SD_Status := OK; elsif Get_Flag (Device, Data_CRC_Fail) then Clear_Flag (Device, Data_CRC_Fail); SD_Status := CRC_Check_Fail; elsif Get_Flag (Device, Data_Timeout) then Clear_Flag (Device, Data_Timeout); SD_Status := Timeout_Error; elsif Get_Flag (Device, RX_Overrun) then Clear_Flag (Device, RX_Overrun); SD_Status := Rx_Overrun; elsif Get_Flag (Device, TX_Underrun) then Clear_Flag (Device, TX_Underrun); SD_Status := Tx_Underrun; end if; for Int in SDMMC_Interrupts loop Disable_Interrupt (Device, Int); end loop; end Interrupt; end SDMMC_Interrupt_Handler; overriding function Write_Block (Controller : in out SDCard_Controller; Block_Number : Unsigned_32; Data : Block) return Boolean is Ret : SD_Error; DMA_Err : DMA_Error_Code; begin Ensure_Card_Informations (Controller); if Use_DMA then -- Flush the data cache Cortex_M.Cache.Invalidate_DCache (Start => Data (Data'First)'Address, Len => Data'Length); DMA_Interrupt_Handler.Set_Transfer_State; SDMMC_Interrupt_Handler.Set_Transfer_State (Controller); Clear_All_Status (SD_DMA, SD_DMA_Tx_Stream); Ret := Write_Blocks_DMA (Controller.Device, Unsigned_64 (Block_Number) * Unsigned_64 (Controller.Info.Card_Block_Size), SD_DMA, SD_DMA_Tx_Stream, SD_Data (Data)); -- this always leaves the last 12 byte standing. Why? -- also...NDTR is not what it should be. if Ret /= OK then DMA_Interrupt_Handler.Clear_Transfer_State; SDMMC_Interrupt_Handler.Clear_Transfer_State; Abort_Transfer (SD_DMA, SD_DMA_Tx_Stream, DMA_Err); return False; end if; DMA_Interrupt_Handler.Wait_Transfer (DMA_Err); -- this unblocks SDMMC_Interrupt_Handler.Wait_Transfer (Ret); -- TX underrun! -- this seems slow. Do we have to wait? loop -- FIXME: some people claim, that this goes wrong with multiblock, see -- http://blog.frankvh.com/2011/09/04/stm32f2xx-sdio-sd-card-interface/ exit when not Get_Flag (Controller.Device, TX_Active); end loop; Clear_All_Status (SD_DMA, SD_DMA_Tx_Stream); Disable (SD_DMA, SD_DMA_Tx_Stream); declare data_incomplete : constant Boolean := DMA_Interrupt_Handler.Buffer_Error and then Items_Transferred (SD_DMA, SD_DMA_Tx_Stream) /= Data'Length / 4; begin return Ret = OK and then DMA_Err = DMA_No_Error and then not data_incomplete; end; else Ret := Write_Blocks (Controller.Device, Unsigned_64 (Block_Number) * Unsigned_64 (Controller.Info.Card_Block_Size), SD_Data (Data)); return Ret = OK; end if; end Write_Block; ---------------- -- Read_Block -- ---------------- overriding function Read_Block (Controller : in out SDCard_Controller; Block_Number : Unsigned_32; Data : out Block) return Boolean is Ret : SD_Error; DMA_Err : DMA_Error_Code; subtype Word_Data is SD_Data (1 .. 4); function To_Data is new Ada.Unchecked_Conversion (HAL.Word, Word_Data); begin Ensure_Card_Informations (Controller); if Use_DMA then DMA_Interrupt_Handler.Set_Transfer_State; SDMMC_Interrupt_Handler.Set_Transfer_State (Controller); Ret := Read_Blocks_DMA (Controller.Device, Unsigned_64 (Block_Number) * Unsigned_64 (Controller.Info.Card_Block_Size), SD_DMA, SD_DMA_Rx_Stream, SD_Data (Data)); if Ret /= OK then DMA_Interrupt_Handler.Clear_Transfer_State; SDMMC_Interrupt_Handler.Clear_Transfer_State; Abort_Transfer (SD_DMA, SD_DMA_Rx_Stream, DMA_Err); return False; end if; SDMMC_Interrupt_Handler.Wait_Transfer (Ret); -- this unblocks: ret= ok DMA_Interrupt_Handler.Wait_Transfer (DMA_Err); -- this unblocks: DMA_err = no err -- following two lines are supposed to flush the FIFO, see manual RM0090 DMA Controller/FIFO Flush --Disable (SD_DMA, SD_DMA_Rx_Stream); --Clear_All_Status (SD_DMA, SD_DMA_Rx_Stream); -- not working -- Workaround: DMA leaves a tail in the SDIO FIFO buffer. We don'T know why, yet. -- one reason might be mentioned in AN4031 sec.4.9.1: "When managing peripheral reads -- over DMA memory port, software must ensure that 4x extra words are read from the -- peripheral. This is to guarantee that last valid data are transferred-out from -- DMA FIFO". However, in our case data is in SDIO FIFO. -- ALso, we don't know how long, but it should be < 32bit*16, since otherwise FIFO would -- be more than half full and thus trigger another DMA burst. -- Read the tail, count how long it is, and then copy over to the target buffer. declare Tail_Data : SD_Data ( 0 .. 15 ); k : Unsigned_32 := Tail_Data'First; next_data : Unsigned_32; begin while Get_Flag (Controller.Device, RX_Active) loop if k < Tail_Data'Length then Tail_Data (k .. k + 3) := To_Data (Read_FIFO (Controller.Device)); -- 4 bytes per FIFO element k := k + 4; end if; end loop; if k > 0 then k := k - 1; next_data := Unsigned_32 (Data'Last) - k; Data (Unsigned_16 (next_data) .. Data'Last) := Block (Tail_Data (0 .. k)); end if; end; -- after having removed the tail, this doesn't block anymore. loop exit when not Get_Flag (Controller.Device, RX_Active); -- now that FIFO is empty, that works. end loop; Clear_All_Status (SD_DMA, SD_DMA_Rx_Stream); Disable (SD_DMA, SD_DMA_Rx_Stream); -- Flush the data cache Cortex_M.Cache.Invalidate_DCache (Start => Data (Data'First)'Address, Len => Data'Length); declare data_incomplete : constant Boolean := DMA_Interrupt_Handler.Buffer_Error and then Items_Transferred (SD_DMA, SD_DMA_Tx_Stream) /= Data'Length / 4; begin return Ret = OK and then DMA_Err = DMA_No_Error and then not data_incomplete; end; else -- polling => rx overrun possible Ret := Read_Blocks (Controller.Device, Unsigned_64 (Block_Number) * Unsigned_64 (Controller.Info.Card_Block_Size), SD_Data (Data)); return Ret = OK; end if; end Read_Block; end Media_Reader.SDCard;
programs/oeis/220/A220466.asm
neoneye/loda
22
29498
; A220466: a((2*n-1)*2^p) = 4^p*(n-1) + 2^(p-1)*(1+2^p), p >= 0 and n >= 1. ; 1,3,2,10,3,7,4,36,5,11,6,26,7,15,8,136,9,19,10,42,11,23,12,100,13,27,14,58,15,31,16,528,17,35,18,74,19,39,20,164,21,43,22,90,23,47,24,392,25,51,26,106,27,55,28,228,29,59,30,122,31,63,32,2080,33,67,34,138,35,71,36,292,37,75,38,154,39,79,40,648,41,83,42,170,43,87,44,356,45,91,46,186,47,95,48,1552,49,99,50,202 add $0,2 mov $1,$0 lpb $1 mul $0,2 sub $1,1 dif $1,2 add $1,1 lpe div $0,2
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0xca_notsx.log_21829_860.asm
ljhsiun2/medusa
9
161815
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r15 push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x5c36, %rdx nop nop nop nop nop lfence mov $0x6162636465666768, %r11 movq %r11, %xmm1 movups %xmm1, (%rdx) nop nop nop inc %rbx lea addresses_WT_ht+0x14612, %rbp nop cmp %r11, %r11 mov $0x6162636465666768, %r15 movq %r15, %xmm5 movups %xmm5, (%rbp) nop nop nop nop nop add %r11, %r11 lea addresses_normal_ht+0x5812, %rbx nop nop nop nop nop cmp $26417, %rdi and $0xffffffffffffffc0, %rbx vmovntdqa (%rbx), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $1, %xmm0, %r11 nop nop nop add $47430, %rdi lea addresses_WC_ht+0x6c12, %rdx nop nop nop nop sub %rsi, %rsi movb (%rdx), %r11b xor $57662, %r15 lea addresses_A_ht+0x1c712, %rsi lea addresses_UC_ht+0xa9e2, %rdi nop nop nop nop nop sub %rbp, %rbp mov $55, %rcx rep movsq nop nop nop nop nop cmp %r15, %r15 lea addresses_A_ht+0xac12, %rdi nop nop nop nop cmp %r15, %r15 movb (%rdi), %bl nop cmp %r11, %r11 lea addresses_normal_ht+0x14012, %rcx nop nop nop nop nop and %r15, %r15 mov $0x6162636465666768, %rdi movq %rdi, (%rcx) nop nop add %r15, %r15 lea addresses_UC_ht+0x324, %rdx nop nop nop nop sub %rbx, %rbx mov (%rdx), %r11w nop nop nop dec %rdx lea addresses_WT_ht+0x2c4e, %rsi nop nop nop nop and $52812, %rdx movl $0x61626364, (%rsi) nop nop and $29683, %rdx lea addresses_A_ht+0x4c12, %rsi nop nop dec %rbx mov (%rsi), %cx nop nop nop sub $27714, %rbx lea addresses_normal_ht+0x1b212, %rsi lea addresses_UC_ht+0xc1b2, %rdi nop inc %rbp mov $106, %rcx rep movsb nop nop nop add $30360, %r11 lea addresses_UC_ht+0x3e6a, %rcx nop nop and %rdx, %rdx mov $0x6162636465666768, %r15 movq %r15, (%rcx) nop nop nop nop cmp %rsi, %rsi lea addresses_A_ht+0x198f2, %rdi nop nop nop nop nop cmp $8918, %rsi mov (%rdi), %rbp nop nop nop inc %r11 lea addresses_normal_ht+0x15cd2, %rsi lea addresses_A_ht+0x1187a, %rdi nop nop cmp %rdx, %rdx mov $1, %rcx rep movsq xor %rsi, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %r15 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r8 push %r9 push %rax push %rbx push %rcx // Store lea addresses_normal+0x11012, %r12 nop nop nop xor %rcx, %rcx movl $0x51525354, (%r12) nop cmp %r11, %r11 // Store lea addresses_UC+0x1ebba, %rcx cmp %r12, %r12 movl $0x51525354, (%rcx) cmp $35464, %r8 // Load lea addresses_WT+0xf45a, %r12 nop nop sub $32530, %rbx mov (%r12), %r8d nop nop nop nop nop inc %r11 // Faulty Load lea addresses_PSE+0xe412, %r8 nop nop nop cmp %r9, %r9 vmovups (%r8), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $1, %xmm1, %rax lea oracles, %r11 and $0xff, %rax shlq $12, %rax mov (%r11,%rax,1), %rax pop %rcx pop %rbx pop %rax pop %r9 pop %r8 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_PSE', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_normal', 'size': 4, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_UC', 'size': 4, 'AVXalign': True}} {'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WT', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_PSE', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}} {'src': {'same': False, 'congruent': 7, 'NT': True, 'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 8, 'NT': True, 'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}} {'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False}} {'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': True}} {'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False}} {'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
programs/oeis/317/A317542.asm
jmorken/loda
1
16115
; A317542: Formal inverse of the period-doubling sequence A096268. ; 0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0 add $0,1 mul $0,2 cal $0,316832 ; In A316831, replace 2's and 3's with 0's. mov $1,$0
PIM/TP09/exemple_vecteurs_creux.adb
Hathoute/ENSEEIHT
1
21605
with Ada.Text_IO; use Ada.Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; with Vecteurs_Creux; use Vecteurs_Creux; -- Exemple d'utilisation des vecteurs creux. procedure Exemple_Vecteurs_Creux is V : T_Vecteur_Creux; Epsilon: constant Float := 1.0e-5; begin Put_Line ("Début du scénario"); -- Initialiser V ne marchera pas car on n'a encore modifié Est_Nul. Initialiser(V); Afficher(V); New_Line; pragma Assert(Est_Nul(V) = True); Detruire(V); pragma Assert(Composante_Recursif(V, 18) = 0.0); pragma Assert(Composante_Iteratif(V, 18) = 0.0); Modifier(V, 18, 1.0); Modifier(V, 2, 3.0); Modifier(V, 5, 11.0); Afficher(V); pragma Assert(Composante_Recursif(V, 18) = 1.0); pragma Assert(Composante_Iteratif(V, 2) = 3.0); Put_Line ("Fin du scénario"); end Exemple_Vecteurs_Creux;
SUBTRACTING.asm
sekharkaredla/8085
1
247800
<filename>SUBTRACTING.asm<gh_stars>1-10 LXI B,4000H LXI H,4001H LDAX B SUB M STA 5000H RST 1
SVD2ada/svd/stm32_svd-dlyb.ads
JCGobbi/Nucleo-STM32H743ZI
0
10259
<filename>SVD2ada/svd/stm32_svd-dlyb.ads pragma Style_Checks (Off); -- This spec has been automatically generated from STM32H743x.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package STM32_SVD.DLYB is pragma Preelaborate; --------------- -- Registers -- --------------- -- DLYB control register type CR_Register is record -- Delay block enable bit DEN : Boolean := False; -- Sampler length enable bit SEN : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record DEN at 0 range 0 .. 0; SEN at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; subtype CFGR_SEL_Field is HAL.UInt4; subtype CFGR_UNIT_Field is HAL.UInt7; subtype CFGR_LNG_Field is HAL.UInt12; -- DLYB configuration register type CFGR_Register is record -- Select the phase for the Output clock SEL : CFGR_SEL_Field := 16#0#; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; -- Delay Defines the delay of a Unit delay cell UNIT : CFGR_UNIT_Field := 16#0#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Delay line length value LNG : CFGR_LNG_Field := 16#0#; -- unspecified Reserved_28_30 : HAL.UInt3 := 16#0#; -- Length valid flag LNGF : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CFGR_Register use record SEL at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; UNIT at 0 range 8 .. 14; Reserved_15_15 at 0 range 15 .. 15; LNG at 0 range 16 .. 27; Reserved_28_30 at 0 range 28 .. 30; LNGF at 0 range 31 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- DELAY_Block_SDMMC1 type DLYB_Peripheral is record -- DLYB control register CR : aliased CR_Register; -- DLYB configuration register CFGR : aliased CFGR_Register; end record with Volatile; for DLYB_Peripheral use record CR at 16#0# range 0 .. 31; CFGR at 16#4# range 0 .. 31; end record; -- DELAY_Block_SDMMC1 DELAY_Block_QUADSPI_Periph : aliased DLYB_Peripheral with Import, Address => DELAY_Block_QUADSPI_Base; -- DELAY_Block_SDMMC1 DELAY_Block_SDMMC1_Periph : aliased DLYB_Peripheral with Import, Address => DELAY_Block_SDMMC1_Base; -- DELAY_Block_SDMMC1 DELAY_Block_SDMMC2_Periph : aliased DLYB_Peripheral with Import, Address => DELAY_Block_SDMMC2_Base; end STM32_SVD.DLYB;
gcc-gcc-7_3_0-release/gcc/ada/a-dinopr.ads
best08618/asylo
7
26744
<reponame>best08618/asylo ------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . D I S P A T C H I N G . N O N _ P R E E M P T I V E -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ -- This unit is not implemented in typical GNAT implementations that lie on -- top of operating systems, because it is infeasible to implement in such -- environments. -- If a target environment provides appropriate support for this package, -- then the Unimplemented_Unit pragma should be removed from this spec and -- an appropriate body provided. package Ada.Dispatching.Non_Preemptive is pragma Preelaborate (Non_Preemptive); pragma Unimplemented_Unit; procedure Yield_To_Higher; procedure Yield_To_Same_Or_Higher renames Yield; end Ada.Dispatching.Non_Preemptive;
Transynther/x86/_processed/US/_st_zr_un_/i7-7700_9_0xca_notsx.log_101_1603.asm
ljhsiun2/medusa
9
9121
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r14 push %r15 push %r9 push %rcx push %rdi push %rsi lea addresses_UC_ht+0x16b2d, %r13 nop nop and %r14, %r14 movb (%r13), %r15b nop nop xor %r9, %r9 lea addresses_A_ht+0x1b70f, %rsi lea addresses_D_ht+0x56d5, %rdi nop nop nop nop nop add $62338, %r9 mov $76, %rcx rep movsw nop nop nop nop and $31690, %r14 lea addresses_WC_ht+0x10387, %rcx dec %r13 mov $0x6162636465666768, %rdi movq %rdi, (%rcx) and $21511, %rcx lea addresses_WT_ht+0x1263f, %rsi lea addresses_WC_ht+0x423f, %rdi sub %r13, %r13 mov $126, %rcx rep movsw nop nop nop nop xor %rsi, %rsi lea addresses_A_ht+0xad3f, %rcx nop nop nop nop nop sub %rdi, %rdi movups (%rcx), %xmm3 vpextrq $0, %xmm3, %r9 nop nop nop nop nop inc %rcx lea addresses_WC_ht+0x473f, %rsi lea addresses_A_ht+0x15813, %rdi and $22607, %r11 mov $23, %rcx rep movsq and $27937, %r11 lea addresses_D_ht+0x23f, %r14 add %rdi, %rdi mov (%r14), %r15 xor %r15, %r15 lea addresses_A_ht+0xb03f, %r9 nop nop inc %r14 mov (%r9), %esi nop add $22436, %rsi lea addresses_WC_ht+0x1669f, %r13 nop nop nop nop xor $23701, %r15 movb $0x61, (%r13) and $26024, %rcx lea addresses_UC_ht+0x8f2f, %r11 clflush (%r11) nop and $30905, %r9 movb $0x61, (%r11) nop sub $22790, %r13 lea addresses_normal_ht+0x1da93, %rsi lea addresses_normal_ht+0x1e93f, %rdi nop nop nop sub %r11, %r11 mov $68, %rcx rep movsb nop cmp %rdi, %rdi pop %rsi pop %rdi pop %rcx pop %r9 pop %r15 pop %r14 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r9 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi // Store lea addresses_normal+0x16237, %r12 nop nop nop nop nop add %r14, %r14 movw $0x5152, (%r12) nop nop nop nop add $63224, %rax // Store lea addresses_D+0x9e3f, %r12 nop nop nop add $48689, %rdx mov $0x5152535455565758, %r14 movq %r14, (%r12) nop nop cmp %r12, %r12 // REPMOV lea addresses_A+0x1373f, %rsi lea addresses_WC+0x7e3f, %rdi and $57833, %rbx mov $98, %rcx rep movsb nop xor %rcx, %rcx // Faulty Load lea addresses_US+0x1de3f, %rsi cmp $7345, %rbx movb (%rsi), %r11b lea oracles, %rdx and $0xff, %r11 shlq $12, %r11 mov (%rdx,%r11,1), %r11 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r9 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': True, 'type': 'addresses_US'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_normal'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 10, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'} {'src': {'congruent': 7, 'same': False, 'type': 'addresses_A'}, 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_WC'}, 'OP': 'REPM'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': True, 'type': 'addresses_US'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 4, 'same': False, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'src': {'congruent': 9, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 7, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 10, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 4, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'} {'src': {'congruent': 2, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'} {'c0': 17, '00': 49, '35': 35} 00 00 00 00 00 c0 c0 00 35 00 c0 00 00 00 00 00 35 35 c0 00 c0 00 00 35 00 00 00 c0 00 c0 35 00 c0 00 35 35 35 00 35 35 35 c0 00 35 00 00 c0 c0 00 35 00 00 35 35 00 00 35 00 c0 00 c0 00 00 00 00 35 35 00 00 35 00 c0 35 35 00 c0 35 00 00 00 35 00 00 00 00 35 c0 c0 00 35 35 35 35 35 35 35 35 35 35 35 00 */
alloy4fun_models/trashltl/models/7/eP3GJ7mZdS7LQYv3b.als
Kaixi26/org.alloytools.alloy
0
1909
open main pred ideP3GJ7mZdS7LQYv3b_prop8 { eventually (all f1,f2 : File | f1 -> f2 in link implies f1 in Trash) } pred __repair { ideP3GJ7mZdS7LQYv3b_prop8 } check __repair { ideP3GJ7mZdS7LQYv3b_prop8 <=> prop8o }
src/fot/PA/Inductive/Existential.agda
asr/fotc
11
5552
------------------------------------------------------------------------------ -- Existential quantifier on the inductive PA universe ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module PA.Inductive.Existential where infix 2 ∃ ------------------------------------------------------------------------------ -- PA universe open import PA.Inductive.Base.Core -- The existential quantifier type on M. data ∃ (A : ℕ → Set) : Set where _,_ : (x : ℕ) → A x → ∃ A -- Sugar syntax for the existential quantifier. syntax ∃ (λ x → e) = ∃[ x ] e -- 2012-03-05: We avoid to use the existential elimination or the -- existential projections because we use pattern matching (and the -- Agda's with constructor). -- The existential elimination. -- -- NB. We do not use the usual type theory elimination with two -- projections because we are working in first-order logic where we do -- not need extract a witness from an existence proof. -- ∃-elim : {A : ℕ → Set}{B : Set} → ∃ A → (∀ {x} → A x → B) → B -- ∃-elim (_ , Ax) h = h Ax -- The existential proyections. -- ∃-proj₁ : ∀ {A} → ∃ A → M -- ∃-proj₁ (x , _) = x -- ∃-proj₂ : ∀ {A} → (h : ∃ A) → A (∃-proj₁ h) -- ∃-proj₂ (_ , Ax) = Ax
projects/batfish/src/org/batfish/grammar/cisco/Cisco_common.g4
Alexia23/batfish
1
7645
parser grammar Cisco_common; options { tokenVocab = CiscoLexer; } access_list_action : PERMIT | DENY ; community : com = COMMUNITY_NUMBER | com = DEC | com = INTERNET | com = LOCAL_AS | com = NO_ADVERTISE | com = NO_EXPORT ; description_line : DESCRIPTION text = M_DESCRIPTION_NON_NEWLINE? NEWLINE ; ec_literal : DEC COLON DEC ; exact_match [String matchText] : {(_input.LT(1).getType() == VARIABLE || _input.LT(1).getType() == COMMUNITY_LIST_NUM_EXPANDED) && _input.LT(1).getText().equals($matchText)}? ( VARIABLE | COMMUNITY_LIST_NUM_EXPANDED ) ; exit_line : EXIT NEWLINE ; extended_community : ec_literal ; interface_name : ( name_prefix_alpha = M_Interface_PREFIX ( ( ( name_middle_parts += M_Interface_PREFIX )? name_middle_parts += DEC ( name_middle_parts += FORWARD_SLASH | name_middle_parts += PERIOD | name_middle_parts += COLON ) )* | name_middle_parts += MODULE ) range ) | ( name = VARIABLE ( FORWARD_SLASH DEC )? ) ; port_specifier : ( EQ ( args += port )+ ) | ( GT arg = port ) | ( NEQ arg = port ) | ( LT arg = port ) | ( RANGE arg1 = port arg2 = port ) ; port : DEC | AOL | BGP | BIFF | BOOTPC | BOOTPS | CHARGEN | CITRIX_ICA | CMD | CTIQBE | DAYTIME | DISCARD | DNSIX | DOMAIN | ECHO | EXEC | FINGER | FTP | FTP_DATA | GOPHER | H323 | HTTPS | HOSTNAME | IDENT | IMAP4 | IRC | ISAKMP | KERBEROS | KLOGIN | KSHELL | LDAP | LDAPS | LPD | LOGIN | LOTUSNOTES | MLAG | MOBILE_IP | NAMESERVER | NETBIOS_DGM | NETBIOS_NS | NETBIOS_SS | NETBIOS_SSN | NNTP | NON500_ISAKMP | NTP | PCANYWHERE_DATA | PCANYWHERE_STATUS | PIM_AUTO_RP | POP2 | POP3 | PPTP | RADIUS | RADIUS_ACCT | RIP | SECUREID_UDP | SMTP | SNMP | SNMPTRAP | SQLNET | SSH | SUNRPC | SYSLOG | TACACS | TALK | TELNET | TFTP | TIME | UUCP | WHO | WHOIS | WWW | XDMCP ; protocol : AHP | DEC | EIGRP | ESP | GRE | ICMP | IGMP | IP | IPINIP | IPV6 | OSPF | PIM | SCTP | TCP | UDP | VRRP ; range : ( range_list += subrange ( COMMA range_list += subrange )* ) | NONE ; subrange : low = DEC ( DASH high = DEC )? ; switchport_trunk_encapsulation : DOT1Q | ISL | NEGOTIATE ; variable : ~NEWLINE ;
alloy4fun_models/trashltl/models/1/kaqQRcX5AAGCY6ZMY.als
Kaixi26/org.alloytools.alloy
0
4974
<reponame>Kaixi26/org.alloytools.alloy open main pred idkaqQRcX5AAGCY6ZMY_prop2 { no File eventually some File } pred __repair { idkaqQRcX5AAGCY6ZMY_prop2 } check __repair { idkaqQRcX5AAGCY6ZMY_prop2 <=> prop2o }
source/xml/sax/xml-sax-lexical_handlers.ads
svn2github/matreshka
24
21607
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010, <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. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Strings; package XML.SAX.Lexical_Handlers is pragma Preelaborate; type SAX_Lexical_Handler is limited interface; not overriding procedure Comment (Self : in out SAX_Lexical_Handler; Text : League.Strings.Universal_String; Success : in out Boolean) is null; -- The reader calls this subprogram to report an XML comment anywhere in -- the document (inside and outside document element, and in the external -- DTD subset). It reports the text of the comment in ch. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure End_CDATA (Self : in out SAX_Lexical_Handler; Success : in out Boolean) is null; -- The reader calls this subprogram to report the end of a CDATA section. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure End_DTD (Self : in out SAX_Lexical_Handler; Success : in out Boolean) is null; -- The reader calls this subprogram to report the end of a DTD declaration, -- if any. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure End_Entity (Self : in out SAX_Lexical_Handler; Name : League.Strings.Universal_String; Success : in out Boolean) is null; -- The reader calls this subprogram to report the end of an entity called -- Name. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding function Error_String (Self : SAX_Lexical_Handler) return League.Strings.Universal_String is abstract; -- The reader calls this function to get an error string, e.g. if any of -- the handler subprograms sets Success to False. not overriding procedure Start_CDATA (Self : in out SAX_Lexical_Handler; Success : in out Boolean) is null; -- The reader calls this subprogram to report the start of a CDATA section. -- The content of the CDATA section is reported through the -- SAX_Content_Handler's Characters subprogram. This subprogram is intended -- only to report the boundary. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure Start_DTD (Self : in out SAX_Lexical_Handler; Name : League.Strings.Universal_String; Public_Id : League.Strings.Universal_String; System_Id : League.Strings.Universal_String; Success : in out Boolean) is null; -- The reader calls this subprogram to report the start of a DTD -- declaration, if any. It reports the name of the document type in Name, -- the public identifier in Public_Id and the system identifier in -- System_Id. -- -- If the public identifier is missing, Public_Id is set to an empty -- string. If the system identifier is missing, System_Id is set to an -- empty string. Note that it is not valid XML to have a public identifier -- but no system identifier; in such cases a parse error will occur. -- -- This subprogram is intended to report the beginning of the DOCTYPE -- declaration; if the document has no DOCTYPE declaration, this subprogram -- will not be invoked. -- -- All declarations reported through SAX_DTD_Handler or SAX_Decl_Handler -- appear between the Start_DTD and End_DTD calls. Declarations belong to -- the internal DTD subsets unless they appear between Start_Entity and -- End_Entity calls. Comments and processing instructions from the DTD also -- are reported between the Start_DTD and End_DTD calls, in their original -- order of (logical) occurrence; they are not appear in their correct -- locations relative to others calls of SAX_DTD_Handler or -- SAX_Decl_Handler, however. -- -- Note that the Start_DTD/End_DTD calls will appear within the -- Start_Document/End_Document calls from SAX_Content_Handler and before -- the first Start_Element event. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. not overriding procedure Start_Entity (Self : in out SAX_Lexical_Handler; Name : League.Strings.Universal_String; Success : in out Boolean) is null; -- The reader calls this subprogram to report the start of an internal or -- external entity called Name. -- -- General entities are reported with their regular names, parameter -- entities have '%' prepended to their names, and the external DTD subset -- has the pseudo-entity name "[dtd]". -- -- Note that if the entity is unknown, the reader reports it through -- SAX_Content_Handler's Skipped_Entity and not through this subprogram. -- -- Because of the streaming event model that SAX uses, some entity -- boundaries cannot be reported under any circumstances: -- -- * general entities within attribute values -- * parameter entities within declarations -- -- These will be silently expanded, with no indication of where the -- original entity boundaries were. -- -- Note also that the boundaries of character references (which are not -- really entities anyway) are not reported. -- -- The reporting of parameter entities (including the external DTD subset) -- is optional, and SAX2 drivers that report Lexical_Handler events may not -- implement it; you can use the -- http://xml.org/sax/features/lexical-handler/parameter-entities feature -- to query or control the reporting of parameter entities. -- -- If this subprogram sets Success to False the reader stops parsing and -- reports an error. The reader uses the function Error_String to get the -- error message. end XML.SAX.Lexical_Handlers;
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c4/c41326a.ada
best08618/asylo
7
19085
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c4/c41326a.ada -- C41326A.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 IMPLICITLY DECLARED EQUALITY AND INEQUALITY OPERATORS -- MAY BE SELECTED FROM OUTSIDE A PACKAGE USING AN EXPANDED NAME, FOR -- AN ACCESS TYPE. -- TBN 7/18/86 WITH REPORT; USE REPORT; PROCEDURE C41326A IS PACKAGE P IS TYPE CELL IS RECORD VALUE : INTEGER; END RECORD; TYPE LINK IS ACCESS CELL; OBJ_LINK_1 : LINK := NEW CELL'(VALUE => 1); OBJ_LINK_2 : LINK := OBJ_LINK_1; END P; VAR_LINK_1 : P.LINK := NEW P.CELL'(VALUE => 1); VAR_LINK_2 : P.LINK := NEW P.CELL'(VALUE => 2); BEGIN TEST ("C41326A", "CHECK THAT IMPLICITLY DECLARED EQUALITY AND " & "INEQUALITY OPERATORS MAY BE SELECTED FROM " & "OUTSIDE A PACKAGE USING AN EXPANDED NAME, " & "FOR AN ACCESS TYPE"); IF P."=" (VAR_LINK_1, P.OBJ_LINK_1) THEN FAILED ("INCORRECT RESULTS FROM EXPANDED NAME - 1"); END IF; IF P."/=" (P.OBJ_LINK_1, P.OBJ_LINK_2) THEN FAILED ("INCORRECT RESULTS FROM EXPANDED NAME - 2"); END IF; IF P."=" (VAR_LINK_2.ALL, P.OBJ_LINK_1.ALL) THEN FAILED ("INCORRECT RESULTS FROM EXPANDED NAME - 3"); END IF; VAR_LINK_2.VALUE := 1; IF P."/=" (VAR_LINK_2.ALL, P.OBJ_LINK_1.ALL) THEN FAILED ("INCORRECT RESULTS FROM EXPANDED NAME - 4"); END IF; RESULT; END C41326A;
Transynther/x86/_processed/AVXALIGN/_zr_/i7-7700_9_0x48_notsx.log_6_139.asm
ljhsiun2/medusa
9
21169
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r15 push %r9 push %rax push %rcx // Faulty Load lea addresses_US+0x5b5e, %r15 nop add $50429, %rcx movb (%r15), %r9b lea oracles, %rax and $0xff, %r9 shlq $12, %r9 mov (%rax,%r9,1), %r9 pop %rcx pop %rax pop %r9 pop %r15 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_US', 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': True, 'size': 1, 'type': 'addresses_US', 'congruent': 0}} <gen_prepare_buffer> {'00': 6} 00 00 00 00 00 00 */
programs/oeis/063/A063377.asm
neoneye/loda
22
86656
; A063377: Sophie Germain degree of n: number of iterations of n under f(k) = 2k+1 before we reach a number that is not a prime. ; 0,5,2,0,4,0,1,0,0,0,3,0,1,0,0,0,1,0,1,0,0,0,2,0,0,0,0,0,2,0,1,0,0,0,0,0,1,0,0,0,3,0,1,0,0,0,1,0,0,0,0,0,2,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,0,0,6,0,0,0,0,0,0,0,1,0,0,0 mov $8,308474 lpb $8,$0 mov $1,$0 add $0,1 seq $1,20639 ; Lpf(n): least prime dividing n (when n > 1); a(1) = 1. Or, smallest prime factor of n, or smallest prime divisor of n. cmp $0,$1 mov $7,2 mul $1,$7 mul $0,$1 div $8,8 add $9,3 lpe mov $1,$9 div $1,3 mov $0,$1
oeis/152/A152435.asm
neoneye/loda-programs
11
24771
; A152435: a(n)=(11^n - 1)/(5*2^(3 - 2*Mod[n, 2])). ; Submitted by <NAME> ; 0,1,3,133,366,16105,44289,1948717,5358972,235794769,648435615,28531167061,78460709418,3452271214393,9493745839581,417724816941565,1148743246589304,50544702849929377,138997932837305787 mov $2,11 pow $2,$0 sub $2,1 dif $2,4 mov $0,$2 div $0,10
libsrc/stdio/ansi/ansifont_f4.asm
ahjelm/z88dk
640
26442
<reponame>ahjelm/z88dk SECTION rodata_font_ansi PUBLIC ansifont_f4 ansifont_f4: BINARY "stdio/ansi/F4.BIN"
source/amf/uml/amf-uml-link_end_creation_datas.ads
svn2github/matreshka
24
26343
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- A link end creation data is not an action. It is an element that -- identifies links. It identifies one end of a link to be created by a -- create link action. ------------------------------------------------------------------------------ limited with AMF.UML.Input_Pins; with AMF.UML.Link_End_Datas; package AMF.UML.Link_End_Creation_Datas is pragma Preelaborate; type UML_Link_End_Creation_Data is limited interface and AMF.UML.Link_End_Datas.UML_Link_End_Data; type UML_Link_End_Creation_Data_Access is access all UML_Link_End_Creation_Data'Class; for UML_Link_End_Creation_Data_Access'Storage_Size use 0; not overriding function Get_Insert_At (Self : not null access constant UML_Link_End_Creation_Data) return AMF.UML.Input_Pins.UML_Input_Pin_Access is abstract; -- Getter of LinkEndCreationData::insertAt. -- -- Specifies where the new link should be inserted for ordered association -- ends, or where an existing link should be moved to. The type of the -- input is UnlimitedNatural, but the input cannot be zero. This pin is -- omitted for association ends that are not ordered. not overriding procedure Set_Insert_At (Self : not null access UML_Link_End_Creation_Data; To : AMF.UML.Input_Pins.UML_Input_Pin_Access) is abstract; -- Setter of LinkEndCreationData::insertAt. -- -- Specifies where the new link should be inserted for ordered association -- ends, or where an existing link should be moved to. The type of the -- input is UnlimitedNatural, but the input cannot be zero. This pin is -- omitted for association ends that are not ordered. not overriding function Get_Is_Replace_All (Self : not null access constant UML_Link_End_Creation_Data) return Boolean is abstract; -- Getter of LinkEndCreationData::isReplaceAll. -- -- Specifies whether the existing links emanating from the object on this -- end should be destroyed before creating a new link. not overriding procedure Set_Is_Replace_All (Self : not null access UML_Link_End_Creation_Data; To : Boolean) is abstract; -- Setter of LinkEndCreationData::isReplaceAll. -- -- Specifies whether the existing links emanating from the object on this -- end should be destroyed before creating a new link. end AMF.UML.Link_End_Creation_Datas;
programs/oeis/134/A134591.asm
jmorken/loda
1
161027
; A134591: a(n) is n reflected in n-th prime: distance between a(n) and p(n) equals distance between p(n) and n. ; 3,4,7,10,17,20,27,30,37,48,51,62,69,72,79,90,101,104,115,122,125,136,143,154,169,176,179,186,189,196,223,230,241,244,263,266,277,288,295,306,317,320,339,342,349,352,375,398,405,408,415,426,429,448,459,470 mov $1,$0 mov $4,$0 cal $0,40 ; The prime numbers. sub $0,$1 sub $0,$1 sub $0,2 add $5,$0 add $3,$5 add $5,$3 add $5,4 mov $1,$5 sub $1,1 mov $2,$4 mul $2,3 add $1,$2
programs/oeis/183/A183010.asm
neoneye/loda
22
87532
<reponame>neoneye/loda ; A183010: a(n) = 24*n - 1. ; -1,23,47,71,95,119,143,167,191,215,239,263,287,311,335,359,383,407,431,455,479,503,527,551,575,599,623,647,671,695,719,743,767,791,815,839,863,887,911,935,959,983,1007,1031,1055,1079,1103,1127,1151,1175,1199,1223,1247,1271,1295,1319,1343,1367,1391,1415,1439,1463,1487,1511,1535,1559,1583,1607,1631,1655,1679,1703,1727,1751,1775,1799,1823,1847,1871,1895,1919,1943,1967,1991,2015,2039,2063,2087,2111,2135,2159,2183,2207,2231,2255,2279,2303,2327,2351,2375 sub $0,1 mul $0,24 add $0,23
programs/oeis/158/A158223.asm
neoneye/loda
22
167548
; A158223: a(n) = 196*n + 1. ; 197,393,589,785,981,1177,1373,1569,1765,1961,2157,2353,2549,2745,2941,3137,3333,3529,3725,3921,4117,4313,4509,4705,4901,5097,5293,5489,5685,5881,6077,6273,6469,6665,6861,7057,7253,7449,7645,7841,8037,8233,8429,8625,8821,9017,9213,9409,9605,9801,9997,10193,10389,10585,10781,10977,11173,11369,11565,11761,11957,12153,12349,12545,12741,12937,13133,13329,13525,13721,13917,14113,14309,14505,14701,14897,15093,15289,15485,15681,15877,16073,16269,16465,16661,16857,17053,17249,17445,17641,17837,18033,18229,18425,18621,18817,19013,19209,19405,19601 mul $0,196 add $0,197
oeis/138/A138463.asm
neoneye/loda-programs
11
15337
<reponame>neoneye/loda-programs ; A138463: A bisection of A006318. ; Submitted by <NAME> ; 2,22,394,8558,206098,5293446,142078746,3937603038,111818026018,3236724317174,95149655201962 add $0,1 mul $0,2 sub $0,1 seq $0,6318 ; Large Schröder numbers (or large Schroeder numbers, or big Schroeder numbers).
src/LibraBFT/Impl/Types/EpochState.agda
LaudateCorpus1/bft-consensus-agda
0
6864
<filename>src/LibraBFT/Impl/Types/EpochState.agda {- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types open import LibraBFT.Impl.OBM.Logging.Logging import LibraBFT.Impl.Types.LedgerInfoWithSignatures as LIWS open import LibraBFT.ImplShared.Consensus.Types open import Optics.All open import Util.Prelude module LibraBFT.Impl.Types.EpochState where verify : EpochState → LedgerInfoWithSignatures → Either ErrLog Unit verify self ledgerInfo = do lcheck (self ^∙ esEpoch == ledgerInfo ^∙ liwsLedgerInfo ∙ liEpoch) ( "EpochState" ∷ "LedgerInfo has unexpected epoch" ∷ []) --, show (self^.esEpoch), show (ledgerInfo^.liwsLedgerInfo.liEpoch) ] LIWS.verifySignatures ledgerInfo (self ^∙ esVerifier) epochChangeVerificationRequired : EpochState → Epoch → Bool epochChangeVerificationRequired self epoch = ⌊ self ^∙ esEpoch <? epoch ⌋ isLedgerInfoStale : EpochState → LedgerInfo → Bool isLedgerInfoStale self ledgerInfo = ⌊ ledgerInfo ^∙ liEpoch <? self ^∙ esEpoch ⌋
Bootloader/Stage2/GDT.asm
Archlisk/fos2
0
88272
[BITS 16] SECTION .text gdt: dq 0x00 .code: dw 0xFFFF dw 0x00 db 0x00 db 0b10011010 db 0b11001111 db 0x00 .data: dw 0xFFFF dw 0x00 db 0x00 db 0b10010010 db 0b11001111 db 0x00 .end: .desc: dw .end - gdt dd gdt GDT_CODE_SEG equ .code - gdt GDT_DATA_SEG equ .data - gdt gdt_load_tmp: lgdt [gdt.desc] ret
oeis/142/A142604.asm
neoneye/loda-programs
11
164737
<reponame>neoneye/loda-programs ; A142604: Primes congruent to 4 mod 55. ; Submitted by <NAME> ; 59,389,499,719,829,1049,1489,1709,2039,2699,3359,3469,4019,4129,4349,4679,4789,5009,5119,5449,5669,5779,6329,6659,7649,7759,8089,8419,8969,9629,9739,10069,10289,10399,10729,10949,11059,11279,11719,11939,12049,12269,12379,13259,14029,14249,15349,15569,15679,16229,16339,16889,17659,17989,18539,18869,18979,19309,20849,20959,21179,21839,22279,23159,23269,23599,23819,23929,24809,24919,25469,25579,25799,26459,27449,27779,28109,28219,28439,28549,28879,29209,29429,29759,30089,30529,30859,31079,31189 mov $1,15 mov $2,$0 add $2,2 pow $2,2 lpb $2 add $1,14 sub $2,2 mov $3,$1 mul $3,2 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,41 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe mov $0,$1 mul $0,2 sub $0,81
src/commands.adb
bracke/websitegenerator
1
6659
with Commands.Generate; with Commands.Create; with Commands.Init; with Commands.Destroy; with Commands.Publish; with Commands.Import; with Commands.Deploy; with Commands.Announce; with CLIC.User_Input; with Commands.Topics.Issues; with Commands.Topics.Contribute; package body Commands is ------------------------- -- Set_Global_Switches -- ------------------------- procedure Set_Global_Switches (Config : in out CLIC.Subcommand.Switches_Configuration) is use CLIC.Subcommand; Help_Switch : aliased Boolean := False; -- Catches the -h/--help help switch begin Define_Switch (Config, Help_Switch'Access, "-h", "--help", "Display general or command-specific help"); end Set_Global_Switches; ------------- -- Execute -- ------------- procedure Execute is begin Sub_Cmd.Parse_Global_Switches; CLIC.TTY.Enable_Color (Force => False); begin Sub_Cmd.Execute; exception when Child_Failed | Command_Failed | Wrong_Command_Arguments => GNAT.OS_Lib.OS_Exit (1); when CLIC.User_Input.User_Interrupt => GNAT.OS_Lib.OS_Exit (1); end; end Execute; begin -- Commands -- Sub_Cmd.Register ("General", new Sub_Cmd.Builtin_Help); Sub_Cmd.Register ("General", new Create.Instance); Sub_Cmd.Register ("General", new Init.Instance); Sub_Cmd.Register ("General", new Generate.Instance); Sub_Cmd.Register ("General", new Destroy.Instance); Sub_Cmd.Register ("General", new Publish.Instance); Sub_Cmd.Register ("General", new Import.Instance); Sub_Cmd.Register ("General", new Deploy.Instance); Sub_Cmd.Register ("General", new Announce.Instance); -- Help topics -- Sub_Cmd.Register (new Topics.Issues.Topic); Sub_Cmd.Register (new Topics.Contribute.Topic); end Commands;
game/data/rom_constants_static.asm
sgadrat/super-tilt-bro
91
179977
;TODO re-check that none of these constants are used directly velocity_table(DEFAULT_GRAVITY, default_gravity_per_system_msb, default_gravity_per_system_lsb)
src/Util/Prelude.agda
JLimperg/msc-thesis-code
5
8859
{-# OPTIONS --without-K --safe #-} module Util.Prelude where open import Data.Bool public using (Bool ; true ; false) open import Data.Empty public using (⊥ ; ⊥-elim) open import Data.Fin public using (Fin ; zero ; suc) open import Data.List public using (List ; [] ; _∷_) open import Data.Maybe public using (Maybe ; just ; nothing) open import Data.Nat public using (ℕ ; zero ; suc) open import Data.Product public using (Σ ; ∃ ; Σ-syntax ; ∃-syntax ; _×_ ; _,_ ; proj₁ ; proj₂) open import Data.Sum public using (_⊎_ ; inj₁ ; inj₂) open import Data.Unit public using (⊤) open import Data.Vec public using (Vec ; [] ; _∷_) open import Function public using (id ; _∘_ ; _∘′_ ; _$_ ; _on_) open import Level public using (Level ; 0ℓ) renaming (zero to lzero ; suc to lsuc ; _⊔_ to _⊔ℓ_) open import Relation.Nullary public using (¬_ ; Dec ; yes ; no) open import Relation.Binary.PropositionalEquality public using ( _≡_ ; _≢_ ; refl ; sym ; trans ; cong ; cong₂ ; subst ; subst₂ ; module ≡-Reasoning ) infix 1 triangle⟨_⟩⟨_⟩⟨_⟩ triangle⟨_⟩⟨_⟩⟨_⟩ : ∀ {a} {A : Set a} x {y z : A} → y ≡ x → z ≡ x → y ≡ z triangle⟨ x ⟩⟨ y≡x ⟩⟨ z≡x ⟩ = trans y≡x (sym z≡x)
programs/oeis/319/A319701.asm
neoneye/loda
22
104423
; A319701: Filter sequence for sequences that are constant for all odd terms >= 3. ; 1,2,3,4,3,5,3,6,3,7,3,8,3,9,3,10,3,11,3,12,3,13,3,14,3,15,3,16,3,17,3,18,3,19,3,20,3,21,3,22,3,23,3,24,3,25,3,26,3,27,3,28,3,29,3,30,3,31,3,32,3,33,3,34,3,35,3,36,3,37,3,38,3,39,3,40,3,41,3,42,3,43,3,44,3,45,3,46,3,47,3,48,3,49,3,50,3,51,3,52 mov $1,$0 sub $1,1 dif $1,2 lpb $1 sub $1,1 sub $0,$1 mod $1,2 lpe add $0,1
src/model/io/lse-model-io-turtle.adb
Heziode/lsystem-editor
2
2106
------------------------------------------------------------------------------- -- LSE -- L-System Editor -- Author: Heziode -- -- License: -- MIT License -- -- Copyright (c) 2018 <NAME> (Heziode) <<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.Float_Text_IO; with Ada.Numerics; with Ada.Numerics.Elementary_Functions; with Ada.Text_IO; with LSE.Utils.Coordinate_2D; with LSE.Utils.Coordinate_2D_Ptr; with LSE.Utils.Utils; package body LSE.Model.IO.Turtle is function Initialize return Instance is This : Instance; begin return This; end Initialize; procedure Set_Width (This : out Instance; Value : Positive) is begin This.Width := Value; end Set_Width; procedure Set_Height (This : out Instance; Value : Positive) is begin This.Height := Value; end Set_Height; procedure Set_Background_Color (This : out Instance; Value : String) is begin This.Background_Color := To_Unbounded_String (Value); end Set_Background_Color; procedure Set_Foreground_Color (This : out Instance; Value : String) is begin This.Foreground_Color := To_Unbounded_String (Value); end Set_Foreground_Color; procedure Set_Angle (This : out Instance; Value : LSE.Utils.Angle.Angle) is begin This.Angle := Value; end Set_Angle; function Get_Width (This : Instance) return Positive is begin return This.Width; end Get_Width; function Get_Height (This : Instance) return Positive is begin return This.Height; end Get_Height; function Get_Background_Color (This : Instance) return String is begin return To_String (This.Background_Color); end Get_Background_Color; function Get_Foreground_Color (This : Instance) return String is begin return To_String (This.Foreground_Color); end Get_Foreground_Color; function Get_Offset_X (This : Instance) return Float is begin return This.Offset_X; end Get_Offset_X; function Get_Offset_Y (This : Instance) return Float is begin return This.Offset_Y; end Get_Offset_Y; function Get_Max_X (This : Instance) return Float is begin return This.Max_X; end Get_Max_X; function Get_Max_Y (This : Instance) return Float is begin return This.Max_Y; end Get_Max_Y; function Get_Min_X (This : Instance) return Float is begin return This.Min_X; end Get_Min_X; function Get_Min_Y (This : Instance) return Float is begin return This.Min_Y; end Get_Min_Y; procedure Set_Max_X (This : out Instance; Value : Float) is begin This.Max_X := Value; end Set_Max_X; procedure Set_Max_Y (This : out Instance; Value : Float) is begin This.Max_Y := Value; end Set_Max_Y; procedure Set_Min_X (This : out Instance; Value : Float) is begin This.Min_X := Value; end Set_Min_X; procedure Set_Min_Y (This : out Instance; Value : Float) is begin This.Min_Y := Value; end Set_Min_Y; function Get_Margin_Top (This : Instance) return Float is begin return This.Margin_Top; end Get_Margin_Top; function Get_Margin_Right (This : Instance) return Float is begin return This.Margin_Right; end Get_Margin_Right; function Get_Margin_Bottom (This : Instance) return Float is begin return This.Margin_Bottom; end Get_Margin_Bottom; function Get_Margin_Left (This : Instance) return Float is begin return This.Margin_Left; end Get_Margin_Left; function Get_Medium (This : Instance) return LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr.Holder is begin return This.Medium; end Get_Medium; procedure Set_Margin_Top (This : out Instance; Value : Natural) is begin This.Margin_Top := Float (Value); end Set_Margin_Top; procedure Set_Margin_Right (This : out Instance; Value : Natural) is begin This.Margin_Right := Float (Value); end Set_Margin_Right; procedure Set_Margin_Bottom (This : out Instance; Value : Natural) is begin This.Margin_Bottom := Float (Value); end Set_Margin_Bottom; procedure Set_Margin_Left (This : out Instance; Value : Natural) is begin This.Margin_Left := Float (Value); end Set_Margin_Left; procedure Set_Margin (This : out Instance; Value : Natural) is begin This.Margin_Top := Float (Value); This.Margin_Right := Float (Value); This.Margin_Bottom := Float (Value); This.Margin_Left := Float (Value); end Set_Margin; procedure Set_Medium (This : out Instance; Value : LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr.Holder) is begin This.Medium := Value; end Set_Medium; procedure Set_Dry_Run (This : out Instance; Value : Boolean) is begin This.Dry_Run := Value; end Set_Dry_Run; procedure Put (This : Instance) is use Ada.Text_IO; use Ada.Float_Text_IO; begin Put_Line ("Turtle:"); Put_Line (" Width :" & Positive'Image (This.Width)); Put_Line (" Height :" & Positive'Image (This.Height)); Put_Line (" Background_Color : " & To_String (This.Background_Color)); Put_Line (" Foreground_Color : " & To_String (This.Foreground_Color)); Put (" Line_Size : "); Put (Item => This.Line_Size, Aft => 2, Exp => 0); New_Line; Put (" Angle :"); Put (Item => Float (This.Angle), Aft => 2, Exp => 0); New_Line; Put (" Max_X :"); Put (Item => This.Max_X, Aft => 2, Exp => 0); New_Line; Put (" Max_Y :"); Put (Item => This.Max_Y, Aft => 2, Exp => 0); New_Line; Put (" Min_X :"); Put (Item => This.Min_X, Aft => 2, Exp => 0); New_Line; Put (" Min_Y :"); Put (Item => This.Min_Y, Aft => 2, Exp => 0); New_Line; Put (" Ratio :"); Put (Item => This.Ratio, Aft => 2, Exp => 0); New_Line; Put (" Offset_X :"); Put (Item => This.Offset_X, Aft => 2, Exp => 0); New_Line; Put (" Offset_Y :"); Put (Item => This.Offset_Y, Aft => 2, Exp => 0); New_Line; Put (" Margin_Top :"); Put (Item => This.Margin_Top, Aft => 2, Exp => 0); New_Line; Put (" Margin_Right :"); Put (Item => This.Margin_Right, Aft => 2, Exp => 0); New_Line; Put (" Margin_Bottom :"); Put (Item => This.Margin_Bottom, Aft => 2, Exp => 0); New_Line; Put (" Margin_Left :"); Put (Item => This.Margin_Left, Aft => 2, Exp => 0); New_Line; end Put; procedure Make_Offset (This : in out Instance) is Boxed_Width : constant Float := Float (This.Width) - This.Margin_Right - This.Margin_Left; Boxed_Height : constant Float := Float (This.Height) - This.Margin_Top - This.Margin_Bottom; begin if (This.Max_X - This.Min_X) = 0.0 or (This.Max_Y - This.Min_Y) = 0.0 then raise Divide_By_Zero; end if; if Boxed_Width / (This.Max_X - This.Min_X) <= Boxed_Height / (This.Max_Y - This.Min_Y) then -- X has the smallest delta This.Ratio := Boxed_Width / (This.Max_X - This.Min_X); else -- Y has the smallest delta This.Ratio := Boxed_Height / (This.Max_Y - This.Min_Y); end if; This.Offset_X := (Boxed_Width / 2.0) - (((This.Ratio * This.Max_X - This.Ratio * This.Min_X) / 2.0) + This.Ratio * This.Min_X); This.Offset_Y := (Boxed_Height / 2.0) - (((This.Ratio * This.Max_Y - This.Ratio * This.Min_Y) / 2.0) + This.Ratio * This.Min_Y); end Make_Offset; procedure Configure (This : in out Instance) is use Ada.Strings; begin if not This.Dry_Run then This.Make_Offset; end if; This.Stack_Angle.Clear; This.Stack_Coordinate.Clear; if This.Dry_Run then This.Max_X := 0.0; This.Max_Y := 0.0; This.Min_X := 0.0; This.Min_Y := 0.0; else -- Configure the medium This.Medium.Reference.Configure (This); end if; This.Stack_Angle.Append (LSE.Utils.Angle.To_Angle (90.0)); This.Stack_Coordinate.Append ( LSE.Utils.Coordinate_2D_Ptr.To_Holder ( LSE.Utils.Coordinate_2D.Initialize)); end Configure; procedure Draw (This : in out Instance) is begin if not This.Dry_Run then This.Medium.Reference.Draw; end if; end Draw; procedure Forward (This : in out Instance; Trace : Boolean := False) is use Ada.Float_Text_IO; use Ada.Numerics.Elementary_Functions; ------------------------ -- Methods prototype -- ------------------------ -- Callback of Update_Element of Stack_Coordinate procedure Update (Item : in out LSE.Utils.Coordinate_2D_Ptr.Holder); -- Update all corners of the L-System edges procedure Update_Corners (This : in out Instance); ----------------------------- -- Declaration of methods -- ----------------------------- procedure Update (Item : in out LSE.Utils.Coordinate_2D_Ptr.Holder) is Copy : LSE.Utils.Coordinate_2D_Ptr.Holder := Item; X : constant Float := This.Ratio * This.Line_Size * Cos (This.Stack_Angle.Last_Element, Degrees_Cycle); Y : constant Float := This.Ratio * This.Line_Size * Sin (This.Stack_Angle.Last_Element, Degrees_Cycle); begin Copy.Reference.Set_X (X); Copy.Reference.Set_Y (Y); Item.Move (Copy); end Update; procedure Update_Corners (This : in out Instance) is X, Y : Float := 0.0; begin for H of reverse This.Stack_Coordinate loop X := X + H.Reference.Get_X; Y := Y + H.Reference.Get_Y; end loop; if X < This.Min_X then This.Min_X := X; elsif X > This.Max_X then This.Max_X := X; end if; if Y < This.Min_Y then This.Min_Y := Y; elsif Y > This.Max_Y then This.Max_Y := Y; end if; end Update_Corners; --------------- -- Variables -- --------------- Copy : LSE.Utils.Coordinate_2D_Ptr.Holder := This.Stack_Coordinate.Last_Element.Copy; begin This.Stack_Coordinate.Update_Element (Index => This.Stack_Coordinate.Last_Index, Process => Update'Access); if not This.Dry_Run then This.Medium.Reference.Forward (This.Stack_Coordinate.Last_Element.Element, Trace); end if; Copy.Reference.Set_X (This.Stack_Coordinate.Last_Element.Element.Get_X + Copy.Reference.Get_X); Copy.Reference.Set_Y (This.Stack_Coordinate.Last_Element.Element.Get_Y + Copy.Reference.Get_Y); This.Stack_Coordinate.Delete_Last; This.Stack_Coordinate.Append (Copy); if This.Dry_Run then Update_Corners (This); end if; end Forward; procedure Rotate_Clockwise (This : in out Instance) is begin This.Stack_Angle.Replace_Element (This.Stack_Angle.Last, To_Angle (This.Stack_Angle.Last_Element - This.Angle)); if not This.Dry_Run then This.Medium.Reference.Rotate_Clockwise; end if; end Rotate_Clockwise; procedure Rotate_Anticlockwise (This : in out Instance) is begin This.Stack_Angle.Replace_Element (This.Stack_Angle.Last, To_Angle (This.Stack_Angle.Last_Element + This.Angle)); if not This.Dry_Run then This.Medium.Reference.Rotate_Anticlockwise; end if; end Rotate_Anticlockwise; procedure UTurn (This : in out Instance) is begin This.Stack_Angle.Replace_Element (This.Stack_Angle.Last, To_Angle (This.Stack_Angle.Last_Element + 180.0)); if not This.Dry_Run then This.Medium.Reference.UTurn; end if; end UTurn; procedure Position_Save (This : in out Instance) is begin This.Stack_Coordinate.Append (LSE.Utils.Coordinate_2D_Ptr.To_Holder ( LSE.Utils.Coordinate_2D.Initialize)); This.Stack_Angle.Append (LSE.Utils.Angle.To_Angle ( This.Stack_Angle.Last_Element)); if not This.Dry_Run then This.Medium.Reference.Position_Save; end if; end Position_Save; procedure Position_Restore (This : in out Instance) is use LSE.Utils.Utils; Item : LSE.Utils.Coordinate_2D_Ptr.Holder; X : Fixed_Point; Y : Fixed_Point; begin Item := This.Stack_Coordinate.Last_Element; X := -Fixed_Point (Item.Element.Get_X); Y := -Fixed_Point (Item.Element.Get_Y); This.Stack_Angle.Delete_Last; This.Stack_Coordinate.Delete_Last; if not This.Dry_Run then This.Medium.Reference.Position_Restore (X, Y); end if; end Position_Restore; end LSE.Model.IO.Turtle;
Chapter 06/ReturningValue/ReturningValue/ReturningValue.asm
bpbpublications/Implementing-Reverse-Engineering
0
162296
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.30319.01 TITLE C:\JitenderN\REBook\ReturningValue\ReturningValue\ReturningValue.cpp .686P .XMM include listing.inc .model flat INCLUDELIB LIBCMT INCLUDELIB OLDNAMES PUBLIC _main ; Function compile flags: /Odtp _TEXT SEGMENT _main PROC ; File c:\jitendern\rebook\returningvalue\returningvalue\returningvalue.cpp ; Line 9 push ebp mov ebp, esp ; Line 10 xor eax, eax ; Line 11 pop ebp ret 0 _main ENDP _TEXT ENDS PUBLIC ?ReturningValue@@YAHXZ ; ReturningValue ; Function compile flags: /Odtp _TEXT SEGMENT ?ReturningValue@@YAHXZ PROC ; ReturningValue ; Line 14 push ebp mov ebp, esp ; Line 15 mov eax, 2020 ; 000007e4H ; Line 16 pop ebp ret 0 ?ReturningValue@@YAHXZ ENDP ; ReturningValue _TEXT ENDS END
loops&IO/helloworld.asm
ihasdapie/AssemblyLearning
1
87240
section .data helloworld db "<NAME>", 10 section .text global _start _start: mov rax, 1 mov rdi, 1 mov rsi, helloworld mov rdx, 14 syscall mov rax, 60 mov rdi, 0 syscall
tests/startup_linux_x64.asm
adrianlizarraga/nibble
3
29563
<filename>tests/startup_linux_x64.asm SECTION .text global _start _start: xor rbp, rbp mov edi, dword [rsp] lea rsi, [rsp + 8] lea rdx, [rsp + 8*rdi + 16] xor eax, eax call main mov edi, eax mov rax, 60 syscall global _nibble_#writeout _nibble_#writeout: push rbp mov rbp, rsp xchg rdi, rsi mov rax, 1 mov rdx, rdi mov rdi, 1 syscall mov rsp, rbp pop rbp ret global _nibble_#readin _nibble_#readin: push rbp mov rbp, rsp xchg rdi, rsi mov rax, 0 mov rdx, rdi mov rdi, 0 syscall mov rsp, rbp pop rbp ret
Transynther/x86/_processed/AVXALIGN/_ht_zr_/i9-9900K_12_0xca_notsx.log_21829_2008.asm
ljhsiun2/medusa
9
1189
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r14 push %r8 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x619, %r14 nop nop nop and %rdi, %rdi movw $0x6162, (%r14) nop nop nop nop nop add $17847, %rbp lea addresses_WT_ht+0x1c8d9, %r11 nop nop nop nop add $30419, %rdi mov $0x6162636465666768, %r8 movq %r8, %xmm6 movups %xmm6, (%r11) nop nop nop nop nop add $40926, %r11 lea addresses_normal_ht+0xca39, %rbp nop nop sub $18933, %rdx movb (%rbp), %r11b add %r10, %r10 lea addresses_A_ht+0xd5d9, %rsi lea addresses_A_ht+0x3769, %rdi nop add $34702, %rbp mov $68, %rcx rep movsq dec %r14 lea addresses_A_ht+0x8ec5, %r14 clflush (%r14) nop dec %rdi movb (%r14), %dl nop nop nop nop add %r8, %r8 lea addresses_WT_ht+0x3cd9, %r14 nop nop nop nop nop sub $15950, %rbp movb (%r14), %r11b nop nop nop nop nop sub %r14, %r14 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r8 pop %r14 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %rax push %rbp push %rbx push %rdi push %rsi // Load lea addresses_UC+0x12819, %rsi nop nop nop cmp %rdi, %rdi movups (%rsi), %xmm0 vpextrq $1, %xmm0, %rbx nop nop xor $8695, %rbp // Store lea addresses_D+0x130f9, %rbp nop nop cmp $520, %r12 movw $0x5152, (%rbp) nop sub $49064, %rbx // Faulty Load lea addresses_RW+0x90d9, %rbx nop nop and $28241, %r12 vmovntdqa (%rbx), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $0, %xmm5, %rsi lea oracles, %rdi and $0xff, %rsi shlq $12, %rsi mov (%rdi,%rsi,1), %rsi pop %rsi pop %rdi pop %rbx pop %rbp pop %rax pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_RW', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 11}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 10}} {'00': 2, '45': 21827} 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 */
LPS/Esercizi/09.05.2022_classe/mips1.asm
Giacomix02/esercitazioni-java
3
176173
#long 32 bit .eqv var_v, 0x10011000 .eqv var_w, 0x10011004 #short signed - unsigned .eqv var_x, 0x10011008 .eqv var_y, 0x1001100a .eqv var_z, 0x1001100c .eqv var_h, 0x1001100e .eqv var_k, 0x10011010 .eqv var_m, 0x10011012 #signed char .eqv var_a, 0x10011014 .eqv var_b, 0x10011015 .eqv var_c, 0x10011016 .text inizio_codice: li $t0, 'A' sb $t0, var_b #store byte li &t0, -43 sb $t0, var_c li $t0, 450 sh $t0, var_x li $t0, 98 sh $t0, var_z li $t0, 22020 sw $t0, var_w li $t0, 600 sh $t0, var_k li $t0, 12 sh $t0, var_m lb $t0, var_b lb $t1, var_c add $t0, $t0, $t1 sb $t0, var_a lhu $t0, var_x lhu $t1, var_z multu $t0,$t1 mflo $t0 addu $t0,$t0,2300 sh $t0,var_y lb $t0, var_a lh $t1, var_k mult $t0,$t1 mflo $t1 lh $t0, var_m add $t0,$t0,$t1 sh $t0, var_h lw $t1, var_w sub $t1, $t1, 160900 sub $t1, $t1, $t0 sw $t1, var_v li $t0, 780 sh $t0, var_h li $t1, -24078 lh $t2, var_m div $t1, $t2 mfhi $t1 sll $t0, $t0, 2 add $t1,$t1,$t0 sh $t1,var_k fine_codice:
models/amalgam/misc/my2.als
transclosure/Amalgam
4
1902
<filename>models/amalgam/misc/my2.als abstract sig Player {} one sig X extends Player {} one sig O extends Player {} sig Index {} sig Board { turn: Player, places: Index -> Index -> Player } pred moveBuggy[b: Board, r: Index, c: Index, b': Board] { no b.places[r][c] b'.turn != b.turn b'.places = b.places ++ (r->c->b.turn) } run moveBuggy for 3 but 2 Board, exactly 3 Index
asm/branch.asm
liuyic00/leros
0
243937
// Test code // first instruction is not executed nop // second instruction is executed twice // conditional branch has one cycle delay // for the condition // // test of branch conditions - should never loop // start: load 1 load 0 load 0 load 7 // branch condition load 0 brnz brnzok branch start brnzok: load 127 load 0 load 127 brz brzok branch start brzok: load 0 load -1 load 0 brn brnok branch start brnok: load -1 load 5 load -1 brp brpok branch start brpok: nop branch brok branch start brok: nop out 0
src/bf_interpreter.asm
RysteQ/SBOS
0
167556
<reponame>RysteQ/SBOS bf_interpreter: pusha mov ax, word BF_MEMORY_SIZE xor cx, cx mov di, bf_memory bf_interpreter_clear_memory: dec ax mov [di], byte 0 cmp ax, byte 0 jne bf_interpreter_clear_memory jmp bf_interpreter_run bf_interpreter_run: cmp [si], byte NULL_TERMINATOR je bf_interpreter_exit mov al, byte [si] inc si inc cx cmp al, byte BF_INCREMENT je bf_increment_memory_cell cmp al, byte BF_DECREMENT je bf_decrement_memory_cell cmp al, byte BF_PRINT je bf_print_memory_cell cmp al, byte BF_READ je bf_read_to_memory_cell cmp al, byte BF_NEXT je bf_next_memory_cell cmp al, byte BF_PREVIOUS je bf_previous_memory_cell cmp al, byte BF_OPENING_BRACKET je bf_opening_bracket cmp al, byte BF_CLOSING_BRACKET je bf_closing_bracket cmp al, byte NULL_TERMINATOR jmp bf_interpreter_exit bf_increment_memory_cell: inc byte [di] jmp bf_interpreter_run bf_decrement_memory_cell: dec byte [di] jmp bf_interpreter_run bf_print_memory_cell: mov ah, byte 0x0e mov al, byte [di] int 0x10 jmp bf_interpreter_run bf_read_to_memory_cell: mov ah, byte 0x00 int 0x16 mov [di], byte al jmp bf_interpreter_run bf_next_memory_cell: inc di jmp bf_interpreter_run bf_previous_memory_cell: dec di jmp bf_interpreter_run bf_opening_bracket: cmp [di], byte 0 jne bf_interpreter_run bf_opening_bracket_find_closing_bracket: cmp [si], byte BF_CLOSING_BRACKET je found_closing_bracket cmp cx, word BF_MEMORY_SIZE je bf_interpreter_exit inc cx inc si jmp bf_opening_bracket_find_closing_bracket found_closing_bracket: inc si jmp bf_interpreter_run bf_closing_bracket: cmp [di], byte 0 je bf_interpreter_run dec si bf_closing_bracket_find_opening_bracket: cmp [si], byte BF_OPENING_BRACKET je bf_interpreter_run cmp cx, word 0 je bf_interpreter_exit dec cx dec si jmp bf_closing_bracket_find_opening_bracket bf_interpreter_exit: popa ret bf_memory: times 1024 db 0 BF_MEMORY_SIZE equ 1024 BF_INCREMENT equ '+' BF_DECREMENT equ '-' BF_PRINT equ '.' BF_READ equ ',' BF_NEXT equ '>' BF_PREVIOUS equ '<' BF_OPENING_BRACKET equ '[' BF_CLOSING_BRACKET equ ']'
oeis/172/A172064.asm
neoneye/loda-programs
11
8492
; A172064: Expansion of (2/(3*sqrt(1-4*z)-1+4*z))*((1-sqrt(1-4*z))/(2*z))^k with k=7. ; Submitted by <NAME>(s3) ; 1,8,46,230,1068,4744,20476,86662,361711,1494384,6126818,24972326,101320712,409609664,1651162688,6640469816,26655382802,106830738224,427612715516,1709790470780,6830461107736,27266848437608,108780114077196,433747232736082,1728750936793339,6887580963472480,27432470651626762,109231650190313094,434846178085885904,1730780352189974784,6887802646494242624,27407113071013595344,109043447625698560878,433808465138564236080,1725702660201265200324,6864513526609795772148,27304543804449350491336 mov $3,$0 mov $5,$0 add $5,1 lpb $5 mov $0,$3 sub $5,1 sub $0,$5 mov $2,7 add $2,$3 add $0,$2 bin $0,$2 mul $4,-1 add $4,$0 lpe mov $0,$4
theorems/homotopy/Freudenthal.agda
timjb/HoTT-Agda
0
4202
{-# OPTIONS --without-K --rewriting #-} open import HoTT import homotopy.WedgeExtension as WedgeExt import homotopy.SuspAdjointLoop as SAL module homotopy.Freudenthal where {- lemma (move this where?) -} private move1-left-on-left : ∀ {i} {A : Type i} {x y : A} (p : x == y) (q : x == y) → ((! q) ∙ p == idp → p == q) move1-left-on-left p idp h = h module FreudenthalEquiv {i} (n k : ℕ₋₂) (kle : k ≤T S n +2+ S n) (X : Ptd i) {{cX : is-connected (S (S n)) (de⊙ X)}} where Q : Susp (de⊙ X) → Type i Q x = Trunc k (north == x) ⊙up : X ⊙→ ⊙Ω (⊙Susp X) ⊙up = SAL.η _ up = fst ⊙up Codes-mer-args : WedgeExt.args {a₀ = pt X} {b₀ = [_] {n = k} (pt X)} Codes-mer-args = record {n = S n; m = S n; P = λ _ _ → (Trunc k (de⊙ X) , raise-level-≤T kle Trunc-level); f = [_]; g = idf _; p = idp} Codes-mer : de⊙ X → Trunc k (de⊙ X) → Trunc k (de⊙ X) Codes-mer = WedgeExt.ext Codes-mer-args Codes-mer-β-l : (λ a → Codes-mer a [ pt X ]) == [_] Codes-mer-β-l = λ= $ WedgeExt.β-l {r = Codes-mer-args} Codes-mer-β-r : (λ b → Codes-mer (pt X) b) == idf _ Codes-mer-β-r = λ= $ WedgeExt.β-r {r = Codes-mer-args} Codes-mer-coh : app= Codes-mer-β-l (pt X) == app= Codes-mer-β-r [ pt X ] Codes-mer-coh = app= Codes-mer-β-l (pt X) =⟨ app=-β (WedgeExt.β-l {r = Codes-mer-args}) (pt X) ⟩ WedgeExt.β-l {r = Codes-mer-args} (pt X) =⟨ ! (move1-left-on-left _ _ (WedgeExt.coh {r = Codes-mer-args})) ⟩ WedgeExt.β-r {r = Codes-mer-args} [ pt X ] =⟨ ! (app=-β (WedgeExt.β-r {r = Codes-mer-args}) [ pt X ]) ⟩ app= Codes-mer-β-r [ pt X ] ∎ Codes-mer-is-equiv : (x : de⊙ X) → is-equiv (Codes-mer x) Codes-mer-is-equiv = conn-extend (pointed-conn-out {n = S n} (de⊙ X) (pt X)) (λ x' → (is-equiv (Codes-mer x') , is-equiv-level)) (λ tt → transport is-equiv (! (Codes-mer-β-r)) (idf-is-equiv _)) Codes-mer-equiv : (x : de⊙ X) → Trunc k (de⊙ X) ≃ Trunc k (de⊙ X) Codes-mer-equiv x = (Codes-mer x , Codes-mer-is-equiv x) Codes-mer-inv-x₀ : <– (Codes-mer-equiv (pt X)) == idf _ Codes-mer-inv-x₀ = ap is-equiv.g (conn-extend-β (pointed-conn-out (de⊙ X) (pt X)) (λ x' → (is-equiv (Codes-mer x') , is-equiv-level)) _ unit) ∙ lemma (! (Codes-mer-β-r)) (snd $ ide _) where lemma : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B} (α : f == g) (e : is-equiv f) → is-equiv.g (transport is-equiv α e) == is-equiv.g e lemma idp e = idp Codes : Susp (de⊙ X) → Type i Codes = SuspRec.f (Trunc k (de⊙ X)) (Trunc k (de⊙ X)) (ua ∘ Codes-mer-equiv) Codes-has-level : (x : Susp (de⊙ X)) → has-level k (Codes x) Codes-has-level = Susp-elim Trunc-level Trunc-level (λ _ → prop-has-all-paths-↓) {- favonia: This equation should be true: [⊙Trunc-fmap ⊙up = (decodeN , decodeN-pt)]. Maybe there is a way to refactor the following code so that pointedness is handled more elegantly. -} decodeN : Codes north → Trunc k (north' (de⊙ X) == north) decodeN = Trunc-fmap up decodeN-pt : decodeN [ pt X ] == [ idp ] decodeN-pt = snd (⊙Trunc-fmap ⊙up) decodeS : Codes south → Q south decodeS = Trunc-fmap merid encode₀ : {x : Susp (de⊙ X)} → north == x → Codes x encode₀ α = transport Codes α [ pt X ] encode : {x : Susp (de⊙ X)} → Trunc k (north == x) → Codes x encode {x} tα = Trunc-rec {{Codes-has-level x}} encode₀ tα abstract encode-decodeN : (c : Codes north) → encode (decodeN c) == c encode-decodeN = Trunc-elim {{λ _ → =-preserves-level Trunc-level}} (λ x → encode (decodeN [ x ]) =⟨ idp ⟩ coe (ap Codes (merid x ∙ ! (merid (pt X)))) [ pt X ] =⟨ ap-∙ Codes (merid x) (! (merid (pt X))) |in-ctx (λ w → coe w [ pt X ]) ⟩ coe (ap Codes (merid x) ∙ ap Codes (! (merid (pt X)))) [ pt X ] =⟨ coe-∙ (ap Codes (merid x)) (ap Codes (! (merid (pt X)))) [ pt X ] ⟩ coe (ap Codes (! (merid (pt X)))) (coe (ap Codes (merid x)) [ pt X ]) =⟨ SuspRec.merid-β _ _ (ua ∘ Codes-mer-equiv) x |in-ctx (λ w → coe (ap Codes (! (merid (pt X)))) (coe w [ pt X ])) ⟩ coe (ap Codes (! (merid (pt X)))) (coe (ua (Codes-mer-equiv x)) [ pt X ]) =⟨ coe-β (Codes-mer-equiv x) [ pt X ] |in-ctx (λ w → coe (ap Codes (! (merid (pt X)))) w) ⟩ coe (ap Codes (! (merid (pt X)))) (Codes-mer x [ pt X ]) =⟨ app= Codes-mer-β-l x |in-ctx (λ w → coe (ap Codes (! (merid (pt X)))) w) ⟩ coe (ap Codes (! (merid (pt X)))) [ x ] =⟨ coe-ap-! Codes (merid (pt X)) [ x ] ⟩ coe! (ap Codes (merid (pt X))) [ x ] =⟨ SuspRec.merid-β _ _ (ua ∘ Codes-mer-equiv) (pt X) |in-ctx (λ w → coe! w [ x ]) ⟩ coe! (ua (Codes-mer-equiv (pt X))) [ x ] =⟨ coe!-β (Codes-mer-equiv (pt X)) [ x ] ⟩ <– (Codes-mer-equiv (pt X)) [ x ] =⟨ app= Codes-mer-inv-x₀ [ x ] ⟩ [ x ] ∎) decode : {x : Susp (de⊙ X)} → Codes x → Q x decode {x} = Susp-elim {P = λ y → Codes y → Q y} decodeN decodeS (λ x' → ↓-→-from-transp (λ= (STS x'))) x where abstract coh : {s₁ s₂ : Susp (de⊙ X)} (p : s₁ == s₂) → (ap (λ s → s ∙ p) (!-inv-r p)) == ∙-assoc p (! p) p ∙ ap (λ s → p ∙ s) (!-inv-l p) ∙ ∙-unit-r p coh idp = idp P : de⊙ X → de⊙ X → (S (n +2+ (S n))) -Type (lmax i i) P = λ x₁ x₂ → ((transport Q (merid x₁) (Trunc-fmap up [ x₂ ]) == Trunc-fmap merid (transport Codes (merid x₁) [ x₂ ])), =-preserves-level (raise-level-≤T kle Trunc-level)) f : (a : de⊙ X) → fst (P a (pt X)) f a = transport Q (merid a) [ up (pt X) ] =⟨ transport-Trunc (north ==_) (merid a) (up (pt X)) ⟩ [ transport (north ==_) (merid a) (up (pt X)) ] =⟨ ap [_] $ transp-cst=idf {A = Susp (de⊙ X)} (merid a) (up (pt X)) ⟩ [ (merid (pt X) ∙ ! (merid (pt X))) ∙ merid a ] =⟨ ap [_] $ ap (λ s → s ∙ merid a) (!-inv-r (merid (pt X))) ⟩ [ merid a ] =⟨ idp ⟩ Trunc-fmap merid [ a ] =⟨ ap (Trunc-fmap merid) (! (app= Codes-mer-β-l a)) ⟩ Trunc-fmap merid (Codes-mer a [ pt X ]) =⟨ ap (Trunc-fmap merid) (! (coe-β (Codes-mer-equiv a) [ pt X ])) ⟩ Trunc-fmap merid (coe (ua (Codes-mer-equiv a)) [ pt X ]) =⟨ ! (SuspRec.merid-β _ _ (ua ∘ Codes-mer-equiv) a) |in-ctx (λ w → Trunc-fmap merid (coe w [ pt X ])) ⟩ Trunc-fmap merid (transport Codes (merid a) [ pt X ]) ∎ g : (b : de⊙ X) → fst (P (pt X) b) g b = transport Q (merid (pt X)) [ up b ] =⟨ transport-Trunc (north ==_) (merid (pt X)) (up b) ⟩ [ transport (north ==_) (merid (pt X)) (up b) ] =⟨ ap [_] $ transp-cst=idf {A = Susp (de⊙ X)} (merid (pt X)) (up b) ⟩ [ (merid b ∙ ! (merid (pt X))) ∙ merid (pt X) ] =⟨ ap [_] $ ∙-assoc (merid b) (! (merid (pt X))) (merid (pt X)) ∙ ap (λ s → merid b ∙ s) (!-inv-l (merid (pt X))) ∙ ∙-unit-r (merid b) ⟩ [ merid b ] =⟨ idp ⟩ Trunc-fmap merid [ b ] =⟨ ap (Trunc-fmap merid) (! (app= Codes-mer-β-r [ b ])) ⟩ Trunc-fmap merid (Codes-mer (pt X) [ b ]) =⟨ ap (Trunc-fmap merid) (! (coe-β (Codes-mer-equiv (pt X)) [ b ])) ⟩ Trunc-fmap merid (coe (ua (Codes-mer-equiv (pt X))) [ b ]) =⟨ ! (SuspRec.merid-β _ _ (ua ∘ Codes-mer-equiv) (pt X)) |in-ctx (λ w → Trunc-fmap merid (coe w [ b ])) ⟩ Trunc-fmap merid (transport Codes (merid (pt X)) [ b ]) ∎ p : f (pt X) == g (pt X) p = ap2 (λ p₁ p₂ → transport Q (merid (pt X)) [ up (pt X) ] =⟨ transport-Trunc (north ==_) (merid (pt X)) (up (pt X)) ⟩ [ transport (north ==_) (merid (pt X)) (up (pt X)) ] =⟨ ap [_] $ transp-cst=idf {A = Susp (de⊙ X)} (merid (pt X)) (up (pt X)) ⟩ [ (merid (pt X) ∙ ! (merid (pt X))) ∙ merid (pt X) ] =⟨ ap [_] p₁ ⟩ [ merid (pt X) ] =⟨ idp ⟩ Trunc-fmap merid [ pt X ] =⟨ ap (Trunc-fmap merid) (! p₂) ⟩ Trunc-fmap merid (Codes-mer (pt X) [ pt X ]) =⟨ ap (Trunc-fmap merid) (! (coe-β (Codes-mer-equiv (pt X)) [ pt X ])) ⟩ Trunc-fmap merid (coe (ua (Codes-mer-equiv (pt X))) [ pt X ]) =⟨ ! (SuspRec.merid-β _ _ (ua ∘ Codes-mer-equiv) (pt X)) |in-ctx (λ w → Trunc-fmap merid (coe w [ pt X ])) ⟩ Trunc-fmap merid (transport Codes (merid (pt X)) [ pt X ]) ∎) (coh (merid (pt X))) Codes-mer-coh STS-args : WedgeExt.args {a₀ = pt X} {b₀ = pt X} STS-args = record {n = S n; m = S n; P = P; f = f; g = g; p = p} STS : (x' : de⊙ X) (c : Codes north) → transport Q (merid x') (Trunc-fmap up c) == Trunc-fmap merid (transport Codes (merid x') c) STS x' = Trunc-elim {{λ _ → =-preserves-level Trunc-level}} (WedgeExt.ext STS-args x') abstract decode-encode : {x : Susp (de⊙ X)} (tα : Q x) → decode {x} (encode {x} tα) == tα decode-encode {x} = Trunc-elim {P = λ tα → decode {x} (encode {x} tα) == tα} {{λ _ → =-preserves-level Trunc-level}} (J (λ y p → decode {y} (encode {y} [ p ]) == [ p ]) (ap [_] (!-inv-r (merid (pt X))))) eq : Trunc k (de⊙ X) ≃ Trunc k (north' (de⊙ X) == north) eq = equiv decodeN encode decode-encode encode-decodeN ⊙eq : ⊙Trunc k X ⊙≃ ⊙Trunc k (⊙Ω (⊙Susp X)) ⊙eq = ≃-to-⊙≃ eq (ap [_] (!-inv-r (merid (pt X)))) path : Trunc k (de⊙ X) == Trunc k (north' (de⊙ X) == north) path = ua eq ⊙path : ⊙Trunc k X == ⊙Trunc k (⊙Ω (⊙Susp X)) ⊙path = ⊙ua ⊙eq {- Used to prove stability in iterated suspensions -} module FreudenthalIso {i} (n : ℕ₋₂) (k : ℕ) (kle : ⟨ S k ⟩ ≤T S n +2+ S n) (X : Ptd i) {{_ : is-connected (S (S n)) (de⊙ X)}} where open FreudenthalEquiv n ⟨ S k ⟩ kle X public hom : Ω^S-group k (⊙Trunc ⟨ S k ⟩ X) →ᴳ Ω^S-group k (⊙Trunc ⟨ S k ⟩ (⊙Ω (⊙Susp X))) hom = Ω^S-group-fmap k (decodeN , decodeN-pt) iso : Ω^S-group k (⊙Trunc ⟨ S k ⟩ X) ≃ᴳ Ω^S-group k (⊙Trunc ⟨ S k ⟩ (⊙Ω (⊙Susp X))) iso = Ω^S-group-emap k ⊙eq
programs/oeis/062/A062708.asm
neoneye/loda
22
160099
<reponame>neoneye/loda<filename>programs/oeis/062/A062708.asm ; A062708: Write 0,1,2,3,4,... in a triangular spiral; then a(n) is the sequence found by reading the terms along the line from 0 in the direction 0,2,... ; 0,2,13,33,62,100,147,203,268,342,425,517,618,728,847,975,1112,1258,1413,1577,1750,1932,2123,2323,2532,2750,2977,3213,3458,3712,3975,4247,4528,4818,5117,5425,5742,6068,6403,6747,7100,7462,7833,8213,8602,9000,9407,9823,10248,10682,11125,11577,12038,12508,12987,13475,13972,14478,14993,15517,16050,16592,17143,17703,18272,18850,19437,20033,20638,21252,21875,22507,23148,23798,24457,25125,25802,26488,27183,27887,28600,29322,30053,30793,31542,32300,33067,33843,34628,35422,36225,37037,37858,38688,39527,40375,41232,42098,42973,43857 sub $1,$0 mul $0,3 bin $0,2 add $1,$0 mov $0,$1
src/power.asm
IGJoshua/assembly-sandbox
1
92618
;;; power.asm ;;; Taken from the nasm tutorial https://cs.lmu.edu/~ray/notes/nasmtutorial/ ; ----------------------------------------------------------------------------- ; A 64-bit command line application to compute x^y. ; ; Syntax: power x y ; x and y are (32-bit) integers ; ----------------------------------------------------------------------------- global main extern printf extern puts extern atoi section .text main: push r12 ; save callee-save registers push r13 push r14 ;; by pushing three registers our stack is already aligned cmp rdi, 3 ; must have exactly two arguments jne error1 mov r12, rsi ; argv ;; We will use ecx to count down form the exponent to zero, esi to hold the ;; value of the base, and eax to hold the running product. mov rdi, [r12+16] ; argv[2] call [rel atoi wrt ..got] ; y in eax cmp eax, 0 ; disallow negative exponents jl error2 mov r13d, eax ; y in r13d mov rdi, [r12+8] ; argv call [rel atoi wrt ..got] ; x in eax mov r14d, eax ; x in r14d mov eax, 1 ; start with answer = 1 check: test r13d, r13d ; we're counting y downto 0 jz gotit ; done imul eax, r14d ; multiply in another x dec r13d jmp check gotit: ; print report on success lea rdi, [rel answer] movsxd rsi, eax mov rax, 0 call [rel printf wrt ..got] jmp done error1: ; print error message lea rdi, [rel badArgumentCount] call [rel puts wrt ..got] jmp done error2: ; print error message lea rdi, [rel negativeExponent] call [rel puts wrt ..got] done: ; restore saved registers pop r14 pop r13 pop r12 ret answer: db "%d", 10, 0 badArgumentCount: db "Requires exactly two arguments", 10, 0 negativeExponent: db "The exponent may not be negative", 10, 0
.emacs.d/elpa/wisi-2.2.1/wisitoken-parse-lr-mckenzie_recover-explore.adb
caqg/linux-home
0
7686
-- Abstract : -- -- See spec. -- -- Copyright (C) 2018 - 2019 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (Modified_GPL); with Ada.Exceptions; with SAL.Gen_Bounded_Definite_Queues; with WisiToken.Parse.LR.McKenzie_Recover.Parse; with WisiToken.Parse.LR.Parser; package body WisiToken.Parse.LR.McKenzie_Recover.Explore is procedure Do_Shift (Label : in String; Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in out Configuration; State : in State_Index; ID : in Token_ID; Cost_Delta : in Integer; Strategy : in Strategies) is use Config_Op_Arrays; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; Op : constant Config_Op := (Insert, ID, Config.Current_Shared_Token, State, Config.Stack.Depth); begin Config.Strategy_Counts (Strategy) := Config.Strategy_Counts (Strategy) + 1; if Is_Full (Config.Ops) then Super.Config_Full ("do_shift ops", Parser_Index); raise Bad_Config; else Append (Config.Ops, Op); end if; if Cost_Delta = 0 then Config.Cost := Config.Cost + McKenzie_Param.Insert (ID); else -- Cost_Delta /= 0 comes from Insert_Minimal_Complete_Actions. That -- doesn't mean it is better than any other solution, so don't let -- cost be 0. -- -- We don't just eliminate all cost for Minimal_Complete_Actions; -- that leads to using it far too much at the expense of better -- solutions. Config.Cost := Integer'Max (1, Config.Cost + McKenzie_Param.Insert (ID) + Cost_Delta); end if; Config.Error_Token.ID := Invalid_Token_ID; Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); if Config.Stack.Is_Full then Super.Config_Full ("do_shift stack", Parser_Index); raise Bad_Config; else Config.Stack.Push ((State, Syntax_Trees.Invalid_Node_Index, (ID, Virtual => True, others => <>))); end if; if Trace_McKenzie > Detail then Base.Put ((if Label'Length > 0 then Label & ": " else "") & "insert " & Image (ID, Super.Trace.Descriptor.all), Super, Shared, Parser_Index, Config); end if; Local_Config_Heap.Add (Config); end Do_Shift; procedure Do_Reduce_1 (Label : in String; Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in out Configuration; Action : in Reduce_Action_Rec; Do_Language_Fixes : in Boolean := True) is use all type Semantic_Checks.Check_Status_Label; use all type WisiToken.Parse.LR.Parser.Language_Fixes_Access; Prev_State : constant Unknown_State_Index := Config.Stack.Peek.State; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; Table : Parse_Table renames Shared.Table.all; Nonterm : Recover_Token; New_State : Unknown_State_Index; begin Config.Check_Status := Parse.Reduce_Stack (Shared, Config.Stack, Action, Nonterm, Default_Virtual => True); case Config.Check_Status.Label is when Ok => null; when Semantic_Checks.Error => Config.Error_Token := Nonterm; Config.Check_Token_Count := Action.Token_Count; if Do_Language_Fixes then if Shared.Language_Fixes /= null then Shared.Language_Fixes (Super.Trace.all, Shared.Lexer, Super.Label (Parser_Index), Shared.Table.all, Shared.Terminals.all, Super.Parser_State (Parser_Index).Tree, Local_Config_Heap, Config); end if; end if; -- Finish the reduce; ignore the check fail. if Config.Stack.Depth < SAL.Base_Peek_Type (Config.Check_Token_Count) then raise SAL.Programmer_Error; else Config.Stack.Pop (SAL.Base_Peek_Type (Config.Check_Token_Count)); end if; Config.Error_Token.ID := Invalid_Token_ID; Config.Check_Status := (Label => Ok); end case; if Config.Stack.Depth = 0 or else Config.Stack.Peek.State = Unknown_State then raise Bad_Config; end if; New_State := Goto_For (Table, Config.Stack.Peek.State, Action.Production.LHS); if New_State = Unknown_State then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), Label & ": Do_Reduce_1: unknown_State " & Config.Stack.Peek.State'Image & " " & Image (Action.Production.LHS, Descriptor)); end if; raise Bad_Config; end if; Config.Stack.Push ((New_State, Syntax_Trees.Invalid_Node_Index, Nonterm)); if Trace_McKenzie > Extra and Label'Length > 0 then Put_Line (Super.Trace.all, Super.Label (Parser_Index), Label & ": state" & State_Index'Image (Prev_State) & " reduce" & Ada.Containers.Count_Type'Image (Action.Token_Count) & " to " & Image (Action.Production.LHS, Descriptor) & ", goto" & State_Index'Image (New_State) & " via" & State_Index'Image (Config.Stack.Peek (2).State)); end if; end Do_Reduce_1; procedure Do_Reduce_2 (Label : in String; Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in out Configuration; Inserted_ID : in Token_ID; Cost_Delta : in Integer; Strategy : in Strategies) is -- Perform reduce actions until shift Inserted_ID; if all succeed, -- add the final configuration to the heap, return True. If a conflict is -- encountered, process the other action the same way. If a semantic -- check fails, enqueue possible solutions. For parse table error -- actions, or exception Bad_Config, return False. Orig_Config : Configuration; Table : Parse_Table renames Shared.Table.all; Next_Action : Parse_Action_Node_Ptr := Action_For (Table, Config.Stack.Peek.State, Inserted_ID); begin if Next_Action.Next /= null then Orig_Config := Config; end if; case Next_Action.Item.Verb is when Shift => Do_Shift (Label, Super, Shared, Parser_Index, Local_Config_Heap, Config, Next_Action.Item.State, Inserted_ID, Cost_Delta, Strategy); when Reduce => Do_Reduce_1 (Label, Super, Shared, Parser_Index, Local_Config_Heap, Config, Next_Action.Item); Do_Reduce_2 (Label, Super, Shared, Parser_Index, Local_Config_Heap, Config, Inserted_ID, Cost_Delta, Strategy); when Accept_It => raise SAL.Programmer_Error with "found test case for Do_Reduce Accept_It"; when Error => null; end case; loop exit when Next_Action.Next = null; -- There is a conflict; create a new config to shift or reduce. declare New_Config : Configuration := Orig_Config; Action : Parse_Action_Rec renames Next_Action.Next.Item; begin case Action.Verb is when Shift => Do_Shift (Label, Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action.State, Inserted_ID, Cost_Delta, Strategy); when Reduce => Do_Reduce_1 (Label, Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action); Do_Reduce_2 (Label, Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Inserted_ID, Cost_Delta, Strategy); when Accept_It => raise SAL.Programmer_Error with "found test case for Do_Reduce Accept_It conflict"; when Error => null; end case; end; Next_Action := Next_Action.Next; end loop; exception when Bad_Config => if Debug_Mode then raise; end if; end Do_Reduce_2; function Fast_Forward (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Local_Config_Heap : in out Config_Heaps.Heap_Type; Config : in out Configuration) return Non_Success_Status is -- Apply the ops in Config; they were inserted by some fix. -- Return Abandon if Config should be abandoned, otherwise Continue. -- Leaves Config.Error_Token, Config.Check_Status set. -- -- If there are conflicts, all are parsed; if more than one succeed, -- all are enqueued in Local_Config_Heap, and this returns Abandon. use Parse.Parse_Item_Arrays; use Config_Op_Arrays; use all type Ada.Containers.Count_Type; Parse_Items : aliased Parse.Parse_Item_Arrays.Vector; Dummy : Boolean := Parse.Parse (Super, Shared, Parser_Index, Parse_Items, Config, Shared_Token_Goal => Invalid_Token_Index, All_Conflicts => True, Trace_Prefix => "fast_forward"); begin -- This solution is from Language_Fixes; any cost increase is done there. if Length (Parse_Items) = 1 then declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Constant_Ref (Parse_Items, 1); begin if Item.Parsed and Item.Config.Current_Insert_Delete = No_Insert_Delete then -- Item.Config.Error_Token.ID, Check_Status are correct. Config := Item.Config; if Is_Full (Config.Ops) then Super.Config_Full ("fast_forward 1", Parser_Index); return Abandon; else Append (Config.Ops, (Fast_Forward, Config.Current_Shared_Token)); end if; Config.Minimal_Complete_State := None; Config.Matching_Begin_Done := False; return Continue; else return Abandon; end if; end; else for I in First_Index (Parse_Items) .. Last_Index (Parse_Items) loop declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Variable_Ref (Parse_Items, I); begin if Item.Parsed and Item.Config.Current_Insert_Delete = No_Insert_Delete then if Is_Full (Config.Ops) then Super.Config_Full ("fast_forward 2", Parser_Index); return Abandon; else Append (Item.Config.Ops, (Fast_Forward, Item.Config.Current_Shared_Token)); end if; Item.Config.Minimal_Complete_State := None; Item.Config.Matching_Begin_Done := False; Local_Config_Heap.Add (Item.Config); if Trace_McKenzie > Detail then Base.Put ("fast forward enqueue", Super, Shared, Parser_Index, Item.Config); end if; end if; end; end loop; return Abandon; end if; exception when Bad_Config => return Abandon; end Fast_Forward; function Check (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in out Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) return Check_Status is use Config_Op_Arrays, Config_Op_Array_Refs; use Parse.Parse_Item_Arrays; use all type Semantic_Checks.Check_Status_Label; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; Parse_Items : aliased Parse.Parse_Item_Arrays.Vector; Result : Check_Status := Continue; function Max_Push_Back_Token_Index (Ops : aliased in Config_Op_Arrays.Vector) return WisiToken.Base_Token_Index is Result : WisiToken.Base_Token_Index := WisiToken.Base_Token_Index'First; begin -- For Ops since last Fast_Forward, return maximum Token_Index in a -- Push_Back. If there are no such ops, return a value that will be -- less than the current token index. for I in reverse First_Index (Ops) .. Last_Index (Ops) loop declare Op : Config_Op renames Constant_Ref (Ops, I); begin exit when Op.Op = Fast_Forward; if Op.Op = Push_Back and then Op.PB_Token_Index > Result then Result := Op.PB_Token_Index; end if; end; end loop; return Result; end Max_Push_Back_Token_Index; begin if Parse.Parse (Super, Shared, Parser_Index, Parse_Items, Config, Config.Resume_Token_Goal, All_Conflicts => False, Trace_Prefix => "check") then Config.Error_Token.ID := Invalid_Token_ID; -- FIXME: if there were conflicts, enqueue them; they might yield a -- cheaper or same cost solution? return Success; end if; -- Set Config.error to reflect failure, if it is at current token, so -- Use_Minimal_Complete_Actions can see it. declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Constant_Ref (Parse_Items, First_Index (Parse_Items)); begin if Item.Config.Check_Status.Label /= Ok then Config.Check_Status := Item.Config.Check_Status; Config.Error_Token := Item.Config.Error_Token; -- Explore cannot fix a check fail; only Language_Fixes can. The -- "ignore error" case is handled immediately on return from -- Language_Fixes in Process_One, below. Result := Abandon; elsif Item.Config.Error_Token.ID /= Invalid_Token_ID then if Item.Shift_Count = 0 then Config.Error_Token := Item.Config.Error_Token; Config.Check_Status := (Label => Ok); else -- Error is not at current token, but Explore might find something -- that will help (see test_mckenzie_recover.adb Extra_Begin). On the -- other hand, this can lead to lots of bogus configs (see -- If_In_Handler). Config.Error_Token.ID := Invalid_Token_ID; Config.Check_Status := (Label => Ok); end if; end if; end; -- All Parse_Items either failed or were not parsed; if they failed -- and made progress, enqueue them so Language_Fixes can try to fix -- them. for I in First_Index (Parse_Items) .. Last_Index (Parse_Items) loop declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Variable_Ref (Parse_Items, I); begin if Item.Config.Error_Token.ID /= Invalid_Token_ID and then Item.Shift_Count > 0 and then Max_Push_Back_Token_Index (Item.Config.Ops) < Item.Config.Current_Shared_Token - 1 then -- Some progress was made; explore at the new error point. It is -- likely that there is only one actual error point, and this moves -- away from it, so we give it a cost. begin Item.Config.Minimal_Complete_State := None; Item.Config.Matching_Begin_Done := False; if Constant_Ref (Item.Config.Ops, Last_Index (Item.Config.Ops)).Op = Fast_Forward then Item.Config.Cost := Item.Config.Cost + McKenzie_Param.Fast_Forward; Variable_Ref (Item.Config.Ops, Last_Index (Item.Config.Ops)).FF_Token_Index := Item.Config.Current_Shared_Token; else Item.Config.Cost := Item.Config.Cost + McKenzie_Param.Fast_Forward; if Is_Full (Item.Config.Ops) then Super.Config_Full ("check 1", Parser_Index); raise Bad_Config; else Append (Item.Config.Ops, (Fast_Forward, Item.Config.Current_Shared_Token)); end if; end if; end; Local_Config_Heap.Add (Item.Config); if Trace_McKenzie > Detail then Base.Put ("new error point ", Super, Shared, Parser_Index, Item.Config); end if; end if; end; end loop; if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "check result: " & Result'Image); end if; return Result; exception when Bad_Config => return Abandon; end Check; function Check_Reduce_To_Start (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Orig_Config : in Configuration) return Boolean -- Returns True if Config reduces to the start nonterm. is Table : Parse_Table renames Shared.Table.all; function To_Reduce_Action (Item : in Minimal_Action) return Reduce_Action_Rec is begin return (Reduce, (Item.Nonterm, 0), null, null, Item.Token_Count); end To_Reduce_Action; Local_Config_Heap : Config_Heaps.Heap_Type; -- never used, because Do_Language_Fixes is False. Config : Configuration := Orig_Config; Actions : Minimal_Action_Arrays.Vector := Table.States (Config.Stack.Peek.State).Minimal_Complete_Actions; begin loop case Actions.Length is when 0 => if (for some Item of Table.States (Config.Stack.Peek.State).Kernel => Item.LHS = Super.Trace.Descriptor.Accept_ID) then return True; else return False; end if; when 1 => case Actions (Actions.First_Index).Verb is when Shift => return False; when Reduce => Do_Reduce_1 ("", Super, Shared, Parser_Index, Local_Config_Heap, Config, To_Reduce_Action (Actions (Actions.First_Index)), Do_Language_Fixes => False); Actions := Table.States (Config.Stack.Peek.State).Minimal_Complete_Actions; end case; when others => return False; end case; -- loop only exits via returns above end loop; exception when Bad_Config => -- From Do_Reduce_1 return False; end Check_Reduce_To_Start; procedure Try_Push_Back (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is Trace : WisiToken.Trace'Class renames Super.Trace.all; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; Token : constant Recover_Token := Config.Stack.Peek.Token; begin -- Try pushing back the stack top, to allow insert and other -- operations at that point. -- -- Since we are not actually changing the source text, it is tempting -- to give this operation zero cost. But then we keep doing push_back -- forever, making no progress. So we give it a cost. if not Token.Virtual then -- If Virtual, this is from earlier in this recover session; no point -- in trying to redo it. declare use Config_Op_Arrays; New_Config : Configuration := Config; begin New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); New_Config.Stack.Pop; if Is_Full (New_Config.Ops) then Super.Config_Full ("push_back 1", Parser_Index); raise Bad_Config; else if Token.Min_Terminal_Index = Invalid_Token_Index then -- Token is empty; Config.current_shared_token does not change, no -- cost increase. Append (New_Config.Ops, (Push_Back, Token.ID, New_Config.Current_Shared_Token)); else New_Config.Cost := New_Config.Cost + McKenzie_Param.Push_Back (Token.ID); Append (New_Config.Ops, (Push_Back, Token.ID, Token.Min_Terminal_Index)); New_Config.Current_Shared_Token := Token.Min_Terminal_Index; end if; end if; New_Config.Strategy_Counts (Explore_Table) := New_Config.Strategy_Counts (Explore_Table) + 1; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Base.Put ("push_back " & Image (Token.ID, Trace.Descriptor.all), Super, Shared, Parser_Index, New_Config); end if; end; end if; end Try_Push_Back; function Just_Pushed_Back_Or_Deleted (Config : in Configuration; ID : in Token_ID) return Boolean is use Config_Op_Arrays, Config_Op_Array_Refs; use all type Ada.Containers.Count_Type; begin if Length (Config.Ops) = 0 then return False; else declare Last_Op : Config_Op renames Constant_Ref (Config.Ops, Last_Index (Config.Ops)); begin return (Last_Op.Op = Push_Back and then Last_Op.PB_ID = ID) or (Last_Op.Op = Delete and then Last_Op.Del_ID = ID); end; end if; end Just_Pushed_Back_Or_Deleted; procedure Try_Undo_Reduce (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is Trace : WisiToken.Trace'Class renames Super.Trace.all; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; Token : constant Recover_Token := Config.Stack.Peek.Token; begin -- Try expanding the nonterm on the stack top, to allow pushing_back -- its components, or insert and other operations at that point. if Undo_Reduce_Valid (Config.Stack, Super.Parser_State (Parser_Index).Tree) then declare use Config_Op_Arrays; New_Config : Configuration := Config; Token_Count : Ada.Containers.Count_Type; begin New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); Token_Count := Undo_Reduce (New_Config.Stack, Super.Parser_State (Parser_Index).Tree); if Token.Min_Terminal_Index /= Invalid_Token_Index then -- If Token is empty no cost increase. New_Config.Cost := New_Config.Cost + McKenzie_Param.Undo_Reduce (Token.ID); end if; if Is_Full (New_Config.Ops) then Super.Config_Full ("undo_reduce 1", Parser_Index); raise Bad_Config; else Append (New_Config.Ops, (Undo_Reduce, Token.ID, Token_Count)); end if; New_Config.Strategy_Counts (Explore_Table) := New_Config.Strategy_Counts (Explore_Table) + 1; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Base.Put ("undo_reduce " & Image (Token.ID, Trace.Descriptor.all), Super, Shared, Parser_Index, New_Config); end if; end; end if; end Try_Undo_Reduce; procedure Insert_From_Action_List (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Minimal_Insert : in Token_ID_Arrays.Vector; Local_Config_Heap : in out Config_Heaps.Heap_Type) is Table : Parse_Table renames Shared.Table.all; EOF_ID : Token_ID renames Super.Trace.Descriptor.EOI_ID; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; -- Find terminal insertions from the current state's action_list to try. -- -- We perform any needed reductions and one shift, so the config is -- in a consistent state, and enqueue the result. If there are any -- conflicts or semantic check fails encountered, they create other -- configs to enqueue. Current_Token : constant Token_ID := Current_Token_ID_Peek (Shared.Terminals.all, Config.Current_Shared_Token, Config.Insert_Delete, Config.Current_Insert_Delete); Cached_Config : Configuration; Cached_Action : Reduce_Action_Rec; -- Most of the time, all the reductions in a state are the same. So -- we cache the first result. This includes one reduction; if an -- associated semantic check failed, this does not include the fixes. I : Parse_Action_Node_Ptr; begin for Node of Table.States (Config.Stack.Peek.State).Action_List loop I := Node.Actions; loop exit when I = null; declare ID : constant Token_ID := Node.Symbol; Action : Parse_Action_Rec renames I.Item; begin if ID /= EOF_ID and then -- can't insert eof ID /= Invalid_Token_ID -- invalid when Verb = Error then if Just_Pushed_Back_Or_Deleted (Config, ID) then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Insert: abandon " & Image (ID, Descriptor) & ": undo push_back"); end if; elsif ID = Current_Token then -- This needed because we allow explore when the error is not at the -- explore point; it prevents inserting useless tokens (ie -- 'identifier ;' in ada_lite). if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Insert: abandon " & Image (ID, Descriptor) & ": current token"); end if; elsif (for some Minimal of Minimal_Insert => ID = Minimal) then -- Was inserted by Insert_Minimal_Complete_Actions null; else case Action.Verb is when Shift => declare New_Config : Configuration := Config; begin Do_Shift ("Insert", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action.State, ID, Cost_Delta => 0, Strategy => Explore_Table); end; when Reduce => if not Equal (Action, Cached_Action) then declare New_Config : Configuration := Config; begin New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); Do_Reduce_1 ("Insert", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action); Cached_Config := New_Config; Cached_Action := Action; Do_Reduce_2 ("Insert", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, ID, Cost_Delta => 0, Strategy => Explore_Table); end; else declare New_Config : Configuration := Cached_Config; begin Do_Reduce_2 ("Insert", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, ID, Cost_Delta => 0, Strategy => Explore_Table); end; end if; when Accept_It => raise SAL.Programmer_Error with "found test case for Process_One Accept_It"; when Error => null; end case; end if; end if; end; I := I.Next; end loop; end loop; end Insert_From_Action_List; function Insert_Minimal_Complete_Actions (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Orig_Config : in out Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) return Token_ID_Arrays.Vector -- Return tokens inserted (empty if none). is use Ada.Containers; Table : Parse_Table renames Shared.Table.all; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; Inserted : Token_ID_Array (1 .. 10) := (others => Invalid_Token_ID); Inserted_Last : Integer := Inserted'First - 1; type Work_Item is record Action : Minimal_Action; Config : Configuration; end record; package Item_Queues is new SAL.Gen_Bounded_Definite_Queues (Work_Item); use Item_Queues; Work : Queue_Type (10); -- The required queue size depends on the number of multiple-item -- Minimal_Complete_Actions encountered. That is limited by compound -- statement nesting, and by the frequency of such actions. function To_Reduce_Action (Action : in Minimal_Action) return Reduce_Action_Rec is (Reduce, (Action.Nonterm, 0), null, null, Action.Token_Count); procedure Minimal_Do_Shift (Action : in Minimal_Action; Config : in out Configuration) is use Config_Op_Arrays, Config_Op_Array_Refs; begin -- Check for a cycle. We compare stack depth as well as state, so -- nested compound statements don't look like a cycle; see -- test_mckenzie_recover Push_Back_1. We don't check for cycles in -- Insert_From_Action_List because we assume cost eliminates cycles -- there; Minimal_Complete_Delta is usually negative, so cost does -- not necessarily increase here. for I in reverse First_Index (Config.Ops) .. Last_Index (Config.Ops) loop declare Op : Config_Op renames Constant_Ref (Config.Ops, I); begin if Op.Op = Insert and then (Op.Ins_ID = Action.ID and Op.State = Action.State and Op.Stack_Depth = Config.Stack.Depth) then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: abandon " & Image (Action.ID, Descriptor) & Action.State'Image & ": cycle"); end if; return; end if; end; end loop; -- We don't check Action.ID = Current_Token; the error is at the -- explore point, so ID is valid. if Just_Pushed_Back_Or_Deleted (Config, Action.ID) then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: abandon " & Image (Action.ID, Descriptor) & ": undo push back"); end if; else Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); Config.Minimal_Complete_State := Active; Inserted_Last := Inserted_Last + 1; Inserted (Inserted_Last) := Action.ID; Do_Shift ("Minimal_Complete_Actions", Super, Shared, Parser_Index, Local_Config_Heap, Config, Action.State, Action.ID, Table.McKenzie_Param.Minimal_Complete_Cost_Delta, Strategy => Minimal_Complete); end if; end Minimal_Do_Shift; procedure Enqueue_Min_Actions (Label : in String; Actions : in Minimal_Action_Arrays.Vector; Recursive : in Boolean; Config : in Configuration; Reduce_Only : in Boolean) is use SAL; Length : array (Actions.First_Index .. Actions.Last_Index) of Count_Type := (others => Count_Type'Last); Item_Not_Recursive : array (Actions.First_Index .. Actions.Last_Index) of Boolean := (others => False); Not_Recursive_Count : Count_Type := 0; Min_Length : Count_Type := Count_Type'Last; Use_Recursive : Boolean; begin -- Enqueue non-minimal actions on Work, if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: " & Label & Image (Actions, Descriptor) & (if Recursive then " recursive" else "")); end if; if Actions.Length = 0 then return; elsif Actions.Length = 1 then if (not Reduce_Only) or Actions (Actions.First_Index).Verb = Reduce then if Is_Full (Work) then Super.Config_Full ("Minimal_Complete_Actions 1", Parser_Index); raise Bad_Config; else Add (Work, (Actions (Actions.First_Index), Config)); end if; end if; return; end if; for I in Actions.First_Index .. Actions.Last_Index loop declare Action : Minimal_Action renames Actions (I); Next_State : constant State_Index := (case Action.Verb is when Shift => Action.State, when Reduce => Goto_For (Shared.Table.all, Config.Stack.Peek (Base_Peek_Type (Action.Token_Count) + 1).State, Action.Nonterm)); Before_Dot : constant Token_ID := (case Action.Verb is when Shift => Action.ID, when Reduce => Action.Nonterm); Kernel : Kernel_Info_Arrays.Vector renames Shared.Table.States (Next_State).Kernel; begin if (not Reduce_Only) or Action.Verb = Reduce then for Item of Kernel loop Item_Not_Recursive (I) := Item_Not_Recursive (I) or not Item.Recursive; if Item.Before_Dot = Before_Dot and Item.Length_After_Dot < Length (I) then Length (I) := Item.Length_After_Dot; if Length (I) < Min_Length then Min_Length := Length (I); end if; end if; end loop; end if; end; if Item_Not_Recursive (I) then Not_Recursive_Count := Not_Recursive_Count + 1; end if; end loop; Use_Recursive := Recursive and Not_Recursive_Count > 0 and Not_Recursive_Count < Actions.Length; for I in Length'Range loop if (Use_Recursive and Item_Not_Recursive (I)) or ((not Use_Recursive) and Length (I) = Min_Length) then if Is_Full (Work) then Super.Config_Full ("Minimal_Complete_Actions 2", Parser_Index); raise Bad_Config; else Add (Work, (Actions (I), Config)); end if; elsif Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: drop " & Image (Actions (I), Descriptor)); end if; end loop; end Enqueue_Min_Actions; begin if Orig_Config.Stack.Depth = 1 then -- Get here with an empty source file, or a syntax error on the first -- token. return Token_ID_Arrays.Empty_Vector; elsif Orig_Config.Minimal_Complete_State = Done then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: done"); end if; return Token_ID_Arrays.Empty_Vector; end if; Enqueue_Min_Actions ("", Table.States (Orig_Config.Stack.Peek.State).Minimal_Complete_Actions, Table.States (Orig_Config.Stack.Peek.State).Minimal_Complete_Actions_Recursive, Orig_Config, Reduce_Only => False); loop exit when Is_Empty (Work); declare Item : Work_Item := Get (Work); begin if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: dequeue work item " & Image (Item.Action, Descriptor)); end if; case Item.Action.Verb is when Reduce => -- Do a reduce, look at resulting state. Keep reducing until we can't -- anymore. declare Reduce_Action : Reduce_Action_Rec := To_Reduce_Action (Item.Action); Actions : Minimal_Action_Arrays.Vector; Recursive : Boolean; begin loop Do_Reduce_1 ("Minimal_Complete_Actions", Super, Shared, Parser_Index, Local_Config_Heap, Item.Config, Reduce_Action, Do_Language_Fixes => False); Actions := Table.States (Item.Config.Stack.Peek.State).Minimal_Complete_Actions; Recursive := Table.States (Item.Config.Stack.Peek.State).Minimal_Complete_Actions_Recursive; case Actions.Length is when 0 => if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions abandoned: no actions"); end if; exit; when 1 => case Actions (Actions.First_Index).Verb is when Shift => Minimal_Do_Shift (Actions (Actions.First_Index), Item.Config); exit; when Reduce => Reduce_Action := To_Reduce_Action (Actions (Actions.First_Index)); end case; when others => Enqueue_Min_Actions ("multiple actions ", Actions, Recursive, Item.Config, Reduce_Only => True); exit; end case; end loop; end; when Shift => Minimal_Do_Shift (Item.Action, Item.Config); end case; end; end loop; if Inserted_Last = Inserted'First - 1 then if Orig_Config.Minimal_Complete_State = Active then Orig_Config.Minimal_Complete_State := Done; end if; end if; return To_Vector (Inserted (1 .. Inserted_Last)); end Insert_Minimal_Complete_Actions; procedure Insert_Matching_Begin (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type; Matching_Begin_Tokens : in Token_ID_Arrays.Vector) is Table : Parse_Table renames Shared.Table.all; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; begin -- We don't check for insert = current token; that's either ok or a -- severe bug in Language_Use_Minimal_Complete. if Config.Matching_Begin_Done then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Matching_Begin abandoned: done"); end if; return; end if; if Just_Pushed_Back_Or_Deleted (Config, Matching_Begin_Tokens (Matching_Begin_Tokens.First_Index)) then if Trace_McKenzie > Extra then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Matching_Begin abandoned " & Image (Matching_Begin_Tokens (Matching_Begin_Tokens.First_Index), Descriptor) & ": undo push_back"); end if; return; end if; declare New_Config : Configuration := Config; begin for ID of Matching_Begin_Tokens loop Insert (New_Config, ID); end loop; declare use Parse.Parse_Item_Arrays; Parse_Items : aliased Parse.Parse_Item_Arrays.Vector; Dummy : constant Boolean := Parse.Parse (Super, Shared, Parser_Index, Parse_Items, New_Config, Shared_Token_Goal => Invalid_Token_Index, All_Conflicts => True, Trace_Prefix => "parse Matching_Begin"); begin for I in First_Index (Parse_Items) .. Last_Index (Parse_Items) loop declare Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Variable_Ref (Parse_Items, I); begin if Item.Parsed and Item.Config.Current_Insert_Delete = No_Insert_Delete then Item.Config.Matching_Begin_Done := True; Item.Config.Cost := Item.Config.Cost + Table.McKenzie_Param.Matching_Begin; Item.Config.Strategy_Counts (Matching_Begin) := Item.Config.Strategy_Counts (Matching_Begin) + 1; Item.Config.Error_Token.ID := Invalid_Token_ID; Item.Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); if Trace_McKenzie > Detail then Base.Put ("Matching_Begin: insert " & Image (Matching_Begin_Tokens, Descriptor), Super, Shared, Parser_Index, Item.Config); end if; Local_Config_Heap.Add (Item.Config); else if Trace_McKenzie > Detail then Base.Put ("Matching_Begin: abandon " & Image (Matching_Begin_Tokens, Descriptor) & ": parse fail", Super, Shared, Parser_Index, Item.Config); end if; end if; end; end loop; end; end; exception when SAL.Container_Full => -- From config_ops_sorted Super.Config_Full ("Minimal_Complete_Actions 3", Parser_Index); end Insert_Matching_Begin; procedure Try_Insert_Terminal (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in out Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is use all type WisiToken.Parse.LR.Parser.Language_Matching_Begin_Tokens_Access; use all type Ada.Containers.Count_Type; Tokens : Token_ID_Array_1_3; Matching_Begin_Tokens : Token_ID_Arrays.Vector; Forbid_Minimal_Insert : Boolean := False; Minimal_Inserted : Token_ID_Arrays.Vector; begin if Shared.Language_Matching_Begin_Tokens /= null then Current_Token_ID_Peek_3 (Shared.Terminals.all, Config.Current_Shared_Token, Config.Insert_Delete, Config.Current_Insert_Delete, Super.Parser_State (Parser_Index).Prev_Deleted, Tokens); Shared.Language_Matching_Begin_Tokens (Tokens, Config, Matching_Begin_Tokens, Forbid_Minimal_Insert); end if; if not Forbid_Minimal_Insert then -- See test_mckenzie_recover.adb Forbid_Minimal_Insert for rationale. Minimal_Inserted := Insert_Minimal_Complete_Actions (Super, Shared, Parser_Index, Config, Local_Config_Heap); end if; if Matching_Begin_Tokens.Length > 0 then Insert_Matching_Begin (Super, Shared, Parser_Index, Config, Local_Config_Heap, Matching_Begin_Tokens); end if; -- We always do all three Insert_Minimal_Complete (unless -- Forbid_Minimal_Insert), Insert_Matching_Begin, -- Insert_From_Action_List; in general it's not possible to tell when -- one will be better (see test_mckenzie_recover.adb -- Always_Minimal_Complete, Always_Matching_Begin). -- Insert_From_Action does not insert the Minimal_Inserted tokens, -- and it will never insert the Matching_Begin_Tokens, so there is no -- duplication. Insert_From_Action_List will normally be more -- expensive. Insert_From_Action_List (Super, Shared, Parser_Index, Config, Minimal_Inserted, Local_Config_Heap); -- It is tempting to use the Goto_List to find nonterms to insert. -- But that can easily lead to error states, and it turns out to be -- not useful, especially if the grammar has been relaxed so most -- expressions and lists can be empty. exception when Bad_Config => null; end Try_Insert_Terminal; procedure Try_Insert_Quote (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in out Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is use Config_Op_Arrays; use all type Parser.Language_String_ID_Set_Access; Descriptor : WisiToken.Descriptor renames Shared.Trace.Descriptor.all; Check_Limit : WisiToken.Token_Index renames Shared.Table.McKenzie_Param.Check_Limit; Current_Line : constant Line_Number_Type := Shared.Terminals.all (Config.Current_Shared_Token).Line; Lexer_Error_Token_Index : Base_Token_Index; Lexer_Error_Token : Base_Token; function Recovered_Lexer_Error (Line : in Line_Number_Type) return Base_Token_Index is begin -- We are assuming the list of lexer errors is short, so binary -- search would not be significantly faster. for Err of reverse Shared.Lexer.Errors loop if Err.Recover_Token /= Invalid_Token_Index and then Shared.Terminals.all (Err.Recover_Token).Line = Line then return Err.Recover_Token; end if; end loop; return Invalid_Token_Index; end Recovered_Lexer_Error; function String_ID_Set (String_ID : in Token_ID) return Token_ID_Set is begin if Shared.Language_String_ID_Set = null then return (String_ID .. String_ID => True); else return Shared.Language_String_ID_Set (Descriptor, String_ID); end if; end String_ID_Set; procedure String_Literal_In_Stack (Label : in String; New_Config : in out Configuration; Matching : in SAL.Peek_Type; String_Literal_ID : in Token_ID) is use Parse.Parse_Item_Arrays; Saved_Shared_Token : constant WisiToken.Token_Index := New_Config.Current_Shared_Token; Tok : Recover_Token; J : WisiToken.Token_Index; Parse_Items : aliased Parse.Parse_Item_Arrays.Vector; begin -- Matching is the index of a token on New_Config.Stack containing a string -- literal. Push back thru that token, then delete all tokens after -- the string literal to Saved_Shared_Token. if not Has_Space (New_Config.Ops, Ada.Containers.Count_Type (Matching)) then Super.Config_Full ("insert quote 1 " & Label, Parser_Index); raise Bad_Config; end if; for I in 1 .. Matching loop Tok := New_Config.Stack.Pop.Token; Append (New_Config.Ops, (Push_Back, Tok.ID, Tok.Min_Terminal_Index)); end loop; New_Config.Current_Shared_Token := Tok.Min_Terminal_Index; -- Find last string literal in pushed back terminals. J := Saved_Shared_Token - 1; loop exit when Shared.Terminals.all (J).ID = String_Literal_ID; J := J - 1; end loop; begin if Parse.Parse (Super, Shared, Parser_Index, Parse_Items, New_Config, Shared_Token_Goal => J, All_Conflicts => False, Trace_Prefix => "insert quote parse pushback " & Label) then -- The non-deleted tokens parsed without error. We don't care if any -- conflicts were encountered; we are not using the parse result. New_Config := Parse.Parse_Item_Array_Refs.Constant_Ref (Parse_Items, 1).Config; Append (New_Config.Ops, (Fast_Forward, New_Config.Current_Shared_Token)); else raise SAL.Programmer_Error; end if; exception when Bad_Config => raise SAL.Programmer_Error; end; if not Has_Space (New_Config.Ops, Ada.Containers.Count_Type (Saved_Shared_Token - 1 - New_Config.Current_Shared_Token)) then Super.Config_Full ("insert quote 2 " & Label, Parser_Index); raise Bad_Config; end if; for J in New_Config.Current_Shared_Token .. Saved_Shared_Token - 1 loop Append (New_Config.Ops, (Delete, Shared.Terminals.all (J).ID, J)); end loop; New_Config.Current_Shared_Token := Saved_Shared_Token; end String_Literal_In_Stack; procedure Finish (Label : in String; New_Config : in out Configuration; First, Last : in Base_Token_Index) is begin -- Delete tokens First .. Last; either First - 1 or Last + 1 should -- be a String_Literal. Leave Current_Shared_Token at Last + 1. New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); -- This is a guess, so we give it a nominal cost New_Config.Cost := New_Config.Cost + 1; if not Has_Space (New_Config.Ops, Ada.Containers.Count_Type (Last - First)) then Super.Config_Full ("insert quote 3 " & Label, Parser_Index); raise Bad_Config; end if; for I in First .. Last loop Append (New_Config.Ops, (Delete, Shared.Terminals.all (I).ID, I)); end loop; New_Config.Current_Shared_Token := Last + 1; -- Let explore do insert after these deletes. Append (New_Config.Ops, (Fast_Forward, New_Config.Current_Shared_Token)); if New_Config.Resume_Token_Goal - Check_Limit < New_Config.Current_Shared_Token then New_Config.Resume_Token_Goal := New_Config.Current_Shared_Token + Check_Limit; if Trace_McKenzie > Detail then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "resume_token_goal:" & WisiToken.Token_Index'Image (New_Config.Resume_Token_Goal)); end if; end if; New_Config.Strategy_Counts (String_Quote) := New_Config.Strategy_Counts (String_Quote) + 1; if Trace_McKenzie > Detail then Base.Put ("insert quote " & Label & " ", Super, Shared, Parser_Index, New_Config); end if; end Finish; begin -- When the lexer finds an unbalanced quote, it inserts a virtual -- balancing quote at the same character position as the unbalanced -- quote, returning an empty string literal token there. The parser -- does not see that as an error; it encounters a syntax error -- before, at, or after that string literal. -- -- Here we assume the parse error in Config.Error_Token is due to -- putting the balancing quote in the wrong place, and attempt to -- find a better place to put the balancing quote. Then all tokens -- from the balancing quote to the unbalanced quote are now part of a -- string literal, so delete them, leaving just the string literal -- created by Lexer error recovery. -- First we check to see if there is an unbalanced quote in the -- current line; if not, just return. Some lexer errors are for other -- unrecognized characters; see ada_mode-recover_bad_char.adb. -- -- An alternate strategy is to treat the lexer error as a parse error -- immediately, but that complicates the parse logic. Config.String_Quote_Checked := Current_Line; Lexer_Error_Token_Index := Recovered_Lexer_Error (Current_Line); if Lexer_Error_Token_Index = Invalid_Token_Index then return; end if; Lexer_Error_Token := Shared.Terminals.all (Lexer_Error_Token_Index); -- It is not possible to tell where the best place to put the -- balancing quote is, so we always try all reasonable places. if Lexer_Error_Token.Byte_Region.First = Config.Error_Token.Byte_Region.First then -- The parse error token is the string literal at the lexer error. -- -- case a: Insert the balancing quote somewhere before the error -- point. There is no way to tell how far back to put the balancing -- quote, so we just do one non-empty token. See -- test_mckenzie_recover.adb String_Quote_0. So far we have not found -- a test case for more than one token. declare New_Config : Configuration := Config; Token : Recover_Token; begin loop Token := New_Config.Stack.Pop.Token; if Token.Byte_Region /= Null_Buffer_Region then if Is_Full (New_Config.Ops) then Super.Config_Full ("insert quote 4 a", Parser_Index); raise Bad_Config; else Append (New_Config.Ops, (Push_Back, Token.ID, Token.Min_Terminal_Index)); end if; exit; end if; end loop; Finish ("a", New_Config, Token.Min_Terminal_Index, Config.Current_Shared_Token - 1); Local_Config_Heap.Add (New_Config); end; -- Note that it is not reasonable to insert a quote after the error -- in this case. If that were the right solution, the parser error -- token would not be the lexer repaired string literal, since a -- string literal would be legal here. elsif Lexer_Error_Token.Byte_Region.First < Config.Error_Token.Byte_Region.First then -- The unbalanced quote is before the parse error token; see -- test_mckenzie_recover.adb String_Quote_2. -- -- The missing quote belongs after the parse error token, before or -- at the end of the current line; try inserting it at the end of -- the current line. -- -- The lexer repaired string literal may be in a reduced token on the -- stack. declare Matching : SAL.Peek_Type := 1; begin Find_Descendant_ID (Super.Parser_State (Parser_Index).Tree, Config, Lexer_Error_Token.ID, String_ID_Set (Lexer_Error_Token.ID), Matching); if Matching = Config.Stack.Depth then -- String literal is in a virtual nonterm; give up. So far this only -- happens in a high cost non critical config. if Trace_McKenzie > Detail then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "insert quote b abandon; string literal in virtual"); end if; return; end if; declare New_Config : Configuration := Config; begin String_Literal_In_Stack ("b", New_Config, Matching, Lexer_Error_Token.ID); Finish ("b", New_Config, Config.Current_Shared_Token, Shared.Line_Begin_Token.all (Current_Line + 1) - 1); Local_Config_Heap.Add (New_Config); end; end; else -- The unbalanced quote is after the parse error token. -- case c: Assume a missing quote belongs immediately before the current token. -- See test_mckenzie_recover.adb String_Quote_3. declare New_Config : Configuration := Config; begin Finish ("c", New_Config, Config.Current_Shared_Token, Lexer_Error_Token_Index - 1); Local_Config_Heap.Add (New_Config); exception when Bad_Config => null; end; -- case d: Assume a missing quote belongs somewhere farther before -- the current token; try one non-empty (as in case a above). See -- test_mckenzie_recover.adb String_Quote_4. declare New_Config : Configuration := Config; Token : Recover_Token; begin loop Token := New_Config.Stack.Pop.Token; if Token.Byte_Region /= Null_Buffer_Region then if Is_Full (New_Config.Ops) then Super.Config_Full ("insert quote 5 d", Parser_Index); raise Bad_Config; else Append (New_Config.Ops, (Push_Back, Token.ID, Token.Min_Terminal_Index)); end if; exit; end if; end loop; Finish ("d", New_Config, Token.Min_Terminal_Index, Lexer_Error_Token_Index - 1); Local_Config_Heap.Add (New_Config); exception when SAL.Container_Empty => -- From Stack.Pop null; when Bad_Config => null; end; -- case e: Assume the actual error is an extra quote that terminates -- an intended string literal early, in which case there is a token -- on the stack containing the string literal that should be extended -- to the found quote. See test_mckenzie_recover.adb String_Quote_1. declare Matching : SAL.Peek_Type := 1; begin -- Lexer_Error_Token is a string literal; find a matching one. Find_Descendant_ID (Super.Parser_State (Parser_Index).Tree, Config, Lexer_Error_Token.ID, String_ID_Set (Lexer_Error_Token.ID), Matching); if Matching = Config.Stack.Depth then -- No matching string literal, so this case does not apply. null; else declare New_Config : Configuration := Config; begin String_Literal_In_Stack ("e", New_Config, Matching, Lexer_Error_Token.ID); Finish ("e", New_Config, Config.Current_Shared_Token, Lexer_Error_Token_Index); Local_Config_Heap.Add (New_Config); end; end if; end; end if; exception when Bad_Config => null; end Try_Insert_Quote; procedure Try_Delete_Input (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Parser_Index : in SAL.Base_Peek_Type; Config : in Configuration; Local_Config_Heap : in out Config_Heaps.Heap_Type) is -- Try deleting (= skipping) the current shared input token. use Config_Op_Arrays, Config_Op_Array_Refs; use all type Ada.Containers.Count_Type; Trace : WisiToken.Trace'Class renames Super.Trace.all; EOF_ID : Token_ID renames Trace.Descriptor.EOI_ID; Check_Limit : WisiToken.Token_Index renames Shared.Table.McKenzie_Param.Check_Limit; McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param; ID : constant Token_ID := Shared.Terminals.all (Config.Current_Shared_Token).ID; begin if ID /= EOF_ID and then -- can't delete EOF (Length (Config.Ops) = 0 or else -- Don't delete an ID we just inserted; waste of time (not Equal (Constant_Ref (Config.Ops, Last_Index (Config.Ops)), (Insert, ID, Config.Current_Shared_Token, 1, 0)))) then declare New_Config : Configuration := Config; function Matching_Push_Back return Boolean is begin for I in reverse First_Index (New_Config.Ops) .. Last_Index (New_Config.Ops) loop declare Op : Config_Op renames Config_Op_Array_Refs.Variable_Ref (New_Config.Ops, I).Element.all; begin exit when not (Op.Op in Undo_Reduce | Push_Back | Delete); if Op = (Push_Back, ID, New_Config.Current_Shared_Token) then return True; end if; end; end loop; return False; end Matching_Push_Back; begin New_Config.Error_Token.ID := Invalid_Token_ID; New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok); New_Config.Cost := New_Config.Cost + McKenzie_Param.Delete (ID); New_Config.Strategy_Counts (Explore_Table) := Config.Strategy_Counts (Explore_Table) + 1; if Matching_Push_Back then -- We are deleting a push_back; cancel the push_back cost, to make -- this the same as plain deleting. New_Config.Cost := Natural'Max (Natural'First, New_Config.Cost - McKenzie_Param.Push_Back (ID)); end if; if Is_Full (New_Config.Ops) then Super.Config_Full ("delete", Parser_Index); raise Bad_Config; else Append (New_Config.Ops, (Delete, ID, Config.Current_Shared_Token)); end if; New_Config.Current_Shared_Token := New_Config.Current_Shared_Token + 1; loop exit when not Super.Parser_State (Parser_Index).Prev_Deleted.Contains (New_Config.Current_Shared_Token); New_Config.Current_Shared_Token := New_Config.Current_Shared_Token + 1; end loop; if New_Config.Resume_Token_Goal - Check_Limit < New_Config.Current_Shared_Token then New_Config.Resume_Token_Goal := New_Config.Current_Shared_Token + Check_Limit; end if; Local_Config_Heap.Add (New_Config); if Trace_McKenzie > Detail then Base.Put ("delete " & Image (ID, Trace.Descriptor.all), Super, Shared, Parser_Index, New_Config); end if; end; end if; end Try_Delete_Input; procedure Process_One (Super : not null access Base.Supervisor; Shared : not null access Base.Shared; Config_Status : out Base.Config_Status) is -- Get one config from Super, check to see if it is a viable -- solution. If not, enqueue variations to check. use all type Base.Config_Status; use all type Parser.Language_Fixes_Access; use all type Semantic_Checks.Check_Status_Label; Trace : WisiToken.Trace'Class renames Super.Trace.all; Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all; Table : Parse_Table renames Shared.Table.all; Parser_Index : SAL.Base_Peek_Type; Config : Configuration; Local_Config_Heap : Config_Heaps.Heap_Type; -- We collect all the variants to enqueue, then deliver them all at -- once to Super, to minimizes task interactions. begin Super.Get (Parser_Index, Config, Config_Status); if Config_Status = All_Done then return; end if; if Trace_McKenzie > Detail then Base.Put ("dequeue", Super, Shared, Parser_Index, Config); if Trace_McKenzie > Extra then Put_Line (Trace, Super.Label (Parser_Index), "stack: " & Image (Config.Stack, Trace.Descriptor.all)); end if; end if; -- Fast_Forward; parse Insert, Delete in Config.Ops that have not -- been parsed yet. 'parse' here means adjusting Config.Stack and -- Current_Terminal_Index. Code in this file always parses when -- adding ops to Config (except as noted); Language_Fixes should use -- McKenzie_Recover.Insert, Delete instead. if Config.Current_Insert_Delete = 1 then -- Config.Current_Insert_Delete > 1 is a programming error. case Fast_Forward (Super, Shared, Parser_Index, Local_Config_Heap, Config) is when Abandon => -- We know Local_Config_Heap is empty; just tell -- Super we are done working. Super.Put (Parser_Index, Local_Config_Heap); return; when Continue => -- We don't increase cost for this Fast_Forward, since it is due to a -- Language_Fixes. null; end case; end if; pragma Assert (Config.Current_Insert_Delete = 0); -- Language_Fixes: let it enqueue configs. if Config.Error_Token.ID /= Invalid_Token_ID then if Shared.Language_Fixes = null then null; else Shared.Language_Fixes (Trace, Shared.Lexer, Super.Label (Parser_Index), Shared.Table.all, Shared.Terminals.all, Super.Parser_State (Parser_Index).Tree, Local_Config_Heap, Config); -- The solutions enqueued by Language_Fixes should be lower cost than -- others (typically 0), so they will be checked first. if Config.Check_Status.Label = Ok then -- Parse table Error action. -- -- We don't clear Config.Error_Token here, because -- Language_Use_Minimal_Complete_Actions needs it. We only clear it -- when a parse results in no error (or a different error), or a -- push_back moves the Current_Token. null; else -- Assume "ignore check error" is a viable solution. But give it a -- cost, so a solution provided by Language_Fixes is preferred. declare New_State : Unknown_State_Index; begin Config.Cost := Config.Cost + Table.McKenzie_Param.Ignore_Check_Fail; -- finish reduce. Config.Stack.Pop (SAL.Base_Peek_Type (Config.Check_Token_Count)); New_State := Goto_For (Table, Config.Stack.Peek.State, Config.Error_Token.ID); if New_State = Unknown_State then if Config.Stack.Depth = 1 then -- Stack is empty, and we did not get Accept; really bad syntax got -- us here; abandon this config. See ada_mode-recover_bad_char.adb. Super.Put (Parser_Index, Local_Config_Heap); return; else raise SAL.Programmer_Error with "process_one found test case for new_state = Unknown; old state " & Trimmed_Image (Config.Stack.Peek.State) & " nonterm " & Image (Config.Error_Token.ID, Trace.Descriptor.all); end if; end if; Config.Stack.Push ((New_State, Syntax_Trees.Invalid_Node_Index, Config.Error_Token)); -- We clear Check_Status and Error_Token so the check error is ignored. Config.Check_Status := (Label => Ok); Config.Error_Token.ID := Invalid_Token_ID; end; end if; end if; end if; -- Call Check to see if this config succeeds. Note that Check does -- more than Fast_Forward, so the fact that Fast_Forward succeeds -- does not mean we don't need to call Check. case Check (Super, Shared, Parser_Index, Config, Local_Config_Heap) is when Success => Super.Success (Parser_Index, Config, Local_Config_Heap); return; when Abandon => Super.Put (Parser_Index, Local_Config_Heap); return; when Continue => null; end case; if Trace_McKenzie > Detail then Base.Put ("continuing", Super, Shared, Parser_Index, Config); if Trace_McKenzie > Extra then Put_Line (Trace, Super.Label (Parser_Index), "stack: " & Image (Config.Stack, Trace.Descriptor.all)); end if; end if; -- Grouping these operations (push_back, delete, insert) ensures that -- there are no duplicate solutions found. We reset the grouping -- after each fast_forward. -- -- We do delete before insert so Insert_Matching_Begin can operate on -- the new next token, before Fast_Forwarding past it. -- -- All possible permutations will be explored. pragma Assert (Config.Stack.Depth > 0); Try_Insert_Terminal (Super, Shared, Parser_Index, Config, Local_Config_Heap); if None_Since_FF (Config.Ops, Delete) and then None_Since_FF (Config.Ops, Insert) and then Config.Stack.Depth > 1 and then -- can't delete the first state (not Check_Reduce_To_Start (Super, Shared, Parser_Index, Config)) -- If Config reduces to the start nonterm, there's no point in push_back. then Try_Push_Back (Super, Shared, Parser_Index, Config, Local_Config_Heap); Try_Undo_Reduce (Super, Shared, Parser_Index, Config, Local_Config_Heap); end if; if None_Since_FF (Config.Ops, Insert) then Try_Delete_Input (Super, Shared, Parser_Index, Config, Local_Config_Heap); end if; -- This is run once per input line, independent of what other ops -- have been done. if Config.Check_Status.Label = Ok and (Descriptor.String_1_ID /= Invalid_Token_ID or Descriptor.String_2_ID /= Invalid_Token_ID) and (Config.String_Quote_Checked = Invalid_Line_Number or else Config.String_Quote_Checked < Shared.Terminals.all (Config.Current_Shared_Token).Line) then -- See if there is a mismatched quote. The solution is to delete -- tokens, replacing them with a string literal. So we try this when -- it is ok to try delete. Try_Insert_Quote (Super, Shared, Parser_Index, Config, Local_Config_Heap); end if; Super.Put (Parser_Index, Local_Config_Heap); exception when Bad_Config => -- Just abandon this config; tell Super we are done. Super.Put (Parser_Index, Local_Config_Heap); when E : others => Super.Put (Parser_Index, Local_Config_Heap); if Debug_Mode then raise; elsif Trace_McKenzie > Outline then Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Process_One: unhandled exception " & Ada.Exceptions.Exception_Name (E) & ": " & Ada.Exceptions.Exception_Message (E)); end if; end Process_One; end WisiToken.Parse.LR.McKenzie_Recover.Explore;
src/Categories/Category/Instance/FamilyOfSetoids.agda
Trebor-Huang/agda-categories
279
6382
<filename>src/Categories/Category/Instance/FamilyOfSetoids.agda {-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.FamilyOfSetoids where -- The Category of "Families of Setoids" -- This fits into this library much better than the Families of Sets -- This particular formalization should be considered alpha, i.e. its -- names will change once things settle. open import Level open import Relation.Binary using (Rel; Setoid; module Setoid; Reflexive; Symmetric; Transitive) open import Function.Base renaming (id to idf; _∘_ to _⊚_) open import Function.Equality open import Function.Inverse using (_InverseOf_) import Relation.Binary.Reasoning.Setoid as SetoidR open import Categories.Category module _ {a b c d : Level} where record Fam : Set (suc (a ⊔ b ⊔ c ⊔ d)) where constructor fam open Setoid using () renaming (Carrier to ∣_∣; _≈_ to _≈≈_) field U : Setoid a b open Setoid U hiding (Carrier) field T : ∣ U ∣ → Setoid c d reindex : {x y : ∣ U ∣} (P : x ≈ y) → T y ⟶ T x -- the following coherence laws are needed to make _≃_ below an equivalence reindex-refl : {x : ∣ U ∣} {bx : ∣ T x ∣} → _≈≈_ (T x) (reindex refl ⟨$⟩ bx) bx reindex-sym : {x y : ∣ U ∣} → (p : x ≈ y) → (reindex (sym p)) InverseOf (reindex p) reindex-trans : {x y z : ∣ U ∣} {b : ∣ T z ∣} → (p : x ≈ y) → (q : y ≈ z) → Setoid._≈_ (T x) (reindex (trans p q) ⟨$⟩ b) (reindex p ∘ reindex q ⟨$⟩ b) open Fam record Hom (B B′ : Fam) : Set (a ⊔ b ⊔ c ⊔ d) where constructor fhom open Setoid (U B) using (_≈_) field map : U B ⟶ U B′ transport : (x : Setoid.Carrier (U B)) → T B x ⟶ T B′ (map ⟨$⟩ x) transport-coh : {x y : Setoid.Carrier (U B)} → (p : x ≈ y) → Setoid._≈_ (T B y ⇨ T B′ (map ⟨$⟩ x)) (transport x ∘ reindex B p) (reindex B′ (Π.cong map p) ∘ transport y) record _≈≈_ {X Y} (F F′ : (Hom X Y)) : Set (a ⊔ b ⊔ c ⊔ d) where constructor feq open Hom open Setoid (U X) renaming (Carrier to A) hiding (refl; _≈_) open Setoid (U Y) -- the order below is chosen to simplify some of the later reasoning field g≈f : {x : A} → map F ⟨$⟩ x ≈ map F′ ⟨$⟩ x φ≈γ : {x : A} → let C = T X x D = T Y (map F ⟨$⟩ x) in {bx : Setoid.Carrier C} → Setoid._≈_ D ((reindex Y g≈f ∘ transport F′ x) ⟨$⟩ bx) (transport F x ⟨$⟩ bx) fam-id : {A : Fam} → Hom A A fam-id {A} = fhom id (λ _ → id) λ p x≈y → Π.cong (reindex A p) x≈y comp : {A B C : Fam} → Hom B C → Hom A B → Hom A C comp {B = B} {C} (fhom map₀ trans₀ coh₀) (fhom map₁ trans₁ coh₁) = fhom (map₀ ∘ map₁) (λ x → trans₀ (map₁ ⟨$⟩ x) ∘ (trans₁ x)) λ {a} {b} p {x} {y} x≈y → let open Setoid (T C (map₀ ∘ map₁ ⟨$⟩ a)) renaming (trans to _⟨≈⟩_) in Π.cong (trans₀ (map₁ ⟨$⟩ a)) (coh₁ p x≈y) ⟨≈⟩ coh₀ (Π.cong map₁ p) (Setoid.refl (T B (map₁ ⟨$⟩ b))) ≈≈-refl : ∀ {A B} → Reflexive (_≈≈_ {A} {B}) ≈≈-refl {B = B} = feq refl (reindex-refl B) where open Setoid (U B) ≈≈-sym : ∀ {A B} → Symmetric (_≈≈_ {A} {B}) ≈≈-sym {A} {B} {F} {G} (feq g≈f φ≈γ) = feq (sym g≈f) λ {x} {bx} → Setoid.trans ( T B (map G ⟨$⟩ x) ) (Π.cong (reindex B (sym g≈f)) (Setoid.sym (T B (map F ⟨$⟩ x)) φ≈γ)) (left-inverse-of (reindex-sym B g≈f) (transport G x ⟨$⟩ bx)) where open Setoid (U B) using (sym; Carrier) open Hom open _InverseOf_ ≈≈-trans : ∀ {A B} → Transitive (_≈≈_ {A} {B}) ≈≈-trans {A} {B} {F} {G} {H} (feq ≈₁ t₁) (feq ≈₂ t₂) = feq (trans ≈₁ ≈₂) (λ {x} {bx} → let open Setoid (T B (Hom.map F ⟨$⟩ x)) renaming (trans to _⟨≈⟩_) in reindex-trans B ≈₁ ≈₂ ⟨≈⟩ (Π.cong (reindex B ≈₁) t₂ ⟨≈⟩ t₁)) where open Setoid (U B) using (trans) comp-resp-≈≈ : {A B C : Fam} {f h : Hom B C} {g i : Hom A B} → f ≈≈ h → g ≈≈ i → comp f g ≈≈ comp h i comp-resp-≈≈ {A} {B} {C} {f} {h} {g} {i} (feq f≈h t-f≈h) (feq g≈i t-g≈i) = feq (trans (Π.cong (map f) g≈i) f≈h) λ {x} → let open Setoid (T C (map (comp f g) ⟨$⟩ x)) renaming (trans to _⟨≈⟩_; sym to ≈sym) in reindex-trans C (cong (map f) g≈i) f≈h ⟨≈⟩ (Π.cong (reindex C (cong (map f) g≈i)) t-f≈h ⟨≈⟩ (≈sym (transport-coh {B} {C} f g≈i (Setoid.refl (T B (map i ⟨$⟩ x)))) ⟨≈⟩ Π.cong (transport f (map g ⟨$⟩ x)) t-g≈i)) where open _≈≈_ open Setoid (U C) open Hom Cat : Category (suc (a ⊔ b ⊔ c ⊔ d)) (a ⊔ b ⊔ c ⊔ d) (a ⊔ b ⊔ c ⊔ d) Cat = record { Obj = Fam ; _⇒_ = Hom ; _≈_ = _≈≈_ ; id = fam-id ; _∘_ = comp ; assoc = λ {_} {_} {_} {_} {f} {g} {h} → assoc′ {f = f} {g} {h} ; sym-assoc = λ {_} {_} {_} {_} {f} {g} {h} → ≈≈-sym (assoc′ {f = f} {g} {h}) ; identityˡ = λ {_} {B} → feq (Setoid.refl (U B)) (reindex-refl B) ; identityʳ = λ {_} {B} → feq (Setoid.refl (U B)) (reindex-refl B) ; identity² = λ {A} → feq (Setoid.refl (U A)) (reindex-refl A) ; equiv = λ {A} {B} → let open Setoid (U B) in record { refl = ≈≈-refl ; sym = ≈≈-sym ; trans = ≈≈-trans } ; ∘-resp-≈ = comp-resp-≈≈ } where open _InverseOf_ assoc′ : {A B C D : Fam} {f : Hom A B} {g : Hom B C} {h : Hom C D} → comp (comp h g) f ≈≈ comp h (comp g f) assoc′ {D = D} = feq (Setoid.refl (U D)) (reindex-refl D) open Category Cat public FamilyOfSetoids : ∀ a b c d → Category (suc (a ⊔ b ⊔ c ⊔ d)) (a ⊔ b ⊔ c ⊔ d) (a ⊔ b ⊔ c ⊔ d) FamilyOfSetoids a b c d = Cat {a} {b} {c} {d}
programs/oeis/027/A027785.asm
karttu/loda
1
104474
; A027785: a(n) = 6*(n+1)*binomial(n+2,12). ; 66,936,7098,38220,163800,594048,1893528,5441904,14360580,35271600,81477396,178474296,373173528,748843200,1448655000,2711882160,4928324310,8718517080,15049821150,25401694500,41997468240,68124925440,108574099920,170228167200,262852317000,400136327136,601059482856,891661815408,1307323714320,1895677180800,2720296754448,3865346922528,5441396114154,7592645740680,10505866766850,14421386634876,19646526719976,26571955632768,35691497423400,47626016970000,63152098502220,83236338341520,109076190628860,142148436229800,184266491409000,237647935586880,304993817954280,389581502441040,495373031121150,627141229299000,790616043069606,992653893998676,1241433157755168,1546679226193920,1919922997792800,2374797061885248,2927374300310928,3596554128583104,4404502140227280,5377149505509600,6544759112420256,7942566126733056 mov $1,$0 add $1,12 bin $1,$0 add $0,11 mul $1,$0 mul $1,6
Cubical/Relation/Binary/Raw/Construct/StrictToNonStrict.agda
bijan2005/univalent-foundations
0
1696
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Relation.Binary.Raw module Cubical.Relation.Binary.Raw.Construct.StrictToNonStrict {a ℓ} {A : Type a} (_<_ : RawRel A ℓ) where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Data.Prod open import Cubical.Data.Sum.Base renaming (rec to ⊎-rec) open import Cubical.Data.Empty renaming (elim to ⊥-elim) using () open import Cubical.Relation.Binary.Raw.Properties open import Cubical.Relation.Nullary ------------------------------------------------------------------------ -- Conversion -- _<_ can be turned into _≤_ as follows: _≤_ : RawRel A _ x ≤ y = (x < y) ⊎ (x ≡ y) ------------------------------------------------------------------------ -- The converted relations have certain properties -- (if the original relations have certain other properties) ≤-isPropValued : isSet A → isPropValued _<_ → Irreflexive _<_ → isPropValued _≤_ ≤-isPropValued isSetA propv irrefl x y (inl p) (inl q) = cong inl (propv x y p q) ≤-isPropValued isSetA propv irrefl x y (inl p) (inr q) = ⊥-elim (irrefl→tonoteq _<_ irrefl p q) ≤-isPropValued isSetA propv irrefl x y (inr p) (inl q) = ⊥-elim (irrefl→tonoteq _<_ irrefl q p) ≤-isPropValued isSetA propv irrefl x y (inr p) (inr q) = cong inr (isSetA x y p q) <⇒≤ : _<_ ⇒ _≤_ <⇒≤ = inl ≤-fromEq : FromEq _≤_ ≤-fromEq = inr ≤-reflexive : Reflexive _≤_ ≤-reflexive = fromeq→reflx _≤_ ≤-fromEq ≤-antisym : Transitive _<_ → Irreflexive _<_ → Antisymmetric _≤_ ≤-antisym transitive irrefl (inl x<y) (inl y<x) = ⊥-elim (trans∧irr→asym _<_ transitive irrefl x<y y<x) ≤-antisym _ _ _ (inr y≡x) = sym y≡x ≤-antisym _ _ (inr x≡y) _ = x≡y ≤-transitive : Transitive _<_ → Transitive _≤_ ≤-transitive <-trans (inl x<y) (inl y<z) = inl $ <-trans x<y y<z ≤-transitive _ (inl x<y) (inr y≡z) = inl $ Respectsʳ≡ _<_ y≡z x<y ≤-transitive _ (inr x≡y) (inl y<z) = inl $ Respectsˡ≡ _<_ (sym x≡y) y<z ≤-transitive _ (inr x≡y) (inr y≡z) = inr $ x≡y ∙ y≡z <-≤-trans : Transitive _<_ → Trans _<_ _≤_ _<_ <-≤-trans transitive x<y (inl y<z) = transitive x<y y<z <-≤-trans transitive x<y (inr y≡z) = Respectsʳ≡ _<_ y≡z x<y ≤-<-trans : Transitive _<_ → Trans _≤_ _<_ _<_ ≤-<-trans transitive (inl x<y) y<z = transitive x<y y<z ≤-<-trans transitive (inr x≡y) y<z = Respectsˡ≡ _<_ (sym x≡y) y<z ≤-total : Trichotomous _<_ → Total _≤_ ≤-total <-tri x y with <-tri x y ... | tri< x<y x≢y x≯y = inl (inl x<y) ... | tri≡ x≮y x≡y x≯y = inl (inr x≡y) ... | tri> x≮y x≢y x>y = inr (inl x>y) ≤-decidable : Discrete A → Decidable _<_ → Decidable _≤_ ≤-decidable _≟_ _<?_ x y with x ≟ y ... | yes p = yes (inr p) ... | no ¬p with x <? y ... | yes q = yes (inl q) ... | no ¬q = no (⊎-rec ¬q ¬p) ≤-decidable′ : Trichotomous _<_ → Decidable _≤_ ≤-decidable′ compare x y with compare x y ... | tri< x<y _ _ = yes (inl x<y) ... | tri≡ _ x≡y _ = yes (inr x≡y) ... | tri> x≮y x≢y _ = no (⊎-rec x≮y x≢y) ------------------------------------------------------------------------ -- Converting structures isPreorder : Transitive _<_ → IsPreorder _≤_ isPreorder transitive = record { reflexive = ≤-reflexive ; transitive = ≤-transitive transitive } isPartialOrder : IsStrictPartialOrder _<_ → IsPartialOrder _≤_ isPartialOrder spo = record { isPreorder = isPreorder S.transitive ; antisym = ≤-antisym S.transitive S.irrefl } where module S = IsStrictPartialOrder spo isTotalOrder : IsStrictTotalOrder _<_ → IsTotalOrder _≤_ isTotalOrder sto = record { isPartialOrder = isPartialOrder S.isStrictPartialOrder ; total = λ x y → ∣ ≤-total S.compare x y ∣ } where module S = IsStrictTotalOrder sto isDecTotalOrder : IsStrictTotalOrder _<_ → IsDecTotalOrder _≤_ isDecTotalOrder sto = record { isTotalOrder = isTotalOrder sto ; _≤?_ = ≤-decidable′ S.compare } where module S = IsStrictTotalOrder sto
src/natools-web-filters.adb
faelys/natools-web
1
8440
------------------------------------------------------------------------------ -- Copyright (c) 2015, <NAME> -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ with Natools.S_Expressions.Atom_Buffers; package body Natools.Web.Filters is --------------------- -- Stack Interface -- --------------------- overriding procedure Apply (Object : in Stack; Output : in out Ada.Streams.Root_Stream_Type'Class; Data : in Ada.Streams.Stream_Element_Array) is begin case Object.Backend.Length is when 0 => Output.Write (Data); when 1 => Apply (Object.Backend.First_Element, Output, Data); when others => declare Buffer : S_Expressions.Atom_Buffers.Atom_Buffer; begin Buffer.Append (Data); for F of Object.Backend loop declare Previous : constant S_Expressions.Atom := Buffer.Data; begin Buffer.Soft_Reset; Apply (F, Buffer, Previous); end; end loop; Output.Write (Buffer.Data); end; end case; end Apply; not overriding procedure Insert (Container : in out Stack; Element : in Filter'Class; On : in Side := Top) is begin case On is when Top => Container.Backend.Prepend (Element); when Bottom => Container.Backend.Append (Element); end case; end Insert; not overriding procedure Remove (Container : in out Stack; Element : in Filter'Class; From : in Side := Top) is begin pragma Assert (not Container.Backend.Is_Empty); case From is when Top => declare Removed : constant Filter'Class := Container.Backend.First_Element; begin Container.Backend.Delete_First; if Removed /= Element then raise Program_Error with "Filters.Remove called with wrong Element"; end if; end; when Bottom => declare Removed : constant Filter'Class := Container.Backend.Last_Element; begin Container.Backend.Delete_Last; if Removed /= Element then raise Program_Error with "Filters.Remove called with wrong Element"; end if; end; end case; end Remove; end Natools.Web.Filters;
demo/src/Sprites.adb
98devin/ada-gba-dev
7
10237
-- Copyright (c) 2021 <NAME> -- zlib License -- see LICENSE for details. with GBA.BIOS; with GBA.BIOS.Arm; with GBA.BIOS.Thumb; with GBA.Display; with GBA.Display.Backgrounds; with GBA.Display.Objects; with GBA.Display.Palettes; with GBA.Display.Tiles; with GBA.Memory; with GBA.Numerics; with GBA.Input; with GBA.Input.Buffered; with GBA.Interrupts; with Interfaces; procedure Sprites is use GBA.BIOS; use GBA.BIOS.Arm; use GBA.Display; use GBA.Display.Backgrounds; use GBA.Display.Objects; use GBA.Display.Palettes; use GBA.Display.Tiles; use GBA.Input; use GBA.Input.Buffered; use GBA.Numerics; use Interfaces; Tile_Red : constant Tile_Data_4 := ( ( 0, 0, 1, 1, 1, 1, 0, 0 ) , ( 0, 1, 1, 1, 1, 1, 1, 0 ) , ( 1, 1, 1, 1, 1, 1, 1, 1 ) , ( 1, 1, 1, 1, 1, 1, 1, 1 ) , ( 1, 1, 1, 1, 1, 1, 1, 1 ) , ( 1, 1, 1, 1, 1, 1, 1, 1 ) , ( 0, 1, 1, 1, 1, 1, 1, 0 ) , ( 0, 0, 1, 1, 1, 1, 0, 0 ) ); Tile_Blue : constant Tile_Data_4 := ( ( 0, 0, 2, 2, 2, 2, 0, 0 ) , ( 0, 2, 2, 2, 2, 2, 2, 0 ) , ( 2, 2, 2, 2, 2, 2, 2, 2 ) , ( 2, 2, 2, 2, 2, 2, 2, 2 ) , ( 2, 2, 2, 2, 2, 2, 2, 2 ) , ( 2, 2, 2, 2, 2, 2, 2, 2 ) , ( 0, 2, 2, 2, 2, 2, 2, 0 ) , ( 0, 0, 2, 2, 2, 2, 0, 0 ) ); Tile_Green : constant Tile_Data_4 := ( ( 0, 0, 3, 3, 3, 3, 0, 0 ) , ( 0, 3, 3, 3, 3, 3, 3, 0 ) , ( 3, 3, 3, 3, 3, 3, 3, 3 ) , ( 3, 3, 3, 3, 3, 3, 3, 3 ) , ( 3, 3, 3, 3, 3, 3, 3, 3 ) , ( 3, 3, 3, 3, 3, 3, 3, 3 ) , ( 0, 3, 3, 3, 3, 3, 3, 0 ) , ( 0, 0, 3, 3, 3, 3, 0, 0 ) ); Tile_Red_ID : constant OBJ_Tile_Index := 1; Tile_Blue_ID : constant OBJ_Tile_Index := 2; Tile_Green_ID : constant OBJ_Tile_Index := 3; function Initial_Attributes_State (Tile : OBJ_Tile_Index) return OBJ_Attributes; pragma Machine_Attribute (Initial_Attributes_State, "target", "thumb"); function Initial_Attributes_State (Tile : OBJ_Tile_Index) return OBJ_Attributes is begin return ( Kind => Regular , Mode => Normal , Tile_Index => Tile , Palette_Index => 0 , Color_Mode => Colors_16 , Disabled => False , Priority => 0 , Shape => Square , Scale => 0 , X => 120 , Y => 80 , Enable_Mosaic => False , Flip_Horizontal => False , Flip_Vertical => False ); end Initial_Attributes_State; procedure BIOS_Sin_Cos (Theta : Radians_32; Sin, Cos : out Fixed_8_8) with No_Inline; pragma Machine_Attribute (BIOS_Sin_Cos, "target", "thumb"); procedure BIOS_Sin_Cos (Theta : Radians_32; Sin, Cos : out Fixed_8_8) is Affine_Sin_Cos : Affine_Transform_Matrix; begin GBA.BIOS.Thumb.Affine_Set ( Transform => Affine_Sin_Cos , Parameters => ( Scale_X | Scale_Y => 1.0 , Angle => Radians_16 (Theta) ) ); Sin := Affine_Sin_Cos.DY; Cos := Affine_Sin_Cos.DX; end; X_Center : constant OBJ_X_Coordinate := 116; Y_Center : constant OBJ_Y_Coordinate := 76; procedure Set_Position (ID : OBJ_ID; X : OBJ_X_Coordinate; Y : OBJ_Y_Coordinate) with Linker_Section => ".iwram" is Attrs : OBJ_Attributes := Attributes_Of_Object (ID); begin Attrs.X := X_Center + X; Attrs.Y := Y_Center + Y; Set_Object_Attributes (ID, Attrs); end; Color_Palette : Palette_16_Ptr := OBJ_Palette_16x16 (0)'Access; Theta : Radians_32 := 0.0; X_Scale : constant Fixed_20_8 := 70.0; Y_Scale : constant Fixed_20_8 := 70.0; begin OBJ_Tile_Memory_4 (Tile_Red_ID) := Tile_Red; OBJ_Tile_Memory_4 (Tile_Blue_ID) := Tile_Blue; OBJ_Tile_Memory_4 (Tile_Green_ID) := Tile_Green; Color_Palette (0 .. 5) := ( ( 0, 0, 0) , (29, 9, 11) , (00, 26, 26) , (19, 26, 21) , (31, 25, 21) , (31, 16, 15) ); Set_Object_Attributes (0, Initial_Attributes_State (Tile_Red_ID)); Set_Object_Attributes (1, Initial_Attributes_State (Tile_Blue_ID)); Set_Object_Attributes (2, Initial_Attributes_State (Tile_Green_ID)); GBA.Interrupts.Enable_Receiving_Interrupts; GBA.Interrupts.Enable_Interrupt (GBA.Interrupts.VBlank); Request_VBlank_Interrupt; Wait_For_VBlank; Set_Display_Mode (Mode_0); Enable_Display_Element (Object_Sprites); loop Update_Key_State; declare Sin, Cos : Fixed_Snorm_32; begin Sin_Cos (Theta, Sin, Cos); Set_Position ( 0 , OBJ_X_Coordinate (Integer (Fixed_20_8 (Sin) * X_Scale) / (2 ** 8)) , OBJ_Y_Coordinate (Integer (Fixed_20_8 (Cos) * Y_Scale) / (2 ** 8)) ); end; declare Sin, Cos : Fixed_Snorm_16; One_Third : constant Radians_32 := 1.0 / 3.0; begin Sin_Cos_LUT (Radians_16 (Theta + One_Third), Sin, Cos); Set_Position ( 1 , OBJ_X_Coordinate (Integer (Fixed_20_8 (Sin) * X_Scale) / (2 ** 8)) , OBJ_Y_Coordinate (Integer (Fixed_20_8 (Cos) * Y_Scale) / (2 ** 8)) ); end; declare Sin, Cos : Fixed_8_8; Two_Thirds : constant Radians_32 := 2.0 / 3.0; begin BIOS_Sin_Cos (Theta + Two_Thirds, Sin, Cos); Set_Position ( 2 , OBJ_X_Coordinate (Integer (Fixed_20_8 (Sin) * X_Scale) / (2 ** 8)) , OBJ_Y_Coordinate (Integer (Fixed_20_8 (Cos) * Y_Scale) / (2 ** 8)) ); end; if Are_Any_Down (A_Button or B_Button) then Theta := @ + (1.0 / 128.0); else Theta := @ + (1.0 / 512.0); end if; Wait_For_VBlank; end loop; end;
PrintDigit.asm
Sahilsinggh/MP_SEM4
1
167720
section .data digit: db 0 section .bss section .text global _start _start: mov eax,8h call _printEAXDigit mov eax,1 mov ebx,0 int 80h _printEAXDigit: add eax, 30h mov [digit],eax mov ecx,digit ;ecx stores const char* while printing String mov eax,4 ;here digit is memory location and [digit] is value mov ebx,1 mov edx,1 int 80h ret
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_2275.asm
ljhsiun2/medusa
9
178898
<reponame>ljhsiun2/medusa .global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r8 push %rax push %rcx push %rdi push %rsi lea addresses_UC_ht+0xb3ee, %rsi lea addresses_D_ht+0x39ee, %rdi nop nop nop nop nop sub $45931, %r8 mov $101, %rcx rep movsb nop nop add %rdi, %rdi lea addresses_normal_ht+0xee, %rsi lea addresses_D_ht+0x862e, %rdi clflush (%rsi) nop nop nop dec %r12 mov $25, %rcx rep movsl nop nop nop nop nop inc %rcx lea addresses_WC_ht+0x1d2ee, %r8 nop nop nop nop nop sub $32810, %rax movl $0x61626364, (%r8) nop nop nop and %r8, %r8 lea addresses_WT_ht+0x2ee, %rcx clflush (%rcx) sub $33008, %rax mov (%rcx), %r12w and $32660, %rsi lea addresses_A_ht+0x16ece, %rsi lea addresses_normal_ht+0xfdee, %rdi nop nop nop lfence mov $49, %rcx rep movsl nop nop cmp $654, %r13 lea addresses_WC_ht+0x13dc2, %r8 nop nop nop xor %r12, %r12 movb $0x61, (%r8) inc %r8 lea addresses_normal_ht+0x181ee, %rax nop nop nop nop nop cmp $36772, %rdi mov (%rax), %rsi nop sub %rdi, %rdi lea addresses_A_ht+0x13f4a, %rcx inc %r8 movb (%rcx), %al nop dec %r8 lea addresses_WT_ht+0x1118e, %rsi lea addresses_A_ht+0x179ca, %rdi nop and $42321, %r12 mov $57, %rcx rep movsl nop nop nop inc %r8 lea addresses_WC_ht+0x312e, %r13 nop nop nop nop sub %rsi, %rsi movb $0x61, (%r13) nop cmp %rsi, %rsi pop %rsi pop %rdi pop %rcx pop %rax pop %r8 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r15 push %rax push %rcx push %rdx // Store lea addresses_UC+0x89ee, %rcx nop nop nop cmp %rax, %rax movl $0x51525354, (%rcx) nop sub $29123, %rax // Faulty Load lea addresses_D+0x155ee, %r15 nop nop nop sub %r11, %r11 mov (%r15), %r14d lea oracles, %r12 and $0xff, %r14 shlq $12, %r14 mov (%r12,%r14,1), %r14 pop %rdx pop %rcx pop %rax pop %r15 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_D', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 4, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_D', 'same': True, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 8, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 8, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
alloy4fun_models/trashltl/models/3/BNMArEkk7dKxtZpkv.als
Kaixi26/org.alloytools.alloy
0
880
open main pred idBNMArEkk7dKxtZpkv_prop4 { some f: File | always eventually f in Trash } pred __repair { idBNMArEkk7dKxtZpkv_prop4 } check __repair { idBNMArEkk7dKxtZpkv_prop4 <=> prop4o }
constants.asm
adhi-thirumala/EvoYellow
16
103080
<filename>constants.asm INCLUDE "macros.asm" INCLUDE "hram.asm" INCLUDE "vram.asm" INCLUDE "constants/hardware_constants.asm" INCLUDE "constants/oam_constants.asm" INCLUDE "constants/misc_constants.asm" INCLUDE "constants/pokemon_constants.asm" INCLUDE "constants/pokedex_constants.asm" INCLUDE "constants/trainer_constants.asm" INCLUDE "constants/item_constants.asm" INCLUDE "constants/type_constants.asm" INCLUDE "constants/move_constants.asm" INCLUDE "constants/move_animation_constants.asm" INCLUDE "constants/move_effect_constants.asm" INCLUDE "constants/status_constants.asm" INCLUDE "constants/sprite_constants.asm" INCLUDE "constants/palette_constants.asm" INCLUDE "constants/evolution_constants.asm" INCLUDE "constants/list_constants.asm" INCLUDE "constants/map_constants.asm" INCLUDE "constants/connection_constants.asm" INCLUDE "constants/hide_show_constants.asm" INCLUDE "constants/credits_constants.asm" INCLUDE "constants/music_constants.asm" INCLUDE "constants/tilesets.asm" INCLUDE "constants/starter_mons.asm" INCLUDE "constants/event_constants.asm" INCLUDE "constants/event_macros.asm" INCLUDE "constants/text_constants.asm" INCLUDE "constants/pikachu_emotion_constants.asm"
ada/common/midi_synthesizer.ads
FrankBuss/Ada_Synth
4
1663
<filename>ada/common/midi_synthesizer.ads with Interfaces; use Interfaces; with MIDI; use MIDI; package MIDI_Synthesizer is Samplerate : constant Float := 44100.0; type Freq_Table is array (0 .. 127) of Float; type Generator is record PhaseIncrement : Float := 0.0; PhaseAccumulator : Float := 0.0; end record; type ADSR_State is (Idle, Attack, Decay, Sustain, Release); type ADSR is record Attack : Float := 50.0 / Samplerate; Decay : Float := 50.0 / Samplerate; Sustain : Float := 0.9; Release : Float := 1.2 / Samplerate; Level : Float := 0.0; State : ADSR_State := Idle; end record; type Synthesizer is new I_Event_Listener with record MIDI_Parser : access Parser'Class; MIDI_Notes : Freq_Table; Generator0 : Generator; ADSR0 : ADSR; end record; function Create_Synthesizer return access Synthesizer; function Next_Sample (Self : in out Synthesizer) return Float; procedure Parse_MIDI_Byte (Self : in out Synthesizer; Received : Unsigned_8); overriding procedure Note_On (Self : in out Synthesizer; Channel : Unsigned_8; Note : Unsigned_8; Velocity : Unsigned_8); overriding procedure Note_Off (Self : in out Synthesizer; Channel : Unsigned_8; Note : Unsigned_8; Velocity : Unsigned_8); overriding procedure Control_Change (Self : in out Synthesizer; Channel : Unsigned_8; Controller_Number : Unsigned_8; Controller_Value : Unsigned_8); end MIDI_Synthesizer;
software/hal/boards/common/hil/hil.ads
TUM-EI-RCS/StratoX
12
15730
-- Institution: Technische Universitaet Muenchen -- Department: Realtime Computer Systems (RCS) -- Project: StratoX -- -- Authors: <NAME> (<EMAIL>) with HAL; with Interfaces; use Interfaces; with Ada.Unchecked_Conversion; -- @summary -- target-independent functions of HIL. package HIL with SPARK_Mode is pragma Preelaborate; --procedure configure_Hardware; subtype Byte is HAL.Byte; -- Unsigned_8 -- Integer_8 type Bit is mod 2**1 with Size => 1; -- Architecture Independent type Unsigned_8_Mask is new Unsigned_8; subtype Unsigned_8_Bit_Index is Natural range 0 .. 7; type Unsigned_16_Mask is new Unsigned_16; type Unsigned_16_Bit_Index is new Natural range 0 .. 15; type Unsigned_32_Mask is new Unsigned_32; type Unsigned_32_Bit_Index is new Natural range 0 .. 31; -- Arrays type Byte_Array is array(Natural range <>) of Byte; type Short_Array is array(Natural range <>) of Unsigned_16; type Word_Array is array(Natural range <>) of Unsigned_32; subtype Byte_Array_2 is Byte_Array(1..2); -- not working (explicit raise in flow_utility.adb) -- type Byte_Array_2 is Byte_Array(1..2); type Byte_Array_4 is array(1..4) of Byte; type Unsigned_8_Array is array(Natural range <>) of Unsigned_8; type Unsigned_16_Array is array(Natural range <>) of Unsigned_16; type Unsigned_32_Array is array(Natural range <>) of Unsigned_32; type Integer_8_Array is array(Natural range <>) of Integer_8; type Integer_16_Array is array(Natural range <>) of Integer_16; type Integer_32_Array is array(Natural range <>) of Integer_32; type Float_Array is array(Natural range <>) of Float; function From_Byte_Array_To_Float is new Ada.Unchecked_Conversion (Source => Byte_Array_4, Target => Float); function From_Float_To_Byte_Array is new Ada.Unchecked_Conversion (Source => Float, Target => Byte_Array_4); -- little endian (lowest byte first) function toBytes(uint : in Unsigned_16) return Byte_Array is (1 => Unsigned_8( uint mod 2**8 ), 2 => Unsigned_8 ( uint / 2**8 ) ); function toBytes( source : in Float) return Byte_Array_4 is (From_Float_To_Byte_Array( source ) ) with Pre => source'Size = 32; -- FAILS (unsigned arg, constrained return) function toBytes_uc(uint : Unsigned_16) return Byte_Array_2 is (1 => Unsigned_8( uint mod 2**8 ), 2 => Unsigned_8 ( uint / 2**8 ) ); function toUnsigned_16( bytes : Byte_Array) return Unsigned_16 is ( Unsigned_16 (bytes (bytes'First )) + Unsigned_16 (bytes (bytes'First + 1)) * 2**8) with Pre => bytes'Length = 2; function toUnsigned_32( bytes : Byte_Array) return Unsigned_32 is ( Unsigned_32 (bytes (bytes'First )) + Unsigned_32 (bytes (bytes'First + 1)) * 2**8 + Unsigned_32 (bytes (bytes'First + 2)) * 2**16 + Unsigned_32 (bytes (bytes'First + 3)) * 2**24) with Pre => bytes'Length = 4; function Bytes_To_Unsigned32 is new Ada.Unchecked_Conversion (Source => Byte_Array_4, Target => Unsigned_32); function Unsigned32_To_Bytes is new Ada.Unchecked_Conversion (Source => Unsigned_32, Target => Byte_Array_4); function From_Byte_To_Integer_8 is new Ada.Unchecked_Conversion (Source => Byte, Target => Integer_8); function From_Byte_Array_To_Integer_32 is new Ada.Unchecked_Conversion (Source => Byte_Array_4, Target => Integer_32); function toInteger_8( value : Byte ) return Integer_8 is ( From_Byte_To_Integer_8( value ) ); function toInteger_32( bytes : Byte_Array) return Integer_32 is (From_Byte_Array_To_Integer_32( Byte_Array_4( bytes ) ) ) with Pre => bytes'Length = 4; function toCharacter( source : Byte ) return Character is ( Character'Val ( source ) ); function toFloat( source : Byte_Array_4 ) return Float is ( From_Byte_Array_To_Float( source ) ); procedure write_Bits( register : in out Unsigned_8; start_index : Unsigned_8_Bit_Index; length : Positive; value : Integer) with Pre => length <= Natural (Unsigned_8_Bit_Index'Last) + 1 - Natural (start_index) and then value < 2**(length-1) + 2**(length-1) - 1; -- e.g. 2^8 = 256, but range is only up to 2^8-1 function read_Bits( register : in Unsigned_8; start_index : Unsigned_8_Bit_Index; length : Positive) return Unsigned_8 with Pre => length <= Natural (Unsigned_8_Bit_Index'Last) + 1 - Natural (start_index), Post => read_Bits'Result < 2**length; -- procedure set_Bit( reg : in out Unsigned_16, bit : Unsigned_16_Bit_ID) is -- mask : Unsigned_16_Mask procedure set_Bits( register : in out Unsigned_16; bit_mask : Unsigned_16_Mask) with Pre => register'Size = bit_mask'Size; procedure clear_Bits( register : in out Unsigned_16; bit_mask : Unsigned_16_Mask) with Pre => register'Size = bit_mask'Size; function isSet( register : Unsigned_16; bit_mask : Unsigned_16_Mask) return Boolean is ( ( register and Unsigned_16( bit_mask ) ) > 0 ); -- procedure Read_Buffer -- (Stream : not null access Streams.Root_Stream_Type'Class; -- Item : out Byte_Array); -- -- procedure Write_Buffer -- (Stream : not null access Streams.Root_Stream_Type'Class; -- Item : in Byte_Array); -- -- for Byte_Array'Read use Read_Buffer; -- for Byte_Array'Write use Write_Buffer; end HIL;
libtool/src/gmp-6.1.2/mpn/sparc64/ultrasparct3/mod_34lsub1.asm
kroggen/aergo
1,602
104854
dnl SPARC v9 mpn_mod_34lsub1 for T3/T4/T5. dnl Copyright 2005, 2013 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb C UltraSPARC T1: - C UltraSPARC T3: 5 C UltraSPARC T4: 1.57 C This is based on the powerpc64/mode64 code. C INPUT PARAMETERS define(`up', `%i0') define(`n', `%i1') ASM_START() REGISTER(%g2,#scratch) REGISTER(%g3,#scratch) PROLOGUE(mpn_mod_34lsub1) save %sp, -176, %sp mov 0, %g1 mov 0, %g3 mov 0, %g4 addcc %g0, 0, %g5 add n, -3, n brlz n, L(lt3) nop add n, -3, n ldx [up+0], %l5 ldx [up+8], %l6 ldx [up+16], %l7 brlz n, L(end) add up, 24, up ALIGN(16) L(top): addxccc(%g1, %l5, %g1) ldx [up+0], %l5 addxccc(%g3, %l6, %g3) ldx [up+8], %l6 addxccc(%g4, %l7, %g4) ldx [up+16], %l7 add n, -3, n brgez n, L(top) add up, 24, up L(end): addxccc( %g1, %l5, %g1) addxccc(%g3, %l6, %g3) addxccc(%g4, %l7, %g4) addxc( %g5, %g0, %g5) L(lt3): cmp n, -2 blt L(2) nop ldx [up+0], %l5 mov 0, %l6 beq L(1) addcc %g1, %l5, %g1 ldx [up+8], %l6 L(1): addxccc(%g3, %l6, %g3) addxccc(%g4, %g0, %g4) addxc( %g5, %g0, %g5) L(2): sllx %g1, 16, %l0 srlx %l0, 16, %l0 C %l0 = %g1 mod 2^48 srlx %g1, 48, %l3 C %l3 = %g1 div 2^48 srl %g3, 0, %g1 sllx %g1, 16, %l4 C %l4 = (%g3 mod 2^32) << 16 srlx %g3, 32, %l5 C %l5 = %g3 div 2^32 sethi %hi(0xffff0000), %g1 andn %g4, %g1, %g1 sllx %g1, 32, %l6 C %l6 = (%g4 mod 2^16) << 32 srlx %g4, 16, %l7 C %l7 = %g4 div 2^16 add %l0, %l3, %l0 add %l4, %l5, %l4 add %l6, %l7, %l6 add %l0, %l4, %l0 add %l6, %g5, %l6 add %l0, %l6, %i0 ret restore EPILOGUE()
oeis/255/A255471.asm
neoneye/loda-programs
11
23598
; A255471: a(n) = A255470(2^n-1). ; 1,6,24,100,396,1596,6364,25500,101916,407836,1631004,6524700,26097436,104392476,417564444,1670268700,6681052956,26724255516,106896934684,427587913500,1710351304476,6841405916956,27365622269724,109462491875100,437849961907996,1751399858816796,7005599412897564,28022397696329500,112089590695839516,448358362962315036,1793433451491346204,7173733806681212700,28694935225293195036,114779740904036091676,459118963610417743644,1836475854453124220700,7345903417789590390556,29383613671204174546716 mov $1,-2 pow $1,$0 mul $1,14 bin $1,2 mov $0,$1 div $0,9 mul $0,6 sub $0,60 div $0,42 add $0,1
user/primes.asm
frank-liang-lbm/xv6-labs-2020
0
14726
<filename>user/primes.asm<gh_stars>0 user/_primes: file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <read_left_first>: @param lpipe:左边的管道符 @param *lfirst:指向读取左边的第一个数据 @return:有数据返回0,无数据返回1 */ int read_left_first(int lpipe[], int *lfirst) { 0: 1101 addi sp,sp,-32 2: ec06 sd ra,24(sp) 4: e822 sd s0,16(sp) 6: e426 sd s1,8(sp) 8: 1000 addi s0,sp,32 a: 84ae mv s1,a1 if (read(lpipe[RD], lfirst, INT_LEN) > 0) c: 4611 li a2,4 e: 4108 lw a0,0(a0) 10: 00000097 auipc ra,0x0 14: 43c080e7 jalr 1084(ra) # 44c <read> 18: 00a04863 bgtz a0,28 <read_left_first+0x28> { printf("prime %d\n", *lfirst); return 0; } return 1; 1c: 4505 li a0,1 } 1e: 60e2 ld ra,24(sp) 20: 6442 ld s0,16(sp) 22: 64a2 ld s1,8(sp) 24: 6105 addi sp,sp,32 26: 8082 ret printf("prime %d\n", *lfirst); 28: 408c lw a1,0(s1) 2a: 00001517 auipc a0,0x1 2e: 92650513 addi a0,a0,-1754 # 950 <malloc+0xe6> 32: 00000097 auipc ra,0x0 36: 77a080e7 jalr 1914(ra) # 7ac <printf> return 0; 3a: 4501 li a0,0 3c: b7cd j 1e <read_left_first+0x1e> 000000000000003e <transmit>: @param lpipe:左边的管道符 @param rpipe:右边的管道符 @param first:左边的第一个数据 */ void transmit(int lpipe[], int rpipe[], int first) { 3e: 7139 addi sp,sp,-64 40: fc06 sd ra,56(sp) 42: f822 sd s0,48(sp) 44: f426 sd s1,40(sp) 46: f04a sd s2,32(sp) 48: ec4e sd s3,24(sp) 4a: 0080 addi s0,sp,64 4c: 84aa mv s1,a0 4e: 89ae mv s3,a1 50: 8932 mv s2,a2 int tmp = 0; 52: fc042623 sw zero,-52(s0) while (read(lpipe[RD], &tmp, INT_LEN) > 0) 56: 4611 li a2,4 58: fcc40593 addi a1,s0,-52 5c: 4088 lw a0,0(s1) 5e: 00000097 auipc ra,0x0 62: 3ee080e7 jalr 1006(ra) # 44c <read> 66: 02a05163 blez a0,88 <transmit+0x4a> { if (tmp % first != 0) 6a: fcc42783 lw a5,-52(s0) 6e: 0327e7bb remw a5,a5,s2 72: d3f5 beqz a5,56 <transmit+0x18> { write(rpipe[WR], &tmp, INT_LEN); 74: 4611 li a2,4 76: fcc40593 addi a1,s0,-52 7a: 0049a503 lw a0,4(s3) 7e: 00000097 auipc ra,0x0 82: 3d6080e7 jalr 982(ra) # 454 <write> 86: bfc1 j 56 <transmit+0x18> } } close(rpipe[WR]); 88: 0049a503 lw a0,4(s3) 8c: 00000097 auipc ra,0x0 90: 3d0080e7 jalr 976(ra) # 45c <close> close(lpipe[RD]); 94: 4088 lw a0,0(s1) 96: 00000097 auipc ra,0x0 9a: 3c6080e7 jalr 966(ra) # 45c <close> } 9e: 70e2 ld ra,56(sp) a0: 7442 ld s0,48(sp) a2: 74a2 ld s1,40(sp) a4: 7902 ld s2,32(sp) a6: 69e2 ld s3,24(sp) a8: 6121 addi sp,sp,64 aa: 8082 ret 00000000000000ac <primes>: /* @funciton:寻找素数 @param:左边的管道符 */ void primes(int lpipe[]) { ac: 7179 addi sp,sp,-48 ae: f406 sd ra,40(sp) b0: f022 sd s0,32(sp) b2: ec26 sd s1,24(sp) b4: 1800 addi s0,sp,48 b6: 84aa mv s1,a0 close(lpipe[WR]); b8: 4148 lw a0,4(a0) ba: 00000097 auipc ra,0x0 be: 3a2080e7 jalr 930(ra) # 45c <close> int p[2]; pipe(p); c2: fd840513 addi a0,s0,-40 c6: 00000097 auipc ra,0x0 ca: 37e080e7 jalr 894(ra) # 444 <pipe> int first_of_left; if (read_left_first(lpipe, &first_of_left) == 0) //左边有数据 ce: fd440593 addi a1,s0,-44 d2: 8526 mv a0,s1 d4: 00000097 auipc ra,0x0 d8: f2c080e7 jalr -212(ra) # 0 <read_left_first> dc: ed1d bnez a0,11a <primes+0x6e> { if (fork() == 0) de: 00000097 auipc ra,0x0 e2: 34e080e7 jalr 846(ra) # 42c <fork> e6: c505 beqz a0,10e <primes+0x62> { primes(p); } transmit(lpipe, p, first_of_left); //将左边的数据传入右边 e8: fd442603 lw a2,-44(s0) ec: fd840593 addi a1,s0,-40 f0: 8526 mv a0,s1 f2: 00000097 auipc ra,0x0 f6: f4c080e7 jalr -180(ra) # 3e <transmit> wait(0); fa: 4501 li a0,0 fc: 00000097 auipc ra,0x0 100: 340080e7 jalr 832(ra) # 43c <wait> exit(0); 104: 4501 li a0,0 106: 00000097 auipc ra,0x0 10a: 32e080e7 jalr 814(ra) # 434 <exit> primes(p); 10e: fd840513 addi a0,s0,-40 112: 00000097 auipc ra,0x0 116: f9a080e7 jalr -102(ra) # ac <primes> } else { close(lpipe[RD]); 11a: 4088 lw a0,0(s1) 11c: 00000097 auipc ra,0x0 120: 340080e7 jalr 832(ra) # 45c <close> close(p[WR]); 124: fdc42503 lw a0,-36(s0) 128: 00000097 auipc ra,0x0 12c: 334080e7 jalr 820(ra) # 45c <close> exit(0); 130: 4501 li a0,0 132: 00000097 auipc ra,0x0 136: 302080e7 jalr 770(ra) # 434 <exit> 000000000000013a <main>: } } int main(int agrc, char *agrv[]) { 13a: 7179 addi sp,sp,-48 13c: f406 sd ra,40(sp) 13e: f022 sd s0,32(sp) 140: ec26 sd s1,24(sp) 142: 1800 addi s0,sp,48 int p[2]; pipe(p); 144: fd840513 addi a0,s0,-40 148: 00000097 auipc ra,0x0 14c: 2fc080e7 jalr 764(ra) # 444 <pipe> for (int i = 2; i <= 35; i++) 150: 4789 li a5,2 152: fcf42a23 sw a5,-44(s0) 156: 02300493 li s1,35 { write(p[WR], &i, INT_LEN); 15a: 4611 li a2,4 15c: fd440593 addi a1,s0,-44 160: fdc42503 lw a0,-36(s0) 164: 00000097 auipc ra,0x0 168: 2f0080e7 jalr 752(ra) # 454 <write> for (int i = 2; i <= 35; i++) 16c: fd442783 lw a5,-44(s0) 170: 2785 addiw a5,a5,1 172: 0007871b sext.w a4,a5 176: fcf42a23 sw a5,-44(s0) 17a: fee4d0e3 bge s1,a4,15a <main+0x20> } if (fork() == 0) 17e: 00000097 auipc ra,0x0 182: 2ae080e7 jalr 686(ra) # 42c <fork> 186: e519 bnez a0,194 <main+0x5a> { primes(p); 188: fd840513 addi a0,s0,-40 18c: 00000097 auipc ra,0x0 190: f20080e7 jalr -224(ra) # ac <primes> } close(p[WR]); 194: fdc42503 lw a0,-36(s0) 198: 00000097 auipc ra,0x0 19c: 2c4080e7 jalr 708(ra) # 45c <close> close(RD); 1a0: 4501 li a0,0 1a2: 00000097 auipc ra,0x0 1a6: 2ba080e7 jalr 698(ra) # 45c <close> wait(0); 1aa: 4501 li a0,0 1ac: 00000097 auipc ra,0x0 1b0: 290080e7 jalr 656(ra) # 43c <wait> exit(0); 1b4: 4501 li a0,0 1b6: 00000097 auipc ra,0x0 1ba: 27e080e7 jalr 638(ra) # 434 <exit> 00000000000001be <strcpy>: #include "kernel/fcntl.h" #include "user/user.h" char* strcpy(char *s, const char *t) { 1be: 1141 addi sp,sp,-16 1c0: e422 sd s0,8(sp) 1c2: 0800 addi s0,sp,16 char *os; os = s; while((*s++ = *t++) != 0) 1c4: 87aa mv a5,a0 1c6: 0585 addi a1,a1,1 1c8: 0785 addi a5,a5,1 1ca: fff5c703 lbu a4,-1(a1) 1ce: fee78fa3 sb a4,-1(a5) 1d2: fb75 bnez a4,1c6 <strcpy+0x8> ; return os; } 1d4: 6422 ld s0,8(sp) 1d6: 0141 addi sp,sp,16 1d8: 8082 ret 00000000000001da <strcmp>: int strcmp(const char *p, const char *q) { 1da: 1141 addi sp,sp,-16 1dc: e422 sd s0,8(sp) 1de: 0800 addi s0,sp,16 while(*p && *p == *q) 1e0: 00054783 lbu a5,0(a0) 1e4: cb91 beqz a5,1f8 <strcmp+0x1e> 1e6: 0005c703 lbu a4,0(a1) 1ea: 00f71763 bne a4,a5,1f8 <strcmp+0x1e> p++, q++; 1ee: 0505 addi a0,a0,1 1f0: 0585 addi a1,a1,1 while(*p && *p == *q) 1f2: 00054783 lbu a5,0(a0) 1f6: fbe5 bnez a5,1e6 <strcmp+0xc> return (uchar)*p - (uchar)*q; 1f8: 0005c503 lbu a0,0(a1) } 1fc: 40a7853b subw a0,a5,a0 200: 6422 ld s0,8(sp) 202: 0141 addi sp,sp,16 204: 8082 ret 0000000000000206 <strlen>: uint strlen(const char *s) { 206: 1141 addi sp,sp,-16 208: e422 sd s0,8(sp) 20a: 0800 addi s0,sp,16 int n; for(n = 0; s[n]; n++) 20c: 00054783 lbu a5,0(a0) 210: cf91 beqz a5,22c <strlen+0x26> 212: 0505 addi a0,a0,1 214: 87aa mv a5,a0 216: 4685 li a3,1 218: 9e89 subw a3,a3,a0 21a: 00f6853b addw a0,a3,a5 21e: 0785 addi a5,a5,1 220: fff7c703 lbu a4,-1(a5) 224: fb7d bnez a4,21a <strlen+0x14> ; return n; } 226: 6422 ld s0,8(sp) 228: 0141 addi sp,sp,16 22a: 8082 ret for(n = 0; s[n]; n++) 22c: 4501 li a0,0 22e: bfe5 j 226 <strlen+0x20> 0000000000000230 <memset>: void* memset(void *dst, int c, uint n) { 230: 1141 addi sp,sp,-16 232: e422 sd s0,8(sp) 234: 0800 addi s0,sp,16 char *cdst = (char *) dst; int i; for(i = 0; i < n; i++){ 236: ce09 beqz a2,250 <memset+0x20> 238: 87aa mv a5,a0 23a: fff6071b addiw a4,a2,-1 23e: 1702 slli a4,a4,0x20 240: 9301 srli a4,a4,0x20 242: 0705 addi a4,a4,1 244: 972a add a4,a4,a0 cdst[i] = c; 246: 00b78023 sb a1,0(a5) for(i = 0; i < n; i++){ 24a: 0785 addi a5,a5,1 24c: fee79de3 bne a5,a4,246 <memset+0x16> } return dst; } 250: 6422 ld s0,8(sp) 252: 0141 addi sp,sp,16 254: 8082 ret 0000000000000256 <strchr>: char* strchr(const char *s, char c) { 256: 1141 addi sp,sp,-16 258: e422 sd s0,8(sp) 25a: 0800 addi s0,sp,16 for(; *s; s++) 25c: 00054783 lbu a5,0(a0) 260: cb99 beqz a5,276 <strchr+0x20> if(*s == c) 262: 00f58763 beq a1,a5,270 <strchr+0x1a> for(; *s; s++) 266: 0505 addi a0,a0,1 268: 00054783 lbu a5,0(a0) 26c: fbfd bnez a5,262 <strchr+0xc> return (char*)s; return 0; 26e: 4501 li a0,0 } 270: 6422 ld s0,8(sp) 272: 0141 addi sp,sp,16 274: 8082 ret return 0; 276: 4501 li a0,0 278: bfe5 j 270 <strchr+0x1a> 000000000000027a <gets>: char* gets(char *buf, int max) { 27a: 711d addi sp,sp,-96 27c: ec86 sd ra,88(sp) 27e: e8a2 sd s0,80(sp) 280: e4a6 sd s1,72(sp) 282: e0ca sd s2,64(sp) 284: fc4e sd s3,56(sp) 286: f852 sd s4,48(sp) 288: f456 sd s5,40(sp) 28a: f05a sd s6,32(sp) 28c: ec5e sd s7,24(sp) 28e: 1080 addi s0,sp,96 290: 8baa mv s7,a0 292: 8a2e mv s4,a1 int i, cc; char c; for(i=0; i+1 < max; ){ 294: 892a mv s2,a0 296: 4481 li s1,0 cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; if(c == '\n' || c == '\r') 298: 4aa9 li s5,10 29a: 4b35 li s6,13 for(i=0; i+1 < max; ){ 29c: 89a6 mv s3,s1 29e: 2485 addiw s1,s1,1 2a0: 0344d863 bge s1,s4,2d0 <gets+0x56> cc = read(0, &c, 1); 2a4: 4605 li a2,1 2a6: faf40593 addi a1,s0,-81 2aa: 4501 li a0,0 2ac: 00000097 auipc ra,0x0 2b0: 1a0080e7 jalr 416(ra) # 44c <read> if(cc < 1) 2b4: 00a05e63 blez a0,2d0 <gets+0x56> buf[i++] = c; 2b8: faf44783 lbu a5,-81(s0) 2bc: 00f90023 sb a5,0(s2) if(c == '\n' || c == '\r') 2c0: 01578763 beq a5,s5,2ce <gets+0x54> 2c4: 0905 addi s2,s2,1 2c6: fd679be3 bne a5,s6,29c <gets+0x22> for(i=0; i+1 < max; ){ 2ca: 89a6 mv s3,s1 2cc: a011 j 2d0 <gets+0x56> 2ce: 89a6 mv s3,s1 break; } buf[i] = '\0'; 2d0: 99de add s3,s3,s7 2d2: 00098023 sb zero,0(s3) return buf; } 2d6: 855e mv a0,s7 2d8: 60e6 ld ra,88(sp) 2da: 6446 ld s0,80(sp) 2dc: 64a6 ld s1,72(sp) 2de: 6906 ld s2,64(sp) 2e0: 79e2 ld s3,56(sp) 2e2: 7a42 ld s4,48(sp) 2e4: 7aa2 ld s5,40(sp) 2e6: 7b02 ld s6,32(sp) 2e8: 6be2 ld s7,24(sp) 2ea: 6125 addi sp,sp,96 2ec: 8082 ret 00000000000002ee <stat>: int stat(const char *n, struct stat *st) { 2ee: 1101 addi sp,sp,-32 2f0: ec06 sd ra,24(sp) 2f2: e822 sd s0,16(sp) 2f4: e426 sd s1,8(sp) 2f6: e04a sd s2,0(sp) 2f8: 1000 addi s0,sp,32 2fa: 892e mv s2,a1 int fd; int r; fd = open(n, O_RDONLY); 2fc: 4581 li a1,0 2fe: 00000097 auipc ra,0x0 302: 176080e7 jalr 374(ra) # 474 <open> if(fd < 0) 306: 02054563 bltz a0,330 <stat+0x42> 30a: 84aa mv s1,a0 return -1; r = fstat(fd, st); 30c: 85ca mv a1,s2 30e: 00000097 auipc ra,0x0 312: 17e080e7 jalr 382(ra) # 48c <fstat> 316: 892a mv s2,a0 close(fd); 318: 8526 mv a0,s1 31a: 00000097 auipc ra,0x0 31e: 142080e7 jalr 322(ra) # 45c <close> return r; } 322: 854a mv a0,s2 324: 60e2 ld ra,24(sp) 326: 6442 ld s0,16(sp) 328: 64a2 ld s1,8(sp) 32a: 6902 ld s2,0(sp) 32c: 6105 addi sp,sp,32 32e: 8082 ret return -1; 330: 597d li s2,-1 332: bfc5 j 322 <stat+0x34> 0000000000000334 <atoi>: int atoi(const char *s) { 334: 1141 addi sp,sp,-16 336: e422 sd s0,8(sp) 338: 0800 addi s0,sp,16 int n; n = 0; while('0' <= *s && *s <= '9') 33a: 00054603 lbu a2,0(a0) 33e: fd06079b addiw a5,a2,-48 342: 0ff7f793 andi a5,a5,255 346: 4725 li a4,9 348: 02f76963 bltu a4,a5,37a <atoi+0x46> 34c: 86aa mv a3,a0 n = 0; 34e: 4501 li a0,0 while('0' <= *s && *s <= '9') 350: 45a5 li a1,9 n = n*10 + *s++ - '0'; 352: 0685 addi a3,a3,1 354: 0025179b slliw a5,a0,0x2 358: 9fa9 addw a5,a5,a0 35a: 0017979b slliw a5,a5,0x1 35e: 9fb1 addw a5,a5,a2 360: fd07851b addiw a0,a5,-48 while('0' <= *s && *s <= '9') 364: 0006c603 lbu a2,0(a3) 368: fd06071b addiw a4,a2,-48 36c: 0ff77713 andi a4,a4,255 370: fee5f1e3 bgeu a1,a4,352 <atoi+0x1e> return n; } 374: 6422 ld s0,8(sp) 376: 0141 addi sp,sp,16 378: 8082 ret n = 0; 37a: 4501 li a0,0 37c: bfe5 j 374 <atoi+0x40> 000000000000037e <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 37e: 1141 addi sp,sp,-16 380: e422 sd s0,8(sp) 382: 0800 addi s0,sp,16 char *dst; const char *src; dst = vdst; src = vsrc; if (src > dst) { 384: 02b57663 bgeu a0,a1,3b0 <memmove+0x32> while(n-- > 0) 388: 02c05163 blez a2,3aa <memmove+0x2c> 38c: fff6079b addiw a5,a2,-1 390: 1782 slli a5,a5,0x20 392: 9381 srli a5,a5,0x20 394: 0785 addi a5,a5,1 396: 97aa add a5,a5,a0 dst = vdst; 398: 872a mv a4,a0 *dst++ = *src++; 39a: 0585 addi a1,a1,1 39c: 0705 addi a4,a4,1 39e: fff5c683 lbu a3,-1(a1) 3a2: fed70fa3 sb a3,-1(a4) while(n-- > 0) 3a6: fee79ae3 bne a5,a4,39a <memmove+0x1c> src += n; while(n-- > 0) *--dst = *--src; } return vdst; } 3aa: 6422 ld s0,8(sp) 3ac: 0141 addi sp,sp,16 3ae: 8082 ret dst += n; 3b0: 00c50733 add a4,a0,a2 src += n; 3b4: 95b2 add a1,a1,a2 while(n-- > 0) 3b6: fec05ae3 blez a2,3aa <memmove+0x2c> 3ba: fff6079b addiw a5,a2,-1 3be: 1782 slli a5,a5,0x20 3c0: 9381 srli a5,a5,0x20 3c2: fff7c793 not a5,a5 3c6: 97ba add a5,a5,a4 *--dst = *--src; 3c8: 15fd addi a1,a1,-1 3ca: 177d addi a4,a4,-1 3cc: 0005c683 lbu a3,0(a1) 3d0: 00d70023 sb a3,0(a4) while(n-- > 0) 3d4: fee79ae3 bne a5,a4,3c8 <memmove+0x4a> 3d8: bfc9 j 3aa <memmove+0x2c> 00000000000003da <memcmp>: int memcmp(const void *s1, const void *s2, uint n) { 3da: 1141 addi sp,sp,-16 3dc: e422 sd s0,8(sp) 3de: 0800 addi s0,sp,16 const char *p1 = s1, *p2 = s2; while (n-- > 0) { 3e0: ca05 beqz a2,410 <memcmp+0x36> 3e2: fff6069b addiw a3,a2,-1 3e6: 1682 slli a3,a3,0x20 3e8: 9281 srli a3,a3,0x20 3ea: 0685 addi a3,a3,1 3ec: 96aa add a3,a3,a0 if (*p1 != *p2) { 3ee: 00054783 lbu a5,0(a0) 3f2: 0005c703 lbu a4,0(a1) 3f6: 00e79863 bne a5,a4,406 <memcmp+0x2c> return *p1 - *p2; } p1++; 3fa: 0505 addi a0,a0,1 p2++; 3fc: 0585 addi a1,a1,1 while (n-- > 0) { 3fe: fed518e3 bne a0,a3,3ee <memcmp+0x14> } return 0; 402: 4501 li a0,0 404: a019 j 40a <memcmp+0x30> return *p1 - *p2; 406: 40e7853b subw a0,a5,a4 } 40a: 6422 ld s0,8(sp) 40c: 0141 addi sp,sp,16 40e: 8082 ret return 0; 410: 4501 li a0,0 412: bfe5 j 40a <memcmp+0x30> 0000000000000414 <memcpy>: void * memcpy(void *dst, const void *src, uint n) { 414: 1141 addi sp,sp,-16 416: e406 sd ra,8(sp) 418: e022 sd s0,0(sp) 41a: 0800 addi s0,sp,16 return memmove(dst, src, n); 41c: 00000097 auipc ra,0x0 420: f62080e7 jalr -158(ra) # 37e <memmove> } 424: 60a2 ld ra,8(sp) 426: 6402 ld s0,0(sp) 428: 0141 addi sp,sp,16 42a: 8082 ret 000000000000042c <fork>: # generated by usys.pl - do not edit #include "kernel/syscall.h" .global fork fork: li a7, SYS_fork 42c: 4885 li a7,1 ecall 42e: 00000073 ecall ret 432: 8082 ret 0000000000000434 <exit>: .global exit exit: li a7, SYS_exit 434: 4889 li a7,2 ecall 436: 00000073 ecall ret 43a: 8082 ret 000000000000043c <wait>: .global wait wait: li a7, SYS_wait 43c: 488d li a7,3 ecall 43e: 00000073 ecall ret 442: 8082 ret 0000000000000444 <pipe>: .global pipe pipe: li a7, SYS_pipe 444: 4891 li a7,4 ecall 446: 00000073 ecall ret 44a: 8082 ret 000000000000044c <read>: .global read read: li a7, SYS_read 44c: 4895 li a7,5 ecall 44e: 00000073 ecall ret 452: 8082 ret 0000000000000454 <write>: .global write write: li a7, SYS_write 454: 48c1 li a7,16 ecall 456: 00000073 ecall ret 45a: 8082 ret 000000000000045c <close>: .global close close: li a7, SYS_close 45c: 48d5 li a7,21 ecall 45e: 00000073 ecall ret 462: 8082 ret 0000000000000464 <kill>: .global kill kill: li a7, SYS_kill 464: 4899 li a7,6 ecall 466: 00000073 ecall ret 46a: 8082 ret 000000000000046c <exec>: .global exec exec: li a7, SYS_exec 46c: 489d li a7,7 ecall 46e: 00000073 ecall ret 472: 8082 ret 0000000000000474 <open>: .global open open: li a7, SYS_open 474: 48bd li a7,15 ecall 476: 00000073 ecall ret 47a: 8082 ret 000000000000047c <mknod>: .global mknod mknod: li a7, SYS_mknod 47c: 48c5 li a7,17 ecall 47e: 00000073 ecall ret 482: 8082 ret 0000000000000484 <unlink>: .global unlink unlink: li a7, SYS_unlink 484: 48c9 li a7,18 ecall 486: 00000073 ecall ret 48a: 8082 ret 000000000000048c <fstat>: .global fstat fstat: li a7, SYS_fstat 48c: 48a1 li a7,8 ecall 48e: 00000073 ecall ret 492: 8082 ret 0000000000000494 <link>: .global link link: li a7, SYS_link 494: 48cd li a7,19 ecall 496: 00000073 ecall ret 49a: 8082 ret 000000000000049c <mkdir>: .global mkdir mkdir: li a7, SYS_mkdir 49c: 48d1 li a7,20 ecall 49e: 00000073 ecall ret 4a2: 8082 ret 00000000000004a4 <chdir>: .global chdir chdir: li a7, SYS_chdir 4a4: 48a5 li a7,9 ecall 4a6: 00000073 ecall ret 4aa: 8082 ret 00000000000004ac <dup>: .global dup dup: li a7, SYS_dup 4ac: 48a9 li a7,10 ecall 4ae: 00000073 ecall ret 4b2: 8082 ret 00000000000004b4 <getpid>: .global getpid getpid: li a7, SYS_getpid 4b4: 48ad li a7,11 ecall 4b6: 00000073 ecall ret 4ba: 8082 ret 00000000000004bc <sbrk>: .global sbrk sbrk: li a7, SYS_sbrk 4bc: 48b1 li a7,12 ecall 4be: 00000073 ecall ret 4c2: 8082 ret 00000000000004c4 <sleep>: .global sleep sleep: li a7, SYS_sleep 4c4: 48b5 li a7,13 ecall 4c6: 00000073 ecall ret 4ca: 8082 ret 00000000000004cc <uptime>: .global uptime uptime: li a7, SYS_uptime 4cc: 48b9 li a7,14 ecall 4ce: 00000073 ecall ret 4d2: 8082 ret 00000000000004d4 <putc>: static char digits[] = "0123456789ABCDEF"; static void putc(int fd, char c) { 4d4: 1101 addi sp,sp,-32 4d6: ec06 sd ra,24(sp) 4d8: e822 sd s0,16(sp) 4da: 1000 addi s0,sp,32 4dc: feb407a3 sb a1,-17(s0) write(fd, &c, 1); 4e0: 4605 li a2,1 4e2: fef40593 addi a1,s0,-17 4e6: 00000097 auipc ra,0x0 4ea: f6e080e7 jalr -146(ra) # 454 <write> } 4ee: 60e2 ld ra,24(sp) 4f0: 6442 ld s0,16(sp) 4f2: 6105 addi sp,sp,32 4f4: 8082 ret 00000000000004f6 <printint>: static void printint(int fd, int xx, int base, int sgn) { 4f6: 7139 addi sp,sp,-64 4f8: fc06 sd ra,56(sp) 4fa: f822 sd s0,48(sp) 4fc: f426 sd s1,40(sp) 4fe: f04a sd s2,32(sp) 500: ec4e sd s3,24(sp) 502: 0080 addi s0,sp,64 504: 84aa mv s1,a0 char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 506: c299 beqz a3,50c <printint+0x16> 508: 0805c863 bltz a1,598 <printint+0xa2> neg = 1; x = -xx; } else { x = xx; 50c: 2581 sext.w a1,a1 neg = 0; 50e: 4881 li a7,0 510: fc040693 addi a3,s0,-64 } i = 0; 514: 4701 li a4,0 do{ buf[i++] = digits[x % base]; 516: 2601 sext.w a2,a2 518: 00000517 auipc a0,0x0 51c: 45050513 addi a0,a0,1104 # 968 <digits> 520: 883a mv a6,a4 522: 2705 addiw a4,a4,1 524: 02c5f7bb remuw a5,a1,a2 528: 1782 slli a5,a5,0x20 52a: 9381 srli a5,a5,0x20 52c: 97aa add a5,a5,a0 52e: 0007c783 lbu a5,0(a5) 532: 00f68023 sb a5,0(a3) }while((x /= base) != 0); 536: 0005879b sext.w a5,a1 53a: 02c5d5bb divuw a1,a1,a2 53e: 0685 addi a3,a3,1 540: fec7f0e3 bgeu a5,a2,520 <printint+0x2a> if(neg) 544: 00088b63 beqz a7,55a <printint+0x64> buf[i++] = '-'; 548: fd040793 addi a5,s0,-48 54c: 973e add a4,a4,a5 54e: 02d00793 li a5,45 552: fef70823 sb a5,-16(a4) 556: 0028071b addiw a4,a6,2 while(--i >= 0) 55a: 02e05863 blez a4,58a <printint+0x94> 55e: fc040793 addi a5,s0,-64 562: 00e78933 add s2,a5,a4 566: fff78993 addi s3,a5,-1 56a: 99ba add s3,s3,a4 56c: 377d addiw a4,a4,-1 56e: 1702 slli a4,a4,0x20 570: 9301 srli a4,a4,0x20 572: 40e989b3 sub s3,s3,a4 putc(fd, buf[i]); 576: fff94583 lbu a1,-1(s2) 57a: 8526 mv a0,s1 57c: 00000097 auipc ra,0x0 580: f58080e7 jalr -168(ra) # 4d4 <putc> while(--i >= 0) 584: 197d addi s2,s2,-1 586: ff3918e3 bne s2,s3,576 <printint+0x80> } 58a: 70e2 ld ra,56(sp) 58c: 7442 ld s0,48(sp) 58e: 74a2 ld s1,40(sp) 590: 7902 ld s2,32(sp) 592: 69e2 ld s3,24(sp) 594: 6121 addi sp,sp,64 596: 8082 ret x = -xx; 598: 40b005bb negw a1,a1 neg = 1; 59c: 4885 li a7,1 x = -xx; 59e: bf8d j 510 <printint+0x1a> 00000000000005a0 <vprintf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void vprintf(int fd, const char *fmt, va_list ap) { 5a0: 7119 addi sp,sp,-128 5a2: fc86 sd ra,120(sp) 5a4: f8a2 sd s0,112(sp) 5a6: f4a6 sd s1,104(sp) 5a8: f0ca sd s2,96(sp) 5aa: ecce sd s3,88(sp) 5ac: e8d2 sd s4,80(sp) 5ae: e4d6 sd s5,72(sp) 5b0: e0da sd s6,64(sp) 5b2: fc5e sd s7,56(sp) 5b4: f862 sd s8,48(sp) 5b6: f466 sd s9,40(sp) 5b8: f06a sd s10,32(sp) 5ba: ec6e sd s11,24(sp) 5bc: 0100 addi s0,sp,128 char *s; int c, i, state; state = 0; for(i = 0; fmt[i]; i++){ 5be: 0005c903 lbu s2,0(a1) 5c2: 18090f63 beqz s2,760 <vprintf+0x1c0> 5c6: 8aaa mv s5,a0 5c8: 8b32 mv s6,a2 5ca: 00158493 addi s1,a1,1 state = 0; 5ce: 4981 li s3,0 if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 5d0: 02500a13 li s4,37 if(c == 'd'){ 5d4: 06400c13 li s8,100 printint(fd, va_arg(ap, int), 10, 1); } else if(c == 'l') { 5d8: 06c00c93 li s9,108 printint(fd, va_arg(ap, uint64), 10, 0); } else if(c == 'x') { 5dc: 07800d13 li s10,120 printint(fd, va_arg(ap, int), 16, 0); } else if(c == 'p') { 5e0: 07000d93 li s11,112 putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]); 5e4: 00000b97 auipc s7,0x0 5e8: 384b8b93 addi s7,s7,900 # 968 <digits> 5ec: a839 j 60a <vprintf+0x6a> putc(fd, c); 5ee: 85ca mv a1,s2 5f0: 8556 mv a0,s5 5f2: 00000097 auipc ra,0x0 5f6: ee2080e7 jalr -286(ra) # 4d4 <putc> 5fa: a019 j 600 <vprintf+0x60> } else if(state == '%'){ 5fc: 01498f63 beq s3,s4,61a <vprintf+0x7a> for(i = 0; fmt[i]; i++){ 600: 0485 addi s1,s1,1 602: fff4c903 lbu s2,-1(s1) 606: 14090d63 beqz s2,760 <vprintf+0x1c0> c = fmt[i] & 0xff; 60a: 0009079b sext.w a5,s2 if(state == 0){ 60e: fe0997e3 bnez s3,5fc <vprintf+0x5c> if(c == '%'){ 612: fd479ee3 bne a5,s4,5ee <vprintf+0x4e> state = '%'; 616: 89be mv s3,a5 618: b7e5 j 600 <vprintf+0x60> if(c == 'd'){ 61a: 05878063 beq a5,s8,65a <vprintf+0xba> } else if(c == 'l') { 61e: 05978c63 beq a5,s9,676 <vprintf+0xd6> } else if(c == 'x') { 622: 07a78863 beq a5,s10,692 <vprintf+0xf2> } else if(c == 'p') { 626: 09b78463 beq a5,s11,6ae <vprintf+0x10e> printptr(fd, va_arg(ap, uint64)); } else if(c == 's'){ 62a: 07300713 li a4,115 62e: 0ce78663 beq a5,a4,6fa <vprintf+0x15a> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 632: 06300713 li a4,99 636: 0ee78e63 beq a5,a4,732 <vprintf+0x192> putc(fd, va_arg(ap, uint)); } else if(c == '%'){ 63a: 11478863 beq a5,s4,74a <vprintf+0x1aa> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 63e: 85d2 mv a1,s4 640: 8556 mv a0,s5 642: 00000097 auipc ra,0x0 646: e92080e7 jalr -366(ra) # 4d4 <putc> putc(fd, c); 64a: 85ca mv a1,s2 64c: 8556 mv a0,s5 64e: 00000097 auipc ra,0x0 652: e86080e7 jalr -378(ra) # 4d4 <putc> } state = 0; 656: 4981 li s3,0 658: b765 j 600 <vprintf+0x60> printint(fd, va_arg(ap, int), 10, 1); 65a: 008b0913 addi s2,s6,8 65e: 4685 li a3,1 660: 4629 li a2,10 662: 000b2583 lw a1,0(s6) 666: 8556 mv a0,s5 668: 00000097 auipc ra,0x0 66c: e8e080e7 jalr -370(ra) # 4f6 <printint> 670: 8b4a mv s6,s2 state = 0; 672: 4981 li s3,0 674: b771 j 600 <vprintf+0x60> printint(fd, va_arg(ap, uint64), 10, 0); 676: 008b0913 addi s2,s6,8 67a: 4681 li a3,0 67c: 4629 li a2,10 67e: 000b2583 lw a1,0(s6) 682: 8556 mv a0,s5 684: 00000097 auipc ra,0x0 688: e72080e7 jalr -398(ra) # 4f6 <printint> 68c: 8b4a mv s6,s2 state = 0; 68e: 4981 li s3,0 690: bf85 j 600 <vprintf+0x60> printint(fd, va_arg(ap, int), 16, 0); 692: 008b0913 addi s2,s6,8 696: 4681 li a3,0 698: 4641 li a2,16 69a: 000b2583 lw a1,0(s6) 69e: 8556 mv a0,s5 6a0: 00000097 auipc ra,0x0 6a4: e56080e7 jalr -426(ra) # 4f6 <printint> 6a8: 8b4a mv s6,s2 state = 0; 6aa: 4981 li s3,0 6ac: bf91 j 600 <vprintf+0x60> printptr(fd, va_arg(ap, uint64)); 6ae: 008b0793 addi a5,s6,8 6b2: f8f43423 sd a5,-120(s0) 6b6: 000b3983 ld s3,0(s6) putc(fd, '0'); 6ba: 03000593 li a1,48 6be: 8556 mv a0,s5 6c0: 00000097 auipc ra,0x0 6c4: e14080e7 jalr -492(ra) # 4d4 <putc> putc(fd, 'x'); 6c8: 85ea mv a1,s10 6ca: 8556 mv a0,s5 6cc: 00000097 auipc ra,0x0 6d0: e08080e7 jalr -504(ra) # 4d4 <putc> 6d4: 4941 li s2,16 putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]); 6d6: 03c9d793 srli a5,s3,0x3c 6da: 97de add a5,a5,s7 6dc: 0007c583 lbu a1,0(a5) 6e0: 8556 mv a0,s5 6e2: 00000097 auipc ra,0x0 6e6: df2080e7 jalr -526(ra) # 4d4 <putc> for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4) 6ea: 0992 slli s3,s3,0x4 6ec: 397d addiw s2,s2,-1 6ee: fe0914e3 bnez s2,6d6 <vprintf+0x136> printptr(fd, va_arg(ap, uint64)); 6f2: f8843b03 ld s6,-120(s0) state = 0; 6f6: 4981 li s3,0 6f8: b721 j 600 <vprintf+0x60> s = va_arg(ap, char*); 6fa: 008b0993 addi s3,s6,8 6fe: 000b3903 ld s2,0(s6) if(s == 0) 702: 02090163 beqz s2,724 <vprintf+0x184> while(*s != 0){ 706: 00094583 lbu a1,0(s2) 70a: c9a1 beqz a1,75a <vprintf+0x1ba> putc(fd, *s); 70c: 8556 mv a0,s5 70e: 00000097 auipc ra,0x0 712: dc6080e7 jalr -570(ra) # 4d4 <putc> s++; 716: 0905 addi s2,s2,1 while(*s != 0){ 718: 00094583 lbu a1,0(s2) 71c: f9e5 bnez a1,70c <vprintf+0x16c> s = va_arg(ap, char*); 71e: 8b4e mv s6,s3 state = 0; 720: 4981 li s3,0 722: bdf9 j 600 <vprintf+0x60> s = "(null)"; 724: 00000917 auipc s2,0x0 728: 23c90913 addi s2,s2,572 # 960 <malloc+0xf6> while(*s != 0){ 72c: 02800593 li a1,40 730: bff1 j 70c <vprintf+0x16c> putc(fd, va_arg(ap, uint)); 732: 008b0913 addi s2,s6,8 736: 000b4583 lbu a1,0(s6) 73a: 8556 mv a0,s5 73c: 00000097 auipc ra,0x0 740: d98080e7 jalr -616(ra) # 4d4 <putc> 744: 8b4a mv s6,s2 state = 0; 746: 4981 li s3,0 748: bd65 j 600 <vprintf+0x60> putc(fd, c); 74a: 85d2 mv a1,s4 74c: 8556 mv a0,s5 74e: 00000097 auipc ra,0x0 752: d86080e7 jalr -634(ra) # 4d4 <putc> state = 0; 756: 4981 li s3,0 758: b565 j 600 <vprintf+0x60> s = va_arg(ap, char*); 75a: 8b4e mv s6,s3 state = 0; 75c: 4981 li s3,0 75e: b54d j 600 <vprintf+0x60> } } } 760: 70e6 ld ra,120(sp) 762: 7446 ld s0,112(sp) 764: 74a6 ld s1,104(sp) 766: 7906 ld s2,96(sp) 768: 69e6 ld s3,88(sp) 76a: 6a46 ld s4,80(sp) 76c: 6aa6 ld s5,72(sp) 76e: 6b06 ld s6,64(sp) 770: 7be2 ld s7,56(sp) 772: 7c42 ld s8,48(sp) 774: 7ca2 ld s9,40(sp) 776: 7d02 ld s10,32(sp) 778: 6de2 ld s11,24(sp) 77a: 6109 addi sp,sp,128 77c: 8082 ret 000000000000077e <fprintf>: void fprintf(int fd, const char *fmt, ...) { 77e: 715d addi sp,sp,-80 780: ec06 sd ra,24(sp) 782: e822 sd s0,16(sp) 784: 1000 addi s0,sp,32 786: e010 sd a2,0(s0) 788: e414 sd a3,8(s0) 78a: e818 sd a4,16(s0) 78c: ec1c sd a5,24(s0) 78e: 03043023 sd a6,32(s0) 792: 03143423 sd a7,40(s0) va_list ap; va_start(ap, fmt); 796: fe843423 sd s0,-24(s0) vprintf(fd, fmt, ap); 79a: 8622 mv a2,s0 79c: 00000097 auipc ra,0x0 7a0: e04080e7 jalr -508(ra) # 5a0 <vprintf> } 7a4: 60e2 ld ra,24(sp) 7a6: 6442 ld s0,16(sp) 7a8: 6161 addi sp,sp,80 7aa: 8082 ret 00000000000007ac <printf>: void printf(const char *fmt, ...) { 7ac: 711d addi sp,sp,-96 7ae: ec06 sd ra,24(sp) 7b0: e822 sd s0,16(sp) 7b2: 1000 addi s0,sp,32 7b4: e40c sd a1,8(s0) 7b6: e810 sd a2,16(s0) 7b8: ec14 sd a3,24(s0) 7ba: f018 sd a4,32(s0) 7bc: f41c sd a5,40(s0) 7be: 03043823 sd a6,48(s0) 7c2: 03143c23 sd a7,56(s0) va_list ap; va_start(ap, fmt); 7c6: 00840613 addi a2,s0,8 7ca: fec43423 sd a2,-24(s0) vprintf(1, fmt, ap); 7ce: 85aa mv a1,a0 7d0: 4505 li a0,1 7d2: 00000097 auipc ra,0x0 7d6: dce080e7 jalr -562(ra) # 5a0 <vprintf> } 7da: 60e2 ld ra,24(sp) 7dc: 6442 ld s0,16(sp) 7de: 6125 addi sp,sp,96 7e0: 8082 ret 00000000000007e2 <free>: static Header base; static Header *freep; void free(void *ap) { 7e2: 1141 addi sp,sp,-16 7e4: e422 sd s0,8(sp) 7e6: 0800 addi s0,sp,16 Header *bp, *p; bp = (Header*)ap - 1; 7e8: ff050693 addi a3,a0,-16 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7ec: 00000797 auipc a5,0x0 7f0: 1947b783 ld a5,404(a5) # 980 <freep> 7f4: a805 j 824 <free+0x42> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 7f6: 4618 lw a4,8(a2) 7f8: 9db9 addw a1,a1,a4 7fa: feb52c23 sw a1,-8(a0) bp->s.ptr = p->s.ptr->s.ptr; 7fe: 6398 ld a4,0(a5) 800: 6318 ld a4,0(a4) 802: fee53823 sd a4,-16(a0) 806: a091 j 84a <free+0x68> } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 808: ff852703 lw a4,-8(a0) 80c: 9e39 addw a2,a2,a4 80e: c790 sw a2,8(a5) p->s.ptr = bp->s.ptr; 810: ff053703 ld a4,-16(a0) 814: e398 sd a4,0(a5) 816: a099 j 85c <free+0x7a> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 818: 6398 ld a4,0(a5) 81a: 00e7e463 bltu a5,a4,822 <free+0x40> 81e: 00e6ea63 bltu a3,a4,832 <free+0x50> { 822: 87ba mv a5,a4 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 824: fed7fae3 bgeu a5,a3,818 <free+0x36> 828: 6398 ld a4,0(a5) 82a: 00e6e463 bltu a3,a4,832 <free+0x50> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 82e: fee7eae3 bltu a5,a4,822 <free+0x40> if(bp + bp->s.size == p->s.ptr){ 832: ff852583 lw a1,-8(a0) 836: 6390 ld a2,0(a5) 838: 02059713 slli a4,a1,0x20 83c: 9301 srli a4,a4,0x20 83e: 0712 slli a4,a4,0x4 840: 9736 add a4,a4,a3 842: fae60ae3 beq a2,a4,7f6 <free+0x14> bp->s.ptr = p->s.ptr; 846: fec53823 sd a2,-16(a0) if(p + p->s.size == bp){ 84a: 4790 lw a2,8(a5) 84c: 02061713 slli a4,a2,0x20 850: 9301 srli a4,a4,0x20 852: 0712 slli a4,a4,0x4 854: 973e add a4,a4,a5 856: fae689e3 beq a3,a4,808 <free+0x26> } else p->s.ptr = bp; 85a: e394 sd a3,0(a5) freep = p; 85c: 00000717 auipc a4,0x0 860: 12f73223 sd a5,292(a4) # 980 <freep> } 864: 6422 ld s0,8(sp) 866: 0141 addi sp,sp,16 868: 8082 ret 000000000000086a <malloc>: return freep; } void* malloc(uint nbytes) { 86a: 7139 addi sp,sp,-64 86c: fc06 sd ra,56(sp) 86e: f822 sd s0,48(sp) 870: f426 sd s1,40(sp) 872: f04a sd s2,32(sp) 874: ec4e sd s3,24(sp) 876: e852 sd s4,16(sp) 878: e456 sd s5,8(sp) 87a: e05a sd s6,0(sp) 87c: 0080 addi s0,sp,64 Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 87e: 02051493 slli s1,a0,0x20 882: 9081 srli s1,s1,0x20 884: 04bd addi s1,s1,15 886: 8091 srli s1,s1,0x4 888: 0014899b addiw s3,s1,1 88c: 0485 addi s1,s1,1 if((prevp = freep) == 0){ 88e: 00000517 auipc a0,0x0 892: 0f253503 ld a0,242(a0) # 980 <freep> 896: c515 beqz a0,8c2 <malloc+0x58> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 898: 611c ld a5,0(a0) if(p->s.size >= nunits){ 89a: 4798 lw a4,8(a5) 89c: 02977f63 bgeu a4,s1,8da <malloc+0x70> 8a0: 8a4e mv s4,s3 8a2: 0009871b sext.w a4,s3 8a6: 6685 lui a3,0x1 8a8: 00d77363 bgeu a4,a3,8ae <malloc+0x44> 8ac: 6a05 lui s4,0x1 8ae: 000a0b1b sext.w s6,s4 p = sbrk(nu * sizeof(Header)); 8b2: 004a1a1b slliw s4,s4,0x4 p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 8b6: 00000917 auipc s2,0x0 8ba: 0ca90913 addi s2,s2,202 # 980 <freep> if(p == (char*)-1) 8be: 5afd li s5,-1 8c0: a88d j 932 <malloc+0xc8> base.s.ptr = freep = prevp = &base; 8c2: 00000797 auipc a5,0x0 8c6: 0c678793 addi a5,a5,198 # 988 <base> 8ca: 00000717 auipc a4,0x0 8ce: 0af73b23 sd a5,182(a4) # 980 <freep> 8d2: e39c sd a5,0(a5) base.s.size = 0; 8d4: 0007a423 sw zero,8(a5) if(p->s.size >= nunits){ 8d8: b7e1 j 8a0 <malloc+0x36> if(p->s.size == nunits) 8da: 02e48b63 beq s1,a4,910 <malloc+0xa6> p->s.size -= nunits; 8de: 4137073b subw a4,a4,s3 8e2: c798 sw a4,8(a5) p += p->s.size; 8e4: 1702 slli a4,a4,0x20 8e6: 9301 srli a4,a4,0x20 8e8: 0712 slli a4,a4,0x4 8ea: 97ba add a5,a5,a4 p->s.size = nunits; 8ec: 0137a423 sw s3,8(a5) freep = prevp; 8f0: 00000717 auipc a4,0x0 8f4: 08a73823 sd a0,144(a4) # 980 <freep> return (void*)(p + 1); 8f8: 01078513 addi a0,a5,16 if((p = morecore(nunits)) == 0) return 0; } } 8fc: 70e2 ld ra,56(sp) 8fe: 7442 ld s0,48(sp) 900: 74a2 ld s1,40(sp) 902: 7902 ld s2,32(sp) 904: 69e2 ld s3,24(sp) 906: 6a42 ld s4,16(sp) 908: 6aa2 ld s5,8(sp) 90a: 6b02 ld s6,0(sp) 90c: 6121 addi sp,sp,64 90e: 8082 ret prevp->s.ptr = p->s.ptr; 910: 6398 ld a4,0(a5) 912: e118 sd a4,0(a0) 914: bff1 j 8f0 <malloc+0x86> hp->s.size = nu; 916: 01652423 sw s6,8(a0) free((void*)(hp + 1)); 91a: 0541 addi a0,a0,16 91c: 00000097 auipc ra,0x0 920: ec6080e7 jalr -314(ra) # 7e2 <free> return freep; 924: 00093503 ld a0,0(s2) if((p = morecore(nunits)) == 0) 928: d971 beqz a0,8fc <malloc+0x92> for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 92a: 611c ld a5,0(a0) if(p->s.size >= nunits){ 92c: 4798 lw a4,8(a5) 92e: fa9776e3 bgeu a4,s1,8da <malloc+0x70> if(p == freep) 932: 00093703 ld a4,0(s2) 936: 853e mv a0,a5 938: fef719e3 bne a4,a5,92a <malloc+0xc0> p = sbrk(nu * sizeof(Header)); 93c: 8552 mv a0,s4 93e: 00000097 auipc ra,0x0 942: b7e080e7 jalr -1154(ra) # 4bc <sbrk> if(p == (char*)-1) 946: fd5518e3 bne a0,s5,916 <malloc+0xac> return 0; 94a: 4501 li a0,0 94c: bf45 j 8fc <malloc+0x92>
testsuite/tests/logging/src/tc_log_prio_and_cat.adb
rocher/Ada_Drivers_Library
192
15884
<reponame>rocher/Ada_Drivers_Library<filename>testsuite/tests/logging/src/tc_log_prio_and_cat.adb<gh_stars>100-1000 with Ada.Text_IO; with Logging; procedure TC_Log_Prio_And_Cat is type Categories is (Debug, Warning, Error); Maximum_Message_Length : constant := 64; package Log is new Logging (Categories => Categories, Priorities => Natural, Default_Category => Debug, Default_Priority => 0, Categories_Enabled_By_Default => True, Prefix_Enabled_By_Default => True, Maximum_Message_Length => Maximum_Message_Length, Maximum_Number_Of_Messages => 6); procedure Pop_And_Print; ------------------- -- Pop_And_Print -- ------------------- procedure Pop_And_Print is Str : String (1 .. Maximum_Message_Length); Length : Natural; Prio : Natural; begin Log.Pop (Str, Length, Prio); if Length /= 0 then Ada.Text_IO.Put_Line ("Prio:" & Prio'Img & " -> " & Str (Str'First .. Str'First + Length - 1)); else Ada.Text_IO.Put_Line ("Pop : The queue is empty"); end if; end Pop_And_Print; begin Ada.Text_IO.Put_Line ("--- Log test begin ---"); -- The priority and category features are already tested separatly so this -- test is just a simple check to see if the two work together. Log.Log_Line (Debug, "Debug, prio 0"); Log.Disable (Debug); Log.Log_Line (Debug, "Debug, should not print"); Log.Enable (Debug); Log.Set_Priority (Debug, 1); Log.Log_Line (Debug, "Debug, prio 1"); Log.Log_Line (Warning, "Warning, prio 0"); Log.Disable (Warning); Log.Log_Line (Warning, "Warning, should not print"); Log.Enable (Warning); Log.Set_Priority (Warning, 2); Log.Log_Line (Warning, "Warning, prio 2"); Log.Log_Line (Error, "Error, prio 0"); Log.Disable (Error); Log.Log_Line (Error, "Error, should not print"); Log.Enable (Error); Log.Set_Priority (Error, 3); Log.Log_Line (Error, "Error, prio 3"); if not Log.Full then Ada.Text_IO.Put_Line ("The queue should be full"); end if; for Cnt in 1 .. 7 loop Pop_And_Print; end loop; if not Log.Empty then Ada.Text_IO.Put_Line ("The queue should be empty"); end if; Ada.Text_IO.Put_Line ("--- Log test end ---"); end TC_Log_Prio_And_Cat;
oeis/159/A159460.asm
neoneye/loda-programs
11
178071
<gh_stars>10-100 ; A159460: Numerator of Hermite(n, 9/11). ; Submitted by <NAME> ; 1,18,82,-7236,-189780,3588408,294225144,85684176,-496875078768,-9109635982560,918220473870624,38573287607466432,-1749983724509205312,-143516534253248214144,2922151180747492056960,538832739303459806545152,-908419478651119648952064,-2102711917198716524623965696,-34111576774406191207442591232,8545404729378297739528027929600,310662315137529026483325537217536,-35767837217715438582615795509348352,-2222606955447800407075344699307788288,150421040149056587686490290704230436864 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 mov $3,$1 mov $1,$2 mul $2,18 mul $3,-1 mul $3,$0 mul $3,242 lpe mov $0,$1
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/pack20_pkg.ads
best08618/asylo
7
21981
<reponame>best08618/asylo<gh_stars>1-10 package Pack20_Pkg is type String_Ptr is access all String; procedure Modify (Fixed : in out String_Ptr); end Pack20_Pkg;
programs/oeis/062/A062068.asm
neoneye/loda
22
20727
<filename>programs/oeis/062/A062068.asm ; A062068: a(n) = d(sigma(n)), where d(k) is the number of divisors function (A000005) and sigma(k) is the sum of divisor function (A000203). ; 1,2,3,2,4,6,4,4,2,6,6,6,4,8,8,2,6,4,6,8,6,9,8,12,2,8,8,8,8,12,6,6,10,8,10,4,4,12,8,12,8,12,6,12,8,12,10,6,4,4,12,6,8,16,12,16,10,12,12,16,4,12,8,2,12,15,6,12,12,15,12,8,4,8,6,12,12,16,10,8,3,12,12,12,12,12,16,18,12,12,10,16,8,15,16,18,6,6,12,4 seq $0,203 ; a(n) = sigma(n), the sum of the divisors of n. Also called sigma_1(n). seq $0,32741 ; a(0) = 0; for n > 0, a(n) = number of proper divisors of n (divisors of n which are less than n). add $0,1
src/stm_board.ads
JCGobbi/Nucleo-STM32H743ZI
0
6937
with System; use System; with STM32.Device; use STM32.Device; with STM32.GPIO; use STM32.GPIO; with STM32.EXTI; use STM32.EXTI; with STM32.Timers; use STM32.Timers; with STM32.ADC; use STM32.ADC; with Ada.Interrupts.Names; use Ada.Interrupts.Names; with Ada.Real_Time; use Ada.Real_Time; package STM_Board is --------------- -- Constants -- --------------- subtype Frequency_Hz is Float; --------------------- -- PWM Full-bridge -- --------------------- PWM_Timer : Timer renames Timer_1; -- Timer for reading sine table values. PWM_Interrupt : Ada.Interrupts.Interrupt_ID renames TIM1_UP_Interrupt; PWM_ISR_Priority : constant Interrupt_Priority := Interrupt_Priority'Last - 3; PWM_A_Channel : Timer_Channel renames Channel_1; PWM_A_H_Pin : GPIO_Point renames PA8; PWM_A_L_Pin : GPIO_Point renames PA7; PWM_A_GPIO_AF : STM32.GPIO_Alternate_Function renames GPIO_AF_TIM1_1; PWM_B_Channel : Timer_Channel renames Channel_3; -- because Channel 2 has two LEDs PWM_B_H_Pin : GPIO_Point renames PA10; PWM_B_L_Pin : GPIO_Point renames PB1; PWM_B_GPIO_AF : STM32.GPIO_Alternate_Function renames GPIO_AF_TIM1_1; PWM_Gate_Power : GPIO_Point renames PA11; -- Output for the FET/IGBT gate drivers. ------------------------------ -- Voltage and Current ADCs -- ------------------------------ Sensor_ADC : constant access Analog_To_Digital_Converter := ADC_1'Access; Sensor_Trigger_Event : External_Events_Regular_Group := Timer6_TRGO_Event; Sensor_Interrupt : Ada.Interrupts.Interrupt_ID renames ADC1_2_Interrupt; Sensor_ISR_Priority : constant Interrupt_Priority := Interrupt_Priority'Last - 2; ADC_Battery_V_Point : constant ADC_Point := (Sensor_ADC, Channel => 10); ADC_Battery_V_Pin : GPIO_Point renames PC0; ADC_Battery_I_Point : constant ADC_Point := (Sensor_ADC, Channel => 11); ADC_Battery_I_Pin : GPIO_Point renames PC1; ADC_Output_V_Point : constant ADC_Point := (Sensor_ADC, Channel => 12); ADC_Output_V_Pin : GPIO_Point renames PC2; --------------- -- ADC Timer -- --------------- -- To syncronize A/D conversion and timers, the ADCs could be triggered -- by any of TIM1, TIM2, TIM3, TIM6, TIM7, TIM15, TIM16 or TIM17 timer. Sensor_Timer : Timer renames Timer_6; ------------------- -- General Timer -- ------------------- General_Timer : Timer renames Timer_3; General_Timer_Interrupt : Ada.Interrupts.Interrupt_ID renames TIM3_Interrupt; General_Timer_ISR_Priority : constant Interrupt_Priority := Interrupt_Priority'Last - 2; -- Channel for reading analog inputs (5 kHz, 200 us) Sensor_Timer_Channel : Timer_Channel renames Channel_4; Sensor_Timer_AF : STM32.GPIO_Alternate_Function renames GPIO_AF_TIM3_2; Sensor_Timer_Point : GPIO_Point renames PC9; -- Point not used because this timer only start an interrupt. ------------------------- -- Other GPIO Channels -- ------------------------- AC_Frequency_Pin : GPIO_Point renames PA0; -- Input for AC frequency select jumper. Button : GPIO_Point renames PC13; -- B1 user button input Button_EXTI_Line : External_Line_Number renames EXTI_Line_13; Button_Interrupt : Ada.Interrupts.Interrupt_ID renames EXTI15_10_Interrupt; Button_ISR_Priority : constant Interrupt_Priority := Interrupt_Priority'Last; Green_LED : GPIO_Point renames PB0; -- LD1 -- Output for OK indication in the nucleo board. Yellow_LED : GPIO_Point renames PE1; -- LD2 -- Output for OK indication in the nucleo board. Red_LED : GPIO_Point renames PB14; -- LD3 -- Output for problem indication in the nucleo board. LCH_LED : GPIO_Point renames Red_LED; -- Last chance handler led. All_LEDs : GPIO_Points := Green_LED & Yellow_LED & Red_LED; Buzzer : GPIO_Point renames PB2; -- Output for buzzer alarm. ------------------------------ -- Procedures and functions -- ------------------------------ procedure Initialize_GPIO; -- Initialize GPIO inputs and outputs. function Read_Input (This : GPIO_Point) return Boolean with Pre => Is_Initialized; -- Read the specified input. procedure Turn_On (This : in out GPIO_Point) with Pre => Is_Initialized and (This /= PWM_Gate_Power); -- Turns ON the specified output. procedure Turn_Off (This : in out GPIO_Point) with Pre => Is_Initialized and (This /= PWM_Gate_Power); -- Turns OFF the specified output. procedure Set_Toggle (This : in out GPIO_Point) with Pre => Is_Initialized and (This /= PWM_Gate_Power); -- Toggle the specified output. procedure All_LEDs_Off with Pre => Is_Initialized; -- Turns OFF all LEDs. procedure All_LEDs_On with Pre => Is_Initialized; -- Turns ON all LEDs. procedure Toggle_LEDs (These : in out GPIO_Points) with Pre => Is_Initialized; -- Toggle the specified LEDs. function Is_Initialized return Boolean; -- Returns True if the board specifics are initialized. private Initialized : Boolean := False; Debounce_Time : constant Time_Span := Milliseconds (300); protected Button_Handler is pragma Interrupt_Priority (Button_ISR_Priority); private Last_Time : Time := Clock; procedure Button_ISR_Handler with Attach_Handler => Button_Interrupt; end Button_Handler; end STM_Board;
source/compiler/compiler-field_descriptors.adb
yannickmoy/protobuf
12
23911
<gh_stars>10-100 -- MIT License -- -- Copyright (c) 2020 <NAME> -- -- Permission is hereby granted, free of charge, to any person obtaining a -- copy of this software and associated documentation files (the "Software"), -- to deal in the Software without restriction, including without limitation -- the rights to use, copy, modify, merge, publish, distribute, sublicense, -- and/or sell copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. package body Compiler.Field_Descriptors is use all type Google.Protobuf.Descriptor.Label; F : Ada_Pretty.Factory renames Compiler.Context.Factory; function "+" (Text : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; function Type_Name (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Is_Option : Boolean; Is_Repeated : Boolean) return Compiler.Context.Ada_Type_Name; function Default (X : Google.Protobuf.Descriptor.PB_Type) return League.Strings.Universal_String; -- Default value for a predefined type function Default (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Is_Option : Boolean; Pkg : League.Strings.Universal_String; Tipe : League.Strings.Universal_String; Fake : Compiler.Context.String_Sets.Set) return Ada_Pretty.Node_Access; -- Default value for a field function Map (X : Google.Protobuf.Descriptor.PB_Type) return Compiler.Context.Ada_Type_Name; function Is_Enum (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto) return Boolean; function Is_Repeated (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Pkg : League.Strings.Universal_String; Tipe : League.Strings.Universal_String; Fake : Compiler.Context.String_Sets.Set) return Boolean; function Is_Packed (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto) return Boolean; function Is_Optional (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto) return Boolean; function Is_Message (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto) return Boolean; function Read_Name (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto) return League.Strings.Universal_String; function Write_Name (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Is_Option : Boolean) return League.Strings.Universal_String; --------------- -- Case_Path -- --------------- function Case_Path (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Pkg : League.Strings.Universal_String; Tipe : League.Strings.Universal_String; Fake : Compiler.Context.String_Sets.Set) return Ada_Pretty.Node_Access is use type League.Strings.Universal_String; My_Name : constant League.Strings.Universal_String := Compiler.Context.To_Ada_Name (Self.Name.Value); Result : Ada_Pretty.Node_Access; begin Result := F.New_Case_Path (F.New_Name (My_Name & "_Kind"), Write_Call (Self, Pkg, Tipe, Fake)); return Result; end Case_Path; --------------- -- Component -- --------------- function Component (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Pkg : League.Strings.Universal_String; Tipe : League.Strings.Universal_String; Fake : Compiler.Context.String_Sets.Set) return Ada_Pretty.Node_Access is use type Compiler.Context.Ada_Type_Name; Result : Ada_Pretty.Node_Access; Name : constant League.Strings.Universal_String := Compiler.Context.To_Ada_Name (Self.Name.Value); Is_Vector : constant Boolean := Is_Repeated (Self, Pkg, Tipe, Fake); Is_Option : constant Boolean := Is_Optional (Self) and not Is_Vector and not Self.Oneof_Index.Is_Set; My_Type : constant League.Strings.Universal_String := Compiler.Context.Relative_Name (+Type_Name (Self, Is_Option, Is_Vector), Pkg); begin Result := F.New_Variable (Name => F.New_Name (Name), Type_Definition => F.New_Selected_Name (My_Type), Initialization => Default (Self, Is_Option, Pkg, Tipe, Fake)); return Result; end Component; ------------- -- Default -- ------------- function Default (X : Google.Protobuf.Descriptor.PB_Type) return League.Strings.Universal_String is use all type Google.Protobuf.Descriptor.PB_Type; begin case X is when TYPE_DOUBLE => return +"0.0"; when TYPE_FLOAT => return +"0.0"; when TYPE_INT64 => return +"0"; when TYPE_UINT64 => return +"0"; when TYPE_INT32 => return +"0"; when TYPE_FIXED64 => return +"0"; when TYPE_FIXED32 => return +"0"; when TYPE_BOOL => return +"False"; when TYPE_STRING => return League.Strings.Empty_Universal_String; when TYPE_GROUP => return League.Strings.Empty_Universal_String; when TYPE_MESSAGE => return League.Strings.Empty_Universal_String; when TYPE_BYTES => return League.Strings.Empty_Universal_String; when TYPE_UINT32 => return +"0"; when TYPE_ENUM => return League.Strings.Empty_Universal_String; when TYPE_SFIXED32 => return +"0"; when TYPE_SFIXED64 => return +"0"; when TYPE_SINT32 => return +"0"; when TYPE_SINT64 => return +"0"; end case; end Default; ------------- -- Default -- ------------- function Default (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Is_Option : Boolean; Pkg : League.Strings.Universal_String; Tipe : League.Strings.Universal_String; Fake : Compiler.Context.String_Sets.Set) return Ada_Pretty.Node_Access is Result : Ada_Pretty.Node_Access; begin if Is_Repeated (Self, Pkg, Tipe, Fake) then null; elsif Is_Option and Compiler.Context.Is_Proto_2 then null; elsif Self.Type_Name.Is_Set then declare Value : constant League.Strings.Universal_String := Self.Type_Name.Value; begin if Compiler.Context.Named_Types.Contains (Value) then declare Full : League.Strings.Universal_String; Element : constant Compiler.Context.Named_Type := Compiler.Context.Named_Types (Value); begin if Element.Is_Enumeration then Full := Element.Ada_Type.Package_Name; Full.Append ("."); Full.Append (Element.Enum.Default); Full := Compiler.Context.Relative_Name (Full, Pkg); Result := F.New_Selected_Name (Full); end if; end; else raise Constraint_Error with "Type not found: " & Value.To_UTF_8_String; end if; end; elsif Self.PB_Type.Is_Set then declare Value : constant League.Strings.Universal_String := Default (Self.PB_Type.Value); begin if not Value.Is_Empty then Result := F.New_Name (Value); end if; end; end if; return Result; end Default; ---------------- -- Dependency -- ---------------- procedure Dependency (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Result : in out Compiler.Context.String_Sets.Set) is Is_Vector : constant Boolean := Is_Repeated (Self, +"", +"", Compiler.Context.String_Sets.Empty_Set); Is_Option : constant Boolean := Is_Optional (Self) and not Is_Vector and not Self.Oneof_Index.Is_Set; My_Pkg : constant League.Strings.Universal_String := Type_Name (Self, Is_Option, Is_Vector).Package_Name; begin if not My_Pkg.Is_Empty then Result.Include (My_Pkg); end if; if Is_Enum (Self) then Result.Include (+"PB_Support.Vectors"); end if; end Dependency; -------------------- -- Get_Used_Types -- -------------------- procedure Get_Used_Types (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Result : in out Compiler.Context.String_Sets.Set) is begin if Self.Type_Name.Is_Set then Result.Include (Self.Type_Name.Value); end if; end Get_Used_Types; ------------- -- Is_Enum -- ------------- function Is_Enum (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto) return Boolean is begin if Self.Type_Name.Is_Set and then Compiler.Context.Named_Types.Contains (Self.Type_Name.Value) then return Compiler.Context.Named_Types (Self.Type_Name.Value).Is_Enumeration; else return False; end if; end Is_Enum; ---------------- -- Is_Message -- ---------------- function Is_Message (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto) return Boolean is begin if Self.Type_Name.Is_Set and then Compiler.Context.Named_Types.Contains (Self.Type_Name.Value) then return not Compiler.Context.Named_Types (Self.Type_Name.Value).Is_Enumeration; else return False; end if; end Is_Message; ----------------- -- Is_Optional -- ----------------- function Is_Optional (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto) return Boolean is begin return not Self.Label.Is_Set or else Self.Label.Value = LABEL_OPTIONAL; end Is_Optional; --------------- -- Is_Packed -- --------------- function Is_Packed (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto) return Boolean is use all type Google.Protobuf.Descriptor.PB_Type; Is_Primitive_Numeric_Vector : constant Boolean := Self.Label.Is_Set and then Self.Label.Value = LABEL_REPEATED and then Self.PB_Type.Is_Set and then Self.PB_Type.Value not in TYPE_BYTES | TYPE_STRING; Packed : constant Boolean := (Self.Options.Is_Set and then Self.Options.Value.Packed.Is_Set and then Self.Options.Value.Packed.Value) -- set explicitly or else -- default in proto3 (Is_Primitive_Numeric_Vector and not Self.Options.Is_Set and not Compiler.Context.Is_Proto_2) or else -- default in proto3 (Is_Primitive_Numeric_Vector and then Self.Options.Is_Set and then not Self.Options.Value.Packed.Is_Set and then not Compiler.Context.Is_Proto_2); begin return Packed; end Is_Packed; ----------------- -- Is_Repeated -- ----------------- function Is_Repeated (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Pkg : League.Strings.Universal_String; Tipe : League.Strings.Universal_String; Fake : Compiler.Context.String_Sets.Set) return Boolean is begin return (Self.Label.Is_Set and then Self.Label.Value = LABEL_REPEATED) or else Fake.Contains (Unique_Id (Self, Pkg, Tipe)); end Is_Repeated; --------- -- Map -- --------- function Map (X : Google.Protobuf.Descriptor.PB_Type) return Compiler.Context.Ada_Type_Name is use all type Google.Protobuf.Descriptor.PB_Type; begin case X is when TYPE_DOUBLE => return (+"Interfaces", +"IEEE_Float_64"); when TYPE_FLOAT => return (+"Interfaces", +"IEEE_Float_32"); when TYPE_INT64 => return (+"Interfaces", +"Integer_64"); when TYPE_UINT64 => return (+"Interfaces", +"Unsigned_64"); when TYPE_INT32 => return (+"Interfaces", +"Integer_32"); when TYPE_FIXED64 => return (+"Interfaces", +"Unsigned_64"); when TYPE_FIXED32 => return (+"Interfaces", +"Unsigned_32"); when TYPE_BOOL => return (+"", +"Boolean"); when TYPE_STRING => return (+"League.Strings", +"Universal_String"); when TYPE_BYTES => return (+"League.Stream_Element_Vectors", +"Stream_Element_Vector"); when TYPE_UINT32 => return (+"Interfaces", +"Unsigned_32"); when TYPE_SFIXED32 => return (+"Interfaces", +"Integer_32"); when TYPE_SFIXED64 => return (+"Interfaces", +"Integer_64"); when TYPE_SINT32 => return (+"Interfaces", +"Integer_32"); when TYPE_SINT64 => return (+"Interfaces", +"Integer_64"); when TYPE_GROUP | TYPE_MESSAGE | TYPE_ENUM => raise Program_Error; end case; end Map; --------------- -- Read_Case -- --------------- function Read_Case (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Pkg : League.Strings.Universal_String; Tipe : League.Strings.Universal_String; Fake : Compiler.Context.String_Sets.Set; Oneof : League.Strings.Universal_String) return Ada_Pretty.Node_Access is use type League.Strings.Universal_String; Is_Vector : constant Boolean := Is_Repeated (Self, Pkg, Tipe, Fake); My_Name : League.Strings.Universal_String := Compiler.Context.To_Ada_Name (Self.Name.Value); Result : Ada_Pretty.Node_Access; Field : Integer; begin Field := Integer (Self.Number.Value); if Self.Oneof_Index.Is_Set then Result := F.New_If (Condition => F.New_List (F.New_Selected_Name ("V.Variant." & Oneof), F.New_Infix (+"/=", F.New_Name (My_Name & "_Kind"))), Then_Path => F.New_Assignment (F.New_Selected_Name (+"V.Variant"), F.New_Parentheses (F.New_List (F.New_Component_Association (F.New_Name (My_Name & "_Kind")), F.New_Component_Association (Choices => F.New_Name (+"others"), Value => F.New_Name (+"<>")))))); My_Name.Prepend ("V.Variant."); elsif not Is_Vector and Is_Optional (Self) and (Is_Message (Self) or Compiler.Context.Is_Proto_2) then My_Name.Prepend ("V."); Result := F.New_If (Condition => F.New_Infix (Operator => +"not", Left => F.New_Selected_Name (My_Name & ".Is_Set")), Then_Path => F.New_Assignment (Left => F.New_Selected_Name (My_Name), Right => F.New_Parentheses (F.New_List (F.New_Component_Association (F.New_Name (+"True")), F.New_Component_Association (Choices => F.New_Name (+"others"), Value => F.New_Name (+"<>")))))); My_Name.Append (".Value"); else My_Name.Prepend ("V."); end if; if Fake.Contains (Unique_Id (Self, Pkg, Tipe)) then Result := F.New_List (Result, F.New_If (Condition => F.New_List (F.New_Selected_Name (My_Name & ".Length"), F.New_Infix (+"=", F.New_Literal (0))), Then_Path => F.New_Statement (F.New_Apply (F.New_Selected_Name (My_Name & ".Append"), F.New_Parentheses (F.New_Name (+"others => <>")))))); My_Name.Append (" (1)"); end if; Result := F.New_List (Result, F.New_Statement (F.New_Apply (Prefix => F.New_Selected_Name (Read_Name (Self)), Arguments => F.New_List ((F.New_Argument_Association (F.New_Name (+"Stream")), F.New_Argument_Association (F.New_Selected_Name (+"Key.Encoding")), F.New_Argument_Association (F.New_Selected_Name (My_Name))))))); Result := F.New_Case_Path (Choice => F.New_Literal (Field), List => Result); return Result; end Read_Case; --------------- -- Read_Name -- --------------- function Read_Name (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto) return League.Strings.Universal_String is use all type Google.Protobuf.Descriptor.PB_Type; use type League.Strings.Universal_String; Result : League.Strings.Universal_String := +"PB_Support.IO.Read"; Is_Vector : constant Boolean := Self.Label.Is_Set and then Self.Label.Value = LABEL_REPEATED; begin if Self.Type_Name.Is_Set and then Compiler.Context.Named_Types.Contains (Self.Type_Name.Value) then Result := Compiler.Context.Named_Types (Self.Type_Name.Value).Ada_Type.Type_Name; Result.Append ("_IO.Read"); elsif Self.PB_Type.Is_Set and then Self.PB_Type.Value in TYPE_INT64 | TYPE_UINT64 | TYPE_INT32 | TYPE_UINT32 then Result.Append ("_Varint"); elsif Self.PB_Type.Is_Set and then Self.PB_Type.Value in TYPE_FIXED64 | TYPE_FIXED32 | TYPE_SFIXED32 | TYPE_SFIXED64 then Result.Append ("_Fixed"); elsif Self.PB_Type.Is_Set and then Self.PB_Type.Value in TYPE_SINT32 | TYPE_SINT64 then Result.Append ("_Zigzag"); end if; if Is_Vector then Result.Append ("_Vector"); end if; return Result; end Read_Name; --------------- -- Type_Name -- --------------- function Type_Name (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Is_Option : Boolean; Is_Repeated : Boolean) return Compiler.Context.Ada_Type_Name is use type League.Strings.Universal_String; use all type Google.Protobuf.Descriptor.PB_Type; Result : Compiler.Context.Ada_Type_Name; begin if Self.Type_Name.Is_Set then -- Message or enum declare Value : constant League.Strings.Universal_String := Self.Type_Name.Value; begin if Compiler.Context.Named_Types.Contains (Value) then declare Element : constant Compiler.Context.Named_Type := Compiler.Context.Named_Types (Value); begin Result := Element.Ada_Type; if Element.Is_Enumeration then if Is_Repeated then Result.Type_Name.Append ("_Vectors.Vector"); elsif Is_Option and Compiler.Context.Is_Proto_2 then Result.Type_Name.Append ("_Vectors.Option"); end if; elsif Is_Repeated then Result.Type_Name.Append ("_Vector"); elsif Is_Option and not Self.Oneof_Index.Is_Set then Result.Type_Name.Prepend ("Optional_"); end if; end; else raise Constraint_Error with "Type not found: " & Value.To_UTF_8_String; end if; end; elsif Is_Option and Compiler.Context.Is_Proto_2 then Result := Map (Self.PB_Type.Value); Result.Package_Name := "PB_Support." & Result.Type_Name & "_Vectors"; Result.Type_Name := +"Option"; elsif not Is_Repeated then Result := Map (Self.PB_Type.Value); elsif Self.PB_Type.Value = TYPE_STRING then Result := (+"League.String_Vectors", +"Universal_String_Vector"); else Result := Map (Self.PB_Type.Value); Result.Package_Name := "PB_Support." & Result.Type_Name & "_Vectors"; Result.Type_Name := +"Vector"; end if; return Result; end Type_Name; --------------- -- Unique_Id -- --------------- function Unique_Id (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Pkg : League.Strings.Universal_String; Tipe : League.Strings.Universal_String) return League.Strings.Universal_String is use type League.Strings.Universal_String; begin return Pkg & "." & Tipe & "." & Self.Name.Value; end Unique_Id; ---------------- -- Write_Call -- ---------------- function Write_Call (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Pkg : League.Strings.Universal_String; Tipe : League.Strings.Universal_String; Fake : Compiler.Context.String_Sets.Set) return Ada_Pretty.Node_Access is use type Compiler.Context.Ada_Type_Name; use type League.Strings.Universal_String; Is_Enum : constant Boolean := Field_Descriptors.Is_Enum (Self); Is_Vector : constant Boolean := Is_Repeated (Self, Pkg, Tipe, Fake); Is_Option : constant Boolean := Is_Optional (Self) and not Is_Vector and not Self.Oneof_Index.Is_Set; My_Name : constant League.Strings.Universal_String := Compiler.Context.To_Ada_Name (Self.Name.Value); Result : Ada_Pretty.Node_Access; Get : League.Strings.Universal_String; Full : League.Strings.Universal_String; Initial : League.Strings.Universal_String; Value : League.Strings.Universal_String := "V." & My_Name; begin if Self.Oneof_Index.Is_Set then Value := "V.Variant." & My_Name; elsif Is_Message (Self) then if Is_Vector then Value.Append (+" (J)"); elsif Is_Option then Value.Append (+".Value"); end if; elsif Is_Option and Compiler.Context.Is_Proto_2 then Value.Append (+".Value"); end if; if Is_Message (Self) then Full := Compiler.Context.Relative_Name (+Type_Name (Self, False, False), Pkg); Result := F.New_List (F.New_Statement (F.New_Apply (F.New_Selected_Name (+"WS.Write_Key"), F.New_Argument_Association (F.New_Parentheses (F.New_List (F.New_Argument_Association (F.New_Literal (Integer (Self.Number.Value))), F.New_Argument_Association (F.New_Selected_Name (+"PB_Support.Length_Delimited"))))))), F.New_Statement (F.New_Apply (F.New_Selected_Name (Full & "'Write"), F.New_List (F.New_Name (+"Stream"), F.New_Selected_Name (Value))))); if Is_Vector then Result := F.New_For (F.New_Name (+"J"), F.New_Name (+"1 .. V." & My_Name & ".Length"), Result); end if; elsif Is_Enum then Get := Compiler.Context.Named_Types (Self.Type_Name.Value).Ada_Type.Type_Name; Result := F.New_List ((F.New_Argument_Association (F.New_Name (+"WS")), F.New_Argument_Association (F.New_Literal (Integer (Self.Number.Value))), F.New_Argument_Association (F.New_Selected_Name (Value)))); if Is_Option and not Compiler.Context.Is_Proto_2 then Result := F.New_Apply (F.New_Selected_Name (Get & "_IO.Write_Option"), F.New_List (Result, Default (Self, False, Pkg, Tipe, Fake))); elsif Is_Packed (Self) then Result := F.New_Apply (F.New_Selected_Name (Get & "_IO.Write_Packed"), Result); else Result := F.New_Apply (F.New_Selected_Name (Get & "_IO.Write"), Result); end if; Result := F.New_Statement (Result); else Result := F.New_List (F.New_Argument_Association (F.New_Literal (Integer (Self.Number.Value))), F.New_Argument_Association (F.New_Selected_Name (Value))); if Is_Option and not Compiler.Context.Is_Proto_2 then Initial := Default (Self.PB_Type.Value); if Initial.Is_Empty then Result := F.New_Apply (F.New_Selected_Name ("WS." & Write_Name (Self, Is_Option)), Result); else Result := F.New_Apply (F.New_Selected_Name ("WS." & Write_Name (Self, Is_Option)), F.New_List (Result, F.New_Name (Initial))); end if; else Result := F.New_Apply (F.New_Selected_Name ("WS." & Write_Name (Self, Is_Option)), Result); end if; Result := F.New_Statement (Result); end if; if Is_Option and (Is_Message (Self) or Compiler.Context.Is_Proto_2) and not Self.Oneof_Index.Is_Set then Result := F.New_If (F.New_Selected_Name ("V." & My_Name & ".Is_Set"), Result); end if; return Result; end Write_Call; ---------------- -- Write_Name -- ---------------- function Write_Name (Self : Google.Protobuf.Descriptor.Field_Descriptor_Proto; Is_Option : Boolean) return League.Strings.Universal_String is use all type Google.Protobuf.Descriptor.PB_Type; Result : League.Strings.Universal_String := +"Write"; Packed : constant Boolean := Is_Packed (Self); begin if Self.PB_Type.Is_Set and then Self.PB_Type.Value in TYPE_INT64 | TYPE_UINT64 | TYPE_INT32 | TYPE_UINT32 then Result.Append ("_Varint"); elsif Self.PB_Type.Is_Set and then Self.PB_Type.Value in TYPE_FIXED64 | TYPE_FIXED32 | TYPE_SFIXED32 | TYPE_SFIXED64 then Result.Append ("_Fixed"); elsif Self.PB_Type.Is_Set and then Self.PB_Type.Value in TYPE_SINT32 | TYPE_SINT64 then Result.Append ("_Zigzag"); end if; if Is_Option and not Compiler.Context.Is_Proto_2 then Result.Append ("_Option"); elsif Packed then Result.Append ("_Packed"); end if; return Result; end Write_Name; end Compiler.Field_Descriptors;
programs/oeis/224/A224456.asm
neoneye/loda
22
170879
; A224456: The Wiener index of the cyclic phenylene with n hexagons (n>=3). ; 459,1008,1845,3024,4599,6624,9153,12240,15939,20304,25389,31248,37935,45504,54009,63504,74043,85680,98469,112464,127719,144288,162225,181584,202419,224784,248733,274320,301599,330624,361449,394128,428715,465264,503829,544464,587223,632160 mov $1,$0 add $0,1 mov $2,$1 add $2,5 mul $0,$2 add $2,2 mul $0,$2 add $0,16 mul $0,9
programs/oeis/096/A096316.asm
neoneye/loda
22
92478
; A096316: Given the number wheel 0,1,2,3,4,5,6,7,8,9 then starting with 2, the next number is a prime p number of positions from the previous number found, for p=2,3,... ; 4,7,2,9,0,3,0,9,2,1,2,9,0,3,0,3,2,3,0,1,4,3,6,5,2,3,6,3,2,5,2,3,0,9,8,9,6,9,6,9,8,9,0,3,0,9,0,3,0,9,2,1,2,3,0,3,2,3,0,1,4,7,4,5,8,5,6,3,0,9,2,1,8,1,0,3,2,9,0,9,8,9,0,3,2,5,4,1,2,5,2,1,8,9,8,1,0,1,4,5 mov $1,$0 seq $1,101301 ; The sum of the first n primes, minus n. add $0,$1 add $0,3 mod $0,10
pl0-antlr4/grammar/com/mark/grammar/PLParser.g4
M4rk9696/animated-octo-barnacle
1
4185
parser grammar PLParser; @header { package com.mark.grammar; } options { tokenVocab=PLLexer; } program : block DOT ; block : consts? vars? procedure* statement ; consts : CONST ID EQUAL NUMBER (COMMA ID EQUAL NUMBER)* COLON ; vars : VAR ID (COMMA ID)* COLON ; procedure : PROCEDURE ID COLON block COLON ; statement : ID ASSIGNMENT expression #assignmentStmt | CALL ID #callStmt | QUESTION ID #questionStmt | WRITE expression #writeStmt | BEGIN statement (COLON statement)* END #beginStmt | IF condition THEN statement #ifStmt | WHILE condition DO statement #whileStmt ; condition : ODD expression // Not operator | expression opr = ( EQUAL | NOTEQUAL | LESSTHAN | LESSTHANEQUAL | GREATORTHAN | GREATORTHANEQUAL ) expression ; expression : unary=(PLUS | MINUS)? term (addOpr term)* ; term : factor (mulOpr factor)* ; addOpr : PLUS | MINUS ; mulOpr : STAR | DIV ; factor : ID #variableFactor | NUMBER #numberFactor | OBRACKET expression CBRACKET #nestedFactor ;
test/Fail/IUnivNotFibrant.agda
cruhland/agda
1,989
16659
<reponame>cruhland/agda<gh_stars>1000+ open import Agda.Primitive open import Agda.Primitive.Cubical record Wrap : Set (lsuc lzero) where field A : IUniv
echo.asm
vishal-prabhu/xv6-lottery-scheduling
0
94755
<filename>echo.asm _echo: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp 6: 83 ec 20 sub $0x20,%esp int i; for(i = 1; i < argc; i++) 9: c7 44 24 1c 01 00 00 movl $0x1,0x1c(%esp) 10: 00 11: eb 4b jmp 5e <main+0x5e> printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n"); 13: 8b 44 24 1c mov 0x1c(%esp),%eax 17: 83 c0 01 add $0x1,%eax 1a: 3b 45 08 cmp 0x8(%ebp),%eax 1d: 7d 07 jge 26 <main+0x26> 1f: b8 df 08 00 00 mov $0x8df,%eax 24: eb 05 jmp 2b <main+0x2b> 26: b8 e1 08 00 00 mov $0x8e1,%eax 2b: 8b 54 24 1c mov 0x1c(%esp),%edx 2f: 8d 0c 95 00 00 00 00 lea 0x0(,%edx,4),%ecx 36: 8b 55 0c mov 0xc(%ebp),%edx 39: 01 ca add %ecx,%edx 3b: 8b 12 mov (%edx),%edx 3d: 89 44 24 0c mov %eax,0xc(%esp) 41: 89 54 24 08 mov %edx,0x8(%esp) 45: c7 44 24 04 e3 08 00 movl $0x8e3,0x4(%esp) 4c: 00 4d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 54: e8 7c 04 00 00 call 4d5 <printf> int main(int argc, char *argv[]) { int i; for(i = 1; i < argc; i++) 59: 83 44 24 1c 01 addl $0x1,0x1c(%esp) 5e: 8b 44 24 1c mov 0x1c(%esp),%eax 62: 3b 45 08 cmp 0x8(%ebp),%eax 65: 7c ac jl 13 <main+0x13> printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n"); exit(); 67: e8 68 02 00 00 call 2d4 <exit> 0000006c <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 6c: 55 push %ebp 6d: 89 e5 mov %esp,%ebp 6f: 57 push %edi 70: 53 push %ebx asm volatile("cld; rep stosb" : 71: 8b 4d 08 mov 0x8(%ebp),%ecx 74: 8b 55 10 mov 0x10(%ebp),%edx 77: 8b 45 0c mov 0xc(%ebp),%eax 7a: 89 cb mov %ecx,%ebx 7c: 89 df mov %ebx,%edi 7e: 89 d1 mov %edx,%ecx 80: fc cld 81: f3 aa rep stos %al,%es:(%edi) 83: 89 ca mov %ecx,%edx 85: 89 fb mov %edi,%ebx 87: 89 5d 08 mov %ebx,0x8(%ebp) 8a: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 8d: 5b pop %ebx 8e: 5f pop %edi 8f: 5d pop %ebp 90: c3 ret 00000091 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 91: 55 push %ebp 92: 89 e5 mov %esp,%ebp 94: 83 ec 10 sub $0x10,%esp char *os; os = s; 97: 8b 45 08 mov 0x8(%ebp),%eax 9a: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 9d: 90 nop 9e: 8b 45 08 mov 0x8(%ebp),%eax a1: 8d 50 01 lea 0x1(%eax),%edx a4: 89 55 08 mov %edx,0x8(%ebp) a7: 8b 55 0c mov 0xc(%ebp),%edx aa: 8d 4a 01 lea 0x1(%edx),%ecx ad: 89 4d 0c mov %ecx,0xc(%ebp) b0: 0f b6 12 movzbl (%edx),%edx b3: 88 10 mov %dl,(%eax) b5: 0f b6 00 movzbl (%eax),%eax b8: 84 c0 test %al,%al ba: 75 e2 jne 9e <strcpy+0xd> ; return os; bc: 8b 45 fc mov -0x4(%ebp),%eax } bf: c9 leave c0: c3 ret 000000c1 <strcmp>: int strcmp(const char *p, const char *q) { c1: 55 push %ebp c2: 89 e5 mov %esp,%ebp while(*p && *p == *q) c4: eb 08 jmp ce <strcmp+0xd> p++, q++; c6: 83 45 08 01 addl $0x1,0x8(%ebp) ca: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) ce: 8b 45 08 mov 0x8(%ebp),%eax d1: 0f b6 00 movzbl (%eax),%eax d4: 84 c0 test %al,%al d6: 74 10 je e8 <strcmp+0x27> d8: 8b 45 08 mov 0x8(%ebp),%eax db: 0f b6 10 movzbl (%eax),%edx de: 8b 45 0c mov 0xc(%ebp),%eax e1: 0f b6 00 movzbl (%eax),%eax e4: 38 c2 cmp %al,%dl e6: 74 de je c6 <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; e8: 8b 45 08 mov 0x8(%ebp),%eax eb: 0f b6 00 movzbl (%eax),%eax ee: 0f b6 d0 movzbl %al,%edx f1: 8b 45 0c mov 0xc(%ebp),%eax f4: 0f b6 00 movzbl (%eax),%eax f7: 0f b6 c0 movzbl %al,%eax fa: 29 c2 sub %eax,%edx fc: 89 d0 mov %edx,%eax } fe: 5d pop %ebp ff: c3 ret 00000100 <strlen>: uint strlen(char *s) { 100: 55 push %ebp 101: 89 e5 mov %esp,%ebp 103: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 106: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 10d: eb 04 jmp 113 <strlen+0x13> 10f: 83 45 fc 01 addl $0x1,-0x4(%ebp) 113: 8b 55 fc mov -0x4(%ebp),%edx 116: 8b 45 08 mov 0x8(%ebp),%eax 119: 01 d0 add %edx,%eax 11b: 0f b6 00 movzbl (%eax),%eax 11e: 84 c0 test %al,%al 120: 75 ed jne 10f <strlen+0xf> ; return n; 122: 8b 45 fc mov -0x4(%ebp),%eax } 125: c9 leave 126: c3 ret 00000127 <memset>: void* memset(void *dst, int c, uint n) { 127: 55 push %ebp 128: 89 e5 mov %esp,%ebp 12a: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 12d: 8b 45 10 mov 0x10(%ebp),%eax 130: 89 44 24 08 mov %eax,0x8(%esp) 134: 8b 45 0c mov 0xc(%ebp),%eax 137: 89 44 24 04 mov %eax,0x4(%esp) 13b: 8b 45 08 mov 0x8(%ebp),%eax 13e: 89 04 24 mov %eax,(%esp) 141: e8 26 ff ff ff call 6c <stosb> return dst; 146: 8b 45 08 mov 0x8(%ebp),%eax } 149: c9 leave 14a: c3 ret 0000014b <strchr>: char* strchr(const char *s, char c) { 14b: 55 push %ebp 14c: 89 e5 mov %esp,%ebp 14e: 83 ec 04 sub $0x4,%esp 151: 8b 45 0c mov 0xc(%ebp),%eax 154: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 157: eb 14 jmp 16d <strchr+0x22> if(*s == c) 159: 8b 45 08 mov 0x8(%ebp),%eax 15c: 0f b6 00 movzbl (%eax),%eax 15f: 3a 45 fc cmp -0x4(%ebp),%al 162: 75 05 jne 169 <strchr+0x1e> return (char*)s; 164: 8b 45 08 mov 0x8(%ebp),%eax 167: eb 13 jmp 17c <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 169: 83 45 08 01 addl $0x1,0x8(%ebp) 16d: 8b 45 08 mov 0x8(%ebp),%eax 170: 0f b6 00 movzbl (%eax),%eax 173: 84 c0 test %al,%al 175: 75 e2 jne 159 <strchr+0xe> if(*s == c) return (char*)s; return 0; 177: b8 00 00 00 00 mov $0x0,%eax } 17c: c9 leave 17d: c3 ret 0000017e <gets>: char* gets(char *buf, int max) { 17e: 55 push %ebp 17f: 89 e5 mov %esp,%ebp 181: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 184: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 18b: eb 4c jmp 1d9 <gets+0x5b> cc = read(0, &c, 1); 18d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 194: 00 195: 8d 45 ef lea -0x11(%ebp),%eax 198: 89 44 24 04 mov %eax,0x4(%esp) 19c: c7 04 24 00 00 00 00 movl $0x0,(%esp) 1a3: e8 44 01 00 00 call 2ec <read> 1a8: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 1ab: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 1af: 7f 02 jg 1b3 <gets+0x35> break; 1b1: eb 31 jmp 1e4 <gets+0x66> buf[i++] = c; 1b3: 8b 45 f4 mov -0xc(%ebp),%eax 1b6: 8d 50 01 lea 0x1(%eax),%edx 1b9: 89 55 f4 mov %edx,-0xc(%ebp) 1bc: 89 c2 mov %eax,%edx 1be: 8b 45 08 mov 0x8(%ebp),%eax 1c1: 01 c2 add %eax,%edx 1c3: 0f b6 45 ef movzbl -0x11(%ebp),%eax 1c7: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 1c9: 0f b6 45 ef movzbl -0x11(%ebp),%eax 1cd: 3c 0a cmp $0xa,%al 1cf: 74 13 je 1e4 <gets+0x66> 1d1: 0f b6 45 ef movzbl -0x11(%ebp),%eax 1d5: 3c 0d cmp $0xd,%al 1d7: 74 0b je 1e4 <gets+0x66> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1d9: 8b 45 f4 mov -0xc(%ebp),%eax 1dc: 83 c0 01 add $0x1,%eax 1df: 3b 45 0c cmp 0xc(%ebp),%eax 1e2: 7c a9 jl 18d <gets+0xf> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1e4: 8b 55 f4 mov -0xc(%ebp),%edx 1e7: 8b 45 08 mov 0x8(%ebp),%eax 1ea: 01 d0 add %edx,%eax 1ec: c6 00 00 movb $0x0,(%eax) return buf; 1ef: 8b 45 08 mov 0x8(%ebp),%eax } 1f2: c9 leave 1f3: c3 ret 000001f4 <stat>: int stat(char *n, struct stat *st) { 1f4: 55 push %ebp 1f5: 89 e5 mov %esp,%ebp 1f7: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 1fa: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 201: 00 202: 8b 45 08 mov 0x8(%ebp),%eax 205: 89 04 24 mov %eax,(%esp) 208: e8 07 01 00 00 call 314 <open> 20d: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 210: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 214: 79 07 jns 21d <stat+0x29> return -1; 216: b8 ff ff ff ff mov $0xffffffff,%eax 21b: eb 23 jmp 240 <stat+0x4c> r = fstat(fd, st); 21d: 8b 45 0c mov 0xc(%ebp),%eax 220: 89 44 24 04 mov %eax,0x4(%esp) 224: 8b 45 f4 mov -0xc(%ebp),%eax 227: 89 04 24 mov %eax,(%esp) 22a: e8 fd 00 00 00 call 32c <fstat> 22f: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 232: 8b 45 f4 mov -0xc(%ebp),%eax 235: 89 04 24 mov %eax,(%esp) 238: e8 bf 00 00 00 call 2fc <close> return r; 23d: 8b 45 f0 mov -0x10(%ebp),%eax } 240: c9 leave 241: c3 ret 00000242 <atoi>: int atoi(const char *s) { 242: 55 push %ebp 243: 89 e5 mov %esp,%ebp 245: 83 ec 10 sub $0x10,%esp int n; n = 0; 248: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 24f: eb 25 jmp 276 <atoi+0x34> n = n*10 + *s++ - '0'; 251: 8b 55 fc mov -0x4(%ebp),%edx 254: 89 d0 mov %edx,%eax 256: c1 e0 02 shl $0x2,%eax 259: 01 d0 add %edx,%eax 25b: 01 c0 add %eax,%eax 25d: 89 c1 mov %eax,%ecx 25f: 8b 45 08 mov 0x8(%ebp),%eax 262: 8d 50 01 lea 0x1(%eax),%edx 265: 89 55 08 mov %edx,0x8(%ebp) 268: 0f b6 00 movzbl (%eax),%eax 26b: 0f be c0 movsbl %al,%eax 26e: 01 c8 add %ecx,%eax 270: 83 e8 30 sub $0x30,%eax 273: 89 45 fc mov %eax,-0x4(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 276: 8b 45 08 mov 0x8(%ebp),%eax 279: 0f b6 00 movzbl (%eax),%eax 27c: 3c 2f cmp $0x2f,%al 27e: 7e 0a jle 28a <atoi+0x48> 280: 8b 45 08 mov 0x8(%ebp),%eax 283: 0f b6 00 movzbl (%eax),%eax 286: 3c 39 cmp $0x39,%al 288: 7e c7 jle 251 <atoi+0xf> n = n*10 + *s++ - '0'; return n; 28a: 8b 45 fc mov -0x4(%ebp),%eax } 28d: c9 leave 28e: c3 ret 0000028f <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 28f: 55 push %ebp 290: 89 e5 mov %esp,%ebp 292: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 295: 8b 45 08 mov 0x8(%ebp),%eax 298: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 29b: 8b 45 0c mov 0xc(%ebp),%eax 29e: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 2a1: eb 17 jmp 2ba <memmove+0x2b> *dst++ = *src++; 2a3: 8b 45 fc mov -0x4(%ebp),%eax 2a6: 8d 50 01 lea 0x1(%eax),%edx 2a9: 89 55 fc mov %edx,-0x4(%ebp) 2ac: 8b 55 f8 mov -0x8(%ebp),%edx 2af: 8d 4a 01 lea 0x1(%edx),%ecx 2b2: 89 4d f8 mov %ecx,-0x8(%ebp) 2b5: 0f b6 12 movzbl (%edx),%edx 2b8: 88 10 mov %dl,(%eax) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 2ba: 8b 45 10 mov 0x10(%ebp),%eax 2bd: 8d 50 ff lea -0x1(%eax),%edx 2c0: 89 55 10 mov %edx,0x10(%ebp) 2c3: 85 c0 test %eax,%eax 2c5: 7f dc jg 2a3 <memmove+0x14> *dst++ = *src++; return vdst; 2c7: 8b 45 08 mov 0x8(%ebp),%eax } 2ca: c9 leave 2cb: c3 ret 000002cc <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 2cc: b8 01 00 00 00 mov $0x1,%eax 2d1: cd 40 int $0x40 2d3: c3 ret 000002d4 <exit>: SYSCALL(exit) 2d4: b8 02 00 00 00 mov $0x2,%eax 2d9: cd 40 int $0x40 2db: c3 ret 000002dc <wait>: SYSCALL(wait) 2dc: b8 03 00 00 00 mov $0x3,%eax 2e1: cd 40 int $0x40 2e3: c3 ret 000002e4 <pipe>: SYSCALL(pipe) 2e4: b8 04 00 00 00 mov $0x4,%eax 2e9: cd 40 int $0x40 2eb: c3 ret 000002ec <read>: SYSCALL(read) 2ec: b8 05 00 00 00 mov $0x5,%eax 2f1: cd 40 int $0x40 2f3: c3 ret 000002f4 <write>: SYSCALL(write) 2f4: b8 10 00 00 00 mov $0x10,%eax 2f9: cd 40 int $0x40 2fb: c3 ret 000002fc <close>: SYSCALL(close) 2fc: b8 15 00 00 00 mov $0x15,%eax 301: cd 40 int $0x40 303: c3 ret 00000304 <kill>: SYSCALL(kill) 304: b8 06 00 00 00 mov $0x6,%eax 309: cd 40 int $0x40 30b: c3 ret 0000030c <exec>: SYSCALL(exec) 30c: b8 07 00 00 00 mov $0x7,%eax 311: cd 40 int $0x40 313: c3 ret 00000314 <open>: SYSCALL(open) 314: b8 0f 00 00 00 mov $0xf,%eax 319: cd 40 int $0x40 31b: c3 ret 0000031c <mknod>: SYSCALL(mknod) 31c: b8 11 00 00 00 mov $0x11,%eax 321: cd 40 int $0x40 323: c3 ret 00000324 <unlink>: SYSCALL(unlink) 324: b8 12 00 00 00 mov $0x12,%eax 329: cd 40 int $0x40 32b: c3 ret 0000032c <fstat>: SYSCALL(fstat) 32c: b8 08 00 00 00 mov $0x8,%eax 331: cd 40 int $0x40 333: c3 ret 00000334 <link>: SYSCALL(link) 334: b8 13 00 00 00 mov $0x13,%eax 339: cd 40 int $0x40 33b: c3 ret 0000033c <mkdir>: SYSCALL(mkdir) 33c: b8 14 00 00 00 mov $0x14,%eax 341: cd 40 int $0x40 343: c3 ret 00000344 <chdir>: SYSCALL(chdir) 344: b8 09 00 00 00 mov $0x9,%eax 349: cd 40 int $0x40 34b: c3 ret 0000034c <dup>: SYSCALL(dup) 34c: b8 0a 00 00 00 mov $0xa,%eax 351: cd 40 int $0x40 353: c3 ret 00000354 <getpid>: SYSCALL(getpid) 354: b8 0b 00 00 00 mov $0xb,%eax 359: cd 40 int $0x40 35b: c3 ret 0000035c <sbrk>: SYSCALL(sbrk) 35c: b8 0c 00 00 00 mov $0xc,%eax 361: cd 40 int $0x40 363: c3 ret 00000364 <sleep>: SYSCALL(sleep) 364: b8 0d 00 00 00 mov $0xd,%eax 369: cd 40 int $0x40 36b: c3 ret 0000036c <uptime>: SYSCALL(uptime) 36c: b8 0e 00 00 00 mov $0xe,%eax 371: cd 40 int $0x40 373: c3 ret 00000374 <gettime>: SYSCALL(gettime) 374: b8 16 00 00 00 mov $0x16,%eax 379: cd 40 int $0x40 37b: c3 ret 0000037c <settickets>: SYSCALL(settickets) 37c: b8 17 00 00 00 mov $0x17,%eax 381: cd 40 int $0x40 383: c3 ret 00000384 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 384: 55 push %ebp 385: 89 e5 mov %esp,%ebp 387: 83 ec 18 sub $0x18,%esp 38a: 8b 45 0c mov 0xc(%ebp),%eax 38d: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 390: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 397: 00 398: 8d 45 f4 lea -0xc(%ebp),%eax 39b: 89 44 24 04 mov %eax,0x4(%esp) 39f: 8b 45 08 mov 0x8(%ebp),%eax 3a2: 89 04 24 mov %eax,(%esp) 3a5: e8 4a ff ff ff call 2f4 <write> } 3aa: c9 leave 3ab: c3 ret 000003ac <printint>: static void printint(int fd, int xx, int base, int sgn) { 3ac: 55 push %ebp 3ad: 89 e5 mov %esp,%ebp 3af: 56 push %esi 3b0: 53 push %ebx 3b1: 83 ec 30 sub $0x30,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 3b4: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 3bb: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 3bf: 74 17 je 3d8 <printint+0x2c> 3c1: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 3c5: 79 11 jns 3d8 <printint+0x2c> neg = 1; 3c7: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 3ce: 8b 45 0c mov 0xc(%ebp),%eax 3d1: f7 d8 neg %eax 3d3: 89 45 ec mov %eax,-0x14(%ebp) 3d6: eb 06 jmp 3de <printint+0x32> } else { x = xx; 3d8: 8b 45 0c mov 0xc(%ebp),%eax 3db: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 3de: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 3e5: 8b 4d f4 mov -0xc(%ebp),%ecx 3e8: 8d 41 01 lea 0x1(%ecx),%eax 3eb: 89 45 f4 mov %eax,-0xc(%ebp) 3ee: 8b 5d 10 mov 0x10(%ebp),%ebx 3f1: 8b 45 ec mov -0x14(%ebp),%eax 3f4: ba 00 00 00 00 mov $0x0,%edx 3f9: f7 f3 div %ebx 3fb: 89 d0 mov %edx,%eax 3fd: 0f b6 80 54 0b 00 00 movzbl 0xb54(%eax),%eax 404: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 408: 8b 75 10 mov 0x10(%ebp),%esi 40b: 8b 45 ec mov -0x14(%ebp),%eax 40e: ba 00 00 00 00 mov $0x0,%edx 413: f7 f6 div %esi 415: 89 45 ec mov %eax,-0x14(%ebp) 418: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 41c: 75 c7 jne 3e5 <printint+0x39> if(neg) 41e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 422: 74 10 je 434 <printint+0x88> buf[i++] = '-'; 424: 8b 45 f4 mov -0xc(%ebp),%eax 427: 8d 50 01 lea 0x1(%eax),%edx 42a: 89 55 f4 mov %edx,-0xc(%ebp) 42d: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 432: eb 1f jmp 453 <printint+0xa7> 434: eb 1d jmp 453 <printint+0xa7> putc(fd, buf[i]); 436: 8d 55 dc lea -0x24(%ebp),%edx 439: 8b 45 f4 mov -0xc(%ebp),%eax 43c: 01 d0 add %edx,%eax 43e: 0f b6 00 movzbl (%eax),%eax 441: 0f be c0 movsbl %al,%eax 444: 89 44 24 04 mov %eax,0x4(%esp) 448: 8b 45 08 mov 0x8(%ebp),%eax 44b: 89 04 24 mov %eax,(%esp) 44e: e8 31 ff ff ff call 384 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 453: 83 6d f4 01 subl $0x1,-0xc(%ebp) 457: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 45b: 79 d9 jns 436 <printint+0x8a> putc(fd, buf[i]); } 45d: 83 c4 30 add $0x30,%esp 460: 5b pop %ebx 461: 5e pop %esi 462: 5d pop %ebp 463: c3 ret 00000464 <printlong>: static void printlong(int fd, unsigned long long xx, int base, int sgn) { 464: 55 push %ebp 465: 89 e5 mov %esp,%ebp 467: 83 ec 38 sub $0x38,%esp 46a: 8b 45 0c mov 0xc(%ebp),%eax 46d: 89 45 e0 mov %eax,-0x20(%ebp) 470: 8b 45 10 mov 0x10(%ebp),%eax 473: 89 45 e4 mov %eax,-0x1c(%ebp) // Force hexadecimal uint upper, lower; upper = xx >> 32; 476: 8b 45 e0 mov -0x20(%ebp),%eax 479: 8b 55 e4 mov -0x1c(%ebp),%edx 47c: 89 d0 mov %edx,%eax 47e: 31 d2 xor %edx,%edx 480: 89 45 f4 mov %eax,-0xc(%ebp) lower = xx & 0xffffffff; 483: 8b 45 e0 mov -0x20(%ebp),%eax 486: 89 45 f0 mov %eax,-0x10(%ebp) if(upper) printint(fd, upper, 16, 0); 489: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 48d: 74 22 je 4b1 <printlong+0x4d> 48f: 8b 45 f4 mov -0xc(%ebp),%eax 492: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 499: 00 49a: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 4a1: 00 4a2: 89 44 24 04 mov %eax,0x4(%esp) 4a6: 8b 45 08 mov 0x8(%ebp),%eax 4a9: 89 04 24 mov %eax,(%esp) 4ac: e8 fb fe ff ff call 3ac <printint> printint(fd, lower, 16, 0); 4b1: 8b 45 f0 mov -0x10(%ebp),%eax 4b4: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 4bb: 00 4bc: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 4c3: 00 4c4: 89 44 24 04 mov %eax,0x4(%esp) 4c8: 8b 45 08 mov 0x8(%ebp),%eax 4cb: 89 04 24 mov %eax,(%esp) 4ce: e8 d9 fe ff ff call 3ac <printint> } 4d3: c9 leave 4d4: c3 ret 000004d5 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. // bdg 10/05/2015: Add %l void printf(int fd, char *fmt, ...) { 4d5: 55 push %ebp 4d6: 89 e5 mov %esp,%ebp 4d8: 83 ec 48 sub $0x48,%esp char *s; int c, i, state; uint *ap; state = 0; 4db: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 4e2: 8d 45 0c lea 0xc(%ebp),%eax 4e5: 83 c0 04 add $0x4,%eax 4e8: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 4eb: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 4f2: e9 ba 01 00 00 jmp 6b1 <printf+0x1dc> c = fmt[i] & 0xff; 4f7: 8b 55 0c mov 0xc(%ebp),%edx 4fa: 8b 45 f0 mov -0x10(%ebp),%eax 4fd: 01 d0 add %edx,%eax 4ff: 0f b6 00 movzbl (%eax),%eax 502: 0f be c0 movsbl %al,%eax 505: 25 ff 00 00 00 and $0xff,%eax 50a: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 50d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 511: 75 2c jne 53f <printf+0x6a> if(c == '%'){ 513: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 517: 75 0c jne 525 <printf+0x50> state = '%'; 519: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 520: e9 88 01 00 00 jmp 6ad <printf+0x1d8> } else { putc(fd, c); 525: 8b 45 e4 mov -0x1c(%ebp),%eax 528: 0f be c0 movsbl %al,%eax 52b: 89 44 24 04 mov %eax,0x4(%esp) 52f: 8b 45 08 mov 0x8(%ebp),%eax 532: 89 04 24 mov %eax,(%esp) 535: e8 4a fe ff ff call 384 <putc> 53a: e9 6e 01 00 00 jmp 6ad <printf+0x1d8> } } else if(state == '%'){ 53f: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 543: 0f 85 64 01 00 00 jne 6ad <printf+0x1d8> if(c == 'd'){ 549: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 54d: 75 2d jne 57c <printf+0xa7> printint(fd, *ap, 10, 1); 54f: 8b 45 e8 mov -0x18(%ebp),%eax 552: 8b 00 mov (%eax),%eax 554: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 55b: 00 55c: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 563: 00 564: 89 44 24 04 mov %eax,0x4(%esp) 568: 8b 45 08 mov 0x8(%ebp),%eax 56b: 89 04 24 mov %eax,(%esp) 56e: e8 39 fe ff ff call 3ac <printint> ap++; 573: 83 45 e8 04 addl $0x4,-0x18(%ebp) 577: e9 2a 01 00 00 jmp 6a6 <printf+0x1d1> } else if(c == 'l') { 57c: 83 7d e4 6c cmpl $0x6c,-0x1c(%ebp) 580: 75 38 jne 5ba <printf+0xe5> printlong(fd, *(unsigned long long *)ap, 10, 0); 582: 8b 45 e8 mov -0x18(%ebp),%eax 585: 8b 50 04 mov 0x4(%eax),%edx 588: 8b 00 mov (%eax),%eax 58a: c7 44 24 10 00 00 00 movl $0x0,0x10(%esp) 591: 00 592: c7 44 24 0c 0a 00 00 movl $0xa,0xc(%esp) 599: 00 59a: 89 44 24 04 mov %eax,0x4(%esp) 59e: 89 54 24 08 mov %edx,0x8(%esp) 5a2: 8b 45 08 mov 0x8(%ebp),%eax 5a5: 89 04 24 mov %eax,(%esp) 5a8: e8 b7 fe ff ff call 464 <printlong> // long longs take up 2 argument slots ap++; 5ad: 83 45 e8 04 addl $0x4,-0x18(%ebp) ap++; 5b1: 83 45 e8 04 addl $0x4,-0x18(%ebp) 5b5: e9 ec 00 00 00 jmp 6a6 <printf+0x1d1> } else if(c == 'x' || c == 'p'){ 5ba: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 5be: 74 06 je 5c6 <printf+0xf1> 5c0: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 5c4: 75 2d jne 5f3 <printf+0x11e> printint(fd, *ap, 16, 0); 5c6: 8b 45 e8 mov -0x18(%ebp),%eax 5c9: 8b 00 mov (%eax),%eax 5cb: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 5d2: 00 5d3: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 5da: 00 5db: 89 44 24 04 mov %eax,0x4(%esp) 5df: 8b 45 08 mov 0x8(%ebp),%eax 5e2: 89 04 24 mov %eax,(%esp) 5e5: e8 c2 fd ff ff call 3ac <printint> ap++; 5ea: 83 45 e8 04 addl $0x4,-0x18(%ebp) 5ee: e9 b3 00 00 00 jmp 6a6 <printf+0x1d1> } else if(c == 's'){ 5f3: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 5f7: 75 45 jne 63e <printf+0x169> s = (char*)*ap; 5f9: 8b 45 e8 mov -0x18(%ebp),%eax 5fc: 8b 00 mov (%eax),%eax 5fe: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 601: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 605: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 609: 75 09 jne 614 <printf+0x13f> s = "(null)"; 60b: c7 45 f4 e8 08 00 00 movl $0x8e8,-0xc(%ebp) while(*s != 0){ 612: eb 1e jmp 632 <printf+0x15d> 614: eb 1c jmp 632 <printf+0x15d> putc(fd, *s); 616: 8b 45 f4 mov -0xc(%ebp),%eax 619: 0f b6 00 movzbl (%eax),%eax 61c: 0f be c0 movsbl %al,%eax 61f: 89 44 24 04 mov %eax,0x4(%esp) 623: 8b 45 08 mov 0x8(%ebp),%eax 626: 89 04 24 mov %eax,(%esp) 629: e8 56 fd ff ff call 384 <putc> s++; 62e: 83 45 f4 01 addl $0x1,-0xc(%ebp) } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 632: 8b 45 f4 mov -0xc(%ebp),%eax 635: 0f b6 00 movzbl (%eax),%eax 638: 84 c0 test %al,%al 63a: 75 da jne 616 <printf+0x141> 63c: eb 68 jmp 6a6 <printf+0x1d1> putc(fd, *s); s++; } } else if(c == 'c'){ 63e: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 642: 75 1d jne 661 <printf+0x18c> putc(fd, *ap); 644: 8b 45 e8 mov -0x18(%ebp),%eax 647: 8b 00 mov (%eax),%eax 649: 0f be c0 movsbl %al,%eax 64c: 89 44 24 04 mov %eax,0x4(%esp) 650: 8b 45 08 mov 0x8(%ebp),%eax 653: 89 04 24 mov %eax,(%esp) 656: e8 29 fd ff ff call 384 <putc> ap++; 65b: 83 45 e8 04 addl $0x4,-0x18(%ebp) 65f: eb 45 jmp 6a6 <printf+0x1d1> } else if(c == '%'){ 661: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 665: 75 17 jne 67e <printf+0x1a9> putc(fd, c); 667: 8b 45 e4 mov -0x1c(%ebp),%eax 66a: 0f be c0 movsbl %al,%eax 66d: 89 44 24 04 mov %eax,0x4(%esp) 671: 8b 45 08 mov 0x8(%ebp),%eax 674: 89 04 24 mov %eax,(%esp) 677: e8 08 fd ff ff call 384 <putc> 67c: eb 28 jmp 6a6 <printf+0x1d1> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 67e: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 685: 00 686: 8b 45 08 mov 0x8(%ebp),%eax 689: 89 04 24 mov %eax,(%esp) 68c: e8 f3 fc ff ff call 384 <putc> putc(fd, c); 691: 8b 45 e4 mov -0x1c(%ebp),%eax 694: 0f be c0 movsbl %al,%eax 697: 89 44 24 04 mov %eax,0x4(%esp) 69b: 8b 45 08 mov 0x8(%ebp),%eax 69e: 89 04 24 mov %eax,(%esp) 6a1: e8 de fc ff ff call 384 <putc> } state = 0; 6a6: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 6ad: 83 45 f0 01 addl $0x1,-0x10(%ebp) 6b1: 8b 55 0c mov 0xc(%ebp),%edx 6b4: 8b 45 f0 mov -0x10(%ebp),%eax 6b7: 01 d0 add %edx,%eax 6b9: 0f b6 00 movzbl (%eax),%eax 6bc: 84 c0 test %al,%al 6be: 0f 85 33 fe ff ff jne 4f7 <printf+0x22> putc(fd, c); } state = 0; } } } 6c4: c9 leave 6c5: c3 ret 000006c6 <free>: static Header base; static Header *freep; void free(void *ap) { 6c6: 55 push %ebp 6c7: 89 e5 mov %esp,%ebp 6c9: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 6cc: 8b 45 08 mov 0x8(%ebp),%eax 6cf: 83 e8 08 sub $0x8,%eax 6d2: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6d5: a1 70 0b 00 00 mov 0xb70,%eax 6da: 89 45 fc mov %eax,-0x4(%ebp) 6dd: eb 24 jmp 703 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6df: 8b 45 fc mov -0x4(%ebp),%eax 6e2: 8b 00 mov (%eax),%eax 6e4: 3b 45 fc cmp -0x4(%ebp),%eax 6e7: 77 12 ja 6fb <free+0x35> 6e9: 8b 45 f8 mov -0x8(%ebp),%eax 6ec: 3b 45 fc cmp -0x4(%ebp),%eax 6ef: 77 24 ja 715 <free+0x4f> 6f1: 8b 45 fc mov -0x4(%ebp),%eax 6f4: 8b 00 mov (%eax),%eax 6f6: 3b 45 f8 cmp -0x8(%ebp),%eax 6f9: 77 1a ja 715 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6fb: 8b 45 fc mov -0x4(%ebp),%eax 6fe: 8b 00 mov (%eax),%eax 700: 89 45 fc mov %eax,-0x4(%ebp) 703: 8b 45 f8 mov -0x8(%ebp),%eax 706: 3b 45 fc cmp -0x4(%ebp),%eax 709: 76 d4 jbe 6df <free+0x19> 70b: 8b 45 fc mov -0x4(%ebp),%eax 70e: 8b 00 mov (%eax),%eax 710: 3b 45 f8 cmp -0x8(%ebp),%eax 713: 76 ca jbe 6df <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 715: 8b 45 f8 mov -0x8(%ebp),%eax 718: 8b 40 04 mov 0x4(%eax),%eax 71b: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 722: 8b 45 f8 mov -0x8(%ebp),%eax 725: 01 c2 add %eax,%edx 727: 8b 45 fc mov -0x4(%ebp),%eax 72a: 8b 00 mov (%eax),%eax 72c: 39 c2 cmp %eax,%edx 72e: 75 24 jne 754 <free+0x8e> bp->s.size += p->s.ptr->s.size; 730: 8b 45 f8 mov -0x8(%ebp),%eax 733: 8b 50 04 mov 0x4(%eax),%edx 736: 8b 45 fc mov -0x4(%ebp),%eax 739: 8b 00 mov (%eax),%eax 73b: 8b 40 04 mov 0x4(%eax),%eax 73e: 01 c2 add %eax,%edx 740: 8b 45 f8 mov -0x8(%ebp),%eax 743: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 746: 8b 45 fc mov -0x4(%ebp),%eax 749: 8b 00 mov (%eax),%eax 74b: 8b 10 mov (%eax),%edx 74d: 8b 45 f8 mov -0x8(%ebp),%eax 750: 89 10 mov %edx,(%eax) 752: eb 0a jmp 75e <free+0x98> } else bp->s.ptr = p->s.ptr; 754: 8b 45 fc mov -0x4(%ebp),%eax 757: 8b 10 mov (%eax),%edx 759: 8b 45 f8 mov -0x8(%ebp),%eax 75c: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 75e: 8b 45 fc mov -0x4(%ebp),%eax 761: 8b 40 04 mov 0x4(%eax),%eax 764: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 76b: 8b 45 fc mov -0x4(%ebp),%eax 76e: 01 d0 add %edx,%eax 770: 3b 45 f8 cmp -0x8(%ebp),%eax 773: 75 20 jne 795 <free+0xcf> p->s.size += bp->s.size; 775: 8b 45 fc mov -0x4(%ebp),%eax 778: 8b 50 04 mov 0x4(%eax),%edx 77b: 8b 45 f8 mov -0x8(%ebp),%eax 77e: 8b 40 04 mov 0x4(%eax),%eax 781: 01 c2 add %eax,%edx 783: 8b 45 fc mov -0x4(%ebp),%eax 786: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 789: 8b 45 f8 mov -0x8(%ebp),%eax 78c: 8b 10 mov (%eax),%edx 78e: 8b 45 fc mov -0x4(%ebp),%eax 791: 89 10 mov %edx,(%eax) 793: eb 08 jmp 79d <free+0xd7> } else p->s.ptr = bp; 795: 8b 45 fc mov -0x4(%ebp),%eax 798: 8b 55 f8 mov -0x8(%ebp),%edx 79b: 89 10 mov %edx,(%eax) freep = p; 79d: 8b 45 fc mov -0x4(%ebp),%eax 7a0: a3 70 0b 00 00 mov %eax,0xb70 } 7a5: c9 leave 7a6: c3 ret 000007a7 <morecore>: static Header* morecore(uint nu) { 7a7: 55 push %ebp 7a8: 89 e5 mov %esp,%ebp 7aa: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 7ad: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 7b4: 77 07 ja 7bd <morecore+0x16> nu = 4096; 7b6: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 7bd: 8b 45 08 mov 0x8(%ebp),%eax 7c0: c1 e0 03 shl $0x3,%eax 7c3: 89 04 24 mov %eax,(%esp) 7c6: e8 91 fb ff ff call 35c <sbrk> 7cb: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 7ce: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 7d2: 75 07 jne 7db <morecore+0x34> return 0; 7d4: b8 00 00 00 00 mov $0x0,%eax 7d9: eb 22 jmp 7fd <morecore+0x56> hp = (Header*)p; 7db: 8b 45 f4 mov -0xc(%ebp),%eax 7de: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 7e1: 8b 45 f0 mov -0x10(%ebp),%eax 7e4: 8b 55 08 mov 0x8(%ebp),%edx 7e7: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 7ea: 8b 45 f0 mov -0x10(%ebp),%eax 7ed: 83 c0 08 add $0x8,%eax 7f0: 89 04 24 mov %eax,(%esp) 7f3: e8 ce fe ff ff call 6c6 <free> return freep; 7f8: a1 70 0b 00 00 mov 0xb70,%eax } 7fd: c9 leave 7fe: c3 ret 000007ff <malloc>: void* malloc(uint nbytes) { 7ff: 55 push %ebp 800: 89 e5 mov %esp,%ebp 802: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 805: 8b 45 08 mov 0x8(%ebp),%eax 808: 83 c0 07 add $0x7,%eax 80b: c1 e8 03 shr $0x3,%eax 80e: 83 c0 01 add $0x1,%eax 811: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 814: a1 70 0b 00 00 mov 0xb70,%eax 819: 89 45 f0 mov %eax,-0x10(%ebp) 81c: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 820: 75 23 jne 845 <malloc+0x46> base.s.ptr = freep = prevp = &base; 822: c7 45 f0 68 0b 00 00 movl $0xb68,-0x10(%ebp) 829: 8b 45 f0 mov -0x10(%ebp),%eax 82c: a3 70 0b 00 00 mov %eax,0xb70 831: a1 70 0b 00 00 mov 0xb70,%eax 836: a3 68 0b 00 00 mov %eax,0xb68 base.s.size = 0; 83b: c7 05 6c 0b 00 00 00 movl $0x0,0xb6c 842: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 845: 8b 45 f0 mov -0x10(%ebp),%eax 848: 8b 00 mov (%eax),%eax 84a: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 84d: 8b 45 f4 mov -0xc(%ebp),%eax 850: 8b 40 04 mov 0x4(%eax),%eax 853: 3b 45 ec cmp -0x14(%ebp),%eax 856: 72 4d jb 8a5 <malloc+0xa6> if(p->s.size == nunits) 858: 8b 45 f4 mov -0xc(%ebp),%eax 85b: 8b 40 04 mov 0x4(%eax),%eax 85e: 3b 45 ec cmp -0x14(%ebp),%eax 861: 75 0c jne 86f <malloc+0x70> prevp->s.ptr = p->s.ptr; 863: 8b 45 f4 mov -0xc(%ebp),%eax 866: 8b 10 mov (%eax),%edx 868: 8b 45 f0 mov -0x10(%ebp),%eax 86b: 89 10 mov %edx,(%eax) 86d: eb 26 jmp 895 <malloc+0x96> else { p->s.size -= nunits; 86f: 8b 45 f4 mov -0xc(%ebp),%eax 872: 8b 40 04 mov 0x4(%eax),%eax 875: 2b 45 ec sub -0x14(%ebp),%eax 878: 89 c2 mov %eax,%edx 87a: 8b 45 f4 mov -0xc(%ebp),%eax 87d: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 880: 8b 45 f4 mov -0xc(%ebp),%eax 883: 8b 40 04 mov 0x4(%eax),%eax 886: c1 e0 03 shl $0x3,%eax 889: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 88c: 8b 45 f4 mov -0xc(%ebp),%eax 88f: 8b 55 ec mov -0x14(%ebp),%edx 892: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 895: 8b 45 f0 mov -0x10(%ebp),%eax 898: a3 70 0b 00 00 mov %eax,0xb70 return (void*)(p + 1); 89d: 8b 45 f4 mov -0xc(%ebp),%eax 8a0: 83 c0 08 add $0x8,%eax 8a3: eb 38 jmp 8dd <malloc+0xde> } if(p == freep) 8a5: a1 70 0b 00 00 mov 0xb70,%eax 8aa: 39 45 f4 cmp %eax,-0xc(%ebp) 8ad: 75 1b jne 8ca <malloc+0xcb> if((p = morecore(nunits)) == 0) 8af: 8b 45 ec mov -0x14(%ebp),%eax 8b2: 89 04 24 mov %eax,(%esp) 8b5: e8 ed fe ff ff call 7a7 <morecore> 8ba: 89 45 f4 mov %eax,-0xc(%ebp) 8bd: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 8c1: 75 07 jne 8ca <malloc+0xcb> return 0; 8c3: b8 00 00 00 00 mov $0x0,%eax 8c8: eb 13 jmp 8dd <malloc+0xde> nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 8ca: 8b 45 f4 mov -0xc(%ebp),%eax 8cd: 89 45 f0 mov %eax,-0x10(%ebp) 8d0: 8b 45 f4 mov -0xc(%ebp),%eax 8d3: 8b 00 mov (%eax),%eax 8d5: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 8d8: e9 70 ff ff ff jmp 84d <malloc+0x4e> } 8dd: c9 leave 8de: c3 ret
code/test-projects/7-seg-display-test/num_display.asm
pdx-lutter/pdx-ece411-fall2018-kjn
0
29165
<reponame>pdx-lutter/pdx-ece411-fall2018-kjn<gh_stars>0 ;-------------------------------------------------------- ; File Created by SDCC : free open source ANSI-C Compiler ; Version 3.5.0 #9253 (Apr 3 2018) (Linux) ; This file was generated Tue Dec 4 00:28:41 2018 ;-------------------------------------------------------- .module num_display .optsdcc -mmcs51 --model-small ;-------------------------------------------------------- ; Public variables in this module ;-------------------------------------------------------- .globl _main .globl _delay .globl _write_command .globl _write_display .globl _i2c_read .globl _i2c_send .globl _i2c_stop .globl _i2c_start .globl _i2c_delay .globl _CY .globl _AC .globl _F0 .globl _RS1 .globl _RS0 .globl _OV .globl _F1 .globl _P .globl _PS .globl _PT1 .globl _PX1 .globl _PT0 .globl _PX0 .globl _RD .globl _WR .globl _T1 .globl _T0 .globl _INT1 .globl _INT0 .globl _TXD .globl _RXD .globl _P3_7 .globl _P3_6 .globl _P3_5 .globl _P3_4 .globl _P3_3 .globl _P3_2 .globl _P3_1 .globl _P3_0 .globl _EA .globl _ES .globl _ET1 .globl _EX1 .globl _ET0 .globl _EX0 .globl _P2_7 .globl _P2_6 .globl _P2_5 .globl _P2_4 .globl _P2_3 .globl _P2_2 .globl _P2_1 .globl _P2_0 .globl _SM0 .globl _SM1 .globl _SM2 .globl _REN .globl _TB8 .globl _RB8 .globl _TI .globl _RI .globl _P1_7 .globl _P1_6 .globl _P1_5 .globl _P1_4 .globl _P1_3 .globl _P1_2 .globl _P1_1 .globl _P1_0 .globl _TF1 .globl _TR1 .globl _TF0 .globl _TR0 .globl _IE1 .globl _IT1 .globl _IE0 .globl _IT0 .globl _P0_7 .globl _P0_6 .globl _P0_5 .globl _P0_4 .globl _P0_3 .globl _P0_2 .globl _P0_1 .globl _P0_0 .globl _B .globl _ACC .globl _PSW .globl _IP .globl _P3 .globl _IE .globl _P2 .globl _SBUF .globl _SCON .globl _P1 .globl _TH1 .globl _TH0 .globl _TL1 .globl _TL0 .globl _TMOD .globl _TCON .globl _PCON .globl _DPH .globl _DPL .globl _SP .globl _P0 .globl _once .globl _display_buffer .globl _number_table ;-------------------------------------------------------- ; special function registers ;-------------------------------------------------------- .area RSEG (ABS,DATA) .org 0x0000 _P0 = 0x0080 _SP = 0x0081 _DPL = 0x0082 _DPH = 0x0083 _PCON = 0x0087 _TCON = 0x0088 _TMOD = 0x0089 _TL0 = 0x008a _TL1 = 0x008b _TH0 = 0x008c _TH1 = 0x008d _P1 = 0x0090 _SCON = 0x0098 _SBUF = 0x0099 _P2 = 0x00a0 _IE = 0x00a8 _P3 = 0x00b0 _IP = 0x00b8 _PSW = 0x00d0 _ACC = 0x00e0 _B = 0x00f0 ;-------------------------------------------------------- ; special function bits ;-------------------------------------------------------- .area RSEG (ABS,DATA) .org 0x0000 _P0_0 = 0x0080 _P0_1 = 0x0081 _P0_2 = 0x0082 _P0_3 = 0x0083 _P0_4 = 0x0084 _P0_5 = 0x0085 _P0_6 = 0x0086 _P0_7 = 0x0087 _IT0 = 0x0088 _IE0 = 0x0089 _IT1 = 0x008a _IE1 = 0x008b _TR0 = 0x008c _TF0 = 0x008d _TR1 = 0x008e _TF1 = 0x008f _P1_0 = 0x0090 _P1_1 = 0x0091 _P1_2 = 0x0092 _P1_3 = 0x0093 _P1_4 = 0x0094 _P1_5 = 0x0095 _P1_6 = 0x0096 _P1_7 = 0x0097 _RI = 0x0098 _TI = 0x0099 _RB8 = 0x009a _TB8 = 0x009b _REN = 0x009c _SM2 = 0x009d _SM1 = 0x009e _SM0 = 0x009f _P2_0 = 0x00a0 _P2_1 = 0x00a1 _P2_2 = 0x00a2 _P2_3 = 0x00a3 _P2_4 = 0x00a4 _P2_5 = 0x00a5 _P2_6 = 0x00a6 _P2_7 = 0x00a7 _EX0 = 0x00a8 _ET0 = 0x00a9 _EX1 = 0x00aa _ET1 = 0x00ab _ES = 0x00ac _EA = 0x00af _P3_0 = 0x00b0 _P3_1 = 0x00b1 _P3_2 = 0x00b2 _P3_3 = 0x00b3 _P3_4 = 0x00b4 _P3_5 = 0x00b5 _P3_6 = 0x00b6 _P3_7 = 0x00b7 _RXD = 0x00b0 _TXD = 0x00b1 _INT0 = 0x00b2 _INT1 = 0x00b3 _T0 = 0x00b4 _T1 = 0x00b5 _WR = 0x00b6 _RD = 0x00b7 _PX0 = 0x00b8 _PT0 = 0x00b9 _PX1 = 0x00ba _PT1 = 0x00bb _PS = 0x00bc _P = 0x00d0 _F1 = 0x00d1 _OV = 0x00d2 _RS0 = 0x00d3 _RS1 = 0x00d4 _F0 = 0x00d5 _AC = 0x00d6 _CY = 0x00d7 ;-------------------------------------------------------- ; overlayable register banks ;-------------------------------------------------------- .area REG_BANK_0 (REL,OVR,DATA) .ds 8 ;-------------------------------------------------------- ; internal ram data ;-------------------------------------------------------- .area DSEG (DATA) _number_table:: .ds 16 _display_buffer:: .ds 10 ;-------------------------------------------------------- ; overlayable items in internal ram ;-------------------------------------------------------- .area OSEG (OVR,DATA) .area OSEG (OVR,DATA) .area OSEG (OVR,DATA) ;-------------------------------------------------------- ; Stack segment in internal ram ;-------------------------------------------------------- .area SSEG __start__stack: .ds 1 ;-------------------------------------------------------- ; indirectly addressable internal ram data ;-------------------------------------------------------- .area ISEG (DATA) ;-------------------------------------------------------- ; absolute internal ram data ;-------------------------------------------------------- .area IABS (ABS,DATA) .area IABS (ABS,DATA) ;-------------------------------------------------------- ; bit data ;-------------------------------------------------------- .area BSEG (BIT) _once:: .ds 1 ;-------------------------------------------------------- ; paged external ram data ;-------------------------------------------------------- .area PSEG (PAG,XDATA) ;-------------------------------------------------------- ; external ram data ;-------------------------------------------------------- .area XSEG (XDATA) ;-------------------------------------------------------- ; absolute external ram data ;-------------------------------------------------------- .area XABS (ABS,XDATA) ;-------------------------------------------------------- ; external initialized ram data ;-------------------------------------------------------- .area XISEG (XDATA) .area HOME (CODE) .area GSINIT0 (CODE) .area GSINIT1 (CODE) .area GSINIT2 (CODE) .area GSINIT3 (CODE) .area GSINIT4 (CODE) .area GSINIT5 (CODE) .area GSINIT (CODE) .area GSFINAL (CODE) .area CSEG (CODE) ;-------------------------------------------------------- ; interrupt vector ;-------------------------------------------------------- .area HOME (CODE) __interrupt_vect: ljmp __sdcc_gsinit_startup ;-------------------------------------------------------- ; global & static initialisations ;-------------------------------------------------------- .area HOME (CODE) .area GSINIT (CODE) .area GSFINAL (CODE) .area GSINIT (CODE) .globl __sdcc_gsinit_startup .globl __sdcc_program_startup .globl __start__stack .globl __mcs51_genXINIT .globl __mcs51_genXRAMCLEAR .globl __mcs51_genRAMCLEAR ; num_display.c:49: unsigned char number_table[] = { mov _number_table,#0x3F mov (_number_table + 0x0001),#0x06 mov (_number_table + 0x0002),#0x5B mov (_number_table + 0x0003),#0x4F mov (_number_table + 0x0004),#0x66 mov (_number_table + 0x0005),#0x6D mov (_number_table + 0x0006),#0x7D mov (_number_table + 0x0007),#0x07 mov (_number_table + 0x0008),#0x7F mov (_number_table + 0x0009),#0x6F mov (_number_table + 0x000a),#0x77 mov (_number_table + 0x000b),#0x7C mov (_number_table + 0x000c),#0x39 mov (_number_table + 0x000d),#0x5E mov (_number_table + 0x000e),#0x79 mov (_number_table + 0x000f),#0x71 ; num_display.c:69: unsigned char display_buffer[] = { mov _display_buffer,#0x06 mov (_display_buffer + 0x0001),#0x00 mov (_display_buffer + 0x0002),#0x5B mov (_display_buffer + 0x0003),#0x00 mov (_display_buffer + 0x0004),#0x00 mov (_display_buffer + 0x0005),#0x00 mov (_display_buffer + 0x0006),#0x4F mov (_display_buffer + 0x0007),#0x00 mov (_display_buffer + 0x0008),#0x66 mov (_display_buffer + 0x0009),#0x00 ; num_display.c:217: bool once = true; setb _once .area GSFINAL (CODE) ljmp __sdcc_program_startup ;-------------------------------------------------------- ; Home ;-------------------------------------------------------- .area HOME (CODE) .area HOME (CODE) __sdcc_program_startup: ljmp _main ; return from main will return to caller ;-------------------------------------------------------- ; code ;-------------------------------------------------------- .area CSEG (CODE) ;------------------------------------------------------------ ;Allocation info for local variables in function 'i2c_delay' ;------------------------------------------------------------ ;i Allocated to registers r6 r7 ;------------------------------------------------------------ ; num_display.c:87: void i2c_delay() ; ----------------------------------------- ; function i2c_delay ; ----------------------------------------- _i2c_delay: ar7 = 0x07 ar6 = 0x06 ar5 = 0x05 ar4 = 0x04 ar3 = 0x03 ar2 = 0x02 ar1 = 0x01 ar0 = 0x00 ; num_display.c:90: for (i = 0; i < 5; i++); mov r6,#0x05 mov r7,#0x00 00104$: mov a,r6 add a,#0xFF mov r4,a mov a,r7 addc a,#0xFF mov r5,a mov ar6,r4 mov ar7,r5 mov a,r4 orl a,r5 jnz 00104$ ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'i2c_start' ;------------------------------------------------------------ ; num_display.c:93: void i2c_start() ; ----------------------------------------- ; function i2c_start ; ----------------------------------------- _i2c_start: ; num_display.c:95: SCL = 0; clr _P2_1 ; num_display.c:96: SDA = 1; setb _P2_0 ; num_display.c:97: i2c_delay(); lcall _i2c_delay ; num_display.c:98: SCL = 1; setb _P2_1 ; num_display.c:99: i2c_delay(); lcall _i2c_delay ; num_display.c:100: SDA = 0; clr _P2_0 ; num_display.c:101: i2c_delay(); lcall _i2c_delay ; num_display.c:102: SCL = 0; clr _P2_1 ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'i2c_stop' ;------------------------------------------------------------ ; num_display.c:105: void i2c_stop() ; ----------------------------------------- ; function i2c_stop ; ----------------------------------------- _i2c_stop: ; num_display.c:107: SCL = 0; clr _P2_1 ; num_display.c:108: i2c_delay(); lcall _i2c_delay ; num_display.c:109: SDA = 0; clr _P2_0 ; num_display.c:110: i2c_delay(); lcall _i2c_delay ; num_display.c:111: SCL = 1; setb _P2_1 ; num_display.c:112: i2c_delay(); lcall _i2c_delay ; num_display.c:113: SDA = 1; setb _P2_0 ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'i2c_send' ;------------------------------------------------------------ ;data_out Allocated to registers r7 ;i Allocated to registers r6 ;ack_bit Allocated to registers r7 ;------------------------------------------------------------ ; num_display.c:116: unsigned char i2c_send(unsigned char data_out) ; ----------------------------------------- ; function i2c_send ; ----------------------------------------- _i2c_send: mov r7,dpl ; num_display.c:119: for (i = 0; i < 8; i++) { mov r6,#0x00 00105$: ; num_display.c:120: SCL = 0; clr _P2_1 ; num_display.c:121: i2c_delay(); push ar7 push ar6 lcall _i2c_delay pop ar6 pop ar7 ; num_display.c:122: if ((data_out & 0x80) == 0) { mov a,r7 jb acc.7,00102$ ; num_display.c:123: SDA = 0; clr _P2_0 sjmp 00103$ 00102$: ; num_display.c:125: SDA = 1; setb _P2_0 00103$: ; num_display.c:127: i2c_delay(); push ar7 push ar6 lcall _i2c_delay ; num_display.c:128: SCL = 1; setb _P2_1 ; num_display.c:129: i2c_delay(); lcall _i2c_delay pop ar6 pop ar7 ; num_display.c:130: data_out<<=1; mov a,r7 add a,r7 mov r7,a ; num_display.c:119: for (i = 0; i < 8; i++) { inc r6 cjne r6,#0x08,00120$ 00120$: jc 00105$ ; num_display.c:132: SCL = 0; clr _P2_1 ; num_display.c:133: i2c_delay(); lcall _i2c_delay ; num_display.c:134: SDA = 1; setb _P2_0 ; num_display.c:135: i2c_delay(); lcall _i2c_delay ; num_display.c:136: SCL = 1; setb _P2_1 ; num_display.c:137: i2c_delay(); lcall _i2c_delay ; num_display.c:138: ack_bit = SDA; mov c,_P2_0 clr a rlc a mov r7,a ; num_display.c:139: i2c_delay(); push ar7 lcall _i2c_delay pop ar7 ; num_display.c:140: SCL = 0; clr _P2_1 ; num_display.c:141: return ack_bit; mov dpl,r7 ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'i2c_read' ;------------------------------------------------------------ ;i Allocated to registers r6 ;Data Allocated to registers r7 ;------------------------------------------------------------ ; num_display.c:144: unsigned char i2c_read() ; ----------------------------------------- ; function i2c_read ; ----------------------------------------- _i2c_read: ; num_display.c:146: unsigned char i, Data=0; mov r7,#0x00 ; num_display.c:147: for (i = 0; i < 8; i++) { mov r6,#0x00 00106$: ; num_display.c:148: SCL = 1; setb _P2_1 ; num_display.c:149: if(SDA) jnb _P2_0,00102$ ; num_display.c:150: Data |=1; orl ar7,#0x01 00102$: ; num_display.c:151: if(i<7) cjne r6,#0x07,00124$ 00124$: jnc 00104$ ; num_display.c:152: Data<<=1; mov a,r7 add a,r7 mov r7,a 00104$: ; num_display.c:153: SCL = 0; clr _P2_1 ; num_display.c:147: for (i = 0; i < 8; i++) { inc r6 cjne r6,#0x08,00126$ 00126$: jc 00106$ ; num_display.c:155: return Data; mov dpl,r7 ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'write_display' ;------------------------------------------------------------ ;address Allocated to registers ;write_bit Allocated to registers ;address_with_write Allocated to registers ;i Allocated to registers r7 ;ack Allocated to registers ;------------------------------------------------------------ ; num_display.c:158: void write_display(void) ; ----------------------------------------- ; function write_display ; ----------------------------------------- _write_display: ; num_display.c:167: i2c_start(); lcall _i2c_start ; num_display.c:168: ack = i2c_send(address_with_write); mov dpl,#0xE0 lcall _i2c_send ; num_display.c:178: ack = i2c_send(0x00); //0x00 is the starting address of the 7-set disp mov dpl,#0x00 lcall _i2c_send ; num_display.c:179: for (i=0; i<DISPLAY_BUFFER_SIZE; i++) { mov r7,#0x00 00102$: ; num_display.c:180: i2c_delay(); push ar7 lcall _i2c_delay pop ar7 ; num_display.c:181: ack = i2c_send(display_buffer[i]); mov a,r7 add a,#_display_buffer mov r1,a mov dpl,@r1 push ar7 lcall _i2c_send pop ar7 ; num_display.c:179: for (i=0; i<DISPLAY_BUFFER_SIZE; i++) { inc r7 cjne r7,#0x0A,00113$ 00113$: jc 00102$ ; num_display.c:183: i2c_stop(); ljmp _i2c_stop ;------------------------------------------------------------ ;Allocation info for local variables in function 'write_command' ;------------------------------------------------------------ ;command_byte Allocated to registers r7 ;address Allocated to registers ;write_bit Allocated to registers ;address_with_write Allocated to registers ;ack Allocated to registers ;------------------------------------------------------------ ; num_display.c:187: void write_command(unsigned char command_byte) ; ----------------------------------------- ; function write_command ; ----------------------------------------- _write_command: mov r7,dpl ; num_display.c:200: i2c_start(); push ar7 lcall _i2c_start ; num_display.c:201: ack = i2c_send(address_with_write); mov dpl,#0xE0 lcall _i2c_send pop ar7 ; num_display.c:207: ack = i2c_send(command_byte); mov dpl,r7 lcall _i2c_send ; num_display.c:208: i2c_stop(); ljmp _i2c_stop ;------------------------------------------------------------ ;Allocation info for local variables in function 'delay' ;------------------------------------------------------------ ;i Allocated to registers r6 r7 ;------------------------------------------------------------ ; num_display.c:211: void delay(void) ; ----------------------------------------- ; function delay ; ----------------------------------------- _delay: ; num_display.c:214: for(i=0;i<500;i++); mov r6,#0xF4 mov r7,#0x01 00104$: mov a,r6 add a,#0xFF mov r4,a mov a,r7 addc a,#0xFF mov r5,a mov ar6,r4 mov ar7,r5 mov a,r4 orl a,r5 jnz 00104$ ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'main' ;------------------------------------------------------------ ; num_display.c:219: void main(void) ; ----------------------------------------- ; function main ; ----------------------------------------- _main: ; num_display.c:226: while (true) 00104$: ; num_display.c:228: if (once) jnb _once,00104$ ; num_display.c:231: delay(); lcall _delay ; num_display.c:233: write_command(ENABLE_DISPLAY_OSCILLATOR); mov dpl,#0x21 lcall _write_command ; num_display.c:234: delay(); lcall _delay ; num_display.c:235: write_command(ENABLE_DISPLAY); mov dpl,#0x81 lcall _write_command ; num_display.c:236: delay(); lcall _delay ; num_display.c:239: write_display(); lcall _write_display ; num_display.c:240: once = false; clr _once sjmp 00104$ .area CSEG (CODE) .area CONST (CODE) .area XINIT (CODE) .area CABS (ABS,CODE)
alloy4fun_models/trashltl/models/4/PXHT7HqkpcvZ3WbJd.als
Kaixi26/org.alloytools.alloy
0
2811
<reponame>Kaixi26/org.alloytools.alloy open main pred idPXHT7HqkpcvZ3WbJd_prop5 { after some File } pred __repair { idPXHT7HqkpcvZ3WbJd_prop5 } check __repair { idPXHT7HqkpcvZ3WbJd_prop5 <=> prop5o }
alloy4fun_models/trainstlt/models/2/yv7jLwRgXkRcPLof9.als
Kaixi26/org.alloytools.alloy
0
4801
<filename>alloy4fun_models/trainstlt/models/2/yv7jLwRgXkRcPLof9.als open main pred idyv7jLwRgXkRcPLof9_prop3 { always(no pos) } pred __repair { idyv7jLwRgXkRcPLof9_prop3 } check __repair { idyv7jLwRgXkRcPLof9_prop3 <=> prop3o }
Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0xca.log_21829_670.asm
ljhsiun2/medusa
9
80425
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0xc795, %rax nop nop nop nop add %rcx, %rcx movb (%rax), %dl nop nop nop nop nop cmp %r10, %r10 lea addresses_D_ht+0x4b95, %rsi lea addresses_A_ht+0x6776, %rdi clflush (%rsi) clflush (%rdi) xor $55803, %r12 mov $79, %rcx rep movsb nop nop nop and $38955, %r10 lea addresses_D_ht+0x18195, %rcx inc %rdi mov (%rcx), %r12d xor $62091, %r12 lea addresses_D_ht+0xb55, %rsi lea addresses_D_ht+0x12359, %rdi nop nop nop nop dec %r13 mov $21, %rcx rep movsq nop nop nop dec %r12 lea addresses_UC_ht+0x15095, %r13 clflush (%r13) nop nop nop sub %r10, %r10 movb $0x61, (%r13) nop nop nop cmp $49855, %r13 lea addresses_D_ht+0xc92d, %rsi lea addresses_D_ht+0x15ee5, %rdi nop nop nop nop lfence mov $30, %rcx rep movsw nop nop nop nop sub %r12, %r12 lea addresses_UC_ht+0x1c995, %rdx nop nop and $31597, %rdi and $0xffffffffffffffc0, %rdx movntdqa (%rdx), %xmm1 vpextrq $0, %xmm1, %r12 nop nop xor %rdx, %rdx lea addresses_A_ht+0xf395, %rsi lea addresses_A_ht+0x779d, %rdi nop nop nop nop nop add %r13, %r13 mov $0, %rcx rep movsw nop nop nop nop nop cmp %r13, %r13 lea addresses_UC_ht+0xc195, %rsi lea addresses_WC_ht+0x4f05, %rdi nop add $18637, %r13 mov $89, %rcx rep movsw nop sub $29928, %rdx lea addresses_D_ht+0x11d95, %rax nop nop nop cmp %r13, %r13 movups (%rax), %xmm5 vpextrq $0, %xmm5, %rdx nop nop nop nop and %rdx, %rdx lea addresses_WC_ht+0xac95, %rdi nop sub %r10, %r10 mov (%rdi), %rsi nop nop nop nop sub %rcx, %rcx lea addresses_UC_ht+0x13995, %rdx nop nop nop sub $33576, %r10 mov (%rdx), %r12d sub %r10, %r10 pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r9 push %rax push %rbx push %rcx push %rdi // Store lea addresses_WC+0x18a35, %rbx nop cmp $30903, %r10 movl $0x51525354, (%rbx) nop nop xor %r12, %r12 // Load lea addresses_WC+0x9d45, %rcx nop nop nop nop nop sub %rbx, %rbx mov (%rcx), %r10 nop nop nop nop nop sub %rcx, %rcx // Faulty Load lea addresses_WC+0x4195, %rcx nop nop nop xor %r9, %r9 movb (%rcx), %r12b lea oracles, %rdi and $0xff, %r12 shlq $12, %r12 mov (%rdi,%r12,1), %r12 pop %rdi pop %rcx pop %rbx pop %rax pop %r9 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 4, 'NT': True, 'type': 'addresses_WC'}} {'src': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 1, 'NT': True, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_A_ht'}} {'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 1, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': True, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 16, 'NT': True, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 8, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_A_ht'}} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_WC_ht'}} {'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 4, 'AVXalign': True, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
programs/oeis/097/A097786.asm
neoneye/loda
22
81530
<gh_stars>10-100 ; A097786: a(n)=3a(n-1)+C(n+3,3),n>0, a(0)=1. ; 1,7,31,113,374,1178,3618,10974,33087,99481,298729,896551,2690108,8070884,24213332,72640812,217923405,653771355,1961315395,5883947725,17651844946,52955536862,158866612886,476599841258,1429799526699 mov $1,1 lpb $0 mov $2,$0 sub $0,1 seq $2,52150 ; Partial sums of A000340, second partial sums of A003462. add $1,$2 lpe mov $0,$1
test/Fail/Issue3855.agda
shlevy/agda
1,989
11558
<gh_stars>1000+ -- Andreas, 2019-06-17, LAIM 2019, issue #3855 -- Only allow erased definitions (such as projections of erased fields) -- in erased context. open import Common.IO open import Common.Unit open import Common.String open import Common.Bool record Erased (A : Set) : Set where constructor erase field @0 gone : A noWorld : Bool → Erased String noWorld true = erase "Hello world!" noWorld false = erase "Hallo, Welt!" -- Illegal definition, should raise a type error. unerase : ∀{A : Set} → Erased A → A unerase = Erased.gone main = putStrLn (unerase (noWorld false)) -- WAS: type checker let it through, compiler produces ill-formed Haskell
oeis/088/A088209.asm
neoneye/loda-programs
11
26926
; A088209: Numerators of convergents of the continued fraction with the n+1 partial quotients: [1;1,1,...(n 1's)...,1,n+1], starting with [1], [1;2], [1;1,3], [1;1,1,4], ... ; Submitted by <NAME> ; 1,3,7,14,28,53,99,181,327,584,1034,1817,3173,5511,9527,16402,28136,48109,82023,139481,236631,400588,676822,1141489,1921993,3231243,5424679,9095126,15230452,25475429,42566379,71052157,118489383,197422736,328664162,546720137,908769581,1509508239,2505681623,4156612186,6891119936,11417980573,18908175087,31295478689,51772051383,85605250708,141483420334,233732509921,385965887377,637092193299,1051201833799,1733831576222,2858714712268,4711765139861,7763380005747,12787264150597,21055663314951 mov $1,$0 lpb $1 sub $1,1 mov $2,$0 add $3,1 add $0,$3 mov $3,$2 lpe add $0,1
Transynther/x86/_processed/NONE/_zr_/i7-8650U_0xd2.log_15343_110.asm
ljhsiun2/medusa
9
25678
<filename>Transynther/x86/_processed/NONE/_zr_/i7-8650U_0xd2.log_15343_110.asm .global s_prepare_buffers s_prepare_buffers: push %r11 push %r14 push %r15 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_A_ht+0x10973, %rsi lea addresses_normal_ht+0x12101, %rdi nop nop dec %rax mov $98, %rcx rep movsl nop and $26419, %rbp lea addresses_WT_ht+0x131c9, %rsi lea addresses_WC_ht+0x14a59, %rdi nop nop and %r14, %r14 mov $64, %rcx rep movsl nop add %rax, %rax lea addresses_normal_ht+0x156c9, %rsi lea addresses_A_ht+0x140c9, %rdi add %r11, %r11 mov $62, %rcx rep movsb nop sub %rcx, %rcx lea addresses_WC_ht+0x1c499, %rsi lea addresses_A_ht+0x16859, %rdi nop nop nop nop nop xor %r15, %r15 mov $78, %rcx rep movsl cmp $15525, %rax lea addresses_normal_ht+0x1b4c9, %r15 dec %rdi vmovups (%r15), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $0, %xmm6, %r11 nop xor $14732, %r11 lea addresses_D_ht+0x17065, %rbp cmp $38438, %rax movb $0x61, (%rbp) nop nop sub %r15, %r15 lea addresses_WT_ht+0x15f49, %rsi lea addresses_A_ht+0x38e9, %rdi nop nop add %rax, %rax mov $71, %rcx rep movsb nop nop add %rax, %rax pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r15 pop %r14 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %r9 push %rax push %rdx push %rsi // Store lea addresses_WC+0x7d15, %rsi clflush (%rsi) nop nop nop sub %r13, %r13 movw $0x5152, (%rsi) and %rax, %rax // Faulty Load lea addresses_UC+0x1a8c9, %rsi nop nop add %rdx, %rdx mov (%rsi), %r14w lea oracles, %r13 and $0xff, %r14 shlq $12, %r14 mov (%r13,%r14,1), %r14 pop %rsi pop %rdx pop %rax pop %r9 pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 11, 'same': True}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}} {'00': 15343} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
oeis/214/A214683.asm
neoneye/loda-programs
11
89626
<gh_stars>10-100 ; A214683: a(n+3) = -a(n+2) + 2a(n+1) + a(n) with a(0)=-1, a(1)=0, a(2)=-3. ; Submitted by <NAME> ; -1,0,-3,2,-8,9,-23,33,-70,113,-220,376,-703,1235,-2265,4032,-7327,13126,-23748,42673,-77043,138641,-250054,450293,-811760,1462292,-2635519,4748343,-8557089,15418256,-27784091,50063514,-90213440,162556377,-292919743 mov $1,2 mov $4,-1 lpb $0 sub $0,1 add $2,$1 add $4,1 add $3,$4 add $1,$3 add $4,$2 mov $2,0 add $3,$4 sub $4,$3 add $3,$4 add $3,$4 lpe mov $0,$4
test/Succeed/Issue2147.agda
shlevy/agda
1,989
9070
<reponame>shlevy/agda open import Agda.Builtin.Equality open import Agda.Builtin.Nat data ⊤ : Set where tt : ⊤ foo : Nat → ⊤ → ⊤ foo 0 tt = tt foo (suc n) tt = foo n tt -- NB tail-recursive test : foo 100000 tt ≡ tt test = refl -- memory blows up here
programs/oeis/082/A082416.asm
neoneye/loda
22
29530
<filename>programs/oeis/082/A082416.asm<gh_stars>10-100 ; A082416: Parity of A073941(n). ; 1,1,1,0,1,0,0,1,0,1,1,1,0,1,0,1,1,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,0,1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,0,0,0,1,1,0,1,1,0,0,0,0,0,1,1,1,0,0,0,0,1,0,1,1,0,1,1,1 trn $0,1 seq $0,5428 ; a(n) = ceiling((1 + sum of preceding terms) / 2) starting with a(0) = 1. mod $0,2
russian-peasant-multiplication/src/peasant.adb
jnguyen1098/legacy-software
1
27472
----------------------------------------------------------------------------- -- Russian Peasant Multiplication -- -- By: <NAME> (XXXXXXXX) -- -- XXXXXXXX -- ----------------------------------------------------------------------------- with Ada.Text_IO; use Ada.Text_IO; with Ada.Long_Integer_Text_IO; use Ada.Long_Integer_Text_IO; with Ada.Calendar; use Ada.Calendar; procedure Peasant is ------------------------------ Main Subprograms ------------------------------- function russianPeasantRecursive(m, n : Long_Integer) return Long_Integer; function russianPeasantIterative(ml, mn : Long_Integer) return Long_Integer; procedure benchmarkRecursive(m, n : Long_Integer); procedure benchmarkIterative(m, n : Long_Integer); ------------------------------------------------------------------------------- -- Recursive Russian Peasant Multiplication function russianPeasantRecursive(m, n : Long_Integer) return Long_Integer is begin -- Base cases if m = 0 then return 0; elsif m = 1 then return n; -- Recursive cases elsif m mod 2 = 0 then return russianPeasantRecursive(m / 2, n * 2); else return n + russianPeasantRecursive(m / 2, n * 2); end if; end russianPeasantRecursive; -- Iterative Russian Peasant Multiplication function russianPeasantIterative(ml, mn : Long_Integer) return Long_Integer is m : Long_Integer := ml; n : Long_Integer := mn; result : Long_Integer := 0; begin -- Continually reduce m until it is 0 -- while raising n by a factor of 2 while m > 0 loop if m mod 2 = 1 then result := result + n; end if; m := m / 2; n := n * 2; end loop; return result; end russianPeasantIterative; -- Benchmark recursive function -- multiplies all -- numbers within a certain range, sequentially procedure benchmarkRecursive(m, n : Long_Integer) is start : Time; finish : Time; result : Long_Integer; begin -- Clock start start := Clock; for i in m .. n loop for j in m .. n loop result := russianPeasantRecursive(i, j); end loop; end loop; if result < 0 then Put_Line("Error"); end if; -- Clock end finish := Clock; Put_Line(" Recursive took" & Duration'Image(finish - start) & " seconds"); end benchmarkRecursive; -- Benchmark recursive function -- multiplies all -- numbers within a certain range, sequentially procedure benchmarkIterative(m, n : Long_Integer) is start : Time; finish : Time; result : Long_Integer; begin -- Clock start start := Clock; for i in m .. n loop for j in m .. n loop result := russianPeasantIterative(i, j); end loop; end loop; if result < 0 then Put_Line("Error"); end if; -- Clock end finish := Clock; Put_Line(" Iterative took" & Duration'Image(finish - start) & " seconds"); end benchmarkIterative; ------------------------------ Variables ------------------------------ multiplier : Long_Integer; multiplicand : Long_Integer; recursiveAns : Long_Integer; iterativeAns : Long_Integer; -- My test suite (it's an array of ranges to use) rng : constant Array(0 .. 4) of Long_Integer := (1,5,50,500,5000); -------------------------------- Main --------------------------------- begin Put_Line("-------------------------------------------"); Put_Line("-- Russian Peasant Multiplication in Ada --"); Put_Line("-- Enter a negative number to quit --"); Put_Line("-- By <NAME> (XXXXXXXX) --"); Put_Line("-------------------------------------------"); -- Benchmarks... delay Duration(1.0); Put_Line("Please wait...running startup benchmarks..."); New_Line; -- Run every test for i in 1 .. 4 loop delay Duration(1.0); -- Printline Put_Line("Multiplying every number from" & Long_Integer'Image(rng(i - 1)) & " to" & Long_Integer'Image(rng(i))); -- Recursive benchmark benchmarkRecursive(rng(i - 1), rng(i)); -- Iterative benchmark benchmarkIterative(rng(i - 1), rng(i)); delay Duration(1.0); New_Line; end loop; loop -- User input Put_Line("Enter a positive number (or negative to quit):"); Put("> "); Get(multiplier); -- Early termination on negative if multiplier < 0 then exit; end if; -- User input again New_Line; Put_Line("Enter another one (or negative to quit):"); Put("> "); Get(multiplicand); -- Early termination on negative if multiplicand < 0 then exit; end if; -- Calculate answers recursiveAns := russianPeasantRecursive(multiplier, multiplicand); iterativeAns := russianPeasantIterative(multiplier, multiplicand); New_Line; -- Print recursive answer Put_Line("(recursive)" & Long_Integer'Image(multiplier) & "*" & Long_Integer'Image(multiplicand) & "=" & Long_Integer'Image(recursiveAns)); -- Print iterative answer Put_Line("(iterative)" & Long_Integer'Image(multiplier) & "*" & Long_Integer'Image(multiplicand) & "=" & Long_Integer'Image(iterativeAns)); New_Line; end loop; New_Line; Put_Line("Thanks for using this program!"); end Peasant; -----------------------------------------------------------------------
rll/src/main/antlr4/com/realitylattice/rll/RLLLexer.g4
reality-lattice/reality-lattice
0
3953
/* * Copyright 2018 <NAME>. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ lexer grammar RLLLexer; @lexer::members { public static final int WHITESPACE = 1; public static final int COMMENTS = 2; } RLL_CREATE : 'create' ; RLL_EDIT : 'edit' ; RLL_DELETE : 'delete' ; RLL_TILE : 'tile' ; RLL_ITEM : 'item' ; WS : [ \t\n\r]+ -> channel(WHITESPACE) ; SL_COMMENT : '//' .*? '\n' -> channel(COMMENTS);
programs/oeis/044/A044387.asm
karttu/loda
0
172496
; A044387: Numbers n such that string 5,5 occurs in the base 10 representation of n but not of n-1. ; 55,155,255,355,455,550,655,755,855,955,1055,1155,1255,1355,1455,1550,1655,1755,1855,1955,2055,2155,2255,2355,2455,2550,2655,2755,2855,2955,3055,3155,3255,3355,3455,3550,3655,3755,3855 mov $3,$0 add $0,5 mov $1,6 mov $5,$0 gcd $0,4 lpb $0,1 mov $0,8 fac $4 mov $1,$4 gcd $5,5 div $0,$5 lpe add $1,49 mov $2,$3 mul $2,100 add $1,$2
oeis/021/A021800.asm
neoneye/loda-programs
11
245023
<reponame>neoneye/loda-programs ; A021800: Decimal expansion of 1/796. ; Submitted by Jon Maiga ; 0,0,1,2,5,6,2,8,1,4,0,7,0,3,5,1,7,5,8,7,9,3,9,6,9,8,4,9,2,4,6,2,3,1,1,5,5,7,7,8,8,9,4,4,7,2,3,6,1,8,0,9,0,4,5,2,2,6,1,3,0,6,5,3,2,6,6,3,3,1,6,5,8,2,9,1,4,5,7,2,8,6,4,3,2,1,6,0,8,0,4,0,2,0,1,0,0,5,0 seq $0,199685 ; a(n) = 5*10^n+1. div $0,398 mod $0,10
source/amf/uml/amf-uml-holders.adb
svn2github/matreshka
24
6557
<filename>source/amf/uml/amf-uml-holders.adb ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.UML.Holders.Aggregation_Kinds; with AMF.UML.Holders.Call_Concurrency_Kinds; with AMF.UML.Holders.Connector_Kinds; with AMF.UML.Holders.Expansion_Kinds; with AMF.UML.Holders.Interaction_Operator_Kinds; with AMF.UML.Holders.Message_Kinds; with AMF.UML.Holders.Message_Sorts; with AMF.UML.Holders.Object_Node_Ordering_Kinds; with AMF.UML.Holders.Parameter_Direction_Kinds; with AMF.UML.Holders.Parameter_Effect_Kinds; with AMF.UML.Holders.Pseudostate_Kinds; with AMF.UML.Holders.Transition_Kinds; with AMF.UML.Holders.Visibility_Kinds; package body AMF.UML.Holders is ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Aggregation_Kind is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Aggregation_Kinds.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Aggregation_Kinds.Element (Holder)); end if; end Element; ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Call_Concurrency_Kind is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Call_Concurrency_Kinds.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Call_Concurrency_Kinds.Element (Holder)); end if; end Element; ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Connector_Kind is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Connector_Kinds.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Connector_Kinds.Element (Holder)); end if; end Element; ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Expansion_Kind is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Expansion_Kinds.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Expansion_Kinds.Element (Holder)); end if; end Element; ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Interaction_Operator_Kind is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Interaction_Operator_Kinds.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Interaction_Operator_Kinds.Element (Holder)); end if; end Element; ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Message_Kind is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Message_Kinds.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Message_Kinds.Element (Holder)); end if; end Element; ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Message_Sort is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Message_Sorts.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Message_Sorts.Element (Holder)); end if; end Element; ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Object_Node_Ordering_Kind is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Object_Node_Ordering_Kinds.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Object_Node_Ordering_Kinds.Element (Holder)); end if; end Element; ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Parameter_Direction_Kind is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Parameter_Direction_Kinds.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Parameter_Direction_Kinds.Element (Holder)); end if; end Element; ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Parameter_Effect_Kind is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Parameter_Effect_Kinds.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Parameter_Effect_Kinds.Element (Holder)); end if; end Element; ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Pseudostate_Kind is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Pseudostate_Kinds.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Pseudostate_Kinds.Element (Holder)); end if; end Element; ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Transition_Kind is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Transition_Kinds.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Transition_Kinds.Element (Holder)); end if; end Element; ------------- -- Element -- ------------- function Element (Holder : League.Holders.Holder) return AMF.UML.Optional_UML_Visibility_Kind is begin if not League.Holders.Has_Tag (Holder, AMF.UML.Holders.Visibility_Kinds.Value_Tag) then raise Constraint_Error; end if; if League.Holders.Is_Empty (Holder) then return (Is_Empty => True); else return (False, AMF.UML.Holders.Visibility_Kinds.Element (Holder)); end if; end Element; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Aggregation_Kind) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Aggregation_Kinds.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Aggregation_Kinds.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Call_Concurrency_Kind) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Call_Concurrency_Kinds.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Call_Concurrency_Kinds.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Connector_Kind) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Connector_Kinds.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Connector_Kinds.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Expansion_Kind) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Expansion_Kinds.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Expansion_Kinds.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Interaction_Operator_Kind) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Interaction_Operator_Kinds.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Interaction_Operator_Kinds.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Message_Kind) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Message_Kinds.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Message_Kinds.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Message_Sort) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Message_Sorts.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Message_Sorts.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Object_Node_Ordering_Kind) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Object_Node_Ordering_Kinds.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Object_Node_Ordering_Kinds.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Parameter_Direction_Kind) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Parameter_Direction_Kinds.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Parameter_Direction_Kinds.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Parameter_Effect_Kind) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Parameter_Effect_Kinds.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Parameter_Effect_Kinds.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Pseudostate_Kind) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Pseudostate_Kinds.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Pseudostate_Kinds.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Transition_Kind) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Transition_Kinds.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Transition_Kinds.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; --------------- -- To_Holder -- --------------- function To_Holder (Element : AMF.UML.Optional_UML_Visibility_Kind) return League.Holders.Holder is begin return Result : League.Holders.Holder do League.Holders.Set_Tag (Result, AMF.UML.Holders.Visibility_Kinds.Value_Tag); if not Element.Is_Empty then AMF.UML.Holders.Visibility_Kinds.Replace_Element (Result, Element.Value); end if; end return; end To_Holder; end AMF.UML.Holders;
samples/vasm_oldstyle/PI_gregoryLeibniz/pi.asm
MaverickAlex/x6502
0
12231
; π = (4/1) - (4/3) + (4/5) - (4/7) + (4/9) - (4/11) + (4/13) - (4/15) ... ; Take 4 and subtract 4 divided by 3. ; Then add 4 divided by 5. ; Then subtract 4 divided by 7. ; Continue alternating between adding and subtracting fractions with a numerator of 4 ; and a denominator of each subsequent odd number. The more times you do this, ; the closer you will get to pi. pi = $00 ; 3 bytes bc factor = $03 ; one byte to hold .incdir "../common" .org $8000 start: cld ;clear decimal mode clc ;clear carry bit lda #$00 ldx #$ff txs ldx #0 jsr div24_init jsr add24_init lda #1 sta pi lda #0 sta pi + 1 sta pi + 2 sta pi + 3 ; jsr init_lcd lda #$ff sta addX sta addY jsr add24; lda #1 sta dividend lda #3 sta divisor jsr div24 lda dividend sta pi BEQ exit: jmp exit .include "lcd.asm" .include "24bit_division.asm" .include "24bit_add.asm" .org $fffc .word start .word $0000
programs/oeis/245/A245627.asm
jmorken/loda
1
20309
<reponame>jmorken/loda ; A245627: Base 10 digit sum of 11*n. ; 0,2,4,6,8,10,12,14,16,18,2,4,6,8,10,12,14,16,18,11,4,6,8,10,12,14,16,18,11,13,6,8,10,12,14,16,18,11,13,15,8,10,12,14,16,18,11,13,15,17,10,12,14,16,18,11,13,15,17,19,12,14,16,18,11,13,15,17,19,21,14,16,18,11,13,15,17,19,21,23,16,18,11,13,15,17,19,21,23,25,18,2,4,6,8,10,12,14,16,18,2,4,6,8,10,12,14,16,18,20,4,6,8,10,12,14,16,18,20,13,6,8,10,12,14,16,18,20,13,15,8,10,12,14,16,18,20,13,15,17,10,12,14,16,18,20,13,15,17,19,12,14,16,18,20,13,15,17,19,21,14,16,18,20,13,15,17,19,21,23,16,18,20,13,15,17,19,21,23,25,18,20,4,6,8,10,12,14,16,18,11,4,6,8,10,12,14,16,18,20,4,6,8,10,12,14,16,18,20,22,6,8,10,12,14,16,18,20,22,15,8,10,12,14,16,18,20,22,15,17,10,12,14,16,18,20,22,15,17,19,12,14,16,18,20,22,15,17,19,21 mul $0,11 mov $1,3 lpb $0 mov $2,$0 div $0,10 mod $2,10 add $1,$2 lpe add $1,29 mul $1,4 sub $1,127 div $1,4
programs/oeis/059/A059973.asm
karttu/loda
0
80653
; A059973: Expansion of (x + x^2 - 2*x^3) / ( 1 - 4*x^2 - x^4). ; 0,1,1,2,4,9,17,38,72,161,305,682,1292,2889,5473,12238,23184,51841,98209,219602,416020,930249,1762289,3940598,7465176,16692641,31622993,70711162,133957148,299537289,567451585,1268860318,2403763488,5374978561 mov $13,$0 mov $15,$0 lpb $15,1 mov $0,$13 sub $15,1 sub $0,$15 mov $9,$0 mov $11,2 lpb $11,1 mov $0,$9 sub $11,1 add $0,$11 sub $0,1 mov $5,$0 mov $7,2 lpb $7,1 clr $0,5 mov $0,$5 sub $7,1 add $0,$7 sub $0,2 mov $1,$0 add $4,$0 sub $0,$0 trn $0,4 mul $4,2 add $4,$1 add $4,2 add $0,$4 cal $0,96748 ; Expansion of (1+x)^2/(1-x^2-x^4). mov $1,$0 mov $8,$7 lpb $8,1 mov $6,$1 sub $8,1 lpe lpe lpb $5,1 mov $5,0 sub $6,$1 lpe mov $1,$6 mov $12,$11 lpb $12,1 mov $10,$1 sub $12,1 lpe lpe lpb $9,1 mov $9,0 sub $10,$1 lpe mov $1,$10 div $1,2 add $14,$1 lpe mov $1,$14
tests/bank_default/2.asm
NullMember/customasm
414
89105
<reponame>NullMember/customasm #d8 1, 2, 3, 4 #bankdef a_new_bank {} ; error: default bank
projects/07/MemoryAccess/StaticTest/StaticTest.asm
WuShaoa/Nand2Tetris
0
9297
@111 D=A @SP A=M M=D @SP M=M+1 @333 D=A @SP A=M M=D @SP M=M+1 @888 D=A @SP A=M M=D @SP M=M+1 @StaticTest.8 D=A @R15 M=D @SP M=M-1 A=M D=M @R15 A=M M=D @StaticTest.3 D=A @R15 M=D @SP M=M-1 A=M D=M @R15 A=M M=D @StaticTest.1 D=A @R15 M=D @SP M=M-1 A=M D=M @R15 A=M M=D @StaticTest.3 D=M @SP A=M M=D @SP M=M+1 @StaticTest.1 D=M @SP A=M M=D @SP M=M+1 @SP M=M-1 A=M D=M @SP M=M-1 A=M D=M-D @SP A=M M=D @SP M=M+1 @StaticTest.8 D=M @SP A=M M=D @SP M=M+1 @SP M=M-1 A=M D=M @SP M=M-1 A=M D=D+M @SP A=M M=D @SP M=M+1
src/m3-bg-scx/m3-bg-scx-ds.asm
c-sp/age-test-roms
0
241641
; Verified: ; 2021-12-01: CPU CGB E - CPU-CGB-06 ; 2021-12-01: CPU CGB B - CPU-CGB-02 ; INCLUDE "hardware.inc" DEF CART_COMPATIBILITY EQU CART_COMPATIBLE_GBC DEF DOUBLE_SPEED EQU 1 INCLUDE "m3-bg-scx/m3-bg-scx.inc"
P6/data_P6_2/MDTest148.asm
alxzzhou/BUAA_CO_2020
1
100110
<filename>P6/data_P6_2/MDTest148.asm<gh_stars>1-10 ori $ra,$ra,0xf div $5,$ra mult $5,$5 mult $1,$1 mfhi $6 srav $6,$5,$3 lui $2,16766 addu $1,$6,$2 div $3,$ra divu $4,$ra ori $4,$5,36815 mthi $6 sb $2,7($0) div $5,$ra mthi $2 lui $5,37788 addiu $5,$5,25373 mflo $1 addu $4,$2,$2 lb $6,12($0) addu $6,$2,$4 addiu $6,$6,17296 mult $6,$6 lb $4,11($0) mflo $0 lui $1,17055 sll $4,$5,12 mfhi $5 divu $4,$ra lui $6,13598 divu $6,$ra divu $1,$ra addu $4,$2,$4 addu $4,$4,$4 addiu $5,$0,-15080 mflo $4 lb $5,8($0) multu $1,$4 ori $1,$1,36983 mfhi $2 addu $5,$4,$3 sb $5,7($0) ori $4,$4,18871 divu $4,$ra mflo $6 addiu $4,$3,7429 lui $0,33336 lb $1,9($0) srav $4,$4,$4 addiu $5,$0,-7054 srav $5,$1,$1 multu $1,$2 multu $1,$4 div $0,$ra multu $6,$5 mflo $5 addiu $5,$1,-29702 addu $1,$1,$4 mult $2,$2 lui $4,26756 ori $5,$2,48945 addu $6,$2,$6 sll $4,$2,28 sll $3,$4,20 mflo $1 lui $5,52834 ori $6,$4,16922 srav $4,$1,$3 ori $1,$0,30433 lui $3,26649 lui $1,41570 mthi $0 multu $0,$3 addiu $4,$6,-22398 addu $5,$5,$3 div $1,$ra divu $5,$ra sll $4,$2,6 addiu $4,$4,23810 multu $4,$1 divu $3,$ra sb $2,4($0) mtlo $1 srav $4,$4,$3 mfhi $0 mfhi $3 addu $1,$0,$0 sb $0,13($0) sll $2,$2,5 mtlo $0 mtlo $5 lui $6,14166 addu $0,$1,$3 mult $1,$4 divu $1,$ra mthi $4 sb $1,9($0) divu $0,$ra lui $4,23142 ori $6,$4,11124 sll $4,$1,19 mult $5,$5 multu $5,$4 sll $1,$4,19 mtlo $4 divu $0,$ra sll $0,$4,13 addu $5,$5,$3 lui $3,36067 mthi $3 lui $6,52661 ori $6,$5,22373 mfhi $2 lb $0,6($0) srav $1,$5,$5 mtlo $3 addiu $6,$2,-19480 mthi $4 lb $5,1($0) addiu $3,$3,11120 mfhi $4 mtlo $1 mthi $3 multu $4,$6 multu $1,$6 sll $3,$5,3 lb $4,1($0) addu $6,$1,$3 mthi $4 mult $5,$2 mtlo $3 sll $4,$4,4 mult $3,$3 mfhi $5 mtlo $5 sll $6,$4,3 lb $4,8($0) mtlo $5 ori $3,$4,2817 sb $4,2($0) addu $1,$5,$3 addu $2,$2,$5 mult $5,$1 mtlo $4 sll $5,$5,2 mfhi $6 div $3,$ra addiu $2,$2,3888 addiu $2,$2,-15036 addiu $6,$4,13092 lui $4,32486 mthi $4 mthi $3 mtlo $2 addiu $2,$2,29958 ori $1,$2,4539 sll $6,$3,2 mthi $5 divu $4,$ra multu $1,$1 sb $4,16($0) lui $1,37707 sll $1,$1,26 mtlo $2 mthi $1 lb $1,12($0) srav $1,$4,$3 divu $4,$ra srav $1,$4,$3 lb $1,6($0) div $2,$ra divu $6,$ra mflo $4 lb $1,3($0) div $0,$ra lb $4,11($0) srav $5,$5,$4 lb $4,11($0) srav $1,$1,$2 mflo $4 addu $6,$6,$4 addu $1,$2,$1 multu $4,$2 sb $4,2($0) addu $4,$4,$3 addu $4,$2,$4 ori $2,$2,773 mthi $5 addiu $0,$0,13194 divu $0,$ra mult $5,$1 divu $4,$ra mfhi $1 mthi $1 multu $3,$4 srav $6,$1,$3 mflo $1 lb $6,10($0) srav $5,$5,$5 mtlo $5 divu $4,$ra sll $4,$2,7 div $5,$ra divu $1,$ra addu $4,$1,$5 mult $1,$0 lb $5,5($0) addu $1,$4,$2 lui $4,13172 addu $5,$1,$5 lb $4,6($0) sb $5,10($0) lb $2,9($0) addiu $3,$3,8010 srav $4,$1,$5 addu $5,$5,$1 div $1,$ra addiu $5,$5,-27077 multu $1,$3 ori $1,$1,20885 divu $6,$ra mult $4,$0 div $6,$ra addiu $6,$4,23387 ori $1,$2,56506 mflo $4 divu $4,$ra div $2,$ra ori $5,$4,56867 mtlo $1 mthi $1 srav $5,$2,$5 srav $6,$2,$6 addu $0,$1,$1 divu $5,$ra addiu $1,$1,23281 mfhi $3 sll $4,$1,9 mflo $5 addiu $5,$1,1416 srav $4,$1,$3 div $3,$ra srav $2,$4,$2 div $2,$ra div $1,$ra mtlo $0 sb $5,14($0) mult $2,$2 ori $4,$6,7295 ori $1,$6,4124 mtlo $4 sb $4,12($0) div $2,$ra mflo $3 multu $4,$5 sll $4,$5,25 srav $6,$6,$3 multu $3,$5 multu $4,$3 lui $0,8757 srav $1,$2,$1 mtlo $4 mfhi $5 srav $4,$1,$2 lb $3,4($0) divu $1,$ra lb $4,16($0) mult $2,$0 sll $4,$4,30 mult $4,$4 mult $0,$3 lui $0,43374 div $3,$ra lb $4,11($0) lui $0,63890 sb $2,1($0) sll $5,$5,10 div $6,$ra div $2,$ra mthi $2 addiu $3,$2,9754 mult $6,$5 ori $3,$4,3295 multu $4,$2 mfhi $6 divu $4,$ra lui $4,59244 divu $1,$ra mthi $2 ori $3,$2,30247 lb $1,5($0) sb $1,15($0) mflo $4 ori $3,$2,58831 divu $4,$ra mflo $4 mfhi $1 mfhi $5 mtlo $0 mthi $2 ori $1,$2,41252 sb $1,16($0) mthi $3 mflo $2 mtlo $0 divu $3,$ra ori $4,$4,11330 addiu $3,$1,-847 divu $1,$ra mthi $4 addu $0,$4,$4 sb $1,4($0) mfhi $4 divu $4,$ra sb $5,14($0) lb $4,16($0) div $1,$ra mflo $2 sll $2,$2,31 divu $4,$ra mfhi $4 div $1,$ra mtlo $4 srav $5,$4,$4 mfhi $4 mtlo $1 mult $5,$0 lui $4,22420 ori $4,$4,7677 mult $2,$2 lb $0,16($0) sb $3,3($0) divu $4,$ra mthi $1 mthi $1 addiu $4,$4,1108 mflo $4 lui $3,58749 multu $5,$4 mtlo $4 div $6,$ra addiu $1,$1,-7036 addu $4,$2,$6 mult $1,$2 sb $1,9($0) mtlo $5 sll $4,$4,5 mult $0,$4 addiu $0,$1,-30977 divu $3,$ra mtlo $0 lui $1,18440 sb $5,7($0) mflo $4 ori $6,$4,4990 mtlo $4 divu $3,$ra lui $2,34033 mthi $1 mthi $4 divu $1,$ra sb $5,11($0) sb $6,10($0) mflo $5 divu $4,$ra lb $1,12($0) addu $6,$6,$6 ori $3,$0,45531 mflo $2 divu $3,$ra lui $4,46405 mult $3,$5 addu $0,$1,$1 sll $5,$5,13 sll $4,$1,9 sll $5,$2,15 lb $4,11($0) lb $4,6($0) sb $6,12($0) addu $1,$2,$1 sll $0,$2,12 lui $6,18860 lb $1,15($0) mflo $4 sll $6,$6,20 ori $4,$2,41202 mult $1,$2 mtlo $1 div $4,$ra mtlo $6 lui $5,32491 sll $4,$1,18 srav $5,$2,$2 mtlo $1 addu $2,$2,$2 srav $1,$1,$1 srav $4,$0,$1 lb $2,11($0) srav $3,$5,$3 lui $4,34578 lui $0,43222 addiu $2,$2,24533 div $5,$ra multu $5,$5 addiu $1,$2,-27793 lui $3,11012 mfhi $5 addu $2,$2,$4 sll $1,$1,23 sb $5,10($0) mtlo $4 lb $4,15($0) mflo $4 mthi $3 lui $1,56192 lui $4,54477 mthi $6 div $6,$ra mfhi $5 ori $4,$2,48689 srav $2,$2,$2 mthi $6 addiu $5,$0,22156 div $4,$ra divu $4,$ra mthi $4 lui $4,995 mult $4,$4 lb $1,16($0) div $4,$ra div $1,$ra mflo $6 sll $4,$6,26 mthi $6 mthi $5 multu $1,$1 addu $0,$5,$4 mthi $0 div $4,$ra lui $6,3644 mult $2,$2 div $0,$ra mthi $4 mthi $4 div $0,$ra ori $1,$1,52715 mthi $3 lb $5,12($0) lui $4,63281 mthi $1 lb $5,11($0) div $4,$ra ori $1,$2,4657 ori $4,$4,62307 srav $6,$2,$3 addu $3,$3,$3 lui $6,7248 mfhi $1 mtlo $4 mtlo $3 div $5,$ra sll $2,$2,29 ori $4,$2,37072 mflo $4 div $2,$ra lb $2,0($0) mthi $4 sb $2,15($0) mthi $0 addu $1,$2,$2 div $1,$ra divu $4,$ra mfhi $5 mult $2,$2 mtlo $1 ori $3,$3,9923 mult $5,$2 divu $4,$ra mfhi $5 mtlo $4 mthi $4 addiu $6,$5,4140 ori $5,$2,15865 divu $6,$ra addu $2,$2,$3 mfhi $5 multu $1,$4 addu $4,$5,$5 sb $3,4($0) ori $2,$1,18277 sb $3,13($0) addiu $4,$5,11368 sll $6,$3,13 sb $4,2($0) mtlo $4 mthi $5 srav $1,$2,$5 srav $5,$1,$5 lb $2,9($0) addu $1,$4,$6 srav $1,$5,$6 div $2,$ra mflo $3 sll $5,$1,18 srav $5,$2,$6 mult $1,$3 ori $5,$5,62303 lb $4,12($0) lui $3,62515 mthi $4 multu $0,$2 addiu $0,$0,-23463 lb $1,6($0) sll $0,$0,27 mtlo $3 ori $4,$4,14657 ori $0,$5,32205 mflo $1 div $0,$ra div $3,$ra srav $4,$4,$1 sll $5,$5,16 lb $2,7($0) mfhi $5 mflo $3 sb $1,5($0) mtlo $1 multu $4,$4 addu $4,$4,$3 mult $5,$2 mfhi $1 srav $2,$2,$2 mult $1,$0 multu $6,$5 lui $5,25188 mult $6,$6 mult $5,$4 divu $2,$ra addu $0,$4,$5 srav $6,$5,$3 mtlo $1 lb $0,15($0) srav $5,$5,$5 srav $4,$4,$4 mthi $1 mfhi $5 lui $3,14726 sll $0,$4,27 div $0,$ra addu $1,$4,$2 lui $5,62597 mthi $4 mflo $2 addu $1,$1,$1 multu $4,$4 divu $4,$ra mthi $3 sll $1,$1,13 srav $6,$6,$6 sb $4,11($0) mflo $4 mflo $1 mtlo $6 sb $6,9($0) srav $0,$0,$0 div $1,$ra mthi $1 mtlo $1 addiu $5,$4,24040 mult $5,$1 addu $2,$2,$1 ori $3,$3,45901 multu $4,$4 srav $4,$4,$2 multu $3,$3 sb $4,2($0) mult $4,$4 mult $4,$5 mthi $2 mult $2,$2 mult $1,$1 mult $4,$4 sb $4,14($0) sll $0,$4,30 multu $1,$4 sb $3,12($0) lb $6,16($0) sb $0,13($0) mflo $5 div $5,$ra sb $1,3($0) div $0,$ra addiu $4,$0,19417 sll $3,$1,10 mtlo $1 divu $4,$ra sll $0,$2,21 div $1,$ra addiu $5,$2,9294 ori $5,$5,52292 ori $4,$4,34541 mthi $3 addiu $3,$5,22557 multu $4,$4 mtlo $4 lui $4,61776 mflo $1 addu $1,$1,$5 div $0,$ra sb $4,9($0) mult $5,$2 srav $4,$4,$4 mtlo $1 mthi $1 multu $3,$6 mthi $2 mflo $5 mflo $1 divu $1,$ra srav $2,$1,$2 ori $0,$1,23242 sb $5,11($0) mtlo $2 divu $5,$ra srav $4,$1,$2 mtlo $1 lb $2,5($0) mflo $0 mtlo $4 sb $0,10($0) mult $1,$4 addiu $1,$4,9961 sll $3,$3,14 srav $5,$5,$5 sll $1,$5,12 divu $0,$ra div $0,$ra lb $1,13($0) mthi $4 sb $1,13($0) divu $4,$ra mthi $2 mult $6,$4 mthi $4 div $5,$ra mtlo $4 lui $2,54584 sb $4,16($0) ori $4,$1,26105 lb $5,13($0) mthi $2 srav $1,$4,$6 mtlo $5 mflo $4 mflo $1 mtlo $6 mfhi $6 mfhi $5 mfhi $3 mflo $4 mult $1,$4 mflo $0 div $4,$ra lui $5,59781 lui $6,8120 addiu $4,$4,4752 sb $5,16($0) mflo $5 sll $5,$5,26 lui $1,51631 srav $2,$4,$2 ori $1,$0,17995 lui $3,58077 sll $4,$2,10 srav $5,$1,$5 div $3,$ra divu $3,$ra divu $5,$ra mfhi $6 addiu $5,$1,-29186 div $5,$ra lui $1,20430 mult $3,$2 sll $5,$6,18 divu $1,$ra mfhi $6 srav $0,$0,$3 div $1,$ra sb $2,0($0) lb $2,16($0) srav $5,$5,$5 mthi $1 addu $0,$4,$0 mfhi $1 divu $3,$ra lb $6,14($0) div $0,$ra lui $1,24149 srav $5,$4,$5 mfhi $2 sb $2,1($0) srav $6,$5,$2 sll $2,$2,22 div $1,$ra mfhi $4 mflo $6 mtlo $4 div $2,$ra div $3,$ra mthi $1 ori $4,$3,37927 sll $5,$1,30 divu $0,$ra div $4,$ra sll $2,$2,6 mult $4,$4 mult $5,$4 mtlo $4 divu $1,$ra srav $4,$4,$4 lui $5,23812 mflo $3 sll $5,$5,11 sb $1,1($0) ori $0,$3,62139 multu $4,$2 lui $5,41634 sll $4,$2,10 addu $6,$1,$3 lui $5,10803 div $4,$ra divu $1,$ra mult $5,$2 mtlo $5 sll $4,$4,24 sb $5,2($0) multu $4,$4 divu $5,$ra addiu $3,$5,30378 mfhi $5 srav $5,$4,$5 sb $6,3($0) mthi $4 mfhi $5 mfhi $3 sll $4,$4,8 srav $0,$5,$2 lui $4,38587 lb $1,8($0) srav $5,$2,$2 divu $1,$ra div $1,$ra mfhi $1 addiu $1,$5,-21522 lui $6,64114 mfhi $6 mtlo $6 div $0,$ra sll $4,$2,15 addu $3,$1,$3 divu $2,$ra div $1,$ra addu $3,$5,$3 mthi $6 lb $2,7($0) ori $4,$0,65320 mult $1,$4 mtlo $3 mtlo $2 ori $5,$1,42476 sb $3,12($0) multu $1,$6 sll $5,$5,5 sll $6,$6,23 mthi $1 multu $5,$2 mflo $5 addiu $5,$3,30140 lb $3,13($0) addiu $0,$1,-5319 mfhi $1 sb $5,11($0) divu $3,$ra lui $4,26398 div $5,$ra mfhi $3 mflo $1 sll $1,$5,13 sb $5,5($0) divu $5,$ra ori $6,$6,60757 lb $1,0($0) div $2,$ra ori $2,$2,62839 srav $4,$4,$4 lui $4,19157 addu $5,$4,$2 mtlo $5 mflo $4 srav $4,$0,$4 ori $1,$1,17638 mult $4,$4 sb $0,14($0) mfhi $0 mult $6,$4 mult $5,$0 lb $5,5($0) div $2,$ra addu $4,$0,$2 addu $4,$2,$2 mult $5,$3 sb $4,6($0) div $4,$ra multu $5,$1 ori $4,$4,50641 lui $5,35991 div $1,$ra mthi $1 ori $4,$4,13348 mflo $0 mthi $1 lui $5,3835 lb $1,6($0) sll $5,$2,23 sll $6,$6,19 mult $3,$3 multu $1,$0 divu $0,$ra mthi $6 multu $4,$1 sll $1,$5,27 div $1,$ra sll $1,$5,10 addu $6,$4,$2 addu $2,$5,$2 mtlo $4 addu $6,$2,$2 mfhi $3 addu $3,$2,$3 divu $4,$ra mthi $6 mult $1,$2 multu $4,$5 mflo $0 srav $5,$0,$4 lb $6,5($0) addiu $0,$5,-32216 addu $5,$5,$4 sb $4,13($0) mflo $4 srav $1,$2,$2 lb $5,4($0) lui $1,40962 divu $1,$ra lui $4,20658 lui $6,5337 mflo $5 multu $2,$2 sll $4,$0,7 srav $1,$0,$0 mthi $6 mflo $6 mult $1,$4 addu $4,$2,$2 addu $5,$5,$5 mult $6,$4 multu $5,$5 divu $5,$ra ori $6,$1,10087 sb $4,7($0) lb $6,7($0) mfhi $4 mtlo $6 mfhi $4 mflo $2 mflo $0 mult $4,$1 div $6,$ra lui $1,32413 lb $3,7($0) srav $4,$4,$5 mthi $2 ori $1,$4,50065 mflo $1 srav $5,$4,$1 mult $4,$1 mfhi $5 lb $4,16($0) lui $5,62515
Transynther/x86/_processed/AVXALIGN/_st_/i3-7100_9_0x84_notsx.log_21829_1086.asm
ljhsiun2/medusa
9
88110
<filename>Transynther/x86/_processed/AVXALIGN/_st_/i3-7100_9_0x84_notsx.log_21829_1086.asm .global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r15 push %r9 push %rbx push %rcx push %rdx // Store lea addresses_PSE+0xe878, %r11 nop nop nop dec %r9 mov $0x5152535455565758, %rcx movq %rcx, %xmm3 vmovups %ymm3, (%r11) nop nop nop nop nop xor $45800, %rcx // Faulty Load lea addresses_WC+0x18790, %r12 nop nop nop nop add $53784, %rbx mov (%r12), %r11d lea oracles, %r9 and $0xff, %r11 shlq $12, %r11 mov (%r9,%r11,1), %r11 pop %rdx pop %rcx pop %rbx pop %r9 pop %r15 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_WC', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_PSE', 'same': False, 'size': 32, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_WC', 'same': True, 'size': 4, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'38': 21829} 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 */
.emacs.d/elpa/wisi-3.1.3/wisitoken-syntax_trees.adb
caqg/linux-home
0
15643
<gh_stars>0 -- Abstract : -- -- See spec. -- -- Copyright (C) 2018 - 2020 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (Modified_GPL); with Ada.Containers; with Ada.Text_IO; with SAL.Generic_Decimal_Image; package body WisiToken.Syntax_Trees is -- Body specs, alphabetical, as needed function Image (Tree : in Syntax_Trees.Tree; N : in Syntax_Trees.Node; Node_Index : in Valid_Node_Index; Descriptor : in WisiToken.Descriptor; Include_Children : in Boolean; Include_RHS_Index : in Boolean := False; Node_Numbers : in Boolean := False) return String; procedure Move_Branch_Point (Tree : in out Syntax_Trees.Tree; Required_Node : in Valid_Node_Index); type Visit_Parent_Mode is (Before, After); function Process_Tree (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Visit_Parent : in Visit_Parent_Mode; Process_Node : access function (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean) return Boolean; -- Call Process_Node on nodes in tree rooted at Node. Return when -- Process_Node returns False (Process_Tree returns False), or when -- all nodes have been processed (Process_Tree returns True). procedure Set_Children (Tree : in out Syntax_Trees.Tree; Parent : in Valid_Node_Index; Children : in Valid_Node_Index_Array); ---------- -- Public and body operations, alphabetical function Action (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Semantic_Action is begin return (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).Action else Tree.Branched_Nodes (Node).Action); end Action; procedure Add_Child (Tree : in out Syntax_Trees.Tree; Parent : in Valid_Node_Index; Child : in Valid_Node_Index) is Node : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Parent); begin Node.Children.Append (Child); Tree.Shared_Tree.Nodes (Child).Parent := Parent; end Add_Child; function Add_Identifier (Tree : in out Syntax_Trees.Tree; ID : in Token_ID; Identifier : in Identifier_Index; Byte_Region : in WisiToken.Buffer_Region) return Valid_Node_Index is begin Tree.Shared_Tree.Nodes.Append ((Label => Virtual_Identifier, Byte_Region => Byte_Region, ID => ID, Identifier => Identifier, others => <>)); Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; return Tree.Last_Shared_Node; end Add_Identifier; function Add_Nonterm (Tree : in out Syntax_Trees.Tree; Production : in WisiToken.Production_ID; Children : in Valid_Node_Index_Array; Action : in Semantic_Action := null; Default_Virtual : in Boolean := False) return Valid_Node_Index is Nonterm_Node : Valid_Node_Index; begin if Tree.Flush then Tree.Shared_Tree.Nodes.Append ((Label => Syntax_Trees.Nonterm, ID => Production.LHS, Action => Action, RHS_Index => Production.RHS, Virtual => (if Children'Length = 0 then Default_Virtual else False), others => <>)); Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; Nonterm_Node := Tree.Last_Shared_Node; else Tree.Branched_Nodes.Append ((Label => Syntax_Trees.Nonterm, ID => Production.LHS, Action => Action, RHS_Index => Production.RHS, Virtual => (if Children'Length = 0 then Default_Virtual else False), others => <>)); Nonterm_Node := Tree.Branched_Nodes.Last_Index; end if; if Children'Length = 0 then return Nonterm_Node; end if; Set_Children (Tree, Nonterm_Node, Children); return Nonterm_Node; end Add_Nonterm; function Add_Terminal (Tree : in out Syntax_Trees.Tree; Terminal : in Token_Index; Terminals : in Base_Token_Arrays.Vector) return Valid_Node_Index is begin if Tree.Flush then Tree.Shared_Tree.Nodes.Append ((Label => Shared_Terminal, ID => Terminals (Terminal).ID, Byte_Region => Terminals (Terminal).Byte_Region, Terminal => Terminal, others => <>)); Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; return Tree.Last_Shared_Node; else Tree.Branched_Nodes.Append ((Label => Shared_Terminal, ID => Terminals (Terminal).ID, Byte_Region => Terminals (Terminal).Byte_Region, Terminal => Terminal, others => <>)); return Tree.Branched_Nodes.Last_Index; end if; end Add_Terminal; function Add_Terminal (Tree : in out Syntax_Trees.Tree; Terminal : in Token_ID; Before : in Base_Token_Index := Invalid_Token_Index) return Valid_Node_Index is begin if Tree.Flush then Tree.Shared_Tree.Nodes.Append ((Label => Virtual_Terminal, ID => Terminal, Before => Before, others => <>)); Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; return Tree.Last_Shared_Node; else Tree.Branched_Nodes.Append ((Label => Virtual_Terminal, ID => Terminal, Before => Before, others => <>)); return Tree.Branched_Nodes.Last_Index; end if; end Add_Terminal; function Before (Tree : in Syntax_Trees.Tree; Virtual_Terminal : in Valid_Node_Index) return Base_Token_Index is begin if Tree.Flush then return Tree.Shared_Tree.Nodes (Virtual_Terminal).Before; else return Tree.Branched_Nodes (Virtual_Terminal).Before; end if; end Before; function Augmented (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Base_Token_Class_Access is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Augmented; else return Tree.Branched_Nodes (Node).Augmented; end if; end Augmented; function Augmented_Const (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Base_Token_Class_Access_Constant is begin if Node <= Tree.Last_Shared_Node then return Base_Token_Class_Access_Constant (Tree.Shared_Tree.Nodes (Node).Augmented); else return Base_Token_Class_Access_Constant (Tree.Branched_Nodes (Node).Augmented); end if; end Augmented_Const; function Buffer_Region_Is_Empty (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Byte_Region = Null_Buffer_Region; else return Tree.Branched_Nodes (Node).Byte_Region = Null_Buffer_Region; end if; end Buffer_Region_Is_Empty; function Byte_Region (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return WisiToken.Buffer_Region is begin return (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).Byte_Region else Tree.Branched_Nodes (Node).Byte_Region); end Byte_Region; function Child (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Child_Index : in Positive_Index_Type) return Node_Index is function Compute (N : in Syntax_Trees.Node) return Node_Index is begin if N.Label /= Nonterm then return Invalid_Node_Index; elsif Child_Index in N.Children.First_Index .. N.Children.Last_Index then return N.Children (Child_Index); else return Invalid_Node_Index; end if; end Compute; begin if Node <= Tree.Last_Shared_Node then return Compute (Tree.Shared_Tree.Nodes (Node)); else return Compute (Tree.Branched_Nodes (Node)); end if; end Child; function Child_Count (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Ada.Containers.Count_Type is begin return Tree.Get_Node_Const_Ref (Node).Children.Length; end Child_Count; function Child_Index (N : in Node; Child : in Valid_Node_Index) return SAL.Peek_Type is begin for I in N.Children.First_Index .. N.Children.Last_Index loop if N.Children (I) = Child then return I; end if; end loop; raise SAL.Programmer_Error; -- Should be prevented by precondition end Child_Index; function Child_Index (Tree : in out Syntax_Trees.Tree; Parent : in Valid_Node_Index; Child : in Valid_Node_Index) return SAL.Peek_Type is N : Node_Var_Ref renames Get_Node_Var_Ref (Tree, Parent); begin return Child_Index (N, Child); end Child_Index; function Children (N : in Syntax_Trees.Node) return Valid_Node_Index_Array is begin if N.Children.Length = 0 then return (1 .. 0 => <>); else return Result : Valid_Node_Index_Array (N.Children.First_Index .. N.Children.Last_Index) do for I in Result'Range loop Result (I) := N.Children (I); end loop; end return; end if; end Children; function Children (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Valid_Node_Index_Array is begin if Node <= Tree.Last_Shared_Node then return Children (Tree.Shared_Tree.Nodes (Node)); else return Children (Tree.Branched_Nodes (Node)); end if; end Children; procedure Clear (Tree : in out Syntax_Trees.Base_Tree) is begin Tree.Finalize; end Clear; procedure Clear (Tree : in out Syntax_Trees.Tree) is begin if Tree.Shared_Tree.Augmented_Present then for Node of Tree.Branched_Nodes loop if Node.Label = Nonterm then Free (Node.Augmented); end if; end loop; end if; Tree.Shared_Tree.Finalize; Tree.Last_Shared_Node := Invalid_Node_Index; Tree.Branched_Nodes.Clear; end Clear; function Copy_Subtree (Tree : in out Syntax_Trees.Tree; Root : in Valid_Node_Index) return Valid_Node_Index is function Copy_Node (Tree : in out Syntax_Trees.Tree; Index : in Valid_Node_Index; Parent : in Node_Index) return Valid_Node_Index is begin case Tree.Shared_Tree.Nodes (Index).Label is when Shared_Terminal => declare Node : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Index); begin Tree.Shared_Tree.Nodes.Append ((Label => Shared_Terminal, ID => Node.ID, Byte_Region => Node.Byte_Region, Parent => Parent, State => Unknown_State, Augmented => Node.Augmented, Terminal => Node.Terminal)); end; when Virtual_Terminal => declare Node : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Index); begin Tree.Shared_Tree.Nodes.Append ((Label => Virtual_Terminal, ID => Node.ID, Byte_Region => Node.Byte_Region, Parent => Parent, State => Unknown_State, Augmented => Node.Augmented, Before => Node.Before)); end; when Virtual_Identifier => declare Node : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Index); begin Tree.Shared_Tree.Nodes.Append ((Label => Virtual_Identifier, ID => Node.ID, Byte_Region => Node.Byte_Region, Parent => Parent, State => Unknown_State, Augmented => Node.Augmented, Identifier => Node.Identifier)); end; when Nonterm => declare Children : constant Valid_Node_Index_Array := Tree.Children (Index); Parent : Node_Index := Invalid_Node_Index; New_Children : Valid_Node_Index_Arrays.Vector; begin if Children'Length > 0 then New_Children.Set_First_Last (Children'First, Children'Last); for I in Children'Range loop New_Children (I) := Copy_Node (Tree, Children (I), Parent); end loop; end if; declare Node : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Index); begin Tree.Shared_Tree.Nodes.Append ((Label => Nonterm, ID => Node.ID, Byte_Region => Node.Byte_Region, Parent => Parent, State => Unknown_State, Augmented => Node.Augmented, Virtual => Node.Virtual, RHS_Index => Node.RHS_Index, Action => Node.Action, Name => Node.Name, Children => New_Children, Min_Terminal_Index => Node.Min_Terminal_Index)); end; Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; Parent := Tree.Last_Shared_Node; for I in New_Children.First_Index .. New_Children.Last_Index loop Tree.Shared_Tree.Nodes (New_Children (I)).Parent := Parent; end loop; return Parent; end; end case; Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; return Tree.Last_Shared_Node; end Copy_Node; begin return Copy_Node (Tree, Root, Invalid_Node_Index); end Copy_Subtree; function Count_IDs (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID) return SAL.Base_Peek_Type is function Compute (N : in Syntax_Trees.Node) return SAL.Base_Peek_Type is use all type SAL.Base_Peek_Type; begin return Result : SAL.Base_Peek_Type := 0 do if N.ID = ID then Result := 1; end if; case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => null; when Nonterm => for I of N.Children loop -- We don't check for Deleted_Child here; encountering one indicates -- an error in the user algorithm. Result := Result + Count_IDs (Tree, I, ID); end loop; end case; end return; end Compute; begin return Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Count_IDs; function Count_Terminals (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Integer -- Count_Terminals must return Integer for Get_Terminals, -- Positive_Index_Type for Get_Terminal_IDs. is function Compute (N : in Syntax_Trees.Node) return Integer is begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return 1; when Nonterm => return Result : Integer := 0 do for C of N.Children loop -- This can be called to build a debugging image while editing the tree if C /= Deleted_Child then Result := Result + Count_Terminals (Tree, C); end if; end loop; end return; end case; end Compute; begin return Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Count_Terminals; procedure Delete_Parent (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index) is N : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Node); Parent : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (N.Parent); begin Parent.Children (Child_Index (Parent, Node)) := Deleted_Child; if N.Parent = Tree.Root then Tree.Root := Node; end if; N.Parent := Invalid_Node_Index; end Delete_Parent; function Error_Message (Tree : in Syntax_Trees.Tree; Terminals : in Base_Token_Array_Access_Constant; Node : in Valid_Node_Index; File_Name : in String; Message : in String) return String is First_Terminal : constant Valid_Node_Index := Tree.First_Terminal (Node); Line : Line_Number_Type := Line_Number_Type'First; Column : Ada.Text_IO.Count := Ada.Text_IO.Count'First; begin case Tree.Label (First_Terminal) is when Shared_Terminal => declare Token : Base_Token renames Terminals.all (Tree.First_Shared_Terminal (First_Terminal)); begin Line := Token.Line; Column := Token.Column; end; when Virtual_Terminal | Virtual_Identifier => Line := Line_Number_Type'First; Column := Ada.Text_IO.Count (Tree.Byte_Region (First_Terminal).First); when others => null; end case; return WisiToken.Error_Message (File_Name, Line, Column, Message); end Error_Message; overriding procedure Finalize (Tree : in out Base_Tree) is begin Tree.Traversing := False; Tree.Parents_Set := False; if Tree.Augmented_Present then for Node of Tree.Nodes loop if Node.Label = Nonterm then Free (Node.Augmented); end if; end loop; Tree.Augmented_Present := False; end if; Tree.Nodes.Finalize; end Finalize; overriding procedure Finalize (Tree : in out Syntax_Trees.Tree) is begin if Tree.Last_Shared_Node /= Invalid_Node_Index then -- Tree.Branched_Nodes Augmented are shallow copies of -- Tree.Shared_Tree.Nodes Augmented, so we don't free them there; -- they are freed in Base_Tree.Finalize above. Tree.Branched_Nodes.Finalize; Tree.Last_Shared_Node := Invalid_Node_Index; Tree.Shared_Tree := null; end if; end Finalize; function Insert_After (User_Data : in out User_Data_Type; Tree : in Syntax_Trees.Tree'Class; Token : in Valid_Node_Index; Insert_On_Blank_Line : in Boolean) return Boolean is pragma Unreferenced (User_Data, Tree, Token, Insert_On_Blank_Line); begin return False; end Insert_After; function Find_Ancestor (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID; Max_Parent : in Boolean := False) return Node_Index is N : Node_Index := Node; Last_Parent : Node_Index := Invalid_Node_Index; begin loop N := (if N <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (N).Parent else Tree.Branched_Nodes (N).Parent); exit when N = Invalid_Node_Index; Last_Parent := N; exit when ID = (if N <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (N).ID else Tree.Branched_Nodes (N).ID); end loop; return (if Max_Parent then Last_Parent else N); end Find_Ancestor; function Find_Ancestor (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; IDs : in Token_ID_Array; Max_Parent : in Boolean := False) return Node_Index is N : Node_Index := Node; Last_Parent : Node_Index := Invalid_Node_Index; begin loop N := (if N <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (N).Parent else Tree.Branched_Nodes (N).Parent); exit when N = Invalid_Node_Index; Last_Parent := N; exit when (for some ID of IDs => ID = (if N <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (N).ID else Tree.Branched_Nodes (N).ID)); end loop; return (if Max_Parent then Last_Parent else N); end Find_Ancestor; function Find_Child (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID) return Node_Index is function Compute (N : in Syntax_Trees.Node) return Node_Index is begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return Invalid_Node_Index; when Nonterm => for C of N.Children loop if C /= Deleted_Child then if ID = (if C <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (C).ID else Tree.Branched_Nodes (C).ID) then return C; end if; end if; end loop; return Invalid_Node_Index; end case; end Compute; begin return Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Find_Child; function Find_Descendant (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID) return Node_Index is Found : Node_Index := Invalid_Node_Index; function Process (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is Node_ID : constant Token_ID := (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).ID else Tree.Branched_Nodes (Node).ID); begin if Node_ID = ID then Found := Node; return False; else return True; end if; end Process; Junk : constant Boolean := Process_Tree (Tree, Node, Before, Process'Access); pragma Unreferenced (Junk); begin return Found; end Find_Descendant; function Find_Descendant (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Predicate : access function (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean) return Node_Index is Found : Node_Index := Invalid_Node_Index; function Process (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin if Predicate (Tree, Node) then Found := Node; return False; else return True; end if; end Process; Junk : constant Boolean := Process_Tree (Tree, Node, Before, Process'Access); pragma Unreferenced (Junk); begin return Found; end Find_Descendant; function Find_Sibling (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID) return Node_Index is function Compute_2 (N : in Syntax_Trees.Node) return Node_Index is begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return Invalid_Node_Index; when Nonterm => for C of N.Children loop if C /= Deleted_Child then if ID = (if C <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (C).ID else Tree.Branched_Nodes (C).ID) then return C; end if; end if; end loop; return Invalid_Node_Index; end case; end Compute_2; function Compute_1 (Parent : in Node_Index) return Node_Index is begin if Parent = Invalid_Node_Index then return Invalid_Node_Index; else return Compute_2 ((if Parent <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Parent) else Tree.Branched_Nodes (Parent))); end if; end Compute_1; begin return Compute_1 ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).Parent else Tree.Branched_Nodes (Node).Parent)); end Find_Sibling; function First_Index (Tree : in Syntax_Trees.Tree) return Node_Index is begin return Tree.Shared_Tree.Nodes.First_Index; end First_Index; procedure Flush (Tree : in out Syntax_Trees.Tree) is begin -- This is the opposite of Move_Branch_Point Tree.Shared_Tree.Nodes.Merge (Tree.Branched_Nodes); Tree.Last_Shared_Node := Tree.Shared_Tree.Nodes.Last_Index; Tree.Flush := True; end Flush; function Flushed (Tree : in Syntax_Trees.Tree) return Boolean is begin return Tree.Flush; end Flushed; procedure Get_IDs (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID; Result : in out Valid_Node_Index_Array; Last : in out SAL.Base_Peek_Type) is use all type SAL.Base_Peek_Type; procedure Compute (N : in Syntax_Trees.Node) is begin if N.ID = ID then Last := Last + 1; Result (Last) := Node; end if; case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => null; when Nonterm => for I of N.Children loop -- Encountering Deleted_Child here is an error in the user algorithm. Get_IDs (Tree, I, ID, Result, Last); end loop; end case; end Compute; begin Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Get_IDs; function Get_IDs (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID) return Valid_Node_Index_Array is Last : SAL.Base_Peek_Type := 0; begin Tree.Shared_Tree.Traversing := True; return Result : Valid_Node_Index_Array (1 .. Count_IDs (Tree, Node, ID)) do Get_IDs (Tree, Node, ID, Result, Last); Tree.Shared_Tree.Traversing := False; end return; end Get_IDs; procedure Get_Terminals (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Result : in out Valid_Node_Index_Array; Last : in out SAL.Base_Peek_Type) is use all type SAL.Base_Peek_Type; procedure Compute (N : in Syntax_Trees.Node) is begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => Last := Last + 1; Result (Last) := Node; when Nonterm => for C of N.Children loop -- This is called to build an edited source image while editing the tree if C /= Deleted_Child then Get_Terminals (Tree, C, Result, Last); end if; end loop; end case; end Compute; begin Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Get_Terminals; function Get_Terminals (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Valid_Node_Index_Array is Last : SAL.Base_Peek_Type := 0; begin Tree.Shared_Tree.Traversing := True; return Result : Valid_Node_Index_Array (1 .. SAL.Base_Peek_Type (Count_Terminals (Tree, Node))) do Get_Terminals (Tree, Node, Result, Last); Tree.Shared_Tree.Traversing := False; end return; end Get_Terminals; function First_Terminal (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Node_Index is function Compute (Index : in Valid_Node_Index; N : in Syntax_Trees.Node) return Node_Index is begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return Index; when Nonterm => for C of N.Children loop -- Encountering Deleted_Child here is an error in the user algorithm. declare Term : constant Node_Index := First_Terminal (Tree, C); begin if Term /= Invalid_Node_Index then return Term; end if; end; end loop; return Invalid_Node_Index; end case; end Compute; begin return Compute (Node, (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end First_Terminal; procedure Get_Terminal_IDs (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Result : in out Token_ID_Array; Last : in out SAL.Base_Peek_Type) is procedure Compute (N : in Syntax_Trees.Node) is use all type SAL.Base_Peek_Type; begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => Last := Last + 1; Result (Integer (Last)) := N.ID; when Nonterm => for I of N.Children loop -- Encountering Deleted_Child here is an error in the user algorithm. Get_Terminal_IDs (Tree, I, Result, Last); end loop; end case; end Compute; begin Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Get_Terminal_IDs; function Get_Terminal_IDs (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Token_ID_Array is Last : SAL.Base_Peek_Type := 0; begin Tree.Shared_Tree.Traversing := True; return Result : Token_ID_Array (1 .. Count_Terminals (Tree, Node)) do Get_Terminal_IDs (Tree, Node, Result, Last); Tree.Shared_Tree.Traversing := False; end return; end Get_Terminal_IDs; function First_Shared_Terminal (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Base_Token_Index is function Compute (N : in Syntax_Trees.Node) return Base_Token_Index is begin return (case N.Label is when Shared_Terminal => N.Terminal, when Virtual_Terminal | Virtual_Identifier => Invalid_Token_Index, when Nonterm => N.Min_Terminal_Index); end Compute; begin if Node <= Tree.Last_Shared_Node then return Compute (Tree.Shared_Tree.Nodes (Node)); else return Compute (Tree.Branched_Nodes (Node)); end if; end First_Shared_Terminal; function First_Terminal_ID (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Token_ID is function Compute (N : in Syntax_Trees.Node) return Token_ID is begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return N.ID; when Nonterm => for C of N.Children loop -- Encountering Deleted_Child here is an error in the user algorithm. declare ID : constant Token_ID := First_Terminal_ID (Tree, C); begin if ID /= Invalid_Token_ID then return ID; end if; end; end loop; return Invalid_Token_ID; end case; end Compute; begin return Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end First_Terminal_ID; function Has_Branched_Nodes (Tree : in Syntax_Trees.Tree) return Boolean is begin return Tree.Branched_Nodes.Length > 0; end Has_Branched_Nodes; function Has_Child (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Child : in Valid_Node_Index) return Boolean is begin for C of Tree.Get_Node_Const_Ref (Node).Children loop if C = Child then return True; end if; end loop; return False; end Has_Child; function Has_Children (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Children.Length > 0; else return Tree.Branched_Nodes (Node).Children.Length > 0; end if; end Has_Children; function Has_Parent (Tree : in Syntax_Trees.Tree; Child : in Valid_Node_Index) return Boolean is begin return (if Child <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Child).Parent /= Invalid_Node_Index else Tree.Branched_Nodes (Child).Parent /= Invalid_Node_Index); end Has_Parent; function Has_Parent (Tree : in Syntax_Trees.Tree; Children : in Valid_Node_Index_Array) return Boolean is begin return (for some Child of Children => (if Child <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Child).Parent /= Invalid_Node_Index else Tree.Branched_Nodes (Child).Parent /= Invalid_Node_Index)); end Has_Parent; function ID (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Token_ID is begin return (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).ID else Tree.Branched_Nodes (Node).ID); end ID; function Identifier (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Base_Identifier_Index is begin return (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).Identifier else Tree.Branched_Nodes (Node).Identifier); end Identifier; function Image (Tree : in Syntax_Trees.Tree; Children : in Valid_Node_Index_Arrays.Vector; Descriptor : in WisiToken.Descriptor; Node_Numbers : in Boolean) return String is use Ada.Strings.Unbounded; Result : Unbounded_String := +"("; Need_Comma : Boolean := False; begin for I of Children loop Result := Result & (if Need_Comma then ", " else "") & (if I = Deleted_Child then "-" else Tree.Image (I, Descriptor, Include_Children => False, Node_Numbers => Node_Numbers)); Need_Comma := True; end loop; Result := Result & ")"; return -Result; end Image; function Image (Tree : in Syntax_Trees.Tree; N : in Syntax_Trees.Node; Node_Index : in Valid_Node_Index; Descriptor : in WisiToken.Descriptor; Include_Children : in Boolean; Include_RHS_Index : in Boolean := False; Node_Numbers : in Boolean := False) return String is use Ada.Strings.Unbounded; Result : Unbounded_String := +(if Node_Numbers then Image (Node_Index) & ":" else ""); begin case N.Label is when Shared_Terminal => Result := Result & Trimmed_Image (N.Terminal) & ":"; when Virtual_Identifier => Result := Result & Trimmed_Image (N.Identifier) & ";"; when others => null; end case; Result := Result & "(" & Image (N.ID, Descriptor) & (if Include_RHS_Index and N.Label = Nonterm then "_" & Trimmed_Image (N.RHS_Index) else "") & (if N.Byte_Region = Null_Buffer_Region then "" else ", " & Image (N.Byte_Region)) & ")"; if Include_Children and N.Label = Nonterm then Result := Result & " <= " & Image (Tree, N.Children, Descriptor, Node_Numbers); end if; return -Result; end Image; function Image (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Descriptor : in WisiToken.Descriptor; Include_Children : in Boolean := False; Include_RHS_Index : in Boolean := False; Node_Numbers : in Boolean := False) return String is begin return Tree.Image ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node)), Node, Descriptor, Include_Children, Include_RHS_Index, Node_Numbers); end Image; function Image (Tree : in Syntax_Trees.Tree; Nodes : in Valid_Node_Index_Array; Descriptor : in WisiToken.Descriptor) return String is use Ada.Strings.Unbounded; Result : Unbounded_String := +"("; Need_Comma : Boolean := False; begin for I in Nodes'Range loop Result := Result & (if Need_Comma then ", " else "") & Tree.Image (Nodes (I), Descriptor); Need_Comma := True; end loop; Result := Result & ")"; return -Result; end Image; function Image (Item : in Node_Sets.Vector; Inverted : in Boolean := False) return String is use Ada.Strings.Unbounded; Result : Unbounded_String; begin for I in Item.First_Index .. Item.Last_Index loop if (if Inverted then not Item (I) else Item (I)) then Result := Result & Node_Index'Image (I); end if; end loop; return -Result; end Image; procedure Initialize (Branched_Tree : in out Syntax_Trees.Tree; Shared_Tree : in Base_Tree_Access; Flush : in Boolean; Set_Parents : in Boolean := False) is begin Branched_Tree := (Ada.Finalization.Controlled with Shared_Tree => Shared_Tree, Last_Shared_Node => Shared_Tree.Nodes.Last_Index, Branched_Nodes => <>, Flush => Flush, Root => <>); Branched_Tree.Shared_Tree.Parents_Set := Set_Parents; end Initialize; function Is_Descendant_Of (Tree : in Syntax_Trees.Tree; Root : in Valid_Node_Index; Descendant : in Valid_Node_Index) return Boolean is Node : Node_Index := Descendant; begin loop exit when Node = Invalid_Node_Index; if Node = Root then return True; end if; Node := Tree.Parent (Node); end loop; return False; end Is_Descendant_Of; function Is_Nonterm (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Label = Nonterm; else return Tree.Branched_Nodes (Node).Label = Nonterm; end if; end Is_Nonterm; function Is_Shared_Terminal (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Label = Shared_Terminal; else return Tree.Branched_Nodes (Node).Label = Shared_Terminal; end if; end Is_Shared_Terminal; function Is_Virtual_Terminal (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Label = Virtual_Terminal; else return Tree.Branched_Nodes (Node).Label = Virtual_Terminal; end if; end Is_Virtual_Terminal; function Is_Virtual (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is function Compute (N : in Syntax_Trees.Node) return Boolean is begin return N.Label = Virtual_Terminal or (N.Label = Nonterm and then N.Virtual); end Compute; begin if Node <= Tree.Last_Shared_Node then return Compute (Tree.Shared_Tree.Nodes (Node)); else return Compute (Tree.Branched_Nodes (Node)); end if; end Is_Virtual; function Is_Virtual_Identifier (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin return (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).Label = Virtual_Identifier else Tree.Branched_Nodes (Node).Label = Virtual_Identifier); end Is_Virtual_Identifier; function Label (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Node_Label is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Label; else return Tree.Branched_Nodes (Node).Label; end if; end Label; function Last_Index (Tree : in Syntax_Trees.Tree) return Node_Index is begin return (if Tree.Flush then Tree.Shared_Tree.Nodes.Last_Index else Tree.Branched_Nodes.Last_Index); end Last_Index; function Last_Shared_Terminal (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Base_Token_Index is -- Max_Terminal_Index is not cached, because it is not needed in recover. function Compute (N : in Syntax_Trees.Node) return Base_Token_Index is begin case N.Label is when Shared_Terminal => return N.Terminal; when Virtual_Terminal | Virtual_Identifier => return Invalid_Token_Index; when Nonterm => for C of reverse N.Children loop -- Encountering Deleted_Child here is an error in the user algorithm. declare Last_Term : constant Base_Token_Index := Tree.Last_Shared_Terminal (C); begin if Last_Term /= Invalid_Token_Index then return Last_Term; end if; end; end loop; return Invalid_Token_Index; end case; end Compute; begin if Node <= Tree.Last_Shared_Node then return Compute (Tree.Shared_Tree.Nodes (Node)); else return Compute (Tree.Branched_Nodes (Node)); end if; end Last_Shared_Terminal; function Last_Terminal (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Node_Index is N : constant Node_Const_Ref := Tree.Get_Node_Const_Ref (Node); begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return Node; when Nonterm => for C of reverse N.Children loop -- Encountering Deleted_Child here is an error in the user algorithm. declare Term : constant Node_Index := Last_Terminal (Tree, C); begin if Term /= Invalid_Node_Index then return Term; end if; end; end loop; return Invalid_Node_Index; end case; end Last_Terminal; function Min_Descendant (Nodes : in Node_Arrays.Vector; Node : in Valid_Node_Index) return Valid_Node_Index is N : Syntax_Trees.Node renames Nodes (Node); begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return Node; when Nonterm => declare Min : Node_Index := Node; begin for C of N.Children loop -- Encountering Deleted_Child here is an error in the user algorithm. Min := Node_Index'Min (Min, Min_Descendant (Nodes, C)); end loop; return Min; end; end case; end Min_Descendant; procedure Move_Branch_Point (Tree : in out Syntax_Trees.Tree; Required_Node : in Valid_Node_Index) is begin -- Note that this preserves all stored indices in Branched_Nodes. Tree.Branched_Nodes.Prepend (Tree.Shared_Tree.Nodes, Required_Node, Tree.Last_Shared_Node); Tree.Last_Shared_Node := Required_Node - 1; end Move_Branch_Point; function Next_Terminal (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Node_Index is use Valid_Node_Index_Arrays; use all type SAL.Base_Peek_Type; function First_Child (Node : in Valid_Node_Index) return Node_Index is N : Node_Const_Ref renames Tree.Get_Node_Const_Ref (Node); begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return Node; when Nonterm => -- Use first non-empty for J in N.Children.First_Index .. N.Children.Last_Index loop -- Encountering Deleted_Child here is an error in the user algorithm. declare Result : constant Node_Index := First_Child (N.Children (J)); begin if Result /= Invalid_Node_Index then return Result; end if; end; end loop; -- All Children are empty return Invalid_Node_Index; end case; end First_Child; function Next_Child (Child : in Valid_Node_Index; Node : in Node_Index) return Node_Index is begin -- Node is Parent of Child; return node immediately after Child. if Node = Invalid_Node_Index then return Invalid_Node_Index; else declare N : Node_Const_Ref renames Tree.Get_Node_Const_Ref (Node); begin pragma Assert (N.Label = Nonterm); for I in N.Children.First_Index .. N.Children.Last_Index loop -- Encountering Deleted_Child here is an error in the user algorithm. if N.Children (I) = Child then -- Use first non-empty next from I + 1. for J in I + 1 .. N.Children.Last_Index loop declare Result : constant Node_Index := First_Child (N.Children (J)); begin if Result /= Invalid_Node_Index then return Result; end if; end; end loop; -- All next Children are empty return Next_Child (Node, N.Parent); end if; end loop; raise SAL.Programmer_Error; end; end if; end Next_Child; N : Node_Const_Ref renames Get_Node_Const_Ref (Tree, Node); begin return Next_Child (Node, N.Parent); end Next_Terminal; function Parent (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Count : in Positive := 1) return Node_Index is Result : Node_Index := Node; N : Natural := 0; begin loop if Result <= Tree.Last_Shared_Node then Result := Tree.Shared_Tree.Nodes (Result).Parent; else Result := Tree.Branched_Nodes (Result).Parent; end if; N := N + 1; exit when N = Count or Result = Invalid_Node_Index; end loop; return Result; end Parent; function Prev_Terminal (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Node_Index is use Valid_Node_Index_Arrays; use all type SAL.Base_Peek_Type; function Last_Child (Node : in Valid_Node_Index) return Node_Index is N : Node_Const_Ref renames Tree.Get_Node_Const_Ref (Node); begin case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => return Node; when Nonterm => -- Use first non-empty from end. for J in reverse N.Children.First_Index .. N.Children.Last_Index loop -- Encountering Deleted_Child here is an error in the user algorithm. declare Result : constant Node_Index := Last_Child (N.Children (J)); begin if Result /= Invalid_Node_Index then return Result; end if; end; end loop; -- All Children are empty return Invalid_Node_Index; end case; end Last_Child; function Prev_Child (Child : in Valid_Node_Index; Node : in Node_Index) return Node_Index is begin -- Node is Parent of Child; return node immediately previous to Child. if Node = Invalid_Node_Index then return Invalid_Node_Index; else declare N : Node_Const_Ref renames Tree.Get_Node_Const_Ref (Node); begin pragma Assert (N.Label = Nonterm); for I in reverse N.Children.First_Index .. N.Children.Last_Index loop -- Encountering Deleted_Child here is an error in the user algorithm. if N.Children (I) = Child then -- Use first non-empty from I - 1. for J in reverse N.Children.First_Index .. I - 1 loop declare Result : constant Node_Index := Last_Child (N.Children (J)); begin if Result /= Invalid_Node_Index then return Result; end if; end; end loop; -- All previous Children are empty return Prev_Child (Node, N.Parent); end if; end loop; raise SAL.Programmer_Error; end; end if; end Prev_Child; N : Node_Const_Ref renames Get_Node_Const_Ref (Tree, Node); begin return Prev_Child (Node, N.Parent); end Prev_Terminal; procedure Print_Tree (Tree : in Syntax_Trees.Tree; Descriptor : in WisiToken.Descriptor; Root : in Node_Index := Invalid_Node_Index; Image_Augmented : in Syntax_Trees.Image_Augmented := null; Image_Action : in Syntax_Trees.Image_Action := null) is use Ada.Text_IO; Node_Printed : Node_Sets.Vector; procedure Print_Node (Node : in Valid_Node_Index; Level : in Integer) is function Image is new SAL.Generic_Decimal_Image (Node_Index); N : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Node); begin if Node_Printed (Node) then -- This does not catch all possible tree edit errors, but it does -- catch circles. raise SAL.Programmer_Error with "Print_Tree: invalid tree; loop:" & Node_Index'Image (Node); else Node_Printed (Node) := True; end if; Put (Image (Node, Width => 4) & ": "); for I in 1 .. Level loop Put ("| "); end loop; Put (Image (Tree, N, Node, Descriptor, Include_Children => False, Include_RHS_Index => True)); if Image_Augmented /= null and N.Augmented /= null then Put (" - " & Image_Augmented (N.Augmented)); end if; if N.Label = Nonterm and then (Image_Action /= null and N.Action /= null) then Put (" - " & Image_Action (N.Action)); end if; New_Line; if N.Label = Nonterm then for Child of N.Children loop if Child = Deleted_Child then Put (" : "); for I in 1 .. Level + 1 loop Put ("| "); end loop; Put_Line (" <deleted>"); else Print_Node (Child, Level + 1); end if; end loop; end if; end Print_Node; Print_Root : constant Node_Index := (if Root = Invalid_Node_Index then Tree.Root else Root); begin Node_Printed.Set_First_Last (Tree.First_Index, Tree.Last_Index); if Print_Root = Invalid_Node_Index then Put_Line ("<empty tree>"); else Print_Node (Print_Root, 0); end if; end Print_Tree; function Process_Tree (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; Visit_Parent : in Visit_Parent_Mode; Process_Node : access function (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean) return Boolean is function Compute (N : in Syntax_Trees.Node) return Boolean is begin if Visit_Parent = Before then if not Process_Node (Tree, Node) then return False; end if; end if; if N.Label = Nonterm then for Child of N.Children loop if Child /= Deleted_Child then if not Process_Tree (Tree, Child, Visit_Parent, Process_Node) then return False; end if; end if; end loop; end if; if Visit_Parent = After then return Process_Node (Tree, Node); else return True; end if; end Compute; begin if Node <= Tree.Last_Shared_Node then return Compute (Tree.Shared_Tree.Nodes (Node)); else return Compute (Tree.Branched_Nodes (Node)); end if; end Process_Tree; procedure Process_Tree (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index; Process_Node : access procedure (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index)) is procedure Compute (N : in Syntax_Trees.Node) is begin if N.Label = Nonterm then for Child of N.Children loop if Child /= Deleted_Child then Process_Tree (Tree, Child, Process_Node); end if; end loop; end if; Process_Node (Tree, Node); end Compute; begin if Node <= Tree.Last_Shared_Node then Compute (Tree.Shared_Tree.Nodes (Node)); else Compute (Tree.Branched_Nodes (Node)); end if; end Process_Tree; procedure Process_Tree (Tree : in out Syntax_Trees.Tree; Process_Node : access procedure (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index); Root : in Node_Index := Invalid_Node_Index) is begin Tree.Shared_Tree.Traversing := True; Process_Tree (Tree, (if Root = Invalid_Node_Index then Tree.Root else Root), Process_Node); Tree.Shared_Tree.Traversing := False; exception when others => Tree.Shared_Tree.Traversing := False; raise; end Process_Tree; function Production_ID (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return WisiToken.Production_ID is begin return (if Node <= Tree.Last_Shared_Node then (Tree.Shared_Tree.Nodes (Node).ID, Tree.Shared_Tree.Nodes (Node).RHS_Index) else (Tree.Branched_Nodes (Node).ID, Tree.Branched_Nodes (Node).RHS_Index)); end Production_ID; procedure Replace_Child (Tree : in out Syntax_Trees.Tree; Parent : in Valid_Node_Index; Child_Index : in SAL.Peek_Type; Old_Child : in Valid_Node_Index; New_Child : in Valid_Node_Index; Old_Child_New_Parent : in Node_Index := Invalid_Node_Index) is N : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Parent); begin N.Children (Child_Index) := New_Child; if Old_Child /= Deleted_Child then Tree.Shared_Tree.Nodes (Old_Child).Parent := Old_Child_New_Parent; end if; Tree.Shared_Tree.Nodes (New_Child).Parent := Parent; end Replace_Child; function RHS_Index (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Natural is begin return (if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).RHS_Index else Tree.Branched_Nodes (Node).RHS_Index); end RHS_Index; function Root (Tree : in Syntax_Trees.Tree) return Node_Index is begin return Tree.Root; end Root; procedure Set_Node_Identifier (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index; ID : in Token_ID; Identifier : in Identifier_Index) is Current : constant Syntax_Trees.Node := Tree.Shared_Tree.Nodes (Node); begin for C of Current.Children loop if C /= Deleted_Child then Tree.Shared_Tree.Nodes (C).Parent := Invalid_Node_Index; end if; end loop; Tree.Shared_Tree.Nodes.Replace_Element (Node, (Label => Virtual_Identifier, ID => ID, Identifier => Identifier, Byte_Region => Current.Byte_Region, Parent => Current.Parent, State => Unknown_State, Augmented => null)); end Set_Node_Identifier; procedure Set_Parents (Tree : in out Syntax_Trees.Tree) is procedure Set_Parents (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index; Parent : in Node_Index) is N : Node_Var_Ref renames Tree.Get_Node_Var_Ref (Node); begin N.Parent := Parent; case N.Label is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => null; when Nonterm => for C of N.Children loop if C = Deleted_Child then -- This can only happen if someone calls Set_Parents after parents -- are already set. raise SAL.Programmer_Error with "encountered Deleted_Child"; end if; Set_Parents (Tree, C, Node); end loop; end case; end Set_Parents; begin Set_Parents (Tree, Root (Tree), Invalid_Node_Index); Tree.Shared_Tree.Parents_Set := True; end Set_Parents; procedure Set_Root (Tree : in out Syntax_Trees.Tree; Root : in Valid_Node_Index) is begin Tree.Root := Root; end Set_Root; function Same_Token (Tree_1 : in Syntax_Trees.Tree'Class; Index_1 : in Valid_Node_Index; Tree_2 : in Syntax_Trees.Tree'Class; Index_2 : in Valid_Node_Index) return Boolean is function Compute (N_1, N_2 : in Syntax_Trees.Node) return Boolean is begin return N_1.Label = N_2.Label and N_1.ID = N_2.ID and N_1.Byte_Region = N_2.Byte_Region; end Compute; begin return Compute ((if Index_1 <= Tree_1.Last_Shared_Node then Tree_1.Shared_Tree.Nodes (Index_1) else Tree_1.Branched_Nodes (Index_1)), (if Index_2 <= Tree_2.Last_Shared_Node then Tree_2.Shared_Tree.Nodes (Index_2) else Tree_2.Branched_Nodes (Index_2))); end Same_Token; procedure Set_Augmented (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index; Value : in Base_Token_Class_Access) is begin if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).Augmented := Value; else Tree.Branched_Nodes (Node).Augmented := Value; end if; Tree.Shared_Tree.Augmented_Present := True; end Set_Augmented; procedure Set_Children (Tree : in out Syntax_Trees.Tree; Parent : in Valid_Node_Index; Children : in Valid_Node_Index_Array) is N : Node_Var_Ref renames Tree.Get_Node_Var_Ref (Parent); Min_Terminal_Index_Set : Boolean := False; begin -- See Design note in spec about Parents, Parent_Set. if Tree.Parents_Set then -- Clear current Children.Parent first, in case some are also in new -- children. for C of N.Children loop if C /= WisiToken.Deleted_Child then Tree.Shared_Tree.Nodes (C).Parent := Invalid_Node_Index; end if; end loop; end if; N.Children.Set_First_Last (Children'First, Children'Last); for I in Children'Range loop N.Children (I) := Children (I); if Tree.Parents_Set then declare Child_Node : Node renames Tree.Shared_Tree.Nodes (Children (I)); begin if Child_Node.Parent /= Invalid_Node_Index then declare Other_Parent : Node renames Tree.Shared_Tree.Nodes (Child_Node.Parent); Child_Index : constant SAL.Base_Peek_Type := Syntax_Trees.Child_Index (Other_Parent, Children (I)); begin Other_Parent.Children (Child_Index) := WisiToken.Deleted_Child; end; end if; Child_Node.Parent := Parent; end; end if; declare K : Node_Const_Ref renames Tree.Get_Node_Const_Ref (Children (I)); begin N.Virtual := N.Virtual or (case K.Label is when Shared_Terminal => False, when Virtual_Terminal | Virtual_Identifier => True, when Nonterm => K.Virtual); if N.Byte_Region.First > K.Byte_Region.First then N.Byte_Region.First := K.Byte_Region.First; end if; if N.Byte_Region.Last < K.Byte_Region.Last then N.Byte_Region.Last := K.Byte_Region.Last; end if; if not Min_Terminal_Index_Set then case K.Label is when Shared_Terminal => Min_Terminal_Index_Set := True; N.Min_Terminal_Index := K.Terminal; when Virtual_Terminal | Virtual_Identifier => null; when Nonterm => if K.Min_Terminal_Index /= Invalid_Token_Index then -- not an empty nonterm Min_Terminal_Index_Set := True; N.Min_Terminal_Index := K.Min_Terminal_Index; end if; end case; end if; end; end loop; end Set_Children; procedure Set_Children (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index; New_ID : in WisiToken.Production_ID; Children : in Valid_Node_Index_Array) is Parent_Node : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Node); begin if New_ID /= (Parent_Node.ID, Parent_Node.RHS_Index) then Parent_Node.Action := null; end if; Parent_Node.ID := New_ID.LHS; Parent_Node.RHS_Index := New_ID.RHS; Set_Children (Tree, Node, Children); end Set_Children; procedure Set_State (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index; State : in State_Index) is begin if Tree.Flush then Tree.Shared_Tree.Nodes (Node).State := State; else if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node).State := State; else Tree.Branched_Nodes (Node).State := State; end if; end if; end Set_State; procedure Set_Flush_False (Tree : in out Syntax_Trees.Tree) is begin if Tree.Flush then Tree.Flush := False; Tree.Branched_Nodes.Set_First_Last (Tree.Last_Shared_Node + 1, Tree.Last_Shared_Node); end if; end Set_Flush_False; procedure Set_Name_Region (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index; Region : in Buffer_Region) is begin if Tree.Flush then Tree.Shared_Tree.Nodes (Node).Name := Region; else if Node <= Tree.Last_Shared_Node then Move_Branch_Point (Tree, Node); end if; Tree.Branched_Nodes (Node).Name := Region; end if; end Set_Name_Region; function Sub_Tree_Root (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Valid_Node_Index is N : Valid_Node_Index := Node; begin loop exit when Tree.Shared_Tree.Nodes (N).Parent = Invalid_Node_Index; N := Tree.Shared_Tree.Nodes (N).Parent; end loop; return N; end Sub_Tree_Root; function Terminal (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Base_Token_Index is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).Terminal; else return Tree.Branched_Nodes (Node).Terminal; end if; end Terminal; function Traversing (Tree : in Syntax_Trees.Tree) return Boolean is begin return Tree.Shared_Tree.Traversing; end Traversing; function Recover_Token (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return WisiToken.Recover_Token is function Compute (N : Syntax_Trees.Node) return WisiToken.Recover_Token is begin case N.Label is when Shared_Terminal => return (ID => N.ID, Byte_Region => N.Byte_Region, Min_Terminal_Index => N.Terminal, Name => Null_Buffer_Region, Virtual => False); when Virtual_Terminal | Virtual_Identifier => return (ID => N.ID, Byte_Region => Null_Buffer_Region, Min_Terminal_Index => Invalid_Token_Index, Name => Null_Buffer_Region, Virtual => True); when Nonterm => return (ID => N.ID, Byte_Region => N.Byte_Region, Min_Terminal_Index => N.Min_Terminal_Index, Name => N.Name, Virtual => N.Virtual); end case; end Compute; begin return Compute ((if Node <= Tree.Last_Shared_Node then Tree.Shared_Tree.Nodes (Node) else Tree.Branched_Nodes (Node))); end Recover_Token; function Recover_Token_Array (Tree : in Syntax_Trees.Tree; Nodes : in Valid_Node_Index_Array) return WisiToken.Recover_Token_Array is begin return Result : WisiToken.Recover_Token_Array (Nodes'First .. Nodes'Last) do for I in Result'Range loop Result (I) := Tree.Recover_Token (Nodes (I)); end loop; end return; end Recover_Token_Array; function State (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Unknown_State_Index is begin if Node <= Tree.Last_Shared_Node then return Tree.Shared_Tree.Nodes (Node).State; else return Tree.Branched_Nodes (Node).State; end if; end State; procedure Validate_Tree (Tree : in out Syntax_Trees.Tree; Terminals : in Base_Token_Array_Access_Constant; Descriptor : in WisiToken.Descriptor; File_Name : in String; Root : in Node_Index := Invalid_Node_Index; Validate_Node : in Syntax_Trees.Validate_Node := null) is procedure Process_Node (Tree : in out Syntax_Trees.Tree; Node : in Valid_Node_Index) is use Ada.Text_IO; N : Syntax_Trees.Node renames Tree.Shared_Tree.Nodes (Node); Node_Image_Output : Boolean := False; begin if N.Label = Nonterm then for I in N.Children.First_Index .. N.Children.Last_Index loop if N.Children (I) = Deleted_Child then if not Node_Image_Output then Put_Line (Current_Error, Tree.Error_Message (Terminals, Node, File_Name, Image (Tree, N, Node, Descriptor, Include_Children => False, Node_Numbers => True))); Node_Image_Output := True; end if; Put_Line (Current_Error, Tree.Error_Message (Terminals, Node, File_Name, "... child" & I'Image & " deleted")); else declare Child_Parent : constant Node_Index := Tree.Shared_Tree.Nodes (N.Children (I)).Parent; begin if Child_Parent /= Node then if not Node_Image_Output then Put_Line (Current_Error, Tree.Error_Message (Terminals, Node, File_Name, Image (Tree, N, Node, Descriptor, Include_Children => False, Node_Numbers => True))); Node_Image_Output := True; end if; if Child_Parent = Invalid_Node_Index then Put_Line (Current_Error, Tree.Error_Message (Terminals, Node, File_Name, "... child.parent invalid")); else Put_Line (Current_Error, Tree.Error_Message (Terminals, Node, File_Name, "... child.parent" & Child_Parent'Image & " incorrect")); end if; end if; end; end if; end loop; end if; if Validate_Node /= null then Validate_Node (Tree, Node, Node_Image_Output); end if; end Process_Node; begin Process_Tree (Tree, (if Root = Invalid_Node_Index then Tree.Root else Root), Process_Node'Access); end Validate_Tree; end WisiToken.Syntax_Trees;
programs/oeis/161/A161617.asm
karttu/loda
1
166958
<reponame>karttu/loda<gh_stars>1-10 ; A161617: 8*n^2+20*n+1. ; 1,29,73,133,209,301,409,533,673,829,1001,1189,1393,1613,1849,2101,2369,2653,2953,3269,3601,3949,4313,4693,5089,5501,5929,6373,6833,7309,7801,8309,8833,9373,9929,10501,11089,11693,12313,12949,13601,14269,14953,15653,16369,17101,17849,18613,19393,20189,21001,21829,22673,23533,24409,25301,26209,27133,28073,29029,30001,30989,31993,33013,34049,35101,36169,37253,38353,39469,40601,41749,42913,44093,45289,46501,47729,48973,50233,51509,52801,54109,55433,56773,58129,59501,60889,62293,63713,65149,66601,68069,69553,71053,72569,74101,75649,77213,78793,80389,82001,83629,85273,86933,88609,90301,92009,93733,95473,97229,99001,100789,102593,104413,106249,108101,109969,111853,113753,115669,117601,119549,121513,123493,125489,127501,129529,131573,133633,135709,137801,139909,142033,144173,146329,148501,150689,152893,155113,157349,159601,161869,164153,166453,168769,171101,173449,175813,178193,180589,183001,185429,187873,190333,192809,195301,197809,200333,202873,205429,208001,210589,213193,215813,218449,221101,223769,226453,229153,231869,234601,237349,240113,242893,245689,248501,251329,254173,257033,259909,262801,265709,268633,271573,274529,277501,280489,283493,286513,289549,292601,295669,298753,301853,304969,308101,311249,314413,317593,320789,324001,327229,330473,333733,337009,340301,343609,346933,350273,353629,357001,360389,363793,367213,370649,374101,377569,381053,384553,388069,391601,395149,398713,402293,405889,409501,413129,416773,420433,424109,427801,431509,435233,438973,442729,446501,450289,454093,457913,461749,465601,469469,473353,477253,481169,485101,489049,493013,496993,500989 mov $1,$0 add $1,5 add $1,$0 mul $1,$0 mul $1,4 add $1,1
agda-stdlib/src/Data/Float/Base.agda
DreamLinuxer/popl21-artifact
5
14511
<gh_stars>1-10 ------------------------------------------------------------------------ -- The Agda standard library -- -- Floats: basic types and operations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Float.Base where open import Relation.Binary.Core using (Rel) import Data.Word.Base as Word open import Function using (_on_) open import Agda.Builtin.Equality ------------------------------------------------------------------------ -- Re-export built-ins publically open import Agda.Builtin.Float public using (Float) renaming -- Relations ( primFloatEquality to _≡ᵇ_ ; primFloatLess to _≤ᵇ_ ; primFloatNumericalEquality to _≈ᵇ_ ; primFloatNumericalLess to _≲ᵇ_ -- Conversions ; primShowFloat to show ; primFloatToWord64 to toWord ; primNatToFloat to fromℕ -- Operations ; primFloatPlus to _+_ ; primFloatMinus to _-_ ; primFloatTimes to _*_ ; primFloatNegate to -_ ; primFloatDiv to _÷_ ; primFloatSqrt to sqrt ; primRound to round ; primFloor to ⌊_⌋ ; primCeiling to ⌈_⌉ ; primExp to e^_ ; primLog to log ; primSin to sin ; primCos to cos ; primTan to tan ; primASin to asin ; primACos to acos ; primATan to atan ) _≈_ : Rel Float _ _≈_ = Word._≈_ on toWord _<_ : Rel Float _ _<_ = Word._<_ on toWord
demos/test.ada
daveshields/AdaEd
3
2697
with text_io; use text_io; procedure main is begin put_line("It works!"); end main;