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
|
---|---|---|---|---|
programs/oeis/057/A057038.asm | jmorken/loda | 1 | 85481 | ; A057038: Let R(i,j) be the rectangle with antidiagonals 1; 2,3; 4,5,6; ...; each k is an R(i(k),j(k)) and A057038(n)=i(2n).
; 1,1,3,2,4,2,4,1,3,5,1,3,5,7,2,4,6,8,2,4,6,8,1,3,5,7,9,1,3,5,7,9,11,2,4,6,8,10,12,2,4,6,8,10,12,1,3,5,7,9,11,13,1,3,5,7,9,11,13,15,2,4,6,8,10,12,14,16,2,4,6,8,10,12,14,16,1,3,5,7,9
mul $0,2
add $0,2
lpb $0
mov $1,$0
add $2,1
trn $0,$2
lpe
|
Transynther/x86/_processed/NONE/_xt_sm_/i9-9900K_12_0xca_notsx.log_21829_342.asm | ljhsiun2/medusa | 9 | 27673 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r8
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x1c372, %r8
nop
nop
nop
nop
cmp $10653, %r13
movb $0x61, (%r8)
nop
nop
add $64401, %rbp
lea addresses_D_ht+0xd78f, %rsi
clflush (%rsi)
nop
nop
nop
nop
nop
sub %rbx, %rbx
movl $0x61626364, (%rsi)
nop
nop
nop
nop
xor $63669, %rbx
lea addresses_normal_ht+0x17a1f, %rbp
nop
nop
dec %r13
mov $0x6162636465666768, %r8
movq %r8, (%rbp)
dec %rdi
lea addresses_WT_ht+0x1c6c7, %rsi
lea addresses_A_ht+0x92cf, %rdi
and %r13, %r13
mov $53, %rcx
rep movsl
nop
xor $31562, %rdi
lea addresses_A_ht+0xbf4f, %rsi
lea addresses_WC_ht+0x1b12f, %rdi
nop
nop
nop
nop
add $56548, %rbx
mov $81, %rcx
rep movsw
nop
nop
nop
nop
nop
add $36075, %rbp
lea addresses_WC_ht+0xf9a5, %r8
cmp %rcx, %rcx
mov (%r8), %ebp
nop
nop
nop
nop
add $39067, %rbp
lea addresses_UC_ht+0x186cf, %rbx
nop
dec %r8
mov $0x6162636465666768, %rsi
movq %rsi, %xmm4
movups %xmm4, (%rbx)
nop
nop
nop
nop
inc %rbx
lea addresses_A_ht+0x1bf4f, %rcx
clflush (%rcx)
nop
nop
nop
nop
nop
sub $20341, %rbp
mov (%rcx), %ebx
nop
nop
nop
nop
nop
cmp $41508, %rbx
lea addresses_normal_ht+0x1ecf, %rsi
lea addresses_normal_ht+0x112cf, %rdi
nop
nop
xor $12833, %r8
mov $56, %rcx
rep movsb
nop
nop
and %rcx, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r8
push %r9
push %rax
push %rcx
push %rdi
push %rsi
// Store
lea addresses_A+0x3a2f, %rsi
nop
and $1847, %rax
movl $0x51525354, (%rsi)
nop
nop
nop
nop
sub $7066, %r8
// Store
lea addresses_PSE+0x1914f, %r9
nop
nop
nop
nop
dec %r11
movl $0x51525354, (%r9)
nop
nop
xor $3778, %rcx
// Store
lea addresses_D+0x16cf, %r11
nop
and %rax, %rax
movw $0x5152, (%r11)
nop
nop
sub $54597, %rdi
// Store
lea addresses_RW+0x22cd, %rdi
nop
nop
nop
nop
nop
dec %r9
movb $0x51, (%rdi)
nop
nop
nop
sub $19084, %r11
// Faulty Load
lea addresses_D+0x16cf, %rax
nop
nop
nop
and $51883, %rcx
movb (%rax), %r9b
lea oracles, %r11
and $0xff, %r9
shlq $12, %r9
mov (%r11,%r9,1), %r9
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r8
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_D', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_WC_ht'}}
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 9}}
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_normal_ht'}}
{'52': 21829}
52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52
*/
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_379.asm | ljhsiun2/medusa | 9 | 18444 | <reponame>ljhsiun2/medusa<filename>Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_379.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r8
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x1728f, %rsi
lea addresses_A_ht+0x14556, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
sub $5389, %r11
mov $91, %rcx
rep movsb
and $56581, %rcx
lea addresses_D_ht+0x1490e, %rsi
lea addresses_WC_ht+0x16e36, %rdi
nop
nop
inc %r9
mov $127, %rcx
rep movsq
nop
nop
nop
nop
nop
and $33439, %r9
lea addresses_WC_ht+0x17c56, %r8
nop
nop
dec %r9
mov (%r8), %r11d
nop
add %rcx, %rcx
lea addresses_WC_ht+0x1ab56, %rsi
nop
nop
nop
add $42682, %r8
movl $0x61626364, (%rsi)
nop
nop
mfence
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r8
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %rcx
push %rdx
// Faulty Load
lea addresses_A+0xbc56, %r10
nop
nop
nop
nop
and $31871, %r12
mov (%r10), %cx
lea oracles, %rdx
and $0xff, %rcx
shlq $12, %rcx
mov (%rdx,%rcx,1), %rcx
pop %rdx
pop %rcx
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_A', 'AVXalign': True, 'size': 8, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_A', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 8}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 4, 'NT': False, 'same': False, 'congruent': 7}}
{'35': 21829}
35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35
*/
|
ASM/DOS/NASM/HelloWorld/Helloworld.asm | EricJB77/RepoOfTime | 3 | 82736 | <reponame>EricJB77/RepoOfTime<gh_stars>1-10
section .text
org 0x100
mov ah, 0x9
mox dx, hello
int 0x21
mox ax, 0x4c00
int 0x21
section .data
hello: db 'Hello World!', 13, 10, '$'
|
exp/t61.asm | nishuiq/Assembly-Learning | 0 | 12161 | <gh_stars>0
assume cs:code, ds:data, ss:stack
data segment
dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0987h
data ends
stack segment
dw 0,0,0,0,0,0,0,0
stack ends
code segment
start:
mov ax,stack
mov ss,ax
mov sp,16
mov ax,data
mov ds,ax
push ds:[0]
push ds:[2]
pop ds:[2]
pop ds:[0]
mov ax,4c00h
int 21h
code ends
end start
|
Palmtree.Math.Core.Implements/vs_build/x64_Debug/TEST_op_Pow.asm | rougemeilland/Palmtree.Math.Core.Implements | 0 | 93744 | <reponame>rougemeilland/Palmtree.Math.Core.Implements
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.16.27026.1
include listing.inc
INCLUDELIB MSVCRTD
INCLUDELIB OLDNAMES
msvcjmc SEGMENT
__7B7A869E_ctype@h DB 01H
__457DD326_basetsd@h DB 01H
__4384A2D9_corecrt_memcpy_s@h DB 01H
__4E51A221_corecrt_wstring@h DB 01H
__2140C079_string@h DB 01H
__1887E595_winnt@h DB 01H
__9FC7C64B_processthreadsapi@h DB 01H
__FA470AEC_memoryapi@h DB 01H
__F37DAFF1_winerror@h DB 01H
__7A450CCC_winbase@h DB 01H
__B4B40122_winioctl@h DB 01H
__86261D59_stralign@h DB 01H
__1C66ECB2_pmc_debug@h DB 01H
__F2CD1EB2_test_op_pow@c DB 01H
msvcjmc ENDS
PUBLIC TEST_PMC_Pow_X_I
PUBLIC __JustMyCode_Default
PUBLIC ??_C@_1EK@HDEICNAJ@?$AAP?$AAM?$AAC?$AA_?$AAF?$AAr?$AAo?$AAm?$AAB?$AAy?$AAt?$AAe?$AAA?$AAr?$AAr@ ; `string'
PUBLIC ??_C@_1CI@OPCGMDC@?$AAP?$AAM?$AAC?$AA_?$AAP?$AAo?$AAw?$AA_?$AAX?$AA_?$AAI?$AA?5?$AA?$CI?$AA?$CF?$AAd@ ; `string'
PUBLIC ??_C@_1DO@JELPAHAG@?$AAP?$AAM?$AAC?$AA_?$AAP?$AAo?$AAw?$AA_?$AAX?$AA_?$AAI?$AAn?$PP?$KJ?$AA0?$PP?$LD@ ; `string'
PUBLIC ??_C@_1EG@MCOLJMDD@?$AAP?$AAM?$AAC?$AA_?$AAT?$AAo?$AAB?$AAy?$AAt?$AAe?$AAA?$AAr?$AAr?$AAa?$AAy@ ; `string'
PUBLIC ??_C@_1BK@CBDJCOBM@?$PP?G?$PP?$PM?$PP?$LP?$AAn?$PP?$IF?$PP?$LJ?$AAL?$AA?$AA?$PP?t?$AAW?$AAj?$AAD@ ; `string'
EXTRN TEST_Assert:PROC
EXTRN FormatTestLabel:PROC
EXTRN FormatTestMesssage:PROC
EXTRN _RTC_CheckStackVars:PROC
EXTRN _RTC_InitBase:PROC
EXTRN _RTC_Shutdown:PROC
EXTRN __CheckForDebuggerJustMyCode:PROC
_BSS SEGMENT
?actual_z_buf@?1??TEST_PMC_Pow_X_I@@9@9 DB 010000H DUP (?) ; `TEST_PMC_Pow_X_I'::`2'::actual_z_buf
_BSS ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$TEST_PMC_Pow_X_I DD imagerel $LN14
DD imagerel $LN14+699
DD imagerel $unwind$TEST_PMC_Pow_X_I
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$_EQUALS_MEMORY DD imagerel _EQUALS_MEMORY
DD imagerel _EQUALS_MEMORY+198
DD imagerel $unwind$_EQUALS_MEMORY
pdata ENDS
; COMDAT rtc$TMZ
rtc$TMZ SEGMENT
_RTC_Shutdown.rtc$TMZ DQ FLAT:_RTC_Shutdown
rtc$TMZ ENDS
; COMDAT rtc$IMZ
rtc$IMZ SEGMENT
_RTC_InitBase.rtc$IMZ DQ FLAT:_RTC_InitBase
rtc$IMZ ENDS
; COMDAT ??_C@_1BK@CBDJCOBM@?$PP?G?$PP?$PM?$PP?$LP?$AAn?$PP?$IF?$PP?$LJ?$AAL?$AA?$AA?$PP?t?$AAW?$AAj?$AAD@
CONST SEGMENT
??_C@_1BK@CBDJCOBM@?$PP?G?$PP?$PM?$PP?$LP?$AAn?$PP?$IF?$PP?$LJ?$AAL?$AA?$AA?$PP?t?$AAW?$AAj?$AAD@ DB 0c7H
DB '0', 0fcH, '0', 0bfH, '0n0', 085H, 'Q', 0b9H, '[L0', 00H, 'N', 0f4H
DB 081H, 'W0j0D0', 00H, 00H ; `string'
CONST ENDS
; COMDAT ??_C@_1EG@MCOLJMDD@?$AAP?$AAM?$AAC?$AA_?$AAT?$AAo?$AAB?$AAy?$AAt?$AAe?$AAA?$AAr?$AAr?$AAa?$AAy@
CONST SEGMENT
??_C@_1EG@MCOLJMDD@?$AAP?$AAM?$AAC?$AA_?$AAT?$AAo?$AAB?$AAy?$AAt?$AAe?$AAA?$AAr?$AAr?$AAa?$AAy@ DB 'P'
DB 00H, 'M', 00H, 'C', 00H, '_', 00H, 'T', 00H, 'o', 00H, 'B', 00H
DB 'y', 00H, 't', 00H, 'e', 00H, 'A', 00H, 'r', 00H, 'r', 00H, 'a'
DB 00H, 'y', 00H, 'n0', 0a9H, '_0^', 0b3H, '0', 0fcH, '0', 0c9H, '0'
DB 'L0', 01fH, 'g', 085H, '_', 01aH, 090H, 08aH, '0g0o0j0D0(', 00H
DB '%', 00H, 'd', 00H, ')', 00H, 00H, 00H ; `string'
CONST ENDS
; COMDAT ??_C@_1DO@JELPAHAG@?$AAP?$AAM?$AAC?$AA_?$AAP?$AAo?$AAw?$AA_?$AAX?$AA_?$AAI?$AAn?$PP?$KJ?$AA0?$PP?$LD@
CONST SEGMENT
??_C@_1DO@JELPAHAG@?$AAP?$AAM?$AAC?$AA_?$AAP?$AAo?$AAw?$AA_?$AAX?$AA_?$AAI?$AAn?$PP?$KJ?$AA0?$PP?$LD@ DB 'P'
DB 00H, 'M', 00H, 'C', 00H, '_', 00H, 'P', 00H, 'o', 00H, 'w', 00H
DB '_', 00H, 'X', 00H, '_', 00H, 'I', 00H, 'n0', 0a9H, '_0^', 0b3H
DB '0', 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH, 090H, 08aH
DB '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H, 00H ; `string'
CONST ENDS
; COMDAT ??_C@_1CI@OPCGMDC@?$AAP?$AAM?$AAC?$AA_?$AAP?$AAo?$AAw?$AA_?$AAX?$AA_?$AAI?$AA?5?$AA?$CI?$AA?$CF?$AAd@
CONST SEGMENT
??_C@_1CI@OPCGMDC@?$AAP?$AAM?$AAC?$AA_?$AAP?$AAo?$AAw?$AA_?$AAX?$AA_?$AAI?$AA?5?$AA?$CI?$AA?$CF?$AAd@ DB 'P'
DB 00H, 'M', 00H, 'C', 00H, '_', 00H, 'P', 00H, 'o', 00H, 'w', 00H
DB '_', 00H, 'X', 00H, '_', 00H, 'I', 00H, ' ', 00H, '(', 00H, '%'
DB 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H, 00H ; `string'
CONST ENDS
; COMDAT ??_C@_1EK@HDEICNAJ@?$AAP?$AAM?$AAC?$AA_?$AAF?$AAr?$AAo?$AAm?$AAB?$AAy?$AAt?$AAe?$AAA?$AAr?$AAr@
CONST SEGMENT
??_C@_1EK@HDEICNAJ@?$AAP?$AAM?$AAC?$AA_?$AAF?$AAr?$AAo?$AAm?$AAB?$AAy?$AAt?$AAe?$AAA?$AAr?$AAr@ DB 'P'
DB 00H, 'M', 00H, 'C', 00H, '_', 00H, 'F', 00H, 'r', 00H, 'o', 00H
DB 'm', 00H, 'B', 00H, 'y', 00H, 't', 00H, 'e', 00H, 'A', 00H, 'r'
DB 00H, 'r', 00H, 'a', 00H, 'y', 00H, 'n0', 0a9H, '_0^', 0b3H, '0'
DB 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH, 090H, 08aH
DB '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H, 00H ; `string'
CONST ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$_EQUALS_MEMORY DD 025053901H
DD 011d2322H
DD 07016001dH
DD 05015H
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$TEST_PMC_Pow_X_I DD 025053901H
DD 011d2322H
DD 070160035H
DD 05015H
xdata ENDS
; COMDAT CONST
CONST SEGMENT
TEST_PMC_Pow_X_I$rtcName$0 DB 078H
DB 00H
ORG $+2
TEST_PMC_Pow_X_I$rtcName$1 DB 07aH
DB 00H
ORG $+2
TEST_PMC_Pow_X_I$rtcName$2 DB 061H
DB 063H
DB 074H
DB 075H
DB 061H
DB 06cH
DB 05fH
DB 07aH
DB 05fH
DB 062H
DB 075H
DB 066H
DB 05fH
DB 073H
DB 069H
DB 07aH
DB 065H
DB 00H
ORG $+6
TEST_PMC_Pow_X_I$rtcVarDesc DD 068H
DD 08H
DQ FLAT:TEST_PMC_Pow_X_I$rtcName$2
DD 048H
DD 08H
DQ FLAT:TEST_PMC_Pow_X_I$rtcName$1
DD 028H
DD 08H
DQ FLAT:TEST_PMC_Pow_X_I$rtcName$0
ORG $+144
TEST_PMC_Pow_X_I$rtcFrameData DD 03H
DD 00H
DQ FLAT:TEST_PMC_Pow_X_I$rtcVarDesc
CONST ENDS
; Function compile flags: /Odt
; COMDAT __JustMyCode_Default
_TEXT SEGMENT
__JustMyCode_Default PROC ; COMDAT
ret 0
__JustMyCode_Default ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu /ZI
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_debug.h
; COMDAT _EQUALS_MEMORY
_TEXT SEGMENT
buffer1$ = 224
count1$ = 232
buffer2$ = 240
count2$ = 248
_EQUALS_MEMORY PROC ; COMDAT
; 155 : {
mov QWORD PTR [rsp+32], r9
mov QWORD PTR [rsp+24], r8
mov QWORD PTR [rsp+16], rdx
mov QWORD PTR [rsp+8], rcx
push rbp
push rdi
sub rsp, 232 ; 000000e8H
lea rbp, QWORD PTR [rsp+32]
mov rdi, rsp
mov ecx, 58 ; 0000003aH
mov eax, -858993460 ; ccccccccH
rep stosd
mov rcx, QWORD PTR [rsp+264]
lea rcx, OFFSET FLAT:__1C66ECB2_pmc_debug@h
call __CheckForDebuggerJustMyCode
; 156 : if (count1 != count2)
mov rax, QWORD PTR count2$[rbp]
cmp QWORD PTR count1$[rbp], rax
je SHORT $LN4@EQUALS_MEM
; 157 : return (-1);
mov eax, -1
jmp SHORT $LN1@EQUALS_MEM
$LN4@EQUALS_MEM:
$LN2@EQUALS_MEM:
; 158 : while (count1 > 0)
cmp QWORD PTR count1$[rbp], 0
jbe SHORT $LN3@EQUALS_MEM
; 159 : {
; 160 : if (*buffer1 != *buffer2)
mov rax, QWORD PTR buffer1$[rbp]
movzx eax, BYTE PTR [rax]
mov rcx, QWORD PTR buffer2$[rbp]
movzx ecx, BYTE PTR [rcx]
cmp eax, ecx
je SHORT $LN5@EQUALS_MEM
; 161 : return (-1);
mov eax, -1
jmp SHORT $LN1@EQUALS_MEM
$LN5@EQUALS_MEM:
; 162 : ++buffer1;
mov rax, QWORD PTR buffer1$[rbp]
inc rax
mov QWORD PTR buffer1$[rbp], rax
; 163 : ++buffer2;
mov rax, QWORD PTR buffer2$[rbp]
inc rax
mov QWORD PTR buffer2$[rbp], rax
; 164 : --count1;
mov rax, QWORD PTR count1$[rbp]
dec rax
mov QWORD PTR count1$[rbp], rax
; 165 : }
jmp SHORT $LN2@EQUALS_MEM
$LN3@EQUALS_MEM:
; 166 : return (0);
xor eax, eax
$LN1@EQUALS_MEM:
; 167 : }
lea rsp, QWORD PTR [rbp+200]
pop rdi
pop rbp
ret 0
_EQUALS_MEMORY ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu /ZI
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\test_op_pow.c
; COMDAT TEST_PMC_Pow_X_I
_TEXT SEGMENT
x$ = 8
z$ = 40
actual_z_buf_size$ = 72
result$ = 100
x_result$ = 132
z_result$ = 164
tv159 = 372
tv144 = 372
tv92 = 372
tv74 = 372
tv133 = 376
tv82 = 376
tv64 = 376
env$ = 416
ep$ = 424
no$ = 432
x_buf$ = 440
x_buf_size$ = 448
y$ = 456
desired_result_code$ = 464
desired_z_buf$ = 472
desired_z_buf_size$ = 480
TEST_PMC_Pow_X_I PROC ; COMDAT
; 40 : {
$LN14:
mov QWORD PTR [rsp+32], r9
mov DWORD PTR [rsp+24], r8d
mov QWORD PTR [rsp+16], rdx
mov QWORD PTR [rsp+8], rcx
push rbp
push rdi
sub rsp, 424 ; 000001a8H
lea rbp, QWORD PTR [rsp+32]
mov rdi, rsp
mov ecx, 106 ; 0000006aH
mov eax, -858993460 ; ccccccccH
rep stosd
mov rcx, QWORD PTR [rsp+456]
lea rcx, OFFSET FLAT:__F2CD1EB2_test_op_pow@c
call __CheckForDebuggerJustMyCode
; 41 : HANDLE x;
; 42 : HANDLE z;
; 43 : static unsigned char actual_z_buf[0x10000];
; 44 : size_t actual_z_buf_size;
; 45 : PMC_STATUS_CODE result;
; 46 : PMC_STATUS_CODE x_result;
; 47 : PMC_STATUS_CODE z_result;
; 48 : TEST_Assert(env, FormatTestLabel(L"PMC_Pow_X_I (%d.%d)", no, 1), (x_result = ep->PMC_FromByteArray(x_buf, x_buf_size, &x)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_FromByteArrayの復帰コードが期待通りではない(%d)", x_result));
lea r8, QWORD PTR x$[rbp]
mov rdx, QWORD PTR x_buf_size$[rbp]
mov rcx, QWORD PTR x_buf$[rbp]
mov rax, QWORD PTR ep$[rbp]
call QWORD PTR [rax+48]
mov DWORD PTR x_result$[rbp], eax
cmp DWORD PTR x_result$[rbp], 0
jne SHORT $LN6@TEST_PMC_P
mov DWORD PTR tv74[rbp], 1
jmp SHORT $LN7@TEST_PMC_P
$LN6@TEST_PMC_P:
mov DWORD PTR tv74[rbp], 0
$LN7@TEST_PMC_P:
mov edx, DWORD PTR x_result$[rbp]
lea rcx, OFFSET FLAT:??_C@_1EK@HDEICNAJ@?$AAP?$AAM?$AAC?$AA_?$AAF?$AAr?$AAo?$AAm?$AAB?$AAy?$AAt?$AAe?$AAA?$AAr?$AAr@
call FormatTestMesssage
mov QWORD PTR tv64[rbp], rax
mov r8d, 1
mov edx, DWORD PTR no$[rbp]
lea rcx, OFFSET FLAT:??_C@_1CI@OPCGMDC@?$AAP?$AAM?$AAC?$AA_?$AAP?$AAo?$AAw?$AA_?$AAX?$AA_?$AAI?$AA?5?$AA?$CI?$AA?$CF?$AAd@
call FormatTestLabel
mov rcx, QWORD PTR tv64[rbp]
mov r9, rcx
mov r8d, DWORD PTR tv74[rbp]
mov rdx, rax
mov rcx, QWORD PTR env$[rbp]
call TEST_Assert
; 49 : TEST_Assert(env, FormatTestLabel(L"PMC_Pow_X_I (%d.%d)", no, 2), (z_result = ep->PMC_Pow_X_I(x, y, &z)) == desired_result_code, FormatTestMesssage(L"PMC_Pow_X_Iの復帰コードが期待通りではない(%d)", z_result));
lea r8, QWORD PTR z$[rbp]
mov edx, DWORD PTR y$[rbp]
mov rcx, QWORD PTR x$[rbp]
mov rax, QWORD PTR ep$[rbp]
call QWORD PTR [rax+536]
mov DWORD PTR z_result$[rbp], eax
mov eax, DWORD PTR desired_result_code$[rbp]
cmp DWORD PTR z_result$[rbp], eax
jne SHORT $LN8@TEST_PMC_P
mov DWORD PTR tv92[rbp], 1
jmp SHORT $LN9@TEST_PMC_P
$LN8@TEST_PMC_P:
mov DWORD PTR tv92[rbp], 0
$LN9@TEST_PMC_P:
mov edx, DWORD PTR z_result$[rbp]
lea rcx, OFFSET FLAT:??_C@_1DO@JELPAHAG@?$AAP?$AAM?$AAC?$AA_?$AAP?$AAo?$AAw?$AA_?$AAX?$AA_?$AAI?$AAn?$PP?$KJ?$AA0?$PP?$LD@
call FormatTestMesssage
mov QWORD PTR tv82[rbp], rax
mov r8d, 2
mov edx, DWORD PTR no$[rbp]
lea rcx, OFFSET FLAT:??_C@_1CI@OPCGMDC@?$AAP?$AAM?$AAC?$AA_?$AAP?$AAo?$AAw?$AA_?$AAX?$AA_?$AAI?$AA?5?$AA?$CI?$AA?$CF?$AAd@
call FormatTestLabel
mov rcx, QWORD PTR tv82[rbp]
mov r9, rcx
mov r8d, DWORD PTR tv92[rbp]
mov rdx, rax
mov rcx, QWORD PTR env$[rbp]
call TEST_Assert
; 50 : if (desired_result_code == PMC_STATUS_OK)
cmp DWORD PTR desired_result_code$[rbp], 0
jne $LN2@TEST_PMC_P
; 51 : {
; 52 : TEST_Assert(env, FormatTestLabel(L"PMC_Pow_X_I (%d.%d)", no, 3), (result = ep->PMC_ToByteArray(z, actual_z_buf, sizeof(actual_z_buf), &actual_z_buf_size)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_ToByteArrayの復帰コードが期待通りではない(%d)", result));
lea r9, QWORD PTR actual_z_buf_size$[rbp]
mov r8d, 65536 ; 00010000H
lea rdx, OFFSET FLAT:?actual_z_buf@?1??TEST_PMC_Pow_X_I@@9@9
mov rcx, QWORD PTR z$[rbp]
mov rax, QWORD PTR ep$[rbp]
call QWORD PTR [rax+56]
mov DWORD PTR result$[rbp], eax
cmp DWORD PTR result$[rbp], 0
jne SHORT $LN10@TEST_PMC_P
mov DWORD PTR tv144[rbp], 1
jmp SHORT $LN11@TEST_PMC_P
$LN10@TEST_PMC_P:
mov DWORD PTR tv144[rbp], 0
$LN11@TEST_PMC_P:
mov edx, DWORD PTR result$[rbp]
lea rcx, OFFSET FLAT:??_C@_1EG@MCOLJMDD@?$AAP?$AAM?$AAC?$AA_?$AAT?$AAo?$AAB?$AAy?$AAt?$AAe?$AAA?$AAr?$AAr?$AAa?$AAy@
call FormatTestMesssage
mov QWORD PTR tv133[rbp], rax
mov r8d, 3
mov edx, DWORD PTR no$[rbp]
lea rcx, OFFSET FLAT:??_C@_1CI@OPCGMDC@?$AAP?$AAM?$AAC?$AA_?$AAP?$AAo?$AAw?$AA_?$AAX?$AA_?$AAI?$AA?5?$AA?$CI?$AA?$CF?$AAd@
call FormatTestLabel
mov rcx, QWORD PTR tv133[rbp]
mov r9, rcx
mov r8d, DWORD PTR tv144[rbp]
mov rdx, rax
mov rcx, QWORD PTR env$[rbp]
call TEST_Assert
; 53 : TEST_Assert(env, FormatTestLabel(L"PMC_Pow_X_I (%d.%d)", no, 4), _EQUALS_MEMORY(actual_z_buf, actual_z_buf_size, desired_z_buf, desired_z_buf_size) == 0, L"データの内容が一致しない");
mov r9, QWORD PTR desired_z_buf_size$[rbp]
mov r8, QWORD PTR desired_z_buf$[rbp]
mov rdx, QWORD PTR actual_z_buf_size$[rbp]
lea rcx, OFFSET FLAT:?actual_z_buf@?1??TEST_PMC_Pow_X_I@@9@9
call _EQUALS_MEMORY
test eax, eax
jne SHORT $LN12@TEST_PMC_P
mov DWORD PTR tv159[rbp], 1
jmp SHORT $LN13@TEST_PMC_P
$LN12@TEST_PMC_P:
mov DWORD PTR tv159[rbp], 0
$LN13@TEST_PMC_P:
mov r8d, 4
mov edx, DWORD PTR no$[rbp]
lea rcx, OFFSET FLAT:??_C@_1CI@OPCGMDC@?$AAP?$AAM?$AAC?$AA_?$AAP?$AAo?$AAw?$AA_?$AAX?$AA_?$AAI?$AA?5?$AA?$CI?$AA?$CF?$AAd@
call FormatTestLabel
lea r9, OFFSET FLAT:??_C@_1BK@CBDJCOBM@?$PP?G?$PP?$PM?$PP?$LP?$AAn?$PP?$IF?$PP?$LJ?$AAL?$AA?$AA?$PP?t?$AAW?$AAj?$AAD@
mov r8d, DWORD PTR tv159[rbp]
mov rdx, rax
mov rcx, QWORD PTR env$[rbp]
call TEST_Assert
$LN2@TEST_PMC_P:
; 54 : }
; 55 : if (z_result == PMC_STATUS_OK)
cmp DWORD PTR z_result$[rbp], 0
jne SHORT $LN3@TEST_PMC_P
; 56 : ep->PMC_Dispose(z);
mov rcx, QWORD PTR z$[rbp]
mov rax, QWORD PTR ep$[rbp]
call QWORD PTR [rax+32]
$LN3@TEST_PMC_P:
; 57 : if (x_result == PMC_STATUS_OK)
cmp DWORD PTR x_result$[rbp], 0
jne SHORT $LN4@TEST_PMC_P
; 58 : ep->PMC_Dispose(x);
mov rcx, QWORD PTR x$[rbp]
mov rax, QWORD PTR ep$[rbp]
call QWORD PTR [rax+32]
$LN4@TEST_PMC_P:
; 59 : }
lea rcx, QWORD PTR [rbp-32]
lea rdx, OFFSET FLAT:TEST_PMC_Pow_X_I$rtcFrameData
call _RTC_CheckStackVars
lea rsp, QWORD PTR [rbp+392]
pop rdi
pop rbp
ret 0
TEST_PMC_Pow_X_I ENDP
_TEXT ENDS
END
|
p2/matrix.asm | t0ush1/ComputerOrganization | 2 | 8714 | .data
A: .space 256 #int A[8][8]
B: .space 256 #int B[8][8]
C: .space 256 #int C[8][8]
space: .asciiz " "
line: .asciiz "\n"
.macro readInt(%x)
li $v0, 5
syscall
move %x, $v0
.end_macro
.macro writeInt(%x)
move $a0, %x
li $v0, 1
syscall
.end_macro
.macro writeString(%s)
la $a0, %s
li $v0, 4
syscall
.end_macro
.macro getAddr(%addr, %i, %j)
sll %addr, %i, 3
add %addr, %addr, %j
sll %addr, %addr, 2
.end_macro
.text
readInt($s0) #read n -> $s0
li $t0, 0 #for (int i = 0; i < n; i ++) i -> $t0
for_1_begin:
beq $t0, $s0, for_1_end
li $t1, 0 #for (int j = 0; j < n; j ++) j -> $t1
for_2_begin:
beq $t1, $s0, for_2_end
getAddr($t2, $t0, $t1) #read A[i][j]
readInt($t3)
sw $t3, A($t2)
addi $t1, $t1, 1
j for_2_begin
for_2_end:
addi $t0, $t0, 1
j for_1_begin
for_1_end:
li $t0, 0 #for (int i = 0; i < n; i ++) i -> $t0
for_3_begin:
beq $t0, $s0, for_3_end
li $t1, 0 #for (int j = 0; j < n; j ++) j -> $t1
for_4_begin:
beq $t1, $s0, for_4_end
getAddr($t2, $t0, $t1) #read B[i][j]
readInt($t3)
sw $t3, B($t2)
addi $t1, $t1, 1
j for_4_begin
for_4_end:
addi $t0, $t0, 1
j for_3_begin
for_3_end:
li $t0, 0 #for (int i = 0; i < n; i ++) i -> $t0
for_5_begin:
beq $t0, $s0, for_5_end
li $t1, 0 #for (int j = 0; j < n; j ++) j -> $t1
for_6_begin:
beq $t1, $s0, for_6_end
li $t3, 0 #int sum = 0 -> $t3
li $t2, 0 #for (int k = 0; k < n; k ++) k -> $t2
for_7_begin:
beq $t2, $s0, for_7_end
getAddr($t4, $t0, $t2) #sum += A[i][k] * B[k][j]
lw $t5, A($t4)
getAddr($t4, $t2, $t1)
lw $t6, B($t4)
mult $t5, $t6
mflo $t4
add $t3, $t3, $t4
addi $t2, $t2, 1
j for_7_begin
for_7_end:
getAddr($t4, $t0, $t1) #C[i][j] = sum
sw $t3, C($t4)
addi $t1, $t1, 1
j for_6_begin
for_6_end:
addi $t0, $t0, 1
j for_5_begin
for_5_end:
li $t0, 0 #for (int i = 0; i < n; i ++) i -> $t0
for_8_begin:
beq $t0, $s0, for_8_end
li $t1, 0 #for (int j = 0; j < n; j ++) j -> $t1
for_9_begin:
beq $t1, $s0, for_9_end
getAddr($t2, $t0, $t1) #write C[i][j]
lw $t3, C($t2)
writeInt($t3)
writeString(space)
sw $t3, B($t2)
addi $t1, $t1, 1
j for_9_begin
for_9_end:
writeString(line)
addi $t0, $t0, 1
j for_8_begin
for_8_end:
li $v0, 10
syscall
|
Groups/Actions/Stabiliser.agda | Smaug123/agdaproofs | 4 | 1305 | {-# OPTIONS --safe --warning=error --without-K #-}
open import Setoids.Setoids
open import Groups.Definition
open import Groups.Subgroups.Definition
open import Groups.Actions.Definition
open import Sets.EquivalenceRelations
open import Groups.Actions.Definition
module Groups.Actions.Stabiliser {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+_ : A → A → A} {G : Group S _+_} (act : GroupAction G T) where
open GroupAction act
open Setoid T
stabiliserPred : (x : B) → (g : A) → Set d
stabiliserPred x g = (action g x) ∼ x
stabiliserWellDefined : (x : B) → {g h : A} → Setoid._∼_ S g h → (stabiliserPred x g) → stabiliserPred x h
stabiliserWellDefined x {g} {h} g=h gx=x = transitive (actionWellDefined1 (Equivalence.symmetric (Setoid.eq S) g=h)) gx=x
where
open Equivalence eq
open Setoid T
open Equivalence (Setoid.eq T)
stabiliserSubgroup : (x : B) → Subgroup G (stabiliserPred x)
Subgroup.isSubset (stabiliserSubgroup x) = stabiliserWellDefined x
Subgroup.closedUnderPlus (stabiliserSubgroup x) gx=x hx=x = transitive associativeAction (transitive (actionWellDefined2 hx=x) gx=x)
Subgroup.containsIdentity (stabiliserSubgroup x) = identityAction
Subgroup.closedUnderInverse (stabiliserSubgroup x) {g} gx=x = transitive (transitive (transitive (actionWellDefined2 (symmetric gx=x)) (symmetric associativeAction)) (actionWellDefined1 (invLeft {g}))) identityAction
where
open Group G
|
src/credits.asm | Gegel85/BTTGB | 1 | 243358 | strncpy::
xor a
or b
or c
ret z
ld a, [hli]
or a
ret z
ld [de], a
inc de
dec bc
jr strncpy
credits::
reset CREDITS_SLIDING
call waitVBLANK
reset LCD_CONTROL
ld de, $9800
ld a, 1
ld bc, $800
call fillMemory
reg VRAM_BANK_SELECT, 1
ld de, $9800
xor a
ld bc, $800
call fillMemory
reset VRAM_BANK_SELECT
ld hl, creditsText
ld bc, creditsTextEnd - creditsText
ld de, $9800
call copyMemory
ld hl, creditTextArray
ld de, $9840
ld bc, $20
call strncpy
reg WY, $90
reg WX, $7
reg LYC, $F
inc a
ld [CREDITS_CURRENT_LINE], a
reset CREDITS_SLIDING
reg CREDITS_LAST_ADDR_H, h
reg CREDITS_LAST_ADDR_L, l
reg CREDITS_LINE_POS, $80
ld hl, STAT_CONTROL
set 6, [hl]
ei
reg INTERRUPT_ENABLED, LCD_STAT_INTERRUPT
reg LCD_CONTROL, LCD_BASE_CONTROL
.loop:
ld a, [LY]
cp $90
jr z, .loop
.loop2:
ld a, [LY]
cp $90
jr nz, .loop2
ld a, [CREDITS_SLIDING]
ld hl, CREDITS_LINE_POS
bit 1, a
jr z, .inc
dec [hl]
dec [hl]
ld a, $A0
cp [hl]
jr z, .nextLine
jp .skip
.inc:
inc [hl]
inc [hl]
jr z, .nextLine
jp .skip
.nextLine:
ld hl, CREDITS_SLIDING
bit 1, [hl]
jr z, .newLine
reset CREDITS_LINE_POS
ld a, [CREDITS_CURRENT_LINE]
ld e, a
xor a
rl e
rla
or a
rl e
rla
add $98
ld d, a
ld a, 1
ld bc, $20
call fillMemory
ld a, [LYC]
add a, $10
ld [LYC], a
inc a
ld [CREDITS_CURRENT_LINE], a
xor a
ld hl, CREDITS_LINES
or [hl]
jr z, .nextText
dec [hl]
jp .skip
.newLine:
reg CREDITS_LINE_POS, $A0
ld a, [CREDITS_LAST_ADDR_H]
ld h, a
ld a, [CREDITS_LAST_ADDR_L]
ld l, a
xor a
or [hl]
jr z, .nextText
ld a, [LYC]
add a, $10
ld [LYC], a
inc a
ld [CREDITS_CURRENT_LINE], a
ld e, a
xor a
rl e
rla
or a
rl e
rla
add $98
ld d, a
ld bc, $20
call strncpy
ld a, h
ld [CREDITS_LAST_ADDR_H], a
ld a, l
ld [CREDITS_LAST_ADDR_L], a
ld hl, CREDITS_LINES
inc [hl]
jr .skip
.nextText:
reg CREDITS_CURRENT_LINE, $10
dec a
ld [LYC], a
ld hl, CREDITS_SLIDING
ld a, %10
xor [hl]
ld [hl], a
jr z, .newText
reset CREDITS_LINE_POS
jr .skip
.newText:
reset CREDITS_LINES
ld hl, CREDITS_LAST_ADDR_H
ld a, [hli]
ld b, a
ld a, [hl]
ld c, a
ld h, b
ld l, c
inc hl
ld a, l
cp a, creditTextArrayEnd & $FF
jr nz, .ok
ld a, h
cp a, creditTextArrayEnd >> 8
jr z, .mainMenu
.ok:
ld de, $9840
ld bc, $20
call strncpy
reg CREDITS_LINE_POS, $A0
ld a, h
ld [CREDITS_LAST_ADDR_H], a
ld a, l
ld [CREDITS_LAST_ADDR_L], a
.skip:
call updateMusics
call getKeys
xor $FF
jr nz, .mainMenu
jp .loop
.mainMenu:
ld hl, STAT_CONTROL
res 6, [hl]
reg INTERRUPT_ENABLED, VBLANK_INTERRUPT
reset SCROLL_X
di
jp mainMenu.lateInit |
Transynther/x86/_processed/NONE/_xt_sm_/i7-7700_9_0x48.log_21829_1881.asm | ljhsiun2/medusa | 9 | 245509 | .global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %r8
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0xd7f4, %rcx
nop
nop
nop
cmp $33607, %r13
movl $0x61626364, (%rcx)
xor %rbp, %rbp
lea addresses_normal_ht+0x1e694, %rax
add %rsi, %rsi
movw $0x6162, (%rax)
nop
nop
nop
nop
nop
sub $25444, %rax
lea addresses_normal_ht+0xfd94, %rsi
lea addresses_A_ht+0x3ae4, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
sub $61478, %r13
mov $12, %rcx
rep movsq
nop
nop
nop
mfence
lea addresses_D_ht+0xbc58, %r13
nop
nop
sub %r15, %r15
mov (%r13), %r8
nop
nop
nop
nop
sub %r13, %r13
lea addresses_D_ht+0x17059, %rax
nop
nop
nop
dec %r13
mov $0x6162636465666768, %r15
movq %r15, %xmm1
vmovups %ymm1, (%rax)
and %rdi, %rdi
lea addresses_normal_ht+0x2394, %rax
nop
nop
dec %rbp
movb (%rax), %r13b
add $37087, %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r8
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r8
push %rbx
push %rcx
push %rdi
push %rdx
// Store
lea addresses_WC+0xa294, %rbx
nop
nop
nop
nop
nop
add %rcx, %rcx
movl $0x51525354, (%rbx)
nop
nop
nop
nop
and $34166, %r12
// Store
mov $0x154, %r14
nop
nop
nop
nop
cmp %rcx, %rcx
movb $0x51, (%r14)
sub $7779, %rcx
// Store
lea addresses_RW+0x1f79a, %r14
nop
nop
nop
sub %r12, %r12
mov $0x5152535455565758, %rbx
movq %rbx, (%r14)
nop
nop
nop
and %rcx, %rcx
// Store
lea addresses_WC+0x12f94, %rcx
nop
inc %rdi
movw $0x5152, (%rcx)
nop
nop
and $39509, %rdi
// Store
mov $0xc94, %r8
and %rdi, %rdi
movw $0x5152, (%r8)
nop
nop
nop
nop
nop
and $62500, %rbx
// Faulty Load
lea addresses_WC+0xa294, %rdi
xor %rcx, %rcx
vmovups (%rdi), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $0, %xmm1, %r14
lea oracles, %rdx
and $0xff, %r14
shlq $12, %r14
mov (%rdx,%r14,1), %r14
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 6, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 1, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 8, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 9, 'size': 2, 'same': False, 'NT': True}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 1, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 10, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 2, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': True, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 6, 'size': 1, 'same': False, 'NT': False}}
{'54': 21829}
54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
*/
|
libsrc/_DEVELOPMENT/math/float/math48/lm/c/sccz80/dread1.asm | meesokim/z88dk | 0 | 83660 | <gh_stars>0
SECTION code_fp_math48
PUBLIC dread1, dread1b
EXTERN cm48_sccz80p_dread1, cm48_sccz80p_dread1b
defc dread1 = cm48_sccz80p_dread1
defc dread1b = cm48_sccz80p_dread1b
|
alloy4fun_models/trashltl/models/15/tYwPvm4gZ2a3YkuhZ.als | Kaixi26/org.alloytools.alloy | 0 | 3573 | open main
pred idtYwPvm4gZ2a3YkuhZ_prop16 {
all f : File | f in Protected since f in Protected
}
pred __repair { idtYwPvm4gZ2a3YkuhZ_prop16 }
check __repair { idtYwPvm4gZ2a3YkuhZ_prop16 <=> prop16o } |
tests/tzgeev.adb | leo-brewin/ada-lapack | 5 | 20824 | with Ada.Text_IO;
with Ada.Text_IO.Complex_IO;
with Ada.Numerics.Generic_Real_Arrays;
with Ada.Numerics.Generic_Complex_Types;
with Ada.Numerics.Generic_Complex_Arrays;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Numerics.Generic_Complex_Elementary_Functions;
with Ada_Lapack;
use Ada.Text_IO;
procedure tzgeev is
type Real is digits 18;
package Real_Arrays is new Ada.Numerics.Generic_Real_Arrays (Real);
package Complex_Types is new Ada.Numerics.Generic_Complex_Types (Real);
package Complex_Arrays is new Ada.Numerics.Generic_Complex_Arrays (Real_Arrays, Complex_Types);
package Real_Maths is new Ada.Numerics.Generic_Elementary_Functions (Real);
package Complex_Maths is new Ada.Numerics.Generic_Complex_Elementary_Functions (Complex_Types);
package Real_IO is new Ada.Text_IO.Float_IO (Real);
package Integer_IO is new Ada.Text_IO.Integer_IO (Integer);
package Complex_IO is new Ada.Text_IO.Complex_IO (Complex_Types);
package Lapack is new Ada_Lapack(Real, Complex_Types, Real_Arrays, Complex_Arrays);
use Lapack;
use Real_Arrays;
use Complex_Types;
use Complex_Arrays;
use Real_IO;
use Integer_IO;
use Complex_IO;
use Real_Maths;
use Complex_Maths;
matrix : Complex_Matrix (1..4,1..4);
matrix_rows : Integer := Matrix'Length (1);
matrix_cols : Integer := Matrix'Length (2);
eigenvalues : Complex_Vector (1..matrix_rows);
eigenvectors_rows : Integer := matrix_rows;
eigenvectors_cols : Integer := matrix_rows;
left_eigenvectors : Complex_Matrix (1..eigenvectors_rows,1..eigenvectors_cols);
right_eigenvectors : Complex_Matrix (1..eigenvectors_rows,1..eigenvectors_cols);
short_vector : Complex_Vector (1..1);
temp_vector : Real_Vector (1..2*matrix_rows);
return_code : Integer;
begin
matrix:= ((( -3.84, 2.25), ( -8.94, -4.75), ( 8.95, -6.53), ( -9.87, 4.82)),
(( -0.66, 0.83), ( -4.40, -3.82), ( -3.50, -4.26), ( -3.15, 7.36)),
(( -3.99, -4.73), ( -5.88, -6.60), ( -3.36, -0.40), ( -0.75, 5.23)),
(( 7.74, 4.18), ( 3.66, -7.53), ( 2.58, 3.60), ( 4.59, 5.41)));
GEEV ( JOBVL => 'V',
JOBVR => 'V',
A => matrix,
LDA => matrix_rows,
N => matrix_cols,
W => eigenvalues,
VL => left_eigenvectors,
VR => right_eigenvectors,
LDVL => eigenvectors_rows,
LDVR => eigenvectors_rows,
WORK => short_vector,
LWORK => -1,
RWORK => temp_vector,
INFO => return_code );
declare
work_vector_rows : Integer := Integer( short_vector(1).Re );
work_vector : Complex_Vector (1 .. work_vector_rows);
begin
GEEV ( JOBVL => 'V',
JOBVR => 'V',
A => matrix,
N => matrix_cols,
LDA => matrix_rows,
W => eigenvalues,
VL => left_eigenvectors,
VR => right_eigenvectors,
LDVL => eigenvectors_rows,
LDVR => eigenvectors_rows,
WORK => work_vector,
LWORK => work_vector_rows,
RWORK => temp_vector,
INFO => return_code );
end;
if (return_code /= 0) then
Put ("ZGEEV failed, the return code was : ");
Put ( return_code );
New_line;
else
Put_line("The eigenvalues");
for i in eigenvalues'range loop
put(eigenvalues(i),3,4,0);
put(" ");
end loop;
new_line;
new_line;
Put_line("The left eigenvectors");
for i in left_eigenvectors'range(1) loop
for j in left_eigenvectors'range(2) loop
put(left_eigenvectors(i,j),3,4,0);
put(" ");
end loop;
new_line;
end loop;
new_line;
Put_line("The right eigenvectors");
for i in right_eigenvectors'range(1) loop
for j in right_eigenvectors'range(2) loop
put(right_eigenvectors(i,j),3,4,0);
put(" ");
end loop;
new_line;
end loop;
end if;
end tzgeev;
|
oeis/059/A059542.asm | neoneye/loda-programs | 11 | 177901 | ; A059542: Beatty sequence for 1 + 1/log(2).
; Submitted by <NAME>
; 2,4,7,9,12,14,17,19,21,24,26,29,31,34,36,39,41,43,46,48,51,53,56,58,61,63,65,68,70,73,75,78,80,83,85,87,90,92,95,97,100,102,105,107,109,112,114,117,119,122,124,127,129,131,134,136,139,141,144,146,149,151,153,156,158,161,163,166,168,170,173,175,178,180,183,185,188,190,192,195,197,200,202,205,207,210,212,214,217,219,222,224,227,229,232,234,236,239,241,244
add $0,1
mov $2,1
mov $3,$0
mul $3,4
lpb $3
mul $1,$0
mul $2,$3
add $1,$2
div $1,$0
sub $2,2
div $2,$0
sub $3,1
max $3,1
mov $4,$0
lpe
mul $1,$0
div $1,$2
mov $0,$1
lpb $0
div $0,2
add $4,1
lpe
mov $0,$4
sub $0,1
|
test/Fail/Issue392.agda | redfish64/autonomic-agda | 3 | 7400 | <gh_stars>1-10
-- Andreas, 2011-09-11
module Issue392 where
import Common.Irrelevance
-- Create an non-irrelevant record R1 (at least one field relevant).
record R1 : Set1 where
field
.f1 : Set
f1' : Set
{- This creates a module with an relevant record parameter
module R1 (r : R1) where
.f1 : Set -- = R1.f1 r
f1' : Set
-}
-- Create an irrelevant instance f2 of R1.
record R2 : Set2 where
field
.f2 : R1
f3 : Set
-- This should not succeed.
open R1 f2 public
{-
identifier f2 is declared irrelevant, so it cannot be used here
when checking that the expression f2 has type R1
-}
|
tools-src/gnu/gcc/gcc/ada/sem_prag.ads | enfoTek/tomato.linksys.e2000.nvram-mod | 80 | 8257 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ P R A G --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-1997 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. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Pragma handling is isolated in a separate package
-- (logically this processing belongs in chapter 4)
with Types; use Types;
package Sem_Prag is
procedure Analyze_Pragma (N : Node_Id);
-- Analyze procedure for pragma reference node N
function Is_Pragma_String_Literal (Par : Node_Id) return Boolean;
-- Given an N_Pragma_Argument_Association node, Par, which has the form
-- of an operator symbol, determines whether or not it should be treated
-- as an string literal. This is called by Sem_Ch6.Analyze_Operator_Symbol.
-- If True is returned, the argument is converted to a string literal. If
-- False is returned, then the argument is treated as an entity reference
-- to the operator.
procedure Process_Compilation_Unit_Pragmas (N : Node_Id);
-- Called at the start of processing compilation unit N to deal with
-- any special issues regarding pragmas. In particular, we have to
-- deal with Suppress_All at this stage, since it appears after the
-- unit instead of before.
procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id);
-- This routine is used to set an encoded interface name. The node
-- S is an N_String_Literal node for the external name to be set, and
-- E is an entity whose Interface_Name field is to be set. In the
-- normal case where S contains a name that is a valid C identifier,
-- then S is simply set as the value of the Interface_Name. Otherwise
-- it is encoded. See the body for details of the encoding. This
-- encoding is only done on VMS systems, since it seems pretty silly,
-- but is needed to pass some dubious tests in the test suite.
end Sem_Prag;
|
libsrc/_DEVELOPMENT/math/float/math32/lm32/c/sdcc/fpclassify.asm | jpoikela/z88dk | 0 | 89430 | <filename>libsrc/_DEVELOPMENT/math/float/math32/lm32/c/sdcc/fpclassify.asm
SECTION code_fp_math32
PUBLIC _fpclassify
EXTERN cm32_sdcc_fpclassify
defc _fpclassify = cm32_sdcc_fpclassify
|
binary16/fwld.asm | DW0RKiN/Floating-point-Library-for-Z80 | 12 | 11374 | <reponame>DW0RKiN/Floating-point-Library-for-Z80<gh_stars>10-100
if not defined @FWLD
; Load Word. Convert unsigned 16-bit integer into floating-point number
; In: HL = Word to convert
; Out: HL = floating point representation
; Pollutes: AF
@FWLD:
if not defined FWLD
; *****************************************
FWLD ; *
; *****************************************
endif
LD A, H ; 1:4
OR A ; 1:4
JR z, FWLD_BYTE ; 2:12/7
CP 2*EXP_PLUS_ONE ; 2:7
JR c, FWLD_LOSSLESS ; 2:12/7
LD A, BIAS/EXP_PLUS_ONE+16 ; 2:7 HL = xxxx xxxx xxxx xxxx
FWLD_NORM:
ADD HL, HL ; 1:11
DEC A ; 1:4
JR nc, FWLD_NORM ; 2:12/7
ADD HL, HL ; 1:11
ADC A, A ; 1:4
ADD HL, HL ; 1:11
ADC A, A ; 1:4 AHL = 0eee eemm mmmm mmmm ?rrr rrrr
RL L ; 2:8 check for rounding
LD L, H ; 1:4
LD H, A ; 1:4
RET nc ; 1:11/5 0 rrrr rrr0
if carry_flow_warning
CCF ; 1:4
endif
RET z ; 1:11/5 1 0000 0000
INC L ; 1:4 rounding up
RET nz ; 1:11/5
INC H ; 1:4
RET ; 1:10
FWLD_BYTE: ; HL = 0000 0000 xxxx xxxx
OR L ; 1:4
RET z ; 1:5/11
LD H, BIAS/EXP_PLUS_ONE+8 ; 2:7
FWLD_BYTE_NORM:
ADD A, A ; 1:4
DEC H ; 1:4
JR nc, FWLD_BYTE_NORM ; 2:12/7
LD L, A ; 1:4
ADD HL, HL ; 1:11
ADD HL, HL ; 1:11 RET with reset carry
RET ; 1:10
FWLD_LOSSLESS: ; HL = 0000 0xxx xxxx xxxx, set carry
; $100 => $5C00
; $200 => $6000, $300 => $6200
; $400 => $6400, $500 => $6500, $600 => $6600, $700 => $6700
AND IMPBIT_MASK ; 2:7
LD A, BIAS+EXP_PLUS_ONE*(MANT_BITS-1) ; 2:7
JR nz, FWLD_LOSSLESS_E ; 2:12/7
if 1
FWLD_LOSSLESS_N:
ADD HL, HL ; 1:11
SUB $04 ; 2:7
BIT 2, H ; 2:8
JR z, FWLD_LOSSLESS_N ; 2:12/7
else
ADD HL, HL ; 1:11
SUB $04 ; 2:7
BIT 2, H ; 2:8
JR nz, FWLD_LOSSLESS_E ; 2:12/7
ADD HL, HL ; 1:11
SUB $04 ; 2:7
endif
FWLD_LOSSLESS_E:
ADD A, H ; 1:4 RET with reset carry
LD H, A ; 1:4
RET ; 1:10
endif
|
Transynther/x86/_processed/AVXALIGN/_ht_/i7-7700_9_0x48.log_1_1515.asm | ljhsiun2/medusa | 9 | 83999 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r12
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x1a4aa, %rbx
nop
nop
nop
nop
nop
cmp $1487, %rax
mov $0x6162636465666768, %r10
movq %r10, (%rbx)
nop
nop
nop
xor %r10, %r10
lea addresses_WC_ht+0x931a, %rsi
lea addresses_normal_ht+0x180ba, %rdi
nop
and %r12, %r12
mov $81, %rcx
rep movsb
nop
nop
nop
nop
add %r12, %r12
lea addresses_UC_ht+0x71da, %r12
nop
nop
nop
nop
and $4931, %rcx
mov $0x6162636465666768, %r10
movq %r10, (%r12)
nop
nop
nop
and %rbx, %rbx
lea addresses_WT_ht+0x21da, %rdi
nop
nop
nop
xor %rsi, %rsi
movw $0x6162, (%rdi)
nop
nop
nop
nop
nop
xor %rsi, %rsi
lea addresses_WC_ht+0x1e2e6, %rsi
lea addresses_WC_ht+0xc09a, %rdi
clflush (%rsi)
nop
add %r11, %r11
mov $65, %rcx
rep movsl
nop
nop
nop
sub $25242, %r10
lea addresses_D_ht+0x3fda, %rsi
lea addresses_A_ht+0x6fda, %rdi
nop
nop
nop
dec %r12
mov $47, %rcx
rep movsl
dec %rdi
lea addresses_WT_ht+0x315a, %rbx
nop
sub %rdi, %rdi
vmovups (%rbx), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $0, %xmm2, %rcx
nop
xor %rax, %rax
lea addresses_WT_ht+0x65da, %rsi
lea addresses_UC_ht+0x14d8a, %rdi
nop
nop
nop
nop
sub $55230, %rbx
mov $47, %rcx
rep movsl
nop
nop
sub %rax, %rax
lea addresses_A_ht+0x51d8, %r12
sub %rbx, %rbx
movb (%r12), %cl
nop
nop
nop
mfence
lea addresses_A_ht+0x7f32, %rdi
nop
nop
nop
nop
nop
sub %r10, %r10
mov (%rdi), %rcx
nop
nop
nop
and %rbx, %rbx
lea addresses_A_ht+0x4a5a, %rax
add %rdi, %rdi
movl $0x61626364, (%rax)
nop
nop
nop
cmp %rdi, %rdi
lea addresses_D_ht+0x1317a, %rcx
nop
xor %rdi, %rdi
mov (%rcx), %rax
nop
nop
nop
add $16724, %r10
lea addresses_normal_ht+0x13ada, %rcx
nop
nop
nop
nop
xor $1277, %r12
movl $0x61626364, (%rcx)
nop
nop
nop
add %rbx, %rbx
lea addresses_A_ht+0xefda, %rdi
nop
nop
nop
add %rcx, %rcx
movb $0x61, (%rdi)
nop
nop
xor $5163, %rcx
lea addresses_normal_ht+0xf250, %rax
nop
nop
nop
nop
cmp $8454, %rdi
mov $0x6162636465666768, %rcx
movq %rcx, %xmm4
vmovups %ymm4, (%rax)
and %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r12
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %rax
push %rbp
push %rbx
push %rcx
push %rdx
// Store
lea addresses_US+0x1d76e, %rdx
nop
nop
nop
nop
nop
add %rax, %rax
mov $0x5152535455565758, %rbp
movq %rbp, %xmm6
movups %xmm6, (%rdx)
nop
and %r12, %r12
// Load
lea addresses_WC+0x6aca, %rax
clflush (%rax)
nop
cmp %rcx, %rcx
vmovaps (%rax), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $1, %xmm1, %rbp
nop
nop
nop
nop
nop
add $28498, %r12
// Store
lea addresses_D+0x1f662, %rbp
nop
nop
xor $26151, %r14
mov $0x5152535455565758, %rbx
movq %rbx, %xmm1
vmovaps %ymm1, (%rbp)
nop
nop
nop
nop
and $19000, %rdx
// Load
lea addresses_D+0x1dda, %rbx
nop
add $27530, %rcx
mov (%rbx), %bp
nop
nop
nop
nop
cmp %r12, %r12
// Load
lea addresses_WC+0x8c8e, %rcx
nop
nop
nop
nop
sub %rbx, %rbx
mov (%rcx), %rdx
nop
nop
nop
dec %r14
// Store
lea addresses_PSE+0x1a5da, %r14
nop
nop
nop
sub %rdx, %rdx
movw $0x5152, (%r14)
cmp $54270, %rdx
// Store
lea addresses_PSE+0x1075a, %rbx
nop
nop
nop
nop
nop
cmp %r12, %r12
movl $0x51525354, (%rbx)
nop
sub %rax, %rax
// Store
lea addresses_A+0x10135, %rcx
nop
nop
nop
nop
nop
sub $34037, %rbx
movl $0x51525354, (%rcx)
inc %r12
// Store
mov $0x69e, %rdx
add %rbx, %rbx
mov $0x5152535455565758, %rbp
movq %rbp, (%rdx)
nop
add $62704, %r14
// Faulty Load
mov $0xfda, %rcx
nop
nop
xor $10369, %rbp
vmovntdqa (%rcx), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $0, %xmm1, %rdx
lea oracles, %rbx
and $0xff, %rdx
shlq $12, %rdx
mov (%rbx,%rdx,1), %rdx
pop %rdx
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 2, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': True, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': True, 'congruent': 2, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 9, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 2, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 9, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 7, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 2, 'size': 8, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': True, 'NT': True}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 2, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 9, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 6, 'size': 2, 'same': True, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': True}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 3, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 7, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 5, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 7, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 11, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 1, 'size': 32, 'same': False, 'NT': False}}
{'46': 1}
46
*/
|
programs/oeis/194/A194932.asm | jmorken/loda | 1 | 99899 | ; A194932: Number of lower triangles of a 3 X 3 0..n array with no element differing from any of its horizontal or vertical neighbors by more than one.
; 64,217,386,557,728,899,1070,1241,1412,1583,1754,1925,2096,2267,2438,2609,2780,2951,3122,3293,3464,3635,3806,3977,4148,4319,4490,4661,4832,5003,5174,5345,5516,5687,5858,6029,6200,6371,6542,6713,6884,7055,7226
mov $1,2
mov $2,$0
add $2,1
mov $3,$0
mul $0,2
sub $0,2
lpb $0
sub $0,1
add $1,5
lpe
sub $1,$2
mul $1,2
trn $1,2
lpb $3
add $1,153
sub $3,1
lpe
add $1,64
|
UniDB/Morph/StarPrime.agda | skeuchel/unidb-agda | 0 | 17125 | module UniDB.Morph.StarPrime where
open import UniDB.Spec
open import UniDB.Morph.Depth
mutual
data Star* (Ξ : MOR) : MOR where
refl : {γ : Dom} → Star* Ξ γ γ
incl : {γ₁ γ₂ : Dom} (ξs : Star+ Ξ γ₁ γ₂) → Star* Ξ γ₁ γ₂
data Star+ (Ξ : MOR) : MOR where
step : {γ₁ γ₂ γ₃ : Dom} (ξs : Star* Ξ γ₁ γ₂) (ξ : Ξ γ₂ γ₃) → Star+ Ξ γ₁ γ₃
module _ {Ξ : MOR} where
mutual
step` : {Ξ : MOR} {γ₁ γ₂ γ₃ : Dom} (ξ : Ξ γ₁ γ₂) (ζs : Star* Ξ γ₂ γ₃) → Star+ Ξ γ₁ γ₃
step` ξ refl = step refl ξ
step` ξ (incl ζ) = step+ ξ ζ
step+ : {Ξ : MOR} {γ₁ γ₂ γ₃ : Dom} (ξ : Ξ γ₁ γ₂) (ζs : Star+ Ξ γ₂ γ₃) → Star+ Ξ γ₁ γ₃
step+ ξ (step ζs ζ) = step (incl (step` ξ ζs)) ζ
mutual
comp** : {γ₁ γ₂ γ₃ : Dom} (ξs : Star* Ξ γ₁ γ₂) (ζs : Star* Ξ γ₂ γ₃) → Star* Ξ γ₁ γ₃
comp** ξs refl = ξs
comp** ξs (incl ζs) = incl (comp*+ ξs ζs)
comp*+ : {γ₁ γ₂ γ₃ : Dom} (ξs : Star* Ξ γ₁ γ₂) (ζs : Star+ Ξ γ₂ γ₃) → Star+ Ξ γ₁ γ₃
comp*+ ξs (step ζs ζ) = step (comp** ξs ζs) ζ
mutual
comp+* : {γ₁ γ₂ γ₃ : Dom} (ξs : Star+ Ξ γ₁ γ₂) (ζs : Star* Ξ γ₂ γ₃) → Star+ Ξ γ₁ γ₃
comp+* ξs refl = ξs
comp+* ξs (incl ζs) = comp++ ξs ζs
comp++ : {γ₁ γ₂ γ₃ : Dom} (ξs : Star+ Ξ γ₁ γ₂) (ζs : Star+ Ξ γ₂ γ₃) → Star+ Ξ γ₁ γ₃
comp++ ξs (step ζs ζ) = step (incl (comp+* ξs ζs)) ζ
module _ {Ξ : MOR} {{upΞ : Up Ξ}} where
mutual
instance
iUpStar* : Up (Star* Ξ)
_↑₁ {{iUpStar*}} refl = refl
_↑₁ {{iUpStar*}} (incl ξs) = incl (ξs ↑₁)
_↑_ {{iUpStar*}} ξ 0 = ξ
_↑_ {{iUpStar*}} ξ (suc δ⁺) = ξ ↑ δ⁺ ↑₁
↑-zero {{iUpStar*}} ξ = refl
↑-suc {{iUpStar*}} ξ δ⁺ = refl
iUpStar+ : Up (Star+ Ξ)
_↑₁ {{iUpStar+}} (step ξs ξ) = step (ξs ↑₁) (ξ ↑₁)
_↑_ {{iUpStar+}} ξ 0 = ξ
_↑_ {{iUpStar+}} ξ (suc δ⁺) = ξ ↑ δ⁺ ↑₁
↑-zero {{iUpStar+}} ξ = refl
↑-suc {{iUpStar+}} ξ δ⁺ = refl
|
src/L/Base/Unit.agda | borszag/smallib | 0 | 15324 | <filename>src/L/Base/Unit.agda
module L.Base.Unit where
-- Reexport definitions
open import L.Base.Unit.Core public
|
src/semantica.ads | alvaromb/Compilemon | 1 | 20016 | with Decls.Dgenerals,
Decls.Dtnode,
Decls.D_Taula_De_Noms,
Decls.D_Atribut,
Decls.dtsimbols,
Ada.Text_Io,
Decls.dtdesc;
use Decls.Dgenerals,
Decls.Dtnode,
Decls.D_Taula_De_Noms,
Decls.D_Atribut,
Decls.dtsimbols,
Ada.Text_Io,
Decls.dtdesc;
package Semantica is
--Definicions basiques
type tInstruccio is
(--1 operand
Rtn,
Call,
Preamb,
Params,
Etiqueta,
Branc_Inc,
-- 2 operands
Negacio,
Op_Not,
Copia,
Paramc,
--3 operands
Suma,
Resta,
Producte,
Divisio,
Modul,
Op_And,
Op_Or,
Consindex,
Asigindex,
Menor,
Menorigual,
Igual,
Majorigual,
Major,
Diferent);
type tCamp is
(Proc,
Var,
Etiq,
Const);
type Camp(tc : tCamp:=Const) is record
case Tc is
when Proc => Idp : num_Proc;
when Var => Idv : num_var;
when Etiq => Ide : num_etiq;
when Const => Idc : num_var;
when others => null;
end case;
end record;
type C3a is record
Instr : tInstruccio;
Camp1 : Camp;
Camp2 : Camp;
Camp3 : Camp;
end record;
type Tprocediment is
(Intern,
Extern);
type Info_Proc (Tp : Tprocediment := Intern) is
record
Ocup_Param : Despl;
case Tp is
when Intern =>
Idn : Id_Nom;
Prof : nprof;
Ocup_Var : Despl;
Etiq : Num_Etiq;
when Extern =>
Etiq_extern : Id_Nom;
end case;
end record;
Info_Proc_Nul : Info_Proc := (Intern, 0, Id_Nul,
0, 0, Etiq_Nul);
type Taula_P is array
(Num_Proc) of Info_Proc;
type T_Procs is record
Tp : Taula_P;
Np : Num_Proc;
end record;
Tp : T_Procs;
--Taula de variables
type Info_Var is record
Id : Id_Nom;
Np : num_proc;
Ocup : Despl;
Desp : Despl;
Tsub : Tipussubjacent;
Param : Boolean;
Const : Boolean;
Valconst : Valor;
end record;
Info_Var_Nul : Info_Var :=
(Id => Id_Nul,
Np => proc_nul,
Ocup => 0,
Desp => 0,
Tsub => Tsnul,
Param => False,
Const => False,
Valconst => 0);
type taula_v is array
(Num_Var) of Info_Var;
type T_Vars is record
Tv : taula_v;
Nv : num_var;
end record;
Tv : T_Vars;
Ne : Num_Etiq := 0;
Arbre : Pnode;
-- Per els brancaments
Zero,
MenysU : num_Var;
-- Procediments
procedure Abuit
(P : out pnode);
procedure creaNode_programa
(P : out Atribut;
A : in Atribut);
procedure creaNode
(p : out atribut;
fe, fd : in atribut;
tn : in Tipusnode);
procedure creaNode
(p : out atribut;
fe, fc, fd : in atribut;
tn : in Tipusnode);
procedure creaNode
(p : out atribut;
fe, fce, fc, fd : in atribut;
tn : in Tipusnode);
procedure creaNode
(p : out atribut;
f : in atribut;
tn : in Tipusnode);
procedure creaNode
(p : out atribut;
fe, fd: in atribut;
op : in operacio;
tn : in Tipusnode);
procedure creaNode
(p : out atribut;
f : in atribut;
op : in operacio;
tn : in Tipusnode);
procedure CreaNode_ID
(p : out atribut;
id : in atribut;
tn : in Tipusnode);
procedure CreaNode_VAL
(p : out atribut;
a : in atribut;
tn : in Tipusnode;
S : in Valor);
procedure CreaNode_MODE
(P : out Atribut;
M : in Mmode;
Tn : in Tipusnode);
procedure creaNode
(P : out Atribut;
Tn : in Tipusnode);
procedure Remunta
(P : out Atribut;
A : in Atribut);
procedure Cons_Tnode
(P : in Pnode;
Tn : out Tipusnode);
-- Procediments per a les Taules
procedure Noves_taules
(Tp : out T_Procs;
Tv : out T_Vars);
-- Procediments per Taula de Procediments
procedure Posa
(Tp : in out T_Procs;
Ip : in Info_Proc;
Idp : out num_Proc);
procedure Modif_Descripcio
(Tp : in out T_Procs;
Idp : in num_proc;
Ip : in Info_Proc);
-- Procediments per Taula de Variables
procedure Posa
(Tv : in out T_Vars;
Iv : in Info_Var;
Idv : out num_var);
private
Ts : Tsimbols;
Tts: Ttsimbols;
Tn : Taula_De_Noms;
Nv : Num_Var;
Np : Num_Proc;
Id_Puts : Num_Proc;
Id_Gets : Num_Proc;
end Semantica;
|
programs/oeis/103/A103447.asm | neoneye/loda | 22 | 15029 | <reponame>neoneye/loda
; A103447: Triangle read by rows: T(n,k) = Moebius(binomial(n,k)) (0 <= k <= n).
; 1,1,1,1,-1,1,1,-1,-1,1,1,0,1,0,1,1,-1,1,1,-1,1,1,1,1,0,1,1,1,1,-1,1,1,1,1,-1,1,1,0,0,0,-1,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,1,0,0,1,1,1,-1,1,-1,1,1,1,1,-1,1,-1,1,1,0,-1,0,0,0,0,0,0,0,-1,0,1,1,-1,-1,-1,-1,0,0,0,0
seq $0,14473 ; Pascal's triangle - 1.
seq $0,8683 ; Möbius (or Moebius) function mu(n). mu(1) = 1; mu(n) = (-1)^k if n is the product of k different primes; otherwise mu(n) = 0.
|
test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Add/Point/Equality.agda | omega12345/agda-mode | 0 | 7557 | ------------------------------------------------------------------------
-- The Agda standard library
--
-- A pointwise lifting of a relation to incorporate an additional point.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- This module is designed to be used with
-- Relation.Nullary.Construct.Add.Point
open import Relation.Binary
module Relation.Binary.Construct.Add.Point.Equality
{a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where
open import Level using (_⊔_)
open import Function
import Relation.Binary.PropositionalEquality as P
open import Relation.Nullary
open import Relation.Nullary.Construct.Add.Point
import Relation.Nullary.Decidable as Dec
------------------------------------------------------------------------
-- Definition
data _≈∙_ : Rel (Pointed A) (a ⊔ ℓ) where
∙≈∙ : ∙ ≈∙ ∙
[_] : {k l : A} → k ≈ l → [ k ] ≈∙ [ l ]
------------------------------------------------------------------------
-- Relational properties
[≈]-injective : ∀ {k l} → [ k ] ≈∙ [ l ] → k ≈ l
[≈]-injective [ k≈l ] = k≈l
≈∙-refl : Reflexive _≈_ → Reflexive _≈∙_
≈∙-refl ≈-refl {∙} = ∙≈∙
≈∙-refl ≈-refl {[ k ]} = [ ≈-refl ]
≈∙-sym : Symmetric _≈_ → Symmetric _≈∙_
≈∙-sym ≈-sym ∙≈∙ = ∙≈∙
≈∙-sym ≈-sym [ x≈y ] = [ ≈-sym x≈y ]
≈∙-trans : Transitive _≈_ → Transitive _≈∙_
≈∙-trans ≈-trans ∙≈∙ ∙≈z = ∙≈z
≈∙-trans ≈-trans [ x≈y ] [ y≈z ] = [ ≈-trans x≈y y≈z ]
≈∙-dec : Decidable _≈_ → Decidable _≈∙_
≈∙-dec _≟_ ∙ ∙ = yes ∙≈∙
≈∙-dec _≟_ ∙ [ l ] = no (λ ())
≈∙-dec _≟_ [ k ] ∙ = no (λ ())
≈∙-dec _≟_ [ k ] [ l ] = Dec.map′ [_] [≈]-injective (k ≟ l)
≈∙-irrelevant : Irrelevant _≈_ → Irrelevant _≈∙_
≈∙-irrelevant ≈-irr ∙≈∙ ∙≈∙ = P.refl
≈∙-irrelevant ≈-irr [ p ] [ q ] = P.cong _ (≈-irr p q)
≈∙-substitutive : ∀ {ℓ} → Substitutive _≈_ ℓ → Substitutive _≈∙_ ℓ
≈∙-substitutive ≈-subst P ∙≈∙ = id
≈∙-substitutive ≈-subst P [ p ] = ≈-subst (P ∘′ [_]) p
------------------------------------------------------------------------
-- Structures
≈∙-isEquivalence : IsEquivalence _≈_ → IsEquivalence _≈∙_
≈∙-isEquivalence ≈-isEquivalence = record
{ refl = ≈∙-refl refl
; sym = ≈∙-sym sym
; trans = ≈∙-trans trans
} where open IsEquivalence ≈-isEquivalence
≈∙-isDecEquivalence : IsDecEquivalence _≈_ → IsDecEquivalence _≈∙_
≈∙-isDecEquivalence ≈-isDecEquivalence = record
{ isEquivalence = ≈∙-isEquivalence isEquivalence
; _≟_ = ≈∙-dec _≟_
} where open IsDecEquivalence ≈-isDecEquivalence
|
src/API/protypo-api-engine_values-record_wrappers.adb | fintatarta/protypo | 0 | 15465 | <gh_stars>0
pragma Ada_2012;
package body Protypo.Api.Engine_Values.Record_Wrappers is
type Record_Access_Handler is
new Handlers.Constant_Interface
with
record
Pos : Record_Maps.Cursor;
end record;
function Read (X : Record_Access_Handler) return Engine_Value
is
begin
return Record_Maps.Element (X.Pos);
end Read;
function To_Handler (Pos : Record_Maps.Cursor) return Engine_Value
with Post => To_Handler'Result.Class = Constant_Handler;
----------------
-- To_Handler --
----------------
function To_Handler (Pos : Record_Maps.Cursor) return Engine_Value
is
use Handlers;
begin
return Create (Constant_Interface_Access'(new Record_Access_Handler'(Pos => Pos)));
end To_Handler;
---------
-- Get --
---------
function Get
(X : Record_Wrapper;
Field : ID)
return Handler_Value
is
begin
if not X.Map.Contains (Field) then
raise Handlers.Unknown_Field with String (Field);
end if;
declare
Result : constant Engine_Value := X.Map (Field);
begin
if Result.Class in Handler_Classes then
return Result;
else
return To_Handler (X.Map.Find (Field));
end if;
end;
end Get;
end Protypo.Api.Engine_Values.Record_Wrappers;
|
src/drivers/gclk_u2122/sam_svd-gclk.ads | Fabien-Chouteau/samd51-hal | 1 | 29365 | -- ============================================================================
-- Atmel Microcontroller Software Support
-- ============================================================================
-- Copyright (c) 2017 Atmel Corporation,
-- a wholly owned subsidiary of Microchip Technology Inc.
--
-- 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 Licence 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.
-- ============================================================================
-- This spec has been automatically generated from ATSAMD51J19A.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package SAM_SVD.GCLK is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Control
type GCLK_CTRLA_Register is record
-- Software Reset
SWRST : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Size => 8, Bit_Order => System.Low_Order_First;
for GCLK_CTRLA_Register use record
SWRST at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
end record;
-- Generic Clock Generator Control 0 Synchronization Busy bits
type SYNCBUSY_GENCTRL0Select is
(-- Generic clock generator 0
Gclk0,
-- Generic clock generator 1
Gclk1,
-- Generic clock generator 2
Gclk2,
-- Generic clock generator 3
Gclk3,
-- Generic clock generator 4
Gclk4,
-- Generic clock generator 5
Gclk5,
-- Generic clock generator 6
Gclk6,
-- Generic clock generator 7
Gclk7,
-- Generic clock generator 8
Gclk8,
-- Generic clock generator 9
Gclk9,
-- Generic clock generator 10
Gclk10,
-- Generic clock generator 11
Gclk11)
with Size => 12;
for SYNCBUSY_GENCTRL0Select use
(Gclk0 => 1,
Gclk1 => 2,
Gclk2 => 4,
Gclk3 => 8,
Gclk4 => 16,
Gclk5 => 32,
Gclk6 => 64,
Gclk7 => 128,
Gclk8 => 256,
Gclk9 => 512,
Gclk10 => 1024,
Gclk11 => 2048);
-- Generic Clock Generator Control 1 Synchronization Busy bits
type SYNCBUSY_GENCTRL1Select is
(-- Generic clock generator 0
Gclk0,
-- Generic clock generator 1
Gclk1,
-- Generic clock generator 2
Gclk2,
-- Generic clock generator 3
Gclk3,
-- Generic clock generator 4
Gclk4,
-- Generic clock generator 5
Gclk5,
-- Generic clock generator 6
Gclk6,
-- Generic clock generator 7
Gclk7,
-- Generic clock generator 8
Gclk8,
-- Generic clock generator 9
Gclk9,
-- Generic clock generator 10
Gclk10,
-- Generic clock generator 11
Gclk11)
with Size => 12;
for SYNCBUSY_GENCTRL1Select use
(Gclk0 => 1,
Gclk1 => 2,
Gclk2 => 4,
Gclk3 => 8,
Gclk4 => 16,
Gclk5 => 32,
Gclk6 => 64,
Gclk7 => 128,
Gclk8 => 256,
Gclk9 => 512,
Gclk10 => 1024,
Gclk11 => 2048);
-- Generic Clock Generator Control 2 Synchronization Busy bits
type SYNCBUSY_GENCTRL2Select is
(-- Generic clock generator 0
Gclk0,
-- Generic clock generator 1
Gclk1,
-- Generic clock generator 2
Gclk2,
-- Generic clock generator 3
Gclk3,
-- Generic clock generator 4
Gclk4,
-- Generic clock generator 5
Gclk5,
-- Generic clock generator 6
Gclk6,
-- Generic clock generator 7
Gclk7,
-- Generic clock generator 8
Gclk8,
-- Generic clock generator 9
Gclk9,
-- Generic clock generator 10
Gclk10,
-- Generic clock generator 11
Gclk11)
with Size => 12;
for SYNCBUSY_GENCTRL2Select use
(Gclk0 => 1,
Gclk1 => 2,
Gclk2 => 4,
Gclk3 => 8,
Gclk4 => 16,
Gclk5 => 32,
Gclk6 => 64,
Gclk7 => 128,
Gclk8 => 256,
Gclk9 => 512,
Gclk10 => 1024,
Gclk11 => 2048);
-- Generic Clock Generator Control 3 Synchronization Busy bits
type SYNCBUSY_GENCTRL3Select is
(-- Generic clock generator 0
Gclk0,
-- Generic clock generator 1
Gclk1,
-- Generic clock generator 2
Gclk2,
-- Generic clock generator 3
Gclk3,
-- Generic clock generator 4
Gclk4,
-- Generic clock generator 5
Gclk5,
-- Generic clock generator 6
Gclk6,
-- Generic clock generator 7
Gclk7,
-- Generic clock generator 8
Gclk8,
-- Generic clock generator 9
Gclk9,
-- Generic clock generator 10
Gclk10,
-- Generic clock generator 11
Gclk11)
with Size => 12;
for SYNCBUSY_GENCTRL3Select use
(Gclk0 => 1,
Gclk1 => 2,
Gclk2 => 4,
Gclk3 => 8,
Gclk4 => 16,
Gclk5 => 32,
Gclk6 => 64,
Gclk7 => 128,
Gclk8 => 256,
Gclk9 => 512,
Gclk10 => 1024,
Gclk11 => 2048);
-- Generic Clock Generator Control 4 Synchronization Busy bits
type SYNCBUSY_GENCTRL4Select is
(-- Generic clock generator 0
Gclk0,
-- Generic clock generator 1
Gclk1,
-- Generic clock generator 2
Gclk2,
-- Generic clock generator 3
Gclk3,
-- Generic clock generator 4
Gclk4,
-- Generic clock generator 5
Gclk5,
-- Generic clock generator 6
Gclk6,
-- Generic clock generator 7
Gclk7,
-- Generic clock generator 8
Gclk8,
-- Generic clock generator 9
Gclk9,
-- Generic clock generator 10
Gclk10,
-- Generic clock generator 11
Gclk11)
with Size => 12;
for SYNCBUSY_GENCTRL4Select use
(Gclk0 => 1,
Gclk1 => 2,
Gclk2 => 4,
Gclk3 => 8,
Gclk4 => 16,
Gclk5 => 32,
Gclk6 => 64,
Gclk7 => 128,
Gclk8 => 256,
Gclk9 => 512,
Gclk10 => 1024,
Gclk11 => 2048);
-- Generic Clock Generator Control 5 Synchronization Busy bits
type SYNCBUSY_GENCTRL5Select is
(-- Generic clock generator 0
Gclk0,
-- Generic clock generator 1
Gclk1,
-- Generic clock generator 2
Gclk2,
-- Generic clock generator 3
Gclk3,
-- Generic clock generator 4
Gclk4,
-- Generic clock generator 5
Gclk5,
-- Generic clock generator 6
Gclk6,
-- Generic clock generator 7
Gclk7,
-- Generic clock generator 8
Gclk8,
-- Generic clock generator 9
Gclk9,
-- Generic clock generator 10
Gclk10,
-- Generic clock generator 11
Gclk11)
with Size => 12;
for SYNCBUSY_GENCTRL5Select use
(Gclk0 => 1,
Gclk1 => 2,
Gclk2 => 4,
Gclk3 => 8,
Gclk4 => 16,
Gclk5 => 32,
Gclk6 => 64,
Gclk7 => 128,
Gclk8 => 256,
Gclk9 => 512,
Gclk10 => 1024,
Gclk11 => 2048);
-- Generic Clock Generator Control 6 Synchronization Busy bits
type SYNCBUSY_GENCTRL6Select is
(-- Generic clock generator 0
Gclk0,
-- Generic clock generator 1
Gclk1,
-- Generic clock generator 2
Gclk2,
-- Generic clock generator 3
Gclk3,
-- Generic clock generator 4
Gclk4,
-- Generic clock generator 5
Gclk5,
-- Generic clock generator 6
Gclk6,
-- Generic clock generator 7
Gclk7,
-- Generic clock generator 8
Gclk8,
-- Generic clock generator 9
Gclk9,
-- Generic clock generator 10
Gclk10,
-- Generic clock generator 11
Gclk11)
with Size => 12;
for SYNCBUSY_GENCTRL6Select use
(Gclk0 => 1,
Gclk1 => 2,
Gclk2 => 4,
Gclk3 => 8,
Gclk4 => 16,
Gclk5 => 32,
Gclk6 => 64,
Gclk7 => 128,
Gclk8 => 256,
Gclk9 => 512,
Gclk10 => 1024,
Gclk11 => 2048);
-- Generic Clock Generator Control 7 Synchronization Busy bits
type SYNCBUSY_GENCTRL7Select is
(-- Generic clock generator 0
Gclk0,
-- Generic clock generator 1
Gclk1,
-- Generic clock generator 2
Gclk2,
-- Generic clock generator 3
Gclk3,
-- Generic clock generator 4
Gclk4,
-- Generic clock generator 5
Gclk5,
-- Generic clock generator 6
Gclk6,
-- Generic clock generator 7
Gclk7,
-- Generic clock generator 8
Gclk8,
-- Generic clock generator 9
Gclk9,
-- Generic clock generator 10
Gclk10,
-- Generic clock generator 11
Gclk11)
with Size => 12;
for SYNCBUSY_GENCTRL7Select use
(Gclk0 => 1,
Gclk1 => 2,
Gclk2 => 4,
Gclk3 => 8,
Gclk4 => 16,
Gclk5 => 32,
Gclk6 => 64,
Gclk7 => 128,
Gclk8 => 256,
Gclk9 => 512,
Gclk10 => 1024,
Gclk11 => 2048);
-- Generic Clock Generator Control 8 Synchronization Busy bits
type SYNCBUSY_GENCTRL8Select is
(-- Generic clock generator 0
Gclk0,
-- Generic clock generator 1
Gclk1,
-- Generic clock generator 2
Gclk2,
-- Generic clock generator 3
Gclk3,
-- Generic clock generator 4
Gclk4,
-- Generic clock generator 5
Gclk5,
-- Generic clock generator 6
Gclk6,
-- Generic clock generator 7
Gclk7,
-- Generic clock generator 8
Gclk8,
-- Generic clock generator 9
Gclk9,
-- Generic clock generator 10
Gclk10,
-- Generic clock generator 11
Gclk11)
with Size => 12;
for SYNCBUSY_GENCTRL8Select use
(Gclk0 => 1,
Gclk1 => 2,
Gclk2 => 4,
Gclk3 => 8,
Gclk4 => 16,
Gclk5 => 32,
Gclk6 => 64,
Gclk7 => 128,
Gclk8 => 256,
Gclk9 => 512,
Gclk10 => 1024,
Gclk11 => 2048);
-- Generic Clock Generator Control 9 Synchronization Busy bits
type SYNCBUSY_GENCTRL9Select is
(-- Generic clock generator 0
Gclk0,
-- Generic clock generator 1
Gclk1,
-- Generic clock generator 2
Gclk2,
-- Generic clock generator 3
Gclk3,
-- Generic clock generator 4
Gclk4,
-- Generic clock generator 5
Gclk5,
-- Generic clock generator 6
Gclk6,
-- Generic clock generator 7
Gclk7,
-- Generic clock generator 8
Gclk8,
-- Generic clock generator 9
Gclk9,
-- Generic clock generator 10
Gclk10,
-- Generic clock generator 11
Gclk11)
with Size => 12;
for SYNCBUSY_GENCTRL9Select use
(Gclk0 => 1,
Gclk1 => 2,
Gclk2 => 4,
Gclk3 => 8,
Gclk4 => 16,
Gclk5 => 32,
Gclk6 => 64,
Gclk7 => 128,
Gclk8 => 256,
Gclk9 => 512,
Gclk10 => 1024,
Gclk11 => 2048);
-- Generic Clock Generator Control 10 Synchronization Busy bits
type SYNCBUSY_GENCTRL10Select is
(-- Generic clock generator 0
Gclk0,
-- Generic clock generator 1
Gclk1,
-- Generic clock generator 2
Gclk2,
-- Generic clock generator 3
Gclk3,
-- Generic clock generator 4
Gclk4,
-- Generic clock generator 5
Gclk5,
-- Generic clock generator 6
Gclk6,
-- Generic clock generator 7
Gclk7,
-- Generic clock generator 8
Gclk8,
-- Generic clock generator 9
Gclk9,
-- Generic clock generator 10
Gclk10,
-- Generic clock generator 11
Gclk11)
with Size => 12;
for SYNCBUSY_GENCTRL10Select use
(Gclk0 => 1,
Gclk1 => 2,
Gclk2 => 4,
Gclk3 => 8,
Gclk4 => 16,
Gclk5 => 32,
Gclk6 => 64,
Gclk7 => 128,
Gclk8 => 256,
Gclk9 => 512,
Gclk10 => 1024,
Gclk11 => 2048);
-- Generic Clock Generator Control 11 Synchronization Busy bits
type SYNCBUSY_GENCTRL11Select is
(-- Generic clock generator 0
Gclk0,
-- Generic clock generator 1
Gclk1,
-- Generic clock generator 2
Gclk2,
-- Generic clock generator 3
Gclk3,
-- Generic clock generator 4
Gclk4,
-- Generic clock generator 5
Gclk5,
-- Generic clock generator 6
Gclk6,
-- Generic clock generator 7
Gclk7,
-- Generic clock generator 8
Gclk8,
-- Generic clock generator 9
Gclk9,
-- Generic clock generator 10
Gclk10,
-- Generic clock generator 11
Gclk11)
with Size => 12;
for SYNCBUSY_GENCTRL11Select use
(Gclk0 => 1,
Gclk1 => 2,
Gclk2 => 4,
Gclk3 => 8,
Gclk4 => 16,
Gclk5 => 32,
Gclk6 => 64,
Gclk7 => 128,
Gclk8 => 256,
Gclk9 => 512,
Gclk10 => 1024,
Gclk11 => 2048);
-- Synchronization Busy
type GCLK_SYNCBUSY_Register is record
-- Read-only. Software Reset Synchroniation Busy bit
SWRST : Boolean;
-- unspecified
Reserved_1_1 : HAL.Bit;
-- Read-only. Generic Clock Generator Control 0 Synchronization Busy
-- bits
GENCTRL : HAL.UInt12;
Reserved_14_31 : HAL.UInt18;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for GCLK_SYNCBUSY_Register use record
SWRST at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
GENCTRL at 0 range 2 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-- Source Select
type GENCTRL_SRCSelect is
(-- XOSC0 oscillator output
Xosc0,
-- XOSC1 oscillator output
Xosc1,
-- Generator input pad
Gclkin,
-- Generic clock generator 1 output
Gclkgen1,
-- OSCULP32K oscillator output
Osculp32K,
-- XOSC32K oscillator output
Xosc32K,
-- DFLL output
Dfll,
-- DPLL0 output
Dpll0,
-- DPLL1 output
Dpll1)
with Size => 4;
for GENCTRL_SRCSelect use
(Xosc0 => 0,
Xosc1 => 1,
Gclkin => 2,
Gclkgen1 => 3,
Osculp32K => 4,
Xosc32K => 5,
Dfll => 6,
Dpll0 => 7,
Dpll1 => 8);
subtype GCLK_GENCTRL_DIV_Field is HAL.UInt16;
-- Generic Clock Generator Control
type GCLK_GENCTRL_Register is record
-- Source Select
SRC : GENCTRL_SRCSelect := SAM_SVD.GCLK.Xosc0;
-- unspecified
Reserved_4_7 : HAL.UInt4 := 16#0#;
-- Generic Clock Generator Enable
GENEN : Boolean := False;
-- Improve Duty Cycle
IDC : Boolean := False;
-- Output Off Value
OOV : Boolean := False;
-- Output Enable
OE : Boolean := False;
-- Divide Selection
DIVSEL : Boolean := False;
-- Run in Standby
RUNSTDBY : Boolean := False;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
-- Division Factor
DIV : GCLK_GENCTRL_DIV_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for GCLK_GENCTRL_Register use record
SRC at 0 range 0 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
GENEN at 0 range 8 .. 8;
IDC at 0 range 9 .. 9;
OOV at 0 range 10 .. 10;
OE at 0 range 11 .. 11;
DIVSEL at 0 range 12 .. 12;
RUNSTDBY at 0 range 13 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
DIV at 0 range 16 .. 31;
end record;
-- Generic Clock Generator Control
type GCLK_GENCTRL_Registers is array (0 .. 11) of GCLK_GENCTRL_Register;
-- Generic Clock Generator
type PCHCTRL_GENSelect is new HAL.UInt4
with Size => 4;
-- Peripheral Clock Control
type GCLK_PCHCTRL_Register is record
-- Generic Clock Generator
GEN : PCHCTRL_GENSelect;
-- unspecified
Reserved_4_5 : HAL.UInt2 := 16#0#;
-- Channel Enable
CHEN : Boolean := False;
-- Write Lock
WRTLOCK : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for GCLK_PCHCTRL_Register use record
GEN at 0 range 0 .. 3;
Reserved_4_5 at 0 range 4 .. 5;
CHEN at 0 range 6 .. 6;
WRTLOCK at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Peripheral Clock Control
type GCLK_PCHCTRL_Registers is array (0 .. 47) of GCLK_PCHCTRL_Register;
-----------------
-- Peripherals --
-----------------
-- Generic Clock Generator
type GCLK_Peripheral is record
-- Control
CTRLA : aliased GCLK_CTRLA_Register;
-- Synchronization Busy
SYNCBUSY : aliased GCLK_SYNCBUSY_Register;
-- Generic Clock Generator Control
GENCTRL : aliased GCLK_GENCTRL_Registers;
-- Peripheral Clock Control
PCHCTRL : aliased GCLK_PCHCTRL_Registers;
end record
with Volatile;
for GCLK_Peripheral use record
CTRLA at 16#0# range 0 .. 7;
SYNCBUSY at 16#4# range 0 .. 31;
GENCTRL at 16#20# range 0 .. 383;
PCHCTRL at 16#80# range 0 .. 1535;
end record;
-- Generic Clock Generator
GCLK_Periph : aliased GCLK_Peripheral
with Import, Address => GCLK_Base;
end SAM_SVD.GCLK;
|
Dave/Logic/Basics.agda | DavidStahl97/formal-proofs | 0 | 14865 | <gh_stars>0
module Dave.Logic.Basics where
open import Dave.Functions
open import Dave.Equality
open import Dave.Isomorphism
open import Dave.Structures.Monoid
{- True -}
data ⊤ : Set where
tt : ⊤
η-⊤ : ∀ (w : ⊤) → tt ≡ w
η-⊤ tt = refl
{- False -}
data ⊥ : Set where
-- no clauses!
⊥-elim : ∀ {A : Set} → ⊥ → A
⊥-elim ()
uniq-⊥ : ∀ {C : Set} (h : ⊥ → C) (w : ⊥) → ⊥-elim w ≡ h w
uniq-⊥ h ()
{- Product (Conjunction) -}
data _×_ (A B : Set) : Set where
⟨_,_⟩ : A → B → A × B
infixr 2 _×_
proj₁ : {A B : Set} → A × B → A
proj₁ ⟨ a , b ⟩ = a
proj₂ : {A B : Set} → A × B → B
proj₂ ⟨ a , b ⟩ = b
×-comm : {A B : Set} → (A × B) ≃ (B × A)
×-comm = record
{
to = λ{ ⟨ a , b ⟩ → ⟨ b , a ⟩ };
from = λ {⟨ b , a ⟩ → ⟨ a , b ⟩};
from∘to = λ { ⟨ a , b ⟩ → refl };
to∘from = λ { ⟨ b , a ⟩ → refl }
}
×-assoc : ∀ {A B C : Set} → (A × B) × C ≃ A × (B × C)
×-assoc = record
{
to = λ {⟨ ⟨ a , b ⟩ , c ⟩ → ⟨ a , ⟨ b , c ⟩ ⟩};
from = λ {⟨ a , ⟨ b , c ⟩ ⟩ → ⟨ ⟨ a , b ⟩ , c ⟩};
from∘to = λ {⟨ ⟨ a , b ⟩ , c ⟩ → refl};
to∘from = λ {⟨ a , ⟨ b , c ⟩ ⟩ → refl}
}
η-× : ∀ {A B : Set} (w : A × B) → ⟨ proj₁ w , proj₂ w ⟩ ≡ w
η-× ⟨ x , y ⟩ = refl
⊤-identityˡ : ∀ {A : Set} → ⊤ × A ≃ A
⊤-identityˡ = record
{
to = λ{ ⟨ tt , x ⟩ → x };
from = λ{ x → ⟨ tt , x ⟩ };
from∘to = λ{ ⟨ tt , x ⟩ → refl };
to∘from = λ{ x → refl }
}
⊤-identityʳ : ∀ {A : Set} → (A × ⊤) ≃ A
⊤-identityʳ {A} = ≃-begin
(A × ⊤) ≃⟨ ×-comm ⟩
(⊤ × A) ≃⟨ ⊤-identityˡ ⟩
A ≃-∎
{- Sum (Disjunction) -}
data _⊎_ (A B : Set) : Set where
inj₁ : A → A ⊎ B
inj₂ : B → A ⊎ B
infixr 1 _⊎_
case-⊎ : ∀ {A B C : Set}
→ (A → C)
→ (B → C)
→ A ⊎ B
-----------
→ C
case-⊎ f g (inj₁ x) = f x
case-⊎ f g (inj₂ y) = g y
uniq-⊎ : ∀ {A B C : Set} (h : A ⊎ B → C) (w : A ⊎ B) →
case-⊎ (h ∘ inj₁) (h ∘ inj₂) w ≡ h w
uniq-⊎ h (inj₁ x) = refl
uniq-⊎ h (inj₂ y) = refl
η-⊎ : ∀ {A B : Set} (w : A ⊎ B) → case-⊎ inj₁ inj₂ w ≡ w
η-⊎ (inj₁ x) = refl
η-⊎ (inj₂ y) = refl
⊥-identityˡ : ∀ {A : Set} → ⊥ ⊎ A ≃ A
⊥-identityˡ = record
{
to = λ {(inj₂ a) → a};
from = λ a → inj₂ a;
from∘to = λ {(inj₂ a) → refl};
to∘from = λ a → refl
}
⊎-comm : ∀ {A B : Set} → A ⊎ B ≃ B ⊎ A
⊎-comm = record
{
to = λ {(inj₁ A) → inj₂ A
; (inj₂ B) → inj₁ B};
from = λ {(inj₁ B) → inj₂ B
; (inj₂ A) → inj₁ A};
from∘to = λ {(inj₁ x) → refl
; (inj₂ x) → refl};
to∘from = λ {(inj₁ x) → refl
; (inj₂ x) → refl}
}
⊎-assoc : ∀ {A B C : Set} → (A ⊎ B) ⊎ C ≃ A ⊎ (B ⊎ C)
⊎-assoc = record
{
to = λ {(inj₁ (inj₁ a)) → inj₁ a
; (inj₁ (inj₂ b)) → inj₂ (inj₁ b)
; (inj₂ c) → inj₂ (inj₂ c)};
from = λ {(inj₁ a) → inj₁ (inj₁ a)
; (inj₂ (inj₁ b)) → inj₁ (inj₂ b)
; (inj₂ (inj₂ c)) → inj₂ c};
from∘to = λ {(inj₁ (inj₁ x)) → refl
; (inj₁ (inj₂ x)) → refl
; (inj₂ x) → refl};
to∘from = λ {(inj₁ x) → refl
; (inj₂ (inj₁ x)) → refl
; (inj₂ (inj₂ x)) → refl}
}
⊥-identityʳ : ∀ {A : Set} → A ⊎ ⊥ ≃ A
⊥-identityʳ {A} = ≃-begin
(A ⊎ ⊥) ≃⟨ ⊎-comm ⟩
(⊥ ⊎ A) ≃⟨ ⊥-identityˡ ⟩
A ≃-∎
{- Equality -}
record _⇔_ (A B : Set) : Set where
field
to : A → B
from : B → A
open _⇔_
⇔-ref : ∀ {A : Set} → A ⇔ A
⇔-ref = record
{
to = λ a → a;
from = λ a → a
}
⇔-sym : ∀ {A B : Set} → A ⇔ B → B ⇔ A
⇔-sym A⇔B = record
{
to = from A⇔B;
from = to A⇔B
}
⇔-trans : ∀ {A B C : Set} → A ⇔ B → B ⇔ C → A ⇔ C
⇔-trans A⇔B B⇔C = record
{
to = λ a → to B⇔C (to A⇔B a);
from = λ c → from A⇔B (from B⇔C c)
}
⇔≃× : ∀ {A B : Set} → A ⇔ B ≃ (A → B) × (B → A)
⇔≃× = record
{
to = λ {A⇔B → ⟨ to A⇔B , from A⇔B ⟩};
from = λ {x → record { to = proj₁ x; from = proj₂ x } };
from∘to = λ A⇔B → refl;
to∘from = λ {⟨ A→B , B→A ⟩ → refl}
}
|
programs/oeis/134/A134478.asm | karttu/loda | 0 | 8872 | ; A134478: Triangle read by rows, T(0,0) = 1; n-th row = (n+1) terms of n, n+1, n+2...
; 1,1,2,2,3,4,3,4,5,6,4,5,6,7,8,5,6,7,8,9,10,6,7,8,9,10,11,12,7,8,9,10,11,12,13,14,8,9,10,11,12,13,14,15,16,9,10,11,12,13,14,15,16,17,18,10,11,12,13,14,15,16,17,18,19,20,11,12,13,14,15,16,17,18,19,20,21,22,12,13,14,15,16,17,18,19,20,21,22,23,24,13,14,15,16,17,18,19,20,21,22,23,24,25,26,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39
mov $1,1
lpb $0,1
add $2,$0
sub $0,1
mov $1,$2
sub $2,$0
trn $0,$2
lpe
|
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0xca_notsx.log_21829_507.asm | ljhsiun2/medusa | 9 | 169261 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0xf4a1, %rax
nop
nop
nop
nop
nop
and %rsi, %rsi
movb (%rax), %dl
cmp $52166, %r11
lea addresses_WC_ht+0xf431, %rsi
lea addresses_WC_ht+0xe921, %rdi
nop
and $63229, %rbx
mov $17, %rcx
rep movsq
nop
inc %rcx
lea addresses_A_ht+0x86a1, %rbx
nop
nop
nop
nop
add %rcx, %rcx
movl $0x61626364, (%rbx)
xor $44077, %rsi
lea addresses_UC_ht+0x11477, %rdx
nop
nop
nop
cmp $57218, %rdi
mov (%rdx), %eax
nop
sub %rbx, %rbx
lea addresses_WC_ht+0x1b2a1, %rsi
nop
nop
nop
nop
and $40883, %rdi
mov (%rsi), %r11
inc %rdi
lea addresses_UC_ht+0xdd99, %rsi
lea addresses_UC_ht+0x32a1, %rdi
nop
nop
nop
nop
nop
and $44767, %rbp
mov $93, %rcx
rep movsw
nop
nop
and $9831, %rdi
lea addresses_D_ht+0x18881, %rax
nop
nop
nop
nop
and %r11, %r11
mov $0x6162636465666768, %rbx
movq %rbx, %xmm1
vmovups %ymm1, (%rax)
xor $43306, %rdi
lea addresses_WT_ht+0x2c21, %rsi
lea addresses_D_ht+0xb1a1, %rdi
nop
xor $21846, %rbp
mov $59, %rcx
rep movsw
nop
nop
nop
nop
and $17626, %rdx
lea addresses_UC_ht+0x10ac1, %rsi
add %rdi, %rdi
movb (%rsi), %r11b
nop
nop
sub %rax, %rax
lea addresses_normal_ht+0x184a1, %rbp
clflush (%rbp)
nop
nop
and %r11, %r11
mov $0x6162636465666768, %rax
movq %rax, (%rbp)
nop
nop
nop
nop
nop
inc %r11
lea addresses_WT_ht+0x52a1, %rsi
lea addresses_UC_ht+0x156a1, %rdi
clflush (%rdi)
nop
inc %rax
mov $24, %rcx
rep movsw
nop
nop
nop
and %rbx, %rbx
lea addresses_D_ht+0x7921, %rsi
lea addresses_normal_ht+0xaba1, %rdi
nop
nop
sub $41425, %rdx
mov $41, %rcx
rep movsb
nop
nop
nop
nop
nop
dec %rcx
lea addresses_UC_ht+0x51a9, %rsi
lea addresses_WC_ht+0x1a651, %rdi
clflush (%rsi)
nop
add %rbp, %rbp
mov $15, %rcx
rep movsl
nop
nop
and $51240, %rdi
lea addresses_WC_ht+0x3185, %rsi
lea addresses_A_ht+0x4e9, %rdi
nop
nop
nop
nop
cmp %rdx, %rdx
mov $110, %rcx
rep movsb
nop
nop
nop
nop
nop
dec %rbx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r13
push %r8
push %rax
push %rbx
push %rsi
// Store
lea addresses_WT+0x14ab1, %rbx
clflush (%rbx)
nop
nop
cmp %r8, %r8
mov $0x5152535455565758, %rax
movq %rax, %xmm6
movups %xmm6, (%rbx)
sub %r11, %r11
// Load
lea addresses_D+0x1c2a1, %r11
nop
nop
sub $35351, %r12
mov (%r11), %rax
nop
sub %r12, %r12
// Load
lea addresses_WC+0x9b31, %rbx
nop
nop
nop
inc %r13
mov (%rbx), %si
nop
nop
add $32810, %rbx
// Faulty Load
lea addresses_WC+0x196a1, %rsi
nop
nop
add %r12, %r12
movups (%rsi), %xmm1
vpextrq $1, %xmm1, %rbx
lea oracles, %rsi
and $0xff, %rbx
shlq $12, %rbx
mov (%rsi,%rbx,1), %rbx
pop %rsi
pop %rbx
pop %rax
pop %r8
pop %r13
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_WC', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_WT', 'size': 16, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_D', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_WC', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_WC', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': True, 'congruent': 8, 'NT': True, 'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': True}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': True}}
{'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}}
{'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': True}}
{'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}}
{'38': 21829}
38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38
*/
|
source/textio/a-teiofo.adb | ytomino/drake | 33 | 25605 | with Ada.Exception_Identification.From_Here;
with Ada.Exceptions.Finally;
with System.Formatting;
with System.UTF_Conversions;
package body Ada.Text_IO.Formatting is
use Exception_Identification.From_Here;
use type System.Long_Long_Integer_Types.Word_Integer;
use type System.Long_Long_Integer_Types.Word_Unsigned;
use type System.Long_Long_Integer_Types.Long_Long_Unsigned;
subtype Word_Integer is System.Long_Long_Integer_Types.Word_Integer;
subtype Word_Unsigned is System.Long_Long_Integer_Types.Word_Unsigned;
subtype Long_Long_Unsigned is
System.Long_Long_Integer_Types.Long_Long_Unsigned;
procedure Skip_Spaces (
File : File_Type); -- Input_File_Type
procedure Skip_Spaces (
File : File_Type)
is
Item : Character;
End_Of_Line : Boolean;
begin
loop
Look_Ahead (File, Item, End_Of_Line); -- checking the predicate
exit when not End_Of_Line
and then Item /= ' '
and then Item /= Character'Val (9);
Skip_Ahead (File);
end loop;
end Skip_Spaces;
procedure Adjust (
File : File_Type; -- Output_File_Type
Width : Field);
procedure Adjust (
File : File_Type;
Width : Field)
is
Line : constant Count := Line_Length (File); -- checking the predicate
begin
if Line > 0 then
if Count (Width) > Line then
Raise_Exception (Layout_Error'Identity);
elsif Col (File) + Count (Width) - 1 > Line then
New_Line (File);
end if;
end if;
end Adjust;
procedure Add (
Buffer : in out String_Access;
Last : in out Natural;
Item : Character);
procedure Add (
Buffer : in out String_Access;
Last : in out Natural;
Item : Character) is
begin
Last := Last + 1;
if Last > Buffer'Last then
Reallocate (Buffer, 1, String_Grow (Buffer'Last)); -- Buffer'First = 1
end if;
Buffer (Last) := Item;
end Add;
procedure Get_Num (
File : File_Type; -- Input_File_Type
Buffer : in out String_Access;
Last : in out Natural;
Based : Boolean);
procedure Get_Num (
File : File_Type;
Buffer : in out String_Access;
Last : in out Natural;
Based : Boolean)
is
Start : constant Natural := Last;
Item : Character;
End_Of_Line : Boolean;
begin
Look_Ahead (File, Item, End_Of_Line); -- checking the predicate
loop
if Item = '_' then
exit when Last = Start;
Add (Buffer, Last, Item);
Skip_Ahead (File);
Look_Ahead (File, Item, End_Of_Line);
end if;
exit when Item not in '0' .. '9'
and then (
not Based
or else (
Item not in 'A' .. 'F' and then Item not in 'a' .. 'f'));
Add (Buffer, Last, Item);
Skip_Ahead (File);
Look_Ahead (File, Item, End_Of_Line);
end loop;
end Get_Num;
procedure Get_Numeric_Literal_To_Buffer (
File : File_Type; -- Input_File_Type
Buffer : in out String_Access;
Last : in out Natural;
Real : Boolean);
procedure Get_Numeric_Literal_To_Buffer (
File : File_Type; -- Input_File_Type
Buffer : in out String_Access;
Last : in out Natural;
Real : Boolean)
is
Prev_Last : Natural;
Mark : Character;
Item : Character;
End_Of_Line : Boolean;
begin
Look_Ahead (File, Item, End_Of_Line);
if Item = '+' or else Item = '-' then
Add (Buffer, Last, Item);
Skip_Ahead (File);
Look_Ahead (File, Item, End_Of_Line);
end if;
Prev_Last := Last;
Get_Num (File, Buffer, Last, Based => False);
if Last > Prev_Last then
Look_Ahead (File, Item, End_Of_Line);
if Item = '#' or else Item = ':' then
Mark := Item;
Add (Buffer, Last, Item);
Skip_Ahead (File);
Get_Num (File, Buffer, Last, Based => True);
Look_Ahead (File, Item, End_Of_Line);
if Item = '.' and then Real then
Add (Buffer, Last, Item);
Skip_Ahead (File);
Get_Num (File, Buffer, Last, Based => False);
Look_Ahead (File, Item, End_Of_Line);
end if;
if Item = Mark then
Add (Buffer, Last, Item);
Skip_Ahead (File);
Look_Ahead (File, Item, End_Of_Line);
end if;
elsif Item = '.' and then Real then
Add (Buffer, Last, Item);
Skip_Ahead (File);
Get_Num (File, Buffer, Last, Based => False);
Look_Ahead (File, Item, End_Of_Line);
end if;
if Item = 'E' or else Item = 'e' then
Add (Buffer, Last, Item);
Skip_Ahead (File);
Look_Ahead (File, Item, End_Of_Line);
if Item = '+' or else Item = '-' then
Add (Buffer, Last, Item);
Skip_Ahead (File);
Look_Ahead (File, Item, End_Of_Line);
end if;
Get_Num (File, Buffer, Last, Based => False);
end if;
end if;
end Get_Numeric_Literal_To_Buffer;
-- implementation
procedure Integer_Image (
To : out String;
Last : out Natural;
Item : System.Long_Long_Integer_Types.Word_Integer;
Base : Number_Base)
is
Unsigned_Item : Word_Unsigned;
begin
Last := To'First - 1;
if Item < 0 then
Last := Last + 1;
To (Last) := '-';
Unsigned_Item := -Word_Unsigned'Mod (Item);
else
Unsigned_Item := Word_Unsigned (Item);
end if;
Modular_Image (To (Last + 1 .. To'Last), Last, Unsigned_Item, Base);
end Integer_Image;
procedure Integer_Image (
To : out String;
Last : out Natural;
Item : Long_Long_Integer;
Base : Number_Base) is
begin
if Standard'Word_Size < Long_Long_Unsigned'Size then
-- optimized for 32bit
declare
Unsigned_Item : Long_Long_Unsigned;
begin
Last := To'First - 1;
if Item < 0 then
Last := Last + 1;
To (Last) := '-';
Unsigned_Item := -Long_Long_Unsigned'Mod (Item);
else
Unsigned_Item := Long_Long_Unsigned (Item);
end if;
Modular_Image (
To (Last + 1 .. To'Last),
Last,
Unsigned_Item,
Base);
end;
else
-- optimized for 64bit
Integer_Image (To, Last, Word_Integer (Item), Base);
end if;
end Integer_Image;
procedure Modular_Image (
To : out String;
Last : out Natural;
Item : System.Long_Long_Integer_Types.Word_Unsigned;
Base : Number_Base)
is
Error : Boolean;
begin
Last := To'First - 1;
if Base /= 10 then
System.Formatting.Image (
Word_Unsigned (Base),
To (Last + 1 .. To'Last),
Last,
Error => Error);
if Error then
Raise_Exception (Layout_Error'Identity);
end if;
Last := Last + 1;
if Last > To'Last then
Raise_Exception (Layout_Error'Identity);
end if;
To (Last) := '#';
end if;
System.Formatting.Image (
Item,
To (Last + 1 .. To'Last),
Last,
Base => Base,
Error => Error);
if Error then
Raise_Exception (Layout_Error'Identity);
end if;
if Base /= 10 then
Last := Last + 1;
if Last > To'Last then
Raise_Exception (Layout_Error'Identity);
end if;
To (Last) := '#';
end if;
end Modular_Image;
procedure Modular_Image (
To : out String;
Last : out Natural;
Item : System.Long_Long_Integer_Types.Long_Long_Unsigned;
Base : Number_Base) is
begin
if Standard'Word_Size < Long_Long_Unsigned'Size then
-- optimized for 32bit
declare
Error : Boolean;
begin
Last := To'First - 1;
if Base /= 10 then
System.Formatting.Image (
Word_Unsigned (Base),
To (Last + 1 .. To'Last),
Last,
Error => Error);
if Error then
Raise_Exception (Layout_Error'Identity);
end if;
Last := Last + 1;
if Last > To'Last then
Raise_Exception (Layout_Error'Identity);
end if;
To (Last) := '#';
end if;
System.Formatting.Image (
Item,
To (Last + 1 .. To'Last),
Last,
Base => Base,
Error => Error);
if Error then
Raise_Exception (Layout_Error'Identity);
end if;
if Base /= 10 then
Last := Last + 1;
if Last > To'Last then
Raise_Exception (Layout_Error'Identity);
end if;
To (Last) := '#';
end if;
end;
else
-- optimized for 64bit
Modular_Image (To, Last, Word_Unsigned (Item), Base);
end if;
end Modular_Image;
function Get_Numeric_Literal (
File : File_Type;
Real : Boolean)
return String is
begin
Skip_Spaces (File); -- checking the predicate
declare
Buffer : aliased String_Access := new String (1 .. 256);
Last : Natural := 0;
package Holder is
new Exceptions.Finally.Scoped_Holder (String_Access, Free);
begin
Holder.Assign (Buffer);
Get_Numeric_Literal_To_Buffer (File, Buffer, Last, Real => Real);
return Buffer (1 .. Last);
end;
end Get_Numeric_Literal;
function Get_Complex_Literal (
File : File_Type)
return String is
begin
Skip_Spaces (File); -- checking the predicate
declare
Buffer : aliased String_Access := new String (1 .. 256);
Last : Natural := 0;
package Holder is
new Exceptions.Finally.Scoped_Holder (String_Access, Free);
begin
Holder.Assign (Buffer);
declare
Item : Character;
End_Of_Line : Boolean;
Paren : Boolean;
begin
Look_Ahead (File, Item, End_Of_Line);
Paren := Item = '(';
if Paren then
Add (Buffer, Last, Item);
Skip_Ahead (File);
Skip_Spaces (File);
end if;
Get_Numeric_Literal_To_Buffer (File, Buffer, Last, Real => True);
Skip_Spaces (File);
Look_Ahead (File, Item, End_Of_Line);
if Item = ',' then
Add (Buffer, Last, Item);
Skip_Ahead (File);
Skip_Spaces (File);
else
Add (Buffer, Last, ' ');
end if;
Get_Numeric_Literal_To_Buffer (File, Buffer, Last, Real => True);
if Paren then
Skip_Spaces (File);
Look_Ahead (File, Item, End_Of_Line);
if Item = ')' then
Add (Buffer, Last, Item);
Skip_Ahead (File);
else
Raise_Exception (Data_Error'Identity);
end if;
end if;
end;
return Buffer (1 .. Last);
end;
end Get_Complex_Literal;
function Get_Enum_Literal (
File : File_Type)
return String is
begin
Skip_Spaces (File); -- checking the predicate
declare
Buffer : aliased String_Access := new String (1 .. 256);
Last : Natural := 0;
package Holder is
new Exceptions.Finally.Scoped_Holder (String_Access, Free);
begin
Holder.Assign (Buffer);
declare
Item : Character;
End_Of_Line : Boolean;
begin
Look_Ahead (File, Item, End_Of_Line);
if Item = ''' then
Add (Buffer, Last, Item);
Skip_Ahead (File);
Look_Ahead (File, Item, End_Of_Line);
if not End_Of_Line then
declare
Length : Natural;
Sequence_Status :
System.UTF_Conversions.Sequence_Status_Type; -- ignore
begin
System.UTF_Conversions.UTF_8_Sequence (
Item,
Length,
Sequence_Status);
Add (Buffer, Last, Item);
Skip_Ahead (File);
for I in 2 .. Length loop
Look_Ahead (File, Item, End_Of_Line);
exit when End_Of_Line;
Add (Buffer, Last, Item);
Skip_Ahead (File);
end loop;
end;
Look_Ahead (File, Item, End_Of_Line);
if Item = ''' then
Add (Buffer, Last, Item);
Skip_Ahead (File);
end if;
end if;
elsif Item in 'A' .. 'Z'
or else Item in 'a' .. 'z'
or else Item >= Character'Val (16#80#)
then
while not End_Of_Line
and then Item /= ' '
and then Item /= Character'Val (9)
loop
if Item = '_' then
Add (Buffer, Last, Item);
Skip_Ahead (File);
Look_Ahead (File, Item, End_Of_Line);
end if;
exit when not (
Item in 'A' .. 'Z'
or else Item in 'a' .. 'z'
or else Item in '0' .. '9'
or else Item >= Character'Val (16#80#));
Add (Buffer, Last, Item);
Skip_Ahead (File);
Look_Ahead (File, Item, End_Of_Line);
end loop;
end if;
end;
return Buffer (1 .. Last);
end;
end Get_Enum_Literal;
procedure Get_Field (
File : File_Type;
Item : out String;
Last : out Natural)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
Has_Data : Boolean := False;
End_Of_Line : Boolean;
begin
Last := Item'First - 1;
for I in Item'Range loop
Look_Ahead (File, Item (I), End_Of_Line);
exit when End_Of_Line;
Skip_Ahead (File);
if Item (I) = Character'Val (9) then
Item (I) := ' '; -- treat tab as space, RM A.10.6(5/2)
elsif Item (I) /= ' ' then
Has_Data := True;
end if;
Last := I;
end loop;
if not Has_Data then
if End_Of_File (File) then
Raise_Exception (End_Error'Identity);
else
Raise_Exception (Data_Error'Identity);
end if;
end if;
end Get_Field;
procedure Head (
File : File_Type;
Item : String;
Width : Field) is
begin
Adjust (File, Field'Max (Width, Item'Last)); -- checking the predicate
Put (File, Item);
for I in Item'Length + 1 .. Width loop
Put (File, ' ');
end loop;
end Head;
procedure Tail (
File : File_Type;
Item : String;
Width : Field) is
begin
Adjust (File, Field'Max (Width, Item'Last)); -- checking the predicate
for I in Item'Length + 1 .. Width loop
Put (File, ' ');
end loop;
Put (File, Item);
end Tail;
procedure Get_Head (
Item : String;
First : out Positive;
Last : out Natural) is
begin
Get_Tail (Item, First); -- skip first spaces
Last := First;
while Last < Item'Last
and then Item (Last + 1) /= ' '
and then Item (Last + 1) /= Character'Val (9)
loop
Last := Last + 1;
end loop;
end Get_Head;
procedure Get_Tail (Item : String; First : out Positive) is
begin
First := Item'First;
loop
if First > Item'Last then
Raise_Exception (End_Error'Identity);
end if;
exit when Item (First) /= ' '
and then Item (First) /= Character'Val (9);
First := First + 1;
end loop;
end Get_Tail;
procedure Head (Target : out String; Source : String) is
Source_Length : constant Natural := Source'Length;
begin
if Target'Length < Source_Length then
Raise_Exception (Layout_Error'Identity);
end if;
Target (Target'First .. Target'First + Source_Length - 1) := Source;
System.Formatting.Fill_Padding (
Target (Target'First + Source_Length .. Target'Last),
' ');
end Head;
procedure Tail (Target : out String; Source : String) is
Source_Length : constant Natural := Source'Length;
begin
if Target'Length < Source_Length then
Raise_Exception (Layout_Error'Identity);
end if;
Target (Target'Last - Source_Length + 1 .. Target'Last) := Source;
System.Formatting.Fill_Padding (
Target (Target'First .. Target'Last - Source_Length),
' ');
end Tail;
procedure Tail (Target : out Wide_String; Source : Wide_String) is
Source_Length : constant Natural := Source'Length;
begin
if Target'Length < Source_Length then
Raise_Exception (Layout_Error'Identity);
end if;
for I in Target'First .. Target'Last - Source_Length loop
Target (I) := ' ';
end loop;
Target (Target'Last - Source_Length + 1 .. Target'Last) := Source;
end Tail;
procedure Tail (Target : out Wide_Wide_String; Source : Wide_Wide_String) is
Source_Length : constant Natural := Source'Length;
begin
if Target'Length < Source_Length then
Raise_Exception (Layout_Error'Identity);
end if;
for I in Target'First .. Target'Last - Source_Length loop
Target (I) := ' ';
end loop;
Target (Target'Last - Source_Length + 1 .. Target'Last) := Source;
end Tail;
end Ada.Text_IO.Formatting;
|
src/lib/sending-source.applescript | kamontat/iMessageAPI | 3 | 4563 | <gh_stars>1-10
-- ---------------------------------
-- BSD 3-Clause License
-- Copyright (c) 2017, <NAME> All rights reserved.
-- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-- * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-- IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
-- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-- ---------------------------------
-- Creator: <NAME>
-- Create at: 20/08/2560
-- Update at: 07/01/2561
-- Version: 2.1.0
-- ---------------------------------
-- code version and explanation
property code_desc : "Run iMessage as background task"
property code_version : "v2.1.1"
-- library name
property lib_name : "searching"
-- file extension
property script_ : ".scpt"
-- library folder
property library : "lib/"
-- file name
property script_file : lib_name & script_
----- EXAMPLE CODE -----
-- tell SEND
-- start()
-- sendMessageByRegex(someRegex, "test mail")
-- versionToString()
-- end tell
----- END EXAMPLE CODE -----
script SEND
-- run this method at first time you need to send message
to start_send()
launch application "Messages"
launch application "Contacts"
end start_send
to end_send()
quit application "Messages"
quit application "Contacts"
end end_send
-- to load searching library in lib folder
-- @return library so you can use like `tell search of loadSearchLibrary()...`
to loadSearchLibrary()
tell application "Finder" to set theContainer to container of (path to me)
set searchPath to POSIX path of (theContainer as text) & library & script_file
return (load script searchPath)
end loadSearchLibrary
-- get currently app version and library version
-- @return only version
to getVersion()
tell search of loadSearchLibrary() to set v to getVersion()
return "sending: " & code_version & "
" & lib_name & ": " & v
end getVersion
-- get currently app description and library description
-- @return version and description
to versionToString()
set l to loadSearchLibrary()
tell search of l to set v to versionToString()
return "sending: " & code_desc & " (" & code_version & ")" & "
" & lib_name & ": " & v
return
end versionToString
-- send message (msg) to regex person (make sure that regex unique enough otherwise exception will throw)
-- @throw - learn more about exception in searching library (on lib folder)
to sendMessage by regex given message:msg
set searchLib to my loadSearchLibrary()
tell search of searchLib to set phoneNumber to getiPhone from regex
_sendMessage by phoneNumber given message:msg
end sendMessage
-- send message (msg) to `phone number`
-- @throw - learn more about exception in searching library (on lib folder)
to _sendMessage by telephone given message:msg
tell application "Messages"
launch
set targetService to 1st service whose service type = iMessage
set targetBuddy to buddy telephone of targetService
send msg to targetBuddy
end tell
end _sendMessage
end script |
MIPS/LAB 6 - Switch.asm | EliederSousa/Assembly-Disassembly | 0 | 165239 | .data
jTable: .word L1,L2,L3,L4,L5
.text
la $t4, jTable # Carrega o endereço de memória da tabela
li $s5, 1 # w
li $s0, 4 # a
li $s1, 0 # b = 0
slti $t3, $s5, 1 # $t3 = (w < 1)
bne $t3, $zero, SAIR # if ($t3 != 0) jmp SAIR
slti $t3, $s5, 6 # $t3 = (w < 6)
beq $t3, $zero, SAIR # if ($t3 == 0) jmp SAIR
# w = w - 1 (fiz assim por que o switch avalia casos entre 1 e 5, não entre 0 e 4)
# portanto, o sll nunca carregaria o primeiro endereço da jTable, e daria erro ao tentar carregar
# quando w = 5 (porque 5 * 4 = 20, e o último endereço da jTable é 16($t1) )
subi $s5, $s5, 1
sll $t1, $s5, 2 # $t1 = w * 4
add $t1, $t1, $t4 # $t1 = &$t4 + $t1 (desloca o endereço $t4, $t1 bytes, e guarda em $t1)
lw $t0, 0($t1) # $t0 = *($t1) ($t0 agora é o valor que está dentro do endereço $t1)
jr $t0 # Segue para o Label indicado em $t0
L1:
slti $t0, $s0, 5 # $t0 = (a < 5)
beq $t0, $zero, SAIR # if ($t0 == 0) jmp SAIR
sll $s1, $s0, 1 # b = a * 2
j SAIR # break;
L2:
slti $t0, $s0, 5 # $t0 = (a < 5)
beq $t0, $zero, ELSE # if ($t0 == 0) jmp ELSE
sll $s1, $s0, 2 # b = a * 4
j SAIR # endif
ELSE:
sll $s1, $s0, 3 # b = a * 8
j SAIR # break;
L3:
WHILE:
beq $s0, $zero, SAIR # if (a == 0) jmp SAIR
add $s1, $s1, $s0 # b += a;
subi $s0, $s0, 1 # a--;
j WHILE
j SAIR # break;
L4:
DO:
add $s1, $s1, $s0 # b += a;
subi $s0, $s0, 1 # a--;
bne $s0, $zero, DO # if (a != 0) jmp DO
j SAIR # break;
L5:
addi $s2, $zero, 0 # c = 0;
FOR:
slti $t0, $s2, 10 # $t0 = (c < 10)
beq $t0, $zero, SAIR # if ($t0 == 0) jmp SAIR
add $s1, $s1, $s2 # b += c;
add $s2, $s2, 1 # c++;
j FOR
j SAIR # break;
SAIR:
|
programs/oeis/165/A165855.asm | neoneye/loda | 22 | 17307 | <reponame>neoneye/loda<gh_stars>10-100
; A165855: Totally multiplicative sequence with a(p) = 34.
; 1,34,34,1156,34,1156,34,39304,1156,1156,34,39304,34,1156,1156,1336336,34,39304,34,39304,1156,1156,34,1336336,1156,1156,39304,39304,34,39304,34,45435424,1156,1156,1156,1336336,34,1156,1156,1336336,34,39304,34,39304,39304,1156,34,45435424,1156,39304,1156,39304,34,1336336,1156,1336336,1156,1156,34,1336336,34,1156,39304,1544804416,1156,39304,34,39304,1156,39304,34,45435424,34,1156,39304,39304,1156,39304,34,45435424,1336336,1156,34,1336336,1156,1156,1156,1336336,34,1336336,1156,39304,1156,1156,1156,1544804416,34,39304,39304,1336336
seq $0,1222 ; Number of prime divisors of n counted with multiplicity (also called bigomega(n) or Omega(n)).
mov $1,34
pow $1,$0
mov $0,$1
|
programs/oeis/013/A013964.asm | neoneye/loda | 22 | 16401 | ; A013964: a(n) = sigma_16(n), the sum of the 16th powers of the divisors of n.
; 1,65537,43046722,4295032833,152587890626,2821153019714,33232930569602,281479271743489,1853020231898563,10000152587956162,45949729863572162,184887084343023426,665416609183179842,2177986570740006274,6568408508343827972,18447025552981295105,48661191875666868482,121441386937936123331,288441413567621167682,655370000156882923458,1430568723474958944644,3011407446068928780994,6132610415680998648962,12116759959504426293058,23283064365539550781251,43609408316038057305154,79766444929892741761924,142736527933249981742466,250246473680347348787522,430473788411329453800964,727423121747185263828482,1208944266640182156001281,1977985247412288784552964,3189108531955579559704834,5070942774935881856350852,7958782736217602010518979,12337511914217166362274242,18903584920981188466375234,28644003789690989734577924,42950328330281631859634114,63759030914653054346432642,93755182430378384355133828,136614025729312093462315202,197355598431523046454794946,282748448472703087370570438,401912888812485608457022594,566977372488557307219621122,794083980706082081584895810,1104427674243953879235868803,1525902189324365539550846787,2094704798860490252155216004,2857986184065286732733752386,3876269050118516845397872322,5227653501370380616851213188,7011372354716994956914353412,9354381094633504036404821378,12416457343132416606522438404,16400403145588924197487829314,21559177407076402401757871042,28211530203893295592643804676,36751693856637464631913392962,47673129129945280635527224834,61581292710752741409475281926,79229371458530977775699951617,101534516782766832929983961092,129631219159659170073247601668,164890958756244164895763202882,209001416798902053900482869506,263988775698124389524242802564,332334376640972889219665787524,416997623116370028124580469122,521586785400758618381603706307,650377879817809571042122834562,808563518322050431884366997954,1002259599051487422485394609222,1238865341669864580899988503106,1527044182248061239445090619524,1877242076364978394235033405188,2301619141096101839813550846722,2814792717453337025705569185730,3433683900058957414550590851205,4178575609053617222702156058754,5072820298953863752478356399682,6144339637187846520573009496452,7425108623655055918743342649732,8953273404221926669239751393474,10772290383998229186693496602884,12933896498808340322191305153218,15496731425178936435099327730562,18530485067555542237005074795206,22113743972844604290554664362884,26339763087347667251520431369346,31313180898223238334521320336004,37157996060782580243252309472514,44012666865465011189263421948932,52041087759553795298747774850882,61425365346268570446197767595522,72380876486926005383481133742211,85145779087472813229810414603206,100001525902844684365543845814083
add $0,1
mov $2,$0
lpb $0
mov $3,$2
mov $4,$0
cmp $4,0
add $0,$4
dif $3,$0
cmp $3,$2
cmp $3,0
mul $3,$0
sub $0,1
pow $3,16
add $1,$3
lpe
add $1,1
mov $0,$1
|
programs/oeis/002/A002698.asm | karttu/loda | 0 | 10363 | <gh_stars>0
; A002698: Coefficients of Chebyshev polynomials: n(2n-3)2^(2n-5).
; 1,18,160,1120,6912,39424,212992,1105920,5570560,27394048,132120576,627048448,2936012800,13589544960,62277025792,282930970624,1275605286912,5712306503680,25426206392320,112562502893568
mov $1,$0
mul $0,2
mov $2,$0
lpb $2,1
add $0,1
mul $1,2
lpb $0,1
add $1,$0
sub $0,1
lpe
sub $2,1
lpe
add $1,1
|
src/lab-code/ravenspark_racecond/account.ads | hannesb0/rtpl18 | 0 | 10127 | pragma profile(Ravenscar);
pragma Partition_Elaboration_Policy (Sequential);
package account with SPARK_Mode
is
Num_Accounts : Natural := 0;
task type Account_Management is
end Account_Management;
-- tasks at package level
t1 : Account_Management;
t2 : Account_Management;
end Account;
|
programs/oeis/017/A017017.asm | karttu/loda | 1 | 240138 | ; A017017: a(n) = 7n+3.
; 3,10,17,24,31,38,45,52,59,66,73,80,87,94,101,108,115,122,129,136,143,150,157,164,171,178,185,192,199,206,213,220,227,234,241,248,255,262,269,276,283,290,297,304,311,318,325,332,339,346,353,360,367,374,381,388,395,402,409,416,423,430,437,444,451,458,465,472,479,486,493,500,507,514,521,528,535,542,549,556,563,570,577,584,591,598,605,612,619,626,633,640,647,654,661,668,675,682,689,696,703,710,717,724,731,738,745,752,759,766,773,780,787,794,801,808,815,822,829,836,843,850,857,864,871,878,885,892,899,906,913,920,927,934,941,948,955,962,969,976,983,990,997,1004,1011,1018,1025,1032,1039,1046,1053,1060,1067,1074,1081,1088,1095,1102,1109,1116,1123,1130,1137,1144,1151,1158,1165,1172,1179,1186,1193,1200,1207,1214,1221,1228,1235,1242,1249,1256,1263,1270,1277,1284,1291,1298,1305,1312,1319,1326,1333,1340,1347,1354,1361,1368,1375,1382,1389,1396,1403,1410,1417,1424,1431,1438,1445,1452,1459,1466,1473,1480,1487,1494,1501,1508,1515,1522,1529,1536,1543,1550,1557,1564,1571,1578,1585,1592,1599,1606,1613,1620,1627,1634,1641,1648,1655,1662,1669,1676,1683,1690,1697,1704,1711,1718,1725,1732,1739,1746
mov $1,$0
mul $1,7
add $1,3
|
decreasoner.macosx/software/relsat-dist/gmp-3.1/mpn/alpha/invert_limb.asm | problem-frames/openpf | 1 | 27918 | <filename>decreasoner.macosx/software/relsat-dist/gmp-3.1/mpn/alpha/invert_limb.asm
dnl Alpha mpn_invert_limb -- Invert a normalized limb.
dnl Copyright (C) 1996, 2000 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Lesser General Public License as published by
dnl the Free Software Foundation; either version 2.1 of the License, or (at your
dnl option) any later version.
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
dnl License for more details.
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the GNU MP Library; see the file COPYING.LIB. If not, write to
dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
dnl MA 02111-1307, USA.
dnl
dnl This is based on sophie:/gmp-stuff/dbg-inv-limb.c.
dnl The ideas are due to <NAME>
dnl
dnl The table below uses 4096 bytes. The file mentioned above has an
dnl alternative function that doesn't require the table, but it runs 50%
dnl slower than this.
include(`../config.m4')
ASM_START()
FLOAT64($C36,9223372036854775808.0) C 2^63
PROLOGUE_GP(mpn_invert_limb)
lda r30,-16(r30)
addq r16,r16,r1
bne r1,$73
lda r0,-1
br r31,$Lend
$73:
srl r16,1,r1
stq r1,0(r30)
ldt f11,0(r30)
cvtqt f11,f1
lda r1,$C36
ldt f10,0(r1)
divt f10,f1,f10
lda r2,$invtab-4096
srl r16,52,r1
addq r1,r1,r1
addq r1,r2,r1
bic r1,6,r2
ldq r2,0(r2)
bic r1,1,r1
extwl r2,r1,r2
sll r2,48,r0
umulh r16,r0,r1
addq r16,r1,r3
stq r3,0(r30)
ldt f11,0(r30)
cvtqt f11,f1
mult f1,f10,f1
cvttqc f1,f1
stt f1,0(r30)
ldq r4,0(r30)
subq r0,r4,r0
umulh r16,r0,r1
mulq r16,r0,r2
addq r16,r1,r3
bge r3,$Loop2
$Loop1: addq r2,r16,r2
cmpult r2,r16,r1
addq r3,r1,r3
addq r0,1,r0
blt r3,$Loop1
$Loop2: cmpult r2,r16,r1
subq r0,1,r0
subq r3,r1,r3
subq r2,r16,r2
bge r3,$Loop2
$Lend:
lda r30,16(r30)
ret r31,(r26),1
EPILOGUE(mpn_invert_limb)
DATASTART(`$invtab',4)
.word 0xffff,0xffc0,0xff80,0xff40,0xff00,0xfec0,0xfe81,0xfe41
.word 0xfe01,0xfdc2,0xfd83,0xfd43,0xfd04,0xfcc5,0xfc86,0xfc46
.word 0xfc07,0xfbc8,0xfb8a,0xfb4b,0xfb0c,0xfacd,0xfa8e,0xfa50
.word 0xfa11,0xf9d3,0xf994,0xf956,0xf918,0xf8d9,0xf89b,0xf85d
.word 0xf81f,0xf7e1,0xf7a3,0xf765,0xf727,0xf6ea,0xf6ac,0xf66e
.word 0xf631,0xf5f3,0xf5b6,0xf578,0xf53b,0xf4fd,0xf4c0,0xf483
.word 0xf446,0xf409,0xf3cc,0xf38f,0xf352,0xf315,0xf2d8,0xf29c
.word 0xf25f,0xf222,0xf1e6,0xf1a9,0xf16d,0xf130,0xf0f4,0xf0b8
.word 0xf07c,0xf03f,0xf003,0xefc7,0xef8b,0xef4f,0xef14,0xeed8
.word 0xee9c,0xee60,0xee25,0xede9,0xedae,0xed72,0xed37,0xecfb
.word 0xecc0,0xec85,0xec4a,0xec0e,0xebd3,0xeb98,0xeb5d,0xeb22
.word 0xeae8,0xeaad,0xea72,0xea37,0xe9fd,0xe9c2,0xe988,0xe94d
.word 0xe913,0xe8d8,0xe89e,0xe864,0xe829,0xe7ef,0xe7b5,0xe77b
.word 0xe741,0xe707,0xe6cd,0xe694,0xe65a,0xe620,0xe5e6,0xe5ad
.word 0xe573,0xe53a,0xe500,0xe4c7,0xe48d,0xe454,0xe41b,0xe3e2
.word 0xe3a9,0xe370,0xe336,0xe2fd,0xe2c5,0xe28c,0xe253,0xe21a
.word 0xe1e1,0xe1a9,0xe170,0xe138,0xe0ff,0xe0c7,0xe08e,0xe056
.word 0xe01e,0xdfe5,0xdfad,0xdf75,0xdf3d,0xdf05,0xdecd,0xde95
.word 0xde5d,0xde25,0xdded,0xddb6,0xdd7e,0xdd46,0xdd0f,0xdcd7
.word 0xdca0,0xdc68,0xdc31,0xdbf9,0xdbc2,0xdb8b,0xdb54,0xdb1d
.word 0xdae6,0xdaae,0xda78,0xda41,0xda0a,0xd9d3,0xd99c,0xd965
.word 0xd92f,0xd8f8,0xd8c1,0xd88b,0xd854,0xd81e,0xd7e8,0xd7b1
.word 0xd77b,0xd745,0xd70e,0xd6d8,0xd6a2,0xd66c,0xd636,0xd600
.word 0xd5ca,0xd594,0xd55f,0xd529,0xd4f3,0xd4bd,0xd488,0xd452
.word 0xd41d,0xd3e7,0xd3b2,0xd37c,0xd347,0xd312,0xd2dd,0xd2a7
.word 0xd272,0xd23d,0xd208,0xd1d3,0xd19e,0xd169,0xd134,0xd100
.word 0xd0cb,0xd096,0xd061,0xd02d,0xcff8,0xcfc4,0xcf8f,0xcf5b
.word 0xcf26,0xcef2,0xcebe,0xce89,0xce55,0xce21,0xcded,0xcdb9
.word 0xcd85,0xcd51,0xcd1d,0xcce9,0xccb5,0xcc81,0xcc4e,0xcc1a
.word 0xcbe6,0xcbb3,0xcb7f,0xcb4c,0xcb18,0xcae5,0xcab1,0xca7e
.word 0xca4b,0xca17,0xc9e4,0xc9b1,0xc97e,0xc94b,0xc918,0xc8e5
.word 0xc8b2,0xc87f,0xc84c,0xc819,0xc7e7,0xc7b4,0xc781,0xc74f
.word 0xc71c,0xc6e9,0xc6b7,0xc684,0xc652,0xc620,0xc5ed,0xc5bb
.word 0xc589,0xc557,0xc524,0xc4f2,0xc4c0,0xc48e,0xc45c,0xc42a
.word 0xc3f8,0xc3c7,0xc395,0xc363,0xc331,0xc300,0xc2ce,0xc29c
.word 0xc26b,0xc239,0xc208,0xc1d6,0xc1a5,0xc174,0xc142,0xc111
.word 0xc0e0,0xc0af,0xc07e,0xc04d,0xc01c,0xbfeb,0xbfba,0xbf89
.word 0xbf58,0xbf27,0xbef6,0xbec5,0xbe95,0xbe64,0xbe33,0xbe03
.word 0xbdd2,0xbda2,0xbd71,0xbd41,0xbd10,0xbce0,0xbcb0,0xbc80
.word 0xbc4f,0xbc1f,0xbbef,0xbbbf,0xbb8f,0xbb5f,0xbb2f,0xbaff
.word 0xbacf,0xba9f,0xba6f,0xba40,0xba10,0xb9e0,0xb9b1,0xb981
.word 0xb951,0xb922,0xb8f2,0xb8c3,0xb894,0xb864,0xb835,0xb806
.word 0xb7d6,0xb7a7,0xb778,0xb749,0xb71a,0xb6eb,0xb6bc,0xb68d
.word 0xb65e,0xb62f,0xb600,0xb5d1,0xb5a2,0xb574,0xb545,0xb516
.word 0xb4e8,0xb4b9,0xb48a,0xb45c,0xb42e,0xb3ff,0xb3d1,0xb3a2
.word 0xb374,0xb346,0xb318,0xb2e9,0xb2bb,0xb28d,0xb25f,0xb231
.word 0xb203,0xb1d5,0xb1a7,0xb179,0xb14b,0xb11d,0xb0f0,0xb0c2
.word 0xb094,0xb067,0xb039,0xb00b,0xafde,0xafb0,0xaf83,0xaf55
.word 0xaf28,0xaefb,0xaecd,0xaea0,0xae73,0xae45,0xae18,0xadeb
.word 0xadbe,0xad91,0xad64,0xad37,0xad0a,0xacdd,0xacb0,0xac83
.word 0xac57,0xac2a,0xabfd,0xabd0,0xaba4,0xab77,0xab4a,0xab1e
.word 0xaaf1,0xaac5,0xaa98,0xaa6c,0xaa40,0xaa13,0xa9e7,0xa9bb
.word 0xa98e,0xa962,0xa936,0xa90a,0xa8de,0xa8b2,0xa886,0xa85a
.word 0xa82e,0xa802,0xa7d6,0xa7aa,0xa77e,0xa753,0xa727,0xa6fb
.word 0xa6d0,0xa6a4,0xa678,0xa64d,0xa621,0xa5f6,0xa5ca,0xa59f
.word 0xa574,0xa548,0xa51d,0xa4f2,0xa4c6,0xa49b,0xa470,0xa445
.word 0xa41a,0xa3ef,0xa3c4,0xa399,0xa36e,0xa343,0xa318,0xa2ed
.word 0xa2c2,0xa297,0xa26d,0xa242,0xa217,0xa1ed,0xa1c2,0xa197
.word 0xa16d,0xa142,0xa118,0xa0ed,0xa0c3,0xa098,0xa06e,0xa044
.word 0xa01a,0x9fef,0x9fc5,0x9f9b,0x9f71,0x9f47,0x9f1c,0x9ef2
.word 0x9ec8,0x9e9e,0x9e74,0x9e4b,0x9e21,0x9df7,0x9dcd,0x9da3
.word 0x9d79,0x9d50,0x9d26,0x9cfc,0x9cd3,0x9ca9,0x9c80,0x9c56
.word 0x9c2d,0x9c03,0x9bda,0x9bb0,0x9b87,0x9b5e,0x9b34,0x9b0b
.word 0x9ae2,0x9ab9,0x9a8f,0x9a66,0x9a3d,0x9a14,0x99eb,0x99c2
.word 0x9999,0x9970,0x9947,0x991e,0x98f6,0x98cd,0x98a4,0x987b
.word 0x9852,0x982a,0x9801,0x97d8,0x97b0,0x9787,0x975f,0x9736
.word 0x970e,0x96e5,0x96bd,0x9695,0x966c,0x9644,0x961c,0x95f3
.word 0x95cb,0x95a3,0x957b,0x9553,0x952b,0x9503,0x94db,0x94b3
.word 0x948b,0x9463,0x943b,0x9413,0x93eb,0x93c3,0x939b,0x9374
.word 0x934c,0x9324,0x92fd,0x92d5,0x92ad,0x9286,0x925e,0x9237
.word 0x920f,0x91e8,0x91c0,0x9199,0x9172,0x914a,0x9123,0x90fc
.word 0x90d4,0x90ad,0x9086,0x905f,0x9038,0x9011,0x8fea,0x8fc3
.word 0x8f9c,0x8f75,0x8f4e,0x8f27,0x8f00,0x8ed9,0x8eb2,0x8e8b
.word 0x8e65,0x8e3e,0x8e17,0x8df1,0x8dca,0x8da3,0x8d7d,0x8d56
.word 0x8d30,0x8d09,0x8ce3,0x8cbc,0x8c96,0x8c6f,0x8c49,0x8c23
.word 0x8bfc,0x8bd6,0x8bb0,0x8b8a,0x8b64,0x8b3d,0x8b17,0x8af1
.word 0x8acb,0x8aa5,0x8a7f,0x8a59,0x8a33,0x8a0d,0x89e7,0x89c1
.word 0x899c,0x8976,0x8950,0x892a,0x8904,0x88df,0x88b9,0x8893
.word 0x886e,0x8848,0x8823,0x87fd,0x87d8,0x87b2,0x878d,0x8767
.word 0x8742,0x871d,0x86f7,0x86d2,0x86ad,0x8687,0x8662,0x863d
.word 0x8618,0x85f3,0x85ce,0x85a9,0x8583,0x855e,0x8539,0x8514
.word 0x84f0,0x84cb,0x84a6,0x8481,0x845c,0x8437,0x8412,0x83ee
.word 0x83c9,0x83a4,0x8380,0x835b,0x8336,0x8312,0x82ed,0x82c9
.word 0x82a4,0x8280,0x825b,0x8237,0x8212,0x81ee,0x81ca,0x81a5
.word 0x8181,0x815d,0x8138,0x8114,0x80f0,0x80cc,0x80a8,0x8084
.word 0x8060,0x803c,0x8018,0x7ff4,0x7fd0,0x7fac,0x7f88,0x7f64
.word 0x7f40,0x7f1c,0x7ef8,0x7ed4,0x7eb1,0x7e8d,0x7e69,0x7e45
.word 0x7e22,0x7dfe,0x7ddb,0x7db7,0x7d93,0x7d70,0x7d4c,0x7d29
.word 0x7d05,0x7ce2,0x7cbf,0x7c9b,0x7c78,0x7c55,0x7c31,0x7c0e
.word 0x7beb,0x7bc7,0x7ba4,0x7b81,0x7b5e,0x7b3b,0x7b18,0x7af5
.word 0x7ad2,0x7aaf,0x7a8c,0x7a69,0x7a46,0x7a23,0x7a00,0x79dd
.word 0x79ba,0x7997,0x7975,0x7952,0x792f,0x790c,0x78ea,0x78c7
.word 0x78a4,0x7882,0x785f,0x783c,0x781a,0x77f7,0x77d5,0x77b2
.word 0x7790,0x776e,0x774b,0x7729,0x7706,0x76e4,0x76c2,0x76a0
.word 0x767d,0x765b,0x7639,0x7617,0x75f5,0x75d2,0x75b0,0x758e
.word 0x756c,0x754a,0x7528,0x7506,0x74e4,0x74c2,0x74a0,0x747e
.word 0x745d,0x743b,0x7419,0x73f7,0x73d5,0x73b4,0x7392,0x7370
.word 0x734f,0x732d,0x730b,0x72ea,0x72c8,0x72a7,0x7285,0x7264
.word 0x7242,0x7221,0x71ff,0x71de,0x71bc,0x719b,0x717a,0x7158
.word 0x7137,0x7116,0x70f5,0x70d3,0x70b2,0x7091,0x7070,0x704f
.word 0x702e,0x700c,0x6feb,0x6fca,0x6fa9,0x6f88,0x6f67,0x6f46
.word 0x6f26,0x6f05,0x6ee4,0x6ec3,0x6ea2,0x6e81,0x6e60,0x6e40
.word 0x6e1f,0x6dfe,0x6dde,0x6dbd,0x6d9c,0x6d7c,0x6d5b,0x6d3a
.word 0x6d1a,0x6cf9,0x6cd9,0x6cb8,0x6c98,0x6c77,0x6c57,0x6c37
.word 0x6c16,0x6bf6,0x6bd6,0x6bb5,0x6b95,0x6b75,0x6b54,0x6b34
.word 0x6b14,0x6af4,0x6ad4,0x6ab4,0x6a94,0x6a73,0x6a53,0x6a33
.word 0x6a13,0x69f3,0x69d3,0x69b3,0x6993,0x6974,0x6954,0x6934
.word 0x6914,0x68f4,0x68d4,0x68b5,0x6895,0x6875,0x6855,0x6836
.word 0x6816,0x67f6,0x67d7,0x67b7,0x6798,0x6778,0x6758,0x6739
.word 0x6719,0x66fa,0x66db,0x66bb,0x669c,0x667c,0x665d,0x663e
.word 0x661e,0x65ff,0x65e0,0x65c0,0x65a1,0x6582,0x6563,0x6544
.word 0x6524,0x6505,0x64e6,0x64c7,0x64a8,0x6489,0x646a,0x644b
.word 0x642c,0x640d,0x63ee,0x63cf,0x63b0,0x6391,0x6373,0x6354
.word 0x6335,0x6316,0x62f7,0x62d9,0x62ba,0x629b,0x627c,0x625e
.word 0x623f,0x6221,0x6202,0x61e3,0x61c5,0x61a6,0x6188,0x6169
.word 0x614b,0x612c,0x610e,0x60ef,0x60d1,0x60b3,0x6094,0x6076
.word 0x6058,0x6039,0x601b,0x5ffd,0x5fdf,0x5fc0,0x5fa2,0x5f84
.word 0x5f66,0x5f48,0x5f2a,0x5f0b,0x5eed,0x5ecf,0x5eb1,0x5e93
.word 0x5e75,0x5e57,0x5e39,0x5e1b,0x5dfd,0x5de0,0x5dc2,0x5da4
.word 0x5d86,0x5d68,0x5d4a,0x5d2d,0x5d0f,0x5cf1,0x5cd3,0x5cb6
.word 0x5c98,0x5c7a,0x5c5d,0x5c3f,0x5c21,0x5c04,0x5be6,0x5bc9
.word 0x5bab,0x5b8e,0x5b70,0x5b53,0x5b35,0x5b18,0x5afb,0x5add
.word 0x5ac0,0x5aa2,0x5a85,0x5a68,0x5a4b,0x5a2d,0x5a10,0x59f3
.word 0x59d6,0x59b8,0x599b,0x597e,0x5961,0x5944,0x5927,0x590a
.word 0x58ed,0x58d0,0x58b3,0x5896,0x5879,0x585c,0x583f,0x5822
.word 0x5805,0x57e8,0x57cb,0x57ae,0x5791,0x5775,0x5758,0x573b
.word 0x571e,0x5702,0x56e5,0x56c8,0x56ac,0x568f,0x5672,0x5656
.word 0x5639,0x561c,0x5600,0x55e3,0x55c7,0x55aa,0x558e,0x5571
.word 0x5555,0x5538,0x551c,0x5500,0x54e3,0x54c7,0x54aa,0x548e
.word 0x5472,0x5456,0x5439,0x541d,0x5401,0x53e5,0x53c8,0x53ac
.word 0x5390,0x5374,0x5358,0x533c,0x5320,0x5304,0x52e8,0x52cb
.word 0x52af,0x5293,0x5277,0x525c,0x5240,0x5224,0x5208,0x51ec
.word 0x51d0,0x51b4,0x5198,0x517c,0x5161,0x5145,0x5129,0x510d
.word 0x50f2,0x50d6,0x50ba,0x509f,0x5083,0x5067,0x504c,0x5030
.word 0x5015,0x4ff9,0x4fdd,0x4fc2,0x4fa6,0x4f8b,0x4f6f,0x4f54
.word 0x4f38,0x4f1d,0x4f02,0x4ee6,0x4ecb,0x4eb0,0x4e94,0x4e79
.word 0x4e5e,0x4e42,0x4e27,0x4e0c,0x4df0,0x4dd5,0x4dba,0x4d9f
.word 0x4d84,0x4d69,0x4d4d,0x4d32,0x4d17,0x4cfc,0x4ce1,0x4cc6
.word 0x4cab,0x4c90,0x4c75,0x4c5a,0x4c3f,0x4c24,0x4c09,0x4bee
.word 0x4bd3,0x4bb9,0x4b9e,0x4b83,0x4b68,0x4b4d,0x4b32,0x4b18
.word 0x4afd,0x4ae2,0x4ac7,0x4aad,0x4a92,0x4a77,0x4a5d,0x4a42
.word 0x4a27,0x4a0d,0x49f2,0x49d8,0x49bd,0x49a3,0x4988,0x496e
.word 0x4953,0x4939,0x491e,0x4904,0x48e9,0x48cf,0x48b5,0x489a
.word 0x4880,0x4865,0x484b,0x4831,0x4817,0x47fc,0x47e2,0x47c8
.word 0x47ae,0x4793,0x4779,0x475f,0x4745,0x472b,0x4711,0x46f6
.word 0x46dc,0x46c2,0x46a8,0x468e,0x4674,0x465a,0x4640,0x4626
.word 0x460c,0x45f2,0x45d8,0x45be,0x45a5,0x458b,0x4571,0x4557
.word 0x453d,0x4523,0x4509,0x44f0,0x44d6,0x44bc,0x44a2,0x4489
.word 0x446f,0x4455,0x443c,0x4422,0x4408,0x43ef,0x43d5,0x43bc
.word 0x43a2,0x4388,0x436f,0x4355,0x433c,0x4322,0x4309,0x42ef
.word 0x42d6,0x42bc,0x42a3,0x428a,0x4270,0x4257,0x423d,0x4224
.word 0x420b,0x41f2,0x41d8,0x41bf,0x41a6,0x418c,0x4173,0x415a
.word 0x4141,0x4128,0x410e,0x40f5,0x40dc,0x40c3,0x40aa,0x4091
.word 0x4078,0x405f,0x4046,0x402d,0x4014,0x3ffb,0x3fe2,0x3fc9
.word 0x3fb0,0x3f97,0x3f7e,0x3f65,0x3f4c,0x3f33,0x3f1a,0x3f01
.word 0x3ee8,0x3ed0,0x3eb7,0x3e9e,0x3e85,0x3e6c,0x3e54,0x3e3b
.word 0x3e22,0x3e0a,0x3df1,0x3dd8,0x3dc0,0x3da7,0x3d8e,0x3d76
.word 0x3d5d,0x3d45,0x3d2c,0x3d13,0x3cfb,0x3ce2,0x3cca,0x3cb1
.word 0x3c99,0x3c80,0x3c68,0x3c50,0x3c37,0x3c1f,0x3c06,0x3bee
.word 0x3bd6,0x3bbd,0x3ba5,0x3b8d,0x3b74,0x3b5c,0x3b44,0x3b2b
.word 0x3b13,0x3afb,0x3ae3,0x3acb,0x3ab2,0x3a9a,0x3a82,0x3a6a
.word 0x3a52,0x3a3a,0x3a22,0x3a09,0x39f1,0x39d9,0x39c1,0x39a9
.word 0x3991,0x3979,0x3961,0x3949,0x3931,0x3919,0x3901,0x38ea
.word 0x38d2,0x38ba,0x38a2,0x388a,0x3872,0x385a,0x3843,0x382b
.word 0x3813,0x37fb,0x37e3,0x37cc,0x37b4,0x379c,0x3785,0x376d
.word 0x3755,0x373e,0x3726,0x370e,0x36f7,0x36df,0x36c8,0x36b0
.word 0x3698,0x3681,0x3669,0x3652,0x363a,0x3623,0x360b,0x35f4
.word 0x35dc,0x35c5,0x35ae,0x3596,0x357f,0x3567,0x3550,0x3539
.word 0x3521,0x350a,0x34f3,0x34db,0x34c4,0x34ad,0x3496,0x347e
.word 0x3467,0x3450,0x3439,0x3422,0x340a,0x33f3,0x33dc,0x33c5
.word 0x33ae,0x3397,0x3380,0x3368,0x3351,0x333a,0x3323,0x330c
.word 0x32f5,0x32de,0x32c7,0x32b0,0x3299,0x3282,0x326c,0x3255
.word 0x323e,0x3227,0x3210,0x31f9,0x31e2,0x31cb,0x31b5,0x319e
.word 0x3187,0x3170,0x3159,0x3143,0x312c,0x3115,0x30fe,0x30e8
.word 0x30d1,0x30ba,0x30a4,0x308d,0x3076,0x3060,0x3049,0x3033
.word 0x301c,0x3005,0x2fef,0x2fd8,0x2fc2,0x2fab,0x2f95,0x2f7e
.word 0x2f68,0x2f51,0x2f3b,0x2f24,0x2f0e,0x2ef8,0x2ee1,0x2ecb
.word 0x2eb4,0x2e9e,0x2e88,0x2e71,0x2e5b,0x2e45,0x2e2e,0x2e18
.word 0x2e02,0x2dec,0x2dd5,0x2dbf,0x2da9,0x2d93,0x2d7c,0x2d66
.word 0x2d50,0x2d3a,0x2d24,0x2d0e,0x2cf8,0x2ce1,0x2ccb,0x2cb5
.word 0x2c9f,0x2c89,0x2c73,0x2c5d,0x2c47,0x2c31,0x2c1b,0x2c05
.word 0x2bef,0x2bd9,0x2bc3,0x2bad,0x2b97,0x2b81,0x2b6c,0x2b56
.word 0x2b40,0x2b2a,0x2b14,0x2afe,0x2ae8,0x2ad3,0x2abd,0x2aa7
.word 0x2a91,0x2a7c,0x2a66,0x2a50,0x2a3a,0x2a25,0x2a0f,0x29f9
.word 0x29e4,0x29ce,0x29b8,0x29a3,0x298d,0x2977,0x2962,0x294c
.word 0x2937,0x2921,0x290c,0x28f6,0x28e0,0x28cb,0x28b5,0x28a0
.word 0x288b,0x2875,0x2860,0x284a,0x2835,0x281f,0x280a,0x27f5
.word 0x27df,0x27ca,0x27b4,0x279f,0x278a,0x2774,0x275f,0x274a
.word 0x2735,0x271f,0x270a,0x26f5,0x26e0,0x26ca,0x26b5,0x26a0
.word 0x268b,0x2676,0x2660,0x264b,0x2636,0x2621,0x260c,0x25f7
.word 0x25e2,0x25cd,0x25b8,0x25a2,0x258d,0x2578,0x2563,0x254e
.word 0x2539,0x2524,0x250f,0x24fa,0x24e5,0x24d1,0x24bc,0x24a7
.word 0x2492,0x247d,0x2468,0x2453,0x243e,0x2429,0x2415,0x2400
.word 0x23eb,0x23d6,0x23c1,0x23ad,0x2398,0x2383,0x236e,0x235a
.word 0x2345,0x2330,0x231c,0x2307,0x22f2,0x22dd,0x22c9,0x22b4
.word 0x22a0,0x228b,0x2276,0x2262,0x224d,0x2239,0x2224,0x2210
.word 0x21fb,0x21e6,0x21d2,0x21bd,0x21a9,0x2194,0x2180,0x216c
.word 0x2157,0x2143,0x212e,0x211a,0x2105,0x20f1,0x20dd,0x20c8
.word 0x20b4,0x20a0,0x208b,0x2077,0x2063,0x204e,0x203a,0x2026
.word 0x2012,0x1ffd,0x1fe9,0x1fd5,0x1fc1,0x1fac,0x1f98,0x1f84
.word 0x1f70,0x1f5c,0x1f47,0x1f33,0x1f1f,0x1f0b,0x1ef7,0x1ee3
.word 0x1ecf,0x1ebb,0x1ea7,0x1e93,0x1e7f,0x1e6a,0x1e56,0x1e42
.word 0x1e2e,0x1e1a,0x1e06,0x1df3,0x1ddf,0x1dcb,0x1db7,0x1da3
.word 0x1d8f,0x1d7b,0x1d67,0x1d53,0x1d3f,0x1d2b,0x1d18,0x1d04
.word 0x1cf0,0x1cdc,0x1cc8,0x1cb5,0x1ca1,0x1c8d,0x1c79,0x1c65
.word 0x1c52,0x1c3e,0x1c2a,0x1c17,0x1c03,0x1bef,0x1bdb,0x1bc8
.word 0x1bb4,0x1ba0,0x1b8d,0x1b79,0x1b66,0x1b52,0x1b3e,0x1b2b
.word 0x1b17,0x1b04,0x1af0,0x1add,0x1ac9,0x1ab6,0x1aa2,0x1a8f
.word 0x1a7b,0x1a68,0x1a54,0x1a41,0x1a2d,0x1a1a,0x1a06,0x19f3
.word 0x19e0,0x19cc,0x19b9,0x19a5,0x1992,0x197f,0x196b,0x1958
.word 0x1945,0x1931,0x191e,0x190b,0x18f8,0x18e4,0x18d1,0x18be
.word 0x18ab,0x1897,0x1884,0x1871,0x185e,0x184b,0x1837,0x1824
.word 0x1811,0x17fe,0x17eb,0x17d8,0x17c4,0x17b1,0x179e,0x178b
.word 0x1778,0x1765,0x1752,0x173f,0x172c,0x1719,0x1706,0x16f3
.word 0x16e0,0x16cd,0x16ba,0x16a7,0x1694,0x1681,0x166e,0x165b
.word 0x1648,0x1635,0x1623,0x1610,0x15fd,0x15ea,0x15d7,0x15c4
.word 0x15b1,0x159f,0x158c,0x1579,0x1566,0x1553,0x1541,0x152e
.word 0x151b,0x1508,0x14f6,0x14e3,0x14d0,0x14bd,0x14ab,0x1498
.word 0x1485,0x1473,0x1460,0x144d,0x143b,0x1428,0x1416,0x1403
.word 0x13f0,0x13de,0x13cb,0x13b9,0x13a6,0x1394,0x1381,0x136f
.word 0x135c,0x1349,0x1337,0x1325,0x1312,0x1300,0x12ed,0x12db
.word 0x12c8,0x12b6,0x12a3,0x1291,0x127f,0x126c,0x125a,0x1247
.word 0x1235,0x1223,0x1210,0x11fe,0x11ec,0x11d9,0x11c7,0x11b5
.word 0x11a3,0x1190,0x117e,0x116c,0x1159,0x1147,0x1135,0x1123
.word 0x1111,0x10fe,0x10ec,0x10da,0x10c8,0x10b6,0x10a4,0x1091
.word 0x107f,0x106d,0x105b,0x1049,0x1037,0x1025,0x1013,0x1001
.word 0x0fef,0x0fdc,0x0fca,0x0fb8,0x0fa6,0x0f94,0x0f82,0x0f70
.word 0x0f5e,0x0f4c,0x0f3a,0x0f28,0x0f17,0x0f05,0x0ef3,0x0ee1
.word 0x0ecf,0x0ebd,0x0eab,0x0e99,0x0e87,0x0e75,0x0e64,0x0e52
.word 0x0e40,0x0e2e,0x0e1c,0x0e0a,0x0df9,0x0de7,0x0dd5,0x0dc3
.word 0x0db2,0x0da0,0x0d8e,0x0d7c,0x0d6b,0x0d59,0x0d47,0x0d35
.word 0x0d24,0x0d12,0x0d00,0x0cef,0x0cdd,0x0ccb,0x0cba,0x0ca8
.word 0x0c97,0x0c85,0x0c73,0x0c62,0x0c50,0x0c3f,0x0c2d,0x0c1c
.word 0x0c0a,0x0bf8,0x0be7,0x0bd5,0x0bc4,0x0bb2,0x0ba1,0x0b8f
.word 0x0b7e,0x0b6c,0x0b5b,0x0b4a,0x0b38,0x0b27,0x0b15,0x0b04
.word 0x0af2,0x0ae1,0x0ad0,0x0abe,0x0aad,0x0a9c,0x0a8a,0x0a79
.word 0x0a68,0x0a56,0x0a45,0x0a34,0x0a22,0x0a11,0x0a00,0x09ee
.word 0x09dd,0x09cc,0x09bb,0x09a9,0x0998,0x0987,0x0976,0x0965
.word 0x0953,0x0942,0x0931,0x0920,0x090f,0x08fe,0x08ec,0x08db
.word 0x08ca,0x08b9,0x08a8,0x0897,0x0886,0x0875,0x0864,0x0853
.word 0x0842,0x0831,0x081f,0x080e,0x07fd,0x07ec,0x07db,0x07ca
.word 0x07b9,0x07a8,0x0798,0x0787,0x0776,0x0765,0x0754,0x0743
.word 0x0732,0x0721,0x0710,0x06ff,0x06ee,0x06dd,0x06cd,0x06bc
.word 0x06ab,0x069a,0x0689,0x0678,0x0668,0x0657,0x0646,0x0635
.word 0x0624,0x0614,0x0603,0x05f2,0x05e1,0x05d1,0x05c0,0x05af
.word 0x059e,0x058e,0x057d,0x056c,0x055c,0x054b,0x053a,0x052a
.word 0x0519,0x0508,0x04f8,0x04e7,0x04d6,0x04c6,0x04b5,0x04a5
.word 0x0494,0x0484,0x0473,0x0462,0x0452,0x0441,0x0431,0x0420
.word 0x0410,0x03ff,0x03ef,0x03de,0x03ce,0x03bd,0x03ad,0x039c
.word 0x038c,0x037b,0x036b,0x035b,0x034a,0x033a,0x0329,0x0319
.word 0x0309,0x02f8,0x02e8,0x02d7,0x02c7,0x02b7,0x02a6,0x0296
.word 0x0286,0x0275,0x0265,0x0255,0x0245,0x0234,0x0224,0x0214
.word 0x0204,0x01f3,0x01e3,0x01d3,0x01c3,0x01b2,0x01a2,0x0192
.word 0x0182,0x0172,0x0161,0x0151,0x0141,0x0131,0x0121,0x0111
.word 0x0101,0x00f0,0x00e0,0x00d0,0x00c0,0x00b0,0x00a0,0x0090
.word 0x0080,0x0070,0x0060,0x0050,0x0040,0x0030,0x0020,0x0010
DATAEND()
ASM_END()
|
Examples/basics/uuid.asm | agguro/linux-nasm | 6 | 92100 | ;name: uuid.asm
;
;description: Generates a UUID
;
;build: nasm -felf64 uuid.asm -o uuid.o
; ld -melf_x86_64 uuid.o -o uuid
;
;remark: Because UUID need to be unique (that's why U stands for) the user need to
; check each generated UUID against a table which contains already generated
; UUID's. This algorithm applied 10000 gives 51 same UUIDs, 100000 times
; gives 135 same UUIDs, 1000000 gives us 18884 same UUIDs. So check the presence
; of an already generated uuid. Another possibility is the use of mysql uuid
; but requires the installation of mysql server.
bits 64
%include "unistd.inc"
;IOV structure definition
struc IOV_STRUC
.iov_base: resq 1
.iov_len: resq 1
endstruc
;macro to use IOV in a less complex manner
%macro IOV 3
%define %1.base %1+IOV_STRUC.base
%define %1.len %1+IOV_STRUC.len
%1: istruc IOV_STRUC
at IOV_STRUC.iov_base, dq %2
at IOV_STRUC.iov_len, dq %3
iend
%endmacro
section .bss
;keep all groups together to create 32 values at once
uuid:
.group1: resb 8
.group2: resb 4
.group3: resb 4
.group4: resb 4
.group5: resb 12
section .data
iov:
IOV s1,uuid.group1,8
IOV s2,hyphen,1
IOV s3,uuid.group2,4
IOV s4,hyphen,1
IOV s5,uuid.group3,4
IOV s6,hyphen,1
IOV s7,uuid.group4,4
IOV s8,hyphen,1
IOV s9,uuid.group5,12
IOV s10,crlf,1
crlf: db 10
hyphen: db "-"
section .text
global _start
_start:
mov rdi, uuid
call generate
; convert to ascii
mov rsi, uuid
mov rdi, uuid
mov rcx, 32
nextDigit:
cld
lodsb
call nibbletoasciihex
stosb
loop nextDigit
syscall writev,stdout,iov,10
syscall exit, 0
generate:
;in : rdi = pointer to buffer to store 32 bytes
;out : rdi = pointer to buffer with GUID
mov rcx,32 ;32 characters to generate
.repeat:
xor rax,rax ;lower boundary of interval
mov rdx,0xF ;higher boundary of interval
call GenerateRandom
cld
stosb
loop .repeat
ret
nibbletoasciihex:
; in :: AL = NIBBLE or 4 bits (least significant)
; out :: AL = Hexadecimal ASCII of NIBBLE
and al,0x0F
or al,"0"
cmp al,"9"
jbe .done
add al,39
.done:
ret
GenerateRandom:
;in rdi : lower boundary of interval
; rsi : higher boundary of interval
;interval length is 0xF
mov rbx,0xF
rdtsc ;read cpu time stamp counter
push rax
rdtsc ;read cpu time stamp counter
mov rax,rdx
pop rax
rol rdx,32 ;mov EDX in high 32 bits of RAX
or rax,rdx ;RAX = seed
call XorShift ;get a pseudo random number
and rax,0xF
ret
XorShift:
mov rdx,rax ;XORSHIFT algorithm
shl rax,13
xor rax,rdx
mov rdx,rax
shr rax,17
xor rax,rdx
mov rdx,rax
shl rax,5
xor rax,rdx ;rax random 64 bit value
ret
|
Rings/Orders/Total/Bounded.agda | Smaug123/agdaproofs | 4 | 6629 | <reponame>Smaug123/agdaproofs
{-# OPTIONS --safe --warning=error --without-K --guardedness #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Orders.Partial.Definition
open import Rings.Orders.Total.Definition
open import Sets.EquivalenceRelations
open import Sequences
open import Setoids.Orders.Partial.Definition
open import Setoids.Orders.Total.Definition
open import Functions.Definition
open import LogicalFormulae
open import Numbers.Naturals.Semiring
open import Groups.Definition
module Rings.Orders.Total.Bounded {m n o : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A → A → A} {_*_ : A → A → A} {_<_ : Rel {m} {o} A} {pOrder : SetoidPartialOrder S _<_} {R : Ring S _+_ _*_} {pRing : PartiallyOrderedRing R pOrder} (tRing : TotallyOrderedRing pRing) where
open import Rings.Orders.Partial.Bounded pRing
open Ring R
open Group additiveGroup
open import Groups.Lemmas (Ring.additiveGroup R)
open Setoid S
open Equivalence eq
open SetoidPartialOrder pOrder
open import Rings.Orders.Total.Lemmas tRing
open PartiallyOrderedRing pRing
boundGreaterThanZero : {s : Sequence A} → (b : Bounded s) → 0G < underlying b
boundGreaterThanZero {s} (a , b) with b 0
... | (l ,, r) = halvePositive a (<WellDefined invLeft reflexive (orderRespectsAddition (<Transitive l r) a))
|
prototyping/Luau/Syntax.agda | Tr4shh/Roblox-Luau | 0 | 3867 | module Luau.Syntax where
open import Agda.Builtin.Equality using (_≡_)
open import Agda.Builtin.Float using (Float)
open import Properties.Dec using (⊥)
open import Luau.Var using (Var)
open import Luau.Addr using (Addr)
open import Luau.Type using (Type)
infixr 5 _∙_
data Annotated : Set where
maybe : Annotated
yes : Annotated
data VarDec : Annotated → Set where
var : Var → VarDec maybe
var_∈_ : ∀ {a} → Var → Type → VarDec a
name : ∀ {a} → VarDec a → Var
name (var x) = x
name (var x ∈ T) = x
data FunDec : Annotated → Set where
_⟨_⟩∈_ : ∀ {a} → Var → VarDec a → Type → FunDec a
_⟨_⟩ : Var → VarDec maybe → FunDec maybe
fun : ∀ {a} → FunDec a → Var
fun (f ⟨ x ⟩∈ T) = f
fun (f ⟨ x ⟩) = f
arg : ∀ {a} → FunDec a → VarDec a
arg (f ⟨ x ⟩∈ T) = x
arg (f ⟨ x ⟩) = x
data BinaryOperator : Set where
+ : BinaryOperator
- : BinaryOperator
* : BinaryOperator
/ : BinaryOperator
data Block (a : Annotated) : Set
data Stat (a : Annotated) : Set
data Expr (a : Annotated) : Set
data Block a where
_∙_ : Stat a → Block a → Block a
done : Block a
data Stat a where
function_is_end : FunDec a → Block a → Stat a
local_←_ : VarDec a → Expr a → Stat a
return : Expr a → Stat a
data Expr a where
nil : Expr a
var : Var → Expr a
addr : Addr → Expr a
_$_ : Expr a → Expr a → Expr a
function_is_end : FunDec a → Block a → Expr a
block_is_end : Var → Block a → Expr a
number : Float → Expr a
binexp : Expr a → BinaryOperator → Expr a → Expr a
|
swift-fin/src/main/antlr4/SwiftFinLexer.g4 | ChristianWulf/grammars-v4 | 4 | 4508 | <reponame>ChristianWulf/grammars-v4<filename>swift-fin/src/main/antlr4/SwiftFinLexer.g4
/*
MIT License
Copyright (c) 2016+ <NAME>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
lexer grammar SwiftFinLexer;
BLOCK1 : LBrace '1' Colon -> pushMode(InsideValue)
;
BLOCK2 : LBrace '2' Colon -> pushMode(InsideValue)
;
BLOCK3 : LBrace '3' Colon -> pushMode(InsideMaps)
;
fragment
Block4 : LBrace '4' Colon
;
BLOCK4_A : Block4 Crlf -> pushMode(InsideB4)
;
BLOCK4_B : Block4 -> pushMode(InsideMaps)
;
BLOCK5 : LBrace '5' Colon -> pushMode(InsideMaps)
;
LBRACE : LBrace;
RBRACE : RBrace;
COLON : Colon;
CRLF : Crlf;
fragment
Crlf : '\r'? '\n'
;
fragment LBrace : '{' ;
fragment RBrace : '}' ;
fragment Colon : ':' ;
fragment Minus : '-' ;
fragment Any : . ;
mode InsideMaps;
M_LBRACE : LBrace -> type(LBRACE), pushMode(InsideMaps);
M_RBRACE : RBrace -> type(RBRACE), popMode;
M_COLON : Colon ;
M_VALUE : ~[:] ;
mode InsideB4;
B4_END : Minus RBrace -> popMode;
B4_COLON : Colon ;
B4_CRLF : Crlf ;
B4_VALUE : ~[:] ;
//SPECIALS : Any ; // every other token
mode InsideValue;
V_END : RBrace -> popMode;
V_VALUE : Any ;
|
BOOTI386.asm | cameronlbass/FAT16LDR | 0 | 88415 | <gh_stars>0
bits 16
org 0
push word 0B800h
pop es
xor di, di
mov al, '@'
mov ah, 0Fh
stosw
halt:
jmp short halt
|
src/instruction.adb | eyeonechi/invalid-behaviour-conservative-analysis | 0 | 30193 | with Debug; use Debug;
with Ada.Numerics.Discrete_Random;
with Ada.Characters.Latin_1;
use Ada.Characters.Latin_1;
package body Instruction is
package Random_OpCode is new Ada.Numerics.Discrete_Random (OpCode);
package Random_Reg is new Ada.Numerics.Discrete_Random (Reg);
package Random_Offset is new Ada.Numerics.Discrete_Random (Offset);
OpCodeG : Random_OpCode.Generator;
RegG : Random_Reg.Generator;
OffsetG : Random_Offset.Generator;
procedure Init is
begin
Random_OpCode.Reset(OpcodeG);
Random_Reg.Reset(RegG);
Random_Offset.Reset(OffsetG);
end Init;
procedure GenerateRandomInstr(Inst : out Instr) is
Op : OpCode := Random_OpCode.Random(OpCodeG);
R1 : Reg := Random_Reg.Random(RegG);
R2 : Reg := Random_Reg.Random(RegG);
R3 : Reg := Random_Reg.Random(RegG);
Offs : Offset := Random_Offset.Random(OffsetG);
begin
case Op is
when ADD =>
Inst := (Op => ADD, AddRd => R1, AddRs1 => R2, AddRs2 => R3);
return;
when SUB =>
Inst := (Op => SUB, SubRd => R1, SubRs1 => R2, SubRs2 => R3);
return;
when MUL =>
Inst := (Op => MUL, MulRd => R1, MulRs1 => R2, MulRs2 => R3);
return;
when DIV =>
Inst := (Op => DIV, DivRd => R1, DivRs1 => R2, DivRs2 => R3);
return;
when RET =>
Inst := (Op => RET, RetRs => R1);
return;
when LDR =>
Inst := (Op => LDR, LdrRd => R1, LdrRs => R2, LdrOffs => Offs);
return;
when STR =>
Inst := (Op => STR, StrRa => R1, StrOffs => Offs, StrRb => R2);
return;
when MOV =>
Inst := (Op => MOV, MovRd => R1, MovOffs => Offs);
return;
when JMP =>
Inst := (Op => JMP, JmpOffs => Offs);
return;
when JZ =>
Inst := (Op => JZ, JzRa => R1, JzOffs => Offs);
return;
when NOP =>
Inst := (OP => NOP);
end case;
end GenerateRandomInstr;
procedure PutReg(R : in Reg) is
begin
Put("R");
Put(Item => Integer(R));
end PutReg;
procedure PutOffset(Offs : in Offset) is
begin
Put(Item => Integer(Offs));
end PutOffset;
procedure DebugPrintInstr(Inst : in Instr) with SPARK_Mode is
begin
Put(Instruction.OpCode'Image(Inst.Op));
case Inst.Op is
when ADD =>
Put(HT); PutReg(Inst.AddRd);
Put(HT); PutReg(Inst.AddRs1);
Put(HT); PutReg(Inst.AddRs2);
return;
when SUB =>
Put(HT); PutReg(Inst.SubRd);
Put(HT); PutReg(Inst.SubRs1);
Put(HT); PutReg(Inst.SubRs2);
return;
when MUL =>
Put(HT); PutReg(Inst.MulRd);
Put(HT); PutReg(Inst.MulRs1);
Put(HT); PutReg(Inst.MulRs2);
return;
when DIV =>
Put(HT); PutReg(Inst.DivRd);
Put(HT); PutReg(Inst.DivRs1);
Put(HT); PutReg(Inst.DivRs2);
return;
when RET =>
Put(HT); PutReg(Inst.RetRs);
return;
when LDR =>
Put(HT); PutReg(Inst.LdrRd);
Put(HT); PutReg(Inst.LdrRs);
Put(HT); PutOffset(Inst.LdrOffs);
return;
when STR =>
Put(HT); PutReg(Inst.StrRa);
Put(HT); PutOffset(Inst.StrOffs);
Put(HT); PutReg(Inst.StrRb);
return;
when MOV =>
Put(HT); PutReg(Inst.MovRd);
Put(HT); PutOffset(Inst.MovOffs);
return;
when JMP =>
Put(HT); PutOffset(Inst.JmpOffs);
return;
when JZ =>
Put(HT); PutReg(Inst.JzRa);
Put(HT); PutOffset(Inst.JzOffs);
return;
when NOP =>
return;
end case;
end DebugPrintInstr;
end Instruction;
|
HOM setup.applescript | AlexanderGalen/applescripts | 3 | 4288 | tell application "QuarkXPress"
tell document 1
make new layer at beginning
repeat
try
set grouped of group box 1 to false
set selection to null
on error
exit repeat
end try
end repeat
set allBoxes to generic boxes
repeat with thisBox in allBoxes
try
set theColor to name of color of frame of thisBox
if theColor is "Die Cut" then move thisBox to beginning of layer 1
set theBounds to bounds of thisBox as list
set y1 to item 1 of theBounds
set y1 to (coerce y1 to real)
if y1 is 0 then delete thisBox
end try
end repeat
set visible of layer 1 to false
try
set jobNumber to name as string
set jobNumber to characters 1 thru 6 of jobNumber as string
set prevInfoText to story 1 of text box "prev" as string
set prevJob to find text "[0-9]{6}" in prevInfoText with regexp and string result
set prevDoc to "HOM_Shortrun:~HOM Active Jobs:" & jobNumber & ":" & prevJob & ":" & prevJob & ".HOM.qxp"
open file prevDoc
end try
end tell
end tell
|
src/svd/sam_svd-rstc.ads | Fabien-Chouteau/samd51-hal | 1 | 27573 | <reponame>Fabien-Chouteau/samd51-hal<gh_stars>1-10
pragma Style_Checks (Off);
-- This spec has been automatically generated from ATSAMD51G19A.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package SAM_SVD.RSTC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Reset Cause
type RSTC_RCAUSE_Register is record
-- Read-only. Power On Reset
POR : Boolean;
-- Read-only. Brown Out CORE Detector Reset
BODCORE : Boolean;
-- Read-only. Brown Out VDD Detector Reset
BODVDD : Boolean;
-- Read-only. NVM Reset
NVM : Boolean;
-- Read-only. External Reset
EXT : Boolean;
-- Read-only. Watchdog Reset
WDT : Boolean;
-- Read-only. System Reset Request
SYST : Boolean;
-- Read-only. Backup Reset
BACKUP : Boolean;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for RSTC_RCAUSE_Register use record
POR at 0 range 0 .. 0;
BODCORE at 0 range 1 .. 1;
BODVDD at 0 range 2 .. 2;
NVM at 0 range 3 .. 3;
EXT at 0 range 4 .. 4;
WDT at 0 range 5 .. 5;
SYST at 0 range 6 .. 6;
BACKUP at 0 range 7 .. 7;
end record;
-- Backup Exit Source
type RSTC_BKUPEXIT_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit;
-- Read-only. Real Timer Counter Interrupt
RTC : Boolean;
-- Read-only. Battery Backup Power Switch
BBPS : Boolean;
-- unspecified
Reserved_3_6 : HAL.UInt4;
-- Read-only. Hibernate
HIB : Boolean;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for RSTC_BKUPEXIT_Register use record
Reserved_0_0 at 0 range 0 .. 0;
RTC at 0 range 1 .. 1;
BBPS at 0 range 2 .. 2;
Reserved_3_6 at 0 range 3 .. 6;
HIB at 0 range 7 .. 7;
end record;
-----------------
-- Peripherals --
-----------------
-- Reset Controller
type RSTC_Peripheral is record
-- Reset Cause
RCAUSE : aliased RSTC_RCAUSE_Register;
-- Backup Exit Source
BKUPEXIT : aliased RSTC_BKUPEXIT_Register;
end record
with Volatile;
for RSTC_Peripheral use record
RCAUSE at 16#0# range 0 .. 7;
BKUPEXIT at 16#2# range 0 .. 7;
end record;
-- Reset Controller
RSTC_Periph : aliased RSTC_Peripheral
with Import, Address => RSTC_Base;
end SAM_SVD.RSTC;
|
dos_games/Ultimate Pong/VESA backup/konwerter.asm | QAston/fasm-2006 | 0 | 87880 | <gh_stars>0
format MZ
use16
entry main:start
segment main
start:
mov bx,program_data
mov ds,bx
mov ah,09h
mov dx,TKomunikat
int 21h
mov ah,0ah
mov dx,BFileName
int 21h
movzx di,byte [FileNameCounter]
lea bx,[FileName]
add di,bx
xor ah,ah
mov [di],ah
sub di,4
mov ax,[di]
cmp ax,'.b'
jne zly_plik
add di,2
mov ax,[di]
cmp ax,'mp'
jne zly_plik
mov ah,3dh
mov al,010b
lea dx,[FileName]
int 21h
jc blad
mov bx,ax
mov ah,3fh
mov cx,54
lea dx,[BFile1]
int 21h
jc blad
xor si,si
mov cx,4
ustawpalete:
mov ah,3fh
mov dx,b
int 21h
mov dl,[r]
;shl dl,2
mov [BPaleta+si],dl
mov dl,[g]
;shl dl,2
mov [BPaleta+si+1],dl
mov dl,[b]
;shl dl,2
mov [BPaleta+si+2],dl
mov dl,[x]
;shl dl,2
mov byte [BPaleta+si+3],dl
add si,4
cmp si,1024
jb ustawpalete
push file_buffer1
pop ds
mov dx,0
mov cx,08000h
mov ah,3fh
int 21h
mov dx,cx
mov ah,3fh
int 21h
push file_buffer2
pop ds
mov dx,0
mov cx,08000h
mov ah,3fh
int 21h
mov dx,cx
mov ah,3fh
int 21h
push file_buffer3
pop ds
mov dx,0
mov cx,08000h
mov ah,3fh
int 21h
mov dx,cx
mov ah,3fh
int 21h
push file_buffer4
pop ds
mov dx,0
mov cx,08000h
mov ah,3fh
int 21h
mov dx,cx
mov ah,3fh
int 21h
push file_buffer5
pop ds
mov dx,0
mov cx,0b000h
mov ah,3fh
int 21h
mov ax,program_data
mov ds,ax
mov ax,'pf'
mov [di],ax
sub di,2
mov ax,'.g'
mov [di],ax
mov ah,3ch
xor cx,cx
lea dx,[FileName]
int 21h
jc blad
mov bx,ax
mov ah,40h
mov cx,1024
lea dx,[BPaleta]
int 21h
push file_buffer5
pop ds
mov dx,0b000h
mov cx,640
filepetla1:
sub dx,cx
mov ah,40h
int 21h
cmp dx,cx
ja filepetla1
push dx ;dx-to co nie miesci sie w linijkach
mov bp,dx
mov cx,640 ;cx-ilosc pikseli z nastej czesci
sub cx,bp
mov dx,0ffffh
sub dx,cx
inc dx
push file_buffer4
pop ds
mov ah,40h
int 21h
sub dx,cx
mov gs,dx
xor dx,dx
push file_buffer5
pop ds
pop cx
mov ah,40h
int 21h
mov dx,gs
sub dx,bp
mov cx,640
add dx,cx
push file_buffer4
pop ds
filepetla2:
sub dx,cx
mov ah,40h
int 21h
cmp dx,cx
jae filepetla2
push dx ;dx-to co nie miesci sie w linijkach
mov bp,dx
mov cx,640 ;cx-ilosc pikseli z nastej czesci
sub cx,bp
mov dx,0ffffh
sub dx,cx
inc dx
push file_buffer3
pop ds
mov ah,40h
int 21h
sub dx,cx
mov gs,dx
xor dx,dx
push file_buffer4
pop ds
pop cx
mov ah,40h
int 21h
mov dx,gs
sub dx,bp
mov cx,640
add dx,cx
push file_buffer3
pop ds
filepetla3:
sub dx,cx
mov ah,40h
int 21h
cmp dx,cx
jae filepetla3
push dx ;dx-to co nie miesci sie w linijkach
mov bp,dx
mov cx,640 ;cx-ilosc pikseli z nastej czesci
sub cx,bp
mov dx,0ffffh
sub dx,cx
inc dx
push file_buffer2
pop ds
mov ah,40h
int 21h
sub dx,cx
mov gs,dx
xor dx,dx
push file_buffer3
pop ds
pop cx
mov ah,40h
int 21h
mov dx,gs
sub dx,bp
mov cx,640
add dx,cx
push file_buffer2
pop ds
filepetla4:
sub dx,cx
mov ah,40h
int 21h
cmp dx,cx
jae filepetla4
push dx ;dx-to co nie miesci sie w linijkach
mov bp,dx
mov cx,640 ;cx-ilosc pikseli z nastej czesci
sub cx,bp
mov dx,0ffffh
sub dx,cx
inc dx
push file_buffer1
pop ds
mov ah,40h
int 21h
sub dx,cx
mov gs,dx
xor dx,dx
push file_buffer2
pop ds
pop cx
mov ah,40h
int 21h
mov dx,gs
sub dx,bp
mov cx,640
add dx,cx
push file_buffer1
pop ds
filepetla5:
sub dx,cx
mov ah,40h
int 21h
cmp dx,cx
jae filepetla5
mov cx,dx
xor dx,dx
mov ah,40h
int 21h
koniec:
xor ah,ah
int 16h
Koniec:
mov ax,4c00h
int 21h
zly_plik:
mov ah,09h
mov dx,TZlyPlik
int 21h
jmp koniec
blad:
mov ah,09h
mov dx,TBlad
int 21h
jmp koniec
segment program_data
TZlyPlik db 'Niewlasciwa nazwa pliku$'
TBlad db 'Blad pliku $'
TKomunikat db 'Wpisz nazwe pliku, ktory chcesz przekonwertowac z bmp na gpf',10,13,'$'
BFileName db 199
FileNameCounter db 0
FileName: times 200 db 0
b db 0
g db 0
r db 0
x db 0
BPaleta: times 1024 db 0
segment file_buffer1
BFile1: times 10000h db 0
segment file_buffer2
BFile2: times 10000h db 0
segment file_buffer3
BFile3: times 10000h db 0
segment file_buffer4
BFile4: times 10000h db 0
segment file_buffer5
BFile5: times 0b000h db 0
Virtual at BFile1
bftype dw ?
bfsize dd ?
bfreserved dd ?
bfoffbits dd ?
bmprozmiar dd ?
bmpszerokosc dd ?
bmpwysokosc dd ?
biplanes dw ?
bibitcount dw ?
bicompression dd ?
bisizeimag dd ?
bixpelspermeter dd ?
biypelspermeter dd ?
bmpliczbakolorow dd ?
biclrimportant dd ?
end virtual |
LibraBFT/Impl/Handle/Properties.agda | cwjnkins/bft-consensus-agda | 0 | 5436 | <filename>LibraBFT/Impl/Handle/Properties.agda<gh_stars>0
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
{-# OPTIONS --allow-unsolved-metas #-}
-- This module provides some scaffolding to define the handlers for our fake/simple "implementation"
-- and connect them to the interface of the SystemModel.
open import Optics.All
open import LibraBFT.Prelude
open import LibraBFT.Lemmas
open import LibraBFT.Base.ByteString
open import LibraBFT.Base.Encode
open import LibraBFT.Base.KVMap
open import LibraBFT.Base.PKCS
open import LibraBFT.Hash
open import LibraBFT.Impl.Base.Types
open import LibraBFT.Impl.Consensus.RoundManager.Properties
open import LibraBFT.Impl.Consensus.Types
open import LibraBFT.Impl.Util.Crypto
open import LibraBFT.Impl.Util.Util
open import LibraBFT.Concrete.System
open import LibraBFT.Concrete.System.Parameters
open EpochConfig
open import LibraBFT.Yasm.Types
open import LibraBFT.Yasm.Yasm ℓ-RoundManager ℓ-VSFP ConcSysParms PeerCanSignForPK (λ {st} {part} {pk} → PeerCanSignForPK-stable {st} {part} {pk})
module LibraBFT.Impl.Handle.Properties where
open import LibraBFT.Impl.Consensus.RoundManager
open import LibraBFT.Impl.Handle
-- This proof is complete except for pieces that are directly about the handlers. Our
-- fake/simple handler does not yet obey the needed properties, so we can't finish this yet.
impl-sps-avp : StepPeerState-AllValidParts
-- In our fake/simple implementation, init and handling V and C msgs do not send any messages
impl-sps-avp _ hpk (step-init _) m∈outs part⊂m ver = ⊥-elim (¬Any[] m∈outs)
impl-sps-avp _ hpk (step-msg {sndr , V vm} _ _) m∈outs _ _ = ⊥-elim (¬Any[] m∈outs)
impl-sps-avp _ hpk (step-msg {sndr , C cm} _ _) m∈outs _ _ = ⊥-elim (¬Any[] m∈outs)
-- These aren't true yet, because processProposalMsgM sends fake votes that don't follow the rules for ValidPartForPK
impl-sps-avp preach hpk (step-msg {sndr , P pm} m∈pool ps≡) m∈outs v⊂m ver ¬init
with m∈outs
-- Handler sends at most one vote, so it can't be "there"
...| there {xs = xs} imp = ⊥-elim (¬Any[] imp)
...| here refl
with v⊂m
...| vote∈qc vs∈qc rbld≈ qc∈m
with qc∈m
...| xxx = {!x!} -- We will prove that votes represented in the SyncInfo of a
-- proposal message were sent before, so these will be inj₂.
-- This will be based on an invariant of the implementation, for
-- example that the QCs included in the SyncInfo of a VoteMsg have
-- been sent before. We will need to use hash injectivity and
-- signature injectivity to ensure a different vote was not sent
-- previously with the same signature.
impl-sps-avp {pk = pk} {α = α} {st = st} preach hpk (step-msg {sndr , P pm} m∈pool ps≡) m∈outs v⊂m ver ¬init
| here refl
| vote∈vm {si}
with MsgWithSig∈? {pk} {ver-signature ver} {msgPool st}
...| yes msg∈ = inj₂ msg∈
...| no msg∉ = inj₁ ( mkPCS4PK {! !} {!!} (inGenInfo refl) {!!} {!!} {!!}
-- The implementation will need to provide evidence that the peer is a member of
-- the epoch of the message it's sending and that it is assigned pk for that epoch.
, msg∉)
open Structural impl-sps-avp
----- Properties that bridge the system model gap to the handler -----
msgsToSendWereSent1 : ∀ {pid ts pm vm} {st : RoundManager}
→ send (V vm) ∈ proj₂ (peerStep pid (P pm) ts st)
→ ∃[ αs ] (SendVote vm αs ∈ LBFT-outs (handle pid (P pm) ts) st)
msgsToSendWereSent1 {pid} {ts} {pm} {vm} {st} send∈acts
with send∈acts
-- The fake handler sends only to node 0 (fakeAuthor), so this doesn't
-- need to be very general yet.
-- TODO-1: generalize this proof so it will work when the set of recipients is
-- not hard coded.
-- The system model allows any message sent to be received by any peer (so the list of
-- recipients it essentially ignored), meaning that our safety proofs will be for a slightly
-- stronger model. Progress proofs will require knowledge of recipients, though, so we will
-- keep the implementation model faithful to the implementation.
...| here refl = fakeAuthor ∷ [] , here refl
-- This captures which kinds of messages are sent by handling which kind of message. It will
-- require additional disjuncts when we implement processVote.
msgsToSendWereSent : ∀ {pid nm m} {st : RoundManager}
→ send m ∈ proj₂ (peerStepWrapper pid nm st)
→ send m ∈ proj₂ (peerStep pid nm 0 st)
× ∃[ vm ] ∃[ pm ] (m ≡ V vm × nm ≡ P pm)
msgsToSendWereSent {pid} {nm = nm} {m} {st} m∈outs
with nm
...| C _ = ⊥-elim (¬Any[] m∈outs)
...| V _ = ⊥-elim (¬Any[] m∈outs)
...| P pm
with m∈outs
...| here v∈outs
with m
...| P _ = ⊥-elim (P≢V (action-send-injective v∈outs))
...| C _ = ⊥-elim (C≢V (action-send-injective v∈outs))
...| V vm rewrite sym v∈outs = here refl , vm , pm , refl , refl
proposalHandlerSentVote : ∀ {pid ts pm vm} {st : RoundManager}
→ send (V vm) ∈ proj₂ (peerStepWrapper pid (P pm) st)
→ ∃[ αs ] (SendVote vm αs ∈ LBFT-outs (handle pid (P pm) ts) st)
proposalHandlerSentVote {pid} {ts} {pm} {vm} {st} m∈outs
with msgsToSendWereSent {pid} {P pm} {st = st} m∈outs
...| send∈ , vm , pm' , refl , refl
with msgsToSendWereSent1 {pid} {ts} {pm'} {st = st} send∈
...| αs , sv = αs , sv
----- Properties that relate handler to system state -----
data _∈RoundManager_ (qc : QuorumCert) (rm : RoundManager) : Set where
inHQC : qc ≡ ₋rmHighestQC rm → qc ∈RoundManager rm
inHCC : qc ≡ ₋rmHighestCommitQC rm → qc ∈RoundManager rm
postulate -- TODO-2: this will be proved for the implementation, confirming that honest
-- participants only store QCs comprising votes that have actually been sent.
-- Votes stored in highesQuorumCert and highestCommitCert were sent before.
-- Note that some implementations might not ensure this, but LibraBFT does
-- because even the leader of the next round sends its own vote to itself,
-- as opposed to using it to construct a QC using its own unsent vote.
qcVotesSentB4 : ∀{pid qc vs pk}{st : SystemState}
→ ReachableSystemState st
→ initialised st pid ≡ initd
→ qc ∈RoundManager (peerStates st pid)
→ vs ∈ qcVotes qc
→ ¬ (∈GenInfo (proj₂ vs))
→ MsgWithSig∈ pk (proj₂ vs) (msgPool st)
-- We can prove this easily because we don't yet do epoch changes,
-- so only the initial EC is relevant. Later, this will require us to use the fact that
-- epoch changes require proof of committing an epoch-changing transaction.
availEpochsConsistent :
∀{pid pid' v v' pk}{st : SystemState}
→ ReachableSystemState st
→ (pkvpf : PeerCanSignForPK st v pid pk)
→ (pkvpf' : PeerCanSignForPK st v' pid' pk)
→ PeerCanSignForPK.𝓔 pkvpf ≡ PeerCanSignForPK.𝓔 pkvpf'
availEpochsConsistent r (mkPCS4PK _ _ (inGenInfo refl) _ _ _)
(mkPCS4PK _ _ (inGenInfo refl) _ _ _) = refl
-- Always true, so far, as no epoch changes.
noEpochIdChangeYet : ∀ {pre : SystemState}{pid}{ppre ppost msgs}
→ ReachableSystemState pre
→ ppre ≡ peerStates pre pid
→ StepPeerState pid (msgPool pre) (initialised pre) ppre (ppost , msgs)
→ initialised pre pid ≡ initd
→ (₋rmEC ppre) ^∙ rmEpoch ≡ (₋rmEC ppost) ^∙ rmEpoch
noEpochIdChangeYet _ ppre≡ (step-init uni) ini = ⊥-elim (uninitd≢initd (trans (sym uni) ini))
noEpochIdChangeYet _ ppre≡ (step-msg {(_ , m)} _ _) ini
with m
...| P p = refl
...| V v = refl
...| C c = refl
open SyncInfo
-- QCs in VoteMsg come from RoundManager
VoteMsgQCsFromRoundManager :
∀ {pid s' outs pk}{pre : SystemState}
→ ReachableSystemState pre
-- For any honest call to /handle/ or /init/,
→ (sps : StepPeerState pid (msgPool pre) (initialised pre) (peerStates pre pid) (s' , outs))
→ ∀{v vm qc} → Meta-Honest-PK pk
-- For every vote v represented in a message output by the call
→ v ⊂Msg (V vm)
→ send (V vm) ∈ outs
→ qc QC∈SyncInfo (vm ^∙ vmSyncInfo)
→ qc ∈RoundManager (peerStates pre pid)
VoteMsgQCsFromRoundManager r (step-init _) _ _ ()
VoteMsgQCsFromRoundManager {pid} {pre = pre} r (step-msg {_ , P pm} m∈pool pinit) {v} {vm}
hpk v⊂m m∈outs qc∈m
with peerStates pre pid
...| rm
with proposalHandlerSentVote {pid} {0} {pm} {vm} {rm} m∈outs
...| _ , v∈outs
with qc∈m
...| withVoteSIHighQC refl
= inHQC (cong ₋siHighestQuorumCert (procPMCerts≡ {0} {pm} {rm} v∈outs))
VoteMsgQCsFromRoundManager {pid} {pre = pre} r (step-msg {_ , P pm} m∈pool pinit) {v} {vm1}
hpk v⊂m m∈outs qc∈m
| rm
| _ , v∈outs
| withVoteSIHighCC hqcIsJust
with cong ₋siHighestCommitCert (procPMCerts≡ {0} {pm} {rm} v∈outs)
...| refl
with (rm ^∙ rmHighestQC) ≟QC (rm ^∙ rmHighestCommitQC)
...| true because (ofʸ refl) = ⊥-elim (maybe-⊥ hqcIsJust refl)
...| false because _ = inHCC (just-injective (sym hqcIsJust))
newVoteSameEpochGreaterRound : ∀ {pre : SystemState}{pid s' outs v m pk}
→ ReachableSystemState pre
→ StepPeerState pid (msgPool pre) (initialised pre) (peerStates pre pid) (s' , outs)
→ ¬ (∈GenInfo (₋vSignature v))
→ Meta-Honest-PK pk
→ v ⊂Msg m → send m ∈ outs → (sig : WithVerSig pk v)
→ ¬ MsgWithSig∈ pk (ver-signature sig) (msgPool pre)
→ v ^∙ vEpoch ≡ (₋rmEC (peerStates pre pid)) ^∙ rmEpoch
× suc ((₋rmEC (peerStates pre pid)) ^∙ rmLastVotedRound) ≡ v ^∙ vRound -- New vote for higher round than last voted
× v ^∙ vRound ≡ ((₋rmEC s') ^∙ rmLastVotedRound) -- Last voted round is round of new vote
newVoteSameEpochGreaterRound {pre = pre} {pid} {v = v} {m} {pk} r (step-msg {(_ , P pm)} msg∈pool pinit) ¬init hpk v⊂m m∈outs sig vnew
rewrite pinit
with msgsToSendWereSent {pid} {P pm} {m} {peerStates pre pid} m∈outs
...| _ , vm , _ , refl , refl
with proposalHandlerSentVote {pid} {0} {pm} {vm} {peerStates pre pid} m∈outs
...| _ , v∈outs
rewrite SendVote-inj-v (Any-singleton⁻ v∈outs)
| SendVote-inj-si (Any-singleton⁻ v∈outs)
with v⊂m
-- Rebuilding keeps the same signature, and the SyncInfo included with the
-- VoteMsg sent comprises QCs from the peer's state. Votes represented in
-- those QCS have signatures that have been sent before, contradicting the
-- assumption that v's signature has not been sent before.
...| vote∈vm {si} = refl , refl , refl
...| vote∈qc {vs = vs} {qc} vs∈qc v≈rbld (inV qc∈m)
rewrite cong ₋vSignature v≈rbld
| procPMCerts≡ {0} {pm} {peerStates pre pid} {vm} v∈outs
with qcVotesSentB4 r pinit (VoteMsgQCsFromRoundManager r (step-msg msg∈pool pinit) hpk v⊂m (here refl) qc∈m) vs∈qc ¬init
...| sentb4 = ⊥-elim (vnew sentb4)
-- We resist the temptation to combine this with the noEpochChangeYet because in future there will be epoch changes
lastVoteRound-mono : ∀ {pre : SystemState}{pid}{ppre ppost msgs}
→ ReachableSystemState pre
→ ppre ≡ peerStates pre pid
→ StepPeerState pid (msgPool pre) (initialised pre) ppre (ppost , msgs)
→ initialised pre pid ≡ initd
→ (₋rmEC ppre) ^∙ rmEpoch ≡ (₋rmEC ppost) ^∙ rmEpoch
→ (₋rmEC ppre) ^∙ rmLastVotedRound ≤ (₋rmEC ppost) ^∙ rmLastVotedRound
lastVoteRound-mono _ ppre≡ (step-init uni) ini = ⊥-elim (uninitd≢initd (trans (sym uni) ini))
lastVoteRound-mono _ ppre≡ (step-msg {(_ , m)} _ _) _
with m
...| P p = const (≤-step (≤-reflexive refl))
...| V v = const (≤-reflexive refl)
...| C c = const (≤-reflexive refl)
postulate -- TODO-1: prove it
¬genVotesRound≢0 : ∀ {pk sig}{st : SystemState}
→ ReachableSystemState st
→ Meta-Honest-PK pk
→ (mws : MsgWithSig∈ pk sig (msgPool st))
→ ¬ (∈GenInfo sig)
→ (msgPart mws) ^∙ vRound ≢ 0
|
mips/brainfuck.asm | brenns10/yams | 17 | 177608 | ###
# File: brainfuck.asm
#
# Code for brainfuck interpereter.
###
.eqv CODE_BUFFER 4096
.eqv OUT_BUFFER 4096
.eqv MEMORY 32768
.data
bf_code: .space CODE_BUFFER
bf_code_size: .word 0
bf_out: .space OUT_BUFFER
bf_buffer: .space MEMORY
.text
# bf_load_code: Loads brainfuck code from a string. Ignores all non-
# coding characters.
# Parameters:
# $a0: Address of source string (null terminated).
# Return:
# $v0: 0 on success, 1 on memory error, 2 on bracket balance error
bf_load_code:
li $t0, CODE_BUFFER
la $t1, bf_code
move $t4, $zero
# $t0 - amount of code bytes remaining.
# $t1 - current code byte to write into.
# $t2 - current byte of input
# $t3 - command to compare input to
# $t4 - bracket balance
_bf_load_loop:
lb $t2, 0($a0)
beq $t2, $zero, _bf_load_return
beq $t0, $zero, _bf_load_memerr_return
li $t3, '>'
beq $t2, $t3, _bf_load_store
li $t3, '<'
beq $t2, $t3, _bf_load_store
li $t3, '+'
beq $t2, $t3, _bf_load_store
li $t3, '-'
beq $t2, $t3, _bf_load_store
li $t3, '.'
beq $t2, $t3, _bf_load_store
li $t3, ','
beq $t2, $t3, _bf_load_store
li $t3, '['
beq $t2, $t3, _bf_load_increment_balance
li $t3, ']'
beq $t2, $t3, _bf_load_decrement_balance
# Fall through for any non-coding characters.
addi $a0, $a0, 1
j _bf_load_loop
_bf_load_increment_balance:
addi $t4, $t4, 1
j _bf_load_store
_bf_load_decrement_balance:
addi $t4, $t4, -1
blt $t4, $zero, _bf_load_balerr_return
_bf_load_store:
sb $t2, 0($t1)
addi $t1, $t1, 1
addi $t0, $t0, -1
addi $a0, $a0, 1
j _bf_load_loop
_bf_load_return:
# Return an error if the bracket balance is off.
bgt $t4, $zero, _bf_load_balerr_return
move $v0, $zero
li $t1, CODE_BUFFER
sub $t1, $t1, $t0 # Calculate size of code
la $t0, bf_code_size
sw $t1, 0($t0) # Save size of code in memory.
jr $ra
_bf_load_memerr_return:
li $v0, 1
j _bf_load_err_return
_bf_load_balerr_return:
li $v0, 2
_bf_load_err_return:
la $t0, bf_code_size # Make sure code_size is zero so nothing gets
sw $zero, 0($t0) # executed
jr $ra
# bf_intrp: Interprets brainfuck code given an input string.
# Parameters:
# $a0: Address of input string (null terminated).
# Returns:
# $v0: 0 on success.
bf_intrp:
# Load code start pointer into $t0.
# Load address of last instruction in $t1.
la $t1, bf_code_size
lw $t1, 0($t1)
la $t0, bf_code
add $t1, $t1, $t0
addi $t1, $t1, -1
# Address of current output in $t2.
la $t2, bf_out
# Data pointer is $t3.
la $t3, bf_buffer
sb $zero, 0($t3)
# Current instruction pointer is $t4 (actual instruction, $t5).
la $t4, bf_code
# Max data pointer, so we know when to zero memory.
addi $t9, $t3, 1
_bf_intrp_loop:
bgt $t4, $t1, _bf_intrp_end
blt $t4, $t0, _bf_intrp_end
blt $t3, $t9, _bf_intrp_nozero
sb $zero, 0($t3)
move $t9, $t3
addi $t9, $t9, 1
_bf_intrp_nozero:
lbu $t5, 0($t4)
li $t6, '+'
beq $t5, $t6, _bf_intrp_inc
li $t6, '-'
beq $t5, $t6, _bf_intrp_dec
li $t6, '>'
beq $t5, $t6, _bf_intrp_nxt
li $t6, '<'
beq $t5, $t6, _bf_intrp_prv
li $t6, ','
beq $t5, $t6, _bf_intrp_read
li $t6, '.'
beq $t5, $t6, _bf_intrp_write
li $t6, '['
beq $t5, $t6, _bf_intrp_loopstart
li $t6, ']'
beq $t5, $t6, _bf_intrp_loopend
_bf_intrp_inc: # + (increment value at data cell)
lbu $t6, 0($t3)
addiu $t6, $t6, 1
sb $t6, 0($t3)
j _bf_intrp_continue
_bf_intrp_dec: # - (decrement value at data cell)
lbu $t6, 0($t3)
li $t7, 1
sub $t6, $t6, $t7
sb $t6, 0($t3)
j _bf_intrp_continue
_bf_intrp_nxt: # > (increment data pointer)
addi $t3, $t3, 1
j _bf_intrp_continue
_bf_intrp_prv: # < (decrement data pointer)
addi $t3, $t3, -1
j _bf_intrp_continue
_bf_intrp_read: # , (read input)
lbu $t6, 0($a0)
sb $t6, 0($t3)
# Check if reading \0, if so, skip incrementing
beq $t6, $zero, _bf_intrp_continue
addi $a0, $a0, 1
j _bf_intrp_continue
_bf_intrp_write: # . (write output)
lbu $t6, 0($t3)
# Compute the second to last byte of output
la $t7, bf_out
addi $t7, $t7, OUT_BUFFER
addi $t7, $t7, -2
# Check if out of space, if so, do not overwrite
bgt $t2, $t7, _bf_intrp_continue
sb $t6, 0($t2)
addi $t2, $t2, 1
j _bf_intrp_continue
_bf_intrp_loopstart: # [ (if cell zero, leave loop)
lbu $t6, 0($t3)
bne $t6, $zero, _bf_intrp_continue
li $t7, 1
li $t8, ']'
_bf_intrp_loopstart_findmatching:
addi $t4, $t4, 1 # Increment instruction pointer
lbu $t6, 0($t4)
beq $t6, $t5, _bf_intrp_loopstart_findmatching_open
beq $t6, $t8, _bf_intrp_loopstart_findmatching_close
j _bf_intrp_loopstart_findmatching
_bf_intrp_loopstart_findmatching_open:
addi $t7, $t7, 1 # Increment nest count
j _bf_intrp_loopstart_findmatching
_bf_intrp_loopstart_findmatching_close:
addi $t7, $t7, -1 # Decrement nest count
# If this evened the nest count, go to next instruction
beq $t7, $zero, _bf_intrp_continue
j _bf_intrp_loopstart_findmatching
_bf_intrp_loopend: # [ (if cell zero, leave loop)
lbu $t6, 0($t3)
beq $t6, $zero, _bf_intrp_continue
li $t7, 1
li $t8, '['
_bf_intrp_loopend_findmatching:
addi $t4, $t4, -1 # Decrement instruction pointer
lbu $t6, 0($t4)
beq $t6, $t5, _bf_intrp_loopend_findmatching_close
beq $t6, $t8, _bf_intrp_loopend_findmatching_open
j _bf_intrp_loopend_findmatching
_bf_intrp_loopend_findmatching_close:
addi $t7, $t7, 1 # Increment nest count
j _bf_intrp_loopend_findmatching
_bf_intrp_loopend_findmatching_open:
addi $t7, $t7, -1 # Decrement nest count
# If this evened the nest count, go to next instruction
beq $t7, $zero, _bf_intrp_continue
j _bf_intrp_loopend_findmatching
_bf_intrp_continue:
addi $t4, $t4, 1
j _bf_intrp_loop
_bf_intrp_end:
# Need to null-terminate output.
sb $zero, 0($t2)
jr $ra
|
Cubical/ZCohomology/Groups/Sn.agda | Schippmunk/cubical | 0 | 12970 | <filename>Cubical/ZCohomology/Groups/Sn.agda
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.ZCohomology.Groups.Sn where
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.Properties
open import Cubical.ZCohomology.Groups.Unit
open import Cubical.ZCohomology.Groups.Connected
open import Cubical.ZCohomology.GroupStructure
open import Cubical.ZCohomology.Groups.Prelims
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Structure
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.HITs.Pushout
open import Cubical.HITs.Sn
open import Cubical.HITs.S1
open import Cubical.HITs.Susp
open import Cubical.HITs.SetTruncation renaming (rec to sRec ; elim to sElim ; elim2 to sElim2 ; map to sMap)
open import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; elim to pElim ; elim2 to pElim2 ; ∥_∥ to ∥_∥₁ ; ∣_∣ to ∣_∣₁) hiding (map)
open import Cubical.Data.Bool
open import Cubical.Data.Sigma
open import Cubical.Data.Int renaming (_+_ to _+ℤ_; +-comm to +ℤ-comm ; +-assoc to +ℤ-assoc)
open import Cubical.Data.Nat
open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec)
open import Cubical.Data.Unit
open import Cubical.Homotopy.Connected
open import Cubical.Algebra.Group
infixr 31 _□_
_□_ : _
_□_ = compGroupIso
open GroupEquiv
open vSES
open GroupIso
open GroupHom
open BijectionIso
Sn-connected : (n : ℕ) (x : typ (S₊∙ (suc n))) → ∥ pt (S₊∙ (suc n)) ≡ x ∥₁
Sn-connected zero = toPropElim (λ _ → propTruncIsProp) ∣ refl ∣₁
Sn-connected (suc zero) = suspToPropElim base (λ _ → propTruncIsProp) ∣ refl ∣₁
Sn-connected (suc (suc n)) = suspToPropElim north (λ _ → propTruncIsProp) ∣ refl ∣₁
H⁰-Sⁿ≅ℤ : (n : ℕ) → GroupIso (coHomGr 0 (S₊ (suc n))) intGroup
H⁰-Sⁿ≅ℤ zero = H⁰-connected base (Sn-connected 0)
H⁰-Sⁿ≅ℤ (suc n) = H⁰-connected north (Sn-connected (suc n))
-- -- ----------------------------------------------------------------------
--- We will need to switch between Sⁿ defined using suspensions and using pushouts
--- in order to apply Mayer Vietoris.
S1Iso : Iso S¹ (Pushout {A = Bool} (λ _ → tt) λ _ → tt)
S1Iso = S¹IsoSuspBool ⋄ invIso PushoutSuspIsoSusp
coHomPushout≅coHomSn : (n m : ℕ) → GroupIso (coHomGr m (S₊ (suc n)))
(coHomGr m (Pushout {A = S₊ n} (λ _ → tt) λ _ → tt))
coHomPushout≅coHomSn zero m =
Iso+Hom→GrIso (setTruncIso (domIso S1Iso))
(sElim2 (λ _ _ → isSet→isGroupoid setTruncIsSet _ _) (λ _ _ → refl))
coHomPushout≅coHomSn (suc n) m =
Iso+Hom→GrIso (setTruncIso (domIso (invIso PushoutSuspIsoSusp)))
(sElim2 (λ _ _ → isSet→isGroupoid setTruncIsSet _ _) (λ _ _ → refl))
-------------------------- H⁰(S⁰) -----------------------------
S0→Int : (a : Int × Int) → S₊ 0 → Int
S0→Int a true = fst a
S0→Int a false = snd a
H⁰-S⁰≅ℤ×ℤ : GroupIso (coHomGr 0 (S₊ 0)) (dirProd intGroup intGroup)
fun (map H⁰-S⁰≅ℤ×ℤ) = sRec (isSet× isSetInt isSetInt) λ f → (f true) , (f false)
isHom (map H⁰-S⁰≅ℤ×ℤ) = sElim2 (λ _ _ → isSet→isGroupoid (isSet× isSetInt isSetInt) _ _)
λ a b → refl
inv H⁰-S⁰≅ℤ×ℤ a = ∣ S0→Int a ∣₂
rightInv H⁰-S⁰≅ℤ×ℤ _ = refl
leftInv H⁰-S⁰≅ℤ×ℤ = sElim (λ _ → isSet→isGroupoid setTruncIsSet _ _)
λ f → cong ∣_∣₂ (funExt (λ {true → refl ; false → refl}))
------------------------- H¹(S⁰) ≅ 0 -------------------------------
private
Hⁿ-S0≃Kₙ×Kₙ : (n : ℕ) → Iso (S₊ 0 → coHomK (suc n)) (coHomK (suc n) × coHomK (suc n))
Iso.fun (Hⁿ-S0≃Kₙ×Kₙ n) f = (f true) , (f false)
Iso.inv (Hⁿ-S0≃Kₙ×Kₙ n) (a , b) true = a
Iso.inv (Hⁿ-S0≃Kₙ×Kₙ n) (a , b) false = b
Iso.rightInv (Hⁿ-S0≃Kₙ×Kₙ n) a = refl
Iso.leftInv (Hⁿ-S0≃Kₙ×Kₙ n) b = funExt λ {true → refl ; false → refl}
isContrHⁿ-S0 : (n : ℕ) → isContr (coHom (suc n) (S₊ 0))
isContrHⁿ-S0 n = isContrRetract (Iso.fun (setTruncIso (Hⁿ-S0≃Kₙ×Kₙ n)))
(Iso.inv (setTruncIso (Hⁿ-S0≃Kₙ×Kₙ n)))
(Iso.leftInv (setTruncIso (Hⁿ-S0≃Kₙ×Kₙ n)))
(isContrHelper n)
where
isContrHelper : (n : ℕ) → isContr (∥ (coHomK (suc n) × coHomK (suc n)) ∥₂)
fst (isContrHelper zero) = ∣ (0₁ , 0₁) ∣₂
snd (isContrHelper zero) = sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ y → elim2 {B = λ x y → ∣ (0₁ , 0₁) ∣₂ ≡ ∣(x , y) ∣₂ }
(λ _ _ → isOfHLevelPlus {n = 2} 2 setTruncIsSet _ _)
(toPropElim2 (λ _ _ → setTruncIsSet _ _) refl) (fst y) (snd y)
isContrHelper (suc zero) = ∣ (0₂ , 0₂) ∣₂
, sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ y → elim2 {B = λ x y → ∣ (0₂ , 0₂) ∣₂ ≡ ∣(x , y) ∣₂ }
(λ _ _ → isOfHLevelPlus {n = 2} 3 setTruncIsSet _ _)
(suspToPropElim2 base (λ _ _ → setTruncIsSet _ _) refl) (fst y) (snd y)
isContrHelper (suc (suc n)) = ∣ (0ₖ (3 + n) , 0ₖ (3 + n)) ∣₂
, sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ y → elim2 {B = λ x y → ∣ (0ₖ (3 + n) , 0ₖ (3 + n)) ∣₂ ≡ ∣(x , y) ∣₂ }
(λ _ _ → isProp→isOfHLevelSuc (4 + n) (setTruncIsSet _ _))
(suspToPropElim2 north (λ _ _ → setTruncIsSet _ _) refl) (fst y) (snd y)
H¹-S⁰≅0 : (n : ℕ) → GroupIso (coHomGr (suc n) (S₊ 0)) trivialGroup
H¹-S⁰≅0 n = IsoContrGroupTrivialGroup (isContrHⁿ-S0 n)
------------------------- H²(S¹) ≅ 0 -------------------------------
Hⁿ-S¹≅0 : (n : ℕ) → GroupIso (coHomGr (2 + n) (S₊ 1)) trivialGroup
Hⁿ-S¹≅0 n = IsoContrGroupTrivialGroup
(isOfHLevelRetractFromIso 0 helper
(_ , helper2))
where
helper : Iso ⟨ coHomGr (2 + n) (S₊ 1)⟩ ∥ Σ (hLevelTrunc (4 + n) (S₊ (2 + n))) (λ x → ∥ x ≡ x ∥₂) ∥₂
helper = compIso (setTruncIso IsoFunSpaceS¹) IsoSetTruncateSndΣ
helper2 : (x : ∥ Σ (hLevelTrunc (4 + n) (S₊ (2 + n))) (λ x → ∥ x ≡ x ∥₂) ∥₂) → ∣ ∣ north ∣ , ∣ refl ∣₂ ∣₂ ≡ x
helper2 =
sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
(uncurry
(trElim (λ _ → isOfHLevelΠ (4 + n) λ _ → isProp→isOfHLevelSuc (3 + n) (setTruncIsSet _ _))
(suspToPropElim (ptSn (suc n)) (λ _ → isPropΠ λ _ → setTruncIsSet _ _)
(sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ p
→ cong ∣_∣₂ (ΣPathP (refl , isContr→isProp helper3 _ _))))))
where
helper4 : isConnected (n + 3) (hLevelTrunc (4 + n) (S₊ (2 + n)))
helper4 = subst (λ m → isConnected m (hLevelTrunc (4 + n) (S₊ (2 + n)))) (+-comm 3 n)
(isOfHLevelRetractFromIso 0 (invIso (truncOfTruncIso (3 + n) 1)) (sphereConnected (2 + n)))
helper3 : isContr ∥ ∣ north ∣ ≡ ∣ north ∣ ∥₂
helper3 = isOfHLevelRetractFromIso 0 setTruncTrunc2Iso
(isConnectedPath 2 (isConnectedSubtr 3 n helper4) _ _)
-- --------------- H¹(Sⁿ), n ≥ 1 --------------------------------------------
H¹-Sⁿ≅0 : (n : ℕ) → GroupIso (coHomGr 1 (S₊ (2 + n))) trivialGroup
H¹-Sⁿ≅0 zero = IsoContrGroupTrivialGroup isContrH¹S²
where
isContrH¹S² : isContr ⟨ coHomGr 1 (S₊ 2) ⟩
isContrH¹S² = ∣ (λ _ → ∣ base ∣) ∣₂
, coHomPointedElim 0 north (λ _ → setTruncIsSet _ _)
λ f p → cong ∣_∣₂ (funExt λ x → sym p ∙∙ sym (spoke f north) ∙∙ spoke f x)
H¹-Sⁿ≅0 (suc n) = IsoContrGroupTrivialGroup isContrH¹S³⁺ⁿ
where
anIso : Iso ⟨ coHomGr 1 (S₊ (3 + n)) ⟩ ∥ (S₊ (3 + n) → hLevelTrunc (4 + n) (coHomK 1)) ∥₂
anIso =
setTruncIso
(codomainIso
(invIso (truncIdempotentIso (4 + n) (isOfHLevelPlus' {n = 1 + n} 3 (isOfHLevelTrunc 3)))))
isContrH¹S³⁺ⁿ-ish : (f : (S₊ (3 + n) → hLevelTrunc (4 + n) (coHomK 1)))
→ ∣ (λ _ → ∣ ∣ base ∣ ∣) ∣₂ ≡ ∣ f ∣₂
isContrH¹S³⁺ⁿ-ish f = ind (f north) refl
where
ind : (x : hLevelTrunc (4 + n) (coHomK 1))
→ x ≡ f north
→ ∣ (λ _ → ∣ ∣ base ∣ ∣) ∣₂ ≡ ∣ f ∣₂
ind = trElim (λ _ → isOfHLevelΠ (4 + n) λ _ → isOfHLevelPlus' {n = (3 + n)} 1 (setTruncIsSet _ _))
(trElim (λ _ → isOfHLevelΠ 3 λ _ → isOfHLevelPlus {n = 1} 2 (setTruncIsSet _ _))
(toPropElim (λ _ → isPropΠ λ _ → setTruncIsSet _ _)
λ p → cong ∣_∣₂ (funExt λ x → p ∙∙ sym (spoke f north) ∙∙ spoke f x)))
isContrH¹S³⁺ⁿ : isContr ⟨ coHomGr 1 (S₊ (3 + n)) ⟩
isContrH¹S³⁺ⁿ =
isOfHLevelRetractFromIso 0
anIso
(∣ (λ _ → ∣ ∣ base ∣ ∣) ∣₂
, sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) isContrH¹S³⁺ⁿ-ish)
--------- H¹(S¹) ≅ ℤ -------
{-
Idea :
H¹(S¹) := ∥ S¹ → K₁ ∥₂
≃ ∥ S¹ → S¹ ∥₂
≃ ∥ S¹ × ℤ ∥₂
≃ ∥ S¹ ∥₂ × ∥ ℤ ∥₂
≃ ℤ
-}
coHom1S1≃ℤ : GroupIso (coHomGr 1 (S₊ 1)) intGroup
coHom1S1≃ℤ = theIso
where
F = Iso.fun S¹→S¹≡S¹×Int
F⁻ = Iso.inv S¹→S¹≡S¹×Int
theIso : GroupIso (coHomGr 1 (S₊ 1)) intGroup
fun (map theIso) = sRec isSetInt (λ f → snd (F f))
isHom (map theIso) =
coHomPointedElimS¹2 _ (λ _ _ → isSetInt _ _)
λ p q → (λ i → winding (guy ∣ base ∣ (cong S¹map (help p q i))))
∙∙ (λ i → winding (guy ∣ base ∣ (congFunct S¹map p q i)))
∙∙ winding-hom (guy ∣ base ∣ (cong S¹map p))
(guy ∣ base ∣ (cong S¹map q))
where
guy = basechange2⁻ ∘ S¹map
help : (p q : Path (coHomK 1) ∣ base ∣ ∣ base ∣) → cong₂ _+ₖ_ p q ≡ p ∙ q
help p q = cong₂Funct _+ₖ_ p q ∙ (λ i → cong (λ x → rUnitₖ 1 x i) p ∙ cong (λ x → lUnitₖ 1 x i) q)
inv theIso a = ∣ (F⁻ (base , a)) ∣₂
rightInv theIso a = cong snd (Iso.rightInv S¹→S¹≡S¹×Int (base , a))
leftInv theIso = sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ f → cong ((sRec setTruncIsSet ∣_∣₂)
∘ sRec setTruncIsSet λ x → ∣ F⁻ (x , (snd (F f))) ∣₂)
(Iso.inv PathIdTrunc₀Iso (isConnectedS¹ (fst (F f))))
∙ cong ∣_∣₂ (Iso.leftInv S¹→S¹≡S¹×Int f)
---------------------------- Hⁿ(Sⁿ) ≅ ℤ , n ≥ 1 -------------------
{-
The proof of the inductive step below is a compact version of the following equations. Let n ≥ 1.
Hⁿ⁺¹(Sⁿ⁺¹) := ∥ Sⁿ⁺¹ → Kₙ₊₁ ∥₂
≅ ∥ Σ[ (a , b) ∈ Kₙ₊₁ ] (Sⁿ → a ≡ b) ∥₂ (characterisation of functions from suspensions)
≅ ∥ Kₙ₊₁ × Kₙ₊₁ × (Sⁿ → ΩKₙ₊₁) ∥₂ (base change in ΩKₙ₊₁)
≅ ∥ Kₙ₊₁ ∥₂ × ∥ Kₙ₊₁ ∥₂ × ∥ (Sⁿ → ΩKₙ₊₁) ∥₂
≅ ∥ Sⁿ → ΩKₙ₊₁ ∥₂ (connectivity of Kₙ₊₁)
≅ ∥ Sⁿ → Kₙ ∥₂ (ΩKₙ₊₁ ≃ Kₙ)
:= Hⁿ(Sⁿ)
≅ ℤ (ind. hyp)
The inverse function Hⁿ(Sⁿ) → Hⁿ⁺¹(Sⁿ⁺¹) is just the function d from Mayer-Vietoris.
However, we can construct d⁻¹ directly in this case, thus avoiding computationally
heavier proofs concerning exact sequences. -}
Hⁿ-Sⁿ≅ℤ : (n : ℕ) → GroupIso (coHomGr (suc n) (S₊ (suc n))) intGroup
Hⁿ-Sⁿ≅ℤ zero = coHom1S1≃ℤ
Hⁿ-Sⁿ≅ℤ (suc n) = invGroupIso helper □ invGroupIso (coHom≅coHomΩ (suc n) _) □ (Hⁿ-Sⁿ≅ℤ n)
where
basePointInd : (p : _) (a : _)
→ (p (ptSn (suc n)) ≡ refl) → sym (rCancelₖ (2 + n) ∣ north ∣)
∙∙ (λ i → (elimFunSⁿ (suc n) n p) ((merid a ∙ sym (merid (ptSn (suc n)))) i) +ₖ ∣ north ∣)
∙∙ rCancelₖ (2 + n) ∣ north ∣
≡ p a
basePointInd p a prefl =
cong (λ z → sym z ∙∙ ((λ i → (elimFunSⁿ (suc n) n p) ((merid a ∙ sym (merid (ptSn (suc n)))) i) +ₖ ∣ north ∣)) ∙∙ z)
(transportRefl refl)
∙∙ sym (rUnit _)
∙∙ (λ j i → rUnitₖ (2 + n) (elimFunSⁿ (suc n) n p ((merid a ∙ sym (merid (ptSn (suc n)))) i)) j)
∙∙ congFunct (elimFunSⁿ (suc n) n p) (merid a) (sym (merid (ptSn (suc n))))
∙∙ (cong (p a ∙_) (cong sym prefl)
∙ sym (rUnit (p a)))
helper : GroupIso (coHomGrΩ (suc n) (S₊ (suc n))) (coHomGr (2 + n) (S₊ (2 + n)))
fun (map helper) = sMap λ f → λ { north → ∣ north ∣
; south → ∣ north ∣
; (merid a i) → f a i}
isHom (map helper) =
sElim2 (λ _ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ f g → cong ∣_∣₂ (funExt λ { north → refl
; south → refl
; (merid a i) j → ∙≡+₂ n (f a) (g a) j i})
inv helper = sMap λ f x → sym (rCancelₖ (2 + n) (f north))
∙∙ (λ i → f ((merid x ∙ sym (merid (ptSn (suc n)))) i) -ₖ f north)
∙∙ rCancelₖ (2 + n) (f north)
rightInv helper =
coHomPointedElimSⁿ (suc n) n (λ _ → setTruncIsSet _ _)
λ p → trRec (isProp→isOfHLevelSuc n (setTruncIsSet _ _))
(λ prefl → cong ∣_∣₂ (funExt λ {north → refl
; south → refl
; (merid a i) j → basePointInd p a prefl j i}))
(Iso.fun (PathIdTruncIso _)
(isOfHLevelSuc 0 (isConnectedPathKn _ ∣ north ∣ ∣ north ∣)
(∣ p (ptSn (suc n)) ∣) ∣ refl ∣))
leftInv helper =
sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ f → (trRec (isProp→isOfHLevelSuc n (setTruncIsSet _ _))
(λ frefl → cong ∣_∣₂ (funExt λ x → basePointInd f x frefl))
((Iso.fun (PathIdTruncIso _)
(isOfHLevelSuc 0 (isConnectedPathKn _ ∣ north ∣ ∣ north ∣)
(∣ f (ptSn (suc n)) ∣) ∣ refl ∣))))
|
programs/oeis/107/A107869.asm | neoneye/loda | 22 | 92331 | <gh_stars>10-100
; A107869: Column 1 of triangle A107867; a(n) = binomial( n*(n+1)/2 + n+1, n).
; 1,3,15,120,1365,20349,376740,8347680,215553195,6358402050,210980549208,7778680504140,315502265971620,13961746143269400,669413654240461560,34569147570568156800,1912924003884628655655,112923282067713332728110
mov $1,$0
add $0,2
bin $0,2
bin $0,$1
|
test/platform.adb | treggit/sdlada | 89 | 22838 | with SDL;
with SDL.CPUS;
with SDL.Log;
with SDL.Platform;
with System;
use type System.Bit_Order;
procedure Platform is
Endian : System.Bit_Order renames System.Default_Bit_Order;
begin
SDL.Log.Set (Category => SDL.Log.Application, Priority => SDL.Log.Debug);
SDL.Log.Put_Debug ("This system is running : " & SDL.Platform.Platforms'Image (SDL.Platform.Get));
-- Endian-ness.
SDL.Log.Put_Debug ("Bit Order : " & System.Bit_Order'Image (Endian));
SDL.Log.Put_Debug ("...in other words : " &
(if Endian = System.High_Order_First then "Big-endian" else "Little-endian"));
-- CPU Info.
SDL.Log.Put_Debug ("CPU count : " & Positive'Image (SDL.CPUS.Count));
SDL.Log.Put_Debug ("CPU cache line size : " & Positive'Image (SDL.CPUS.Cache_Line_Size));
SDL.Log.Put_Debug ("RDTSC : " & Boolean'Image (SDL.CPUS.Has_RDTSC));
SDL.Log.Put_Debug ("AltiVec : " & Boolean'Image (SDL.CPUS.Has_AltiVec));
SDL.Log.Put_Debug ("3DNow! : " & Boolean'Image (SDL.CPUS.Has_3DNow));
SDL.Log.Put_Debug ("SSE : " & Boolean'Image (SDL.CPUS.Has_SSE));
SDL.Log.Put_Debug ("SSE2 : " & Boolean'Image (SDL.CPUS.Has_SSE_2));
SDL.Log.Put_Debug ("SSE3 : " & Boolean'Image (SDL.CPUS.Has_SSE_3));
SDL.Log.Put_Debug ("SSE4.1 : " & Boolean'Image (SDL.CPUS.Has_SSE_4_1));
SDL.Log.Put_Debug ("SSE4.2 : " & Boolean'Image (SDL.CPUS.Has_SSE_4_2));
SDL.Finalise;
end Platform;
|
Cubical/Displayed/Properties.agda | FernandoLarrain/cubical | 1 | 2519 | {-# OPTIONS --safe #-}
module Cubical.Displayed.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence using (pathToEquiv; univalence; ua-ungluePath-Equiv)
open import Cubical.Data.Unit
open import Cubical.Data.Sigma
open import Cubical.Relation.Binary
open BinaryRelation
open import Cubical.Displayed.Base
private
variable
ℓ ℓA ℓA' ℓP ℓ≅A ℓ≅A' ℓB ℓB' ℓ≅B ℓ≅B' ℓC ℓ≅C : Level
-- induction principles
module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) where
open UARel 𝒮-A
𝒮-J : {a : A}
(P : (a' : A) → (p : a ≡ a') → Type ℓ)
(d : P a refl)
{a' : A}
(p : a ≅ a')
→ P a' (≅→≡ p)
𝒮-J {a} P d {a'} p
= J (λ y q → P y q)
d
(≅→≡ p)
𝒮-J-2 : {a : A}
(P : (a' : A) → (p : a ≅ a') → Type ℓ)
(d : P a (ρ a))
{a' : A}
(p : a ≅ a')
→ P a' p
𝒮-J-2 {a = a} P d {a'} p
= subst (λ r → P a' r) (Iso.leftInv (uaIso a a') p) g
where
g : P a' (≡→≅ (≅→≡ p))
g = 𝒮-J (λ y q → P y (≡→≅ q)) d p
-- constructors
module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A}
{B : A → Type ℓB}
(_≅ᴰ⟨_⟩_ : {a a' : A} → B a → UARel._≅_ 𝒮-A a a' → B a' → Type ℓ≅B)
where
open UARel 𝒮-A
-- constructor that reduces ua to the case where p = ρ a by induction on p
private
𝒮ᴰ-make-aux : (uni : {a : A} (b b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ (b ≡ b'))
→ ({a a' : A} (b : B a) (p : a ≅ a') (b' : B a') → (b ≅ᴰ⟨ p ⟩ b') ≃ PathP (λ i → B (≅→≡ p i)) b b')
𝒮ᴰ-make-aux uni {a} {a'} b p
= 𝒮-J-2 𝒮-A
(λ y q → (b' : B y) → (b ≅ᴰ⟨ q ⟩ b') ≃ PathP (λ i → B (≅→≡ q i)) b b')
(λ b' → uni' b')
p
where
g : (b' : B a) → (b ≡ b') ≡ PathP (λ i → B (≅→≡ (ρ a) i)) b b'
g b' = subst (λ r → (b ≡ b') ≡ PathP (λ i → B (r i)) b b')
(sym (Iso.rightInv (uaIso a a) refl))
refl
uni' : (b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ PathP (λ i → B (≅→≡ (ρ a) i)) b b'
uni' b' = compEquiv (uni b b') (pathToEquiv (g b'))
𝒮ᴰ-make-1 : (uni : {a : A} (b b' : B a) → b ≅ᴰ⟨ ρ a ⟩ b' ≃ (b ≡ b'))
→ DUARel 𝒮-A B ℓ≅B
DUARel._≅ᴰ⟨_⟩_ (𝒮ᴰ-make-1 uni) = _≅ᴰ⟨_⟩_
DUARel.uaᴰ (𝒮ᴰ-make-1 uni) = 𝒮ᴰ-make-aux uni
-- constructor that reduces univalence further to contractibility of relational singletons
𝒮ᴰ-make-2 : (ρᴰ : {a : A} → isRefl _≅ᴰ⟨ ρ a ⟩_)
(contrTotal : (a : A) → contrRelSingl _≅ᴰ⟨ ρ a ⟩_)
→ DUARel 𝒮-A B ℓ≅B
𝒮ᴰ-make-2 ρᴰ contrTotal = 𝒮ᴰ-make-1 (contrRelSingl→isUnivalent _ ρᴰ (contrTotal _))
-- relational isomorphisms
𝒮-iso→iso : {A : Type ℓA} (𝒮-A : UARel A ℓ≅A)
{B : Type ℓB} (𝒮-B : UARel B ℓ≅B)
(F : RelIso (UARel._≅_ 𝒮-A) (UARel._≅_ 𝒮-B))
→ Iso A B
𝒮-iso→iso 𝒮-A 𝒮-B F
= RelIso→Iso (UARel._≅_ 𝒮-A)
(UARel._≅_ 𝒮-B)
(UARel.≅→≡ 𝒮-A)
(UARel.≅→≡ 𝒮-B)
F
-- fiberwise relational isomorphisms
module _ {A : Type ℓA} {𝒮-A : UARel A ℓ≅A}
{A' : Type ℓA'} {𝒮-A' : UARel A' ℓ≅A'}
(F : Iso A A')
{B : A → Type ℓB} (𝒮ᴰ-B : DUARel 𝒮-A B ℓ≅B)
{B' : A' → Type ℓB'} (𝒮ᴰ-B' : DUARel 𝒮-A' B' ℓ≅B') where
open UARel 𝒮-A
open DUARel 𝒮ᴰ-B renaming (_≅ᴰ⟨_⟩_ to _≅B⟨_⟩_
; uaᴰ to uaB
; fiberRel to fiberRelB
; uaᴰρ to uaᴰρB)
open DUARel 𝒮ᴰ-B' renaming (_≅ᴰ⟨_⟩_ to _≅B'⟨_⟩_
; uaᴰ to uaB'
; fiberRel to fiberRelB'
; uaᴰρ to uaᴰρB')
private
f = Iso.fun F
-- the following can of course be done slightly more generally
-- for fiberwise binary relations
F*fiberRelB' : (a : A) → Rel (B' (f a)) (B' (f a)) ℓ≅B'
F*fiberRelB' a = fiberRelB' (f a)
module _ (G : (a : A) → RelIso (fiberRelB a) (F*fiberRelB' a)) where
private
fiberIsoOver : (a : A) → Iso (B a) (B' (f a))
fiberIsoOver a
= RelIso→Iso (fiberRelB a)
(F*fiberRelB' a)
(equivFun (uaᴰρB _ _))
(equivFun (uaᴰρB' _ _))
(G a)
-- DUARelFiberIsoOver→TotalIso produces an isomorphism of total spaces
-- from a relational isomorphism between B a and (F * B) a
𝒮ᴰ-fiberIsoOver→totalIso : Iso (Σ A B) (Σ A' B')
𝒮ᴰ-fiberIsoOver→totalIso = Σ-cong-iso F fiberIsoOver
|
src/third_party/nasm/travis/test/align13.asm | Mr-Sheep/naiveproxy | 2,219 | 8289 | <reponame>Mr-Sheep/naiveproxy
; Test of non-power-of-2 alignment
bits 32
inc eax
inc eax
align 13
inc eax
inc eax
align 13
inc eax
inc eax
align 13
align 13 ;should do nothing
inc eax
inc eax
|
test/data/input/unnecessary-jumps-2.asm | CDPcode/optimips-prime | 0 | 241898 | <gh_stars>0
j L0
add $v0, $a0, $t0
L0:
beqz $v0, L1
add $v0, $a0, $t0
L1:
add $v0, $a0, $t0
|
Function/Iteration.agda | Lolirofle/stuff-in-agda | 6 | 10212 | <filename>Function/Iteration.agda
module Function.Iteration where
open import Data
open import Functional
open import Numeral.Natural
open import Type
open import Syntax.Number
module _ {ℓ} {T : Type{ℓ}} where
-- Repeated function composition
-- Example:
-- f ^ 0 = id
-- f ^ 1 = f
-- f ^ 2 = f ∘ f
-- f ^ 3 = f ∘ f ∘ f
-- f ^ 4 = f ∘ f ∘ f ∘ f
_^_ : (T → T) → ℕ → (T → T)
_^_ f 𝟎 = id
_^_ f (𝐒(n)) = f ∘ (f ^ n)
_⁰ : (T → T) → (T → T)
_⁰ = _^ 0
_¹ : (T → T) → (T → T)
_¹ = _^ 1
_² : (T → T) → (T → T)
_² = _^ 2
_³ : (T → T) → (T → T)
_³ = _^ 3
_⁴ : (T → T) → (T → T)
_⁴ = _^ 4
_⁵ : (T → T) → (T → T)
_⁵ = _^ 5
_⁶ : (T → T) → (T → T)
_⁶ = _^ 6
_⁷ : (T → T) → (T → T)
_⁷ = _^ 7
_⁸ : (T → T) → (T → T)
_⁸ = _^ 8
_⁹ : (T → T) → (T → T)
_⁹ = _^ 9
module _ {ℓ₁}{ℓ₂} {X : Type{ℓ₁}} {Y : Type{ℓ₂}} where
-- Repeat a binary operation n times for the same element and an initial element
-- Example: repeatₗ 3 id (_∘_) f = ((id ∘ f) ∘ f) ∘ f
-- Example in Haskell: (foldl (.) (id) (take 5 (repeat f)))
-- Implementation in Haskell: (\n null op elem -> foldl op null (take n (repeat elem))) :: Int -> a -> (b -> a -> b) -> b -> b
repeatₗ : ℕ → (Y → X → Y) → (Y → X → Y)
repeatₗ n (_▫_) null elem = ((_▫ elem) ^ n) (null)
-- Repeat a binary operation n times for the same element and an initial element
-- Example: repeatᵣ 3 id (_∘_) f = f ∘ (f ∘ (f ∘ id))
-- Implementation in Haskell: (\n elem op null -> foldr op null (take n (repeat elem))) :: Int -> a -> (a -> b -> b) -> b -> b
repeatᵣ : ℕ → (X → Y → Y) → (X → Y → Y)
repeatᵣ n (_▫_) elem = (elem ▫_) ^ n
module _ {ℓ} {X : Type{ℓ}} where
-- Repeat a binary operation n times for the same element and using the default element on zero.
-- Examples:
-- repeatₗ 0 def (_∘_) f = def
-- repeatₗ 1 def (_∘_) f = f
-- repeatₗ 4 def (_∘_) f = ((f ∘ f) ∘ f) ∘ f
repeatₗ-default : ℕ → (X → X → X) → X → (X → X)
repeatₗ-default 𝟎 _ def _ = def
repeatₗ-default (𝐒(n)) (_▫_) _ elem = repeatₗ(n) (_▫_) elem elem
-- Repeat a binary operation n times for the same element and using the default element on zero.
-- Examples:
-- repeatᵣ 0 f (_∘_) def = def
-- repeatᵣ 1 f (_∘_) def = f
-- repeatᵣ 4 f (_∘_) def = f ∘ (f ∘ (f ∘ f))
repeatᵣ-default : ℕ → (X → X → X) → X → (X → X)
repeatᵣ-default 𝟎 _ _ def = def
repeatᵣ-default (𝐒(n)) (_▫_) elem _ = repeatᵣ(n) (_▫_) elem elem
|
Appl/FileMgrs2/CommonDesktop/CMain/cmainDiskOps.asm | steakknife/pcgeos | 504 | 105364 | COMMENT @----------------------------------------------------------------------
Copyright (c) GeoWorks 1988 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Desktop/Main
FILE: mainDiskOps.asm
ROUTINES:
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 12/89 Initial version
DESCRIPTION:
This file contains code to handle disk copy and disk format.
$Id: cmainDiskOps.asm,v 1.2 98/06/03 13:37:08 joon Exp $
------------------------------------------------------------------------------@
DiskCode segment resource
if _GMGR
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DiskStartDiskFormatBox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: bring up format disk box
CALLED BY: MSG_META_START_DISK_FORMAT_BOX
PASS:
RETURN:
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 04/28/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DiskStartDiskFormatBox method DesktopClass, MSG_META_START_DISK_FORMAT_BOX
call ShowHourglass
;
; set up media-type list in dialog
;
mov bx, handle DiskFormatSourceList
mov si, offset DiskFormatSourceList
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
call ObjMessageCallFixup ; ax = selection
mov cx, ax ; cx = selection
mov ax, MSG_DISK_FORMAT_SOURCE_DRIVE
mov bx, handle 0 ; bx = proces handle
call ObjMessageCallFixup ; fake apply msg
if not _ZMGR
;
; set QuickFormat option on or off according to Advanced Disk Options
;
mov bx, handle OptionsList
mov si, offset OptionsList
mov cx, mask OMI_SHOW_ADV_DISK_OPTIONS
mov ax, MSG_GEN_BOOLEAN_GROUP_IS_BOOLEAN_SELECTED
call ObjMessageCall
mov ax, MSG_GEN_SET_USABLE
jc gotMessage
mov ax, MSG_GEN_SET_NOT_USABLE
gotMessage:
mov dl, VUM_NOW
mov bx, handle DiskFormatQuickMode
mov si, offset DiskFormatQuickMode
call ObjMessageCall
endif ; if (not _ZMGR)
;
; bring up format box
;
mov bx, handle DiskFormatBox
mov si, offset DiskFormatBox
mov ax, MSG_GEN_INTERACTION_INITIATE
call ObjMessageFixup
call HideHourglass
ret
DiskStartDiskFormatBox endm
endif ; if _GMGR
if _GMGRONLY ; no disk copy and disk rename for GeoLauncher
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DiskStartDiskCopyBox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: bring up copy disk box
CALLED BY: MSG_META_START_DISK_COPY_BOX
PASS:
RETURN:
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 04/28/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DiskStartDiskCopyBox method DesktopClass, MSG_META_START_DISK_COPY_BOX
call ShowHourglass
;
; set up destination list in dialog
;
mov bx, handle DiskCopySourceList
mov si, offset DiskCopySourceList
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
call ObjMessageCallFixup ; ax = selection
mov cx, ax ; cx = selection
mov ax, MSG_DISK_COPY_SOURCE_DRIVE
mov bx, handle 0 ; bx = proces handle
call ObjMessageCallFixup ; fake apply msg
if not _ZMGR
;
; set Greedy option on or off according to Advanced Disk Options
;
mov bx, handle OptionsList
mov si, offset OptionsList
mov cx, mask OMI_SHOW_ADV_DISK_OPTIONS
mov ax, MSG_GEN_BOOLEAN_GROUP_IS_BOOLEAN_SELECTED
call ObjMessageCall
mov ax, MSG_GEN_SET_USABLE
jc gotMessage
mov ax, MSG_GEN_SET_NOT_USABLE
gotMessage:
mov dl, VUM_NOW
mov bx, handle DiskCopyGreedyOption
mov si, offset DiskCopyGreedyOption
call ObjMessageCall
endif ; if (not _ZMGR)
;
; bring up copy box
;
mov bx, handle DiskCopyBox
mov si, offset DiskCopyBox
mov ax, MSG_GEN_INTERACTION_INITIATE
call ObjMessageFixup
call HideHourglass
ret
DiskStartDiskCopyBox endm
endif ; if _GMGRONLY
if not _FCAB
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopDiskCopyCopy
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: handle disk copy
CALLED BY: MSG_DISK_COPY_COPY
PASS:
RETURN:
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 12/29/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopDiskCopyCopy method DesktopClass, MSG_DISK_COPY_COPY
call IndicateBusy
mov ss:[recurErrorFlag], 0 ; allows us to use common
; dialog box code
mov ss:[copyStatusMoniker], 0 ; prepare for status reporting
mov ss:[activeCopyStatusMoniker], 0
;
; get source drive number
;
GM< mov bx, handle DiskMenuResource ; bx:si = disk list >
GM< mov si, offset DiskMenuResource:DiskCopySourceList >
GM< mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION >
GM< call ObjMessageCall ; al = source drive number >
ND< mov ax, ss:[ndClickedOnDrive] ; ah = source media descriptor
push ax ; save 'em
;
; clear out progress fields
;
mov ax, DCC_REPORT_READ_PCT
mov dx, 1000
call CopyCallbackRoutine
;
; enable cancel button
;
clr ss:[cancelOperation] ; clear cancel flag
clr ss:[cancelMonikerToChange] ; no moniker to change
mov bx, handle CopyStatusCancel
mov si, offset CopyStatusCancel
mov ax, MSG_GEN_SET_ENABLED
mov dl, VUM_NOW
call ObjMessageCall
;
; get destination drive number
;
mov bx, handle DiskMenuResource ; bx:si = disk list
mov si, offset DiskMenuResource:DiskCopyDestList
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
call ObjMessageCall ; al = dest drive number
; ah = dest media descriptor
pop bx ; bl = source drive number
mov dh, bl ; dh = source
mov dl, al ; dl = dest
;
; Get greedy flag
;
push dx
mov bx, handle DiskMenuResource
mov si, offset DiskMenuResource:DiskCopyGreedyOption
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
call ObjMessageCall ; al <- DiskCopyFlags
pop dx
mov cx, SEGMENT_CS ; cx:bp = status callback
mov bp, offset CopyCallbackRoutine
push ax
mov ax, ACTIVE_TYPE_DISK_COPY
call DesktopMarkActive ; application will be active
pop ax
jnz done ; if already active, do nada
mov ss:[destinationInserted], FALSE
call DiskCopy
call MarkNotActive ; (preserves flags)
jc error ; error
mov ax, DISK_COPY_OK
error:
cmp ax, ERR_OPERATION_CANCELLED
jne afterCancelCheck
cmp ss:[destinationInserted], TRUE
je afterCancelCheck
mov ax, ERR_CANCEL_SANS_DEST
afterCancelCheck:
;
; make sure status box is down
;
push ax ; save results
mov bx, handle CopyStatusBox
mov si, offset CopyStatusBox
mov ax, MSG_GEN_GUP_INTERACTION_COMMAND
mov cx, IC_DISMISS
call ObjMessageCall
pop ax ; retrieve results
;
; report disk copy error or success
;
segmov ds, cs, si
mov si, offset CopyDiskErrorTable
FXIP< mov cx, (length CopyDiskErrorTable)*(size DesktopErrorTableEntry) >
FXIP< call SysCopyToStackDSSI ;ds:si = table on stack >
call DesktopErrorReporter ; else, report error
FXIP< call SysRemoveFromStack ;release stack space >
done:
call IndicateNotBusy
ret
DesktopDiskCopyCopy endm
;
; The following errors, which DiskCopy is capable of returning, should
; never come back to us, as we always pass valid data, to the best of our
; ability:
; - ERR_INVALID_SOURCE_DRIVE
; - ERR_INVALID_DEST_DRIVE
; - ERR_SOURCE_DRIVE_DOESNT_SUPPORT_DISK_COPY
; - ERR_DEST_DRIVE_DOESNT_SUPPORT_DISK_COPY
; - ERR_DRIVES_HOLD_DIFFERENT_FILESYSTEM_TYPES
; - FMT_CANNOT_FORMAT_FIXED_DISKS_IN_CUR_RELEASE
; - FMT_BAD_PARTITION_TABLE
; - FMT_ERR_READING_PARITION_TABLE
; - FMT_ERR_NO_PARTITION_FOUND
; - FMT_ERR_MULTIPLE_PRIMARY_PARTITIONS
; - FMT_ERR_NO_EXTENDED_PARTITION_FOUND
; - FMT_READY
; - FMT_RUNNING
; - FMT_ERR_DISK_UNAVAILABLE (applies only to network drives)
;
CopyDiskErrorTable DesktopErrorTableEntry \
<
DISK_COPY_OK,
CopyCopyOKStr,
mask DETF_NOTICE
>,
<
ERR_DISKCOPY_INSUFFICIENT_MEM,
CopyNoMemErrStr,
0
>,
<
FMT_ERR_CANNOT_ALLOC_SECTOR_BUFFER,
CopyNoMemErrStr,
0
>,
<
ERR_CANT_READ_FROM_SOURCE,
CopyReadErrStr,
0
>,
<
ERR_CANT_WRITE_TO_DEST,
CopyWriteErrStr,
0
>,
<
ERR_OPERATION_CANCELLED,
CopyCancelledErrStr,
mask DETF_NOTICE
>,
<
ERR_CANCEL_SANS_DEST,
CopyCancelSansDestErrStr,
mask DETF_NOTICE
>,
<
FMT_ABORTED,
CopyFmtFormatAbortedErrStr,
mask DETF_NOTICE
>,
<
FMT_DRIVE_NOT_READY,
CopyCantFormatDestErrStr,
0
>,
<
FMT_ERR_WRITING_BOOT,
CopyCantFormatDestErrStr,
0
>,
<
FMT_ERR_WRITING_ROOT_DIR,
CopyCantFormatDestErrStr,
0
>,
<
FMT_ERR_WRITING_FAT,
CopyCantFormatDestErrStr,
0
>,
<
FMT_SET_VOLUME_NAME_ERR,
CopyCantFormatDestErrStr,
0
>,
<
FMT_ERR_CANNOT_FORMAT_TRACK,
CopyCantFormatDestErrStr,
0
>,
<
FMT_ERR_DISK_IS_IN_USE,
CopyFmtErrDiskIsInUseStr,
0
>,
<
ERR_DISK_IS_IN_USE,
CopyFmtErrDiskIsInUseStr,
0
>,
<
FMT_ERR_WRITE_PROTECTED,
CopyFmtErrWriteProtectedStr,
0
>,
<
ERR_SOURCE_DISK_INCOMPATIBLE_WITH_DEST_DRIVE,
CopySourceDiskIncompatibleWithDestDriveStr,
0
>,
<
ERR_SOURCE_DISK_NOT_FORMATTED,
CopySourceDiskNotFormattedStr,
0
>,
<NIL>
CheckHack < length CopyDiskErrorTable eq 20>
endif ; if (not _FCAB)
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopDiskFormatFormat
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: handle disk format
CALLED BY: MSG_DISK_FORMAT_FORMAT
PASS:
RETURN:
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 12/29/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopDiskFormatFormat method DesktopClass, MSG_DISK_FORMAT_FORMAT
;
; See if should quick-format if possible.
;
mov bx, handle DiskMenuResource
mov si, offset DiskMenuResource:DiskFormatQuickMode
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
call ObjMessageCallFixup ; ax = DiskFormatFlags
push ax ; save DiskFormatFlags
;
; get drive number to format
;
GM< mov bx, handle DiskMenuResource ; bx:si = disk list >
GM< mov si, offset DiskMenuResource:DiskFormatSourceList >
GM< mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION >
GM< call ObjMessageCallFixup ; al = drive number >
ND< mov ax, ss:[ndClickedOnDrive] ; ah = media descriptor >
push ax ; save 'em
;
; get media format to use
;
mov bx, handle DiskMenuResource ; bx:si = media list
mov si, offset DiskMenuResource:DiskFormatMediaList
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
call ObjMessageCallFixup ; al = media type
pop bx ; bl = drive
; bh = media (max.)
mov ah, al ; ah = media
mov al, bl ; al = drive
pop cx ; DiskFormatFlags
if _PCMCIA_FORMAT
call DesktopDiskFormatCheckForPCMCIASpecialCases
jc done
endif
mov bp,cx ;DiskFormatFlags
mov cx,ax ;MediaType,drive number
mov dh,bh ;maxMedia
mov ax,MSG_DISK_FORMAT_FORMAT_LOW
mov bx, handle 0
call ObjMessageNone
if _PCMCIA_FORMAT
done:
endif
ret
DesktopDiskFormatFormat endp
if _PCMCIA_FORMAT
iniPCMCIAFormatCategory char "pcmciaFormat",0
iniPCMCIAFormatFlashCommandKey char "flashCommand",0
iniPCMCIAFormatFlashPreArgsKey char "flashPreArgs",0
iniPCMCIAFormatFlashPostArgsKey char "flashPostArgs",0
iniPCMCIAFormatATACommandKey char "ataCommand",0
iniPCMCIAFormatATAPreArgsKey char "ataPreArgs",0
iniPCMCIAFormatATAPostArgsKey char "ataPostArgs",0
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopDiskFormatCheckForPCMCIASpecialCases
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Check for PCMCIA MediaTypes that require special processing.
Performing processing if necessary
CALLED BY: INTERNAL
DesktopDiskFormatFormat
PASS: ah - MediaType
al - drive number
bh - max. media
cx - DiskFormatFlags
RETURN:
stc - don't call DesktopDiskFormatFormatLow
clc - proceed as normal
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 9/16/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopDiskFormatCheckForPCMCIASpecialCases proc near
command local PathName
args local PathName ;this should be big enough
driveNumber local byte
commandOffset local word
preArgsOffset local word
postArgsOffset local word
ForceRef command
ForceRef args
ForceRef commandOffset
ForceRef preArgsOffset
ForceRef postArgsOffset
.enter
mov driveNumber,al
cmp ah, MEDIA_FLASH
je mediaFlash
cmp ah, MEDIA_ATA
je mediaATA
clc
done:
.leave
ret
mediaFlash:
call DesktopDiskFormatFormatFlash
stc
jmp done
mediaATA:
call DesktopDiskFormatFormatATA
stc
jmp done
DesktopDiskFormatCheckForPCMCIASpecialCases endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopDiskFormatFormatFlash
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Setup vardata and make dos call to format a FLASH pcmcia
card
CALLED BY: INTERNAL
DesktopDiskFormatCheckForPCMCIASpecialCases
PASS: ah = MEDIA_FLASH
bh - max. media
cx - DiskFormatFlags
inherited stack frame
driveNumber - set
RETURN:
nothing
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 9/14/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopDiskFormatFormatFlash proc near
uses ax,bx,cx,dx,di,si
.enter inherit DesktopDiskFormatCheckForPCMCIASpecialCases
; Let user know what is happening.
; This isn't an error but the it does what I want it to.
;
mov ax,FORMAT_PCMCIA_EXIT_TO_DOS_LONG
call DesktopOKError
; Get Dos command and execute it
;
mov cx,offset iniPCMCIAFormatFlashCommandKey
mov commandOffset, cx
mov cx,offset iniPCMCIAFormatFlashPreArgsKey
mov preArgsOffset, cx
mov cx,offset iniPCMCIAFormatFlashPostArgsKey
mov postArgsOffset, cx
call DesktopDiskFormatGetPCMCIAFormatCommand
EC < jc iniError
NEC < jc errorDB
call DesktopDiskFormatPCMCIADosExec
EC < jc dosExecError
NEC < jc errorDB
; Add vardata to the application object so that we
; will know on startup that we exited to format a flash card
;
push bp
sub sp,size AddVarDataParams
mov bp,sp
clrdw ss:[bp].AVDP_data
mov ss:[bp].AVDP_dataSize, 0
mov ss:[bp].AVDP_dataType, ATTR_DESKTOP_FORMATTING_FLASH_CARD or \
mask VDF_SAVE_TO_STATE ;duh
mov dx,size AddVarDataParams
mov bx,handle Desktop
mov si,offset Desktop
mov di,mask MF_STACK or mask MF_CALL
mov ax,MSG_META_ADD_VAR_DATA
call ObjMessage
add sp,size AddVarDataParams
pop bp ;locals
done:
.leave
ret
if ERROR_CHECK
iniError:
WARNING < WARNING_MISSING_INI_FILE_STUFF_FOR_PCMCIA_FORMAT >
jmp errorDB
dosExecError:
WARNING < WARNING_MISSING_INI_FILE_STUFF_FOR_PCMCIA_FORMAT >
jmp errorDB
endif
errorDB:
mov ax,ERROR_UNABLE_TO_EXECUTE_DOS_PROGRAM_TO_FORMAT_PCMCIA
call DesktopOKError
jmp done
DesktopDiskFormatFormatFlash endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopDiskFormatFormatATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Setup vardata and make dos call to format a ATA pcmcia
card
CALLED BY: INTERNAL
DesktopDiskFormatCheckForPCMCIASpecialCases
PASS: ah = MEDIA_ATA
bh - max. media
cx - DiskFormatFlags
inherited stack frame
driveNumber - set
RETURN:
nothing
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 9/14/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopDiskFormatFormatATA proc near
uses ax,bx,cx,dx,di,si
.enter inherit DesktopDiskFormatCheckForPCMCIASpecialCases
; Hey, there is an add sp,4 at errorDB: later in this
; routine to clear the stack. If you change what is pushed
; then fix the add.
;
push bx,cx ;passed info
; Let user know what is happening.
; This isn't an error but the it does what I want it to.
;
mov ax,FORMAT_PCMCIA_EXIT_TO_DOS_SHORT
call DesktopOKError
; Get Dos command and execute it
;
mov cx,offset iniPCMCIAFormatATACommandKey
mov commandOffset,cx
mov cx,offset iniPCMCIAFormatATAPreArgsKey
mov preArgsOffset,cx
mov cx,offset iniPCMCIAFormatATAPostArgsKey
mov postArgsOffset,cx
call DesktopDiskFormatGetPCMCIAFormatCommand
EC < jc iniError
NEC < jc errorDB
call DesktopDiskFormatPCMCIADosExec
EC < jc dosExecError
NEC < jc errorDB
; Add vardata to the application object so that we
; will know on startup that we exited to format an
; ata card
;
pop bx,cx ;passed info
mov al,driveNumber
push bp
sub sp,size DesktopFormattingATACard
mov di,sp
sub sp,size AddVarDataParams
mov bp,sp
movdw ss:[bp].AVDP_data,ssdi ;fptr to DFAC struct
mov ss:[bp].AVDP_dataSize, size DesktopFormattingATACard
mov ss:[bp].AVDP_dataType, ATTR_DESKTOP_FORMATTING_ATA_CARD or \
mask VDF_SAVE_TO_STATE ;duh
mov ss:[di].DFAC_driveNumber,al
mov ss:[di].DFAC_maxMedia,bh
mov ss:[di].DFAC_diskFormatFlags,cx
mov dx,size AddVarDataParams
mov bx,handle Desktop
mov si,offset Desktop
mov di,mask MF_STACK or mask MF_CALL ;must do call
mov ax,MSG_META_ADD_VAR_DATA
call ObjMessage
add sp,size DesktopFormattingATACard + size AddVarDataParams
pop bp ;locals
done:
.leave
ret
if ERROR_CHECK
iniError:
WARNING < WARNING_MISSING_INI_FILE_STUFF_FOR_PCMCIA_FORMAT >
jmp errorDB
dosExecError:
WARNING < WARNING_MISSING_INI_FILE_STUFF_FOR_PCMCIA_FORMAT >
jmp errorDB
endif
errorDB:
add sp,4 ;clear passed info
mov ax,ERROR_UNABLE_TO_EXECUTE_DOS_PROGRAM_TO_FORMAT_PCMCIA
call DesktopOKError
jmp done
DesktopDiskFormatFormatATA endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopDiskFormatGetPCMCIAFormatCommand
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Fill in stack frame with command name and args
CALLED BY: INTERNAL
DesktopDiskFormatFormatFlash
DesktopDiskFormatFormatATA
PASS:
inherited stack frame
RETURN:
clc - no error
stc - couldn't find ini category or key or bad drive number
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 9/16/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopDiskFormatGetPCMCIAFormatCommand proc near
uses ax,bx,cx,dx,di,si,ds,es
.enter inherit DesktopDiskFormatCheckForPCMCIASpecialCases
; Get command to execute from ini file
;
push bp ;locals
mov ax,ss
mov es,ax ;destination
lea di, command
mov si,offset iniPCMCIAFormatCategory
mov dx,commandOffset
mov cx,cs
mov ds,cx
mov bp, (IFCC_INTACT shl offset IFRF_CHAR_CONVERT) or \
(size PathName shl offset IFRF_SIZE)
call InitFileReadString
pop bp ;locals
jc done ;bail if error
; Get arguments to put before the drive letter and
; curse the boneheads at msystem while you are at it.
;
push bp ;locals
lea di, args ;dest buffer offset
mov dx, preArgsOffset
mov cx,cs
mov bp, (IFCC_INTACT shl offset IFRF_CHAR_CONVERT) or \
(size PathName shl offset IFRF_SIZE)
call InitFileReadString
pop bp ;locals
; Put a space after the preArgs, if there are any
;
jcxz getDriveName ;number of chars in pre args
add di,cx ;after preArgs
mov al,C_SPACE
stosb
getDriveName:
; Put drive name plus : and a space at current position of args
;
mov al,driveNumber
neg cx ;bytes in args already used
add cx, size args ;bytes available in args
call DriveGetName
jc done
mov ax,C_COLON or (C_SPACE shl 8)
stosw
; Get args to use after driver letter from ini file
;
push bp ;locals
mov dx, postArgsOffset
mov cx,cs
mov bp, (IFCC_INTACT shl offset IFRF_CHAR_CONVERT) or \
(size PathName shl offset IFRF_SIZE)
call InitFileReadString
pop bp ;locals
jc noPostArgs
done:
.leave
ret
noPostArgs:
; If no postArgs then null terminate the args string
;
clr al
stosb
clc ;success
jmp done
DesktopDiskFormatGetPCMCIAFormatCommand endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopDiskFormatPCMCIADosExec
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Execute the dos command in the passed stack frame to
format or prepare for format a PCMCIA card
CALLED BY: INTERNAL
DesktopDiskFormatFormatFlash
DesktopDiskFormatFormatATA
PASS: inherited stack frame
RETURN:
clc - ok
ax - Destroyed
stc - couldn't run dos program
ax - FileError
DESTROYED:
see RETURN
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 9/16/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopDiskFormatPCMCIADosExec proc near
uses bx,cx,si,di,ds,es
.enter inherit DesktopDiskFormatCheckForPCMCIASpecialCases
push bp ;locals
clr bx ;no disk handle
mov ax,ss
mov ds,ax ;command string segment
lea si, command
mov es,ax ;args string segment
lea di, args
clr ax,bp,dx ;no execute path
mov cx,mask DEF_FORCED_SHUTDOWN
call DosExec
pop bp ;locals
.leave
ret
DesktopDiskFormatPCMCIADosExec endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopHandlePCMCIAFormatOnOpenComplete
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Check for vardata that indicates that we shutdown to
format a pcmcia card.
CALLED BY: INTERNAL
DesktopOpenComplete
PASS: *ds:si - Desktop
RETURN:
nothing
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 9/21/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopHandlePCMCIAFormatOnOpenComplete proc far
uses ax,bx
.enter
mov ax,ATTR_DESKTOP_FORMATTING_FLASH_CARD
call ObjVarFindData
jc mediaFlash
mov ax,ATTR_DESKTOP_FORMATTING_ATA_CARD
call ObjVarFindData
jc mediaATA
done:
.leave
ret
mediaFlash:
call DesktopCompletePCMCIAFlashFormat
jmp done
mediaATA:
call DesktopCompletePCMCIAATAFormat
jmp done
DesktopHandlePCMCIAFormatOnOpenComplete endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopCompletePCMCIAFlashFormat
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Complete formatting of PCMCIA Flash card. Notify
user of any error condition
CALLED BY: INTERNAL
DesktopHandlePCMCIAFormatOnOpenComplete
PASS: *ds:si - Desktop
ds:bx - ATTR_DESKTOP_FORMATTING_FLASH_CARD vardata
RETURN:
nothing
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 9/21/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopCompletePCMCIAFlashFormat proc near
uses ax,di,si,cx,dx
.enter
mov ax,ATTR_DESKTOP_FORMATTING_FLASH_CARD
call ObjVarDeleteData
mov di,offset flashFormatTerminationCodes
mov si,offset flashFormatErrorNumbers
mov cx,length flashFormatTerminationCodes
mov dx,FORMAT_PCMCIA_FAILED_FOR_UNKNOWN_REASON
call DesktopDiskFormatDisplayPCMCIAFormatResults
.leave
ret
DesktopCompletePCMCIAFlashFormat endp
; Success must be first entry in table
;
flashFormatTerminationCodes byte \
0,
1,
2,
3,
5,
7,
8,
9,
10,
11,
12,
13,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31
flashFormatErrorNumbers word \
FORMAT_PCMCIA_FLASH_SUCCESSFUL,
FORMAT_PCMCIA_WRITE_PROTECTED,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER,
FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER
CheckHack <length flashFormatTerminationCodes eq length flashFormatErrorNumbers>
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopCompletePCMCIAATAFormat
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Complete formatting of PCMCIA ATA card. Notify
user of any error condition
CALLED BY: INTERNAL
DesktopHandlePCMCIAFormatOnOpenComplete
PASS: *ds:si - Desktop
ds:bx - ATTR_DESKTOP_FORMATTING_ATA_CARD vardata
RETURN:
nothing
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 9/21/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopCompletePCMCIAATAFormat proc near
uses ax,bx,cx,dx,di,si
.enter
; Get info needed to complete formating of card
;
mov ch,MEDIA_ATA
mov cl,ds:[bx].DFAC_driveNumber
mov bp,ds:[bx].DFAC_diskFormatFlags
ornf bp, mask DFF_FORCE_ERASE
mov dh,ds:[bx].DFAC_maxMedia
push cx,dx,si ;formatting info, Desktop chunk
mov di,offset ataFormatTerminationCodes
mov si,offset ataFormatErrorNumbers
mov cx, length ataFormatTerminationCodes
mov dx,PARTITION_PCMCIA_ATA_FAILED
call DesktopDiskFormatDisplayPCMCIAFormatResults
pop cx,dx,si ;formating info, Desktop chunk
jnc nukeVarData
; Complete formatting of card on the process thread
;
call GeodeGetProcessHandle
mov di,mask MF_FIXUP_DS
mov ax,MSG_DISK_FORMAT_FORMAT_LOW
call ObjMessage
nukeVarData:
mov ax,ATTR_DESKTOP_FORMATTING_ATA_CARD
call ObjVarDeleteData
.leave
ret
DesktopCompletePCMCIAATAFormat endp
; Success must be first entry in table
;
ataFormatTerminationCodes byte \
0
ataFormatErrorNumbers word \
0 ;don't display anything
CheckHack <length ataFormatTerminationCodes eq length ataFormatErrorNumbers>
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopDiskFormatDisplayPCMCIAFormatResults
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the dos termination code and display success or
failure messages.
CALLED BY: INTERNAL
PASS: di - offset from cs to child termination code table
si - offset from cs to DesktopErrors table
cx - length in bytes of child termination code table
dx - DesktopErrors number to use if parent
termination code is non zero or child termination
code cannot be found
RETURN:
stc - success
clc - fail
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 9/21/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopDiskFormatDisplayPCMCIAFormatResults proc near
uses ax,bx,cx,dx,di,si,es
termCode local byte
.enter
; Get termination code
;
mov ah,0x4d
call FileInt21
mov termCode,ah ;parent termination code
tst ah
jnz unknownFailure
mov termCode,al ;child termination code
; Search termination code table
;
segmov es,cs
mov bx,di ;save original offset
repne scasb
jnz unknownFailure
; Convert byte offset that is one byte past found
; termination code to word offset and point into
; DesktopErrors table.
;
sub di,bx ;subtract original offset
dec di
shl di,1
add si,di
; Get DesktopErrors from table. If it is zero then
; bail with out displaying anything
;
mov ax,es:[si]
tst ax
jz noError
; If was first "error" in table, then we were actually
; successful.
;
tst di
jnz failureOKError
call DesktopOKError
noError:
stc
done:
.leave
ret
unknownFailure:
mov ax,dx
failureOKError:
clr dx ;assume no string block
cmp ax,FORMAT_PCMCIA_FAILED_DISPLAY_ERROR_NUMBER
je createNumberString
failureError:
call DesktopOKError
failure:
clc
jmp done
createNumberString:
; Alloc a block and put the string representing the numeric
; error in it. This is for display with DesktopOKError.
;
mov cl,termCode
call CreateNumericStringBlock
jc failure
jmp failureError
DesktopDiskFormatDisplayPCMCIAFormatResults endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateNumericStringBlock
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Allocate a block and put the asiic termination code string in it
CALLED BY: INTERNAL
DesktopDiskFormatDisplayPCMCIAFormatResults
PASS:
cl - termination code
RETURN:
clc - block created
dx - block handle
stc - block not created
dx - 0
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 10/18/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateNumericStringBlock proc near
uses ax,bx,cx,es
.enter
mov dl,cl ;save termination code
mov ax,UHTA_NULL_TERM_BUFFER_SIZE
mov cx,mask HF_SHARABLE or (mask HAF_LOCK shl 8)
call MemAlloc
jc failed
mov es,ax
mov al,dl ;term code low word low byte
clr ah ;term code low word high byte
clr dx,di ;term code high word, buffer offset
mov cx,mask UHTAF_NULL_TERMINATE
call UtilHex32ToAscii
call MemUnlock
mov dx,bx
clc
done:
.leave
ret
failed:
clr dx
stc
jmp done
CreateNumericStringBlock endp
endif ;_PCMCIA_FORMAT
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopDiskFormatFormatLow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Format a disk using DiskFormat given the media, drive, etc.
This routine does not perform any prep work, such as
partitioning MEDIA_ATA cards.
CALLED BY: INTERNAL
DesktopDiskFormatFormat
PASS: ch - MediaType
cl - drive number
dh - max. media
bp - DiskFormatFlags
RETURN:
nothing
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 9/13/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopDiskFormatFormatLow method DesktopClass, MSG_DISK_FORMAT_FORMAT_LOW
uses ax,cx,dx,bp
.enter
call IndicateBusy
push bp ;DiskFormatFlags
mov ax,cx ;MediaType, drive numer
mov bh,dh ;max media
;
; warn user about formatting low-density disks in high-density drive
; al = drive
; ah = media
; bh = max. media
;
cmp bh, MEDIA_1M2 ; 1.2M?
jne no1M2Warning ; nope, no warning needed
cmp ah, MEDIA_1M2 ; formatting as 1.2M?
je no1M2Warning ; yes, no warning needed
push ax ; save drive/media
mov ax, WARNING_FORMAT_LO_IN_HI ; else, give warning
call DesktopYesNoWarning
cmp ax, YESNO_YES
pop ax ; retreive drive/media
jne done_JMP_pop
no1M2Warning:
;
; user wants to format, prompt for volume name
;
askForName:
push ax ; save drive, media
mov bx, handle DiskMenuResource
mov si, offset FormatVolumeEntry
;
; if nullVolumeName != 0, then the code for XIP have to change too.
;
NOFXIP < mov dx, cs ; dx:bp = null string >
NOFXIP < mov bp, offset nullVolumeName >
FXIP < clr bp >
FXIP < push bp >
FXIP < mov dx, ss >
FXIP < mov bp, sp ;dx:bp = null str on stack >
call CallFixupSetText ; clear last volume name
FXIP < pop bp >
mov {byte} ss:[formatVolumeName], 0 ; clear volume name buffer
SBCS < mov {byte} ss:[formatVolumeName], 0 ; clear volume name buffer>
DBCS < mov {wchar} ss:[formatVolumeName], 0 ; clear volume name buffer>
mov si, offset FormatVolumeBox
call UserDoDialog ; put up volume name box
; (ax = 0 if DETACH)
cmp ax, OKCANCEL_OK
pop ax ; retrieve media, drive
je 111$ ; continue
done_JMP_pop:
pop ax ; discard DiskFormatFlags
jmp done ; user CANCEL'ed
111$:
;
; get volume entered
;
push ax ; save drive, media
FXIP< push ds >
FXIP< GetResourceSegmentNS dgroup, ds, TRASH_BX >
FXIP< mov dx, ds ; dx = dgroup >
FXIP< pop ds >
mov bx, handle DiskMenuResource
mov si, offset FormatVolumeEntry
mov ax, MSG_VIS_TEXT_GET_ALL_PTR
NOFXIP< mov dx, segment dgroup >
mov bp, offset formatVolumeName ; return volume name in buffer
call ObjMessageCallFixup ; get volume name
EC < cmp cx, VOLUME_NAME_LENGTH >
EC < ERROR_A ERROR_COPY_FORMAT_DISK >
;
; fix-up entered volume name
;
push ds
NOFXIP< mov si, segment dgroup >
FXIP< GetResourceSegmentNS dgroup, ds >
FXIP< segmov es, ds, si >
mov ds, si ; ds:si = volume name
mov es, si
mov si, offset formatVolumeName
spaceLoop:
SBCS < lodsb ; nuke leading spaces >
DBCS < lodsw ; nuke leading spaces >
SBCS < cmp al, ' ' >
DBCS < cmp ax, ' ' >
je spaceLoop
dec si ; point at first non-space
DBCS < dec si >
mov di, si ; es:di = final volume name
; ds:si = volume name
call CheckVolumeName ; C clr if okay, C set if error
; reported (ax = from
; DesktopOKError if C=1)
pop ds
jc badName
;
; if no volume name entered, smash user's head with brick
;
SBCS < cmp {byte} ss:[formatVolumeName], 0 ; null name? >
DBCS < cmp {wchar} ss:[formatVolumeName], 0 ; null name? >
jne goodName ; nope, let user be
mov ax, WARNING_DISK_FORMAT_NO_NAME
call DesktopYesNoWarning ; harrass user
cmp ax, YESNO_YES ; wants to have no name?
je goodName ; yes, let it continue
badName:
xchg bx, ax ; bx = answer (1-byte inst.)
pop ax ; else, retrieve media
cmp bx, DESK_DB_DETACH ; detaching?
je done_JMP_pop ; yes, no mas
jmp askForName ; else, enter name again
goodName:
;
; clear percentage done field in format status box
;
clr ax ; 0% done
call FormatCallbackRoutine
;
; close all Folder Windows for this disk, if any
;
pop ax ; al = drive number
push ax
call DiskRegisterDiskSilently
jc afterRegister
call FormatVerifyDestroyDest ; can we clobber src disk?
; (closes relevant Folder
; Windows if so)
tst ax
jnz doneJNZwPop ; if no destroy dest, exit
afterRegister:
;
; put up format status box
;
push bx ; save disk handle (or 0)
;
; enable cancel button
;
clr ss:[cancelOperation] ; clear cancel flag
clr ss:[cancelMonikerToChange] ; no moniker to change
mov bx, handle FormatStatusCancel
mov si, offset FormatStatusCancel
mov ax, MSG_GEN_SET_ENABLED
mov dl, VUM_NOW
call ObjMessageCallFixup
mov bx, handle DiskMenuResource
mov si, offset FormatStatusBox
mov ax, MSG_GEN_INTERACTION_INITIATE
push di ; save volume name (es:di)
call ObjMessageCallFixup
pop di
;
; finally, format disk
;
mov ax, ACTIVE_TYPE_DISK_FORMAT
call DesktopMarkActive ; application will be active
pop bx
doneJNZwPop:
pop ax ; retrieve drive, media
pop bp ; retrieve DiskFormatFlags
jnz doneJMP ; if cannot mark, then detaching
; already and status will
; be removed by detaching
;
; set path to avoid causing bogus "disk-in-use" errors if our
; current path just happens to be on the disk we are about to
; format (we allow formatting disks with open folder windows)
;
push ax
mov ax, SP_TOP
call FileSetStandardPath
pop ax
mov cx, SEGMENT_CS ; cx:dx = status callback
mov dx, offset FormatCallbackRoutine
; bx is disk handle or 0, to
; indicate disk is known to
; be unformatted
mov si, offset formatVolumeName ; ds:si <- volume name
call DiskFormat
call MarkNotActive ; application activity done
; (preserves flags)
;
; remove status box
;
pushf ; save status
push ax, si, di, dx, cx ; save error code, sizes
mov bx, handle DiskMenuResource
mov si, offset FormatStatusBox
mov ax, MSG_GEN_GUP_INTERACTION_COMMAND
mov cx, IC_DISMISS
call ObjMessageFixup
pop ax, si, di, dx, cx ; restore error code, sizes
popf ; restore status
jnc success ; success!
;
; report format error
; (if detach is waiting for us, don't report error -
; "obscure case")
;
segmov ds, cs, si
mov si, offset FormatDiskErrorTable
if FULL_EXECUTE_IN_PLACE
mov cx, (length FormatDiskErrorTable)*(size DesktopErrorTableEntry)
call SysCopyToStackDSSI ;ds:si = table on stack
endif
call DesktopErrorReporter ; else, report error
; (will not put up box
; if detaching)
FXIP < call SysRemoveFromStack >
doneJMP:
jmp short done
success:
;
; format succesful
; si:di = bytes good
; dx:cx = bytes bad
; (if detach is waiting for us, don't put up box)
;
cmp ss:[willBeDetaching], TRUE ; detach waiting?
je done ; yes, no box
cmp ss:[detachActiveHandling], TRUE ; detach-while-active box up?
je done ; yes, no box
mov ax, SST_NOTIFY
call UserStandardSound
push si, di ; save good bytes
push dx, cx ; save bad bytes
add di, cx
adc si, dx
mov dx, di ; ax:dx = total
mov ax, si
mov si, offset FormatSizesText1
call ConvertAndShowSize
pop ax, dx ; ax:dx = bad
mov si, offset FormatSizesText2
call ConvertAndShowSize
pop ax, dx ; ax:dx = good
mov si, offset FormatSizesText3
call ConvertAndShowSize
mov bx, handle DiskMenuResource
mov si, offset FormatDoneBox
mov ax, MSG_GEN_INTERACTION_INITIATE
call ObjMessageNone
done:
call IndicateNotBusy
.leave
ret
DesktopDiskFormatFormatLow endp
ife FULL_EXECUTE_IN_PLACE
LocalDefNLString nullVolumeName <0>
endif
;
; pass:
; bx = disk handle of old source disk
;
; return:
; ax = 0 to continue
; ax <> 0 to cancel
; destroy:
; nothing
;
FormatVerifyDestroyDest proc near
uses dx, si, di, ds, si
.enter
call DiskGetDrive ; al = drive
mov dl, al ; dl = drive
; bx = disk handle
mov ax, DCC_VERIFY_DEST_DESTRUCTION ; use this handy code
call CopyCallbackRoutine ; ax = 0 to continue
.leave
ret
FormatVerifyDestroyDest endp
ConvertAndShowSize proc near
SBCS < sub sp, 20 >
DBCS < sub sp, 20*(size wchar) >
mov di, sp
segmov es, ss
call ASCIIizeDWordAXDX
mov dx, ss ; dx:bp = ASCII bytes
mov bp, sp
mov bx, handle DiskMenuResource ; bx:si = size text object
call CallFixupSetText
SBCS < add sp, 20 >
DBCS < add sp, 20*size(wchar) >
ret
ConvertAndShowSize endp
; The following errors, which DiskFormat is capable of returning, should
; never come back to us, as we always pass valid data, to the best of our
; ability:
; - FMT_CANNOT_FORMAT_FIXED_DISKS_IN_CUR_RELEASE
; - FMT_BAD_PARTITION_TABLE
; - FMT_ERR_READING_PARITION_TABLE
; - FMT_ERR_NO_PARTITION_FOUND
; - FMT_ERR_MULTIPLE_PRIMARY_PARTITIONS
; - FMT_ERR_NO_EXTENDED_PARTITION_FOUND
; - FMT_READY
; - FMT_RUNNING
; - FMT_ERR_DISK_UNAVAILABLE (applies only to network drives)
;
FormatDiskErrorTable DesktopErrorTableEntry \
<
FMT_ABORTED,
FmtFormatAbortedErrStr,
mask DETF_NOTICE
>,
<
FMT_DRIVE_NOT_READY,
FmtDriveNotReadyErrStr,
0
>,
<
FMT_ERR_WRITING_BOOT,
FmtErrWritingBootErrStr,
0
>,
<
FMT_ERR_WRITING_ROOT_DIR,
FmtErrWritingRootDirErrStr,
0
>,
<
FMT_ERR_WRITING_FAT,
FmtErrWritingFatErrStr,
0
>,
<
FMT_SET_VOLUME_NAME_ERR,
FmtErrSetVolumeNameErrStr,
0
>,
<
FMT_ERR_DISK_IS_IN_USE,
FmtErrDiskIsInUseStr,
0
>,
<
FMT_ERR_WRITE_PROTECTED,
FmtErrWriteProtectedStr,
0
>,
<
FMT_ERR_CANNOT_ALLOC_SECTOR_BUFFER,
FmtErrNoMemStr,
0
>,
<
FMT_ERR_CANNOT_FORMAT_TRACK,
FmtErrCantFormatTrackStr,
0
>,
<NIL>
CheckHack < length FormatDiskErrorTable eq 11 >
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FormatCallbackRoutine
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: callback routine for disk format to report status
CALLED BY: format code
PASS: ax = percentage done
RETURN: carry set to CANCEL
carry clear to continue
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 01/23/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FormatCallbackRoutine proc far
uses ax, bx, cx, dx, ds, si, es, di, bp
.enter
;
; show percentage done
;
mov dx, ax ; ax:dx = percent
clr ax
mov di, offset formatStatusBuffer ; es:di = buffer for string
mov bp, di
segmov es, ss
call ASCIIizeDWordAXDX ; es:di = null-term at end
if DBCS_PCGEOS
mov ax, '%'
stosw
clr ax
stosw ; tack on percent sign and null
else
mov ax, '%' or (0 shl 8)
stosw ; tack on percent sign and null
endif
mov dx, ss ; dx:bp = ASCII bytes
mov bx, handle DiskMenuResource ; bx:si = size text object
mov si, offset FormatStatusPercentage
push dx, bp ; save message params
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
clr cx ; null-terminated text
call ObjMessageNone ; don't use MF_CALL
pop dx, bp
cmp ss:[detachActiveHandling], TRUE ; detach-while-active box up?
jne 40$ ; nope
cmp ss:[activeType], ACTIVE_TYPE_DISK_FORMAT
jne 40$ ; nope
mov bx, handle ActiveFormatProgress ; if so, update progress there
mov si, offset ActiveFormatProgress
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
clr cx ; null-terminated text
call ObjMessageNone ; don't use MF_CALL
40$:
;
; check for cancel
;
clc ; assume no cancel
cmp ss:[cancelOperation], 0 ; cancel?
je 80$ ; no
mov ss:[cancelOperation], 0 ; else, clear flag
stc ; and indicate cancel
80$:
.leave
ret
FormatCallbackRoutine endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CopyCallbackRoutine
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: callback routine for disk copy to report status, prompt
for source and destination disks
CALLED BY: copy routine
PASS/RETURN:
;DCC_GET_SOURCE_DISK
; passed:
; ax - DCC_GET_SOURCE_DISK
; dl - 0 based drive number
; callback routine to return:
; ax = 0 to continue, non-0 to abort
;
;DCC_REPORT_NUM_SWAPS
; passed:
; ax - DCC_REPORT_NUM_SWAPS
; dx - number of swaps required
; callback routine to return:
; ax = 0 to continue, non-0 to abort
;
;DCC_GET_DEST_DISK
; passed:
; ax - DCC_GET_DEST_DISK
; dl - 0 based drive number
; callback routine to return:
; ax = 0 to continue, non-0 to abort
;
;DCC_VERIFY_DEST_DESTRUCTION
; passed:
; ax - DCC_REPORT_NUM_SWAPS
; bx - disk handle of destination disk
; dl - 0 based drive number
; ds:si - name of destination disk
; callback routine to return:
; ax = 0 to continue, non-0 to abort
;
;DCC_REPORT_FORMAT_PCT
; passed:
; ax - DCC_REPORT_FORMAT_PCT
; dx - percentage of destination disk formatted
; callback routine to return:
; ax = 0 to continue, non-0 to abort
;DCC_REPORT_READ_PCT
; passed:
; ax - DCC_REPORT_READ_PCT
; dx - percentage of source disk read
; callback routine to return:
; ax = 0 to continue, non-0 to abort
;
;DCC_REPORT_WRITE_PCT
; passed:
; ax - DCC_REPORT_WRITE_PCT
; dx - percentage of dest disk written
; callback routine to return:
; ax = 0 to continue, non-0 to abort
;
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 05/23/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CopyCallbackRoutine proc far
uses bx, cx, dx, si, di, ds, es, bp
.enter
clr di
copyCallbackLoop:
cmp ax, cs:[copyCallbackTable][di]
je haveRout
add di, 2
EC < cmp di, COPY_CALLBACK_TABLE_SIZE >
EC < ERROR_Z UNKNOWN_COPY_CALLBACK_VALUE >
jmp short copyCallbackLoop
haveRout:
mov ax, cs:[copyCallbackRoutTable][di]
call ax
.leave
ret
CopyCallbackRoutine endp
copyCallbackTable label word
ifndef GEOLAUNCHER
word DCC_GET_SOURCE_DISK
word DCC_REPORT_NUM_SWAPS
word DCC_GET_DEST_DISK
endif
word DCC_VERIFY_DEST_DESTRUCTION
ifndef GEOLAUNCHER
word DCC_REPORT_FORMAT_PCT
word DCC_REPORT_READ_PCT
word DCC_REPORT_WRITE_PCT
endif
COPY_CALLBACK_TABLE_SIZE equ ($-copyCallbackTable)
copyCallbackRoutTable label word
ifndef GEOLAUNCHER
word offset CopyCallbackGetSourceDisk
word offset CopyCallbackReportNumSwaps
word offset CopyCallbackGetDestDisk
endif
word offset CopyCallbackVerifyDestDestruction
ifndef GEOLAUNCHER
word offset CopyCallbackReportFormatPct
word offset CopyCallbackReportReadPct
word offset CopyCallbackReportWritePct
;
; pass: dl = source drive
; return: ax = 0 to continue
CopyCallbackGetSourceDisk proc near
mov ax, WARNING_DISK_COPY_SOURCE
FALL_THRU CopyCallbackGetDiskCommon
CopyCallbackGetSourceDisk endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CopyCallbackGetDiskCommon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Ask the user for a disk
CALLED BY: (INTERNAL) CopyCallbackGetSourceDisk,
CopyCallbackGetDestDisk
PASS: ax = message to pass to DesktopYesNoWarning
dl = drive number
RETURN: ax = 0 to continue
DESTROYED: cx, es, di
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/ 8/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CopyCallbackGetDiskCommon proc near
SBCS < mov cx, DRIVE_NAME_MAX_LENGTH >
DBCS < mov cx, DRIVE_NAME_MAX_LENGTH*2 >
sub sp, cx
mov di, sp
segmov es, ss
push ax
mov al, dl
call DriveGetName
pop ax
jc cancel
segmov ds, ss
mov dx, sp ; ds:dx <- drive name
call DesktopYesNoWarning
cmp ax, YESNO_YES ; acknowledged?
mov ax, 0 ; assume so (preserve flag)
je done ; yes, return ax = 0
CheckHack <WARNING_DISK_COPY_SOURCE ne -1>
CheckHack <WARNING_DISK_COPY_DEST ne -1>
cancel:
inc ax ; else, return non-zero
done:
SBCS < add sp, DRIVE_NAME_MAX_LENGTH ; clear stack >
DBCS < add sp, DRIVE_NAME_MAX_LENGTH*2 ; clear stack >
ret
CopyCallbackGetDiskCommon endp
;
; pass: dx = num swaps required
; return: ax = 0 to continue
CopyCallbackReportNumSwaps proc near
SBCS < sub sp, 10 >
DBCS < sub sp, 10*(size wchar) >
clr ax ; ax:dx = num swaps
cmp dx, 1
je done ; assume answer is yes if
; it will require only 1
; disk swap
mov di, ss
mov es, di
mov ds, di
mov di, sp
call ASCIIizeDWordAXDX
mov dx, sp ; ds:dx = num swaps
mov ax, WARNING_DISK_COPY_NUM_SWAPS
call DesktopYesNoWarning
cmp ax, YESNO_YES ; continue?
mov ax, 0 ; assume so (preserve flag)
je done ; yes, return ax=0
inc ax ; else, return non-zero
done:
SBCS < add sp, 10 >
DBCS < add sp, 10*(size wchar) >
ret
CopyCallbackReportNumSwaps endp
;
; pass: dl = dest drive
; return: ax = 0 to continue
CopyCallbackGetDestDisk proc near
mov ax, WARNING_DISK_COPY_DEST
GOTO CopyCallbackGetDiskCommon
CopyCallbackGetDestDisk endp
endif
;
; pass: bx = disk handle of dest. disk
; dl = dest drive
; return: ax = 0 to continue
;
CopyCallbackVerifyDestDestruction proc near
;
; Figure the name of the drive and the disk at once.
;
SBCS < mov cx, DRIVE_NAME_MAX_LENGTH+ size VolumeName >
DBCS < mov cx, DRIVE_NAME_MAX_LENGTH*2+ size VolumeName >
sub sp, cx
segmov es, ss, ax
mov ds, ax
mov di, sp ; es:di <- buffer
mov al, dl ; al <- drive number
mov dx, di ; ds:dx <- drive name, in case unnamed
call DriveGetName
LocalNextChar esdi ; skip null-term
dec cx
DBCS < dec cx >
call DiskGetVolumeName
mov ax, WARNING_DISK_COPY_DESTROY_DEST_NO_NAME
call DiskCheckUnnamed
jc 50$
mov dx, di ; use disk name instead
mov ax, WARNING_DISK_COPY_DESTROY_DEST_NAME ; assume have disk name
50$:
call DesktopYesNoWarning
cmp ax, YESNO_YES ; acknowledged?
mov ax, 0 ; assume so (preserve flag)
je done ; yes, return ax=0
inc ax ; else, return non-zero
done:
; if destruction allowed, folders and tree will deal with getting
; file-change notification of the disk having been formatted.
SBCS < add sp, DRIVE_NAME_MAX_LENGTH+size VolumeName >
DBCS < add sp, DRIVE_NAME_MAX_LENGTH*2+size VolumeName >
ret
CopyCallbackVerifyDestDestruction endp
ifndef GEOLAUNCHER ; no disk operations for GeoLauncher
;
; pass:
; dx = pct of format done
; return:
; ax = 0 to continue
CopyCallbackReportFormatPct proc near
mov ss:[destinationInserted], TRUE
mov cx, offset CopyStatusFormatMoniker
mov bp, offset ActiveCopyStatusFormatMoniker
call CopyCallbackReportPctCommon
ret
CopyCallbackReportFormatPct endp
;
; pass:
; dx = pct of read done
; return:
; ax = 0 to continue
CopyCallbackReportReadPct proc near
mov ss:[destinationInserted], FALSE
mov cx, offset CopyStatusReadingMoniker
mov bp, offset ActiveCopyStatusReadingMoniker
call CopyCallbackReportPctCommon
ret
CopyCallbackReportReadPct endp
;
; pass:
; dx = pct of write done
; return:
; ax = 0 to continue
CopyCallbackReportWritePct proc near
mov ss:[destinationInserted], TRUE
mov cx, offset CopyStatusWritingMoniker
mov bp, offset ActiveCopyStatusWritingMoniker
call CopyCallbackReportPctCommon
ret
CopyCallbackReportWritePct endp
;
; pass:
; cx = chunk of moniker for CopyStatusGroup
; bp = chunk of moniker for ActiveCopyProgressGroup
; dx = percentage done (if > 100, zeros percentage fields without
; bringing up box)
;
CopyCallbackReportPctCommon proc near
cmp dx, 100
jbe 10$
clr dx ; zero percentage field
jmp short 20$
10$:
push dx ; save percentage
push bp ; save moniker for active box
;
; make sure correct moniker is showing.
;
; NOTE: do not MF_CALL these things, as ui thread might be blocked
; on what we're doing in the filesystem.
;
mov bx, handle CopyStatusGroup
mov si, offset CopyStatusGroup
cmp cx, ss:[copyStatusMoniker] ; correct moniker?
;
je 17$ ; yes, done
mov ss:[copyStatusMoniker], cx
mov ax, MSG_GEN_USE_VIS_MONIKER
mov dl, VUM_NOW
call ObjMessageNone ; set desired moniker
;
17$:
;
; do the same for the active progress box, if needed
;
pop cx ; cx <- desired moniker
cmp ss:[detachActiveHandling], TRUE ; detach-while-active box up?
jne 117$ ; nope, not needed
cmp ss:[activeType], ACTIVE_TYPE_DISK_COPY
jne 117$ ; nope, not needed
mov bx, handle ActiveCopyProgressGroup
mov si, offset ActiveCopyProgressGroup
cmp cx, ss:[activeCopyStatusMoniker] ; correct moniker?
;
je 117$ ; yes, done
mov ss:[activeCopyStatusMoniker], cx ; save moniker
mov ax, MSG_GEN_USE_VIS_MONIKER
mov dl, VUM_NOW
call ObjMessageNone ; set desired moniker
;
;
117$:
;
; make sure box is up
;
mov bx, handle CopyStatusBox
mov si, offset CopyStatusBox
mov ax, MSG_GEN_INTERACTION_INITIATE
; avoid deadlock possibility - brianc 12/26/90
; call ObjMessageCall
call ObjMessageNone
;
pop dx ; retrieve percentage
20$:
;
; show percentage done
;
clr ax ; ax:dx = percent
segmov es, ss
mov di, offset formatStatusBuffer ; buffer must be FIXED
mov bp, di
call ASCIIizeDWordAXDX
if DBCS_PCGEOS
mov ax, '%'
stosw ; tack on percent sign and null
clr ax
stosw
else
mov ax, '%' or (0 shl 8)
stosw ; tack on percent sign and null
endif
mov dx, ss ; dx:bp = ASCII bytes
mov bx, handle CopyStatusPercentage ; bx:si = size text object
mov si, offset CopyStatusPercentage
push dx, bp ; save message params
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
clr cx ; null-terminated text
call ObjMessageNone ; don't use MF_CALL
pop dx, bp ; retrieve message params
cmp ss:[detachActiveHandling], TRUE ; detach-while-active box up?
jne 40$ ; nope
cmp ss:[activeType], ACTIVE_TYPE_DISK_COPY
jne 40$ ; nope
mov bx, handle ActiveCopyProgress ; bx:si = detach-while-active
mov si, offset ActiveCopyProgress ; progress string
mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR
clr cx ; null-terminated text
call ObjMessageNone ; don't use MF_CALL
40$:
;
; check for cancel
;
clr ax ; assume no cancel
cmp ss:[cancelOperation], 0 ; cancel?
je 80$ ; no
mov ss:[cancelOperation], 0 ; else, clear flag
inc ax ; and indicate cancel
80$:
ret
CopyCallbackReportPctCommon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopDiskCopySourceDrive
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: handle click on disk copy source drive - enable/disable
matching destination drives
CALLED BY: MSG_DISK_COPY_SOURCE_DRIVE send by disk copy
source drive GenList object
PASS: cx = identifier of the exclusive drive in source list
RETURN: carry clear (so carry error handling will not be triggered)
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 12/29/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopDiskCopySourceDrive method DesktopClass,
MSG_DISK_COPY_SOURCE_DRIVE
sourceDrive local byte
sourceMedia local byte
entryPosition local word
.enter
call ShowHourglass
; cl = drive number
; ch = media descriptor
mov sourceDrive, cl
mov sourceMedia, ch ; save it
;
; loop through all destination drives, enabling/disabling their
; buttons if the have compatible/incompatible media
;
clr entryPosition ; first position in dest. list
driveLoop:
mov cx, entryPosition ; position to get
mov bx, handle DiskMenuResource ; bx:si = destination list
mov si, offset DiskMenuResource:DiskCopyDestList
mov ax, MSG_GEN_FIND_CHILD_AT_POSITION
push bp
call ObjMessageCall ; cx:dx = child's OD
pop bp
jc done ; no more children
mov bx, cx ; bx:si = drive clicked on
mov si, dx
mov ax, MSG_GEN_ITEM_GET_IDENTIFIER
push bp
call ObjMessageCall ; al = drive number
; ah = media descriptor
pop bp
mov di, MSG_GEN_SET_ENABLED ; assume compatible
;
; See if source drive supports default media of dest drive, first
;
push ax
mov al, sourceDrive
call DriveTestMediaSupport
pop ax
push ax
jnc 10$ ; yup
;
; How about the other way around?
;
push ax ; save identifier
mov ah, sourceMedia ; al = dest drv, ah = src media
call DriveTestMediaSupport ; compatible?
jnc 10$ ; yes
mov di, MSG_GEN_SET_NOT_ENABLED ; not compatible
10$:
mov ax, di ; ax = method
mov dl, VUM_NOW ; update
push bp
call ObjMessageCall ; enable/disable button
pop bp
;
; if this is source drive, select it
; ax = identifier
;
pop ax ; restore identifier
cmp al, sourceDrive ; is this source drive?
jne 20$ ; no
push bp
mov cx, ax ; cx = identifier of button
mov bx, handle DiskMenuResource ; bx:si = GenItemGroup
mov si, offset DiskMenuResource:DiskCopyDestList
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
clr dx
call ObjMessageCall ; select it
pop bp
20$:
inc entryPosition ; do next one
jmp short driveLoop
done:
call HideHourglass
clc ; no error
.leave
ret
DesktopDiskCopySourceDrive endm
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DesktopDiskFormatSourceDrive
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: handle click on disk format source drive - enable/disable
matching media types
CALLED BY: MSG_DISK_FORMAT_SOURCE_DRIVE send by disk format
source drive GenList object
PASS: cx = identifier of the exclusive drive in format source list
(cl is drive number, ch is media descriptor)
RETURN: carry clear (so carry error handling will not be triggered)
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 12/29/89 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DesktopDiskFormatSourceDrive method DesktopClass,
MSG_DISK_FORMAT_SOURCE_DRIVE
sourceDrive local byte
sourceMedia local byte
.enter
call ShowHourglass
; cl = drive number
; ch = media descriptor
mov sourceDrive, cl ; save 'em
mov sourceMedia, ch
clr di ; start of table
nextMedia:
mov ax, cs:[DiskFormatMediaDescriptorTable][di] ; al = media
mov ah, sourceDrive
xchg al, ah ; al = drive, ah = media
call DriveTestMediaSupport ; is media available for drive?
mov ax, MSG_GEN_SET_USABLE ; assume so
jnc burp ; if so, set usable
mov ax, MSG_GEN_SET_NOT_USABLE ; else, set not usable
burp:
mov bx, handle DiskMenuResource
mov si, cs:[DiskFormatMediaButtonTable][di]
mov dl, VUM_DELAYED_VIA_APP_QUEUE ; update later
push di ; save table offset
call ObjMessageNone ; set button status
; (preserves bp)
pop di ; retrieve table offset
;
; select default media for this drive
;
mov ax, cs:[DiskFormatMediaDescriptorTable][di] ; al = media
cmp al, sourceMedia ; is this it?
jne notDefault
clr ah ; ax = media type
push bp, di
mov cx, ax ; cx = media type
mov bx, handle DiskFormatMediaList ; bx:si = format source list
mov si, offset DiskFormatMediaList
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
clr dx
call ObjMessageCall ; select it
pop bp, di
notDefault:
add di, 2 ; move to next entry
cmp di, DISK_FORMAT_MEDIA_TABLE_SIZE ; end of table?
jne nextMedia ; no, do next media
call HideHourglass
clc ; no errors
.leave
ret
DesktopDiskFormatSourceDrive endm
;
; tables mapping media descriptors to buttons in .ui file
;
DiskFormatMediaDescriptorTable label word
word MEDIA_160K
word MEDIA_180K
word MEDIA_320K
word MEDIA_360K
word MEDIA_720K
word MEDIA_1M2
word MEDIA_1M44
word MEDIA_2M88
word MEDIA_FIXED_DISK
word MEDIA_CUSTOM
word MEDIA_SRAM
word MEDIA_ATA
if _PCMCIA_FORMAT
word MEDIA_FLASH
endif
if PZ_PCGEOS
; word MEDIA_640K
word MEDIA_1M232
endif
DISK_FORMAT_MEDIA_TABLE_SIZE equ ($ - DiskFormatMediaDescriptorTable)
DiskFormatMediaButtonTable label word
word offset DiskMenuResource:DiskFormatMedia160
word offset DiskMenuResource:DiskFormatMedia180
word offset DiskMenuResource:DiskFormatMedia320
word offset DiskMenuResource:DiskFormatMedia360
word offset DiskMenuResource:DiskFormatMedia720
word offset DiskMenuResource:DiskFormatMedia1M2
word offset DiskMenuResource:DiskFormatMedia1M44
word offset DiskMenuResource:DiskFormatMedia2M88
word offset DiskMenuResource:DiskFormatMediaFixed
word offset DiskMenuResource:DiskFormatMediaCustom
word offset DiskMenuResource:DiskFormatMediaSRAM
word offset DiskMenuResource:DiskFormatMediaATA
if _PCMCIA_FORMAT
word offset DiskMenuResource:DiskFormatMediaFLASH
endif
if PZ_PCGEOS
; word offset DiskMenuResource:DiskFormatMedia640
word offset DiskMenuResource:DiskFormatMedia1M232
endif
if _GMGRONLY ; no disk operations for GeoLauncher
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DiskStartDiskRenameBox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: bring up rename disk box with useful drive
CALLED BY: MSG_META_START_DISK_RENAME_BOX
PASS: es - segment of DesktopClass
RETURN:
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 05/24/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DiskStartDiskRenameBox method DesktopClass, MSG_META_START_DISK_RENAME_BOX
call ShowHourglass
;
; get current disk, in case of no target
;
mov bx, handle DiskRenameBox ; bx:si = rename box
mov si, offset DiskRenameBox
mov ax, MSG_FOB_GET_DISK_HANDLE
call ObjMessageCall ; cx = disk handle
tst cx
jnz haveOldDisk
NOFXIP< segmov es, dgroup, cx >
FXIP < mov cx, bx >
FXIP < GetResourceSegmentNS dgroup, es, TRASH_BX >
FXIP < mov bx, cx >
mov cx, es:[geosDiskHandle] ; just use GEOS disk handle
haveOldDisk:
push cx ; save it
;
; get current target drive
;
mov bx, handle FileSystemDisplayGroup
mov si, offset FileSystemDisplayGroup
mov ax, MSG_META_GET_TARGET_EXCL
call ObjMessageCallFixup ; cx:dx = target GenDisplay
pop bx ; bx = current disk handle
jcxz haveDisk ; no target, use current
if not _ZMGR
if _TREE_MENU
cmp cx, handle TreeWindow
jne notTree
cmp dx, offset TreeWindow
jne notTree
;
; tree is target
;
mov bx, handle TreeObject
mov si, offset TreeObject
jmp diskCommon
;
; get target folder
;
notTree:
endif ; if _TREE_MENU
endif
mov bx, ss:[targetFolder] ; bx:si = target folder object
mov si, offset FolderObjectTemplate:FolderObject ; common offset
if not _ZMGR
if _TREE_MENU
diskCommon:
endif ; if _TREE_MENU
endif
sub sp, size DiskInfoStruct
mov dx, ss ; dx:bp = buffer
mov bp, sp
mov ax, MSG_GET_DISK_INFO
call ObjMessageCallFixup ; fill buffer, ax <- disk
mov_tr bx, ax ; bx <- disk handle
add sp, size DiskInfoStruct
haveDisk:
;
; show this drive in rename drive list and its name in name area
; bx = disk handle
;
;
; make sure that we've got an entry in the DiskRenameDriveList before
; trying to set it
;
push bx
call DiskGetDrive ; al = drive
call DriveGetDefaultMedia ; ah = media
mov cx, ax ; cx = identifier
mov ax, MSG_GEN_ITEM_GROUP_GET_ITEM_OPTR
mov bx, handle DiskRenameDriveList
mov si, offset DiskRenameDriveList
call ObjMessageCallFixup
pop bx
jc setRenameDisk ; found, set it
;
; curent disk not found in DiskRenameDriveList, try currently selected
; disk in DiskRenameDriveList
;
mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION
mov bx, handle DiskRenameDriveList
mov si, offset DiskRenameDriveList
call ObjMessageCallFixup ; ax = current selection
cmp ax, GIGS_NONE
je dontSet ; nothing found
mov cx, ax ; cx = identifer
mov ax, MSG_DISK_RENAME_DRIVE
mov bx, handle 0
clr di
call ObjMessage
jmp short dontSet ; finish up
setRenameDisk:
push bx
call SetRenameDriveButton
pop bx
call SetAndStoreRenameDisk ; show its name
dontSet:
;
; bring up rename box
;
mov bx, handle DiskRenameBox
mov si, offset DiskRenameBox
mov ax, MSG_GEN_INTERACTION_INITIATE
call ObjMessageFixup
call HideHourglass
ret
DiskStartDiskRenameBox endm
endif ; if _GMGRONLY
if not _FCAB
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DiskRenameRename
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: rename disk
CALLED BY: MSG_DISK_RENAME
PASS:
RETURN:
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 04/05/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DiskRenameRename method DesktopClass, MSG_DISK_RENAME
call ShowHourglass
;
; get new volume name
;
mov bx, handle DiskRenameDestName
mov si, offset DiskRenameDestName
mov ax, MSG_VIS_TEXT_GET_ALL_BLOCK
clr dx ; return global block
call ObjMessageCallFixup ; cx <- block
mov bx, cx
push bx ; save volume name block
call MemLock
mov ds, ax
;
; get disk handle
;
mov bx, handle DiskRenameBox ; bx:si = rename box
mov si, offset DiskRenameBox
mov ax, MSG_FOB_GET_DISK_HANDLE
call ObjMessageCall ; cx = disk handle
mov bx, cx ; bx = disk handle
clr si ; ds:si = new name
call CheckVolumeName ; C clr if okay, C set if error
; reported (ax = from
; DesktopOKError if C=1)
jc afterRename ; error, done, allows new name
call DiskSetVolumeName
jnc afterRename
cmp ax, ERROR_WRITE_PROTECTED ; useful error?
je 44$ ; yes, use it
cmp ax, ERROR_INVALID_NAME
je 44$
mov ax, ERROR_DISK_RENAME ; report generic disk rename
; error, as DOS doesn't
; give useful error code
44$:
call DesktopOKError ; put up box and wait
afterRename:
pop bx ; free volume name block
pushf ; save rename status
call MemFree
popf ; retrieve rename status
jc done ; if error, don't dismiss
;
; broadcast disk name change
; cx = disk handle of disk renamed
;
mov dx, cx
mov ax, MSG_UPDATE_DISK_NAME ; disk name changed for DX
mov di, mask MF_FORCE_QUEUE ; do later
call SendToTreeAndBroadcast
;
; close rename disk box (since operation successful)
;
mov bx, handle DiskRenameBox
mov si, offset DiskRenameBox
mov ax, MSG_GEN_GUP_INTERACTION_COMMAND
mov cx, IC_DISMISS
call ObjMessageNone
done:
call HideHourglass
ret
DiskRenameRename endm
endif ; if (not _FCAB)
;
; pass:
; ds:si - volume name
; return:
; carry clear if no error
; carry set if error (error reported)
; AX = error code
;
CheckVolumeName proc near
uses si
.enter
checkChar:
if DBCS_PCGEOS
lodsw
cmp ax, 0
else
lodsb
cmp al, 0 ; end of name?
endif
jz done ; yes, carry clear
call CheckDOSVolumeNameChar ; Z=1 if bad char
jne checkChar
mov ax, ERROR_BAD_VOLUME_NAME
call DesktopOKError
stc ; indicate error
done:
.leave
ret
CheckVolumeName endp
;
; al = character to check
;
CheckDOSVolumeNameChar proc near
uses es, di, cx
.enter
segmov es, cs, di
mov di, offset DOSBadVolumeCharsTable
mov cx, DOS_BAD_VOLUME_CHARS_LENGTH
SBCS < repne scasb >
DBCS < repne scasw >
.leave
ret
CheckDOSVolumeNameChar endp
SBCS <DOSBadVolumeCharsTable byte '*?/\\|.,;:+=<>[]()&^' >
SBCS <DOS_BAD_VOLUME_CHARS_LENGTH equ ($-DOSBadVolumeCharsTable) >
DBCS <DOSBadVolumeCharsTable wchar '*?/\\|.,;:+=<>[]()&^' >
DBCS <DOS_BAD_VOLUME_CHARS_LENGTH equ (($-DOSBadVolumeCharsTable)/(size wchar))>
if not _FCAB
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DiskRenameRenameDrive
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: read disk specified and show current volume name, if any
CALLED BY: MSG_DISK_RENAME_DRIVE
PASS: cx = identifier of the exclusive drive in rename drive list
RETURN: carry - set on error
- clear if OK
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 04/05/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DiskRenameRenameDrive method DesktopClass, MSG_DISK_RENAME_DRIVE
call ShowHourglass
;
; get drive number
;
mov ax, cx ; al = drive number
; ah = media descriptor
call DiskRegisterDiskSilently
; bx = disk handle, if any
jnc noError
mov ax, ERROR_DRIVE_NOT_READY ; report error, if so
call DesktopOKError
;
; For GeoManager, restore last selected drive
;
GM< mov bx, handle DiskRenameBox ; bx:si = rename box >
GM< mov si, offset DiskRenameBox >
GM< mov ax, MSG_FOB_GET_DISK_HANDLE >
GM< call ObjMessageCallFixup ; cx = disk handle >
GM< mov bx, cx >
GM< call SetRenameDriveButton ; select this drive >
stc ; let caller know we failed
jmp short exit
noError:
GM< push bx >
call SetAndStoreRenameDisk
GM< pop bx >
GM< call SetRenameDriveButton ; force drive button to be >
; correct again
clc ; no error
exit:
call HideHourglass
ret
DiskRenameRenameDrive endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SetAndStoreRenameDisk
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: save a diskhandle of the drive to rename.
CALLED BY: DiskRenameRenameDrive
PASS: bx - disk handle to store
RETURN: none
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
dlitwin 11/14/92 added header
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SetAndStoreRenameDisk proc near
;
; store disk handle with rename box
;
push bx ; save disk handle
mov cx, bx ; cx = disk handle
mov bx, handle DiskRenameBox ; bx:si = rename box
mov si, offset DiskRenameBox
mov ax, MSG_FOB_SET_DISK_HANDLE
call ObjMessageCallFixup
pop bx ; restore disk handle
;
; show current volume name
;
; volume buffer (with room for unnamed brackets)
SBCS <FULL_VOLUME_NAME_LENGTH = VOLUME_NAME_LENGTH+1+2 >
DBCS <FULL_VOLUME_NAME_LENGTH = (VOLUME_NAME_LENGTH+1+2)*2 >
sub sp, FULL_VOLUME_NAME_LENGTH
segmov es, ss
mov di, sp
LocalLoadChar ax, '['
LocalPutChar esdi, ax ; in case unnamed
call DiskGetVolumeName
call DiskCheckUnnamed ; unnamed?
jnc 40$ ; no
;
; unnamed, add ending bracket
;
SBCS < push di >
SBCS < mov al, 0 >
DBCS < clr ax >
mov cx, VOLUME_NAME_LENGTH
SBCS < repne scasb ; es:di = after null >
DBCS < repne scasw ; es:di = after null >
LocalPrevChar esdi ; es:di = null
mov ax, ']' ; bracket + null
stosw
DBCS < clr ax >
DBCS < stosw >
SBCS < pop di >
SBCS < dec di ; point at beginning bracket >
DBCS < mov di, sp ; point at beginning bracket >
stc
40$:
mov dx, es
mov bp, di
mov bx, handle DiskRenameSrcName
mov si, offset DiskRenameSrcName
push dx, bp
pushf
call CallFixupSetText
;
; put source name in dest. name field and select it
;
popf ; retrieve unnamed? result
pop dx, bp ; retrieve method params
jnc 80$ ; => has name
NOFXIP< mov dx, cs ; if unnamed, use null string >
FXIP< push ds
FXIP< GetResourceSegmentNS dgroup, ds, TRASH_BX >
FXIP< mov dx, ds ; dx = dgroup >
FXIP< pop ds >
mov bp, offset nullRenameString
80$:
mov bx, handle DiskRenameDestName
mov si, offset DiskRenameDestName
call CallFixupSetText
mov ax, MSG_VIS_TEXT_SELECT_RANGE_SMALL ; select name
mov cx, 0
mov dx, 0x8000
call ObjMessageCallFixup
add sp, FULL_VOLUME_NAME_LENGTH
ret
SetAndStoreRenameDisk endp
if FULL_EXECUTE_IN_PLACE
idata segment
endif
LocalDefNLString nullRenameString <0>
if FULL_EXECUTE_IN_PLACE
idata ends
endif
if _GMGRONLY
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SetRenameDriveButton
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Sets the ui for the disk-to-be-renamed to the drive of the
passed in diskhandle.
t
CALLED BY: DiskRenameRenameDrive
PASS: bx - diskhandle
RETURN: none
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
dlitwin 11/14/92 added header
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SetRenameDriveButton proc near
call DiskGetDrive ; al = drive
call DriveGetDefaultMedia ; ah = media
mov cx, ax ; cx = drive/media
mov bx, handle DiskMenuResource ; bx:si = disk list
mov si, offset DiskMenuResource:DiskRenameDriveList
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
clr dx
call ObjMessageCallFixup
ret
SetRenameDriveButton endp
endif ; if _GMGRONLY
endif ; if (not _FCAB)
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CancelTriggerTrigger
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: handle press on cancel button
CALLED BY: MSG_GEN_TRIGGER_SEND_ACTION
PASS: es - segment of CancelTriggerClass
RETURN:
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
brianc 01/02/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CancelTriggerTrigger method CancelTriggerClass, MSG_GEN_TRIGGER_SEND_ACTION
NOFXIP< segmov es, dgroup, bx ; es = dgroup >
FXIP < GetResourceSegmentNS dgroup, es, TRASH_BX >
;
; flag cancel
;
mov es:[cancelOperation], 0xff
push ax
mov dl, VUM_NOW
mov ax, MSG_GEN_SET_NOT_ENABLED
call ObjCallInstanceNoLock
tst es:[cancelMonikerToChange] ; moniker to change?
jz skip
push si
mov ax, MSG_GEN_USE_VIS_MONIKER
mov dl, VUM_NOW
mov cx, offset StoppingProgressMoniker
mov bx, handle ProgressUI
mov si, es:[cancelMonikerToChange]
call ObjMessageCallFixup
pop si
skip:
pop ax
;
; call superclass to do its stuff
;
segmov es, <segment CancelTriggerClass>, di
mov di, offset CancelTriggerClass
call ObjCallSuperNoLock
ret
CancelTriggerTrigger endp
DiskCode ends
|
libsrc/_DEVELOPMENT/arch/zxn/esxdos/c/sdcc_iy/esx_ide_bank_free.asm | jpoikela/z88dk | 640 | 87946 | <gh_stars>100-1000
; unsigned char esx_ide_bank_free(unsigned char banktype, unsigned char page)
SECTION code_esxdos
PUBLIC _esx_ide_bank_free
EXTERN l0_esx_ide_bank_free_callee
_esx_ide_bank_free:
pop af
pop hl
push hl
push af
jp l0_esx_ide_bank_free_callee
|
tests/counter-reuse.nasm | DerickEddington/cabna | 0 | 93166 | global _start
global thread_main
%include "cabna/sys/iface.nasm"
%assign count 100_000_000
section .text
def_start
proc thread_main: ; (done (a n))
thread_main_race
jmp_ret alloc_task
mov qword [arg1_rdi + task.exec], done
mov qword [arg1_rdi + task.need], 1
mov rbx, arg1_rdi
jmp_ret alloc_task
mov qword [arg1_rdi + task.exec], a
mov qword [arg1_rdi + task.arg1], count
mov [arg1_rdi + task.rcvr], rbx
mov qword [arg1_rdi + task.ridx], 1
mov cet_r14, arg1_rdi
jmp a
proc done: ; Exit program.
stat call print_stats
mov rdi, [cet_r14 + task.arg1]
mov eax, 231 ; exit_group syscall number
syscall
; (define (a n) (b (- n 1)))
proc a:
sub qword [cet_r14 + task.arg1], 1
mov qword [cet_r14 + task.exec], b
jmp b
; (define (b n) (c (- n 2)))
proc b:
sub qword [cet_r14 + task.arg1], 2
mov qword [cet_r14 + task.exec], c
jmp c
; (define (c n) (if (<= n 0) n (a n)))
proc c:
mov rbx, [cet_r14 + task.arg1]
test rbx, rbx
likely jg .continue
mov arg1_rdi, rbx
jmp_ret supply_retval
jmp_ret_to free_pet, exec_avail
.continue:
mov qword [cet_r14 + task.exec], a
jmp a
|
source/ada83/text_io.ads | ytomino/drake | 33 | 13765 | <filename>source/ada83/text_io.ads
pragma License (Unrestricted);
with Ada.Text_IO;
package Text_IO renames Ada.Text_IO;
|
lab01/xv6-master/sh.asm | ahchu1993/opsys | 0 | 83420 | <reponame>ahchu1993/opsys<filename>lab01/xv6-master/sh.asm
_sh: file format elf32-i386
Disassembly of section .text:
00000000 <runcmd>:
struct cmd *parsecmd(char*);
// Execute cmd. Never returns.
void
runcmd(struct cmd *cmd)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 38 sub $0x38,%esp
struct execcmd *ecmd;
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
6: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
a: 75 0c jne 18 <runcmd+0x18>
exit(0);
c: c7 04 24 00 00 00 00 movl $0x0,(%esp)
13: e8 88 0f 00 00 call fa0 <exit>
switch(cmd->type){
18: 8b 45 08 mov 0x8(%ebp),%eax
1b: 8b 00 mov (%eax),%eax
1d: 83 f8 05 cmp $0x5,%eax
20: 77 09 ja 2b <runcmd+0x2b>
22: 8b 04 85 24 15 00 00 mov 0x1524(,%eax,4),%eax
29: ff e0 jmp *%eax
default:
panic("runcmd");
2b: c7 04 24 f8 14 00 00 movl $0x14f8,(%esp)
32: e8 61 03 00 00 call 398 <panic>
case EXEC:
ecmd = (struct execcmd*)cmd;
37: 8b 45 08 mov 0x8(%ebp),%eax
3a: 89 45 e8 mov %eax,-0x18(%ebp)
if(ecmd->argv[0] == 0)
3d: 8b 45 e8 mov -0x18(%ebp),%eax
40: 8b 40 04 mov 0x4(%eax),%eax
43: 85 c0 test %eax,%eax
45: 75 0c jne 53 <runcmd+0x53>
exit(0);
47: c7 04 24 00 00 00 00 movl $0x0,(%esp)
4e: e8 4d 0f 00 00 call fa0 <exit>
exec(ecmd->argv[0], ecmd->argv);
53: 8b 45 e8 mov -0x18(%ebp),%eax
56: 8d 50 04 lea 0x4(%eax),%edx
59: 8b 45 e8 mov -0x18(%ebp),%eax
5c: 8b 40 04 mov 0x4(%eax),%eax
5f: 89 54 24 04 mov %edx,0x4(%esp)
63: 89 04 24 mov %eax,(%esp)
66: e8 75 0f 00 00 call fe0 <exec>
printf(2, "exec %s failed\n", ecmd->argv[0]);
6b: 8b 45 e8 mov -0x18(%ebp),%eax
6e: 8b 40 04 mov 0x4(%eax),%eax
71: 89 44 24 08 mov %eax,0x8(%esp)
75: c7 44 24 04 ff 14 00 movl $0x14ff,0x4(%esp)
7c: 00
7d: c7 04 24 02 00 00 00 movl $0x2,(%esp)
84: e8 a8 10 00 00 call 1131 <printf>
break;
89: e9 9f 01 00 00 jmp 22d <runcmd+0x22d>
case REDIR:
rcmd = (struct redircmd*)cmd;
8e: 8b 45 08 mov 0x8(%ebp),%eax
91: 89 45 f4 mov %eax,-0xc(%ebp)
close(rcmd->fd);
94: 8b 45 f4 mov -0xc(%ebp),%eax
97: 8b 40 14 mov 0x14(%eax),%eax
9a: 89 04 24 mov %eax,(%esp)
9d: e8 2e 0f 00 00 call fd0 <close>
if(open(rcmd->file, rcmd->mode) < 0){
a2: 8b 45 f4 mov -0xc(%ebp),%eax
a5: 8b 50 10 mov 0x10(%eax),%edx
a8: 8b 45 f4 mov -0xc(%ebp),%eax
ab: 8b 40 08 mov 0x8(%eax),%eax
ae: 89 54 24 04 mov %edx,0x4(%esp)
b2: 89 04 24 mov %eax,(%esp)
b5: e8 2e 0f 00 00 call fe8 <open>
ba: 85 c0 test %eax,%eax
bc: 79 2a jns e8 <runcmd+0xe8>
printf(2, "open %s failed\n", rcmd->file);
be: 8b 45 f4 mov -0xc(%ebp),%eax
c1: 8b 40 08 mov 0x8(%eax),%eax
c4: 89 44 24 08 mov %eax,0x8(%esp)
c8: c7 44 24 04 0f 15 00 movl $0x150f,0x4(%esp)
cf: 00
d0: c7 04 24 02 00 00 00 movl $0x2,(%esp)
d7: e8 55 10 00 00 call 1131 <printf>
exit(1);
dc: c7 04 24 01 00 00 00 movl $0x1,(%esp)
e3: e8 b8 0e 00 00 call fa0 <exit>
}
runcmd(rcmd->cmd);
e8: 8b 45 f4 mov -0xc(%ebp),%eax
eb: 8b 40 04 mov 0x4(%eax),%eax
ee: 89 04 24 mov %eax,(%esp)
f1: e8 0a ff ff ff call 0 <runcmd>
break;
f6: e9 32 01 00 00 jmp 22d <runcmd+0x22d>
case LIST:
lcmd = (struct listcmd*)cmd;
fb: 8b 45 08 mov 0x8(%ebp),%eax
fe: 89 45 ec mov %eax,-0x14(%ebp)
if(fork1() == 0)
101: e8 bf 02 00 00 call 3c5 <fork1>
106: 85 c0 test %eax,%eax
108: 75 0e jne 118 <runcmd+0x118>
runcmd(lcmd->left);
10a: 8b 45 ec mov -0x14(%ebp),%eax
10d: 8b 40 04 mov 0x4(%eax),%eax
110: 89 04 24 mov %eax,(%esp)
113: e8 e8 fe ff ff call 0 <runcmd>
wait(0);
118: c7 04 24 00 00 00 00 movl $0x0,(%esp)
11f: e8 84 0e 00 00 call fa8 <wait>
runcmd(lcmd->right);
124: 8b 45 ec mov -0x14(%ebp),%eax
127: 8b 40 08 mov 0x8(%eax),%eax
12a: 89 04 24 mov %eax,(%esp)
12d: e8 ce fe ff ff call 0 <runcmd>
break;
132: e9 f6 00 00 00 jmp 22d <runcmd+0x22d>
case PIPE:
pcmd = (struct pipecmd*)cmd;
137: 8b 45 08 mov 0x8(%ebp),%eax
13a: 89 45 f0 mov %eax,-0x10(%ebp)
if(pipe(p) < 0)
13d: 8d 45 dc lea -0x24(%ebp),%eax
140: 89 04 24 mov %eax,(%esp)
143: e8 70 0e 00 00 call fb8 <pipe>
148: 85 c0 test %eax,%eax
14a: 79 0c jns 158 <runcmd+0x158>
panic("pipe");
14c: c7 04 24 1f 15 00 00 movl $0x151f,(%esp)
153: e8 40 02 00 00 call 398 <panic>
if(fork1() == 0){
158: e8 68 02 00 00 call 3c5 <fork1>
15d: 85 c0 test %eax,%eax
15f: 75 3b jne 19c <runcmd+0x19c>
close(1);
161: c7 04 24 01 00 00 00 movl $0x1,(%esp)
168: e8 63 0e 00 00 call fd0 <close>
dup(p[1]);
16d: 8b 45 e0 mov -0x20(%ebp),%eax
170: 89 04 24 mov %eax,(%esp)
173: e8 a8 0e 00 00 call 1020 <dup>
close(p[0]);
178: 8b 45 dc mov -0x24(%ebp),%eax
17b: 89 04 24 mov %eax,(%esp)
17e: e8 4d 0e 00 00 call fd0 <close>
close(p[1]);
183: 8b 45 e0 mov -0x20(%ebp),%eax
186: 89 04 24 mov %eax,(%esp)
189: e8 42 0e 00 00 call fd0 <close>
runcmd(pcmd->left);
18e: 8b 45 f0 mov -0x10(%ebp),%eax
191: 8b 40 04 mov 0x4(%eax),%eax
194: 89 04 24 mov %eax,(%esp)
197: e8 64 fe ff ff call 0 <runcmd>
}
if(fork1() == 0){
19c: e8 24 02 00 00 call 3c5 <fork1>
1a1: 85 c0 test %eax,%eax
1a3: 75 3b jne 1e0 <runcmd+0x1e0>
close(0);
1a5: c7 04 24 00 00 00 00 movl $0x0,(%esp)
1ac: e8 1f 0e 00 00 call fd0 <close>
dup(p[0]);
1b1: 8b 45 dc mov -0x24(%ebp),%eax
1b4: 89 04 24 mov %eax,(%esp)
1b7: e8 64 0e 00 00 call 1020 <dup>
close(p[0]);
1bc: 8b 45 dc mov -0x24(%ebp),%eax
1bf: 89 04 24 mov %eax,(%esp)
1c2: e8 09 0e 00 00 call fd0 <close>
close(p[1]);
1c7: 8b 45 e0 mov -0x20(%ebp),%eax
1ca: 89 04 24 mov %eax,(%esp)
1cd: e8 fe 0d 00 00 call fd0 <close>
runcmd(pcmd->right);
1d2: 8b 45 f0 mov -0x10(%ebp),%eax
1d5: 8b 40 08 mov 0x8(%eax),%eax
1d8: 89 04 24 mov %eax,(%esp)
1db: e8 20 fe ff ff call 0 <runcmd>
}
close(p[0]);
1e0: 8b 45 dc mov -0x24(%ebp),%eax
1e3: 89 04 24 mov %eax,(%esp)
1e6: e8 e5 0d 00 00 call fd0 <close>
close(p[1]);
1eb: 8b 45 e0 mov -0x20(%ebp),%eax
1ee: 89 04 24 mov %eax,(%esp)
1f1: e8 da 0d 00 00 call fd0 <close>
wait(0);
1f6: c7 04 24 00 00 00 00 movl $0x0,(%esp)
1fd: e8 a6 0d 00 00 call fa8 <wait>
wait(0);
202: c7 04 24 00 00 00 00 movl $0x0,(%esp)
209: e8 9a 0d 00 00 call fa8 <wait>
break;
20e: eb 1d jmp 22d <runcmd+0x22d>
case BACK:
bcmd = (struct backcmd*)cmd;
210: 8b 45 08 mov 0x8(%ebp),%eax
213: 89 45 e4 mov %eax,-0x1c(%ebp)
if(fork1() == 0)
216: e8 aa 01 00 00 call 3c5 <fork1>
21b: 85 c0 test %eax,%eax
21d: 75 0e jne 22d <runcmd+0x22d>
runcmd(bcmd->cmd);
21f: 8b 45 e4 mov -0x1c(%ebp),%eax
222: 8b 40 04 mov 0x4(%eax),%eax
225: 89 04 24 mov %eax,(%esp)
228: e8 d3 fd ff ff call 0 <runcmd>
break;
}
exit(0);
22d: c7 04 24 00 00 00 00 movl $0x0,(%esp)
234: e8 67 0d 00 00 call fa0 <exit>
00000239 <getcmd>:
}
int
getcmd(char *buf, int nbuf)
{
239: 55 push %ebp
23a: 89 e5 mov %esp,%ebp
23c: 83 ec 18 sub $0x18,%esp
printf(2, "$ ");
23f: c7 44 24 04 3c 15 00 movl $0x153c,0x4(%esp)
246: 00
247: c7 04 24 02 00 00 00 movl $0x2,(%esp)
24e: e8 de 0e 00 00 call 1131 <printf>
memset(buf, 0, nbuf);
253: 8b 45 0c mov 0xc(%ebp),%eax
256: 89 44 24 08 mov %eax,0x8(%esp)
25a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
261: 00
262: 8b 45 08 mov 0x8(%ebp),%eax
265: 89 04 24 mov %eax,(%esp)
268: e8 8d 0b 00 00 call dfa <memset>
gets(buf, nbuf);
26d: 8b 45 0c mov 0xc(%ebp),%eax
270: 89 44 24 04 mov %eax,0x4(%esp)
274: 8b 45 08 mov 0x8(%ebp),%eax
277: 89 04 24 mov %eax,(%esp)
27a: e8 d2 0b 00 00 call e51 <gets>
if(buf[0] == 0) // EOF
27f: 8b 45 08 mov 0x8(%ebp),%eax
282: 0f b6 00 movzbl (%eax),%eax
285: 84 c0 test %al,%al
287: 75 07 jne 290 <getcmd+0x57>
return -1;
289: b8 ff ff ff ff mov $0xffffffff,%eax
28e: eb 05 jmp 295 <getcmd+0x5c>
return 0;
290: b8 00 00 00 00 mov $0x0,%eax
}
295: c9 leave
296: c3 ret
00000297 <main>:
int
main(void)
{
297: 55 push %ebp
298: 89 e5 mov %esp,%ebp
29a: 83 e4 f0 and $0xfffffff0,%esp
29d: 83 ec 20 sub $0x20,%esp
static char buf[100];
int fd;
// Assumes three file descriptors open.
while((fd = open("console", O_RDWR)) >= 0){
2a0: eb 19 jmp 2bb <main+0x24>
if(fd >= 3){
2a2: 83 7c 24 1c 02 cmpl $0x2,0x1c(%esp)
2a7: 7e 12 jle 2bb <main+0x24>
close(fd);
2a9: 8b 44 24 1c mov 0x1c(%esp),%eax
2ad: 89 04 24 mov %eax,(%esp)
2b0: e8 1b 0d 00 00 call fd0 <close>
break;
2b5: 90 nop
}
}
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
2b6: e9 b5 00 00 00 jmp 370 <main+0xd9>
{
static char buf[100];
int fd;
// Assumes three file descriptors open.
while((fd = open("console", O_RDWR)) >= 0){
2bb: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp)
2c2: 00
2c3: c7 04 24 3f 15 00 00 movl $0x153f,(%esp)
2ca: e8 19 0d 00 00 call fe8 <open>
2cf: 89 44 24 1c mov %eax,0x1c(%esp)
2d3: 83 7c 24 1c 00 cmpl $0x0,0x1c(%esp)
2d8: 79 c8 jns 2a2 <main+0xb>
break;
}
}
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
2da: e9 91 00 00 00 jmp 370 <main+0xd9>
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
2df: 0f b6 05 20 16 00 00 movzbl 0x1620,%eax
2e6: 3c 63 cmp $0x63,%al
2e8: 75 5a jne 344 <main+0xad>
2ea: 0f b6 05 21 16 00 00 movzbl 0x1621,%eax
2f1: 3c 64 cmp $0x64,%al
2f3: 75 4f jne 344 <main+0xad>
2f5: 0f b6 05 22 16 00 00 movzbl 0x1622,%eax
2fc: 3c 20 cmp $0x20,%al
2fe: 75 44 jne 344 <main+0xad>
// Clumsy but will have to do for now.
// Chdir has no effect on the parent if run in the child.
buf[strlen(buf)-1] = 0; // chop \n
300: c7 04 24 20 16 00 00 movl $0x1620,(%esp)
307: e8 c9 0a 00 00 call dd5 <strlen>
30c: 83 e8 01 sub $0x1,%eax
30f: c6 80 20 16 00 00 00 movb $0x0,0x1620(%eax)
if(chdir(buf+3) < 0)
316: c7 04 24 23 16 00 00 movl $0x1623,(%esp)
31d: e8 f6 0c 00 00 call 1018 <chdir>
322: 85 c0 test %eax,%eax
324: 79 49 jns 36f <main+0xd8>
printf(2, "cannot cd %s\n", buf+3);
326: c7 44 24 08 23 16 00 movl $0x1623,0x8(%esp)
32d: 00
32e: c7 44 24 04 47 15 00 movl $0x1547,0x4(%esp)
335: 00
336: c7 04 24 02 00 00 00 movl $0x2,(%esp)
33d: e8 ef 0d 00 00 call 1131 <printf>
continue;
342: eb 2c jmp 370 <main+0xd9>
}
if(fork1() == 0)
344: e8 7c 00 00 00 call 3c5 <fork1>
349: 85 c0 test %eax,%eax
34b: 75 14 jne 361 <main+0xca>
runcmd(parsecmd(buf));
34d: c7 04 24 20 16 00 00 movl $0x1620,(%esp)
354: e8 db 03 00 00 call 734 <parsecmd>
359: 89 04 24 mov %eax,(%esp)
35c: e8 9f fc ff ff call 0 <runcmd>
wait(0);
361: c7 04 24 00 00 00 00 movl $0x0,(%esp)
368: e8 3b 0c 00 00 call fa8 <wait>
36d: eb 01 jmp 370 <main+0xd9>
// Clumsy but will have to do for now.
// Chdir has no effect on the parent if run in the child.
buf[strlen(buf)-1] = 0; // chop \n
if(chdir(buf+3) < 0)
printf(2, "cannot cd %s\n", buf+3);
continue;
36f: 90 nop
break;
}
}
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
370: c7 44 24 04 64 00 00 movl $0x64,0x4(%esp)
377: 00
378: c7 04 24 20 16 00 00 movl $0x1620,(%esp)
37f: e8 b5 fe ff ff call 239 <getcmd>
384: 85 c0 test %eax,%eax
386: 0f 89 53 ff ff ff jns 2df <main+0x48>
}
if(fork1() == 0)
runcmd(parsecmd(buf));
wait(0);
}
exit(0);
38c: c7 04 24 00 00 00 00 movl $0x0,(%esp)
393: e8 08 0c 00 00 call fa0 <exit>
00000398 <panic>:
}
void
panic(char *s)
{
398: 55 push %ebp
399: 89 e5 mov %esp,%ebp
39b: 83 ec 18 sub $0x18,%esp
printf(2, "%s\n", s);
39e: 8b 45 08 mov 0x8(%ebp),%eax
3a1: 89 44 24 08 mov %eax,0x8(%esp)
3a5: c7 44 24 04 55 15 00 movl $0x1555,0x4(%esp)
3ac: 00
3ad: c7 04 24 02 00 00 00 movl $0x2,(%esp)
3b4: e8 78 0d 00 00 call 1131 <printf>
exit(0);
3b9: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3c0: e8 db 0b 00 00 call fa0 <exit>
000003c5 <fork1>:
}
int
fork1(void)
{
3c5: 55 push %ebp
3c6: 89 e5 mov %esp,%ebp
3c8: 83 ec 28 sub $0x28,%esp
int pid;
pid = fork();
3cb: e8 c8 0b 00 00 call f98 <fork>
3d0: 89 45 f4 mov %eax,-0xc(%ebp)
if(pid == -1)
3d3: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
3d7: 75 0c jne 3e5 <fork1+0x20>
panic("fork");
3d9: c7 04 24 59 15 00 00 movl $0x1559,(%esp)
3e0: e8 b3 ff ff ff call 398 <panic>
return pid;
3e5: 8b 45 f4 mov -0xc(%ebp),%eax
}
3e8: c9 leave
3e9: c3 ret
000003ea <execcmd>:
//PAGEBREAK!
// Constructors
struct cmd*
execcmd(void)
{
3ea: 55 push %ebp
3eb: 89 e5 mov %esp,%ebp
3ed: 83 ec 28 sub $0x28,%esp
struct execcmd *cmd;
cmd = malloc(sizeof(*cmd));
3f0: c7 04 24 54 00 00 00 movl $0x54,(%esp)
3f7: e8 1b 10 00 00 call 1417 <malloc>
3fc: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
3ff: c7 44 24 08 54 00 00 movl $0x54,0x8(%esp)
406: 00
407: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
40e: 00
40f: 8b 45 f4 mov -0xc(%ebp),%eax
412: 89 04 24 mov %eax,(%esp)
415: e8 e0 09 00 00 call dfa <memset>
cmd->type = EXEC;
41a: 8b 45 f4 mov -0xc(%ebp),%eax
41d: c7 00 01 00 00 00 movl $0x1,(%eax)
return (struct cmd*)cmd;
423: 8b 45 f4 mov -0xc(%ebp),%eax
}
426: c9 leave
427: c3 ret
00000428 <redircmd>:
struct cmd*
redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
428: 55 push %ebp
429: 89 e5 mov %esp,%ebp
42b: 83 ec 28 sub $0x28,%esp
struct redircmd *cmd;
cmd = malloc(sizeof(*cmd));
42e: c7 04 24 18 00 00 00 movl $0x18,(%esp)
435: e8 dd 0f 00 00 call 1417 <malloc>
43a: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
43d: c7 44 24 08 18 00 00 movl $0x18,0x8(%esp)
444: 00
445: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
44c: 00
44d: 8b 45 f4 mov -0xc(%ebp),%eax
450: 89 04 24 mov %eax,(%esp)
453: e8 a2 09 00 00 call dfa <memset>
cmd->type = REDIR;
458: 8b 45 f4 mov -0xc(%ebp),%eax
45b: c7 00 02 00 00 00 movl $0x2,(%eax)
cmd->cmd = subcmd;
461: 8b 45 f4 mov -0xc(%ebp),%eax
464: 8b 55 08 mov 0x8(%ebp),%edx
467: 89 50 04 mov %edx,0x4(%eax)
cmd->file = file;
46a: 8b 45 f4 mov -0xc(%ebp),%eax
46d: 8b 55 0c mov 0xc(%ebp),%edx
470: 89 50 08 mov %edx,0x8(%eax)
cmd->efile = efile;
473: 8b 45 f4 mov -0xc(%ebp),%eax
476: 8b 55 10 mov 0x10(%ebp),%edx
479: 89 50 0c mov %edx,0xc(%eax)
cmd->mode = mode;
47c: 8b 45 f4 mov -0xc(%ebp),%eax
47f: 8b 55 14 mov 0x14(%ebp),%edx
482: 89 50 10 mov %edx,0x10(%eax)
cmd->fd = fd;
485: 8b 45 f4 mov -0xc(%ebp),%eax
488: 8b 55 18 mov 0x18(%ebp),%edx
48b: 89 50 14 mov %edx,0x14(%eax)
return (struct cmd*)cmd;
48e: 8b 45 f4 mov -0xc(%ebp),%eax
}
491: c9 leave
492: c3 ret
00000493 <pipecmd>:
struct cmd*
pipecmd(struct cmd *left, struct cmd *right)
{
493: 55 push %ebp
494: 89 e5 mov %esp,%ebp
496: 83 ec 28 sub $0x28,%esp
struct pipecmd *cmd;
cmd = malloc(sizeof(*cmd));
499: c7 04 24 0c 00 00 00 movl $0xc,(%esp)
4a0: e8 72 0f 00 00 call 1417 <malloc>
4a5: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
4a8: c7 44 24 08 0c 00 00 movl $0xc,0x8(%esp)
4af: 00
4b0: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
4b7: 00
4b8: 8b 45 f4 mov -0xc(%ebp),%eax
4bb: 89 04 24 mov %eax,(%esp)
4be: e8 37 09 00 00 call dfa <memset>
cmd->type = PIPE;
4c3: 8b 45 f4 mov -0xc(%ebp),%eax
4c6: c7 00 03 00 00 00 movl $0x3,(%eax)
cmd->left = left;
4cc: 8b 45 f4 mov -0xc(%ebp),%eax
4cf: 8b 55 08 mov 0x8(%ebp),%edx
4d2: 89 50 04 mov %edx,0x4(%eax)
cmd->right = right;
4d5: 8b 45 f4 mov -0xc(%ebp),%eax
4d8: 8b 55 0c mov 0xc(%ebp),%edx
4db: 89 50 08 mov %edx,0x8(%eax)
return (struct cmd*)cmd;
4de: 8b 45 f4 mov -0xc(%ebp),%eax
}
4e1: c9 leave
4e2: c3 ret
000004e3 <listcmd>:
struct cmd*
listcmd(struct cmd *left, struct cmd *right)
{
4e3: 55 push %ebp
4e4: 89 e5 mov %esp,%ebp
4e6: 83 ec 28 sub $0x28,%esp
struct listcmd *cmd;
cmd = malloc(sizeof(*cmd));
4e9: c7 04 24 0c 00 00 00 movl $0xc,(%esp)
4f0: e8 22 0f 00 00 call 1417 <malloc>
4f5: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
4f8: c7 44 24 08 0c 00 00 movl $0xc,0x8(%esp)
4ff: 00
500: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
507: 00
508: 8b 45 f4 mov -0xc(%ebp),%eax
50b: 89 04 24 mov %eax,(%esp)
50e: e8 e7 08 00 00 call dfa <memset>
cmd->type = LIST;
513: 8b 45 f4 mov -0xc(%ebp),%eax
516: c7 00 04 00 00 00 movl $0x4,(%eax)
cmd->left = left;
51c: 8b 45 f4 mov -0xc(%ebp),%eax
51f: 8b 55 08 mov 0x8(%ebp),%edx
522: 89 50 04 mov %edx,0x4(%eax)
cmd->right = right;
525: 8b 45 f4 mov -0xc(%ebp),%eax
528: 8b 55 0c mov 0xc(%ebp),%edx
52b: 89 50 08 mov %edx,0x8(%eax)
return (struct cmd*)cmd;
52e: 8b 45 f4 mov -0xc(%ebp),%eax
}
531: c9 leave
532: c3 ret
00000533 <backcmd>:
struct cmd*
backcmd(struct cmd *subcmd)
{
533: 55 push %ebp
534: 89 e5 mov %esp,%ebp
536: 83 ec 28 sub $0x28,%esp
struct backcmd *cmd;
cmd = malloc(sizeof(*cmd));
539: c7 04 24 08 00 00 00 movl $0x8,(%esp)
540: e8 d2 0e 00 00 call 1417 <malloc>
545: 89 45 f4 mov %eax,-0xc(%ebp)
memset(cmd, 0, sizeof(*cmd));
548: c7 44 24 08 08 00 00 movl $0x8,0x8(%esp)
54f: 00
550: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
557: 00
558: 8b 45 f4 mov -0xc(%ebp),%eax
55b: 89 04 24 mov %eax,(%esp)
55e: e8 97 08 00 00 call dfa <memset>
cmd->type = BACK;
563: 8b 45 f4 mov -0xc(%ebp),%eax
566: c7 00 05 00 00 00 movl $0x5,(%eax)
cmd->cmd = subcmd;
56c: 8b 45 f4 mov -0xc(%ebp),%eax
56f: 8b 55 08 mov 0x8(%ebp),%edx
572: 89 50 04 mov %edx,0x4(%eax)
return (struct cmd*)cmd;
575: 8b 45 f4 mov -0xc(%ebp),%eax
}
578: c9 leave
579: c3 ret
0000057a <gettoken>:
char whitespace[] = " \t\r\n\v";
char symbols[] = "<|>&;()";
int
gettoken(char **ps, char *es, char **q, char **eq)
{
57a: 55 push %ebp
57b: 89 e5 mov %esp,%ebp
57d: 83 ec 28 sub $0x28,%esp
char *s;
int ret;
s = *ps;
580: 8b 45 08 mov 0x8(%ebp),%eax
583: 8b 00 mov (%eax),%eax
585: 89 45 f0 mov %eax,-0x10(%ebp)
while(s < es && strchr(whitespace, *s))
588: eb 04 jmp 58e <gettoken+0x14>
s++;
58a: 83 45 f0 01 addl $0x1,-0x10(%ebp)
{
char *s;
int ret;
s = *ps;
while(s < es && strchr(whitespace, *s))
58e: 8b 45 f0 mov -0x10(%ebp),%eax
591: 3b 45 0c cmp 0xc(%ebp),%eax
594: 73 1d jae 5b3 <gettoken+0x39>
596: 8b 45 f0 mov -0x10(%ebp),%eax
599: 0f b6 00 movzbl (%eax),%eax
59c: 0f be c0 movsbl %al,%eax
59f: 89 44 24 04 mov %eax,0x4(%esp)
5a3: c7 04 24 f0 15 00 00 movl $0x15f0,(%esp)
5aa: e8 6f 08 00 00 call e1e <strchr>
5af: 85 c0 test %eax,%eax
5b1: 75 d7 jne 58a <gettoken+0x10>
s++;
if(q)
5b3: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
5b7: 74 08 je 5c1 <gettoken+0x47>
*q = s;
5b9: 8b 45 10 mov 0x10(%ebp),%eax
5bc: 8b 55 f0 mov -0x10(%ebp),%edx
5bf: 89 10 mov %edx,(%eax)
ret = *s;
5c1: 8b 45 f0 mov -0x10(%ebp),%eax
5c4: 0f b6 00 movzbl (%eax),%eax
5c7: 0f be c0 movsbl %al,%eax
5ca: 89 45 f4 mov %eax,-0xc(%ebp)
switch(*s){
5cd: 8b 45 f0 mov -0x10(%ebp),%eax
5d0: 0f b6 00 movzbl (%eax),%eax
5d3: 0f be c0 movsbl %al,%eax
5d6: 83 f8 3c cmp $0x3c,%eax
5d9: 7f 1e jg 5f9 <gettoken+0x7f>
5db: 83 f8 3b cmp $0x3b,%eax
5de: 7d 23 jge 603 <gettoken+0x89>
5e0: 83 f8 29 cmp $0x29,%eax
5e3: 7f 3f jg 624 <gettoken+0xaa>
5e5: 83 f8 28 cmp $0x28,%eax
5e8: 7d 19 jge 603 <gettoken+0x89>
5ea: 85 c0 test %eax,%eax
5ec: 0f 84 83 00 00 00 je 675 <gettoken+0xfb>
5f2: 83 f8 26 cmp $0x26,%eax
5f5: 74 0c je 603 <gettoken+0x89>
5f7: eb 2b jmp 624 <gettoken+0xaa>
5f9: 83 f8 3e cmp $0x3e,%eax
5fc: 74 0b je 609 <gettoken+0x8f>
5fe: 83 f8 7c cmp $0x7c,%eax
601: 75 21 jne 624 <gettoken+0xaa>
case '(':
case ')':
case ';':
case '&':
case '<':
s++;
603: 83 45 f0 01 addl $0x1,-0x10(%ebp)
break;
607: eb 70 jmp 679 <gettoken+0xff>
case '>':
s++;
609: 83 45 f0 01 addl $0x1,-0x10(%ebp)
if(*s == '>'){
60d: 8b 45 f0 mov -0x10(%ebp),%eax
610: 0f b6 00 movzbl (%eax),%eax
613: 3c 3e cmp $0x3e,%al
615: 75 61 jne 678 <gettoken+0xfe>
ret = '+';
617: c7 45 f4 2b 00 00 00 movl $0x2b,-0xc(%ebp)
s++;
61e: 83 45 f0 01 addl $0x1,-0x10(%ebp)
}
break;
622: eb 55 jmp 679 <gettoken+0xff>
default:
ret = 'a';
624: c7 45 f4 61 00 00 00 movl $0x61,-0xc(%ebp)
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
62b: eb 04 jmp 631 <gettoken+0xb7>
s++;
62d: 83 45 f0 01 addl $0x1,-0x10(%ebp)
s++;
}
break;
default:
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
631: 8b 45 f0 mov -0x10(%ebp),%eax
634: 3b 45 0c cmp 0xc(%ebp),%eax
637: 73 40 jae 679 <gettoken+0xff>
639: 8b 45 f0 mov -0x10(%ebp),%eax
63c: 0f b6 00 movzbl (%eax),%eax
63f: 0f be c0 movsbl %al,%eax
642: 89 44 24 04 mov %eax,0x4(%esp)
646: c7 04 24 f0 15 00 00 movl $0x15f0,(%esp)
64d: e8 cc 07 00 00 call e1e <strchr>
652: 85 c0 test %eax,%eax
654: 75 23 jne 679 <gettoken+0xff>
656: 8b 45 f0 mov -0x10(%ebp),%eax
659: 0f b6 00 movzbl (%eax),%eax
65c: 0f be c0 movsbl %al,%eax
65f: 89 44 24 04 mov %eax,0x4(%esp)
663: c7 04 24 f6 15 00 00 movl $0x15f6,(%esp)
66a: e8 af 07 00 00 call e1e <strchr>
66f: 85 c0 test %eax,%eax
671: 74 ba je 62d <gettoken+0xb3>
673: eb 04 jmp 679 <gettoken+0xff>
if(q)
*q = s;
ret = *s;
switch(*s){
case 0:
break;
675: 90 nop
676: eb 01 jmp 679 <gettoken+0xff>
s++;
if(*s == '>'){
ret = '+';
s++;
}
break;
678: 90 nop
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
s++;
break;
}
if(eq)
679: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
67d: 74 0e je 68d <gettoken+0x113>
*eq = s;
67f: 8b 45 14 mov 0x14(%ebp),%eax
682: 8b 55 f0 mov -0x10(%ebp),%edx
685: 89 10 mov %edx,(%eax)
while(s < es && strchr(whitespace, *s))
687: eb 04 jmp 68d <gettoken+0x113>
s++;
689: 83 45 f0 01 addl $0x1,-0x10(%ebp)
break;
}
if(eq)
*eq = s;
while(s < es && strchr(whitespace, *s))
68d: 8b 45 f0 mov -0x10(%ebp),%eax
690: 3b 45 0c cmp 0xc(%ebp),%eax
693: 73 1d jae 6b2 <gettoken+0x138>
695: 8b 45 f0 mov -0x10(%ebp),%eax
698: 0f b6 00 movzbl (%eax),%eax
69b: 0f be c0 movsbl %al,%eax
69e: 89 44 24 04 mov %eax,0x4(%esp)
6a2: c7 04 24 f0 15 00 00 movl $0x15f0,(%esp)
6a9: e8 70 07 00 00 call e1e <strchr>
6ae: 85 c0 test %eax,%eax
6b0: 75 d7 jne 689 <gettoken+0x10f>
s++;
*ps = s;
6b2: 8b 45 08 mov 0x8(%ebp),%eax
6b5: 8b 55 f0 mov -0x10(%ebp),%edx
6b8: 89 10 mov %edx,(%eax)
return ret;
6ba: 8b 45 f4 mov -0xc(%ebp),%eax
}
6bd: c9 leave
6be: c3 ret
000006bf <peek>:
int
peek(char **ps, char *es, char *toks)
{
6bf: 55 push %ebp
6c0: 89 e5 mov %esp,%ebp
6c2: 83 ec 28 sub $0x28,%esp
char *s;
s = *ps;
6c5: 8b 45 08 mov 0x8(%ebp),%eax
6c8: 8b 00 mov (%eax),%eax
6ca: 89 45 f4 mov %eax,-0xc(%ebp)
while(s < es && strchr(whitespace, *s))
6cd: eb 04 jmp 6d3 <peek+0x14>
s++;
6cf: 83 45 f4 01 addl $0x1,-0xc(%ebp)
peek(char **ps, char *es, char *toks)
{
char *s;
s = *ps;
while(s < es && strchr(whitespace, *s))
6d3: 8b 45 f4 mov -0xc(%ebp),%eax
6d6: 3b 45 0c cmp 0xc(%ebp),%eax
6d9: 73 1d jae 6f8 <peek+0x39>
6db: 8b 45 f4 mov -0xc(%ebp),%eax
6de: 0f b6 00 movzbl (%eax),%eax
6e1: 0f be c0 movsbl %al,%eax
6e4: 89 44 24 04 mov %eax,0x4(%esp)
6e8: c7 04 24 f0 15 00 00 movl $0x15f0,(%esp)
6ef: e8 2a 07 00 00 call e1e <strchr>
6f4: 85 c0 test %eax,%eax
6f6: 75 d7 jne 6cf <peek+0x10>
s++;
*ps = s;
6f8: 8b 45 08 mov 0x8(%ebp),%eax
6fb: 8b 55 f4 mov -0xc(%ebp),%edx
6fe: 89 10 mov %edx,(%eax)
return *s && strchr(toks, *s);
700: 8b 45 f4 mov -0xc(%ebp),%eax
703: 0f b6 00 movzbl (%eax),%eax
706: 84 c0 test %al,%al
708: 74 23 je 72d <peek+0x6e>
70a: 8b 45 f4 mov -0xc(%ebp),%eax
70d: 0f b6 00 movzbl (%eax),%eax
710: 0f be c0 movsbl %al,%eax
713: 89 44 24 04 mov %eax,0x4(%esp)
717: 8b 45 10 mov 0x10(%ebp),%eax
71a: 89 04 24 mov %eax,(%esp)
71d: e8 fc 06 00 00 call e1e <strchr>
722: 85 c0 test %eax,%eax
724: 74 07 je 72d <peek+0x6e>
726: b8 01 00 00 00 mov $0x1,%eax
72b: eb 05 jmp 732 <peek+0x73>
72d: b8 00 00 00 00 mov $0x0,%eax
}
732: c9 leave
733: c3 ret
00000734 <parsecmd>:
struct cmd *parseexec(char**, char*);
struct cmd *nulterminate(struct cmd*);
struct cmd*
parsecmd(char *s)
{
734: 55 push %ebp
735: 89 e5 mov %esp,%ebp
737: 53 push %ebx
738: 83 ec 24 sub $0x24,%esp
char *es;
struct cmd *cmd;
es = s + strlen(s);
73b: 8b 5d 08 mov 0x8(%ebp),%ebx
73e: 8b 45 08 mov 0x8(%ebp),%eax
741: 89 04 24 mov %eax,(%esp)
744: e8 8c 06 00 00 call dd5 <strlen>
749: 8d 04 03 lea (%ebx,%eax,1),%eax
74c: 89 45 f0 mov %eax,-0x10(%ebp)
cmd = parseline(&s, es);
74f: 8b 45 f0 mov -0x10(%ebp),%eax
752: 89 44 24 04 mov %eax,0x4(%esp)
756: 8d 45 08 lea 0x8(%ebp),%eax
759: 89 04 24 mov %eax,(%esp)
75c: e8 60 00 00 00 call 7c1 <parseline>
761: 89 45 f4 mov %eax,-0xc(%ebp)
peek(&s, es, "");
764: c7 44 24 08 5e 15 00 movl $0x155e,0x8(%esp)
76b: 00
76c: 8b 45 f0 mov -0x10(%ebp),%eax
76f: 89 44 24 04 mov %eax,0x4(%esp)
773: 8d 45 08 lea 0x8(%ebp),%eax
776: 89 04 24 mov %eax,(%esp)
779: e8 41 ff ff ff call 6bf <peek>
if(s != es){
77e: 8b 45 08 mov 0x8(%ebp),%eax
781: 3b 45 f0 cmp -0x10(%ebp),%eax
784: 74 27 je 7ad <parsecmd+0x79>
printf(2, "leftovers: %s\n", s);
786: 8b 45 08 mov 0x8(%ebp),%eax
789: 89 44 24 08 mov %eax,0x8(%esp)
78d: c7 44 24 04 5f 15 00 movl $0x155f,0x4(%esp)
794: 00
795: c7 04 24 02 00 00 00 movl $0x2,(%esp)
79c: e8 90 09 00 00 call 1131 <printf>
panic("syntax");
7a1: c7 04 24 6e 15 00 00 movl $0x156e,(%esp)
7a8: e8 eb fb ff ff call 398 <panic>
}
nulterminate(cmd);
7ad: 8b 45 f4 mov -0xc(%ebp),%eax
7b0: 89 04 24 mov %eax,(%esp)
7b3: e8 a4 04 00 00 call c5c <nulterminate>
return cmd;
7b8: 8b 45 f4 mov -0xc(%ebp),%eax
}
7bb: 83 c4 24 add $0x24,%esp
7be: 5b pop %ebx
7bf: 5d pop %ebp
7c0: c3 ret
000007c1 <parseline>:
struct cmd*
parseline(char **ps, char *es)
{
7c1: 55 push %ebp
7c2: 89 e5 mov %esp,%ebp
7c4: 83 ec 28 sub $0x28,%esp
struct cmd *cmd;
cmd = parsepipe(ps, es);
7c7: 8b 45 0c mov 0xc(%ebp),%eax
7ca: 89 44 24 04 mov %eax,0x4(%esp)
7ce: 8b 45 08 mov 0x8(%ebp),%eax
7d1: 89 04 24 mov %eax,(%esp)
7d4: e8 bc 00 00 00 call 895 <parsepipe>
7d9: 89 45 f4 mov %eax,-0xc(%ebp)
while(peek(ps, es, "&")){
7dc: eb 30 jmp 80e <parseline+0x4d>
gettoken(ps, es, 0, 0);
7de: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
7e5: 00
7e6: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp)
7ed: 00
7ee: 8b 45 0c mov 0xc(%ebp),%eax
7f1: 89 44 24 04 mov %eax,0x4(%esp)
7f5: 8b 45 08 mov 0x8(%ebp),%eax
7f8: 89 04 24 mov %eax,(%esp)
7fb: e8 7a fd ff ff call 57a <gettoken>
cmd = backcmd(cmd);
800: 8b 45 f4 mov -0xc(%ebp),%eax
803: 89 04 24 mov %eax,(%esp)
806: e8 28 fd ff ff call 533 <backcmd>
80b: 89 45 f4 mov %eax,-0xc(%ebp)
parseline(char **ps, char *es)
{
struct cmd *cmd;
cmd = parsepipe(ps, es);
while(peek(ps, es, "&")){
80e: c7 44 24 08 75 15 00 movl $0x1575,0x8(%esp)
815: 00
816: 8b 45 0c mov 0xc(%ebp),%eax
819: 89 44 24 04 mov %eax,0x4(%esp)
81d: 8b 45 08 mov 0x8(%ebp),%eax
820: 89 04 24 mov %eax,(%esp)
823: e8 97 fe ff ff call 6bf <peek>
828: 85 c0 test %eax,%eax
82a: 75 b2 jne 7de <parseline+0x1d>
gettoken(ps, es, 0, 0);
cmd = backcmd(cmd);
}
if(peek(ps, es, ";")){
82c: c7 44 24 08 77 15 00 movl $0x1577,0x8(%esp)
833: 00
834: 8b 45 0c mov 0xc(%ebp),%eax
837: 89 44 24 04 mov %eax,0x4(%esp)
83b: 8b 45 08 mov 0x8(%ebp),%eax
83e: 89 04 24 mov %eax,(%esp)
841: e8 79 fe ff ff call 6bf <peek>
846: 85 c0 test %eax,%eax
848: 74 46 je 890 <parseline+0xcf>
gettoken(ps, es, 0, 0);
84a: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
851: 00
852: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp)
859: 00
85a: 8b 45 0c mov 0xc(%ebp),%eax
85d: 89 44 24 04 mov %eax,0x4(%esp)
861: 8b 45 08 mov 0x8(%ebp),%eax
864: 89 04 24 mov %eax,(%esp)
867: e8 0e fd ff ff call 57a <gettoken>
cmd = listcmd(cmd, parseline(ps, es));
86c: 8b 45 0c mov 0xc(%ebp),%eax
86f: 89 44 24 04 mov %eax,0x4(%esp)
873: 8b 45 08 mov 0x8(%ebp),%eax
876: 89 04 24 mov %eax,(%esp)
879: e8 43 ff ff ff call 7c1 <parseline>
87e: 89 44 24 04 mov %eax,0x4(%esp)
882: 8b 45 f4 mov -0xc(%ebp),%eax
885: 89 04 24 mov %eax,(%esp)
888: e8 56 fc ff ff call 4e3 <listcmd>
88d: 89 45 f4 mov %eax,-0xc(%ebp)
}
return cmd;
890: 8b 45 f4 mov -0xc(%ebp),%eax
}
893: c9 leave
894: c3 ret
00000895 <parsepipe>:
struct cmd*
parsepipe(char **ps, char *es)
{
895: 55 push %ebp
896: 89 e5 mov %esp,%ebp
898: 83 ec 28 sub $0x28,%esp
struct cmd *cmd;
cmd = parseexec(ps, es);
89b: 8b 45 0c mov 0xc(%ebp),%eax
89e: 89 44 24 04 mov %eax,0x4(%esp)
8a2: 8b 45 08 mov 0x8(%ebp),%eax
8a5: 89 04 24 mov %eax,(%esp)
8a8: e8 67 02 00 00 call b14 <parseexec>
8ad: 89 45 f4 mov %eax,-0xc(%ebp)
if(peek(ps, es, "|")){
8b0: c7 44 24 08 79 15 00 movl $0x1579,0x8(%esp)
8b7: 00
8b8: 8b 45 0c mov 0xc(%ebp),%eax
8bb: 89 44 24 04 mov %eax,0x4(%esp)
8bf: 8b 45 08 mov 0x8(%ebp),%eax
8c2: 89 04 24 mov %eax,(%esp)
8c5: e8 f5 fd ff ff call 6bf <peek>
8ca: 85 c0 test %eax,%eax
8cc: 74 46 je 914 <parsepipe+0x7f>
gettoken(ps, es, 0, 0);
8ce: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
8d5: 00
8d6: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp)
8dd: 00
8de: 8b 45 0c mov 0xc(%ebp),%eax
8e1: 89 44 24 04 mov %eax,0x4(%esp)
8e5: 8b 45 08 mov 0x8(%ebp),%eax
8e8: 89 04 24 mov %eax,(%esp)
8eb: e8 8a fc ff ff call 57a <gettoken>
cmd = pipecmd(cmd, parsepipe(ps, es));
8f0: 8b 45 0c mov 0xc(%ebp),%eax
8f3: 89 44 24 04 mov %eax,0x4(%esp)
8f7: 8b 45 08 mov 0x8(%ebp),%eax
8fa: 89 04 24 mov %eax,(%esp)
8fd: e8 93 ff ff ff call 895 <parsepipe>
902: 89 44 24 04 mov %eax,0x4(%esp)
906: 8b 45 f4 mov -0xc(%ebp),%eax
909: 89 04 24 mov %eax,(%esp)
90c: e8 82 fb ff ff call 493 <pipecmd>
911: 89 45 f4 mov %eax,-0xc(%ebp)
}
return cmd;
914: 8b 45 f4 mov -0xc(%ebp),%eax
}
917: c9 leave
918: c3 ret
00000919 <parseredirs>:
struct cmd*
parseredirs(struct cmd *cmd, char **ps, char *es)
{
919: 55 push %ebp
91a: 89 e5 mov %esp,%ebp
91c: 83 ec 38 sub $0x38,%esp
int tok;
char *q, *eq;
while(peek(ps, es, "<>")){
91f: e9 f5 00 00 00 jmp a19 <parseredirs+0x100>
tok = gettoken(ps, es, 0, 0);
924: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
92b: 00
92c: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp)
933: 00
934: 8b 45 10 mov 0x10(%ebp),%eax
937: 89 44 24 04 mov %eax,0x4(%esp)
93b: 8b 45 0c mov 0xc(%ebp),%eax
93e: 89 04 24 mov %eax,(%esp)
941: e8 34 fc ff ff call 57a <gettoken>
946: 89 45 f4 mov %eax,-0xc(%ebp)
if(gettoken(ps, es, &q, &eq) != 'a')
949: 8d 45 ec lea -0x14(%ebp),%eax
94c: 89 44 24 0c mov %eax,0xc(%esp)
950: 8d 45 f0 lea -0x10(%ebp),%eax
953: 89 44 24 08 mov %eax,0x8(%esp)
957: 8b 45 10 mov 0x10(%ebp),%eax
95a: 89 44 24 04 mov %eax,0x4(%esp)
95e: 8b 45 0c mov 0xc(%ebp),%eax
961: 89 04 24 mov %eax,(%esp)
964: e8 11 fc ff ff call 57a <gettoken>
969: 83 f8 61 cmp $0x61,%eax
96c: 74 0c je 97a <parseredirs+0x61>
panic("missing file for redirection");
96e: c7 04 24 7b 15 00 00 movl $0x157b,(%esp)
975: e8 1e fa ff ff call 398 <panic>
switch(tok){
97a: 8b 45 f4 mov -0xc(%ebp),%eax
97d: 83 f8 3c cmp $0x3c,%eax
980: 74 0f je 991 <parseredirs+0x78>
982: 83 f8 3e cmp $0x3e,%eax
985: 74 38 je 9bf <parseredirs+0xa6>
987: 83 f8 2b cmp $0x2b,%eax
98a: 74 61 je 9ed <parseredirs+0xd4>
98c: e9 88 00 00 00 jmp a19 <parseredirs+0x100>
case '<':
cmd = redircmd(cmd, q, eq, O_RDONLY, 0);
991: 8b 55 ec mov -0x14(%ebp),%edx
994: 8b 45 f0 mov -0x10(%ebp),%eax
997: c7 44 24 10 00 00 00 movl $0x0,0x10(%esp)
99e: 00
99f: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
9a6: 00
9a7: 89 54 24 08 mov %edx,0x8(%esp)
9ab: 89 44 24 04 mov %eax,0x4(%esp)
9af: 8b 45 08 mov 0x8(%ebp),%eax
9b2: 89 04 24 mov %eax,(%esp)
9b5: e8 6e fa ff ff call 428 <redircmd>
9ba: 89 45 08 mov %eax,0x8(%ebp)
break;
9bd: eb 5a jmp a19 <parseredirs+0x100>
case '>':
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
9bf: 8b 55 ec mov -0x14(%ebp),%edx
9c2: 8b 45 f0 mov -0x10(%ebp),%eax
9c5: c7 44 24 10 01 00 00 movl $0x1,0x10(%esp)
9cc: 00
9cd: c7 44 24 0c 01 02 00 movl $0x201,0xc(%esp)
9d4: 00
9d5: 89 54 24 08 mov %edx,0x8(%esp)
9d9: 89 44 24 04 mov %eax,0x4(%esp)
9dd: 8b 45 08 mov 0x8(%ebp),%eax
9e0: 89 04 24 mov %eax,(%esp)
9e3: e8 40 fa ff ff call 428 <redircmd>
9e8: 89 45 08 mov %eax,0x8(%ebp)
break;
9eb: eb 2c jmp a19 <parseredirs+0x100>
case '+': // >>
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
9ed: 8b 55 ec mov -0x14(%ebp),%edx
9f0: 8b 45 f0 mov -0x10(%ebp),%eax
9f3: c7 44 24 10 01 00 00 movl $0x1,0x10(%esp)
9fa: 00
9fb: c7 44 24 0c 01 02 00 movl $0x201,0xc(%esp)
a02: 00
a03: 89 54 24 08 mov %edx,0x8(%esp)
a07: 89 44 24 04 mov %eax,0x4(%esp)
a0b: 8b 45 08 mov 0x8(%ebp),%eax
a0e: 89 04 24 mov %eax,(%esp)
a11: e8 12 fa ff ff call 428 <redircmd>
a16: 89 45 08 mov %eax,0x8(%ebp)
parseredirs(struct cmd *cmd, char **ps, char *es)
{
int tok;
char *q, *eq;
while(peek(ps, es, "<>")){
a19: c7 44 24 08 98 15 00 movl $0x1598,0x8(%esp)
a20: 00
a21: 8b 45 10 mov 0x10(%ebp),%eax
a24: 89 44 24 04 mov %eax,0x4(%esp)
a28: 8b 45 0c mov 0xc(%ebp),%eax
a2b: 89 04 24 mov %eax,(%esp)
a2e: e8 8c fc ff ff call 6bf <peek>
a33: 85 c0 test %eax,%eax
a35: 0f 85 e9 fe ff ff jne 924 <parseredirs+0xb>
case '+': // >>
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
break;
}
}
return cmd;
a3b: 8b 45 08 mov 0x8(%ebp),%eax
}
a3e: c9 leave
a3f: c3 ret
00000a40 <parseblock>:
struct cmd*
parseblock(char **ps, char *es)
{
a40: 55 push %ebp
a41: 89 e5 mov %esp,%ebp
a43: 83 ec 28 sub $0x28,%esp
struct cmd *cmd;
if(!peek(ps, es, "("))
a46: c7 44 24 08 9b 15 00 movl $0x159b,0x8(%esp)
a4d: 00
a4e: 8b 45 0c mov 0xc(%ebp),%eax
a51: 89 44 24 04 mov %eax,0x4(%esp)
a55: 8b 45 08 mov 0x8(%ebp),%eax
a58: 89 04 24 mov %eax,(%esp)
a5b: e8 5f fc ff ff call 6bf <peek>
a60: 85 c0 test %eax,%eax
a62: 75 0c jne a70 <parseblock+0x30>
panic("parseblock");
a64: c7 04 24 9d 15 00 00 movl $0x159d,(%esp)
a6b: e8 28 f9 ff ff call 398 <panic>
gettoken(ps, es, 0, 0);
a70: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
a77: 00
a78: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp)
a7f: 00
a80: 8b 45 0c mov 0xc(%ebp),%eax
a83: 89 44 24 04 mov %eax,0x4(%esp)
a87: 8b 45 08 mov 0x8(%ebp),%eax
a8a: 89 04 24 mov %eax,(%esp)
a8d: e8 e8 fa ff ff call 57a <gettoken>
cmd = parseline(ps, es);
a92: 8b 45 0c mov 0xc(%ebp),%eax
a95: 89 44 24 04 mov %eax,0x4(%esp)
a99: 8b 45 08 mov 0x8(%ebp),%eax
a9c: 89 04 24 mov %eax,(%esp)
a9f: e8 1d fd ff ff call 7c1 <parseline>
aa4: 89 45 f4 mov %eax,-0xc(%ebp)
if(!peek(ps, es, ")"))
aa7: c7 44 24 08 a8 15 00 movl $0x15a8,0x8(%esp)
aae: 00
aaf: 8b 45 0c mov 0xc(%ebp),%eax
ab2: 89 44 24 04 mov %eax,0x4(%esp)
ab6: 8b 45 08 mov 0x8(%ebp),%eax
ab9: 89 04 24 mov %eax,(%esp)
abc: e8 fe fb ff ff call 6bf <peek>
ac1: 85 c0 test %eax,%eax
ac3: 75 0c jne ad1 <parseblock+0x91>
panic("syntax - missing )");
ac5: c7 04 24 aa 15 00 00 movl $0x15aa,(%esp)
acc: e8 c7 f8 ff ff call 398 <panic>
gettoken(ps, es, 0, 0);
ad1: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
ad8: 00
ad9: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp)
ae0: 00
ae1: 8b 45 0c mov 0xc(%ebp),%eax
ae4: 89 44 24 04 mov %eax,0x4(%esp)
ae8: 8b 45 08 mov 0x8(%ebp),%eax
aeb: 89 04 24 mov %eax,(%esp)
aee: e8 87 fa ff ff call 57a <gettoken>
cmd = parseredirs(cmd, ps, es);
af3: 8b 45 0c mov 0xc(%ebp),%eax
af6: 89 44 24 08 mov %eax,0x8(%esp)
afa: 8b 45 08 mov 0x8(%ebp),%eax
afd: 89 44 24 04 mov %eax,0x4(%esp)
b01: 8b 45 f4 mov -0xc(%ebp),%eax
b04: 89 04 24 mov %eax,(%esp)
b07: e8 0d fe ff ff call 919 <parseredirs>
b0c: 89 45 f4 mov %eax,-0xc(%ebp)
return cmd;
b0f: 8b 45 f4 mov -0xc(%ebp),%eax
}
b12: c9 leave
b13: c3 ret
00000b14 <parseexec>:
struct cmd*
parseexec(char **ps, char *es)
{
b14: 55 push %ebp
b15: 89 e5 mov %esp,%ebp
b17: 83 ec 38 sub $0x38,%esp
char *q, *eq;
int tok, argc;
struct execcmd *cmd;
struct cmd *ret;
if(peek(ps, es, "("))
b1a: c7 44 24 08 9b 15 00 movl $0x159b,0x8(%esp)
b21: 00
b22: 8b 45 0c mov 0xc(%ebp),%eax
b25: 89 44 24 04 mov %eax,0x4(%esp)
b29: 8b 45 08 mov 0x8(%ebp),%eax
b2c: 89 04 24 mov %eax,(%esp)
b2f: e8 8b fb ff ff call 6bf <peek>
b34: 85 c0 test %eax,%eax
b36: 74 17 je b4f <parseexec+0x3b>
return parseblock(ps, es);
b38: 8b 45 0c mov 0xc(%ebp),%eax
b3b: 89 44 24 04 mov %eax,0x4(%esp)
b3f: 8b 45 08 mov 0x8(%ebp),%eax
b42: 89 04 24 mov %eax,(%esp)
b45: e8 f6 fe ff ff call a40 <parseblock>
b4a: e9 0b 01 00 00 jmp c5a <parseexec+0x146>
ret = execcmd();
b4f: e8 96 f8 ff ff call 3ea <execcmd>
b54: 89 45 f4 mov %eax,-0xc(%ebp)
cmd = (struct execcmd*)ret;
b57: 8b 45 f4 mov -0xc(%ebp),%eax
b5a: 89 45 f0 mov %eax,-0x10(%ebp)
argc = 0;
b5d: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ret = parseredirs(ret, ps, es);
b64: 8b 45 0c mov 0xc(%ebp),%eax
b67: 89 44 24 08 mov %eax,0x8(%esp)
b6b: 8b 45 08 mov 0x8(%ebp),%eax
b6e: 89 44 24 04 mov %eax,0x4(%esp)
b72: 8b 45 f4 mov -0xc(%ebp),%eax
b75: 89 04 24 mov %eax,(%esp)
b78: e8 9c fd ff ff call 919 <parseredirs>
b7d: 89 45 f4 mov %eax,-0xc(%ebp)
while(!peek(ps, es, "|)&;")){
b80: e9 8e 00 00 00 jmp c13 <parseexec+0xff>
if((tok=gettoken(ps, es, &q, &eq)) == 0)
b85: 8d 45 e0 lea -0x20(%ebp),%eax
b88: 89 44 24 0c mov %eax,0xc(%esp)
b8c: 8d 45 e4 lea -0x1c(%ebp),%eax
b8f: 89 44 24 08 mov %eax,0x8(%esp)
b93: 8b 45 0c mov 0xc(%ebp),%eax
b96: 89 44 24 04 mov %eax,0x4(%esp)
b9a: 8b 45 08 mov 0x8(%ebp),%eax
b9d: 89 04 24 mov %eax,(%esp)
ba0: e8 d5 f9 ff ff call 57a <gettoken>
ba5: 89 45 e8 mov %eax,-0x18(%ebp)
ba8: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
bac: 0f 84 85 00 00 00 je c37 <parseexec+0x123>
break;
if(tok != 'a')
bb2: 83 7d e8 61 cmpl $0x61,-0x18(%ebp)
bb6: 74 0c je bc4 <parseexec+0xb0>
panic("syntax");
bb8: c7 04 24 6e 15 00 00 movl $0x156e,(%esp)
bbf: e8 d4 f7 ff ff call 398 <panic>
cmd->argv[argc] = q;
bc4: 8b 55 ec mov -0x14(%ebp),%edx
bc7: 8b 4d e4 mov -0x1c(%ebp),%ecx
bca: 8b 45 f0 mov -0x10(%ebp),%eax
bcd: 89 4c 90 04 mov %ecx,0x4(%eax,%edx,4)
cmd->eargv[argc] = eq;
bd1: 8b 4d ec mov -0x14(%ebp),%ecx
bd4: 8b 55 e0 mov -0x20(%ebp),%edx
bd7: 8b 45 f0 mov -0x10(%ebp),%eax
bda: 83 c1 08 add $0x8,%ecx
bdd: 89 54 88 0c mov %edx,0xc(%eax,%ecx,4)
argc++;
be1: 83 45 ec 01 addl $0x1,-0x14(%ebp)
if(argc >= MAXARGS)
be5: 83 7d ec 09 cmpl $0x9,-0x14(%ebp)
be9: 7e 0c jle bf7 <parseexec+0xe3>
panic("too many args");
beb: c7 04 24 bd 15 00 00 movl $0x15bd,(%esp)
bf2: e8 a1 f7 ff ff call 398 <panic>
ret = parseredirs(ret, ps, es);
bf7: 8b 45 0c mov 0xc(%ebp),%eax
bfa: 89 44 24 08 mov %eax,0x8(%esp)
bfe: 8b 45 08 mov 0x8(%ebp),%eax
c01: 89 44 24 04 mov %eax,0x4(%esp)
c05: 8b 45 f4 mov -0xc(%ebp),%eax
c08: 89 04 24 mov %eax,(%esp)
c0b: e8 09 fd ff ff call 919 <parseredirs>
c10: 89 45 f4 mov %eax,-0xc(%ebp)
ret = execcmd();
cmd = (struct execcmd*)ret;
argc = 0;
ret = parseredirs(ret, ps, es);
while(!peek(ps, es, "|)&;")){
c13: c7 44 24 08 cb 15 00 movl $0x15cb,0x8(%esp)
c1a: 00
c1b: 8b 45 0c mov 0xc(%ebp),%eax
c1e: 89 44 24 04 mov %eax,0x4(%esp)
c22: 8b 45 08 mov 0x8(%ebp),%eax
c25: 89 04 24 mov %eax,(%esp)
c28: e8 92 fa ff ff call 6bf <peek>
c2d: 85 c0 test %eax,%eax
c2f: 0f 84 50 ff ff ff je b85 <parseexec+0x71>
c35: eb 01 jmp c38 <parseexec+0x124>
if((tok=gettoken(ps, es, &q, &eq)) == 0)
break;
c37: 90 nop
argc++;
if(argc >= MAXARGS)
panic("too many args");
ret = parseredirs(ret, ps, es);
}
cmd->argv[argc] = 0;
c38: 8b 55 ec mov -0x14(%ebp),%edx
c3b: 8b 45 f0 mov -0x10(%ebp),%eax
c3e: c7 44 90 04 00 00 00 movl $0x0,0x4(%eax,%edx,4)
c45: 00
cmd->eargv[argc] = 0;
c46: 8b 55 ec mov -0x14(%ebp),%edx
c49: 8b 45 f0 mov -0x10(%ebp),%eax
c4c: 83 c2 08 add $0x8,%edx
c4f: c7 44 90 0c 00 00 00 movl $0x0,0xc(%eax,%edx,4)
c56: 00
return ret;
c57: 8b 45 f4 mov -0xc(%ebp),%eax
}
c5a: c9 leave
c5b: c3 ret
00000c5c <nulterminate>:
// NUL-terminate all the counted strings.
struct cmd*
nulterminate(struct cmd *cmd)
{
c5c: 55 push %ebp
c5d: 89 e5 mov %esp,%ebp
c5f: 83 ec 38 sub $0x38,%esp
struct execcmd *ecmd;
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
c62: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
c66: 75 0a jne c72 <nulterminate+0x16>
return 0;
c68: b8 00 00 00 00 mov $0x0,%eax
c6d: e9 c8 00 00 00 jmp d3a <nulterminate+0xde>
switch(cmd->type){
c72: 8b 45 08 mov 0x8(%ebp),%eax
c75: 8b 00 mov (%eax),%eax
c77: 83 f8 05 cmp $0x5,%eax
c7a: 0f 87 b7 00 00 00 ja d37 <nulterminate+0xdb>
c80: 8b 04 85 d0 15 00 00 mov 0x15d0(,%eax,4),%eax
c87: ff e0 jmp *%eax
case EXEC:
ecmd = (struct execcmd*)cmd;
c89: 8b 45 08 mov 0x8(%ebp),%eax
c8c: 89 45 e8 mov %eax,-0x18(%ebp)
for(i=0; ecmd->argv[i]; i++)
c8f: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp)
c96: eb 14 jmp cac <nulterminate+0x50>
*ecmd->eargv[i] = 0;
c98: 8b 55 e0 mov -0x20(%ebp),%edx
c9b: 8b 45 e8 mov -0x18(%ebp),%eax
c9e: 83 c2 08 add $0x8,%edx
ca1: 8b 44 90 0c mov 0xc(%eax,%edx,4),%eax
ca5: c6 00 00 movb $0x0,(%eax)
return 0;
switch(cmd->type){
case EXEC:
ecmd = (struct execcmd*)cmd;
for(i=0; ecmd->argv[i]; i++)
ca8: 83 45 e0 01 addl $0x1,-0x20(%ebp)
cac: 8b 55 e0 mov -0x20(%ebp),%edx
caf: 8b 45 e8 mov -0x18(%ebp),%eax
cb2: 8b 44 90 04 mov 0x4(%eax,%edx,4),%eax
cb6: 85 c0 test %eax,%eax
cb8: 75 de jne c98 <nulterminate+0x3c>
*ecmd->eargv[i] = 0;
break;
cba: eb 7b jmp d37 <nulterminate+0xdb>
case REDIR:
rcmd = (struct redircmd*)cmd;
cbc: 8b 45 08 mov 0x8(%ebp),%eax
cbf: 89 45 f4 mov %eax,-0xc(%ebp)
nulterminate(rcmd->cmd);
cc2: 8b 45 f4 mov -0xc(%ebp),%eax
cc5: 8b 40 04 mov 0x4(%eax),%eax
cc8: 89 04 24 mov %eax,(%esp)
ccb: e8 8c ff ff ff call c5c <nulterminate>
*rcmd->efile = 0;
cd0: 8b 45 f4 mov -0xc(%ebp),%eax
cd3: 8b 40 0c mov 0xc(%eax),%eax
cd6: c6 00 00 movb $0x0,(%eax)
break;
cd9: eb 5c jmp d37 <nulterminate+0xdb>
case PIPE:
pcmd = (struct pipecmd*)cmd;
cdb: 8b 45 08 mov 0x8(%ebp),%eax
cde: 89 45 f0 mov %eax,-0x10(%ebp)
nulterminate(pcmd->left);
ce1: 8b 45 f0 mov -0x10(%ebp),%eax
ce4: 8b 40 04 mov 0x4(%eax),%eax
ce7: 89 04 24 mov %eax,(%esp)
cea: e8 6d ff ff ff call c5c <nulterminate>
nulterminate(pcmd->right);
cef: 8b 45 f0 mov -0x10(%ebp),%eax
cf2: 8b 40 08 mov 0x8(%eax),%eax
cf5: 89 04 24 mov %eax,(%esp)
cf8: e8 5f ff ff ff call c5c <nulterminate>
break;
cfd: eb 38 jmp d37 <nulterminate+0xdb>
case LIST:
lcmd = (struct listcmd*)cmd;
cff: 8b 45 08 mov 0x8(%ebp),%eax
d02: 89 45 ec mov %eax,-0x14(%ebp)
nulterminate(lcmd->left);
d05: 8b 45 ec mov -0x14(%ebp),%eax
d08: 8b 40 04 mov 0x4(%eax),%eax
d0b: 89 04 24 mov %eax,(%esp)
d0e: e8 49 ff ff ff call c5c <nulterminate>
nulterminate(lcmd->right);
d13: 8b 45 ec mov -0x14(%ebp),%eax
d16: 8b 40 08 mov 0x8(%eax),%eax
d19: 89 04 24 mov %eax,(%esp)
d1c: e8 3b ff ff ff call c5c <nulterminate>
break;
d21: eb 14 jmp d37 <nulterminate+0xdb>
case BACK:
bcmd = (struct backcmd*)cmd;
d23: 8b 45 08 mov 0x8(%ebp),%eax
d26: 89 45 e4 mov %eax,-0x1c(%ebp)
nulterminate(bcmd->cmd);
d29: 8b 45 e4 mov -0x1c(%ebp),%eax
d2c: 8b 40 04 mov 0x4(%eax),%eax
d2f: 89 04 24 mov %eax,(%esp)
d32: e8 25 ff ff ff call c5c <nulterminate>
break;
}
return cmd;
d37: 8b 45 08 mov 0x8(%ebp),%eax
}
d3a: c9 leave
d3b: c3 ret
00000d3c <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
d3c: 55 push %ebp
d3d: 89 e5 mov %esp,%ebp
d3f: 57 push %edi
d40: 53 push %ebx
asm volatile("cld; rep stosb" :
d41: 8b 4d 08 mov 0x8(%ebp),%ecx
d44: 8b 55 10 mov 0x10(%ebp),%edx
d47: 8b 45 0c mov 0xc(%ebp),%eax
d4a: 89 cb mov %ecx,%ebx
d4c: 89 df mov %ebx,%edi
d4e: 89 d1 mov %edx,%ecx
d50: fc cld
d51: f3 aa rep stos %al,%es:(%edi)
d53: 89 ca mov %ecx,%edx
d55: 89 fb mov %edi,%ebx
d57: 89 5d 08 mov %ebx,0x8(%ebp)
d5a: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
d5d: 5b pop %ebx
d5e: 5f pop %edi
d5f: 5d pop %ebp
d60: c3 ret
00000d61 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
d61: 55 push %ebp
d62: 89 e5 mov %esp,%ebp
d64: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
d67: 8b 45 08 mov 0x8(%ebp),%eax
d6a: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
d6d: 8b 45 0c mov 0xc(%ebp),%eax
d70: 0f b6 10 movzbl (%eax),%edx
d73: 8b 45 08 mov 0x8(%ebp),%eax
d76: 88 10 mov %dl,(%eax)
d78: 8b 45 08 mov 0x8(%ebp),%eax
d7b: 0f b6 00 movzbl (%eax),%eax
d7e: 84 c0 test %al,%al
d80: 0f 95 c0 setne %al
d83: 83 45 08 01 addl $0x1,0x8(%ebp)
d87: 83 45 0c 01 addl $0x1,0xc(%ebp)
d8b: 84 c0 test %al,%al
d8d: 75 de jne d6d <strcpy+0xc>
;
return os;
d8f: 8b 45 fc mov -0x4(%ebp),%eax
}
d92: c9 leave
d93: c3 ret
00000d94 <strcmp>:
int
strcmp(const char *p, const char *q)
{
d94: 55 push %ebp
d95: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
d97: eb 08 jmp da1 <strcmp+0xd>
p++, q++;
d99: 83 45 08 01 addl $0x1,0x8(%ebp)
d9d: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
da1: 8b 45 08 mov 0x8(%ebp),%eax
da4: 0f b6 00 movzbl (%eax),%eax
da7: 84 c0 test %al,%al
da9: 74 10 je dbb <strcmp+0x27>
dab: 8b 45 08 mov 0x8(%ebp),%eax
dae: 0f b6 10 movzbl (%eax),%edx
db1: 8b 45 0c mov 0xc(%ebp),%eax
db4: 0f b6 00 movzbl (%eax),%eax
db7: 38 c2 cmp %al,%dl
db9: 74 de je d99 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
dbb: 8b 45 08 mov 0x8(%ebp),%eax
dbe: 0f b6 00 movzbl (%eax),%eax
dc1: 0f b6 d0 movzbl %al,%edx
dc4: 8b 45 0c mov 0xc(%ebp),%eax
dc7: 0f b6 00 movzbl (%eax),%eax
dca: 0f b6 c0 movzbl %al,%eax
dcd: 89 d1 mov %edx,%ecx
dcf: 29 c1 sub %eax,%ecx
dd1: 89 c8 mov %ecx,%eax
}
dd3: 5d pop %ebp
dd4: c3 ret
00000dd5 <strlen>:
uint
strlen(char *s)
{
dd5: 55 push %ebp
dd6: 89 e5 mov %esp,%ebp
dd8: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
ddb: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
de2: eb 04 jmp de8 <strlen+0x13>
de4: 83 45 fc 01 addl $0x1,-0x4(%ebp)
de8: 8b 45 fc mov -0x4(%ebp),%eax
deb: 03 45 08 add 0x8(%ebp),%eax
dee: 0f b6 00 movzbl (%eax),%eax
df1: 84 c0 test %al,%al
df3: 75 ef jne de4 <strlen+0xf>
;
return n;
df5: 8b 45 fc mov -0x4(%ebp),%eax
}
df8: c9 leave
df9: c3 ret
00000dfa <memset>:
void*
memset(void *dst, int c, uint n)
{
dfa: 55 push %ebp
dfb: 89 e5 mov %esp,%ebp
dfd: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
e00: 8b 45 10 mov 0x10(%ebp),%eax
e03: 89 44 24 08 mov %eax,0x8(%esp)
e07: 8b 45 0c mov 0xc(%ebp),%eax
e0a: 89 44 24 04 mov %eax,0x4(%esp)
e0e: 8b 45 08 mov 0x8(%ebp),%eax
e11: 89 04 24 mov %eax,(%esp)
e14: e8 23 ff ff ff call d3c <stosb>
return dst;
e19: 8b 45 08 mov 0x8(%ebp),%eax
}
e1c: c9 leave
e1d: c3 ret
00000e1e <strchr>:
char*
strchr(const char *s, char c)
{
e1e: 55 push %ebp
e1f: 89 e5 mov %esp,%ebp
e21: 83 ec 04 sub $0x4,%esp
e24: 8b 45 0c mov 0xc(%ebp),%eax
e27: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
e2a: eb 14 jmp e40 <strchr+0x22>
if(*s == c)
e2c: 8b 45 08 mov 0x8(%ebp),%eax
e2f: 0f b6 00 movzbl (%eax),%eax
e32: 3a 45 fc cmp -0x4(%ebp),%al
e35: 75 05 jne e3c <strchr+0x1e>
return (char*)s;
e37: 8b 45 08 mov 0x8(%ebp),%eax
e3a: eb 13 jmp e4f <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
e3c: 83 45 08 01 addl $0x1,0x8(%ebp)
e40: 8b 45 08 mov 0x8(%ebp),%eax
e43: 0f b6 00 movzbl (%eax),%eax
e46: 84 c0 test %al,%al
e48: 75 e2 jne e2c <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
e4a: b8 00 00 00 00 mov $0x0,%eax
}
e4f: c9 leave
e50: c3 ret
00000e51 <gets>:
char*
gets(char *buf, int max)
{
e51: 55 push %ebp
e52: 89 e5 mov %esp,%ebp
e54: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
e57: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
e5e: eb 44 jmp ea4 <gets+0x53>
cc = read(0, &c, 1);
e60: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
e67: 00
e68: 8d 45 ef lea -0x11(%ebp),%eax
e6b: 89 44 24 04 mov %eax,0x4(%esp)
e6f: c7 04 24 00 00 00 00 movl $0x0,(%esp)
e76: e8 45 01 00 00 call fc0 <read>
e7b: 89 45 f4 mov %eax,-0xc(%ebp)
if(cc < 1)
e7e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
e82: 7e 2d jle eb1 <gets+0x60>
break;
buf[i++] = c;
e84: 8b 45 f0 mov -0x10(%ebp),%eax
e87: 03 45 08 add 0x8(%ebp),%eax
e8a: 0f b6 55 ef movzbl -0x11(%ebp),%edx
e8e: 88 10 mov %dl,(%eax)
e90: 83 45 f0 01 addl $0x1,-0x10(%ebp)
if(c == '\n' || c == '\r')
e94: 0f b6 45 ef movzbl -0x11(%ebp),%eax
e98: 3c 0a cmp $0xa,%al
e9a: 74 16 je eb2 <gets+0x61>
e9c: 0f b6 45 ef movzbl -0x11(%ebp),%eax
ea0: 3c 0d cmp $0xd,%al
ea2: 74 0e je eb2 <gets+0x61>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
ea4: 8b 45 f0 mov -0x10(%ebp),%eax
ea7: 83 c0 01 add $0x1,%eax
eaa: 3b 45 0c cmp 0xc(%ebp),%eax
ead: 7c b1 jl e60 <gets+0xf>
eaf: eb 01 jmp eb2 <gets+0x61>
cc = read(0, &c, 1);
if(cc < 1)
break;
eb1: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
eb2: 8b 45 f0 mov -0x10(%ebp),%eax
eb5: 03 45 08 add 0x8(%ebp),%eax
eb8: c6 00 00 movb $0x0,(%eax)
return buf;
ebb: 8b 45 08 mov 0x8(%ebp),%eax
}
ebe: c9 leave
ebf: c3 ret
00000ec0 <stat>:
int
stat(char *n, struct stat *st)
{
ec0: 55 push %ebp
ec1: 89 e5 mov %esp,%ebp
ec3: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
ec6: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
ecd: 00
ece: 8b 45 08 mov 0x8(%ebp),%eax
ed1: 89 04 24 mov %eax,(%esp)
ed4: e8 0f 01 00 00 call fe8 <open>
ed9: 89 45 f0 mov %eax,-0x10(%ebp)
if(fd < 0)
edc: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
ee0: 79 07 jns ee9 <stat+0x29>
return -1;
ee2: b8 ff ff ff ff mov $0xffffffff,%eax
ee7: eb 23 jmp f0c <stat+0x4c>
r = fstat(fd, st);
ee9: 8b 45 0c mov 0xc(%ebp),%eax
eec: 89 44 24 04 mov %eax,0x4(%esp)
ef0: 8b 45 f0 mov -0x10(%ebp),%eax
ef3: 89 04 24 mov %eax,(%esp)
ef6: e8 05 01 00 00 call 1000 <fstat>
efb: 89 45 f4 mov %eax,-0xc(%ebp)
close(fd);
efe: 8b 45 f0 mov -0x10(%ebp),%eax
f01: 89 04 24 mov %eax,(%esp)
f04: e8 c7 00 00 00 call fd0 <close>
return r;
f09: 8b 45 f4 mov -0xc(%ebp),%eax
}
f0c: c9 leave
f0d: c3 ret
00000f0e <atoi>:
int
atoi(const char *s)
{
f0e: 55 push %ebp
f0f: 89 e5 mov %esp,%ebp
f11: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
f14: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
f1b: eb 24 jmp f41 <atoi+0x33>
n = n*10 + *s++ - '0';
f1d: 8b 55 fc mov -0x4(%ebp),%edx
f20: 89 d0 mov %edx,%eax
f22: c1 e0 02 shl $0x2,%eax
f25: 01 d0 add %edx,%eax
f27: 01 c0 add %eax,%eax
f29: 89 c2 mov %eax,%edx
f2b: 8b 45 08 mov 0x8(%ebp),%eax
f2e: 0f b6 00 movzbl (%eax),%eax
f31: 0f be c0 movsbl %al,%eax
f34: 8d 04 02 lea (%edx,%eax,1),%eax
f37: 83 e8 30 sub $0x30,%eax
f3a: 89 45 fc mov %eax,-0x4(%ebp)
f3d: 83 45 08 01 addl $0x1,0x8(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
f41: 8b 45 08 mov 0x8(%ebp),%eax
f44: 0f b6 00 movzbl (%eax),%eax
f47: 3c 2f cmp $0x2f,%al
f49: 7e 0a jle f55 <atoi+0x47>
f4b: 8b 45 08 mov 0x8(%ebp),%eax
f4e: 0f b6 00 movzbl (%eax),%eax
f51: 3c 39 cmp $0x39,%al
f53: 7e c8 jle f1d <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
f55: 8b 45 fc mov -0x4(%ebp),%eax
}
f58: c9 leave
f59: c3 ret
00000f5a <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
f5a: 55 push %ebp
f5b: 89 e5 mov %esp,%ebp
f5d: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
f60: 8b 45 08 mov 0x8(%ebp),%eax
f63: 89 45 f8 mov %eax,-0x8(%ebp)
src = vsrc;
f66: 8b 45 0c mov 0xc(%ebp),%eax
f69: 89 45 fc mov %eax,-0x4(%ebp)
while(n-- > 0)
f6c: eb 13 jmp f81 <memmove+0x27>
*dst++ = *src++;
f6e: 8b 45 fc mov -0x4(%ebp),%eax
f71: 0f b6 10 movzbl (%eax),%edx
f74: 8b 45 f8 mov -0x8(%ebp),%eax
f77: 88 10 mov %dl,(%eax)
f79: 83 45 f8 01 addl $0x1,-0x8(%ebp)
f7d: 83 45 fc 01 addl $0x1,-0x4(%ebp)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
f81: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
f85: 0f 9f c0 setg %al
f88: 83 6d 10 01 subl $0x1,0x10(%ebp)
f8c: 84 c0 test %al,%al
f8e: 75 de jne f6e <memmove+0x14>
*dst++ = *src++;
return vdst;
f90: 8b 45 08 mov 0x8(%ebp),%eax
}
f93: c9 leave
f94: c3 ret
f95: 90 nop
f96: 90 nop
f97: 90 nop
00000f98 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
f98: b8 01 00 00 00 mov $0x1,%eax
f9d: cd 40 int $0x40
f9f: c3 ret
00000fa0 <exit>:
SYSCALL(exit)
fa0: b8 02 00 00 00 mov $0x2,%eax
fa5: cd 40 int $0x40
fa7: c3 ret
00000fa8 <wait>:
SYSCALL(wait)
fa8: b8 03 00 00 00 mov $0x3,%eax
fad: cd 40 int $0x40
faf: c3 ret
00000fb0 <waitpid>:
SYSCALL(waitpid)
fb0: b8 17 00 00 00 mov $0x17,%eax
fb5: cd 40 int $0x40
fb7: c3 ret
00000fb8 <pipe>:
SYSCALL(pipe)
fb8: b8 04 00 00 00 mov $0x4,%eax
fbd: cd 40 int $0x40
fbf: c3 ret
00000fc0 <read>:
SYSCALL(read)
fc0: b8 05 00 00 00 mov $0x5,%eax
fc5: cd 40 int $0x40
fc7: c3 ret
00000fc8 <write>:
SYSCALL(write)
fc8: b8 10 00 00 00 mov $0x10,%eax
fcd: cd 40 int $0x40
fcf: c3 ret
00000fd0 <close>:
SYSCALL(close)
fd0: b8 15 00 00 00 mov $0x15,%eax
fd5: cd 40 int $0x40
fd7: c3 ret
00000fd8 <kill>:
SYSCALL(kill)
fd8: b8 06 00 00 00 mov $0x6,%eax
fdd: cd 40 int $0x40
fdf: c3 ret
00000fe0 <exec>:
SYSCALL(exec)
fe0: b8 07 00 00 00 mov $0x7,%eax
fe5: cd 40 int $0x40
fe7: c3 ret
00000fe8 <open>:
SYSCALL(open)
fe8: b8 0f 00 00 00 mov $0xf,%eax
fed: cd 40 int $0x40
fef: c3 ret
00000ff0 <mknod>:
SYSCALL(mknod)
ff0: b8 11 00 00 00 mov $0x11,%eax
ff5: cd 40 int $0x40
ff7: c3 ret
00000ff8 <unlink>:
SYSCALL(unlink)
ff8: b8 12 00 00 00 mov $0x12,%eax
ffd: cd 40 int $0x40
fff: c3 ret
00001000 <fstat>:
SYSCALL(fstat)
1000: b8 08 00 00 00 mov $0x8,%eax
1005: cd 40 int $0x40
1007: c3 ret
00001008 <link>:
SYSCALL(link)
1008: b8 13 00 00 00 mov $0x13,%eax
100d: cd 40 int $0x40
100f: c3 ret
00001010 <mkdir>:
SYSCALL(mkdir)
1010: b8 14 00 00 00 mov $0x14,%eax
1015: cd 40 int $0x40
1017: c3 ret
00001018 <chdir>:
SYSCALL(chdir)
1018: b8 09 00 00 00 mov $0x9,%eax
101d: cd 40 int $0x40
101f: c3 ret
00001020 <dup>:
SYSCALL(dup)
1020: b8 0a 00 00 00 mov $0xa,%eax
1025: cd 40 int $0x40
1027: c3 ret
00001028 <getpid>:
SYSCALL(getpid)
1028: b8 0b 00 00 00 mov $0xb,%eax
102d: cd 40 int $0x40
102f: c3 ret
00001030 <sbrk>:
SYSCALL(sbrk)
1030: b8 0c 00 00 00 mov $0xc,%eax
1035: cd 40 int $0x40
1037: c3 ret
00001038 <sleep>:
SYSCALL(sleep)
1038: b8 0d 00 00 00 mov $0xd,%eax
103d: cd 40 int $0x40
103f: c3 ret
00001040 <uptime>:
SYSCALL(uptime)
1040: b8 0e 00 00 00 mov $0xe,%eax
1045: cd 40 int $0x40
1047: c3 ret
00001048 <count>:
SYSCALL(count)
1048: b8 16 00 00 00 mov $0x16,%eax
104d: cd 40 int $0x40
104f: c3 ret
00001050 <change_priority>:
SYSCALL(change_priority)
1050: b8 18 00 00 00 mov $0x18,%eax
1055: cd 40 int $0x40
1057: c3 ret
00001058 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
1058: 55 push %ebp
1059: 89 e5 mov %esp,%ebp
105b: 83 ec 28 sub $0x28,%esp
105e: 8b 45 0c mov 0xc(%ebp),%eax
1061: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
1064: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
106b: 00
106c: 8d 45 f4 lea -0xc(%ebp),%eax
106f: 89 44 24 04 mov %eax,0x4(%esp)
1073: 8b 45 08 mov 0x8(%ebp),%eax
1076: 89 04 24 mov %eax,(%esp)
1079: e8 4a ff ff ff call fc8 <write>
}
107e: c9 leave
107f: c3 ret
00001080 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
1080: 55 push %ebp
1081: 89 e5 mov %esp,%ebp
1083: 53 push %ebx
1084: 83 ec 44 sub $0x44,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
1087: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
108e: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
1092: 74 17 je 10ab <printint+0x2b>
1094: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
1098: 79 11 jns 10ab <printint+0x2b>
neg = 1;
109a: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
10a1: 8b 45 0c mov 0xc(%ebp),%eax
10a4: f7 d8 neg %eax
10a6: 89 45 f4 mov %eax,-0xc(%ebp)
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
10a9: eb 06 jmp 10b1 <printint+0x31>
neg = 1;
x = -xx;
} else {
x = xx;
10ab: 8b 45 0c mov 0xc(%ebp),%eax
10ae: 89 45 f4 mov %eax,-0xc(%ebp)
}
i = 0;
10b1: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
do{
buf[i++] = digits[x % base];
10b8: 8b 4d ec mov -0x14(%ebp),%ecx
10bb: 8b 5d 10 mov 0x10(%ebp),%ebx
10be: 8b 45 f4 mov -0xc(%ebp),%eax
10c1: ba 00 00 00 00 mov $0x0,%edx
10c6: f7 f3 div %ebx
10c8: 89 d0 mov %edx,%eax
10ca: 0f b6 80 00 16 00 00 movzbl 0x1600(%eax),%eax
10d1: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
10d5: 83 45 ec 01 addl $0x1,-0x14(%ebp)
}while((x /= base) != 0);
10d9: 8b 45 10 mov 0x10(%ebp),%eax
10dc: 89 45 d4 mov %eax,-0x2c(%ebp)
10df: 8b 45 f4 mov -0xc(%ebp),%eax
10e2: ba 00 00 00 00 mov $0x0,%edx
10e7: f7 75 d4 divl -0x2c(%ebp)
10ea: 89 45 f4 mov %eax,-0xc(%ebp)
10ed: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
10f1: 75 c5 jne 10b8 <printint+0x38>
if(neg)
10f3: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
10f7: 74 28 je 1121 <printint+0xa1>
buf[i++] = '-';
10f9: 8b 45 ec mov -0x14(%ebp),%eax
10fc: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
1101: 83 45 ec 01 addl $0x1,-0x14(%ebp)
while(--i >= 0)
1105: eb 1a jmp 1121 <printint+0xa1>
putc(fd, buf[i]);
1107: 8b 45 ec mov -0x14(%ebp),%eax
110a: 0f b6 44 05 dc movzbl -0x24(%ebp,%eax,1),%eax
110f: 0f be c0 movsbl %al,%eax
1112: 89 44 24 04 mov %eax,0x4(%esp)
1116: 8b 45 08 mov 0x8(%ebp),%eax
1119: 89 04 24 mov %eax,(%esp)
111c: e8 37 ff ff ff call 1058 <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
1121: 83 6d ec 01 subl $0x1,-0x14(%ebp)
1125: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1129: 79 dc jns 1107 <printint+0x87>
putc(fd, buf[i]);
}
112b: 83 c4 44 add $0x44,%esp
112e: 5b pop %ebx
112f: 5d pop %ebp
1130: c3 ret
00001131 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
1131: 55 push %ebp
1132: 89 e5 mov %esp,%ebp
1134: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
1137: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
ap = (uint*)(void*)&fmt + 1;
113e: 8d 45 0c lea 0xc(%ebp),%eax
1141: 83 c0 04 add $0x4,%eax
1144: 89 45 f4 mov %eax,-0xc(%ebp)
for(i = 0; fmt[i]; i++){
1147: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
114e: e9 7e 01 00 00 jmp 12d1 <printf+0x1a0>
c = fmt[i] & 0xff;
1153: 8b 55 0c mov 0xc(%ebp),%edx
1156: 8b 45 ec mov -0x14(%ebp),%eax
1159: 8d 04 02 lea (%edx,%eax,1),%eax
115c: 0f b6 00 movzbl (%eax),%eax
115f: 0f be c0 movsbl %al,%eax
1162: 25 ff 00 00 00 and $0xff,%eax
1167: 89 45 e8 mov %eax,-0x18(%ebp)
if(state == 0){
116a: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
116e: 75 2c jne 119c <printf+0x6b>
if(c == '%'){
1170: 83 7d e8 25 cmpl $0x25,-0x18(%ebp)
1174: 75 0c jne 1182 <printf+0x51>
state = '%';
1176: c7 45 f0 25 00 00 00 movl $0x25,-0x10(%ebp)
117d: e9 4b 01 00 00 jmp 12cd <printf+0x19c>
} else {
putc(fd, c);
1182: 8b 45 e8 mov -0x18(%ebp),%eax
1185: 0f be c0 movsbl %al,%eax
1188: 89 44 24 04 mov %eax,0x4(%esp)
118c: 8b 45 08 mov 0x8(%ebp),%eax
118f: 89 04 24 mov %eax,(%esp)
1192: e8 c1 fe ff ff call 1058 <putc>
1197: e9 31 01 00 00 jmp 12cd <printf+0x19c>
}
} else if(state == '%'){
119c: 83 7d f0 25 cmpl $0x25,-0x10(%ebp)
11a0: 0f 85 27 01 00 00 jne 12cd <printf+0x19c>
if(c == 'd'){
11a6: 83 7d e8 64 cmpl $0x64,-0x18(%ebp)
11aa: 75 2d jne 11d9 <printf+0xa8>
printint(fd, *ap, 10, 1);
11ac: 8b 45 f4 mov -0xc(%ebp),%eax
11af: 8b 00 mov (%eax),%eax
11b1: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
11b8: 00
11b9: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
11c0: 00
11c1: 89 44 24 04 mov %eax,0x4(%esp)
11c5: 8b 45 08 mov 0x8(%ebp),%eax
11c8: 89 04 24 mov %eax,(%esp)
11cb: e8 b0 fe ff ff call 1080 <printint>
ap++;
11d0: 83 45 f4 04 addl $0x4,-0xc(%ebp)
11d4: e9 ed 00 00 00 jmp 12c6 <printf+0x195>
} else if(c == 'x' || c == 'p'){
11d9: 83 7d e8 78 cmpl $0x78,-0x18(%ebp)
11dd: 74 06 je 11e5 <printf+0xb4>
11df: 83 7d e8 70 cmpl $0x70,-0x18(%ebp)
11e3: 75 2d jne 1212 <printf+0xe1>
printint(fd, *ap, 16, 0);
11e5: 8b 45 f4 mov -0xc(%ebp),%eax
11e8: 8b 00 mov (%eax),%eax
11ea: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
11f1: 00
11f2: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
11f9: 00
11fa: 89 44 24 04 mov %eax,0x4(%esp)
11fe: 8b 45 08 mov 0x8(%ebp),%eax
1201: 89 04 24 mov %eax,(%esp)
1204: e8 77 fe ff ff call 1080 <printint>
ap++;
1209: 83 45 f4 04 addl $0x4,-0xc(%ebp)
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
120d: e9 b4 00 00 00 jmp 12c6 <printf+0x195>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
1212: 83 7d e8 73 cmpl $0x73,-0x18(%ebp)
1216: 75 46 jne 125e <printf+0x12d>
s = (char*)*ap;
1218: 8b 45 f4 mov -0xc(%ebp),%eax
121b: 8b 00 mov (%eax),%eax
121d: 89 45 e4 mov %eax,-0x1c(%ebp)
ap++;
1220: 83 45 f4 04 addl $0x4,-0xc(%ebp)
if(s == 0)
1224: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
1228: 75 27 jne 1251 <printf+0x120>
s = "(null)";
122a: c7 45 e4 e8 15 00 00 movl $0x15e8,-0x1c(%ebp)
while(*s != 0){
1231: eb 1f jmp 1252 <printf+0x121>
putc(fd, *s);
1233: 8b 45 e4 mov -0x1c(%ebp),%eax
1236: 0f b6 00 movzbl (%eax),%eax
1239: 0f be c0 movsbl %al,%eax
123c: 89 44 24 04 mov %eax,0x4(%esp)
1240: 8b 45 08 mov 0x8(%ebp),%eax
1243: 89 04 24 mov %eax,(%esp)
1246: e8 0d fe ff ff call 1058 <putc>
s++;
124b: 83 45 e4 01 addl $0x1,-0x1c(%ebp)
124f: eb 01 jmp 1252 <printf+0x121>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
1251: 90 nop
1252: 8b 45 e4 mov -0x1c(%ebp),%eax
1255: 0f b6 00 movzbl (%eax),%eax
1258: 84 c0 test %al,%al
125a: 75 d7 jne 1233 <printf+0x102>
125c: eb 68 jmp 12c6 <printf+0x195>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
125e: 83 7d e8 63 cmpl $0x63,-0x18(%ebp)
1262: 75 1d jne 1281 <printf+0x150>
putc(fd, *ap);
1264: 8b 45 f4 mov -0xc(%ebp),%eax
1267: 8b 00 mov (%eax),%eax
1269: 0f be c0 movsbl %al,%eax
126c: 89 44 24 04 mov %eax,0x4(%esp)
1270: 8b 45 08 mov 0x8(%ebp),%eax
1273: 89 04 24 mov %eax,(%esp)
1276: e8 dd fd ff ff call 1058 <putc>
ap++;
127b: 83 45 f4 04 addl $0x4,-0xc(%ebp)
127f: eb 45 jmp 12c6 <printf+0x195>
} else if(c == '%'){
1281: 83 7d e8 25 cmpl $0x25,-0x18(%ebp)
1285: 75 17 jne 129e <printf+0x16d>
putc(fd, c);
1287: 8b 45 e8 mov -0x18(%ebp),%eax
128a: 0f be c0 movsbl %al,%eax
128d: 89 44 24 04 mov %eax,0x4(%esp)
1291: 8b 45 08 mov 0x8(%ebp),%eax
1294: 89 04 24 mov %eax,(%esp)
1297: e8 bc fd ff ff call 1058 <putc>
129c: eb 28 jmp 12c6 <printf+0x195>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
129e: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
12a5: 00
12a6: 8b 45 08 mov 0x8(%ebp),%eax
12a9: 89 04 24 mov %eax,(%esp)
12ac: e8 a7 fd ff ff call 1058 <putc>
putc(fd, c);
12b1: 8b 45 e8 mov -0x18(%ebp),%eax
12b4: 0f be c0 movsbl %al,%eax
12b7: 89 44 24 04 mov %eax,0x4(%esp)
12bb: 8b 45 08 mov 0x8(%ebp),%eax
12be: 89 04 24 mov %eax,(%esp)
12c1: e8 92 fd ff ff call 1058 <putc>
}
state = 0;
12c6: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
12cd: 83 45 ec 01 addl $0x1,-0x14(%ebp)
12d1: 8b 55 0c mov 0xc(%ebp),%edx
12d4: 8b 45 ec mov -0x14(%ebp),%eax
12d7: 8d 04 02 lea (%edx,%eax,1),%eax
12da: 0f b6 00 movzbl (%eax),%eax
12dd: 84 c0 test %al,%al
12df: 0f 85 6e fe ff ff jne 1153 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
12e5: c9 leave
12e6: c3 ret
12e7: 90 nop
000012e8 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
12e8: 55 push %ebp
12e9: 89 e5 mov %esp,%ebp
12eb: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
12ee: 8b 45 08 mov 0x8(%ebp),%eax
12f1: 83 e8 08 sub $0x8,%eax
12f4: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
12f7: a1 8c 16 00 00 mov 0x168c,%eax
12fc: 89 45 fc mov %eax,-0x4(%ebp)
12ff: eb 24 jmp 1325 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
1301: 8b 45 fc mov -0x4(%ebp),%eax
1304: 8b 00 mov (%eax),%eax
1306: 3b 45 fc cmp -0x4(%ebp),%eax
1309: 77 12 ja 131d <free+0x35>
130b: 8b 45 f8 mov -0x8(%ebp),%eax
130e: 3b 45 fc cmp -0x4(%ebp),%eax
1311: 77 24 ja 1337 <free+0x4f>
1313: 8b 45 fc mov -0x4(%ebp),%eax
1316: 8b 00 mov (%eax),%eax
1318: 3b 45 f8 cmp -0x8(%ebp),%eax
131b: 77 1a ja 1337 <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)
131d: 8b 45 fc mov -0x4(%ebp),%eax
1320: 8b 00 mov (%eax),%eax
1322: 89 45 fc mov %eax,-0x4(%ebp)
1325: 8b 45 f8 mov -0x8(%ebp),%eax
1328: 3b 45 fc cmp -0x4(%ebp),%eax
132b: 76 d4 jbe 1301 <free+0x19>
132d: 8b 45 fc mov -0x4(%ebp),%eax
1330: 8b 00 mov (%eax),%eax
1332: 3b 45 f8 cmp -0x8(%ebp),%eax
1335: 76 ca jbe 1301 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
1337: 8b 45 f8 mov -0x8(%ebp),%eax
133a: 8b 40 04 mov 0x4(%eax),%eax
133d: c1 e0 03 shl $0x3,%eax
1340: 89 c2 mov %eax,%edx
1342: 03 55 f8 add -0x8(%ebp),%edx
1345: 8b 45 fc mov -0x4(%ebp),%eax
1348: 8b 00 mov (%eax),%eax
134a: 39 c2 cmp %eax,%edx
134c: 75 24 jne 1372 <free+0x8a>
bp->s.size += p->s.ptr->s.size;
134e: 8b 45 f8 mov -0x8(%ebp),%eax
1351: 8b 50 04 mov 0x4(%eax),%edx
1354: 8b 45 fc mov -0x4(%ebp),%eax
1357: 8b 00 mov (%eax),%eax
1359: 8b 40 04 mov 0x4(%eax),%eax
135c: 01 c2 add %eax,%edx
135e: 8b 45 f8 mov -0x8(%ebp),%eax
1361: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
1364: 8b 45 fc mov -0x4(%ebp),%eax
1367: 8b 00 mov (%eax),%eax
1369: 8b 10 mov (%eax),%edx
136b: 8b 45 f8 mov -0x8(%ebp),%eax
136e: 89 10 mov %edx,(%eax)
1370: eb 0a jmp 137c <free+0x94>
} else
bp->s.ptr = p->s.ptr;
1372: 8b 45 fc mov -0x4(%ebp),%eax
1375: 8b 10 mov (%eax),%edx
1377: 8b 45 f8 mov -0x8(%ebp),%eax
137a: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
137c: 8b 45 fc mov -0x4(%ebp),%eax
137f: 8b 40 04 mov 0x4(%eax),%eax
1382: c1 e0 03 shl $0x3,%eax
1385: 03 45 fc add -0x4(%ebp),%eax
1388: 3b 45 f8 cmp -0x8(%ebp),%eax
138b: 75 20 jne 13ad <free+0xc5>
p->s.size += bp->s.size;
138d: 8b 45 fc mov -0x4(%ebp),%eax
1390: 8b 50 04 mov 0x4(%eax),%edx
1393: 8b 45 f8 mov -0x8(%ebp),%eax
1396: 8b 40 04 mov 0x4(%eax),%eax
1399: 01 c2 add %eax,%edx
139b: 8b 45 fc mov -0x4(%ebp),%eax
139e: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
13a1: 8b 45 f8 mov -0x8(%ebp),%eax
13a4: 8b 10 mov (%eax),%edx
13a6: 8b 45 fc mov -0x4(%ebp),%eax
13a9: 89 10 mov %edx,(%eax)
13ab: eb 08 jmp 13b5 <free+0xcd>
} else
p->s.ptr = bp;
13ad: 8b 45 fc mov -0x4(%ebp),%eax
13b0: 8b 55 f8 mov -0x8(%ebp),%edx
13b3: 89 10 mov %edx,(%eax)
freep = p;
13b5: 8b 45 fc mov -0x4(%ebp),%eax
13b8: a3 8c 16 00 00 mov %eax,0x168c
}
13bd: c9 leave
13be: c3 ret
000013bf <morecore>:
static Header*
morecore(uint nu)
{
13bf: 55 push %ebp
13c0: 89 e5 mov %esp,%ebp
13c2: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
13c5: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
13cc: 77 07 ja 13d5 <morecore+0x16>
nu = 4096;
13ce: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
13d5: 8b 45 08 mov 0x8(%ebp),%eax
13d8: c1 e0 03 shl $0x3,%eax
13db: 89 04 24 mov %eax,(%esp)
13de: e8 4d fc ff ff call 1030 <sbrk>
13e3: 89 45 f0 mov %eax,-0x10(%ebp)
if(p == (char*)-1)
13e6: 83 7d f0 ff cmpl $0xffffffff,-0x10(%ebp)
13ea: 75 07 jne 13f3 <morecore+0x34>
return 0;
13ec: b8 00 00 00 00 mov $0x0,%eax
13f1: eb 22 jmp 1415 <morecore+0x56>
hp = (Header*)p;
13f3: 8b 45 f0 mov -0x10(%ebp),%eax
13f6: 89 45 f4 mov %eax,-0xc(%ebp)
hp->s.size = nu;
13f9: 8b 45 f4 mov -0xc(%ebp),%eax
13fc: 8b 55 08 mov 0x8(%ebp),%edx
13ff: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
1402: 8b 45 f4 mov -0xc(%ebp),%eax
1405: 83 c0 08 add $0x8,%eax
1408: 89 04 24 mov %eax,(%esp)
140b: e8 d8 fe ff ff call 12e8 <free>
return freep;
1410: a1 8c 16 00 00 mov 0x168c,%eax
}
1415: c9 leave
1416: c3 ret
00001417 <malloc>:
void*
malloc(uint nbytes)
{
1417: 55 push %ebp
1418: 89 e5 mov %esp,%ebp
141a: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
141d: 8b 45 08 mov 0x8(%ebp),%eax
1420: 83 c0 07 add $0x7,%eax
1423: c1 e8 03 shr $0x3,%eax
1426: 83 c0 01 add $0x1,%eax
1429: 89 45 f4 mov %eax,-0xc(%ebp)
if((prevp = freep) == 0){
142c: a1 8c 16 00 00 mov 0x168c,%eax
1431: 89 45 f0 mov %eax,-0x10(%ebp)
1434: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1438: 75 23 jne 145d <malloc+0x46>
base.s.ptr = freep = prevp = &base;
143a: c7 45 f0 84 16 00 00 movl $0x1684,-0x10(%ebp)
1441: 8b 45 f0 mov -0x10(%ebp),%eax
1444: a3 8c 16 00 00 mov %eax,0x168c
1449: a1 8c 16 00 00 mov 0x168c,%eax
144e: a3 84 16 00 00 mov %eax,0x1684
base.s.size = 0;
1453: c7 05 88 16 00 00 00 movl $0x0,0x1688
145a: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
145d: 8b 45 f0 mov -0x10(%ebp),%eax
1460: 8b 00 mov (%eax),%eax
1462: 89 45 ec mov %eax,-0x14(%ebp)
if(p->s.size >= nunits){
1465: 8b 45 ec mov -0x14(%ebp),%eax
1468: 8b 40 04 mov 0x4(%eax),%eax
146b: 3b 45 f4 cmp -0xc(%ebp),%eax
146e: 72 4d jb 14bd <malloc+0xa6>
if(p->s.size == nunits)
1470: 8b 45 ec mov -0x14(%ebp),%eax
1473: 8b 40 04 mov 0x4(%eax),%eax
1476: 3b 45 f4 cmp -0xc(%ebp),%eax
1479: 75 0c jne 1487 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
147b: 8b 45 ec mov -0x14(%ebp),%eax
147e: 8b 10 mov (%eax),%edx
1480: 8b 45 f0 mov -0x10(%ebp),%eax
1483: 89 10 mov %edx,(%eax)
1485: eb 26 jmp 14ad <malloc+0x96>
else {
p->s.size -= nunits;
1487: 8b 45 ec mov -0x14(%ebp),%eax
148a: 8b 40 04 mov 0x4(%eax),%eax
148d: 89 c2 mov %eax,%edx
148f: 2b 55 f4 sub -0xc(%ebp),%edx
1492: 8b 45 ec mov -0x14(%ebp),%eax
1495: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
1498: 8b 45 ec mov -0x14(%ebp),%eax
149b: 8b 40 04 mov 0x4(%eax),%eax
149e: c1 e0 03 shl $0x3,%eax
14a1: 01 45 ec add %eax,-0x14(%ebp)
p->s.size = nunits;
14a4: 8b 45 ec mov -0x14(%ebp),%eax
14a7: 8b 55 f4 mov -0xc(%ebp),%edx
14aa: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
14ad: 8b 45 f0 mov -0x10(%ebp),%eax
14b0: a3 8c 16 00 00 mov %eax,0x168c
return (void*)(p + 1);
14b5: 8b 45 ec mov -0x14(%ebp),%eax
14b8: 83 c0 08 add $0x8,%eax
14bb: eb 38 jmp 14f5 <malloc+0xde>
}
if(p == freep)
14bd: a1 8c 16 00 00 mov 0x168c,%eax
14c2: 39 45 ec cmp %eax,-0x14(%ebp)
14c5: 75 1b jne 14e2 <malloc+0xcb>
if((p = morecore(nunits)) == 0)
14c7: 8b 45 f4 mov -0xc(%ebp),%eax
14ca: 89 04 24 mov %eax,(%esp)
14cd: e8 ed fe ff ff call 13bf <morecore>
14d2: 89 45 ec mov %eax,-0x14(%ebp)
14d5: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
14d9: 75 07 jne 14e2 <malloc+0xcb>
return 0;
14db: b8 00 00 00 00 mov $0x0,%eax
14e0: eb 13 jmp 14f5 <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){
14e2: 8b 45 ec mov -0x14(%ebp),%eax
14e5: 89 45 f0 mov %eax,-0x10(%ebp)
14e8: 8b 45 ec mov -0x14(%ebp),%eax
14eb: 8b 00 mov (%eax),%eax
14ed: 89 45 ec mov %eax,-0x14(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
14f0: e9 70 ff ff ff jmp 1465 <malloc+0x4e>
}
14f5: c9 leave
14f6: c3 ret
|
commands/apps/safari/safari-close-duplicated-tabs.applescript | daviddzhou/script-commands | 3,305 | 747 | <reponame>daviddzhou/script-commands
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Close Duplicated Tabs
# @raycast.mode silent
# Optional parameters:
# @raycast.packageName Safari
# @raycast.icon images/safari.png
# @Documentation:
# @raycast.author <NAME>
# @raycast.authorURL https://github.com/thomaspaulmann
# @raycast.description Close tabs with the same URL.
tell window 1 of application "Safari"
set visitedURLs to {}
set closedTabs to 0
set allTabs to tabs
repeat with i from length of allTabs to 1 by -1
set currentTab to item i of allTabs
set currentURL to URL of currentTab
if visitedURLs contains currentURL then
close currentTab
set closedTabs to closedTabs + 1
else
copy currentURL to end of visitedURLs
end if
end repeat
if closedTabs is equal to 1 then
log "Closed 1 duplicated tab"
else if closedTabs is greater than 1 then
log "Closed " & closedTabs & " duplicated tab"
else
log "No duplicated tabs found"
end if
end |
oeis/122/A122690.asm | neoneye/loda-programs | 11 | 85249 | ; A122690: a(n) = 5*a(n-1) + 4*a(n-2) with a(0)=1, a(1)=4.
; Submitted by <NAME>(s2)
; 1,4,24,136,776,4424,25224,143816,819976,4675144,26655624,151978696,866515976,4940494664,28168537224,160604664776,915697472776,5220906022984,29767320006024,169720224122056,967670400634376,5517232899660104,31456846100838024,179353162102830536,1022593194917504776,5830378622998846024,33242265894664249224,189532843965316630216,1080633283405240147976,6161297792887467260744,35129022098058296895624,200290301661841353521096,1141967596701439955187976,6510999190154565190024264,37122866337578585770873224
mov $1,1
lpb $0
sub $0,1
mov $2,$1
add $1,$3
add $2,$1
mul $1,4
mov $3,$2
lpe
mov $0,$1
|
engine/battle/move_effects/spite.asm | AtmaBuster/pokeplat-gen2 | 6 | 97956 | BattleCommand_spite:
; spite
ld a, [wAttackMissed]
and a
jp nz, .failed
ld bc, PARTYMON_STRUCT_LENGTH ; ????
ld hl, wEnemyMonMoves
ldh a, [hBattleTurn]
and a
jr z, .got_moves
ld hl, wBattleMonMoves
.got_moves
ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP
call GetBattleVar
and a
jr z, .failed
ld b, a
push bc
ld bc, STRUGGLE
call CompareMove
pop bc
jr z, .failed
ld c, -1
.loop
inc c
ld a, [hli]
cp b
jr nz, .loop
ld [wNamedObjectIndexBuffer], a
dec hl
ld b, 0
push bc
ld c, wBattleMonPP - wBattleMonMoves
add hl, bc
pop bc
ld a, [hl]
and PP_MASK
jr z, .failed
push bc
call GetMoveName
; lose 2-5 PP
call BattleRandom
and %11
inc a
inc a
ld b, a
ld a, [hl]
and PP_MASK
cp b
jr nc, .deplete_pp
ld b, a
.deplete_pp
ld a, [hl]
sub b
ld [hl], a
push af
ld a, MON_PP
call OpponentPartyAttr
ld d, b
pop af
pop bc
add hl, bc
ld e, a
ld a, BATTLE_VARS_SUBSTATUS5_OPP
call GetBattleVar
bit SUBSTATUS_TRANSFORMED, a
jr nz, .transformed
ldh a, [hBattleTurn]
and a
jr nz, .not_wildmon
ld a, [wBattleMode]
dec a
jr nz, .not_wildmon
ld hl, wWildMonPP
add hl, bc
.not_wildmon
ld [hl], e
.transformed
push de
call AnimateCurrentMove
pop de
ld a, d
ld [wDeciramBuffer], a
ld hl, SpiteEffectText
jp StdBattleTextbox
.failed
jp PrintDidntAffect2
|
programs/oeis/329/A329320.asm | karttu/loda | 0 | 8552 | <filename>programs/oeis/329/A329320.asm
; A329320: a(n) = Sum_{k=0..floor(log_2(n))} 1 - A035263(1 + floor(n/2^k)).
; 0,1,1,1,1,2,1,2,1,2,2,2,1,2,2,2,1,2,2,2,2,3,2,3,1,2,2,2,2,3,2,3,1,2,2,2,2,3,2,3,2,3,3,3,2,3,3,3,1,2,2,2,2,3,2,3,2,3,3,3,2,3,3,3,1,2,2,2,2,3,2,3,2,3,3,3,2,3,3,3,2,3,3,3,3,4,3,4,2,3,3,3,3,4,3,4,1,2,2,2,2,3,2,3,2,3,3,3,2,3,3,3,2,3,3,3,3,4,3,4,2,3,3,3,3,4,3,4,1,2,2,2,2,3,2,3,2,3,3,3,2,3,3,3,2,3,3,3,3,4,3,4,2,3,3,3,3,4,3,4,2,3,3,3,3,4,3,4,3,4,4,4,3,4,4,4,2,3,3,3,3,4,3,4,3,4,4,4,3,4,4,4,1,2,2,2,2,3,2,3,2,3,3,3,2,3,3,3,2,3,3,3,3,4,3,4,2,3,3,3,3,4,3,4,2,3,3,3,3,4,3,4,3,4,4,4,3,4,4,4,2,3,3,3,3,4,3,4,3,4
lpb $0,1
gcd $2,3
lpb $0,1
mul $2,$0
div $0,2
mod $2,2
add $1,$2
add $2,1
lpe
lpe
|
oeis/332/A332182.asm | neoneye/loda-programs | 11 | 162480 | <reponame>neoneye/loda-programs
; A332182: a(n) = 8*(10^(2n+1)-1)/9 - 6*10^n.
; Submitted by <NAME>(m1)
; 2,828,88288,8882888,888828888,88888288888,8888882888888,888888828888888,88888888288888888,8888888882888888888,888888888828888888888,88888888888288888888888,8888888888882888888888888,888888888888828888888888888,88888888888888288888888888888,8888888888888882888888888888888
seq $0,177108 ; a(n) = 4*(10^n-3).
add $1,$0
sub $1,3
add $2,$0
mul $2,$1
mov $0,$2
sub $0,700
div $0,180
add $0,2
|
tests/src/test_parsers.ads | onox/json-ada | 28 | 4384 | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <<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 AUnit.Test_Suites;
with AUnit.Test_Fixtures;
package Test_Parsers is
function Suite return AUnit.Test_Suites.Access_Test_Suite;
private
type Test is new AUnit.Test_Fixtures.Test_Fixture with null record;
-- Keyword
procedure Test_True_Text (Object : in out Test);
procedure Test_False_Text (Object : in out Test);
procedure Test_Null_Text (Object : in out Test);
-- String
procedure Test_Empty_String_Text (Object : in out Test);
procedure Test_Non_Empty_String_Text (Object : in out Test);
procedure Test_Number_String_Text (Object : in out Test);
-- Integer/float number
procedure Test_Integer_Number_Text (Object : in out Test);
procedure Test_Integer_Number_To_Float_Text (Object : in out Test);
procedure Test_Float_Number_Text (Object : in out Test);
-- Array
procedure Test_Empty_Array_Text (Object : in out Test);
procedure Test_One_Element_Array_Text (Object : in out Test);
procedure Test_Multiple_Elements_Array_Text (Object : in out Test);
procedure Test_Array_Iterable (Object : in out Test);
procedure Test_Multiple_Array_Iterable (Object : in out Test);
-- Object
procedure Test_Empty_Object_Text (Object : in out Test);
procedure Test_One_Member_Object_Text (Object : in out Test);
procedure Test_Multiple_Members_Object_Text (Object : in out Test);
procedure Test_Object_Iterable (Object : in out Test);
procedure Test_Array_Object_Array (Object : in out Test);
procedure Test_Object_Array_Object (Object : in out Test);
procedure Test_Object_No_Array (Object : in out Test);
procedure Test_Object_No_Object (Object : in out Test);
-- Exceptions
procedure Test_Empty_Text_Exception (Object : in out Test);
procedure Test_Array_No_Value_Separator_Exception (Object : in out Test);
procedure Test_Array_No_End_Array_Exception (Object : in out Test);
procedure Test_No_EOF_After_Array_Exception (Object : in out Test);
procedure Test_Object_No_Value_Separator_Exception (Object : in out Test);
procedure Test_Object_No_Name_Separator_Exception (Object : in out Test);
procedure Test_Object_Key_No_String_Exception (Object : in out Test);
procedure Test_Object_No_Second_Member_Exception (Object : in out Test);
procedure Test_Object_Duplicate_Keys_Exception (Object : in out Test);
procedure Test_Object_No_Value_Exception (Object : in out Test);
procedure Test_Object_No_End_Object_Exception (Object : in out Test);
procedure Test_No_EOF_After_Object_Exception (Object : in out Test);
end Test_Parsers;
|
src/LibraBFT/ImplShared/Consensus/Types/EpochIndep.agda | LaudateCorpus1/bft-consensus-agda | 0 | 9254 | {- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Base.Types
open import LibraBFT.Impl.OBM.Rust.Duration
open import LibraBFT.Impl.OBM.Rust.RustTypes
open import LibraBFT.ImplShared.Base.Types
open import Optics.All
open import Util.ByteString
open import Util.Encode
open import Util.Hash
open import Util.KVMap as Map
open import Util.PKCS
open import Util.Prelude
------------------------------------------------------------------------------
open import Data.String using (String)
-- Defines the types that /DO NOT/ depend on an epoch config.
-- TODO-3: update types to reflect more recent version of LibraBFT. This is
-- a substantial undertaking that should probably be led by someone who can
-- access our internal implementation.
module LibraBFT.ImplShared.Consensus.Types.EpochIndep where
-- Below here is incremental progress towards something
-- that will eventually mirror the types in LBFT.Consensus.Types
-- that /DO NOT/ depend on the set of active authors
-- or safety rules, which we call the /EpochConfig/.
Author : Set
Author = NodeId
AccountAddress : Set
AccountAddress = Author
AuthorName : Set
AuthorName = Author
aAuthorName : Lens Author AuthorName
aAuthorName = mkLens' (λ x → x) (λ x → const x)
HashValue : Set
HashValue = Hash
TX : Set
TX = ByteString
Instant : Set
Instant = ℕ -- TODO-2: should eventually be a time stamp
postulate -- TODO-1: implement/prove PK equality
_≟-PK_ : (pk1 pk2 : PK) → Dec (pk1 ≡ pk2)
instance
Eq-PK : Eq PK
Eq._≟_ Eq-PK = _≟-PK_
-- LBFT-OBM-DIFF: We do not have world state. We just count the Epoch/Round as the version.
record Version : Set where
constructor Version∙new
field
_vVE : Epoch
_vVR : Round
open Version public
postulate instance enc-Version : Encoder Version
postulate -- TODO-1: implement/prove Version equality
_≟-Version_ : (v1 v2 : Version) → Dec (v1 ≡ v2)
instance
Eq-Version : Eq Version
Eq._≟_ Eq-Version = _≟-Version_
_≤-Version_ : Version → Version → Set
v1 ≤-Version v2 = _vVE v1 < _vVE v2
⊎ _vVE v1 ≡ _vVE v2 × _vVR v1 ≤ _vVR v2
_≤?-Version_ : (v1 v2 : Version) → Dec (v1 ≤-Version v2)
v1 ≤?-Version v2
with _vVE v1 <? _vVE v2
...| yes prf = yes (inj₁ prf)
...| no ege
with _vVE v1 ≟ _vVE v2
...| no rneq = no (⊥-elim ∘ λ { (inj₁ x) → ege x
; (inj₂ (x , _)) → rneq x })
...| yes refl
with _vVR v1 ≤? _vVR v2
...| yes rleq = yes (inj₂ (refl , rleq))
...| no rgt = no (⊥-elim ∘ λ { (inj₁ x) → ege x
; (inj₂ (_ , x)) → rgt x })
_<-Version_ : Version → Version → Set
v1 <-Version v2 = _vVE v1 < _vVE v2
⊎ _vVE v1 ≡ _vVE v2 × _vVR v1 < _vVR v2
_<?-Version_ : (v1 v2 : Version) → Dec (v1 <-Version v2)
v1 <?-Version v2
with _vVE v1 <? _vVE v2
...| yes prf = yes (inj₁ prf)
...| no ege
with _vVE v1 ≟ _vVE v2
...| no rneq = no (⊥-elim ∘ λ { (inj₁ x) → ege x
; (inj₂ (x , _)) → rneq x })
...| yes refl
with _vVR v1 <? _vVR v2
...| yes rleq = yes (inj₂ (refl , rleq))
...| no rgt = no (⊥-elim ∘ λ { (inj₁ x) → ege x
; (inj₂ (_ , x)) → rgt x })
-- ------------------------------------------------------------------------------
record ValidatorSigner : Set where
constructor ValidatorSigner∙new
field
_vsAuthor : AccountAddress
_vsPrivateKey : SK -- Note that the SystemModel doesn't
-- allow one node to examine another's
-- state, so we don't model someone being
-- able to impersonate someone else unless
-- PK is "dishonest", which models the
-- possibility that the corresponding secret
-- key may have been leaked.
open ValidatorSigner public
unquoteDecl vsAuthor vsPrivateKey = mkLens (quote ValidatorSigner)
(vsAuthor ∷ vsPrivateKey ∷ [])
RawEncNetworkAddress = Author
record ValidatorConfig : Set where
constructor ValidatorConfig∙new
field
_vcConsensusPublicKey : PK
_vcValidatorNetworkAddress : RawEncNetworkAddress
open ValidatorConfig public
unquoteDecl vcConsensusPublicKey vcValidatorNetworkAddress = mkLens (quote ValidatorConfig)
(vcConsensusPublicKey ∷ vcValidatorNetworkAddress ∷ [])
record ValidatorInfo : Set where
constructor ValidatorInfo∙new
field
_viAccountAddress : AccountAddress
_viConsensusVotingPower : U64
_viConfig : ValidatorConfig
open ValidatorInfo public
unquoteDecl viAccountAddress viConsensusVotingPower viConfig = mkLens (quote ValidatorInfo)
(viAccountAddress ∷ viConsensusVotingPower ∷ viConfig ∷ [])
-- getter only in Haskell
-- key for validating signed messages from this validator
viConsensusPublicKey : Lens ValidatorInfo PK
viConsensusPublicKey = viConfig ∙ vcConsensusPublicKey
record ValidatorConsensusInfo : Set where
constructor ValidatorConsensusInfo∙new
field
_vciPublicKey : PK
_vciVotingPower : U64
open ValidatorConsensusInfo public
unquoteDecl vciPublicKey vciVotingPower = mkLens (quote ValidatorConsensusInfo)
(vciPublicKey ∷ vciVotingPower ∷ [])
record ValidatorVerifier : Set where
constructor mkValidatorVerifier
field
_vvAddressToValidatorInfo : KVMap AccountAddress ValidatorConsensusInfo
_vvQuorumVotingPower : ℕ -- TODO-2: see above; for now, this is QuorumSize
_vvTotalVotingPower : ℕ -- TODO-2: see above; for now, this is number of peers in EpochConfig
open ValidatorVerifier public
unquoteDecl vvAddressToValidatorInfo vvQuorumVotingPower vvTotalVotingPower = mkLens (quote ValidatorVerifier)
(vvAddressToValidatorInfo ∷ vvQuorumVotingPower ∷ vvTotalVotingPower ∷ [])
-- getter only in Haskell
vvObmAuthors : Lens ValidatorVerifier (List AccountAddress)
vvObmAuthors = mkLens' g s
where
g : ValidatorVerifier → List AccountAddress
g vv = Map.kvm-keys (vv ^∙ vvAddressToValidatorInfo)
s : ValidatorVerifier → List AccountAddress → ValidatorVerifier
s vv _ = vv -- TODO-1 : cannot be done: need a way to defined only getters
data ConsensusScheme : Set where ConsensusScheme∙new : ConsensusScheme
-- instance S.Serialize ConsensusScheme
record ValidatorSet : Set where
constructor ValidatorSet∙new
field
_vsScheme : ConsensusScheme
_vsPayload : List ValidatorInfo
-- instance S.Serialize ValidatorSet
open ValidatorSet public
unquoteDecl vsScheme vsPayload = mkLens (quote ValidatorSet)
(vsScheme ∷ vsPayload ∷ [])
record EpochState : Set where
constructor EpochState∙new
field
_esEpoch : Epoch
_esVerifier : ValidatorVerifier
open EpochState public
unquoteDecl esEpoch esVerifier = mkLens (quote EpochState)
(esEpoch ∷ esVerifier ∷ [])
postulate -- one valid assumption, one that can be proved using it
instance
Enc-EpochState : Encoder EpochState
Enc-EpochStateMB : Encoder (Maybe EpochState) -- TODO-1: make combinator to build this
-- ------------------------------------------------------------------------------
record BlockInfo : Set where
constructor BlockInfo∙new
field
_biEpoch : Epoch
_biRound : Round
_biId : HashValue
_biExecutedStateId : HashValue -- aka liTransactionAccumulatorHash
_biVersion : Version
--, _biTimestamp :: Instant
_biNextEpochState : Maybe EpochState
open BlockInfo public
unquoteDecl biEpoch biRound biId biExecutedStateId biVersion biNextEpochState = mkLens (quote BlockInfo)
(biEpoch ∷ biRound ∷ biId ∷ biExecutedStateId ∷ biVersion ∷ biNextEpochState ∷ [])
postulate instance enc-BlockInfo : Encoder BlockInfo
postulate
_≟-BlockInfo_ : (bi1 bi2 : BlockInfo) → Dec (bi1 ≡ bi2)
instance
Eq-BlockInfo : Eq BlockInfo
Eq._≟_ Eq-BlockInfo = _≟-BlockInfo_
BlockInfo-η : ∀{e1 e2 r1 r2 i1 i2 x1 x2 v1 v2 n1 n2}
→ e1 ≡ e2 → r1 ≡ r2 → i1 ≡ i2 → x1 ≡ x2 → v1 ≡ v2 → n1 ≡ n2
→ BlockInfo∙new e1 r1 i1 x1 v1 n1 ≡ BlockInfo∙new e2 r2 i2 x2 v2 n2
BlockInfo-η refl refl refl refl refl refl = refl
instance
Eq-ByteString : Eq ByteString
Eq._≟_ Eq-ByteString = _≟ByteString_
{-
_≟BlockInfo_ : (b₁ b₂ : BlockInfo) → Dec (b₁ ≡ b₂)
l ≟BlockInfo r with ((l ^∙ biEpoch) ≟ (r ^∙ biEpoch))
...| no no-e = no λ where refl → no-e refl
...| yes refl with ((l ^∙ biRound) ≟ (r ^∙ biRound))
...| no no-r = no λ where refl → no-r refl
...| yes refl with ((l ^∙ biId) ≟ (r ^∙ biId))
...| no no-i = no λ where refl → no-i refl
...| yes refl = yes refl
instance
Eq-BlockInfo : Eq BlockInfo
Eq._≟_ Eq-BlockInfo = _≟BlockInfo_
BlockInfo-η : ∀{e1 e2 r1 r2 i1 i2} → e1 ≡ e2 → r1 ≡ r2 → i1 ≡ i2
→ BlockInfo∙new e1 r1 i1 ≡ BlockInfo∙new e2 r2 i2
BlockInfo-η refl refl refl = refl
-}
biNextBlockEpoch : Lens BlockInfo Epoch
biNextBlockEpoch = mkLens' g s
where
g : BlockInfo → Epoch
g bi = maybeS (bi ^∙ biNextEpochState)
(bi ^∙ biEpoch)
( _^∙ esEpoch)
s : BlockInfo → Epoch → BlockInfo
s bi _ = bi -- TODO-1 : cannot be done: need a way to defined only getters
-- ------------------------------------------------------------------------------
record LedgerInfo : Set where
constructor LedgerInfo∙new
field
_liCommitInfo : BlockInfo
_liConsensusDataHash : HashValue
open LedgerInfo public
unquoteDecl liCommitInfo liConsensusDataHash = mkLens (quote LedgerInfo)
(liCommitInfo ∷ liConsensusDataHash ∷ [])
postulate instance enc-LedgerInfo : Encoder LedgerInfo
postulate instance ws-LedgerInfo : WithSig LedgerInfo
-- GETTER only in Haskell
liEpoch : Lens LedgerInfo Epoch
liEpoch = liCommitInfo ∙ biEpoch
-- GETTER only in Haskell
liNextBlockEpoch : Lens LedgerInfo Epoch
liNextBlockEpoch = liCommitInfo ∙ biNextBlockEpoch
-- GETTER only in Haskell
liConsensusBlockId : Lens LedgerInfo HashValue
liConsensusBlockId = liCommitInfo ∙ biId
-- GETTER only in Haskell
liTransactionAccumulatorHash : Lens LedgerInfo HashValue
liTransactionAccumulatorHash = liCommitInfo ∙ biExecutedStateId
-- GETTER only in Haskell
liVersion : Lens LedgerInfo Version
liVersion = liCommitInfo ∙ biVersion
-- GETTER only in Haskell
liNextEpochState : Lens LedgerInfo (Maybe EpochState)
liNextEpochState = mkLens' g s
where
g : LedgerInfo → Maybe EpochState
g = (_^∙ liCommitInfo ∙ biNextEpochState)
s : LedgerInfo → Maybe EpochState → LedgerInfo
s l _ = l -- TODO-1 : cannot be done: need a way to defined only getters
-- GETTER only in Haskell
liEndsEpoch : Lens LedgerInfo Bool
liEndsEpoch = mkLens' g s
where
g : LedgerInfo → Bool
g = is-just ∘ (_^∙ liNextEpochState)
s : LedgerInfo → Bool → LedgerInfo
s l _ = l -- TODO-1 : cannot be done: need a way to defined only getters
LedgerInfo-η : ∀ {ci1 ci2 : BlockInfo} {cdh1 cdh2 : Hash}
→ ci1 ≡ ci2
→ cdh1 ≡ cdh2
→ (LedgerInfo∙new ci1 cdh1) ≡ (LedgerInfo∙new ci2 cdh2)
LedgerInfo-η refl refl = refl
record LedgerInfoWithSignatures : Set where
constructor LedgerInfoWithSignatures∙new
field
_liwsLedgerInfo : LedgerInfo
_liwsSignatures : KVMap Author Signature
open LedgerInfoWithSignatures public
unquoteDecl liwsLedgerInfo liwsSignatures = mkLens (quote LedgerInfoWithSignatures)
(liwsLedgerInfo ∷ liwsSignatures ∷ [])
postulate instance enc-LedgerInfoWithSignatures : Encoder LedgerInfoWithSignatures
-- GETTER only in Haskell
liwsEpoch : Lens LedgerInfoWithSignatures Epoch
liwsEpoch = liwsLedgerInfo ∙ liEpoch
-- GETTER only in Haskell
liwsVersion : Lens LedgerInfoWithSignatures Version
liwsVersion = liwsLedgerInfo ∙ liVersion
-- GETTER only in Haskell
liwsNextEpochState : Lens LedgerInfoWithSignatures (Maybe EpochState)
liwsNextEpochState = liwsLedgerInfo ∙ liNextEpochState
-- ------------------------------------------------------------------------------
record Timeout : Set where
constructor Timeout∙new
field
_toEpoch : Epoch
_toRound : Round
open Timeout public
unquoteDecl toEpoch toRound = mkLens (quote Timeout)
(toEpoch ∷ toRound ∷ [])
postulate instance enc-Timeout : Encoder Timeout
-- ------------------------------------------------------------------------------
record VoteData : Set where
constructor VoteData∙new
field
_vdProposed : BlockInfo
_vdParent : BlockInfo
open VoteData public
unquoteDecl vdProposed vdParent = mkLens (quote VoteData)
(vdProposed ∷ vdParent ∷ [])
postulate instance enc-VoteData : Encoder VoteData
VoteData-η : ∀ {pr1 par1 pr2 par2 : BlockInfo} → pr1 ≡ pr2 → par1 ≡ par2
→ (VoteData∙new pr1 par1) ≡ (VoteData∙new pr2 par2)
VoteData-η refl refl = refl
-- DESIGN NOTE: The _vAuthor field is included only to facilitate lookup of the public key against
-- which to verify the signature. An alternative would be to use an index into the members of the
-- epoch config, which would save message space and therefore bandwidth.
record Vote : Set where
constructor Vote∙new
field
_vVoteData : VoteData
_vAuthor : Author
_vLedgerInfo : LedgerInfo
_vSignature : Signature
_vTimeoutSignature : Maybe Signature
open Vote public
unquoteDecl vVoteData vAuthor vLedgerInfo vSignature vTimeoutSignature = mkLens (quote Vote)
(vVoteData ∷ vAuthor ∷ vLedgerInfo ∷ vSignature ∷ vTimeoutSignature ∷ [])
postulate instance enc-Vote : Encoder Vote
-- not defined in Haskell
vParent : Lens Vote BlockInfo
vParent = vVoteData ∙ vdParent
-- not defined in Haskell
vProposed : Lens Vote BlockInfo
vProposed = vVoteData ∙ vdProposed
-- not defined in Haskell
vParentId : Lens Vote Hash
vParentId = vVoteData ∙ vdParent ∙ biId
-- not defined in Haskell
vParentRound : Lens Vote Round
vParentRound = vVoteData ∙ vdParent ∙ biRound
-- not defined in Haskell
vProposedId : Lens Vote Hash
vProposedId = vVoteData ∙ vdProposed ∙ biId
-- getter only in Haskell
vEpoch : Lens Vote Epoch
vEpoch = vVoteData ∙ vdProposed ∙ biEpoch
-- getter only in Haskell
vRound : Lens Vote Round
vRound = vVoteData ∙ vdProposed ∙ biRound
-- ------------------------------------------------------------------------------
record QuorumCert : Set where
constructor QuorumCert∙new
field
_qcVoteData : VoteData
_qcSignedLedgerInfo : LedgerInfoWithSignatures
open QuorumCert public
unquoteDecl qcVoteData qcSignedLedgerInfo = mkLens (quote QuorumCert)
(qcVoteData ∷ qcSignedLedgerInfo ∷ [])
postulate instance enc-QuorumCert : Encoder QuorumCert
-- Because QuorumCert has an injective encoding (postulated, for now),
-- we can use it to determine equality of QuorumCerts.
_≟QC_ : (q1 q2 : QuorumCert) → Dec (q1 ≡ q2)
_≟QC_ = ≡-Encoder enc-QuorumCert
_QCBoolEq_ : QuorumCert → QuorumCert → Bool
_QCBoolEq_ q1 q2 = does (q1 ≟QC q2)
-- getter only in Haskell
qcCertifiedBlock : Lens QuorumCert BlockInfo
qcCertifiedBlock = qcVoteData ∙ vdProposed
-- getter only in Haskell
qcParentBlock : Lens QuorumCert BlockInfo
qcParentBlock = qcVoteData ∙ vdParent
-- getter only in Haskell
qcLedgerInfo : Lens QuorumCert LedgerInfoWithSignatures
qcLedgerInfo = qcSignedLedgerInfo
-- getter only in Haskell
qcCommitInfo : Lens QuorumCert BlockInfo
qcCommitInfo = qcSignedLedgerInfo ∙ liwsLedgerInfo ∙ liCommitInfo
-- getter only in Haskell
qcEndsEpoch : Lens QuorumCert Bool
qcEndsEpoch = mkLens' g s
where
g : QuorumCert → Bool
g q = is-just (q ^∙ qcSignedLedgerInfo ∙ liwsLedgerInfo ∙ liNextEpochState)
s : QuorumCert → Bool → QuorumCert
s q _ = q -- TODO-1 : cannot be done: need a way to defined only getters
-- Constructs a 'vote' that was gathered in a QC.
rebuildVote : QuorumCert → Author × Signature → Vote
rebuildVote qc (α , sig)
= record { _vVoteData = _qcVoteData qc
; _vAuthor = α
; _vLedgerInfo = qc ^∙ (qcSignedLedgerInfo ∙ liwsLedgerInfo)
; _vSignature = sig
; _vTimeoutSignature = nothing -- Is this correct? The original vote may have had a
-- timeout signature, but we don't know. Does it
-- matter?
}
-- Two votes are equivalent if they are identical except they may differ on timeout signature
_≈Vote_ : (v1 v2 : Vote) → Set
v1 ≈Vote v2 = v2 ≡ record v1 { _vTimeoutSignature = _vTimeoutSignature v2 }
qcVotesKV : QuorumCert → KVMap Author Signature
qcVotesKV = _liwsSignatures ∘ _qcSignedLedgerInfo
qcVotes : QuorumCert → List (Author × Signature)
qcVotes qc = kvm-toList (qcVotesKV qc)
-- not defined in Haskell
qcCertifies : Lens QuorumCert Hash
qcCertifies = qcVoteData ∙ vdProposed ∙ biId
-- not defined in Haskell
qcRound : Lens QuorumCert Round
qcRound = qcVoteData ∙ vdProposed ∙ biRound
_qcCertifies : QuorumCert → Hash
_qcCertifies q = q ^∙ qcCertifies
_qcRound : QuorumCert → Round
_qcRound q = q ^∙ qcRound
-- ------------------------------------------------------------------------------
record TimeoutCertificate : Set where
constructor mkTimeoutCertificate
field
_tcTimeout : Timeout
_tcSignatures : KVMap Author Signature
open TimeoutCertificate public
unquoteDecl tcTimeout tcSignatures = mkLens (quote TimeoutCertificate)
(tcTimeout ∷ tcSignatures ∷ [])
TimeoutCertificate∙new : Timeout → TimeoutCertificate
TimeoutCertificate∙new to = mkTimeoutCertificate to Map.empty
-- getter only in haskell
tcEpoch : Lens TimeoutCertificate Epoch
tcEpoch = tcTimeout ∙ toEpoch
-- getter only in haskell
tcRound : Lens TimeoutCertificate Round
tcRound = tcTimeout ∙ toRound
-- ------------------------------------------------------------------------------
data BlockType : Set where
Proposal : TX → Author → BlockType
NilBlock : BlockType
Genesis : BlockType
postulate instance enc-BlockType : Encoder BlockType
postulate -- Valid assumption, payloadIsEmpty
-- TODO-1 : Need to decide what empty means.
-- Only important on epoch change.
payloadIsEmpty : TX → Bool
_≟BlockType_ : (b₁ b₂ : BlockType) → Dec (b₁ ≡ b₂)
Genesis ≟BlockType Genesis = true because ofʸ refl
NilBlock ≟BlockType NilBlock = true because ofʸ refl
(Proposal t₁ a₁) ≟BlockType (Proposal t₂ a₂) with t₁ ≟ t₂
...| no no-t = no λ where refl → no-t refl
...| yes refl with a₁ ≟ a₂
...| no no-a = no λ where refl → no-a refl
...| yes refl = yes refl
Genesis ≟BlockType NilBlock = no (λ ())
Genesis ≟BlockType (Proposal _ _) = no (λ ())
NilBlock ≟BlockType Genesis = no (λ ())
NilBlock ≟BlockType (Proposal _ _) = no (λ ())
(Proposal _ _) ≟BlockType Genesis = no (λ ())
(Proposal _ _) ≟BlockType NilBlock = no (λ ())
instance
Eq-BlockType : Eq BlockType
Eq._≟_ Eq-BlockType = _≟BlockType_
record BlockData : Set where
constructor BlockData∙new
field
_bdEpoch : Epoch
_bdRound : Round
-- QUESTION: How do we represent a block that extends the
-- genesis block, which doesn't come with a QC. Maybe the
-- genesis block has an associated QC established for the epoch?
_bdQuorumCert : QuorumCert
_bdBlockType : BlockType
open BlockData public
unquoteDecl bdEpoch bdRound bdQuorumCert bdBlockType = mkLens (quote BlockData)
(bdEpoch ∷ bdRound ∷ bdQuorumCert ∷ bdBlockType ∷ [])
postulate instance enc-BlockData : Encoder BlockData
-- not defined in Haskell
bdParentId : Lens BlockData Hash
bdParentId = bdQuorumCert ∙ qcVoteData ∙ vdParent ∙ biId
-- not defined in Haskell
-- This is the id of a block
bdBlockId : Lens BlockData Hash
bdBlockId = bdQuorumCert ∙ qcVoteData ∙ vdProposed ∙ biId
-- getter only in Haskell
bdAuthor : Lens BlockData (Maybe Author)
bdAuthor = mkLens' g s
where
g : BlockData → Maybe Author
g bd = case (bd ^∙ bdBlockType) of λ where
(Proposal _ author) → just author
_ → nothing
s : BlockData → Maybe Author → BlockData
s bd nothing = bd
s bd (just auth) =
bd & bdBlockType %~ λ where
(Proposal tx _) → Proposal tx auth
bdt → bdt
-- getter only in Haskell
bdPayload : Lens BlockData (Maybe TX)
bdPayload = mkLens' g s
where
g : BlockData → Maybe TX
g bd = case bd ^∙ bdBlockType of λ where
(Proposal a _) → just a
_ → nothing
s : BlockData → Maybe TX → BlockData
s bd _ = bd -- TODO-1 : cannot be done: need a way to define only getters
-- ------------------------------------------------------------------------------
-- The signature is a Maybe to allow us to use 'nothing' as the
-- 'bSignature' when constructing a block to sign later. Also,
-- "nil" blocks are not signed because they are produced
-- independently by different validators. This is to enable
-- committing after an epoch-changing command is processed: we
-- cannot add more commands, but we need to add some quorum
-- certificates in order to commit the epoch-changing command.
record Block : Set where
constructor Block∙new
field
_bId : HashValue
_bBlockData : BlockData
_bSignature : Maybe Signature
open Block public
unquoteDecl bId bBlockData bSignature = mkLens (quote Block)
(bId ∷ bBlockData ∷ bSignature ∷ [])
postulate instance enc : Encoder Block
-- getter only in Haskell
bAuthor : Lens Block (Maybe Author)
bAuthor = bBlockData ∙ bdAuthor
-- getter only in Haskell
bEpoch : Lens Block Epoch
bEpoch = bBlockData ∙ bdEpoch
-- getter only in Haskell
bRound : Lens Block Round
bRound = bBlockData ∙ bdRound
-- getter only in Haskell
bQuorumCert : Lens Block QuorumCert
bQuorumCert = bBlockData ∙ bdQuorumCert
-- getter only in Haskell
bParentId : Lens Block HashValue
bParentId = bQuorumCert ∙ qcCertifiedBlock ∙ biId
-- getter only in Haskell
bPayload : Lens Block (Maybe TX)
bPayload = bBlockData ∙ bdPayload
bdQcSigs : Lens Block (KVMap Author Signature)
bdQcSigs = bBlockData ∙ bdQuorumCert ∙ qcLedgerInfo ∙ liwsSignatures
-- Equivalence of Blocks modulo signatures (both on the Block and in the QuorumCert it contains)
infix 4 _≈Block_
_≈Block_ : (b₁ b₂ : Block) → Set
b₁ ≈Block b₂ = b₁ ≡ (b₂ & bSignature ∙~ (b₁ ^∙ bSignature)
& bdQcSigs ∙~ (b₁ ^∙ bdQcSigs))
sym≈Block : Symmetric _≈Block_
sym≈Block refl = refl
-- ------------------------------------------------------------------------------
record AccumulatorExtensionProof : Set where
constructor AccumulatorExtensionProof∙new
field
_aepObmNumLeaves : Version
open AccumulatorExtensionProof public
unquoteDecl aepObmNumLeaves = mkLens (quote AccumulatorExtensionProof)
(aepObmNumLeaves ∷ [])
record VoteProposal : Set where
constructor VoteProposal∙new
field
_vpAccumulatorExtensionProof : AccumulatorExtensionProof
_vpBlock : Block
_vpNextEpochState : Maybe EpochState
open VoteProposal public
unquoteDecl vpAccumulatorExtensionProof vpBlock vpNextEpochState = mkLens (quote VoteProposal)
(vpAccumulatorExtensionProof ∷ vpBlock ∷ vpNextEpochState ∷ [])
record MaybeSignedVoteProposal : Set where
constructor MaybeSignedVoteProposal∙new
field
_msvpVoteProposal : VoteProposal
open MaybeSignedVoteProposal public
unquoteDecl msvpVoteProposal = mkLens (quote MaybeSignedVoteProposal)
(msvpVoteProposal ∷ [])
-- ------------------------------------------------------------------------------
record LastVoteInfo : Set where
constructor LastVoteInfo∙new
field
_lviLiDigest : HashValue
_lviRound : Round
_lviIsTimeout : Bool
open LastVoteInfo public
record PendingVotes : Set where
constructor mkPendingVotes
field
_pvLiDigestToVotes : KVMap HashValue LedgerInfoWithSignatures
_pvMaybePartialTC : Maybe TimeoutCertificate
_pvAuthorToVote : KVMap Author Vote
open PendingVotes public
unquoteDecl pvLiDigestToVotes pvMaybePartialTC pvAuthorToVote = mkLens (quote PendingVotes)
(pvLiDigestToVotes ∷ pvMaybePartialTC ∷ pvAuthorToVote ∷ [])
PendingVotes∙new : PendingVotes
PendingVotes∙new = mkPendingVotes Map.empty nothing Map.empty
-- ------------------------------------------------------------------------------
record StateComputeResult : Set where
constructor StateComputeResult∙new
field
_scrObmNumLeaves : Version
_scrEpochState : Maybe EpochState
open StateComputeResult public
unquoteDecl scrObmNumLeaves scrEpochState = mkLens (quote StateComputeResult)
(scrObmNumLeaves ∷ scrEpochState ∷ [])
postulate -- TODO: eliminate after fully implementing executeBlockE
stateComputeResult : StateComputeResult
record ExecutedBlock : Set where
constructor ExecutedBlock∙new
field
_ebBlock : Block
_ebStateComputeResult : StateComputeResult
open ExecutedBlock public
unquoteDecl ebBlock ebStateComputeResult = mkLens (quote ExecutedBlock)
(ebBlock ∷ ebStateComputeResult ∷ [])
-- getter only in Haskell
ebId : Lens ExecutedBlock HashValue
ebId = ebBlock ∙ bId
-- getter only in Haskell
ebQuorumCert : Lens ExecutedBlock QuorumCert
ebQuorumCert = ebBlock ∙ bQuorumCert
-- getter only in Haskell
ebParentId : Lens ExecutedBlock HashValue
ebParentId = ebQuorumCert ∙ qcCertifiedBlock ∙ biId
-- getter only in Haskell
ebRound : Lens ExecutedBlock Round
ebRound = ebBlock ∙ bRound
-- ------------------------------------------------------------------------------
record LinkableBlock : Set where
constructor LinkableBlock∙new
field
_lbExecutedBlock : ExecutedBlock
-- _lbChildren : Set HashValue
open LinkableBlock public
unquoteDecl lbExecutedBlock = mkLens (quote LinkableBlock)
(lbExecutedBlock ∷ [])
-- getter only in Haskell
lbId : Lens LinkableBlock HashValue
lbId = lbExecutedBlock ∙ ebId
-- ------------------------------------------------------------------------------
-- A block tree depends on a epoch config but works regardlesss of which
-- EpochConfig we have.
record BlockTree : Set where
constructor mkBlockTree
field
_btIdToBlock : KVMap HashValue LinkableBlock
_btRootId : HashValue
_btHighestCertifiedBlockId : HashValue
_btHighestQuorumCert : QuorumCert
_btHighestTimeoutCert : Maybe TimeoutCertificate
_btHighestCommitCert : QuorumCert
_btIdToQuorumCert : KVMap HashValue QuorumCert
_btPrunedBlockIds : VecDeque
_btMaxPrunedBlocksInMem : ℕ
open BlockTree public
unquoteDecl btIdToBlock btRootId btHighestCertifiedBlockId btHighestQuorumCert
btHighestTimeoutCert btHighestCommitCert
btIdToQuorumCert btPrunedBlockIds
btMaxPrunedBlocksInMem = mkLens (quote BlockTree)
(btIdToBlock ∷ btRootId ∷ btHighestCertifiedBlockId ∷ btHighestQuorumCert ∷
btHighestTimeoutCert ∷ btHighestCommitCert ∷
btIdToQuorumCert ∷ btPrunedBlockIds ∷
btMaxPrunedBlocksInMem ∷ [])
btGetLinkableBlock : HashValue → BlockTree → Maybe LinkableBlock
btGetLinkableBlock hv bt = Map.lookup hv (bt ^∙ btIdToBlock)
btGetBlock : HashValue → BlockTree → Maybe ExecutedBlock
btGetBlock hv bt = (_^∙ lbExecutedBlock) <$> btGetLinkableBlock hv bt
-- getter only in Haskell
btRoot : Lens BlockTree (Maybe ExecutedBlock)
btRoot = mkLens' g s
where
g : BlockTree → Maybe ExecutedBlock
g bt = btGetBlock (bt ^∙ btRootId) bt
-- TODO-1 : the setter is not needed/defined in Haskell
-- Defining it just to make progress, but it can't be defined
-- correctly in terms of type correctness (let alone setting a new root!)
s : BlockTree → Maybe ExecutedBlock → BlockTree
s bt _ = bt -- TODO-1 : cannot be done: need a way to defined only getters
-- getter only in haskell
btHighestCertifiedBlock : Lens BlockTree (Maybe ExecutedBlock)
btHighestCertifiedBlock = mkLens' g s
where
g : BlockTree → (Maybe ExecutedBlock)
g bt = btGetBlock (bt ^∙ btHighestCertifiedBlockId) bt
s : BlockTree → (Maybe ExecutedBlock) → BlockTree
s bt _ = bt -- TODO-1 : cannot be done: need a way to defined only getters
-- ------------------------------------------------------------------------------
record LedgerStore : Set where
constructor mkLedgerStore
field
_lsObmVersionToEpoch : Map.KVMap Version Epoch
_lsObmEpochToLIWS : Map.KVMap Epoch LedgerInfoWithSignatures
_lsLatestLedgerInfo : Maybe LedgerInfoWithSignatures
open LedgerStore public
unquoteDecl lsObmVersionToEpoch lsObmEpochToLIWS lsLatestLedgerInfo = mkLens (quote LedgerStore)
(lsObmVersionToEpoch ∷ lsObmEpochToLIWS ∷ lsLatestLedgerInfo ∷ [])
record DiemDB : Set where
constructor DiemDB∙new
field
_ddbLedgerStore : LedgerStore
open DiemDB public
unquoteDecl ddbLedgerStore = mkLens (quote DiemDB)
(ddbLedgerStore ∷ [])
record LedgerRecoveryData : Set where
constructor LedgerRecoveryData∙new
field
_lrdStorageLedger : LedgerInfo
record MockSharedStorage : Set where
constructor mkMockSharedStorage
field
-- Safety state
_mssBlock : Map.KVMap HashValue Block
_mssQc : Map.KVMap HashValue QuorumCert
_mssLis : Map.KVMap Version LedgerInfoWithSignatures
_mssLastVote : Maybe Vote
-- Liveness state
_mssHighestTimeoutCertificate : Maybe TimeoutCertificate
_mssValidatorSet : ValidatorSet
open MockSharedStorage public
unquoteDecl mssBlock mssQc mssLis mssLastVote
mssHighestTimeoutCertificate mssValidatorSet = mkLens (quote MockSharedStorage)
(mssBlock ∷ mssQc ∷ mssLis ∷ mssLastVote ∷
mssHighestTimeoutCertificate ∷ mssValidatorSet ∷ [])
record MockStorage : Set where
constructor MockStorage∙new
field
_msSharedStorage : MockSharedStorage
_msStorageLedger : LedgerInfo
_msObmDiemDB : DiemDB
open MockStorage public
unquoteDecl msSharedStorage msStorageLedger msObmDiemDB = mkLens (quote MockStorage)
(msSharedStorage ∷ msStorageLedger ∷ msObmDiemDB ∷ [])
PersistentLivenessStorage = MockStorage
-- IMPL-DIFF : This is defined without record fields in Haskell.
-- The record fields below are never used. But RootInfo must be a record for pattern matching.
record RootInfo : Set where
constructor RootInfo∙new
field
_riBlock : Block
_riQC1 : QuorumCert
_riQC2 : QuorumCert
-- ------------------------------------------------------------------------------
record SafetyData : Set where
constructor SafetyData∙new
field
_sdEpoch : Epoch
_sdLastVotedRound : Round
_sdPreferredRound : Round
_sdLastVote : Maybe Vote
open SafetyData public
unquoteDecl sdEpoch sdLastVotedRound sdPreferredRound sdLastVote =
mkLens (quote SafetyData)
(sdEpoch ∷ sdLastVotedRound ∷ sdPreferredRound ∷ sdLastVote ∷ [])
record Waypoint : Set where
constructor Waypoint∙new
field
_wVersion : Version
_wValue : HashValue
open Waypoint public
unquoteDecl wVersion wValue = mkLens (quote Waypoint)
(wVersion ∷ wValue ∷ [])
postulate instance enc-Waypoint : Encoder Waypoint
record PersistentSafetyStorage : Set where
constructor mkPersistentSafetyStorage
field
_pssSafetyData : SafetyData
_pssAuthor : Author
_pssWaypoint : Waypoint
_pssObmSK : Maybe SK
open PersistentSafetyStorage public
unquoteDecl pssSafetyData pssAuthor pssWaypoint pssObmSK = mkLens (quote PersistentSafetyStorage)
(pssSafetyData ∷ pssAuthor ∷ pssWaypoint ∷ pssObmSK ∷ [])
record OnChainConfigPayload : Set where
constructor OnChainConfigPayload∙new
field
_occpEpoch : Epoch
_occpObmValidatorSet : ValidatorSet
open OnChainConfigPayload public
unquoteDecl occpEpoch occpObmValidatorSet = mkLens (quote OnChainConfigPayload)
(occpEpoch ∷ occpObmValidatorSet ∷ [])
-- instance S.Serialize OnChainConfigPayload
record ReconfigEventEpochChange : Set where
constructor ReconfigEventEpochChange∙new
field
_reecOnChainConfigPayload : OnChainConfigPayload
-- instance S.Serialize ReconfigEventEpochChange
-- ------------------------------------------------------------------------------
-- IMPL-DIFF : Haskell StateComputer has pluggable functions.
-- The Agda version just calls them directly
record StateComputer : Set where
constructor StateComputer∙new
field
_scObmVersion : Version
open StateComputer public
unquoteDecl scObmVersion = mkLens (quote StateComputer)
(scObmVersion ∷ [])
StateComputerComputeType
= StateComputer → Block → HashValue
→ Either (List String) StateComputeResult
StateComputerCommitType
= StateComputer → DiemDB → ExecutedBlock → LedgerInfoWithSignatures
→ Either (List String) (StateComputer × DiemDB × Maybe ReconfigEventEpochChange)
StateComputerSyncToType
= LedgerInfoWithSignatures
→ Either (List String) ReconfigEventEpochChange
-- ------------------------------------------------------------------------------
record BlockStore : Set where
constructor BlockStore∙new
field
_bsInner : BlockTree
_bsStateComputer : StateComputer
_bsStorage : PersistentLivenessStorage
open BlockStore public
unquoteDecl bsInner bsStateComputer bsStorage = mkLens (quote BlockStore)
(bsInner ∷ bsStateComputer ∷ bsStorage ∷ [])
postulate -- TODO: stateComputer
stateComputer : StateComputer
-- getter only in Haskell
bsRoot : Lens BlockStore (Maybe ExecutedBlock)
bsRoot = bsInner ∙ btRoot
-- getter only in Haskell
bsHighestQuorumCert : Lens BlockStore QuorumCert
bsHighestQuorumCert = bsInner ∙ btHighestQuorumCert
-- getter only in Haskell
bsHighestCommitCert : Lens BlockStore QuorumCert
bsHighestCommitCert = bsInner ∙ btHighestCommitCert
-- getter only in Haskell
bsHighestTimeoutCert : Lens BlockStore (Maybe TimeoutCertificate)
bsHighestTimeoutCert = bsInner ∙ btHighestTimeoutCert
-- ------------------------------------------------------------------------------
data NewRoundReason : Set where
QCReady : NewRoundReason
TOReady : NewRoundReason
record NewRoundEvent : Set where
constructor NewRoundEvent∙new
field
_nreRound : Round
_nreReason : NewRoundReason
_nreTimeout : Duration
unquoteDecl nreRound nreReason nreTimeout = mkLens (quote NewRoundEvent)
(nreRound ∷ nreReason ∷ nreTimeout ∷ [])
-- LibraBFT.ImplShared.Consensus.Types contains
-- ExponentialTimeInterval, RoundState
-- ------------------------------------------------------------------------------
record ProposalGenerator : Set where
constructor ProposalGenerator∙new
field
_pgLastRoundGenerated : Round
open ProposalGenerator
unquoteDecl pgLastRoundGenerated = mkLens (quote ProposalGenerator)
(pgLastRoundGenerated ∷ [])
-- ------------------------------------------------------------------------------
data ObmNotValidProposerReason : Set where
ProposalDoesNotHaveAnAuthor ProposerForBlockIsNotValidForThisRound NotValidProposer : ObmNotValidProposerReason
record ProposerElection : Set where
constructor ProposerElection∙new
field
_peProposers : List Author -- TODO-1 : this should be 'Set Author'
-- _peObmLeaderOfRound : LeaderOfRoundFn
-- _peObmNodesInOrder : NodesInOrder
open ProposerElection
-- ------------------------------------------------------------------------------
record SafetyRules : Set where
constructor mkSafetyRules
field
_srPersistentStorage : PersistentSafetyStorage
_srExportConsensusKey : Bool
_srValidatorSigner : Maybe ValidatorSigner
_srEpochState : Maybe EpochState
open SafetyRules public
unquoteDecl srPersistentStorage srExportConsensusKey srValidatorSigner srEpochState = mkLens (quote SafetyRules)
(srPersistentStorage ∷ srExportConsensusKey ∷ srValidatorSigner ∷ srEpochState ∷ [])
-- ------------------------------------------------------------------------------
record BlockRetrievalRequest : Set where
constructor BlockRetrievalRequest∙new
field
_brqObmFrom : Author
_brqBlockId : HashValue
_brqNumBlocks : U64
open BlockRetrievalRequest public
unquoteDecl brqObmFrom brqBlockId brqNumBlocks = mkLens (quote BlockRetrievalRequest)
(brqObmFrom ∷ brqBlockId ∷ brqNumBlocks ∷ [])
postulate instance enc-BlockRetrievalRequest : Encoder BlockRetrievalRequest
data BlockRetrievalStatus : Set where
BRSSucceeded BRSIdNotFound BRSNotEnoughBlocks : BlockRetrievalStatus
open BlockRetrievalStatus public
postulate instance enc-BlockRetrievalState : Encoder BlockRetrievalStatus
brs-eq : (brs₁ brs₂ : BlockRetrievalStatus) → Dec (brs₁ ≡ brs₂)
brs-eq BRSSucceeded BRSSucceeded = yes refl
brs-eq BRSSucceeded BRSIdNotFound = no λ ()
brs-eq BRSSucceeded BRSNotEnoughBlocks = no λ ()
brs-eq BRSIdNotFound BRSSucceeded = no λ ()
brs-eq BRSIdNotFound BRSIdNotFound = yes refl
brs-eq BRSIdNotFound BRSNotEnoughBlocks = no λ ()
brs-eq BRSNotEnoughBlocks BRSSucceeded = no λ ()
brs-eq BRSNotEnoughBlocks BRSIdNotFound = no λ ()
brs-eq BRSNotEnoughBlocks BRSNotEnoughBlocks = yes refl
instance
Eq-BlockRetrievalStatus : Eq BlockRetrievalStatus
Eq._≟_ Eq-BlockRetrievalStatus = brs-eq
record BlockRetrievalResponse : Set where
constructor BlockRetrievalResponse∙new
field
_brpObmFrom : (Author × Epoch × Round) -- for logging
_brpStatus : BlockRetrievalStatus
_brpBlocks : List Block
unquoteDecl brpObmFrom brpStatus brpBlocks = mkLens (quote BlockRetrievalResponse)
(brpObmFrom ∷ brpStatus ∷ brpBlocks ∷ [])
postulate instance enc-BlockRetrievalResponse : Encoder BlockRetrievalResponse
-- ------------------------------------------------------------------------------
-- LibraBFT.ImplShared.Consensus.Types contains
-- ObmNeedFetch, RoundManager
-- ------------------------------------------------------------------------------
record BlockRetriever : Set where
constructor BlockRetriever∙new
field
_brDeadline : Instant
_brPreferredPeer : Author
open BlockRetriever public
unquoteDecl brDeadline brPreferredPeer = mkLens (quote BlockRetriever)
(brDeadline ∷ brPreferredPeer ∷ [])
-- ------------------------------------------------------------------------------
record SyncInfo : Set where
constructor mkSyncInfo -- Bare constructor to enable pattern matching against SyncInfo; "smart"
-- constructor SyncInfo∙new is below
field
_siHighestQuorumCert : QuorumCert
_sixxxHighestCommitCert : Maybe QuorumCert
_siHighestTimeoutCert : Maybe TimeoutCertificate
open SyncInfo public
-- Note that we do not automatically derive a lens for siHighestCommitCert;
-- it is defined manually below.
unquoteDecl siHighestQuorumCert sixxxHighestCommitCert siHighestTimeoutCert = mkLens (quote SyncInfo)
(siHighestQuorumCert ∷ sixxxHighestCommitCert ∷ siHighestTimeoutCert ∷ [])
postulate instance enc-SyncInfo : Encoder SyncInfo
SyncInfo∙new : QuorumCert → QuorumCert → Maybe TimeoutCertificate → SyncInfo
SyncInfo∙new highestQuorumCert highestCommitCert highestTimeoutCert =
record { _siHighestQuorumCert = highestQuorumCert
; _sixxxHighestCommitCert = if highestQuorumCert QCBoolEq highestCommitCert
then nothing else (just highestCommitCert)
; _siHighestTimeoutCert = highestTimeoutCert }
-- getter only in Haskell
siHighestCommitCert : Lens SyncInfo QuorumCert
siHighestCommitCert =
mkLens' (λ x → fromMaybe (x ^∙ siHighestQuorumCert) (x ^∙ sixxxHighestCommitCert))
(λ x qc → record x { _sixxxHighestCommitCert = just qc })
-- getter only in Haskell
siHighestCertifiedRound : Lens SyncInfo Round
siHighestCertifiedRound = siHighestQuorumCert ∙ qcCertifiedBlock ∙ biRound
-- getter only in Haskell
siHighestTimeoutRound : Lens SyncInfo Round
siHighestTimeoutRound =
mkLens' (maybe 0 (_^∙ tcRound) ∘ (_^∙ siHighestTimeoutCert))
(λ x _r → x) -- TODO-1
-- getter only in Haskell
siHighestCommitRound : Lens SyncInfo Round
siHighestCommitRound = siHighestCommitCert ∙ qcCommitInfo ∙ biRound
-- getter only in Haskell
siHighestRound : Lens SyncInfo Round
siHighestRound =
mkLens' (λ x → (x ^∙ siHighestCertifiedRound) ⊔ (x ^∙ siHighestTimeoutRound))
(λ x _r → x) -- TODO-1
-- getter only in Haskell
siEpoch : Lens SyncInfo Epoch
siEpoch = siHighestQuorumCert ∙ qcCertifiedBlock ∙ biEpoch
-- getter only in Haskell
siObmRound : Lens SyncInfo Round
siObmRound = siHighestQuorumCert ∙ qcCertifiedBlock ∙ biRound
-- ------------------------------------------------------------------------------
record ProposalMsg : Set where
constructor ProposalMsg∙new
field
_pmProposal : Block
_pmSyncInfo : SyncInfo
open ProposalMsg public
unquoteDecl pmProposal pmSyncInfo = mkLens (quote ProposalMsg)
(pmProposal ∷ pmSyncInfo ∷ [])
postulate instance enc-ProposalMsg : Encoder ProposalMsg
-- getter only in Haskell
pmEpoch : Lens ProposalMsg Epoch
pmEpoch = pmProposal ∙ bEpoch
-- getter only in Haskell
pmRound : Lens ProposalMsg Round
pmRound = pmProposal ∙ bRound
-- getter only in Haskell
pmProposer : Lens ProposalMsg (Maybe Author)
pmProposer = pmProposal ∙ bAuthor
-- ------------------------------------------------------------------------------
record VoteMsg : Set where
constructor VoteMsg∙new
field
_vmVote : Vote
_vmSyncInfo : SyncInfo
open VoteMsg public
unquoteDecl vmVote vmSyncInfo = mkLens (quote VoteMsg)
(vmVote ∷ vmSyncInfo ∷ [])
postulate instance enc-VoteMsg : Encoder VoteMsg
-- not defined in Haskell
vmProposed : Lens VoteMsg BlockInfo
vmProposed = vmVote ∙ vVoteData ∙ vdProposed
-- not defined in Haskell
vmParent : Lens VoteMsg BlockInfo
vmParent = vmVote ∙ vVoteData ∙ vdParent
-- getter-only in Haskell
vmEpoch : Lens VoteMsg Epoch
vmEpoch = vmVote ∙ vEpoch
-- getter-only in Haskell
vmRound : Lens VoteMsg Round
vmRound = vmVote ∙ vRound
-- ------------------------------------------------------------------------------
-- This is a notification of a commit. It may not be explicitly included in an implementation,
-- but we need something to be able to express correctness conditions. It will
-- probably have something different in it, but will serve the purpose for now.
record CommitMsg : Set where
constructor CommitMsg∙new
field
_cmEpoch : Epoch
_cmAuthor : NodeId
_cmRound : Round
_cmCert : QuorumCert -- We assume for now that a CommitMsg contains the QuorumCert of the head of the 3-chain
_cmSigMB : Maybe Signature
open CommitMsg public
unquoteDecl cmEpoch cmAuthor cmRound cmCert cmSigMB = mkLens (quote CommitMsg)
(cmEpoch ∷ cmAuthor ∷ cmRound ∷ cmCert ∷ cmSigMB ∷ [])
postulate instance enc-CommitMsg : Encoder CommitMsg
-- ------------------------------------------------------------------------------
data RootMetadata : Set where RootMetadata∙new : RootMetadata
-- ------------------------------------------------------------------------------
record RecoveryData : Set where
constructor mkRecoveryData
field
_rdLastVote : Maybe Vote
_rdRoot : RootInfo
_rdRootMetadata : RootMetadata
_rdBlocks : List Block
_rdQuorumCerts : List QuorumCert
_rdBlocksToPrune : Maybe (List HashValue)
_rdHighestTimeoutCertificate : Maybe TimeoutCertificate
open RecoveryData public
unquoteDecl rdLastVote rdRoot rdRootMetadata rdBlocks
rdQuorumCerts rdBlocksToPrune rdHighestTimeoutCertificate = mkLens (quote RecoveryData)
(rdLastVote ∷ rdRoot ∷ rdRootMetadata ∷ rdBlocks ∷
rdQuorumCerts ∷ rdBlocksToPrune ∷ rdHighestTimeoutCertificate ∷ [])
------------------------------------------------------------------------------
record EpochChangeProof : Set where
constructor EpochChangeProof∙new
field
_ecpLedgerInfoWithSigs : List LedgerInfoWithSignatures
_ecpMore : Bool
open EpochChangeProof public
unquoteDecl ecpLedgerInfoWithSigs ecpMore = mkLens (quote EpochChangeProof)
(ecpLedgerInfoWithSigs ∷ ecpMore ∷ [])
-- instance S.Serialize EpochChangeProof
record Ledger2WaypointConverter : Set where
constructor mkLedger2WaypointConverter
field
_l2wcEpoch : Epoch
_l2wcRootHash : HashValue
_l2wcVersion : Version
--_l2wcTimestamp : Instant
_l2wcNextEpochState : Maybe EpochState
open Ledger2WaypointConverter public
unquoteDecl l2wcEpoch 2wcRootHash 2wcVersion
{-l2wcTimestamp-} l2wcNextEpochState = mkLens (quote Ledger2WaypointConverter)
(l2wcEpoch ∷ 2wcRootHash ∷ 2wcVersion ∷
{-l2wcTimestamp-} l2wcNextEpochState ∷ [])
record EpochRetrievalRequest : Set where
constructor EpochRetrievalRequest∙new
field
_eprrqStartEpoch : Epoch
_eprrqEndEpoch : Epoch
unquoteDecl eprrqStartEpoch eprrqEndEpoch = mkLens (quote EpochRetrievalRequest)
(eprrqStartEpoch ∷ eprrqEndEpoch ∷ [])
-- instance S.Serialize EpochRetrievalRequest
------------------------------------------------------------------------------
record ConsensusState : Set where
constructor ConsensusState∙new
field
_csSafetyData : SafetyData
_csWaypoint : Waypoint
--_csInValidatorSet : Bool -- LBFT-OBM-DIFF: only used in tests in Rust
open ConsensusState public
unquoteDecl csSafetyData csWaypoint {-csInValidatorSet-} = mkLens (quote ConsensusState)
(csSafetyData ∷ csWaypoint {-∷ csInValidatorSet-} ∷ [])
------------------------------------------------------------------------------
data SafetyRulesWrapper : Set where
SRWLocal : SafetyRules → SafetyRulesWrapper
record SafetyRulesManager : Set where
constructor mkSafetyRulesManager
field
_srmInternalSafetyRules : SafetyRulesWrapper
open SafetyRulesWrapper public
unquoteDecl srmInternalSafetyRules = mkLens (quote SafetyRulesManager)
(srmInternalSafetyRules ∷ [])
data SafetyRulesService : Set where
SRSLocal : SafetyRulesService
record SafetyRulesConfig : Set where
constructor SafetyRulesConfig∙new
field
_srcService : SafetyRulesService
_srcExportConsensusKey : Bool
_srcObmGenesisWaypoint : Waypoint
open SafetyRulesConfig public
unquoteDecl srcService srcExportConsensusKey srcObmGenesisWaypoint = mkLens (quote SafetyRulesConfig)
(srcService ∷ srcExportConsensusKey ∷ srcObmGenesisWaypoint ∷ [])
record ConsensusConfig : Set where
constructor ConsensusConfig∙new
field
_ccMaxPrunedBlocksInMem : Usize
_ccRoundInitialTimeoutMS : U64
_ccSafetyRules : SafetyRulesConfig
_ccSyncOnly : Bool
open ConsensusConfig public
unquoteDecl ccMaxPrunedBlocksInMem ccRoundInitialTimeoutMS ccSafetyRules ccSyncOnly = mkLens (quote ConsensusConfig)
(ccMaxPrunedBlocksInMem ∷ ccRoundInitialTimeoutMS ∷ ccSafetyRules ∷ ccSyncOnly ∷ [])
record NodeConfig : Set where
constructor NodeConfig∙new
field
_ncObmMe : AuthorName
_ncConsensus : ConsensusConfig
open NodeConfig public
unquoteDecl ncObmMe ncConsensus = mkLens (quote NodeConfig)
(ncObmMe ∷ ncConsensus ∷ [])
record RecoveryManager : Set where
constructor RecoveryManager∙new
field
_rcmEpochState : EpochState
_rcmStorage : PersistentLivenessStorage
--_rcmStateComputer : StateComputer
_rcmLastCommittedRound : Round
open RecoveryManager public
unquoteDecl rcmEpochState rcmStorage {- rcmStateComputer-} rcmLastCommittedRound = mkLens (quote RecoveryManager)
(rcmEpochState ∷ rcmStorage {-∷ rcmStateComputer-} ∷ rcmLastCommittedRound ∷ [])
-- RoundProcessor in EpochManagerTypes (because it depends on RoundManager)
-- EpochManager in EpochManagerTypes (because it depends on RoundProcessor)
-- ------------------------------------------------------------------------------
data VoteReceptionResult : Set where
QCVoteAdded : U64 → VoteReceptionResult
TCVoteAdded : U64 → VoteReceptionResult
DuplicateVote : VoteReceptionResult
EquivocateVote : VoteReceptionResult
NewQuorumCertificate : QuorumCert → VoteReceptionResult
NewTimeoutCertificate : TimeoutCertificate → VoteReceptionResult
UnexpectedRound : Round → Round → VoteReceptionResult
VRR_TODO : VoteReceptionResult
-- ------------------------------------------------------------------------------
-- LibraBFT.ImplShared.Interface.Output contains
-- Output
-- ------------------------------------------------------------------------------
data VerifyError : Set where
UnknownAuthor : AuthorName → VerifyError
TooLittleVotingPower : U64 → U64 → VerifyError
TooManySignatures : Usize → Usize → VerifyError
InvalidSignature : VerifyError
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/aggr20.adb | best08618/asylo | 7 | 6209 | <reponame>best08618/asylo
-- { dg-do compile }
package body Aggr20 is
procedure Proc (R : out Rec3) is
begin
R := (Callback => Nil_Rec2);
end;
end Aggr20;
|
programs/oeis/237/A237415.asm | neoneye/loda | 22 | 18510 | ; A237415: For k in {2,3,...,9} define a sequence as follows: a(0)=0; for n>=0, a(n+1)=a(n)+1, unless a(n) ends in k, in which case a(n+1) is obtained by replacing the last digit of a(n) with the digit(s) of k^3. This is k(2).
; 0,1,2,8,9,10,11,12,18,19,20,21,22,28,29,30,31,32,38,39,40,41,42,48,49,50,51,52,58,59,60,61,62,68,69,70,71,72,78,79,80,81,82,88,89,90,91,92,98,99,100,101,102,108,109,110,111,112,118,119,120,121,122,128,129,130,131,132,138,139,140,141,142,148,149,150,151,152,158,159,160,161,162,168,169,170,171,172,178,179,180,181,182,188,189,190,191,192,198,199
mov $1,$0
add $0,2
div $0,5
mul $0,5
add $0,$1
|
alloy4fun_models/trashltl/models/18/zYQSqarrz45HetZqP.als | Kaixi26/org.alloytools.alloy | 0 | 4390 | <gh_stars>0
open main
pred idzYQSqarrz45HetZqP_prop19 {
always (all f : Protected | f in Trash until f in Protected)
}
pred __repair { idzYQSqarrz45HetZqP_prop19 }
check __repair { idzYQSqarrz45HetZqP_prop19 <=> prop19o } |
oeis/170/A170755.asm | neoneye/loda-programs | 11 | 11568 | <filename>oeis/170/A170755.asm<gh_stars>10-100
; A170755: Expansion of g.f.: (1+x)/(1-35*x).
; 1,36,1260,44100,1543500,54022500,1890787500,66177562500,2316214687500,81067514062500,2837362992187500,99307704726562500,3475769665429687500,121651938290039062500,4257817840151367187500,149023624405297851562500,5215826854185424804687500,182553939896489868164062500,6389387896377145385742187500,223628576373200088500976562500,7827000173062003097534179687500,273945006057170108413696289062500,9588075212000953794479370117187500,335582632420033382806777954101562500
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
div $3,$2
mul $2,35
lpe
mov $0,$2
div $0,35
|
src/fsmaker-commands-init.adb | Fabien-Chouteau/fsmaker | 0 | 1030 | <gh_stars>0
with Simple_Logging;
with Interfaces.C_Streams; use Interfaces.C_Streams;
package body FSmaker.Commands.Init is
-------------
-- Execute --
-------------
overriding
procedure Execute (This : in out Instance;
Args : AAA.Strings.Vector)
is
function ftruncate (FS : int;
Length : Long_Integer)
return int;
pragma Import (C, ftruncate, "ftruncate");
begin
case Args.Count is
when 0 =>
This.Failure ("Missing argument <size>");
when 1 =>
declare
Arg : constant String := Args (1);
Size : Natural;
begin
Size := Natural'Value (Args (1));
This.Setup_Image (To_Format => True);
if ftruncate (int (This.FD), Long_Integer (Size)) /= 0 then
raise Program_Error with "ftruncate error: " &
GNAT.OS_Lib.Errno_Message;
end if;
Simple_Logging.Always ("Format with Size:" & Size'Img);
This.Target.Format (This.FD, Size);
This.Success;
exception
when Constraint_Error =>
This.Failure ("Invalid size argument: '" & Arg & "'");
end;
when others =>
This.Failure ("Too many arguments");
end case;
end Execute;
--------------------
-- Setup_Switches --
--------------------
overriding
procedure Setup_Switches
(This : in out Instance;
Config : in out CLIC.Subcommand.Switches_Configuration)
is
begin
null;
end Setup_Switches;
end FSmaker.Commands.Init;
|
asm/interrupt.asm | PenetratingShot/OS | 11 | 12598 | ; Defined in isr.c
[extern isr_handler]
[extern irq_handler]
%macro pushaq 0
push rax
push rbx
push rcx
push rdx
push rbp
push rsi
push rdi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
%endmacro
%macro popaq 0
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rbp
pop rdx
pop rcx
pop rbx
pop rax
%endmacro
isr_common:
pushaq
cld
xor rax, rax
mov rdi, rsp
call isr_handler
popaq
; Remove the error code and interrupt number
add rsp, 16
iretq
irq_common:
pushaq
cld
xor rax, rax
mov rdi, rsp
call irq_handler
popaq
; Remove the error code and interrupt number
add rsp, 16
iretq
global isr0
global isr1
global isr2
global isr3
global isr4
global isr5
global isr6
global isr7
global isr8
global isr9
global isr10
global isr11
global isr12
global isr13
global isr14
global isr15
global isr16
global isr17
global isr18
global isr19
global isr20
global isr21
global isr22
global isr23
global isr24
global isr25
global isr26
global isr27
global isr28
global isr29
global isr30
global isr31
; IRQs
global irq0
global irq1
global irq2
global irq3
global irq4
global irq5
global irq6
global irq7
global irq8
global irq9
global irq10
global irq11
global irq12
global irq13
global irq14
global irq15
; 0: Divide By Zero Exception
isr0:
push byte 0
push byte 0
jmp isr_common
; 1: Debug Exception
isr1:
push byte 0
push byte 1
jmp isr_common
; 2: Non Maskable Interrupt Exception
isr2:
push byte 0
push byte 2
jmp isr_common
; 3: Int 3 Exception
isr3:
push byte 0
push byte 3
jmp isr_common
; 4: INTO Exception
isr4:
push byte 0
push byte 4
jmp isr_common
; 5: Out of Bounds Exception
isr5:
push byte 0
push byte 5
jmp isr_common
; 6: Invalid Opcode Exception
isr6:
push byte 0
push byte 6
jmp isr_common
; 7: Coprocessor Not Available Exception
isr7:
push byte 0
push byte 7
jmp isr_common
; 8: Double Fault Exception (With Error Code!)
isr8:
push byte 8
jmp isr_common
; 9: Coprocessor Segment Overrun Exception
isr9:
push byte 0
push byte 9
jmp isr_common
; 10: Bad TSS Exception (With Error Code!)
isr10:
push byte 10
jmp isr_common
; 11: Segment Not Present Exception (With Error Code!)
isr11:
push byte 11
jmp isr_common
; 12: Stack Fault Exception (With Error Code!)
isr12:
push byte 12
jmp isr_common
; 13: General Protection Fault Exception (With Error Code!)
isr13:
push byte 13
jmp isr_common
; 14: Page Fault Exception (With Error Code!)
isr14:
push byte 14
jmp isr_common
; 15: Reserved Exception
isr15:
push byte 0
push byte 15
jmp isr_common
; 16: Floating Point Exception
isr16:
push byte 0
push byte 16
jmp isr_common
; 17: Alignment Check Exception
isr17:
push byte 0
push byte 17
jmp isr_common
; 18: Machine Check Exception
isr18:
push byte 0
push byte 18
jmp isr_common
; 19: Reserved
isr19:
push byte 0
push byte 19
jmp isr_common
; 20: Reserved
isr20:
push byte 0
push byte 20
jmp isr_common
; 21: Reserved
isr21:
push byte 0
push byte 21
jmp isr_common
; 22: Reserved
isr22:
push byte 0
push byte 22
jmp isr_common
; 23: Reserved
isr23:
push byte 0
push byte 23
jmp isr_common
; 24: Reserved
isr24:
push byte 0
push byte 24
jmp isr_common
; 25: Reserved
isr25:
push byte 0
push byte 25
jmp isr_common
; 26: Reserved
isr26:
push byte 0
push byte 26
jmp isr_common
; 27: Reserved
isr27:
push byte 0
push byte 27
jmp isr_common
; 28: Reserved
isr28:
push byte 0
push byte 28
jmp isr_common
; 29: Reserved
isr29:
push byte 0
push byte 29
jmp isr_common
; 30: Reserved
isr30:
push byte 0
push byte 30
jmp isr_common
; 31: Reserved
isr31:
push byte 0
push byte 31
jmp isr_common
; IRQ handlers
irq0:
push byte 0
push byte 32
jmp irq_common
irq1:
push byte 1
push byte 33
jmp irq_common
irq2:
push byte 2
push byte 34
jmp irq_common
irq3:
push byte 3
push byte 35
jmp irq_common
irq4:
push byte 4
push byte 36
jmp irq_common
irq5:
push byte 5
push byte 37
jmp irq_common
irq6:
push byte 6
push byte 38
jmp irq_common
irq7:
push byte 7
push byte 39
jmp irq_common
irq8:
push byte 8
push byte 40
jmp irq_common
irq9:
push byte 9
push byte 41
jmp irq_common
irq10:
push byte 10
push byte 42
jmp irq_common
irq11:
push byte 11
push byte 43
jmp irq_common
irq12:
push byte 12
push byte 44
jmp irq_common
irq13:
push byte 13
push byte 45
jmp irq_common
irq14:
push byte 14
push byte 46
jmp irq_common
irq15:
push byte 15
push byte 47
jmp irq_common |
source/textio/a-tigbio.ads | ytomino/drake | 33 | 22221 | pragma License (Unrestricted);
-- generalized unit of Ada.Text_IO.Bounded_IO
with Ada.Strings.Generic_Bounded;
generic
with package Bounded_Strings is new Strings.Generic_Bounded (<>);
with package Bounded is new Bounded_Strings.Generic_Bounded_Length (<>);
with procedure Put (
File : File_Type;
Item : Bounded_Strings.String_Type) is <>;
with procedure Put_Line (
File : File_Type;
Item : Bounded_Strings.String_Type) is <>;
with procedure Get_Line (
File : File_Type;
Item : out Bounded_Strings.String_Type;
Last : out Natural) is <>;
package Ada.Text_IO.Generic_Bounded_IO is
procedure Put (
File : File_Type; -- Output_File_Type
Item : Bounded.Bounded_String);
procedure Put (
Item : Bounded.Bounded_String);
procedure Put_Line (
File : File_Type; -- Output_File_Type
Item : Bounded.Bounded_String);
procedure Put_Line (
Item : Bounded.Bounded_String);
function Get_Line (
File : File_Type) -- Input_File_Type
return Bounded.Bounded_String;
function Get_Line
return Bounded.Bounded_String;
procedure Get_Line (
File : File_Type; -- Input_File_Type
Item : out Bounded.Bounded_String);
procedure Get_Line (
Item : out Bounded.Bounded_String);
end Ada.Text_IO.Generic_Bounded_IO;
|
source/web/fastcgi/matreshka-fastcgi-streaming_server.adb | svn2github/matreshka | 24 | 18280 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2013, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Containers.Ordered_Maps;
with Ada.Streams;
with Ada.Text_IO;
with GNAT.Sockets;
--with Matreshka.Internals.Unicode.Characters.Latin;
--with Matreshka.FastCGI.Query_Items;
--with FastCGI.Requests.Internals;
--with FastCGI.Replies.Internals;
with FastCGI.Handlers.Responder;
with Matreshka.FastCGI.Descriptors;
with Matreshka.FastCGI.Protocol;
package body Matreshka.FastCGI.Streaming_Server is
use Ada.Streams;
-- use League.Stream_Element_Vectors;
-- use Matreshka.Internals.Unicode.Characters.Latin;
use Matreshka.FastCGI.Protocol;
package Request_Handler_Maps is
new Ada.Containers.Ordered_Maps
(FCGI_Request_Identifier,
Matreshka.FastCGI.Descriptors.Descriptor_Access,
Matreshka.FastCGI."<",
Matreshka.FastCGI.Descriptors."=");
function FCGI_Listen_Socket return GNAT.Sockets.Socket_Type;
-- Returns socket to be listen to accept connections from web-server.
-- FCGI_Request_Complete : constant := 0;
-- FCGI_Cant_Mpx_Conn : constant := 1;
-- FCGI_Overloaded : constant := 2;
-- FCGI_Unknown_Role : constant := 3;
procedure Process_Connection
(Socket : GNAT.Sockets.Socket_Type;
Responder_Factory : Standard.FastCGI.Application.Responder_Factory);
procedure Process_Begin_Request
(Responder_Factory : Standard.FastCGI.Application.Responder_Factory;
Socket : GNAT.Sockets.Socket_Type;
Request_Id : FCGI_Request_Identifier;
Buffer : Stream_Element_Array);
-- Process FCGI_BEGIN_REQUEST record
-- procedure Execute_Request
-- (Socket : GNAT.Sockets.Socket_Type;
-- Request_Id : FCGI_Request_Identifier;
-- Handler : Standard.FastCGI.Application.Callback);
--
-- procedure Send_Header
-- (Socket : GNAT.Sockets.Socket_Type;
-- Packet_Type : Matreshka.FastCGI.Protocol.FCGI_Packet_Type;
-- Request_Id : FCGI_Request_Identifier;
-- Content_Length : Ada.Streams.Stream_Element_Offset;
-- Padding_Length : Ada.Streams.Stream_Element_Offset);
--
-- procedure Send_End_Request
-- (Socket : GNAT.Sockets.Socket_Type;
-- Request_Id : FCGI_Request_Identifier;
-- Application_Status : Integer;
-- Protocol_Status : Ada.Streams.Stream_Element);
Requests : Request_Handler_Maps.Map;
-------------
-- Execute --
-------------
procedure Execute
(Responder_Factory : Standard.FastCGI.Application.Responder_Factory)
is
Socket : GNAT.Sockets.Socket_Type;
Address : GNAT.Sockets.Sock_Addr_Type;
begin
null;
-- Dsc.Request_Id := 0;
--
loop
GNAT.Sockets.Accept_Socket (FCGI_Listen_Socket, Socket, Address);
-- XXX Address mush be checked here in presence in the environment
-- variable.
Process_Connection (Socket, Responder_Factory);
end loop;
end Execute;
-- ---------------------
-- -- Execute_Request --
-- ---------------------
--
-- procedure Execute_Request
-- (Socket : GNAT.Sockets.Socket_Type;
-- Request_Id : FCGI_Request_Identifier;
-- Handler : Standard.FastCGI.Application.Callback)
-- is
-- procedure Send_Headers;
--
-- ------------------
-- -- Send_Headers --
-- ------------------
--
-- procedure Send_Headers is
--
-- Content_Length : Stream_Element_Offset := 2;
-- Padding_Length : Stream_Element_Offset;
--
-- procedure Compute_Length (Position : Maps.Cursor);
--
-- procedure Send_Header (Position : Maps.Cursor);
--
-- --------------------
-- -- Compute_Length --
-- --------------------
--
-- procedure Compute_Length (Position : Maps.Cursor) is
-- Name : constant Stream_Element_Vector := Maps.Key (Position);
-- Value : constant Stream_Element_Vector := Maps.Element (Position);
--
-- begin
-- Content_Length := Content_Length + Name.Length + Value.Length + 4;
-- end Compute_Length;
--
-- -----------------
-- -- Send_Header --
-- -----------------
--
-- procedure Send_Header (Position : Maps.Cursor) is
-- Name : constant Stream_Element_Array
-- := Maps.Key (Position).To_Stream_Element_Array;
-- Value : constant Stream_Element_Array
-- := Maps.Element (Position).To_Stream_Element_Array;
-- Separator : constant Stream_Element_Array (1 .. 2)
-- := (Colon, Space);
-- End_Mark : constant Stream_Element_Array (1 .. 2)
-- := (Carriage_Return, Line_Feed);
-- Last : Stream_Element_Offset;
--
-- begin
-- GNAT.Sockets.Send_Socket (Socket, Name, Last);
--
-- if Last /= Name'Last then
-- raise Program_Error;
-- end if;
--
-- GNAT.Sockets.Send_Socket (Socket, Separator, Last);
--
-- if Last /= Separator'Last then
-- raise Program_Error;
-- end if;
--
-- GNAT.Sockets.Send_Socket (Socket, Value, Last);
--
-- if Last /= Value'Last then
-- raise Program_Error;
-- end if;
--
-- GNAT.Sockets.Send_Socket (Socket, End_Mark, Last);
--
-- if Last /= End_Mark'Last then
-- raise Program_Error;
-- end if;
-- end Send_Header;
--
-- begin
-- -- Compute length of all headers.
--
-- Dsc.Reply_Headers.Iterate (Compute_Length'Access);
--
-- -- Compute padding length.
--
-- Padding_Length := 8 - Content_Length mod 8;
--
-- if Padding_Length = 8 then
-- Padding_Length := 0;
-- end if;
--
-- -- Send header.
--
-- Send_Header
-- (Socket, FCGI_Stdout, Dsc.Request_Id, Content_Length, Padding_Length);
--
-- -- Send headers' content.
--
-- Dsc.Reply_Headers.Iterate (Send_Header'Access);
--
-- -- Send end of headers mark and padding elements.
--
-- declare
-- Buffer : constant Stream_Element_Array (1 .. Padding_Length + 2)
-- := (Carriage_Return, Line_Feed, others => 0);
-- Last : Stream_Element_Offset;
--
-- begin
-- GNAT.Sockets.Send_Socket (Socket, Buffer, Last);
--
-- if Last /= Buffer'Last then
-- raise Program_Error;
-- end if;
-- end;
-- end Send_Headers;
--
-- ------------------------
-- -- Send_Output_Stream --
-- ------------------------
--
-- procedure Send_Output_Stream
-- (Packet_Type : Matreshka.FastCGI.Protocol.FCGI_Packet_Type;
-- Data : League.Stream_Element_Vectors.Stream_Element_Vector)
-- is
-- Buffer : constant Stream_Element_Array
-- := Data.To_Stream_Element_Array;
-- Padding :
-- constant Stream_Element_Array (1 .. 8 - (Buffer'Length) mod 8)
-- := (others => 0);
-- Length : Stream_Element_Offset := Padding'Length;
-- Last : Stream_Element_Offset;
--
-- begin
-- if Buffer'Length /= 0 then
-- if Length = 8 then
-- Length := 0;
-- end if;
--
-- Send_Header
-- (Socket, Packet_Type, Dsc.Request_Id, Buffer'Length, Length);
--
-- GNAT.Sockets.Send_Socket (Socket, Buffer, Last);
--
-- if Buffer'Last /= Last then
-- raise Program_Error;
-- end if;
--
-- if Length /= 0 then
-- GNAT.Sockets.Send_Socket (Socket, Padding, Last);
--
-- if Padding'Last /= Last then
-- raise Program_Error;
-- end if;
-- end if;
-- end if;
--
-- -- Send empty output packet to mark end of data.
--
-- Send_Header (Socket, Packet_Type, Dsc.Request_Id, 0, 0);
-- end Send_Output_Stream;
--
-- Request : Standard.FastCGI.Requests.Request
-- := Standard.FastCGI.Requests.Internals.Create (Dsc'Access);
-- Reply : Standard.FastCGI.Replies.Reply
-- := Standard.FastCGI.Replies.Internals.Create (Dsc'Access);
-- Status : Integer;
--
-- begin
-- -- Prepare query parameters.
--
-- Query_Items.Decode_Query_Items (Dsc);
--
-- -- Execute callback.
--
-- Handler (Request, Reply, Status);
--
-- -- Send headers.
--
-- Send_Headers;
--
-- -- Send stdout.
--
-- Send_Output_Stream (FCGI_Stdout, Dsc.Stdout);
--
-- -- Send stderr if any.
--
-- if not Dsc.Stderr.Is_Empty then
-- Send_Output_Stream (FCGI_Stderr, Dsc.Stderr);
-- end if;
--
-- -- Send end request packet.
--
-- Send_End_Request (Socket, Dsc.Request_Id, Status, FCGI_Request_Complete);
--
-- -- Reset descriptor's state.
--
-- Dsc.Request_Id := 0;
-- Dsc.Request_Headers.Clear;
-- Dsc.Query_Items.Clear;
-- Dsc.Reply_Headers.Clear;
-- Dsc.Stdin.Clear;
-- Dsc.Stdout.Clear;
-- Dsc.Stderr.Clear;
-- end Execute_Request;
------------------------
-- FCGI_Listen_Socket --
------------------------
function FCGI_Listen_Socket return GNAT.Sockets.Socket_Type is separate;
---------------------------
-- Process_Begin_Request --
---------------------------
procedure Process_Begin_Request
(Responder_Factory : Standard.FastCGI.Application.Responder_Factory;
Socket : GNAT.Sockets.Socket_Type;
Request_Id : FCGI_Request_Identifier;
Buffer : Stream_Element_Array)
is
Header : FCGI_Begin_Request_Record;
for Header'Address use Buffer'Address;
pragma Import (Ada, Header);
Handler : Matreshka.FastCGI.Descriptors.Descriptor_Access;
begin
-- Allocate corresponding handler.
case Get_Role (Header) is
when FCGI_Responder =>
Handler :=
Standard.FastCGI.Handlers.Responder.To_Descriptor
(Responder_Factory.all);
when FCGI_Authorizer =>
raise Program_Error;
when FCGI_Filter =>
raise Program_Error;
when others =>
raise Program_Error;
end case;
-- if (Request.Flags and FCGI_Keep_Conn) /= 0 then
-- raise Program_Error;
-- end if;
-- Store handler into the set of active requests and dispatch begin
-- request envent.
Requests.Insert (Request_Id, Handler);
Handler.Internal_Begin_Request (Socket, Request_Id);
end Process_Begin_Request;
------------------------
-- Process_Connection --
------------------------
procedure Process_Connection
(Socket : GNAT.Sockets.Socket_Type;
Responder_Factory : Standard.FastCGI.Application.Responder_Factory)
is
Header : FCGI_Header;
Buffer : Raw_FCGI_Header;
for Buffer'Address use Header'Address;
Last : Stream_Element_Offset;
Request_Id : FCGI_Request_Identifier;
Content_Length : Stream_Element_Offset;
Padding_Length : Stream_Element_Offset;
begin
loop
GNAT.Sockets.Receive_Socket (Socket, Buffer, Last);
exit when Last < Buffer'First;
if Last /= Buffer'Last then
raise Program_Error;
end if;
if Get_Version (Header) /= Supported_FCGI_Version then
raise Program_Error;
end if;
Request_Id := Get_Request_Id (Header);
Content_Length := Get_Content_Length (Header);
Padding_Length := Get_Padding_Length (Header);
declare
Buffer :
Stream_Element_Array (1 .. Content_Length + Padding_Length);
begin
-- Receive packet's data when necessary.
if Buffer'Length /= 0 then
GNAT.Sockets.Receive_Socket (Socket, Buffer, Last);
if Last /= Buffer'Last then
raise Program_Error;
end if;
end if;
case Get_Packet_Type (Header) is
when FCGI_Begin_Request =>
Process_Begin_Request
(Responder_Factory,
Socket,
Request_Id,
Buffer (1 .. Content_Length));
when FCGI_Abort_Request =>
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
"");
-- null;
when FCGI_End_Request =>
null;
when FCGI_Params =>
Requests.Element
(Request_Id).Internal_Params (Buffer (1 .. Content_Length));
when FCGI_Stdin =>
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
"FCGI_Stdin");
if Content_Length /= 0 then
Requests.Element
(Request_Id).Internal_Stdin
(Buffer (1 .. Content_Length));
else
null;
end if;
-- Process_Stdin
-- (Socket, Request_Id, Buffer (1 .. Content_Length));
--
-- if Content_Length = 0 then
-- Execute_Request (Socket, Request_Id, Handler);
-- end if;
when FCGI_Stdout =>
null;
when FCGI_Stderr =>
null;
when FCGI_Data =>
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
"FCGI_Data");
-- null;
when FCGI_Get_Values =>
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
"FCGI_Get_Values");
-- null;
when FCGI_Get_Values_Result =>
null;
when FCGI_Unknown_Type =>
null;
when others =>
Ada.Text_IO.Put_Line
(Ada.Text_IO.Standard_Error,
"unknown");
-- null;
end case;
end;
end loop;
GNAT.Sockets.Close_Socket (Socket);
end Process_Connection;
-- ----------------------
-- -- Send_End_Request --
-- ----------------------
--
-- procedure Send_End_Request
-- (Socket : GNAT.Sockets.Socket_Type;
-- Request_Id : FCGI_Request_Identifier;
-- Application_Status : Integer;
-- Protocol_Status : Ada.Streams.Stream_Element)
-- is
-- Buffer : FCGI_End_Request_Body_Stream_Element_Array := (others => 0);
-- Header : FCGI_End_Request_Body;
-- for Header'Address use Buffer'Address;
-- Last : Ada.Streams.Stream_Element_Offset;
--
-- begin
-- Send_Header (Socket, FCGI_End_Request, Request_Id, 8, 0);
--
-- Header.App_Status_Byte_3 :=
-- Stream_Element (Application_Status / 2 ** 24);
-- Header.App_Status_Byte_2 :=
-- Stream_Element (Application_Status / 2 ** 16 mod 2 ** 8);
-- Header.App_Status_Byte_1 :=
-- Stream_Element (Application_Status / 2 ** 8 mod 2 ** 8);
-- Header.App_Status_Byte_0 :=
-- Stream_Element (Application_Status mod 2 ** 8);
-- Header.Protocol_Status := Protocol_Status;
--
-- GNAT.Sockets.Send_Socket (Socket, Buffer, Last);
--
-- if Buffer'Last /= Last then
-- raise Program_Error;
-- end if;
-- end Send_End_Request;
--
-- -----------------
-- -- Send_Header --
-- -----------------
--
-- procedure Send_Header
-- (Socket : GNAT.Sockets.Socket_Type;
-- Packet_Type : Matreshka.FastCGI.Protocol.FCGI_Packet_Type;
-- Request_Id : FCGI_Request_Identifier;
-- Content_Length : Ada.Streams.Stream_Element_Offset;
-- Padding_Length : Ada.Streams.Stream_Element_Offset)
-- is
-- Buffer : Raw_FCGI_Header;
-- Header : FCGI_Header;
-- for Header'Address use Buffer'Address;
-- Last : Ada.Streams.Stream_Element_Offset;
--
-- begin
-- Initialize
-- (Header, Packet_Type, Request_Id, Content_Length, Padding_Length);
--
-- GNAT.Sockets.Send_Socket (Socket, Buffer, Last);
--
-- if Buffer'Last /= Last then
-- raise Program_Error;
-- end if;
-- end Send_Header;
end Matreshka.FastCGI.Streaming_Server;
|
xv6/forktest.asm | ZhangHnu/xv6FileSystem | 0 | 97853 |
_forktest: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
printf(1, "fork test OK\n");
}
int
main(void)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 e4 f0 and $0xfffffff0,%esp
forktest();
6: e8 35 00 00 00 call 40 <forktest>
exit();
b: e8 44 03 00 00 call 354 <exit>
00000010 <printf>:
#define N 1000
void
printf(int fd, const char *s, ...)
{
10: 55 push %ebp
11: 89 e5 mov %esp,%ebp
13: 53 push %ebx
14: 83 ec 14 sub $0x14,%esp
17: 8b 5d 0c mov 0xc(%ebp),%ebx
write(fd, s, strlen(s));
1a: 89 1c 24 mov %ebx,(%esp)
1d: e8 8e 01 00 00 call 1b0 <strlen>
22: 89 5c 24 04 mov %ebx,0x4(%esp)
26: 89 44 24 08 mov %eax,0x8(%esp)
2a: 8b 45 08 mov 0x8(%ebp),%eax
2d: 89 04 24 mov %eax,(%esp)
30: e8 3f 03 00 00 call 374 <write>
}
35: 83 c4 14 add $0x14,%esp
38: 5b pop %ebx
39: 5d pop %ebp
3a: c3 ret
3b: 90 nop
3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000040 <forktest>:
void
forktest(void)
{
40: 55 push %ebp
41: 89 e5 mov %esp,%ebp
43: 53 push %ebx
int n, pid;
printf(1, "fork test\n");
for(n=0; n<N; n++){
44: 31 db xor %ebx,%ebx
write(fd, s, strlen(s));
}
void
forktest(void)
{
46: 83 ec 14 sub $0x14,%esp
int n, pid;
printf(1, "fork test\n");
49: c7 44 24 04 f4 03 00 movl $0x3f4,0x4(%esp)
50: 00
51: c7 04 24 01 00 00 00 movl $0x1,(%esp)
58: e8 b3 ff ff ff call 10 <printf>
5d: eb 13 jmp 72 <forktest+0x32>
5f: 90 nop
for(n=0; n<N; n++){
pid = fork();
if(pid < 0)
break;
if(pid == 0)
60: 0f 84 8f 00 00 00 je f5 <forktest+0xb5>
{
int n, pid;
printf(1, "fork test\n");
for(n=0; n<N; n++){
66: 83 c3 01 add $0x1,%ebx
69: 81 fb e8 03 00 00 cmp $0x3e8,%ebx
6f: 90 nop
70: 74 4e je c0 <forktest+0x80>
pid = fork();
72: e8 d5 02 00 00 call 34c <fork>
if(pid < 0)
77: 83 f8 00 cmp $0x0,%eax
7a: 7d e4 jge 60 <forktest+0x20>
if(n == N){
printf(1, "fork claimed to work N times!\n", N);
exit();
}
for(; n > 0; n--){
7c: 85 db test %ebx,%ebx
7e: 66 90 xchg %ax,%ax
80: 74 15 je 97 <forktest+0x57>
82: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(wait() < 0){
88: e8 cf 02 00 00 call 35c <wait>
8d: 85 c0 test %eax,%eax
8f: 90 nop
90: 78 4f js e1 <forktest+0xa1>
if(n == N){
printf(1, "fork claimed to work N times!\n", N);
exit();
}
for(; n > 0; n--){
92: 83 eb 01 sub $0x1,%ebx
95: 75 f1 jne 88 <forktest+0x48>
printf(1, "wait stopped early\n");
exit();
}
}
if(wait() != -1){
97: e8 c0 02 00 00 call 35c <wait>
9c: 83 f8 ff cmp $0xffffffff,%eax
9f: 90 nop
a0: 75 58 jne fa <forktest+0xba>
printf(1, "wait got too many\n");
exit();
}
printf(1, "fork test OK\n");
a2: c7 44 24 04 26 04 00 movl $0x426,0x4(%esp)
a9: 00
aa: c7 04 24 01 00 00 00 movl $0x1,(%esp)
b1: e8 5a ff ff ff call 10 <printf>
}
b6: 83 c4 14 add $0x14,%esp
b9: 5b pop %ebx
ba: 5d pop %ebp
bb: c3 ret
bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(pid == 0)
exit();
}
if(n == N){
printf(1, "fork claimed to work N times!\n", N);
c0: c7 44 24 08 e8 03 00 movl $0x3e8,0x8(%esp)
c7: 00
c8: c7 44 24 04 34 04 00 movl $0x434,0x4(%esp)
cf: 00
d0: c7 04 24 01 00 00 00 movl $0x1,(%esp)
d7: e8 34 ff ff ff call 10 <printf>
exit();
dc: e8 73 02 00 00 call 354 <exit>
}
for(; n > 0; n--){
if(wait() < 0){
printf(1, "wait stopped early\n");
e1: c7 44 24 04 ff 03 00 movl $0x3ff,0x4(%esp)
e8: 00
e9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
f0: e8 1b ff ff ff call 10 <printf>
exit();
f5: e8 5a 02 00 00 call 354 <exit>
}
}
if(wait() != -1){
printf(1, "wait got too many\n");
fa: c7 44 24 04 13 04 00 movl $0x413,0x4(%esp)
101: 00
102: c7 04 24 01 00 00 00 movl $0x1,(%esp)
109: e8 02 ff ff ff call 10 <printf>
exit();
10e: e8 41 02 00 00 call 354 <exit>
113: 90 nop
114: 90 nop
115: 90 nop
116: 90 nop
117: 90 nop
118: 90 nop
119: 90 nop
11a: 90 nop
11b: 90 nop
11c: 90 nop
11d: 90 nop
11e: 90 nop
11f: 90 nop
00000120 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
120: 55 push %ebp
char *os;
os = s;
while((*s++ = *t++) != 0)
121: 31 d2 xor %edx,%edx
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
123: 89 e5 mov %esp,%ebp
125: 8b 45 08 mov 0x8(%ebp),%eax
128: 53 push %ebx
129: 8b 5d 0c mov 0xc(%ebp),%ebx
12c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
char *os;
os = s;
while((*s++ = *t++) != 0)
130: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx
134: 88 0c 10 mov %cl,(%eax,%edx,1)
137: 83 c2 01 add $0x1,%edx
13a: 84 c9 test %cl,%cl
13c: 75 f2 jne 130 <strcpy+0x10>
;
return os;
}
13e: 5b pop %ebx
13f: 5d pop %ebp
140: c3 ret
141: eb 0d jmp 150 <strcmp>
143: 90 nop
144: 90 nop
145: 90 nop
146: 90 nop
147: 90 nop
148: 90 nop
149: 90 nop
14a: 90 nop
14b: 90 nop
14c: 90 nop
14d: 90 nop
14e: 90 nop
14f: 90 nop
00000150 <strcmp>:
int
strcmp(const char *p, const char *q)
{
150: 55 push %ebp
151: 89 e5 mov %esp,%ebp
153: 8b 4d 08 mov 0x8(%ebp),%ecx
156: 56 push %esi
157: 8b 55 0c mov 0xc(%ebp),%edx
15a: 53 push %ebx
while(*p && *p == *q)
15b: 0f b6 01 movzbl (%ecx),%eax
15e: 0f b6 1a movzbl (%edx),%ebx
161: 84 c0 test %al,%al
163: 74 23 je 188 <strcmp+0x38>
165: 38 d8 cmp %bl,%al
167: 74 10 je 179 <strcmp+0x29>
169: eb 2d jmp 198 <strcmp+0x48>
16b: 90 nop
16c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
170: 83 c1 01 add $0x1,%ecx
173: 38 d8 cmp %bl,%al
175: 75 21 jne 198 <strcmp+0x48>
p++, q++;
177: 89 f2 mov %esi,%edx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
179: 0f b6 41 01 movzbl 0x1(%ecx),%eax
p++, q++;
17d: 8d 72 01 lea 0x1(%edx),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
180: 0f b6 5a 01 movzbl 0x1(%edx),%ebx
184: 84 c0 test %al,%al
186: 75 e8 jne 170 <strcmp+0x20>
p++, q++;
return (uchar)*p - (uchar)*q;
188: 0f b6 db movzbl %bl,%ebx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
18b: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
18d: 29 d8 sub %ebx,%eax
}
18f: 5b pop %ebx
190: 5e pop %esi
191: 5d pop %ebp
192: c3 ret
193: 90 nop
194: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
p++, q++;
return (uchar)*p - (uchar)*q;
198: 0f b6 db movzbl %bl,%ebx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
19b: 0f b6 c0 movzbl %al,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
19e: 29 d8 sub %ebx,%eax
}
1a0: 5b pop %ebx
1a1: 5e pop %esi
1a2: 5d pop %ebp
1a3: c3 ret
1a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000001b0 <strlen>:
uint
strlen(const char *s)
{
1b0: 55 push %ebp
int n;
for(n = 0; s[n]; n++)
1b1: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
}
uint
strlen(const char *s)
{
1b3: 89 e5 mov %esp,%ebp
1b5: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
1b8: 80 39 00 cmpb $0x0,(%ecx)
1bb: 74 0e je 1cb <strlen+0x1b>
1bd: 31 d2 xor %edx,%edx
1bf: 90 nop
1c0: 83 c2 01 add $0x1,%edx
1c3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
1c7: 89 d0 mov %edx,%eax
1c9: 75 f5 jne 1c0 <strlen+0x10>
;
return n;
}
1cb: 5d pop %ebp
1cc: c3 ret
1cd: 8d 76 00 lea 0x0(%esi),%esi
000001d0 <memset>:
void*
memset(void *dst, int c, uint n)
{
1d0: 55 push %ebp
1d1: 89 e5 mov %esp,%ebp
1d3: 8b 55 08 mov 0x8(%ebp),%edx
1d6: 57 push %edi
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
1d7: 8b 4d 10 mov 0x10(%ebp),%ecx
1da: 8b 45 0c mov 0xc(%ebp),%eax
1dd: 89 d7 mov %edx,%edi
1df: fc cld
1e0: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
1e2: 89 d0 mov %edx,%eax
1e4: 5f pop %edi
1e5: 5d pop %ebp
1e6: c3 ret
1e7: 89 f6 mov %esi,%esi
1e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001f0 <strchr>:
char*
strchr(const char *s, char c)
{
1f0: 55 push %ebp
1f1: 89 e5 mov %esp,%ebp
1f3: 8b 45 08 mov 0x8(%ebp),%eax
1f6: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for(; *s; s++)
1fa: 0f b6 10 movzbl (%eax),%edx
1fd: 84 d2 test %dl,%dl
1ff: 75 12 jne 213 <strchr+0x23>
201: eb 1d jmp 220 <strchr+0x30>
203: 90 nop
204: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
208: 0f b6 50 01 movzbl 0x1(%eax),%edx
20c: 84 d2 test %dl,%dl
20e: 74 10 je 220 <strchr+0x30>
210: 83 c0 01 add $0x1,%eax
if(*s == c)
213: 38 ca cmp %cl,%dl
215: 75 f1 jne 208 <strchr+0x18>
return (char*)s;
return 0;
}
217: 5d pop %ebp
218: c3 ret
219: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
strchr(const char *s, char c)
{
for(; *s; s++)
if(*s == c)
return (char*)s;
return 0;
220: 31 c0 xor %eax,%eax
}
222: 5d pop %ebp
223: c3 ret
224: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
22a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000230 <gets>:
char*
gets(char *buf, int max)
{
230: 55 push %ebp
231: 89 e5 mov %esp,%ebp
233: 57 push %edi
234: 56 push %esi
int i, cc;
char c;
for(i=0; i+1 < max; ){
235: 31 f6 xor %esi,%esi
return 0;
}
char*
gets(char *buf, int max)
{
237: 53 push %ebx
238: 83 ec 2c sub $0x2c,%esp
23b: 8b 7d 08 mov 0x8(%ebp),%edi
int i, cc;
char c;
for(i=0; i+1 < max; ){
23e: eb 31 jmp 271 <gets+0x41>
cc = read(0, &c, 1);
240: 8d 45 e7 lea -0x19(%ebp),%eax
243: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
24a: 00
24b: 89 44 24 04 mov %eax,0x4(%esp)
24f: c7 04 24 00 00 00 00 movl $0x0,(%esp)
256: e8 11 01 00 00 call 36c <read>
if(cc < 1)
25b: 85 c0 test %eax,%eax
25d: 7e 1a jle 279 <gets+0x49>
break;
buf[i++] = c;
25f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
263: 89 de mov %ebx,%esi
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
265: 3c 0d cmp $0xd,%al
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
267: 88 44 1f ff mov %al,-0x1(%edi,%ebx,1)
if(c == '\n' || c == '\r')
26b: 74 0c je 279 <gets+0x49>
26d: 3c 0a cmp $0xa,%al
26f: 74 08 je 279 <gets+0x49>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
271: 8d 5e 01 lea 0x1(%esi),%ebx
274: 3b 5d 0c cmp 0xc(%ebp),%ebx
277: 7c c7 jl 240 <gets+0x10>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
279: c6 04 37 00 movb $0x0,(%edi,%esi,1)
return buf;
}
27d: 83 c4 2c add $0x2c,%esp
280: 89 f8 mov %edi,%eax
282: 5b pop %ebx
283: 5e pop %esi
284: 5f pop %edi
285: 5d pop %ebp
286: c3 ret
287: 89 f6 mov %esi,%esi
289: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000290 <stat>:
int
stat(const char *n, struct stat *st)
{
290: 55 push %ebp
291: 89 e5 mov %esp,%ebp
293: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
296: 8b 45 08 mov 0x8(%ebp),%eax
return buf;
}
int
stat(const char *n, struct stat *st)
{
299: 89 5d f8 mov %ebx,-0x8(%ebp)
29c: 89 75 fc mov %esi,-0x4(%ebp)
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
29f: be ff ff ff ff mov $0xffffffff,%esi
stat(const char *n, struct stat *st)
{
int fd;
int r;
fd = open(n, O_RDONLY);
2a4: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2ab: 00
2ac: 89 04 24 mov %eax,(%esp)
2af: e8 e0 00 00 00 call 394 <open>
if(fd < 0)
2b4: 85 c0 test %eax,%eax
stat(const char *n, struct stat *st)
{
int fd;
int r;
fd = open(n, O_RDONLY);
2b6: 89 c3 mov %eax,%ebx
if(fd < 0)
2b8: 78 19 js 2d3 <stat+0x43>
return -1;
r = fstat(fd, st);
2ba: 8b 45 0c mov 0xc(%ebp),%eax
2bd: 89 1c 24 mov %ebx,(%esp)
2c0: 89 44 24 04 mov %eax,0x4(%esp)
2c4: e8 e3 00 00 00 call 3ac <fstat>
close(fd);
2c9: 89 1c 24 mov %ebx,(%esp)
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
r = fstat(fd, st);
2cc: 89 c6 mov %eax,%esi
close(fd);
2ce: e8 a9 00 00 00 call 37c <close>
return r;
}
2d3: 89 f0 mov %esi,%eax
2d5: 8b 5d f8 mov -0x8(%ebp),%ebx
2d8: 8b 75 fc mov -0x4(%ebp),%esi
2db: 89 ec mov %ebp,%esp
2dd: 5d pop %ebp
2de: c3 ret
2df: 90 nop
000002e0 <atoi>:
int
atoi(const char *s)
{
2e0: 55 push %ebp
int n;
n = 0;
2e1: 31 c0 xor %eax,%eax
return r;
}
int
atoi(const char *s)
{
2e3: 89 e5 mov %esp,%ebp
2e5: 8b 4d 08 mov 0x8(%ebp),%ecx
2e8: 53 push %ebx
int n;
n = 0;
while('0' <= *s && *s <= '9')
2e9: 0f b6 11 movzbl (%ecx),%edx
2ec: 8d 5a d0 lea -0x30(%edx),%ebx
2ef: 80 fb 09 cmp $0x9,%bl
2f2: 77 1c ja 310 <atoi+0x30>
2f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
n = n*10 + *s++ - '0';
2f8: 0f be d2 movsbl %dl,%edx
2fb: 83 c1 01 add $0x1,%ecx
2fe: 8d 04 80 lea (%eax,%eax,4),%eax
301: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
305: 0f b6 11 movzbl (%ecx),%edx
308: 8d 5a d0 lea -0x30(%edx),%ebx
30b: 80 fb 09 cmp $0x9,%bl
30e: 76 e8 jbe 2f8 <atoi+0x18>
n = n*10 + *s++ - '0';
return n;
}
310: 5b pop %ebx
311: 5d pop %ebp
312: c3 ret
313: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
319: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000320 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
320: 55 push %ebp
321: 89 e5 mov %esp,%ebp
323: 56 push %esi
324: 8b 45 08 mov 0x8(%ebp),%eax
327: 53 push %ebx
328: 8b 5d 10 mov 0x10(%ebp),%ebx
32b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
32e: 85 db test %ebx,%ebx
330: 7e 14 jle 346 <memmove+0x26>
n = n*10 + *s++ - '0';
return n;
}
void*
memmove(void *vdst, const void *vsrc, int n)
332: 31 d2 xor %edx,%edx
334: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
*dst++ = *src++;
338: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
33c: 88 0c 10 mov %cl,(%eax,%edx,1)
33f: 83 c2 01 add $0x1,%edx
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
342: 39 da cmp %ebx,%edx
344: 75 f2 jne 338 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
346: 5b pop %ebx
347: 5e pop %esi
348: 5d pop %ebp
349: c3 ret
34a: 90 nop
34b: 90 nop
0000034c <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
34c: b8 01 00 00 00 mov $0x1,%eax
351: cd 40 int $0x40
353: c3 ret
00000354 <exit>:
SYSCALL(exit)
354: b8 02 00 00 00 mov $0x2,%eax
359: cd 40 int $0x40
35b: c3 ret
0000035c <wait>:
SYSCALL(wait)
35c: b8 03 00 00 00 mov $0x3,%eax
361: cd 40 int $0x40
363: c3 ret
00000364 <pipe>:
SYSCALL(pipe)
364: b8 04 00 00 00 mov $0x4,%eax
369: cd 40 int $0x40
36b: c3 ret
0000036c <read>:
SYSCALL(read)
36c: b8 05 00 00 00 mov $0x5,%eax
371: cd 40 int $0x40
373: c3 ret
00000374 <write>:
SYSCALL(write)
374: b8 10 00 00 00 mov $0x10,%eax
379: cd 40 int $0x40
37b: c3 ret
0000037c <close>:
SYSCALL(close)
37c: b8 15 00 00 00 mov $0x15,%eax
381: cd 40 int $0x40
383: c3 ret
00000384 <kill>:
SYSCALL(kill)
384: b8 06 00 00 00 mov $0x6,%eax
389: cd 40 int $0x40
38b: c3 ret
0000038c <exec>:
SYSCALL(exec)
38c: b8 07 00 00 00 mov $0x7,%eax
391: cd 40 int $0x40
393: c3 ret
00000394 <open>:
SYSCALL(open)
394: b8 0f 00 00 00 mov $0xf,%eax
399: cd 40 int $0x40
39b: c3 ret
0000039c <mknod>:
SYSCALL(mknod)
39c: b8 11 00 00 00 mov $0x11,%eax
3a1: cd 40 int $0x40
3a3: c3 ret
000003a4 <unlink>:
SYSCALL(unlink)
3a4: b8 12 00 00 00 mov $0x12,%eax
3a9: cd 40 int $0x40
3ab: c3 ret
000003ac <fstat>:
SYSCALL(fstat)
3ac: b8 08 00 00 00 mov $0x8,%eax
3b1: cd 40 int $0x40
3b3: c3 ret
000003b4 <link>:
SYSCALL(link)
3b4: b8 13 00 00 00 mov $0x13,%eax
3b9: cd 40 int $0x40
3bb: c3 ret
000003bc <mkdir>:
SYSCALL(mkdir)
3bc: b8 14 00 00 00 mov $0x14,%eax
3c1: cd 40 int $0x40
3c3: c3 ret
000003c4 <chdir>:
SYSCALL(chdir)
3c4: b8 09 00 00 00 mov $0x9,%eax
3c9: cd 40 int $0x40
3cb: c3 ret
000003cc <dup>:
SYSCALL(dup)
3cc: b8 0a 00 00 00 mov $0xa,%eax
3d1: cd 40 int $0x40
3d3: c3 ret
000003d4 <getpid>:
SYSCALL(getpid)
3d4: b8 0b 00 00 00 mov $0xb,%eax
3d9: cd 40 int $0x40
3db: c3 ret
000003dc <sbrk>:
SYSCALL(sbrk)
3dc: b8 0c 00 00 00 mov $0xc,%eax
3e1: cd 40 int $0x40
3e3: c3 ret
000003e4 <sleep>:
SYSCALL(sleep)
3e4: b8 0d 00 00 00 mov $0xd,%eax
3e9: cd 40 int $0x40
3eb: c3 ret
000003ec <uptime>:
SYSCALL(uptime)
3ec: b8 0e 00 00 00 mov $0xe,%eax
3f1: cd 40 int $0x40
3f3: c3 ret
|
Tests/yasm-regression/push64.asm | 13xforever/x86-assembly-textmate-bundle | 69 | 168861 | [bits 64]
push dword 50 ; out: 6a 32
push dword -1 ; out: 6a ff
push strict dword 50 ; out: 68 32 00 00 00
push strict dword -1 ; out: 68 ff ff ff ff
push dword 1000000000000 ; out: 68 00 10 a5 d4
|
oeis/142/A142633.asm | neoneye/loda-programs | 11 | 247101 | <reponame>neoneye/loda-programs<filename>oeis/142/A142633.asm
; A142633: Primes congruent to 46 mod 55.
; Submitted by <NAME>
; 101,211,431,541,761,1091,1201,1531,1861,2081,2411,2521,2741,2851,3181,3511,4391,4721,4831,5051,5381,5711,5821,6151,6481,6701,7691,8461,8681,9011,9341,9781,10111,10331,10771,11321,11981,12421,12641,13411,14071,14401,14621,14731,14951,15061,15391,16381,16931,17041,17921,18251,18691,18911,19571,19681,20011,20231,20341,21001,21221,21661,21881,21991,22541,22651,22871,23201,23311,23531,23971,24631,24851,25621,25841,25951,26171,26501,27271,28151,28591,28921,29251,29581,30241,31121,31231,31891,32441
mov $1,50
mov $2,$0
add $2,2
pow $2,2
lpb $2
sub $2,1
mov $3,$1
mul $3,2
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,55
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
mov $0,$1
mul $0,2
sub $0,109
|
Library/Spool/Process/processDualThread.asm | steakknife/pcgeos | 504 | 82374 | <filename>Library/Spool/Process/processDualThread.asm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Geoworks 1995 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Process
FILE: processDualThread.asm
AUTHOR: <NAME>, Apr 13, 1995
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Joon 4/13/95 Initial revision
DESCRIPTION:
$Id: processDualThread.asm,v 1.1 97/04/07 11:11:09 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrintGraphics segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintSwathNoBlocking
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Print a page-wide bitmap on another thread
CALLED BY: GLOBAL
PASS: bx - PState handle
dx.cx - VM file and block handle for Huge bitmap
RETURN: carry - set if some error
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Joon 4/ 6/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if _DUAL_THREADED_PRINTING ;----------------------------------------------
PrintSwathNoBlocking proc far
curJob local SpoolJobInfo
uses ax,cx,si,di,ds,es
.enter inherit
; Can we print using print thread?
call LockQueue
mov ds, ax
mov si, curJob.SJI_qHan ; get chunk handle of queue
mov si, ds:[si] ; ds:si <- QueueInfo
mov si, ds:[si].QI_printThreadInfo
call UnlockQueue
tst si ; si <- PrintThreadInfo block handle
jnz otherThread
; Print it ourself
mov di, DR_PRINT_SWATH
call curJob.SJI_pDriver
jmp done
otherThread:
; Wait for previous swath to finish
xchg bx, si ; bx <- PrintThreadInfo, si <- PState
call MemDerefDS
mov bx, ds:[PTI_printSem]
call ThreadPSem
mov bx, ds:[PTI_dataSem]
call ThreadPSem
clr ax
xchg ah, ds:[PTI_errorFlags]
sahf
jnc noError
call ThreadVSem
mov bx, ds:[PTI_printSem]
call ThreadVSem
jmp done ; carry set
noError:
; Now print using print thread
mov ds:[PTI_pstate], si
movdw ds:[PTI_bitmap], dxcx
movdw ds:[PTI_driverEntry], curJob.SJI_pDriver, ax
call ThreadVSem ; PTI_dataSem
done:
.leave
ret
PrintSwathNoBlocking endp
endif ; _DUAL_THREADED_PRINTING ---------------------------------------------
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintThreadPrintSwaths
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Print swaths
CALLED BY: AllocDeviceQueue via ThreadCreate
PASS: ds = es = owning geode's dgroup
cx = PrintThreadInfo block handle
ax, bx = undefined
dx, bp = 0
si = owning geode handle
di = LCT_NEW_CLIENT_THREAD
RETURN: nothing
DESTROYED: everything
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Joon 4/ 6/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if _DUAL_THREADED_PRINTING ;----------------------------------------------
PrintThreadPrintSwaths proc far
; Print swaths until we're done printing.
mov bx, cx ; bx <- PrintThreadInfo block handle
call MemDerefDS
push bx ; save PrintThreadInfo block handle
swathLoop:
cmp ds:[PTI_status], PTIS_EXIT
je exit
; Do we have a swath ready to print?
mov bx, ds:[PTI_dataSem]
call ThreadPSem
clrdw dxcx
xchgdw dxcx, ds:[PTI_bitmap]
mov bp, ds:[PTI_pstate]
call ThreadVSem
tstdw dxcx
jnz printSwath
mov ax, 15 ; sleep for 0.25 seconds
call TimerSleep
jmp swathLoop
printSwath:
; Got swath. Print it.
mov di, DR_PRINT_SWATH
mov bx, bp
call ds:[PTI_driverEntry]
lahf
mov ds:[PTI_errorFlags], ah
mov bx, ds:[PTI_printSem]
call ThreadVSem
jmp swathLoop
exit:
mov bx, ds:[PTI_dataSem]
call ThreadFreeSem
mov bx, ds:[PTI_printSem]
call ThreadFreeSem
pop bx ; restore PrintThreadInfo block handle
call MemFree
clr cx, dx, bp, si ; setup arguments for ThreadDestroy
ret
PrintThreadPrintSwaths endp
endif ; _DUAL_THREADED_PRINTING ---------------------------------------------
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrintBlockOnPrintThread
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Block until print thread is finished printing
CALLED BY: PrintGraphicsPage
PASS: inherit stack frame
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Joon 7/27/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if _DUAL_THREADED_PRINTING ;----------------------------------------------
PrintBlockOnPrintThread proc near
curJob local SpoolJobInfo
uses ax,bx,ds
.enter inherit
call LockQueue
mov ds, ax
mov bx, curJob.SJI_qHan ; get chunk handle of queue
mov bx, ds:[bx] ; ds:bx <- QueueInfo
mov bx, ds:[bx].QI_printThreadInfo
call UnlockQueue
tst bx ; bx <- PrintThreadInfo block handle
jz done
; Wait for print thread to finish
call MemDerefDS
mov bx, ds:[PTI_printSem]
call ThreadPSem
call ThreadVSem
done:
.leave
ret
PrintBlockOnPrintThread endp
endif ; _DUAL_THREADED_PRINTING ---------------------------------------------
PrintGraphics ends
|
programs/oeis/152/A152733.asm | neoneye/loda | 22 | 165651 | <reponame>neoneye/loda<gh_stars>10-100
; A152733: a(n) + a(n+1) + a(n+2) = 3^n.
; 0,0,3,6,18,57,168,504,1515,4542,13626,40881,122640,367920,1103763,3311286,9933858,29801577,89404728,268214184,804642555,2413927662,7241782986,21725348961,65176046880,195528140640,586584421923,1759753265766,5279259797298,15837779391897,47513338175688,142540014527064,427620043581195,1282860130743582,3848580392230746,11545741176692241,34637223530076720,103911670590230160,311735011770690483,935205035312071446,2805615105936214338,8416845317808643017,25250535953425929048,75751607860277787144,227254823580833361435,681764470742500084302,2045293412227500252906,6135880236682500758721,18407640710047502276160,55222922130142506828480,165668766390427520485443,497006299171282561456326,1491018897513847684368978,4473056692541543053106937,13419170077624629159320808,40257510232873887477962424,120772530698621662433887275,362317592095864987301661822,1086952776287594961904985466,3260858328862784885714956401,9782574986588354657144869200,29347724959765063971434607600,88043174879295191914303822803,264129524637885575742911468406,792388573913656727228734405218,2377165721740970181686203215657,7131497165222910545058609646968,21394491495668731635175828940904,64183474487006194905527486822715,192550423461018584716582460468142,577651270383055754149747381404426,1732953811149167262449242144213281,5198861433447501787347726432639840,15596584300342505362043179297919520,46789752901027516086129537893758563,140369258703082548258388613681275686,421107776109247644775165841043827058
seq $0,77842 ; Expansion of (1-x)/(1-2*x-2*x^2-3*x^3).
div $0,3
add $0,1
div $0,2
mul $0,3
|
sk/sfx/60.asm | Cancer52/flamedriver | 9 | 80490 | Sound_60_Header:
smpsHeaderStartSong 3
smpsHeaderVoice Sound_60_Voices
smpsHeaderTempoSFX $01
smpsHeaderChanSFX $01
smpsHeaderSFXChannel cFM5, Sound_60_FM5, $E7, $00
; FM5 Data
Sound_60_FM5:
smpsSetvoice $00
Sound_60_Loop00:
dc.b nC6, $01
smpsAlterPitch $FF
smpsFMAlterVol $01
smpsLoop $00, $06, Sound_60_Loop00
smpsModSet $01, $01, $03, $00
dc.b nC6, $50
Sound_60_Loop01:
dc.b smpsNoAttack, $04
smpsFMAlterVol $01
smpsLoop $00, $08, Sound_60_Loop01
smpsStop
Sound_60_Voices:
; Voice $00
; $3A
; $41, $12, $62, $52, $5F, $1F, $1F, $8C, $08, $05, $04, $1E
; $03, $04, $02, $06, $2F, $2F, $1F, $0F, $29, $27, $1F, $80
smpsVcAlgorithm $02
smpsVcFeedback $07
smpsVcUnusedBits $00
smpsVcDetune $05, $06, $01, $04
smpsVcCoarseFreq $02, $02, $02, $01
smpsVcRateScale $02, $00, $00, $01
smpsVcAttackRate $0C, $1F, $1F, $1F
smpsVcAmpMod $00, $00, $00, $00
smpsVcDecayRate1 $1E, $04, $05, $08
smpsVcDecayRate2 $06, $02, $04, $03
smpsVcDecayLevel $00, $01, $02, $02
smpsVcReleaseRate $0F, $0F, $0F, $0F
smpsVcTotalLevel $00, $1F, $27, $29
|
krenel_booter.asm | somerandomdev49/Simple_ISA | 1 | 178637 | #!/usr/bin/sisa16_asm -run
//..include"libc.hasm"
..include"libc_pre.hasm"
..(2):
..dinclude"libc_pre.bin"
..(0x25):
my_page_o_crap:
fill 256, '7'
..(7):
:STR_my_string:
..ascii:Enter some text:
bytes '\r' ,'\n', 0;
bytes 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
bytes 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
:STR_my_other_string:
..ascii:Krenel shut down...
bytes '\r' ,'\n', 0;
:STR_yet_other_string:
..ascii:End of Program.
bytes '\r' ,'\n', 0;
..main(3): //three actually goes unused by krenel, so it is safe to put code there. Dont use 1, or just ..main
lrx0 %/krenel_boot%;
proc_krenel;
halt;
..(55):
side_process_looptop:
la 'V';
putchar;
la '\n'; syscall;
// lla %0xDE02%; syscall; //sleep!
la 100; alpush; proc_wait; alpop;
farllda %&0xAABBCC%;
nota;
sc %side_process_looptop%; jmpifeq; //continue looping while zero.
//Shutdown.
//lla %0xDEAD%; syscall;
//write to disk! See if it makes it through at all.
llb %0x2500%;
lla %0xDE01%; //Disk write.
lrx0 %/0x3001%;
syscall;
lrx0 %/0x3001%;
llb %0x2600%;
lla %0xDE03%; //Disk read.
syscall;
la '\r'; putchar;
la '\n'; putchar;
la 'q'; putchar;
la 'u'; putchar;
la 'i'; putchar;
la 't'; putchar;
la '\r'; putchar;
la '\n'; putchar; interrupt;
lrx0 %/0x260000%;
proc_prints;
la '\n'; interrupt;
//Fork bomb. Uncomment at your own risk.
sc %0%;
lb 0;la 2; farista;
lb 1;
la 1; //if this process was created with exec.
//la 55; //if this process was created with fork.
farista;
lb 2; la 0x44; farista;
lla %0xDE06%;
syscall;
cpc;
jmp;
lb 0; mod;
halt;
..(8):
krenel_boot:
push %10%; //make some room for that bootloader!
// //<TODO: needs update> Overwrite the krenel. There is no way it would work if this was being done to krenel memory.
// lrx0 %/0x20000%;
// lrx1 %/0x20480%;
// overwrite_krenel_looptop:
// cbrx0;
// la 0;
// farista;
// rxincr;
// rxcmp;
// sc %overwrite_krenel_looptop%; jmpifneq;
//exec region syscall.
lla %0xDE04%; lb 55; syscall;
//Instead, fork it!
//bootloader written here
//This is written at 0: la 55, lfarpc
//sc %0%;
//lb 0;la 2; farista;
//lb 1; la 55; farista;
//lb 2; la 0x44; farista;
//lla %0xDE06%;
//syscall;
nota; sc %main_program_failure%; jmpifeq;
lrx0 0, %&STR_my_string%;
proc_prints;
la '\n'; syscall;
nota; sc %main_program_failure%; jmpifeq;
//Commit sudoku- kill ourselves.
//lla %0xDE00%;lb 0;syscall;
lrx0 0, %&STR_my_string%;
proc_gets;
la '\r'; putchar;
la '\n'; putchar;
la '\n'; syscall;
lrx0 0, %&STR_my_string%;
proc_prints;
la '\r'; putchar;
la '\n'; putchar;
la '\n'; syscall;
//lla %0xDE00%;lb 1;syscall; //Kill the other guy.
//Send him a message instead.
lla %0xDE05%;
lb 1;
sc %1%;
lrx0 %/0xAABBCC%;
syscall;
lrx0 0, %&STR_my_string%;
proc_gets
la '\r'; putchar;
la '\n'; putchar;
la '\n'; syscall;
lrx0 0, %&STR_my_string%;
proc_prints;
la '\r'; putchar;
la '\n'; putchar;
la '\n'; syscall;
lrx0 0, %&STR_yet_other_string%;
proc_prints;
//lla %0xDEAD%; syscall;
lla %0xDE00%;lb 1;syscall; //Kill the other guy.
lla %0xDE00%;lb 2;syscall; //Kill the other guy.
lla %0xDE00%;lb 3;syscall; //Kill the other guy.
lla %0xDE00%;lb 4;syscall; //Kill the other guy.
lla %0xDE00%;lb 5;syscall; //Kill the other guy.
lla %0xDE00%;lb 6;syscall; //Kill the other guy.
lla %0xDE00%;lb 7;syscall; //Kill the other guy.
lla %0xDE00%;lb 8;syscall; //Kill ourselves. 8 wraps around to 0.
lb 0; rx1b; fltdiv
main_program_failure:
halt;
|
source/nodes/program-nodes-procedure_declarations.ads | optikos/oasis | 0 | 18379 | <filename>source/nodes/program-nodes-procedure_declarations.ads
-- Copyright (c) 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Defining_Names;
with Program.Elements.Parameter_Specifications;
with Program.Elements.Aspect_Specifications;
with Program.Elements.Procedure_Declarations;
with Program.Element_Visitors;
package Program.Nodes.Procedure_Declarations is
pragma Preelaborate;
type Procedure_Declaration is
new Program.Nodes.Node
and Program.Elements.Procedure_Declarations.Procedure_Declaration
and Program.Elements.Procedure_Declarations.Procedure_Declaration_Text
with private;
function Create
(Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Overriding_Token : Program.Lexical_Elements.Lexical_Element_Access;
Procedure_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Name : not null Program.Elements.Defining_Names
.Defining_Name_Access;
Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
Parameters : Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access;
Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
Is_Token : Program.Lexical_Elements.Lexical_Element_Access;
Abstract_Token : Program.Lexical_Elements.Lexical_Element_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Procedure_Declaration;
type Implicit_Procedure_Declaration is
new Program.Nodes.Node
and Program.Elements.Procedure_Declarations.Procedure_Declaration
with private;
function Create
(Name : not null Program.Elements.Defining_Names
.Defining_Name_Access;
Parameters : Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Not : Boolean := False;
Has_Overriding : Boolean := False;
Has_Abstract : Boolean := False)
return Implicit_Procedure_Declaration
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Procedure_Declaration is
abstract new Program.Nodes.Node
and Program.Elements.Procedure_Declarations.Procedure_Declaration
with record
Name : not null Program.Elements.Defining_Names
.Defining_Name_Access;
Parameters : Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Procedure_Declaration'Class);
overriding procedure Visit
(Self : not null access Base_Procedure_Declaration;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Name
(Self : Base_Procedure_Declaration)
return not null Program.Elements.Defining_Names.Defining_Name_Access;
overriding function Parameters
(Self : Base_Procedure_Declaration)
return Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access;
overriding function Aspects
(Self : Base_Procedure_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
overriding function Is_Procedure_Declaration_Element
(Self : Base_Procedure_Declaration)
return Boolean;
overriding function Is_Declaration_Element
(Self : Base_Procedure_Declaration)
return Boolean;
type Procedure_Declaration is
new Base_Procedure_Declaration
and Program.Elements.Procedure_Declarations.Procedure_Declaration_Text
with record
Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Overriding_Token : Program.Lexical_Elements.Lexical_Element_Access;
Procedure_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
Is_Token : Program.Lexical_Elements.Lexical_Element_Access;
Abstract_Token : Program.Lexical_Elements.Lexical_Element_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Procedure_Declaration_Text
(Self : aliased in out Procedure_Declaration)
return Program.Elements.Procedure_Declarations
.Procedure_Declaration_Text_Access;
overriding function Not_Token
(Self : Procedure_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Overriding_Token
(Self : Procedure_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Procedure_Token
(Self : Procedure_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Left_Bracket_Token
(Self : Procedure_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Right_Bracket_Token
(Self : Procedure_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Is_Token
(Self : Procedure_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Abstract_Token
(Self : Procedure_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function With_Token
(Self : Procedure_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Semicolon_Token
(Self : Procedure_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Not (Self : Procedure_Declaration) return Boolean;
overriding function Has_Overriding
(Self : Procedure_Declaration)
return Boolean;
overriding function Has_Abstract
(Self : Procedure_Declaration)
return Boolean;
type Implicit_Procedure_Declaration is
new Base_Procedure_Declaration
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Not : Boolean;
Has_Overriding : Boolean;
Has_Abstract : Boolean;
end record;
overriding function To_Procedure_Declaration_Text
(Self : aliased in out Implicit_Procedure_Declaration)
return Program.Elements.Procedure_Declarations
.Procedure_Declaration_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Procedure_Declaration)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Procedure_Declaration)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Procedure_Declaration)
return Boolean;
overriding function Has_Not
(Self : Implicit_Procedure_Declaration)
return Boolean;
overriding function Has_Overriding
(Self : Implicit_Procedure_Declaration)
return Boolean;
overriding function Has_Abstract
(Self : Implicit_Procedure_Declaration)
return Boolean;
end Program.Nodes.Procedure_Declarations;
|
Task/GUI-Maximum-window-dimensions/Ada/gui-maximum-window-dimensions.ada | LaudateCorpus1/RosettaCodeData | 1 | 20522 | with Gtk.Main;
with Glib;
with Gtk.Window; use Gtk.Window;
with Gtk.Enums; use Gtk.Enums;
with Ada.Text_IO; use Ada.Text_IO;
procedure Max_Size is
Win : Gtk_Window;
Win_W, Win_H : Glib.Gint;
package Int_Io is new Integer_IO (Glib.Gint);
Hid : Gtk.Main.Quit_Handler_Id;
begin
Gtk.Main.Init;
Gtk_New (Win);
Initialize (Win, Window_Toplevel);
Maximize (Win);
Show (Win);
Get_Size (Win, Win_W, Win_H);
Put ("Maximum dimensions of window : W ");
Int_Io.Put (Win_W, Width => 4);
Put (" x H ");
Int_Io.Put (Win_H, Width => 4);
New_Line;
Hid := Gtk.Main.Quit_Add_Destroy (0, Win);
end Max_Size;
|
test/interaction/Issue2669.agda | cruhland/agda | 1,989 | 403 | <gh_stars>1000+
module _ where
record Pair (A B : Set) : Set where
field
π₁ : A
π₂ : B
open Pair
foo : {A B : Set} → Pair A B → Pair A B
foo = λ { x → {!x!} }
{- Case splitting on x produces:
foo = λ { record { π₁ = π₃ ; π₂ = π₃ } → ? }
Repeated variables in pattern: π₃
-}
|
thirdparty/adasdl/thin/adasdl/AdaSDL_framebuff/sdltests/loopwave.adb | Lucretia/old_nehe_ada95 | 0 | 18273 | <filename>thirdparty/adasdl/thin/adasdl/AdaSDL_framebuff/sdltests/loopwave.adb
-- ----------------------------------------------------------------- --
-- --
-- This is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public --
-- License as published by the Free Software Foundation; either --
-- version 2 of the License, or (at your option) any later version. --
-- --
-- This software is distributed in the hope that it will be useful, --
-- but WITHOUT 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 along with this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- ----------------------------------------------------------------- --
-- ----------------------------------------------------------------- --
-- This is a translation, to the Ada programming language, of the --
-- original C test files written by <NAME> - www.libsdl.org --
-- translation made by <NAME> - www.adapower.net/~avargas --
-- ----------------------------------------------------------------- --
-- ---------------------------------------------------------------
-- This is a possible translation to Ada of the program loopwave.c
-- originally writen by -- <NAME>.--
-- Translation made by -- <NAME> --
-- ---------------------------------------------------------------
-- Program to load a wave file and loop playing it using SDL sound
-- This is only for simple WAVEs
-- ----------------------------------------------------------------- --
-- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
-- ----------------------------------------------------------------- --
-- SERIOUS WARNING: The Ada code in this files may, at some points,
-- rely directly on pointer arithmetic which is considered very
-- unsafe and PRONE TO ERROR. The AdaSDL_Mixer examples are
-- more appropriate and easier to understand. They should be used in
-- replacement of this files. Please go there.
-- This file exists only for the sake of completness and to test
-- AdaSDL without the dependency of AdaSDL_Mixer.
-- ----------------------------------------------------------------- --
-- WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
-- ----------------------------------------------------------------- --
with System.OS_Interface;
with Interfaces.C.Strings;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.OS_Lib;
with SDL.Types; use SDL.Types;
with SDL.Timer;
with SDL.Error;
with SDL.Audio;
with SDL.Quit;
with Lib_C;
with Loopwave_Callback; use Loopwave_Callback;
procedure Loopwave is
-- These could be avoided with use clauses.
-- but I like to trace the origin of things
package A renames SDL.Audio;
package C renames Interfaces.C;
package CS renames Interfaces.C.Strings;
package Er renames SDL.Error;
package T renames SDL.Timer;
use type C.int;
use type A.audiostatus;
use type A.AudioSpec_ptr;
-- -------------------------------------
name : CS.chars_ptr :=
CS.New_String (" ");
Valid_WAV : Boolean := True;
begin
-- Load the SDL library
if SDL.Init (SDL.INIT_AUDIO) < 0 then
Put_Line ("Couldn't load SDL: " & Er.Get_Error);
GNAT.OS_Lib.OS_Exit (1);
end if;
SDL.Quit.atexit (SDL.SDL_Quit'Access);
if Argument_Count = 0 then
Put_Line ("Usage: " & Command_Name & " <wavefile>");
GNAT.OS_Lib.OS_Exit (1);
end if;
-- Load the wave file into memory
-- A.Load_WAV (
-- CS.New_String (Argument (1)),
-- wave.spec,
-- wave.sound,
-- wave.soundlen,
-- Valid_WAV);
A.Load_WAV (
CS.New_String (Argument (1)),
wave.spec'Access,
wave.sound'Access,
wave.soundlen'Access,
Valid_WAV);
if not Valid_WAV then
Put_Line("Couldn't load " & Argument (1) & Er.Get_Error);
GNAT.OS_Lib.OS_Exit (1);
end if;
wave.spec.callback := fillerup'Access;
-- Set the signals
-- #ifdef SIGHUP
-- Lib_C.Set_Signal (System.OS_Interface.SIGHUP, poked'Access);
-- #endif
Lib_C.Set_Signal (System.OS_Interface.SIGINT, poked'Access);
-- #ifdef SIGQUIT
-- Lib_C.Set_Signal (System.OS_Interface.SIGQUIT, poked'Access);
-- #endif
Lib_C.Set_Signal (System.OS_Interface.SIGTERM, poked'Access);
-- Initialize fillrup variables
if A.OpenAudio(wave.spec'Access, null) < 0 then
Put_Line ("Couldn't open audio: " & Er.Get_Error);
A.FreeWAV (wave.sound);
GNAT.OS_Lib.OS_Exit (2);
end if;
A.PauseAudio (0);
-- Let the audio run
Put_Line ("using audio driver: " &
CS.Value (A.AudioDriverName (
name,
32)));
declare
i : Integer := 0;
begin
while done = 0 and A.GetAudioStatus = A.AUDIO_PLAYING loop
T.SDL_Delay (1000);
end loop;
end;
Put_Line ("Closing audio");
A.CloseAudio;
Put_Line ("Free WAV");
A.FreeWAV (wave.sound);
Put_Line ("The End");
end Loopwave;
|
Data/Bin/DivMod.agda | Rotsor/BinDivMod | 1 | 1962 | module Data.Bin.DivMod where
import Data.Fin
import Data.Product
import Data.Bin
import Data.Nat
import Relation.Binary.PropositionalEquality
import Data.Digit hiding (0b; 1b)
import Data.List
import Algebra
import Algebra.Structures
import Data.Bin.NatHelpers
open Data.Bin using (Bin; toℕ; toBits; fromBits; _1#; 0#; 2+_; 0b; 1b)
module PropEq = Relation.Binary.PropositionalEquality
open Data.List using (_∷_; []; List)
open Data.Nat using (ℕ; zero; suc)
import Data.Nat.Properties
open import Data.Bin.Utils
open import Data.Bin.Bijection using (fromℕ-bijection; fromℕ; toℕ-inj; toFromℕ-inverse)
import Data.Bin.Addition
module Properties where
open import Data.Bin.Multiplication
open Data.Bin using () renaming (_+_ to _B+_; _*_ to _B*_)
open Algebra.Structures using (IsCommutativeMonoid; module IsCommutativeSemiring)
open PropEq
open Data.Nat using (_+_; _*_)
open Data.Nat.Properties using (isCommutativeSemiring)
open IsCommutativeSemiring isCommutativeSemiring
module Everything where
open Data.Bin using (_1#; 0#; Bin; _+_; _*2; _*2+1; toℕ; ⌊_/2⌋; _*_; less)
open import Data.Bin.Properties using (<-strictTotalOrder)
open import Function
open Data.Product
open import Relation.Binary
open Relation.Binary.PropositionalEquality renaming (setoid to ≡-setoid)
open import Relation.Nullary
open import Relation.Nullary.Decidable
open Data.Fin using (zero; suc)
open Data.List using (_∷_; [])
open StrictTotalOrder <-strictTotalOrder hiding (trans)
open import Data.Bin.Minus using (_-_)
BinFin : Bin → Set
BinFin n = ∃ λ x → x < n
toBin : ∀ {x} → BinFin x → Bin
toBin = proj₁
{- data DivMod : Bin → Bin → Set where
result : ∀ {divisor : Bin} (q : Bin) (r : BinFin divisor) → DivMod (toBin r + q * divisor) divisor-}
data DivMod' (dividend : Bin) (divisor : Bin) : Set where
result : (q : Bin) (r : BinFin divisor) → (eq : dividend ≡ toBin r + q * divisor) → DivMod' dividend divisor
open Data.Digit
open Data.Bin using (addBitLists; addBits; toBits; fromBits)
open import Data.List using (List; _++_; [_]; [])
open import Data.Empty
import Data.Bin.Bijection
import Data.Bin.Multiplication
open Algebra.Structures using (module IsCommutativeMonoid)
import Data.Bin.Props
open Data.Bin.Props using (*-distrib; *2-is-2*; *2-distrib)
open IsCommutativeMonoid Data.Bin.Props.bin-+-is-comm-monoid using ()
renaming (identity to +-identity; comm to +-comm; assoc to +-assoc)
open IsCommutativeMonoid Data.Bin.Props.bin-*-is-comm-monoid using () renaming (comm to *-comm)
*-distribˡ : ∀ {a b c} → c * (a + b) ≡ c * a + c * b
*-distribˡ {a} {b} {c} = *-comm c (a + b) ⟨ trans ⟩ *-distrib {a} {b} {c} ⟨ trans ⟩ cong₂ _+_ (*-comm a c) (*-comm b c)
*-*2-assoc : ∀ {a b} → (a * b) *2 ≡ a *2 * b
*-*2-assoc {a} {b} = Data.Bin.Multiplication.*-*2-comm a b
*2-cong : ∀ {a b} → a ≡ b → a *2 ≡ b *2
*2-cong = cong _*2
+-cong₁ : ∀ {a b c} → a ≡ b → a + c ≡ b + c
+-cong₁ {c = c} = cong (λ z → z + c)
+-cong₂ : ∀ {a b c} → a ≡ b → c + a ≡ c + b
+-cong₂ {c = c} = cong (λ z → c + z)
+-identityʳ = proj₂ +-identity
divMod2-lem : ∀ {a} → a ≡ ⌊ a /2⌋ *2 + a %2
divMod2-lem {0#} = refl
divMod2-lem {[] 1#} = refl
divMod2-lem {(zero ∷ xs) 1#} = sym (+-identityʳ (⌊ (zero ∷ xs) 1# /2⌋ *2))
divMod2-lem {(suc zero ∷ xs) 1#} = Data.Bin.Multiplication.∷1#-interpretation (suc zero) xs
⟨ trans ⟩ +-comm ([] 1#) ((zero ∷ xs) 1#)
divMod2-lem {(suc (suc ()) ∷ xs) 1#}
import Relation.Binary.EqReasoning
open import Data.Bin.Props
helper' : ∀ l → ⌊ l 1# /2⌋ < l 1#
helper' [] = Data.Bin.less (Data.Nat.s≤s Data.Nat.z≤n)
helper' (x ∷ xs) = Data.Bin.less (Data.Bin.NatHelpers.kojojo x (toℕ (xs 1#)) (1+≢0 xs))
helper : ∀ {a} {d} → (≢0 : False (d ≟ fromℕ 0)) → ¬ (a < d) → ⌊ a /2⌋ < a
helper {_} {0#} () _
helper {0#} {l 1#} _ a≮d = ⊥-elim (a≮d (z<nz l))
helper {l 1#} _ _ = helper' l
open import Data.Sum
_≤_ : Bin → Bin → Set
a ≤ b = a ≡ b ⊎ a < b
¬>→< : ∀ {a b} → ¬ (b ≤ a) → a < b
¬>→< {a} {b} a≰b with compare a b
... | tri< a<b _ _ = a<b
... | tri≈ _ a≡b _ = ⊥-elim (a≰b (inj₁ (sym a≡b)))
... | tri> _ _ a>b = ⊥-elim (a≰b (inj₂ a>b))
*2-gives-space : ∀ {x y z} → (x < y) → z < fromℕ 2 → x *2 + z < y *2
*2-gives-space {x} {y} {z} (less x<y) (less z<2) = less (finalize (Data.Bin.NatHelpers.*2-gives-space x<y z<2)) where
open Data.Nat using () renaming (_*_ to _ℕ*_; _+_ to _ℕ+_; _<_ to _ℕ<_)
eq1 : toℕ x ℕ* 2 ℕ+ toℕ z ≡ toℕ (x *2 + z)
eq1 = sym (Data.Bin.Addition.+-is-addition (x *2) z ⟨ trans ⟩ cong (λ q → q ℕ+ toℕ z) (Data.Bin.Multiplication.*2-is-*2 x))
eq2 : toℕ y ℕ* 2 ≡ toℕ (y *2)
eq2 = sym (Data.Bin.Multiplication.*2-is-*2 y)
finalize : toℕ x ℕ* 2 ℕ+ toℕ z ℕ< toℕ y ℕ* 2 → toℕ (x *2 + z) ℕ< toℕ (y *2)
finalize = subst₂ _ℕ<_ eq1 eq2
<-pres₁ : ∀ {a b c} → a ≡ b → a < c → b < c
<-pres₁ refl eq = eq
<-pres₂ : ∀ {a b c} → a ≡ b → c < a → c < b
<-pres₂ refl eq = eq
*-identityˡ : ∀ {x} → [] 1# * x ≡ x
*-identityˡ = refl
x*2≡x+x : ∀ {x} → x *2 ≡ x + x
x*2≡x+x {x} = *2-is-2* x ⟨ trans ⟩ *-distrib {[] 1#} {[] 1#} {x} ⟨ trans ⟩ cong₂ _+_ (*-identityˡ {x}) (*-identityˡ {x})
%2<2 : ∀ {x} → x %2 < fromℕ 2
%2<2 {0#} = Data.Bin.less (Data.Nat.s≤s Data.Nat.z≤n)
%2<2 {[] 1#} = Data.Bin.less (Data.Nat.s≤s (Data.Nat.s≤s Data.Nat.z≤n))
%2<2 {(zero ∷ xs) 1#} = Data.Bin.less (Data.Nat.s≤s Data.Nat.z≤n)
%2<2 {(suc zero ∷ xs) 1#} = Data.Bin.less (Data.Nat.s≤s (Data.Nat.s≤s Data.Nat.z≤n))
%2<2 {(suc (suc ()) ∷ xs) 1#}
-+-elim : ∀ {x z} → ¬ x < z → x - z + z ≡ x
-+-elim = Data.Bin.Minus.-+-elim'
open import Data.Bin.Addition using (+-is-addition)
open import Data.Bin.Minus using (_-?_; positive; negative; equal; Greater; greater)
lemma1 : ∀ (f d q : Bin) → (d + f) + q * d ≡ f + (fromℕ 1 + q) * d
lemma1 f d q =
let open ≡-Reasoning in
begin
(d + f) + q * d
≡⟨ +-cong₁ {c = q * d} (+-comm d f) ⟩
(f + d) + q * d
≡⟨ +-assoc f d (q * d) ⟩
f + (d + q * d)
≡⟨ +-cong₂ {c = f} (+-cong₁ {c = q * d} (*-identityˡ {d})) ⟩
f + ((fromℕ 1 * d) + q * d)
≡⟨ +-cong₂ {c = f} (PropEq.sym (*-distrib {fromℕ 1} {q} {d})) ⟩
f + (fromℕ 1 + q) * d
∎
lemma2 : ∀ d q → d + q * d ≡ d + 0# + q * d
lemma2 d q = cong₂ _+_ (sym (proj₂ +-identity d)) (refl {x = q * d})
open import Algebra.FunctionProperties
using (LeftCancellative; RightCancellative; Cancellative)
+-cancelˡ-< : LeftCancellative Data.Nat._<_ Data.Nat._+_
+-cancelˡ-< c {y} {z} le =
Data.Nat.Properties.+-cancelˡ-≤ c
(subst₂ Data.Nat._≤_
(PropEq.sym (Data.Nat.Properties.+-suc c y))
(PropEq.refl {x = (Data.Nat._+_ c z)}) le)
+-<-left-cancellative : LeftCancellative _<_ _+_
+-<-left-cancellative c {a} {b} (less le) = less (+-cancelˡ-< (toℕ c) brr) where
brr : toℕ c Data.Nat.+ toℕ a Data.Nat.< toℕ c Data.Nat.+ toℕ b
brr = (subst₂ Data.Nat._<_
(Data.Bin.Addition.+-is-addition c a)
(Data.Bin.Addition.+-is-addition c b) le)
+-elim₂ : RightCancellative _<_ _+_
+-elim₂ {z} x y (less lt) rewrite +-is-addition x z | +-is-addition y z = less (Data.Bin.NatHelpers.+-elim₂ {toℕ x} {toℕ y} {toℕ z} lt)
fixup-divmod :
∀ a d q r
→ a ≡ r + q * d
→ r < d + d
→ DivMod' a d
fixup-divmod a d q r eq not-too-big =
case r -? d of λ {
(positive (greater diff PropEq.refl)) →
result
(fromℕ 1 + q)
(diff 1# , +-<-left-cancellative d not-too-big)
(PropEq.trans eq (lemma1 (diff 1#) d q));
(negative x) → result q (r , Data.Bin.Minus.greater-to-< _ _ x) eq ;
(equal PropEq.refl) →
result
(fromℕ 1 + q)
(0# ,
(+-<-left-cancellative
d
(subst (λ z → z < d + d) (PropEq.sym (proj₂ +-identity _)) not-too-big )) )
(PropEq.trans eq (PropEq.trans (lemma2 d q) (lemma1 0# d q)))
}
lemma3 : ∀ r q d bit → (r + q * d) *2 + bit ≡ (r *2 + bit) + q *2 * d
lemma3 r q d bit =
let open ≡-Reasoning in
begin
(r + q * d) *2 + bit
≡⟨ +-cong₁ {c = bit}
(begin
(r + q * d) *2
≡⟨ *2-distrib r (q * d) ⟩
r *2 + (q * d) *2
≡⟨ +-comm (r *2) ((q * d) *2) ⟩
(q * d) *2 + r *2
∎) ⟩
((q * d) *2 + r *2) + bit
≡⟨ +-assoc ((q * d) *2) (r *2) (bit) ⟩
(q * d) *2 + (r *2 + bit)
≡⟨ +-comm ((q * d) *2) (r *2 + bit) ⟩
(r *2 + bit) + (q * d) *2
≡⟨ +-cong₂ {c = r *2 + bit} (*-*2-assoc {q} {d}) ⟩
(r *2 + bit) + q *2 * d
∎
dm-step :
∀ a d q (r : BinFin d) → a ≡ toBin r + q * d →
∀ w (bit : BinFin (fromℕ 2))
→ w ≡ (a *2 + proj₁ bit)
→ DivMod' w d
dm-step ._ d q (r' , r'<d) refl ._ (bit , bit<2) refl =
fixup-divmod
_ d (q *2) (r' *2 + bit)
(lemma3 r' q d bit)
(<-pres₂ x*2≡x+x (*2-gives-space {r'} {d} {bit} r'<d (bit<2)))
dmRec : (d : Bin) → {≢0 : False (d ≟ fromℕ 0)} → (a : Bin) → ((a' : Bin) → (a' < a) → DivMod' a' d) → DivMod' a d
dmRec d {≢0} a rec =
case a <? d of λ {
(yes a<d) → result (0#) (a , a<d) (sym (+-identityʳ _)) ;
(no ¬a<d) →
case rec ⌊ a /2⌋ (helper ≢0 ¬a<d) of
λ { (result q r eq) →
dm-step ⌊ a /2⌋ d q r eq a (a %2 , %2<2) divMod2-lem } }
import Data.Bin.Rec
_divMod_ : (a : Bin) → (d : Bin) → {≢0 : False (d ≟ fromℕ 0)} → DivMod' a d
_divMod_ a d {≡0} = Data.Bin.Rec.rec (λ x → DivMod' x d) (dmRec d {≡0}) a
|
src/main/resources/com/woodplc/cora/grammar/FuzzyFortran.g4 | mchochlov/CoRA | 0 | 1685 | <filename>src/main/resources/com/woodplc/cora/grammar/FuzzyFortran.g4<gh_stars>0
grammar FuzzyFortran;
import FuzzyFortranFast;
module : moduleStatement (typeStatement | publicStatement | privateStatement | subprogram | . )*? moduleEndStatement;
typeStatement
: typename (',' (dimensionStatement|intentStatement| PARAMETER| ALLOCATABLE| accessSpecifier | OPTIONAL | SAVE | EXTERNAL | TARGET | POINTER | PROTECTED))* '::'? typeStatementNameList
;
publicStatement : PUBLIC ('::'? identifier (',' identifier)*)?;
privateStatement : PRIVATE ('::'? identifier (',' identifier)*)?;
allocateStatement : ALLOCATE LPAREN (typename '::')? exprList1 (',' allocOpt)* RPAREN;
allocOpt : optKeywords '=' identifier;
optKeywords : STAT | ERRMSG | SOURCE | MOLD;
typeStatementNameList
: assignmentStatement (',' assignmentStatement)*
| typeStatementName (',' typeStatementName)*
;
typeStatementName
: arrayDeclarator
|identifier
;
assignmentStatement
: expression1 '=' expression1
;
accessSpecifier : PUBLIC | PRIVATE;
intentStatement
: INTENT LPAREN INTENTION RPAREN
| INTENT LPAREN INTENTION RPAREN '::'? arrayDeclaratorExtents
;
dimensionStatement
: DIMENSION arrayDeclarators
| DIMENSION LPAREN arrayDeclaratorExtents RPAREN
;
arrayDeclarator
: identifier LPAREN arrayDeclaratorExtents RPAREN
;
arrayDeclarators
: arrayDeclarator (',' arrayDeclarator)*
;
arrayDeclaratorExtents
: arrayDeclaratorExtent (',' arrayDeclaratorExtent)*
;
arrayDeclaratorExtent
: expression1
;
typename
: REAL (LPAREN expression1 RPAREN)?
| COMPLEX (LPAREN expression1 RPAREN)
| DOUBLE COMPLEX
| DOUBLE PRECISION
| INTEGER (LPAREN expression1 RPAREN)?
| LOGICAL (LPAREN expression1 RPAREN)?
| CHARACTER (LPAREN ((KIND|LEN) '=')? (expression1|'*') RPAREN)?
| CHARACTER '*' expression1
| TYPE LPAREN identifier RPAREN
| CLASS LPAREN identifier RPAREN
;
expression1
: identifier LPAREN exprList1 RPAREN expression1
| identifier LPAREN exprList1? RPAREN
| expression1 (EQ | NE | GT | GE | LT | LE | LOR | LAND ) expression1
| (LNOT) expression1
| expression1 POWER expression1
| expression1 ('*' | DIV) expression1
| expression1 ('+' | '-') expression1
| expression1 DIV DIV expression1
| ('+'|'-') expression1
| identifier
| NUMBER
| logicalConstant
| LPAREN expression1 RPAREN
| expression1 ':' expression1
| ':'
| expression1 ':'
| ':' expression1
| expression1 '%' expression1
| '%' expression1
;
logicalConstant : (TRUE | FALSE)
;
exprList1 : expression1 ((','|':') expression1)*;
moduleStatement : MODULE identifier;
moduleEndStatement : END MODULE identifier?;
subprogram : ( COMMENT | OLD_COMMENT | EMPTY_LINE )* prefix* subType identifier body END (subType (identifier)?)? (NL|EOF)
//{System.out.println("subprogram: " + $start+ $stop);}
;
body : ( ifStatement | ifOneLine | callStatement | allocateStatement | . )*?
//{System.out.println("body: " + $ctx.start);}
;
callStatement :
CALL (callPrefix)? identifier (LPAREN)?
;
callPrefix : identifier '%';
identifier
: ID
| INTENTION
| NUMBER
| ERRMSG
| ALLOCATE
;
ALLOCATABLE : A L L O C A T A B L E;
ALLOCATE : A L L O C A T E;
PARAMETER : P A R A M E T E R;
PUBLIC : P U B L I C;
PRIVATE : P R I V A T E;
OPTIONAL : O P T I O N A L;
EXTERNAL : E X T E R N A L;
INTRINSIC : I N T R I N S I C;
SAVE : S A V E ;
TARGET : T A R G E T;
POINTER : P O I N T E R ;
PROTECTED : P R O T E C T E D ;
INTENT : I N T E N T;
CLASS : C L A S S;
DOUBLE : D O U B L E;
COMPLEX : C O M P L E X;
PRECISION : P R E C I S I O N;
CHARACTER : C H A R A C T E R;
KIND : K I N D;
LEN : L E N;
fragment IN : I N;
fragment OUT : O U T;
fragment INOUT : I N [ \t]* O U T;
INTENTION : IN | OUT | INOUT;
POWER : '**' ;
LNOT : '.not.' | '.NOT.' ;
LAND : '.and.' | '.AND.' ;
LOR : '.or.' | '.OR.' ;
EQV : '.eqv.' | '.EQV.' ;
NEQV : '.neqv.' | '.NEQV.' ;
XOR : '.xor.' | '.XOR.' ;
EOR : '.eor.' | '.EOR.' ;
LT : '.lt.' | '.LT.' | '<' ;
LE : '.le.' | '.LE.' | '<=' ;
GT : '.gt.' | '.GT.' | '>' ;
GE : '.ge.' | '.GE.' | '>=' ;
NE : '.ne.' | '.NE.' | '/=' ;
EQ : '.eq.' | '.EQ.' | '==' ;
TRUE : '.true.' | '.TRUE.' ;
FALSE : '.false.' | '.FALSE.' ;
DIMENSION : D I M E N S I O N ;
ERRMSG : E R R M S G;
SOURCE : S O U R C E;
MOLD : M O L D;
STAT : S T A T;
TYPE_SKIP : T Y P E .*? END [ \t]+ T Y P E -> skip;
TYPE : T Y P E; |
libsrc/target/smc777/graphics/w_plotpixl_MODE4.asm | Frodevan/z88dk | 640 | 100026 | <filename>libsrc/target/smc777/graphics/w_plotpixl_MODE4.asm
;
; Plot pixel at (x,y) coordinate.
SECTION code_clib
PUBLIC w_plotpixel_MODE4
defc NEEDplot = 1
.w_plotpixel_MODE4
INCLUDE "pixel_MODE4.inc"
|
courses/fundamentals_of_ada/labs/prompts/160_genericity/main.adb | AdaCore/training_material | 15 | 9623 | <gh_stars>10-100
with Ada.Text_IO; use Ada.Text_IO;
with Data_Type;
with Generic_List;
with Generic_List.Output;
procedure Main is
-- Create instance of generic list package
-- Create instance of generic list output package
-- My_List : List.List_T; -- Object of generic list type
Element : Data_Type.Record_T;
begin
null;
-- loop
-- Query user to populate Element object
-- Add Element object to My_List
-- end loop;
-- Sort My_List
-- Print My_List;
end Main;
|
src/fot/PA/Inductive/PropertiesATP.agda | asr/fotc | 11 | 11531 | ------------------------------------------------------------------------------
-- Inductive PA properties
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module PA.Inductive.PropertiesATP where
open import PA.Inductive.Base
------------------------------------------------------------------------------
+-rightIdentity : ∀ n → n + zero ≡ n
+-rightIdentity zero = refl
+-rightIdentity (succ n) = prf (+-rightIdentity n)
where postulate prf : n + zero ≡ n → succ n + zero ≡ succ n
-- TODO (21 November 2014). See Apia issue 16
-- {-# ATP prove prf #-}
x+Sy≡S[x+y] : ∀ m n → m + succ n ≡ succ (m + n)
x+Sy≡S[x+y] zero _ = refl
x+Sy≡S[x+y] (succ m) n = prf (x+Sy≡S[x+y] m n)
where postulate prf : m + succ n ≡ succ (m + n) →
succ m + succ n ≡ succ (succ m + n)
-- TODO (21 November 2014). See Apia issue 16
-- {-# ATP prove prf #-}
+-comm : ∀ m n → m + n ≡ n + m
+-comm zero n = sym (+-rightIdentity n)
+-comm (succ m) n = prf (+-comm m n)
where postulate prf : m + n ≡ n + m → succ m + n ≡ n + succ m
-- TODO (21 November 2014). See Apia issue 16
-- {-# ATP prove prf x+Sy≡S[x+y] #-}
|
agda/Categories/Exponential.agda | oisdk/combinatorics-paper | 4 | 7051 | <filename>agda/Categories/Exponential.agda
{-# OPTIONS --cubical --safe #-}
module Categories.Exponential where
open import Prelude hiding (_×_)
open import Categories
open import Categories.Product
module _ {ℓ₁ ℓ₂} (C : Category ℓ₁ ℓ₂) (hasProducts : HasProducts C) where
open Category C
open HasProducts hasProducts
module _ (Y Z : Ob) where
record Exponential : Type (ℓ₁ ℓ⊔ ℓ₂) where
field
obj : Ob
eval : C [ obj × Y , Z ]
uniq : ∀ (X : Ob) (f : C [ X × Y , Z ]) →
∃![ f~ ] (C [ eval ∘ (f~ |×| Category.Id C) ] ≡ f)
HasExponentials : Type (ℓ₁ ℓ⊔ ℓ₂)
HasExponentials = ∀ X Y → Exponential X Y
|
antigos/versao_modificaoes_mauricio.asm | mauriciocc/batalha-univatal | 0 | 19311 | <filename>antigos/versao_modificaoes_mauricio.asm
org 100h
.DATA
mensagem_inicial DB "BEM VINDO AO UNIVATAL, FAVOR DIGITE EM MAIUSCULO, A POSICAO DE SEUS NAVIOS:",0
lmensagem_inicial:
; Constantes de desenho
const_popa_horizontal EQU '<'
const_proa_horizontal EQU '>'
const_popa_vertical EQU '^'
const_proa_vertical EQU 'Y'
const_conves EQU '0'
const_barril EQU 'O'
const_agua EQU ' '
const_agua_atingida EQU 178
const_embarcacao_atingida EQU '*'
const_posicao_tiro_feito EQU '.'
const_barril_arr DB const_barril,0
const_bote_horizontal DB const_popa_horizontal, const_proa_horizontal,0
const_bote_vertical DB const_popa_vertical, const_proa_vertical,0
const_lancha_horizontal DB const_popa_horizontal, const_conves, const_proa_horizontal,0
const_lancha_vertical DB const_popa_vertical, const_conves, const_proa_vertical,0
const_barcaca_horizontal DB const_popa_horizontal, const_conves, const_conves, const_proa_horizontal,0
const_barcaca_vertical DB const_popa_vertical, const_conves, const_conves, const_proa_vertical,0
; Constantes para utilizar no "var_objeto"
const_objeto_barril EQU 1
const_objeto_bote EQU 2
const_objeto_lancha EQU 3
const_objeto_barcaca EQU 4
; Constantes para utilizar no "orientacao_escrita"
const_horizontal EQU 'H'
const_vertical EQU 'V'
; Constantes do tabuleiro
const_char_inicio_colunas EQU 'A'
const_char_inicio_linhas EQU '1'
; Posicoes iniciais dos tabuleiros
const_tabuleiro1_x EQU 1
const_tabuleiro1_y EQU 5
const_tabuleiro2_x EQU 41
const_tabuleiro2_y EQU 5
; Tamanho do tabuleiro
const_numero_colunas EQU 8
const_numero_linhas EQU 8
; Variavel para informar metodos a respeito de qual tabuleiro esta sendo realizada a operacao (1 ou 2)
var_tabuleiro DB 1
; Aqui guarda as informacoes do tabuleiro, onde estao os barcos, disparos, etc. (matriz 8x8 = 64 posicoes)
var_status_tabuleiro1 DB 64 DUP(const_agua)
var_status_tabuleiro2 DB 64 DUP(const_agua)
var_disparos_outro_player DB 64 DUP(const_agua)
posX DW 0
posY DW 0
posicao DW 0
; Controla a orientacao da funcao _escreve_char (usar constantes const_horizontal e const_vertical)
orientacao_escrita DB const_horizontal
; Controla o que sera desenhado ao chamar a funcao _desenha_objeto
var_objeto DB const_objeto_barril
mult DB 0
aux DB 0
.CODE
MOV AX, 0B800h
MOV ES, AX
;TELA_INICIAL:
; MOV SI, offset mensagem_inicial
; CALL _escreve_vetor_char
; Aqui precisamos coletar as posicoes do usuario
mov var_tabuleiro, 1
call _desenha_tabuleiro
mov posX, 2
mov posY, 2
mov var_objeto, const_objeto_barcaca
mov orientacao_escrita, const_vertical
mov var_tabuleiro, 1
call _desenha_objeto
;mov var_tabuleiro, 2
;call _desenha_tabuleiro
ret
; Logica ----------------------------------------
;-------------------------------------------------------------
; Efetua disparo na posicao especificada (grava na variavel var_status_tabuleiro2)
;
; Parametros:
; - posX
; - posY
;
; Retorna:
; - AL = 0 se disparo nao pode ser efetuado
; - AL = 1 se disparo foi efetuado
;
; Exemplo de uso
;
;mov posX, 2
;mov posY, 2
;call _efetua_disparo
_efetua_disparo:
push si
call _valida_disparo
cmp al, 1
je __ed_run
jmp __ed_end
__ed_run:
call _calcula_posicao_memoria
mov si, ax
mov var_status_tabuleiro2[si], const_posicao_tiro_feito
mov ax,1
__ed_end:
pop si
ret
;-------------------------------------------------------------
; Busca por disparo efetuado (var_disparos_outro_player) e
; altera em memoria com os resultados
; (var_disparos_outro_player e var_status_tabuleiro1)
;
; Variaveis utilizadas:
; - var_disparos_outro_player
; - var_status_tabuleiro1
;
; O retorno e feito no registrador AX:
; 1 -> caso tenha acertado algo
; 0 -> nao acertou nada
; Exemplo de uso:
;
;; Insere disparo na posicao 2
;lea si, var_disparos_outro_player
;add si, 2
;mov [si], const_posicao_tiro_feito
;
;; Insere barril na posicao 2
;lea si, var_status_tabuleiro1
;add si, 2
;mov [si], const_barril
;
;call _substitui_disparo_outro_player
_substitui_disparo_outro_player:
push si
push bx
lea si, var_disparos_outro_player
call _busca_disparo_outro_player
cmp ax, -1
jne __sdop_encontrou_disparo
mov ax, 0
ret
__sdop_encontrou_disparo:
;checa se acertou algo
lea si, var_status_tabuleiro1
add si, ax
push ax
mov al, [si]
call _acertou_algo
cmp al, 1
pop ax
je __sdop_acertou_algo
;aqui nao acertou
mov bl, const_agua_atingida
mov bh, 0
jmp __sdop_acertou_algo_end
__sdop_acertou_algo:
;aqui quer dizer que acertou
mov bl, const_embarcacao_atingida
mov bh, 1
__sdop_acertou_algo_end:
;pega caracter e substui nas memorias
lea si, var_disparos_outro_player
add si, ax
mov [si], bl
lea si, var_status_tabuleiro1
add si, ax
mov [si], bl
mov ax, 0
mov al, bh
pop bx
pop si
ret
;-------------------------------------------------------------
; Realiza busca por disparo efetuado (ver constante "const_posicao_tiro_feito")
; Parametros:
; - SI (deve estar setado no offset do vetor a ser verificado, acredito que sera "var_disparos_outro_player")
; Logica:
; Busca no vetor um valor igual a "const_posicao_tiro_feito"
; Caso encontre: retorna o indice do elemento dentro do vetor no registrador AX
; Caso nao econtre: retorna no AX -> -1
;
; Exemplo de uso:
;; Escreve disparo na posicao 3 do vetor (si+2)
;lea si, var_disparos_outro_player
;add si, 2
;mov [si], const_posicao_tiro_feito
;
;; Busca a posicao do disparo, apos chamada o registrador AX contera o valor 2
;lea si, var_disparos_outro_player
;call _busca_disparo_outro_player
_busca_disparo_outro_player:
mov ax, 0
__bdop_loop:
push si
add si, ax
mov bl, [si]
pop si
cmp bl, const_posicao_tiro_feito
je __bdop_end_loop
inc ax
cmp ax, 64
je __bdop_end_loop_not_found
jmp __bdop_loop
__bdop_end_loop_not_found:
mov ax, -1
__bdop_end_loop:
ret
;-------------------------------------------------------------
; Verifica se posicao selecionada para disparo ja nao foi utilizada
; Parametros:
; - posX
; - posY
; Logica:
; Checa na variavel "var_status_tabuleiro2" se ja nao houve disparo na posicao
; O retorno e feito no registrador AL
; caso retorne 1 -> quer dizer que pode disparar
; caso retorne 0 -> quer dizer que ja houve disparo
_valida_disparo:
push bx
push si
call _calcula_posicao_memoria
mov si, ax
mov al, var_status_tabuleiro2[si]
cmp al, const_agua
jne __vd_diferente
mov al, 1
jmp __vd_fim
__vd_diferente:
mov al, 0
__vd_fim:
pop si
pop bx
ret
;-------------------------------------------------------------
; Verifica se a posicao para posicionamento do objeto e valida
;
; NOTA: posX e posY em relacao ao tabuleiro (8x8 neste caso)
;
; Parametros:
; - posX
; - posY
; - orientacao_escrita
; - var_objeto
;
; Logica:
; - Calcula tamanho do objeto
; - Verifica se ele vai ser desenhado ao longo do X ou Y
; - Incrementa o valor da posicao X ou Y dependendo da orientacao da escrita
; - Verifica se os valores nao estouram o tamanho do tabuleiro
; - Checa se o posicionamento da embarcacao nao ira sobrepor outra embarcacao
;
; O retorno e feito no registrador AL
; caso retorne 1 -> quer dizer que a posicao e valida
; caso retorne 0 -> quer dizer que a posicao e invalida
_valida_posicao_objeto:
push posX
push posY
mov ax, 0
mov al, var_objeto
mov cx, ax
dec al
cmp orientacao_escrita, const_horizontal
jne __vpo_vertical
add posX, ax
jmp __vpo_fim_orientacao
__vpo_vertical:
add posY, ax
__vpo_fim_orientacao:
cmp posX, const_numero_colunas
jng __vpo_nao_e_maior_x
mov al, 0
jmp __vpo_fim
__vpo_nao_e_maior_x:
cmp posY, const_numero_linhas
jng __vpo_nao_e_maior_y
mov al, 0
jmp __vpo_fim
__vpo_nao_e_maior_y:
pop posY
pop posX
push posX
push posY
__vpo_loop_validacao:
; Valida se a posicao contem agua
call _calcula_posicao_memoria
push si
mov si, ax
cmp var_status_tabuleiro1[si], const_agua
pop si
je __vpo_agua_encontrada
mov ax, 0
jmp __vpo_fim
__vpo_agua_encontrada:
; Incrementa X ou Y
cmp orientacao_escrita, const_horizontal
jne __vpo_loop_vertical
inc posX
jmp __vpo_loop_orientacao
__vpo_loop_vertical:
inc posY
__vpo_loop_orientacao:
loop __vpo_loop_validacao
mov ax, 1
__vpo_fim:
pop posY
pop posX
ret
_calcula_posicao_memoria:
push bx
mov ax, posY
dec ax
mov bl, const_numero_colunas
mul bl
add ax, posX
dec ax
pop bx
ret
;-------------------------------------------------------------
; Traduz um caracter ASCII (A...H) para um valor (1,2,3...) (usado para colunas)
; Parametro deve estar no registrador AL e o retorno e feito
; atraves do mesmo registrador
_letra_para_valor:
SUB AL, 64
ret
;-------------------------------------------------------------
; Checa se o disparo acertou algo
; Logica:
;
; Se AL for maior que 46(const_posicao_tiro_feito) e menor que 178(const_agua_atingida)
; quer dizer que acertou algo
;
; O retorno e feito no registrador AL
; caso retorne 1 -> quer dizer que acertou
; caso retorne 0 -> quer dizer que nao acertou nada
_acertou_algo:
CMP AL, const_posicao_tiro_feito
; SE AL <= PULA
JLE __aa_nao_acertou
CMP AL, const_agua_atingida
; SE AL >= PULA
JLE __aa_nao_acertou
mov al, 1
ret
__aa_nao_acertou:
mov al, 0
ret
; Interface grafica ----------------------------------------
; Posiciona na posicao X Y setadas nas variaveis posX e posY
_gotoXY:
push ax
push bx
mov ax, posY
mov bl, 160
dec ax
mul bl
mov bx, posX
dec bx
add ax, bx
add ax, bx
mov posicao, ax
mov di, ax
pop bx
pop ax
ret
; Desenha tabuleiro (setar variavel "var_tabuleiro" para o tabuleiro desejado (1 ou 2))
_desenha_tabuleiro:
push ax
push bx
push cx
mov ah, orientacao_escrita ; Salva orientacao
cmp var_tabuleiro, 1
jne __dt_pos_tabuleiro2
mov posX, const_tabuleiro1_x
mov posY, const_tabuleiro1_y
mov bx, offset var_status_tabuleiro1
jmp __dt_pos_fim
__dt_pos_tabuleiro2:
mov posX, const_tabuleiro2_x
mov posY, const_tabuleiro2_y
mov bx, offset var_status_tabuleiro2
__dt_pos_fim:
call _gotoXY
push posX
push posY
mov cx, const_numero_colunas
mov al, const_char_inicio_colunas
mov orientacao_escrita, const_horizontal
call _escreve_espaco
dt_loop_cols:
call _escreve_char
inc al
loop dt_loop_cols
pop posY
pop posX
push posX
push posY
inc posY
call _gotoXY
mov cx, const_numero_linhas
mov al, const_char_inicio_linhas
mov orientacao_escrita, const_vertical
dt_loop_rows:
call _escreve_char
inc al
loop dt_loop_rows
pop posY
pop posX
inc posX
mov cx, posX
inc posY
call _gotoXY
mov si, bx
mov bx, 0
mov orientacao_escrita, const_horizontal
__dt_stat_loop_linhas:
__dt_stat_loop_cols:
mov al, bl
mul bh
push si
add si, ax
mov al, [si]
call _escreve_char
pop si
inc bh
cmp bh, const_numero_colunas
jl __dt_stat_loop_cols
mov posX, cx
inc posY
call _gotoXY
mov bh, 0
inc bl
cmp bl, const_numero_linhas
jl __dt_stat_loop_linhas
mov orientacao_escrita, ah; Restaura orientacao
pop cx
pop bx
pop ax
ret
;-----------------------------------------------------------
; Desenha objeto considerando as variaveis:
; - posX: posicao aonde sera desenhado no X do tabuleiro (1 ate 8 neste caso)
; - posY: posicao aonde sera desenhado no Y do tabuleiro (1 ate 8 neste caso)
; - var_objeto: define qual objeto desenhar (ver constantes)
; - orientacao_escrita: define a orientacao do desenho (ver constantes)
; - var_tabuleiro: tabuleiro onde sera inserida a embarcacao
_desenha_objeto:
; Posiciona no tabuleiro
push posX
push posY
cmp var_tabuleiro, 1
jne __do_pos_tabuleiro_2
add posX, const_tabuleiro1_x
add posY, const_tabuleiro1_y
jmp __do_pos
__do_pos_tabuleiro_2:
add posX, const_tabuleiro2_x
add posY, const_tabuleiro2_y
__do_pos:
call _gotoXY
pop posY
pop posX
; Fim do posicionamento
push si
; Checa barril
cmp var_objeto, const_objeto_barril
JNE __do_pula_barril
mov si, offset const_barril_arr
jmp __db_fim
__do_pula_barril:
cmp orientacao_escrita, const_horizontal
JNE __db_orientacao_vertical:
; Checa bote
cmp var_objeto, const_objeto_bote
JNE __do_pula_bote_horizontal
mov si, offset const_bote_horizontal
jmp __db_fim
__do_pula_bote_horizontal:
; Checa lancha
cmp var_objeto, const_objeto_lancha
JNE __do_pula_lancha_horizontal
mov si, offset const_lancha_horizontal
jmp __db_fim
__do_pula_lancha_horizontal:
;Se nao for nenhum, e barcaca
mov si, offset const_barcaca_horizontal
jmp __db_fim
__db_orientacao_vertical:
; Checa bote
cmp var_objeto, const_objeto_bote
JNE __do_pula_bote_vertical
mov si, offset const_bote_vertical
jmp __db_fim
__do_pula_bote_vertical:
; Checa lancha
cmp var_objeto, const_objeto_lancha
JNE __do_pula_lancha_vertical
mov si, offset const_lancha_vertical
jmp __db_fim
__do_pula_lancha_vertical:
;Se nao for nenhum, e barcaca
mov si, offset const_barcaca_vertical
__db_fim:
push si
call _escreve_vetor_char
pop si
; Fim do desenha em tela
; Escreve na memoria
push di
push ax
push bx
mov ax, posY
dec ax
mov bx, const_numero_linhas
mul bx
add ax, posX
dec ax
cmp var_tabuleiro, 1
jne __do_mem_tabuleiro2
add ax, offset var_status_tabuleiro1
mov di, ax
call _escreve_vetor_char_mem
__do_mem_tabuleiro2:
; Fim da escrita em memoria
pop bx
pop ax
pop di
pop si
ret
;-----------------------------------------------------------
; Escreve um ' ' na posicao atual
_escreve_espaco:
push ax
mov al, ' '
call _escreve_char
pop ax
ret
; Escreve char que esta no registrador AL em tela
_escreve_char:
MOV ES:[DI], AL ; ESCREVE CARACTER
MOV ES:[DI+1], 00011111b ;10101110b ; ESCREVE ATRIBUTO
CMP orientacao_escrita, const_horizontal
JNE __ec_orientacao_vertical:
ADD DI, 2
ret
__ec_orientacao_vertical:
ADD DI, 160
ret
_escreve_vetor_char:
MOV AL, [SI]
CMP AL, 0
JZ __ev_fim
call _escreve_char
INC SI
JNZ _escreve_vetor_char
__ev_fim:
ret
; Escreve char que esta no registrador AL em memoria
; Escreve no endereco de DI
_escreve_char_memoria:
MOV [DI], AL ; ESCREVE CARACTER
CMP orientacao_escrita, const_horizontal
JNE __ecm_orientacao_vertical:
ADD DI, 1
ret
__ecm_orientacao_vertical:
ADD DI, const_numero_colunas
ret
; Escreve vetor do SI no DI
_escreve_vetor_char_mem:
MOV AL, [SI]
CMP AL, 0
JZ __evcm_fim
call _escreve_char_memoria
INC SI
JNZ _escreve_vetor_char_mem
__evcm_fim:
ret
|
programs/oeis/020/A020654.asm | jmorken/loda | 1 | 96445 | <reponame>jmorken/loda<filename>programs/oeis/020/A020654.asm<gh_stars>1-10
; A020654: Lexicographically earliest infinite increasing sequence of nonnegative numbers containing no 5-term arithmetic progression.
; 0,1,2,3,5,6,7,8,10,11,12,13,15,16,17,18,25,26,27,28,30,31,32,33,35,36,37,38,40,41,42,43,50,51,52,53,55,56,57,58,60,61,62,63,65,66,67,68,75,76,77,78,80,81,82,83,85,86,87,88,90,91,92,93,125,126,127,128,130,131,132,133,135,136,137,138,140,141,142,143,150,151,152,153,155,156,157,158,160,161,162,163,165,166,167,168,175,176,177,178,180,181,182,183,185,186,187,188,190,191,192,193,200,201,202,203,205,206,207,208,210,211,212,213,215,216,217,218,250,251,252,253,255,256,257,258,260,261,262,263,265,266,267,268,275,276,277,278,280,281,282,283,285,286,287,288,290,291,292,293,300,301,302,303,305,306,307,308,310,311,312,313,315,316,317,318,325,326,327,328,330,331,332,333,335,336,337,338,340,341,342,343,375,376,377,378,380,381,382,383,385,386,387,388,390,391,392,393,400,401,402,403,405,406,407,408,410,411,412,413,415,416,417,418,425,426,427,428,430,431,432,433,435,436,437,438,440,441,442,443,450,451,452,453,455,456,457,458,460,461
mov $5,$0
mov $6,$0
mov $7,$0
lpb $7
mov $0,$5
sub $7,1
sub $0,$7
sub $0,$2
add $2,$0
mov $3,$2
mov $4,2
lpb $3
dif $3,4
mul $4,5
lpe
mov $8,$4
div $8,8
add $1,$8
lpe
add $1,$6
|
src/autogenerated/bcm2835_h.ads | TamaMcGlinn/ada_raspio | 1 | 20156 | pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with x86_64_linux_gnu_bits_stdint_uintn_h;
with Interfaces.C.Strings;
package bcm2835_h is
HIGH : constant := 16#1#; -- /usr/local/include/bcm2835.h:190
LOW : constant := 16#0#; -- /usr/local/include/bcm2835.h:192
BCM2835_PERI_BASE : constant :=
16#2000_0000#; -- /usr/local/include/bcm2835.h:196
-- unsupported macro: BCM2835_GPIO_PADS (BCM2835_PERI_BASE + 0x100000)
-- unsupported macro: BCM2835_CLOCK_BASE (BCM2835_PERI_BASE + 0x101000)
-- unsupported macro: BCM2835_GPIO_BASE (BCM2835_PERI_BASE + 0x200000)
-- unsupported macro: BCM2835_SPI0_BASE (BCM2835_PERI_BASE + 0x204000)
-- unsupported macro: BCM2835_GPIO_PWM (BCM2835_PERI_BASE + 0x20C000)
BCM2835_PAGE_SIZE : constant :=
(4 * 1_024); -- /usr/local/include/bcm2835.h:230
BCM2835_BLOCK_SIZE : constant :=
(4 * 1_024); -- /usr/local/include/bcm2835.h:232
BCM2835_GPFSEL0 : constant :=
16#0000#; -- /usr/local/include/bcm2835.h:239
BCM2835_GPFSEL1 : constant :=
16#0004#; -- /usr/local/include/bcm2835.h:240
BCM2835_GPFSEL2 : constant :=
16#0008#; -- /usr/local/include/bcm2835.h:241
BCM2835_GPFSEL3 : constant :=
16#000c#; -- /usr/local/include/bcm2835.h:242
BCM2835_GPFSEL4 : constant :=
16#0010#; -- /usr/local/include/bcm2835.h:243
BCM2835_GPFSEL5 : constant :=
16#0014#; -- /usr/local/include/bcm2835.h:244
BCM2835_GPSET0 : constant := 16#001c#; -- /usr/local/include/bcm2835.h:245
BCM2835_GPSET1 : constant := 16#0020#; -- /usr/local/include/bcm2835.h:246
BCM2835_GPCLR0 : constant := 16#0028#; -- /usr/local/include/bcm2835.h:247
BCM2835_GPCLR1 : constant := 16#002c#; -- /usr/local/include/bcm2835.h:248
BCM2835_GPLEV0 : constant := 16#0034#; -- /usr/local/include/bcm2835.h:249
BCM2835_GPLEV1 : constant := 16#0038#; -- /usr/local/include/bcm2835.h:250
BCM2835_GPEDS0 : constant := 16#0040#; -- /usr/local/include/bcm2835.h:251
BCM2835_GPEDS1 : constant := 16#0044#; -- /usr/local/include/bcm2835.h:252
BCM2835_GPREN0 : constant := 16#004c#; -- /usr/local/include/bcm2835.h:253
BCM2835_GPREN1 : constant := 16#0050#; -- /usr/local/include/bcm2835.h:254
BCM2835_GPFEN0 : constant := 16#0048#; -- /usr/local/include/bcm2835.h:255
BCM2835_GPFEN1 : constant := 16#005c#; -- /usr/local/include/bcm2835.h:256
BCM2835_GPHEN0 : constant := 16#0064#; -- /usr/local/include/bcm2835.h:257
BCM2835_GPHEN1 : constant := 16#0068#; -- /usr/local/include/bcm2835.h:258
BCM2835_GPLEN0 : constant := 16#0070#; -- /usr/local/include/bcm2835.h:259
BCM2835_GPLEN1 : constant := 16#0074#; -- /usr/local/include/bcm2835.h:260
BCM2835_GPAREN0 : constant :=
16#007c#; -- /usr/local/include/bcm2835.h:261
BCM2835_GPAREN1 : constant :=
16#0080#; -- /usr/local/include/bcm2835.h:262
BCM2835_GPAFEN0 : constant :=
16#0088#; -- /usr/local/include/bcm2835.h:263
BCM2835_GPAFEN1 : constant :=
16#008c#; -- /usr/local/include/bcm2835.h:264
BCM2835_GPPUD : constant := 16#0094#; -- /usr/local/include/bcm2835.h:265
BCM2835_GPPUDCLK0 : constant :=
16#0098#; -- /usr/local/include/bcm2835.h:266
BCM2835_GPPUDCLK1 : constant :=
16#009c#; -- /usr/local/include/bcm2835.h:267
BCM2835_PADS_GPIO_0_27 : constant :=
16#002c#; -- /usr/local/include/bcm2835.h:294
BCM2835_PADS_GPIO_28_45 : constant :=
16#0030#; -- /usr/local/include/bcm2835.h:295
BCM2835_PADS_GPIO_46_53 : constant :=
16#0034#; -- /usr/local/include/bcm2835.h:296
-- unsupported macro: BCM2835_PAD_PASSWRD (0x5A << 24)
BCM2835_PAD_SLEW_RATE_UNLIMITED : constant :=
16#10#; -- /usr/local/include/bcm2835.h:300
BCM2835_PAD_HYSTERESIS_ENABLED : constant :=
16#08#; -- /usr/local/include/bcm2835.h:301
BCM2835_PAD_DRIVE_2mA : constant :=
16#00#; -- /usr/local/include/bcm2835.h:302
BCM2835_PAD_DRIVE_4mA : constant :=
16#01#; -- /usr/local/include/bcm2835.h:303
BCM2835_PAD_DRIVE_6mA : constant :=
16#02#; -- /usr/local/include/bcm2835.h:304
BCM2835_PAD_DRIVE_8mA : constant :=
16#03#; -- /usr/local/include/bcm2835.h:305
BCM2835_PAD_DRIVE_10mA : constant :=
16#04#; -- /usr/local/include/bcm2835.h:306
BCM2835_PAD_DRIVE_12mA : constant :=
16#05#; -- /usr/local/include/bcm2835.h:307
BCM2835_PAD_DRIVE_14mA : constant :=
16#06#; -- /usr/local/include/bcm2835.h:308
BCM2835_PAD_DRIVE_16mA : constant :=
16#07#; -- /usr/local/include/bcm2835.h:309
BCM2835_SPI0_CS : constant :=
16#0000#; -- /usr/local/include/bcm2835.h:380
BCM2835_SPI0_FIFO : constant :=
16#0004#; -- /usr/local/include/bcm2835.h:381
BCM2835_SPI0_CLK : constant :=
16#0008#; -- /usr/local/include/bcm2835.h:382
BCM2835_SPI0_DLEN : constant :=
16#000c#; -- /usr/local/include/bcm2835.h:383
BCM2835_SPI0_LTOH : constant :=
16#0010#; -- /usr/local/include/bcm2835.h:384
BCM2835_SPI0_DC : constant :=
16#0014#; -- /usr/local/include/bcm2835.h:385
BCM2835_SPI0_CS_LEN_LONG : constant :=
16#0200_0000#; -- /usr/local/include/bcm2835.h:388
BCM2835_SPI0_CS_DMA_LEN : constant :=
16#0100_0000#; -- /usr/local/include/bcm2835.h:389
BCM2835_SPI0_CS_CSPOL2 : constant :=
16#0080_0000#; -- /usr/local/include/bcm2835.h:390
BCM2835_SPI0_CS_CSPOL1 : constant :=
16#0040_0000#; -- /usr/local/include/bcm2835.h:391
BCM2835_SPI0_CS_CSPOL0 : constant :=
16#0020_0000#; -- /usr/local/include/bcm2835.h:392
BCM2835_SPI0_CS_RXF : constant :=
16#0010_0000#; -- /usr/local/include/bcm2835.h:393
BCM2835_SPI0_CS_RXR : constant :=
16#0008_0000#; -- /usr/local/include/bcm2835.h:394
BCM2835_SPI0_CS_TXD : constant :=
16#0004_0000#; -- /usr/local/include/bcm2835.h:395
BCM2835_SPI0_CS_RXD : constant :=
16#0002_0000#; -- /usr/local/include/bcm2835.h:396
BCM2835_SPI0_CS_DONE : constant :=
16#0001_0000#; -- /usr/local/include/bcm2835.h:397
BCM2835_SPI0_CS_TE_EN : constant :=
16#0000_8000#; -- /usr/local/include/bcm2835.h:398
BCM2835_SPI0_CS_LMONO : constant :=
16#0000_4000#; -- /usr/local/include/bcm2835.h:399
BCM2835_SPI0_CS_LEN : constant :=
16#0000_2000#; -- /usr/local/include/bcm2835.h:400
BCM2835_SPI0_CS_REN : constant :=
16#0000_1000#; -- /usr/local/include/bcm2835.h:401
BCM2835_SPI0_CS_ADCS : constant :=
16#0000_0800#; -- /usr/local/include/bcm2835.h:402
BCM2835_SPI0_CS_INTR : constant :=
16#0000_0400#; -- /usr/local/include/bcm2835.h:403
BCM2835_SPI0_CS_INTD : constant :=
16#0000_0200#; -- /usr/local/include/bcm2835.h:404
BCM2835_SPI0_CS_DMAEN : constant :=
16#0000_0100#; -- /usr/local/include/bcm2835.h:405
BCM2835_SPI0_CS_TA : constant :=
16#0000_0080#; -- /usr/local/include/bcm2835.h:406
BCM2835_SPI0_CS_CSPOL : constant :=
16#0000_0040#; -- /usr/local/include/bcm2835.h:407
BCM2835_SPI0_CS_CLEAR : constant :=
16#0000_0030#; -- /usr/local/include/bcm2835.h:408
BCM2835_SPI0_CS_CLEAR_RX : constant :=
16#0000_0020#; -- /usr/local/include/bcm2835.h:409
BCM2835_SPI0_CS_CLEAR_TX : constant :=
16#0000_0010#; -- /usr/local/include/bcm2835.h:410
BCM2835_SPI0_CS_CPOL : constant :=
16#0000_0008#; -- /usr/local/include/bcm2835.h:411
BCM2835_SPI0_CS_CPHA : constant :=
16#0000_0004#; -- /usr/local/include/bcm2835.h:412
BCM2835_SPI0_CS_CS : constant :=
16#0000_0003#; -- /usr/local/include/bcm2835.h:413
BCM2835_PWM_CONTROL : constant := 0; -- /usr/local/include/bcm2835.h:475
BCM2835_PWM_STATUS : constant := 1; -- /usr/local/include/bcm2835.h:476
BCM2835_PWM0_RANGE : constant := 4; -- /usr/local/include/bcm2835.h:477
BCM2835_PWM0_DATA : constant := 5; -- /usr/local/include/bcm2835.h:478
BCM2835_PWM1_RANGE : constant := 8; -- /usr/local/include/bcm2835.h:479
BCM2835_PWM1_DATA : constant := 9; -- /usr/local/include/bcm2835.h:480
BCM2835_PWMCLK_CNTL : constant := 40; -- /usr/local/include/bcm2835.h:482
BCM2835_PWMCLK_DIV : constant := 41; -- /usr/local/include/bcm2835.h:483
BCM2835_PWM1_MS_MODE : constant :=
16#8000#; -- /usr/local/include/bcm2835.h:485
BCM2835_PWM1_USEFIFO : constant :=
16#2000#; -- /usr/local/include/bcm2835.h:486
BCM2835_PWM1_REVPOLAR : constant :=
16#1000#; -- /usr/local/include/bcm2835.h:487
BCM2835_PWM1_OFFSTATE : constant :=
16#0800#; -- /usr/local/include/bcm2835.h:488
BCM2835_PWM1_REPEATFF : constant :=
16#0400#; -- /usr/local/include/bcm2835.h:489
BCM2835_PWM1_SERIAL : constant :=
16#0200#; -- /usr/local/include/bcm2835.h:490
BCM2835_PWM1_ENABLE : constant :=
16#0100#; -- /usr/local/include/bcm2835.h:491
BCM2835_PWM0_MS_MODE : constant :=
16#0080#; -- /usr/local/include/bcm2835.h:493
BCM2835_PWM0_USEFIFO : constant :=
16#0020#; -- /usr/local/include/bcm2835.h:494
BCM2835_PWM0_REVPOLAR : constant :=
16#0010#; -- /usr/local/include/bcm2835.h:495
BCM2835_PWM0_OFFSTATE : constant :=
16#0008#; -- /usr/local/include/bcm2835.h:496
BCM2835_PWM0_REPEATFF : constant :=
16#0004#; -- /usr/local/include/bcm2835.h:497
BCM2835_PWM0_SERIAL : constant :=
16#0002#; -- /usr/local/include/bcm2835.h:498
BCM2835_PWM0_ENABLE : constant :=
16#0001#; -- /usr/local/include/bcm2835.h:499
-- arg-macro: procedure delay (x)
-- bcm2835_delay(x)
-- arg-macro: procedure delayMicroseconds (x)
-- bcm2835_delayMicroseconds(x)
-- bcm2835.h
-- C and C++ support for Broadcom BCM 2835 as used in Raspberry Pi Author:
-- <NAME> (<EMAIL>) Copyright (C) 2011-2012 Mike McCauley
-- $Id: bcm2835.h,v 1.7 2012/12/01 22:56:52 mikem Exp mikem $
--/ \mainpage C library for Broadcom BCM 2835 as used in Raspberry Pi
--/
--/ This is a C library for Raspberry Pi (RPi). It provides access to
--/ GPIO and other IO functions on the Broadcom BCM 2835 chip,
--/ allowing access to the GPIO pins on the
--/ 26 pin IDE plug on the RPi board so you can control and interface with various external devices.
--/
--/ It provides functions for reading digital inputs and setting digital outputs.
--/ Pin event detection is supported by polling (interrupts not supported).
--/
--/ It is C++ compatible, and installs as a header file and non-shared library on
--/ any Linux-based distro (but clearly is no use except on Raspberry Pi or another board with
--/ BCM 2835).
--/
--/ The version of the package that this documentation refers to can be downloaded
--/ from http://www.open.com.au/mikem/bcm2835/bcm2835-1.15.tar.gz
--/ You can find the latest version at http://www.open.com.au/mikem/bcm2835
--/
--/ Several example programs are provided.
--/
--/ Based on data in http://elinux.org/RPi_Low-level_peripherals and
--/ http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
--/ and http://www.scribd.com/doc/101830961/GPIO-Pads-Control2
--/
--/ You can also find online help and discussion at http://groups.google.com/group/bcm2835
--/ Please use that group for all questions and discussions on this topic.
--/ Do not contact the author directly, unless it is to discuss commercial licensing.
--/
--/ Tested on debian6-19-04-2012, 2012-07-15-wheezy-raspbian and Occidentalisv01
--/ CAUTION: it has been observed that when detect enables such as bcm2835_gpio_len()
--/ are used and the pin is pulled LOW
--/ it can cause temporary hangs on 2012-07-15-wheezy-raspbian and Occidentalisv01.
--/ Reason for this is not yet determined, but suspect that an interrupt handler is
--/ hitting a hard loop on those OSs.
--/ If you must use bcm2835_gpio_len() and friends, make sure you disable the pins with
--/ bcm2835_gpio_cler_len() and friends after use.
--/
--/ \par Installation
--/
--/ This library consists of a single non-shared library and header file, which will be
--/ installed in the usual places by make install
--/
--/ \code
--/ tar zxvf bcm2835-1.0.tar.gz
--/ cd bcm2835-1.0
--/ ./configure
--/ make
--/ sudo make check
--/ sudo make install
--/ \endcode
--/
--/ \par Physical Addresses
--/
--/ The functions bcm2835_peri_read(), bcm2835_peri_write() and bcm2835_peri_set_bits()
--/ are low level peripheral register access functions. They are designed to use
--/ physical addresses as described in section 1.2.3 ARM physical addresses
--/ of the BCM2835 ARM Peripherals manual.
--/ Physical addresses range from 0x20000000 to 0x20FFFFFF for peripherals. The bus
--/ addresses for peripherals are set up to map onto the peripheral bus address range starting at
--/ 0x7E000000. Thus a peripheral advertised in the manual at bus address 0x7Ennnnnn is available at
--/ physical address 0x20nnnnnn.
--/
--/ The base address of the various peripheral registers are available with the following
--/ externals:
--/ bcm2835_gpio
--/ bcm2835_pwm
--/ bcm2835_clk
--/ bcm2835_pads
--/ bcm2835_spio0
--/
--/ \par Pin Numbering
--/
--/ The GPIO pin numbering as used by RPi is different to and inconsistent with the underlying
--/ BCM 2835 chip pin numbering. http://elinux.org/RPi_BCM2835_GPIOs
--/
--/ RPi has a 26 pin IDE header that provides access to some of the GPIO pins on the BCM 2835,
--/ as well as power and ground pins. Not all GPIO pins on the BCM 2835 are available on the
--/ IDE header.
--/
--/ RPi Version 2 also has a P5 connector with 4 GPIO pins, 5V, 3.3V and Gnd.
--/
--/ The functions in this library are designed to be passed the BCM 2835 GPIO pin number and _not_
--/ the RPi pin number. There are symbolic definitions for each of the available pins
--/ that you should use for convenience. See \ref RPiGPIOPin.
--/
--/ \par SPI Pins
--/
--/ The bcm2835_spi_* functions allow you to control the BCM 2835 SPI0 interface,
--/ allowing you to send and received data by SPI (Serial Peripheral Interface).
--/ For more information about SPI, see http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
--/
--/ When bcm2835_spi_begin() is called it changes the bahaviour of the SPI interface pins from their
--/ default GPIO behaviour in order to support SPI. While SPI is in use, you will not be able
--/ to control the state of the SPI pins through the usual bcm2835_spi_gpio_write().
--/ When bcm2835_spi_end() is called, the SPI pins will all revert to inputs, and can then be
--/ configured and controled with the usual bcm2835_gpio_* calls.
--/
--/ The Raspberry Pi GPIO pins used for SPI are:
--/
--/ - P1-19 (MOSI)
--/ - P1-21 (MISO)
--/ - P1-23 (CLK)
--/ - P1-24 (CE0)
--/ - P1-26 (CE1)
--/
--/ \par Open Source Licensing GPL V2
--/
--/ This is the appropriate option if you want to share the source code of your
--/ application with everyone you distribute it to, and you also want to give them
--/ the right to share who uses it. If you wish to use this software under Open
--/ Source Licensing, you must contribute all your source code to the open source
--/ community in accordance with the GPL Version 2 when your application is
--/ distributed. See http://www.gnu.org/copyleft/gpl.html and COPYING
--/
--/ \par Acknowledgements
--/
--/ Some of this code has been inspired by <NAME> Gert.
--/
--/ \par Revision History
--/
--/ \version 1.0 Initial release
--/ \version 1.1 Minor bug fixes
--/ \version 1.2 Added support for SPI
--/ \version 1.3 Added bcm2835_spi_transfern()
--/ \version 1.4 Fixed a problem that prevented SPI CE1 being used. Reported by <NAME>.
--/ \version 1.5 Added bcm2835_close() to deinit the library. Suggested by <NAME>
--/ \version 1.6 Document testing on 2012-07-15-wheezy-raspbian and Occidentalisv01
--/ Functions bcm2835_gpio_ren(), bcm2835_gpio_fen(), bcm2835_gpio_hen()
--/ bcm2835_gpio_len(), bcm2835_gpio_aren() and bcm2835_gpio_afen() now
--/ changes only the pin specified. Other pins that were already previoulsy
--/ enabled stay enabled.
--/ Added bcm2835_gpio_clr_ren(), bcm2835_gpio_clr_fen(), bcm2835_gpio_clr_hen()
--/ bcm2835_gpio_clr_len(), bcm2835_gpio_clr_aren(), bcm2835_gpio_clr_afen()
--/ to clear the enable for individual pins, suggested by <NAME>.
--/ \version 1.7 Added bcm2835_spi_transfernb to support different buffers for read and write.
--/ \version 1.8 Improvements to read barrier, as suggested by maddin.
--/ \version 1.9 Improvements contributed by mikew:
--/ I noticed that it was mallocing memory for the mmaps on /dev/mem.
--/ It's not necessary to do that, you can just mmap the file directly,
--/ so I've removed the mallocs (and frees).
--/ I've also modified delayMicroseconds() to use nanosleep() for long waits,
--/ and a busy wait on a high resolution timer for the rest. This is because
--/ I've found that calling nanosleep() takes at least 100-200 us.
--/ You need to link using '-lrt' using this version.
--/ I've added some unsigned casts to the debug prints to silence compiler
--/ warnings I was getting, fixed some typos, and changed the value of
--/ BCM2835_PAD_HYSTERESIS_ENABLED to 0x08 as per Gert van Loo's doc at
--/ http://www.scribd.com/doc/101830961/GPIO-Pads-Control2
--/ Also added a define for the passwrd value that Gert says is needed to
--/ change pad control settings.
--/ \version 1.10 Changed the names of the delay functions to bcm2835_delay()
--/ and bcm2835_delayMicroseconds() to prevent collisions with wiringPi.
--/ Macros to map delay()-> bcm2835_delay() and
--/ Macros to map delayMicroseconds()-> bcm2835_delayMicroseconds(), which
--/ can be disabled by defining BCM2835_NO_DELAY_COMPATIBILITY
--/ \version 1.11 Fixed incorrect link to download file
--/ \version 1.12 New GPIO pin definitions for RPi version 2 (which has a diffrent GPIO mapping)
--/ \version 1.13 New GPIO pin definitions for RPi version 2 plug P5
--/ Hardware base pointers are now available (after initialisation) externally as bcm2835_gpio
--/ bcm2835_pwm bcm2835_clk bcm2835_pads bcm2835_spi0.
--/ \version 1.14 Now compiles even if CLOCK_MONOTONIC_RAW is not available, uses CLOCK_MONOTONIC instead.
--/ Fixed errors in documentation of SPI divider prefquencies based on 250MHz clock.
--/ Reported by <NAME>.
--/ \version 1.15 Added bcm2835_close() to end of examples as suggested by <NAME>.
--/
--/ \author <NAME> (<EMAIL>)
-- Defines for BCM2835
--/ \defgroup constants Constants for passing to and from library functions
--/ The values here are designed to be passed to various functions in the bcm2835 library.
--/ @{
--/ This means pin HIGH, true, 3.3volts on a pin.
--/ This means pin LOW, false, 0volts on a pin.
-- Physical addresses for various peripheral register sets
--/ Base Physical Address of the BCM 2835 peripheral registers
--/ Base Physical Address of the Pads registers
--/ Base Physical Address of the Clock/timer registers
--/ Base Physical Address of the GPIO registers
--/ Base Physical Address of the SPI0 registers
--/ Base Physical Address of the PWM registers
--/ Base of the GPIO registers.
--/ Available after bcm2835_init has been called
bcm2835_gpio : access x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t; -- /usr/local/include/bcm2835.h:210
pragma Import (C, bcm2835_gpio, "bcm2835_gpio");
--/ Base of the PWM registers.
--/ Available after bcm2835_init has been called
bcm2835_pwm : access x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t; -- /usr/local/include/bcm2835.h:214
pragma Import (C, bcm2835_pwm, "bcm2835_pwm");
--/ Base of the CLK registers.
--/ Available after bcm2835_init has been called
bcm2835_clk : access x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t; -- /usr/local/include/bcm2835.h:218
pragma Import (C, bcm2835_clk, "bcm2835_clk");
--/ Base of the PADS registers.
--/ Available after bcm2835_init has been called
bcm2835_pads : access x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t; -- /usr/local/include/bcm2835.h:222
pragma Import (C, bcm2835_pads, "bcm2835_pads");
--/ Base of the SPI0 registers.
--/ Available after bcm2835_init has been called
bcm2835_spi0 : access x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t; -- /usr/local/include/bcm2835.h:226
pragma Import (C, bcm2835_spi0, "bcm2835_spi0");
--/ Size of memory page on RPi
--/ Size of memory block on RPi
-- Defines for GPIO
-- The BCM2835 has 54 GPIO pins.
-- BCM2835 data sheet, Page 90 onwards.
--/ GPIO register offsets from BCM2835_GPIO_BASE. Offsets into the GPIO Peripheral block in bytes per 6.1 Register View
--/ \brief bcm2835PortFunction
--/ Port function select modes for bcm2835_gpio_fsel()
--/< Input
--/< Output
--/< Alternate function 0
--/< Alternate function 1
--/< Alternate function 2
--/< Alternate function 3
--/< Alternate function 4
--/< Alternate function 5
--/< Function select bits mask
subtype bcm2835FunctionSelect is unsigned;
BCM2835_GPIO_FSEL_INPT : constant unsigned := 0;
BCM2835_GPIO_FSEL_OUTP : constant unsigned := 1;
BCM2835_GPIO_FSEL_ALT0 : constant unsigned := 4;
BCM2835_GPIO_FSEL_ALT1 : constant unsigned := 5;
BCM2835_GPIO_FSEL_ALT2 : constant unsigned := 6;
BCM2835_GPIO_FSEL_ALT3 : constant unsigned := 7;
BCM2835_GPIO_FSEL_ALT4 : constant unsigned := 3;
BCM2835_GPIO_FSEL_ALT5 : constant unsigned := 2;
BCM2835_GPIO_FSEL_MASK : constant unsigned :=
7; -- /usr/local/include/bcm2835.h:282
--/ \brief bcm2835PUDControl
--/ Pullup/Pulldown defines for bcm2835_gpio_pud()
--/< Off ? disable pull-up/down
--/< Enable Pull Down control
--/< Enable Pull Up control
type bcm2835PUDControl is
(BCM2835_GPIO_PUD_OFF, BCM2835_GPIO_PUD_DOWN, BCM2835_GPIO_PUD_UP);
pragma Convention
(C, bcm2835PUDControl); -- /usr/local/include/bcm2835.h:291
--/ Pad control register offsets from BCM2835_GPIO_PADS
--/ Pad Control masks
--/ \brief bcm2835PadGroup
--/ Pad group specification for bcm2835_gpio_pad()
--/< Pad group for GPIO pads 0 to 27
--/< Pad group for GPIO pads 28 to 45
--/< Pad group for GPIO pads 46 to 53
type bcm2835PadGroup is
(BCM2835_PAD_GROUP_GPIO_0_27, BCM2835_PAD_GROUP_GPIO_28_45,
BCM2835_PAD_GROUP_GPIO_46_53);
pragma Convention (C, bcm2835PadGroup); -- /usr/local/include/bcm2835.h:318
--/ \brief GPIO Pin Numbers
--/
--/ Here we define Raspberry Pin GPIO pins on P1 in terms of the underlying BCM GPIO pin numbers.
--/ These can be passed as a pin number to any function requiring a pin.
--/ Not all pins on the RPi 26 bin IDE plug are connected to GPIO pins
--/ and some can adopt an alternate function.
--/ RPi version 2 has some slightly different pinouts, and these are values RPI_V2_*.
--/ At bootup, pins 8 and 10 are set to UART0_TXD, UART0_RXD (ie the alt0 function) respectively
--/ When SPI0 is in use (ie after bcm2835_spi_begin()), pins 19, 21, 23, 24, 26 are dedicated to SPI
--/ and cant be controlled independently
--/< Version 1, Pin P1-03
--/< Version 1, Pin P1-05
--/< Version 1, Pin P1-07
--/< Version 1, Pin P1-08, defaults to alt function 0 UART0_TXD
--/< Version 1, Pin P1-10, defaults to alt function 0 UART0_RXD
--/< Version 1, Pin P1-11
--/< Version 1, Pin P1-12
--/< Version 1, Pin P1-13
--/< Version 1, Pin P1-15
--/< Version 1, Pin P1-16
--/< Version 1, Pin P1-18
--/< Version 1, Pin P1-19, MOSI when SPI0 in use
--/< Version 1, Pin P1-21, MISO when SPI0 in use
--/< Version 1, Pin P1-22
--/< Version 1, Pin P1-23, CLK when SPI0 in use
--/< Version 1, Pin P1-24, CE0 when SPI0 in use
--/< Version 1, Pin P1-26, CE1 when SPI0 in use
-- RPi Version 2
--/< Version 2, Pin P1-03
--/< Version 2, Pin P1-05
--/< Version 2, Pin P1-07
--/< Version 2, Pin P1-08, defaults to alt function 0 UART0_TXD
--/< Version 2, Pin P1-10, defaults to alt function 0 UART0_RXD
--/< Version 2, Pin P1-11
--/< Version 2, Pin P1-12
--/< Version 2, Pin P1-13
--/< Version 2, Pin P1-15
--/< Version 2, Pin P1-16
--/< Version 2, Pin P1-18
--/< Version 2, Pin P1-19, MOSI when SPI0 in use
--/< Version 2, Pin P1-21, MISO when SPI0 in use
--/< Version 2, Pin P1-22
--/< Version 2, Pin P1-23, CLK when SPI0 in use
--/< Version 2, Pin P1-24, CE0 when SPI0 in use
--/< Version 2, Pin P1-26, CE1 when SPI0 in use
-- RPi Version 2, new plug P5
--/< Version 2, Pin P5-03
--/< Version 2, Pin P5-04
--/< Version 2, Pin P5-05
--/< Version 2, Pin P5-06
subtype RPiGPIOPin is unsigned;
RPI_GPIO_P1_03 : constant unsigned := 0;
RPI_GPIO_P1_05 : constant unsigned := 1;
RPI_GPIO_P1_07 : constant unsigned := 4;
RPI_GPIO_P1_08 : constant unsigned := 14;
RPI_GPIO_P1_10 : constant unsigned := 15;
RPI_GPIO_P1_11 : constant unsigned := 17;
RPI_GPIO_P1_12 : constant unsigned := 18;
RPI_GPIO_P1_13 : constant unsigned := 21;
RPI_GPIO_P1_15 : constant unsigned := 22;
RPI_GPIO_P1_16 : constant unsigned := 23;
RPI_GPIO_P1_18 : constant unsigned := 24;
RPI_GPIO_P1_19 : constant unsigned := 10;
RPI_GPIO_P1_21 : constant unsigned := 9;
RPI_GPIO_P1_22 : constant unsigned := 25;
RPI_GPIO_P1_23 : constant unsigned := 11;
RPI_GPIO_P1_24 : constant unsigned := 8;
RPI_GPIO_P1_26 : constant unsigned := 7;
RPI_V2_GPIO_P1_03 : constant unsigned := 2;
RPI_V2_GPIO_P1_05 : constant unsigned := 3;
RPI_V2_GPIO_P1_07 : constant unsigned := 4;
RPI_V2_GPIO_P1_08 : constant unsigned := 14;
RPI_V2_GPIO_P1_10 : constant unsigned := 15;
RPI_V2_GPIO_P1_11 : constant unsigned := 17;
RPI_V2_GPIO_P1_12 : constant unsigned := 18;
RPI_V2_GPIO_P1_13 : constant unsigned := 27;
RPI_V2_GPIO_P1_15 : constant unsigned := 22;
RPI_V2_GPIO_P1_16 : constant unsigned := 23;
RPI_V2_GPIO_P1_18 : constant unsigned := 24;
RPI_V2_GPIO_P1_19 : constant unsigned := 10;
RPI_V2_GPIO_P1_21 : constant unsigned := 9;
RPI_V2_GPIO_P1_22 : constant unsigned := 25;
RPI_V2_GPIO_P1_23 : constant unsigned := 11;
RPI_V2_GPIO_P1_24 : constant unsigned := 8;
RPI_V2_GPIO_P1_26 : constant unsigned := 7;
RPI_V2_GPIO_P5_03 : constant unsigned := 28;
RPI_V2_GPIO_P5_04 : constant unsigned := 29;
RPI_V2_GPIO_P5_05 : constant unsigned := 30;
RPI_V2_GPIO_P5_06 : constant unsigned :=
31; -- /usr/local/include/bcm2835.h:375
-- Defines for SPI
-- GPIO register offsets from BCM2835_SPI0_BASE. Offsets into the SPI
-- Peripheral block in bytes per 10.5 SPI Register Map Register masks
-- for SPI0_CS
--/ \brief bcm2835SPIBitOrder SPI Bit order
--/ Specifies the SPI data bit ordering for bcm2835_spi_setBitOrder()
--/< LSB First
--/< MSB First
type bcm2835SPIBitOrder is
(BCM2835_SPI_BIT_ORDER_LSBFIRST, BCM2835_SPI_BIT_ORDER_MSBFIRST);
pragma Convention
(C, bcm2835SPIBitOrder); -- /usr/local/include/bcm2835.h:421
--/ \brief SPI Data mode
--/ Specify the SPI data mode to be passed to bcm2835_spi_setDataMode()
--/< CPOL = 0, CPHA = 0
--/< CPOL = 0, CPHA = 1
--/< CPOL = 1, CPHA = 0
--/< CPOL = 1, CPHA = 1
type bcm2835SPIMode is
(BCM2835_SPI_MODE0, BCM2835_SPI_MODE1, BCM2835_SPI_MODE2,
BCM2835_SPI_MODE3);
pragma Convention (C, bcm2835SPIMode); -- /usr/local/include/bcm2835.h:431
--/ \brief bcm2835SPIChipSelect
--/ Specify the SPI chip select pin(s)
--/< Chip Select 0
--/< Chip Select 1
--/< Chip Select 2 (ie pins CS1 and CS2 are asserted)
--/< No CS, control it yourself
type bcm2835SPIChipSelect is
(BCM2835_SPI_CS0, BCM2835_SPI_CS1, BCM2835_SPI_CS2, BCM2835_SPI_CS_NONE);
pragma Convention
(C, bcm2835SPIChipSelect); -- /usr/local/include/bcm2835.h:441
--/ \brief bcm2835SPIClockDivider
--/ Specifies the divider used to generate the SPI clock from the system clock.
--/ Figures below give the divider, clock period and clock frequency.
--/ Clock divided is based on nominal base clock rate of 250MHz
--/ It is reported that (contrary to the documentation) any even divider may used.
--/ The frequencies shown for each divider have been confirmed by measurement
--/< 65536 = 262.144us = 3.814697260kHz
--/< 32768 = 131.072us = 7.629394531kHz
--/< 16384 = 65.536us = 15.25878906kHz
--/< 8192 = 32.768us = 30/51757813kHz
--/< 4096 = 16.384us = 61.03515625kHz
--/< 2048 = 8.192us = 122.0703125kHz
--/< 1024 = 4.096us = 244.140625kHz
--/< 512 = 2.048us = 488.28125kHz
--/< 256 = 1.024us = 976.5625MHz
--/< 128 = 512ns = = 1.953125MHz
--/< 64 = 256ns = 3.90625MHz
--/< 32 = 128ns = 7.8125MHz
--/< 16 = 64ns = 15.625MHz
--/< 8 = 32ns = 31.25MHz
--/< 4 = 16ns = 62.5MHz
--/< 2 = 8ns = 125MHz, fastest you can get
--/< 0 = 262.144us = 3.814697260kHz, same as 0/65536
subtype bcm2835SPIClockDivider is unsigned;
BCM2835_SPI_CLOCK_DIVIDER_65536 : constant unsigned := 0;
BCM2835_SPI_CLOCK_DIVIDER_32768 : constant unsigned := 32_768;
BCM2835_SPI_CLOCK_DIVIDER_16384 : constant unsigned := 16_384;
BCM2835_SPI_CLOCK_DIVIDER_8192 : constant unsigned := 8_192;
BCM2835_SPI_CLOCK_DIVIDER_4096 : constant unsigned := 4_096;
BCM2835_SPI_CLOCK_DIVIDER_2048 : constant unsigned := 2_048;
BCM2835_SPI_CLOCK_DIVIDER_1024 : constant unsigned := 1_024;
BCM2835_SPI_CLOCK_DIVIDER_512 : constant unsigned := 512;
BCM2835_SPI_CLOCK_DIVIDER_256 : constant unsigned := 256;
BCM2835_SPI_CLOCK_DIVIDER_128 : constant unsigned := 128;
BCM2835_SPI_CLOCK_DIVIDER_64 : constant unsigned := 64;
BCM2835_SPI_CLOCK_DIVIDER_32 : constant unsigned := 32;
BCM2835_SPI_CLOCK_DIVIDER_16 : constant unsigned := 16;
BCM2835_SPI_CLOCK_DIVIDER_8 : constant unsigned := 8;
BCM2835_SPI_CLOCK_DIVIDER_4 : constant unsigned := 4;
BCM2835_SPI_CLOCK_DIVIDER_2 : constant unsigned := 2;
BCM2835_SPI_CLOCK_DIVIDER_1 : constant unsigned :=
1; -- /usr/local/include/bcm2835.h:468
--/ @}
-- Defines for PWM
-- Historical name compatibility
--/ \defgroup init Library initialisation and management
--/ These functions allow you to intialise and control the bcm2835 library
--/ @{
--/ Initialise the library by opening /dev/mem and getting pointers to the
--/ internal memory for BCM 2835 device registers. You must call this (successfully)
--/ before calling any other
--/ functions in this library (except bcm2835_set_debug).
--/ If bcm2835_init() fails by returning 0,
--/ calling any other function may result in crashes or other failures.
--/ Prints messages to stderr in case of errors.
--/ \return 1 if successful else 0
function bcm2835_init return int; -- /usr/local/include/bcm2835.h:523
pragma Import (C, bcm2835_init, "bcm2835_init");
--/ Close the library, deallocating any allocated memory and closing /dev/mem
--/ \return 1 if successful else 0
function bcm2835_close return int; -- /usr/local/include/bcm2835.h:527
pragma Import (C, bcm2835_close, "bcm2835_close");
--/ Sets the debug level of the library.
--/ A value of 1 prevents mapping to /dev/mem, and makes the library print out
--/ what it would do, rather than accessing the GPIO registers.
--/ A value of 0, the default, causes normal operation.
--/ Call this before calling bcm2835_init();
--/ \param[in] debug The new debug level. 1 means debug
procedure bcm2835_set_debug
(debug : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:535
pragma Import (C, bcm2835_set_debug, "bcm2835_set_debug");
--/ @} // end of init
--/ \defgroup lowlevel Low level register access
--/ These functions provide low level register access, and should not generally
--/ need to be used
--/
--/ @{
--/ Reads 32 bit value from a peripheral address
--/ The read is done twice, and is therefore always safe in terms of
--/ manual section 1.3 Peripheral access precautions for correct memory ordering
--/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
--/ \return the value read from the 32 bit register
--/ \sa Physical Addresses
function bcm2835_peri_read
(paddr : access x86_64_linux_gnu_bits_stdint_uintn_h.uint32_t)
return x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t; -- /usr/local/include/bcm2835.h:551
pragma Import (C, bcm2835_peri_read, "bcm2835_peri_read");
--/ Reads 32 bit value from a peripheral address without the read barrier
--/ You should only use this when your code has previously called bcm2835_peri_read()
--/ within the same peripheral, and no other peripheral access has occurred since.
--/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
--/ \return the value read from the 32 bit register
--/ \sa Physical Addresses
function bcm2835_peri_read_nb
(paddr : access x86_64_linux_gnu_bits_stdint_uintn_h.uint32_t)
return x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t; -- /usr/local/include/bcm2835.h:560
pragma Import (C, bcm2835_peri_read_nb, "bcm2835_peri_read_nb");
--/ Writes 32 bit value from a peripheral address
--/ The write is done twice, and is therefore always safe in terms of
--/ manual section 1.3 Peripheral access precautions for correct memory ordering
--/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
--/ \param[in] value The 32 bit value to write
--/ \sa Physical Addresses
procedure bcm2835_peri_write
(paddr : access x86_64_linux_gnu_bits_stdint_uintn_h.uint32_t;
value : x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t); -- /usr/local/include/bcm2835.h:569
pragma Import (C, bcm2835_peri_write, "bcm2835_peri_write");
--/ Writes 32 bit value from a peripheral address without the write barrier
--/ You should only use this when your code has previously called bcm2835_peri_write()
--/ within the same peripheral, and no other peripheral access has occurred since.
--/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
--/ \param[in] value The 32 bit value to write
--/ \sa Physical Addresses
procedure bcm2835_peri_write_nb
(paddr : access x86_64_linux_gnu_bits_stdint_uintn_h.uint32_t;
value : x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t); -- /usr/local/include/bcm2835.h:577
pragma Import (C, bcm2835_peri_write_nb, "bcm2835_peri_write_nb");
--/ Alters a number of bits in a 32 peripheral regsiter.
--/ It reads the current valu and then alters the bits deines as 1 in mask,
--/ according to the bit value in value.
--/ All other bits that are 0 in the mask are unaffected.
--/ Use this to alter a subset of the bits in a register.
--/ The write is done twice, and is therefore always safe in terms of
--/ manual section 1.3 Peripheral access precautions for correct memory ordering
--/ \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc.
--/ \param[in] value The 32 bit value to write, masked in by mask.
--/ \param[in] mask Bitmask that defines the bits that will be altered in the register.
--/ \sa Physical Addresses
procedure bcm2835_peri_set_bits
(paddr : access x86_64_linux_gnu_bits_stdint_uintn_h.uint32_t;
value : x86_64_linux_gnu_bits_stdint_uintn_h.uint32_t;
mask : x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t); -- /usr/local/include/bcm2835.h:590
pragma Import (C, bcm2835_peri_set_bits, "bcm2835_peri_set_bits");
--/ @} // end of lowlevel
--/ \defgroup gpio GPIO register access
--/ These functions allow you to control the GPIO interface. You can set the
--/ function of each GPIO pin, read the input state and set the output state.
--/ @{
--/ Sets the Function Select register for the given pin, which configures
--/ the pin as Input, Output or one of the 6 alternate functions.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from RPiGPIOPin.
--/ \param[in] mode Mode to set the pin to, one of BCM2835_GPIO_FSEL_* from \ref bcm2835FunctionSelect
procedure bcm2835_gpio_fsel
(pin : x86_64_linux_gnu_bits_stdint_uintn_h.uint8_t;
mode : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:602
pragma Import (C, bcm2835_gpio_fsel, "bcm2835_gpio_fsel");
--/ Sets the specified pin output to
--/ HIGH.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
--/ \sa bcm2835_gpio_write()
procedure bcm2835_gpio_set
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:608
pragma Import (C, bcm2835_gpio_set, "bcm2835_gpio_set");
--/ Sets the specified pin output to
--/ LOW.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
--/ \sa bcm2835_gpio_write()
procedure bcm2835_gpio_clr
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:614
pragma Import (C, bcm2835_gpio_clr, "bcm2835_gpio_clr");
--/ Reads the current level on the specified
--/ pin and returns either HIGH or LOW. Works whether or not the pin
--/ is an input or an output.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
--/ \return the current level either HIGH or LOW
function bcm2835_gpio_lev
(pin : x86_64_linux_gnu_bits_stdint_uintn_h.uint8_t)
return x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t; -- /usr/local/include/bcm2835.h:621
pragma Import (C, bcm2835_gpio_lev, "bcm2835_gpio_lev");
--/ Event Detect Status.
--/ Tests whether the specified pin has detected a level or edge
--/ as requested by bcm2835_gpio_ren(), bcm2835_gpio_fen(), bcm2835_gpio_hen(),
--/ bcm2835_gpio_len(), bcm2835_gpio_aren(), bcm2835_gpio_afen().
--/ Clear the flag for a given pin by calling bcm2835_gpio_set_eds(pin);
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
--/ \return HIGH if the event detect status for th given pin is true.
function bcm2835_gpio_eds
(pin : x86_64_linux_gnu_bits_stdint_uintn_h.uint8_t)
return x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t; -- /usr/local/include/bcm2835.h:630
pragma Import (C, bcm2835_gpio_eds, "bcm2835_gpio_eds");
--/ Sets the Event Detect Status register for a given pin to 1,
--/ which has the effect of clearing the flag. Use this afer seeing
--/ an Event Detect Status on the pin.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_set_eds
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:636
pragma Import (C, bcm2835_gpio_set_eds, "bcm2835_gpio_set_eds");
--/ Enable Rising Edge Detect Enable for the specified pin.
--/ When a rising edge is detected, sets the appropriate pin in Event Detect Status.
--/ The GPRENn registers use
--/ synchronous edge detection. This means the input signal is sampled using the
--/ system clock and then it is looking for a ?011? pattern on the sampled signal. This
--/ has the effect of suppressing glitches.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_ren
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:645
pragma Import (C, bcm2835_gpio_ren, "bcm2835_gpio_ren");
--/ Disable Rising Edge Detect Enable for the specified pin.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_clr_ren
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:649
pragma Import (C, bcm2835_gpio_clr_ren, "bcm2835_gpio_clr_ren");
--/ Enable Falling Edge Detect Enable for the specified pin.
--/ When a falling edge is detected, sets the appropriate pin in Event Detect Status.
--/ The GPRENn registers use
--/ synchronous edge detection. This means the input signal is sampled using the
--/ system clock and then it is looking for a ?100? pattern on the sampled signal. This
--/ has the effect of suppressing glitches.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_fen
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:658
pragma Import (C, bcm2835_gpio_fen, "bcm2835_gpio_fen");
--/ Disable Falling Edge Detect Enable for the specified pin.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_clr_fen
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:662
pragma Import (C, bcm2835_gpio_clr_fen, "bcm2835_gpio_clr_fen");
--/ Enable High Detect Enable for the specified pin.
--/ When a HIGH level is detected on the pin, sets the appropriate pin in Event Detect Status.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_hen
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:667
pragma Import (C, bcm2835_gpio_hen, "bcm2835_gpio_hen");
--/ Disable High Detect Enable for the specified pin.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_clr_hen
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:671
pragma Import (C, bcm2835_gpio_clr_hen, "bcm2835_gpio_clr_hen");
--/ Enable Low Detect Enable for the specified pin.
--/ When a LOW level is detected on the pin, sets the appropriate pin in Event Detect Status.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_len
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:676
pragma Import (C, bcm2835_gpio_len, "bcm2835_gpio_len");
--/ Disable Low Detect Enable for the specified pin.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_clr_len
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:680
pragma Import (C, bcm2835_gpio_clr_len, "bcm2835_gpio_clr_len");
--/ Enable Asynchronous Rising Edge Detect Enable for the specified pin.
--/ When a rising edge is detected, sets the appropriate pin in Event Detect Status.
--/ Asynchronous means the incoming signal is not sampled by the system clock. As such
--/ rising edges of very short duration can be detected.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_aren
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:687
pragma Import (C, bcm2835_gpio_aren, "bcm2835_gpio_aren");
--/ Disable Asynchronous Rising Edge Detect Enable for the specified pin.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_clr_aren
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:691
pragma Import (C, bcm2835_gpio_clr_aren, "bcm2835_gpio_clr_aren");
--/ Enable Asynchronous Falling Edge Detect Enable for the specified pin.
--/ When a falling edge is detected, sets the appropriate pin in Event Detect Status.
--/ Asynchronous means the incoming signal is not sampled by the system clock. As such
--/ falling edges of very short duration can be detected.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_afen
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:698
pragma Import (C, bcm2835_gpio_afen, "bcm2835_gpio_afen");
--/ Disable Asynchronous Falling Edge Detect Enable for the specified pin.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
procedure bcm2835_gpio_clr_afen
(pin : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:702
pragma Import (C, bcm2835_gpio_clr_afen, "bcm2835_gpio_clr_afen");
--/ Sets the Pull-up/down register for the given pin. This is
--/ used with bcm2835_gpio_pudclk() to set the Pull-up/down resistor for the given pin.
--/ However, it is usually more convenient to use bcm2835_gpio_set_pud().
--/ \param[in] pud The desired Pull-up/down mode. One of BCM2835_GPIO_PUD_* from bcm2835PUDControl
--/ \sa bcm2835_gpio_set_pud()
procedure bcm2835_gpio_pud
(pud : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:709
pragma Import (C, bcm2835_gpio_pud, "bcm2835_gpio_pud");
--/ Clocks the Pull-up/down value set earlier by bcm2835_gpio_pud() into the pin.
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
--/ \param[in] on HIGH to clock the value from bcm2835_gpio_pud() into the pin.
--/ LOW to remove the clock.
--/ \sa bcm2835_gpio_set_pud()
procedure bcm2835_gpio_pudclk
(pin : x86_64_linux_gnu_bits_stdint_uintn_h.uint8_t;
on : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:716
pragma Import (C, bcm2835_gpio_pudclk, "bcm2835_gpio_pudclk");
--/ Reads and returns the Pad Control for the given GPIO group.
--/ \param[in] group The GPIO pad group number, one of BCM2835_PAD_GROUP_GPIO_*
--/ \return Mask of bits from BCM2835_PAD_* from \ref bcm2835PadGroup
function bcm2835_gpio_pad
(group : x86_64_linux_gnu_bits_stdint_uintn_h.uint8_t)
return x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t; -- /usr/local/include/bcm2835.h:721
pragma Import (C, bcm2835_gpio_pad, "bcm2835_gpio_pad");
--/ Sets the Pad Control for the given GPIO group.
--/ \param[in] group The GPIO pad group number, one of BCM2835_PAD_GROUP_GPIO_*
--/ \param[in] control Mask of bits from BCM2835_PAD_* from \ref bcm2835PadGroup
procedure bcm2835_gpio_set_pad
(group : x86_64_linux_gnu_bits_stdint_uintn_h.uint8_t;
control : x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t); -- /usr/local/include/bcm2835.h:726
pragma Import (C, bcm2835_gpio_set_pad, "bcm2835_gpio_set_pad");
--/ Delays for the specified number of milliseconds.
--/ Uses nanosleep(), and therefore does not use CPU until the time is up.
--/ \param[in] millis Delay in milliseconds
procedure bcm2835_delay
(millis : unsigned); -- /usr/local/include/bcm2835.h:731
pragma Import (C, bcm2835_delay, "bcm2835_delay");
--/ Delays for the specified number of microseconds.
--/ Uses nanosleep(), and therefore does not use CPU until the time is up.
--/ However, you are at the mercy of nanosleep(). From the manual for nanosleep:
--/ If the interval specified in req is not an exact multiple of the granularity
--/ underlying clock (see time(7)), then the interval will be
--/ rounded up to the next multiple. Furthermore, after the sleep com-
--/ pletes, there may still be a delay before the CPU becomes free to once
--/ again execute the calling thread.
--/ For times less than about 450 microseconds, uses a busy wait on a high resolution timer.
--/ It is reported that a delay of 0 microseconds on RaspberryPi will in fact
--/ result in a dleay of about 80 microseconds. Your mileage may vary.
--/ \param[in] micros Delay in microseconds
procedure bcm2835_delayMicroseconds
(micros : unsigned); -- /usr/local/include/bcm2835.h:745
pragma Import (C, bcm2835_delayMicroseconds, "bcm2835_delayMicroseconds");
--/ Sets the output state of the specified pin
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
--/ \param[in] on HIGH sets the output to HIGH and LOW to LOW.
procedure bcm2835_gpio_write
(pin : x86_64_linux_gnu_bits_stdint_uintn_h.uint8_t;
on : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:750
pragma Import (C, bcm2835_gpio_write, "bcm2835_gpio_write");
--/ Sets the Pull-up/down mode for the specified pin. This is more convenient than
--/ clocking the mode in with bcm2835_gpio_pud() and bcm2835_gpio_pudclk().
--/ \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin.
--/ \param[in] pud The desired Pull-up/down mode. One of BCM2835_GPIO_PUD_* from bcm2835PUDControl
procedure bcm2835_gpio_set_pud
(pin : x86_64_linux_gnu_bits_stdint_uintn_h.uint8_t;
pud : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:756
pragma Import (C, bcm2835_gpio_set_pud, "bcm2835_gpio_set_pud");
--/ @}
--/ \defgroup spi SPI access
--/ These functions let you use SPI0 (Serial Peripheral Interface) to
--/ interface with an external SPI device.
--/ @{
--/ Start SPI operations.
--/ Forces RPi SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1)
--/ to alternate function ALT0, which enables those pins for SPI interface.
--/ You should call bcm2835_spi_end() when all SPI funcitons are complete to return the pins to
--/ their default functions
--/ \sa bcm2835_spi_end()
procedure bcm2835_spi_begin; -- /usr/local/include/bcm2835.h:771
pragma Import (C, bcm2835_spi_begin, "bcm2835_spi_begin");
--/ End SPI operations.
--/ SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1)
--/ are returned to their default INPUT behaviour.
procedure bcm2835_spi_end; -- /usr/local/include/bcm2835.h:776
pragma Import (C, bcm2835_spi_end, "bcm2835_spi_end");
--/ Sets the SPI bit order
--/ NOTE: has no effect. Not supported by SPI0.
--/ Defaults to
--/ \param[in] order The desired bit order, one of BCM2835_SPI_BIT_ORDER_*,
--/ see \ref bcm2835SPIBitOrder
procedure bcm2835_spi_setBitOrder
(order : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:783
pragma Import (C, bcm2835_spi_setBitOrder, "bcm2835_spi_setBitOrder");
--/ Sets the SPI clock divider and therefore the
--/ SPI clock speed.
--/ \param[in] divider The desired SPI clock divider, one of BCM2835_SPI_CLOCK_DIVIDER_*,
--/ see \ref bcm2835SPIClockDivider
procedure bcm2835_spi_setClockDivider
(divider : x86_64_linux_gnu_bits_stdint_uintn_h
.uint16_t); -- /usr/local/include/bcm2835.h:789
pragma Import
(C, bcm2835_spi_setClockDivider, "bcm2835_spi_setClockDivider");
--/ Sets the SPI data mode
--/ Sets the clock polariy and phase
--/ \param[in] mode The desired data mode, one of BCM2835_SPI_MODE*,
--/ see \ref bcm2835SPIMode
procedure bcm2835_spi_setDataMode
(mode : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:795
pragma Import (C, bcm2835_spi_setDataMode, "bcm2835_spi_setDataMode");
--/ Sets the chip select pin(s)
--/ When an bcm2835_spi_transfer() is made, the selected pin(s) will be asserted during the
--/ transfer.
--/ \param[in] cs Specifies the CS pins(s) that are used to activate the desired slave.
--/ One of BCM2835_SPI_CS*, see \ref bcm2835SPIChipSelect
procedure bcm2835_spi_chipSelect
(cs : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:802
pragma Import (C, bcm2835_spi_chipSelect, "bcm2835_spi_chipSelect");
--/ Sets the chip select pin polarity for a given pin
--/ When an bcm2835_spi_transfer() occurs, the currently selected chip select pin(s)
--/ will be asserted to the
--/ value given by active. When transfers are not happening, the chip select pin(s)
--/ return to the complement (inactive) value.
--/ \param[in] cs The chip select pin to affect
--/ \param[in] active Whether the chip select pin is to be active HIGH
procedure bcm2835_spi_setChipSelectPolarity
(cs : x86_64_linux_gnu_bits_stdint_uintn_h.uint8_t;
active : x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t); -- /usr/local/include/bcm2835.h:811
pragma Import
(C, bcm2835_spi_setChipSelectPolarity,
"bcm2835_spi_setChipSelectPolarity");
--/ Transfers one byte to and from the currently selected SPI slave.
--/ Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect)
--/ during the transfer.
--/ Clocks the 8 bit value out on MOSI, and simultaneously clocks in data from MISO.
--/ Returns the read data byte from the slave.
--/ Uses polled transfer as per section 10.6.1 of the BCM 2835 ARM Peripherls manual
--/ \param[in] value The 8 bit data byte to write to MOSI
--/ \return The 8 bit byte simultaneously read from MISO
--/ \sa bcm2835_spi_transfern()
function bcm2835_spi_transfer
(value : x86_64_linux_gnu_bits_stdint_uintn_h.uint8_t)
return x86_64_linux_gnu_bits_stdint_uintn_h
.uint8_t; -- /usr/local/include/bcm2835.h:822
pragma Import (C, bcm2835_spi_transfer, "bcm2835_spi_transfer");
--/ Transfers any number of bytes to and from the currently selected SPI slave.
--/ Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect)
--/ during the transfer.
--/ Clocks the len 8 bit bytes out on MOSI, and simultaneously clocks in data from MISO.
--/ The data read read from the slave is placed into rbuf. rbuf must be at least len bytes long
--/ Uses polled transfer as per section 10.6.1 of the BCM 2835 ARM Peripherls manual
--/ \param[in] tbuf Buffer of bytes to send.
--/ \param[out] rbuf Received bytes will by put in this buffer
--/ \param[in] len Number of bytes in the tbuf buffer, and the number of bytes to send/received
--/ \sa bcm2835_spi_transfer()
procedure bcm2835_spi_transfernb
(tbuf : Interfaces.C.Strings.chars_ptr;
rbuf : Interfaces.C.Strings.chars_ptr;
len : x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t); -- /usr/local/include/bcm2835.h:834
pragma Import (C, bcm2835_spi_transfernb, "bcm2835_spi_transfernb");
--/ Transfers any number of bytes to and from the currently selected SPI slave
--/ using bcm2835_spi_transfernb.
--/ The returned data from the slave replaces the transmitted data in the buffer.
--/ \param[in,out] buf Buffer of bytes to send. Received bytes will replace the contents
--/ \param[in] len Number of bytes int eh buffer, and the number of bytes to send/received
--/ \sa bcm2835_spi_transfer()
procedure bcm2835_spi_transfern
(buf : Interfaces.C.Strings.chars_ptr;
len : x86_64_linux_gnu_bits_stdint_uintn_h
.uint32_t); -- /usr/local/include/bcm2835.h:842
pragma Import (C, bcm2835_spi_transfern, "bcm2835_spi_transfern");
--/ @}
--/ @example blink.c
--/ Blinks RPi GPIO pin 11 on and off
--/ @example input.c
--/ Reads the state of an RPi input pin
--/ @example event.c
--/ Shows how to use event detection on an input pin
--/ @example spi.c
--/ Shows how to use SPI interface to transfer a byte to and from an SPI device
--/ @example spin.c
--/ Shows how to use SPI interface to transfer a number of bytes to and from an SPI device
end bcm2835_h;
|
programs/oeis/004/A004522.asm | karttu/loda | 0 | 25811 | ; A004522: Generalized nim sum n + n in base 12.
; 0,2,4,6,8,10,0,2,4,6,8,10,24,26,28,30,32,34,24,26,28,30,32,34,48,50,52,54,56,58,48,50,52,54,56,58,72,74,76,78,80,82,72,74,76,78,80,82,96,98,100,102,104,106,96,98,100
mov $1,$0
div $0,6
mod $0,2
mul $0,6
add $1,1
mov $2,3
lpb $0,1
mov $0,4
sub $1,$2
sub $1,3
lpe
sub $1,1
mul $1,2
|
src/templates/ada/utilities.ads | joffreyhuguet/LmcpGen | 6 | 1827 | <reponame>joffreyhuguet/LmcpGen
package Utilities is
generic
Width: Positive;
function LeftPad (Str : String; Level : Natural) return String;
end Utilities; |
oeis/234/A234513.asm | neoneye/loda-programs | 11 | 175717 | ; A234513: 8*binomial(9*n+8,n)/(9*n+8).
; Submitted by <NAME>
; 1,8,100,1496,24682,433160,7932196,149846840,2898753715,57135036024,1143315429776,23166186450680,474347963242860,9799792252101016,204022381037886400,4276098770070159096,90151561242584838605,1910564646571462338800,40678796347199656702056,869731127784443193108840,18665326056173496725538370,401945903545378918358095008,8682588675625082016612130800,188089883132880735601148579480,4085218877701036424076527204067,88942614247441762570572655688304,1940752656920197742380319829196432
sub $1,$0
mul $0,8
add $0,6
sub $1,2
bin $1,$0
add $0,1
div $1,$0
mov $0,$1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.