text stringlengths 1 1.05M |
|---|
; A207656: Number of n X 3 0..1 arrays avoiding 0 0 0 and 1 1 1 horizontally and 0 0 1 and 1 0 0 vertically.
; 6,36,84,198,474,1140,2748,6630,16002,38628,93252,225126,543498,1312116,3167724,7647558,18462834,44573220,107609268,259791750,627192762,1514177268,3655547292,8825271846,21306090978,51437453796,124180998564,299799450918,723779900394,1747359251700,4218498403788,10184356059270,24587210522322,59358777103908,143304764730132,345968306564166,835241377858458,2016451062281076,4868143502420604
lpb $0
mov $1,$0
cal $1,98586 ; a(n) = (1/2) * (5*P(n+1) + P(n) - 1), where P(k) are the Pell numbers A000129.
mov $0,0
mul $1,254
lpe
div $1,254
mul $1,6
add $1,6
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %r8
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x4423, %rax
nop
nop
sub %r8, %r8
vmovups (%rax), %ymm7
vextracti128 $0, %ymm7, %xmm7
vpextrq $0, %xmm7, %rdx
nop
nop
nop
nop
nop
xor $64268, %rax
lea addresses_D_ht+0x15873, %rdx
dec %r8
mov $0x6162636465666768, %r13
movq %r13, %xmm2
and $0xffffffffffffffc0, %rdx
vmovaps %ymm2, (%rdx)
nop
inc %rax
lea addresses_A_ht+0x7b0a, %rsi
lea addresses_A_ht+0x5a43, %rdi
nop
xor $19065, %r15
mov $90, %rcx
rep movsw
nop
xor %rdx, %rdx
lea addresses_WT_ht+0x11f43, %rsi
lea addresses_WT_ht+0x3a23, %rdi
nop
nop
nop
nop
cmp $50955, %rdx
mov $58, %rcx
rep movsw
inc %r8
lea addresses_D_ht+0x5d23, %rsi
lea addresses_A_ht+0x1d093, %rdi
nop
nop
and $40204, %r15
mov $87, %rcx
rep movsb
nop
add $48833, %r13
lea addresses_normal_ht+0x1c1a3, %rdi
nop
nop
add $60307, %r8
and $0xffffffffffffffc0, %rdi
movntdqa (%rdi), %xmm6
vpextrq $0, %xmm6, %rcx
nop
nop
nop
sub %rdi, %rdi
lea addresses_WT_ht+0x55c7, %r8
nop
nop
nop
nop
cmp $35500, %rdx
mov $0x6162636465666768, %rax
movq %rax, %xmm1
movups %xmm1, (%r8)
nop
nop
nop
nop
nop
dec %rax
lea addresses_WT_ht+0x11d23, %r13
xor $38058, %r8
mov (%r13), %rdx
nop
nop
nop
nop
nop
and $48076, %rsi
lea addresses_A_ht+0xc323, %r8
cmp $7558, %rdx
movb (%r8), %r13b
xor $3420, %rax
lea addresses_D_ht+0x1afa3, %rsi
xor $59426, %rax
movw $0x6162, (%rsi)
nop
xor $16521, %rax
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r8
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r8
push %r9
push %rbx
push %rcx
push %rdx
// Store
lea addresses_RW+0xe923, %r9
nop
nop
xor $8698, %rcx
movw $0x5152, (%r9)
sub %r9, %r9
// Store
lea addresses_US+0x1fd23, %rdx
nop
nop
nop
nop
nop
xor %r8, %r8
mov $0x5152535455565758, %r14
movq %r14, %xmm2
vmovups %ymm2, (%rdx)
nop
add %rbx, %rbx
// Load
lea addresses_D+0xb7b3, %rcx
nop
nop
nop
nop
cmp %r9, %r9
vmovups (%rcx), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $0, %xmm6, %r14
nop
nop
dec %r14
// Store
lea addresses_A+0x11b63, %rcx
nop
inc %r12
movw $0x5152, (%rcx)
nop
nop
nop
nop
inc %r14
// Load
mov $0x7b80640000000a53, %rcx
nop
nop
dec %rdx
mov (%rcx), %r8d
nop
nop
nop
nop
and $5509, %r14
// Store
lea addresses_WC+0xbac3, %rbx
nop
nop
nop
add %r14, %r14
mov $0x5152535455565758, %r9
movq %r9, %xmm4
vmovups %ymm4, (%rbx)
nop
nop
nop
nop
nop
dec %r8
// Store
lea addresses_US+0xffa3, %r12
clflush (%r12)
nop
nop
nop
cmp %r14, %r14
mov $0x5152535455565758, %rbx
movq %rbx, (%r12)
nop
nop
nop
nop
nop
add %r8, %r8
// Store
lea addresses_PSE+0x11c23, %r8
nop
nop
nop
nop
and $55260, %r12
mov $0x5152535455565758, %rbx
movq %rbx, %xmm4
movups %xmm4, (%r8)
xor $24527, %rcx
// Faulty Load
lea addresses_normal+0x16523, %rdx
xor %r12, %r12
mov (%rdx), %rbx
lea oracles, %r8
and $0xff, %rbx
shlq $12, %rbx
mov (%r8,%rbx,1), %rbx
pop %rdx
pop %rcx
pop %rbx
pop %r9
pop %r8
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 5}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 4}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_A_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 2}}
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 7}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 6}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
; A011897: a(n) = floor(n*(n-1)*(n-2)/15).
; 0,0,0,0,1,4,8,14,22,33,48,66,88,114,145,182,224,272,326,387,456,532,616,708,809,920,1040,1170,1310,1461,1624,1798,1984,2182,2393,2618,2856,3108,3374,3655,3952,4264,4592,4936,5297,5676,6072,6486,6918,7369,7840,8330,8840,9370,9921,10494,11088,11704,12342,13003,13688,14396,15128,15884,16665,17472,18304,19162,20046,20957,21896,22862,23856,24878,25929,27010,28120,29260,30430,31631,32864,34128,35424,36752,38113,39508,40936,42398,43894,45425,46992,48594,50232,51906,53617,55366,57152,58976,60838,62739
bin $0,3
mul $0,2
div $0,5
|
# Authors: Miriam Penger, Lena Gerken, Tina Hoeflich
# Based on CESP lecture
# Moves paddles according to keyboard inputs.
# 'w' and 's' for up/down movement of left paddle
# 'o' and 'l' for up/down movement of right paddle
# Inputs:
# a4: highest y-coordinate reached by the paddle on the left
# a6: highest y-coordinate reached by the paddle on the right
# Using:
# a3: x0 - left boundary of rectangle
# a4: y0 - top boundary of rectangle
# a5: x1 - right boundary of rectangle
# a6: y1 - bottom boundary of rectangle
# a7: fill color of rectangle as RGB value
# Returns:
# a3: highest y-coordinate reached by the paddle on the left
# a4: lowest y-coordinate reached by the paddle on the left
# a5: highest y-coordinate reached by the paddle on the right
# a6: lowest y-coordinate reached by the paddle on the right
j move_paddles
.text
move_paddles:
# allocate memory for a4 and a6 input values
addi sp, sp, -12
sw ra, 0 (sp)
sw a4, 4 (sp)
sw a6, 8 (sp)
li s0, KEYBOARD_ADDDRESS
lw a4, 4 (sp)
lw a6, 8 (sp)
lw t0, (s0)
beq t0, zero switch.end_paddles
lw t0, 4(s0)
switch.start_paddles:
# left paddle up
switch.w:
li t1, 'w'
bne t0, t1 switch.s
ble a4, zero, switch.end_paddles # won't move left paddle beyond the top screen boundaries
li t2, LEFT_PADDLE_BOUNDARY
mv a3, t2 # set left boundary
# a4 is already set through input value
li t3, PADDLE_WIDTH
add t4, t2, t3
mv a5, t4 # set right boundary
li t2, PADDLE_HEIGHT
add a6, a4, t2 # set bottom boundary
# draw white section on top
mv a6, a4
li t3, PADDLE_MOVEMENT_SPEED
sub a4, a4, t3
li a7, 0xffffff
jal draw_rectangle
# draw black section underneath
li t2, PADDLE_HEIGHT
add a4, a4, t2
add a6, a6, t2
li a7, 0x000000
jal draw_rectangle
# update initial a4 and a6 values
li t2, PADDLE_HEIGHT
sub a4, a4, t2
lw a6, 8 (sp) # stays the same as it was not moved
beq zero, zero switch.end_paddles
# left paddle down
switch.s:
li t1, 's'
bne t0, t1 switch.o
li t3, DISPLAY_HEIGHT
li t4, PADDLE_HEIGHT
sub t2, t3, t4 # subtract paddle height as only top y-coordinate is known for bottom impact collision detection
bge a4, t2, switch.end_paddles # won't move left paddle beyond the bottom screen boundaries
li t2, LEFT_PADDLE_BOUNDARY
mv a3, t2 # set left boundary
# a4 is already set through input value
li t3, PADDLE_WIDTH
add t5, t2, t3
mv a5, t5 # set right boundary
add a6, a4, t4 # set bottom boundary
# draw white section underneath
add a4, a4, t4
li t5, PADDLE_MOVEMENT_SPEED
add a6, a6, t5
li a7, 0xffffff
jal draw_rectangle
# draw black section on top
li t4, PADDLE_HEIGHT
sub a4, a4, t4
sub a6, a6, t4
li a7, 0x000000
jal draw_rectangle
# update initial a4 and a6 values
li t5, PADDLE_MOVEMENT_SPEED
add a4, a4, t5
lw a6, 8 (sp) # stays the same as it was not moved
beq zero, zero switch.end_paddles
# right paddle up
switch.o:
li t1, 'o'
bne t0, t1 switch.l
ble a6, zero, switch.end_paddles # won't move right paddle beyond the top screen boundaries
li t2, RIGHT_PADDLE_BOUNDARY
mv a3, t2 # set left boundary
mv a4, a6 # a4 is already set through input value a6
li t3, PADDLE_WIDTH
add t4, t2, t3
mv a5, t4 # set right boundary
li t2, PADDLE_HEIGHT
add a6, a4, t2 # set bottom boundary
# draw white section on top
mv a6, a4
li t3, PADDLE_MOVEMENT_SPEED
sub a4, a4, t3
li a7, 0xffffff
jal draw_rectangle
# draw black section underneath
li t2, PADDLE_HEIGHT
add a4, a4, t2
add a6, a6, t2
li a7, 0x000000
jal draw_rectangle
# update initial a4 and a6 values
li t2, PADDLE_HEIGHT
sub a6, a4, t2
lw a4, 4 (sp) # stays the same as it was not moved
beq zero, zero switch.end_paddles
# right paddle down
switch.l:
li t1, 'l'
bne t0, t1 switch.end_paddles
li t3, DISPLAY_HEIGHT
li t4, PADDLE_HEIGHT
sub t2, t3, t4 # subtract paddle height of 30 as only top y-coordinate is known for bottom impact collision detection
bge a6, t2, switch.end_paddles # won't move right paddle beyond the bottom screen boundaries
li t2, RIGHT_PADDLE_BOUNDARY
mv a3, t2 # set left boundary
mv a4, a6 # a4 is already set through input value a6
li t3, PADDLE_WIDTH
add t5, t2, t3
mv a5, t5 # set right boundary
add a6, a4, t4 # set bottom boundary
# draw white section underneath
add a4, a4, t4
li t5, PADDLE_MOVEMENT_SPEED
add a6, a6, t5
li a7, 0xffffff
jal draw_rectangle
# draw black section on top
li t4, PADDLE_HEIGHT
sub a4, a4, t4
sub a6, a6, t4
li a7, 0x000000
jal draw_rectangle
# update initial a4 and a6 values
lw a4, 4 (sp) # stays the same as it was not moved
# a6 is already correct
beq zero, zero switch.end_paddles
switch.end_paddles:
li t2, PADDLE_HEIGHT
mv a3, a4 # highest y-coordinate reached by the paddle on the left
add a4, a3, t2 # lowest y-coordinate reached by the paddle on the left
mv a5, a6 # highest y-coordinate reached by the paddle on the right
add a6, a5, t2 # lowest y-coordinate reached by the paddle on the right
lw ra, 0 (sp)
addi sp, sp, 12
ret
|
; $Id: bit_close_ei.asm,v 1.4 2016-06-16 20:23:52 dom Exp $
;
; Philips P2000 1 bit sound functions
;
; Close sound and restore interrupts
;
; Stefano Bodrato - Apr 2014
;
SECTION code_clib
PUBLIC bit_close_ei
PUBLIC _bit_close_ei
EXTERN __bit_irqstatus
.bit_close_ei
._bit_close_ei
push hl
ld hl,(__bit_irqstatus)
ex (sp),hl
pop af
ret po
ei
ret
|
; int fscanf_unlocked(FILE *stream, const char *format, ...)
SECTION code_stdio
PUBLIC _fscanf_unlocked
EXTERN asm_fscanf_unlocked
defc _fscanf_unlocked = asm_fscanf_unlocked
|
SECTION .text
GLOBAL mul_p448_solinas
mul_p448_solinas:
sub rsp, 0x4a0
mov rax, rdx; preserving value of arg2 into a new reg
mov rdx, [ rdx + 0x18 ]; saving arg2[3] in rdx.
mulx r10, r11, [ rsi + 0x0 ]; x190, x189<- arg1[0] * arg2[3]
mov rdx, [ rsi + 0x8 ]; arg1[1] to rdx
mulx rcx, r8, [ rax + 0x10 ]; x176, x175<- arg1[1] * arg2[2]
mov rdx, [ rsi + 0x10 ]; arg1[2] to rdx
mov [ rsp + 0x0 ], r15; spilling callerSaver15 to mem
mulx r9, r15, [ rax + 0x8 ]; x164, x163<- arg1[2] * arg2[1]
mov rdx, [ rsi + 0x18 ]; arg1[3] to rdx
mov [ rsp + 0x8 ], r14; spilling callerSaver14 to mem
mov [ rsp + 0x10 ], r13; spilling callerSaver13 to mem
mulx r14, r13, [ rax + 0x0 ]; x154, x153<- arg1[3] * arg2[0]
mov rdx, [ rax + 0x38 ]; arg2[7] to rdx
mov [ rsp + 0x18 ], r12; spilling callerSaver12 to mem
mov [ rsp + 0x20 ], rbp; spilling callerSaverbp to mem
mulx r12, rbp, [ rsi + 0x20 ]; x62, x61<- arg1[4] * arg2[7]
mov rdx, [ rax + 0x30 ]; arg2[6] to rdx
mov [ rsp + 0x28 ], rbx; spilling callerSaverbx to mem
mov [ rsp + 0x30 ], rdi; spilling out1 to mem
mulx rbx, rdi, [ rsi + 0x28 ]; x54, x53<- arg1[5] * arg2[6]
mov rdx, [ rsi + 0x30 ]; arg1[6] to rdx
mov [ rsp + 0x38 ], r10; spilling x190 to mem
mov [ rsp + 0x40 ], rcx; spilling x176 to mem
mulx r10, rcx, [ rax + 0x28 ]; x44, x43<- arg1[6] * arg2[5]
mov rdx, [ rax + 0x20 ]; arg2[4] to rdx
mov [ rsp + 0x48 ], r9; spilling x164 to mem
mov [ rsp + 0x50 ], r14; spilling x154 to mem
mulx r9, r14, [ rsi + 0x38 ]; x32, x31<- arg1[7] * arg2[4]
mov [ rsp + 0x58 ], r12; spilling x62 to mem
xor r12, r12
adox r14, rcx
adcx r14, rdi
setc dil; spill CF x202 to reg (rdi)
clc;
adcx r14, rbp
setc bpl; spill CF x206 to reg (rbp)
clc;
adcx r14, r13
seto r13b; spill OF x198 to reg (r13)
mov rcx, -0x3 ; moving imm to reg
inc rcx; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r14, r15
seto r15b; spill OF x214 to reg (r15)
mov rcx, -0x3 ; moving imm to reg
inc rcx; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r14, r8
seto r8b; spill OF x218 to reg (r8)
mov rcx, -0x3 ; moving imm to reg
inc rcx; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r14, r11
movzx r13, r13b
lea r10, [ r10 + r9 ]
lea r10, [ r10 + r13 ]
movzx rdi, dil
lea rbx, [ rbx + r10 ]
lea rbx, [ rbx + rdi ]
movzx rbp, bpl
lea rbx, [ rbp + rbx ]
mov rbp, [ rsp + 0x58 ]
lea rbx, [rbp+rbx]
adcx rbx, [ rsp + 0x50 ]
movzx r15, r15b
lea rbx, [ r15 + rbx ]
mov r15, [ rsp + 0x48 ]
lea rbx, [r15+rbx]
movzx r8, r8b
lea rbx, [ r8 + rbx ]
mov r8, [ rsp + 0x40 ]
lea rbx, [r8+rbx]
adox rbx, [ rsp + 0x38 ]
mov r11, r14; x225, copying x221 here, cause x221 is needed in a reg for other than x225, namely all: , x225, x226, size: 2
shrd r11, rbx, 56; x225 <- x223||x221 >> 56
mov r9, 0x38 ; moving imm to reg
bzhi r14, r14, r9; x226 <- x221 (only least 0x38 bits)
mov rdx, [ rsi + 0x0 ]; arg1[0] to rdx
mulx r13, rdi, [ rax + 0x20 ]; x188, x187<- arg1[0] * arg2[4]
mov rdx, [ rax + 0x18 ]; arg2[3] to rdx
mulx rbp, r15, [ rsi + 0x8 ]; x174, x173<- arg1[1] * arg2[3]
mov rdx, [ rax + 0x10 ]; arg2[2] to rdx
mulx r8, r10, [ rsi + 0x10 ]; x162, x161<- arg1[2] * arg2[2]
mov rdx, [ rax + 0x8 ]; arg2[1] to rdx
mulx rbx, r12, [ rsi + 0x18 ]; x152, x151<- arg1[3] * arg2[1]
mov rdx, [ rax + 0x0 ]; arg2[0] to rdx
mulx r9, rcx, [ rsi + 0x20 ]; x144, x143<- arg1[4] * arg2[0]
mov rdx, [ rsi + 0x8 ]; arg1[1] to rdx
mov [ rsp + 0x60 ], r14; spilling x226 to mem
mov [ rsp + 0x68 ], r13; spilling x188 to mem
mulx r14, r13, [ rax + 0x38 ]; x124, x123<- arg1[1] * arg2[7]
mov rdx, [ rax + 0x30 ]; arg2[6] to rdx
mov [ rsp + 0x70 ], rbp; spilling x174 to mem
mov [ rsp + 0x78 ], r8; spilling x162 to mem
mulx rbp, r8, [ rsi + 0x10 ]; x122, x121<- arg1[2] * arg2[6]
mov rdx, [ rsi + 0x18 ]; arg1[3] to rdx
mov [ rsp + 0x80 ], rbx; spilling x152 to mem
mov [ rsp + 0x88 ], r9; spilling x144 to mem
mulx rbx, r9, [ rax + 0x28 ]; x118, x117<- arg1[3] * arg2[5]
mov rdx, [ rsi + 0x20 ]; arg1[4] to rdx
mov [ rsp + 0x90 ], r14; spilling x124 to mem
mov [ rsp + 0x98 ], rbp; spilling x122 to mem
mulx r14, rbp, [ rax + 0x20 ]; x112, x111<- arg1[4] * arg2[4]
mov rdx, [ rax + 0x18 ]; arg2[3] to rdx
mov [ rsp + 0xa0 ], rbx; spilling x118 to mem
mov [ rsp + 0xa8 ], r14; spilling x112 to mem
mulx rbx, r14, [ rsi + 0x28 ]; x104, x103<- arg1[5] * arg2[3]
mov rdx, [ rsi + 0x30 ]; arg1[6] to rdx
mov [ rsp + 0xb0 ], rbx; spilling x104 to mem
mov [ rsp + 0xb8 ], r11; spilling x225 to mem
mulx rbx, r11, [ rax + 0x10 ]; x96, x95<- arg1[6] * arg2[2]
mov rdx, [ rsi + 0x38 ]; arg1[7] to rdx
mov [ rsp + 0xc0 ], rbx; spilling x96 to mem
mov [ rsp + 0xc8 ], rdi; spilling x187 to mem
mulx rbx, rdi, [ rax + 0x8 ]; x88, x87<- arg1[7] * arg2[1]
mov rdx, [ rax + 0x38 ]; arg2[7] to rdx
mov [ rsp + 0xd0 ], rbx; spilling x88 to mem
mov [ rsp + 0xd8 ], r15; spilling x173 to mem
mulx rbx, r15, [ rsi + 0x28 ]; x52, x51<- arg1[5] * arg2[7]
mov rdx, [ rsi + 0x30 ]; arg1[6] to rdx
mov [ rsp + 0xe0 ], rbx; spilling x52 to mem
mov [ rsp + 0xe8 ], r10; spilling x161 to mem
mulx rbx, r10, [ rax + 0x30 ]; x42, x41<- arg1[6] * arg2[6]
mov rdx, [ rsi + 0x38 ]; arg1[7] to rdx
mov [ rsp + 0xf0 ], rbx; spilling x42 to mem
mov [ rsp + 0xf8 ], r12; spilling x151 to mem
mulx rbx, r12, [ rax + 0x28 ]; x30, x29<- arg1[7] * arg2[5]
mov rdx, [ rax + 0x38 ]; arg2[7] to rdx
mov [ rsp + 0x100 ], rbx; spilling x30 to mem
mov [ rsp + 0x108 ], rcx; spilling x143 to mem
mulx rbx, rcx, [ rsi + 0x28 ]; x24, x23<- arg1[5] * arg2[7]
mov rdx, [ rsi + 0x30 ]; arg1[6] to rdx
mov [ rsp + 0x110 ], rbx; spilling x24 to mem
mov [ rsp + 0x118 ], r13; spilling x123 to mem
mulx rbx, r13, [ rax + 0x30 ]; x22, x21<- arg1[6] * arg2[6]
mov rdx, [ rax + 0x28 ]; arg2[5] to rdx
mov [ rsp + 0x120 ], rbx; spilling x22 to mem
mov [ rsp + 0x128 ], r8; spilling x121 to mem
mulx rbx, r8, [ rsi + 0x38 ]; x18, x17<- arg1[7] * arg2[5]
adox r8, r13
clc;
adcx r8, rcx
setc cl; spill CF x388 to reg (rcx)
clc;
adcx r8, r12
setc r12b; spill CF x392 to reg (r12)
clc;
adcx r8, r10
setc r10b; spill CF x396 to reg (r10)
clc;
adcx r8, r15
setc r15b; spill CF x400 to reg (r15)
clc;
adcx r8, rdi
setc dil; spill CF x404 to reg (rdi)
clc;
adcx r8, r11
setc r11b; spill CF x408 to reg (r11)
clc;
adcx r8, r14
setc r14b; spill CF x412 to reg (r14)
clc;
adcx r8, rbp
seto bpl; spill OF x384 to reg (rbp)
mov r13, -0x2 ; moving imm to reg
inc r13; OF<-0x0, preserve CF (debug: 6; load -2, increase it, save as -1)
adox r8, r9
seto r9b; spill OF x420 to reg (r9)
inc r13; OF<-0x0, preserve CF (debug: state 2 (y: -1, n: 0))
adox r8, [ rsp + 0x128 ]
mov byte [ rsp + 0x130 ], r9b; spilling byte x420 to mem
seto r9b; spill OF x424 to reg (r9)
mov byte [ rsp + 0x138 ], r14b; spilling byte x412 to mem
mov r14, -0x3 ; moving imm to reg
inc r14; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r8, [ rsp + 0x118 ]
setc r14b; spill CF x416 to reg (r14)
clc;
adcx r8, [ rsp + 0x108 ]
mov byte [ rsp + 0x140 ], r9b; spilling byte x424 to mem
seto r9b; spill OF x428 to reg (r9)
mov byte [ rsp + 0x148 ], r14b; spilling byte x416 to mem
mov r14, -0x3 ; moving imm to reg
inc r14; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r8, [ rsp + 0xf8 ]
seto r14b; spill OF x436 to reg (r14)
mov byte [ rsp + 0x150 ], r9b; spilling byte x428 to mem
mov r9, -0x3 ; moving imm to reg
inc r9; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r8, [ rsp + 0xe8 ]
setc r9b; spill CF x432 to reg (r9)
clc;
adcx r8, [ rsp + 0xd8 ]
mov byte [ rsp + 0x158 ], r14b; spilling byte x436 to mem
setc r14b; spill CF x444 to reg (r14)
clc;
adcx r8, [ rsp + 0xc8 ]
mov byte [ rsp + 0x160 ], r14b; spilling byte x444 to mem
setc r14b; spill CF x448 to reg (r14)
clc;
adcx r8, [ rsp + 0xb8 ]
movzx rbp, bpl
lea rbx, [ rbp + rbx ]
mov rbp, [ rsp + 0x120 ]
lea rbx, [rbp+rbx]
movzx rcx, cl
lea rbx, [ rcx + rbx ]
mov rcx, [ rsp + 0x110 ]
lea rbx, [rcx+rbx]
movzx r12, r12b
lea rbx, [ r12 + rbx ]
mov r12, [ rsp + 0x100 ]
lea rbx, [r12+rbx]
movzx r10, r10b
lea rbx, [ r10 + rbx ]
mov r10, [ rsp + 0xf0 ]
lea rbx, [r10+rbx]
movzx r15, r15b
lea rbx, [ r15 + rbx ]
mov r15, [ rsp + 0xe0 ]
lea rbx, [r15+rbx]
movzx rdi, dil
lea rbx, [ rdi + rbx ]
mov rdi, [ rsp + 0xd0 ]
lea rbx, [rdi+rbx]
movzx r11, r11b
lea rbx, [ r11 + rbx ]
mov r11, [ rsp + 0xc0 ]
lea rbx, [r11+rbx]
movzx rbp, byte [ rsp + 0x138 ]; load byte memx412 to register64
lea rbx, [ rbp + rbx ]
mov rbp, [ rsp + 0xb0 ]
lea rbx, [rbp+rbx]
movzx rcx, byte [ rsp + 0x148 ]; load byte memx416 to register64
lea rbx, [ rcx + rbx ]
mov rcx, [ rsp + 0xa8 ]
lea rbx, [rcx+rbx]
movzx r12, byte [ rsp + 0x130 ]; load byte memx420 to register64
lea rbx, [ r12 + rbx ]
mov r12, [ rsp + 0xa0 ]
lea rbx, [r12+rbx]
movzx r10, byte [ rsp + 0x140 ]; load byte memx424 to register64
lea rbx, [ r10 + rbx ]
mov r10, [ rsp + 0x98 ]
lea rbx, [r10+rbx]
movzx r15, byte [ rsp + 0x150 ]; load byte memx428 to register64
lea rbx, [ r15 + rbx ]
mov r15, [ rsp + 0x90 ]
lea rbx, [r15+rbx]
movzx r9, r9b
lea rbx, [ r9 + rbx ]
mov r9, [ rsp + 0x88 ]
lea rbx, [r9+rbx]
movzx rdi, byte [ rsp + 0x158 ]; load byte memx436 to register64
lea rbx, [ rdi + rbx ]
mov rdi, [ rsp + 0x80 ]
lea rbx, [rdi+rbx]
adox rbx, [ rsp + 0x78 ]
movzx r11, byte [ rsp + 0x160 ]; load byte memx444 to register64
lea rbx, [ r11 + rbx ]
mov r11, [ rsp + 0x70 ]
lea rbx, [r11+rbx]
movzx r14, r14b
lea rbx, [ r14 + rbx ]
mov r14, [ rsp + 0x68 ]
lea rbx, [r14+rbx]
adc rbx, 0x0
mov rdx, [ rax + 0x38 ]; arg2[7] to rdx
mulx rbp, rcx, [ rsi + 0x0 ]; x182, x181<- arg1[0] * arg2[7]
mov rdx, [ rax + 0x30 ]; arg2[6] to rdx
mulx r12, r10, [ rsi + 0x8 ]; x168, x167<- arg1[1] * arg2[6]
mov rdx, [ rax + 0x28 ]; arg2[5] to rdx
mulx r15, r9, [ rsi + 0x10 ]; x156, x155<- arg1[2] * arg2[5]
mov rdx, [ rax + 0x20 ]; arg2[4] to rdx
mulx rdi, r11, [ rsi + 0x18 ]; x146, x145<- arg1[3] * arg2[4]
mov rdx, [ rsi + 0x20 ]; arg1[4] to rdx
mulx r14, r13, [ rax + 0x18 ]; x138, x137<- arg1[4] * arg2[3]
mov rdx, [ rsi + 0x28 ]; arg1[5] to rdx
mov [ rsp + 0x168 ], rbx; spilling x561 to mem
mov [ rsp + 0x170 ], r8; spilling x559 to mem
mulx rbx, r8, [ rax + 0x10 ]; x132, x131<- arg1[5] * arg2[2]
mov rdx, [ rsi + 0x30 ]; arg1[6] to rdx
mov [ rsp + 0x178 ], rbp; spilling x182 to mem
mov [ rsp + 0x180 ], r12; spilling x168 to mem
mulx rbp, r12, [ rax + 0x8 ]; x128, x127<- arg1[6] * arg2[1]
mov rdx, [ rsi + 0x38 ]; arg1[7] to rdx
mov [ rsp + 0x188 ], r15; spilling x156 to mem
mov [ rsp + 0x190 ], rdi; spilling x146 to mem
mulx r15, rdi, [ rax + 0x0 ]; x126, x125<- arg1[7] * arg2[0]
mov rdx, [ rax + 0x38 ]; arg2[7] to rdx
mov [ rsp + 0x198 ], r14; spilling x138 to mem
mov [ rsp + 0x1a0 ], rbx; spilling x132 to mem
mulx r14, rbx, [ rsi + 0x20 ]; x106, x105<- arg1[4] * arg2[7]
mov rdx, [ rsi + 0x28 ]; arg1[5] to rdx
mov [ rsp + 0x1a8 ], rbp; spilling x128 to mem
mov [ rsp + 0x1b0 ], r15; spilling x126 to mem
mulx rbp, r15, [ rax + 0x30 ]; x98, x97<- arg1[5] * arg2[6]
mov rdx, [ rax + 0x28 ]; arg2[5] to rdx
mov [ rsp + 0x1b8 ], r14; spilling x106 to mem
mov [ rsp + 0x1c0 ], rbp; spilling x98 to mem
mulx r14, rbp, [ rsi + 0x30 ]; x90, x89<- arg1[6] * arg2[5]
mov rdx, [ rax + 0x20 ]; arg2[4] to rdx
mov [ rsp + 0x1c8 ], r14; spilling x90 to mem
mov [ rsp + 0x1d0 ], rcx; spilling x181 to mem
mulx r14, rcx, [ rsi + 0x38 ]; x82, x81<- arg1[7] * arg2[4]
test al, al
adox rcx, rbp
adcx rcx, r15
setc r15b; spill CF x232 to reg (r15)
clc;
adcx rcx, rbx
seto bl; spill OF x228 to reg (rbx)
mov rbp, -0x2 ; moving imm to reg
inc rbp; OF<-0x0, preserve CF (debug: 6; load -2, increase it, save as -1)
adox rcx, rdi
setc dil; spill CF x236 to reg (rdi)
clc;
adcx rcx, r12
seto r12b; spill OF x240 to reg (r12)
inc rbp; OF<-0x0, preserve CF (debug: state 2 (y: -1, n: 0))
adox rcx, r8
setc r8b; spill CF x244 to reg (r8)
clc;
adcx rcx, r13
seto r13b; spill OF x248 to reg (r13)
mov byte [ rsp + 0x1d8 ], r8b; spilling byte x244 to mem
mov r8, -0x3 ; moving imm to reg
inc r8; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox rcx, r11
seto r11b; spill OF x256 to reg (r11)
mov r8, -0x3 ; moving imm to reg
inc r8; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox rcx, r9
setc r9b; spill CF x252 to reg (r9)
clc;
adcx rcx, r10
setc r10b; spill CF x264 to reg (r10)
clc;
adcx rcx, [ rsp + 0x1d0 ]
movzx rbx, bl
lea r14, [ rbx + r14 ]
mov rbx, [ rsp + 0x1c8 ]
lea r14, [rbx+r14]
movzx r15, r15b
lea r14, [ r15 + r14 ]
mov r15, [ rsp + 0x1c0 ]
lea r14, [r15+r14]
movzx rdi, dil
lea r14, [ rdi + r14 ]
mov rdi, [ rsp + 0x1b8 ]
lea r14, [rdi+r14]
movzx r12, r12b
lea r14, [ r12 + r14 ]
mov r12, [ rsp + 0x1b0 ]
lea r14, [r12+r14]
movzx rbx, byte [ rsp + 0x1d8 ]; load byte memx244 to register64
lea r14, [ rbx + r14 ]
mov rbx, [ rsp + 0x1a8 ]
lea r14, [rbx+r14]
movzx r13, r13b
lea r14, [ r13 + r14 ]
mov r13, [ rsp + 0x1a0 ]
lea r14, [r13+r14]
movzx r9, r9b
lea r14, [ r9 + r14 ]
mov r9, [ rsp + 0x198 ]
lea r14, [r9+r14]
movzx r11, r11b
lea r14, [ r11 + r14 ]
mov r11, [ rsp + 0x190 ]
lea r14, [r11+r14]
adox r14, [ rsp + 0x188 ]
movzx r10, r10b
lea r14, [ r10 + r14 ]
mov r10, [ rsp + 0x180 ]
lea r14, [r10+r14]
adcx r14, [ rsp + 0x178 ]
mov r15, rcx; x562, copying x267 here, cause x267 is needed in a reg for other than x562, namely all: , x562, x563, size: 2
shrd r15, r14, 56; x562 <- x269||x267 >> 56
mov rdi, 0xffffffffffffff ; moving imm to reg
and rcx, rdi; x563 <- x267&0xffffffffffffff
mov r12, r15; x564, copying x562 here, cause x562 is needed in a reg for other than x564, namely all: , x564--x565, x569--x570, size: 2
adox r12, [ rsp + 0x170 ]
mov rbx, [ rsp + 0x168 ]; x566, copying x561 here, cause x561 is needed in a reg for other than x566, namely all: , x566, size: 1
adox rbx, rbp
mov r13, r12; x567, copying x564 here, cause x564 is needed in a reg for other than x567, namely all: , x567, x568, size: 2
shrd r13, rbx, 56; x567 <- x566||x564 >> 56
and r12, rdi; x568 <- x564&0xffffffffffffff
mov rdx, [ rax + 0x0 ]; arg2[0] to rdx
mulx r9, r11, [ rsi + 0x0 ]; x196, x195<- arg1[0] * arg2[0]
mov rdx, [ rax + 0x38 ]; arg2[7] to rdx
mulx r10, r14, [ rsi + 0x8 ]; x80, x79<- arg1[1] * arg2[7]
mov rdx, [ rax + 0x30 ]; arg2[6] to rdx
mulx rbx, rbp, [ rsi + 0x10 ]; x78, x77<- arg1[2] * arg2[6]
mov rdx, [ rsi + 0x18 ]; arg1[3] to rdx
mulx r8, rdi, [ rax + 0x28 ]; x74, x73<- arg1[3] * arg2[5]
mov rdx, [ rax + 0x20 ]; arg2[4] to rdx
mov [ rsp + 0x1e0 ], r12; spilling x568 to mem
mov [ rsp + 0x1e8 ], rcx; spilling x563 to mem
mulx r12, rcx, [ rsi + 0x20 ]; x68, x67<- arg1[4] * arg2[4]
mov rdx, [ rsi + 0x28 ]; arg1[5] to rdx
mov [ rsp + 0x1f0 ], r13; spilling x567 to mem
mov [ rsp + 0x1f8 ], r9; spilling x196 to mem
mulx r13, r9, [ rax + 0x18 ]; x60, x59<- arg1[5] * arg2[3]
mov rdx, [ rax + 0x10 ]; arg2[2] to rdx
mov [ rsp + 0x200 ], r10; spilling x80 to mem
mov [ rsp + 0x208 ], rbx; spilling x78 to mem
mulx r10, rbx, [ rsi + 0x30 ]; x50, x49<- arg1[6] * arg2[2]
mov rdx, [ rsi + 0x38 ]; arg1[7] to rdx
mov [ rsp + 0x210 ], r8; spilling x74 to mem
mov [ rsp + 0x218 ], r12; spilling x68 to mem
mulx r8, r12, [ rax + 0x8 ]; x38, x37<- arg1[7] * arg2[1]
mov rdx, [ rax + 0x38 ]; arg2[7] to rdx
mov [ rsp + 0x220 ], r13; spilling x60 to mem
mov [ rsp + 0x228 ], r10; spilling x50 to mem
mulx r13, r10, [ rsi + 0x28 ]; x12, x11<- arg1[5] * arg2[7]
mov rdx, [ rax + 0x30 ]; arg2[6] to rdx
mov [ rsp + 0x230 ], r8; spilling x38 to mem
mov [ rsp + 0x238 ], r13; spilling x12 to mem
mulx r8, r13, [ rsi + 0x30 ]; x10, x9<- arg1[6] * arg2[6]
mov rdx, [ rax + 0x28 ]; arg2[5] to rdx
mov [ rsp + 0x240 ], r8; spilling x10 to mem
mov [ rsp + 0x248 ], r11; spilling x195 to mem
mulx r8, r11, [ rsi + 0x38 ]; x6, x5<- arg1[7] * arg2[5]
adox r11, r13
adcx r11, r10
seto r10b; spill OF x520 to reg (r10)
mov r13, -0x2 ; moving imm to reg
inc r13; OF<-0x0, preserve CF (debug: 6; load -2, increase it, save as -1)
adox r11, r12
seto r12b; spill OF x528 to reg (r12)
inc r13; OF<-0x0, preserve CF (debug: state 2 (y: -1, n: 0))
adox r11, rbx
seto bl; spill OF x532 to reg (rbx)
mov byte [ rsp + 0x250 ], r12b; spilling byte x528 to mem
mov r12, -0x3 ; moving imm to reg
inc r12; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r11, r9
setc r9b; spill CF x524 to reg (r9)
clc;
adcx r11, rcx
seto cl; spill OF x536 to reg (rcx)
mov r12, -0x3 ; moving imm to reg
inc r12; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r11, rdi
seto dil; spill OF x544 to reg (rdi)
mov r12, -0x3 ; moving imm to reg
inc r12; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r11, rbp
setc bpl; spill CF x540 to reg (rbp)
clc;
adcx r11, r14
seto r14b; spill OF x548 to reg (r14)
mov r12, -0x3 ; moving imm to reg
inc r12; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r11, [ rsp + 0x248 ]
setc r12b; spill CF x552 to reg (r12)
clc;
adcx r15, r11
movzx r10, r10b
lea r8, [ r10 + r8 ]
mov r10, [ rsp + 0x240 ]
lea r8, [r10+r8]
movzx r9, r9b
lea r8, [ r9 + r8 ]
mov r9, [ rsp + 0x238 ]
lea r8, [r9+r8]
movzx r10, byte [ rsp + 0x250 ]; load byte memx528 to register64
lea r8, [ r10 + r8 ]
mov r10, [ rsp + 0x230 ]
lea r8, [r10+r8]
movzx rbx, bl
lea r8, [ rbx + r8 ]
mov rbx, [ rsp + 0x228 ]
lea r8, [rbx+r8]
movzx rcx, cl
lea r8, [ rcx + r8 ]
mov rcx, [ rsp + 0x220 ]
lea r8, [rcx+r8]
movzx rbp, bpl
lea r8, [ rbp + r8 ]
mov rbp, [ rsp + 0x218 ]
lea r8, [rbp+r8]
movzx rdi, dil
lea r8, [ rdi + r8 ]
mov rdi, [ rsp + 0x210 ]
lea r8, [rdi+r8]
movzx r14, r14b
lea r8, [ r14 + r8 ]
mov r14, [ rsp + 0x208 ]
lea r8, [r14+r8]
movzx r12, r12b
lea r8, [ r12 + r8 ]
mov r12, [ rsp + 0x200 ]
lea r8, [r12+r8]
adox r8, [ rsp + 0x1f8 ]
adc r8, 0x0
mov rdx, [ rax + 0x20 ]; arg2[4] to rdx
mulx r9, r10, [ rsi + 0x8 ]; x172, x171<- arg1[1] * arg2[4]
mov rdx, [ rax + 0x28 ]; arg2[5] to rdx
mulx rbx, rcx, [ rsi + 0x0 ]; x186, x185<- arg1[0] * arg2[5]
mov rdx, [ rsi + 0x10 ]; arg1[2] to rdx
mulx rbp, rdi, [ rax + 0x18 ]; x160, x159<- arg1[2] * arg2[3]
mov rdx, [ rsi + 0x18 ]; arg1[3] to rdx
mulx r14, r12, [ rax + 0x10 ]; x150, x149<- arg1[3] * arg2[2]
mov rdx, [ rax + 0x8 ]; arg2[1] to rdx
mulx r11, r13, [ rsi + 0x20 ]; x142, x141<- arg1[4] * arg2[1]
mov rdx, [ rsi + 0x28 ]; arg1[5] to rdx
mov [ rsp + 0x258 ], r8; spilling x571 to mem
mov [ rsp + 0x260 ], r15; spilling x569 to mem
mulx r8, r15, [ rax + 0x0 ]; x136, x135<- arg1[5] * arg2[0]
mov rdx, [ rax + 0x38 ]; arg2[7] to rdx
mov [ rsp + 0x268 ], rbx; spilling x186 to mem
mov [ rsp + 0x270 ], r9; spilling x172 to mem
mulx rbx, r9, [ rsi + 0x10 ]; x120, x119<- arg1[2] * arg2[7]
mov rdx, [ rax + 0x30 ]; arg2[6] to rdx
mov [ rsp + 0x278 ], rbp; spilling x160 to mem
mov [ rsp + 0x280 ], r14; spilling x150 to mem
mulx rbp, r14, [ rsi + 0x18 ]; x116, x115<- arg1[3] * arg2[6]
mov rdx, [ rsi + 0x20 ]; arg1[4] to rdx
mov [ rsp + 0x288 ], r11; spilling x142 to mem
mov [ rsp + 0x290 ], r8; spilling x136 to mem
mulx r11, r8, [ rax + 0x28 ]; x110, x109<- arg1[4] * arg2[5]
mov rdx, [ rsi + 0x28 ]; arg1[5] to rdx
mov [ rsp + 0x298 ], rbx; spilling x120 to mem
mov [ rsp + 0x2a0 ], rbp; spilling x116 to mem
mulx rbx, rbp, [ rax + 0x20 ]; x102, x101<- arg1[5] * arg2[4]
mov rdx, [ rsi + 0x30 ]; arg1[6] to rdx
mov [ rsp + 0x2a8 ], r11; spilling x110 to mem
mov [ rsp + 0x2b0 ], rbx; spilling x102 to mem
mulx r11, rbx, [ rax + 0x18 ]; x94, x93<- arg1[6] * arg2[3]
mov rdx, [ rax + 0x10 ]; arg2[2] to rdx
mov [ rsp + 0x2b8 ], r11; spilling x94 to mem
mov [ rsp + 0x2c0 ], rcx; spilling x185 to mem
mulx r11, rcx, [ rsi + 0x38 ]; x86, x85<- arg1[7] * arg2[2]
mov rdx, [ rsi + 0x30 ]; arg1[6] to rdx
mov [ rsp + 0x2c8 ], r11; spilling x86 to mem
mov [ rsp + 0x2d0 ], r10; spilling x171 to mem
mulx r11, r10, [ rax + 0x38 ]; x40, x39<- arg1[6] * arg2[7]
mov rdx, [ rsi + 0x38 ]; arg1[7] to rdx
mov [ rsp + 0x2d8 ], r11; spilling x40 to mem
mov [ rsp + 0x2e0 ], rdi; spilling x159 to mem
mulx r11, rdi, [ rax + 0x30 ]; x28, x27<- arg1[7] * arg2[6]
mov rdx, [ rsi + 0x30 ]; arg1[6] to rdx
mov [ rsp + 0x2e8 ], r11; spilling x28 to mem
mov [ rsp + 0x2f0 ], r12; spilling x149 to mem
mulx r11, r12, [ rax + 0x38 ]; x20, x19<- arg1[6] * arg2[7]
mov rdx, [ rsi + 0x38 ]; arg1[7] to rdx
mov [ rsp + 0x2f8 ], r11; spilling x20 to mem
mov [ rsp + 0x300 ], r13; spilling x141 to mem
mulx r11, r13, [ rax + 0x30 ]; x16, x15<- arg1[7] * arg2[6]
test al, al
adox r13, r12
adcx r13, rdi
setc dil; spill CF x328 to reg (rdi)
clc;
adcx r13, r10
setc r10b; spill CF x332 to reg (r10)
clc;
adcx r13, rcx
setc cl; spill CF x336 to reg (rcx)
clc;
adcx r13, rbx
seto bl; spill OF x324 to reg (rbx)
mov r12, -0x2 ; moving imm to reg
inc r12; OF<-0x0, preserve CF (debug: 6; load -2, increase it, save as -1)
adox r13, rbp
setc bpl; spill CF x340 to reg (rbp)
clc;
adcx r13, r8
setc r8b; spill CF x348 to reg (r8)
clc;
adcx r13, r14
setc r14b; spill CF x352 to reg (r14)
clc;
adcx r13, r9
setc r9b; spill CF x356 to reg (r9)
clc;
adcx r13, r15
setc r15b; spill CF x360 to reg (r15)
clc;
adcx r13, [ rsp + 0x300 ]
seto r12b; spill OF x344 to reg (r12)
mov byte [ rsp + 0x308 ], r15b; spilling byte x360 to mem
mov r15, -0x2 ; moving imm to reg
inc r15; OF<-0x0, preserve CF (debug: 6; load -2, increase it, save as -1)
adox r13, [ rsp + 0x2f0 ]
setc r15b; spill CF x364 to reg (r15)
clc;
adcx r13, [ rsp + 0x2e0 ]
mov byte [ rsp + 0x310 ], r15b; spilling byte x364 to mem
setc r15b; spill CF x372 to reg (r15)
clc;
adcx r13, [ rsp + 0x2d0 ]
mov byte [ rsp + 0x318 ], r15b; spilling byte x372 to mem
seto r15b; spill OF x368 to reg (r15)
mov byte [ rsp + 0x320 ], r9b; spilling byte x356 to mem
mov r9, -0x2 ; moving imm to reg
inc r9; OF<-0x0, preserve CF (debug: 6; load -2, increase it, save as -1)
adox r13, [ rsp + 0x2c0 ]
setc r9b; spill CF x376 to reg (r9)
clc;
adcx r13, [ rsp + 0x1f0 ]
movzx rbx, bl
lea r11, [ rbx + r11 ]
mov rbx, [ rsp + 0x2f8 ]
lea r11, [rbx+r11]
movzx rdi, dil
lea r11, [ rdi + r11 ]
mov rdi, [ rsp + 0x2e8 ]
lea r11, [rdi+r11]
movzx r10, r10b
lea r11, [ r10 + r11 ]
mov r10, [ rsp + 0x2d8 ]
lea r11, [r10+r11]
movzx rcx, cl
lea r11, [ rcx + r11 ]
mov rcx, [ rsp + 0x2c8 ]
lea r11, [rcx+r11]
movzx rbp, bpl
lea r11, [ rbp + r11 ]
mov rbp, [ rsp + 0x2b8 ]
lea r11, [rbp+r11]
movzx r12, r12b
lea r11, [ r12 + r11 ]
mov r12, [ rsp + 0x2b0 ]
lea r11, [r12+r11]
movzx r8, r8b
lea r11, [ r8 + r11 ]
mov r8, [ rsp + 0x2a8 ]
lea r11, [r8+r11]
movzx r14, r14b
lea r11, [ r14 + r11 ]
mov r14, [ rsp + 0x2a0 ]
lea r11, [r14+r11]
movzx rbx, byte [ rsp + 0x320 ]; load byte memx356 to register64
lea r11, [ rbx + r11 ]
mov rbx, [ rsp + 0x298 ]
lea r11, [rbx+r11]
movzx rdi, byte [ rsp + 0x308 ]; load byte memx360 to register64
lea r11, [ rdi + r11 ]
mov rdi, [ rsp + 0x290 ]
lea r11, [rdi+r11]
movzx r10, byte [ rsp + 0x310 ]; load byte memx364 to register64
lea r11, [ r10 + r11 ]
mov r10, [ rsp + 0x288 ]
lea r11, [r10+r11]
movzx r15, r15b
lea r11, [ r15 + r11 ]
mov r15, [ rsp + 0x280 ]
lea r11, [r15+r11]
movzx rcx, byte [ rsp + 0x318 ]; load byte memx372 to register64
lea r11, [ rcx + r11 ]
mov rcx, [ rsp + 0x278 ]
lea r11, [rcx+r11]
movzx r9, r9b
lea r11, [ r9 + r11 ]
mov r9, [ rsp + 0x270 ]
lea r11, [r9+r11]
adox r11, [ rsp + 0x268 ]
adc r11, 0x0
mov rbp, [ rsp + 0x260 ]; load m64 x569 to register64
mov r12, [ rsp + 0x258 ]; load m64 x571 to register64
mov r8, rbp; x575, copying x569 here, cause x569 is needed in a reg for other than x575, namely all: , x575, x576, size: 2
shrd r8, r12, 56; x575 <- x571||x569 >> 56
mov r12, 0xffffffffffffff ; moving imm to reg
and rbp, r12; x576 <- x569&0xffffffffffffff
mov rdx, [ rsi + 0x0 ]; arg1[0] to rdx
mulx r14, rbx, [ rax + 0x8 ]; x194, x193<- arg1[0] * arg2[1]
mov rdx, [ rax + 0x0 ]; arg2[0] to rdx
mulx rdi, r10, [ rsi + 0x8 ]; x180, x179<- arg1[1] * arg2[0]
mov rdx, [ rsi + 0x10 ]; arg1[2] to rdx
mulx r15, rcx, [ rax + 0x38 ]; x76, x75<- arg1[2] * arg2[7]
mov rdx, [ rsi + 0x18 ]; arg1[3] to rdx
mulx r9, r12, [ rax + 0x30 ]; x72, x71<- arg1[3] * arg2[6]
mov rdx, [ rsi + 0x20 ]; arg1[4] to rdx
mov [ rsp + 0x328 ], rbp; spilling x576 to mem
mov [ rsp + 0x330 ], r11; spilling x574 to mem
mulx rbp, r11, [ rax + 0x28 ]; x66, x65<- arg1[4] * arg2[5]
mov rdx, [ rax + 0x20 ]; arg2[4] to rdx
mov [ rsp + 0x338 ], r13; spilling x572 to mem
mov [ rsp + 0x340 ], r14; spilling x194 to mem
mulx r13, r14, [ rsi + 0x28 ]; x58, x57<- arg1[5] * arg2[4]
mov rdx, [ rax + 0x18 ]; arg2[3] to rdx
mov [ rsp + 0x348 ], rdi; spilling x180 to mem
mov [ rsp + 0x350 ], r15; spilling x76 to mem
mulx rdi, r15, [ rsi + 0x30 ]; x48, x47<- arg1[6] * arg2[3]
mov rdx, [ rsi + 0x38 ]; arg1[7] to rdx
mov [ rsp + 0x358 ], r9; spilling x72 to mem
mov [ rsp + 0x360 ], rbp; spilling x66 to mem
mulx r9, rbp, [ rax + 0x10 ]; x36, x35<- arg1[7] * arg2[2]
mov rdx, [ rsi + 0x30 ]; arg1[6] to rdx
mov [ rsp + 0x368 ], r13; spilling x58 to mem
mov [ rsp + 0x370 ], rdi; spilling x48 to mem
mulx r13, rdi, [ rax + 0x38 ]; x8, x7<- arg1[6] * arg2[7]
mov rdx, [ rsi + 0x38 ]; arg1[7] to rdx
mov [ rsp + 0x378 ], r9; spilling x36 to mem
mov [ rsp + 0x380 ], r13; spilling x8 to mem
mulx r9, r13, [ rax + 0x30 ]; x4, x3<- arg1[7] * arg2[6]
adox r13, rdi
adcx r13, rbp
seto bpl; spill OF x484 to reg (rbp)
mov rdi, -0x2 ; moving imm to reg
inc rdi; OF<-0x0, preserve CF (debug: 6; load -2, increase it, save as -1)
adox r13, r15
seto r15b; spill OF x492 to reg (r15)
inc rdi; OF<-0x0, preserve CF (debug: state 2 (y: -1, n: 0))
adox r13, r14
seto r14b; spill OF x496 to reg (r14)
mov byte [ rsp + 0x388 ], r15b; spilling byte x492 to mem
mov r15, -0x3 ; moving imm to reg
inc r15; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r13, r11
seto r11b; spill OF x500 to reg (r11)
mov r15, -0x3 ; moving imm to reg
inc r15; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r13, r12
seto r12b; spill OF x504 to reg (r12)
mov r15, -0x3 ; moving imm to reg
inc r15; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r13, rcx
seto cl; spill OF x508 to reg (rcx)
mov r15, -0x3 ; moving imm to reg
inc r15; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r13, r10
setc r10b; spill CF x488 to reg (r10)
clc;
adcx r13, rbx
seto bl; spill OF x512 to reg (rbx)
mov r15, -0x3 ; moving imm to reg
inc r15; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r13, r8
movzx rbp, bpl
lea r9, [ rbp + r9 ]
mov rbp, [ rsp + 0x380 ]
lea r9, [rbp+r9]
movzx r10, r10b
lea r9, [ r10 + r9 ]
mov r10, [ rsp + 0x378 ]
lea r9, [r10+r9]
movzx r8, byte [ rsp + 0x388 ]; load byte memx492 to register64
lea r9, [ r8 + r9 ]
mov r8, [ rsp + 0x370 ]
lea r9, [r8+r9]
movzx r14, r14b
lea r9, [ r14 + r9 ]
mov r14, [ rsp + 0x368 ]
lea r9, [r14+r9]
movzx r11, r11b
lea r9, [ r11 + r9 ]
mov r11, [ rsp + 0x360 ]
lea r9, [r11+r9]
movzx r12, r12b
lea r9, [ r12 + r9 ]
mov r12, [ rsp + 0x358 ]
lea r9, [r12+r9]
movzx rcx, cl
lea r9, [ rcx + r9 ]
mov rcx, [ rsp + 0x350 ]
lea r9, [rcx+r9]
movzx rbx, bl
lea r9, [ rbx + r9 ]
mov rbx, [ rsp + 0x348 ]
lea r9, [rbx+r9]
adcx r9, [ rsp + 0x340 ]
adox r9, rdi
mov rbp, [ rsp + 0x338 ]; load m64 x572 to register64
mov r10, [ rsp + 0x330 ]; load m64 x574 to register64
mov r8, rbp; x580, copying x572 here, cause x572 is needed in a reg for other than x580, namely all: , x580, x581, size: 2
shrd r8, r10, 56; x580 <- x574||x572 >> 56
mov r10, 0x38 ; moving imm to reg
bzhi rbp, rbp, r10; x581 <- x572 (only least 0x38 bits)
mov rdx, [ rax + 0x30 ]; arg2[6] to rdx
mulx r14, r11, [ rsi + 0x0 ]; x184, x183<- arg1[0] * arg2[6]
mov rdx, [ rax + 0x28 ]; arg2[5] to rdx
mulx r12, rcx, [ rsi + 0x8 ]; x170, x169<- arg1[1] * arg2[5]
mov rdx, [ rax + 0x20 ]; arg2[4] to rdx
mulx rbx, rdi, [ rsi + 0x10 ]; x158, x157<- arg1[2] * arg2[4]
mov rdx, [ rsi + 0x18 ]; arg1[3] to rdx
mulx r10, r15, [ rax + 0x18 ]; x148, x147<- arg1[3] * arg2[3]
mov rdx, [ rax + 0x10 ]; arg2[2] to rdx
mov [ rsp + 0x390 ], rbp; spilling x581 to mem
mov [ rsp + 0x398 ], r9; spilling x579 to mem
mulx rbp, r9, [ rsi + 0x20 ]; x140, x139<- arg1[4] * arg2[2]
mov rdx, [ rsi + 0x28 ]; arg1[5] to rdx
mov [ rsp + 0x3a0 ], r13; spilling x577 to mem
mov [ rsp + 0x3a8 ], r14; spilling x184 to mem
mulx r13, r14, [ rax + 0x8 ]; x134, x133<- arg1[5] * arg2[1]
mov rdx, [ rsi + 0x30 ]; arg1[6] to rdx
mov [ rsp + 0x3b0 ], r12; spilling x170 to mem
mov [ rsp + 0x3b8 ], rbx; spilling x158 to mem
mulx r12, rbx, [ rax + 0x0 ]; x130, x129<- arg1[6] * arg2[0]
mov rdx, [ rsi + 0x18 ]; arg1[3] to rdx
mov [ rsp + 0x3c0 ], r10; spilling x148 to mem
mov [ rsp + 0x3c8 ], rbp; spilling x140 to mem
mulx r10, rbp, [ rax + 0x38 ]; x114, x113<- arg1[3] * arg2[7]
mov rdx, [ rsi + 0x20 ]; arg1[4] to rdx
mov [ rsp + 0x3d0 ], r13; spilling x134 to mem
mov [ rsp + 0x3d8 ], r12; spilling x130 to mem
mulx r13, r12, [ rax + 0x30 ]; x108, x107<- arg1[4] * arg2[6]
mov rdx, [ rax + 0x28 ]; arg2[5] to rdx
mov [ rsp + 0x3e0 ], r10; spilling x114 to mem
mov [ rsp + 0x3e8 ], r13; spilling x108 to mem
mulx r10, r13, [ rsi + 0x28 ]; x100, x99<- arg1[5] * arg2[5]
mov rdx, [ rax + 0x20 ]; arg2[4] to rdx
mov [ rsp + 0x3f0 ], r10; spilling x100 to mem
mov [ rsp + 0x3f8 ], r8; spilling x580 to mem
mulx r10, r8, [ rsi + 0x30 ]; x92, x91<- arg1[6] * arg2[4]
mov rdx, [ rsi + 0x38 ]; arg1[7] to rdx
mov [ rsp + 0x400 ], r10; spilling x92 to mem
mov [ rsp + 0x408 ], r11; spilling x183 to mem
mulx r10, r11, [ rax + 0x18 ]; x84, x83<- arg1[7] * arg2[3]
mov rdx, [ rax + 0x38 ]; arg2[7] to rdx
mov [ rsp + 0x410 ], r10; spilling x84 to mem
mov [ rsp + 0x418 ], rcx; spilling x169 to mem
mulx r10, rcx, [ rsi + 0x38 ]; x26, x25<- arg1[7] * arg2[7]
mov rdx, [ rsi + 0x38 ]; arg1[7] to rdx
mov [ rsp + 0x420 ], r10; spilling x26 to mem
mov [ rsp + 0x428 ], rdi; spilling x157 to mem
mulx r10, rdi, [ rax + 0x38 ]; x14, x13<- arg1[7] * arg2[7]
adox rdi, rcx
clc;
adcx rdi, r11
setc r11b; spill CF x276 to reg (r11)
clc;
adcx rdi, r8
seto r8b; spill OF x272 to reg (r8)
mov rcx, -0x2 ; moving imm to reg
inc rcx; OF<-0x0, preserve CF (debug: 6; load -2, increase it, save as -1)
adox rdi, r13
seto r13b; spill OF x284 to reg (r13)
inc rcx; OF<-0x0, preserve CF (debug: state 2 (y: -1, n: 0))
adox rdi, r12
seto r12b; spill OF x288 to reg (r12)
mov byte [ rsp + 0x430 ], r13b; spilling byte x284 to mem
mov r13, -0x3 ; moving imm to reg
inc r13; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox rdi, rbp
setc bpl; spill CF x280 to reg (rbp)
clc;
adcx rdi, rbx
setc bl; spill CF x296 to reg (rbx)
clc;
adcx rdi, r14
setc r14b; spill CF x300 to reg (r14)
clc;
adcx rdi, r9
seto r9b; spill OF x292 to reg (r9)
mov r13, -0x3 ; moving imm to reg
inc r13; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox rdi, r15
setc r15b; spill CF x304 to reg (r15)
clc;
adcx rdi, [ rsp + 0x428 ]
seto r13b; spill OF x308 to reg (r13)
mov byte [ rsp + 0x438 ], r15b; spilling byte x304 to mem
mov r15, -0x3 ; moving imm to reg
inc r15; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox rdi, [ rsp + 0x418 ]
setc r15b; spill CF x312 to reg (r15)
clc;
adcx rdi, [ rsp + 0x408 ]
mov byte [ rsp + 0x440 ], r15b; spilling byte x312 to mem
setc r15b; spill CF x320 to reg (r15)
clc;
adcx rdi, [ rsp + 0x3f8 ]
movzx r8, r8b
lea r10, [ r8 + r10 ]
mov r8, [ rsp + 0x420 ]
lea r10, [r8+r10]
movzx r11, r11b
lea r10, [ r11 + r10 ]
mov r11, [ rsp + 0x410 ]
lea r10, [r11+r10]
movzx rbp, bpl
lea r10, [ rbp + r10 ]
mov rbp, [ rsp + 0x400 ]
lea r10, [rbp+r10]
movzx r8, byte [ rsp + 0x430 ]; load byte memx284 to register64
lea r10, [ r8 + r10 ]
mov r8, [ rsp + 0x3f0 ]
lea r10, [r8+r10]
movzx r12, r12b
lea r10, [ r12 + r10 ]
mov r12, [ rsp + 0x3e8 ]
lea r10, [r12+r10]
movzx r9, r9b
lea r10, [ r9 + r10 ]
mov r9, [ rsp + 0x3e0 ]
lea r10, [r9+r10]
movzx rbx, bl
lea r10, [ rbx + r10 ]
mov rbx, [ rsp + 0x3d8 ]
lea r10, [rbx+r10]
movzx r14, r14b
lea r10, [ r14 + r10 ]
mov r14, [ rsp + 0x3d0 ]
lea r10, [r14+r10]
movzx r11, byte [ rsp + 0x438 ]; load byte memx304 to register64
lea r10, [ r11 + r10 ]
mov r11, [ rsp + 0x3c8 ]
lea r10, [r11+r10]
movzx r13, r13b
lea r10, [ r13 + r10 ]
mov r13, [ rsp + 0x3c0 ]
lea r10, [r13+r10]
movzx rbp, byte [ rsp + 0x440 ]; load byte memx312 to register64
lea r10, [ rbp + r10 ]
mov rbp, [ rsp + 0x3b8 ]
lea r10, [rbp+r10]
adox r10, [ rsp + 0x3b0 ]
movzx r15, r15b
lea r10, [ r15 + r10 ]
mov r15, [ rsp + 0x3a8 ]
lea r10, [r15+r10]
adc r10, 0x0
mov r8, [ rsp + 0x3a0 ]; load m64 x577 to register64
mov r12, [ rsp + 0x398 ]; load m64 x579 to register64
mov r9, r8; x585, copying x577 here, cause x577 is needed in a reg for other than x585, namely all: , x585, x586, size: 2
shrd r9, r12, 56; x585 <- x579||x577 >> 56
mov r12, 0x38 ; moving imm to reg
bzhi r8, r8, r12; x586 <- x577 (only least 0x38 bits)
mov rdx, [ rax + 0x10 ]; arg2[2] to rdx
mulx rbx, r14, [ rsi + 0x0 ]; x192, x191<- arg1[0] * arg2[2]
mov rdx, [ rax + 0x8 ]; arg2[1] to rdx
mulx r11, r13, [ rsi + 0x8 ]; x178, x177<- arg1[1] * arg2[1]
mov rdx, [ rsi + 0x10 ]; arg1[2] to rdx
mulx rbp, r15, [ rax + 0x0 ]; x166, x165<- arg1[2] * arg2[0]
mov rdx, [ rax + 0x38 ]; arg2[7] to rdx
mulx rcx, r12, [ rsi + 0x18 ]; x70, x69<- arg1[3] * arg2[7]
mov rdx, [ rax + 0x30 ]; arg2[6] to rdx
mov [ rsp + 0x448 ], r8; spilling x586 to mem
mov [ rsp + 0x450 ], r10; spilling x584 to mem
mulx r8, r10, [ rsi + 0x20 ]; x64, x63<- arg1[4] * arg2[6]
mov rdx, [ rsi + 0x28 ]; arg1[5] to rdx
mov [ rsp + 0x458 ], rdi; spilling x582 to mem
mov [ rsp + 0x460 ], rbx; spilling x192 to mem
mulx rdi, rbx, [ rax + 0x28 ]; x56, x55<- arg1[5] * arg2[5]
mov rdx, [ rsi + 0x30 ]; arg1[6] to rdx
mov [ rsp + 0x468 ], r11; spilling x178 to mem
mov [ rsp + 0x470 ], rbp; spilling x166 to mem
mulx r11, rbp, [ rax + 0x20 ]; x46, x45<- arg1[6] * arg2[4]
mov rdx, [ rax + 0x18 ]; arg2[3] to rdx
mov [ rsp + 0x478 ], rcx; spilling x70 to mem
mov [ rsp + 0x480 ], r8; spilling x64 to mem
mulx rcx, r8, [ rsi + 0x38 ]; x34, x33<- arg1[7] * arg2[3]
mov rdx, [ rax + 0x38 ]; arg2[7] to rdx
mov [ rsp + 0x488 ], rdi; spilling x56 to mem
mov [ rsp + 0x490 ], r11; spilling x46 to mem
mulx rdi, r11, [ rsi + 0x38 ]; x2, x1<- arg1[7] * arg2[7]
adox r11, r8
clc;
adcx r11, rbp
setc bpl; spill CF x456 to reg (rbp)
clc;
adcx r11, rbx
seto bl; spill OF x452 to reg (rbx)
mov r8, -0x2 ; moving imm to reg
inc r8; OF<-0x0, preserve CF (debug: 6; load -2, increase it, save as -1)
adox r11, r10
seto r10b; spill OF x464 to reg (r10)
inc r8; OF<-0x0, preserve CF (debug: state 2 (y: -1, n: 0))
adox r11, r12
setc r12b; spill CF x460 to reg (r12)
clc;
adcx r11, r15
seto r15b; spill OF x468 to reg (r15)
mov byte [ rsp + 0x498 ], r10b; spilling byte x464 to mem
mov r10, -0x3 ; moving imm to reg
inc r10; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r11, r13
seto r13b; spill OF x476 to reg (r13)
mov r10, -0x3 ; moving imm to reg
inc r10; OF<-0x0, preserve CF (debug 7; load -3, increase it, save it as -2). #last resort
adox r11, r14
setc r14b; spill CF x472 to reg (r14)
clc;
adcx r11, r9
movzx rbx, bl
lea rcx, [ rcx + rdi ]
lea rcx, [ rcx + rbx ]
movzx rbp, bpl
lea rcx, [ rbp + rcx ]
mov rbp, [ rsp + 0x490 ]
lea rcx, [rbp+rcx]
movzx r12, r12b
lea rcx, [ r12 + rcx ]
mov r12, [ rsp + 0x488 ]
lea rcx, [r12+rcx]
movzx r9, byte [ rsp + 0x498 ]; load byte memx464 to register64
lea rcx, [ r9 + rcx ]
mov r9, [ rsp + 0x480 ]
lea rcx, [r9+rcx]
movzx r15, r15b
lea rcx, [ r15 + rcx ]
mov r15, [ rsp + 0x478 ]
lea rcx, [r15+rcx]
movzx r14, r14b
lea rcx, [ r14 + rcx ]
mov r14, [ rsp + 0x470 ]
lea rcx, [r14+rcx]
movzx r13, r13b
lea rcx, [ r13 + rcx ]
mov r13, [ rsp + 0x468 ]
lea rcx, [r13+rcx]
adox rcx, [ rsp + 0x460 ]
adc rcx, 0x0
mov rdi, [ rsp + 0x458 ]; load m64 x582 to register64
mov rbx, [ rsp + 0x450 ]; load m64 x584 to register64
mov rbp, rdi; x590, copying x582 here, cause x582 is needed in a reg for other than x590, namely all: , x590, x591, size: 2
shrd rbp, rbx, 56; x590 <- x584||x582 >> 56
mov rbx, 0x38 ; moving imm to reg
bzhi rdi, rdi, rbx; x591 <- x582 (only least 0x38 bits)
add rbp, [ rsp + 0x1e8 ]
mov r12, r11; x593, copying x587 here, cause x587 is needed in a reg for other than x593, namely all: , x593, x594, size: 2
shrd r12, rcx, 56; x593 <- x589||x587 >> 56
mov r9, 0xffffffffffffff ; moving imm to reg
and r11, r9; x594 <- x587&0xffffffffffffff
add r12, [ rsp + 0x60 ]
mov r15, rbp; x596, copying x592 here, cause x592 is needed in a reg for other than x596, namely all: , x596, x597, size: 2
shr r15, 56; x596 <- x592>> 56
bzhi rbp, rbp, rbx; x597 <- x592 (only least 0x38 bits)
mov r14, r12; x598, copying x595 here, cause x595 is needed in a reg for other than x598, namely all: , x598, x599, size: 2
shr r14, 56; x598 <- x595>> 56
and r12, r9; x599 <- x595&0xffffffffffffff
mov r13, r15; x600, copying x596 here, cause x596 is needed in a reg for other than x600, namely all: , x600, x601, size: 2
add r13, [ rsp + 0x1e0 ]
add r15, [ rsp + 0x328 ]
lea r14, [ r14 + r13 ]
mov rcx, r14; x603, copying x602 here, cause x602 is needed in a reg for other than x603, namely all: , x603, x604, size: 2
shr rcx, 56; x603 <- x602>> 56
bzhi r14, r14, rbx; x604 <- x602 (only least 0x38 bits)
add rcx, [ rsp + 0x390 ]
mov r13, r15; x606, copying x601 here, cause x601 is needed in a reg for other than x606, namely all: , x606, x607, size: 2
shr r13, 56; x606 <- x601>> 56
and r15, r9; x607 <- x601&0xffffffffffffff
add r13, [ rsp + 0x448 ]
mov r8, [ rsp + 0x30 ]; load m64 out1 to register64
mov [ r8 + 0x0 ], r15; out1[0] = x607
mov [ r8 + 0x8 ], r13; out1[1] = x608
mov [ r8 + 0x10 ], r11; out1[2] = x594
mov [ r8 + 0x18 ], r12; out1[3] = x599
mov [ r8 + 0x20 ], r14; out1[4] = x604
mov [ r8 + 0x28 ], rcx; out1[5] = x605
mov [ r8 + 0x30 ], rdi; out1[6] = x591
mov [ r8 + 0x38 ], rbp; out1[7] = x597
mov r15, [ rsp + 0x0 ] ; pop
mov r14, [ rsp + 0x8 ] ; pop
mov r13, [ rsp + 0x10 ] ; pop
mov r12, [ rsp + 0x18 ] ; pop
mov rbp, [ rsp + 0x20 ] ; pop
mov rbx, [ rsp + 0x28 ] ; pop
add rsp, 0x4a0
ret
; cpu Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
; ratio 0.6439
; seed 1785685356
; CC / CFLAGS clang / -march=native -mtune=native -O3
; time needed: 4458 ms / 10 evals=> 445.8ms/eval
; Time spent for assembling and measureing (initial batch_size=38, initial num_batches=31): 82 ms
; number of used evaluations: 10
; Ratio (time for assembling + measure)/(total runtime for 10 evals): 0.018393898609241812
; number reverted permutation/ tried permutation: 9 / 9 =100.000%
; number reverted decision/ tried decision: 1 / 1 =100.000% |
; A010514: Decimal expansion of square root of 61.
; 7,8,1,0,2,4,9,6,7,5,9,0,6,6,5,4,3,9,4,1,2,9,7,2,2,7,3,5,7,5,9,1,0,1,4,1,3,5,6,8,3,0,5,1,3,6,6,4,8,5,6,3,3,0,0,1,7,7,2,4,3,7,6,0,1,9,0,7,8,5,5,8,8,9,3,6,7,2,7,0,5,4,4,2,5,4,3,3,0,5,2,2,6,7,0,0,4,8,9,5
mov $1,1
mov $2,1
mov $3,$0
add $3,8
mov $4,$0
add $4,3
mul $4,2
mov $7,10
pow $7,$4
mov $9,10
lpb $3
mov $4,$2
pow $4,2
mul $4,61
mov $5,$1
pow $5,2
add $4,$5
mov $6,$1
mov $1,$4
mul $6,$2
mul $6,2
mov $2,$6
mov $8,$4
div $8,$7
max $8,2
div $1,$8
div $2,$8
sub $3,1
lpe
mov $3,$9
pow $3,$0
div $2,$3
div $1,$2
mod $1,$9
mov $0,$1
|
; Various messages output by the second stage
second_stage_msg db 'Second stage loaded', 0
a20_msg_one db 'A20 line already enabled', 0
a20_msg_two db 'A20 line enabled by BIOS', 0
a20_msg_three db 'A20 line enabled using keyboard controller', 0
a20_msg_four db 'A20 line enabled using Fast A20 gate', 0
no_a20_msg db 'Unable to enable A20 line', 0
wait_for_key_msg db 'Press a key to continue', 0
msgFailure db 'Unable to find KERNEL.SYS. ', 0
a20_message_list dw no_a20_msg
dw a20_msg_one
dw a20_msg_two
dw a20_msg_three
dw a20_msg_four |
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0xedbf, %r11
nop
nop
nop
and %rbp, %rbp
mov (%r11), %r9w
nop
nop
nop
nop
nop
cmp $14557, %r10
lea addresses_UC_ht+0x5baf, %rax
nop
nop
nop
nop
nop
sub $12455, %r9
mov (%rax), %cx
nop
nop
and %r10, %r10
lea addresses_D_ht+0x195bf, %rbp
clflush (%rbp)
nop
nop
nop
nop
nop
cmp %r14, %r14
movups (%rbp), %xmm6
vpextrq $1, %xmm6, %r11
nop
nop
nop
nop
nop
sub $1008, %r9
lea addresses_WC_ht+0xbcbf, %rsi
lea addresses_WC_ht+0x1e8ce, %rdi
nop
nop
nop
nop
nop
inc %r11
mov $69, %rcx
rep movsq
nop
nop
nop
xor $50300, %rsi
lea addresses_UC_ht+0x2cbf, %rsi
lea addresses_UC_ht+0x15f3f, %rdi
clflush (%rdi)
nop
nop
nop
dec %r11
mov $99, %rcx
rep movsw
nop
nop
nop
nop
and $34679, %rax
lea addresses_D_ht+0x17eef, %r14
nop
nop
add %rsi, %rsi
mov $0x6162636465666768, %r10
movq %r10, %xmm5
vmovups %ymm5, (%r14)
nop
nop
nop
nop
and $58294, %r9
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r15
push %rax
push %rbx
push %rcx
push %rsi
// Store
mov $0xbf, %r12
nop
nop
nop
nop
cmp %r13, %r13
movw $0x5152, (%r12)
and %r13, %r13
// Faulty Load
lea addresses_WC+0xa5bf, %rax
nop
nop
nop
nop
and $31742, %rsi
movups (%rax), %xmm3
vpextrq $0, %xmm3, %r13
lea oracles, %rbx
and $0xff, %r13
shlq $12, %r13
mov (%rbx,%r13,1), %r13
pop %rsi
pop %rcx
pop %rbx
pop %rax
pop %r15
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 8, 'NT': True, 'type': 'addresses_WC'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_P'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 3, 'AVXalign': True, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 7, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_D_ht'}}
{'46': 17, '44': 22, '48': 221, '47': 571, '00': 9812, 'a0': 2505, '53': 1250, 'de': 3, '80': 1, 'd2': 1, 'c0': 4, 'd0': 131, 'ff': 7282, '12': 1, 'a6': 5, 'e0': 3}
ff 00 ff a0 ff 00 ff 00 ff a0 ff a0 47 00 00 ff 00 ff 00 48 ff a0 ff 00 ff 00 ff a0 ff 00 ff 00 ff 00 ff 00 ff 00 00 ff 00 ff 00 ff a0 ff 00 00 ff 00 ff a0 ff 00 ff 00 ff 00 ff 00 ff 00 53 00 ff 00 00 00 ff a0 ff 00 ff 00 00 ff 00 ff 00 ff 00 00 ff 00 ff d0 00 53 00 ff a0 ff 00 ff 00 00 00 ff 00 ff a0 ff 00 ff 00 ff a0 ff d0 ff 00 ff 00 ff 00 00 00 00 ff a0 ff a0 ff a0 47 00 00 ff 00 00 ff a0 ff 00 ff 00 00 ff 00 ff 00 ff a0 ff 00 ff 00 47 00 ff 00 00 ff 00 ff a0 47 00 ff 00 ff 00 00 ff 00 00 47 00 00 ff 00 ff 00 00 00 53 00 ff 00 ff 00 00 ff 00 00 ff 00 ff 00 00 ff 00 ff 00 00 ff 00 00 47 00 00 ff 00 00 ff a0 ff 00 00 ff a0 00 ff 00 47 00 ff 00 ff 00 ff 00 00 00 00 53 00 ff 00 ff 00 53 00 ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 47 00 ff 00 00 53 00 00 ff 00 ff 00 ff a0 ff a0 53 00 ff 00 ff 00 ff 00 00 00 ff 00 ff 00 00 ff 00 ff 00 ff a0 ff 00 47 00 ff 00 00 00 ff 00 ff a0 ff a0 ff a0 48 ff 00 ff 00 00 ff 00 ff 00 00 47 00 ff 00 ff a0 ff 00 ff 00 53 00 48 00 00 ff 00 ff 00 00 ff 00 ff 00 ff a0 48 ff 00 ff 00 00 ff a0 00 ff 00 48 ff a0 ff 00 00 ff 00 53 00 53 00 ff a0 00 00 00 ff 00 00 47 00 ff 00 ff 00 ff 00 48 ff 00 53 00 ff 00 ff 00 ff 00 ff 00 ff 00 ff 00 47 00 ff 00 ff 00 53 00 ff a0 47 00 ff 00 00 ff 00 ff 00 ff 00 00 00 ff 00 ff 00 ff a0 ff 00 00 ff 00 ff 00 ff 00 53 00 ff 00 00 ff 00 ff 00 48 ff 00 00 00 ff 00 00 00 ff 00 ff 00 ff 00 ff d0 ff 00 00 47 00 ff 00 ff a0 ff 00 ff 00 53 00 00 00 00 ff 00 00 ff 00 ff 00 ff 00 ff 00 00 ff 00 ff a0 ff 00 00 00 00 ff 00 00 ff 00 ff 00 ff 00 53 00 ff 00 ff 00 ff 00 ff 00 ff 00 47 00 53 00 ff 00 53 00 00 00 ff 00 ff 00 00 ff 00 53 00 ff 00 00 ff 00 53 00 ff a0 47 00 53 00 ff 00 00 47 00 00 ff 00 ff a0 00 00 ff 00 ff a0 00 53 00 ff 00 00 00 ff 00 53 00 00 ff 00 ff 00 ff 00 00 00 00 ff a0 ff 00 00 47 00 00 00 ff a0 ff 00 ff 00 ff 00 ff 00 53 00 ff 00 47 00 ff 00 ff 00 ff a0 53 00 ff a0 00 53 00 ff 00 ff 00 ff 00 00 ff 00 ff 00 ff 00 00 ff 00 ff 00 ff 00 53 00 ff 00 00 ff 00 ff 00 ff 00 53 00 ff a0 00 00 53 00 00 00 ff a0 00 ff d0 ff a0 ff 00 ff 00 00 00 ff 00 ff 00 00 00 ff 00 ff 00 00 47 00 ff 00 ff 00 ff 00 ff 00 ff a0 ff 00 ff 00 ff 00 00 ff a0 00 ff 00 ff 00 ff 00 ff 00 ff a0 ff 00 00 ff 00 ff 00 53 00 ff 00 ff d0 ff 00 ff 00 ff 00 00 53 00 00 00 ff a0 00 00 00 00 ff 00 00 ff 00 ff 00 ff 00 53 00 47 00 ff 00 ff a0 ff a0 48 ff 00 ff a0 00 47 00 00 53 00 00 00 00 00 ff 00 ff a0 ff 00 ff 00 48 00 00 ff a0 00 ff 00 ff 00 ff a0 ff 00 48 ff a0 ff a0 00 ff 00 ff 00 00 53 00 ff 00 ff 00 00 00 ff a0 ff a0 ff 00 53 00 ff 00 ff 00 ff 00 ff 00 ff 00 53 00 ff a0 53 00 ff d0 00 53 00 46 ff 00 ff 00 ff 00 53 00 00 ff 00 ff 00 00 ff 00 ff 00 ff 00 00 ff 00 ff 00 ff a0 ff 00 00 ff a0 ff a0 ff 00 ff 00 53 00 00 ff a0 ff 00 00 ff 00 00 00 00 53 00 ff 00 00 48 ff 00 00 47 00 ff 00 53 00 ff 00 ff 00 ff 00 ff a0 53 00 ff 00 47 00 ff a0 00 00 ff 00 53 00 00 00 00 ff 00 ff 00 ff 00 00 ff 00 ff 00 00 ff 00 ff 00 ff 00 ff 00 00 ff 00 00 53 00 c0 ff 00 ff 00 00 ff a0 ff 00 48 ff a0 ff 00 ff a0 00 ff a0 00 53 00 ff d0 ff a0
*/
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %rax
push %rbx
push %rcx
lea addresses_UC_ht+0xe579, %rax
and $57523, %r12
movb $0x61, (%rax)
mfence
pop %rcx
pop %rbx
pop %rax
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %rbx
push %rsi
// Faulty Load
lea addresses_WT+0x14a35, %r11
nop
cmp $23442, %rbx
movaps (%r11), %xmm2
vpextrq $0, %xmm2, %rsi
lea oracles, %rbx
and $0xff, %rsi
shlq $12, %rsi
mov (%rbx,%rsi,1), %rsi
pop %rsi
pop %rbx
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 0, 'same': True, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 2, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
_zombie: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(void)
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 51 push %ecx
e: 83 ec 04 sub $0x4,%esp
if(fork() > 0)
11: e8 38 03 00 00 call 34e <fork>
16: 85 c0 test %eax,%eax
18: 7e 0d jle 27 <main+0x27>
sleep(5); // Let child exit before parent.
1a: 83 ec 0c sub $0xc,%esp
1d: 6a 05 push $0x5
1f: e8 c2 03 00 00 call 3e6 <sleep>
24: 83 c4 10 add $0x10,%esp
exit();
27: e8 2a 03 00 00 call 356 <exit>
0000002c <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
2c: 55 push %ebp
2d: 89 e5 mov %esp,%ebp
2f: 57 push %edi
30: 53 push %ebx
asm volatile("cld; rep stosb" :
31: 8b 4d 08 mov 0x8(%ebp),%ecx
34: 8b 55 10 mov 0x10(%ebp),%edx
37: 8b 45 0c mov 0xc(%ebp),%eax
3a: 89 cb mov %ecx,%ebx
3c: 89 df mov %ebx,%edi
3e: 89 d1 mov %edx,%ecx
40: fc cld
41: f3 aa rep stos %al,%es:(%edi)
43: 89 ca mov %ecx,%edx
45: 89 fb mov %edi,%ebx
47: 89 5d 08 mov %ebx,0x8(%ebp)
4a: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
4d: 90 nop
4e: 5b pop %ebx
4f: 5f pop %edi
50: 5d pop %ebp
51: c3 ret
00000052 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
52: 55 push %ebp
53: 89 e5 mov %esp,%ebp
55: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
58: 8b 45 08 mov 0x8(%ebp),%eax
5b: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
5e: 90 nop
5f: 8b 45 08 mov 0x8(%ebp),%eax
62: 8d 50 01 lea 0x1(%eax),%edx
65: 89 55 08 mov %edx,0x8(%ebp)
68: 8b 55 0c mov 0xc(%ebp),%edx
6b: 8d 4a 01 lea 0x1(%edx),%ecx
6e: 89 4d 0c mov %ecx,0xc(%ebp)
71: 0f b6 12 movzbl (%edx),%edx
74: 88 10 mov %dl,(%eax)
76: 0f b6 00 movzbl (%eax),%eax
79: 84 c0 test %al,%al
7b: 75 e2 jne 5f <strcpy+0xd>
;
return os;
7d: 8b 45 fc mov -0x4(%ebp),%eax
}
80: c9 leave
81: c3 ret
00000082 <strcmp>:
int
strcmp(const char *p, const char *q)
{
82: 55 push %ebp
83: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
85: eb 08 jmp 8f <strcmp+0xd>
p++, q++;
87: 83 45 08 01 addl $0x1,0x8(%ebp)
8b: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
8f: 8b 45 08 mov 0x8(%ebp),%eax
92: 0f b6 00 movzbl (%eax),%eax
95: 84 c0 test %al,%al
97: 74 10 je a9 <strcmp+0x27>
99: 8b 45 08 mov 0x8(%ebp),%eax
9c: 0f b6 10 movzbl (%eax),%edx
9f: 8b 45 0c mov 0xc(%ebp),%eax
a2: 0f b6 00 movzbl (%eax),%eax
a5: 38 c2 cmp %al,%dl
a7: 74 de je 87 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
a9: 8b 45 08 mov 0x8(%ebp),%eax
ac: 0f b6 00 movzbl (%eax),%eax
af: 0f b6 d0 movzbl %al,%edx
b2: 8b 45 0c mov 0xc(%ebp),%eax
b5: 0f b6 00 movzbl (%eax),%eax
b8: 0f b6 c0 movzbl %al,%eax
bb: 29 c2 sub %eax,%edx
bd: 89 d0 mov %edx,%eax
}
bf: 5d pop %ebp
c0: c3 ret
000000c1 <strlen>:
uint
strlen(char *s)
{
c1: 55 push %ebp
c2: 89 e5 mov %esp,%ebp
c4: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
c7: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
ce: eb 04 jmp d4 <strlen+0x13>
d0: 83 45 fc 01 addl $0x1,-0x4(%ebp)
d4: 8b 55 fc mov -0x4(%ebp),%edx
d7: 8b 45 08 mov 0x8(%ebp),%eax
da: 01 d0 add %edx,%eax
dc: 0f b6 00 movzbl (%eax),%eax
df: 84 c0 test %al,%al
e1: 75 ed jne d0 <strlen+0xf>
;
return n;
e3: 8b 45 fc mov -0x4(%ebp),%eax
}
e6: c9 leave
e7: c3 ret
000000e8 <memset>:
void*
memset(void *dst, int c, uint n)
{
e8: 55 push %ebp
e9: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
eb: 8b 45 10 mov 0x10(%ebp),%eax
ee: 50 push %eax
ef: ff 75 0c pushl 0xc(%ebp)
f2: ff 75 08 pushl 0x8(%ebp)
f5: e8 32 ff ff ff call 2c <stosb>
fa: 83 c4 0c add $0xc,%esp
return dst;
fd: 8b 45 08 mov 0x8(%ebp),%eax
}
100: c9 leave
101: c3 ret
00000102 <strchr>:
char*
strchr(const char *s, char c)
{
102: 55 push %ebp
103: 89 e5 mov %esp,%ebp
105: 83 ec 04 sub $0x4,%esp
108: 8b 45 0c mov 0xc(%ebp),%eax
10b: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
10e: eb 14 jmp 124 <strchr+0x22>
if(*s == c)
110: 8b 45 08 mov 0x8(%ebp),%eax
113: 0f b6 00 movzbl (%eax),%eax
116: 3a 45 fc cmp -0x4(%ebp),%al
119: 75 05 jne 120 <strchr+0x1e>
return (char*)s;
11b: 8b 45 08 mov 0x8(%ebp),%eax
11e: eb 13 jmp 133 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
120: 83 45 08 01 addl $0x1,0x8(%ebp)
124: 8b 45 08 mov 0x8(%ebp),%eax
127: 0f b6 00 movzbl (%eax),%eax
12a: 84 c0 test %al,%al
12c: 75 e2 jne 110 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
12e: b8 00 00 00 00 mov $0x0,%eax
}
133: c9 leave
134: c3 ret
00000135 <gets>:
char*
gets(char *buf, int max)
{
135: 55 push %ebp
136: 89 e5 mov %esp,%ebp
138: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
13b: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
142: eb 42 jmp 186 <gets+0x51>
cc = read(0, &c, 1);
144: 83 ec 04 sub $0x4,%esp
147: 6a 01 push $0x1
149: 8d 45 ef lea -0x11(%ebp),%eax
14c: 50 push %eax
14d: 6a 00 push $0x0
14f: e8 1a 02 00 00 call 36e <read>
154: 83 c4 10 add $0x10,%esp
157: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
15a: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
15e: 7e 33 jle 193 <gets+0x5e>
break;
buf[i++] = c;
160: 8b 45 f4 mov -0xc(%ebp),%eax
163: 8d 50 01 lea 0x1(%eax),%edx
166: 89 55 f4 mov %edx,-0xc(%ebp)
169: 89 c2 mov %eax,%edx
16b: 8b 45 08 mov 0x8(%ebp),%eax
16e: 01 c2 add %eax,%edx
170: 0f b6 45 ef movzbl -0x11(%ebp),%eax
174: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
176: 0f b6 45 ef movzbl -0x11(%ebp),%eax
17a: 3c 0a cmp $0xa,%al
17c: 74 16 je 194 <gets+0x5f>
17e: 0f b6 45 ef movzbl -0x11(%ebp),%eax
182: 3c 0d cmp $0xd,%al
184: 74 0e je 194 <gets+0x5f>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
186: 8b 45 f4 mov -0xc(%ebp),%eax
189: 83 c0 01 add $0x1,%eax
18c: 3b 45 0c cmp 0xc(%ebp),%eax
18f: 7c b3 jl 144 <gets+0xf>
191: eb 01 jmp 194 <gets+0x5f>
cc = read(0, &c, 1);
if(cc < 1)
break;
193: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
194: 8b 55 f4 mov -0xc(%ebp),%edx
197: 8b 45 08 mov 0x8(%ebp),%eax
19a: 01 d0 add %edx,%eax
19c: c6 00 00 movb $0x0,(%eax)
return buf;
19f: 8b 45 08 mov 0x8(%ebp),%eax
}
1a2: c9 leave
1a3: c3 ret
000001a4 <stat>:
int
stat(char *n, struct stat *st)
{
1a4: 55 push %ebp
1a5: 89 e5 mov %esp,%ebp
1a7: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
1aa: 83 ec 08 sub $0x8,%esp
1ad: 6a 00 push $0x0
1af: ff 75 08 pushl 0x8(%ebp)
1b2: e8 df 01 00 00 call 396 <open>
1b7: 83 c4 10 add $0x10,%esp
1ba: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
1bd: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1c1: 79 07 jns 1ca <stat+0x26>
return -1;
1c3: b8 ff ff ff ff mov $0xffffffff,%eax
1c8: eb 25 jmp 1ef <stat+0x4b>
r = fstat(fd, st);
1ca: 83 ec 08 sub $0x8,%esp
1cd: ff 75 0c pushl 0xc(%ebp)
1d0: ff 75 f4 pushl -0xc(%ebp)
1d3: e8 d6 01 00 00 call 3ae <fstat>
1d8: 83 c4 10 add $0x10,%esp
1db: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
1de: 83 ec 0c sub $0xc,%esp
1e1: ff 75 f4 pushl -0xc(%ebp)
1e4: e8 95 01 00 00 call 37e <close>
1e9: 83 c4 10 add $0x10,%esp
return r;
1ec: 8b 45 f0 mov -0x10(%ebp),%eax
}
1ef: c9 leave
1f0: c3 ret
000001f1 <atoi>:
int
atoi(const char *s)
{
1f1: 55 push %ebp
1f2: 89 e5 mov %esp,%ebp
1f4: 83 ec 10 sub $0x10,%esp
int n, sign;
n = 0;
1f7: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while (*s == ' ') s++;
1fe: eb 04 jmp 204 <atoi+0x13>
200: 83 45 08 01 addl $0x1,0x8(%ebp)
204: 8b 45 08 mov 0x8(%ebp),%eax
207: 0f b6 00 movzbl (%eax),%eax
20a: 3c 20 cmp $0x20,%al
20c: 74 f2 je 200 <atoi+0xf>
sign = (*s == '-') ? -1 : 1;
20e: 8b 45 08 mov 0x8(%ebp),%eax
211: 0f b6 00 movzbl (%eax),%eax
214: 3c 2d cmp $0x2d,%al
216: 75 07 jne 21f <atoi+0x2e>
218: b8 ff ff ff ff mov $0xffffffff,%eax
21d: eb 05 jmp 224 <atoi+0x33>
21f: b8 01 00 00 00 mov $0x1,%eax
224: 89 45 f8 mov %eax,-0x8(%ebp)
if (*s == '+' || *s == '-')
227: 8b 45 08 mov 0x8(%ebp),%eax
22a: 0f b6 00 movzbl (%eax),%eax
22d: 3c 2b cmp $0x2b,%al
22f: 74 0a je 23b <atoi+0x4a>
231: 8b 45 08 mov 0x8(%ebp),%eax
234: 0f b6 00 movzbl (%eax),%eax
237: 3c 2d cmp $0x2d,%al
239: 75 2b jne 266 <atoi+0x75>
s++;
23b: 83 45 08 01 addl $0x1,0x8(%ebp)
while('0' <= *s && *s <= '9')
23f: eb 25 jmp 266 <atoi+0x75>
n = n*10 + *s++ - '0';
241: 8b 55 fc mov -0x4(%ebp),%edx
244: 89 d0 mov %edx,%eax
246: c1 e0 02 shl $0x2,%eax
249: 01 d0 add %edx,%eax
24b: 01 c0 add %eax,%eax
24d: 89 c1 mov %eax,%ecx
24f: 8b 45 08 mov 0x8(%ebp),%eax
252: 8d 50 01 lea 0x1(%eax),%edx
255: 89 55 08 mov %edx,0x8(%ebp)
258: 0f b6 00 movzbl (%eax),%eax
25b: 0f be c0 movsbl %al,%eax
25e: 01 c8 add %ecx,%eax
260: 83 e8 30 sub $0x30,%eax
263: 89 45 fc mov %eax,-0x4(%ebp)
n = 0;
while (*s == ' ') s++;
sign = (*s == '-') ? -1 : 1;
if (*s == '+' || *s == '-')
s++;
while('0' <= *s && *s <= '9')
266: 8b 45 08 mov 0x8(%ebp),%eax
269: 0f b6 00 movzbl (%eax),%eax
26c: 3c 2f cmp $0x2f,%al
26e: 7e 0a jle 27a <atoi+0x89>
270: 8b 45 08 mov 0x8(%ebp),%eax
273: 0f b6 00 movzbl (%eax),%eax
276: 3c 39 cmp $0x39,%al
278: 7e c7 jle 241 <atoi+0x50>
n = n*10 + *s++ - '0';
return sign*n;
27a: 8b 45 f8 mov -0x8(%ebp),%eax
27d: 0f af 45 fc imul -0x4(%ebp),%eax
}
281: c9 leave
282: c3 ret
00000283 <atoo>:
int
atoo(const char *s)
{
283: 55 push %ebp
284: 89 e5 mov %esp,%ebp
286: 83 ec 10 sub $0x10,%esp
int n, sign;
n = 0;
289: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while (*s == ' ') s++;
290: eb 04 jmp 296 <atoo+0x13>
292: 83 45 08 01 addl $0x1,0x8(%ebp)
296: 8b 45 08 mov 0x8(%ebp),%eax
299: 0f b6 00 movzbl (%eax),%eax
29c: 3c 20 cmp $0x20,%al
29e: 74 f2 je 292 <atoo+0xf>
sign = (*s == '-') ? -1 : 1;
2a0: 8b 45 08 mov 0x8(%ebp),%eax
2a3: 0f b6 00 movzbl (%eax),%eax
2a6: 3c 2d cmp $0x2d,%al
2a8: 75 07 jne 2b1 <atoo+0x2e>
2aa: b8 ff ff ff ff mov $0xffffffff,%eax
2af: eb 05 jmp 2b6 <atoo+0x33>
2b1: b8 01 00 00 00 mov $0x1,%eax
2b6: 89 45 f8 mov %eax,-0x8(%ebp)
if (*s == '+' || *s == '-')
2b9: 8b 45 08 mov 0x8(%ebp),%eax
2bc: 0f b6 00 movzbl (%eax),%eax
2bf: 3c 2b cmp $0x2b,%al
2c1: 74 0a je 2cd <atoo+0x4a>
2c3: 8b 45 08 mov 0x8(%ebp),%eax
2c6: 0f b6 00 movzbl (%eax),%eax
2c9: 3c 2d cmp $0x2d,%al
2cb: 75 27 jne 2f4 <atoo+0x71>
s++;
2cd: 83 45 08 01 addl $0x1,0x8(%ebp)
while('0' <= *s && *s <= '7')
2d1: eb 21 jmp 2f4 <atoo+0x71>
n = n*8 + *s++ - '0';
2d3: 8b 45 fc mov -0x4(%ebp),%eax
2d6: 8d 0c c5 00 00 00 00 lea 0x0(,%eax,8),%ecx
2dd: 8b 45 08 mov 0x8(%ebp),%eax
2e0: 8d 50 01 lea 0x1(%eax),%edx
2e3: 89 55 08 mov %edx,0x8(%ebp)
2e6: 0f b6 00 movzbl (%eax),%eax
2e9: 0f be c0 movsbl %al,%eax
2ec: 01 c8 add %ecx,%eax
2ee: 83 e8 30 sub $0x30,%eax
2f1: 89 45 fc mov %eax,-0x4(%ebp)
n = 0;
while (*s == ' ') s++;
sign = (*s == '-') ? -1 : 1;
if (*s == '+' || *s == '-')
s++;
while('0' <= *s && *s <= '7')
2f4: 8b 45 08 mov 0x8(%ebp),%eax
2f7: 0f b6 00 movzbl (%eax),%eax
2fa: 3c 2f cmp $0x2f,%al
2fc: 7e 0a jle 308 <atoo+0x85>
2fe: 8b 45 08 mov 0x8(%ebp),%eax
301: 0f b6 00 movzbl (%eax),%eax
304: 3c 37 cmp $0x37,%al
306: 7e cb jle 2d3 <atoo+0x50>
n = n*8 + *s++ - '0';
return sign*n;
308: 8b 45 f8 mov -0x8(%ebp),%eax
30b: 0f af 45 fc imul -0x4(%ebp),%eax
}
30f: c9 leave
310: c3 ret
00000311 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
311: 55 push %ebp
312: 89 e5 mov %esp,%ebp
314: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
317: 8b 45 08 mov 0x8(%ebp),%eax
31a: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
31d: 8b 45 0c mov 0xc(%ebp),%eax
320: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
323: eb 17 jmp 33c <memmove+0x2b>
*dst++ = *src++;
325: 8b 45 fc mov -0x4(%ebp),%eax
328: 8d 50 01 lea 0x1(%eax),%edx
32b: 89 55 fc mov %edx,-0x4(%ebp)
32e: 8b 55 f8 mov -0x8(%ebp),%edx
331: 8d 4a 01 lea 0x1(%edx),%ecx
334: 89 4d f8 mov %ecx,-0x8(%ebp)
337: 0f b6 12 movzbl (%edx),%edx
33a: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
33c: 8b 45 10 mov 0x10(%ebp),%eax
33f: 8d 50 ff lea -0x1(%eax),%edx
342: 89 55 10 mov %edx,0x10(%ebp)
345: 85 c0 test %eax,%eax
347: 7f dc jg 325 <memmove+0x14>
*dst++ = *src++;
return vdst;
349: 8b 45 08 mov 0x8(%ebp),%eax
}
34c: c9 leave
34d: c3 ret
0000034e <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
34e: b8 01 00 00 00 mov $0x1,%eax
353: cd 40 int $0x40
355: c3 ret
00000356 <exit>:
SYSCALL(exit)
356: b8 02 00 00 00 mov $0x2,%eax
35b: cd 40 int $0x40
35d: c3 ret
0000035e <wait>:
SYSCALL(wait)
35e: b8 03 00 00 00 mov $0x3,%eax
363: cd 40 int $0x40
365: c3 ret
00000366 <pipe>:
SYSCALL(pipe)
366: b8 04 00 00 00 mov $0x4,%eax
36b: cd 40 int $0x40
36d: c3 ret
0000036e <read>:
SYSCALL(read)
36e: b8 05 00 00 00 mov $0x5,%eax
373: cd 40 int $0x40
375: c3 ret
00000376 <write>:
SYSCALL(write)
376: b8 10 00 00 00 mov $0x10,%eax
37b: cd 40 int $0x40
37d: c3 ret
0000037e <close>:
SYSCALL(close)
37e: b8 15 00 00 00 mov $0x15,%eax
383: cd 40 int $0x40
385: c3 ret
00000386 <kill>:
SYSCALL(kill)
386: b8 06 00 00 00 mov $0x6,%eax
38b: cd 40 int $0x40
38d: c3 ret
0000038e <exec>:
SYSCALL(exec)
38e: b8 07 00 00 00 mov $0x7,%eax
393: cd 40 int $0x40
395: c3 ret
00000396 <open>:
SYSCALL(open)
396: b8 0f 00 00 00 mov $0xf,%eax
39b: cd 40 int $0x40
39d: c3 ret
0000039e <mknod>:
SYSCALL(mknod)
39e: b8 11 00 00 00 mov $0x11,%eax
3a3: cd 40 int $0x40
3a5: c3 ret
000003a6 <unlink>:
SYSCALL(unlink)
3a6: b8 12 00 00 00 mov $0x12,%eax
3ab: cd 40 int $0x40
3ad: c3 ret
000003ae <fstat>:
SYSCALL(fstat)
3ae: b8 08 00 00 00 mov $0x8,%eax
3b3: cd 40 int $0x40
3b5: c3 ret
000003b6 <link>:
SYSCALL(link)
3b6: b8 13 00 00 00 mov $0x13,%eax
3bb: cd 40 int $0x40
3bd: c3 ret
000003be <mkdir>:
SYSCALL(mkdir)
3be: b8 14 00 00 00 mov $0x14,%eax
3c3: cd 40 int $0x40
3c5: c3 ret
000003c6 <chdir>:
SYSCALL(chdir)
3c6: b8 09 00 00 00 mov $0x9,%eax
3cb: cd 40 int $0x40
3cd: c3 ret
000003ce <dup>:
SYSCALL(dup)
3ce: b8 0a 00 00 00 mov $0xa,%eax
3d3: cd 40 int $0x40
3d5: c3 ret
000003d6 <getpid>:
SYSCALL(getpid)
3d6: b8 0b 00 00 00 mov $0xb,%eax
3db: cd 40 int $0x40
3dd: c3 ret
000003de <sbrk>:
SYSCALL(sbrk)
3de: b8 0c 00 00 00 mov $0xc,%eax
3e3: cd 40 int $0x40
3e5: c3 ret
000003e6 <sleep>:
SYSCALL(sleep)
3e6: b8 0d 00 00 00 mov $0xd,%eax
3eb: cd 40 int $0x40
3ed: c3 ret
000003ee <uptime>:
SYSCALL(uptime)
3ee: b8 0e 00 00 00 mov $0xe,%eax
3f3: cd 40 int $0x40
3f5: c3 ret
000003f6 <halt>:
SYSCALL(halt)
3f6: b8 16 00 00 00 mov $0x16,%eax
3fb: cd 40 int $0x40
3fd: c3 ret
000003fe <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
3fe: 55 push %ebp
3ff: 89 e5 mov %esp,%ebp
401: 83 ec 18 sub $0x18,%esp
404: 8b 45 0c mov 0xc(%ebp),%eax
407: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
40a: 83 ec 04 sub $0x4,%esp
40d: 6a 01 push $0x1
40f: 8d 45 f4 lea -0xc(%ebp),%eax
412: 50 push %eax
413: ff 75 08 pushl 0x8(%ebp)
416: e8 5b ff ff ff call 376 <write>
41b: 83 c4 10 add $0x10,%esp
}
41e: 90 nop
41f: c9 leave
420: c3 ret
00000421 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
421: 55 push %ebp
422: 89 e5 mov %esp,%ebp
424: 53 push %ebx
425: 83 ec 24 sub $0x24,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
428: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
42f: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
433: 74 17 je 44c <printint+0x2b>
435: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
439: 79 11 jns 44c <printint+0x2b>
neg = 1;
43b: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
442: 8b 45 0c mov 0xc(%ebp),%eax
445: f7 d8 neg %eax
447: 89 45 ec mov %eax,-0x14(%ebp)
44a: eb 06 jmp 452 <printint+0x31>
} else {
x = xx;
44c: 8b 45 0c mov 0xc(%ebp),%eax
44f: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
452: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
459: 8b 4d f4 mov -0xc(%ebp),%ecx
45c: 8d 41 01 lea 0x1(%ecx),%eax
45f: 89 45 f4 mov %eax,-0xc(%ebp)
462: 8b 5d 10 mov 0x10(%ebp),%ebx
465: 8b 45 ec mov -0x14(%ebp),%eax
468: ba 00 00 00 00 mov $0x0,%edx
46d: f7 f3 div %ebx
46f: 89 d0 mov %edx,%eax
471: 0f b6 80 fc 0a 00 00 movzbl 0xafc(%eax),%eax
478: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
47c: 8b 5d 10 mov 0x10(%ebp),%ebx
47f: 8b 45 ec mov -0x14(%ebp),%eax
482: ba 00 00 00 00 mov $0x0,%edx
487: f7 f3 div %ebx
489: 89 45 ec mov %eax,-0x14(%ebp)
48c: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
490: 75 c7 jne 459 <printint+0x38>
if(neg)
492: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
496: 74 2d je 4c5 <printint+0xa4>
buf[i++] = '-';
498: 8b 45 f4 mov -0xc(%ebp),%eax
49b: 8d 50 01 lea 0x1(%eax),%edx
49e: 89 55 f4 mov %edx,-0xc(%ebp)
4a1: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
4a6: eb 1d jmp 4c5 <printint+0xa4>
putc(fd, buf[i]);
4a8: 8d 55 dc lea -0x24(%ebp),%edx
4ab: 8b 45 f4 mov -0xc(%ebp),%eax
4ae: 01 d0 add %edx,%eax
4b0: 0f b6 00 movzbl (%eax),%eax
4b3: 0f be c0 movsbl %al,%eax
4b6: 83 ec 08 sub $0x8,%esp
4b9: 50 push %eax
4ba: ff 75 08 pushl 0x8(%ebp)
4bd: e8 3c ff ff ff call 3fe <putc>
4c2: 83 c4 10 add $0x10,%esp
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
4c5: 83 6d f4 01 subl $0x1,-0xc(%ebp)
4c9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
4cd: 79 d9 jns 4a8 <printint+0x87>
putc(fd, buf[i]);
}
4cf: 90 nop
4d0: 8b 5d fc mov -0x4(%ebp),%ebx
4d3: c9 leave
4d4: c3 ret
000004d5 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
4d5: 55 push %ebp
4d6: 89 e5 mov %esp,%ebp
4d8: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
4db: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
4e2: 8d 45 0c lea 0xc(%ebp),%eax
4e5: 83 c0 04 add $0x4,%eax
4e8: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
4eb: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
4f2: e9 59 01 00 00 jmp 650 <printf+0x17b>
c = fmt[i] & 0xff;
4f7: 8b 55 0c mov 0xc(%ebp),%edx
4fa: 8b 45 f0 mov -0x10(%ebp),%eax
4fd: 01 d0 add %edx,%eax
4ff: 0f b6 00 movzbl (%eax),%eax
502: 0f be c0 movsbl %al,%eax
505: 25 ff 00 00 00 and $0xff,%eax
50a: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
50d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
511: 75 2c jne 53f <printf+0x6a>
if(c == '%'){
513: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
517: 75 0c jne 525 <printf+0x50>
state = '%';
519: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
520: e9 27 01 00 00 jmp 64c <printf+0x177>
} else {
putc(fd, c);
525: 8b 45 e4 mov -0x1c(%ebp),%eax
528: 0f be c0 movsbl %al,%eax
52b: 83 ec 08 sub $0x8,%esp
52e: 50 push %eax
52f: ff 75 08 pushl 0x8(%ebp)
532: e8 c7 fe ff ff call 3fe <putc>
537: 83 c4 10 add $0x10,%esp
53a: e9 0d 01 00 00 jmp 64c <printf+0x177>
}
} else if(state == '%'){
53f: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
543: 0f 85 03 01 00 00 jne 64c <printf+0x177>
if(c == 'd'){
549: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
54d: 75 1e jne 56d <printf+0x98>
printint(fd, *ap, 10, 1);
54f: 8b 45 e8 mov -0x18(%ebp),%eax
552: 8b 00 mov (%eax),%eax
554: 6a 01 push $0x1
556: 6a 0a push $0xa
558: 50 push %eax
559: ff 75 08 pushl 0x8(%ebp)
55c: e8 c0 fe ff ff call 421 <printint>
561: 83 c4 10 add $0x10,%esp
ap++;
564: 83 45 e8 04 addl $0x4,-0x18(%ebp)
568: e9 d8 00 00 00 jmp 645 <printf+0x170>
} else if(c == 'x' || c == 'p'){
56d: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
571: 74 06 je 579 <printf+0xa4>
573: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
577: 75 1e jne 597 <printf+0xc2>
printint(fd, *ap, 16, 0);
579: 8b 45 e8 mov -0x18(%ebp),%eax
57c: 8b 00 mov (%eax),%eax
57e: 6a 00 push $0x0
580: 6a 10 push $0x10
582: 50 push %eax
583: ff 75 08 pushl 0x8(%ebp)
586: e8 96 fe ff ff call 421 <printint>
58b: 83 c4 10 add $0x10,%esp
ap++;
58e: 83 45 e8 04 addl $0x4,-0x18(%ebp)
592: e9 ae 00 00 00 jmp 645 <printf+0x170>
} else if(c == 's'){
597: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
59b: 75 43 jne 5e0 <printf+0x10b>
s = (char*)*ap;
59d: 8b 45 e8 mov -0x18(%ebp),%eax
5a0: 8b 00 mov (%eax),%eax
5a2: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
5a5: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
5a9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
5ad: 75 25 jne 5d4 <printf+0xff>
s = "(null)";
5af: c7 45 f4 8b 08 00 00 movl $0x88b,-0xc(%ebp)
while(*s != 0){
5b6: eb 1c jmp 5d4 <printf+0xff>
putc(fd, *s);
5b8: 8b 45 f4 mov -0xc(%ebp),%eax
5bb: 0f b6 00 movzbl (%eax),%eax
5be: 0f be c0 movsbl %al,%eax
5c1: 83 ec 08 sub $0x8,%esp
5c4: 50 push %eax
5c5: ff 75 08 pushl 0x8(%ebp)
5c8: e8 31 fe ff ff call 3fe <putc>
5cd: 83 c4 10 add $0x10,%esp
s++;
5d0: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
5d4: 8b 45 f4 mov -0xc(%ebp),%eax
5d7: 0f b6 00 movzbl (%eax),%eax
5da: 84 c0 test %al,%al
5dc: 75 da jne 5b8 <printf+0xe3>
5de: eb 65 jmp 645 <printf+0x170>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
5e0: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
5e4: 75 1d jne 603 <printf+0x12e>
putc(fd, *ap);
5e6: 8b 45 e8 mov -0x18(%ebp),%eax
5e9: 8b 00 mov (%eax),%eax
5eb: 0f be c0 movsbl %al,%eax
5ee: 83 ec 08 sub $0x8,%esp
5f1: 50 push %eax
5f2: ff 75 08 pushl 0x8(%ebp)
5f5: e8 04 fe ff ff call 3fe <putc>
5fa: 83 c4 10 add $0x10,%esp
ap++;
5fd: 83 45 e8 04 addl $0x4,-0x18(%ebp)
601: eb 42 jmp 645 <printf+0x170>
} else if(c == '%'){
603: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
607: 75 17 jne 620 <printf+0x14b>
putc(fd, c);
609: 8b 45 e4 mov -0x1c(%ebp),%eax
60c: 0f be c0 movsbl %al,%eax
60f: 83 ec 08 sub $0x8,%esp
612: 50 push %eax
613: ff 75 08 pushl 0x8(%ebp)
616: e8 e3 fd ff ff call 3fe <putc>
61b: 83 c4 10 add $0x10,%esp
61e: eb 25 jmp 645 <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
620: 83 ec 08 sub $0x8,%esp
623: 6a 25 push $0x25
625: ff 75 08 pushl 0x8(%ebp)
628: e8 d1 fd ff ff call 3fe <putc>
62d: 83 c4 10 add $0x10,%esp
putc(fd, c);
630: 8b 45 e4 mov -0x1c(%ebp),%eax
633: 0f be c0 movsbl %al,%eax
636: 83 ec 08 sub $0x8,%esp
639: 50 push %eax
63a: ff 75 08 pushl 0x8(%ebp)
63d: e8 bc fd ff ff call 3fe <putc>
642: 83 c4 10 add $0x10,%esp
}
state = 0;
645: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
64c: 83 45 f0 01 addl $0x1,-0x10(%ebp)
650: 8b 55 0c mov 0xc(%ebp),%edx
653: 8b 45 f0 mov -0x10(%ebp),%eax
656: 01 d0 add %edx,%eax
658: 0f b6 00 movzbl (%eax),%eax
65b: 84 c0 test %al,%al
65d: 0f 85 94 fe ff ff jne 4f7 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
663: 90 nop
664: c9 leave
665: c3 ret
00000666 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
666: 55 push %ebp
667: 89 e5 mov %esp,%ebp
669: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
66c: 8b 45 08 mov 0x8(%ebp),%eax
66f: 83 e8 08 sub $0x8,%eax
672: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
675: a1 18 0b 00 00 mov 0xb18,%eax
67a: 89 45 fc mov %eax,-0x4(%ebp)
67d: eb 24 jmp 6a3 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
67f: 8b 45 fc mov -0x4(%ebp),%eax
682: 8b 00 mov (%eax),%eax
684: 3b 45 fc cmp -0x4(%ebp),%eax
687: 77 12 ja 69b <free+0x35>
689: 8b 45 f8 mov -0x8(%ebp),%eax
68c: 3b 45 fc cmp -0x4(%ebp),%eax
68f: 77 24 ja 6b5 <free+0x4f>
691: 8b 45 fc mov -0x4(%ebp),%eax
694: 8b 00 mov (%eax),%eax
696: 3b 45 f8 cmp -0x8(%ebp),%eax
699: 77 1a ja 6b5 <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)
69b: 8b 45 fc mov -0x4(%ebp),%eax
69e: 8b 00 mov (%eax),%eax
6a0: 89 45 fc mov %eax,-0x4(%ebp)
6a3: 8b 45 f8 mov -0x8(%ebp),%eax
6a6: 3b 45 fc cmp -0x4(%ebp),%eax
6a9: 76 d4 jbe 67f <free+0x19>
6ab: 8b 45 fc mov -0x4(%ebp),%eax
6ae: 8b 00 mov (%eax),%eax
6b0: 3b 45 f8 cmp -0x8(%ebp),%eax
6b3: 76 ca jbe 67f <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
6b5: 8b 45 f8 mov -0x8(%ebp),%eax
6b8: 8b 40 04 mov 0x4(%eax),%eax
6bb: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
6c2: 8b 45 f8 mov -0x8(%ebp),%eax
6c5: 01 c2 add %eax,%edx
6c7: 8b 45 fc mov -0x4(%ebp),%eax
6ca: 8b 00 mov (%eax),%eax
6cc: 39 c2 cmp %eax,%edx
6ce: 75 24 jne 6f4 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
6d0: 8b 45 f8 mov -0x8(%ebp),%eax
6d3: 8b 50 04 mov 0x4(%eax),%edx
6d6: 8b 45 fc mov -0x4(%ebp),%eax
6d9: 8b 00 mov (%eax),%eax
6db: 8b 40 04 mov 0x4(%eax),%eax
6de: 01 c2 add %eax,%edx
6e0: 8b 45 f8 mov -0x8(%ebp),%eax
6e3: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
6e6: 8b 45 fc mov -0x4(%ebp),%eax
6e9: 8b 00 mov (%eax),%eax
6eb: 8b 10 mov (%eax),%edx
6ed: 8b 45 f8 mov -0x8(%ebp),%eax
6f0: 89 10 mov %edx,(%eax)
6f2: eb 0a jmp 6fe <free+0x98>
} else
bp->s.ptr = p->s.ptr;
6f4: 8b 45 fc mov -0x4(%ebp),%eax
6f7: 8b 10 mov (%eax),%edx
6f9: 8b 45 f8 mov -0x8(%ebp),%eax
6fc: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
6fe: 8b 45 fc mov -0x4(%ebp),%eax
701: 8b 40 04 mov 0x4(%eax),%eax
704: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
70b: 8b 45 fc mov -0x4(%ebp),%eax
70e: 01 d0 add %edx,%eax
710: 3b 45 f8 cmp -0x8(%ebp),%eax
713: 75 20 jne 735 <free+0xcf>
p->s.size += bp->s.size;
715: 8b 45 fc mov -0x4(%ebp),%eax
718: 8b 50 04 mov 0x4(%eax),%edx
71b: 8b 45 f8 mov -0x8(%ebp),%eax
71e: 8b 40 04 mov 0x4(%eax),%eax
721: 01 c2 add %eax,%edx
723: 8b 45 fc mov -0x4(%ebp),%eax
726: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
729: 8b 45 f8 mov -0x8(%ebp),%eax
72c: 8b 10 mov (%eax),%edx
72e: 8b 45 fc mov -0x4(%ebp),%eax
731: 89 10 mov %edx,(%eax)
733: eb 08 jmp 73d <free+0xd7>
} else
p->s.ptr = bp;
735: 8b 45 fc mov -0x4(%ebp),%eax
738: 8b 55 f8 mov -0x8(%ebp),%edx
73b: 89 10 mov %edx,(%eax)
freep = p;
73d: 8b 45 fc mov -0x4(%ebp),%eax
740: a3 18 0b 00 00 mov %eax,0xb18
}
745: 90 nop
746: c9 leave
747: c3 ret
00000748 <morecore>:
static Header*
morecore(uint nu)
{
748: 55 push %ebp
749: 89 e5 mov %esp,%ebp
74b: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
74e: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
755: 77 07 ja 75e <morecore+0x16>
nu = 4096;
757: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
75e: 8b 45 08 mov 0x8(%ebp),%eax
761: c1 e0 03 shl $0x3,%eax
764: 83 ec 0c sub $0xc,%esp
767: 50 push %eax
768: e8 71 fc ff ff call 3de <sbrk>
76d: 83 c4 10 add $0x10,%esp
770: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
773: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
777: 75 07 jne 780 <morecore+0x38>
return 0;
779: b8 00 00 00 00 mov $0x0,%eax
77e: eb 26 jmp 7a6 <morecore+0x5e>
hp = (Header*)p;
780: 8b 45 f4 mov -0xc(%ebp),%eax
783: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
786: 8b 45 f0 mov -0x10(%ebp),%eax
789: 8b 55 08 mov 0x8(%ebp),%edx
78c: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
78f: 8b 45 f0 mov -0x10(%ebp),%eax
792: 83 c0 08 add $0x8,%eax
795: 83 ec 0c sub $0xc,%esp
798: 50 push %eax
799: e8 c8 fe ff ff call 666 <free>
79e: 83 c4 10 add $0x10,%esp
return freep;
7a1: a1 18 0b 00 00 mov 0xb18,%eax
}
7a6: c9 leave
7a7: c3 ret
000007a8 <malloc>:
void*
malloc(uint nbytes)
{
7a8: 55 push %ebp
7a9: 89 e5 mov %esp,%ebp
7ab: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
7ae: 8b 45 08 mov 0x8(%ebp),%eax
7b1: 83 c0 07 add $0x7,%eax
7b4: c1 e8 03 shr $0x3,%eax
7b7: 83 c0 01 add $0x1,%eax
7ba: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
7bd: a1 18 0b 00 00 mov 0xb18,%eax
7c2: 89 45 f0 mov %eax,-0x10(%ebp)
7c5: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
7c9: 75 23 jne 7ee <malloc+0x46>
base.s.ptr = freep = prevp = &base;
7cb: c7 45 f0 10 0b 00 00 movl $0xb10,-0x10(%ebp)
7d2: 8b 45 f0 mov -0x10(%ebp),%eax
7d5: a3 18 0b 00 00 mov %eax,0xb18
7da: a1 18 0b 00 00 mov 0xb18,%eax
7df: a3 10 0b 00 00 mov %eax,0xb10
base.s.size = 0;
7e4: c7 05 14 0b 00 00 00 movl $0x0,0xb14
7eb: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7ee: 8b 45 f0 mov -0x10(%ebp),%eax
7f1: 8b 00 mov (%eax),%eax
7f3: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
7f6: 8b 45 f4 mov -0xc(%ebp),%eax
7f9: 8b 40 04 mov 0x4(%eax),%eax
7fc: 3b 45 ec cmp -0x14(%ebp),%eax
7ff: 72 4d jb 84e <malloc+0xa6>
if(p->s.size == nunits)
801: 8b 45 f4 mov -0xc(%ebp),%eax
804: 8b 40 04 mov 0x4(%eax),%eax
807: 3b 45 ec cmp -0x14(%ebp),%eax
80a: 75 0c jne 818 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
80c: 8b 45 f4 mov -0xc(%ebp),%eax
80f: 8b 10 mov (%eax),%edx
811: 8b 45 f0 mov -0x10(%ebp),%eax
814: 89 10 mov %edx,(%eax)
816: eb 26 jmp 83e <malloc+0x96>
else {
p->s.size -= nunits;
818: 8b 45 f4 mov -0xc(%ebp),%eax
81b: 8b 40 04 mov 0x4(%eax),%eax
81e: 2b 45 ec sub -0x14(%ebp),%eax
821: 89 c2 mov %eax,%edx
823: 8b 45 f4 mov -0xc(%ebp),%eax
826: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
829: 8b 45 f4 mov -0xc(%ebp),%eax
82c: 8b 40 04 mov 0x4(%eax),%eax
82f: c1 e0 03 shl $0x3,%eax
832: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
835: 8b 45 f4 mov -0xc(%ebp),%eax
838: 8b 55 ec mov -0x14(%ebp),%edx
83b: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
83e: 8b 45 f0 mov -0x10(%ebp),%eax
841: a3 18 0b 00 00 mov %eax,0xb18
return (void*)(p + 1);
846: 8b 45 f4 mov -0xc(%ebp),%eax
849: 83 c0 08 add $0x8,%eax
84c: eb 3b jmp 889 <malloc+0xe1>
}
if(p == freep)
84e: a1 18 0b 00 00 mov 0xb18,%eax
853: 39 45 f4 cmp %eax,-0xc(%ebp)
856: 75 1e jne 876 <malloc+0xce>
if((p = morecore(nunits)) == 0)
858: 83 ec 0c sub $0xc,%esp
85b: ff 75 ec pushl -0x14(%ebp)
85e: e8 e5 fe ff ff call 748 <morecore>
863: 83 c4 10 add $0x10,%esp
866: 89 45 f4 mov %eax,-0xc(%ebp)
869: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
86d: 75 07 jne 876 <malloc+0xce>
return 0;
86f: b8 00 00 00 00 mov $0x0,%eax
874: eb 13 jmp 889 <malloc+0xe1>
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){
876: 8b 45 f4 mov -0xc(%ebp),%eax
879: 89 45 f0 mov %eax,-0x10(%ebp)
87c: 8b 45 f4 mov -0xc(%ebp),%eax
87f: 8b 00 mov (%eax),%eax
881: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
884: e9 6d ff ff ff jmp 7f6 <malloc+0x4e>
}
889: c9 leave
88a: c3 ret
|
// Copyright (c) 2012-2013 The Bitcoin Core developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2017-2019 The Adeptio developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "key.h"
#include "base58.h"
#include "script/script.h"
#include "uint256.h"
#include "util.h"
#include "utilstrencodings.h"
#include <string>
#include <vector>
#include <boost/test/unit_test.hpp>
using namespace std;
static const string strSecret1 ("87vK7Vayi3QLsuiva5yWSuVwSMhMcRM9dBsaD6JXMD1P5vnjRFn");
static const string strSecret2 ("87FGYGFDg5SYfdD4XL593hr7do6f52czPecVsYSAXi8N4RGeS9i");
static const string strSecret1C ("YRYJwfAyJ9c2jhi3T2xQyLijGvM7yLTw4izDaNQLxBzgUYrQiPmJ");
static const string strSecret2C ("YNZyazHkwUbkmUpEYsBGWwHnHQTy2n9rJy1gS5k54YXVx3pE8n6N");
static const CBitcoinAddress addr1 ("DBFi8XAE1rcdCQfkv9w22n8Y9RxgaJnrDD");
static const CBitcoinAddress addr2 ("DPvKfv1FVp69yZMDzeuugvfZ9pzYiMv1bs");
static const CBitcoinAddress addr1C("DNPrHK9ezAAUVExFDpZ7EE1xWpPskgp1gP");
static const CBitcoinAddress addr2C("DNBVSAoc2whPFjZVAZ1pQbXPJk1LRrDC8Q");
static const string strAddressBad("Xta1praZQjyELweyMByXyiREw1ZRsjXzVP");
#ifdef KEY_TESTS_DUMPINFO
void dumpKeyInfo(uint256 privkey)
{
CKey key;
key.resize(32);
memcpy(&secret[0], &privkey, 32);
vector<unsigned char> sec;
sec.resize(32);
memcpy(&sec[0], &secret[0], 32);
printf(" * secret (hex): %s\n", HexStr(sec).c_str());
for (int nCompressed=0; nCompressed<2; nCompressed++)
{
bool fCompressed = nCompressed == 1;
printf(" * %s:\n", fCompressed ? "compressed" : "uncompressed");
CBitcoinSecret bsecret;
bsecret.SetSecret(secret, fCompressed);
printf(" * secret (base58): %s\n", bsecret.ToString().c_str());
CKey key;
key.SetSecret(secret, fCompressed);
vector<unsigned char> vchPubKey = key.GetPubKey();
printf(" * pubkey (hex): %s\n", HexStr(vchPubKey).c_str());
printf(" * address (base58): %s\n", CBitcoinAddress(vchPubKey).ToString().c_str());
}
}
#endif
BOOST_AUTO_TEST_SUITE(key_tests)
BOOST_AUTO_TEST_CASE(key_test1)
{
CBitcoinSecret bsecret1, bsecret2, bsecret1C, bsecret2C, baddress1;
BOOST_CHECK( bsecret1.SetString (strSecret1));
BOOST_CHECK( bsecret2.SetString (strSecret2));
BOOST_CHECK( bsecret1C.SetString(strSecret1C));
BOOST_CHECK( bsecret2C.SetString(strSecret2C));
BOOST_CHECK(!baddress1.SetString(strAddressBad));
CKey key1 = bsecret1.GetKey();
BOOST_CHECK(key1.IsCompressed() == false);
CKey key2 = bsecret2.GetKey();
BOOST_CHECK(key2.IsCompressed() == false);
CKey key1C = bsecret1C.GetKey();
BOOST_CHECK(key1C.IsCompressed() == true);
CKey key2C = bsecret2C.GetKey();
BOOST_CHECK(key2C.IsCompressed() == true);
CPubKey pubkey1 = key1. GetPubKey();
CPubKey pubkey2 = key2. GetPubKey();
CPubKey pubkey1C = key1C.GetPubKey();
CPubKey pubkey2C = key2C.GetPubKey();
BOOST_CHECK(key1.VerifyPubKey(pubkey1));
BOOST_CHECK(!key1.VerifyPubKey(pubkey1C));
BOOST_CHECK(!key1.VerifyPubKey(pubkey2));
BOOST_CHECK(!key1.VerifyPubKey(pubkey2C));
BOOST_CHECK(!key1C.VerifyPubKey(pubkey1));
BOOST_CHECK(key1C.VerifyPubKey(pubkey1C));
BOOST_CHECK(!key1C.VerifyPubKey(pubkey2));
BOOST_CHECK(!key1C.VerifyPubKey(pubkey2C));
BOOST_CHECK(!key2.VerifyPubKey(pubkey1));
BOOST_CHECK(!key2.VerifyPubKey(pubkey1C));
BOOST_CHECK(key2.VerifyPubKey(pubkey2));
BOOST_CHECK(!key2.VerifyPubKey(pubkey2C));
BOOST_CHECK(!key2C.VerifyPubKey(pubkey1));
BOOST_CHECK(!key2C.VerifyPubKey(pubkey1C));
BOOST_CHECK(!key2C.VerifyPubKey(pubkey2));
BOOST_CHECK(key2C.VerifyPubKey(pubkey2C));
BOOST_CHECK(addr1.Get() == CTxDestination(pubkey1.GetID()));
BOOST_CHECK(addr2.Get() == CTxDestination(pubkey2.GetID()));
BOOST_CHECK(addr1C.Get() == CTxDestination(pubkey1C.GetID()));
BOOST_CHECK(addr2C.Get() == CTxDestination(pubkey2C.GetID()));
for (int n=0; n<16; n++)
{
string strMsg = strprintf("Very secret message %i: 11", n);
uint256 hashMsg = Hash(strMsg.begin(), strMsg.end());
// normal signatures
vector<unsigned char> sign1, sign2, sign1C, sign2C;
BOOST_CHECK(key1.Sign (hashMsg, sign1));
BOOST_CHECK(key2.Sign (hashMsg, sign2));
BOOST_CHECK(key1C.Sign(hashMsg, sign1C));
BOOST_CHECK(key2C.Sign(hashMsg, sign2C));
BOOST_CHECK( pubkey1.Verify(hashMsg, sign1));
BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2));
BOOST_CHECK( pubkey1.Verify(hashMsg, sign1C));
BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2C));
BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1));
BOOST_CHECK( pubkey2.Verify(hashMsg, sign2));
BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1C));
BOOST_CHECK( pubkey2.Verify(hashMsg, sign2C));
BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1));
BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2));
BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1C));
BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2C));
BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1));
BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2));
BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1C));
BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2C));
// compact signatures (with key recovery)
vector<unsigned char> csign1, csign2, csign1C, csign2C;
BOOST_CHECK(key1.SignCompact (hashMsg, csign1));
BOOST_CHECK(key2.SignCompact (hashMsg, csign2));
BOOST_CHECK(key1C.SignCompact(hashMsg, csign1C));
BOOST_CHECK(key2C.SignCompact(hashMsg, csign2C));
CPubKey rkey1, rkey2, rkey1C, rkey2C;
BOOST_CHECK(rkey1.RecoverCompact (hashMsg, csign1));
BOOST_CHECK(rkey2.RecoverCompact (hashMsg, csign2));
BOOST_CHECK(rkey1C.RecoverCompact(hashMsg, csign1C));
BOOST_CHECK(rkey2C.RecoverCompact(hashMsg, csign2C));
BOOST_CHECK(rkey1 == pubkey1);
BOOST_CHECK(rkey2 == pubkey2);
BOOST_CHECK(rkey1C == pubkey1C);
BOOST_CHECK(rkey2C == pubkey2C);
}
// test deterministic signing
std::vector<unsigned char> detsig, detsigc;
string strMsg = "Very deterministic message";
uint256 hashMsg = Hash(strMsg.begin(), strMsg.end());
BOOST_CHECK(key1.Sign(hashMsg, detsig));
BOOST_CHECK(key1C.Sign(hashMsg, detsigc));
BOOST_CHECK(detsig == detsigc);
BOOST_CHECK(detsig == ParseHex("30450221009071d4fead181ea197d6a23106c48ee5de25e023b38afaf71c170e3088e5238a02200dcbc7f1aad626a5ee812e08ef047114642538e423a94b4bd6a272731cf500d0"));
BOOST_CHECK(key2.Sign(hashMsg, detsig));
BOOST_CHECK(key2C.Sign(hashMsg, detsigc));
BOOST_CHECK(detsig == detsigc);
BOOST_CHECK(detsig == ParseHex("304402204f304f1b05599f88bc517819f6d43c69503baea5f253c55ea2d791394f7ce0de02204f23c0d4c1f4d7a89bf130fed755201d22581911a8a44cf594014794231d325a"));
BOOST_CHECK(key1.SignCompact(hashMsg, detsig));
BOOST_CHECK(key1C.SignCompact(hashMsg, detsigc));
BOOST_CHECK(detsig == ParseHex("1b9071d4fead181ea197d6a23106c48ee5de25e023b38afaf71c170e3088e5238a0dcbc7f1aad626a5ee812e08ef047114642538e423a94b4bd6a272731cf500d0"));
BOOST_CHECK(detsigc == ParseHex("1f9071d4fead181ea197d6a23106c48ee5de25e023b38afaf71c170e3088e5238a0dcbc7f1aad626a5ee812e08ef047114642538e423a94b4bd6a272731cf500d0"));
BOOST_CHECK(key2.SignCompact(hashMsg, detsig));
BOOST_CHECK(key2C.SignCompact(hashMsg, detsigc));
BOOST_CHECK(detsig == ParseHex("1b4f304f1b05599f88bc517819f6d43c69503baea5f253c55ea2d791394f7ce0de4f23c0d4c1f4d7a89bf130fed755201d22581911a8a44cf594014794231d325a"));
BOOST_CHECK(detsigc == ParseHex("1f4f304f1b05599f88bc517819f6d43c69503baea5f253c55ea2d791394f7ce0de4f23c0d4c1f4d7a89bf130fed755201d22581911a8a44cf594014794231d325a"));
}
BOOST_AUTO_TEST_SUITE_END()
|
; A027658: C(n+2,2)+C(n+4,5).
; 1,4,12,31,71,147,280,498,837,1342,2068,3081,4459,6293,8688,11764,15657,20520,26524,33859,42735,53383,66056,81030,98605,119106,142884,170317,201811,237801,278752,325160,377553,436492,502572,576423,658711,750139,851448,963418,1086869,1222662,1371700,1534929,1713339,1907965,2119888,2350236,2600185,2870960,3163836,3480139,3821247,4188591,4583656,5007982,5463165,5950858,6472772,7030677,7626403,8261841,8938944,9659728,10426273,11240724,12105292,13022255,13993959,15022819,16111320,17262018,18477541,19760590,21113940,22540441,24043019,25624677,27288496,29037636,30875337,32804920,34829788,36953427,39179407,41511383,43953096,46508374,49181133,51975378,54895204,57944797,61128435,64450489,67915424,71527800,75292273,79213596,83296620,87546295,91967671,96565899,101346232,106314026,111474741,116833942,122397300,128170593,134159707,140370637,146809488,153482476,160395929,167556288,174970108,182644059,190584927,198799615,207295144,216078654,225157405,234538778,244230276,254239525,264574275,275242401,286251904,297610912,309327681,321410596,333868172,346709055,359942023,373575987,387619992,402083218,416974981,432304734,448082068,464316713,481018539,498197557,515863920,534027924,552700009,571890760,591610908,611871331,632683055,654057255,676005256,698538534,721668717,745407586,769767076,794759277,820396435,846690953,873655392,901302472,929645073,958696236,988469164,1018977223,1050233943,1082253019,1115048312,1148633850,1183023829,1218232614,1254274740,1291164913,1328918011,1367549085,1407073360,1447506236,1488863289,1531160272,1574413116,1618637931,1663851007,1710068815,1757308008,1805585422,1854918077,1905323178,1956818116,2009420469,2063148003,2118018673,2174050624,2231262192,2289671905,2349298484,2410160844,2472278095,2535669543,2600354691,2666353240,2733685090,2802370341,2872429294,2943882452,3016750521,3091054411,3166815237,3244054320,3322793188,3403053577,3484857432,3568226908,3653184371,3739752399,3827953783,3917811528,4009348854,4102589197,4197556210,4294273764,4392765949,4493057075,4595171673,4699134496,4804970520,4912704945,5022363196,5133970924,5247554007,5363138551,5480750891,5600417592,5722165450,5846021493,5972012982,6100167412,6230512513,6363076251,6497886829,6634972688,6774362508,6916085209,7060169952,7206646140,7355543419,7506891679,7660721055,7817061928,7975944926,8137400925,8301461050
mov $12,$0
mov $14,$0
add $14,1
lpb $14,1
clr $0,12
mov $0,$12
sub $14,1
sub $0,$14
mov $9,$0
mov $11,$0
add $11,1
lpb $11,1
mov $0,$9
sub $11,1
sub $0,$11
add $0,8
mov $7,$0
sub $7,6
bin $7,3
add $7,1
add $10,$7
lpe
add $13,$10
lpe
mov $1,$13
|
;
; ANSI Video handling for the Sharp PC G-800 family
;
; Stefano Bodrato - 2017
;
; set it up with:
; .__console_w = max columns
; .__console_h = max rows
;
; Display a char in location (__console_y),(__console_x)
; A=char to display
;
;
; $Id: f_ansi_char.asm$
;
SECTION code_clib
PUBLIC ansi_CHAR
EXTERN __console_y
EXTERN __console_x
.ansi_CHAR
ld de,(__console_x)
jp $BE62
|
<%
from pwnlib.shellcraft.amd64.linux import syscall
%>
<%page args="ss, oss"/>
<%docstring>
Invokes the syscall sigaltstack. See 'man 2 sigaltstack' for more information.
Arguments:
ss(sigaltstack): ss
oss(sigaltstack): oss
</%docstring>
${syscall('SYS_sigaltstack', ss, oss)}
|
INCLUDE "config_private.inc"
SECTION code_driver
SECTION code_driver_character_output
PUBLIC _siob_putc
EXTERN siobTxBuffer
EXTERN siobTxCount, siobTxIn
_siob_putc:
; enter : l = char to output
; exit : l = 1 if Tx buffer is full
; carry reset
; modifies : af, hl
di
ld a,(siobTxCount) ; get the number of bytes in the Tx buffer
or a ; check whether the buffer is empty
jr NZ,putc_buffer_tx ; buffer not empty, so abandon immediate Tx
in a,(__IO_SIOB_CONTROL_REGISTER) ; get the SIOB register R0
and __IO_SIO_RR0_TX_EMPTY ; test whether we can transmit on SIOB
jr Z,putc_buffer_tx ; if not, so abandon immediate Tx
ld a,l ; Retrieve Tx character for immediate Tx
out (__IO_SIOB_DATA_REGISTER),a ; output the Tx byte to the SIOB
ld l,0 ; indicate Tx buffer was not full
ei
ret ; and just complete
putc_buffer_tx:
ld a,(siobTxCount) ; Get the number of bytes in the Tx buffer
cp __IO_SIO_TX_SIZE-1 ; check whether there is space in the buffer
jr NC,putc_buffer_tx_overflow ; buffer full, so drop the Tx byte and return
ld a,l ; Tx byte
ld hl,siobTxCount
inc (hl) ; atomic increment of Tx count
ld hl,(siobTxIn) ; get the pointer to where we poke
ei
ld (hl),a ; write the Tx byte to the siobTxIn
inc l ; move the Tx pointer, just low byte along
IF __IO_SIO_TX_SIZE != 0x100
ld a,__IO_SIO_TX_SIZE-1 ; load the buffer size, (n^2)-1
and l ; range check
or siobTxBuffer&0xFF ; locate base
ld l,a ; return the low byte to l
ENDIF
ld (siobTxIn),hl ; write where the next byte should be poked
ld l,0 ; indicate Tx buffer was not full
ret
putc_buffer_tx_overflow:
ld l,1 ; indicate Tx buffer was full
ei
ret
EXTERN _sio_need
defc NEED = _sio_need
|
;/*!
; @file
;
; @ingroup fapi
;
; @brief DosSizeSeg DOS wrapper
;
; (c) osFree Project 2018, <http://www.osFree.org>
; for licence see licence.txt in root directory, or project website
;
; This is Family API implementation for DOS, used with BIND tools
; to link required API
;
; @author Yuri Prokushev (yuri.prokushev@gmail.com)
;
;*/
.8086
; Helpers
INCLUDE helpers.inc
INCLUDE dos.inc
_TEXT SEGMENT BYTE PUBLIC 'CODE' USE16
@PROLOG DOS16PSIZESEG
@START DOS16PSIZESEG
XOR AX,AX
EXIT:
@EPILOG DOS16PSIZESEG
_TEXT ENDS
END
|
dnl mpn_half
dnl Copyright 2011 The Code Cavern
dnl This file is part of the MPIR Library.
dnl The MPIR 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
dnl by the Free Software Foundation; either version 2.1 of the License, or (at
dnl your option) any later version.
dnl The MPIR 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 MPIR Library; see the file COPYING.LIB. If not, write
dnl to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
dnl Boston, MA 02110-1301, USA.
include(`../config.m4')
ASM_START()
PROLOGUE(mpn_half)
mov %rsi,%rax
lea -8(%rdi,%rsi,8),%rdi
shr $2,%rsi
and $3,%eax
jz t1
shrq $1,(%rdi)
lea -8(%rdi),%rdi
dec %rax
jz t1
rcrq $1,(%rdi)
lea -8(%rdi),%rdi
dec %rax
jz t1
rcrq $1,(%rdi)
lea -8(%rdi),%rdi
dec %rax
t1:
sbb %rdx,%rdx
cmp $0,%rsi
jz skiplp
add %rdx,%rdx
.align 16
lp:
rcrq $1,(%rdi)
nop
rcrq $1,-8(%rdi)
rcrq $1,-16(%rdi)
rcrq $1,-24(%rdi)
nop
dec %rsi
lea -32(%rdi),%rdi
jnz lp
sbb %rdx,%rdx
skiplp:
sub %rdx,%rax
shl $63,%rax
ret
EPILOGUE()
|
; A128833: Number of n-tuples where each entry is chosen from the subsets of {1,2,3,4,5} such that the intersection of all n entries is empty.
; 1,243,16807,759375,28629151,992436543,33038369407,1078203909375,34842114263551,1120413075641343,35940921946155007,1151514816750309375,36870975646169341951,1180231376725002502143,37773167607267111108607
add $0,1
mov $1,2
pow $1,$0
sub $1,1
pow $1,5
mov $0,$1
|
;;
;; Copyright (c) 2012-2021, Intel Corporation
;;
;; 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 Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
%include "include/datastruct.asm"
%include "include/constants.asm"
%ifndef MB_MGR_DATASTRUCT_ASM_INCLUDED
%define MB_MGR_DATASTRUCT_ASM_INCLUDED
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Define constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%define MAX_AES_JOBS 128
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Define AES_ARGS and AES Out of Order Data Structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; AES_ARGS
;; name size align
FIELD _aesarg_in, 8*16, 8 ; array of 16 pointers to in text
FIELD _aesarg_out, 8*16, 8 ; array of 16 pointers to out text
FIELD _aesarg_keys, 8*16, 8 ; array of 16 pointers to keys
FIELD _aesarg_IV, 16*16, 64 ; array of 16 128-bit IV's
FIELD _aesarg_key_tab,16*16*15, 64 ; array of 128-bit round keys
END_FIELDS
%assign _AES_ARGS_size _FIELD_OFFSET
%assign _AES_ARGS_align _STRUCT_ALIGN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; MB_MGR_AES_OOO
;; name size align
FIELD _aes_args, _AES_ARGS_size, _AES_ARGS_align
FIELD _aes_lens, 16*2, 16
FIELD _aes_unused_lanes, 8, 8
FIELD _aes_job_in_lane, 16*8, 8
FIELD _aes_lanes_in_use, 8, 8
FIELD _aes_lens_64, 16*8, 64
FIELD _aes_road_block, 8, 8
END_FIELDS
%assign _MB_MGR_AES_OOO_size _FIELD_OFFSET
%assign _MB_MGR_AES_OOO_align _STRUCT_ALIGN
_aes_args_in equ _aes_args + _aesarg_in
_aes_args_out equ _aes_args + _aesarg_out
_aes_args_keys equ _aes_args + _aesarg_keys
_aes_args_IV equ _aes_args + _aesarg_IV
_aes_args_key_tab equ _aes_args + _aesarg_key_tab
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Build on top of AES args and AES OOO - it needs to be compatible
START_FIELDS ; MB_MGR_DOCSIS_AES_OOO
;; name size align
FIELD _docsis_aes_args, _AES_ARGS_size, _AES_ARGS_align
FIELD _docsis_aes_lens, 16*2, 16
FIELD _docsis_aes_unused_lanes, 8, 8
FIELD _docsis_aes_job_in_lane, 16*8, 8
FIELD _docsis_aes_lanes_in_use, 8, 8
FIELD _docsis_crc_init, 16*16, 64
FIELD _docsis_crc_len, 16*2, 16
FIELD _docsis_crc_done, 16*1, 16
FIELD _docsis_crc_road_block, 8, 8
END_FIELDS
%assign _MB_MGR_DOCSIS_AES_OOO_size _FIELD_OFFSET
%assign _MB_MGR_DOCSIS_AES_OOO_align _STRUCT_ALIGN
_docsis_aes_args_in equ _docsis_aes_args + _aesarg_in
_docsis_aes_args_out equ _docsis_aes_args + _aesarg_out
_docsis_aes_args_keys equ _docsis_aes_args + _aesarg_keys
_docsis_aes_args_IV equ _docsis_aes_args + _aesarg_IV
_docsis_aes_args_key_tab equ _docsis_aes_args + _aesarg_key_tab
_docsis_crc_args_init equ _docsis_aes_args + _docsis_crc_init
_docsis_crc_args_len equ _docsis_aes_args + _docsis_crc_len
_docsis_crc_args_done equ _docsis_aes_args + _docsis_crc_done
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Define XCBC Out of Order Data Structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; AES_XCBC_ARGS_X16
;; name size align
FIELD _aesxcbcarg_in, 16*8, 8 ; array of 16 pointers to in text
FIELD _aesxcbcarg_keys, 16*8, 8 ; array of 16 pointers to keys
FIELD _aesxcbcarg_ICV, 16*16, 32 ; array of 16 128-bit ICV's
FIELD _aesxcbcarg_key_tab, 16*16*11, 64 ; array of 128-bit round keys
END_FIELDS
%assign _AES_XCBC_ARGS_X16_size _FIELD_OFFSET
%assign _AES_XCBC_ARGS_X16_align _STRUCT_ALIGN
START_FIELDS ; XCBC_LANE_DATA
;;; name size align
FIELD _xcbc_final_block, 2*16, 32 ; final block with padding
FIELD _xcbc_job_in_lane, 8, 8 ; pointer to job object
FIELD _xcbc_final_done, 8, 8 ; offset to start of data
END_FIELDS
%assign _XCBC_LANE_DATA_size _FIELD_OFFSET
%assign _XCBC_LANE_DATA_align _STRUCT_ALIGN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; MB_MGR_AES_XCBC_OOO
;; name size align
FIELD _aes_xcbc_args, _AES_XCBC_ARGS_X16_size, _AES_XCBC_ARGS_X16_align
FIELD _aes_xcbc_lens, 16*2, 32
FIELD _aes_xcbc_unused_lanes, 8, 8
FIELD _aes_xcbc_ldata, _XCBC_LANE_DATA_size*16, _XCBC_LANE_DATA_align
FIELD _aes_xcbc_num_lanes_inuse, 8, 8
FIELD _aes_xcbc_road_block, 8, 8
END_FIELDS
%assign _MB_MGR_AES_XCBC_OOO_size _FIELD_OFFSET
%assign _MB_MGR_AES_XCBC_OOO_align _STRUCT_ALIGN
_aes_xcbc_args_in equ _aes_xcbc_args + _aesxcbcarg_in
_aes_xcbc_args_keys equ _aes_xcbc_args + _aesxcbcarg_keys
_aes_xcbc_args_ICV equ _aes_xcbc_args + _aesxcbcarg_ICV
_aes_xcbc_args_key_tab equ _aes_xcbc_args + _aesxcbcarg_key_tab
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Define CMAC Out of Order Data Structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; MB_MGR_CMAC_OOO
;; name size align
FIELD _aes_cmac_args, _AES_ARGS_size, _AES_ARGS_align
FIELD _aes_cmac_lens, 16*2, 32
FIELD _aes_cmac_init_done, 16*2, 32
FIELD _aes_cmac_unused_lanes, 8, 8
FIELD _aes_cmac_job_in_lane, 16*8, 16
FIELD _aes_cmac_num_lanes_inuse, 8, 8
FIELD _aes_cmac_scratch, 16*16, 32
FIELD _aes_cmac_road_block, 8, 8
END_FIELDS
%assign _MB_MGR_CMAC_OOO_size _FIELD_OFFSET
%assign _MB_MGR_CMAC_OOO_align _STRUCT_ALIGN
_aes_cmac_args_in equ _aes_cmac_args + _aesarg_in
_aes_cmac_args_keys equ _aes_cmac_args + _aesarg_keys
_aes_cmac_args_IV equ _aes_cmac_args + _aesarg_IV
_aes_cmac_args_key_tab equ _aes_cmac_args + _aesarg_key_tab
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Define CCM Out of Order Data Structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; MB_MGR_CCM_OOO
;; name size align
FIELD _aes_ccm_args, _AES_ARGS_size, _AES_ARGS_align
FIELD _aes_ccm_lens, 16*2, 32
FIELD _aes_ccm_init_done, 16*2, 32
FIELD _aes_ccm_unused_lanes, 8, 8
FIELD _aes_ccm_job_in_lane, 16*8, 16
FIELD _aes_ccm_num_lanes_inuse, 8, 8
FIELD _aes_ccm_init_blocks, 16*4*16, 64
FIELD _aes_ccm_road_block, 8, 8
END_FIELDS
%assign _MB_MGR_CCM_OOO_size _FIELD_OFFSET
%assign _MB_MGR_CCM_OOO_align _STRUCT_ALIGN
_aes_ccm_args_in equ _aes_ccm_args + _aesarg_in
_aes_ccm_args_keys equ _aes_ccm_args + _aesarg_keys
_aes_ccm_args_IV equ _aes_ccm_args + _aesarg_IV
_aes_ccm_args_key_tab equ _aes_ccm_args + _aesarg_key_tab
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Define DES Out of Order Data Structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; DES_ARGS_X16
;; name size align
FIELD _desarg_in, 16*8, 8 ; array of 16 pointers to in text
FIELD _desarg_out, 16*8, 8 ; array of 16 pointers to out text
FIELD _desarg_keys, 16*8, 8 ; array of 16 pointers to keys
FIELD _desarg_IV, 16*8, 32 ; array of 16 64-bit IV's
FIELD _desarg_plen, 16*4, 32 ; array of 16 32-bit partial lens
FIELD _desarg_blen, 16*4, 32 ; array of 16 32-bit block lens
FIELD _desarg_lin, 16*8, 8 ; array of 16 pointers to last (block) in text
FIELD _desarg_lout, 16*8, 8 ; array of 16 pointers to last (block) out text
END_FIELDS
%assign _DES_ARGS_X16_size _FIELD_OFFSET
%assign _DES_ARGS_X16_align _STRUCT_ALIGN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; MB_MGR_DES_OOO
;; name size align
FIELD _des_args, _DES_ARGS_X16_size, _DES_ARGS_X16_align
FIELD _des_lens, 16*2, 16
FIELD _des_unused_lanes, 8, 8
FIELD _des_job_in_lane, 16*8, 8
FIELD _des_lanes_in_use, 8, 8
FIELD _des_road_block, 8, 8
END_FIELDS
%assign _MB_MGR_DES_OOO_size _FIELD_OFFSET
%assign _MB_MGR_DES_OOO_align _STRUCT_ALIGN
_des_args_in equ _des_args + _desarg_in
_des_args_out equ _des_args + _desarg_out
_des_args_keys equ _des_args + _desarg_keys
_des_args_IV equ _des_args + _desarg_IV
_des_args_PLen equ _des_args + _desarg_plen
_des_args_BLen equ _des_args + _desarg_blen
_des_args_LIn equ _des_args + _desarg_lin
_des_args_LOut equ _des_args + _desarg_lout
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Define ZUC Out of Order Data Structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; ZUC_ARGS_X16
;; name size align
FIELD _zucarg_in, 16*8, 64 ; array of 16 pointers to in text
FIELD _zucarg_out, 16*8, 64 ; array of 16 pointers to out text
FIELD _zucarg_keys, 16*8, 8 ; array of 16 pointers to keys
FIELD _zucarg_IV, 16*32, 32 ; array of IVs (up to 25 bytes each)
FIELD _zucarg_digest, 16*4, 64 ; array of 16 digests
FIELD _zucarg_KS, 16*128, 64 ; array of 128-byte keystream of 16 buffers
END_FIELDS
%assign _ZUC_ARGS_X16_size _FIELD_OFFSET
%assign _ZUC_ARGS_X16_align _STRUCT_ALIGN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; MB_MGR_ZUC_OOO
;; name size align
FIELD _zuc_args, _ZUC_ARGS_X16_size, _ZUC_ARGS_X16_align
FIELD _zuc_lens, 16*2, 32
FIELD _zuc_unused_lanes, 8, 8
FIELD _zuc_job_in_lane, 16*8, 8
FIELD _zuc_lanes_in_use, 8, 8
FIELD _zuc_state, 16*4*22, 64
FIELD _zuc_init_not_done , 2, 2
FIELD _zuc_unused_lane_bitmask, 2, 2
FIELD _zuc_road_block, 8, 8
END_FIELDS
%assign _MB_MGR_ZUC_OOO_size _FIELD_OFFSET
%assign _MB_MGR_ZUC_OOO_align _STRUCT_ALIGN
_zuc_args_in equ _zuc_args + _zucarg_in
_zuc_args_out equ _zuc_args + _zucarg_out
_zuc_args_keys equ _zuc_args + _zucarg_keys
_zuc_args_IV equ _zuc_args + _zucarg_IV
_zuc_args_digest equ _zuc_args + _zucarg_digest
_zuc_args_KS equ _zuc_args + _zucarg_KS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Define HMAC Out Of Order Data Structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; HMAC_SHA1_LANE_DATA
;;; name size align
FIELD _extra_block, 2*64+8, 32 ; final block with padding
FIELD _job_in_lane, 8, 8 ; pointer to job object
FIELD _outer_block, 64, 1 ; block containing hash
FIELD _outer_done, 4, 4 ; boolean flag
FIELD _extra_blocks, 4, 4 ; num extra blocks (1 or 2)
FIELD _size_offset, 4, 4 ; offset in extra_block to start of size
FIELD _start_offset, 4, 4 ; offset to start of data
END_FIELDS
%assign _HMAC_SHA1_LANE_DATA_size _FIELD_OFFSET
%assign _HMAC_SHA1_LANE_DATA_align _STRUCT_ALIGN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; SHA512_LANE_DATA
;;; name size align
FIELD _extra_block_sha512, 2* SHA512_BLK_SZ + 16, 32 ; final block with padding, alignment 16 to read in XMM chunks
FIELD _outer_block_sha512, SHA512_BLK_SZ, 1 ; block containing hash
FIELD _job_in_lane_sha512, 8, 8 ; pointer to job object
FIELD _outer_done_sha512, 4, 4 ; boolean flag
FIELD _extra_blocks_sha512, 4, 4 ; num extra blocks (1 or 2)
FIELD _size_offset_sha512, 4, 4 ; offset in extra_block to start of size
FIELD _start_offset_sha512, 4, 4 ; offset to start of data
END_FIELDS
%assign _SHA512_LANE_DATA_size _FIELD_OFFSET
%assign _SHA512_LANE_DATA_align _STRUCT_ALIGN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; SHA1_ARGS
;;; name size align
FIELD _digest, SHA1_DIGEST_SIZE, 32 ; transposed digest
FIELD _data_ptr_sha1, PTR_SZ*MAX_SHA1_LANES, 8 ; array of pointers to data
END_FIELDS
%assign _SHA1_ARGS_size _FIELD_OFFSET
%assign _SHA1_ARGS_align _STRUCT_ALIGN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; MB_MGR_HMAC_SHA_1_OOO
;;; name size align
FIELD _args, _SHA1_ARGS_size, _SHA1_ARGS_align
FIELD _lens, 32, 32
FIELD _unused_lanes, 8, 8
FIELD _ldata, _HMAC_SHA1_LANE_DATA_size*MAX_SHA1_LANES, _HMAC_SHA1_LANE_DATA_align
FIELD _num_lanes_inuse_sha1, 4, 4
FIELD _road_block_sha1, 8, 8
END_FIELDS
%assign _MB_MGR_HMAC_SHA_1_OOO_size _FIELD_OFFSET
%assign _MB_MGR_HMAC_SHA_1_OOO_align _STRUCT_ALIGN
_args_digest equ _args + _digest
_args_data_ptr equ _args + _data_ptr_sha1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; SHA256_ARGS
;;; name size align
FIELD _digest_sha256, SHA256_DIGEST_SIZE, 32 ; transposed digest
FIELD _data_ptr_sha256, PTR_SZ*MAX_SHA256_LANES, 8 ; array of pointers to data
END_FIELDS
%assign _SHA256_ARGS_size _FIELD_OFFSET
%assign _SHA256_ARGS_align _STRUCT_ALIGN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; MB_MGR_HMAC_SHA_256_OOO
;;; name size align
FIELD _args_sha256, _SHA256_ARGS_size, _SHA256_ARGS_align
FIELD _lens_sha256, 16*2, 16
FIELD _unused_lanes_sha256, 8, 8
FIELD _ldata_sha256, _HMAC_SHA1_LANE_DATA_size * MAX_SHA256_LANES, _HMAC_SHA1_LANE_DATA_align
FIELD _num_lanes_inuse_sha256, 4, 4
FIELD _road_block_sha256, 8, 8
END_FIELDS
%assign _MB_MGR_HMAC_SHA_256_OOO_size _FIELD_OFFSET
%assign _MB_MGR_HMAC_SHA_256_OOO_align _STRUCT_ALIGN
_args_digest_sha256 equ _args_sha256 + _digest_sha256
_args_data_ptr_sha256 equ _args_sha256 + _data_ptr_sha256
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Define HMAC SHA512 Out Of Order Data Structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; SHA512_ARGS
;;; name size align
FIELD _digest_sha512, SHA512_DIGEST_SIZE, 32 ; transposed digest. 2 lanes, 8 digest words, each 8 bytes long
FIELD _data_ptr_sha512, MAX_SHA512_LANES * PTR_SZ, 8 ; array of pointers to data
END_FIELDS
%assign _SHA512_ARGS_size _FIELD_OFFSET
%assign _SHA512_ARGS_align _STRUCT_ALIGN
;; ---------------------------------------
START_FIELDS ; MB_MGR_HMAC_SHA512_OOO
;;; name size align
FIELD _args_sha512, _SHA512_ARGS_size, _SHA512_ARGS_align
FIELD _lens_sha512, 16, 16
FIELD _unused_lanes_sha512, 8, 8
FIELD _ldata_sha512, _SHA512_LANE_DATA_size * MAX_SHA512_LANES, _SHA512_LANE_DATA_align
FIELD _road_block_sha512, 8, 8
END_FIELDS
%assign _MB_MGR_HMAC_SHA_512_OOO_size _FIELD_OFFSET
%assign _MB_MGR_HMAC_SHA_512_OOO_align _STRUCT_ALIGN
_args_digest_sha512 equ _args_sha512 + _digest_sha512
_args_data_ptr_sha512 equ _args_sha512 + _data_ptr_sha512
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Define HMAC MD5 Out Of Order Data Structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; MD5_ARGS
;;; name size align
FIELD _digest_md5, MD5_DIGEST_SIZE, 32 ; transposed digest
FIELD _data_ptr_md5, MAX_MD5_LANES*PTR_SZ, 8 ; array of pointers to data
END_FIELDS
%assign _MD5_ARGS_size _FIELD_OFFSET
%assign _MD5_ARGS_align _STRUCT_ALIGN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; MB_MGR_HMAC_MD5_OOO
;;; name size align
FIELD _args_md5, _MD5_ARGS_size, _MD5_ARGS_align
FIELD _lens_md5, MAX_MD5_LANES*2, 16
FIELD _unused_lanes_md5, 8, 8
FIELD _ldata_md5, _HMAC_SHA1_LANE_DATA_size * MAX_MD5_LANES, _HMAC_SHA1_LANE_DATA_align
FIELD _num_lanes_inuse_md5, 4, 8
FIELD _road_block_md5, 8, 8
END_FIELDS
%assign _MB_MGR_HMAC_MD5_OOO_size _FIELD_OFFSET
%assign _MB_MGR_HMAC_MD5_OOO_align _STRUCT_ALIGN
_args_digest_md5 equ _args_md5 + _digest_md5
_args_data_ptr_md5 equ _args_md5 + _data_ptr_md5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Define Snow3G Out of Order Data Structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; SNOW3G_ARGS
;; name size align
FIELD __snow3g_arg_in, 16*8, 64 ; array of 16 pointers to in text
FIELD __snow3g_arg_out, 16*8, 64 ; array of 16 pointers to out text
FIELD __snow3g_arg_keys, 16*8, 64 ; array of 16 pointers to keys
FIELD __snow3g_arg_IV, 16*8, 64 ; array of 16 pointers to IVs
FIELD __snow3g_arg_LFSR_0, 16*4, 64 ; 16 x 32-bit LFSR 0 register
FIELD __snow3g_arg_LFSR_1, 16*4, 64 ; 16 x 32-bit LFSR 1 register
FIELD __snow3g_arg_LFSR_2, 16*4, 64 ; 16 x 32-bit LFSR 2 register
FIELD __snow3g_arg_LFSR_3, 16*4, 64 ; 16 x 32-bit LFSR 3 register
FIELD __snow3g_arg_LFSR_4, 16*4, 64 ; 16 x 32-bit LFSR 4 register
FIELD __snow3g_arg_LFSR_5, 16*4, 64 ; 16 x 32-bit LFSR 5 register
FIELD __snow3g_arg_LFSR_6, 16*4, 64 ; 16 x 32-bit LFSR 6 register
FIELD __snow3g_arg_LFSR_7, 16*4, 64 ; 16 x 32-bit LFSR 7 register
FIELD __snow3g_arg_LFSR_8, 16*4, 64 ; 16 x 32-bit LFSR 8 register
FIELD __snow3g_arg_LFSR_9, 16*4, 64 ; 16 x 32-bit LFSR 9 register
FIELD __snow3g_arg_LFSR_10, 16*4, 64 ; 16 x 32-bit LFSR 10 register
FIELD __snow3g_arg_LFSR_11, 16*4, 64 ; 16 x 32-bit LFSR 11 register
FIELD __snow3g_arg_LFSR_12, 16*4, 64 ; 16 x 32-bit LFSR 12 register
FIELD __snow3g_arg_LFSR_13, 16*4, 64 ; 16 x 32-bit LFSR 13 register
FIELD __snow3g_arg_LFSR_14, 16*4, 64 ; 16 x 32-bit LFSR 14 register
FIELD __snow3g_arg_LFSR_15, 16*4, 64 ; 16 x 32-bit LFSR 15 register
FIELD __snow3g_arg_FSM_1, 16*4, 64 ; 16 x 32-bit FSM 1 register
FIELD __snow3g_arg_FSM_2, 16*4, 64 ; 16 x 32-bit FSM 2 register
FIELD __snow3g_arg_FSM_3, 16*4, 64 ; 16 x 32-bit FSM 3 register
FIELD __snow3g_arg_LD_ST_MASK,16*8, 64 ; array of 64-bit load/store byte mask
FIELD __snow3g_arg_byte_length,16*8, 64 ; array of 64-bit original lengths (in bytes)
END_FIELDS
%assign _SNOW3G_ARGS_size _FIELD_OFFSET
%assign _SNOW3G_ARGS_align _STRUCT_ALIGN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; MB_MGR_SNOW3G_OOO
;; name size align
FIELD _snow3g_args, _SNOW3G_ARGS_size, _SNOW3G_ARGS_align
FIELD _snow3g_lens, 16*4, 64 ; 16 x 32-bit vector
FIELD _snow3g_job_in_lane, 16*8, 8
FIELD _snow3g_bits_fixup, 16*4, 4
FIELD _snow3g_INIT_MASK, 8, 8
FIELD _snow3g_unused_lanes, 8, 8
FIELD _snow3g_lanes_in_use, 8, 8
FIELD _snow3g_init_done, 8, 8
FIELD _snow3g_ks, 16*4*8, 32 ; reserve space to store keystream for 16 buffers
FIELD _snow3g_road_block, 8, 8
END_FIELDS
%assign _MB_MGR_SNOW3G_OOO_size _FIELD_OFFSET
%assign _MB_MGR_SNOW3G_OOO_align _STRUCT_ALIGN
_snow3g_lens_dw equ _snow3g_lens
_snow3g_args_in equ _snow3g_args + __snow3g_arg_in
_snow3g_args_out equ _snow3g_args + __snow3g_arg_out
_snow3g_args_keys equ _snow3g_args + __snow3g_arg_keys
_snow3g_args_IV equ _snow3g_args + __snow3g_arg_IV
_snow3g_args_LFSR_0 equ _snow3g_args + __snow3g_arg_LFSR_0
_snow3g_args_LFSR_1 equ _snow3g_args + __snow3g_arg_LFSR_1
_snow3g_args_LFSR_2 equ _snow3g_args + __snow3g_arg_LFSR_2
_snow3g_args_LFSR_3 equ _snow3g_args + __snow3g_arg_LFSR_3
_snow3g_args_LFSR_4 equ _snow3g_args + __snow3g_arg_LFSR_4
_snow3g_args_LFSR_5 equ _snow3g_args + __snow3g_arg_LFSR_5
_snow3g_args_LFSR_6 equ _snow3g_args + __snow3g_arg_LFSR_6
_snow3g_args_LFSR_7 equ _snow3g_args + __snow3g_arg_LFSR_7
_snow3g_args_LFSR_8 equ _snow3g_args + __snow3g_arg_LFSR_8
_snow3g_args_LFSR_9 equ _snow3g_args + __snow3g_arg_LFSR_9
_snow3g_args_LFSR_10 equ _snow3g_args + __snow3g_arg_LFSR_10
_snow3g_args_LFSR_11 equ _snow3g_args + __snow3g_arg_LFSR_11
_snow3g_args_LFSR_12 equ _snow3g_args + __snow3g_arg_LFSR_12
_snow3g_args_LFSR_13 equ _snow3g_args + __snow3g_arg_LFSR_13
_snow3g_args_LFSR_14 equ _snow3g_args + __snow3g_arg_LFSR_14
_snow3g_args_LFSR_15 equ _snow3g_args + __snow3g_arg_LFSR_15
_snow3g_args_FSM_1 equ _snow3g_args + __snow3g_arg_FSM_1
_snow3g_args_FSM_2 equ _snow3g_args + __snow3g_arg_FSM_2
_snow3g_args_FSM_3 equ _snow3g_args + __snow3g_arg_FSM_3
_snow3g_args_LD_ST_MASK equ _snow3g_args + __snow3g_arg_LD_ST_MASK
_snow3g_args_byte_length equ _snow3g_args + __snow3g_arg_byte_length
%endif ;; MB_MGR_DATASTRUCT_ASM_INCLUDED
|
; A168300: a(n) = 6*n - a(n-1) - 2 with a(1)=5.
; 5,5,11,11,17,17,23,23,29,29,35,35,41,41,47,47,53,53,59,59,65,65,71,71,77,77,83,83,89,89,95,95,101,101,107,107,113,113,119,119,125,125,131,131,137,137,143,143,149,149,155,155,161,161,167,167,173,173,179,179,185,185,191,191,197,197,203,203,209,209,215,215,221,221,227,227,233,233,239,239,245,245,251,251,257,257,263,263,269,269,275,275,281,281,287,287,293,293,299,299
div $0,2
mul $0,6
add $0,5
|
10003430: 83 ec 0c sub esp,0xc
10003433: 83 3d 00 00 01 10 ff cmp DWORD PTR ds:0x10010000,0xffffffff
1000343a: 75 08 jne 0x10003444
1000343c: 32 c0 xor al,al
1000343e: 83 c4 0c add esp,0xc
10003441: c2 0c 00 ret 0xc
10003444: 8a 4c 24 10 mov cl,BYTE PTR [esp+0x10]
10003448: 66 8b 54 24 14 mov dx,WORD PTR [esp+0x14]
1000344d: 33 c0 xor eax,eax
1000344f: 50 push eax
10003450: 66 89 44 24 0c mov WORD PTR [esp+0xc],ax
10003455: 88 44 24 07 mov BYTE PTR [esp+0x7],al
10003459: 8d 44 24 14 lea eax,[esp+0x14]
1000345d: 50 push eax
1000345e: 88 4c 24 0d mov BYTE PTR [esp+0xd],cl
10003462: 6a 01 push 0x1
10003464: 66 89 54 24 12 mov WORD PTR [esp+0x12],dx
10003469: 8d 4c 24 0f lea ecx,[esp+0xf]
1000346d: 51 push ecx
1000346e: 8b 0d 10 52 01 10 mov ecx,DWORD PTR ds:0x10015210
10003474: 66 c7 44 24 1a 01 00 mov WORD PTR [esp+0x1a],0x1
1000347b: 8b 54 24 18 mov edx,DWORD PTR [esp+0x18]
1000347f: 52 push edx
10003480: c6 44 24 18 80 mov BYTE PTR [esp+0x18],0x80
10003485: 8b 44 24 18 mov eax,DWORD PTR [esp+0x18]
10003489: 50 push eax
1000348a: 51 push ecx
1000348b: e8 8c 03 00 00 call 0x1000381c
10003490: 8a 44 24 03 mov al,BYTE PTR [esp+0x3]
10003494: 83 c4 0c add esp,0xc
10003497: c2 0c 00 ret 0xc
1000349a: cc int3
1000349b: cc int3
1000349c: cc int3
1000349d: cc int3
1000349e: cc int3
1000349f: cc int3
|
; template.asm
; template file for assembly programs, compiled and linked with C.
; Simon Heath
; 22/4/2003
; Initialized data
segment .data
; Uninitialized data
segment .bss
; Code
segment .text
global _asm_main
_asm_main:
; Enter the routine
enter 0,0
pusha
; Insert code here
; Return to C
popa
mov eax, 0
leave
ret
|
UndergroundPathNS_h:
db UNDERGROUND ; tileset
db UNDERGROUND_PATH_NS_HEIGHT, UNDERGROUND_PATH_NS_WIDTH ; dimensions (y, x)
dw UndergroundPathNSBlocks, UndergroundPathNSTextPointers, UndergroundPathNSScript ; blocks, texts, scripts
db $00 ; connections
dw UndergroundPathNSObject ; objects
|
CPU 8086
%define MEMCGAEVEN 0xB800
%define MEMCGAODD 0xBA00
%define KB_ESC 01
%define KB_UP 48h
%define KB_DOWN 50h
%define KB_LEFT 4Bh
%define KB_RIGHT 4Dh
%define BYTESPERROW 160d
%define JOYSTICKPORT 201h
%define JS2B 10000000b
%define JS2A 01000000b
%define JS1B 00100000b
%define JS1A 00010000b
%define JS2Y 00001000b
%define JS2X 00000100b
%define JS1Y 00000010b
%define JS1X 00000001b
; Macros
; vsync: Esperar retrazo vertical
%macro VSync 0
MOV DX, 03DAH
%%Retrace1:
IN AL,DX ; AL := Port[03DAH]
TEST AL,8 ; Is bit 3 set?
JZ %%Retrace1 ; No, continue waiting
%%Retrace2: ; IN AL,DX
IN AL,DX ; AL := Port[03DAH]
TEST AL,8 ; Is bit 3 unset?
JNZ %%Retrace2 ; No, continue waiting
%endmacro
%macro mSetVideoMode 1
mov ah, 0 ; Establecer modo de video
mov al, %1 ; Modo de video
int 10h ; LLamar a la BIOS para servicios de video
%endmacro
%macro mEscribeStringzColor 3
; ds:bx = stringz
; %1 = atributos (colores)
; %2 = x
; %3 = y
mov dh, %3
mov dl, %2
mov ch, %1
call escribestringz
%endmacro
%macro readJoystick 0
mov dx, JOYSTICKPORT
in al, dx
%endmacro
org 100h
section .text
start:
mSetVideoMode 3 ; CGA Modo 3: Texto a color, 80 x 25.
; Disable blinking
mov dx, 03D8h
mov al, 00001001b
out dx, al
lea bx, [msg1]
mEscribeStringzColor 00001111b, 6, 2
; jmp fin
.mainloop:
.readkeyb:
mov ah, 1
int 16h
jz .nohaytecla
mov ah, 0
int 16h
cmp ah, KB_ESC ; Comprobar si es tecla ESC
je fin
.nohaytecla:
readJoystick
push ax
test al, JS1A
jnz .noa
mov bh, 00001011b
mov bl, 'A'
mov dh, 4
mov dl, 6
call escribecaracter
jmp .sig1
.noa:
mov bh, 00001111b
mov bl, 0
mov dh, 4
mov dl, 6
call escribecaracter
.sig1:
pop ax
test al, JS1B
jnz .nob
mov bh, 00001011b
mov bl, 'B'
mov dh, 4
mov dl, 8
call escribecaracter
jmp .sig2
.nob:
mov bh, 00001111b
mov bl, 0
mov dh, 4
mov dl, 8
call escribecaracter
.sig2:
call readjoystickpos
mov bx, [js1ycount]
mov dh, 4
mov dl, 15
call escribepalabradecimal
mov bx, [js1xcount]
mov dh, 4
mov dl, 22
call escribepalabradecimal
VSync
jmp .mainloop
fin:
; 2 .- Salir al sistema
mSetVideoMode 3 ; CGA Modo 3: Texto a color, 80 x 25.
int 20h
readjoystickpos:
xor ax, ax
mov [js2ycount], ax
mov [js2xcount], ax
mov [js1ycount], ax
mov [js1xcount], ax
cli ; Deshabilitar interrupciones
mov dx, JOYSTICKPORT
out dx, al
.jsloop:
in al, dx
test al, JS2Y
jz .sig1
inc word [js2ycount]
.sig1:
test al, JS2X
jz .sig2
inc word [js2xcount]
.sig2:
test al, JS1Y
jz .sig3
inc word [js1ycount]
.sig3:
test al, JS1X
jz .sig4
inc word [js1xcount]
.sig4:
test al, ( JS2Y | JS2X | JS1Y | JS1X )
jnz .jsloop
sti ; Habilitar interrupciones
ret
escribepalabradecimal:
; bx = valor a escribir en pantalla
; dh = coord y
; dl = coord x
mov cx, cs ; Use code segment in .com executable, because is the same as data segment
mov ds, cx
mov cx, MEMCGAEVEN
mov es, cx
mov al, BYTESPERROW
mul dh
xor dh, dh
shl dx, 1 ; multiplicar x * 2
add ax, dx
mov di, ax ; Destino en pantalla en es:di
mov ax, bx
mov cx, 5 ; 5 dígitos máximo
std
.ciclodigito:
xor dx, dx
mov bx, 10d
div bx
xchg ax, dx
add al, '0'
mov ah, 00001111b
stosw
mov ax, dx
dec cx
test ax, ax
jnz .ciclodigito
.cicloceros:
cmp cx, 0
jna .salir
mov al, 0
mov ah, 00001111b
rep stosw
.salir:
cld
ret
escribecaracter:
; bh = atributos / colores
; bl = caracter ascii
; dh = coord y
; dl = coord x
mov cx, cs ; Use code segment in .com executable, because is the same as data segment
mov ds, cx
mov cx, MEMCGAEVEN
mov es, cx
mov al, BYTESPERROW
mul dh
xor dh, dh
shl dx, 1 ; multiplicar x * 2
add ax, dx
mov di, ax ; Destino en pantalla en es:di
mov ax, bx
stosw
ret
escribestringz:
; escribe en pantalla cadena de caracteres terminada en cero
; bx = puntero a cadena
; dh = coord y
; dl = coord x
; ch = atributos/colores
mov ax, cs ; Use code segment in .com executable, because is the same as data segment
mov ds, ax
mov ax, MEMCGAEVEN
mov es, ax
mov si, bx ; cadena origen en si
mov al, BYTESPERROW
mul dh
xor dh, dh
shl dx, 1 ; multiplicar x * 2
add ax, dx
mov di, ax ; Destino en pantalla en es:di
mov ah, ch ; atributos en byte alto
.ciclo:
lodsb ; Cargar caracter en al
test al, al ; si es caracter es cero, terminar de escribir
jz .fin
; mov ah, ch
stosw ; Escribir en pantalla, caracter + atributos
jmp .ciclo
.fin:
ret
section .data
; program data
js2ycount: dw 0000h
js2xcount: dw 0000h
js1ycount: dw 0000h
js1xcount: dw 0000h
msg1: db 'Botones y posici', 0A2h, 'n del Joystick', 0x00 ; message
|
SECTION code_fp_dai32
PUBLIC l_f32_add
EXTERN ___dai32_setup_arith
EXTERN ___dai32_xfadd
EXTERN ___dai32_return
l_f32_add:
call ___dai32_setup_arith
call ___dai32_xfadd
jp ___dai32_return
|
// Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the BSD 3-Clause License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the
// License at
//
// https://opensource.org/licenses/BSD-3-Clause
//
// 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.
#include "flare/rpc/protocol/protobuf/std_protocol.h"
#include "thirdparty/googletest/gtest/gtest.h"
#include "thirdparty/protobuf/util/message_differencer.h"
#include "flare/init/on_init.h"
#include "flare/rpc/protocol/protobuf/call_context.h"
#include "flare/rpc/protocol/protobuf/message.h"
#include "flare/rpc/protocol/protobuf/service_method_locator.h"
#include "flare/testing/echo_service.flare.pb.h"
#include "flare/testing/main.h"
namespace flare::protobuf {
struct Dummy : testing::EchoService {
} dummy;
FLARE_ON_INIT(10, [] {
ServiceMethodLocator::Instance()->AddService(dummy.GetDescriptor());
});
TEST(StdProtocol, ClientToServer) {
auto src = object_pool::Get<rpc::RpcMeta>();
src->set_correlation_id(1);
src->set_method_type(rpc::METHOD_TYPE_SINGLE);
src->mutable_request_meta()->set_method_name(
"flare.testing.EchoService.Echo");
auto src_cp = *src;
testing::EchoRequest payload;
payload.set_body("asdf");
StdProtocol client_prot(false), server_prot(true);
ProtoMessage msg(std::move(src), MaybeOwning(non_owning, &payload));
NoncontiguousBuffer buffer;
ProactiveCallContext pcc;
pcc.accept_response_in_bytes = false;
pcc.method = dummy.GetDescriptor()->FindMethodByName("Echo");
client_prot.WriteMessage(msg, &buffer, &pcc);
ASSERT_TRUE(
google::protobuf::util::MessageDifferencer::Equals(*msg.meta, src_cp));
ASSERT_TRUE(google::protobuf::util::MessageDifferencer::Equals(
*std::get<1>(msg.msg_or_buffer), payload));
std::unique_ptr<Message> parsed;
PassiveCallContext passive_ctx;
ASSERT_TRUE(server_prot.TryCutMessage(&buffer, &parsed) ==
StreamProtocol::MessageCutStatus::Cut);
ASSERT_TRUE(server_prot.TryParse(&parsed, &passive_ctx));
ASSERT_EQ(0, buffer.ByteSize());
// Same as the original one.
auto parsed_casted = cast<ProtoMessage>(parsed.get());
ASSERT_TRUE(google::protobuf::util::MessageDifferencer::Equals(
*msg.meta, *parsed_casted->meta));
ASSERT_TRUE(google::protobuf::util::MessageDifferencer::Equals(
*std::get<1>(msg.msg_or_buffer),
*std::get<1>(parsed_casted->msg_or_buffer)));
}
TEST(StdProtocol, ServerToClient) {
auto src = object_pool::Get<rpc::RpcMeta>();
src->set_correlation_id(1);
src->set_method_type(rpc::METHOD_TYPE_SINGLE);
src->mutable_response_meta()->set_status(rpc::STATUS_OVERLOADED);
src->mutable_response_meta()->set_description("great job.");
auto src_cp = *src;
testing::EchoResponse payload;
payload.set_body("abcd");
StdProtocol server_prot(true), client_prot(false);
ProtoMessage msg(std::move(src), MaybeOwning(non_owning, &payload));
NoncontiguousBuffer buffer;
PassiveCallContext passive_ctx;
server_prot.WriteMessage(msg, &buffer, &passive_ctx);
ASSERT_TRUE(
google::protobuf::util::MessageDifferencer::Equals(*msg.meta, src_cp));
ASSERT_TRUE(google::protobuf::util::MessageDifferencer::Equals(
*std::get<1>(msg.msg_or_buffer), payload));
testing::EchoResponse unpack_to;
std::unique_ptr<Message> parsed;
ProactiveCallContext pcc;
pcc.accept_response_in_bytes = false;
pcc.expecting_stream = false;
pcc.response_ptr = &unpack_to;
ASSERT_TRUE(client_prot.TryCutMessage(&buffer, &parsed) ==
StreamProtocol::MessageCutStatus::Cut);
ASSERT_TRUE(client_prot.TryParse(&parsed, &pcc));
ASSERT_EQ(0, buffer.ByteSize());
// Same as the original one.
auto parsed_casted = cast<ProtoMessage>(parsed.get());
ASSERT_TRUE(google::protobuf::util::MessageDifferencer::Equals(
*msg.meta, *parsed_casted->meta));
ASSERT_TRUE(google::protobuf::util::MessageDifferencer::Equals(
*std::get<1>(msg.msg_or_buffer),
*std::get<1>(parsed_casted->msg_or_buffer)));
}
} // namespace flare::protobuf
FLARE_TEST_MAIN
|
object_const_def ; object_event constants
const GOLDENRODFLOWERSHOP_TEACHER
const GOLDENRODFLOWERSHOP_FLORIA
GoldenrodFlowerShop_MapScripts:
db 0 ; scene scripts
db 0 ; callbacks
FlowerShopTeacherScript:
checkevent EVENT_FOUGHT_SUDOWOODO
iftrue .Lalala
checkevent EVENT_GOT_SQUIRTBOTTLE
iftrue .GotSquirtbottle
checkevent EVENT_MET_FLORIA
iffalse .HaventMetFloria
checkevent EVENT_TALKED_TO_FLORIA_AT_FLOWER_SHOP
iffalse .Lalala
checkflag ENGINE_PLAINBADGE
iffalse .NoPlainBadge
faceplayer
opentext
writetext GoldenrodFlowerShopTeacherHeresTheSquirtbottleText
buttonsound
verbosegiveitem SQUIRTBOTTLE
setevent EVENT_GOT_SQUIRTBOTTLE
closetext
setevent EVENT_FLORIA_AT_SUDOWOODO
clearevent EVENT_FLORIA_AT_FLOWER_SHOP
end
.Lalala:
turnobject GOLDENRODFLOWERSHOP_TEACHER, LEFT
opentext
writetext GoldenrodFlowerShopTeacherLalalaHavePlentyOfWaterText
waitbutton
closetext
end
.GotSquirtbottle:
jumptextfaceplayer GoldenrodFlowerShopTeacherDontDoAnythingDangerousText
.NoPlainBadge:
jumptextfaceplayer GoldenrodFlowerShopTeacherAskWantToBorrowWaterBottleText
.HaventMetFloria:
jumptextfaceplayer GoldenrodFlowerShopTeacherMySisterWentToSeeWigglyTreeRoute36Text
FlowerShopFloriaScript:
faceplayer
opentext
checkevent EVENT_FOUGHT_SUDOWOODO
iftrue .FoughtSudowoodo
checkevent EVENT_GOT_SQUIRTBOTTLE
iftrue .GotSquirtbottle
writetext GoldenrodFlowerShopFloriaWonderIfSisWillLendWaterBottleText
waitbutton
closetext
setevent EVENT_TALKED_TO_FLORIA_AT_FLOWER_SHOP
setevent EVENT_FLORIA_AT_FLOWER_SHOP
clearevent EVENT_FLORIA_AT_SUDOWOODO
end
.GotSquirtbottle:
writetext GoldenrodFlowerShopFloriaYouBeatWhitneyText
waitbutton
closetext
end
.FoughtSudowoodo:
writetext GoldenrodFlowerShopFloriaItReallyWasAMonText
waitbutton
closetext
end
FlowerShopShelf1:
; unused
jumpstd picturebookshelf
FlowerShopShelf2:
; unused
jumpstd magazinebookshelf
FlowerShopRadio:
; unused
jumpstd radio2
GoldenrodFlowerShopTeacherMySisterWentToSeeWigglyTreeRoute36Text:
text "Have you seen that"
line "wiggly tree that's"
para "growing on ROUTE"
line "36?"
para "My little sister"
line "got all excited"
para "and went to see"
line "it…"
para "I'm worried… Isn't"
line "it dangerous?"
done
GoldenrodFlowerShopTeacherAskWantToBorrowWaterBottleText:
text "Do you want to"
line "borrow the water"
para "bottle too?"
line "I don't want you"
para "doing anything"
line "dangerous with it."
done
GoldenrodFlowerShopTeacherHeresTheSquirtbottleText:
text "Oh, you're better"
line "than WHITNEY…"
para "You'll be OK,"
line "then. Here's the"
cont "SQUIRTBOTTLE!"
done
GoldenrodFlowerShopTeacherDontDoAnythingDangerousText:
text "Don't do anything"
line "too dangerous!"
done
GoldenrodFlowerShopTeacherLalalaHavePlentyOfWaterText:
text "Lalala lalalala."
line "Have plenty of"
cont "water, my lovely!"
done
GoldenrodFlowerShopFloriaWonderIfSisWillLendWaterBottleText:
text "When I told my sis"
line "about the jiggly"
para "tree, she told me"
line "it's dangerous."
para "If I beat WHITNEY,"
line "I wonder if she'll"
para "lend me her water"
line "bottle…"
done
GoldenrodFlowerShopFloriaYouBeatWhitneyText:
text "Wow, you beat"
line "WHITNEY? Cool!"
done
GoldenrodFlowerShopFloriaItReallyWasAMonText:
text "So it really was a"
line "#MON!"
done
GoldenrodFlowerShop_MapEvents:
db 0, 0 ; filler
db 2 ; warp events
warp_event 2, 7, GOLDENROD_CITY, 6
warp_event 3, 7, GOLDENROD_CITY, 6
db 0 ; coord events
db 0 ; bg events
db 2 ; object events
object_event 2, 4, SPRITE_TEACHER, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, FlowerShopTeacherScript, -1
object_event 5, 6, SPRITE_LASS, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, FlowerShopFloriaScript, EVENT_FLORIA_AT_FLOWER_SHOP
|
*=$c000
lda #<NUMBER
ldy #>NUMBER
jsr REALFAC
ldx #00
ldy #$20
jsr 48087
lda #0
ldy #$20
jsr 48034
jsr 49009
ldx #$10
ldy #$20
jsr 48087
jsr 43708
rts
NUMBER .real 3124.4569
|
#include <bits/stdc++.h>
using namespace std;
// Macros
#ifdef D3BUG
#define cerrd if (D3BUG) cerr
#else
#define cerrd if (false) cerr
#endif
// Types
template <typename T> using vector1D = vector<T>;
template <typename T> using vector2D = vector<vector1D<T>>;
template <typename T> using vector3D = vector<vector2D<T>>;
// Output stream overloads.
template<
// Output stream overload for STL containers with one explicit type parameter.
template<class> class Range, class T,
typename = enable_if_t<std::is_same_v<Range<T>, std::deque<T>> ||
std::is_same_v<Range<T>, std::forward_list<T>> ||
std::is_same_v<Range<T>, std::list<T>> ||
std::is_same_v<Range<T>, std::multiset<T>> ||
std::is_same_v<Range<T>, std::set<T>> ||
std::is_same_v<Range<T>, std::unordered_multiset<T>> ||
std::is_same_v<Range<T>, std::unordered_set<T>> ||
std::is_same_v<Range<T>, std::vector<T>>>
>
std::ostream& operator<<(std::ostream& out, const Range<T>& range) {
constexpr auto brackets = std::is_same_v<Range<T>, vector<T>> ? "[]" : "{}";
out << brackets[0];
for (auto it = range.begin(); it != range.end(); ++it) {
out << *it << (next(it) != range.end() ? ", " : "");
}
return out << brackets[1];
}
template<
// Output stream overload for STL containers with two explicit type parameters.
template<class, class> class Range, class K, class V,
typename = enable_if_t<std::is_same_v<Range<K, V>, std::map<K, V>> ||
std::is_same_v<Range<K, V>, std::multimap<K, V>> ||
std::is_same_v<Range<K, V>, std::unordered_map<K, V>> ||
std::is_same_v<Range<K, V>, std::unordered_multimap<K, V>>>
>
std::ostream& operator<<(std::ostream& out, const Range<K, V>& range) {
out << '{';
for (auto it = range.begin(); it != range.end(); ++it) {
out << it->first << ": " << it->second << (next(it) != range.end() ? ", " : "");
}
return out << '}';
}
template <class F, class S>
std::ostream& operator<<(std::ostream& out, const std::pair<F, S>& pair) {
return out << '(' << pair.first << ", " << pair.second << ')';
}
// Hash Template Specializations
template<class T, class U>
struct hash<std::pair<T, U>> {
size_t operator()(const std::pair<T, U>& pair) const noexcept {
return hash<T>{}(pair.first) ^ (hash<U>{}(pair.second) << 1);
}
};
void solution();
// Initalize the execution environment and call the solution function.
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
solution();
}
// -----------------------------------------------------------------------------
void solution() {
int T;
cin >> T;
for (int t = 1; t <= T; ++t) {
int N;
cin >> N;
vector<pair<int, int>> buses(N);
for (int i = 0; i < N; ++i) {
cin >> buses[i].first >> buses[i].second;
}
int P;
cin >> P;
vector<int> cities(P);
for (int i = 0; i < P; ++i) {
cin >> cities[i];
}
map<int, int> events;
for (const auto [beg, end] : buses) {
++events[beg];
--events[end + 1];
}
int current = 0;
map<int, int> network = {{0, 0}};
for (const auto [pos, change] : events) {
current += change;
network[pos] = current;
}
vector<int> res(P);
for (int i = 0; i < P; ++i) {
const auto it = --network.upper_bound(cities[i]);
res[i] = it->second;
}
cout << "Case #" << t << ":";
for (int i = 0; i < P; ++i) {
cout << ' ' << res[i];
}
cout << '\n';
}
}
|
COMMENT @----------------------------------------------------------------------
Copyright (c) GeoWorks 1993 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Avoid
FILE: avoidApp.asm
REVISION HISTORY:
Name Date Description
---- ---- -----------
Doug 4/93 Initial version
DESCRIPTION:
Demonstration program for how to deal properly with becoming
a non-detachable application on a system working in transparent-
launch mode (such as Zoomer)
IMPORTANT:
RCS STAMP:
$Id: avoidApp.asm,v 1.1 97/04/04 16:34:02 newdeal Exp $
------------------------------------------------------------------------------@
idata segment
AvoidApplicationClass
idata ends
AppCode segment resource ;start of code resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AvoidAppOptionsChange
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Handle change in transparent detach options
PASS: *ds:si - app object
es - segment of class
ax - MSG_AVOID_APPLICATION_OPTIONS_CHANGE
cx - GIGI_selectedBooleans
dx - GIGI_indeterminateBooleans
bp - GIGI_modifiedBooleans
RETURN: nothing
ALLOWED TO DESTROY:
bx, si, di, ds, es
PSEUDO CODE/STRATEGY/KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
doug 4/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AvoidAppOptionsChange method AvoidApplicationClass,
MSG_AVOID_APP_OPTIONS_CHANGE
test cx, mask ABID_OPERATION_IN_PROGRESS ; Identifier
jz endOperation
;startOperation:
; Since we're starting up some operation that we don't want to be
; detached in the middle of, change our status to indicate that
; we wish to avoid transparent detach.
;
mov cx, mask AS_AVOID_TRANSPARENT_DETACH ; bit to set
clr dx ; nothing to clear
jmp short ready
endOperation:
; Now that we're done with the background operation, allow ourselves
; to be transparently detachable agin.
;
clr cx ; nothing to set
mov dx, mask AS_AVOID_TRANSPARENT_DETACH ; bit to clear
ready:
mov ax, MSG_GEN_APPLICATION_SET_STATE
call UserCallApplication
ret
AvoidAppOptionsChange endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AvoidAppCallSuperAndUpdateActiveBox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Intercept various messages that affect changes in the state
we use to decided whether to have an Active dialog up or
not, call the superclass to provide default handling, & then
get the Active dialog on or off screen as current state
dictates.
PASS: *ds:si - app object
es - segment of class
ax - message
nothing
RETURN: nothing
ALLOWED TO DESTROY:
bx, si, di, ds, es
PSEUDO CODE/STRATEGY/KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
doug 4/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AvoidAppCallSuperAndUpdateActiveBox method AvoidApplicationClass,
MSG_META_GAINED_FULL_SCREEN_EXCL,
MSG_META_LOST_FULL_SCREEN_EXCL,
MSG_GEN_APPLICATION_SET_STATE,
MSG_META_DETACH
mov di, offset AvoidApplicationClass
call ObjCallSuperNoLock
pushf
push ax, cx, dx, bp ; save return values
call AvoidAppUpdateActiveBox
pop ax, cx, dx, bp ; restore return values
popf
ret
AvoidAppCallSuperAndUpdateActiveBox endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AvoidAppUpdateActiveBox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Check current state to see whether Active box should be on
screen or off, then get it there.
CALLED BY: INTERNAL
PASS: *ds:si - GenApplication
RETURN: nothing
DESTROYED: ax, bx, cx, dx, di, bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Doug 4/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AvoidAppUpdateActiveBox proc near
; All these messages in one way or another affect whether we want
; to have the Activate dialog on screen... SO figure out again
; if we want to have it up, based on current state.
;
; Up only if AS_AVOID_TRANSPARENT_DETACH and (not AS_DETACHING) and
; (not AS_HAS_FULL_SCREEN_EXCL), otherwise down.
;
mov ax, MSG_GEN_APPLICATION_GET_STATE
call UserCallApplication
test ax, mask AS_AVOID_TRANSPARENT_DETACH
jz offScreen
test ax, mask AS_DETACHING
jnz offScreen
test ax, mask AS_HAS_FULL_SCREEN_EXCL
jnz offScreen
;onScreen:
call AvoidAppInitiateActiveDialog
jmp short done
offScreen:
call AvoidAppDismissActiveDialog
done:
ret
AvoidAppUpdateActiveBox endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AvoidAppInitiateActiveDialog
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get "Active" dialog on screen
CALLED BY: INTERNAL
AvoidAppLostFullScreenExcl
PASS: *ds:si - app object
RETURN: nothing
DESTROYED: ax, bx, cx, dx, di, bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Doug 5/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AvoidAppInitiateActiveDialog proc near uses si
.enter
GetResourceHandleNS ActiveDialog, bx
mov si, offset AvoidActiveDialog
; See if already in use or not
;
mov ax, MSG_GEN_FIND_PARENT
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
tst cx ; If already has parent, then we may
jnz afterInAndUsable ; assume usable as well since we always
; do this in pairs, so just initiate
mov cx, bx
mov dx, si
clr bp
mov ax, MSG_GEN_ADD_CHILD
call UserCallApplication
mov ax, MSG_GEN_SET_USABLE
mov dl, VUM_NOW
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
afterInAndUsable:
mov ax, MSG_GEN_INTERACTION_INITIATE
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
.leave
ret
AvoidAppInitiateActiveDialog endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AvoidAppDismissActiveDialog
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Remove "Active" dialog from screen
CALLED BY: INTERNAL
PASS: *ds:si - app object
RETURN: nothing
DESTROYED: ax, bx, cx, dx, di, bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Doug 5/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AvoidAppDismissActiveDialog proc near uses si
.enter
GetResourceHandleNS ActiveDialog, bx
mov si, offset AvoidActiveDialog
; See if hooked in & on screen or not
;
mov ax, MSG_GEN_FIND_PARENT
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
tst cx ; If no parent, then must be not usable
jz done ; as well. Exit with nothing to do.
mov ax, MSG_GEN_SET_NOT_USABLE
mov dl, VUM_NOW
call ObjMessage
mov cx, bx
mov dx, si
clr bp
mov ax, MSG_GEN_REMOVE_CHILD
call UserCallApplication
done:
.leave
ret
AvoidAppDismissActiveDialog endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AvoidAppGoToAvoid
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Respond to user request to go to this application
PASS: *ds:si - instance data
ds:di - ptr to start of master instance data
es - segment of class
ax - MSG_AVOID_APP_GOTO_AVOID
RETURN: nothing
ALLOWED TO DESTROY:
bx, si, di, ds, es
PSEUDO CODE/STRATEGY/KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
doug 4/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AvoidAppGoToAvoid method AvoidApplicationClass, MSG_AVOID_APP_GOTO_AVOID
;
; Raise our app back to the top, which as a by-product, will bring
; down the Active dialog, if up (because of a GAINED_FULL_SCREEN_EXCL
; arriving that we intercept)
;
mov ax, MSG_GEN_BRING_TO_TOP
GOTO ObjCallInstanceNoLock
AvoidAppGoToAvoid endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AvoidAppQuitOperation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Respond to user request to go to this application
PASS: *ds:si - instance data
ds:di - ptr to start of master instance data
es - segment of class
ax - MSG_AVOID_APP_GOTO_AVOID
RETURN: nothing
ALLOWED TO DESTROY:
bx, si, di, ds, es
PSEUDO CODE/STRATEGY/KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
doug 4/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AvoidAppQuitOperation method AvoidApplicationClass,
MSG_AVOID_APP_QUIT_OPERATION
push si
GetResourceHandleNS Interface, bx
mov si, offset AvoidOptionsBooleanGroup
; Clear operation boolean
;
mov ax, MSG_GEN_BOOLEAN_GROUP_SET_BOOLEAN_STATE
mov cx, mask ABID_OPERATION_IN_PROGRESS ; Identifier
clr dx ; clear boolean
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
pop si
; Quit avoiding detach, which as a by-product will bring down the
; Active dialog, if up.
;
clr cx
mov dx, mask AS_AVOID_TRANSPARENT_DETACH
mov ax, MSG_GEN_APPLICATION_SET_STATE
call UserCallApplication
ret
AvoidAppQuitOperation endm
AppCode ends ;end of AppCode resource
|
#include "StdInc.h"
#include "DrawCommands.h"
#include "Hooking.h"
#include "CfxRect.h"
#include <CrossBuildRuntime.h>
#define PURECALL() __asm { jmp _purecall }
namespace rage
{
struct dlDrawCommandBuffer
{
void AddDrawCommand(int type);
};
}
static hook::thiscall_stub<void(rage::dlDrawCommandBuffer*, int)> addDrawCommand([] ()
{
return hook::pattern("48 8B D9 44 23 91 38 18 00 00 41 81").count(1).get(0).get<void>(-0xC);
});
static hook::cdecl_stub<void*(uintptr_t)> allocDrawCommand([] ()
{
return hook::pattern("48 8B D9 4D 63 82 38 18 00 00 49").count(1).get(0).get<void>(-0xD);
});
class DrawCommand
{
private:
uint32_t m_size;
uint32_t m_pad;
public:
inline void SetSize(int size)
{
m_size &= 0xFFF00000;
m_size |= 0x33000;
m_size |= size >> 2;
}
};
class GenericTwoArgDrawCommand : public DrawCommand
{
private:
void(*m_callback)(void*);
char m_pad[16];
void(*m_userCallback)(uintptr_t, uintptr_t);
uintptr_t m_data1;
uintptr_t m_data2;
private:
void InvokeCommand()
{
m_userCallback(m_data1, m_data2);
}
public:
void Initialize(void(*userCB)(uintptr_t, uintptr_t), uintptr_t* data1, uintptr_t* data2)
{
m_callback = [] (void* data)
{
((GenericTwoArgDrawCommand*)(((char*)data) - 32))->InvokeCommand();
};
m_userCallback = userCB;
m_data1 = *data1;
m_data2 = *data2;
}
};
template<typename T>
T* AllocateDrawCommand()
{
T* dc = (T*)allocDrawCommand(sizeof(T));
dc->SetSize(sizeof(T));
return dc;
}
void rage::dlDrawCommandBuffer::AddDrawCommand(int type)
{
return addDrawCommand(this, type);
}
static rage::dlDrawCommandBuffer** g_drawCommandBuffer;
void EnqueueGenericDrawCommand(void(*cb)(uintptr_t, uintptr_t), uintptr_t* arg1, uintptr_t* arg2)
{
if (!IsOnRenderThread())
{
(*g_drawCommandBuffer)->AddDrawCommand(8);
GenericTwoArgDrawCommand* dc = AllocateDrawCommand<GenericTwoArgDrawCommand>();
dc->Initialize(cb, arg1, arg2);
}
else
{
cb(*arg1, *arg2);
}
}
static int32_t g_renderThreadTlsIndex;
bool IsOnRenderThread()
{
char* moduleTls = *(char**)__readgsqword(88);
return (*reinterpret_cast<int32_t*>(moduleTls + g_renderThreadTlsIndex) & 2) != 0;
}
//void WRAPPER SetTexture(rage::grcTexture* texture) { EAXJMP(0x627FB0); }
static hook::cdecl_stub<void()> drawImVertices([] ()
{
return hook::get_call(hook::pattern("E9 ? ? ? ? E8 ? ? ? ? 8B 7C 24 58 44").count(1).get(0).get<void>(5));
});
static hook::cdecl_stub<void(int, int)> beginImVertices([] ()
{
return hook::pattern("48 8D 44 24 60 45 8D 41 24 8B D3 8B CF").count(1).get(0).get<void>(-0x5E);
});
static hook::cdecl_stub<void(float, float, float, float, float, float, uint32_t, float, float)> addImVertex([] ()
{
return hook::pattern("F3 41 0F 11 01 F3 0F 10 44 24 28 F3 41").count(1).get(0).get<void>(-0x30);
});
namespace rage
{
void grcBegin(int type, int count)
{
beginImVertices(type, count);
}
void grcVertex(float x, float y, float z, float nX, float nY, float nZ, uint32_t color, float u, float v)
{
// colors are the other way around in Payne again, so RGBA-swap we go
color = (color & 0xFF00FF00) | _rotl(color & 0x00FF00FF, 16);
addImVertex(x, y, z, nX, nY, nZ, color, u, v);
}
void grcEnd()
{
drawImVertices();
}
}
static hook::cdecl_stub<void(void*, void*, bool)> setScreenSpaceMatrix([] ()
{
return hook::pattern("48 85 C9 48 8B D9 48 8B FA 48 0F 44").count(1).get(0).get<void>(-0xA);
});
static hook::thiscall_stub<void(intptr_t, int, int, int32_t)> setSubShader([] ()
{
return hook::pattern("4C 63 DA 83 F8 FF 75 07").count(1).get(0).get<void>(-0x6);
});
static hook::thiscall_stub<void(intptr_t, int)> setSubShaderUnk([] ()
{
return hook::get_call(hook::pattern("F6 D8 1B D2 83 E2 02 E8 ? ? ? ? 41 8B D7").count(1).get(0).get<void>(7));
});
static intptr_t* gtaImShader;
static int32_t* gtaImTechnique;
static HookFunction shaderIdHookFunc([] ()
{
auto shaderMatch = hook::pattern("F0 00 00 80 3F E8 ? ? ? ? 44 8B 0D").count(1).get(0).get<char>(13);
gtaImTechnique = (int32_t*)(*(int32_t*)shaderMatch + shaderMatch + 4);
shaderMatch += 7;
gtaImShader = (intptr_t*)(*(int32_t*)shaderMatch + shaderMatch + 4);
});
static hook::cdecl_stub<void(void*)> drawMatrix_ctor([]()
{
return hook::get_pattern("80 3F 33 C9 48 89 8B 10 04 00 00", -12);
});
struct drawMatrix
{
char pad[1168];
drawMatrix()
{
drawMatrix_ctor(this);
}
};
static hook::cdecl_stub<void(drawMatrix*)> activateMatrix([]()
{
return hook::get_pattern("40 8A F2 48 8B D9 75 14", -0x1D);
});
static drawMatrix* g_imMatrix;
void PushDrawBlitImShader()
{
if (!g_imMatrix)
{
g_imMatrix = new drawMatrix();
}
// activate matrix
activateMatrix(g_imMatrix);
// set screen space stuff
setScreenSpaceMatrix(nullptr, nullptr, true);
// shader methods: set subshader?
setSubShader(*gtaImShader, 0, 0, *gtaImTechnique);
setSubShaderUnk(*gtaImShader, 0);
}
static hook::thiscall_stub<void(intptr_t)> popSubShader([] ()
{
return hook::get_call(hook::pattern("48 8B 4F 48 E8 ? ? ? ? 48 8B 4F 48 E8").get(0).get<void>(4));
});
static hook::thiscall_stub<void(intptr_t)> popSubShaderUnk([] ()
{
return hook::get_call(hook::pattern("48 8B 4F 48 E8 ? ? ? ? 48 8B 4F 48 E8").get(0).get<void>(13));
});
static hook::cdecl_stub<void()> popImShaderAndResetParams([] ()
{
// 393-
if (Is372())
{
return hook::get_call(hook::pattern("0F 28 D8 E8 ? ? ? ? 48 8D 4C 24 68 E8 ? ? ? ? 48 8B").count(1).get(0).get<void>(13));
}
// 463/505+
return hook::get_call(hook::pattern("F3 0F 11 64 24 20 E8 ? ? ? ? 48 8D 8C 24 98").count(1).get(0).get<void>(19));
});
void PopDrawBlitImShader()
{
//popSubShaderUnk(*gtaImShader);
//popSubShader(*gtaImShader);
popImShaderAndResetParams();
}
// params2 is unused for drawblit, params1 is global color multiplier (default multiplies alpha by 0 :( )
static hook::cdecl_stub<void(const float[4], const float[4])> setImGenParams([] ()
{
return hook::get_call(hook::pattern("48 8D 4D A7 0F 29 4D A7 0F 29 45 97 E8").count(1).get(0).get<void>(12));
});
static hook::cdecl_stub<void(rage::grcTexture*)> setTextureGtaIm([] ()
{
return hook::pattern("48 8B D9 4C 8B C9 48 8B 0D").count(1).get(0).get<void>(-0xD);
});
void SetTextureGtaIm(rage::grcTexture* texture)
{
const float params1[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
const float params2[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
setImGenParams(params1, params2);
setTextureGtaIm(texture);
}
//void WRAPPER DrawImSprite(float x1, float y1, float x2, float y2, float z, float u1, float v1, float u2, float v2, uint32_t* color, int subShader) { EAXJMP(0x852CE0); }
void DrawImSprite(float x1, float y1, float x2, float y2, float z, float u1, float v1, float u2, float v2, uint32_t* colorPtr, int subShader)
{
auto oldRasterizerState = GetRasterizerState();
SetRasterizerState(GetStockStateIdentifier(StateType::RasterizerStateNoCulling));
auto oldDepthStencilState = GetDepthStencilState();
SetDepthStencilState(GetStockStateIdentifier(StateType::DepthStencilStateNoDepth));
PushDrawBlitImShader();
uint32_t color = *colorPtr;
// this swaps ABGR (as CRGBA is ABGR in little-endian) to ARGB by rotating left
color = (color & 0xFF00FF00) | _rotl(color & 0x00FF00FF, 16);
CRect rect(x1, y1, x2, y2);
rage::grcBegin(4, 4);
rage::grcVertex(rect.fX1, rect.fY1, z, 0.0f, 0.0f, -1.0f, color, u1, v1);
rage::grcVertex(rect.fX2, rect.fY1, z, 0.0f, 0.0f, -1.0f, color, u2, v1);
rage::grcVertex(rect.fX1, rect.fY2, z, 0.0f, 0.0f, -1.0f, color, u1, v2);
rage::grcVertex(rect.fX2, rect.fY2, z, 0.0f, 0.0f, -1.0f, color, u2, v2);
rage::grcEnd();
PopDrawBlitImShader();
SetDepthStencilState(oldDepthStencilState);
SetRasterizerState(oldRasterizerState);
}
static uint32_t* g_resolution;
static uint32_t g_realResolution[2];
void GetGameResolution(int& resX, int& resY)
{
resX = g_resolution[0];
resY = g_resolution[1];
if (IsOnRenderThread() && (resX != resY))
{
g_realResolution[0] = resX;
g_realResolution[1] = resY;
}
else
{
resX = g_realResolution[0];
resY = g_realResolution[1];
}
}
static hook::cdecl_stub<uint32_t(const D3D11_RASTERIZER_DESC*)> createRasterizerState([]()
{
return hook::get_pattern("48 8D 4D D7 F3 0F 11 7D FF F3 44 0F", -0x86);
});
hook::cdecl_stub<void(uint32_t)> setRasterizerState([] ()
{
return hook::pattern("74 0D 80 0D ? ? ? ? 02 89 0D ? ? ? ? C3").count(1).get(0).get<void>(-6);
});
static uint32_t* g_nextRasterizerState;
static uint32_t* g_nextBlendState;
static float** g_nextBlendFactor;
static uint32_t* g_nextSampleMask;
static uint32_t* g_nextDepthStencilState;
uint32_t CreateRasterizerState(const D3D11_RASTERIZER_DESC* desc)
{
return createRasterizerState(desc);
}
uint32_t GetRasterizerState()
{
return *g_nextRasterizerState;
}
void SetRasterizerState(uint32_t state)
{
setRasterizerState(state);
}
hook::cdecl_stub<void(uint32_t, float*, uint32_t)> setBlendState([] ()
{
return hook::pattern("74 1A 80 0D ? ? ? ? 04 89 0D").count(1).get(0).get<void>(-0x17);
});
uint32_t GetBlendState()
{
return *g_nextBlendState;
}
void SetBlendState(uint32_t state)
{
setBlendState(state, *g_nextBlendFactor, *g_nextSampleMask);
}
hook::cdecl_stub<void(uint32_t)> setDepthStencilState([] ()
{
return hook::pattern("3B C2 74 13 80 0D ? ? ? ? 01 89").count(1).get(0).get<void>(-0x2D);
});
uint32_t GetDepthStencilState()
{
return *g_nextDepthStencilState;
}
void SetDepthStencilState(uint32_t state)
{
setDepthStencilState(state);
}
static uint32_t* stockStates[StateTypeMax];
uint32_t GetStockStateIdentifier(StateType state)
{
if (state >= 0 && state < StateTypeMax)
{
return *stockStates[state];
}
return 0;
}
static hook::cdecl_stub<uint32_t(void* shaderGroup, void*, int sampler)> getSamplerState([] ()
{
return hook::get_call(hook::pattern("48 8D 91 88 02 00 00 44 0F 29 54 24 60 44 0F").count(1).get(0).get<void>(25));
});
static hook::cdecl_stub<void(void* shaderGroup, void*, int sampler, uint32_t)> setSamplerState([] ()
{
return hook::get_call(hook::pattern("48 8D 91 88 02 00 00 44 0F 29 54 24 60 44 0F").count(1).get(0).get<void>(25 + 36));
});
static hook::cdecl_stub<uint32_t(const D3D11_SAMPLER_DESC*)> createSamplerState([] ()
{
return hook::get_call(hook::pattern("54 03 00 00 00 C7 44 24 58 03 00 00 00").count(1).get(0).get<void>(13));
});
static int* g_imDiffuseSampler;
uint32_t CreateSamplerState(const D3D11_SAMPLER_DESC* desc)
{
return createSamplerState(desc);
}
uint32_t GetImDiffuseSamplerState()
{
char* struc = *(char**)((*gtaImShader) + 8);
return getSamplerState(struc, (void*)(*gtaImShader), *g_imDiffuseSampler);
}
void SetImDiffuseSamplerState(uint32_t samplerStateIdentifier)
{
char* struc = *(char**)((*gtaImShader) + 8);
setSamplerState(struc, (void*)(*gtaImShader), *g_imDiffuseSampler, samplerStateIdentifier);
}
static ID3D11Device** g_d3d11Device;
static int g_d3d11DeviceContextOffset;
ID3D11Device* GetD3D11Device()
{
return *g_d3d11Device;
}
ID3D11DeviceContext* GetD3D11DeviceContext()
{
return *(ID3D11DeviceContext**)(*(uintptr_t*)(__readgsqword(88)) + g_d3d11DeviceContextOffset);
}
#if 0
namespace rage
{
static hook::cdecl_stub<bool(grmShaderFx*, const char*, void*, bool)> _grmShaderFx_LoadTechnique([]()
{
// 1604-unused
return (void*)0x141330094;
});
static hook::cdecl_stub<int(grmShaderFx*, int, bool, int)> _grmShaderFx_PushTechnique([]()
{
// 1604-unused
return (void*)0x14132E0F8;
});
grmShaderFactory* grmShaderFactory::GetInstance()
{
// 1604-unused
return *(grmShaderFactory**)0x142B40F78;
}
static hook::cdecl_stub<void(grmShaderDef*, int, grmShaderFx*)> _grmShaderDef_PushPass([]()
{
// 1604-unused
return (void*)0x1412ECD74;
});
static hook::cdecl_stub<void(grmShaderDef*)> _grmShaderDef_PopPass([]()
{
// 1604-unused
return (void*)0x1412F630C;
});
static hook::cdecl_stub<int(grmShaderDef*, const char*)> _grmShaderDef_GetParameter([]()
{
// 1604-unused
return (void*)0x141304028;
});
static hook::cdecl_stub<int(grmShaderDef*, const char*)> _grmShaderDef_GetTechnique([]()
{
// 1604-unused
return (void*)0x141303EAC;
});
static hook::cdecl_stub<void(grmShaderDef*, grmShaderFx*, int, void*)> _grmShaderDef_SetSampler([]()
{
// 1604-unused
return (void*)0x14130CE88;
});
static hook::cdecl_stub<void(grmShaderDef*, grmShaderFx*, int, const void*, int, int)> _grmShaderDef_SetParameter([]()
{
// 1604-unused
return (void*)0x14130AB8C;
});
void grmShaderDef::PushPass(int pass, grmShaderFx* shader)
{
return _grmShaderDef_PushPass(this, pass, shader);
}
void grmShaderDef::PopPass()
{
return _grmShaderDef_PopPass(this);
}
int grmShaderDef::GetParameter(const char* name)
{
return _grmShaderDef_GetParameter(this, name);
}
int grmShaderDef::GetTechnique(const char* name)
{
return _grmShaderDef_GetTechnique(this, name);
}
void grmShaderDef::SetSampler(grmShaderFx* shader, int index, void* sampler)
{
return _grmShaderDef_SetSampler(this, shader, index, sampler);
}
void grmShaderDef::SetParameter(grmShaderFx* shader, int index, const void* data, int size, int count)
{
return _grmShaderDef_SetParameter(this, shader, index, data, size, count);
}
bool grmShaderFx::LoadTechnique(const char* name, void* templ, bool a4)
{
return _grmShaderFx_LoadTechnique(this, name, templ, a4);
}
int grmShaderFx::PushTechnique(int technique, bool unk1, int a4)
{
return _grmShaderFx_PushTechnique(this, technique, unk1, a4);
}
void grmShaderFx::PushPass(int index)
{
m_shader->PushPass(index, this);
}
void grmShaderFx::PopPass()
{
m_shader->PopPass();
}
void grmShaderFx::PopTechnique()
{
// 1604-unused
*(void**)0x142B07F80 = nullptr;
}
}
static hook::cdecl_stub<void(const float*)> _setWorldMatrix([]()
{
// 1604-unused
return (void*)0x141309F58;
});
void SetWorldMatrix(const float* matrix)
{
_setWorldMatrix(matrix);
}
#include <MinHook.h>
static void(*g_origRenderEntityList)(void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7);
fwEvent<> OnTempDrawEntityList;
void RenderEntityList(void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7)
{
OnTempDrawEntityList();
g_origRenderEntityList(a1, a2, a3, a4, a5, a6, a7);
}
static void(*g_origRunScannedEntityList)(void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7);
void RunScannedEntityList(void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7)
{
OnTempDrawEntityList();
g_origRunScannedEntityList(a1, a2, a3, a4, a5, a6, a7);
}
#endif
static HookFunction hookFunction([] ()
{
//MH_Initialize();
// 1604, TEMP/TODO, unused
//MH_CreateHook((void*)0x1404E9884, RenderEntityList, (void**)& g_origRenderEntityList);
// -> this MH_CreateHook((void*)0x1415955E0, RunScannedEntityList, (void**)&g_origRunScannedEntityList);
//hook::set_call(&g_origRunOnEntityList, )
//hook::set_call(&g_origRenderEntityList, 0x1404F3D8D);
//hook::call(0x1404F31C8, RenderEntityList);
//MH_EnableHook(MH_ALL_HOOKS);
char* location = hook::pattern("44 8B CE 33 D2 48 89 0D").count(1).get(0).get<char>(8);
g_d3d11Device = (ID3D11Device**)(location + *(int32_t*)location + 4);
g_d3d11DeviceContextOffset = *(int*)(location - 59);
// things
location = hook::pattern("74 0D 80 0D ? ? ? ? 02 89 0D ? ? ? ? C3").count(1).get(0).get<char>(-4);
g_nextRasterizerState = (uint32_t*)(*(int32_t*)location + location + 4);
location = hook::pattern("74 1A 80 0D ? ? ? ? 04 89 0D").count(1).get(0).get<char>(11);
g_nextBlendState = (uint32_t*)(*(int32_t*)location + location + 4);
location += 6;
g_nextBlendFactor = (float**)(*(int32_t*)location + location + 4);
location += 7;
g_nextSampleMask = (uint32_t*)(*(int32_t*)location + location + 4);
location = hook::pattern("3B C2 74 13 80 0D ? ? ? ? 01 89").count(1).get(0).get<char>(13);
g_nextDepthStencilState = (uint32_t*)(*(int32_t*)location + location + 4);
// sampler state stuff
location = hook::pattern("48 8B D9 4C 8B C9 48 8B 0D").count(1).get(0).get<char>(-4);
g_imDiffuseSampler = (int*)(*(int32_t*)location + location + 4);
// resolution
location = hook::pattern("C7 05 ? ? ? ? 00 05 00 00").count(1).get(0).get<char>(2);
g_resolution = (uint32_t*)(*(int32_t*)location + location + 8);
// states
location = hook::pattern("44 89 74 24 5C 89 05 ? ? ? ? E8").count(1).get(0).get<char>(7);
stockStates[RasterizerStateDefault] = (uint32_t*)(*(int32_t*)location + location + 4);
location += 17;
stockStates[RasterizerStateNoCulling] = (uint32_t*)(*(int32_t*)location + location + 4);
location += 20;
stockStates[BlendStateNoBlend] = (uint32_t*)(*(int32_t*)location + location + 4);
location = hook::pattern("44 89 7D EC 44 89 7D E0 89 05").count(1).get(0).get<char>(10);
stockStates[BlendStateDefault] = (uint32_t*)(*(int32_t*)location + location + 4);
// first one is subtractive; motivation for relying on count >1 is that this is a RAGE function, unlikely to get modified by patches
location = hook::pattern("48 8D 4D D0 33 D2 44 89 7D EC 89 05").count(2).get(1).get<char>(12);
stockStates[BlendStatePremultiplied] = (uint32_t*)(*(int32_t*)location + location + 4);
location = hook::pattern("33 D2 44 89 74 24 20 44 89 74 24 24 89 05").count(1).get(0).get<char>(14);
stockStates[DepthStencilStateNoDepth] = (uint32_t*)(*(int32_t*)location + location + 4);
// draw command buffer
location = hook::pattern("EB 07 48 89 2D ? ? ? ? BA 1E 00 00 00 48").count(1).get(0).get<char>(5);
g_drawCommandBuffer = (rage::dlDrawCommandBuffer**)(*(int32_t*)location + location + 4);
location = hook::pattern("42 09 0C 02 BA 01 00 00 00 83 F9 04 0F 44 C2").count(1).get(0).get<char>(-15);
g_renderThreadTlsIndex = *(int32_t*)location;
OnGrcCreateDevice.Connect([] ()
{
g_realResolution[0] = g_resolution[0];
g_realResolution[1] = g_resolution[1];
}, -500);
// set immediate mode vertex limit to 8x what it was (so, 32 MB)
{
auto location = hook::get_pattern<char>("44 89 74 24 74 89 05 ? ? ? ? 89 44", 5);
auto refloc = hook::get_address<char*>(location + 2);
hook::put<uint32_t>(refloc, 0x4000000);
hook::put<uint32_t>(refloc + 4, 0x7FFF8 * 4);
hook::nop(location, 6); // setter
hook::put<uint8_t>(location, 0xB8); // write to eax for later
hook::put<uint32_t>(location + 1, 0x4000000);
}
});
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r14
push %r15
push %r8
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x130b9, %r11
add %r8, %r8
movw $0x6162, (%r11)
nop
nop
sub %r14, %r14
lea addresses_WT_ht+0x1c05, %rbx
nop
nop
nop
nop
and $1765, %r15
mov $0x6162636465666768, %r12
movq %r12, %xmm4
vmovups %ymm4, (%rbx)
nop
nop
nop
nop
nop
and %rbx, %rbx
lea addresses_normal_ht+0x4909, %rsi
lea addresses_normal_ht+0x4830, %rdi
nop
cmp %r14, %r14
mov $112, %rcx
rep movsw
nop
inc %r12
lea addresses_WT_ht+0xcd49, %rcx
nop
nop
add %rdi, %rdi
mov (%rcx), %r12d
nop
nop
nop
nop
cmp %r14, %r14
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r15
pop %r14
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %r9
push %rbx
push %rdi
push %rdx
// Faulty Load
lea addresses_RW+0xdd49, %r9
cmp $1439, %rbx
mov (%r9), %edi
lea oracles, %r9
and $0xff, %rdi
shlq $12, %rdi
mov (%r9,%rdi,1), %rdi
pop %rdx
pop %rdi
pop %rbx
pop %r9
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_RW', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_RW', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 2}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32}}
{'src': {'same': False, 'congruent': 6, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_normal_ht'}}
{'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
#include "train_templ.h"
namespace {
template <>
inline TUserDefinedQuerywiseError BuildError<TUserDefinedQuerywiseError>(const NCatboostOptions::TCatBoostOptions& params, const TMaybe<TCustomObjectiveDescriptor>&) {
return TUserDefinedQuerywiseError(params.LossFunctionDescription->GetLossParams(), IsStoreExpApprox(params));
}
}
template void TrainOneIter<TUserDefinedQuerywiseError>(const TTrainData&, TLearnContext*);
|
/* --------------------------------------------------------------------------
* CppADCodeGen: C++ Algorithmic Differentiation with Source Code Generation:
* Copyright (C) 2016 Ciengis
*
* CppADCodeGen is distributed under multiple licenses:
*
* - Eclipse Public License Version 1.0 (EPL1), and
* - GNU General Public License Version 3 (GPL3).
*
* EPL1 terms and conditions can be found in the file "epl-v10.txt", while
* terms and conditions for the GPL3 can be found in the file "gpl3.txt".
* ----------------------------------------------------------------------------
* Author: Joao Leal
*/
#include <iosfwd>
#include <cppad/cg.hpp>
#include <cppad/cg/lang/latex/latex.hpp>
using namespace CppAD;
using namespace CppAD::cg;
int main() {
// use a special object for source code generation
using CGD = CG<double>;
using ADCG = AD<CGD>;
/***************************************************************************
* the model
**************************************************************************/
// independent variable vector
CppAD::vector<ADCG> x(2);
x[0] = 2.;
x[1] = 3.;
Independent(x);
// dependent variable vector
CppAD::vector<ADCG> y(1);
// the model
ADCG a = x[0] / 1. + x[1] * x[1];
y[0] = a / 2;
ADFun<CGD> fun(x, y); // the model tape
/***************************************************************************
* Generate the Latex source code
**************************************************************************/
CodeHandler<double> handler;
CppAD::vector<CGD> xv(x.size());
handler.makeVariables(xv);
CppAD::vector<CGD> vals = fun.Forward(0, xv);
LanguageLatex<double> langLatex;
LangLatexDefaultVariableNameGenerator<double> nameGen;
std::ofstream texfile;
texfile.open("algorithm.tex");
handler.generateCode(texfile, langLatex, vals, nameGen);
texfile.close();
/***************************************************************************
* Compile a PDF file
**************************************************************************/
#ifdef PDFLATEX_COMPILER
std::string dir = system::getWorkingDirectory();
system::callExecutable(PDFLATEX_COMPILER, {"-halt-on-error", "-shell-escape",
system::createPath({dir, "resources"}, "latex_template.tex")});
#endif
} |
; size_t b_array_insert_callee(b_array_t *a, size_t idx, int c)
SECTION code_adt_b_array
PUBLIC _b_array_insert_callee
_b_array_insert_callee:
pop af
pop hl
pop bc
pop de
push af
INCLUDE "adt/b_array/z80/asm_b_array_insert.asm"
|
; A009001: Expansion of e.g.f: (1+x)*cos(x).
; 1,1,-1,-3,1,5,-1,-7,1,9,-1,-11,1,13,-1,-15,1,17,-1,-19,1,21,-1,-23,1,25,-1,-27,1,29,-1,-31,1,33,-1,-35,1,37,-1,-39,1,41,-1,-43,1,45,-1,-47,1,49,-1,-51,1,53,-1,-55,1,57,-1,-59,1,61,-1,-63,1,65,-1,-67,1,69,-1,-71,1,73,-1,-75,1,77,-1,-79,1,81,-1,-83,1,85,-1,-87,1,89,-1,-91,1,93,-1,-95,1,97,-1,-99,1,101,-1,-103,1,105,-1,-107,1,109,-1,-111,1,113,-1,-115,1,117,-1,-119,1,121,-1,-123,1,125,-1,-127,1,129,-1,-131,1,133,-1,-135,1,137,-1,-139,1,141,-1,-143,1,145,-1,-147,1,149,-1,-151,1,153,-1,-155,1,157,-1,-159,1,161,-1,-163,1,165,-1,-167,1,169,-1,-171,1,173,-1,-175,1,177,-1,-179,1,181,-1,-183,1,185,-1,-187,1,189,-1,-191,1,193,-1,-195,1,197,-1,-199,1,201,-1,-203,1,205,-1,-207,1,209,-1,-211,1,213,-1,-215,1,217,-1,-219,1,221,-1,-223,1,225,-1,-227,1,229,-1,-231,1,233,-1,-235,1,237,-1,-239,1,241,-1,-243,1,245,-1,-247,1,249
mov $1,$0
mov $2,$0
mov $0,1
lpb $2
sub $1,$0
add $0,$1
sub $1,$0
sub $2,1
lpe
mov $1,$0
|
/***
* This file is based on or incorporates material from the UnitTest++ r30 open source project.
* Microsoft is not the original author of this code but has modified it and is licensing the code under
* the MIT License. Microsoft reserves all other rights not expressly granted under the MIT License,
* whether by implication, estoppel or otherwise.
*
* UnitTest++ r30
*
* Copyright (c) 2006 Noel Llopis and Charles Nicholson
* Portions Copyright (c) Microsoft Corporation
*
* All Rights Reserved.
*
* MIT License
*
* 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.
***/
#include "TestHeader.h"
namespace UnitTest {
TestReporter::TestReporter()
{
}
TestReporter::~TestReporter()
{
}
}
|
;
; feilipu, 2019 April
;
; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;
;-------------------------------------------------------------------------
; m32_fsmul - z80 floating point multiply
;-------------------------------------------------------------------------
;
; since the z180, and z80n only have support for 8x8bit multiply,
; the multiplication of the mantissas needs to be broken
; into stages and accumulated at the end.
;
; calculation for the z80 is done by replicating z180 mlt de functionality
; with a fast 16_8x8 multiply, with zero operand and zero bit elimination.
;
; abc * def
;
; = (ab*2^8+c) * (de*2^8+f)
; = ab*de*2^16 +
; ab*f*2^8 + c*de*2^8 +
; c*f
;
; = a*d*2^32 + a*e*2^24 + b*d*2^24 + b*e*2^16 +
; a*f*2^16 + b*f*2^8 +
; c*d*2^16 + c*e*2^8 +
; c*f
;
; = (a*d)*2^32 +
; (a*e + b*d)*2^24 +
; (b*e + a*f + c*d)*2^16 +
; (b*f + c*e)*2^8 +
; (c*f)*2^0
;
; assume worst overflow case: abc=def=0xffffff
; assume worst underflow case: abc=def=0x800000
;
; 0xFF FF FF * 0xFF FF FF = 0x FF FF FE 00 00 01
;
; 0x80 00 00 * 0x80 00 00 = 0x 40 00 00 00 00 00
;
; for underflow, maximum left shift is 1 place
; so we should report 32 bits of accuracy (don't need all 48 bits)
; = 24 bits significant + 1 bit shift + 7 bits rounding
;
;-------------------------------------------------------------------------
; FIXME clocks
;-------------------------------------------------------------------------
SECTION code_clib
SECTION code_fp_math32
EXTERN m32_fsconst_nzero, m32_fsconst_pzero
EXTERN m32_fsconst_ninf, m32_fsconst_pinf
EXTERN m32_mulu_32h_24x24
PUBLIC m32_fsmul, m32_fsmul_callee
.m32_fsmul
ex de,hl ; DEHL -> HLDE
ld a,h ; put sign bit into A
add hl,hl ; shift exponent into H
scf ; set implicit bit
rr l ; shift msb into mantissa
exx ; first h' = eeeeeeee, lde' = 1mmmmmmm mmmmmmmm mmmmmmmm
ld hl,002h ; get second operand off of the stack
add hl,sp
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld c,(hl)
inc hl
ld h,(hl)
ld l,c ; hlde = seeeeeee emmmmmmm mmmmmmmm mmmmmmmm
jr fmrejoin
.m32_fsmul_callee
ex de,hl ; DEHL -> HLDE
ld a,h ; put sign bit into A
add hl,hl ; shift exponent into H
scf ; set implicit bit
rr l ; shift msb into mantissa
exx ; first h' = eeeeeeee, lde' = 1mmmmmmm mmmmmmmm mmmmmmmm
pop bc ; pop return address
pop de ; get second operand off of the stack
pop hl ; hlde = seeeeeee emmmmmmm mmmmmmmm mmmmmmmm
push bc ; return address on stack
.fmrejoin
xor a,h ; xor sign flags
ex af,af ; save sign flag in a[7]' and f' reg
add hl,hl ; shift exponent into h
scf ; set implicit bit
rr l ; shift msb into mantissa
; second h = eeeeeeee, lde = 1mmmmmmm mmmmmmmm mmmmmmmm
ld a,h ; calculate the exponent
or a ; second exponent zero then result is zero
jr Z,mulzero
sub a,07fh ; subtract out bias, so when exponents are added only one bias present
jr C,fmchkuf
exx
add a,h
jp C,mulovl
jr fmnouf
.fmchkuf
exx
add a,h ; add the exponents
jr NC,mulzero
.fmnouf
ld b,a
or a
jr Z,mulzero ; check sum of exponents for zero
ex af,af
ld a,b
push af ; stack: sum of exponents a, and xor sign of exponents in f
; first h = eeeeeeee, lde = 1mmmmmmm mmmmmmmm mmmmmmmm
; second h' = eeeeeeee, lde' = 1mmmmmmm mmmmmmmm mmmmmmmm
; sum of exponents in a', xor of exponents in sign f'
;
; multiplication of two 24-bit numbers into a 32-bit product
call m32_mulu_32h_24x24 ; exit : HLDE = 32-bit product
pop bc ; retrieve sign and exponent from stack = b,c[7]
bit 7,h ; need to shift result left if msb!=1
jr NZ,fm2
sla e
rl d
adc hl,hl
jr fm3
.fm2
inc b
jr Z,mulovl
.fm3
ld a,e
ld e,h ; put 24 bit mantissa in place, HLD into EHL
ld h,l
ld l,d
and 0c0h ; round using feilipu method
jr Z,fm4
set 0,l
.fm4
sla e ; adjust mantissa for exponent
sla c ; put sign into C
rr b ; put sign and 7 exp bits into place
rr e ; put last exp bit into place
ld d,b ; put sign and exponent in D
ret ; return IEEE DEHL
.mulovl
ex af,af ; get sign
rla
jp C,m32_fsconst_ninf
jp m32_fsconst_pinf ; done overflow
.mulzero
ex af,af ; get sign
rla
jp C,m32_fsconst_nzero
jp m32_fsconst_pzero ; done underflow
|
Route2TradeHouse_h:
db HOUSE ; tileset
db ROUTE_2_TRADE_HOUSE_HEIGHT, ROUTE_2_TRADE_HOUSE_WIDTH ; dimensions (y, x)
dw Route2TradeHouse_Blocks ; blocks
dw Route2TradeHouse_TextPointers ; texts
dw Route2TradeHouse_Script ; scripts
db 0 ; connections
dw Route2TradeHouse_Object ; objects
|
; A089833: a(n) = A000108(n)*(A000142(n+1)-1).
; Submitted by Christian Krause
; 0,1,10,115,1666,30198,665148,17296851,518916970,17643220738,670442556004,28158587998814,1295295050441588,64764752531737100,3497296636751245560,202843204931717665155,12576278705767060962330
mov $2,$0
add $0,1
seq $0,33312 ; a(n) = n! - 1.
seq $2,108 ; Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!).
mul $0,$2
|
// Given an x/y position and some text
message: .byte $0f, $03
.text "hello world\n"
.byte $01, $00
.text "how are you?\0"
// When we display that text
test_text:
lda #<message
sta text_src
lda #>message
sta text_src+1
// Then it should appear at the given x/y position on screen
lda #<actual_text_buffer
sta plot_buffer_lo
lda #>actual_text_buffer
sta plot_buffer_hi
lda #$28
sta plot_buffer_x
lda #$05
sta plot_buffer_y
jsr text_plot
lda #<expected_text_buffer
sta expected_plot_buffer_lo
lda #>expected_text_buffer
sta expected_plot_buffer_hi
lda #<actual_text_buffer
sta actual_plot_buffer_lo
lda #>actual_text_buffer
sta actual_plot_buffer_hi
lda #$28
sta buffers_x
lda #$05
sta buffers_y
jsr compare_buffers
lda cmp_res
bne !fail+
lda #green
jmp !result+
!fail: lda #red
!result: sta $d020
rts
expected_text_buffer:
.text " how are you? "
.text " "
.text " "
.text " hello world "
.text " "
.byte $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
actual_text_buffer:
.text " "
.text " "
.text " "
.text " "
.text " "
.byte $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
|
; THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
; SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
; END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
; ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
; IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
; SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
; FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
; CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
; AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
; COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
.386
option oldstructs
.nolist
include pstypes.inc
include psmacros.inc
include tmap_inc.asm
.list
assume cs:_TEXT, ds:_DATA
_DATA segment dword public USE32 'DATA'
rcsid db "$Id: tmap_lnt.asm 1.2 1996/01/24 18:33:58 matt Exp $"
align 4
num_big_steps dd ?
_DATA ends
_TEXT segment para public USE32 'CODE'
align 16
public asm_tmap_scanline_lnt_
asm_tmap_scanline_lnt_:
START_TIMER
push eax
push ecx
push edx
push ebx
push ebp
push esi
push edi
; set edi = address of first pixel to modify
mov edi, _dest_row_data
mov eax, _fx_v
shr eax, 6
mov edx, _fx_u
shl edx, 10
mov dx, ax ; EDX=U:V in 6.10 format
mov eax, _fx_dv_dx
shr eax, 6
mov esi, _fx_du_dx
shl esi, 10
mov si, ax ; ESI=DU:DV in 6.10 format
mov ecx, _pixptr
mov eax, _loop_count
inc eax
mov _loop_count, eax
shr eax, 3
je DoLeftOverPixels
mov num_big_steps, eax
and _loop_count, 7
NextPixelBlock:
COUNT = 0
REPT 8
mov eax, edx
shr ax, 10
rol eax, 6
and eax, 0ffffh
add edx, esi
mov al, [ecx+eax]
cmp al, 255
je @f
mov [edi+COUNT], al
@@:
COUNT = COUNT + 1
ENDM
add edi, COUNT
dec num_big_steps
jne NextPixelBlock
DoLeftOverPixels:
mov eax,_loop_count
test eax, -1
jz _none_to_do
shr eax, 1
je one_more_pix
mov _loop_count, eax
pushf
NextPixel:
COUNT = 0
REPT 2
mov eax, edx
shr ax, 10
rol eax, 6
and eax, 0ffffh
add edx, esi
mov al, [ecx+eax]
cmp al, 255
je @f
mov [edi+COUNT], al
@@:
COUNT = COUNT + 1
ENDM
add edi, COUNT
dec _loop_count
jne NextPixel
popf
jnc _none_to_do
one_more_pix:
mov eax, edx
shr ax, 10
rol eax, 6
and eax, 0ffffh
mov al, [ecx+eax]
cmp al, 255
je @f
mov [edi], al
@@:
_none_to_do:
pop edi
pop esi
pop ebp
pop ebx
pop edx
pop ecx
pop eax
STOP_TIMER
ret
_TEXT ends
end
|
; A103831: For even n, a(n) = n*(n+1), for odd n, a(n) = 2*n + 1.
; 0,3,6,7,20,11,42,15,72,19,110,23,156,27,210,31,272,35,342,39,420,43,506,47,600,51,702,55,812,59,930,63,1056,67,1190,71,1332,75,1482,79,1640,83,1806,87,1980,91,2162,95,2352,99,2550,103,2756,107,2970,111,3192,115,3422,119,3660,123,3906,127,4160,131,4422,135,4692,139,4970,143,5256,147,5550,151,5852,155,6162,159,6480,163,6806,167,7140,171,7482,175,7832,179,8190,183,8556,187,8930,191,9312,195,9702,199,10100,203,10506,207,10920,211,11342,215,11772,219,12210,223,12656,227,13110,231,13572,235,14042,239,14520,243,15006,247,15500,251,16002,255,16512,259,17030,263,17556,267,18090,271,18632,275,19182,279,19740,283,20306,287,20880,291,21462,295,22052,299,22650,303,23256,307,23870,311,24492,315,25122,319,25760,323,26406,327,27060,331,27722,335,28392,339,29070,343,29756,347,30450,351,31152,355,31862,359,32580,363,33306,367,34040,371,34782,375,35532,379,36290,383,37056,387,37830,391,38612,395,39402,399,40200,403,41006,407,41820,411,42642,415,43472,419,44310,423,45156,427,46010,431,46872,435,47742,439,48620,443,49506,447,50400,451,51302,455,52212,459,53130,463,54056,467,54990,471,55932,475,56882,479,57840,483,58806,487,59780,491,60762,495,61752,499
mov $1,2
gcd $1,$0
mov $2,$0
pow $0,$1
mul $1,2
mod $1,3
add $1,$0
sub $1,1
add $1,$2
|
;
; Extracted from cephes-math
;
; Cephes is a C language library for special functions of mathematical physics
; and related items of interest to scientists and engineers.
; https://fossies.org/
;
; Coefficients from lolremez, to make use of additional accuracy in
; calculation from 32-bit mantissa poly() function.
;
; Approximation of f(x) = 10**x
; with weight function g(x) = 10**x
; on interval [ 0, 0.15051499783 ]
; with a polynomial of degree 7.
; double f(double x)
; {
; double u = 8.090484272600454e-2;
; u = u * x + 2.0380373931544082e-1;
; u = u * x + 5.3978993685198384e-1;
; u = u * x + 1.1712266435079228;
; u = u * x + 2.0346796696616236;
; u = u * x + 2.6509490353631601;
; u = u * x + 2.3025850931327687;
; return u * x + 9.9999999999984258e-1;
; }
;
;-------------------------------------------------------------------------
; Coefficients for exp10f()
;-------------------------------------------------------------------------
SECTION rodata_fp_math32
PUBLIC _m32_coeff_exp10f
._m32_coeff_exp10f
DEFQ 0x3F800000 ; 1.0000000000000000E+00
DEFQ 0x40135D8E ; 2.3025850931327687E+00
DEFQ 0x4029A926 ; 2.6509490353631601E+00
DEFQ 0x40023831 ; 2.0346796696616236E+00
DEFQ 0x3F95EAC1 ; 1.1712266435079228E+00
DEFQ 0x3F0A2FAC ; 5.3978993685198384E-01
DEFQ 0x3E50B1ED ; 2.0380373931544082E-01
DEFQ 0x3DA5B170 ; 8.0904842726004540E-02
|
// Copyright (c) 2017-present, Xiaomi, Inc. All rights reserved.
// This source code is licensed under the Apache License Version 2.0, which
// can be found in the LICENSE file in the root directory of this source tree.
#include <gtest/gtest.h>
#include <dsn/utility/fail_point.h>
#include "replica_test_base.h"
namespace dsn {
namespace replication {
class replica_split_test : public testing::Test
{
public:
void SetUp()
{
_stub = make_unique<mock_replica_stub>();
_stub->set_state_connected();
mock_app_info();
_parent = _stub->generate_replica(
_app_info, _parent_pid, partition_status::PS_PRIMARY, _init_ballot);
mock_group_check_request();
}
void TearDown() {}
void mock_app_info()
{
_app_info.app_id = 2;
_app_info.app_name = "split_test";
_app_info.app_type = "replica";
_app_info.is_stateful = true;
_app_info.max_replica_count = 3;
_app_info.partition_count = 8;
}
void mock_group_check_request()
{
_group_check_req.child_gpid = _child_pid;
_group_check_req.config.ballot = _init_ballot;
_group_check_req.config.status = partition_status::PS_PRIMARY;
}
void mock_notify_catch_up_request()
{
_parent->set_child_gpid(_child_pid);
_catch_up_req.child_gpid = _child_pid;
_catch_up_req.parent_gpid = _parent_pid;
_catch_up_req.child_ballot = _init_ballot;
_catch_up_req.child_address = dsn::rpc_address("127.0.0.1", 1);
}
void mock_register_child_request()
{
partition_configuration &p_config = _register_req.parent_config;
p_config.pid = _parent_pid;
p_config.ballot = _init_ballot;
p_config.last_committed_decree = _decree;
partition_configuration &c_config = _register_req.child_config;
c_config.pid = _child_pid;
c_config.ballot = _init_ballot + 1;
c_config.last_committed_decree = 0;
_register_req.app = _app_info;
_register_req.primary_address = dsn::rpc_address("127.0.0.1", 10086);
}
void generate_child(partition_status::type status)
{
_child = _stub->generate_replica(_app_info, _child_pid, status, _init_ballot);
_parent->set_child_gpid(_child_pid);
_parent->set_init_child_ballot(_init_ballot);
}
void mock_shared_log()
{
mock_mutation_log_shared_ptr shared_log_mock = new mock_mutation_log_shared("./");
_stub->set_log(shared_log_mock);
}
void mock_private_log(gpid pid, mock_replica_ptr rep, bool mock_log_file_flag)
{
mock_mutation_log_private_ptr private_log_mock = new mock_mutation_log_private(pid, rep);
if (mock_log_file_flag) {
mock_log_file_ptr log_file_mock = new mock_log_file("log.1.0.txt", 0);
log_file_mock->set_file_size(100);
private_log_mock->add_log_file(log_file_mock);
}
rep->_private_log = private_log_mock;
}
void mock_prepare_list(mock_replica_ptr rep, bool add_to_plog)
{
_mock_plist = new prepare_list(rep, 1, _max_count, [](mutation_ptr mu) {});
for (int i = 1; i < _max_count + 1; ++i) {
mutation_ptr mu = new mutation();
mu->data.header.decree = i;
mu->data.header.ballot = _init_ballot;
_mock_plist->put(mu);
if (add_to_plog) {
rep->_private_log->append(mu, LPC_WRITE_REPLICATION_LOG_PRIVATE, nullptr, nullptr);
mu->set_logged();
}
}
rep->_prepare_list = _mock_plist;
}
void mock_parent_states()
{
mock_shared_log();
mock_private_log(_parent_pid, _parent, true);
mock_prepare_list(_parent, true);
}
void mock_child_split_context(gpid parent_gpid, bool is_prepare_list_copied, bool is_caught_up)
{
_child->_split_states.parent_gpid = parent_gpid;
_child->_split_states.is_prepare_list_copied = is_prepare_list_copied;
_child->_split_states.is_caught_up = is_caught_up;
}
void mock_mutation_list(decree min_decree)
{
// mock mutation list
for (int d = 1; d < _max_count; ++d) {
mutation_ptr mu = _mock_plist->get_mutation_by_decree(d);
if (d > min_decree) {
_mutation_list.push_back(mu);
}
}
}
void mock_parent_primary_context(bool will_all_caught_up)
{
_parent->_primary_states.statuses[dsn::rpc_address("127.0.0.1", 1)] =
partition_status::PS_PRIMARY;
_parent->_primary_states.statuses[dsn::rpc_address("127.0.0.1", 2)] =
partition_status::PS_SECONDARY;
_parent->_primary_states.statuses[dsn::rpc_address("127.0.0.1", 3)] =
partition_status::PS_SECONDARY;
_parent->_primary_states.caught_up_children.insert(dsn::rpc_address("127.0.0.1", 2));
if (will_all_caught_up) {
_parent->_primary_states.caught_up_children.insert(dsn::rpc_address("127.0.0.1", 3));
}
_parent->_primary_states.sync_send_write_request = false;
}
bool get_sync_send_write_request() { return _parent->_primary_states.sync_send_write_request; }
void
mock_child_async_learn_states(mock_replica_ptr plist_rep, bool add_to_plog, decree min_decree)
{
mock_shared_log();
mock_private_log(_child_pid, _child, false);
mock_prepare_list(plist_rep, add_to_plog);
// mock_learn_state
_mock_learn_state.to_decree_included = _decree;
_mock_learn_state.files.push_back("fake_file_name");
// mock parent private log files
_private_log_files.push_back("log.1.0.txt");
// mock mutation list
mock_mutation_list(min_decree);
}
void cleanup_prepare_list(mock_replica_ptr rep) { rep->_prepare_list->reset(0); }
void cleanup_child_split_context()
{
_child->_split_states.cleanup(true);
_child->tracker()->wait_outstanding_tasks();
}
partition_split_context get_split_context() { return _child->_split_states; }
primary_context get_replica_primary_context(mock_replica_ptr rep)
{
return rep->_primary_states;
}
bool is_parent_not_in_split() { return (_parent->_child_gpid.get_app_id() == 0); }
int32_t get_partition_version(mock_replica_ptr rep) { return rep->_partition_version.load(); }
void test_on_add_child()
{
_parent->on_add_child(_group_check_req);
_parent->tracker()->wait_outstanding_tasks();
}
bool test_parent_check_states() { return _parent->parent_check_states(); }
void test_child_copy_prepare_list()
{
mock_child_async_learn_states(_parent, false, _decree);
std::shared_ptr<prepare_list> plist = std::make_shared<prepare_list>(_parent, *_mock_plist);
_child->child_copy_prepare_list(_mock_learn_state,
_mutation_list,
_private_log_files,
_total_file_size,
std::move(plist));
_child->tracker()->wait_outstanding_tasks();
}
void test_child_learn_states()
{
mock_child_async_learn_states(_child, true, _decree);
_child->child_learn_states(
_mock_learn_state, _mutation_list, _private_log_files, _total_file_size, _decree);
_child->tracker()->wait_outstanding_tasks();
}
void test_child_apply_private_logs()
{
mock_child_async_learn_states(_child, true, 0);
_child->child_apply_private_logs(
_private_log_files, _mutation_list, _total_file_size, _decree);
_child->tracker()->wait_outstanding_tasks();
}
void test_child_catch_up_states(decree local_decree, decree goal_decree, decree min_decree)
{
mock_child_async_learn_states(_child, true, 0);
_child->set_app_last_committed_decree(local_decree);
if (local_decree < goal_decree) {
// set prepare_list's start_decree = {min_decree}
_child->prepare_list_truncate(min_decree);
// set prepare_list's last_committed_decree = {goal_decree}
_child->prepare_list_commit_hard(goal_decree);
}
_child->child_catch_up_states();
_child->tracker()->wait_outstanding_tasks();
}
dsn::error_code test_parent_handle_child_catch_up()
{
notify_cacth_up_response resp;
_parent->parent_handle_child_catch_up(_catch_up_req, resp);
_parent->tracker()->wait_outstanding_tasks();
return resp.err;
}
void test_register_child_on_meta()
{
_parent->register_child_on_meta(_init_ballot);
_parent->tracker()->wait_outstanding_tasks();
}
void test_on_register_child_rely(partition_status::type status, dsn::error_code resp_err)
{
mock_register_child_request();
_parent->_config.status = status;
register_child_response resp;
resp.err = resp_err;
resp.app = _register_req.app;
resp.app.partition_count *= 2;
resp.parent_config = _register_req.parent_config;
resp.child_config = _register_req.child_config;
_parent->on_register_child_on_meta_reply(ERR_OK, _register_req, resp);
_parent->tracker()->wait_outstanding_tasks();
}
public:
std::unique_ptr<mock_replica_stub> _stub;
mock_replica_ptr _parent;
mock_replica_ptr _child;
dsn::app_info _app_info;
dsn::gpid _parent_pid = gpid(2, 1);
dsn::gpid _child_pid = gpid(2, 9);
uint32_t _old_partition_count = 8;
ballot _init_ballot = 3;
decree _decree = 5;
group_check_request _group_check_req;
notify_catch_up_request _catch_up_req;
register_child_request _register_req;
std::vector<std::string> _private_log_files;
std::vector<mutation_ptr> _mutation_list;
const uint32_t _max_count = 10;
prepare_list *_mock_plist;
const uint64_t _total_file_size = 100;
learn_state _mock_learn_state;
};
TEST_F(replica_split_test, add_child_wrong_ballot)
{
ballot wrong_ballot = 5;
_group_check_req.config.ballot = wrong_ballot;
test_on_add_child();
ASSERT_EQ(_stub->get_replica(_child_pid), nullptr);
}
TEST_F(replica_split_test, add_child_with_child_existed)
{
_parent->set_child_gpid(_child_pid);
test_on_add_child();
ASSERT_EQ(_stub->get_replica(_child_pid), nullptr);
}
TEST_F(replica_split_test, add_child_succeed)
{
fail::setup();
fail::cfg("replica_stub_create_child_replica_if_not_found", "return()");
fail::cfg("replica_child_init_replica", "return()");
test_on_add_child();
ASSERT_NE(_stub->get_replica(_child_pid), nullptr);
_stub->get_replica(_child_pid)->tracker()->wait_outstanding_tasks();
fail::teardown();
}
TEST_F(replica_split_test, parent_check_states_with_wrong_status)
{
generate_child(partition_status::PS_PARTITION_SPLIT);
_parent->set_partition_status(partition_status::PS_POTENTIAL_SECONDARY);
fail::setup();
fail::cfg("replica_stub_split_replica_exec", "return()");
bool flag = test_parent_check_states();
ASSERT_FALSE(flag);
fail::teardown();
}
TEST_F(replica_split_test, parent_check_states)
{
generate_child(partition_status::PS_PARTITION_SPLIT);
bool flag = test_parent_check_states();
ASSERT_TRUE(flag);
}
TEST_F(replica_split_test, copy_prepare_list_with_wrong_status)
{
generate_child(partition_status::PS_INACTIVE);
mock_child_split_context(_parent_pid, false, false);
fail::setup();
fail::cfg("replica_stub_split_replica_exec", "return()");
test_child_copy_prepare_list();
fail::teardown();
cleanup_prepare_list(_parent);
// TODO(heyuchen): child should be equal to error(after implement child_handle_split_error)
}
TEST_F(replica_split_test, copy_prepare_list_succeed)
{
generate_child(partition_status::PS_PARTITION_SPLIT);
mock_child_split_context(_parent_pid, false, false);
fail::setup();
fail::cfg("replica_stub_split_replica_exec", "return()");
fail::cfg("replica_child_learn_states", "return()");
test_child_copy_prepare_list();
fail::teardown();
partition_split_context split_context = get_split_context();
ASSERT_EQ(split_context.is_prepare_list_copied, true);
ASSERT_EQ(_child->get_plist()->count(), _max_count);
cleanup_prepare_list(_parent);
cleanup_prepare_list(_child);
cleanup_child_split_context();
}
TEST_F(replica_split_test, learn_states_succeed)
{
generate_child(partition_status::PS_PARTITION_SPLIT);
mock_child_split_context(_parent_pid, true, false);
fail::setup();
fail::cfg("replica_child_apply_private_logs", "return()");
fail::cfg("replica_child_catch_up_states", "return()");
test_child_learn_states();
fail::teardown();
cleanup_prepare_list(_child);
cleanup_child_split_context();
}
TEST_F(replica_split_test, learn_states_with_replay_private_log_error)
{
generate_child(partition_status::PS_PARTITION_SPLIT);
mock_child_split_context(_parent_pid, true, false);
fail::setup();
fail::cfg("replica_child_apply_private_logs", "return(error)");
fail::cfg("replica_child_catch_up_states", "return()");
test_child_learn_states();
fail::teardown();
cleanup_prepare_list(_child);
cleanup_child_split_context();
}
TEST_F(replica_split_test, child_apply_private_logs_succeed)
{
generate_child(partition_status::PS_PARTITION_SPLIT);
mock_child_split_context(_parent_pid, true, false);
fail::setup();
fail::cfg("mutation_log_replay_succeed", "return()");
fail::cfg("replication_app_base_apply_mutation", "return()");
test_child_apply_private_logs();
fail::teardown();
cleanup_prepare_list(_child);
cleanup_child_split_context();
}
TEST_F(replica_split_test, catch_up_succeed_with_all_states_learned)
{
generate_child(partition_status::PS_PARTITION_SPLIT);
mock_child_split_context(_parent_pid, true, false);
fail::setup();
fail::cfg("replica_child_notify_catch_up", "return()");
test_child_catch_up_states(_decree, _decree, _decree);
fail::teardown();
partition_split_context split_context = get_split_context();
ASSERT_EQ(split_context.is_caught_up, true);
cleanup_prepare_list(_child);
cleanup_child_split_context();
}
TEST_F(replica_split_test, catch_up_succeed_with_learn_in_memory_mutations)
{
generate_child(partition_status::PS_PARTITION_SPLIT);
mock_child_split_context(_parent_pid, true, false);
fail::setup();
fail::cfg("replica_child_notify_catch_up", "return()");
fail::cfg("replication_app_base_apply_mutation", "return()");
test_child_catch_up_states(_decree, _max_count - 1, 1);
fail::teardown();
partition_split_context split_context = get_split_context();
ASSERT_EQ(split_context.is_caught_up, true);
cleanup_prepare_list(_child);
cleanup_child_split_context();
}
TEST_F(replica_split_test, handle_catch_up_with_ballot_wrong)
{
mock_notify_catch_up_request();
_catch_up_req.child_ballot = 1;
fail::setup();
fail::cfg("replica_parent_check_sync_point_commit", "return()");
dsn::error_code err = test_parent_handle_child_catch_up();
fail::teardown();
ASSERT_EQ(err, ERR_INVALID_STATE);
}
TEST_F(replica_split_test, handle_catch_up_with_not_all_caught_up)
{
mock_parent_primary_context(false);
mock_notify_catch_up_request();
fail::setup();
fail::cfg("replica_parent_check_sync_point_commit", "return()");
dsn::error_code err = test_parent_handle_child_catch_up();
fail::teardown();
ASSERT_EQ(err, ERR_OK);
ASSERT_FALSE(get_sync_send_write_request());
}
TEST_F(replica_split_test, handle_catch_up_with_all_caught_up)
{
mock_parent_primary_context(true);
mock_notify_catch_up_request();
fail::setup();
fail::cfg("replica_parent_check_sync_point_commit", "return()");
dsn::error_code err = test_parent_handle_child_catch_up();
fail::teardown();
ASSERT_EQ(err, ERR_OK);
ASSERT_TRUE(get_sync_send_write_request());
}
TEST_F(replica_split_test, register_child_test)
{
fail::setup();
fail::cfg("replica_parent_send_register_request", "return()");
test_register_child_on_meta();
fail::teardown();
ASSERT_EQ(_parent->status(), partition_status::PS_INACTIVE);
ASSERT_EQ(get_partition_version(_parent), -1);
}
TEST_F(replica_split_test, register_child_reply_with_wrong_status)
{
generate_child(partition_status::PS_PARTITION_SPLIT);
mock_child_split_context(_parent_pid, true, true);
test_on_register_child_rely(partition_status::PS_PRIMARY, ERR_OK);
primary_context parent_primary_states = get_replica_primary_context(_parent);
ASSERT_EQ(parent_primary_states.register_child_task, nullptr);
}
TEST_F(replica_split_test, register_child_reply_with_child_registered)
{
generate_child(partition_status::PS_PARTITION_SPLIT);
mock_child_split_context(_parent_pid, true, true);
test_on_register_child_rely(partition_status::PS_INACTIVE, ERR_CHILD_REGISTERED);
primary_context parent_primary_states = get_replica_primary_context(_parent);
ASSERT_EQ(parent_primary_states.register_child_task, nullptr);
ASSERT_TRUE(is_parent_not_in_split());
}
TEST_F(replica_split_test, register_child_reply_succeed)
{
generate_child(partition_status::PS_PARTITION_SPLIT);
mock_child_split_context(_parent_pid, true, true);
fail::setup();
fail::cfg("replica_stub_split_replica_exec", "return()");
test_on_register_child_rely(partition_status::PS_INACTIVE, ERR_OK);
fail::teardown();
ASSERT_TRUE(is_parent_not_in_split());
}
} // namespace replication
} // namespace dsn
|
dnl Alpha ev67 mpn_gcd_11 -- Nx1 greatest common divisor.
dnl Copyright 2003, 2004 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C ev67: 3.4 cycles/bitpair for 1x1 part
C mp_limb_t mpn_gcd_1 (mp_srcptr xp, mp_size_t xsize, mp_limb_t y);
C
C In the 1x1 part, the algorithm is to change x,y to abs(x-y),min(x,y) and
C strip trailing zeros from abs(x-y) to maintain x and y both odd.
C
C The trailing zeros are calculated from just x-y, since in twos-complement
C there's the same number of trailing zeros on d or -d. This means the cttz
C runs in parallel with abs(x-y).
C
C The loop takes 5 cycles, and at 0.68 iterations per bit for two N-bit
C operands with this algorithm gives the measured 3.4 c/l.
C
C The slottings shown are for SVR4 style systems, Unicos differs in the
C initial gp setup and the LEA.
ASM_START()
PROLOGUE(mpn_gcd_11)
mov r16, r0
mov r17, r1
ALIGN(16)
L(top): subq r0, r1, r7 C l0 d = x - y
cmpult r0, r1, r16 C u0 test x >= y
subq r1, r0, r4 C l0 new_x = y - x
cttz r7, r8 C U0 d twos
cmoveq r16, r7, r4 C l0 new_x = d if x>=y
cmovne r16, r0, r1 C u0 y = x if x<y
unop C l \ force cmoveq into l0
unop C u /
C C cmoveq2 L0, cmovne2 U0
srl r4, r8, r0 C U0 x = new_x >> twos
bne r7, L(top) C U1 stop when d==0
L(end): mov r1, r0 C U0 return y << common_twos
ret r31, (r26), 1 C L0
EPILOGUE()
ASM_END()
|
<%
from pwnlib.shellcraft.thumb.linux import syscall
%>
<%page args="pid"/>
<%docstring>
Invokes the syscall sched_getscheduler. See 'man 2 sched_getscheduler' for more information.
Arguments:
pid(pid_t): pid
</%docstring>
${syscall('SYS_sched_getscheduler', pid)}
|
input: INP
STA [x]
STA [z]
INP
STA [y]
LDB #1
SUB
STA [y]
loop: LDA [x]
LDB [z]
ADD
STA [x]
LDA [y]
LDB #1
SUB
STA [y]
JSP [loop]
output: LDA [x]
OUT
HLT
== Vars ==
x: NOP
y: NOP
z: NOP
|
; A131507: 2n+1 appears n+1 times.
; 1,3,3,5,5,5,7,7,7,7,9,9,9,9,9,11,11,11,11,11,11,13,13,13,13,13,13,13,15,15,15,15,15,15,15,15,17,17,17,17,17,17,17,17,17,19,19,19,19,19,19,19,19,19,19,21,21,21,21,21,21,21,21,21,21,21,23,23,23,23,23,23,23,23,23,23,23,23,25,25,25,25,25,25,25,25,25,25,25,25,25,27,27,27,27,27,27,27,27,27,27,27,27,27,27,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43
mul $0,2
mov $1,1
lpb $0,1
add $1,2
sub $0,$1
lpe
|
// Original test: ./lavallee/hw4/problem6/bnez_4.asm
// Author: lavallee
// Test source code follows
//// This program tests a regular branch case
lbi r5, 5 // set r5 to non zero number
bnez r5, 76 // non-corner case branch
halt
|
; A339265: Expansion of Product_{n >= 1} (1 - x^(2*n))*(1 - x^(2*n-1))*(1 - x^(2*n+1)).
; 1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1
seq $0,196 ; Integer part of square root of n. Or, number of positive squares <= n. Or, n appears 2n+1 times.
mov $1,-1
pow $1,$0
mov $0,$1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r15
push %r8
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x1a860, %rsi
lea addresses_WT_ht+0x123e0, %rdi
clflush (%rsi)
nop
add $36377, %r8
mov $112, %rcx
rep movsw
nop
nop
nop
nop
nop
xor $51581, %rsi
lea addresses_WC_ht+0x3ee0, %r15
sub %r11, %r11
movl $0x61626364, (%r15)
nop
nop
nop
nop
nop
cmp %rdi, %rdi
lea addresses_D_ht+0x19010, %rsi
lea addresses_D_ht+0x3dd0, %rdi
nop
nop
nop
add %r15, %r15
mov $127, %rcx
rep movsb
nop
nop
nop
nop
and %r15, %r15
lea addresses_WT_ht+0x1b6e0, %rcx
nop
nop
inc %rdi
vmovups (%rcx), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %r8
cmp $10210, %r8
lea addresses_A_ht+0x10148, %rcx
nop
nop
cmp %rsi, %rsi
mov $0x6162636465666768, %r11
movq %r11, %xmm4
movups %xmm4, (%rcx)
nop
nop
nop
add $17391, %r8
lea addresses_A_ht+0x11e60, %rsi
nop
nop
nop
inc %r9
mov (%rsi), %r8w
nop
nop
nop
nop
nop
sub %r15, %r15
lea addresses_UC_ht+0x14ce0, %rsi
lea addresses_UC_ht+0x10560, %rdi
nop
nop
nop
nop
and $2343, %rdx
mov $28, %rcx
rep movsq
nop
nop
nop
nop
nop
xor $6634, %r15
lea addresses_D_ht+0x3bd4, %rdi
nop
nop
xor %rsi, %rsi
vmovups (%rdi), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $1, %xmm0, %r11
nop
nop
cmp $7292, %r11
lea addresses_WT_ht+0x15f78, %rsi
lea addresses_normal_ht+0x1e054, %rdi
nop
nop
nop
sub $36709, %rdx
mov $114, %rcx
rep movsq
nop
sub $61488, %r11
lea addresses_WC_ht+0xb690, %r9
dec %r11
movw $0x6162, (%r9)
nop
add $25214, %r9
lea addresses_UC_ht+0x160e0, %rdx
nop
nop
xor %rcx, %rcx
movups (%rdx), %xmm0
vpextrq $1, %xmm0, %r9
nop
cmp %r15, %r15
lea addresses_WT_ht+0x1a8ee, %rsi
nop
nop
nop
nop
nop
sub %r9, %r9
movb (%rsi), %r8b
nop
nop
sub $33959, %rdx
lea addresses_A_ht+0x1c860, %rsi
lea addresses_normal_ht+0xdfe0, %rdi
nop
nop
cmp %r11, %r11
mov $94, %rcx
rep movsw
sub $29361, %rdi
lea addresses_UC_ht+0x12bb, %rsi
lea addresses_D_ht+0x479c, %rdi
nop
nop
nop
nop
nop
cmp %r11, %r11
mov $41, %rcx
rep movsw
nop
nop
nop
nop
nop
add %r11, %r11
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r8
pop %r15
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %rax
push %rbx
push %rcx
push %rdx
// Faulty Load
lea addresses_normal+0x132e0, %r10
nop
nop
nop
sub $44555, %rbx
mov (%r10), %rax
lea oracles, %r10
and $0xff, %rax
shlq $12, %rax
mov (%r10,%rax,1), %rax
pop %rdx
pop %rcx
pop %rbx
pop %rax
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 8, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 10}}
{'src': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 10}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 3}}
{'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 6}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': True, 'size': 2, 'NT': False, 'same': False, 'congruent': 4}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 7}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 1}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}}
{'src': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
#include <iostream>
#include <vector>
#include <fstream>
#include "sstream"
#include<algorithm>
enum class State {
kStart,
kEmpty,
kObstacle,
kClosed,
kPath,
kFinish
};
// directional deltas
const int delta[4][2]{{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
std::string CellString(State state){
switch(state){
case State::kObstacle: return "⛰ ";
case State::kPath: return "🚗 ";
case State::kStart: return "🚦 ";
case State::kFinish: return "🏁 ";
default: return "0 ";
}
}
std::vector<State> ParseLine(std::string line){
std::vector<State> myVector;
std::istringstream myStream(line);
int n;
char c;
while (myStream >> n >> c && c == ',') {
if (n == 0) {
myVector.push_back(State::kEmpty);
} else {
myVector.push_back(State::kObstacle);
}
}
return myVector;
}
void printBoard(std::vector<std::vector<State>> board) {
for(int i = 0; i < board.size();++i){
for(int j = 0; j < board[i].size();++j){
std::cout <<CellString(board[i][j]);
}
std::cout <<std::endl;
}
}
std::vector<std::vector<State>> ReadBoardFile(std::string path){
std::vector<std::vector<State>> board;
std::vector<State>inputVector;
std::ifstream myReadFile(path);
std::string line;
if(myReadFile.is_open()){
while(getline(myReadFile, line)){
std::cout << line<<std::endl;
// on each line call parse line to get a vector
inputVector = ParseLine(line);
// return a vector of vector
board.push_back(inputVector);
}
myReadFile.close();
} else std::cout << "Could not open the file"<<std::endl;
return board;
}
int Heuristic(int x1,int y1,int x2,int y2){
return abs(x2-x1) + abs(y2-y1);
}
void AddToOpen(int x,int y,int g,int h,std::vector<std::vector<int>> &openList,std::vector<std::vector<State>> &grid){
std::vector<int> node ={x,y,g,h};
openList.push_back(node);
//Set the grid value for the x and y coordinates to the enum value kClosed. We have added kClosed to the set of enum values.
grid[x][y] = State::kClosed;
}
bool CheckValidCell(int x,int y,std::vector<std::vector<State>> &grid){
bool on_grid_x =(x>=0 && x<grid.size());
bool on_grid_y =(y>=0 && y<grid[0].size());
if(on_grid_x && on_grid_y){
return grid[x][y] == State::kEmpty;
}
return false;
}
bool Compare(const std::vector<int> first,const std::vector<int> second){
int f1=first[2]+first[3];
int f2=second[2]+second[3];
return f1>f2;
}
void CellSort(std::vector<std::vector<int>> *myVector){
std::sort(myVector->begin(), myVector->end(),Compare);
}
void ExpandNeighbors(std::vector<int> currentNode, int goal[2],
std::vector<std::vector<int>>& openList,
std::vector<std::vector<State>>& grid){
int x = currentNode[0];
int y = currentNode[1];
int g = currentNode[2];
for(int i=0;i<4;++i){
int x2 = x + delta[i][0];
int y2 = y + delta[i][1];
if (CheckValidCell(x2,y2,grid)){
int g2 = g + 1;
int h2 = Heuristic(x2,y2,goal[0],goal[1]);
AddToOpen(x2,y2,g2,h2,openList,grid);
}
}
}
std::vector<std::vector<State>> Search(std::vector<std::vector<State>>grid,int init[2],int goal[2]){
std::vector<std::vector<int>> open {};
//initialize the starting node
int x = init[0];
int y = init[1];
int g = 0;
int h = Heuristic(x,y,goal[0],goal[1]);
AddToOpen(x,y,g,h,open,grid);
while(open.size() > 0){
// sort the open list and get current node
CellSort(&open);
auto currentNode = open.back();
open.pop_back();
x = currentNode[0];
y = currentNode[1];
grid[x][y] = State::kPath;
// check if i reached the goal
if(x==goal[0] && y==goal[1]){
grid[ init[0] ][ init[1] ] = State::kStart;
grid[ goal[0] ][ goal[1] ] = State::kFinish;
return grid;
}
// else go to neighbors
ExpandNeighbors(currentNode,goal,open,grid);
}
std::cout << "No path found." << std::endl;
return std::vector<std::vector<State>> {};
}
int main() {
auto board = ReadBoardFile("/home/charity/CLionProjects/Grids/resources/grids.txt");
std::cout << "From grids file"<<std::endl;
printBoard(board);
int init[2] = {0, 0};
int goal[2] = {4, 5};
std::vector<std::vector<State>>solution = Search(board, init, goal);
printBoard(solution);
return 0;
}
|
/**
* Demonstrates the basics of a queue.
* (Implemented using a singly linked list)
*/
#include<iostream>
#include<stdexcept>
using namespace std;
/**
* Node object to represent each place in the queue.
* Contains one int value of data.
* Contains a pointer to the next node in the queue.
*/
struct Node {
int data; //The value stored in the node
Node *next; //Pointer to the next node in the list
};
/**
* Queue
*/
class Queue {
private:
int count; //Keeps track of the number of nodes
Node *front; //Pointer to the front of the queue
Node *back; //Pointer to the back of the queue
public:
//Constructor.
Queue() {
count = 0;
front = NULL;
back = NULL;
}
//Destructor.
~Queue() {
clear();
}
//push method. Adds data to the back of the queue.
//Complexity = O(1)
void push(int newData) {
Node *temp = new Node; //Create new node
temp->data = newData; //Set its data
temp->next = NULL; //Its next pointer will point to NULL (since it will be at the back)
if(back == NULL) {
front = temp; //Check if queue is empty (new node is in the front)
}
else {
back->next = temp; //Have the current back node point to the new node
}
back = temp; //Make the back pointer point to the new node
count++; //Increase the count
}
//pop method. Removes and retrieves the data at the front of the queue.
//Complexity = O(1)
int pop() {
if(front == NULL) {
__throw_underflow_error("Queue is empty"); //Checks if the queue is empty
}
int tempData = front->data; //Gets the data from the front of the queue
Node *tempNode = front->next; //Temporary pointer to the front of the queue
free(front);
front = tempNode;
count--;
return tempData; //Return the value from the node that was at the front
}
//peek method. Retrieves (but does not remove) the data at the front of the queue.
//Complexity = O(1)
int peek() {
if(front == NULL) {
__throw_underflow_error("Queue is empty"); //Checks if the queue is empty
}
return front->data;
}
//size method. Retrieves the length/number of nodes in the queue.
int size() {
return count;
}
//isEmpty method. Determines if the queue is empty.
bool isEmpty() {
return front == NULL ? true : false; //Returns true if front is NULL
}
//Resets the queue
//Complexity = O(n)
void clear() {
Node *current = front; //Starts at the front
Node* next;
while (current != NULL) {
next = current->next; //Gets the next node
free(current); //Frees the current node
current = next; //Makes the next node the current node
}
front = NULL; //Updates the front to NULL
back = NULL; //Updates the back to NULL
}
};
/**
* Main Function.
*/
int main() {
Queue q;
cout << "Pushing 1, 2, and 3" << endl;
q.push(1);
q.push(2);
q.push(3);
cout << "Queue length: " << q.size() << endl;
cout << "Peeking at top: " << q.peek() << endl;
cout << "Popping from top: " << q.pop() << endl;
cout << "Queue length: " << q.size() << endl;
cout << "Peeking at top: " << q.peek() << endl << endl;
cout << "Pushing 4, 5, and 6" << endl;
q.push(4);
q.push(5);
q.push(6);
cout << "Queue length: " << q.size() << endl;
cout << "Peeking at top: " << q.peek() << endl;
int value = q.pop();
cout << "Popped from top: " << value << endl;
cout << "Queue length: " << q.size() << endl;
cout << "Peeking at top: " << q.peek() << endl << endl;
cout << "Pushing 7 and 8" << endl;
q.push(7);
q.push(8);
cout << "Queue length: " << q.size() << endl;
cout << "\nEmptying..." << endl;
while(!q.isEmpty()) {
cout << "Popped " << q.pop() << endl;
cout << "Queue length: " << q.size() << endl;
}
cout << "Done" << endl << endl;
cout << "Trying to pop the next item (there aren't any)" << endl;
try {
q.pop();
}
catch(underflow_error e) {
cout << "Exception handled - " << e.what() << endl << endl;
}
} |
class Solution {
public:
int lengthOfLongestSubstring(string s) {
set<char> t;
int res = 0, left = 0, right = 0;
while (right < s.size()) {
if (t.find(s[right]) == t.end()) {
t.insert(s[right++]);
res = max(res, (int)t.size());
} else {
t.erase(s[left++]);
}
}
return res;
}
};
class Solution {
public:
int lengthOfLongestSubstring(string s) {
vector<int> m(256, -1);
int res = 0, left = -1;
for (int i = 0; i < s.size(); ++i) {
left = max(left, m[s[i]]);
m[s[i]] = i;
res = max(res, i - left);
}
return res;
}
}; |
//#include <cassert>
//#include <cstdio>
//#include <cmath>
//#include <iostream>
//#include <iomanip>
//#include <sstream>
//#include <vector>
//#include <map>
//#include <queue>
//#include <numeric>
//#include <algorithm>
//
//using namespace std;
//using lint = long long;
//constexpr int MOD = 1000000007, INF = 1111111111;
//constexpr lint LINF = 1LL << 60;
//
//template <class T>
//ostream &operator<<(ostream &os, const vector<T> &vec) {
// for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
// return os;
//}
//
//#ifdef _DEBUG
//template <class T>
//void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
//template <class Head, class... Tail>
//void dump(const char* str, Head &&h, Tail &&... t) {
// while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
// dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
//}
//#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
//#else
//#define DMP(...) ((void)0)
//#endif
//
//template <class T>
//const pair<T, T> operator+(const pair<T, T> &l,const pair<T, T> &r) {
// return { l.first + r.first,l.second + r.second };
//}
//
//template<class T>
//inline bool chmin(T &a, T b) { return a > b && (a = b, true); }
//
//int main() {
//
// cin.tie(nullptr);
// ios::sync_with_stdio(false);
//
// int H, W;
// cin >> H >> W;
//
// int blk = 0;
// vector<vector<char>> grid(H, vector<char>(W));
// for (int i = 0; i < H; i++) {
// for (int j = 0; j < W; j++) {
// cin >> grid[i][j];
// if(grid[i][j] == '#') blk++;
// }
// }
//
// auto ingrid = [&](pair<int,int> p) {
// return 0 <= p.first&&p.first < H && 0 <= p.second&&p.second < W;
// };
//
// vector<vector<int>> memo(H, vector<int>(W, INF));
// queue<pair<int,int>> que;
// memo.front().front() = 0;
// que.emplace(0, 0);
//
// while (!que.empty()) {
//
// auto now = que.front();
// que.pop();
//
// for (const auto &del : vector <pair<int, int>>{ {0, 1}, {1, 0}, {-1, 0}, {0, -1} }) {
// auto next = now + del;
// if (ingrid(next) && grid[next.first][next.second] != '#' &&
// chmin(memo[next.first][next.second], memo[now.first][now.second] + 1)) que.emplace(next);
// }
//
// }
//
// DMP(memo);
//
// if (memo.back().back() == INF) cout << -1 << "\n";
// else cout << H * W - blk - memo.back().back() - 1 << "\n";
//
// return 0;
//} |
SFX_Swap_1_Ch4:
duty 2
unknownsfx0x20 8, 225, 64, 7
endchannel
SFX_Swap_1_Ch5:
duty 2
unknownsfx0x20 2, 8, 0, 0
unknownsfx0x20 8, 177, 65, 7
endchannel
|
; A265676: a(n) is the total number of petals of the Flower of Life at the n-th iteration.
; 0,1,7,19,43,67,97,139,181,229,289,349,415,493,571,655,751,847,949,1063,1177,1297,1429,1561,1699,1849,1999,2155,2323,2491,2665,2851,3037,3229,3433,3637,3847,4069,4291,4519,4759,4999,5245,5503,5761,6025,6301,6577,6859,7153,7447,7747,8059,8371,8689,9019,9349,9685,10033,10381,10735,11101,11467,11839,12223,12607,12997,13399,13801,14209,14629,15049,15475,15913,16351,16795,17251,17707,18169,18643,19117,19597,20089,20581,21079,21589,22099,22615,23143,23671,24205,24751,25297,25849,26413,26977,27547
mov $3,$0
mul $0,2
mov $4,$0
add $4,1
mul $4,2
lpb $0
bin $0,2
mod $4,3
mul $4,2
sub $0,$4
mov $1,$0
mov $0,1
sub $1,1
lpe
mov $2,$3
mul $2,$3
add $1,$2
mov $0,$1
|
//Arithmetic Shift Right: preserves sign when dividing by a power of 2
sfmt: .string "%d / (2 to the power %d) = %d \n" //Define string format for printf
//Define register aliases
fp .req x29
lr .req x30
//Define m4 macros
define(x_reg, x19)
define(y_reg, x20)
define(z_reg, x21)
//Define main function
.global main //Make "main" visible to OS
.balign 4 //Instructions must be word aligned
main:
stp fp, lr, [sp, -16]! //Save FP and LR to stack, allocating 16 bytes, pre-increment sp
mov fp, sp //Update FP to current SP
//ASR Operation
mov x_reg, -10 //1111 ... 1111 1000 = -8
mov y_reg, 1 //0000 ... 1111 0001 = 2^1 = 2 --shift by one bit
asr z_reg, x_reg, y_reg //1111 ... 1111 1100 = -4
b print
print:
adrp x0, sfmt //Set 1st arg (high order bits)
add x0, x0, :lo12:sfmt //Set 1st arg (lower 12 bits)
mov x1, x_reg //Set 2nd arg
mov x2, y_reg //Set 3rd arg
mov x3, z_reg //Set 4th arg
b exit
exit:
bl printf //Call printf function
mov w0, 0 //Set up return value of 0 from main
end:
ldp fp, lr, [sp], 16 //Restore FP and LR from stack, post-increment SP
ret //Return to caller
|
enemySpritePatterns: ;; from here on, each offset of 32 pixels is a different enemy sprite
explosion_sprite:
; LARGE
db #00,#00,#00,#18,#1c,#0e,#02,#60,#70,#00,#06,#0c,#1c,#19,#01,#00
db #00,#c0,#c0,#8c,#1c,#38,#20,#0e,#06,#00,#20,#38,#9c,#8c,#80,#00
; MEDIUM
db #00,#00,#00,#00,#00,#0c,#06,#02,#30,#38,#00,#06,#0c,#0c,#00,#00
db #00,#00,#00,#c0,#80,#98,#30,#20,#00,#1c,#04,#20,#b0,#98,#80,#00
; SMALL
db #00,#00,#00,#00,#00,#00,#00,#04,#02,#00,#0c,#00,#02,#04,#00,#00
db #00,#00,#00,#00,#00,#00,#80,#90,#20,#00,#18,#00,#20,#90,#80,#00
; TINY
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#02,#00,#00,#02,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#80,#20,#00,#00,#20,#80,#00
rat_enemySprite:
; sprite 1
; LARGE
db #00,#00,#00,#0f,#10,#20,#41,#00,#19,#37,#0f,#05,#0f,#1e,#18,#00
db #00,#00,#fc,#02,#7a,#fc,#fc,#7e,#be,#d6,#26,#ac,#28,#40,#00,#00
; MEDIUM
db #00,#00,#00,#03,#0c,#10,#01,#02,#19,#0f,#05,#0f,#1c,#18,#00,#00
db #00,#00,#00,#c0,#38,#04,#f4,#78,#b8,#78,#78,#58,#50,#80,#00,#00
; SMALL:
db #00,#00,#00,#00,#00,#03,#0c,#00,#03,#00,#0f,#06,#0e,#19,#00,#00
db #00,#00,#00,#00,#00,#e0,#10,#08,#e8,#f0,#70,#f0,#a0,#00,#00,#00
; TINY:
db #00,#00,#00,#00,#00,#00,#00,#00,#03,#04,#01,#03,#07,#06,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#e0,#10,#f0,#e0,#e0,#80,#00,#00
; sprite 2
; LARGE:
db #00,#01,#06,#08,#10,#10,#21,#03,#02,#19,#37,#0f,#05,#0f,#1e,#18
db #00,#f8,#04,#02,#7a,#fc,#fc,#fe,#7e,#96,#e6,#2c,#a8,#40,#00,#00
; MEDIUM:
db #00,#00,#01,#06,#08,#10,#01,#03,#02,#19,#0f,#05,#0e,#1c,#18,#00
db #00,#00,#c0,#30,#08,#04,#f4,#f8,#78,#b8,#78,#58,#50,#80,#00,#00
; SMALL:
db #00,#00,#00,#00,#00,#00,#03,#04,#0b,#00,#0f,#06,#0e,#19,#00,#00
db #00,#00,#00,#00,#00,#c0,#30,#08,#e8,#f0,#70,#f0,#a0,#00,#00,#00
; TINY:
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#03,#05,#03,#07,#06,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#e0,#10,#f0,#e0,#e0,#80,#00,#00
blob_enemySprite:
; sprite1
; LARGE
db #00,#00,#00,#0b,#07,#07,#0e,#09,#0c,#0f,#1f,#1e,#3d,#61,#03,#00
db #00,#00,#00,#80,#e8,#f0,#70,#98,#38,#f0,#f8,#fc,#fc,#8e,#02,#00
; MEDIUM
db #00,#00,#00,#00,#00,#01,#0b,#06,#05,#06,#07,#0f,#1e,#31,#03,#00
db #00,#00,#00,#00,#00,#c0,#e0,#68,#b0,#70,#e0,#e0,#f0,#f8,#0c,#00
; SMALL
db #00,#00,#00,#00,#00,#00,#00,#05,#03,#02,#05,#06,#07,#0f,#19,#00
db #00,#00,#00,#00,#00,#00,#00,#c0,#e0,#e0,#60,#e0,#e0,#f0,#98,#00
; TINY
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#05,#03,#02,#03,#07,#0d,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#80,#c0,#c0,#c0,#e0,#b0,#00
; sprite4
; LARGE
db #00,#00,#00,#00,#0b,#07,#07,#0e,#09,#0c,#1f,#3e,#7d,#c1,#03,#00
db #00,#00,#00,#00,#c0,#e8,#f0,#70,#98,#30,#f8,#fc,#fe,#87,#00,#00
; MEDIUM
db #00,#00,#00,#00,#00,#00,#01,#0b,#06,#05,#06,#0f,#3e,#61,#03,#00
db #00,#00,#00,#00,#00,#00,#c0,#e0,#68,#b0,#70,#e0,#f0,#fc,#00,#00
; SMALL
db #00,#00,#00,#00,#00,#00,#00,#00,#05,#03,#02,#05,#06,#0f,#18,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#c0,#e0,#e0,#60,#e0,#f0,#d8,#00
; TINY
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#05,#03,#02,#07,#0d,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#80,#c0,#c0,#e0,#b0,#00
skeleton_forward_enemySprite:
; sprite1
; LARGE:
db #07,#0f,#09,#09,#0e,#07,#15,#2a,#4b,#81,#87,#9a,#20,#98,#0c,#38
db #c0,#e0,#20,#20,#e0,#c0,#50,#a8,#a4,#02,#c2,#b2,#08,#32,#60,#38
; MEDIUM:
db #00,#00,#07,#09,#09,#0e,#07,#15,#28,#4b,#41,#47,#0a,#50,#08,#38
db #00,#00,#c0,#20,#20,#e0,#c0,#50,#28,#a4,#04,#c4,#a0,#14,#20,#38
; SMALL:
db #00,#00,#00,#00,#00,#03,#05,#05,#07,#12,#20,#21,#27,#08,#04,#0c
db #00,#00,#00,#00,#00,#80,#40,#40,#c0,#90,#08,#08,#c8,#20,#40,#60
; TINY:
db #00,#00,#00,#00,#00,#00,#00,#00,#03,#05,#03,#0a,#10,#13,#02,#06
db #00,#00,#00,#00,#00,#00,#00,#00,#80,#40,#80,#a0,#10,#90,#80,#c0
; sprite2
; LARGE:
db #00,#07,#0f,#09,#09,#0e,#07,#15,#6a,#8b,#81,#9f,#22,#98,#0c,#38
db #00,#c0,#e0,#20,#20,#e0,#c0,#50,#ac,#a2,#02,#f2,#88,#32,#60,#38
; MEDIUM:
db #00,#00,#00,#07,#09,#09,#0e,#07,#15,#28,#4b,#41,#4f,#12,#48,#38
db #00,#00,#00,#c0,#20,#20,#e0,#c0,#50,#28,#a4,#04,#e4,#90,#24,#38
; SMALL:
db #00,#00,#00,#00,#00,#00,#03,#05,#05,#07,#12,#20,#21,#2f,#04,#0c
db #00,#00,#00,#00,#00,#00,#80,#40,#40,#c0,#90,#08,#08,#e8,#40,#60
; TINY:
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#03,#05,#0b,#12,#11,#02,#06
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#80,#40,#a0,#90,#10,#80,#c0
; sprite3
; LARGE:
db #00,#00,#07,#0f,#09,#09,#06,#77,#85,#8a,#81,#1f,#a2,#18,#0c,#38
db #00,#00,#c0,#e0,#20,#20,#c0,#dc,#42,#a2,#02,#f0,#8a,#30,#60,#38
; MEDIUM:
db #00,#00,#00,#00,#07,#09,#09,#0e,#37,#45,#48,#41,#0f,#52,#08,#38
db #00,#00,#00,#00,#c0,#20,#20,#e0,#d8,#44,#24,#04,#e0,#94,#20,#38
; SMALL:
db #00,#00,#00,#00,#00,#00,#03,#05,#05,#17,#22,#20,#21,#0f,#04,#0c
db #00,#00,#00,#00,#00,#00,#80,#40,#40,#d0,#88,#08,#08,#e0,#40,#60
; TINY:
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#03,#0d,#13,#12,#01,#02,#06
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#80,#60,#90,#90,#00,#80,#c0
knight_enemySprite:
; sprite1
; LARGE:
db #00,#0f,#10,#0f,#1a,#1a,#1a,#2f,#70,#6e,#66,#46,#0b,#1d,#0c,#3c
db #00,#e0,#10,#e0,#b0,#b0,#b0,#00,#fc,#fc,#fc,#fc,#78,#30,#40,#78
; MEDIUM:
db #00,#00,#00,#07,#08,#07,#0a,#0a,#17,#38,#36,#26,#0b,#0d,#04,#1c
db #00,#00,#00,#c0,#20,#c0,#a0,#a0,#00,#f8,#f8,#f8,#70,#20,#40,#70
; SMALL:
db #00,#00,#00,#00,#00,#00,#07,#0f,#0a,#0a,#07,#18,#17,#13,#02,#06
db #00,#00,#00,#00,#00,#00,#c0,#e0,#a0,#a0,#c0,#70,#70,#70,#a0,#c0
; TINY:
db #00,#00,#00,#00,#00,#00,#00,#00,#03,#07,#05,#07,#08,#0b,#02,#06
db #00,#00,#00,#00,#00,#00,#00,#00,#80,#c0,#40,#c0,#e0,#e0,#e0,#c0
; sprite2
; LARGE:
db #00,#00,#0f,#10,#0f,#1a,#1a,#1a,#2f,#70,#6e,#66,#4a,#1d,#0c,#3c
db #00,#00,#e0,#10,#e0,#b0,#b0,#b0,#00,#fc,#fc,#fc,#fc,#78,#30,#48
; MEDIUM:
db #00,#00,#00,#00,#07,#08,#07,#0a,#0a,#17,#38,#36,#2a,#0d,#04,#1c
db #00,#00,#00,#00,#c0,#20,#c0,#a0,#a0,#00,#f8,#f8,#f8,#70,#20,#50
; SMALL:
db #00,#00,#00,#00,#00,#00,#00,#07,#0f,#0a,#0a,#07,#18,#13,#12,#06
db #00,#00,#00,#00,#00,#00,#00,#c0,#e0,#a0,#a0,#c0,#70,#70,#70,#a0
; TINY:
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#03,#07,#05,#03,#08,#0a,#06
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#80,#c0,#40,#e0,#e0,#e0,#c0
; sprite3
; LARGE:
db #00,#00,#0f,#10,#0f,#1a,#1a,#1a,#2f,#70,#6e,#66,#4a,#1c,#0c,#3c
db #00,#00,#e0,#10,#e0,#b0,#b0,#b0,#e0,#00,#fc,#fc,#fc,#fc,#78,#30
; MEDIUM:
db #00,#00,#00,#00,#07,#08,#07,#0a,#0a,#17,#38,#36,#2a,#0c,#04,#1c
db #00,#00,#00,#00,#c0,#20,#c0,#a0,#a0,#00,#00,#f8,#f8,#f8,#70,#20
; SMALL:
db #00,#00,#00,#00,#00,#00,#00,#07,#0f,#0a,#0a,#07,#18,#13,#12,#06
db #00,#00,#00,#00,#00,#00,#00,#c0,#e0,#a0,#a0,#80,#e0,#e0,#e0,#40
; TTINY:
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#03,#07,#05,#03,#08,#0a,#06
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#80,#c0,#40,#e0,#e0,#e0,#c0
snake_enemySprite:
; sprite1
; LARGE:
db #00,#00,#00,#07,#0b,#17,#3f,#3d,#33,#03,#07,#07,#07,#07,#07,#03
db #00,#00,#00,#00,#80,#80,#82,#86,#8c,#98,#9c,#0c,#38,#f8,#f0,#80
; MEDIUM:
db #00,#00,#00,#00,#00,#03,#07,#0b,#1f,#19,#03,#03,#03,#03,#03,#01
db #00,#00,#00,#00,#00,#00,#80,#80,#88,#90,#90,#18,#18,#38,#f0,#c0
; SMALL:
db #00,#00,#00,#00,#00,#00,#00,#03,#05,#0f,#0d,#01,#03,#03,#03,#01
db #00,#00,#00,#00,#00,#00,#00,#00,#80,#80,#90,#a0,#20,#20,#e0,#c0
; TINY:
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#03,#05,#07,#01,#01,#01,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#20,#20,#e0,#c0
; sprite2
; LARGE:
db #00,#00,#00,#00,#0e,#17,#2f,#7d,#7b,#63,#03,#07,#07,#07,#07,#03
db #00,#00,#00,#00,#00,#00,#90,#98,#8c,#8c,#9c,#18,#38,#f8,#f0,#80
; MEDIUM:
db #00,#00,#00,#00,#00,#00,#06,#0f,#17,#3f,#33,#03,#03,#03,#03,#01
db #00,#00,#00,#00,#00,#00,#00,#00,#10,#08,#08,#18,#18,#38,#f0,#c0
; SMALL:
db #00,#00,#00,#00,#00,#00,#00,#06,#0b,#1f,#1b,#03,#03,#03,#03,#01
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#40,#20,#20,#20,#e0,#c0
; TINY:
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#03,#05,#07,#01,#01,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#20,#20,#e0,#c0
medusa_enemySprite:
; TORSO 1:
; LARGE:
db #01, #06, #19, #27, #08, #13, #05, #09, #00, #00, #07, #0f, #1b, #11, #31, #21
db #e0, #18, #e6, #f9, #c4, #f2, #28, #24, #c0, #00, #38, #fc, #f6, #62, #f3, #f1
; MEDIUM
db #00, #00, #00, #01, #06, #0b, #04, #0b, #05, #00, #00, #07, #0f, #09, #11, #11
db #00, #00, #00, #e0, #18, #f4, #c8, #f4, #28, #c0, #00, #38, #fc, #e4, #e2, #e2
; SMALL
db #00, #00, #00, #00, #00, #00, #02, #01, #04, #01, #04, #00, #03, #05, #05, #09
db #00, #00, #00, #00, #00, #00, #20, #c0, #90, #c0, #90, #00, #e0, #d0, #d0, #c8
; TINY:
db #00, #00, #00, #00, #00, #00, #00, #00, #02, #00, #05, #01, #00, #03, #05, #09
db #00, #00, #00, #00, #00, #00, #00, #00, #40, #00, #a0, #80, #00, #c0, #a0, #90
; TAIL 1:
; LARGE:
db #00, #03, #03, #03, #03, #43, #61, #61, #71, #7b, #3f, #3f, #1f, #00, #0a, #00
db #00, #70, #78, #80, #b8, #bc, #9c, #80, #bc, #bc, #9c, #60, #7c, #b8, #c0, #00
; MEDIUM:
db #00, #03, #03, #03, #01, #21, #21, #33, #3f, #3f, #1f, #00, #05, #00, #00, #00
db #00, #60, #70, #80, #b8, #b8, #80, #b8, #b8, #80, #38, #50, #60, #00, #00, #00
; SMALL:
db #00, #01, #01, #09, #09, #0f, #0f, #04, #02, #00, #00, #00, #00, #00, #00, #00
db #00, #60, #00, #60, #00, #60, #00, #60, #c0, #00, #00, #00, #00, #00, #00, #00
; TINY:
db #00, #01, #05, #07, #07, #03, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00
db #00, #80, #80, #80, #80, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00
; TORSO 2:
; LARGE:
db #00, #01, #26, #19, #07, #18, #03, #0d, #01, #00, #07, #0f, #1b, #11, #19, #09
db #00, #e0, #19, #e6, #f8, #c6, #f0, #2c, #e0, #c0, #38, #fc, #f6, #62, #f6, #f4
; MEDIUM:
db #00, #00, #00, #00, #09, #06, #0b, #04, #03, #05, #00, #07, #0f, #09, #09, #05
db #00, #00, #00, #00, #e4, #18, #f4, #c8, #f0, #28, #c0, #38, #fc, #e4, #e4, #e8
; SMALL:
db #00, #00, #00, #00, #00, #00, #00, #02, #01, #04, #01, #04, #03, #05, #05, #05
db #00, #00, #00, #00, #00, #00, #00, #20, #c0, #90, #c0, #90, #60, #d0, #d0, #d0
; TINY:
db #00, #00, #00, #00, #00, #00, #00, #00, #00, #02, #00, #05, #01, #03, #05, #05
db #00, #00, #00, #00, #00, #00, #00, #00, #00, #40, #00, #a0, #80, #c0, #a0, #a0
; TAIL 2:
; LARGE:
db #00, #03, #03, #03, #01, #11, #31, #31, #71, #7b, #3f, #3f, #1f, #00, #0a, #00
db #00, #70, #78, #80, #bc, #de, #de, #c0, #de, #be, #9c, #60, #7c, #b8, #c0, #00
; MEDIUM:
db #00, #03, #03, #03, #01, #09, #19, #1b, #3f, #3f, #1f, #00, #05, #00, #00, #00
db #00, #60, #70, #80, #b8, #b8, #80, #b8, #b8, #80, #38, #50, #60, #00, #00, #00
; SMALL:
db #00, #01, #01, #05, #09, #0f, #0f, #04, #02, #00, #00, #00, #00, #00, #00, #00
db #00, #60, #00, #60, #00, #60, #00, #60, #c0, #00, #00, #00, #00, #00, #00, #00
; TINY:
db #00, #01, #05, #07, #07, #03, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00
db #00, #80, #80, #80, #80, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00, #00
ker_enemySprite:
; HAIR 1:
; LARGE:
db #00, #01, #13, #1b, #0f, #77, #3f, #1f, #11, #00, #06, #00, #01, #01, #00, #00
db #00, #20, #60, #6c, #78, #f6, #fc, #f8, #88, #00, #60, #00, #80, #80, #00, #00
; MEDIUM
db #00, #00, #00, #00, #01, #0d, #07, #3f, #1f, #1f, #11, #00, #06, #00, #01, #01
db #00, #00, #00, #00, #20, #68, #f0, #fc, #f8, #f8, #88, #00, #60, #00, #80, #80
; SMALL
db #04, #02, #1b, #0f, #07, #01, #00, #02, #00, #01, #00, #00, #00, #00, #00, #00
db #a0, #c0, #d8, #f0, #e0, #80, #00, #40, #00, #80, #00, #00, #00, #00, #00, #00
; TINY:
db #00, #00, #00, #00, #05, #03, #03, #01, #00, #00, #00, #00, #00, #00, #00, #00
db #00, #00, #00, #00, #a0, #c0, #c0, #80, #00, #00, #00, #00, #00, #00, #00, #00
; BODY 1:
; LARGE:
db #00, #0e, #71, #f7, #c2, #9c, #bd, #22, #03, #21, #06, #06, #02, #0c, #14, #00
db #00, #70, #8e, #ef, #43, #39, #bd, #44, #c0, #84, #60, #60, #40, #30, #28, #00
; MEDIUM:
db #00, #00, #00, #0e, #31, #77, #42, #5c, #11, #02, #11, #06, #02, #04, #0c, #00
db #00, #00, #00, #70, #8c, #ee, #42, #3a, #88, #40, #88, #60, #40, #20, #30, #00
; SMALL:
db #00, #00, #00, #00, #00, #00, #16, #39, #23, #04, #09, #10, #03, #02, #04, #00
db #00, #00, #00, #00, #00, #00, #68, #9c, #c4, #20, #90, #08, #c0, #40, #20, #00
; TINY:
db #00, #00, #00, #00, #00, #00, #00, #0c, #01, #0d, #08, #01, #01, #02, #02, #00
db #00, #00, #00, #00, #00, #00, #00, #30, #80, #b0, #10, #80, #80, #40, #40, #00
; HAIR 2:
; LARGE:
db #00, #01, #13, #1b, #0f, #77, #3f, #1f, #11, #00, #06, #00, #00, #00, #00, #00
db #00, #20, #60, #6c, #78, #f6, #fc, #f8, #88, #00, #60, #00, #00, #00, #00, #00
; MEDIUM:
db #00, #00, #00, #00, #01, #0d, #07, #3f, #1f, #1f, #11, #00, #06, #00, #00, #00
db #00, #00, #00, #00, #20, #68, #f0, #fc, #f8, #f8, #88, #00, #60, #00, #00, #00
; SMALL:
db #04, #02, #1b, #0f, #07, #01, #00, #02, #00, #00, #00, #00, #00, #00, #00, #00
db #a0, #c0, #d8, #f0, #e0, #80, #00, #40, #00, #00, #00, #00, #00, #00, #00, #00
; TINY:
db #00, #00, #00, #00, #05, #03, #03, #01, #00, #00, #00, #00, #00, #00, #00, #00
db #00, #00, #00, #00, #a0, #c0, #c0, #80, #00, #00, #00, #00, #00, #00, #00, #00
; BODY 2:
; LARGE:
db #00, #6e, #f1, #d7, #83, #8d, #1e, #33, #23, #01, #26, #06, #02, #0c, #14, #00
db #00, #76, #8f, #eb, #c1, #b1, #78, #cc, #c4, #80, #64, #60, #40, #30, #28, #00
; MEDIUM:
db #00, #00, #00, #2e, #71, #57, #43, #0d, #1a, #13, #01, #16, #02, #04, #0c, #00
db #00, #00, #00, #74, #8e, #ea, #c2, #b0, #58, #c8, #80, #68, #40, #20, #30, #00
; SMALL:
db #00, #00, #00, #00, #00, #00, #36, #39, #03, #0d, #12, #11, #03, #02, #04, #00
db #00, #00, #00, #00, #00, #00, #6c, #9c, #c0, #b0, #48, #88, #c0, #40, #20, #00
; TINY:
db #00, #00, #00, #00, #00, #00, #00, #0c, #09, #05, #08, #09, #01, #02, #02, #00
db #00, #00, #00, #00, #00, #00, #00, #30, #90, #a0, #10, #90, #80, #40, #40, #00
switchRightSprite:
; LARGE
db #00,#00,#00,#00,#00,#00,#00,#03,#04,#0b,#16,#2e,#2f,#2f,#3f,#00
db #00,#00,#00,#06,#0e,#1c,#38,#d0,#20,#d0,#68,#74,#f4,#f4,#fc,#00
; MEDIUM
db #00,#00,#00,#00,#00,#00,#00,#00,#03,#04,#0b,#16,#16,#17,#1f,#00
db #00,#00,#00,#00,#00,#0c,#1c,#38,#d0,#20,#d0,#68,#68,#e8,#f8,#00
; SMALL
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#03,#06,#0e,#0f,#0f,#00
db #00,#00,#00,#00,#00,#00,#00,#18,#30,#60,#c0,#60,#70,#f0,#f0,#00
; TINY
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#03,#06,#07,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#10,#20,#40,#c0,#60,#e0,#00
switchLeftSprite:
; LARGE
db #00,#00,#00,#60,#70,#38,#1c,#0b,#04,#0b,#16,#2e,#2f,#2f,#3f,#00
db #00,#00,#00,#00,#00,#00,#00,#c0,#20,#d0,#68,#74,#f4,#f4,#fc,#00
; MEDIUM
db #00,#00,#00,#00,#00,#30,#38,#1c,#0b,#04,#0b,#16,#16,#17,#1f,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#c0,#20,#d0,#68,#68,#e8,#f8,#00
; SMALL
db #00,#00,#00,#00,#00,#00,#00,#18,#0c,#06,#03,#06,#0e,#0f,#0f,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#c0,#60,#70,#f0,#f0,#00
; TINY
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#08,#04,#02,#03,#06,#07,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#c0,#60,#e0,#00
; Version of the switches that is pressed or not, rather than switching left/right:
;switchRightSprite:
; ; sprite1
; db #00,#00,#00,#07,#07,#00,#01,#01,#01,#0f,#10,#2f,#2f,#2f,#3f,#00
; db #00,#00,#00,#e0,#e0,#00,#80,#80,#80,#f0,#08,#f4,#f4,#f4,#fc,#00
; ; sprite2
; db #00,#00,#00,#00,#00,#07,#07,#00,#01,#01,#07,#08,#17,#17,#1f,#00
; db #00,#00,#00,#00,#00,#e0,#e0,#00,#80,#80,#e0,#10,#e8,#e8,#f8,#00
; ; sprite3
; db #00,#00,#00,#00,#00,#00,#00,#03,#00,#01,#01,#07,#08,#0b,#0f,#00
; db #00,#00,#00,#00,#00,#00,#00,#c0,#00,#80,#80,#e0,#10,#d0,#f0,#00
; ; sprite4
; db #00,#00,#00,#00,#00,#00,#00,#00,#00,#03,#01,#01,#03,#05,#07,#00
; db #00,#00,#00,#00,#00,#00,#00,#00,#00,#80,#00,#00,#80,#40,#c0,#00
;
;switchLeftSprite:
; ; sprite1
; db #00,#00,#00,#00,#00,#00,#07,#07,#01,#0f,#10,#2f,#2f,#2f,#3f,#00
; db #00,#00,#00,#00,#00,#00,#e0,#e0,#80,#f0,#08,#f4,#f4,#f4,#fc,#00
; ; sprite2
; db #00,#00,#00,#00,#00,#00,#00,#07,#07,#01,#07,#08,#17,#17,#1f,#00
; db #00,#00,#00,#00,#00,#00,#00,#e0,#e0,#80,#e0,#10,#e8,#e8,#f8,#00
; ; sprite3
; db #00,#00,#00,#00,#00,#00,#00,#00,#00,#03,#00,#07,#08,#0b,#0f,#00
; db #00,#00,#00,#00,#00,#00,#00,#00,#00,#c0,#00,#e0,#10,#d0,#f0,#00
; ; sprite4
; db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#03,#03,#05,#07,#00
; db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#80,#80,#40,#c0,#00
enemyBulletSprite:
; LARGE
db #00,#00,#00,#00,#00,#00,#00,#00,#01,#02,#03,#03,#01,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#80,#c0,#c0,#c0,#80,#00,#00,#00
; MEDIUM
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#01,#03,#03,#01,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#80,#c0,#c0,#80,#00,#00,#00
; SMALL
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#01,#01,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#80,#80,#00,#00,#00
; TINY
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#01,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00
; Unused enemy sprites:
;
;fireball_enemySprite:
; ; LARGE
; db #00,#00,#00,#02,#0f,#07,#1e,#0c,#1c,#0e,#1f,#0f,#05,#00,#00,#00
; db #00,#00,#00,#60,#e0,#f8,#70,#30,#38,#60,#f0,#e0,#a0,#00,#00,#00
; ; MEDIUM
; db #00,#00,#00,#00,#00,#02,#07,#0e,#0c,#04,#0e,#07,#02,#00,#00,#00
; db #00,#00,#00,#00,#00,#c0,#e0,#70,#20,#30,#60,#e0,#c0,#00,#00,#00
; ; SMALL
; db #00,#00,#00,#00,#00,#00,#01,#01,#07,#06,#03,#03,#01,#00,#00,#00
; db #00,#00,#00,#00,#00,#00,#40,#e0,#60,#30,#70,#e0,#40,#00,#00,#00
; ; TINY
; db #00,#00,#00,#00,#00,#00,#00,#00,#03,#02,#06,#03,#01,#00,#00,#00
; db #00,#00,#00,#00,#00,#00,#00,#80,#c0,#40,#60,#c0,#00,#00,#00,#00
;
;python_enemySprite:
; ; Sprite 1 (left)
; ; LARGE:
; db #00,#00,#01,#03,#0e,#19,#37,#6f,#5f,#d1,#c0,#c0,#80,#00,#00,#00
; db #00,#40,#82,#1a,#8f,#c7,#c1,#ea,#db,#b5,#69,#5d,#4e,#11,#1f,#04
; ; MEDIUM:
; db #00,#00,#00,#00,#03,#06,#0d,#1b,#17,#34,#30,#20,#20,#00,#00,#00
; db #00,#00,#20,#c2,#9a,#4f,#c3,#e0,#eb,#d5,#55,#35,#2a,#2e,#19,#07
; ; SMALL:
; db #00,#00,#00,#00,#00,#00,#00,#00,#01,#02,#02,#02,#00,#00,#00,#00
; db #00,#00,#00,#00,#00,#10,#60,#81,#67,#fa,#35,#0d,#0e,#0e,#07,#03
; ; TINY:
; db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00
; db #00,#00,#00,#00,#00,#00,#00,#08,#10,#3a,#79,#4d,#02,#06,#07,#03
; ; Sprite 1 (right)
; ; LARGE: (
; db #00,#00,#08,#0b,#1e,#fd,#f2,#4b,#fb,#f0,#50,#f0,#e8,#1e,#61,#de
; db #00,#00,#00,#00,#00,#80,#c0,#60,#a0,#b2,#32,#36,#0c,#3c,#f8,#70
; ; MEDIUM:
; db #00,#00,#00,#10,#16,#fc,#f3,#c5,#f6,#e2,#e0,#e0,#c0,#3f,#c7,#b9
; db #00,#00,#00,#00,#00,#00,#00,#80,#80,#c0,#c8,#18,#70,#f0,#e0,#80
; ; SMALL:
; db #00,#00,#00,#00,#00,#20,#18,#24,#fa,#d5,#e1,#e1,#c0,#c0,#3f,#ff
; db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#40,#c0,#80,#00
; ; TINY:
; db #00,#00,#00,#00,#00,#00,#00,#20,#10,#28,#dc,#c4,#80,#84,#78,#e0
; db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00
;
; ; Sprite 2: (left)
; ; LARGE:
; db #00,#00,#01,#0f,#18,#37,#6f,#df,#c1,#c0,#80,#00,#00,#00,#00,#00
; db #10,#60,#c0,#02,#da,#cf,#e7,#e9,#da,#b3,#69,#5d,#4d,#10,#1f,#04
; ; MEDIUM:
; db #00,#00,#00,#00,#03,#06,#0d,#1b,#10,#30,#20,#20,#00,#00,#00,#00
; db #00,#00,#38,#e0,#82,#5a,#ef,#f3,#e8,#5b,#15,#35,#29,#2e,#19,#07
; ; SMALL:
; db #00,#00,#00,#00,#00,#00,#00,#00,#01,#02,#00,#00,#00,#00,#00,#00
; db #00,#00,#00,#00,#00,#18,#60,#90,#79,#17,#12,#0d,#0d,#0e,#06,#03
; ; TINY:
; db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00
; db #00,#00,#00,#00,#00,#00,#00,#0c,#18,#38,#5a,#0d,#01,#06,#06,#03
; ; Sprite 2: (right)
; ; LARGE:
; db #10,#0c,#06,#08,#0b,#1e,#fc,#f3,#48,#f8,#f0,#50,#f0,#ee,#01,#de
; db #00,#00,#00,#00,#00,#80,#c0,#60,#60,#68,#24,#04,#0c,#3c,#f8,#70
; ; MEDIUM:
; db #00,#00,#70,#08,#10,#16,#fd,#f1,#c0,#f0,#e0,#e0,#e0,#df,#07,#b9
; db #00,#00,#00,#00,#00,#00,#00,#80,#80,#c0,#48,#18,#70,#f0,#e0,#80
; ; SMALL:
; db #00,#00,#00,#00,#00,#60,#18,#04,#22,#f9,#d0,#e0,#e0,#c0,#df,#3f
; db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#40,#c0,#80,#00
; ; TINY:
; db #00,#00,#00,#00,#00,#00,#00,#60,#30,#18,#24,#c0,#c0,#84,#b8,#60
; db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00
;
;skeleton_left_enemySprite:
; ; sprite1
; db #01,#01,#00,#03,#06,#0a,#31,#30,#08,#04,#22,#3b,#26,#44,#0f,#00
; db #fc,#fe,#e4,#64,#be,#4a,#20,#90,#4c,#36,#1a,#08,#00,#00,#80,#00
; ; sprite6
; db #01,#01,#00,#03,#06,#0a,#31,#38,#16,#09,#04,#0c,#18,#30,#7c,#00
; db #fc,#fe,#e4,#64,#be,#4a,#20,#90,#4c,#36,#9a,#c8,#c0,#f8,#00,#00
; ; sprite7
; db #00,#01,#01,#00,#03,#06,#0a,#32,#31,#0c,#02,#0c,#18,#31,#3d,#00
; db #00,#fc,#fe,#e4,#64,#be,#8a,#40,#30,#cc,#76,#1a,#c8,#80,#e0,#00
item_sprite_colors: ; sprite/4 indexes this table (only used for arrows, chests, potions, hearts and keys)
db 7,9 ;; ice arrows / arrows
db 10,7,5,10 ;; chests / potions / hearts / keys
knight_sprites:
; walk sprite1
db #0f,#1f,#1f,#1f,#1f,#1f,#07,#00,#1b,#3b,#37,#27,#00,#07,#06,#00
db #f0,#f8,#f8,#f8,#f8,#f8,#e0,#00,#d8,#dc,#ec,#04,#e0,#60,#40,#00
; walk sprite2
db #00,#0f,#1f,#1f,#1f,#1f,#1f,#04,#1b,#3b,#37,#20,#07,#06,#02,#00
db #00,#f0,#f8,#f8,#f8,#f8,#f8,#20,#d8,#dc,#ec,#e4,#00,#e0,#60,#00
; sword swing sprite
db #00,#0f,#1f,#1f,#1f,#1f,#1f,#04,#1b,#3b,#37,#27,#00,#07,#06,#00
db #00,#f0,#f8,#f8,#f8,#f8,#f0,#20,#d0,#e0,#e0,#00,#e0,#60,#40,#00
knight_sprites_outline:
; walk sprite1
db #0f,#10,#20,#23,#20,#20,#20,#18,#1f,#24,#44,#48,#58,#2f,#08,#09
db #f0,#08,#04,#c4,#04,#04,#04,#18,#f8,#24,#22,#12,#fa,#14,#90,#a0
; walk sprite2
db #00,#0f,#10,#20,#23,#20,#20,#20,#1b,#24,#44,#48,#5f,#28,#09,#05
db #00,#f0,#08,#04,#c4,#04,#04,#04,#d8,#24,#22,#12,#1a,#f4,#10,#90
; sword swing sprite
db #00,#0f,#10,#20,#23,#20,#20,#20,#1b,#24,#44,#48,#58,#2f,#08,#09
db #00,#f0,#08,#04,#c4,#04,#04,#08,#d8,#28,#10,#10,#f0,#10,#90,#a0
sword_sprite:
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00
db #00,#80,#c0,#c0,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00
goldsword_sprite:
db #00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00
db #80,#c0,#c0,#c0,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00,#00
|
; A200535: G.f. satisfies: A(x) = exp( Sum_{n>=1} [Sum_{k=0..2*n} C(2*n,k)^2 * x^k] / A(x)^n * x^n/n ).
; 1,1,4,5,9,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,256,260
mov $2,$0
trn $0,2
mov $1,1
lpb $2
mov $3,$0
mov $0,$1
add $1,1
lpb $3
mov $3,$1
add $3,2
lpe
add $0,$2
mov $1,$3
add $1,1
sub $2,1
lpe
|
/**********************************************************************
* $Id: DistanceOp.cpp 2758 2009-12-01 16:16:18Z mloskot $
*
* GEOS - Geometry Engine Open Source
* http://geos.refractions.net
*
* Copyright (C) 2006 Refractions Research Inc.
* Copyright (C) 2001-2002 Vivid Solutions Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: operation/distance/DistanceOp.java rev 1.21 (JTS-1.10)
*
**********************************************************************/
#include <geos/operation/distance/DistanceOp.h>
#include <geos/operation/distance/GeometryLocation.h>
#include <geos/operation/distance/ConnectedElementLocationFilter.h>
#include <geos/algorithm/PointLocator.h>
#include <geos/algorithm/CGAlgorithms.h>
#include <geos/geom/Coordinate.h>
#include <geos/geom/CoordinateSequence.h>
#include <geos/geom/CoordinateArraySequence.h>
#include <geos/geom/LineString.h>
#include <geos/geom/Point.h>
#include <geos/geom/Polygon.h>
#include <geos/geom/Envelope.h>
#include <geos/geom/LineSegment.h>
#include <geos/geom/util/PolygonExtracter.h>
#include <geos/geom/util/LinearComponentExtracter.h>
#include <geos/geom/util/PointExtracter.h>
#include <vector>
#include <iostream>
#ifndef GEOS_DEBUG
#define GEOS_DEBUG 0
#endif
using namespace std;
using namespace geos::geom;
//using namespace geos::algorithm;
namespace geos {
namespace operation { // geos.operation
namespace distance { // geos.operation.distance
using namespace geom;
//using namespace geom::util;
/*public static (deprecated)*/
double
DistanceOp::distance(const Geometry *g0, const Geometry *g1)
{
DistanceOp distOp(g0,g1);
return distOp.distance();
}
/*public static*/
double
DistanceOp::distance(const Geometry& g0, const Geometry& g1)
{
DistanceOp distOp(g0,g1);
return distOp.distance();
}
/*public static deprecated*/
CoordinateSequence*
DistanceOp::closestPoints(const Geometry *g0, const Geometry *g1)
{
DistanceOp distOp(g0,g1);
return distOp.nearestPoints();
}
/*public static*/
CoordinateSequence*
DistanceOp::nearestPoints(const Geometry *g0, const Geometry *g1)
{
DistanceOp distOp(g0,g1);
return distOp.nearestPoints();
}
DistanceOp::DistanceOp(const Geometry *g0, const Geometry *g1):
geom(2),
terminateDistance(0.0),
minDistanceLocation(0),
minDistance(DoubleMax)
{
geom[0] = g0;
geom[1] = g1;
}
DistanceOp::DistanceOp(const Geometry& g0, const Geometry& g1):
geom(2),
terminateDistance(0.0),
minDistanceLocation(0),
minDistance(DoubleMax)
{
geom[0] = &g0;
geom[1] = &g1;
}
DistanceOp::DistanceOp(const Geometry& g0, const Geometry& g1, double tdist)
:
geom(2),
terminateDistance(tdist),
minDistanceLocation(0),
minDistance(DoubleMax)
{
geom[0] = &g0;
geom[1] = &g1;
}
DistanceOp::~DistanceOp()
{
size_t i;
for (i=0; i<newCoords.size(); i++) delete newCoords[i];
if ( minDistanceLocation )
{
for (i=0; i<minDistanceLocation->size(); i++)
{
delete (*minDistanceLocation)[i];
}
delete minDistanceLocation;
}
}
/**
* Report the distance between the closest points on the input geometries.
*
* @return the distance between the geometries
*/
double
DistanceOp::distance()
{
computeMinDistance();
return minDistance;
}
/* public */
CoordinateSequence*
DistanceOp::closestPoints()
{
return nearestPoints();
}
/* public */
CoordinateSequence*
DistanceOp::nearestPoints()
{
// lazily creates minDistanceLocation
computeMinDistance();
assert(0 != minDistanceLocation);
std::vector<GeometryLocation*>& locs = *minDistanceLocation;
// Empty input geometries result in this behaviour
if ( locs[0] == 0 || locs[1] == 0 )
{
// either both or none are set..
assert(locs[0] == 0 && locs[1] == 0);
return 0;
}
GeometryLocation* loc0 = locs[0];
GeometryLocation* loc1 = locs[1];
const Coordinate& c0 = loc0->getCoordinate();
const Coordinate& c1 = loc1->getCoordinate();
CoordinateSequence* nearestPts = new CoordinateArraySequence();
nearestPts->add(c0);
nearestPts->add(c1);
return nearestPts;
}
/*private, unused!*/
vector<GeometryLocation*>* DistanceOp::nearestLocations(){
computeMinDistance();
return minDistanceLocation;
}
void
DistanceOp::updateMinDistance(vector<GeometryLocation*>& locGeom, bool flip)
{
assert(minDistanceLocation);
// if not set then don't update
if (locGeom[0]==NULL)
{
#if GEOS_DEBUG
std::cerr << "updateMinDistance called with loc[0] == null and loc[1] == " << locGeom[1] << std::endl;
#endif
assert(locGeom[1] == NULL);
return;
}
delete (*minDistanceLocation)[0];
delete (*minDistanceLocation)[1];
if (flip) {
(*minDistanceLocation)[0]=locGeom[1];
(*minDistanceLocation)[1]=locGeom[0];
} else {
(*minDistanceLocation)[0]=locGeom[0];
(*minDistanceLocation)[1]=locGeom[1];
}
}
/*private*/
void
DistanceOp::computeMinDistance()
{
// only compute once!
if (minDistanceLocation) return;
#if GEOS_DEBUG
std::cerr << "---Start: " << geom[0]->toString() << " - " << geom[1]->toString() << std::endl;
#endif
minDistanceLocation = new vector<GeometryLocation*>(2);
computeContainmentDistance();
if (minDistance <= terminateDistance)
{
return;
}
computeFacetDistance();
#if GEOS_DEBUG
std::cerr << "---End " << std::endl;
#endif
}
/*private*/
void
DistanceOp::computeContainmentDistance()
{
using geom::util::PolygonExtracter;
Polygon::ConstVect polys1;
PolygonExtracter::getPolygons(*(geom[1]), polys1);
#if GEOS_DEBUG
std::cerr << "PolygonExtracter found " << polys1.size() << " polygons in geometry 2" << std::endl;
#endif
// NOTE:
// Expected to fill minDistanceLocation items
// if minDistance <= terminateDistance
vector<GeometryLocation*> *locPtPoly = new vector<GeometryLocation*>(2);
// test if either geometry has a vertex inside the other
if ( ! polys1.empty() )
{
vector<GeometryLocation*> *insideLocs0 =
ConnectedElementLocationFilter::getLocations(geom[0]);
computeInside(insideLocs0, polys1, locPtPoly);
if (minDistance <= terminateDistance) {
assert( (*locPtPoly)[0] );
assert( (*locPtPoly)[1] );
(*minDistanceLocation)[0] = (*locPtPoly)[0];
(*minDistanceLocation)[1] = (*locPtPoly)[1];
delete locPtPoly;
for (size_t i=0; i<insideLocs0->size(); i++)
{
GeometryLocation *l = (*insideLocs0)[i];
if ( l != (*minDistanceLocation)[0] &&
l != (*minDistanceLocation)[1] )
{
delete l;
}
}
delete insideLocs0;
return;
}
for (size_t i=0; i<insideLocs0->size(); i++)
delete (*insideLocs0)[i];
delete insideLocs0;
}
Polygon::ConstVect polys0;
PolygonExtracter::getPolygons(*(geom[0]), polys0);
#if GEOS_DEBUG
std::cerr << "PolygonExtracter found " << polys0.size() << " polygons in geometry 1" << std::endl;
#endif
if ( ! polys0.empty() )
{
vector<GeometryLocation*> *insideLocs1 = ConnectedElementLocationFilter::getLocations(geom[1]);
computeInside(insideLocs1, polys0, locPtPoly);
if (minDistance <= terminateDistance) {
// flip locations, since we are testing geom 1 VS geom 0
assert( (*locPtPoly)[0] );
assert( (*locPtPoly)[1] );
(*minDistanceLocation)[0] = (*locPtPoly)[1];
(*minDistanceLocation)[1] = (*locPtPoly)[0];
delete locPtPoly;
for (size_t i=0; i<insideLocs1->size(); i++)
{
GeometryLocation *l = (*insideLocs1)[i];
if ( l != (*minDistanceLocation)[0] &&
l != (*minDistanceLocation)[1] )
{
delete l;
}
}
delete insideLocs1;
return;
}
for (size_t i=0; i<insideLocs1->size(); i++)
delete (*insideLocs1)[i];
delete insideLocs1;
}
delete locPtPoly;
// If minDistance <= terminateDistance we must have
// set minDistanceLocations to some non-null item
assert( minDistance > terminateDistance ||
( (*minDistanceLocation)[0] && (*minDistanceLocation)[1] ) );
}
/*private*/
void
DistanceOp::computeInside(vector<GeometryLocation*> *locs,
const Polygon::ConstVect& polys,
vector<GeometryLocation*> *locPtPoly)
{
for (size_t i=0, ni=locs->size(); i<ni; ++i)
{
GeometryLocation *loc=(*locs)[i];
for (size_t j=0, nj=polys.size(); j<nj; ++j)
{
computeInside(loc, polys[j], locPtPoly);
if (minDistance<=terminateDistance) return;
}
}
}
/*private*/
void
DistanceOp::computeInside(GeometryLocation *ptLoc,
const Polygon *poly,
vector<GeometryLocation*> *locPtPoly)
{
const Coordinate &pt=ptLoc->getCoordinate();
// if pt is not in exterior, distance to geom is 0
if (Location::EXTERIOR!=ptLocator.locate(pt, static_cast<const Geometry *>(poly)))
{
minDistance = 0.0;
(*locPtPoly)[0] = ptLoc;
GeometryLocation *locPoly = new GeometryLocation(poly, pt);
(*locPtPoly)[1] = locPoly;
return;
}
}
/*private*/
void
DistanceOp::computeFacetDistance()
{
using geom::util::LinearComponentExtracter;
using geom::util::PointExtracter;
vector<GeometryLocation*> locGeom(2);
/**
* Geometries are not wholely inside, so compute distance from lines
* and points
* of one to lines and points of the other
*/
LineString::ConstVect lines0;
LineString::ConstVect lines1;
LinearComponentExtracter::getLines(*(geom[0]), lines0);
LinearComponentExtracter::getLines(*(geom[1]), lines1);
#if GEOS_DEBUG
std::cerr << "LinearComponentExtracter found "
<< lines0.size() << " lines in geometry 1 and "
<< lines1.size() << " lines in geometry 2 "
<< std::endl;
#endif
Point::ConstVect pts0;
Point::ConstVect pts1;
PointExtracter::getPoints(*(geom[0]), pts0);
PointExtracter::getPoints(*(geom[1]), pts1);
#if GEOS_DEBUG
std::cerr << "PointExtracter found "
<< pts0.size() << " points in geometry 1 and "
<< pts1.size() << " points in geometry 2 "
<< std::endl;
#endif
// exit whenever minDistance goes LE than terminateDistance
computeMinDistanceLines(lines0, lines1, locGeom);
updateMinDistance(locGeom, false);
if (minDistance <= terminateDistance) {
#if GEOS_DEBUG
std::cerr << "Early termination after line-line distance" << std::endl;
#endif
return;
};
locGeom[0]=NULL;
locGeom[1]=NULL;
computeMinDistanceLinesPoints(lines0, pts1, locGeom);
updateMinDistance(locGeom, false);
if (minDistance <= terminateDistance) {
#if GEOS_DEBUG
std::cerr << "Early termination after lines0-points1 distance" << std::endl;
#endif
return;
};
locGeom[0]=NULL;
locGeom[1]=NULL;
computeMinDistanceLinesPoints(lines1, pts0, locGeom);
updateMinDistance(locGeom, true);
if (minDistance <= terminateDistance){
#if GEOS_DEBUG
std::cerr << "Early termination after lines1-points0 distance" << std::endl;
#endif
return;
};
locGeom[0]=NULL;
locGeom[1]=NULL;
computeMinDistancePoints(pts0, pts1, locGeom);
updateMinDistance(locGeom, false);
#if GEOS_DEBUG
std::cerr << "termination after pts-pts distance" << std::endl;
#endif
}
/*private*/
void
DistanceOp::computeMinDistanceLines(
const LineString::ConstVect& lines0,
const LineString::ConstVect& lines1,
vector<GeometryLocation*>& locGeom)
{
for (size_t i=0, ni=lines0.size(); i<ni; ++i)
{
const LineString *line0=lines0[i];
for (size_t j=0, nj=lines1.size(); j<nj; ++j) {
const LineString *line1=lines1[j];
computeMinDistance(line0, line1, locGeom);
if (minDistance<=terminateDistance) return;
}
}
}
/*private*/
void
DistanceOp::computeMinDistancePoints(
const Point::ConstVect& points0,
const Point::ConstVect& points1,
vector<GeometryLocation*>& locGeom)
{
for (size_t i=0, ni=points0.size(); i<ni; ++i)
{
const Point *pt0 = points0[i];
for (size_t j=0, nj=points1.size(); j<nj; ++j)
{
const Point *pt1 = points1[j];
double dist = pt0->getCoordinate()->distance(*(pt1->getCoordinate()));
#if GEOS_DEBUG
std::cerr << "Distance "
<< pt0->toString() << " - "
<< pt1->toString() << ": "
<< dist << ", minDistance: " << minDistance
<< std::endl;
#endif
if (dist < minDistance)
{
minDistance = dist;
// this is wrong - need to determine closest points on both segments!!!
delete locGeom[0];
locGeom[0] = new GeometryLocation(pt0, 0, *(pt0->getCoordinate()));
delete locGeom[1];
locGeom[1] = new GeometryLocation(pt1, 0, *(pt1->getCoordinate()));
}
if (minDistance<=terminateDistance) return;
}
}
}
/*private*/
void
DistanceOp::computeMinDistanceLinesPoints(
const LineString::ConstVect& lines,
const Point::ConstVect& points,
vector<GeometryLocation*>& locGeom)
{
for (size_t i=0;i<lines.size();i++)
{
const LineString *line=lines[i];
for (size_t j=0;j<points.size();j++)
{
const Point *pt=points[j];
computeMinDistance(line,pt,locGeom);
if (minDistance<=terminateDistance) return;
}
}
}
/*private*/
void
DistanceOp::computeMinDistance(
const LineString *line0,
const LineString *line1,
vector<GeometryLocation*>& locGeom)
{
using geos::algorithm::CGAlgorithms;
const Envelope *env0=line0->getEnvelopeInternal();
const Envelope *env1=line1->getEnvelopeInternal();
if (env0->distance(env1)>minDistance) {
return;
}
const CoordinateSequence *coord0=line0->getCoordinatesRO();
const CoordinateSequence *coord1=line1->getCoordinatesRO();
size_t npts0=coord0->getSize();
size_t npts1=coord1->getSize();
// brute force approach!
for(size_t i=0; i<npts0-1; ++i)
{
for(size_t j=0; j<npts1-1; ++j)
{
double dist=CGAlgorithms::distanceLineLine(coord0->getAt(i),coord0->getAt(i+1),
coord1->getAt(j),coord1->getAt(j+1));
if (dist < minDistance) {
minDistance = dist;
LineSegment seg0(coord0->getAt(i), coord0->getAt(i + 1));
LineSegment seg1(coord1->getAt(j), coord1->getAt(j + 1));
CoordinateSequence* closestPt = seg0.closestPoints(seg1);
Coordinate *c1 = new Coordinate(closestPt->getAt(0));
Coordinate *c2 = new Coordinate(closestPt->getAt(1));
newCoords.push_back(c1);
newCoords.push_back(c2);
delete closestPt;
delete locGeom[0];
locGeom[0] = new GeometryLocation(line0, i, *c1);
delete locGeom[1];
locGeom[1] = new GeometryLocation(line1, j, *c2);
}
if (minDistance<=terminateDistance) return;
}
}
}
/*private*/
void
DistanceOp::computeMinDistance(const LineString *line,
const Point *pt,
vector<GeometryLocation*>& locGeom)
{
using geos::algorithm::CGAlgorithms;
const Envelope *env0=line->getEnvelopeInternal();
const Envelope *env1=pt->getEnvelopeInternal();
if (env0->distance(env1)>minDistance) {
return;
}
const CoordinateSequence *coord0=line->getCoordinatesRO();
Coordinate *coord=new Coordinate(*(pt->getCoordinate()));
newCoords.push_back(coord);
// brute force approach!
size_t npts0=coord0->getSize();
for(size_t i=0; i<npts0-1; ++i)
{
double dist=CGAlgorithms::distancePointLine(*coord,coord0->getAt(i),coord0->getAt(i+1));
if (dist < minDistance) {
minDistance = dist;
LineSegment seg(coord0->getAt(i), coord0->getAt(i + 1));
Coordinate segClosestPoint;
seg.closestPoint(*coord, segClosestPoint);
delete locGeom[0];
locGeom[0] = new GeometryLocation(line, i, segClosestPoint);
delete locGeom[1];
locGeom[1] = new GeometryLocation(pt, 0, *coord);
}
if (minDistance<=terminateDistance) return;
}
}
/* public static */
bool
DistanceOp::isWithinDistance(const geom::Geometry& g0,
const geom::Geometry& g1,
double distance)
{
DistanceOp distOp(g0, g1, distance);
return distOp.distance() <= distance;
}
} // namespace geos.operation.distance
} // namespace geos.operation
} // namespace geos
/**********************************************************************
* $Log$
* Revision 1.24 2006/06/12 11:29:24 strk
* unsigned int => size_t
*
* Revision 1.23 2006/03/24 09:52:41 strk
* USE_INLINE => GEOS_INLINE
*
* Revision 1.22 2006/03/23 12:12:01 strk
* Fixes to allow build with -DGEOS_INLINE
*
* Revision 1.21 2006/03/21 17:55:01 strk
* opDistance.h header split
*
* Revision 1.20 2006/03/03 10:46:21 strk
* Removed 'using namespace' from headers, added missing headers in .cpp files, removed useless includes in headers (bug#46)
**********************************************************************/
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "OpenWireRedeliveryPolicyTest.h"
#include <cms/Connection.h>
#include <cms/Session.h>
#include <cms/MessageProducer.h>
#include <cms/MessageConsumer.h>
#include <activemq/core/policies/DefaultRedeliveryPolicy.h>
#include <activemq/core/ActiveMQConnectionFactory.h>
#include <activemq/core/ActiveMQConnection.h>
#include <activemq/core/ActiveMQConsumer.h>
#include <activemq/commands/ActiveMQTextMessage.h>
#include <decaf/lang/Thread.h>
#include <decaf/lang/Pointer.h>
#include <decaf/lang/Long.h>
#include <decaf/util/concurrent/CountDownLatch.h>
#include <decaf/util/concurrent/atomic/AtomicInteger.h>
using namespace cms;
using namespace activemq;
using namespace activemq::commands;
using namespace activemq::core;
using namespace activemq::core::policies;
using namespace activemq::test;
using namespace activemq::test::openwire;
using namespace decaf;
using namespace decaf::lang;
using namespace decaf::util;
using namespace decaf::util::concurrent;
using namespace decaf::util::concurrent::atomic;
////////////////////////////////////////////////////////////////////////////////
OpenWireRedeliveryPolicyTest::OpenWireRedeliveryPolicyTest() {
}
////////////////////////////////////////////////////////////////////////////////
OpenWireRedeliveryPolicyTest::~OpenWireRedeliveryPolicyTest() {
}
////////////////////////////////////////////////////////////////////////////////
std::string OpenWireRedeliveryPolicyTest::getBrokerURL() const {
return activemq::util::IntegrationCommon::getInstance().getOpenwireURL();
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testGetNext() {
DefaultRedeliveryPolicy policy;
policy.setInitialRedeliveryDelay(0);
policy.setRedeliveryDelay(500);
policy.setBackOffMultiplier((short) 2);
policy.setUseExponentialBackOff(true);
long long delay = policy.getNextRedeliveryDelay(0);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect delay for cycle 1", 500LL, delay);
delay = policy.getNextRedeliveryDelay(delay);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect delay for cycle 2", 500L*2LL, delay);
delay = policy.getNextRedeliveryDelay(delay);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect delay for cycle 3", 500L*4LL, delay);
policy.setUseExponentialBackOff(false);
delay = policy.getNextRedeliveryDelay(delay);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect delay for cycle 4", 500LL, delay);
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testGetNextWithInitialDelay() {
DefaultRedeliveryPolicy policy;
policy.setInitialRedeliveryDelay(500);
long long delay = policy.getNextRedeliveryDelay(500);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect delay for cycle 1", 1000LL, delay);
delay = policy.getNextRedeliveryDelay(delay);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect delay for cycle 2", 1000LL, delay);
delay = policy.getNextRedeliveryDelay(delay);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect delay for cycle 3", 1000LL, delay);
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testExponentialRedeliveryPolicyDelaysDeliveryOnRollback() {
Pointer<ActiveMQConnectionFactory> connectionFactory(
new ActiveMQConnectionFactory(getBrokerURL()));
Pointer<Connection> connection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = connection.dynamicCast<ActiveMQConnection>();
// Receive a message with the JMS API
RedeliveryPolicy* policy = amqConnection->getRedeliveryPolicy();
policy->setInitialRedeliveryDelay(0);
policy->setRedeliveryDelay(500);
policy->setBackOffMultiplier((short) 2);
policy->setUseExponentialBackOff(true);
connection->start();
Pointer<Session> session(connection->createSession(Session::SESSION_TRANSACTED));
Pointer<Queue> destination(session->createTemporaryQueue());
Pointer<MessageProducer> producer(session->createProducer(destination.get()));
Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
// Send the messages
Pointer<TextMessage> message1(session->createTextMessage("1st"));
Pointer<TextMessage> message2(session->createTextMessage("2nd"));
producer->send(message1.get());
producer->send(message2.get());
session->commit();
Pointer<cms::Message> received(consumer->receive(1000));
Pointer<TextMessage> textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT(textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
// No delay on first rollback..
received.reset(consumer->receive(250));
CPPUNIT_ASSERT(received != NULL);
session->rollback();
// Show subsequent re-delivery delay is incrementing.
received.reset(consumer->receive(250));
CPPUNIT_ASSERT(received == NULL);
received.reset(consumer->receive(750));
CPPUNIT_ASSERT(received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
// Show re-delivery delay is incrementing exponentially
received.reset(consumer->receive(100));
CPPUNIT_ASSERT(received == NULL);
received.reset(consumer->receive(500));
CPPUNIT_ASSERT(received == NULL);
received.reset(consumer->receive(800));
CPPUNIT_ASSERT(received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testNornalRedeliveryPolicyDelaysDeliveryOnRollback() {
Pointer<ActiveMQConnectionFactory> connectionFactory(
new ActiveMQConnectionFactory(getBrokerURL()));
Pointer<Connection> connection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = connection.dynamicCast<ActiveMQConnection>();
// Receive a message with the JMS API
RedeliveryPolicy* policy = amqConnection->getRedeliveryPolicy();
policy->setInitialRedeliveryDelay(0);
policy->setRedeliveryDelay(500);
connection->start();
Pointer<Session> session(connection->createSession(Session::SESSION_TRANSACTED));
Pointer<Queue> destination(session->createTemporaryQueue());
Pointer<MessageProducer> producer(session->createProducer(destination.get()));
Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
// Send the messages
Pointer<TextMessage> message1(session->createTextMessage("1st"));
Pointer<TextMessage> message2(session->createTextMessage("2nd"));
producer->send(message1.get());
producer->send(message2.get());
session->commit();
Pointer<cms::Message> received(consumer->receive(1000));
Pointer<TextMessage> textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT(textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
// No delay on first rollback..
received.reset(consumer->receive(250));
CPPUNIT_ASSERT(received != NULL);
session->rollback();
// Show subsequent re-delivery delay is incrementing.
received.reset(consumer->receive(100));
CPPUNIT_ASSERT(received == NULL);
received.reset(consumer->receive(700));
CPPUNIT_ASSERT(received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
// The message gets redelivered after 500 ms every time since
// we are not using exponential backoff.
received.reset(consumer->receive(100));
CPPUNIT_ASSERT(received == NULL);
received.reset(consumer->receive(700));
CPPUNIT_ASSERT(received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->commit();
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testDLQHandling() {
Pointer<ActiveMQConnectionFactory> connectionFactory(
new ActiveMQConnectionFactory(getBrokerURL()));
Pointer<Connection> connection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = connection.dynamicCast<ActiveMQConnection>();
// Receive a message with the JMS API
RedeliveryPolicy* policy = amqConnection->getRedeliveryPolicy();
policy->setInitialRedeliveryDelay(100);
policy->setUseExponentialBackOff(false);
policy->setMaximumRedeliveries(2);
connection->start();
Pointer<Session> session(connection->createSession(Session::SESSION_TRANSACTED));
Pointer<Queue> destination(session->createTemporaryQueue());
Pointer<MessageProducer> producer(session->createProducer(destination.get()));
Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
Pointer<Queue> dlq(session->createQueue("ActiveMQ.DLQ"));
amqConnection->destroyDestination(dlq.get());
Pointer<MessageConsumer> dlqConsumer(session->createConsumer(dlq.get()));
// Send the messages
Pointer<TextMessage> message1(session->createTextMessage("1st"));
Pointer<TextMessage> message2(session->createTextMessage("2nd"));
producer->send(message1.get());
producer->send(message2.get());
session->commit();
Pointer<cms::Message> received(consumer->receive(1000));
Pointer<TextMessage> textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_MESSAGE("Failed to get first delivery", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
received.reset(consumer->receive(1000));
CPPUNIT_ASSERT_MESSAGE("Failed to get second delivery", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
received.reset(consumer->receive(2000));
CPPUNIT_ASSERT_MESSAGE("Failed to get third delivery", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
// The last rollback should cause the 1st message to get sent to the DLQ
received.reset(consumer->receive(1000));
CPPUNIT_ASSERT_MESSAGE("Failed to get first delivery of msg 2", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("2nd"), textMessage->getText());
session->commit();
// We should be able to get the message off the DLQ now.
received.reset(dlqConsumer->receive(1000));
CPPUNIT_ASSERT_MESSAGE("Failed to get DLQ'd message", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->commit();
if (textMessage->propertyExists("dlqDeliveryFailureCause")) {
std::string cause = textMessage->getStringProperty("dlqDeliveryFailureCause");
CPPUNIT_ASSERT_MESSAGE("cause exception has no policy ref",
cause.find("RedeliveryPolicy") != std::string::npos);
}
session->commit();
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testInfiniteMaximumNumberOfRedeliveries() {
Pointer<ActiveMQConnectionFactory> connectionFactory(
new ActiveMQConnectionFactory(getBrokerURL()));
Pointer<Connection> connection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = connection.dynamicCast<ActiveMQConnection>();
// Receive a message with the JMS API
RedeliveryPolicy* policy = amqConnection->getRedeliveryPolicy();
policy->setInitialRedeliveryDelay(100);
policy->setUseExponentialBackOff(false);
// let's set the maximum redeliveries to no maximum (ie. infinite)
policy->setMaximumRedeliveries(-1);
connection->start();
Pointer<Session> session(connection->createSession(Session::SESSION_TRANSACTED));
Pointer<Queue> destination(session->createTemporaryQueue());
Pointer<MessageProducer> producer(session->createProducer(destination.get()));
Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
// Send the messages
Pointer<TextMessage> message1(session->createTextMessage("1st"));
Pointer<TextMessage> message2(session->createTextMessage("2nd"));
producer->send(message1.get());
producer->send(message2.get());
session->commit();
Pointer<cms::Message> received(consumer->receive(1000));
Pointer<TextMessage> textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_MESSAGE("Failed to get first delivery", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
// we should be able to get the 1st message redelivered until a session.commit is called
received.reset(consumer->receive(1000));
CPPUNIT_ASSERT_MESSAGE("Failed to get second delivery", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
received.reset(consumer->receive(2000));
CPPUNIT_ASSERT_MESSAGE("Failed to get third delivery", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
received.reset(consumer->receive(2000));
CPPUNIT_ASSERT_MESSAGE("Failed to get fourth delivery", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
received.reset(consumer->receive(2000));
CPPUNIT_ASSERT_MESSAGE("Failed to get fifth delivery", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
received.reset(consumer->receive(2000));
CPPUNIT_ASSERT_MESSAGE("Failed to get sixth delivery", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->commit();
received.reset(consumer->receive(1000));
CPPUNIT_ASSERT_MESSAGE("Failed to get message two", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("2nd"), textMessage->getText());
session->commit();
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testMaximumRedeliveryDelay() {
Pointer<ActiveMQConnectionFactory> connectionFactory(
new ActiveMQConnectionFactory(getBrokerURL()));
Pointer<Connection> connection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = connection.dynamicCast<ActiveMQConnection>();
// Receive a message with the JMS API
RedeliveryPolicy* policy = amqConnection->getRedeliveryPolicy();
policy->setInitialRedeliveryDelay(10);
policy->setUseExponentialBackOff(true);
policy->setMaximumRedeliveries(-1);
policy->setRedeliveryDelay(50);
policy->setMaximumRedeliveryDelay(1000);
policy->setBackOffMultiplier((short) 2);
policy->setUseExponentialBackOff(true);
connection->start();
Pointer<Session> session(connection->createSession(Session::SESSION_TRANSACTED));
Pointer<Queue> destination(session->createTemporaryQueue());
Pointer<MessageProducer> producer(session->createProducer(destination.get()));
Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
// Send the messages
Pointer<TextMessage> message1(session->createTextMessage("1st"));
Pointer<TextMessage> message2(session->createTextMessage("2nd"));
producer->send(message1.get());
producer->send(message2.get());
session->commit();
Pointer<cms::Message> received;
for(int i = 0; i < 10; ++i) {
// we should be able to get the 1st message redelivered until a session.commit is called
received.reset(consumer->receive(2000));
Pointer<TextMessage> textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_MESSAGE("Failed to get message", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
}
received.reset(consumer->receive(2000));
Pointer<TextMessage> textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_MESSAGE("Failed to get message one last time", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->commit();
received.reset(consumer->receive(2000));
CPPUNIT_ASSERT_MESSAGE("Failed to get message two", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("2nd"), textMessage->getText());
session->commit();
long long result = policy->getNextRedeliveryDelay(Integer::MAX_VALUE);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Max delay should be 1 second.", 1000LL, result);
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testZeroMaximumNumberOfRedeliveries() {
Pointer<ActiveMQConnectionFactory> connectionFactory(
new ActiveMQConnectionFactory(getBrokerURL()));
Pointer<Connection> connection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = connection.dynamicCast<ActiveMQConnection>();
// Receive a message with the JMS API
RedeliveryPolicy* policy = amqConnection->getRedeliveryPolicy();
policy->setInitialRedeliveryDelay(100);
policy->setUseExponentialBackOff(false);
// let's set the maximum redeliveries to 0
policy->setMaximumRedeliveries(0);
connection->start();
Pointer<Session> session(connection->createSession(Session::SESSION_TRANSACTED));
Pointer<Queue> destination(session->createTemporaryQueue());
Pointer<MessageProducer> producer(session->createProducer(destination.get()));
Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
// Send the messages
Pointer<TextMessage> message1(session->createTextMessage("1st"));
Pointer<TextMessage> message2(session->createTextMessage("2nd"));
producer->send(message1.get());
producer->send(message2.get());
session->commit();
Pointer<cms::Message> received(consumer->receive(1000));
Pointer<TextMessage> textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_MESSAGE("Failed to get first delivery", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
// the 1st message should not be redelivered since maximumRedeliveries is set to 0
received.reset(consumer->receive(1000));
CPPUNIT_ASSERT_MESSAGE("Failed to get message two", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("2nd"), textMessage->getText());
session->commit();
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testRepeatedRedeliveryReceiveNoCommit() {
Pointer<ActiveMQConnectionFactory> connectionFactory(
new ActiveMQConnectionFactory(getBrokerURL()));
Pointer<Connection> connection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = connection.dynamicCast<ActiveMQConnection>();
connection->start();
Pointer<Session> dlqSession(connection->createSession(Session::AUTO_ACKNOWLEDGE));
Pointer<Queue> destination(dlqSession->createQueue("testRepeatedRedeliveryReceiveNoCommit"));
Pointer<Queue> dlq(dlqSession->createQueue("ActiveMQ.DLQ"));
amqConnection->destroyDestination(destination.get());
amqConnection->destroyDestination(dlq.get());
Pointer<MessageProducer> producer(dlqSession->createProducer(destination.get()));
Pointer<MessageConsumer> consumer(dlqSession->createConsumer(dlq.get()));
Pointer<TextMessage> message1(dlqSession->createTextMessage("1st"));
producer->send(message1.get());
const int MAX_REDELIVERIES = 4;
for (int i = 0; i <= MAX_REDELIVERIES + 1; i++) {
Pointer<Connection> loopConnection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = loopConnection.dynamicCast<ActiveMQConnection>();
// Receive a message with the JMS API
RedeliveryPolicy* policy = amqConnection->getRedeliveryPolicy();
policy->setInitialRedeliveryDelay(0);
policy->setUseExponentialBackOff(false);
policy->setMaximumRedeliveries(MAX_REDELIVERIES);
loopConnection->start();
Pointer<Session> session(loopConnection->createSession(Session::SESSION_TRANSACTED));
Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
Pointer<cms::Message> received(consumer->receive(1000));
if (i <= MAX_REDELIVERIES) {
Pointer<ActiveMQTextMessage> textMessage = received.dynamicCast<ActiveMQTextMessage>();
CPPUNIT_ASSERT_MESSAGE("Failed to get first delivery", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
CPPUNIT_ASSERT_EQUAL(i, textMessage->getRedeliveryCounter());
} else {
CPPUNIT_ASSERT_MESSAGE("null on exceeding redelivery count", received == NULL);
}
loopConnection->close();
}
// We should be able to get the message off the DLQ now.
Pointer<cms::Message> received(consumer->receive(1000));
CPPUNIT_ASSERT_MESSAGE("Failed to get from DLQ", received != NULL);
Pointer<TextMessage> textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
if (textMessage->propertyExists("dlqDeliveryFailureCause")) {
std::string cause = textMessage->getStringProperty("dlqDeliveryFailureCause");
CPPUNIT_ASSERT_MESSAGE("cause exception has no policy ref",
cause.find("RedeliveryPolicy") != std::string::npos);
} else {
CPPUNIT_FAIL("Message did not have a rollback cause");
}
}
////////////////////////////////////////////////////////////////////////////////
namespace {
class AsyncListener : public cms::MessageListener {
private:
AtomicInteger* receivedCount;
CountDownLatch* done;
public:
AsyncListener(AtomicInteger* receivedCount, CountDownLatch* done) {
this->receivedCount = receivedCount;
this->done = done;
}
virtual void onMessage(const cms::Message* message) {
try {
const ActiveMQTextMessage* textMessage = dynamic_cast<const ActiveMQTextMessage*>(message);
CPPUNIT_ASSERT_MESSAGE("Failed to get first delivery", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
CPPUNIT_ASSERT_EQUAL(receivedCount->get(), textMessage->getRedeliveryCounter());
receivedCount->incrementAndGet();
done->countDown();
} catch (Exception& ignored) {
ignored.printStackTrace();
}
}
};
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testRepeatedRedeliveryOnMessageNoCommit() {
Pointer<ActiveMQConnectionFactory> connectionFactory(
new ActiveMQConnectionFactory(getBrokerURL()));
Pointer<Connection> connection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = connection.dynamicCast<ActiveMQConnection>();
connection->start();
Pointer<Session> dlqSession(connection->createSession(Session::AUTO_ACKNOWLEDGE));
Pointer<Queue> destination(dlqSession->createQueue("testRepeatedRedeliveryOnMessageNoCommit"));
Pointer<Queue> dlq(dlqSession->createQueue("ActiveMQ.DLQ"));
amqConnection->destroyDestination(destination.get());
amqConnection->destroyDestination(dlq.get());
Pointer<MessageProducer> producer(dlqSession->createProducer(destination.get()));
Pointer<MessageConsumer> consumer(dlqSession->createConsumer(dlq.get()));
// Send the messages
Pointer<TextMessage> message1(dlqSession->createTextMessage("1st"));
producer->send(message1.get());
const int MAX_REDELIVERIES = 4;
AtomicInteger receivedCount(0);
for (int i = 0; i <= MAX_REDELIVERIES + 1; i++) {
Pointer<Connection> loopConnection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = loopConnection.dynamicCast<ActiveMQConnection>();
// Receive a message with the JMS API
RedeliveryPolicy* policy = amqConnection->getRedeliveryPolicy();
policy->setInitialRedeliveryDelay(0);
policy->setUseExponentialBackOff(false);
policy->setMaximumRedeliveries(MAX_REDELIVERIES);
loopConnection->start();
Pointer<Session> session(loopConnection->createSession(Session::SESSION_TRANSACTED));
Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
CountDownLatch done(1);
AsyncListener listener(&receivedCount, &done);
consumer->setMessageListener(&listener);
if (i <= MAX_REDELIVERIES) {
CPPUNIT_ASSERT_MESSAGE("listener didn't get a message", done.await(5, TimeUnit::SECONDS));
} else {
// final redlivery gets poisoned before dispatch
CPPUNIT_ASSERT_MESSAGE("listener got unexpected message", !done.await(2, TimeUnit::SECONDS));
}
loopConnection->close();
}
// We should be able to get the message off the DLQ now.
Pointer<cms::Message> received(consumer->receive(1000));
CPPUNIT_ASSERT_MESSAGE("Failed to get from DLQ", received != NULL);
Pointer<TextMessage> textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
if (textMessage->propertyExists("dlqDeliveryFailureCause")) {
std::string cause = textMessage->getStringProperty("dlqDeliveryFailureCause");
CPPUNIT_ASSERT_MESSAGE("cause exception has no policy ref",
cause.find("RedeliveryPolicy") != std::string::npos);
} else {
CPPUNIT_FAIL("Message did not have a rollback cause");
}
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testInitialRedeliveryDelayZero() {
Pointer<ActiveMQConnectionFactory> connectionFactory(
new ActiveMQConnectionFactory(getBrokerURL()));
Pointer<Connection> connection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = connection.dynamicCast<ActiveMQConnection>();
// Receive a message with the JMS API
RedeliveryPolicy* policy = amqConnection->getRedeliveryPolicy();
policy->setInitialRedeliveryDelay(0);
policy->setUseExponentialBackOff(false);
policy->setMaximumRedeliveries(1);
connection->start();
Pointer<Session> session(connection->createSession(Session::SESSION_TRANSACTED));
Pointer<Queue> destination(session->createTemporaryQueue());
Pointer<MessageProducer> producer(session->createProducer(destination.get()));
Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
// Send the messages
Pointer<TextMessage> message1(session->createTextMessage("1st"));
Pointer<TextMessage> message2(session->createTextMessage("2nd"));
producer->send(message1.get());
producer->send(message2.get());
session->commit();
Pointer<cms::Message> received(consumer->receive(100));
Pointer<TextMessage> textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_MESSAGE("Failed to get first delivery", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
// Both should be able for consumption.
received.reset(consumer->receive(100));
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_MESSAGE("Failed to get message one again", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
received.reset(consumer->receive(100));
CPPUNIT_ASSERT_MESSAGE("Failed to get message two", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("2nd"), textMessage->getText());
session->commit();
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testInitialRedeliveryDelayOne() {
Pointer<ActiveMQConnectionFactory> connectionFactory(
new ActiveMQConnectionFactory(getBrokerURL()));
Pointer<Connection> connection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = connection.dynamicCast<ActiveMQConnection>();
// Receive a message with the JMS API
RedeliveryPolicy* policy = amqConnection->getRedeliveryPolicy();
policy->setInitialRedeliveryDelay(1000);
policy->setUseExponentialBackOff(false);
policy->setMaximumRedeliveries(1);
connection->start();
Pointer<Session> session(connection->createSession(Session::SESSION_TRANSACTED));
Pointer<Queue> destination(session->createTemporaryQueue());
Pointer<MessageProducer> producer(session->createProducer(destination.get()));
Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
// Send the messages
Pointer<TextMessage> message1(session->createTextMessage("1st"));
Pointer<TextMessage> message2(session->createTextMessage("2nd"));
producer->send(message1.get());
producer->send(message2.get());
session->commit();
Pointer<cms::Message> received(consumer->receive(100));
Pointer<TextMessage> textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_MESSAGE("Failed to get first delivery", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
received.reset(consumer->receive(100));
CPPUNIT_ASSERT(received == NULL);
received.reset(consumer->receive(2000));
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_MESSAGE("Failed to get message one again", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
received.reset(consumer->receive(100));
CPPUNIT_ASSERT_MESSAGE("Failed to get message two", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("2nd"), textMessage->getText());
session->commit();
}
////////////////////////////////////////////////////////////////////////////////
void OpenWireRedeliveryPolicyTest::testRedeliveryDelayOne() {
Pointer<ActiveMQConnectionFactory> connectionFactory(
new ActiveMQConnectionFactory(getBrokerURL()));
Pointer<Connection> connection(connectionFactory->createConnection());
Pointer<ActiveMQConnection> amqConnection = connection.dynamicCast<ActiveMQConnection>();
// Receive a message with the JMS API
RedeliveryPolicy* policy = amqConnection->getRedeliveryPolicy();
policy->setInitialRedeliveryDelay(0);
policy->setRedeliveryDelay(1000);
policy->setUseExponentialBackOff(false);
policy->setMaximumRedeliveries(2);
connection->start();
Pointer<Session> session(connection->createSession(Session::SESSION_TRANSACTED));
Pointer<Queue> destination(session->createTemporaryQueue());
Pointer<MessageProducer> producer(session->createProducer(destination.get()));
Pointer<MessageConsumer> consumer(session->createConsumer(destination.get()));
// Send the messages
Pointer<TextMessage> message1(session->createTextMessage("1st"));
Pointer<TextMessage> message2(session->createTextMessage("2nd"));
producer->send(message1.get());
producer->send(message2.get());
session->commit();
Pointer<cms::Message> received(consumer->receive(100));
Pointer<TextMessage> textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_MESSAGE("Failed to get first delivery", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
received.reset(consumer->receive(100));
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_MESSAGE("first redelivery was not immediate.", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
session->rollback();
received.reset(consumer->receive(100));
CPPUNIT_ASSERT_MESSAGE("seconds redelivery should be delayed.", received == NULL);
received.reset(consumer->receive(2000));
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_MESSAGE("Failed to get message one again", textMessage != NULL);
CPPUNIT_ASSERT_EQUAL(std::string("1st"), textMessage->getText());
received.reset(consumer->receive(100));
CPPUNIT_ASSERT_MESSAGE("Failed to get message two", received != NULL);
textMessage = received.dynamicCast<TextMessage>();
CPPUNIT_ASSERT_EQUAL(std::string("2nd"), textMessage->getText());
session->commit();
}
|
; A311481: Coordination sequence Gal.6.219.2 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; Submitted by Christian Krause
; 1,4,8,12,17,21,27,31,36,40,44,48,52,56,60,65,69,75,79,84,88,92,96,100,104,108,113,117,123,127,132,136,140,144,148,152,156,161,165,171,175,180,184,188,192,196,200,204,209,213
sub $2,$0
seq $0,313788 ; Coordination sequence Gal.6.326.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
mul $0,2
add $0,$2
mov $1,2
add $1,$0
mul $1,2
div $1,3
sub $1,1
add $1,$2
add $1,$2
mov $0,$1
|
#include "CalibrationMotion.h"
#include <mc_filter/utils/clamp.h>
#include "../ForceSensorCalibration.h"
void CalibrationMotion::start(mc_control::fsm::Controller & ctl)
{
ctl.datastore().make_call("CalibrationMotion::Stop", [this]() { interrupted_ = true; });
auto & robot = ctl.robot();
auto robotConf = ctl.config()(robot.name());
if(!robotConf.has("motion"))
{
mc_rtc::log::error("[{}] Calibration controller expects a joints entry", name());
output("FAILURE");
}
auto conf = robotConf("motion");
conf("duration", duration_);
conf("percentLimits", percentLimits_);
mc_filter::utils::clampInPlace(percentLimits_, 0, 1);
auto postureTask = ctl.getPostureTask(robot.name());
savedStiffness_ = postureTask->stiffness();
postureTask->stiffness(conf("stiffness", 10));
constexpr double PI = mc_rtc::constants::PI;
for(const auto & jConfig : conf("joints"))
{
std::string name = jConfig("name");
if(!ctl.robot().hasJoint(name))
{
mc_rtc::log::error("[{}] No joint named \"{}\" in robot \"{}\"", this->name(), name, ctl.robot().name());
output("FAILURE");
}
auto percentLimits = percentLimits_;
jConfig("percentLimits", percentLimits);
mc_filter::utils::clampInPlace(percentLimits, 0, 1);
double period = jConfig("period");
auto jidx = robot.jointIndexByName(name);
auto start = robot.mbc().q[jidx][0];
auto actualLower = robot.ql()[jidx][0];
auto actualUpper = robot.qu()[jidx][0];
auto actualRange = actualUpper - actualLower;
// Reduced range
const auto range = percentLimits * actualRange;
const auto lower = actualLower + (actualRange - range) / 2;
const auto upper = actualUpper - (actualRange - range) / 2;
if(start < lower || start > upper)
{
mc_rtc::log::error("[{}] Starting joint configuration of joint {} [{}] is outside of the reduced limit range "
"[{}, {}] (percentLimits: {}, actual joint limits: [{}, {}]",
this->name(), name, start, lower, upper, actualLower, actualUpper);
output("FAILURE");
}
// compute the starting time such that the joint does not move initially
// that is such that f(start_dt) = start
// i.e start_dt = f^(-1)(start)
double start_dt = period * (acos(sqrt(start - lower) / sqrt(upper - lower))) / PI;
jointUpdates_.emplace_back(
/* f(t): periodic function that moves the joint between its limits */
[this, postureTask, lower, upper, start_dt, period, name]() {
auto t = start_dt + dt_;
auto q = lower + (upper - lower) * (1 + cos((2 * PI * t) / period)) / 2;
postureTask->target({{name, {q}}});
});
}
ctl.gui()->addElement(
{}, mc_rtc::gui::NumberSlider("Progress", [this]() { return dt_; }, [](double) {}, 0, duration_),
mc_rtc::gui::Button("Stop Motion", [this]() {
mc_rtc::log::warning("[{}] Motion was interrupted before it's planned duration ({:.2f}/{:.2f}s)", name(), dt_,
duration_);
interrupted_ = true;
}));
}
bool CalibrationMotion::run(mc_control::fsm::Controller & ctl_)
{
if(output() == "FAILURE")
{
return true;
}
// Update all joint positions
for(auto & updateJoint : jointUpdates_)
{
updateJoint();
}
if(dt_ > duration_)
{
output("OK");
return true;
}
else if(interrupted_)
{
output("INTERRUPTED");
return true;
}
dt_ += ctl_.timeStep;
return false;
}
void CalibrationMotion::teardown(mc_control::fsm::Controller & ctl_)
{
auto postureTask = ctl_.getPostureTask(ctl_.robot().name());
postureTask->stiffness(savedStiffness_);
ctl_.gui()->removeElement({}, "Progress");
ctl_.gui()->removeElement({}, "Stop Motion");
ctl_.datastore().remove("CalibrationMotion::Stop");
}
EXPORT_SINGLE_STATE("CalibrationMotion", CalibrationMotion)
|
;-------------------------------------------
;the content of this file is excluded, |
;when the user disables logging features |
;in hyperion command line. pls keep in mind |
;and dont rely on its existence. |
;-------------------------------------------
;--- Begin Macro Section ---
macro createStringBruteforcing location
{
mov [location+0],'B'
mov [location+1],'r'
mov [location+2],'u'
mov [location+3],'t'
mov [location+4],'e'
mov [location+5],'f'
mov [location+6],'o'
mov [location+7],'r'
mov [location+8],'c'
mov [location+9],'i'
mov [location+10],'n'
mov [location+11],'g'
mov [location+12],' '
mov [location+13],'K'
mov [location+14],'e'
mov [location+15],'y'
mov [location+16],0
lea rax,[location]
}
macro createStringSettingPermissions location
{
mov [location+0],'S'
mov [location+1],'e'
mov [location+2],'t'
mov [location+3],'t'
mov [location+4],'i'
mov [location+5],'n'
mov [location+6],'g'
mov [location+7],' '
mov [location+8],'S'
mov [location+9],'e'
mov [location+10],'c'
mov [location+11],'t'
mov [location+12],'i'
mov [location+13],'o'
mov [location+14],'n'
mov [location+15],' '
mov [location+16],'P'
mov [location+17],'e'
mov [location+18],'r'
mov [location+19],'m'
mov [location+20],'i'
mov [location+21],'s'
mov [location+22],'s'
mov [location+23],'i'
mov [location+24],'o'
mov [location+25],'n'
mov [location+26],'s'
mov [location+27],0
lea rax,[location]
}
macro createStringOrdinal location
{
mov [location+0],'O'
mov [location+1],'r'
mov [location+2],'d'
mov [location+3],'i'
mov [location+4],'n'
mov [location+5],'a'
mov [location+6],'l'
mov [location+7],':'
mov [location+8],' '
mov [location+9],0
lea rax,[location]
}
macro createStringName location
{
mov [location+0],'N'
mov [location+1],'a'
mov [location+2],'m'
mov [location+3],'e'
mov [location+4],':'
mov [location+5],' '
mov [location+6],0
lea rax,[location]
}
macro createStringProcessImportDirectory location
{
mov [location+0],'P'
mov [location+1],'r'
mov [location+2],'o'
mov [location+3],'c'
mov [location+4],'e'
mov [location+5],'s'
mov [location+6],'s'
mov [location+7],'i'
mov [location+8],'n'
mov [location+9],'g'
mov [location+10],' '
mov [location+11],'I'
mov [location+12],'m'
mov [location+13],'p'
mov [location+14],'o'
mov [location+15],'r'
mov [location+16],'t'
mov [location+17],' '
mov [location+18],'D'
mov [location+19],'i'
mov [location+20],'r'
mov [location+21],'e'
mov [location+22],'c'
mov [location+23],'t'
mov [location+24],'o'
mov [location+25],'r'
mov [location+26],'y'
mov [location+27],':'
mov [location+28],0
lea rax,[location]
}
macro createStringFoundImportTable location
{
mov [location+0],'I'
mov [location+1],'m'
mov [location+2],'p'
mov [location+3],'o'
mov [location+4],'r'
mov [location+5],'t'
mov [location+6],' '
mov [location+7],'T'
mov [location+8],'a'
mov [location+9],'b'
mov [location+10],'l'
mov [location+11],'e'
mov [location+12],':'
mov [location+13],0
lea rax,[location]
}
macro createStringLoadingFilesAPIs location
{
mov [location+0],'L'
mov [location+1],'o'
mov [location+2],'a'
mov [location+3],'d'
mov [location+4],'i'
mov [location+5],'n'
mov [location+6],'g'
mov [location+7],' '
mov [location+8],'A'
mov [location+9],'P'
mov [location+10],'I'
mov [location+11],'s'
mov [location+12],0
lea rax,[location]
}
macro createStringMappingFileInMemory location
{
mov [location+0],'M'
mov [location+1],'a'
mov [location+2],'p'
mov [location+3],'p'
mov [location+4],'i'
mov [location+5],'n'
mov [location+6],'g'
mov [location+7],' '
mov [location+8],'F'
mov [location+9],'i'
mov [location+10],'l'
mov [location+11],'e'
mov [location+12],' '
mov [location+13],'i'
mov [location+14],'n'
mov [location+15],'t'
mov [location+16],'o'
mov [location+17],' '
mov [location+18],'M'
mov [location+19],'e'
mov [location+20],'m'
mov [location+21],'o'
mov [location+22],'r'
mov [location+23],'y'
mov [location+24],0
lea rax,[location]
}
macro createStringLoaded location
{
mov [location+0],'L'
mov [location+1],'o'
mov [location+2],'a'
mov [location+3],'d'
mov [location+4],'e'
mov [location+5],'d'
mov [location+6],' '
mov [location+7],0
lea rax,[location]
}
macro createStringLoadedPEHeader location
{
mov [location+0],'S'
mov [location+1],'e'
mov [location+2],'t'
mov [location+3],' '
mov [location+4],'I'
mov [location+5],'m'
mov [location+6],'a'
mov [location+7],'g'
mov [location+8],'e'
mov [location+9],' '
mov [location+10],'w'
mov [location+11],'r'
mov [location+12],'i'
mov [location+13],'t'
mov [location+14],'a'
mov [location+15],'b'
mov [location+16],'l'
mov [location+17],'e'
mov [location+18],':'
mov [location+19],0
lea rax,[location]
}
macro createStringVerifyPE location
{
mov [location+0],'V'
mov [location+1],'e'
mov [location+2],'r'
mov [location+3],'i'
mov [location+4],'f'
mov [location+5],'y'
mov [location+6],'i'
mov [location+7],'n'
mov [location+8],'g'
mov [location+9],' '
mov [location+10],'P'
mov [location+11],'E'
mov [location+12],0
lea rax,[location]
}
macro createStringVerifyChecksum location
{
mov [location+0],'V'
mov [location+1],'e'
mov [location+2],'r'
mov [location+3],'i'
mov [location+4],'f'
mov [location+5],'y'
mov [location+6],'i'
mov [location+7],'n'
mov [location+8],'g'
mov [location+9],' '
mov [location+10],'C'
mov [location+11],'h'
mov [location+12],'e'
mov [location+13],'c'
mov [location+14],'k'
mov [location+15],'s'
mov [location+16],'u'
mov [location+17],'m'
mov [location+18],0
lea rax,[location]
}
macro createStringDone location
{
mov [location+0],'D'
mov [location+1],'o'
mov [location+2],'n'
mov [location+3],'e'
mov [location+4],0
lea rax,[location]
}
macro createStringError location
{
mov [location+0],'E'
mov [location+1],'r'
mov [location+2],'r'
mov [location+3],'o'
mov [location+4],'r'
mov [location+5],0
lea rax,[location]
}
macro createStringStartingHyperion location
{
mov [location+00],'H'
mov [location+01],'y'
mov [location+02],'p'
mov [location+03],'e'
mov [location+04],'r'
mov [location+05],'i'
mov [location+06],'o'
mov [location+07],'n'
mov [location+08],' '
mov [location+09],'L'
mov [location+10],'o'
mov [location+11],'g'
mov [location+12],'f'
mov [location+13],'i'
mov [location+14],'l'
mov [location+15],'e'
mov [location+16],13
mov [location+17],10
mov [location+18],0
lea rax,[location]
}
macro createStringStartingHyperionLines location
{
mov [location+00],'-'
mov [location+01],'-'
mov [location+02],'-'
mov [location+03],'-'
mov [location+04],'-'
mov [location+05],'-'
mov [location+06],'-'
mov [location+07],'-'
mov [location+08],'-'
mov [location+09],'-'
mov [location+10],'-'
mov [location+11],'-'
mov [location+12],'-'
mov [location+13],'-'
mov [location+14],'-'
mov [location+15],'-'
mov [location+16],13
mov [location+17],10
mov [location+18],0
lea rax,[location]
}
macro createStringLogTxt location
{
mov [location+0],'l'
mov [location+1],'o'
mov [location+2],'g'
mov [location+3],'.'
mov [location+4],'t'
mov [location+5],'x'
mov [location+6],'t'
mov [location+7],0
lea rax,[location]
}
;writes a string and a newline to the logfile
macro writeWithNewLine char_sequence, char_buffer, error_exit{
char_sequence char_buffer
lea rax,[str1]
fastcall writeLog_, rax
test rax,rax
jz error_exit
fastcall writeNewLineToLog_
test rax,rax
jz error_exit
}
;write a string to the logfile
macro writeLog content, error_exit{
fastcall writeLog_, content
test rax,rax
jz error_exit
}
;delete old log file and create a new one
macro initLogFile error_exit{
fastcall initLogFile_, error_exit
test rax,rax
jz error_exit
}
;write a newline into logfile
macro writeNewLineToLog error_exit{
fastcall writeNewLineToLog_
test rax,rax
jz error_exit
}
;write a register value into logile
macro writeRegisterToLog value, error_exit{
fastcall writeRegisterToLog_, value
test rax,rax
jz error_exit
}
;TODO: Does not really fit into architecture
macro writeSectionNameAndAddressToLog{
lea rdi,[str1]
mov byte [rdi+8],0
mov rdx,[section_header]
lea rsi,[rdx+IMAGE_SECTION_HEADER._Name]
mov rcx,8
mov r12, rdi
rep movsb
mov rdi, r12
writeLog rdi, ls_exit_error
writeNewLineToLog ls_exit_error
mov rdx,[section_header]
mov eax,[rdx+IMAGE_SECTION_HEADER.VirtualAddress]
add rax,[image_base]
writeRegisterToLog rax, ls_exit_error
}
;--- End Macro Section ---
;get the length of a string
proc strlen_ uses rdi rcx, string_ptr:QWORD
mov [string_ptr],rcx
mov rdi,[string_ptr]
sub rcx, rcx
sub al, al
not rcx
cld
repne scasb
not rcx
dec rcx
mov rax,rcx
ret
endp
;write <content> into log.txt
;returns false if an eerror occurs
proc writeLog_ content:QWORD
local str1[256]:BYTE, oldlogsize:QWORD, newlogsize:QWORD, contentsize:QWORD,\
filehandle:QWORD, filemappingobject:QWORD, mapaddress:QWORD, retval:QWORD
mov [content],rcx
;open file
createStringLogTxt str1
sub r11,r11
invoke CreateFile, rax, GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ, r11, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, r11
mov [retval],rax
test rax,rax
jz wl_logexit
mov [filehandle],rax
;get logfile size
invoke GetFileSize, qword [filehandle], 0
mov [oldlogsize],rax
;get size of string for logfile for concatenation
fastcall strlen_, qword [content]
mov [contentsize], rax
add rax,qword [oldlogsize]
mov [newlogsize], rax
;create the file mapping
sub r10,r10
invoke CreateFileMapping, qword [filehandle], r10, PAGE_READWRITE, r10, rax, r10
mov [retval],rax
test rax, rax
jz wl_closelogfile
mov [filemappingobject],rax
sub r10,r10
invoke MapViewOfFile, rax, FILE_MAP_ALL_ACCESS, r10, r10, qword [newlogsize]
mov [retval],rax
test rax, rax
jz wl_closemaphandle
mov [mapaddress],rax
;copy string into map
add rax,[oldlogsize]
mov rdi,rax
mov rsi,[content]
mov rcx,[contentsize]
repz movsb
mov [retval],1
wl_unmapfile:
invoke UnmapViewOfFile, qword [mapaddress]
wl_closemaphandle:
invoke CloseHandle, qword [filemappingobject]
wl_closelogfile:
invoke CloseHandle, qword [filehandle]
wl_logexit:
mov rax,[retval]
ret;
endp
;adds a <newline> to the logfile
;returns false if an error occurs
proc writeNewLineToLog_
local str1[3]:BYTE
lea rax,[str1]
mov byte [rax+0],13
mov byte [rax+1],10
mov byte [rax+2],0
fastcall writeLog_, rax
ret
endp
;returns false if an error occurs
proc writeRegisterToLog_ Value:QWORD
local str1[18]:BYTE, retval:QWORD
mov [Value],rcx
lea rax,[str1]
fastcall binToString_, rax, [Value]
fastcall writeLog_, rax
mov [retval],rax
test rax,rax
jz wrtl_exit
fastcall writeNewLineToLog_
mov [retval],rax
test rax,rax
jz wrtl_exit
wrtl_exit:
mov rax,[retval]
ret
endp
;converts <bin> into an 8 byte string and stores it <buffer>
proc binToString_ buffer:QWORD, bin:QWORD
mov [buffer],rcx
mov [bin], rdx
mov r10,[bin]
mov rcx,16
bts_next_byte:
mov rax,r10
and rax,0000000fh
cmp rax,9
jg bts_add_55
bts_add_48:
add rax,48
jmp bts_store_bin
bts_add_55:
add rax,55
bts_store_bin:
dec rcx
mov rdx,[buffer]
mov byte [rcx+rdx],al
test rcx,rcx
jz bts_finished_conversion
shr r10,4
jmp bts_next_byte
bts_finished_conversion:
mov rax,[buffer]
mov byte [rax+16],0
ret
endp
;Write initial message into logfile
proc initLogFile_
local str1[256]:BYTE
createStringLogTxt str1
invoke DeleteFile, rax
createStringStartingHyperionLines str1
fastcall writeLog_, rax
test rax,rax
jz ilf_exit_error
createStringStartingHyperion str1
fastcall writeLog_, rax
test rax,rax
jz ilf_exit_error
createStringStartingHyperionLines str1
fastcall writeLog_, rax
test rax,rax
jz ilf_exit_error
fastcall writeNewLineToLog_
test rax,rax
jz ilf_exit_error
ilf_exit_success:
mov rax,1
ret
ilf_exit_error:
sub rax,rax
ret
endp |
/* mpcorb2.cpp: functions to get basic data on 'mpcorb.dat' files
(Not really very relevant to anything, as it's turned out!)
Copyright (C) 2010, Project Pluto
This program 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 program 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 program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
#include <stdio.h>
#include <stdlib.h>
/* 'mpcorb.dat' files have some oddities that complicate automated
handling. Each file has a dozen or so lines of "header" data.
Following are a few hundred thousand lines of numbered objects,
with each line being 203 bytes long (202 bytes of actual data
plus a line-feed terminator).
Then an additional line-feed is inserted, followed by more lines
for unnumbered multi-opposition objects, plus another line-feed and
more lines for single-opposition objects (all unnumbered). Hence,
you can't just seek to (header_size + 203 * record_number) and
read 202 bytes. Well, you can do that for numbered objects...
but for unnumbered multi-opp ones, you need to go an additional
byte, to account for that !*#% line feed; and for single-opp
data, you need to go yet another byte. So knowing ahead of time
the header length and how many objects there are of each type
could be useful.
As it turned out, I never actually needed the following (I worked
away around the need). So it's not as thoroughly tested as it might be.
User beware.
data[0] = header length, in bytes;
data[1] = number of numbered asteroids / start of multi-opps;
data[2] = start of single-opp objects;
data[3] = total number of objects */
#define MPCORB_RECLEN 203
int get_mpcorb_info( FILE *ifile, long *data)
{
char buff[210];
int lines_read = 0, i;
fseek( ifile, 0L, SEEK_SET);
data[0] = 0; /* assume no header */
data[1] = data[2] = data[3] = 0;
while( lines_read < 50 && fgets( buff, sizeof( buff), ifile))
{
lines_read++;
if( *buff == '-') /* we've read the entire header */
{
lines_read = 1000;
data[0] = ftell( ifile);
}
}
fseek( ifile, 0L, SEEK_END);
data[3] = (ftell( ifile) - data[0]) / MPCORB_RECLEN;
for( i = 1; i <= 3; i++)
{
long step, loc1;
for( step = 0x800000; step; step >>= 1)
{
loc1 = data[i] + step;
if( !fseek( ifile, data[0] + loc1 * MPCORB_RECLEN, SEEK_SET))
if( fread( buff, 10, 1, ifile))
{
if( buff[0] == 10 && loc1 > data[2])
data[2] = loc1;
else if( buff[0] != 10 && buff[1] != 10 && loc1 > data[1])
data[1] = loc1;
}
}
}
data[1]++;
return( 0);
}
int main( const int argc, const char **argv)
{
FILE *ifile = fopen( "mpcorb.dat", "rb");
long data[4];
char tbuff[80];
if( ifile)
{
get_mpcorb_info( ifile, data);
printf( "%ld %ld %ld %ld\n", data[0], data[1], data[2], data[3]);
}
else
printf( "mpcorb.dat not opened\n");
if( argc > 1)
{
long rec_num = atol( argv[1]);
long offset = data[0] + rec_num * MPCORB_RECLEN;
if( rec_num >= data[2])
offset += 2;
else if( rec_num >= data[1])
offset++;
fseek( ifile, offset, SEEK_SET);
fread( tbuff, 80, 1, ifile);
tbuff[79] = '\0';
printf( "%s", tbuff);
}
return( 0);
}
|
; A323703: Number of values of (X^3 + X) mod prime(n).
; 1,3,3,5,7,9,11,13,15,19,21,25,27,29,31,35,39,41,45,47,49,53,55,59,65,67,69,71,73,75,85,87,91,93,99,101,105,109,111,115,119,121,127,129,131,133,141,149,151,153,155,159,161,167,171,175,179,181,185,187,189,195,205,207,209,211,221,225,231,233,235,239,245,249,253,255,259,265,267,273,279,281,287,289,293,295,299,305,307,309,311,319,325,327,333,335,339,347,349,361
seq $0,6005 ; The odd prime numbers together with 1.
div $0,3
mul $0,2
add $0,1
|
SECTION code_fp_math16
PUBLIC _sqrtf16
EXTERN cm16_sdcc_sqrt
defc _sqrtf16 = cm16_sdcc_sqrt
|
; re-setup a window
include win1_mac_oli
include win1_keys_wman
include win1_keys_wwork
include win1_keys_wstatus
section utility
xdef xwm_rset
;+++
; re-setup a window into a given definition
;
; Entry Exit
; d1.l size (or 0, or -1) position
; a2 wman vector
; a4 wwork
;---
xwm_rset subr a0/a1/a3/d3/d2
move.l ww_chid(a4),a0 ; channel id
move.l ww_wstat(a4),a1 ; window status area
move.l ww_wdef(a4),a3 ; window defintion
move.l ws_ptpos(a1),d3 ; absolute pointer position
move.l ww_xorg(a4),d2 ; origin of window..
sub.l d2,d3 ; ptr pos in primary
add.l ww_xsize(a4),d2 ; ..bottom right hand corner
xjsr xwm_wsiz ; check window size
jsr wm.setup(a2) ; setup window
move.l d3,ww_xorg(a4) ; adjust pointer position
sub.l ww_xsize(a4),d2 ; get new origin
add.l d3,d2 ; rel. by ptr pos
move.l d2,d1
subend
end
|
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "console.h"
#include <optional>
#include <string>
#include <vector>
#include "third_party/quickjs/quickjs-libc.h"
#include "third_party/quickjs/quickjs.h"
#include "tools/shell/console/command_line_options.h"
namespace shell {
extern "C" const uint8_t qjsc_repl[];
extern "C" const uint32_t qjsc_repl_size;
int ConsoleMain(int argc, const char **argv) {
CommandLineOptions options;
std::vector<std::string> params;
if (!ParseCommandLine(argc, argv, &options, ¶ms).ok()) {
return 1;
}
JSRuntime *rt = JS_NewRuntime();
if (rt == nullptr) {
fprintf(stderr, "Cannot allocate JS runtime");
return 1;
}
JSContext *ctx = JS_NewContext(rt);
if (ctx == nullptr) {
fprintf(stderr, "Cannot allocate JS context");
return 1;
}
// System modules
js_init_module_std(ctx, "std");
js_init_module_os(ctx, "os");
const char *str =
"import * as std from 'std';\n"
"import * as os from 'os';\n"
"globalThis.std = std;\n"
"globalThis.os = os;\n";
JSValue init_compile =
JS_Eval(ctx, str, strlen(str), "<input>", JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_COMPILE_ONLY);
if (JS_IsException(init_compile)) {
js_std_dump_error(ctx);
return 1;
}
js_module_set_import_meta(ctx, init_compile, 1, 1);
JSValue init_run = JS_EvalFunction(ctx, init_compile);
if (JS_IsException(init_run)) {
js_std_dump_error(ctx);
return 1;
}
// TODO(jeremymanson): The second and third parameter below let you define properties on the
// command line, which might be nice at some point.
js_std_add_helpers(ctx, 0, nullptr);
if (!options.command_string) {
// Use the qjs repl for the time being.
js_std_eval_binary(ctx, qjsc_repl, qjsc_repl_size, 0);
} else {
const char *command = options.command_string->c_str();
JSValue result = JS_Eval(ctx, command, options.command_string->length(), "batch", 0);
if (JS_IsException(result)) {
js_std_dump_error(ctx);
return 1;
}
}
js_std_loop(ctx);
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
return 0;
}
} // namespace shell
|
/*
YAEP (Yet Another Earley Parser)
Copyright (c) 1997-2018 Vladimir Makarov <vmakarov@gcc.gnu.org>
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.
*/
#include <stdlib.h>
#include"common.h"
static const char *input = "a+a*(a*+a)";
static const char *description =
"\n"
"E : T # 0\n"
" | E '+' T # plus (0 2)\n"
" ;\n"
"T : F # 0\n"
" | T '*' F # mult (0 2)\n"
" ;\n"
"F : 'a' # 0\n"
" | '(' E ')' # 1\n"
" ;\n"
;
int
main (int argc, char **argv)
{
test_complex_parse (input, description, 0, 0, 0, 0, argc, argv);
exit (0);
}
|
/******************************************************************************
* Copyright 2019 The Apollo Authors. All Rights Reserved.
*
* 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.
*****************************************************************************/
#include "modules/planning/tasks/deciders/path_assessment_decider/path_assessment_decider.h"
#include <algorithm>
#include <cmath>
#include <limits>
#include <utility>
#include "modules/common/configs/vehicle_config_helper.h"
#include "modules/common/proto/pnc_point.pb.h"
#include "modules/map/hdmap/hdmap_util.h"
#include "modules/planning/common/planning_context.h"
#include "modules/planning/tasks/deciders/path_bounds_decider/path_bounds_decider.h"
#include "modules/planning/tasks/deciders/utils/path_decider_obstacle_utils.h"
namespace apollo {
namespace planning {
using apollo::common::ErrorCode;
using apollo::common::Status;
using apollo::common::VehicleConfigHelper;
using apollo::common::math::Box2d;
using apollo::common::math::NormalizeAngle;
using apollo::common::math::Polygon2d;
using apollo::common::math::Vec2d;
using apollo::hdmap::HDMapUtil;
namespace {
// PointDecision contains (s, PathPointType, distance to closest obstacle).
using PathPointDecision = std::tuple<double, PathData::PathPointType, double>;
constexpr double kMinObstacleArea = 1e-4;
} // namespace
PathAssessmentDecider::PathAssessmentDecider(const TaskConfig& config)
: Decider(config) {}
Status PathAssessmentDecider::Process(
Frame* const frame, ReferenceLineInfo* const reference_line_info) {
// Sanity checks.
CHECK_NOTNULL(frame);
CHECK_NOTNULL(reference_line_info);
const auto& candidate_path_data = reference_line_info->GetCandidatePathData();
if (candidate_path_data.empty()) {
ADEBUG << "Candidate path data is empty.";
} else {
ADEBUG << "There are " << candidate_path_data.size() << " candidate paths";
}
const auto& end_time0 = std::chrono::system_clock::now();
// 1. Remove invalid path.
std::vector<PathData> valid_path_data;
for (const auto& curr_path_data : candidate_path_data) {
// RecordDebugInfo(curr_path_data, curr_path_data.path_label(),
// reference_line_info);
if (curr_path_data.path_label().find("fallback") != std::string::npos) {
if (IsValidFallbackPath(*reference_line_info, curr_path_data)) {
valid_path_data.push_back(curr_path_data);
}
} else {
if (IsValidRegularPath(*reference_line_info, curr_path_data)) {
valid_path_data.push_back(curr_path_data);
}
}
}
const auto& end_time1 = std::chrono::system_clock::now();
std::chrono::duration<double> diff = end_time1 - end_time0;
ADEBUG << "Time for path validity checking: " << diff.count() * 1000
<< " msec.";
// 2. Analyze and add important info for speed decider to use.
for (auto& curr_path_data : valid_path_data) {
if (curr_path_data.path_label().find("fallback") != std::string::npos) {
continue;
}
SetPathInfo(*reference_line_info, &curr_path_data);
// Trim all the lane-borrowing paths so that it ends with an in-lane
// position.
if (curr_path_data.path_label().find("pullover") == std::string::npos) {
TrimTailingOutLanePoints(&curr_path_data);
}
// TODO(jiacheng): remove empty path_data.
// RecordDebugInfo(curr_path_data, curr_path_data.path_label(),
// reference_line_info);
ADEBUG << "For " << curr_path_data.path_label() << ", "
<< "path length = " << curr_path_data.frenet_frame_path().size();
}
// If there is no valid path_data, exit.
if (valid_path_data.empty()) {
const std::string msg = "Neither regular nor fallback path is valid.";
AERROR << msg;
return Status(ErrorCode::PLANNING_ERROR, msg);
}
ADEBUG << "There are " << valid_path_data.size() << " valid path data.";
const auto& end_time2 = std::chrono::system_clock::now();
diff = end_time2 - end_time1;
ADEBUG << "Time for path info labeling: " << diff.count() * 1000 << " msec.";
// 3. Pick the optimal path.
std::sort(valid_path_data.begin(), valid_path_data.end(),
[](const PathData& lhs, const PathData& rhs) {
ADEBUG << "Comparing " << lhs.path_label() << " and "
<< rhs.path_label();
// Empty path_data is never the larger one.
if (lhs.Empty()) {
ADEBUG << "LHS is empty.";
return false;
}
if (rhs.Empty()) {
ADEBUG << "RHS is empty.";
return true;
}
// Regular path goes before fallback path.
bool lhs_is_regular =
lhs.path_label().find("regular") != std::string::npos;
bool rhs_is_regular =
rhs.path_label().find("regular") != std::string::npos;
if (lhs_is_regular != rhs_is_regular) {
return lhs_is_regular;
}
// For two lane-borrow directions, based on ADC's position,
// select the more convenient one.
if ((lhs.path_label().find("left") != std::string::npos &&
rhs.path_label().find("right") != std::string::npos) ||
(lhs.path_label().find("right") != std::string::npos &&
rhs.path_label().find("left") != std::string::npos)) {
double adc_l = lhs.frenet_frame_path().front().l();
if (adc_l < -1.0 || adc_l > 1.0) {
if (adc_l < -1.0) {
return lhs.path_label().find("right") != std::string::npos;
} else {
return lhs.path_label().find("left") != std::string::npos;
}
}
}
// Select longer path.
// If roughly same length, then select self-lane path.
bool lhs_on_selflane =
lhs.path_label().find("self") != std::string::npos;
bool rhs_on_selflane =
rhs.path_label().find("self") != std::string::npos;
constexpr double kSelfPathLengthComparisonTolerance = 15.0;
constexpr double kNeighborPathLengthComparisonTolerance = 25.0;
double lhs_path_length = lhs.frenet_frame_path().back().s();
double rhs_path_length = rhs.frenet_frame_path().back().s();
if (lhs_on_selflane || rhs_on_selflane) {
if (std::fabs(lhs_path_length - rhs_path_length) >
kSelfPathLengthComparisonTolerance) {
return lhs_path_length > rhs_path_length;
} else {
return lhs_on_selflane;
}
} else {
if (std::fabs(lhs_path_length - rhs_path_length) >
kNeighborPathLengthComparisonTolerance) {
return lhs_path_length > rhs_path_length;
}
}
// If roughly same length, and must borrow neighbor lane,
// then prefer to borrow forward lane rather than reverse lane.
int lhs_on_reverse =
ContainsOutOnReverseLane(lhs.path_point_decision_guide());
int rhs_on_reverse =
ContainsOutOnReverseLane(rhs.path_point_decision_guide());
// TODO(jiacheng): make this a flag.
if (std::abs(lhs_on_reverse - rhs_on_reverse) > 6) {
return lhs_on_reverse < rhs_on_reverse;
}
// If same length, both neighbor lane are forward,
// then select the one that returns to in-lane earlier.
constexpr double kBackToSelfLaneComparisonTolerance = 20.0;
int lhs_back_idx =
GetBackToInLaneIndex(lhs.path_point_decision_guide());
int rhs_back_idx =
GetBackToInLaneIndex(rhs.path_point_decision_guide());
double lhs_back_s = lhs.frenet_frame_path()[lhs_back_idx].s();
double rhs_back_s = rhs.frenet_frame_path()[rhs_back_idx].s();
if (std::fabs(lhs_back_s - rhs_back_s) >
kBackToSelfLaneComparisonTolerance) {
return lhs_back_idx < rhs_back_idx;
}
// If same length, both forward, back to inlane at same time,
// select the left one to side-pass.
bool lhs_on_leftlane =
lhs.path_label().find("left") != std::string::npos;
bool rhs_on_leftlane =
rhs.path_label().find("left") != std::string::npos;
if (lhs_on_leftlane != rhs_on_leftlane) {
ADEBUG << "Select left lane over right lane.";
return lhs_on_leftlane;
}
// Otherwise, they are the same path, lhs is not < rhs.
return false;
});
ADEBUG << "There are " << valid_path_data.size() << " path(s).";
ADEBUG << "Using " << valid_path_data.front().path_label() << " path.";
if (valid_path_data.front().path_label().find("fallback") !=
std::string::npos) {
FLAGS_static_decision_nudge_l_buffer = 0.8;
} else {
FLAGS_static_decision_nudge_l_buffer = 0.3;
}
*(reference_line_info->mutable_path_data()) = valid_path_data.front();
reference_line_info->SetBlockingObstacleId(
valid_path_data.front().blocking_obstacle_id());
const auto& end_time3 = std::chrono::system_clock::now();
diff = end_time3 - end_time2;
ADEBUG << "Time for optimal path selection: " << diff.count() * 1000
<< " msec.";
// TODO(jiacheng): retire the following code.
std::vector<PathData> new_candidate_path_data;
for (const auto& curr_path_data : valid_path_data) {
if (!curr_path_data.Empty()) {
new_candidate_path_data.push_back(curr_path_data);
}
}
reference_line_info->SetCandidatePathData(std::move(new_candidate_path_data));
// 4. Update necessary info for lane-borrow decider's future uses.
// Update front static obstacle's info.
auto* mutable_path_decider_status = PlanningContext::Instance()
->mutable_planning_status()
->mutable_path_decider();
if (!(reference_line_info->GetBlockingObstacleId()).empty()) {
int front_static_obstacle_cycle_counter =
mutable_path_decider_status->front_static_obstacle_cycle_counter();
if (front_static_obstacle_cycle_counter < 0) {
front_static_obstacle_cycle_counter = 0;
}
mutable_path_decider_status->set_front_static_obstacle_id(
reference_line_info->GetBlockingObstacleId());
mutable_path_decider_status->set_front_static_obstacle_cycle_counter(
std::min(front_static_obstacle_cycle_counter + 1, 10));
} else {
mutable_path_decider_status->set_front_static_obstacle_cycle_counter(0);
}
// Update self-lane usage info.
if (reference_line_info->path_data().path_label().find("self") !=
std::string::npos) {
// && std::get<1>(reference_line_info->path_data()
// .path_point_decision_guide()
// .front()) == PathData::PathPointType::IN_LANE) {
int able_to_use_self_lane_counter =
mutable_path_decider_status->able_to_use_self_lane_counter();
if (able_to_use_self_lane_counter < 0) {
able_to_use_self_lane_counter = 0;
}
mutable_path_decider_status->set_able_to_use_self_lane_counter(
std::min(able_to_use_self_lane_counter + 1, 10));
} else {
mutable_path_decider_status->set_able_to_use_self_lane_counter(0);
}
// Update side-pass direction.
if (mutable_path_decider_status->is_in_path_lane_borrow_scenario()) {
bool left_borrow = false;
bool right_borrow = false;
const auto& path_decider_status =
PlanningContext::Instance()->planning_status().path_decider();
for (const auto& lane_borrow_direction :
path_decider_status.decided_side_pass_direction()) {
if (lane_borrow_direction == PathDeciderStatus::LEFT_BORROW &&
reference_line_info->path_data().path_label().find("left") !=
std::string::npos) {
left_borrow = true;
}
if (lane_borrow_direction == PathDeciderStatus::RIGHT_BORROW &&
reference_line_info->path_data().path_label().find("right") !=
std::string::npos) {
right_borrow = true;
}
}
auto* mutable_path_decider_status = PlanningContext::Instance()
->mutable_planning_status()
->mutable_path_decider();
mutable_path_decider_status->clear_decided_side_pass_direction();
if (right_borrow) {
mutable_path_decider_status->add_decided_side_pass_direction(
PathDeciderStatus::RIGHT_BORROW);
}
if (left_borrow) {
mutable_path_decider_status->add_decided_side_pass_direction(
PathDeciderStatus::LEFT_BORROW);
}
}
const auto& end_time4 = std::chrono::system_clock::now();
diff = end_time4 - end_time3;
ADEBUG << "Time for FSM state updating: " << diff.count() * 1000 << " msec.";
// Plot the path in simulator for debug purpose.
RecordDebugInfo(reference_line_info->path_data(), "Planning PathData",
reference_line_info);
return Status::OK();
}
bool PathAssessmentDecider::IsValidRegularPath(
const ReferenceLineInfo& reference_line_info, const PathData& path_data) {
// Basic sanity checks.
if (path_data.Empty()) {
ADEBUG << path_data.path_label() << ": path data is empty.";
return false;
}
// Check if the path is greatly off the reference line.
if (IsGreatlyOffReferenceLine(path_data)) {
ADEBUG << path_data.path_label() << ": ADC is greatly off reference line.";
return false;
}
// Check if the path is greatly off the road.
if (IsGreatlyOffRoad(reference_line_info, path_data)) {
ADEBUG << path_data.path_label() << ": ADC is greatly off road.";
return false;
}
// Check if there is any collision.
if (IsCollidingWithStaticObstacles(reference_line_info, path_data)) {
ADEBUG << path_data.path_label() << ": ADC has collision.";
return false;
}
if (IsStopOnReverseNeighborLane(reference_line_info, path_data)) {
ADEBUG << path_data.path_label() << ": stop at reverse neighbor lane";
return false;
}
return true;
}
bool PathAssessmentDecider::IsValidFallbackPath(
const ReferenceLineInfo& reference_line_info, const PathData& path_data) {
// Basic sanity checks.
if (path_data.Empty()) {
ADEBUG << "Fallback Path: path data is empty.";
return false;
}
// Check if the path is greatly off the reference line.
if (IsGreatlyOffReferenceLine(path_data)) {
ADEBUG << "Fallback Path: ADC is greatly off reference line.";
return false;
}
// Check if the path is greatly off the road.
if (IsGreatlyOffRoad(reference_line_info, path_data)) {
ADEBUG << "Fallback Path: ADC is greatly off road.";
return false;
}
return true;
}
void PathAssessmentDecider::SetPathInfo(
const ReferenceLineInfo& reference_line_info, PathData* const path_data) {
// Go through every path_point, and label its:
// - in-lane/out-of-lane info
// - distance to the closest obstacle.
std::vector<PathPointDecision> path_decision;
InitPathPointDecision(*path_data, &path_decision);
if (path_data->path_label().find("fallback") == std::string::npos &&
path_data->path_label().find("self") == std::string::npos) {
SetPathPointType(reference_line_info, *path_data, &path_decision);
}
// SetObstacleDistance(reference_line_info, *path_data, &path_decision);
path_data->SetPathPointDecisionGuide(path_decision);
}
void PathAssessmentDecider::TrimTailingOutLanePoints(
PathData* const path_data) {
// Don't trim self-lane path or fallback path.
if (path_data->path_label().find("fallback") != std::string::npos ||
path_data->path_label().find("self") != std::string::npos) {
return;
}
// Trim.
ADEBUG << "Trimming " << path_data->path_label();
auto frenet_path = path_data->frenet_frame_path();
auto path_point_decision = path_data->path_point_decision_guide();
CHECK_EQ(frenet_path.size(), path_point_decision.size());
while (!path_point_decision.empty() &&
std::get<1>(path_point_decision.back()) !=
PathData::PathPointType::IN_LANE) {
if (std::get<1>(path_point_decision.back()) ==
PathData::PathPointType::OUT_ON_FORWARD_LANE) {
ADEBUG << "Trimming out forward lane point";
} else if (std::get<1>(path_point_decision.back()) ==
PathData::PathPointType::OUT_ON_REVERSE_LANE) {
ADEBUG << "Trimming out reverse lane point";
} else {
ADEBUG << "Trimming unknown lane point";
}
frenet_path.pop_back();
path_point_decision.pop_back();
}
path_data->SetFrenetPath(frenet_path);
path_data->SetPathPointDecisionGuide(path_point_decision);
}
bool PathAssessmentDecider::IsGreatlyOffReferenceLine(
const PathData& path_data) {
constexpr double kOffReferenceLineThreshold = 20.0;
const auto& frenet_path = path_data.frenet_frame_path();
for (const auto& frenet_path_point : frenet_path) {
if (std::fabs(frenet_path_point.l()) > kOffReferenceLineThreshold) {
ADEBUG << "Greatly off reference line at s = " << frenet_path_point.s()
<< ", with l = " << frenet_path_point.l();
return true;
}
}
return false;
}
bool PathAssessmentDecider::IsGreatlyOffRoad(
const ReferenceLineInfo& reference_line_info, const PathData& path_data) {
constexpr double kOffRoadThreshold = 10.0;
const auto& frenet_path = path_data.frenet_frame_path();
for (const auto& frenet_path_point : frenet_path) {
double road_left_width = 0.0;
double road_right_width = 0.0;
if (reference_line_info.reference_line().GetRoadWidth(
frenet_path_point.s(), &road_left_width, &road_right_width)) {
if (frenet_path_point.l() > road_left_width + kOffRoadThreshold ||
frenet_path_point.l() < -road_right_width - kOffRoadThreshold) {
ADEBUG << "Greatly off-road at s = " << frenet_path_point.s()
<< ", with l = " << frenet_path_point.l();
return true;
}
}
}
return false;
}
bool PathAssessmentDecider::IsCollidingWithStaticObstacles(
const ReferenceLineInfo& reference_line_info, const PathData& path_data) {
// Get all obstacles and convert them into frenet-frame polygons.
std::vector<Polygon2d> obstacle_polygons;
const auto& indexed_obstacles =
reference_line_info.path_decision().obstacles();
for (const auto* obstacle : indexed_obstacles.Items()) {
// Filter out unrelated obstacles.
if (!IsWithinPathDeciderScopeObstacle(*obstacle)) {
continue;
}
// Ignore too small obstacles.
const auto& obstacle_sl = obstacle->PerceptionSLBoundary();
if ((obstacle_sl.end_s() - obstacle_sl.start_s()) *
(obstacle_sl.end_l() - obstacle_sl.start_l()) <
kMinObstacleArea) {
continue;
}
// Convert into polygon and save it.
obstacle_polygons.push_back(
Polygon2d({Vec2d(obstacle_sl.start_s(), obstacle_sl.start_l()),
Vec2d(obstacle_sl.start_s(), obstacle_sl.end_l()),
Vec2d(obstacle_sl.end_s(), obstacle_sl.end_l()),
Vec2d(obstacle_sl.end_s(), obstacle_sl.start_l())}));
}
// Go through all the four corner points at every path pt, check collision.
for (size_t i = 0; i < path_data.discretized_path().size(); ++i) {
if (path_data.frenet_frame_path().back().s() -
path_data.frenet_frame_path()[i].s() <
kNumExtraTailBoundPoint * kPathBoundsDeciderResolution) {
break;
}
const auto& path_point = path_data.discretized_path()[i];
// Get the four corner points ABCD of ADC at every path point.
const auto& vehicle_box =
common::VehicleConfigHelper::Instance()->GetBoundingBox(path_point);
std::vector<Vec2d> ABCDpoints = vehicle_box.GetAllCorners();
for (const auto& corner_point : ABCDpoints) {
// For each corner point, project it onto reference_line
common::SLPoint curr_point_sl;
if (!reference_line_info.reference_line().XYToSL(corner_point,
&curr_point_sl)) {
AERROR << "Failed to get the projection from point onto "
"reference_line";
return true;
}
auto curr_point = Vec2d(curr_point_sl.s(), curr_point_sl.l());
// Check if it's in any polygon of other static obstacles.
for (const auto& obstacle_polygon : obstacle_polygons) {
if (obstacle_polygon.IsPointIn(curr_point)) {
ADEBUG << "ADC is colliding with obstacle at path s = "
<< path_point.s();
return true;
}
}
}
}
return false;
}
bool PathAssessmentDecider::IsStopOnReverseNeighborLane(
const ReferenceLineInfo& reference_line_info, const PathData& path_data) {
if (path_data.path_label().find("left") == std::string::npos &&
path_data.path_label().find("right") == std::string::npos) {
return false;
}
std::vector<common::SLPoint> all_stop_point_sl =
reference_line_info.GetAllStopDecisionSLPoint();
if (all_stop_point_sl.empty()) {
return false;
}
double check_s = 0.0;
constexpr double kLookForwardBuffer = 5.0; // filter out sidepass stop fence
const double adc_end_s = reference_line_info.AdcSlBoundary().end_s();
for (const auto& stop_point_sl : all_stop_point_sl) {
if (stop_point_sl.s() - adc_end_s < kLookForwardBuffer) {
continue;
}
check_s = stop_point_sl.s();
break;
}
if (check_s <= 0.0) {
return false;
}
double lane_left_width = 0.0;
double lane_right_width = 0.0;
if (!reference_line_info.reference_line().GetLaneWidth(
check_s, &lane_left_width, &lane_right_width)) {
return false;
}
constexpr double kSDelta = 0.3;
common::SLPoint path_point_sl;
for (const auto& frenet_path_point : path_data.frenet_frame_path()) {
if (std::fabs(frenet_path_point.s() - check_s) < kSDelta) {
path_point_sl.set_s(frenet_path_point.s());
path_point_sl.set_l(frenet_path_point.l());
}
}
ADEBUG << "path_point_sl[" << path_point_sl.s() << ", " << path_point_sl.l()
<< "] lane_left_width[" << lane_left_width << "] lane_right_width["
<< lane_right_width << "]";
hdmap::Id neighbor_lane_id;
double neighbor_lane_width = 0.0;
if (path_data.path_label().find("left") != std::string::npos &&
path_point_sl.l() > lane_left_width) {
if (reference_line_info.GetNeighborLaneInfo(
ReferenceLineInfo::LaneType::LeftReverse, path_point_sl.s(),
&neighbor_lane_id, &neighbor_lane_width)) {
ADEBUG << "stop path point at LeftReverse neighbor lane["
<< neighbor_lane_id.id() << "]";
return true;
}
} else if (path_data.path_label().find("right") != std::string::npos &&
path_point_sl.l() < -lane_right_width) {
if (reference_line_info.GetNeighborLaneInfo(
ReferenceLineInfo::LaneType::RightReverse, path_point_sl.s(),
&neighbor_lane_id, &neighbor_lane_width)) {
ADEBUG << "stop path point at RightReverse neighbor lane["
<< neighbor_lane_id.id() << "]";
return true;
}
}
return false;
}
void PathAssessmentDecider::InitPathPointDecision(
const PathData& path_data,
std::vector<PathPointDecision>* const path_point_decision) {
// Sanity checks.
CHECK_NOTNULL(path_point_decision);
path_point_decision->clear();
// Go through every path point in path data, and initialize a
// corresponding path point decision.
for (const auto& frenet_path_point : path_data.frenet_frame_path()) {
path_point_decision->emplace_back(frenet_path_point.s(),
PathData::PathPointType::UNKNOWN,
std::numeric_limits<double>::max());
}
}
void PathAssessmentDecider::SetPathPointType(
const ReferenceLineInfo& reference_line_info, const PathData& path_data,
std::vector<PathPointDecision>* const path_point_decision) {
// Sanity checks.
CHECK_NOTNULL(path_point_decision);
// Go through every path_point, and add in-lane/out-of-lane info.
const auto& discrete_path = path_data.discretized_path();
const auto& vehicle_config =
common::VehicleConfigHelper::Instance()->GetConfig();
const double ego_length = vehicle_config.vehicle_param().length();
const double ego_width = vehicle_config.vehicle_param().width();
const double ego_back_to_center =
vehicle_config.vehicle_param().back_edge_to_center();
const double ego_center_shift_distance =
ego_length / 2.0 - ego_back_to_center;
bool is_prev_point_out_lane = false;
for (size_t i = 0; i < discrete_path.size(); ++i) {
const auto& rear_center_path_point = discrete_path[i];
const double ego_theta = rear_center_path_point.theta();
Box2d ego_box({rear_center_path_point.x(), rear_center_path_point.y()},
ego_theta, ego_length, ego_width);
Vec2d shift_vec{ego_center_shift_distance * std::cos(ego_theta),
ego_center_shift_distance * std::sin(ego_theta)};
ego_box.Shift(shift_vec);
SLBoundary ego_sl_boundary;
if (!reference_line_info.reference_line().GetSLBoundary(ego_box,
&ego_sl_boundary)) {
ADEBUG << "Unable to get SL-boundary of ego-vehicle.";
continue;
}
double lane_left_width = 0.0;
double lane_right_width = 0.0;
double middle_s =
(ego_sl_boundary.start_s() + ego_sl_boundary.end_s()) / 2.0;
if (reference_line_info.reference_line().GetLaneWidth(
middle_s, &lane_left_width, &lane_right_width)) {
// Rough sl boundary estimate using single point lane width
double back_to_inlane_extra_buffer = 0.5;
double in_and_out_lane_hysteresis_buffer =
is_prev_point_out_lane ? back_to_inlane_extra_buffer : 0.0;
if (ego_sl_boundary.end_l() >
lane_left_width + in_and_out_lane_hysteresis_buffer ||
ego_sl_boundary.start_l() <
-lane_right_width - in_and_out_lane_hysteresis_buffer) {
if (path_data.path_label().find("reverse") != std::string::npos) {
std::get<1>((*path_point_decision)[i]) =
PathData::PathPointType::OUT_ON_REVERSE_LANE;
} else if (path_data.path_label().find("forward") !=
std::string::npos) {
std::get<1>((*path_point_decision)[i]) =
PathData::PathPointType::OUT_ON_FORWARD_LANE;
} else {
std::get<1>((*path_point_decision)[i]) =
PathData::PathPointType::UNKNOWN;
}
if (!is_prev_point_out_lane) {
if (ego_sl_boundary.end_l() >
lane_left_width + back_to_inlane_extra_buffer ||
ego_sl_boundary.start_l() <
-lane_right_width - back_to_inlane_extra_buffer) {
is_prev_point_out_lane = true;
}
}
} else {
// The path point is within the reference_line's lane.
std::get<1>((*path_point_decision)[i]) =
PathData::PathPointType::IN_LANE;
if (is_prev_point_out_lane) {
if (ego_sl_boundary.end_l() > lane_left_width ||
ego_sl_boundary.start_l() < -lane_right_width) {
is_prev_point_out_lane = false;
}
}
}
} else {
AERROR << "reference line not ready when setting path point guide";
return;
}
}
}
void PathAssessmentDecider::SetObstacleDistance(
const ReferenceLineInfo& reference_line_info, const PathData& path_data,
std::vector<PathPointDecision>* const path_point_decision) {
// Sanity checks
CHECK_NOTNULL(path_point_decision);
// Get all obstacles and convert them into frenet-frame polygons.
std::vector<Polygon2d> obstacle_polygons;
const auto& indexed_obstacles =
reference_line_info.path_decision().obstacles();
for (const auto* obstacle : indexed_obstacles.Items()) {
// Filter out unrelated obstacles.
if (!IsWithinPathDeciderScopeObstacle(*obstacle)) {
continue;
}
// Convert into polygon and save it.
const auto& obstacle_box = obstacle->PerceptionBoundingBox();
if (obstacle_box.area() < kMinObstacleArea) {
continue;
}
obstacle_polygons.emplace_back(obstacle_box);
}
// Go through every path point, update closest obstacle info.
const auto& discrete_path = path_data.discretized_path();
for (size_t i = 0; i < discrete_path.size(); ++i) {
const auto& path_point = discrete_path[i];
// Get the bounding box of the vehicle at that point.
const auto& vehicle_box =
common::VehicleConfigHelper::Instance()->GetBoundingBox(path_point);
// Go through all the obstacle polygons, and update the min distance.
double min_distance_to_obstacles = std::numeric_limits<double>::max();
for (const auto& obstacle_polygon : obstacle_polygons) {
double distance_to_vehicle = obstacle_polygon.DistanceTo(vehicle_box);
min_distance_to_obstacles =
std::min(min_distance_to_obstacles, distance_to_vehicle);
}
std::get<2>((*path_point_decision)[i]) = min_distance_to_obstacles;
}
}
void PathAssessmentDecider::RecordDebugInfo(
const PathData& path_data, const std::string& debug_name,
ReferenceLineInfo* const reference_line_info) {
const auto& path_points = path_data.discretized_path();
auto* ptr_optimized_path =
reference_line_info->mutable_debug()->mutable_planning_data()->add_path();
ptr_optimized_path->set_name(debug_name);
ptr_optimized_path->mutable_path_point()->CopyFrom(
{path_points.begin(), path_points.end()});
}
int ContainsOutOnReverseLane(
const std::vector<PathPointDecision>& path_point_decision) {
int ret = 0;
for (const auto& curr_decision : path_point_decision) {
if (std::get<1>(curr_decision) ==
PathData::PathPointType::OUT_ON_REVERSE_LANE) {
++ret;
}
}
return ret;
}
int GetBackToInLaneIndex(
const std::vector<PathPointDecision>& path_point_decision) {
// CHECK(!path_point_decision.empty());
// CHECK(std::get<1>(path_point_decision.back()) ==
// PathData::PathPointType::IN_LANE);
for (int i = static_cast<int>(path_point_decision.size()) - 1; i >= 0; --i) {
if (std::get<1>(path_point_decision[i]) !=
PathData::PathPointType::IN_LANE) {
return i;
}
}
return 0;
}
} // namespace planning
} // namespace apollo
|
Name: ys_mplay0.asm
Type: file
Size: 43685
Last-Modified: '2016-05-13T04:52:57Z'
SHA-1: 8678B03BD6785EF98FBCD8E9BB97E9FDC3BE943F
Description: null
|
DSEG SEGMENT PARA PUBLIC'DSEG'
M DB 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
P DB 20 DUP(?)
N DB 20 DUP(?)
DSEG ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DSEG
START: MOV AX,DSEG
MOV DS,AX
LEA SI,P
LEA DI,N
LEA BX,M
XOR AX,AX
XOR DX,DX
MOV CX,20
L1: MOV AL,[BX]
TEST AL,80H
JZ L2
MOV [DI],AL
INC BX
INC DI
INC DH
JMP L3
L2: MOV [SI],AL
INC BX
INC SI
INC DL
L3: LOOP L1
MOV CX,2
L5: MOV BL,DL
SHR DL,1
SHR DL,1
SHR DL,1
SHR DL,1
AND DL,0FH
CMP DL,10
JB L4
ADD DL,7
L4: ADD DL,30H
MOV AH,2
INT 21H
MOV DL,BL
AND DL,0FH
CMP DL,10
JB L6
ADD DL,7
L6: ADD DL,30H
MOV AH,2
INT 21H
MOV DL,0AH
MOV AH,2
INT 21H
MOV DL,0DH
MOV AH,2
INT 21H
MOV DL,DH
LOOP L5
MOV AH,4CH
INT 21H
CODE ENDS
END START |
// Copyright (c) 2011-2018 The Karmacoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <qt/recentrequeststablemodel.h>
#include <qt/karmacoinunits.h>
#include <qt/guiutil.h>
#include <qt/optionsmodel.h>
#include <clientversion.h>
#include <streams.h>
RecentRequestsTableModel::RecentRequestsTableModel(WalletModel *parent) :
QAbstractTableModel(parent), walletModel(parent)
{
// Load entries from wallet
std::vector<std::string> vReceiveRequests;
parent->loadReceiveRequests(vReceiveRequests);
for (const std::string& request : vReceiveRequests)
addNewRequest(request);
/* These columns must match the indices in the ColumnIndex enumeration */
columns << tr("Date") << tr("Label") << tr("Message") << getAmountTitle();
connect(walletModel->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &RecentRequestsTableModel::updateDisplayUnit);
}
RecentRequestsTableModel::~RecentRequestsTableModel()
{
/* Intentionally left empty */
}
int RecentRequestsTableModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return list.length();
}
int RecentRequestsTableModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return columns.length();
}
QVariant RecentRequestsTableModel::data(const QModelIndex &index, int role) const
{
if(!index.isValid() || index.row() >= list.length())
return QVariant();
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
const RecentRequestEntry *rec = &list[index.row()];
switch(index.column())
{
case Date:
return GUIUtil::dateTimeStr(rec->date);
case Label:
if(rec->recipient.label.isEmpty() && role == Qt::DisplayRole)
{
return tr("(no label)");
}
else
{
return rec->recipient.label;
}
case Message:
if(rec->recipient.message.isEmpty() && role == Qt::DisplayRole)
{
return tr("(no message)");
}
else
{
return rec->recipient.message;
}
case Amount:
if (rec->recipient.amount == 0 && role == Qt::DisplayRole)
return tr("(no amount requested)");
else if (role == Qt::EditRole)
return KarmacoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), rec->recipient.amount, false, KarmacoinUnits::separatorNever);
else
return KarmacoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), rec->recipient.amount);
}
}
else if (role == Qt::TextAlignmentRole)
{
if (index.column() == Amount)
return (int)(Qt::AlignRight|Qt::AlignVCenter);
}
return QVariant();
}
bool RecentRequestsTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
return true;
}
QVariant RecentRequestsTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(orientation == Qt::Horizontal)
{
if(role == Qt::DisplayRole && section < columns.size())
{
return columns[section];
}
}
return QVariant();
}
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
void RecentRequestsTableModel::updateAmountColumnTitle()
{
columns[Amount] = getAmountTitle();
Q_EMIT headerDataChanged(Qt::Horizontal,Amount,Amount);
}
/** Gets title for amount column including current display unit if optionsModel reference available. */
QString RecentRequestsTableModel::getAmountTitle()
{
return (this->walletModel->getOptionsModel() != nullptr) ? tr("Requested") + " ("+KarmacoinUnits::shortName(this->walletModel->getOptionsModel()->getDisplayUnit()) + ")" : "";
}
QModelIndex RecentRequestsTableModel::index(int row, int column, const QModelIndex &parent) const
{
Q_UNUSED(parent);
return createIndex(row, column);
}
bool RecentRequestsTableModel::removeRows(int row, int count, const QModelIndex &parent)
{
Q_UNUSED(parent);
if(count > 0 && row >= 0 && (row+count) <= list.size())
{
for (int i = 0; i < count; ++i)
{
const RecentRequestEntry* rec = &list[row+i];
if (!walletModel->saveReceiveRequest(rec->recipient.address.toStdString(), rec->id, ""))
return false;
}
beginRemoveRows(parent, row, row + count - 1);
list.erase(list.begin() + row, list.begin() + row + count);
endRemoveRows();
return true;
} else {
return false;
}
}
Qt::ItemFlags RecentRequestsTableModel::flags(const QModelIndex &index) const
{
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
}
// called when adding a request from the GUI
void RecentRequestsTableModel::addNewRequest(const SendCoinsRecipient &recipient)
{
RecentRequestEntry newEntry;
newEntry.id = ++nReceiveRequestsMaxId;
newEntry.date = QDateTime::currentDateTime();
newEntry.recipient = recipient;
CDataStream ss(SER_DISK, CLIENT_VERSION);
ss << newEntry;
if (!walletModel->saveReceiveRequest(recipient.address.toStdString(), newEntry.id, ss.str()))
return;
addNewRequest(newEntry);
}
// called from ctor when loading from wallet
void RecentRequestsTableModel::addNewRequest(const std::string &recipient)
{
std::vector<char> data(recipient.begin(), recipient.end());
CDataStream ss(data, SER_DISK, CLIENT_VERSION);
RecentRequestEntry entry;
ss >> entry;
if (entry.id == 0) // should not happen
return;
if (entry.id > nReceiveRequestsMaxId)
nReceiveRequestsMaxId = entry.id;
addNewRequest(entry);
}
// actually add to table in GUI
void RecentRequestsTableModel::addNewRequest(RecentRequestEntry &recipient)
{
beginInsertRows(QModelIndex(), 0, 0);
list.prepend(recipient);
endInsertRows();
}
void RecentRequestsTableModel::sort(int column, Qt::SortOrder order)
{
qSort(list.begin(), list.end(), RecentRequestEntryLessThan(column, order));
Q_EMIT dataChanged(index(0, 0, QModelIndex()), index(list.size() - 1, NUMBER_OF_COLUMNS - 1, QModelIndex()));
}
void RecentRequestsTableModel::updateDisplayUnit()
{
updateAmountColumnTitle();
}
bool RecentRequestEntryLessThan::operator()(RecentRequestEntry &left, RecentRequestEntry &right) const
{
RecentRequestEntry *pLeft = &left;
RecentRequestEntry *pRight = &right;
if (order == Qt::DescendingOrder)
std::swap(pLeft, pRight);
switch(column)
{
case RecentRequestsTableModel::Date:
return pLeft->date.toTime_t() < pRight->date.toTime_t();
case RecentRequestsTableModel::Label:
return pLeft->recipient.label < pRight->recipient.label;
case RecentRequestsTableModel::Message:
return pLeft->recipient.message < pRight->recipient.message;
case RecentRequestsTableModel::Amount:
return pLeft->recipient.amount < pRight->recipient.amount;
default:
return pLeft->id < pRight->id;
}
}
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// 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.
#include "AmbitMode.h"
#include "EditorModeManager.h"
#include "EditorViewportClient.h"
#include "Toolkits/ToolkitManager.h"
#include "AmbitObject.h"
#include "AmbitWeather.h"
#include "AmbitWidget.h"
#include "Ambit/Utils/UserMetricsSubsystem.h"
const FEditorModeID FAmbitMode::EM_AmbitModeId = TEXT("EM_AmbitMode");
FAmbitMode* FAmbitMode::GetEditorMode()
{
return static_cast<FAmbitMode*>(GLevelEditorModeTools().GetActiveMode(EM_AmbitModeId));
}
FAmbitMode::FAmbitMode()
{
UISettings = NewObject<UAmbitObject>(GetTransientPackage(), TEXT("AmbitSettings"), RF_Transactional);
UISettings->SetParent(this);
}
FAmbitMode::~FAmbitMode() = default;
void FAmbitMode::AddReferencedObjects(FReferenceCollector& Collector)
{
// Call parent implementation
FEdMode::AddReferencedObjects(Collector);
Collector.AddReferencedObject(UISettings);
}
void FAmbitMode::Enter()
{
FEdMode::Enter();
if (!Toolkit.IsValid() && UsesToolkits())
{
// this is what instantiates the UI for Ambit's custom mode
Toolkit = MakeShareable(new FAmbitModeToolkit);
Toolkit->Init(Owner->GetToolkitHost());
}
GEngine->GetEngineSubsystem<UUserMetricsSubsystem>()->Track(UserMetrics::AmbitMode::KAmbitModeOpenEvent,
UserMetrics::AmbitMode::KAmbitModeNameSpace);
}
void FAmbitMode::Exit()
{
if (Toolkit.IsValid())
{
FToolkitManager::Get().CloseToolkit(Toolkit.ToSharedRef());
Toolkit.Reset();
}
// Call base Exit method to ensure proper cleanup
FEdMode::Exit();
GEngine->GetEngineSubsystem<UUserMetricsSubsystem>()->Track(UserMetrics::AmbitMode::KAmbitModeCloseEvent,
UserMetrics::AmbitMode::KAmbitModeNameSpace);
}
void FAmbitMode::Tick(FEditorViewportClient* ViewportClient, float DeltaTime)
{
FEdMode::Tick(ViewportClient, DeltaTime);
for (TObjectIterator<AAmbitWeather> It; It; ++It)
{
AAmbitWeather* Weather = Cast<AAmbitWeather>(*It);
if (Weather != nullptr)
{
Weather->ApplyTimeOfDay(UISettings->TimeOfDay);
Weather->ApplyWeather(UISettings->WeatherParameters);
if (UISettings->TimeOfDay != TimeOfDay::KDefaultMorningSolarTime && UISettings->TimeOfDay !=
TimeOfDay::KDefaultMidDaySolarTime && UISettings->TimeOfDay != TimeOfDay::KDefaultEveningSolarTime &&
UISettings->TimeOfDay != TimeOfDay::KDefaultNightSolarTime)
{
UISettings->PresetTimeOfDay = TimeOfDay::KCustom;
}
UISettings->PresetWeather = AmbitWeatherParameters::GetWeatherType(UISettings->WeatherParameters);
}
}
}
void FAmbitMode::Render(const FSceneView* View, FViewport* Viewport, FPrimitiveDrawInterface* PDI)
{
FEdMode::Render(View, Viewport, PDI);
}
bool FAmbitMode::UsesToolkits() const
{
return true;
}
|
// Copyright (c) 2014-2016 The Dash developers
// Copyright (c) 2016-2017 The PIVX developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "spork.h"
#include "base58.h"
#include "key.h"
#include "main.h"
#include "masternode-budget.h"
#include "net.h"
#include "protocol.h"
#include "sync.h"
#include "sporkdb.h"
#include "util.h"
#include <boost/lexical_cast.hpp>
using namespace std;
using namespace boost;
class CSporkMessage;
class CSporkManager;
CSporkManager sporkManager;
std::map<uint256, CSporkMessage> mapSporks;
std::map<int, CSporkMessage> mapSporksActive;
// ViBOOK: on startup load spork values from previous session if they exist in the sporkDB
void LoadSporksFromDB()
{
for (int i = SPORK_START; i <= SPORK_END; ++i) {
// Since not all spork IDs are in use, we have to exclude undefined IDs
std::string strSpork = sporkManager.GetSporkNameByID(i);
if (strSpork == "Unknown") continue;
// attempt to read spork from sporkDB
CSporkMessage spork;
if (!pSporkDB->ReadSpork(i, spork)) {
LogPrintf("%s : no previous value for %s found in database\n", __func__, strSpork);
continue;
}
// add spork to memory
mapSporks[spork.GetHash()] = spork;
mapSporksActive[spork.nSporkID] = spork;
std::time_t result = spork.nValue;
// If SPORK Value is greater than 1,000,000 assume it's actually a Date and then convert to a more readable format
if (spork.nValue > 1000000) {
LogPrintf("%s : loaded spork %s with value %d : %s", __func__,
sporkManager.GetSporkNameByID(spork.nSporkID), spork.nValue,
std::ctime(&result));
} else {
LogPrintf("%s : loaded spork %s with value %d\n", __func__,
sporkManager.GetSporkNameByID(spork.nSporkID), spork.nValue);
}
}
}
void ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
{
if (fLiteMode) return; //disable all obfuscation/masternode related functionality
if (strCommand == "spork") {
//LogPrintf("ProcessSpork::spork\n");
CDataStream vMsg(vRecv);
CSporkMessage spork;
vRecv >> spork;
if (chainActive.Tip() == NULL) return;
// Ignore spork messages about unknown/deleted sporks
std::string strSpork = sporkManager.GetSporkNameByID(spork.nSporkID);
if (strSpork == "Unknown") return;
uint256 hash = spork.GetHash();
if (mapSporksActive.count(spork.nSporkID)) {
if (mapSporksActive[spork.nSporkID].nTimeSigned >= spork.nTimeSigned) {
if (fDebug) LogPrintf("spork - seen %s block %d \n", hash.ToString(), chainActive.Tip()->nHeight);
return;
} else {
if (fDebug) LogPrintf("spork - got updated spork %s block %d \n", hash.ToString(), chainActive.Tip()->nHeight);
}
}
LogPrintf("spork - new %s ID %d Time %d bestHeight %d\n", hash.ToString(), spork.nSporkID, spork.nValue, chainActive.Tip()->nHeight);
if (!sporkManager.CheckSignature(spork)) {
LogPrintf("spork - invalid signature\n");
Misbehaving(pfrom->GetId(), 100);
return;
}
mapSporks[hash] = spork;
mapSporksActive[spork.nSporkID] = spork;
sporkManager.Relay(spork);
// ViBOOK: add to spork database.
pSporkDB->WriteSpork(spork.nSporkID, spork);
}
if (strCommand == "getsporks") {
std::map<int, CSporkMessage>::iterator it = mapSporksActive.begin();
while (it != mapSporksActive.end()) {
pfrom->PushMessage("spork", it->second);
it++;
}
}
}
// grab the value of the spork on the network, or the default
int64_t GetSporkValue(int nSporkID)
{
int64_t r = -1;
if (mapSporksActive.count(nSporkID)) {
r = mapSporksActive[nSporkID].nValue;
} else {
if (nSporkID == SPORK_2_SWIFTTX) r = SPORK_2_SWIFTTX_DEFAULT;
if (nSporkID == SPORK_3_SWIFTTX_BLOCK_FILTERING) r = SPORK_3_SWIFTTX_BLOCK_FILTERING_DEFAULT;
if (nSporkID == SPORK_5_MAX_VALUE) r = SPORK_5_MAX_VALUE_DEFAULT;
if (nSporkID == SPORK_7_MASTERNODE_SCANNING) r = SPORK_7_MASTERNODE_SCANNING_DEFAULT;
if (nSporkID == SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT) r = SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT;
if (nSporkID == SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT) r = SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT_DEFAULT;
if (nSporkID == SPORK_10_MASTERNODE_PAY_UPDATED_NODES) r = SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT;
if (nSporkID == SPORK_11_LOCK_INVALID_UTXO) r = SPORK_11_LOCK_INVALID_UTXO_DEFAULT;
if (nSporkID == SPORK_13_ENABLE_SUPERBLOCKS) r = SPORK_13_ENABLE_SUPERBLOCKS_DEFAULT;
if (nSporkID == SPORK_14_NEW_PROTOCOL_ENFORCEMENT) r = SPORK_14_NEW_PROTOCOL_ENFORCEMENT_DEFAULT;
if (nSporkID == SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) r = SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2_DEFAULT;
if (nSporkID == SPORK_16_ZEROCOIN_MAINTENANCE_MODE) r = SPORK_16_ZEROCOIN_MAINTENANCE_MODE_DEFAULT;
if (r == -1) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID);
}
return r;
}
// grab the spork value, and see if it's off
bool IsSporkActive(int nSporkID)
{
int64_t r = GetSporkValue(nSporkID);
if (r == -1) return false;
return r < GetTime();
}
void ReprocessBlocks(int nBlocks)
{
std::map<uint256, int64_t>::iterator it = mapRejectedBlocks.begin();
while (it != mapRejectedBlocks.end()) {
//use a window twice as large as is usual for the nBlocks we want to reset
if ((*it).second > GetTime() - (nBlocks * 60 * 5)) {
BlockMap::iterator mi = mapBlockIndex.find((*it).first);
if (mi != mapBlockIndex.end() && (*mi).second) {
LOCK(cs_main);
CBlockIndex* pindex = (*mi).second;
LogPrintf("ReprocessBlocks - %s\n", (*it).first.ToString());
CValidationState state;
ReconsiderBlock(state, pindex);
}
}
++it;
}
CValidationState state;
{
LOCK(cs_main);
DisconnectBlocksAndReprocess(nBlocks);
}
if (state.IsValid()) {
ActivateBestChain(state);
}
}
bool CSporkManager::CheckSignature(CSporkMessage& spork)
{
//note: need to investigate why this is failing
std::string strMessage = boost::lexical_cast<std::string>(spork.nSporkID) + boost::lexical_cast<std::string>(spork.nValue) + boost::lexical_cast<std::string>(spork.nTimeSigned);
CPubKey pubkeynew(ParseHex(Params().SporkKey()));
std::string errorMessage = "";
if (obfuScationSigner.VerifyMessage(pubkeynew, spork.vchSig, strMessage, errorMessage)) {
return true;
}
return false;
}
bool CSporkManager::Sign(CSporkMessage& spork)
{
std::string strMessage = boost::lexical_cast<std::string>(spork.nSporkID) + boost::lexical_cast<std::string>(spork.nValue) + boost::lexical_cast<std::string>(spork.nTimeSigned);
CKey key2;
CPubKey pubkey2;
std::string errorMessage = "";
if (!obfuScationSigner.SetKey(strMasterPrivKey, errorMessage, key2, pubkey2)) {
LogPrintf("CMasternodePayments::Sign - ERROR: Invalid masternodeprivkey: '%s'\n", errorMessage);
return false;
}
if (!obfuScationSigner.SignMessage(strMessage, errorMessage, spork.vchSig, key2)) {
LogPrintf("CMasternodePayments::Sign - Sign message failed");
return false;
}
if (!obfuScationSigner.VerifyMessage(pubkey2, spork.vchSig, strMessage, errorMessage)) {
LogPrintf("CMasternodePayments::Sign - Verify message failed");
return false;
}
return true;
}
bool CSporkManager::UpdateSpork(int nSporkID, int64_t nValue)
{
CSporkMessage msg;
msg.nSporkID = nSporkID;
msg.nValue = nValue;
msg.nTimeSigned = GetTime();
if (Sign(msg)) {
Relay(msg);
mapSporks[msg.GetHash()] = msg;
mapSporksActive[nSporkID] = msg;
return true;
}
return false;
}
void CSporkManager::Relay(CSporkMessage& msg)
{
CInv inv(MSG_SPORK, msg.GetHash());
RelayInv(inv);
}
bool CSporkManager::SetPrivKey(std::string strPrivKey)
{
CSporkMessage msg;
// Test signing successful, proceed
strMasterPrivKey = strPrivKey;
Sign(msg);
if (CheckSignature(msg)) {
LogPrintf("CSporkManager::SetPrivKey - Successfully initialized as spork signer\n");
return true;
} else {
return false;
}
}
int CSporkManager::GetSporkIDByName(std::string strName)
{
if (strName == "SPORK_2_SWIFTTX") return SPORK_2_SWIFTTX;
if (strName == "SPORK_3_SWIFTTX_BLOCK_FILTERING") return SPORK_3_SWIFTTX_BLOCK_FILTERING;
if (strName == "SPORK_5_MAX_VALUE") return SPORK_5_MAX_VALUE;
if (strName == "SPORK_7_MASTERNODE_SCANNING") return SPORK_7_MASTERNODE_SCANNING;
if (strName == "SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT") return SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT;
if (strName == "SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT") return SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT;
if (strName == "SPORK_10_MASTERNODE_PAY_UPDATED_NODES") return SPORK_10_MASTERNODE_PAY_UPDATED_NODES;
if (strName == "SPORK_11_LOCK_INVALID_UTXO") return SPORK_11_LOCK_INVALID_UTXO;
if (strName == "SPORK_13_ENABLE_SUPERBLOCKS") return SPORK_13_ENABLE_SUPERBLOCKS;
if (strName == "SPORK_14_NEW_PROTOCOL_ENFORCEMENT") return SPORK_14_NEW_PROTOCOL_ENFORCEMENT;
if (strName == "SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2") return SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2;
if (strName == "SPORK_16_ZEROCOIN_MAINTENANCE_MODE") return SPORK_16_ZEROCOIN_MAINTENANCE_MODE;
return -1;
}
std::string CSporkManager::GetSporkNameByID(int id)
{
if (id == SPORK_2_SWIFTTX) return "SPORK_2_SWIFTTX";
if (id == SPORK_3_SWIFTTX_BLOCK_FILTERING) return "SPORK_3_SWIFTTX_BLOCK_FILTERING";
if (id == SPORK_5_MAX_VALUE) return "SPORK_5_MAX_VALUE";
if (id == SPORK_7_MASTERNODE_SCANNING) return "SPORK_7_MASTERNODE_SCANNING";
if (id == SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT) return "SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT";
if (id == SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT) return "SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT";
if (id == SPORK_10_MASTERNODE_PAY_UPDATED_NODES) return "SPORK_10_MASTERNODE_PAY_UPDATED_NODES";
if (id == SPORK_11_LOCK_INVALID_UTXO) return "SPORK_11_LOCK_INVALID_UTXO";
if (id == SPORK_13_ENABLE_SUPERBLOCKS) return "SPORK_13_ENABLE_SUPERBLOCKS";
if (id == SPORK_14_NEW_PROTOCOL_ENFORCEMENT) return "SPORK_14_NEW_PROTOCOL_ENFORCEMENT";
if (id == SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) return "SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2";
if (id == SPORK_16_ZEROCOIN_MAINTENANCE_MODE) return "SPORK_16_ZEROCOIN_MAINTENANCE_MODE";
return "Unknown";
}
|
// Generated code. Do not edit
// Create the model
Model createTestModel() {
const std::vector<Operand> operands = {
{
.type = OperandType::TENSOR_QUANT8_ASYMM,
.dimensions = {1, 4, 2, 1},
.numberOfConsumers = 1,
.scale = 1.0f,
.zeroPoint = 0,
.lifetime = OperandLifeTime::MODEL_INPUT,
.location = {.poolIndex = 0, .offset = 0, .length = 0},
},
{
.type = OperandType::TENSOR_INT32,
.dimensions = {2},
.numberOfConsumers = 1,
.scale = 0.0f,
.zeroPoint = 0,
.lifetime = OperandLifeTime::CONSTANT_COPY,
.location = {.poolIndex = 0, .offset = 0, .length = 8},
},
{
.type = OperandType::TENSOR_INT32,
.dimensions = {2, 2},
.numberOfConsumers = 1,
.scale = 0.0f,
.zeroPoint = 0,
.lifetime = OperandLifeTime::CONSTANT_COPY,
.location = {.poolIndex = 0, .offset = 8, .length = 16},
},
{
.type = OperandType::TENSOR_QUANT8_ASYMM,
.dimensions = {6, 2, 4, 1},
.numberOfConsumers = 0,
.scale = 1.0f,
.zeroPoint = 0,
.lifetime = OperandLifeTime::MODEL_OUTPUT,
.location = {.poolIndex = 0, .offset = 0, .length = 0},
}
};
const std::vector<Operation> operations = {
{
.type = OperationType::SPACE_TO_BATCH_ND,
.inputs = {0, 1, 2},
.outputs = {3},
}
};
const std::vector<uint32_t> inputIndexes = {0};
const std::vector<uint32_t> outputIndexes = {3};
std::vector<uint8_t> operandValues = {
3, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0
};
const std::vector<hidl_memory> pools = {};
return {
.operands = operands,
.operations = operations,
.inputIndexes = inputIndexes,
.outputIndexes = outputIndexes,
.operandValues = operandValues,
.pools = pools,
};
}
bool is_ignored(int i) {
static std::set<int> ignore = {};
return ignore.find(i) != ignore.end();
}
|
; BSS intro
%macro println 0
mov rax,0x01
mov rdi,0x01
mov rsi,0x0a
mov rdx,0x01
syscall
%endmacro
global _start
section .data
msg10 db "Enter Your name : ",0x00
len10 equ $-msg10
msg20 db "Enter Your group : ",0x00
len20 equ $-msg20
msg30 db "Enter Your age : ",0x00
len30 equ $-msg30
msg1 db "Your name : ",0x00
len1 equ $-msg1
msg2 db "Your group is : ",0x00
len2 equ $-msg2
msg3 db "Your age is : ",0x00
len3 equ $-msg3
section .bss
name resb 18
group resb 16
age resb 4
section .data
section .text
_start:
push len10
push msg10
call print
push 0x018
push name
call frominput
println
push len20
push msg20
call print
push 0x016
push group
call frominput
println
push len30
push msg30
call print
push 0x018
push age
call frominput
println
push len1
push msg1
call print
push len1
push name
call print
println
push len2
push msg2
call print
push len2
push group
call print
println
push len3
push msg3
call print
push len3
push age
call print
println
;exit
mov rax,0x03c
mov rdi,0x00
syscall
print:
push rbp
mov rbp,rsp
mov rax,0x01
mov rdi,0x01
mov rsi,QWORD [rbp+16]
mov rdx,QWORD [rbp+24]
syscall
leave
ret
frominput:
push rbp
mov rbp,rsp
mov rax,0x00
mov rdi,0x00
mov rsi,QWORD [rbp+16]
mov rdx,QWORD [rbp+24]
syscall
mov rax,rsi
leave
ret
|
.include "m8def.inc"
.macro OutTo
ldi R16,@1
out @0,R16
.endm
.macro WriteRAM
STS @0,@1
.endm
.macro WriteRAMConst
LDI R16,@1
STS @0,R16
.endm
.macro ReadRAMTo
LDS @0,@1
.endm
.equ SegmentPort=PortD
.equ ButtonStart=PinB0
.equ ButtonStop=PinB1
.equ ButtonDecMin=PinB2
.equ ButtonIncMin=PinB3
.equ Rele=PB4
.equ Beeper=PB5
.equ Cathode1=PB6
.equ Cathode2=PB7
.def SystemSettings=R29
.equ BeepEnable=1
.dseg
Digit: .byte 2
Count: .byte 1
.cseg
.org 0
//--------------Interrupt vector---------------------------
RJMP StartProgram ; Reset Handler
reti;rjmp EXT_INT0 ; IRQ0 Handler
reti;rjmp EXT_INT1 ; IRQ1 Handler
reti;rjmp TIM2_COMP ; Timer2 Compare Handler
reti;rjmp TIM2_OVF ; Timer2 Overflow Handler
reti;rjmp TIM1_CAPT ; Timer1 Capture Handler
reti;rjmp TIM1_COMPA ; Timer1 Compare A Handler
reti;rjmp TIM1_COMPB ; Timer1 Compare B Handler
RJMP OnTimer1 ; Timer1 Overflow Handler
RJMP OnTimer0 ; Timer0 Overflow Handler
reti;rjmp SPI_STC ; SPI Transfer Complete Handler
reti;rjmp USART_RXC ; USART RX Complete Handler
reti;rjmp USART_UDRE ; UDR Empty Handler
reti;rjmp USART_TXC ; USART TX Complete Handler
reti;rjmp ADC_ ; ADC Conversion Complete Handler
reti;rjmp EE_RDY ; EEPROM Ready Handler
reti;rjmp ANA_COMP ; Analog Comparator Handler
reti;rjmp TWSI ; Two-wire Serial Interface Handler
reti;rjmp SPM_RDY ;0b11101000
//-----------------------------------------------------------
StartProgram:
;-----Init Stack-----
OutTo SPL,Low (RAMEND)
OutTo SPH,High(RAMEND)
;---Init I/O Ports----
OutTo DDRD, 0b11111111
OutTo DDRB, 0b11110000
OutTo PORTB,0b00001111
OutTo TIMSK,0b00000001
OutTo TCCR0,0b00000101
OutTo TCCR1B,0b00000100
;---------------------
CLR R16
STS Digit,R16
STS Digit+1,R16
STS Count,R16
CLR R27
CLR R28
CLR R29
;---------------------
SEI
Main:
SBRC SystemSettings,0
SBI PORTB,Beeper
//Out digit to Segment1
OutTo SegmentPort,0
CBI PortB,Cathode1
LDS R19,Digit
RCALL Decoder
RCALL Delay
SBI PortB,Cathode1
//---------------------
SBRC SystemSettings,0
CBI PORTB,Beeper
//Out digit to Segment1
OutTo SegmentPort,0
CBI PortB,Cathode2
LDS R19,Digit+1
RCALL Decoder
RCALL Delay
SBI PortB,Cathode2
//---------------------
rjmp Main
OnTimer0:
ReadRAMTo R16,Count
INC R16
WriteRAM Count,R16
CPI R16,0x10
BRNE OutInterrupt
SBRC R28,0
RCALL IncBeepTime
SBIS PINB,ButtonStop
rcall OnClickStop
SBIS PINB,ButtonStart
rcall OnClickStart
SBIS PINB,ButtonIncMin
rcall OnClickIncMin
SBIS PINB,ButtonDecMin
rcall OnClickDecMin
WriteRAMConst Count,0
OutInterrupt:
RETI
IncBeepTime:
COM SystemSettings
INC R27
CPI R27,60
BRNE OutModule
CLR R27
CLR R28
CLR R29
CBI PORTB,Beeper
OutModule:
RET
OnTimer1:
OutTo TCNT1L,0xEE
OutTo TCNT1H,0x85
INC R27
CPI R27,60
BRNE OutInterrupt
CLR R27
ReadRAMTo R16,Digit+1
DEC R16
WriteRAM Digit+1,R16
RCALL NormalizeDigit
ReadRAMTo R16,Digit+1
ReadRAMTo R17,Digit
ADD R16,R17
CPI R16,0
BRNE OutInterrupt
OutTo TIMSK,0b00000001
CBI PORTB,Rele
LDI SystemSettings,BeepEnable
LDI R28,1
RETI
OnClickStart:
ReadRAMTo R16,Digit+1
ReadRAMTo R17,Digit
ADD R16,R17
CPI R16,0
BREQ OutInterrupt
OutTo TIMSK,0b00000101
SBI PORTB,Rele
RET
OnClickStop:
CBI PORTB,Beeper
SBRC SystemSettings,0
CLR SystemSettings
SBRC R28,0
CLR R28
CBI PORTB,Rele
IN R16,TIMSK
SBRC R16,TOIE1
RCALL ResetTime
OutTo TIMSK,0b00000001
RET
ResetTime:
WriteRamConst Digit,0
WriteRamConst Digit+1,0
RET
OnClickIncMin:
IN R16,TIMSK
SBRC R16,TOIE1
RET
LDS R16,Digit+1
INC R16
STS Digit+1,R16
RCALL NormalizeDigit
RET
OnClickDecMin:
IN R16,TIMSK
SBRC R16,TOIE1
RET
LDS R16,Digit+1
DEC R16
STS Digit+1,R16
RCALL NormalizeDigit
RET
Decoder:
LDI ZL,Low(DcMatrix*2)
LDI ZH,High(DcMatrix*2)
ADD ZL,R19
LPM
MOV R19,R0
OUT SegmentPort,R19
RET
Delay:
LDI R30, $FF
WGLOOP4:
LDI R31, $15
WGLOOP5:
DEC R31
BRNE WGLOOP5
DEC R30
BRNE WGLOOP4
RET
DcMatrix:
.DB 0b00111111,0b00000110 ;0,1
.DB 0b01011011,0b01001111 ;2,3
.DB 0b01100110,0b01101101 ;4,5
.DB 0b01111101,0b00000111 ;6,7
.DB 0b01111111,0b01101111 ;8,9
NormalizeDigit:
ReadRAMTo R16,Digit+1
ReadRAMTo R17,Digit
CPI R16,255
BREQ DecTens
CPI R16,10
BREQ IncTens
RJMP ExitModule
DecTens:
DEC R17
LDI R16,9
CPI R17,255
BRNE ExitModule
LDI R17,0
LDI R16,0
RJMP ExitModule
IncTens:
INC R17
LDI R16,0
CPI R17,10
BRNE ExitModule
LDI R17,9
LDI R16,9
RJMP ExitModule
ExitModule:
STS Digit,R17
STS Digit+1,R16
RET
|
// Font generated by stb_font_inl_generator.c (4/1 bpp)
//
// Following instructions show how to use the only included font, whatever it is, in
// a generic way so you can replace it with any other font by changing the include.
// To use multiple fonts, replace STB_SOMEFONT_* below with STB_FONT_arial_bold_17_latin1_*,
// and separately install each font. Note that the CREATE function call has a
// totally different name; it's just 'stb_font_arial_bold_17_latin1'.
//
/* // Example usage:
static stb_fontchar fontdata[STB_SOMEFONT_NUM_CHARS];
static void init(void)
{
// optionally replace both STB_SOMEFONT_BITMAP_HEIGHT with STB_SOMEFONT_BITMAP_HEIGHT_POW2
static unsigned char fontpixels[STB_SOMEFONT_BITMAP_HEIGHT][STB_SOMEFONT_BITMAP_WIDTH];
STB_SOMEFONT_CREATE(fontdata, fontpixels, STB_SOMEFONT_BITMAP_HEIGHT);
... create texture ...
// for best results rendering 1:1 pixels texels, use nearest-neighbor sampling
// if allowed to scale up, use bilerp
}
// This function positions characters on integer coordinates, and assumes 1:1 texels to pixels
// Appropriate if nearest-neighbor sampling is used
static void draw_string_integer(int x, int y, char *str) // draw with top-left point x,y
{
... use texture ...
... turn on alpha blending and gamma-correct alpha blending ...
glBegin(GL_QUADS);
while (*str) {
int char_codepoint = *str++;
stb_fontchar *cd = &fontdata[char_codepoint - STB_SOMEFONT_FIRST_CHAR];
glTexCoord2f(cd->s0, cd->t0); glVertex2i(x + cd->x0, y + cd->y0);
glTexCoord2f(cd->s1, cd->t0); glVertex2i(x + cd->x1, y + cd->y0);
glTexCoord2f(cd->s1, cd->t1); glVertex2i(x + cd->x1, y + cd->y1);
glTexCoord2f(cd->s0, cd->t1); glVertex2i(x + cd->x0, y + cd->y1);
// if bilerping, in D3D9 you'll need a half-pixel offset here for 1:1 to behave correct
x += cd->advance_int;
}
glEnd();
}
// This function positions characters on float coordinates, and doesn't require 1:1 texels to pixels
// Appropriate if bilinear filtering is used
static void draw_string_float(float x, float y, char *str) // draw with top-left point x,y
{
... use texture ...
... turn on alpha blending and gamma-correct alpha blending ...
glBegin(GL_QUADS);
while (*str) {
int char_codepoint = *str++;
stb_fontchar *cd = &fontdata[char_codepoint - STB_SOMEFONT_FIRST_CHAR];
glTexCoord2f(cd->s0f, cd->t0f); glVertex2f(x + cd->x0f, y + cd->y0f);
glTexCoord2f(cd->s1f, cd->t0f); glVertex2f(x + cd->x1f, y + cd->y0f);
glTexCoord2f(cd->s1f, cd->t1f); glVertex2f(x + cd->x1f, y + cd->y1f);
glTexCoord2f(cd->s0f, cd->t1f); glVertex2f(x + cd->x0f, y + cd->y1f);
// if bilerping, in D3D9 you'll need a half-pixel offset here for 1:1 to behave correct
x += cd->advance;
}
glEnd();
}
*/
#ifndef STB_FONTCHAR__TYPEDEF
#define STB_FONTCHAR__TYPEDEF
typedef struct
{
// coordinates if using integer positioning
float s0,t0,s1,t1;
signed short x0,y0,x1,y1;
int advance_int;
// coordinates if using floating positioning
float s0f,t0f,s1f,t1f;
float x0f,y0f,x1f,y1f;
float advance;
} stb_fontchar;
#endif
#define STB_FONT_arial_bold_17_latin1_BITMAP_WIDTH 256
#define STB_FONT_arial_bold_17_latin1_BITMAP_HEIGHT 96
#define STB_FONT_arial_bold_17_latin1_BITMAP_HEIGHT_POW2 128
#define STB_FONT_arial_bold_17_latin1_FIRST_CHAR 32
#define STB_FONT_arial_bold_17_latin1_NUM_CHARS 224
#define STB_FONT_arial_bold_17_latin1_LINE_SPACING 11
static unsigned int stb__arial_bold_17_latin1_pixels[]={
0x00000000,0x00000000,0xa8000000,0x00ed8551,0x1db13bb6,0x50003b60,
0x37a6007d,0x02615000,0x802a6530,0x1bb004ea,0x7641f5c0,0x7776dc5e,
0x5c0001ee,0x8bf9802e,0xcfec885f,0x981df100,0x705f101f,0x7d817dfd,
0x9bffb730,0xd9ff4403,0x3e01bf97,0x00ff8fd5,0x1ff13bfa,0xd0013e20,
0x3f7a200b,0xfeffc804,0x7dc7e400,0x2007e401,0x37e602fb,0x73ff642f,
0x5fffffff,0x3600bb20,0xe8ae9806,0x6fcdfc84,0x17a01d90,0x77ff43ec,
0x21f61fff,0xebaacefb,0x25dfb02f,0x209fd77d,0x0ff8551a,0x98001fa0,
0x002a2002,0x0054c544,0x2006a22e,0x50015329,0x5401a801,0xe9fe0552,
0x03f9dfff,0x2a201636,0x5fd00000,0x802202ee,0x227cc1fc,0xdfb12efb,
0x807ee3ec,0x6c7e82fa,0x3db17e67,0xd5ff4ea8,0xd83f419f,0xeffeb80e,
0x77ff5c03,0x77ff5c03,0x77ff5c03,0x77ff5c03,0x7541ed83,0x4ea83db4,
0x44ea83db,0x37fffa7f,0x17fa03f9,0x7777776c,0xd117640e,0xc82ffb8b,
0xf317a22e,0x7fc1fc89,0x4fb0dc43,0x95dd72fb,0x8fd0d93d,0xfd1be27d,
0xfff5fa83,0x83f4dfdb,0x7fff40ff,0xffd05fff,0x3a0bffff,0x05ffffff,
0xbffffffd,0x3fffffa0,0x2a0ff45f,0xfa83fd5f,0x5fa83fd5,0xbfff73fc,
0x3fe607f3,0xffffe80f,0x2fd40fff,0xfffd8bf5,0xfa97ea0d,0x07ec6f85,
0xfb003ff1,0xeadfb9f4,0x7c0f88ff,0xd1be3ec7,0xff5fa83f,0x07e8ff47,
0x977e41ff,0x7e42ffb8,0x85ff712e,0xff712efc,0x712efc85,0x2efc85ff,
0x7f45ff71,0x1feafd41,0x41feafd4,0x913fc5fa,0x207f3bff,0xfe83fffc,
0x6c3fe001,0x3eafea2f,0x6c3fe0ef,0x3fc7e82f,0xae401fe6,0x7d4df1f8,
0x45f98be6,0xfd0ff47d,0x3ff5fa83,0xf07ea7dc,0x641ffc1f,0x641ffc6f,
0x641ffc6f,0x641ffc6f,0x641ffc6f,0xf507fa6f,0xbf507fab,0x8bf507fa,
0xf9df887f,0x6faff883,0x32001fe8,0x7dc7f8bf,0x7e4bfd15,0x3fb07f8b,
0x1ff11be2,0x5f57a800,0x70f8a7cc,0x547d83ff,0xa83fd2ff,0x7dc3ff5f,
0x43fe0fd4,0x7fa81ff8,0x3ea07fe2,0x2a07fe27,0x207fe27f,0x07fe27fa,
0x41fe9fea,0xa83fd5fa,0xfa83fd5f,0x6fc43fc5,0xd5fb83f9,0xccdfe85f,
0x5bf303cc,0x23ff989f,0x3eb7e66f,0x3e23fb04,0x7441ff86,0x87f2d703,
0x7e4b73fb,0x3e63ec1e,0xfa83fd2f,0x8fec7ff5,0x261ff07e,0x21ff107f,
0x1ff107f9,0x7fc41fe6,0x3e20ff30,0x220ff30f,0xa83fd0ff,0xfa83fd5f,
0x5fa83fd5,0x4efc43fc,0xf92fe83f,0xfffffe8b,0x3fbfa05f,0xfaeffa81,
0x80ff7f44,0x7e437c7e,0x4a97f61e,0x745f71f3,0x7dc2f99f,0x87fa3ec5,
0xfafdc1fe,0x3a7fddff,0x3e61ff07,0x30ffa81f,0x1ff503ff,0x3ea07fe6,
0x503ff30f,0x07fe61ff,0x0ff43fea,0x20ff57ee,0xb83fd5fb,0x7c43fc5f,
0x7fcc3f9d,0x3a0ffcab,0x009999bf,0xe981bfee,0x6ffb86ff,0x10fd1be0,
0x1fffdffd,0xdf15f3ec,0x0bfbffb7,0x6f8fb1be,0x53ee17ec,0x21cffbff,
0x7c1ff07e,0x7c7fc83f,0x7c7fc83f,0x7c7fc83f,0x7c7fc83f,0x367fc83f,
0xfda7dc2f,0x2fda7dc2,0x21fe27dc,0x643f9df8,0x3fffffff,0xf10007fa,
0x1ff9007f,0xf103ff88,0xc881fc89,0x3ec1cfff,0x32bb6abb,0x7f8113df,
0xd8bf13ec,0xffa7f45f,0x3e0fd010,0xf5177e47,0x22efc87f,0x77e43ffa,
0xf90ffea2,0x21ffd45d,0x3fea2efc,0x9fd17f63,0x29fd17f6,0x227f45fd,
0xf9df887f,0x66667fc3,0x007fa6fd,0x3201ff10,0xff10bf64,0xf107ea01,
0x40676407,0x003ba27d,0x6c7e83f9,0xff317e27,0x3e1fffbf,0x4f3fa00f,
0x7f447fea,0x886fffef,0x6fffeffe,0xffeffe88,0xeffe886f,0xfe886fff,
0x4c6fffef,0x0fffdfff,0xfffbfff3,0x3f7ffe61,0x0ff950ff,0x547f3bf1,
0xd2ff886f,0x3ddddddf,0x205feb98,0x30ffbdfc,0x2ec0bfd7,0x82f806d8,
0x5e7f447d,0x81feca99,0x2afb2dfd,0xffea84fd,0x803fe1ef,0x5ff95ffe,
0x13ffff20,0x09ffff90,0x04ffffc8,0x027fffe4,0x413ffff2,0x41efffea,
0x41efffea,0x21efffea,0xdf887ffd,0x40ff63f9,0xffffd5fc,0xff985fff,
0x3ff2200e,0x03bfe62e,0x1f980fc4,0xfb05eea8,0xdffdb710,0x3fe6017b,
0x03bf2fb3,0x30000030,0x10002200,0x00088001,0x02200044,0x00300180,
0x00000006,0x00980000,0x40098040,0x0004c018,0x00880188,0x11188440,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00049800,0x20076c40,0x115105e8,0x805d9035,0x04ea8048,
0x275413a6,0x1a8176c0,0x51288055,0x2207d900,0x2288350a,0x000dd802,
0x00800000,0x00000000,0x7dc40000,0xffd701df,0x3776c07d,0x7d403f20,
0x6e884f8a,0x77402540,0xc803b600,0x3f7f200f,0x06fa7c40,0x20277ffc,
0xfa81fdfa,0x7ff44f8b,0x017d406e,0x309f17f5,0x7f5c07ff,0x880fb9ce,
0x03fc80ef,0x2e05bfd9,0x077c403f,0x3bf20fb8,0xfffe86ff,0x8a885fff,
0x806a00a8,0x101a88a8,0x4401d805,0x4005400a,0x2a26a01a,0x40551a81,
0xa8015338,0x21510351,0x00a8a41a,0x2ba600cc,0xfbde83e8,0xfffffe81,
0x01d903ff,0x677dc36c,0x701f207f,0x3e36c01f,0x321ccdae,0x7ff712ef,
0x7777776c,0xdddddb0e,0x3bbb61dd,0x76c0eeee,0x41ffed41,0x44eb85ec,
0x13b601ed,0x76c03db0,0x009db004,0x3db013b6,0x13a61f6c,0x2000276c,
0xfc813098,0x40ffee2e,0xfd818008,0x00c03fd1,0xf89f0022,0x07ff05ae,
0x7fff4df9,0xffd0ffff,0x3a1fffff,0x0fffffff,0xdff70ffc,0x2ff887ff,
0x3ff07fe6,0x803ffe60,0xfff301ff,0x0fff9801,0x007ffcc0,0x07ff43ff,
0xfff30bf3,0x05f75401,0x3e05f754,0x1bfbe23f,0x2a02fbaa,0x23fa0bee,
0xfed886f9,0x77f6c43e,0x7ec2f883,0x0ffc40ef,0x03fd3fd4,0x7f401fe8,
0x743ff001,0xb83dcc8f,0x3e13f66f,0x7fff901f,0xfc80ffc0,0x7fe403ff,
0x7ffe403f,0xfe87fe03,0x3217e65f,0xdf903fff,0x77e41ffb,0x3ff10ffd,
0x91fe7ba2,0x641ffbdf,0xff0ffdef,0xbfb07f91,0x6fec3ff9,0x07d41ffc,
0x993fff22,0x21ff107f,0x0ff401fe,0x7c007fa0,0x03adf11f,0x1ff59fd0,
0xff103ff0,0x0ffc0df5,0x037d7fc4,0x40df5ff1,0x206faff8,0x3fffa1ff,
0xff88bf32,0x5cff06fa,0x4fb9fe4f,0x44774ff3,0xfb9fe0ff,0xf4fb9fe4,
0x550bf91f,0x645517e4,0xd503642f,0x07fe65ff,0xcdfe9fe2,0x37fa3ccc,
0x3fa3cccc,0xf83ccccd,0x0b3df31f,0x05fdff30,0x57ee07fe,0x03ff02fe,
0x40bfabf7,0x205fd5fb,0x205fd5fb,0x3f3fa1ff,0x5fb8bf36,0xcef985fd,
0x9df35fdc,0x3fe2bfb9,0x1ff50fd8,0x3f733be6,0xfb99df35,0x3fa23feb,
0x3ffeca84,0x21fff654,0x9da8984e,0x9c4ffe5f,0x3fffa6fb,0x3ffa5fff,
0x3fa5ffff,0xf85fffff,0x26f7fe1f,0x17ff205f,0x2fe81ff8,0x07fe0bf9,
0x82fe4bfa,0x20bf92fe,0x20bf92fe,0x3a3fa1ff,0x7f45f9cf,0xefa8bf92,
0xdf53cccc,0x7ec79999,0xa9ff21fe,0x53ccccef,0x279999df,0x25ff30ff,
0x3fcbdfe8,0x7f97bfd1,0x37e617c4,0x3f23f9da,0x3ffefa9e,0x26666ffa,
0x2666ffa0,0x266ffa09,0x21ff8099,0x02fedffc,0xff807fe2,0x655ffcc1,
0x41ff80ff,0xffcabff9,0x655ffcc0,0x5ffcc0ff,0xff80ffca,0x3fe63fa1,
0x2ffe65fb,0x3e20ffca,0x37c42a66,0x17fdc153,0x37c47ff3,0x99be2153,
0x7dc1ff0a,0x9fe4bf55,0xa8ff25fa,0xeeefd80f,0x3bffa20f,0x3fa0fffe,
0x200ff401,0x3ff001fe,0x803effc8,0x07fe00ff,0xfffffff9,0xfc83ff07,
0x43ffffff,0xfffffffc,0x7ffffe43,0x21ff83ff,0xbfff90fe,0x7fffffe4,
0x75eff43f,0x3af7fa1f,0x37ffee1f,0xdfe86ffe,0x37fa1feb,0xb1ff1feb,
0x3fe25fdb,0xff13ffbb,0x3e47ff77,0x81dffc88,0xfeefffc8,0xe803fd2f,
0x00ff401f,0x06541ff8,0x7c01ff00,0x6667fc1f,0x1ff86fdc,0x6e6667fc,
0x6667fc6f,0x67fc6fdc,0xf86fdccc,0x7c43fa1f,0x333fe5ff,0x6c46fdcc,
0x7ec42eff,0x2f3e62ef,0xb104fffd,0xfd885dff,0x2e3fe2ef,0x77fe44ff,
0x3bff25fb,0x5017a5fb,0xeb82200b,0xdddddfd0,0x3bbbfa3d,0xddfd1eee,
0xff83dddd,0x3e000ec1,0xa87fe00f,0x42ff886f,0x21bea1ff,0x0df52ff8,
0x1bea5ff1,0x3ff0bfe2,0xbff507f4,0x3fe21bea,0x20100102,0x00200082,
0x01004002,0x2004c010,0xfd000029,0x25ffffff,0xfffffffe,0xffffffd2,
0x341ff85f,0xf007fc00,0xc81fec3f,0xfb0ffc5f,0x7ed7f207,0x3f6bf903,
0xff8bf903,0xbfb03fa1,0x2fe40ff6,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x01440000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x7c400000,0x3ffae04f,0x3e7f303e,
0x26079d05,0xfd70bf2f,0x03ff605b,0x5407e5fa,0x261eb9de,0xfdb7406f,
0x17dfd700,0xf885fd88,0x6984e880,0x0d309d10,0x41677f5c,0x07d43eea,
0x00cfec88,0x7e401fe2,0x3aa04e83,0xfc81ebcf,0x07bfb302,0x3a0bebba,
0x85ffffff,0x3609d2e9,0xf11f703b,0xffdffb87,0x42f57d40,0xfc81d75d,
0x4c2fffcf,0x7657602f,0xffeffe80,0x0be3261f,0x09ff307b,0x09ff303d,
0x3bfee03d,0x5e7c1ffe,0xfc813a0f,0x7cc04fbc,0xc81fc402,0xffbff706,
0x703f885f,0x305fd9ff,0x5df90261,0x000bfee2,0xfd988288,0x87f43fb9,
0x188443fb,0x221fd000,0x000882ff,0xd8977dc0,0x260ff86f,0xa89b1106,
0xa89b1105,0xfb87fa05,0x4be6be65,0x47fa00fa,0x4008807e,0x203ea018,
0x85ff11fe,0x4c3fa018,0x77f6c43d,0x7e41ffc3,0x1f7f6c46,0xe8fbfb62,
0x1fffffff,0x41db01fe,0x6c1db0ed,0xfe8df30e,0x076c1db2,0x3e0b7f6a,
0x220dc43f,0xb00ba4e8,0x3600fc49,0xfe807e24,0x7c43310c,0x809d1faa,
0x205fcefc,0xb502dfda,0x85f105bf,0xd97f47f8,0x7c43b60e,0xfcdfd806,
0x503ff11f,0xfcdfd8ff,0x3f37f61f,0xd5bf751f,0x2bfa215f,0x3a0ff809,
0x7f41ff1f,0x2fe8df31,0x70ff41ff,0x44bffbff,0xbfa801ff,0x9b00b53f,
0x926c0264,0xdfffa809,0x57eee80b,0xfff8801f,0x3f7fee04,0x7effdc5f,
0x7c44f85f,0x0ff97f46,0x037cc7fa,0x265f9154,0x41ff107f,0x2a8bf22a,
0xf2f98bf2,0x4ffffe8b,0x47fa0ff8,0xf87fa0ff,0x3e5ff31f,0xff87fa0f,
0x3fcc3fa1,0x0f459500,0x3e257033,0x44ae0310,0x3aa0660f,0x5c42ffff,
0x440c9d0b,0xf013fffd,0xff07f43f,0x1b607f43,0x97fc43fa,0xe87fa0ff,
0x950bf30f,0x3fe67ffd,0x540ffa81,0x6543ffec,0x7fb53ffe,0x32a15bf7,
0x0ff81aef,0xd07fc7fa,0x7f7fe43f,0x741ff2ff,0xfc8df31f,0x0001ff13,
0x405f892e,0x80ddf93d,0x9817e23d,0x2a00ffeb,0x20eff98f,0xfbffacfe,
0x7f91be65,0x87f91be6,0x67fdc0fb,0x41ff2fff,0x33fee1fe,0x37fa22fe,
0x0ffe3fcb,0xdfe89ff2,0xbfd13fcb,0x3ffa7f97,0x2e1fffff,0xf83fe03f,
0x7fc1ff1f,0x7ec67641,0x8ffc1ff1,0xf27dc6f9,0x203e883f,0x817ba0f8,
0x07e66e69,0x997ba34c,0x201fe84c,0x44fed94e,0x8ffff27f,0x9a7dc6f9,
0x2627dc6f,0x67fdc42f,0x7c1ff2fd,0x1f7f541f,0x23fc97ea,0x3fea2efc,
0x3fc97ea3,0x89fe4bf5,0x219fd9ef,0x3fa00ee8,0x3fa3ff11,0x4d43ff11,
0x8ff43fa0,0x87fe1ff8,0x87bf20fe,0xd8f205fd,0x10ba05cc,0x9b1740bd,
0x222fe8b9,0x21f501ff,0x1fe2bd4e,0x1ff83ffd,0x21ff83fa,0x804f80fe,
0x223fd2fd,0x84ec81ff,0x3ffbbff8,0x3ffbffa2,0x5dffc46f,0x77ff13ff,
0x6d3e27ff,0xeffffd86,0x3afbf65e,0xd7dfb1ff,0x56fec3ff,0x2fbf66fc,
0x3ff21ffe,0x7f445fec,0x300fffef,0x17ff7ccd,0x817a2354,0x3ffbe66a,
0x3f7bfee2,0x5d93a06f,0x7677ec7f,0x3f22ffff,0x7e45fecf,0xdb05fecf,
0x3f65fb00,0x101ffebe,0x7dff903f,0xffff90bf,0x2fbff209,0x2fbff25f,
0x17e5f35f,0x3ffb73ea,0x36fffa26,0xb7ffd11f,0x7ffecc3f,0x2fffa21e,
0x77f5c1fd,0xfffc880b,0x330b601c,0xe83d01b9,0x41e81eef,0x6dc0ec99,
0x3ea04fff,0x887fbea0,0xfc9dfffd,0x05f7f5c0,0x805f7f5c,0x12fd807b,
0x83fb7ffd,0x00404eeb,0x00200110,0x0130c402,0x08008040,0x00802200,
0x00080020,0x1440cc05,0x102aaaa2,0x0200cc05,0x00a20aa0,0x80040103,
0x00018800,0x00000002,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x5b910000,
0x0bbbbba0,0xe8873b66,0xdb01ba25,0x4c07d501,0x2000d9cd,0x2000beda,
0x1f542deb,0x0000fb6a,0x20b5b910,0x8004aadc,0xd97a22ec,0x507b600e,
0x71ec809d,0xdffda85d,0xdfd7100b,0x0ffd8039,0x067f4eec,0x1cefeb88,
0x8bfdff50,0x43fffff9,0x10ffeff9,0x203fc4df,0x04fa81ff,0x2617f2f6,
0x7f7fdc5f,0x3f617e46,0x93ee5fff,0x4c5ffffd,0x22fea3ff,0x82ffa84f,
0x982fdbe9,0x3ea0adfc,0x0ff97ea5,0xbf507fa0,0x7f92fd80,0x7ff7ffdc,
0x731ce885,0x3abea05f,0x7f6fffc5,0x731ce886,0x3a3fd05f,0x2673ea1f,
0xfb9fec09,0x3fc4df12,0x26207fe0,0x436c0000,0xd83fb0ff,0x0ff9fe26,
0x45be2131,0x3ef7a1ff,0x87d15d31,0x0006e8c9,0x8dfdbff5,0x7c5fb0ff,
0x507fa00f,0x12fd80bf,0x42ffee13,0x2fa22ff9,0x05f32aaa,0x7ff06211,
0x27d10ff4,0x443f32b9,0xfc8ff27f,0x01ff101a,0x07f89be2,0x27cc0ffc,
0x305bfb50,0x81fd9fe0,0xf83fe081,0x9fec9f51,0x40013098,0x444fdec9,
0x7f43efed,0xbfc87f61,0x64ffc7f8,0x507fa0cf,0xdaeea8bf,0x309fb02f,
0xcdfa5c15,0xfb50b54e,0x2e1ff85b,0x67d52e4f,0x37ccb55e,0x7ffec9f7,
0x7dffcc3f,0xf89fe21d,0x6c0ffc07,0xfbff703f,0x540ed8bf,0xed84fdef,
0x223fea80,0x7ecbf32f,0x76c076c4,0x7ff7fd40,0x3f37f60f,0x7f90a61f,
0x227d6fcc,0x26fedfff,0x92fd41fe,0x05fff9ff,0x96c007fe,0x71e2d71f,
0x7cbffbff,0x2d93ee1f,0x53c4a25f,0xff2fdcdf,0x7d45ff7b,0xf11ffcef,
0xf01fea3f,0x206fd83f,0xe83fa1ff,0x7fff440f,0xfc80fe83,0xfe8be62f,
0x7f45ffbb,0x7ec0fe80,0x1545ff12,0x7fd405f9,0x20ff7f40,0x747fa3ff,
0xfd2fd41f,0x260bfe21,0x3bbb20ff,0x7777c3e5,0x21ff87a1,0x6c7ff0fe,
0x07e23e1f,0x2e6f98f4,0x4bf5044f,0x27f51ff9,0x7ffcfff8,0xdf90ffc0,
0xf91be601,0x3fe07f47,0x7f42fd8a,0x2a5fb100,0x37bfa63f,0x7407f44f,
0xf91fe20f,0x3ffeca89,0xf703ff50,0x641ff0df,0xfb83fd3f,0x2fe8df35,
0xe87fe7f9,0x7c7a6fff,0x4c3e0eca,0xff9fe46f,0x8f47fddf,0x987c512e,
0x980ff27f,0xf89fe26f,0xfbfbdf16,0x1ff0dccf,0x09883fe2,0x24fb8df3,
0xa97e60fe,0x5007f45f,0x4613eebf,0x407f43fc,0x91fe60fe,0x2f7fa27f,
0x1ff883fc,0xff07ff10,0x2fd9fdc3,0x46f9a7dc,0x3a7f92fe,0x326f984f,
0x34d3a3f4,0xf4fb8df3,0xc839ff7f,0x2abb7d74,0x2fd87fc6,0x227dcfd1,
0x227f52fe,0x53ee016f,0x363fc7f9,0xfe87fe2f,0x7f883fa0,0x21fd0fee,
0x5cff26f9,0x7f49915f,0x7f407f41,0x1fd0ff40,0x83fc97ea,0x3fe204f9,
0x3fa3ff80,0x4fe8bfb1,0x17fc43fa,0x90bfee5b,0x8657ccdf,0x7fc2e9c9,
0x87fc3fa1,0x3265f300,0x7e42e88b,0x77e46fde,0x7fdc1ffc,0x0df11ffd,
0x4ffeff88,0x37ee77dc,0x17fb3ff2,0xcefc81fd,0xb07f40ff,0x321ffbdf,
0x3fb7fa5f,0xfe80fe86,0x7f67fdc0,0x3eeffe25,0x9809883f,0xfff05feb,
0x7fccffbb,0x320fffdf,0x72fffcff,0xfdfffc8d,0x85fcc5ff,0xffc83ea8,
0x03fe5fec,0x5442fe60,0x19fd503e,0x02fffc88,0x7c45bff7,0x5ffda806,
0x01bffb50,0xe817dfd7,0x6ffe440f,0x3220fe82,0x97f21cff,0xe80dffd9,
0xa80fe80f,0x7e40befd,0xfa85fbef,0x00eff985,0x839ff5ff,0x41efffea,
0x2fccffb8,0x3fff6e01,0xfdfb302d,0x77f5c05b,0x4003fe0b,0x02dfffd9,
0x10008008,0x00020000,0x07f40100,0x807f4010,0x3a004000,0x200fe80f,
0xfa800800,0x08001305,0x00000180,0x000c0008,0x06000002,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x2604c000,0x3b60d9cd,0x3603eeee,0xc83eeeee,0x6c3ba22e,
0x41deeeee,0x361db3eb,0x17e6000e,0x003b61db,0xd802fb6a,0xd818804e,
0x0eeeeeee,0xeeedbfc4,0x3b203eee,0xeeeeeeee,0xed803db1,0x1eda74c1,
0x9dddddd3,0x3bbbbbae,0xeb83db5e,0xddddd11e,0x00f649dd,0xf917fec4,
0x45fcbd83,0x6ffffffe,0xffffffd0,0x3f26f98d,0x3fffffa5,0x753f21ff,
0x2001ff0f,0x87f45fe8,0x7fdc00fe,0xfff307fe,0x740fd801,0x0fffffff,
0xfffebfec,0xff304fff,0xfffffffd,0xfd007fa3,0x3ff6fa83,0x3fffffea,
0xffffff95,0xfb8bfaff,0x3fffe22f,0x0bfa5fff,0xe833bee0,0x0ff4001f,
0x3fd07fd3,0x3fa1ff4c,0x3fa1ff8a,0x9f927ec1,0x007fc3fa,0x7405ffc8,
0xd87fc00f,0x3fffc83f,0x3fa07ec0,0xbfff5401,0x3f2002fe,0x7f406f9b,
0x7f43deee,0x1ffb7d41,0x3fd33331,0x5fd0bf70,0x3200bfea,0x00bfa1ff,
0xdff90ff2,0x3bf67b69,0xff507fa2,0x7fa83fd0,0x22fdf7d4,0x91fe41fe,
0x7fc3fa7f,0xdf507db0,0xfd0ed8bf,0x5443df73,0xff113ee2,0xd5530df5,
0x07fa557f,0x3aff7db0,0x1ff1002f,0xffe80df3,0x3fa5ffff,0x1ffb7d41,
0x3ee07f50,0xffaafe85,0x42ffa803,0x7fe402fe,0x53bff25e,0x0ffdcfff,
0x47f883fd,0xf109bfe9,0x3ffa621f,0x337fa1af,0x3ee0efdc,0x23fe1fd3,
0x9ef885fc,0xfe87f45f,0x7407fdcf,0xfeafdc2f,0x7ffffe42,0x999bfd7f,
0xd7f89479,0x2055559f,0x99ff34fc,0x50ff4799,0x337fa1ff,0x3ff6fdcc,
0x5fb81ba0,0x06ffcfe8,0xfe84ff98,0x2f7fe402,0x23ff87fa,0x883fd1ff,
0x3fffe1ff,0x7e47fe4f,0x3a7fffff,0x44ffffff,0x3e1fd2fa,0xfc80efcf,
0x87f45f99,0x407fe3fe,0x92fe86fd,0xfecca8bf,0xffffd4cc,0x2ff10bff,
0x86fffffe,0xfff30ff8,0x0ff4dfff,0x7fff4bfa,0x3ff6ffff,0x7dc07f70,
0xfffffe85,0x417fa202,0x2fc802fe,0x87fe1fe8,0x883fd1fe,0x2ffa60ff,
0x261ff309,0x22abffaa,0xfda99bfe,0x87f47e65,0xfa85ffff,0x0fe8bf34,
0x40ff43fd,0x7fcc0efd,0xb00ffcab,0x99bfe81f,0xd7f88099,0x7055559f,
0x3df955df,0x0ff41333,0x2ffa3ff3,0xff6fb999,0x5c01ff03,0xbbffe85f,
0x1dfb00ff,0x3200bfa0,0x3e1fe82f,0x7f47fa0f,0x7f43fcc1,0x9953fd41,
0x7f499bff,0xf887fc41,0x3bfe1fd0,0x7ffec1fe,0x1fd0ffff,0x41fe83fa,
0xffc80efc,0xb03fffff,0x001fe81f,0x00bfaff1,0x3ffffffe,0x7ffff406,
0x507fa5ff,0xf107fedf,0xe85fb80b,0x3217fa4f,0x0bfa01ff,0x3f60bf20,
0x1fe83fe1,0x27f443fd,0x9fd10ff4,0x7fffffe4,0xff507fa7,0x3e1fd0c1,
0x7646fa9f,0xd0effeee,0xfe83fa1f,0x7c03bee1,0x6fdccccf,0x03fd0550,
0x17f5fe20,0x2aabbee0,0x7ff406fc,0x3fa0ceef,0x1ffb7d41,0x3ee01fd4,
0x3ea2fe85,0x00bfea2f,0x5f9005fd,0x3fe7bfb0,0x77f47fa0,0xfd06ffee,
0x01fffddd,0x3bfa07fa,0x2e5ffeee,0x3fe1fd3f,0x7cc07fb0,0x0fe87f45,
0x7ffc47fa,0x0df55fff,0x3ff25ff1,0xdfd7ffff,0x883ddddd,0xe805fd7f,
0x777fcc3f,0x03fd2eee,0xb7d41fe8,0x017e41ff,0x0bfa17ee,0x3ffa1dfb,
0x3a6eeeee,0x44eeeeef,0x5ffa82fc,0xe8ff41ff,0x00ceffff,0x19dffffd,
0x7f40ff40,0x5c4effff,0x3fe1fd3f,0x2601ff30,0xfe87f45f,0x7fdc7fa0,
0x7fb5ffff,0x7fe57f20,0xffd7ffff,0x885fffff,0x5405fd7f,0xffff987f,
0x03fd3fff,0xb7d41fe8,0x00fec1ff,0x0bfa17ee,0x3ffa9ff3,0x3a7fffff,
0x46ffffff,0x000202fc,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x3a600000,0xc8bb620e,0xb0fba22e,
0x4c1f641d,0xd30fb65e,0xd90bbb69,0x3bbbb67d,0x77776c3e,0x800002de,
0x00000000,0x2e000000,0x81aaaaaa,0x026000aa,0xb0000000,0x08876c1d,
0xeeeeea80,0x3ae17b26,0xdf92fec4,0x3fea4fc8,0xdf71fe26,0x7ff49f90,
0x7ffd7e60,0x753ffe25,0x26ffffff,0xfffffffe,0x02dfda83,0x45d9df93,
0xfccffec8,0xbeea80df,0x83dfd980,0x4c3efed8,0x0222dffd,0x801fe818,
0x237a0fda,0x4ffc8dfc,0x8bbf67b6,0x3fe6fadd,0x6fcc7fa0,0x3fbbaa01,
0x98bfe27f,0x57fc41ff,0x37d41ff9,0x3ea1fffb,0x3e07fc45,0x997ffa1f,
0x54ffff5f,0x43fd4fff,0x83fd0ffa,0x6ffdc6fc,0x67fd45ff,0x66fe47fe,
0x0efcdfff,0x83ff7bf2,0x42fecffb,0x21ffcdfd,0x10ffbbee,0x076c0c01,
0x0effeb88,0x3ffb3ffe,0xfff1ffce,0x3fe1ffb9,0xe83fe5ef,0x5dffd11f,
0x5c1ffa80,0x5c13f66f,0xf884feff,0x64bf3fe7,0x263fe83f,0x97fff46f,
0x3fbff5f9,0x7f53f7f2,0x1fe97f41,0x87fe37d4,0x647f60fe,0xfc8a63ff,
0x27f8fee6,0x4c3fa4fb,0x5f91543d,0x10ccbbe6,0xaaa98c01,0xff912aaa,
0x23ff039f,0x27fb0ffa,0x7c7fe3ff,0x3a0ff83f,0x7ffecc1f,0xd02ff984,
0x401ff59f,0xfd00effe,0x29f5bf33,0x26fb81fe,0x7e7f44fc,0x2ffebf36,
0x29f7fd3f,0x47fea1fe,0xfeaa9bfe,0x7f91be63,0x7df5dbe2,0x77ff6545,
0xdf34fdcc,0x3e2bfb99,0xffd95006,0x0e7ffec7,0xffc8c011,0xff37ffff,
0xf30ff809,0x1ff9fe4d,0x40ffc7fa,0x407fe0ff,0x3e20ffd8,0x3bfe603f,
0x27fdc02f,0x17f77fb0,0x7c41fedf,0xfe83ff1f,0xf5f9cfe8,0x7bf1bf3f,
0x3ffffa9f,0x3fffa5ff,0x3e60cfff,0xdf9a7dc6,0x3a4fa8fa,0xccefcbef,
0x99df53cc,0x01be6799,0x7f97bfd1,0x8ffff5c4,0x66546008,0xfd14cccc,
0x99fe05df,0x7fcfee5f,0x07fc7fa0,0x1ff88ff4,0x877ff5c4,0xfc804fe8,
0x7ffc405f,0xfb9f700f,0x81bebfa3,0xe86f9cfd,0x5fbff98f,0x7f5fd1ff,
0x3bbfa9f7,0x667f43ee,0x43ff04ff,0x3fff10fe,0x937cc7f6,0xf8854cdf,
0x0fe82a66,0x92fd4bf3,0x644aa27f,0x40c0114f,0xffb300aa,0xf33fc19f,
0x0ff9fdcb,0x407fc7fa,0x1ffebefd,0x83bfff91,0x1eeeeffd,0x6c01ff88,
0xf305fdef,0x7f7e4ffd,0x3f3bea04,0xff90fe83,0x3f23febf,0xfd4fb9fe,
0xf11fe803,0xd9ff909f,0xebefc8bf,0x2effe26f,0x1ffbdfff,0x87faf7fa,
0x22fecffb,0x3ffbbff8,0x3fd77ff1,0xfe818022,0x07fe4401,0xf72fccff,
0x1fe83fe7,0xffd101ff,0x3fe63fb7,0xffffb00c,0x03fe03ff,0xff89ffa8,
0x4cbfff03,0x7fc02fff,0x10fe80ff,0x23febfff,0x29f77ffa,0x0ff401fe,
0xfd703ff5,0x76f4417d,0x7f5c0bef,0x2effd9cf,0x4177fec4,0xfc83efea,
0x36a5fbef,0x80223dff,0x1000cb81,0xbf33fc17,0x20ff9fdc,0x401ff1fe,
0x0000a600,0xf8807fc0,0x203fee4f,0x7ffc3ffd,0x82ffe400,0x57fea0fe,
0x75ff88ff,0xd007fa9f,0x206fd83f,0x08008600,0x10010010,0x20200100,
0x999999a8,0x00000001,0x00000000,0x3fe00000,0xfd0df900,0xd81ff70b,
0x2ff9806f,0x5fd81fd0,0x5cffa1ff,0xe803fd4f,0x027fc41f,0x00000000,
0x00000000,0x00000000,0x00000000,0x20000000,0x000000ff,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x02620000,0x37aa0404,0x17649d90,0x887643b6,0x4a8fa66e,0x547d50ec,
0x46a00a89,0x0100001a,0xa8000000,0x1fffffff,0xfffffa80,0xe98221ff,
0x198b7666,0x3b2dd104,0x993b2022,0x08fffee2,0xaaaa8102,0x0000aaaa,
0x4c17dc00,0x44ebccbf,0x20ff9cfd,0xb97ea5fa,0x323ff53f,0x7ed3fa2f,
0x8ed93ee5,0xf93f706e,0xffb27441,0x220ff207,0x0efe45fd,0x37f621ec,
0xffffff50,0x5177543f,0x3fffffff,0x57f987fc,0x5fdfffff,0xb7f88ff4,
0x261be25f,0x3ee1fd0f,0x3e1fd3ff,0x7ffc4fb6,0x003fffff,0x417dc000,
0x3ffffff9,0x417fffc4,0x445fb0ff,0x3a7ffb5f,0x3fffa20f,0xf982620e,
0x67cc4f9c,0x53fe64f9,0xf887c8c8,0x2f8c987f,0x5dcdb5f5,0xd1b51cbd,
0xf55f0009,0x7fc3f900,0x272edf30,0xf30dffda,0x45fb7f85,0x49dd92f9,
0xe82220dc,0x01729b0f,0x22000000,0x0aacfdaa,0x07fa6bfa,0x7e413fea,
0x8fe86f8b,0x85f9eedf,0x9000fff9,0x7f43fb5f,0x36220fe9,0x70ffd914,
0x3fe07fbf,0x547eadb0,0x7cc1cffc,0x99999932,0x01f9e619,0xf8f10fe4,
0x74044005,0x20881f76,0x00000000,0x54000000,0x1fffffff,0xb83fa9be,
0x7df106ff,0x7f7f907f,0xfb05f9f9,0x3ee009ff,0x3fd12fcb,0x7e5360df,
0x477c47c8,0x74e8886f,0xfec83ead,0xff51fd41,0x743fffff,0x1fc806dd,
0x000000fa,0x00000000,0x00000000,0x9bfd9930,0x6c4ffc19,0x7f7fc42f,
0x01fffb04,0xff53fff3,0xe9efd81f,0x46fc404f,0x7d67cc5f,0xfbf74d83,
0x5f93fb8f,0xf89fdfd4,0x2e7a24fe,0x44b3bea4,0x09999999,0x22002ee2,
0x3bba20c1,0x003eeeee,0x00000000,0x00000000,0x220bee00,0x42fffffe,
0x81ff9bfe,0x3fe05ffa,0xd90bff17,0x4fb8fa21,0x203f63f2,0x540fd8fc,
0xdb0a2662,0x59517a61,0x65400350,0x000002cc,0x2eeee000,0x0001bbbb,
0x00000000,0x00000000,0x3e60bee0,0x325fcedd,0x7c1bf26f,0xe97f202f,
0xfb81003f,0x500d46a4,0x00001513,0x00000000,0x00000000,0x00000000,
0x00000000,0x20000000,0x010300a9,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
};
static signed short stb__arial_bold_17_latin1_x[224]={ 0,1,0,0,0,0,0,0,0,0,0,0,0,0,
1,-1,0,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,1,1,1,0,1,1,0,1,
1,1,1,0,1,0,1,0,0,1,-1,0,0,-1,0,1,-1,0,0,-1,0,0,1,0,0,0,0,0,1,1,
-1,1,1,0,1,0,1,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,
1,0,0,-1,0,0,0,0,-1,-1,0,0,0,0,1,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,-1,0,1,1,1,1,-1,0,-1,-1,-1,1,0,0,0,0,0,0,0,1,1,1,1,-1,1,1,0,0,
0,0,0,0,0,0,0,0,0,0,-1,0,-1,-1,0,1,0,0,0,0,0,0,0,1,1,1,1,0,1,0,
};
static signed short stb__arial_bold_17_latin1_y[224]={ 13,2,2,1,1,1,1,2,1,1,1,3,10,8,
10,1,2,2,2,2,2,2,2,2,2,2,5,5,3,5,3,1,1,2,2,1,2,2,2,1,2,2,2,2,
2,2,2,1,2,1,2,1,2,2,2,2,2,2,2,2,1,2,1,14,1,4,2,4,2,4,1,4,2,2,
2,2,2,4,4,4,4,4,4,4,2,5,5,5,5,5,5,1,1,1,6,3,3,3,3,3,3,3,3,3,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,13,5,2,1,3,2,
1,1,1,1,1,5,5,8,1,0,1,2,1,1,1,5,2,6,13,1,1,5,1,1,1,5,-1,-1,-1,-1,
-1,-1,2,1,-1,-1,-1,-1,-1,-1,-1,-1,2,-1,-1,-1,-1,-1,-1,4,1,-1,-1,-1,-1,-1,2,1,1,1,
1,2,1,1,4,4,1,1,1,1,1,1,1,1,2,2,1,1,1,2,1,3,4,1,1,1,1,1,2,1,
};
static unsigned short stb__arial_bold_17_latin1_w[224]={ 0,3,7,9,8,13,11,3,5,5,6,9,4,5,
3,6,8,5,8,8,9,9,8,8,8,8,3,3,9,9,9,9,15,11,10,11,10,9,8,11,9,3,8,10,
8,11,9,12,9,12,10,10,9,9,12,15,11,12,10,4,6,4,9,10,4,8,8,9,9,8,6,9,8,3,
5,8,3,13,8,9,8,9,6,8,5,8,9,12,9,9,8,6,2,6,9,9,9,9,9,9,9,9,9,9,
9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,0,3,9,9,9,9,
2,8,6,13,6,8,9,5,13,10,6,8,5,5,4,9,10,3,5,4,6,8,13,13,13,9,11,11,11,11,
11,11,16,11,9,9,9,9,5,5,6,6,12,9,12,12,12,12,12,9,12,9,9,9,9,12,9,8,8,8,
8,8,8,8,13,9,8,8,8,8,5,5,6,6,9,8,9,9,9,9,9,8,9,8,8,8,8,9,8,9,
};
static unsigned short stb__arial_bold_17_latin1_h[224]={ 0,11,4,13,14,13,13,4,16,16,7,9,6,3,
3,13,12,11,11,12,11,12,12,11,12,12,8,11,9,6,9,12,16,11,11,13,11,11,11,13,11,11,12,11,
11,11,11,13,11,14,11,13,11,12,11,11,11,11,11,15,13,15,7,3,4,10,12,10,12,10,12,13,11,11,
15,11,11,9,9,10,13,13,9,10,12,9,8,8,8,12,8,16,16,16,4,10,10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,12,14,13,9,11,
16,16,3,13,7,8,6,3,13,2,6,11,7,7,4,12,14,3,4,7,7,8,13,13,13,12,14,14,14,14,
14,14,11,16,14,14,14,14,14,14,14,14,11,14,15,15,15,15,15,8,13,15,15,15,15,14,11,13,13,13,
13,12,13,13,10,13,13,13,13,13,12,12,12,12,12,11,13,13,13,12,13,9,10,13,13,13,13,16,15,16,
};
static unsigned short stb__arial_bold_17_latin1_s[224]={ 253,68,198,41,1,173,187,179,36,30,134,
14,174,221,227,248,60,148,108,148,85,69,79,204,133,161,77,252,188,147,237,
203,57,117,57,108,23,138,154,1,190,200,98,223,245,65,55,10,77,10,87,
162,213,232,42,26,14,1,234,109,219,215,111,238,206,151,223,141,242,132,1,
79,99,95,114,76,72,198,212,98,37,226,221,160,8,228,44,54,34,213,247,
73,80,83,183,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,
169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,253,157,59,
51,24,47,54,11,231,46,104,90,164,221,13,179,157,129,141,121,193,88,220,
217,211,99,127,81,148,134,120,107,88,160,131,119,107,231,163,42,243,33,23,
43,53,82,100,143,34,150,120,133,146,159,172,67,190,185,195,205,90,69,180,
221,230,239,1,194,23,32,118,245,212,203,181,172,142,127,170,177,184,14,199,
209,27,117,98,179,108,89,236,61,70,20,100,1, };
static unsigned short stb__arial_bold_17_latin1_t[224]={ 1,61,85,33,18,33,33,85,1,1,85,
85,85,85,85,18,47,61,61,47,61,47,47,61,47,47,85,47,73,85,73,
47,1,61,61,33,61,61,61,47,61,61,47,61,61,73,73,33,73,18,73,
33,61,47,73,73,73,74,61,1,33,1,85,85,85,73,47,73,47,73,61,
33,61,61,1,61,61,73,73,73,47,33,73,73,61,73,85,85,85,47,73,
1,1,1,85,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,
73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,73,1,47,18,
33,85,61,1,1,85,47,85,85,85,85,47,90,85,61,85,85,85,47,1,
85,85,85,85,85,33,33,33,47,18,18,18,18,18,1,61,1,1,18,18,
18,18,18,18,18,61,18,1,1,1,1,1,85,18,1,1,1,1,18,61,
18,18,18,33,47,33,33,73,33,18,18,18,18,47,47,47,47,47,61,33,
33,47,47,33,73,73,33,33,33,33,1,1,1, };
static unsigned short stb__arial_bold_17_latin1_a[224]={ 68,81,115,135,135,216,176,58,
81,81,95,142,68,81,68,68,135,135,135,135,135,135,135,135,
135,135,81,81,142,142,142,149,237,176,176,176,176,162,149,189,
176,68,135,176,149,203,176,189,162,189,176,162,149,176,162,230,
162,162,149,81,68,81,142,135,81,135,149,135,149,135,81,149,
149,68,68,135,68,216,149,149,149,149,95,135,81,149,135,189,
135,135,122,95,68,95,142,183,183,183,183,183,183,183,183,183,
183,183,183,183,183,183,183,183,183,183,183,183,183,183,183,183,
183,183,183,183,183,183,183,183,68,81,135,135,135,135,68,135,
81,179,90,135,142,81,179,134,97,134,81,81,81,140,135,68,
81,81,89,135,203,203,203,149,176,176,176,176,176,176,243,176,
162,162,162,162,68,68,68,68,176,176,189,189,189,189,189,142,
189,176,176,176,176,162,162,149,135,135,135,135,135,135,216,135,
135,135,135,135,68,68,68,68,149,149,149,149,149,149,149,134,
149,149,149,149,149,135,149,135, };
// Call this function with
// font: NULL or array length
// data: NULL or specified size
// height: STB_FONT_arial_bold_17_latin1_BITMAP_HEIGHT or STB_FONT_arial_bold_17_latin1_BITMAP_HEIGHT_POW2
// return value: spacing between lines
static void stb_font_arial_bold_17_latin1(stb_fontchar font[STB_FONT_arial_bold_17_latin1_NUM_CHARS],
unsigned char data[STB_FONT_arial_bold_17_latin1_BITMAP_HEIGHT][STB_FONT_arial_bold_17_latin1_BITMAP_WIDTH],
int height)
{
int i,j;
if (data != 0) {
unsigned int *bits = stb__arial_bold_17_latin1_pixels;
unsigned int bitpack = *bits++, numbits = 32;
for (i=0; i < STB_FONT_arial_bold_17_latin1_BITMAP_WIDTH*height; ++i)
data[0][i] = 0; // zero entire bitmap
for (j=1; j < STB_FONT_arial_bold_17_latin1_BITMAP_HEIGHT-1; ++j) {
for (i=1; i < STB_FONT_arial_bold_17_latin1_BITMAP_WIDTH-1; ++i) {
unsigned int value;
if (numbits==0) bitpack = *bits++, numbits=32;
value = bitpack & 1;
bitpack >>= 1, --numbits;
if (value) {
if (numbits < 3) bitpack = *bits++, numbits = 32;
data[j][i] = (bitpack & 7) * 0x20 + 0x1f;
bitpack >>= 3, numbits -= 3;
} else {
data[j][i] = 0;
}
}
}
}
// build font description
if (font != 0) {
float recip_width = 1.0f / STB_FONT_arial_bold_17_latin1_BITMAP_WIDTH;
float recip_height = 1.0f / height;
for (i=0; i < STB_FONT_arial_bold_17_latin1_NUM_CHARS; ++i) {
// pad characters so they bilerp from empty space around each character
font[i].s0 = (stb__arial_bold_17_latin1_s[i]) * recip_width;
font[i].t0 = (stb__arial_bold_17_latin1_t[i]) * recip_height;
font[i].s1 = (stb__arial_bold_17_latin1_s[i] + stb__arial_bold_17_latin1_w[i]) * recip_width;
font[i].t1 = (stb__arial_bold_17_latin1_t[i] + stb__arial_bold_17_latin1_h[i]) * recip_height;
font[i].x0 = stb__arial_bold_17_latin1_x[i];
font[i].y0 = stb__arial_bold_17_latin1_y[i];
font[i].x1 = stb__arial_bold_17_latin1_x[i] + stb__arial_bold_17_latin1_w[i];
font[i].y1 = stb__arial_bold_17_latin1_y[i] + stb__arial_bold_17_latin1_h[i];
font[i].advance_int = (stb__arial_bold_17_latin1_a[i]+8)>>4;
font[i].s0f = (stb__arial_bold_17_latin1_s[i] - 0.5f) * recip_width;
font[i].t0f = (stb__arial_bold_17_latin1_t[i] - 0.5f) * recip_height;
font[i].s1f = (stb__arial_bold_17_latin1_s[i] + stb__arial_bold_17_latin1_w[i] + 0.5f) * recip_width;
font[i].t1f = (stb__arial_bold_17_latin1_t[i] + stb__arial_bold_17_latin1_h[i] + 0.5f) * recip_height;
font[i].x0f = stb__arial_bold_17_latin1_x[i] - 0.5f;
font[i].y0f = stb__arial_bold_17_latin1_y[i] - 0.5f;
font[i].x1f = stb__arial_bold_17_latin1_x[i] + stb__arial_bold_17_latin1_w[i] + 0.5f;
font[i].y1f = stb__arial_bold_17_latin1_y[i] + stb__arial_bold_17_latin1_h[i] + 0.5f;
font[i].advance = stb__arial_bold_17_latin1_a[i]/16.0f;
}
}
}
#ifndef STB_SOMEFONT_CREATE
#define STB_SOMEFONT_CREATE stb_font_arial_bold_17_latin1
#define STB_SOMEFONT_BITMAP_WIDTH STB_FONT_arial_bold_17_latin1_BITMAP_WIDTH
#define STB_SOMEFONT_BITMAP_HEIGHT STB_FONT_arial_bold_17_latin1_BITMAP_HEIGHT
#define STB_SOMEFONT_BITMAP_HEIGHT_POW2 STB_FONT_arial_bold_17_latin1_BITMAP_HEIGHT_POW2
#define STB_SOMEFONT_FIRST_CHAR STB_FONT_arial_bold_17_latin1_FIRST_CHAR
#define STB_SOMEFONT_NUM_CHARS STB_FONT_arial_bold_17_latin1_NUM_CHARS
#define STB_SOMEFONT_LINE_SPACING STB_FONT_arial_bold_17_latin1_LINE_SPACING
#endif
|
.size 8000
.text@48
jp lstatint
.text@100
jp lbegin
.data@143
c0
.text@150
lbegin:
ld a, 00
ldff(ff), a
ld a, 30
ldff(00), a
ld a, 01
ldff(4d), a
stop, 00
ld a, ff
ldff(45), a
ld b, 91
call lwaitly_b
ld hl, fe00
ld d, 10
ld a, d
ld(hl++), a
ld a, 08
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 09
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 0a
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 28
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 29
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 2a
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 48
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 49
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 4a
ld(hl++), a
ld a, 40
ldff(41), a
ld a, 02
ldff(ff), a
xor a, a
ldff(0f), a
ei
ld a, 01
ldff(45), a
ld c, 41
ld a, 93
ldff(40), a
ld a, 04
ldff(43), a
.text@1000
lstatint:
nop
.text@1093
ldff a, (c)
and a, 03
jp lprint_a
.text@7000
lprint_a:
push af
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
pop af
ld(9800), a
ld bc, 7a00
ld hl, 8000
ld d, a0
lprint_copytiles:
ld a, (bc)
inc bc
ld(hl++), a
dec d
jrnz lprint_copytiles
ld a, c0
ldff(47), a
ld a, 80
ldff(68), a
ld a, ff
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
xor a, a
ldff(69), a
ldff(69), a
ldff(43), a
ld a, 91
ldff(40), a
lprint_limbo:
jr lprint_limbo
.text@7400
lwaitly_b:
ld c, 44
lwaitly_b_loop:
ldff a, (c)
cmp a, b
jrnz lwaitly_b_loop
ret
.data@7a00
00 00 7f 7f 41 41 41 41
41 41 41 41 41 41 7f 7f
00 00 08 08 08 08 08 08
08 08 08 08 08 08 08 08
00 00 7f 7f 01 01 01 01
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 01 01 01 01
3f 3f 01 01 01 01 7f 7f
00 00 41 41 41 41 41 41
7f 7f 01 01 01 01 01 01
00 00 7f 7f 40 40 40 40
7e 7e 01 01 01 01 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 41 41 41 41 7f 7f
00 00 7f 7f 01 01 02 02
04 04 08 08 10 10 10 10
00 00 3e 3e 41 41 41 41
3e 3e 41 41 41 41 3e 3e
00 00 7f 7f 41 41 41 41
7f 7f 01 01 01 01 7f 7f
|
#ifndef UTILITY_HPP
#define UTILITY_HPP
namespace ft {
template <class T1, class T2> struct pair {
public:
typedef T1 first_type;
typedef T2 second_type;
first_type first;
second_type second;
pair() : first(), second() {}
template <class U, class V>
pair(const pair<U, V> &pr) : first(pr.first), second(pr.second) {}
pair(const first_type &a, const second_type &b) : first(a), second(b) {}
pair &operator=(const pair &pr) {
if (this != &pr) {
first = pr.first;
second = pr.second;
}
return *this;
}
};
template <class T1, class T2>
bool operator==(const pair<T1, T2> &lhs, const pair<T1, T2> &rhs) {
return lhs.first == rhs.first && lhs.second == rhs.second;
}
template <class T1, class T2>
bool operator!=(const pair<T1, T2> &lhs, const pair<T1, T2> &rhs) {
return !(lhs == rhs);
}
template <class T1, class T2>
bool operator<(const pair<T1, T2> &lhs, const pair<T1, T2> &rhs) {
return lhs.first < rhs.first ||
(!(rhs.first < lhs.first) && lhs.second < rhs.second);
}
template <class T1, class T2>
bool operator<=(const pair<T1, T2> &lhs, const pair<T1, T2> &rhs) {
return !(rhs < lhs);
}
template <class T1, class T2>
bool operator>(const pair<T1, T2> &lhs, const pair<T1, T2> &rhs) {
return rhs < lhs;
}
template <class T1, class T2>
bool operator>=(const pair<T1, T2> &lhs, const pair<T1, T2> &rhs) {
return !(lhs < rhs);
}
template <class T1, class T2> pair<T1, T2> make_pair(T1 x, T2 y) {
return (pair<T1, T2>(x, y));
}
} // namespace ft
#endif
|
; A160749: a(n) = (11*n^2 + 19*n + 10)/2.
; 5,20,46,83,131,190,260,341,433,536,650,775,911,1058,1216,1385,1565,1756,1958,2171,2395,2630,2876,3133,3401,3680,3970,4271,4583,4906,5240,5585,5941,6308,6686,7075,7475,7886,8308,8741,9185,9640,10106,10583,11071,11570,12080,12601,13133,13676,14230,14795,15371,15958,16556,17165,17785,18416,19058,19711,20375,21050,21736,22433,23141,23860,24590,25331,26083,26846,27620,28405,29201,30008,30826,31655,32495,33346,34208,35081,35965,36860,37766,38683,39611,40550,41500,42461,43433,44416,45410,46415,47431,48458,49496,50545,51605,52676,53758,54851
mul $0,11
add $0,10
bin $0,2
add $0,10
div $0,11
|
;
;
; ZX Maths Routines
;
; 9/12/02 - Stefano Bodrato
;
; $Id: exp.asm,v 1.1 2003/03/24 09:17:40 stefano Exp $
;
;double exp(double)
;Number in FA..
IF FORzx
INCLUDE "#zxfp.def"
ELSE
INCLUDE "#81fp.def"
ENDIF
XLIB exp
LIB fsetup1
LIB stkequ
.exp
call fsetup1
defb ZXFP_EXP
defb ZXFP_END_CALC
jp stkequ
|
SFX_Teleport_Enter1_1_Ch1:
duty 1
unknownsfx0x10 23
unknownsfx0x20 15, 215, 0, 7
unknownsfx0x20 15, 183, 128, 6
unknownsfx0x20 15, 135, 0, 6
unknownsfx0x20 15, 71, 128, 5
unknownsfx0x20 15, 23, 0, 5
unknownsfx0x10 8
endchannel
|
; int fprintf_unlocked(FILE *stream, const char *format, ...)
SECTION code_stdio
PUBLIC fprintf_unlocked
EXTERN asm_fprintf_unlocked
defc fprintf_unlocked = asm_fprintf_unlocked
|
db KADABRA ; 064
db 40, 35, 30, 105, 120, 70
; hp atk def spd sat sdf
db PSYCHIC, PSYCHIC ; type
db 100 ; catch rate
db 145 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F25 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/kadabra/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_SLOW ; growth rate
dn EGG_HUMANSHAPE, EGG_HUMANSHAPE ; egg groups
; tm/hm learnset
tmhm DYNAMICPUNCH, HEADBUTT, CURSE, TOXIC, ZAP_CANNON, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, RETURN, DIG, PSYCHIC_M, SHADOW_BALL, DOUBLE_TEAM, ICE_PUNCH, SWAGGER, SLEEP_TALK, THUNDERPUNCH, DREAM_EATER, REST, ATTRACT, THIEF, FIRE_PUNCH, NIGHTMARE, FLASH
; end
|
; A256818: Number of length n+3 0..1 arrays with at most two downsteps in every n consecutive neighbor pairs.
; 16,32,64,128,245,442,753,1220,1894,2836,4118,5824,8051,10910,14527,19044,24620,31432,39676,49568,61345,75266,91613,110692,132834,158396,187762,221344,259583,302950,351947,407108,469000,538224,615416,701248,796429,901706,1017865,1145732,1286174,1440100,1608462,1792256,1992523,2210350,2446871,2703268,2980772,3280664,3604276,3952992,4328249,4731538,5164405,5628452,6125338,6656780,7224554,7830496,8476503,9164534,9896611,10674820,11501312,12378304,13308080,14292992,15335461,16437978,17603105
mov $2,$0
add $2,5
bin $2,$0
mov $4,$0
mul $0,10
add $0,$2
add $0,6
mov $5,11
add $5,$0
mov $1,$5
sub $1,2
mov $3,$4
mul $3,$4
mul $3,$4
add $1,$3
mov $0,$1
|
; A290922: p-INVERT of the positive integers, where p(S) = 1 - S - 2*S^2.
; 1,5,20,75,279,1040,3881,14485,54060,201755,752959,2810080,10487361,39139365,146070100,545141035,2034494039,7592835120,28336846441,105754550645,394681356140,1472970873915,5497202139519,20515837684160,76566148597121,285748756704325,1066428878220180,3979966756176395
mov $6,$0
add $6,1
mov $7,$0
lpb $6
mov $0,$7
sub $6,1
sub $0,$6
mov $3,4
mov $4,4
lpb $0
sub $0,1
add $4,$3
add $3,$4
add $4,$3
lpe
sub $5,$5
add $5,$3
mov $3,40
mul $3,$5
mov $2,$3
sub $2,80
div $2,120
add $2,1
add $1,$2
lpe
|
#pragma once
#include <string>
#include <list>
#include <variant>
#include <memory>
#include <system_error>
#if defined(RICHTEXT_USE_SYSTEM_UFORMAT)
#include <uformat/texter.hpp>
#else
#include "bundled/uformat/texter.hpp"
#endif
namespace richtext {
enum class tag {
undefined, normal, strong, emphasis, strong_emphasis
};
class span {
public:
using size_type = std::string::size_type;
span() noexcept = default;
span(span const&) = delete;
span& operator = (span const&) = delete;
span(span&&) noexcept = default;
span& operator = (span&&) noexcept = default;
enum tag tag() const noexcept { return tag_; }
std::string const& text() const noexcept { return text_; }
bool empty() const noexcept { return text_.empty(); }
size_type length() const noexcept { return text_.size(); }
span(enum tag tag, std::string text) noexcept:
tag_{tag}, text_{std::move(text)}
{ }
explicit span(std::string text) noexcept:
tag_{tag::normal}, text_{std::move(text)}
{ }
private:
enum tag tag_;
std::string text_;
};
class text {
public:
using items_type = std::list<span>;
using const_iterator = items_type::const_iterator;
using size_type = items_type::size_type;
text() = default;
text(text const&) = delete;
text& operator = (text const&) = delete;
text(text&&) = default;
text& operator = (text&&) = default;
const_iterator begin() const noexcept { return items_.begin(); }
const_iterator end() const noexcept { return items_.end(); }
bool empty() const noexcept { return items_.empty(); }
size_type count() const noexcept { return items_.size(); }
size_type length() const noexcept { return length_; }
explicit text(std::string text) : length_{ text.size() } {
items_.emplace_back(span{ std::move(text) });
}
text&& add(span span) {
length_ += span.length();
items_.emplace_back(std::move(span));
return std::move(*this);
}
text&& add(std::string text) {
length_ += text.length();
items_.emplace_back(span{ std::move(text) });
return std::move(*this);
}
text&& add(tag tag, std::string text) {
length_ += text.length();
items_.emplace_back(span{ tag, std::move(text) });
return std::move(*this);
}
private:
items_type items_;
size_type length_{ 0 };
};
class paragraph {
public:
paragraph() = default;
paragraph(paragraph const&) = delete;
paragraph& operator = (paragraph const&) = delete;
paragraph(paragraph&&) = default;
paragraph& operator = (paragraph&&) = default;
explicit paragraph(text text) noexcept: text_{std::move(text)} { }
explicit paragraph(std::string text) noexcept: text_{std::move(text)} { }
text const& text() const noexcept { return text_; }
paragraph&& add(span span) {
text_.add(std::move(span));
return std::move(*this);
}
paragraph&& add(std::string text) {
text_.add(span{ std::move(text) });
return std::move(*this);
}
paragraph&& add(tag tag, std::string text) {
text_.add(span{ tag, std::move(text) });
return std::move(*this);
}
private:
class text text_;
};
using table_header = std::vector<std::string>;
class table_row {
public:
using items_type = std::vector<span>;
using size_type = items_type::size_type;
using const_iterator = items_type::const_iterator;
table_row() = default;
table_row(table_row const&) = delete;
table_row& operator = (table_row const&) = delete;
table_row(table_row&&) = default;
table_row& operator = (table_row&&) = default;
size_type size() const noexcept { return items_.size(); }
const_iterator begin() const noexcept { return items_.begin(); }
const_iterator end() const noexcept { return items_.end(); }
span const& at(size_type i) const noexcept { return items_[i]; }
table_row&& add(std::string text) {
items_.emplace_back(span{ std::move(text) });
return std::move(*this);
}
table_row&& add(tag tag, std::string text) {
items_.emplace_back(span{ tag, std::move(text) });
return std::move(*this);
}
private:
items_type items_;
};
class table {
public:
using rows_type = std::list<table_row>;
using const_iterator = rows_type::const_iterator;
using size_type = rows_type::size_type;
table() = default;
table(table const&) = delete;
table& operator = (table const&) = delete;
table(table&&) = default;
table& operator = (table&&) = default;
explicit table(table_header header) noexcept: header_{std::move(header)} { }
table_header const& header() const noexcept { return header_; }
const_iterator begin() const noexcept { return rows_.begin(); }
const_iterator end() const noexcept { return rows_.end(); }
size_type columns_count() const noexcept { return header_.size(); }
size_type rows_count() const noexcept { return rows_.size(); }
table&& add(table_row row) {
if (row.size() != header_.size())
return std::move(*this);
rows_.emplace_back(std::move(row));
return std::move(*this);
}
private:
table_header header_;
rows_type rows_;
};
class fragment;
using fragment_ptr = std::unique_ptr<fragment>;
class ordered_list;
class unordered_list {
public:
using items_type = std::list<fragment_ptr>;
using size_type = items_type::size_type;
using const_iterator = items_type::const_iterator;
unordered_list() = default;
unordered_list(unordered_list const&) = delete;
unordered_list& operator = (unordered_list const&) = delete;
unordered_list(unordered_list&&) = default;
unordered_list& operator = (unordered_list&&) = default;
explicit unordered_list(std::string header) noexcept: header_{std::move(header)} { }
std::string const& header() const noexcept { return header_; }
const_iterator begin() const noexcept { return items_.begin(); }
const_iterator end() const noexcept { return items_.end(); }
bool empty() const noexcept { return items_.empty(); }
size_type size() const noexcept { return items_.size(); }
unordered_list&& add(paragraph);
unordered_list&& add(unordered_list);
unordered_list&& add(ordered_list);
private:
std::string header_;
items_type items_;
};
class ordered_list {
public:
using items_type = std::list<fragment_ptr>;
using const_iterator = items_type::const_iterator;
using size_type = items_type::size_type;
ordered_list() = default;
ordered_list(ordered_list const&) = delete;
ordered_list& operator = (ordered_list const&) = delete;
ordered_list(ordered_list&&) = default;
ordered_list& operator = (ordered_list&&) = default;
explicit ordered_list(std::string header) noexcept: header_{ std::move(header) } { }
std::string const& header() const noexcept { return header_; }
const_iterator begin() const noexcept { return items_.begin(); }
const_iterator end() const noexcept { return items_.end(); }
bool empty() const noexcept { return items_.empty(); }
size_type size() const noexcept { return items_.size(); }
ordered_list&& add(paragraph);
ordered_list&& add(unordered_list);
ordered_list&& add(ordered_list);
private:
std::string header_;
items_type items_;
};
enum class fragment_kind {
undefined, paragraph, table, unordered_list, ordered_list, subsection, section
};
class fragment {
public:
using item_type = std::variant<std::monostate, paragraph, table,
unordered_list, ordered_list>;
fragment() = default;
fragment(fragment const&) = delete;
fragment& operator = (fragment const&) = delete;
fragment(fragment&&) = default;
fragment& operator = (fragment&&) = default;
explicit fragment(paragraph paragraph) noexcept: item_{std::move(paragraph)} { }
explicit fragment(table table) noexcept: item_{std::move(table)} { }
explicit fragment(unordered_list unordered_list) noexcept : item_{std::move(unordered_list)} { }
explicit fragment(ordered_list ordered_list) noexcept: item_{std::move(ordered_list)} { }
paragraph const* paragraph() const noexcept { return std::get_if<class paragraph>(&item_); }
table const* table() const noexcept { return std::get_if<class table>(&item_); }
unordered_list const* unordered_list() const noexcept { return std::get_if<class unordered_list>(&item_); }
ordered_list const* ordered_list() const noexcept { return std::get_if<class ordered_list>(&item_); }
fragment_kind kind() const noexcept {
switch(item_.index()) {
case 1 : return fragment_kind::paragraph;
case 2 : return fragment_kind::table;
case 3 : return fragment_kind::unordered_list;
case 4 : return fragment_kind::ordered_list;
default : return fragment_kind::undefined;
}
}
private:
item_type item_;
};
inline unordered_list&& unordered_list::add(paragraph paragraph) {
items_.emplace_back(std::make_unique<fragment>(std::move(paragraph)));
return std::move(*this);
}
inline unordered_list&& unordered_list::add(unordered_list unordered_list) {
items_.emplace_back(std::make_unique<fragment>(std::move(unordered_list)));
return std::move(*this);
}
inline unordered_list&& unordered_list::add(ordered_list ordered_list) {
items_.emplace_back(std::make_unique<fragment>(std::move(ordered_list)));
return std::move(*this);
}
inline ordered_list&& ordered_list::add(paragraph paragraph) {
items_.emplace_back(std::make_unique<fragment>(std::move(paragraph)));
return std::move(*this);
}
inline ordered_list&& ordered_list::add(unordered_list unordered_list) {
items_.emplace_back(std::make_unique<fragment>(std::move(unordered_list)));
return std::move(*this);
}
inline ordered_list&& ordered_list::add(ordered_list ordered_list) {
items_.emplace_back(std::make_unique<fragment>(std::move(ordered_list)));
return std::move(*this);
}
class subsection {
public:
using items_type = std::list<fragment>;
using const_iterator = items_type::const_iterator;
subsection() = default;
subsection(subsection const&) = delete;
subsection& operator = (subsection const&) = delete;
subsection(subsection&&) = default;
subsection& operator = (subsection&&) = default;
explicit subsection(std::string header) noexcept: header_{std::move(header)} { }
const_iterator begin() const noexcept { return items_.begin(); }
const_iterator end() const noexcept { return items_.end(); }
std::string const& header() const noexcept { return header_; }
subsection&& add(paragraph paragraph) {
items_.emplace_back(fragment{ std::move(paragraph) });
return std::move(*this);
}
subsection&& add(table table) {
items_.emplace_back(fragment{std::move(table)});
return std::move(*this);
}
subsection&& add(unordered_list unordered_list) {
items_.emplace_back(fragment{std::move(unordered_list)});
return std::move(*this);
}
subsection&& add(ordered_list ordered_list) {
items_.emplace_back(fragment{std::move(ordered_list)});
return std::move(*this);
}
private:
std::string header_;
items_type items_;
};
class subsection_or_fragment {
public:
using item_type = std::variant<std::monostate, class paragraph, class table,
class unordered_list, class ordered_list,
class subsection>;
subsection_or_fragment() = default;
subsection_or_fragment(subsection_or_fragment const&) = delete;
subsection_or_fragment& operator = (subsection_or_fragment const&) = delete;
subsection_or_fragment(subsection_or_fragment&&) = default;
subsection_or_fragment& operator = (subsection_or_fragment&&) = default;
explicit subsection_or_fragment(paragraph paragraph) noexcept: item_{std::move(paragraph)} { }
explicit subsection_or_fragment(table table) noexcept: item_{std::move(table)} { }
explicit subsection_or_fragment(unordered_list unordered_list) noexcept: item_{std::move(unordered_list)} { }
explicit subsection_or_fragment(ordered_list ordered_list) noexcept: item_{std::move(ordered_list)} { }
explicit subsection_or_fragment(subsection subsection) noexcept: item_{std::move(subsection)} { }
paragraph const* paragraph() const noexcept { return std::get_if<class paragraph>(&item_); }
table const* table() const noexcept { return std::get_if<class table>(&item_); }
unordered_list const* unordered_list() const noexcept { return std::get_if<class unordered_list>(&item_); }
ordered_list const* ordered_list() const noexcept { return std::get_if<class ordered_list>(&item_); }
subsection const* subsection() const noexcept { return std::get_if<class subsection>(&item_); }
fragment_kind kind() const noexcept {
switch(item_.index()) {
case 1 : return fragment_kind::paragraph;
case 2 : return fragment_kind::table;
case 3 : return fragment_kind::unordered_list;
case 4 : return fragment_kind::ordered_list;
case 5 : return fragment_kind::subsection;
default : return fragment_kind::undefined;
}
}
private:
item_type item_;
};
class section {
public:
using items_type = std::list<subsection_or_fragment>;
using const_iterator = items_type::const_iterator;
section() = default;
section(section const&) = delete;
section& operator = (section const&) = delete;
section(section&&) = default;
section& operator = (section&&) = default;
explicit section(std::string header) noexcept: header_{std::move(header)} { }
const_iterator begin() const noexcept { return items_.begin(); }
const_iterator end() const noexcept { return items_.end(); }
std::string const& header() const noexcept { return header_; }
section&& add(paragraph paragraph) {
items_.emplace_back(subsection_or_fragment{ std::move(paragraph) });
return std::move(*this);
}
section&& add(table table) {
items_.emplace_back(subsection_or_fragment{std::move(table)});
return std::move(*this);
}
section&& add(unordered_list unordered_list) {
items_.emplace_back(subsection_or_fragment{std::move(unordered_list)});
return std::move(*this);
}
section&& add(ordered_list ordered_list) {
items_.emplace_back(subsection_or_fragment{std::move(ordered_list)});
return std::move(*this);
}
section&& add(subsection subsection) {
items_.emplace_back(subsection_or_fragment{std::move(subsection)});
return std::move(*this);
}
private:
std::string header_;
items_type items_;
};
class section_or_fragment {
public:
using item_type = std::variant<std::monostate, class paragraph,
class table, class unordered_list, class ordered_list,
class subsection, class section>;
section_or_fragment() = default;
section_or_fragment(section_or_fragment const&) = delete;
section_or_fragment& operator = (section_or_fragment const&) = delete;
section_or_fragment(section_or_fragment&&) = default;
section_or_fragment& operator = (section_or_fragment&&) = default;
explicit section_or_fragment(paragraph paragraph) noexcept: item_{std::move(paragraph)} { }
explicit section_or_fragment(table table) noexcept: item_{std::move(table)} { }
explicit section_or_fragment(unordered_list unordered_list) noexcept: item_{std::move(unordered_list)} { }
explicit section_or_fragment(ordered_list ordered_list) noexcept: item_{std::move(ordered_list)} { }
explicit section_or_fragment(subsection subsection) noexcept: item_{std::move(subsection)} { }
explicit section_or_fragment(section section) noexcept: item_{std::move(section)} { }
paragraph const* paragraph() const noexcept { return std::get_if<class paragraph>(&item_); }
table const* table() const noexcept { return std::get_if<class table>(&item_); }
unordered_list const* unordered_list() const noexcept { return std::get_if<class unordered_list>(&item_); }
ordered_list const* ordered_list() const noexcept { return std::get_if<class ordered_list>(&item_); }
subsection const* subsection() const noexcept { return std::get_if<class subsection>(&item_); }
section const* section() const noexcept { return std::get_if<class section>(&item_); }
fragment_kind kind() const noexcept {
switch(item_.index()) {
case 1 : return fragment_kind::paragraph;
case 2 : return fragment_kind::table;
case 3 : return fragment_kind::unordered_list;
case 4 : return fragment_kind::ordered_list;
case 5 : return fragment_kind::subsection;
case 6 : return fragment_kind::section;
default : return fragment_kind::undefined;
}
}
private:
item_type item_;
};
class document {
public:
using items_type = std::list<section_or_fragment>;
using const_iterator = items_type::const_iterator;
document() = default;
document(document const&) = delete;
document& operator = (document const&) = delete;
document(document&&) = default;
document& operator = (document&&) = default;
explicit document(std::string header) noexcept: header_{std::move(header)} { }
const_iterator begin() const noexcept { return items_.begin(); }
const_iterator end() const noexcept { return items_.end(); }
std::string const& header() const noexcept { return header_; }
document&& add(paragraph paragraph) {
items_.emplace_back(section_or_fragment{ std::move(paragraph) });
return std::move(*this);
}
document&& add(table table) {
items_.emplace_back(section_or_fragment{std::move(table)});
return std::move(*this);
}
document&& add(unordered_list unordered_list) {
items_.emplace_back(section_or_fragment{std::move(unordered_list)});
return std::move(*this);
}
document&& add(ordered_list ordered_list) {
items_.emplace_back(section_or_fragment{std::move(ordered_list)});
return std::move(*this);
}
document&& add(subsection subsection) {
items_.emplace_back(section_or_fragment{std::move(subsection)});
return std::move(*this);
}
document&& add(section section) {
items_.emplace_back(section_or_fragment{std::move(section)});
return std::move(*this);
}
private:
std::string header_;
items_type items_;
};
class formatter {
public:
using string_type = uformat::continuous_texter::string_type;
using size_type = uformat::continuous_texter::size_type;
string_type const& string() const noexcept { return texter_.string(); }
char const* data() const noexcept { return texter_.data(); }
size_type size() const noexcept { return texter_.size(); }
void render(document const& document) {
on_document_begin(document);
if(!document.header().empty()) {
on_document_header(document.header());
}
for(auto const& section_or_fragment: document)
switch(section_or_fragment.kind()) {
case fragment_kind::paragraph:
render(*section_or_fragment.paragraph());
continue;
case fragment_kind::table:
render(*section_or_fragment.table());
continue;
case fragment_kind::unordered_list:
render(*section_or_fragment.unordered_list());
continue;
case fragment_kind::ordered_list:
render(*section_or_fragment.ordered_list());
continue;
case fragment_kind::subsection:
render(*section_or_fragment.subsection());
continue;
case fragment_kind::section:
render(*section_or_fragment.section());
continue;
default:
continue;
}
on_document_end(document);
}
bool write(std::string const& filename, std::error_code& ec) const noexcept {
FILE* file = fopen(filename.data(), "wb+");
if (file == nullptr) {
ec = std::make_error_code(std::errc(errno));
return false;
}
auto const written = fwrite(texter_.data(), sizeof(char), texter_.size(), file);
fclose(file);
if (written != texter_.size()) {
ec = std::make_error_code(std::errc(errno));
return false;
}
return true;
}
protected:
uformat::continuous_texter& texter() noexcept { return texter_; }
virtual void on_document_begin(document const&) { }
virtual void on_document_end(document const&) { }
virtual void on_document_header(std::string const&) { }
virtual void on_text(text const&) { }
virtual void on_paragraph_begin(paragraph const&) { }
virtual void on_paragraph_end(paragraph const&) { }
virtual void on_table_begin(table const&) { }
virtual void on_table_end(table const&) { }
virtual void on_table_header_begin(table_header const&) { }
virtual void on_table_header_end(table_header const&) { }
virtual void on_table_header_cell(std::size_t, std::string const&) { }
virtual void on_table_row_begin(table_row const&) { }
virtual void on_table_row_end(table_row const&) { }
virtual void on_table_cell_begin(std::size_t, span const&) { }
virtual void on_table_cell_end(std::size_t, span const&) { }
virtual void on_table_cell_text(std::size_t, span const&) { }
virtual void on_subsection_begin(subsection const&) { }
virtual void on_subsection_end(subsection const&) { }
virtual void on_subsection_header(std::string const&) { }
virtual void on_section_begin(section const&) { }
virtual void on_section_end(section const&) { }
virtual void on_section_header(std::string const&) { }
virtual void on_unordered_list_begin(unordered_list const&) { }
virtual void on_unordered_list_end(unordered_list const&) { }
virtual void on_unordered_list_header(std::string const&) { }
virtual void on_unordered_list_item_begin(fragment const&) { }
virtual void on_unordered_list_item_end(fragment const&) { }
virtual void on_ordered_list_begin(ordered_list const&) { }
virtual void on_ordered_list_end(ordered_list const&) { }
virtual void on_ordered_list_header(std::string const&) { }
virtual void on_ordered_list_item_begin(std::size_t, fragment const&) { }
virtual void on_ordered_list_item_end(std::size_t, fragment const&) { }
private:
uformat::continuous_texter texter_;
void render(paragraph const& paragraph) {
on_paragraph_begin(paragraph);
on_text(paragraph.text());
on_paragraph_end(paragraph);
}
void render(table const& table) {
on_table_begin(table);
if(!table.header().empty()) {
on_table_header_begin(table.header());
std::size_t i = 0;
for(std::size_t i = 0; i != table.header().size(); ++i)
on_table_header_cell(i, table.header()[i]);
on_table_header_end(table.header());
}
for(auto const& row: table) {
on_table_row_begin(row);
std::size_t i = 0;
for(auto const& cell: row) {
on_table_cell_begin(i, cell);
on_table_cell_text(i, cell);
on_table_cell_end(i, cell);
++i;
}
on_table_row_end(row);
}
on_table_end(table);
}
void render(unordered_list const& unordered_list) {
on_unordered_list_begin(unordered_list);
if (!unordered_list.header().empty())
on_unordered_list_header(unordered_list.header());
for(auto const& item: unordered_list) {
on_unordered_list_item_begin(*item);
switch(item->kind()) {
case fragment_kind::paragraph:
on_text(item->paragraph()->text());
break;
case fragment_kind::unordered_list:
render(*item->unordered_list());
break;
case fragment_kind::ordered_list:
render(*item->ordered_list());
break;
default:
break;
}
on_unordered_list_item_end(*item);
}
on_unordered_list_end(unordered_list);
}
void render(ordered_list const& ordered_list) {
on_ordered_list_begin(ordered_list);
if (!ordered_list.header().empty())
on_ordered_list_header(ordered_list.header());
std::size_t i = 1;
for (auto const& item : ordered_list) {
on_ordered_list_item_begin(i, *item);
switch(item->kind()) {
case fragment_kind::paragraph:
on_text(item->paragraph()->text());
break;
case fragment_kind::unordered_list:
render(*item->unordered_list());
break;
case fragment_kind::ordered_list:
render(*item->ordered_list());
break;
default:
break;
}
on_ordered_list_item_end(i, *item);
++i;
}
on_ordered_list_end(ordered_list);
}
void render(subsection const& subsection) {
on_subsection_begin(subsection);
if(!subsection.header().empty()) {
on_subsection_header(subsection.header());
}
for(auto const& fragment: subsection)
switch(fragment.kind()) {
case fragment_kind::paragraph:
render(*fragment.paragraph());
continue;
case fragment_kind::table:
render(*fragment.table());
continue;
case fragment_kind::unordered_list:
render(*fragment.unordered_list());
continue;
case fragment_kind::ordered_list:
render(*fragment.ordered_list());
continue;
default:
continue;
}
on_subsection_end(subsection);
}
void render(section const& section) {
on_section_begin(section);
if (!section.header().empty()) {
on_section_header(section.header());
}
for(auto const& subsection_or_fragment: section)
switch(subsection_or_fragment.kind()) {
case fragment_kind::paragraph:
render(*subsection_or_fragment.paragraph());
continue;
case fragment_kind::table:
render(*subsection_or_fragment.table());
continue;
case fragment_kind::unordered_list:
render(*subsection_or_fragment.unordered_list());
continue;
case fragment_kind::ordered_list:
render(*subsection_or_fragment.ordered_list());
continue;
case fragment_kind::subsection:
render(*subsection_or_fragment.subsection());
continue;
default:
continue;
}
on_section_end(section);
}
};
}
|
%macro exit 1
mov eax, 1
mov ebx, %1
int 0x80
%endmacro
%macro write 1 ;write n
mov eax, %1
push eax
push fmt
call printf ;printf("%d\n", n)
add esp, 4
%endmacro
%macro divis 1 ;divis n
mov eax, [i]
mov edx, 0
mov ebx, %1
div ebx
cmp edx, 0 ;eax = i % n == 0
%endmacro
section .data
fmt db "%d", 0xA, 0 ;format string for printing numbers
i dd 0 ;counter for iteration
total dd 0 ;sum of numbers divisble by 3 and 5
section .text
extern printf
global _start
sum:
mov eax, [i]
add [total], eax ;total += i
jmp end
_start:
divis 3
jz sum ; if i % 3 == 0, add i to total
divis 5
jz sum ; if i % 5 == 0, add i to total
end:
inc dword [i] ;++i
cmp dword [i], 1000
jl _start ;if i < 1000, continue iteration
write [total] ;print sum of numbers divisible by 3 and 5
exit 0
ret
|
; A099022: a(n) = Sum_{k=0..n} C(n,k)*(2*n-k)!.
; Submitted by Jon Maiga
; 1,3,38,1158,65304,5900520,780827760,142358474160,34209760152960,10478436416945280,3984884716852972800,1842169367191937414400,1017403495472574045158400,661599650478455071589606400,500354503197888042597961267200,435447353708763072625260119808000,432083859959860461174481549553664000,484916532555172220993522369351798784000,611127048680664715752957576737429889024000,859410471899148459248238137543144739151872000,1340912564441170249019237618446466016434749440000
mov $4,$0
mov $6,2
lpb $6
mov $0,$4
sub $6,1
add $0,$6
sub $0,1
mov $1,1
mov $2,1
mov $3,$0
lpb $3
mul $1,2
mul $1,$0
mul $2,$3
add $1,$2
sub $3,1
max $3,1
add $0,$3
lpe
mul $1,$0
mov $0,$1
mul $0,2
add $0,1
mov $4,13
add $5,$2
mov $7,$6
mul $7,$0
add $5,$7
lpe
mov $0,$5
sub $0,479001601
|
db VENOMOTH ; pokedex id
db 70 ; base hp
db 65 ; base attack
db 60 ; base defense
db 90 ; base speed
db 90 ; base special
db BUG ; species type 1
db POISON ; species type 2
db 75 ; catch rate
db 138 ; base exp yield
INCBIN "pic/gsmon/venomoth.pic",0,1 ; 77, sprite dimensions
dw VenomothPicFront
dw VenomothPicBack
; attacks known at lvl 0
db TACKLE
db 0
db 0
db 0
db 0 ; growth rate
; learnset
tmlearn 2,4,6
tmlearn 9,10,12,15
tmlearn 20,21,22
tmlearn 29,31,32
tmlearn 33,34,37,39
tmlearn 44,46
tmlearn 50,55
db BANK(VenomothPicFront)
|
/*
* GraphBuilderAutoCompleteGTest.cpp
*
* Created on: 14.08.2014
* Author: Marvin Ritter (marvin.ritter@gmail.com)
*/
#include <gtest/gtest.h>
#include <algorithm>
#include <tuple>
#include <networkit/graph/Graph.hpp>
#include <networkit/graph/GraphBuilder.hpp>
#include <networkit/auxiliary/Random.hpp>
#include <networkit/auxiliary/Parallel.hpp>
namespace NetworKit {
class GraphBuilderAutoCompleteGTest: public testing::TestWithParam< std::tuple<bool, bool, bool> > {
public:
virtual void SetUp();
protected:
GraphBuilder bHouse;
std::vector< std::pair<node, node> > houseEdgesOut;
std::vector< std::vector<edgeweight> > Ahouse;
count n_house;
count m_house;
bool isGraph() const { return !isWeighted() && !isDirected(); }
bool isWeightedGraph() const { return isWeighted() && !isDirected(); }
bool isDirectedGraph() const { return !isWeighted() && isDirected(); }
bool isWeightedDirectedGraph() const { return isWeighted() && isDirected(); }
bool isWeighted() const;
bool isDirected() const;
bool useParallel() const;
GraphBuilder createGraphBuilder(count n = 0) const;
Graph toGraph(GraphBuilder& b) const;
};
INSTANTIATE_TEST_CASE_P(InstantiationName, GraphBuilderAutoCompleteGTest, testing::Values(
std::make_tuple(false, false, false), // weighted, directed, parallel
std::make_tuple(true, false, false),
std::make_tuple(false, true, false),
std::make_tuple(true, true, false),
std::make_tuple(false, false, true),
std::make_tuple(true, false, true),
std::make_tuple(false, true, true),
std::make_tuple(true, true, true)
));
bool GraphBuilderAutoCompleteGTest::isWeighted() const {
return std::get<0>(GetParam());
}
bool GraphBuilderAutoCompleteGTest::isDirected() const {
return std::get<1>(GetParam());
}
bool GraphBuilderAutoCompleteGTest::useParallel() const {
return std::get<2>(GetParam());
}
GraphBuilder GraphBuilderAutoCompleteGTest::createGraphBuilder(count n) const {
return GraphBuilder(n, isWeighted(), isDirected());
}
Graph GraphBuilderAutoCompleteGTest::toGraph(GraphBuilder& b) const {
return b.toGraph(true, useParallel());
}
void GraphBuilderAutoCompleteGTest::SetUp() {
/*
* 0
* . \
* / \
* / .
* 1 <-- 2
* ^ \ .|
* | \/ |
* | / \ |
* |/ ..
* 3 <-- 4
*
* move you pen from node to node:
* 3 -> 1 -> 0 -> 2 -> 1 -> 4 -> 3 -> 2 -> 4
*/
n_house = 5;
m_house = 8;
bHouse = createGraphBuilder(5);
houseEdgesOut = {
{3, 1},
{1, 0},
{0, 2},
{2, 1},
{1, 4},
{4, 3},
{3, 2},
{2, 4}
};
Ahouse = {n_house, std::vector<edgeweight>(n_house, 0.0)};
edgeweight ew = 1.0;
for (auto& e : houseEdgesOut) {
node u = e.first;
node v = e.second;
bHouse.addHalfOutEdge(u, v, ew);
Ahouse[u][v] = ew;
if (!bHouse.isDirected()) {
Ahouse[v][u] = ew;
}
if (bHouse.isWeighted()) {
ew += 1.0;
}
}
}
TEST_P(GraphBuilderAutoCompleteGTest, testEmptyGraph) {
auto b = createGraphBuilder();
ASSERT_EQ(0u, b.numberOfNodes());
Graph G = toGraph(b);
ASSERT_EQ(0u, G.numberOfNodes());
ASSERT_EQ(0u, G.numberOfEdges());
ASSERT_TRUE(G.isEmpty());
}
TEST_P(GraphBuilderAutoCompleteGTest, testAddNode) {
auto b = createGraphBuilder();
b.addNode();
ASSERT_EQ(1u, b.numberOfNodes());
b.addNode();
b.addNode();
ASSERT_EQ(3u, b.numberOfNodes());
Graph G = toGraph(b);
ASSERT_TRUE(G.hasNode(0));
ASSERT_TRUE(G.hasNode(1));
ASSERT_TRUE(G.hasNode(2));
ASSERT_FALSE(G.hasNode(3));
ASSERT_EQ(3u, G.numberOfNodes());
ASSERT_EQ(0u, G.numberOfEdges());
ASSERT_FALSE(G.isEmpty());
}
/** NODE PROPERTIES **/
TEST_P(GraphBuilderAutoCompleteGTest, testDegree) {
Graph Ghouse = toGraph(this->bHouse);
if (isDirected()) {
ASSERT_EQ(1u, Ghouse.degree(0));
ASSERT_EQ(2u, Ghouse.degree(1));
ASSERT_EQ(2u, Ghouse.degree(2));
ASSERT_EQ(2u, Ghouse.degree(3));
ASSERT_EQ(1u, Ghouse.degree(4));
} else {
ASSERT_EQ(2u, Ghouse.degree(0));
ASSERT_EQ(4u, Ghouse.degree(1));
ASSERT_EQ(4u, Ghouse.degree(2));
ASSERT_EQ(3u, Ghouse.degree(3));
ASSERT_EQ(3u, Ghouse.degree(4));
}
}
TEST_P(GraphBuilderAutoCompleteGTest, testDegreeIn) {
Graph Ghouse = toGraph(this->bHouse);
if (isDirected()) {
ASSERT_EQ(1u, Ghouse.degreeIn(0));
ASSERT_EQ(2u, Ghouse.degreeIn(1));
ASSERT_EQ(2u, Ghouse.degreeIn(2));
ASSERT_EQ(1u, Ghouse.degreeIn(3));
ASSERT_EQ(2u, Ghouse.degreeIn(4));
} else {
ASSERT_EQ(2u, Ghouse.degreeIn(0));
ASSERT_EQ(4u, Ghouse.degreeIn(1));
ASSERT_EQ(4u, Ghouse.degreeIn(2));
ASSERT_EQ(3u, Ghouse.degreeIn(3));
ASSERT_EQ(3u, Ghouse.degreeIn(4));
}
}
TEST_P(GraphBuilderAutoCompleteGTest, testDegreeOut) {
Graph Ghouse = toGraph(this->bHouse);
if (isDirected()) {
ASSERT_EQ(1u, Ghouse.degreeOut(0));
ASSERT_EQ(2u, Ghouse.degreeOut(1));
ASSERT_EQ(2u, Ghouse.degreeOut(2));
ASSERT_EQ(2u, Ghouse.degreeOut(3));
ASSERT_EQ(1u, Ghouse.degreeOut(4));
} else {
ASSERT_EQ(2u, Ghouse.degreeOut(0));
ASSERT_EQ(4u, Ghouse.degreeOut(1));
ASSERT_EQ(4u, Ghouse.degreeOut(2));
ASSERT_EQ(3u, Ghouse.degreeOut(3));
ASSERT_EQ(3u, Ghouse.degreeOut(4));
}
}
/** EDGE MODIFIERS **/
TEST_P(GraphBuilderAutoCompleteGTest, testAddHalfEdge) {
auto b = createGraphBuilder(3);
// Graph with 2 normal edges
b.addHalfEdge(0, 1, 4.51);
b.addHalfEdge(1, 2, 2.39);
Graph G = toGraph(b);
ASSERT_EQ(2u, G.numberOfEdges());
ASSERT_FALSE(G.hasEdge(0, 2)); // was never added
ASSERT_TRUE(G.hasEdge(0, 1));
ASSERT_TRUE(G.hasEdge(1, 2));
ASSERT_FALSE(G.hasEdge(2, 2)); // will be added later
// check weights
if (G.isWeighted()) {
ASSERT_EQ(4.51, G.weight(0, 1));
ASSERT_EQ(2.39, G.weight(1, 2));
} else {
ASSERT_EQ(defaultEdgeWeight, G.weight(0, 1));
ASSERT_EQ(defaultEdgeWeight, G.weight(1, 2));
}
if (G.isDirected()) {
ASSERT_FALSE(G.hasEdge(1, 0));
ASSERT_FALSE(G.hasEdge(2, 1));
// add edge in the other direction
// note: bidirectional edges are not supported, so both edges have different weights
G.addEdge(2, 1, 6.23);
ASSERT_TRUE(G.hasEdge(2, 1));
if (G.isWeighted()) {
ASSERT_EQ(2.39, G.weight(1, 2));
ASSERT_EQ(6.23, G.weight(2, 1));
} else {
ASSERT_EQ(defaultEdgeWeight, G.weight(2, 1));
}
} else {
ASSERT_TRUE(G.hasEdge(1, 0));
ASSERT_TRUE(G.hasEdge(2, 1));
if (G.isWeighted()) {
ASSERT_EQ(4.51, G.weight(1, 0));
ASSERT_EQ(2.39, G.weight(2, 1));
} else {
ASSERT_EQ(defaultEdgeWeight, G.weight(1, 0));
ASSERT_EQ(defaultEdgeWeight, G.weight(2, 1));
}
}
}
/** GLOBAL PROPERTIES **/
TEST_P(GraphBuilderAutoCompleteGTest, testIsWeighted) {
ASSERT_EQ(isWeighted(), this->bHouse.isWeighted());
Graph Ghouse = toGraph(this->bHouse);
ASSERT_EQ(isWeighted(), Ghouse.isWeighted());
}
TEST_P(GraphBuilderAutoCompleteGTest, testIsDirected) {
ASSERT_EQ(isDirected(), this->bHouse.isDirected());
Graph Ghouse = toGraph(this->bHouse);
ASSERT_EQ(isDirected(), Ghouse.isDirected());
}
TEST_P(GraphBuilderAutoCompleteGTest, testNumberOfSelfLoops) {
auto b = createGraphBuilder(3);
b.addHalfEdge(0, 1);
b.addHalfEdge(0, 0);
Graph G = toGraph(b);
ASSERT_EQ(1u, G.numberOfSelfLoops());
}
TEST_P(GraphBuilderAutoCompleteGTest, testUpperNodeIdBound) {
ASSERT_EQ(5u, this->bHouse.upperNodeIdBound());
Graph Ghouse = toGraph(this->bHouse);
ASSERT_EQ(5u, Ghouse.upperNodeIdBound());
}
/** EDGE ATTRIBUTES **/
TEST_P(GraphBuilderAutoCompleteGTest, testSetWeight) {
auto b = createGraphBuilder(10);
b.addHalfEdge(0, 1);
b.addHalfEdge(1, 2);
if (isWeighted()) {
// edges should get weight defaultWeight on creation and setWeight should overwrite this
b.setWeight(1, 2, 2.718);
// setting an edge weight should create the edge if it doesn't exists
b.setWeight(5, 6, 56.0);
// directed graphs are not symmetric, undirected are
b.setWeight(3, 4, 2.718);
if (isDirected()) {
b.setWeight(4, 3, 5.243);
}
// self-loop
b.addHalfEdge(8, 8, 2.5);
b.setWeight(8, 8, 3.14);
Graph G = toGraph(b);
ASSERT_TRUE(G.checkConsistency());
// edges should get weight defaultWeight on creation and setWeight should overwrite this
ASSERT_EQ(defaultEdgeWeight, G.weight(0, 1));
ASSERT_EQ(2.718, G.weight(1, 2));
if (isDirected()) {
ASSERT_EQ(nullWeight, G.weight(1, 0));
ASSERT_EQ(nullWeight, G.weight(2, 1));
} else {
// undirected graph is symmetric
ASSERT_EQ(defaultEdgeWeight, G.weight(1, 0));
ASSERT_EQ(2.718, G.weight(2, 1));
}
// setting an edge weight should create the edge if it doesn't exists
ASSERT_EQ(56.0, G.weight(5, 6));
ASSERT_EQ(isDirected() ? nullWeight : 56.0, G.weight(6, 5));
ASSERT_TRUE(G.hasEdge(5, 6));
// directed graphs are not symmetric, undirected are
if (isDirected()) {
ASSERT_EQ(2.718, G.weight(3, 4));
ASSERT_EQ(5.243, G.weight(4, 3));
} else {
// we have actually 2 edges in both direction. It is not defined which weight is returned.
ASSERT_TRUE(G.weight(3, 4) == 2.718 || G.weight(3, 4) == 5.243);
ASSERT_TRUE(G.weight(4, 3) == 2.718 || G.weight(4, 3) == 5.243);
}
// self-loop
ASSERT_EQ(3.14, G.weight(8, 8));
}
}
/** toGraph **/
TEST_P(GraphBuilderAutoCompleteGTest, testSameAsGraph) {
Aux::Random::setSeed(1, false);
const double epsilon = 1e-6;
const count runs = 100;
const count n_max = 100;
// in each loop run we will create a random graph (using a GraphBuilder and a Graph)
// we will only use methods that both GraphBuilder and Graph support and
for (index i = 0; i < runs; i++) {
count n = Aux::Random::integer(n_max);
auto b = createGraphBuilder(n);
Graph G_expected(n, isWeighted(), isDirected());
G_expected.forNodes([&](node v) {
double p = Aux::Random::probability();
// if we change edges we have to keep in mind, that GraphBuilder is designed to keep only half-edges.
// e.g. if we have already added an edge v -> u, changing the weight of u -> v might create a new edge in the builder but change the existing edge in G_expected (does not apply for directed graphs)
if (p < 0.1) { // new node
n++;
b.addNode();
G_expected.addNode();
} else { // new edge
node u = Aux::Random::integer(v, n - 1); // self-loops possible
edgeweight ew = Aux::Random::probability();
b.addHalfEdge(v, u, ew);
G_expected.addEdge(v, u, ew);
}
if (isWeighted()) {
node u = Aux::Random::integer(v, n - 1); // self-loops possible
edgeweight ew = Aux::Random::probability();
if (p < 0.5) {
b.setWeight(v, u, ew);
G_expected.setWeight(v, u, ew);
} else {
b.increaseWeight(v, u, ew);
G_expected.increaseWeight(v, u, ew);
}
}
});
Graph G_actual = toGraph(b);
// check for correct graph properties
ASSERT_EQ(G_expected.numberOfNodes(), G_actual.numberOfNodes());
ASSERT_EQ(G_expected.numberOfEdges(), G_actual.numberOfEdges());
ASSERT_EQ(G_expected.upperNodeIdBound(), G_actual.upperNodeIdBound());
ASSERT_EQ(G_expected.numberOfSelfLoops(), G_actual.numberOfSelfLoops());
// compare nodes and edges of G_expected and G_actual
G_expected.forNodes([&](node v) {
ASSERT_TRUE(G_actual.hasNode(v));
ASSERT_EQ(G_expected.degree(v), G_actual.degree(v));
ASSERT_EQ(G_expected.degreeIn(v), G_actual.degreeIn(v));
ASSERT_EQ(G_expected.degreeOut(v), G_actual.degreeOut(v));
ASSERT_NEAR(G_expected.weightedDegree(v), G_actual.weightedDegree(v), epsilon);
ASSERT_NEAR(G_expected.volume(v), G_actual.volume(v), epsilon);
});
G_expected.forEdges([&](node u, node v, edgeweight ew) {
ASSERT_TRUE(G_actual.hasEdge(u, v));
ASSERT_NEAR(ew, G_actual.weight(u, v), epsilon);
});
// make sure that G_actual has not more nodes/edges than G_expected
G_actual.forNodes([&](node v) {
ASSERT_TRUE(G_expected.hasNode(v));
});
G_actual.forEdges([&](node u, node v) {
ASSERT_TRUE(G_expected.hasEdge(u, v));
});
}
}
TEST_P(GraphBuilderAutoCompleteGTest, testForValidStateAfterToGraph) {
Graph Ghouse = toGraph(this->bHouse);
ASSERT_TRUE(this->bHouse.isEmpty());
ASSERT_EQ(0u, this->bHouse.numberOfNodes());
ASSERT_EQ(0u, this->bHouse.upperNodeIdBound());
ASSERT_EQ(isWeighted(), this->bHouse.isWeighted());
ASSERT_EQ(isDirected(), this->bHouse.isDirected());
this->bHouse.forNodes([&](node) {
FAIL();
});
Graph G1 = toGraph(this->bHouse);
ASSERT_TRUE(G1.isEmpty());
ASSERT_EQ(0u, G1.numberOfNodes());
ASSERT_EQ(0u, G1.upperNodeIdBound());
ASSERT_EQ(isWeighted(), G1.isWeighted());
ASSERT_EQ(isDirected(), G1.isDirected());
node v = this->bHouse.addNode();
node u = this->bHouse.addNode();
this->bHouse.addHalfEdge(v, u, 0.25);
Graph G2 = toGraph(this->bHouse);
ASSERT_FALSE(G2.isEmpty());
ASSERT_EQ(2u, G2.numberOfNodes());
ASSERT_EQ(1u, G2.numberOfEdges());
ASSERT_TRUE(G2.hasEdge(v, u));
if (!isDirected()) {
ASSERT_TRUE(G2.hasEdge(u, v));
}
if (isWeighted()) {
ASSERT_EQ(0.25, G2.weight(v, u));
} else {
ASSERT_EQ(1.0, G2.weight(v, u));
}
}
/** NODE ITERATORS **/
TEST_P(GraphBuilderAutoCompleteGTest, testForNodes) {
auto b = createGraphBuilder(3);
std::vector<bool> visited(4, false);
b.forNodes([&](node v) {
ASSERT_FALSE(visited[v]);
if (v == 2) {
b.addNode();
}
visited[v] = true;
});
for (bool x : visited) {
ASSERT_TRUE(x);
}
}
TEST_P(GraphBuilderAutoCompleteGTest, testParallelForNodes) {
std::vector<node> visited;
this->bHouse.parallelForNodes([&](node u) {
#pragma omp critical
visited.push_back(u);
});
Aux::Parallel::sort(visited.begin(), visited.end());
ASSERT_EQ(5u, visited.size());
for (index i = 0; i < this->bHouse.upperNodeIdBound(); i++) {
ASSERT_EQ(i, visited[i]);
}
}
TEST_P(GraphBuilderAutoCompleteGTest, testForNodePairs) {
count n = 10;
auto b = createGraphBuilder(n);
std::vector< std::vector<bool> > visited(n, std::vector<bool>(n, false));
b.forNodePairs([&](node u, node v) {
if (visited[u][v] || visited[v][u]) {
FAIL();
} else {
visited[u][v] = true;
}
});
for (node u = 0; u < n; u++) {
for (node v = 0; v < n; v++) {
if (u == v) {
ASSERT_FALSE(visited[u][u]);
} else {
ASSERT_TRUE(visited[u][v] ^ visited[v][u]);
}
}
}
}
TEST_P(GraphBuilderAutoCompleteGTest, testParallelForNodePairs) {
count n = 10;
auto b = createGraphBuilder(n);
std::vector< std::vector<bool> > visited(n, std::vector<bool>(n, false));
b.forNodePairs([&](node u, node v) {
if (visited[u][v]) {
FAIL();
} else {
visited[u][v] = true;
}
});
for (node u = 0; u < n; u++) {
for (node v = 0; v < n; v++) {
if (u == v) {
ASSERT_FALSE(visited[u][u]);
} else {
ASSERT_TRUE(visited[u][v] ^ visited[v][u]);
}
}
}
}
} /* namespace NetworKit */
|
; A244058: n-th term of the 'Reverse and Add!' sequence starting with n.
; Submitted by Jon Maiga
; 1,4,12,77,44,363,484,4444,79497,14003,88088,175857,1596595,1716517,17794887,13528163,176599676,839546037,1317544822,853595347,8836886388,13236127322,13297007933,668823329856,175304440267,909153350908,9317488848228,8813200023188,84990400509047,47337877873374,85806211160857,159080900918995,1836791253097647,7392457106543036,7756400989936676,159461943744915405,86554579308545557,683299767657992386,9780847499057381868,188035114741144187,1366599524425984772,93189525099063489228,53803389955998341824
mov $1,$0
mov $2,$0
lpb $2
mov $0,$1
add $0,1
seq $0,4086 ; Read n backwards (referred to as R(n) in many sequences).
add $1,$0
sub $2,1
lpe
mov $0,$1
add $0,1
|
; external functions from X11 library
extern XOpenDisplay
extern XDisplayName
extern XCloseDisplay
extern XCreateSimpleWindow
extern XMapWindow
extern XRootWindow
extern XSelectInput
extern XFlush
extern XCreateGC
extern XSetForeground
extern XDrawLine
extern XNextEvent
; external functions from stdio library (ld-linux-x86-64.so.2)
extern exit
extern printf
%define StructureNotifyMask 131072
%define KeyPressMask 1
%define ButtonPressMask 4
%define MapNotify 19
%define KeyPress 2
%define ButtonPress 4
%define Expose 12
%define ConfigureNotify 22
%define CreateNotify 16
%define QWORD 8
%define DWORD 4
%define WORD 2
%define BYTE 1
global main
section .bss
display_name: resq 1
screen: resd 1
depth: resd 1
connection: resd 1
width: resd 1
height: resd 1
window: resq 1
gc: resq 1
section .data
question1: db "Valeur X = %f , Y = %f , Z = %f",10,0
questionCount: db "Valeur de CountPF = %d",10,0
questionf: db "Valeur = %f",10,0
questionpl1: db "PL1 = %d - PL2 = %d",10,0
questionV: db "V1 = %d - V2 = %d",10,0
questionCo: db "X1 = %f - Y1 = %f - Z1 = %f",10,0
questionCo2: db "X2 = %f - Y2 = %f - Z2 = %f",10,0
questionPrime: db "Xprime1 = %f - Yprime1 = %f",10,0
questionPrime2: db "Xprime2 = %f - Yprime2 = %f",10,0
questionTest: db "Test conversion x1 = %d - y1 = %d",10,0
questionTest2: db "Test conversion x2 = %d - y2 = %d",10,0
questionTopBot: db "topDiv = %f - botDiv = %f",10,0
questionNormal: db "A = %d - B = %d",10,0
questionNormal2: db "Normal = %d",10,0
fenetre: db 0
tabPoint: db 0
countPoint: db 0
countFace: db 0
nFace: db 0
boucleP: db 0
pointLec1: db 0
pointLec2: db 0
A: db 0
B: db 0
C: db 0
xA: dd 0
xB: dd 0
xC: dd 0
yA: dd 0
yB: dd 0
yC: dd 0
xBA: dd 0
xBC: dd 0
yBA: dd 0
yBC: dd 0
normal: dd 0
x1: dd 0
y1: dd 0
z1: dd 0
x2: dd 0
y2: dd 0
z2: dd 0
v1: db 0
v2: db 0
df: dd 400.0
zoff: dd 400.0
xoff: dd 200.0
yoff: dd 200.0
topvdiv: dd 0
botdiv: dd 0
xP1: dd 0
yP1: dd 0
xP2: dd 0
yP2: dd 0
x1C: dd 0
y1C: dd 0
x2C: dd 0
y2C: dd 0
topDiv: dd 0
botDiv: dd 0
event: times 24 dq 0
; Un point par ligne sous la forme X,Y,Z
dodec: dd 0.0,50.0,80.901699 ; point 0
dd 0.0,-50.0,80.901699 ; point 1
dd 80.901699,0.0,50.0 ; point 2
dd 80.901699,0.0,-50.0 ; point 3
dd 0.0,50.0,-80.901699 ; point 4
dd 0.0,-50.0,-80.901699 ; point 5
dd -80.901699,0.0,-50.0 ; point 6
dd -80.901699,0.0,50.0 ; point 7
dd 50.0,80.901699,0.0 ; point 8
dd -50.0,80.901699,0.0 ; point 9
dd -50.0,-80.901699,0.0 ; point 10
dd 50.0,-80.901699,0.0 ; point 11
; Une face par ligne, chaque face est composée de 3 points tels que numérotés dans le tableau dodec ci-dessus
; Les points sont donnés dans le bon ordre pour le calcul des normales.
; Exemples :
; pour la première face (0,8,9), on fera le produit vectoriel des vecteurs 80 (vecteur des points 8 et 0) et 89 (vecteur des points 8 et 9)
; pour la deuxième face (0,2,8), on fera le produit vectoriel des vecteurs 20 (vecteur des points 2 et 0) et 28 (vecteur des points 2 et 8)
; etc...
faces: db 0,8,9,0
db 0,2,8,0
db 2,3,8,2
db 3,4,8,3
db 4,9,8,4
db 6,9,4,6
db 7,9,6,7
db 7,0,9,7
db 1,10,11,1
db 1,11,2,1
db 11,3,2,11
db 11,5,3,11
db 11,10,5,11
db 10,6,5,10
db 10,7,6,10
db 10,1,7,10
db 0,7,1,0
db 0,1,2,0
db 3,5,4,3
db 5,6,4,5
section .text
;##################################################
;########### PROGRAMME PRINCIPAL ##################
;##################################################
main:
calculNormal:
mov al,4
mul byte[nFace]
mov byte[tabPoint],al ;tabPoint = 4 * nFace
movzx ecx,byte[tabPoint]
mov al,byte[faces+ecx] ;récupere le numéro du point par apport a Nface
mov byte[A],al ;A = poisition dans le tableau en fonction de count
inc byte[tabPoint]
movzx ecx,byte[tabPoint]
mov al,byte[faces+ecx] ;récupere le numéro du point par apport a Nface
mov byte[B],al ;A = poisition dans le tableau en fonction de count
inc byte[tabPoint]
movzx ecx,byte[tabPoint]
mov al,byte[faces+ecx] ;récupere le numéro du point par apport a Nface
mov byte[C],al ;A = poisition dans le tableau en fonction de count
;Coordonée A
mov al,3
mul byte[A]
mov byte[v1],al ;On multiplie PointLec1 directement pour juste incrémenté apres
movzx ecx,byte[v1]
movss xmm0,dword[dodec+ecx*DWORD] ;cherche la position de X2 en fonction de V1 dans dodec
movss dword[xA],xmm0
inc byte[v1]
movzx ecx,byte[v1]
movss xmm0,dword[dodec+ecx*DWORD] ;cherche la position de y2 en fonction de V1 dans dodec
movss dword[yA],xmm0
;Coordonée B
mov al,3
mul byte[B]
mov byte[v1],al ;On multiplie PointLec1 directement pour juste incrémenté apres
movzx ecx,byte[v1]
movss xmm0,dword[dodec+ecx*DWORD] ;cherche la position de X2 en fonction de V1 dans dodec
movss dword[xB],xmm0
inc byte[v1]
movzx ecx,byte[v1]
movss xmm0,dword[dodec+ecx*DWORD] ;cherche la position de y2 en fonction de V1 dans dodec
movss dword[yB],xmm0
;Coordonée C
mov al,3
mul byte[C]
mov byte[v1],al ;On multiplie PointLec1 directement pour juste incrémenté apres
movzx ecx,byte[v1]
movss xmm0,dword[dodec+ecx*DWORD] ;cherche la position de X2 en fonction de V1 dans dodec
movss dword[xC],xmm0
inc byte[v1]
movzx ecx,byte[v1]
movss xmm0,dword[dodec+ecx*DWORD] ;cherche la position de y2 en fonction de V1 dans dodec
movss dword[yC],xmm0
MathsNormal:
movss xmm0,dword[xA]
movss xmm1,dword[xB]
subss xmm0,xmm1
movss dword[xBA],xmm0 ;calcul de xBA
movss xmm0,dword[xC]
movss xmm1,dword[xB]
subss xmm0,xmm1
movss dword[xBC],xmm0 ;calcul de xBC
movss xmm0,dword[yA]
movss xmm1,dword[yB]
subss xmm0,xmm1
movss dword[yBA],xmm0 ;calcul de yBA
movss xmm0,dword[yC]
movss xmm1,dword[yB]
subss xmm0,xmm1
movss dword[yBC],xmm0 ;calcul de yBC
movss xmm0,dword[xBA]
mulss xmm0,[yBC] ;xBA* yBC -> xmm0
movss xmm1,dword[yBA]
mulss xmm1,[xBC] ; yBA * xBC -> xmm1
subss xmm0,xmm1 ; normal = xmm0 - xmm1
cvtss2si eax,xmm0 ;Conversion en entier
mov dword[normal],eax ;normal en entier dword
cmp dword[normal],0
jg boucleFace ;si supérieur à 0 on retourne en bas sans dessin
;sinon on continue et dessine
bouclePoint:
cmp byte[countPoint],3
jae boucleFace
mov al,4
mul byte[nFace]
add al,byte[countPoint]
mov byte[tabPoint],al ;tabPoint = 4 * nFace
movzx ecx,byte[tabPoint]
mov al,byte[faces+ecx] ;récupere le numéro du point par apport a Nface
mov byte[pointLec1],al ;PL1 = poisition dans le tableau en fonction de count
inc byte[tabPoint]
inc byte[countPoint]
movzx ecx,byte[tabPoint]
mov al,byte[faces+ecx]
mov byte[pointLec2],al ;PL2 = PL1 + 1 dans le tableau
;Coordonée P1
mov al,3
mul byte[pointLec1]
mov byte[v1],al ;On multiplie PointLec1 directement pour juste incrémenté apres
movzx ecx,byte[v1]
movss xmm0,dword[dodec+ecx*DWORD] ;cherche la position de X2 en fonction de V1 dans dodec
movss dword[x1],xmm0
inc byte[v1]
movzx ecx,byte[v1]
movss xmm0,dword[dodec+ecx*DWORD] ;cherche la position de y2 en fonction de V1 dans dodec
movss dword[y1],xmm0
inc byte[v1]
movzx ecx,byte[v1]
movss xmm0,dword[dodec+ecx*DWORD] ;cherche la position de z2 en fonction de V1 dans dodec
movss dword[z1],xmm0
;Coordonée P2
mov al,3
mul byte[pointLec2]
mov byte[v2],al
movzx ecx,byte[v2]
movss xmm0,dword[dodec+ecx*DWORD] ;cherche la position de X2 en fonction de V1 dans dodec
movss dword[x2],xmm0
inc byte[v2]
movzx ecx,byte[v2]
movss xmm0,dword[dodec+ecx*DWORD] ;cherche la position de y2 en fonction de V1 dans dodec
movss dword[y2],xmm0
inc byte[v2]
movzx ecx,byte[v2]
movss xmm0,dword[dodec+ecx*DWORD] ;cherche la position de z2 en fonction de V1 dans dodec
movss dword[z2],xmm0
maths3D:
;x1'
;topdiv = (df * x1)
movss xmm0,dword[df]
mulss xmm0,[x1]
movss dword[topDiv],xmm0
;botdiv = z1 + zoff
movss xmm1,dword[z1]
addss xmm1,[zoff]
movss dword[botDiv],xmm1
;x1' = (topdov / botdiv) + xoff
divss xmm0,xmm1
addss xmm0,[xoff]
movss dword[xP1],xmm0
cvtss2si eax,xmm0 ;Conversion en entier
mov dword[x1C],eax
;y1'
;topdiv = (df * y1)
movss xmm0,dword[df]
mulss xmm0,[y1]
movss dword[topDiv],xmm0
;botdiv = z1 + zoff
movss xmm1,dword[z1]
addss xmm1,[zoff]
movss dword[botDiv],xmm1
;y1' = (topdov / botdiv) + yoff
divss xmm0,xmm1
addss xmm0,[yoff]
movss dword[yP1],xmm0
cvtss2si eax,xmm0 ;Conversion en entier
mov dword[y1C],eax
;x2'
;topdiv = (df * x2)
movss xmm0,dword[df]
mulss xmm0,[x2]
movss dword[topDiv],xmm0
;botdiv = z2 + zoff
movss xmm1,dword[z2]
addss xmm1,[zoff]
movss dword[botDiv],xmm1
;x2' = (topdov / botdiv) + xoff
divss xmm0,xmm1
addss xmm0,[xoff]
movss dword[xP2],xmm0
cvtss2si eax,xmm0 ;Conversion en entier
mov dword[x2C],eax
;y2'
;topdiv = (df * y2)
movss xmm0,dword[df]
mulss xmm0,[y2]
movss dword[topDiv],xmm0
;botdiv = z2 + zoff
movss xmm1,dword[z2]
addss xmm1,[zoff]
movss dword[botDiv],xmm1
;y2' = (topdov / botdiv) + yoff
divss xmm0,xmm1
addss xmm0,[yoff]
movss dword[yP2],xmm0
cvtss2si eax,xmm0 ;Conversion en entier
mov dword[y2C],eax
affichage:
;lecture Point1 et Point2 du tableau Faces
push rbp
mov rdi,questionNormal
movzx rsi,byte[pointLec1]
movzx rdx,byte[pointLec2]
mov rax,0
call printf
pop rbp
push rbp
mov rdi,questionNormal2
xor rsi,rsi
mov esi,dword[normal]
mov rax,0
call printf
pop rbp
cmp byte[fenetre],1
je prog_principal
;####################################
;## Code de création de la fenêtre ##
;####################################
mov byte[fenetre],1
xor rdi,rdi
call XOpenDisplay ; Création de display
mov qword[display_name],rax ; rax=nom du display
mov rax,qword[display_name]
mov eax,dword[rax+0xe0]
mov dword[screen],eax
mov rdi,qword[display_name]
mov esi,dword[screen]
call XRootWindow
mov rbx,rax
mov rdi,qword[display_name]
mov rsi,rbx
mov rdx,10
mov rcx,10
mov r8,400 ; largeur
mov r9,400 ; hauteur
push 0xFFFFFF ; background 0xRRGGBB
push 0x00FF00
push 1
call XCreateSimpleWindow
mov qword[window],rax
mov rdi,qword[display_name]
mov rsi,qword[window]
mov rdx,131077 ;131072
call XSelectInput
mov rdi,qword[display_name]
mov rsi,qword[window]
call XMapWindow
mov rdi,qword[display_name]
mov rsi,qword[window]
mov rdx,0
mov rcx,0
call XCreateGC
mov qword[gc],rax
mov rdi,qword[display_name]
mov rsi,qword[gc]
mov rdx,0x000000 ; Couleur du crayon
call XSetForeground
; boucle de gestion des évènements
boucle:
mov rdi,qword[display_name]
mov rsi,event
call XNextEvent
cmp dword[event],ConfigureNotify
je prog_principal
cmp dword[event],KeyPress
je closeDisplay
jmp boucle
;###########################################
;## Fin du code de création de la fenêtre ##
;###########################################
;############################################
;## Ici commence le programme principal ##
;############################################
prog_principal:
mov rdi,qword[display_name]
mov rsi,qword[window]
mov rdx,qword[gc]
mov ecx,dword[x1C] ; coordonnée source en x
mov r8d,dword[y1C] ; coordonnée source en y
mov r9d,dword[x2C] ; coordonnée destination en x
push qword[y2C] ; coordonnée destination en y
call XDrawLine
jmp bouclePoint
boucleFace:
;numéro de la face pour le tableau Faces
;La boucle prend fin quand nFace > 20 apres le dessin
inc byte[nFace]
cmp byte[nFace],19
ja flush
mov byte[countPoint],0 ;on remet notre count à 0
jmp calculNormal
;##############################################
;## Ici se termine VOTRE programme principal ##
;############################################## jb boucle
jmp flush
flush:
mov rdi,qword[display_name]
call XFlush
jmp boucle
mov rax,34
syscall
closeDisplay:
mov rax,qword[display_name]
mov rdi,rax
call XCloseDisplay
xor rdi,rdi
call exit
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.