text
stringlengths
1
1.05M
module SHOP levelText: db "Level: ",TEXT_END userCoins: db "Coins: ",TEXT_END userLives: db "Lives: ",TEXT_END continuations: db "1 - Life: 55 coins",TEXT_END ; invulnerable: db "Invulnerable: 75",TEXT_END ; 1 time ; skipLevel: db "Skip level: 100",TEXT_END currentLevelPassword: db "2 - Password: 120 coins",TEXT_END complete: db "fire to complete",TEXT_END notMoney: db "not enough money",TEXT_END successfulPurchase: db "successful purchase",TEXT_END pricelist: db "Pricelist:",TEXT_END sale: db "SALE",TEXT_END ;--------------------------------------------- ; FIXME fool protection does not work if you buy a password, then play and die, after death in the store you can buy the same password again. init: call PASS.clearData call fadeOutFull call clearScreen call displayShop ld a,SYSTEM.SHOP_UPDATE ret ;--------------------------------------------- update: ld de,#0e08 ; Y,X ld bc,#0210 ; height, width call blinkArea ld de,#0801 ld bc,#0801 call blinkArea ld de,#081E ld bc,#0801 call blinkArea ld a,(delta2) inc a cp 75 jr c,.m2 push af call hideMessage pop af dec a .m2: ld (delta2),a call showCoinsLives ld a,(lastKeyPresed) push af call CONTROL.digListener pop bc ld a,(de) ld (lastKeyPresed),a ; save last key pressed cp b jr nz,.more ; space key ld bc,#7FFE in a,(c) bit 0,a jr z,.toGame ld a,SYSTEM.SHOP_UPDATE ret .more: cp '1' push af call z,addLife pop af cp '2' push af call z,showPassword pop af cp '0' jr z,.toGame cp '5' jr z,.toGame ld a,SYSTEM.SHOP_UPDATE ret nz .toGame: ld a,SYSTEM.GAME_INIT ret ;--------------------------------------------- hideMessage: xor a ld de,#1206 ; Y,X ld bc,#0214 ; height, width jp fillArea ;--------------------------------------------- sucPurchaseShow: call resetDelta2 call SOUND_PLAYER.SET_SOUND.coin ld hl,#4404 ld (textColor),hl ld hl,successfulPurchase ld de,#5046 jp printText2x1 ;--------------------------------------------- notMoneyShow: call hideMessage call resetDelta2 call SOUND_PLAYER.SET_SOUND.eat ld hl,#4202 ld (textColor),hl ld hl,notMoney ld de,#5048 jp printText2x1 ;--------------------------------------------- addLife: ld hl,(coins) ld de,55 or a sbc hl,de jr c,notMoneyShow ld (coins),hl ld hl,(lives) inc hl ld (lives),hl jr sucPurchaseShow ;--------------------------------------------- showPassword: ld a,(passData) or a jr nz,.show ; protection from the fool, so as not to buy the same password again. ld hl,(coins) ld de,120 or a sbc hl,de jr c,notMoneyShow ld (coins),hl call sucPurchaseShow ld a,(currentLevel) call PASS.setLevPass .show: ; call SOUND_PLAYER.SET_SOUND.key ld hl,passData ld de,#48c8 jp printText2x1 ;--------------------------------------------- displayShop: ld hl,#4507 ld (textColor),hl ld hl,levelText ld de,#4006 call printText2x1 ld hl,userLives ld de,#4046 call printText2x1 ld hl,userCoins ld de,#4086 call printText2x1 ld hl,#4344 ld (textColor),hl ld hl,pricelist ld de,#480b call printText2x1 ld hl,#4645 ld (textColor),hl ld hl,continuations ld de,#4844 call printText2x1 ld hl,currentLevelPassword ld de,#4884 call printText2x1 ld hl,#0141 ld (textColor),hl ld hl,complete ld de,#50c8 call printText2x1 ld hl,sale ld de,#4801 call printText2x1V ld hl,sale ld de,#481E jp printText2x1V ;--------------------------------------------- showCoinsLives: call convertCoin ld hl,(lives) ld de,livesText call asciiConvert ld a,(currentLevel) inc a ld l,a ld h,0 ld de,levelNumberText call asciiConvert ld hl,#4445 ld (textColor),hl ld hl,levelNumberText ld de,#4006+20-5 call printText2x1 ld hl,livesText ld de,#4046+20-5 call printText2x1 ld hl,coinsText ld de,#4086+20-5 jp printText2x1 endmodule
SECTION code_fp_math48 PUBLIC fma EXTERN cm48_sccz80_fma defc fma = cm48_sccz80_fma
// Copyright (c) 2013 GitHub, Inc. All rights reserved. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. #include <string> #include <vector> #include "base/bind.h" #include "atom/browser/api/atom_api_window.h" #include "atom/browser/native_window.h" #include "atom/browser/ui/file_dialog.h" #include "atom/browser/ui/message_box.h" #include "atom/common/native_mate_converters/file_path_converter.h" #include "atom/common/native_mate_converters/function_converter.h" #include "native_mate/dictionary.h" #include "atom/common/node_includes.h" namespace { void ShowMessageBox(int type, const std::vector<std::string>& buttons, const std::string& title, const std::string& message, const std::string& detail, atom::NativeWindow* window, mate::Arguments* args) { v8::Handle<v8::Value> peek = args->PeekNext(); atom::MessageBoxCallback callback; if (mate::Converter<atom::MessageBoxCallback>::FromV8(args->isolate(), peek, &callback)) { atom::ShowMessageBox(window, (atom::MessageBoxType)type, buttons, title, message, detail, callback); } else { int chosen = atom::ShowMessageBox(window, (atom::MessageBoxType)type, buttons, title, message, detail); args->Return(chosen); } } void ShowOpenDialog(const std::string& title, const base::FilePath& default_path, int properties, atom::NativeWindow* window, mate::Arguments* args) { v8::Handle<v8::Value> peek = args->PeekNext(); file_dialog::OpenDialogCallback callback; if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(args->isolate(), peek, &callback)) { file_dialog::ShowOpenDialog(window, title, default_path, properties, callback); } else { std::vector<base::FilePath> paths; if (file_dialog::ShowOpenDialog(window, title, default_path, properties, &paths)) args->Return(paths); } } void ShowSaveDialog(const std::string& title, const base::FilePath& default_path, atom::NativeWindow* window, mate::Arguments* args) { v8::Handle<v8::Value> peek = args->PeekNext(); file_dialog::SaveDialogCallback callback; if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(args->isolate(), peek, &callback)) { file_dialog::ShowSaveDialog(window, title, default_path, callback); } else { base::FilePath path; if (file_dialog::ShowSaveDialog(window, title, default_path, &path)) args->Return(path); } } void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused, v8::Handle<v8::Context> context, void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod("showMessageBox", &ShowMessageBox); dict.SetMethod("showOpenDialog", &ShowOpenDialog); dict.SetMethod("showSaveDialog", &ShowSaveDialog); } } // namespace NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_dialog, Initialize)
; A321773: Number of compositions of n into parts with distinct multiplicities and with exactly three parts. ; 1,3,6,4,9,9,10,12,15,13,18,18,19,21,24,22,27,27,28,30,33,31,36,36,37,39,42,40,45,45,46,48,51,49,54,54,55,57,60,58,63,63,64,66,69,67,72,72,73,75,78,76,81,81,82,84,87,85,90,90,91,93,96,94,99,99,100,102,105,103,108,108,109,111,114,112,117,117,118,120,123,121,126,126,127,129,132,130,135,135,136,138,141,139,144,144,145,147,150,148 mov $2,$0 add $0,2 div $0,2 mov $3,$2 gcd $3,3 lpb $0 mul $0,3 sub $0,$3 mov $2,$0 mov $0,0 lpe seq $0,142 ; Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n, number of permutations of n letters). mul $0,$2 mov $1,2 add $1,$0 sub $1,1 mov $0,$1
; A047405: Numbers that are congruent to {0, 1, 2, 3, 6} mod 8. ; 0,1,2,3,6,8,9,10,11,14,16,17,18,19,22,24,25,26,27,30,32,33,34,35,38,40,41,42,43,46,48,49,50,51,54,56,57,58,59,62,64,65,66,67,70,72,73,74,75,78,80,81,82,83,86,88,89 mov $2,$0 mov $0,2 add $0,$2 mov $3,$0 lpb $0,1 add $3,$0 trn $0,2 add $3,1 sub $3,$0 trn $0,3 mov $1,$3 lpe sub $1,5
; A049871: a(n)=Sum{a(k): k=0,1,2,...,n-4,n-2,n-1}; a(n-3) is not a summand; 3 initial terms required. ; Submitted by Christian Krause ; 1,3,3,6,10,20,37,70,130,243,453,846,1579,2948,5503,10273,19177,35799,66828,124752,232882,434735,811546,1514962,2828071,5279331,9855246,18397383,34343506,64111097,119680057,223413991,417060391 mov $2,2 mov $5,1 lpb $0 sub $0,1 sub $3,$4 add $1,$3 mov $3,$4 mov $4,$2 mov $2,$3 add $2,$1 add $5,$4 mov $3,$5 lpe mov $0,$5
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r8 push %r9 push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0xda1a, %rdx clflush (%rdx) nop nop nop add $8569, %r10 mov (%rdx), %rbp nop nop nop and $51922, %r8 lea addresses_WT_ht+0x1025a, %rbx nop nop nop nop nop lfence movb (%rbx), %r11b nop sub %rdx, %rdx lea addresses_WT_ht+0x1403a, %r10 nop nop inc %rbx mov (%r10), %r9w nop nop nop nop nop sub %r10, %r10 lea addresses_WT_ht+0xab9a, %rsi lea addresses_normal_ht+0x1d9a, %rdi sub %rbx, %rbx mov $20, %rcx rep movsw nop nop nop nop sub %rbx, %rbx lea addresses_A_ht+0x9172, %rdx clflush (%rdx) nop nop nop nop and $46648, %rbp mov $0x6162636465666768, %r10 movq %r10, %xmm0 and $0xffffffffffffffc0, %rdx movaps %xmm0, (%rdx) nop nop nop nop xor %rdi, %rdi lea addresses_UC_ht+0xb01a, %rbx clflush (%rbx) xor %rdi, %rdi movl $0x61626364, (%rbx) nop add %r8, %r8 lea addresses_WC_ht+0xc09a, %rdi nop nop nop nop sub $37103, %rsi mov $0x6162636465666768, %r8 movq %r8, %xmm6 movups %xmm6, (%rdi) nop nop nop add %rcx, %rcx lea addresses_D_ht+0x1089a, %rdi nop nop nop nop cmp %rbp, %rbp mov (%rdi), %cx nop nop nop xor $1985, %rdi lea addresses_A_ht+0x13106, %rdi clflush (%rdi) inc %rcx mov (%rdi), %r9d nop nop cmp $23897, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %r9 pop %r8 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r8 push %rax push %rbp push %rbx push %rdi push %rdx // Store lea addresses_UC+0x101a, %r11 nop nop nop nop nop sub %rdi, %rdi mov $0x5152535455565758, %rbp movq %rbp, %xmm5 vmovups %ymm5, (%r11) nop nop sub $27677, %rdx // Store lea addresses_RW+0xc12, %rax sub $2301, %r8 movl $0x51525354, (%rax) nop sub %r11, %r11 // Faulty Load lea addresses_PSE+0x4b9a, %rbx nop nop nop and %r8, %r8 mov (%rbx), %edx lea oracles, %rbx and $0xff, %rdx shlq $12, %rdx mov (%rbx,%rdx,1), %rdx pop %rdx pop %rdi pop %rbx pop %rbp pop %rax pop %r8 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 3, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 1, 'same': False, 'type': 'addresses_RW'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_PSE'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'NT': True, 'AVXalign': True, 'size': 2, 'congruent': 4, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 0, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 2, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
; ; jccolext.asm - colorspace conversion (64-bit AVX2) ; ; Copyright (C) 2009, 2016, D. R. Commander. ; Copyright (C) 2015, Intel Corporation. ; ; Based on the x86 SIMD extension for IJG JPEG library ; Copyright (C) 1999-2006, MIYASAKA Masaru. ; For conditions of distribution and use, see copyright notice in jsimdext.inc ; ; This file should be assembled with NASM (Netwide Assembler), ; can *not* be assembled with Microsoft's MASM or any compatible ; assembler (including Borland's Turbo Assembler). ; NASM is available from http://nasm.sourceforge.net/ or ; http://sourceforge.net/project/showfiles.php?group_id=6208 ; ; [TAB8] %include "jcolsamp.inc" ; -------------------------------------------------------------------------- ; ; Convert some rows of samples to the output colorspace. ; ; GLOBAL(void) ; jsimd_rgb_ycc_convert_avx2 (JDIMENSION img_width, ; JSAMPARRAY input_buf, JSAMPIMAGE output_buf, ; JDIMENSION output_row, int num_rows); ; ; r10d = JDIMENSION img_width ; r11 = JSAMPARRAY input_buf ; r12 = JSAMPIMAGE output_buf ; r13d = JDIMENSION output_row ; r14d = int num_rows %define wk(i) rbp-(WK_NUM-(i))*SIZEOF_YMMWORD ; ymmword wk[WK_NUM] %define WK_NUM 8 align 32 global EXTN(jsimd_rgb_ycc_convert_avx2) EXTN(jsimd_rgb_ycc_convert_avx2): push rbp mov rax, rsp ; rax = original rbp sub rsp, byte 4 and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits mov [rsp], rax mov rbp, rsp ; rbp = aligned rbp lea rsp, [wk(0)] collect_args 5 push rbx mov ecx, r10d test rcx, rcx jz near .return push rcx mov rsi, r12 mov ecx, r13d mov rdi, JSAMPARRAY [rsi+0*SIZEOF_JSAMPARRAY] mov rbx, JSAMPARRAY [rsi+1*SIZEOF_JSAMPARRAY] mov rdx, JSAMPARRAY [rsi+2*SIZEOF_JSAMPARRAY] lea rdi, [rdi+rcx*SIZEOF_JSAMPROW] lea rbx, [rbx+rcx*SIZEOF_JSAMPROW] lea rdx, [rdx+rcx*SIZEOF_JSAMPROW] pop rcx mov rsi, r11 mov eax, r14d test rax, rax jle near .return .rowloop: push rdx push rbx push rdi push rsi push rcx ; col mov rsi, JSAMPROW [rsi] ; inptr mov rdi, JSAMPROW [rdi] ; outptr0 mov rbx, JSAMPROW [rbx] ; outptr1 mov rdx, JSAMPROW [rdx] ; outptr2 cmp rcx, byte SIZEOF_YMMWORD jae near .columnloop %if RGB_PIXELSIZE == 3 ; --------------- .column_ld1: push rax push rdx lea rcx, [rcx+rcx*2] ; imul ecx,RGB_PIXELSIZE test cl, SIZEOF_BYTE jz short .column_ld2 sub rcx, byte SIZEOF_BYTE movzx rax, BYTE [rsi+rcx] .column_ld2: test cl, SIZEOF_WORD jz short .column_ld4 sub rcx, byte SIZEOF_WORD movzx rdx, WORD [rsi+rcx] shl rax, WORD_BIT or rax, rdx .column_ld4: vmovd xmmA, eax pop rdx pop rax test cl, SIZEOF_DWORD jz short .column_ld8 sub rcx, byte SIZEOF_DWORD vmovd xmmF, XMM_DWORD [rsi+rcx] vpslldq xmmA, xmmA, SIZEOF_DWORD vpor xmmA, xmmA, xmmF .column_ld8: test cl, SIZEOF_MMWORD jz short .column_ld16 sub rcx, byte SIZEOF_MMWORD vmovq xmmB, XMM_MMWORD [rsi+rcx] vpslldq xmmA, xmmA, SIZEOF_MMWORD vpor xmmA, xmmA, xmmB .column_ld16: test cl, SIZEOF_XMMWORD jz short .column_ld32 sub rcx, byte SIZEOF_XMMWORD vmovdqu xmmB, XMM_MMWORD [rsi+rcx] vperm2i128 ymmA, ymmA, ymmA, 1 vpor ymmA, ymmB .column_ld32: test cl, SIZEOF_YMMWORD jz short .column_ld64 sub rcx, byte SIZEOF_YMMWORD vmovdqa ymmF, ymmA vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD] .column_ld64: test cl, 2*SIZEOF_YMMWORD mov rcx, SIZEOF_YMMWORD jz short .rgb_ycc_cnv vmovdqa ymmB, ymmA vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD] vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD] jmp short .rgb_ycc_cnv .columnloop: vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD] vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD] vmovdqu ymmB, YMMWORD [rsi+2*SIZEOF_YMMWORD] .rgb_ycc_cnv: ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05 ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A) ; ymmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L) ; ymmB=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V) vmovdqu ymmC, ymmA vinserti128 ymmA, ymmF, xmmA, 0 ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05 ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L) vinserti128 ymmC, ymmC, xmmB, 0 ; ymmC=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A) vinserti128 ymmB, ymmB, xmmF, 0 ; ymmB=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V) vperm2i128 ymmF, ymmC, ymmC, 1 ; ymmF=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A ; 1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q) vmovdqa ymmG, ymmA vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 10 20 01 11 21 02 12 ; 22 03 13 23 04 14 24 05 0G 1G 2G 0H 1H 2H 0I 1I) vpsrldq ymmG, ymmG, 8 ; ymmG=(22 03 13 23 04 14 24 05 0G 1G 2G 0H 1H 2H 0I 1I ; 2I 0J 1J 2J 0K 1K 2K 0L -- -- -- -- -- -- -- --) vpunpckhbw ymmA, ymmA, ymmF ; ymmA=(00 08 10 18 20 28 01 09 11 19 21 29 02 0A 12 1A ; 0G 0O 1G 1O 2G 2O 0H 0P 1H 1P 2H 2P 0I 0Q 1I 1Q) vpslldq ymmF, ymmF, 8 ; ymmF=(-- -- -- -- -- -- -- -- 15 25 06 16 26 07 17 27 ; 08 18 28 09 19 29 0A 1A 1L 2L 0M 1M 2M 0N 1N 2N) vpunpcklbw ymmG, ymmG, ymmB ; ymmG=(22 2A 03 0B 13 1B 23 2B 04 0C 14 1C 24 2C 05 0D ; 2I 2Q 0J 0R 1J 1R 2J 2R 0K 0S 1K 1S 2K 2S 0L 0T) vpunpckhbw ymmF, ymmF, ymmB ; ymmF=(15 1D 25 2D 06 0E 16 1E 26 2E 07 0F 17 1F 27 2F ; 1L 1T 2L 2T 0M 0U 1M 1U 2M 2U 0N 0V 1N 1V 2N 2V) vmovdqa ymmD, ymmA vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 08 10 18 20 28 01 09 ; 11 19 21 29 02 0A 12 1A 0G 0O 1G 1O 2G 2O 0H 0P) vpsrldq ymmD, ymmD, 8 ; ymmD=(11 19 21 29 02 0A 12 1A 0G 0O 1G 1O 2G 2O 0H 0P ; 1H 1P 2H 2P 0I 0Q 1I 1Q -- -- -- -- -- -- -- --) vpunpckhbw ymmA, ymmA, ymmG ; ymmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 01 05 09 0D ; 0G 0K 0O 0S 1G 1K 1O 1S 2G 2K 2O 2S 0H 0L 0P 0T) vpslldq ymmG, ymmG, 8 ; ymmG=(-- -- -- -- -- -- -- -- 22 2A 03 0B 13 1B 23 2B ; 04 0C 14 1C 24 2C 05 0D 2I 2Q 0J 0R 1J 1R 2J 2R) vpunpcklbw ymmD, ymmD, ymmF ; ymmD=(11 15 19 1D 21 25 29 2D 02 06 0A 0E 12 16 1A 1E ; 1H 1L 1P 1T 2H 2L 2P 2T 0I 0M 0Q 0U 1I 1M 1Q 1U) vpunpckhbw ymmG, ymmG, ymmF ; ymmG=(22 26 2A 2E 03 07 0B 0F 13 17 1B 1F 23 27 2B 2F ; 2I 2M 2Q 2U 0J 0N 0R 0V 1J 1N 1R 1V 2J 2N 2R 2V) vmovdqa ymmE, ymmA vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 04 08 0C 10 14 18 1C ; 20 24 28 2C 01 05 09 0D 0G 0K 0O 0S 1G 1K 1O 1S) vpsrldq ymmE, ymmE, 8 ; ymmE=(20 24 28 2C 01 05 09 0D 0G 0K 0O 0S 1G 1K 1O 1S ; 2G 2K 2O 2S 0H 0L 0P 0T -- -- -- -- -- -- -- --) vpunpckhbw ymmA, ymmA, ymmD ; ymmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E ; 0G 0I 0K 0M 0O 0Q 0S 0U 1G 1I 1K 1M 1O 1Q 1S 1U) vpslldq ymmD, ymmD, 8 ; ymmD=(-- -- -- -- -- -- -- -- 11 15 19 1D 21 25 29 2D ; 02 06 0A 0E 12 16 1A 1E 1H 1L 1P 1T 2H 2L 2P 2T) vpunpcklbw ymmE, ymmE, ymmG ; ymmE=(20 22 24 26 28 2A 2C 2E 01 03 05 07 09 0B 0D 0F ; 2G 2I 2K 2M 2O 2Q 2S 2U 0H 0J 0L 0N 0P 0R 0T 0V) vpunpckhbw ymmD, ymmD, ymmG ; ymmD=(11 13 15 17 19 1B 1D 1F 21 23 25 27 29 2B 2D 2F ; 1H 1J 1L 1N 1P 1R 1T 1V 2H 2J 2L 2N 2P 2R 2T 2V) vpxor ymmH, ymmH, ymmH vmovdqa ymmC, ymmA vpunpcklbw ymmA, ymmA, ymmH ; ymmA=(00 02 04 06 08 0A 0C 0E 0G 0I 0K 0M 0O 0Q 0S 0U) vpunpckhbw ymmC, ymmC, ymmH ; ymmC=(10 12 14 16 18 1A 1C 1E 1G 1I 1K 1M 1O 1Q 1S 1U) vmovdqa ymmB, ymmE vpunpcklbw ymmE, ymmE, ymmH ; ymmE=(20 22 24 26 28 2A 2C 2E 2G 2I 2K 2M 2O 2Q 2S 2U) vpunpckhbw ymmB, ymmB, ymmH ; ymmB=(01 03 05 07 09 0B 0D 0F 0H 0J 0L 0N 0P 0R 0T 0V) vmovdqa ymmF, ymmD vpunpcklbw ymmD, ymmD, ymmH ; ymmD=(11 13 15 17 19 1B 1D 1F 1H 1J 1L 1N 1P 1R 1T 1V) vpunpckhbw ymmF, ymmF, ymmH ; ymmF=(21 23 25 27 29 2B 2D 2F 2H 2J 2L 2N 2P 2R 2T 2V) %else ; RGB_PIXELSIZE == 4 ; ----------- .column_ld1: test cl, SIZEOF_XMMWORD/16 jz short .column_ld2 sub rcx, byte SIZEOF_XMMWORD/16 vmovd xmmA, XMM_DWORD [rsi+rcx*RGB_PIXELSIZE] .column_ld2: test cl, SIZEOF_XMMWORD/8 jz short .column_ld4 sub rcx, byte SIZEOF_XMMWORD/8 vmovq xmmF, XMM_MMWORD [rsi+rcx*RGB_PIXELSIZE] vpslldq xmmA, xmmA, SIZEOF_MMWORD vpor xmmA, xmmA, xmmF .column_ld4: test cl, SIZEOF_XMMWORD/4 jz short .column_ld8 sub rcx, byte SIZEOF_XMMWORD/4 vmovdqa xmmF, xmmA vperm2i128 ymmF, ymmF, ymmF, 1 vmovdqu xmmA, XMMWORD [rsi+rcx*RGB_PIXELSIZE] vpor ymmA, ymmA, ymmF .column_ld8: test cl, SIZEOF_XMMWORD/2 jz short .column_ld16 sub rcx, byte SIZEOF_XMMWORD/2 vmovdqa ymmF, ymmA vmovdqu ymmA, YMMWORD [rsi+rcx*RGB_PIXELSIZE] .column_ld16: test cl, SIZEOF_XMMWORD mov rcx, SIZEOF_YMMWORD jz short .rgb_ycc_cnv vmovdqa ymmE, ymmA vmovdqa ymmH, ymmF vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD] vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD] jmp short .rgb_ycc_cnv .columnloop: vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD] vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD] vmovdqu ymmE, YMMWORD [rsi+2*SIZEOF_YMMWORD] vmovdqu ymmH, YMMWORD [rsi+3*SIZEOF_YMMWORD] .rgb_ycc_cnv: ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33 ; 04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37) ; ymmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B ; 0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F) ; ymmE=(0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N) ; ymmH=(0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V) vmovdqa ymmB, ymmA vinserti128 ymmA, ymmA, xmmE, 1 ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33 ; 0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J) vperm2i128 ymmE, ymmB, ymmE, 0x31 ; ymmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37 ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N) vmovdqa ymmB, ymmF vinserti128 ymmF, ymmF, xmmH, 1 ; ymmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B ; 0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R) vperm2i128 ymmH, ymmB, ymmH, 0x31 ; ymmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V) vmovdqa ymmD, ymmA vpunpcklbw ymmA, ymmA, ymmE ; ymmA=(00 04 10 14 20 24 30 34 01 05 11 15 21 25 31 35 ; 0G 0K 1G 1K 2G 2K 3G 3K 0H 0L 1H 1L 2H 2L 3H 3L) vpunpckhbw ymmD, ymmD, ymmE ; ymmD=(02 06 12 16 22 26 32 36 03 07 13 17 23 27 33 37 ; 0I 0M 1I 1M 2I 2M 3I 3M 0J 0N 1J 1N 2J 2N 3J 3N) vmovdqa ymmC, ymmF vpunpcklbw ymmF, ymmF, ymmH ; ymmF=(08 0C 18 1C 28 2C 38 3C 09 0D 19 1D 29 2D 39 3D ; 0O 0S 1O 1S 2O 2S 3O 3S 0P 0T 1P 1T 2P 2T 3P 3T) vpunpckhbw ymmC, ymmC, ymmH ; ymmC=(0A 0E 1A 1E 2A 2E 3A 3E 0B 0F 1B 1F 2B 2F 3B 3F ; 0Q 0U 1Q 1U 2Q 2U 3Q 3U 0R 0V 1R 1V 2R 2V 3R 3V) vmovdqa ymmB, ymmA vpunpcklwd ymmA, ymmA, ymmF ; ymmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C ; 0G 0K 0O 0S 1G 1K 1O 1S 2G 2K 2O 2S 3G 3K 3O 3S) vpunpckhwd ymmB, ymmB, ymmF ; ymmB=(01 05 09 0D 11 15 19 1D 21 25 29 2D 31 35 39 3D ; 0H 0L 0P 0T 1H 1L 1P 1T 2H 2L 2P 2T 3H 3L 3P 3T) vmovdqa ymmG, ymmD vpunpcklwd ymmD, ymmD, ymmC ; ymmD=(02 06 0A 0E 12 16 1A 1E 22 26 2A 2E 32 36 3A 3E ; 0I 0M 0Q 0U 1I 1M 1Q 1U 2I 2M 2Q 2U 3I 3M 3Q 3U) vpunpckhwd ymmG, ymmG, ymmC ; ymmG=(03 07 0B 0F 13 17 1B 1F 23 27 2B 2F 33 37 3B 3F ; 0J 0N 0R 0V 1J 1N 1R 1V 2J 2N 2R 2V 3J 3N 3R 3V) vmovdqa ymmE, ymmA vpunpcklbw ymmA, ymmA, ymmD ; ymmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E ; 0G 0I 0K 0M 0O 0Q 0S 0U 1G 1I 1K 1M 1O 1Q 1S 1U) vpunpckhbw ymmE, ymmE, ymmD ; ymmE=(20 22 24 26 28 2A 2C 2E 30 32 34 36 38 3A 3C 3E ; 2G 2I 2K 2M 2O 2Q 2S 2U 3G 3I 3K 3M 3O 3Q 3S 3U) vmovdqa ymmH, ymmB vpunpcklbw ymmB, ymmB, ymmG ; ymmB=(01 03 05 07 09 0B 0D 0F 11 13 15 17 19 1B 1D 1F ; 0H 0J 0L 0N 0P 0R 0T 0V 1H 1J 1L 1N 1P 1R 1T 1V) vpunpckhbw ymmH, ymmH, ymmG ; ymmH=(21 23 25 27 29 2B 2D 2F 31 33 35 37 39 3B 3D 3F ; 2H 2J 2L 2N 2P 2R 2T 2V 3H 3J 3L 3N 3P 3R 3T 3V) vpxor ymmF, ymmF, ymmF vmovdqa ymmC, ymmA vpunpcklbw ymmA, ymmA, ymmF ; ymmA=(00 02 04 06 08 0A 0C 0E 0G 0I 0K 0M 0O 0Q 0S 0U) vpunpckhbw ymmC, ymmC, ymmF ; ymmC=(10 12 14 16 18 1A 1C 1E 1G 1I 1K 1M 1O 1Q 1S 1U) vmovdqa ymmD, ymmB vpunpcklbw ymmB, ymmB, ymmF ; ymmB=(01 03 05 07 09 0B 0D 0F 0H 0J 0L 0N 0P 0R 0T 0V) vpunpckhbw ymmD, ymmD, ymmF ; ymmD=(11 13 15 17 19 1B 1D 1F 1H 1J 1L 1N 1P 1R 1T 1V) vmovdqa ymmG, ymmE vpunpcklbw ymmE, ymmE, ymmF ; ymmE=(20 22 24 26 28 2A 2C 2E 2G 2I 2K 2M 2O 2Q 2S 2U) vpunpckhbw ymmG, ymmG, ymmF ; ymmG=(30 32 34 36 38 3A 3C 3E 3G 3I 3K 3M 3O 3Q 3S 3U) vpunpcklbw ymmF, ymmF, ymmH vpunpckhbw ymmH, ymmH, ymmH vpsrlw ymmF, ymmF, BYTE_BIT ; ymmF=(21 23 25 27 29 2B 2D 2F 2H 2J 2L 2N 2P 2R 2T 2V) vpsrlw ymmH, ymmH, BYTE_BIT ; ymmH=(31 33 35 37 39 3B 3D 3F 3H 3J 3L 3N 3P 3R 3T 3V) %endif ; RGB_PIXELSIZE ; --------------- ; ymm0=R(02468ACEGIKMOQSU)=RE, ymm2=G(02468ACEGIKMOQSU)=GE, ymm4=B(02468ACEGIKMOQSU)=BE ; ymm1=R(13579BDFHJLNPRTV)=RO, ymm3=G(13579BDFHJLNPRTV)=GO, ymm5=B(13579BDFHJLNPRTV)=BO ; (Original) ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE ; ; (This implementation) ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G ; Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE ; Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE vmovdqa YMMWORD [wk(0)], ymm0 ; wk(0)=RE vmovdqa YMMWORD [wk(1)], ymm1 ; wk(1)=RO vmovdqa YMMWORD [wk(2)], ymm4 ; wk(2)=BE vmovdqa YMMWORD [wk(3)], ymm5 ; wk(3)=BO vmovdqa ymm6, ymm1 vpunpcklwd ymm1, ymm1, ymm3 vpunpckhwd ymm6, ymm6, ymm3 vmovdqa ymm7, ymm1 vmovdqa ymm4, ymm6 vpmaddwd ymm1, ymm1, [rel PW_F0299_F0337] ; ymm1=ROL*FIX(0.299)+GOL*FIX(0.337) vpmaddwd ymm6, ymm6, [rel PW_F0299_F0337] ; ymm6=ROH*FIX(0.299)+GOH*FIX(0.337) vpmaddwd ymm7, ymm7, [rel PW_MF016_MF033] ; ymm7=ROL*-FIX(0.168)+GOL*-FIX(0.331) vpmaddwd ymm4, ymm4, [rel PW_MF016_MF033] ; ymm4=ROH*-FIX(0.168)+GOH*-FIX(0.331) vmovdqa YMMWORD [wk(4)], ymm1 ; wk(4)=ROL*FIX(0.299)+GOL*FIX(0.337) vmovdqa YMMWORD [wk(5)], ymm6 ; wk(5)=ROH*FIX(0.299)+GOH*FIX(0.337) vpxor ymm1, ymm1, ymm1 vpxor ymm6, ymm6, ymm6 vpunpcklwd ymm1, ymm1, ymm5 ; ymm1=BOL vpunpckhwd ymm6, ymm6, ymm5 ; ymm6=BOH vpsrld ymm1, ymm1, 1 ; ymm1=BOL*FIX(0.500) vpsrld ymm6, ymm6, 1 ; ymm6=BOH*FIX(0.500) vmovdqa ymm5, [rel PD_ONEHALFM1_CJ] ; ymm5=[PD_ONEHALFM1_CJ] vpaddd ymm7, ymm7, ymm1 vpaddd ymm4, ymm4, ymm6 vpaddd ymm7, ymm7, ymm5 vpaddd ymm4, ymm4, ymm5 vpsrld ymm7, ymm7, SCALEBITS ; ymm7=CbOL vpsrld ymm4, ymm4, SCALEBITS ; ymm4=CbOH vpackssdw ymm7, ymm7, ymm4 ; ymm7=CbO vmovdqa ymm1, YMMWORD [wk(2)] ; ymm1=BE vmovdqa ymm6, ymm0 vpunpcklwd ymm0, ymm0, ymm2 vpunpckhwd ymm6, ymm6, ymm2 vmovdqa ymm5, ymm0 vmovdqa ymm4, ymm6 vpmaddwd ymm0, ymm0, [rel PW_F0299_F0337] ; ymm0=REL*FIX(0.299)+GEL*FIX(0.337) vpmaddwd ymm6, ymm6, [rel PW_F0299_F0337] ; ymm6=REH*FIX(0.299)+GEH*FIX(0.337) vpmaddwd ymm5, ymm5, [rel PW_MF016_MF033] ; ymm5=REL*-FIX(0.168)+GEL*-FIX(0.331) vpmaddwd ymm4, ymm4, [rel PW_MF016_MF033] ; ymm4=REH*-FIX(0.168)+GEH*-FIX(0.331) vmovdqa YMMWORD [wk(6)], ymm0 ; wk(6)=REL*FIX(0.299)+GEL*FIX(0.337) vmovdqa YMMWORD [wk(7)], ymm6 ; wk(7)=REH*FIX(0.299)+GEH*FIX(0.337) vpxor ymm0, ymm0, ymm0 vpxor ymm6, ymm6, ymm6 vpunpcklwd ymm0, ymm0, ymm1 ; ymm0=BEL vpunpckhwd ymm6, ymm6, ymm1 ; ymm6=BEH vpsrld ymm0, ymm0, 1 ; ymm0=BEL*FIX(0.500) vpsrld ymm6, ymm6, 1 ; ymm6=BEH*FIX(0.500) vmovdqa ymm1, [rel PD_ONEHALFM1_CJ] ; ymm1=[PD_ONEHALFM1_CJ] vpaddd ymm5, ymm5, ymm0 vpaddd ymm4, ymm4, ymm6 vpaddd ymm5, ymm5, ymm1 vpaddd ymm4, ymm4, ymm1 vpsrld ymm5, ymm5, SCALEBITS ; ymm5=CbEL vpsrld ymm4, ymm4, SCALEBITS ; ymm4=CbEH vpackssdw ymm5, ymm5, ymm4 ; ymm5=CbE vpsllw ymm7, ymm7, BYTE_BIT vpor ymm5, ymm5, ymm7 ; ymm5=Cb vmovdqu YMMWORD [rbx], ymm5 ; Save Cb vmovdqa ymm0, YMMWORD [wk(3)] ; ymm0=BO vmovdqa ymm6, YMMWORD [wk(2)] ; ymm6=BE vmovdqa ymm1, YMMWORD [wk(1)] ; ymm1=RO vmovdqa ymm4, ymm0 vpunpcklwd ymm0, ymm0, ymm3 vpunpckhwd ymm4, ymm4, ymm3 vmovdqa ymm7, ymm0 vmovdqa ymm5, ymm4 vpmaddwd ymm0, ymm0, [rel PW_F0114_F0250] ; ymm0=BOL*FIX(0.114)+GOL*FIX(0.250) vpmaddwd ymm4, ymm4, [rel PW_F0114_F0250] ; ymm4=BOH*FIX(0.114)+GOH*FIX(0.250) vpmaddwd ymm7, ymm7, [rel PW_MF008_MF041] ; ymm7=BOL*-FIX(0.081)+GOL*-FIX(0.418) vpmaddwd ymm5, ymm5, [rel PW_MF008_MF041] ; ymm5=BOH*-FIX(0.081)+GOH*-FIX(0.418) vmovdqa ymm3, [rel PD_ONEHALF] ; ymm3=[PD_ONEHALF] vpaddd ymm0, ymm0, YMMWORD [wk(4)] vpaddd ymm4, ymm4, YMMWORD [wk(5)] vpaddd ymm0, ymm0, ymm3 vpaddd ymm4, ymm4, ymm3 vpsrld ymm0, ymm0, SCALEBITS ; ymm0=YOL vpsrld ymm4, ymm4, SCALEBITS ; ymm4=YOH vpackssdw ymm0, ymm0, ymm4 ; ymm0=YO vpxor ymm3, ymm3, ymm3 vpxor ymm4, ymm4, ymm4 vpunpcklwd ymm3, ymm3, ymm1 ; ymm3=ROL vpunpckhwd ymm4, ymm4, ymm1 ; ymm4=ROH vpsrld ymm3, ymm3, 1 ; ymm3=ROL*FIX(0.500) vpsrld ymm4, ymm4, 1 ; ymm4=ROH*FIX(0.500) vmovdqa ymm1, [rel PD_ONEHALFM1_CJ] ; ymm1=[PD_ONEHALFM1_CJ] vpaddd ymm7, ymm7, ymm3 vpaddd ymm5, ymm5, ymm4 vpaddd ymm7, ymm7, ymm1 vpaddd ymm5, ymm5, ymm1 vpsrld ymm7, ymm7, SCALEBITS ; ymm7=CrOL vpsrld ymm5, ymm5, SCALEBITS ; ymm5=CrOH vpackssdw ymm7, ymm7, ymm5 ; ymm7=CrO vmovdqa ymm3, YMMWORD [wk(0)] ; ymm3=RE vmovdqa ymm4, ymm6 vpunpcklwd ymm6, ymm6, ymm2 vpunpckhwd ymm4, ymm4, ymm2 vmovdqa ymm1, ymm6 vmovdqa ymm5, ymm4 vpmaddwd ymm6, ymm6, [rel PW_F0114_F0250] ; ymm6=BEL*FIX(0.114)+GEL*FIX(0.250) vpmaddwd ymm4, ymm4, [rel PW_F0114_F0250] ; ymm4=BEH*FIX(0.114)+GEH*FIX(0.250) vpmaddwd ymm1, ymm1, [rel PW_MF008_MF041] ; ymm1=BEL*-FIX(0.081)+GEL*-FIX(0.418) vpmaddwd ymm5, ymm5, [rel PW_MF008_MF041] ; ymm5=BEH*-FIX(0.081)+GEH*-FIX(0.418) vmovdqa ymm2, [rel PD_ONEHALF] ; ymm2=[PD_ONEHALF] vpaddd ymm6, ymm6, YMMWORD [wk(6)] vpaddd ymm4, ymm4, YMMWORD [wk(7)] vpaddd ymm6, ymm6, ymm2 vpaddd ymm4, ymm4, ymm2 vpsrld ymm6, ymm6, SCALEBITS ; ymm6=YEL vpsrld ymm4, ymm4, SCALEBITS ; ymm4=YEH vpackssdw ymm6, ymm6, ymm4 ; ymm6=YE vpsllw ymm0, ymm0, BYTE_BIT vpor ymm6, ymm6, ymm0 ; ymm6=Y vmovdqu YMMWORD [rdi], ymm6 ; Save Y vpxor ymm2, ymm2, ymm2 vpxor ymm4, ymm4, ymm4 vpunpcklwd ymm2, ymm2, ymm3 ; ymm2=REL vpunpckhwd ymm4, ymm4, ymm3 ; ymm4=REH vpsrld ymm2, ymm2, 1 ; ymm2=REL*FIX(0.500) vpsrld ymm4, ymm4, 1 ; ymm4=REH*FIX(0.500) vmovdqa ymm0, [rel PD_ONEHALFM1_CJ] ; ymm0=[PD_ONEHALFM1_CJ] vpaddd ymm1, ymm1, ymm2 vpaddd ymm5, ymm5, ymm4 vpaddd ymm1, ymm1, ymm0 vpaddd ymm5, ymm5, ymm0 vpsrld ymm1, ymm1, SCALEBITS ; ymm1=CrEL vpsrld ymm5, ymm5, SCALEBITS ; ymm5=CrEH vpackssdw ymm1, ymm1, ymm5 ; ymm1=CrE vpsllw ymm7, ymm7, BYTE_BIT vpor ymm1, ymm1, ymm7 ; ymm1=Cr vmovdqu YMMWORD [rdx], ymm1 ; Save Cr sub rcx, byte SIZEOF_YMMWORD add rsi, RGB_PIXELSIZE*SIZEOF_YMMWORD ; inptr add rdi, byte SIZEOF_YMMWORD ; outptr0 add rbx, byte SIZEOF_YMMWORD ; outptr1 add rdx, byte SIZEOF_YMMWORD ; outptr2 cmp rcx, byte SIZEOF_YMMWORD jae near .columnloop test rcx, rcx jnz near .column_ld1 pop rcx ; col pop rsi pop rdi pop rbx pop rdx add rsi, byte SIZEOF_JSAMPROW ; input_buf add rdi, byte SIZEOF_JSAMPROW add rbx, byte SIZEOF_JSAMPROW add rdx, byte SIZEOF_JSAMPROW dec rax ; num_rows jg near .rowloop .return: pop rbx vzeroupper uncollect_args 5 mov rsp, rbp ; rsp <- aligned rbp pop rsp ; rsp <- original rbp pop rbp ret ; For some reason, the OS X linker does not honor the request to align the ; segment unless we do this. align 32
/* Dummy file to avoid warning in the superset */
//---------------------------------------------------------------------------// // Copyright (c) 2018-2021 Mikhail Komarov <nemo@nil.foundation> // // MIT License // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. //---------------------------------------------------------------------------// #include <nil/actor/core/fstream.hh> #include <nil/actor/core/core.hh> #include <nil/actor/core/file.hh> #include <nil/actor/core/app_template.hh> #include <nil/actor/core/do_with.hh> #include <nil/actor/core/loop.hh> #include <fmt/printf.h> using namespace nil::actor; using namespace std::chrono_literals; int main(int ac, char **av) { app_template at; namespace bpo = boost::program_options; at.add_options()("concurrency", bpo::value<unsigned>()->default_value(1), "Write operations to issue in parallel")( "buffer-size", bpo::value<size_t>()->default_value(4096), "Write buffer size")("total-ops", bpo::value<unsigned>()->default_value(100000), "Total write operations to issue")("sloppy-size", bpo::value<bool>()->default_value(false), "Enable the sloppy-size optimization"); return at.run(ac, av, [&at] { auto concurrency = at.configuration()["concurrency"].as<unsigned>(); auto buffer_size = at.configuration()["buffer-size"].as<size_t>(); auto total_ops = at.configuration()["total-ops"].as<unsigned>(); auto sloppy_size = at.configuration()["sloppy-size"].as<bool>(); file_open_options foo; foo.sloppy_size = sloppy_size; return open_file_dma("testfile.tmp", open_flags::wo | open_flags::create | open_flags::exclusive, foo) .then([=](file f) { file_output_stream_options foso; foso.buffer_size = buffer_size; foso.preallocation_size = 32 << 20; foso.write_behind = concurrency; return make_file_output_stream(f, foso).then([=](output_stream<char> &&os) { return do_with( std::move(os), std::move(f), unsigned(0), [=](output_stream<char> &os, file &f, unsigned &completed) { auto start = std::chrono::steady_clock::now(); return repeat([=, &os, &completed] { if (completed == total_ops) { return make_ready_future<stop_iteration>(stop_iteration::yes); } char buf[buffer_size]; memset(buf, 0, buffer_size); return os.write(buf, buffer_size).then([&completed] { ++completed; return stop_iteration::no; }); }) .then([=, &os] { auto end = std::chrono::steady_clock::now(); using fseconds = std::chrono::duration<float, std::ratio<1, 1>>; auto iops = total_ops / std::chrono::duration_cast<fseconds>(end - start).count(); fmt::print("{:10} {:10} {:10} {:12}\n", "bufsize", "ops", "iodepth", "IOPS"); fmt::print("{:10d} {:10d} {:10d} {:12.0f}\n", buffer_size, total_ops, concurrency, iops); return os.flush(); }) .then([&os] { return os.close(); }); }); }); }); }); }
// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef VSOMEIP_MESSAGE_BASE_HPP #define VSOMEIP_MESSAGE_BASE_HPP #include "../../compat/vsomeip/enumeration_types.hpp" #include "../../compat/vsomeip/export.hpp" #include "../../compat/vsomeip/internal/deserializable.hpp" #include "../../compat/vsomeip/internal/serializable.hpp" #include "../../compat/vsomeip/primitive_types.hpp" namespace vsomeip { /** * * \defgroup vsomeip * * @{ * */ /** * \brief Base class to implement SOME/IP messages. * * This class implements the SOME/IP message header and connects to the * serialzing/deserializing functionalities. The class is inherited by * the message classes within ::vsomeip and vsomeip::sd that add the * payload representations for regular and Service Discovery messages. */ class message_base : public serializable, public deserializable { public: VSOMEIP_EXPORT virtual ~message_base() {}; /** * \brief Returns the message identifier. * * The method returns the message identifier that consists of * service identifier and method identifier. */ VSOMEIP_EXPORT virtual message_t get_message() const = 0; /** * \brief Set the message identifier. * * The methods sets service identifier and method identifier in * a single call. * * \param _message The new message identifier. */ VSOMEIP_EXPORT virtual void set_message(message_t _message) = 0; /** * \brief Returns the service identifier from the message header. */ VSOMEIP_EXPORT virtual service_t get_service() const = 0; /** * \brief Set the service identifier in the message header. */ VSOMEIP_EXPORT virtual void set_service(service_t _service) = 0; /** * \brief Returns the instance identifier. * * The instance identifier is _not_ part of the SOME/IP header. It is * either derived from the incoming message (local) or from the port * that was used to send a message (external). */ VSOMEIP_EXPORT virtual instance_t get_instance() const = 0; /** * \brief Set the instance identifier in the message header. * * To address the correct service instance, vsomeip uses the instance * identifier. For external services it is mapped to a IP address and port * combination before the message is sent. For internal messages is * transferred as additional data appended to the SOME/IP messages. * Therefore, before sending a message, a user application must set the * instance identifier. */ VSOMEIP_EXPORT virtual void set_instance(instance_t _instance) = 0; /** * \brief Get the method/event identifier from the message header. */ VSOMEIP_EXPORT virtual method_t get_method() const = 0; /** * \brief Set the method/event identifier in the message header. */ VSOMEIP_EXPORT virtual void set_method(method_t _method) = 0; /** * \brief Get the payload length from the message header. */ VSOMEIP_EXPORT virtual length_t get_length() const = 0; /** * \brief Get the request identifier from the message header. * * The request identifier consists of the client identifier and the * session identifier. As it does really make sense to set it as * a whole, setting is not supported. */ VSOMEIP_EXPORT virtual request_t get_request() const = 0; /** * \brief Set the client identifier in the message header. */ VSOMEIP_EXPORT virtual client_t get_client() const = 0; /** * \brief Set the client identifier in the message header. * * For requests this is automatically done by @ref application::send. * For notications this is not needed. */ VSOMEIP_EXPORT virtual void set_client(client_t _client) = 0; /** * \brief Get the session identifier from the message header. */ VSOMEIP_EXPORT virtual session_t get_session() const = 0; /** * \brief Set the session identifier in the message header. * * For requests this is automatically done by @ref application::send * For notifications it is not needed to set the session identifier. */ VSOMEIP_EXPORT virtual void set_session(session_t _session) = 0; /** * \brief Get the protocol version from the message header. * * As the protocol version is a fixed value for a vsomeip implementation, * it cannot be set. */ VSOMEIP_EXPORT virtual protocol_version_t get_protocol_version() const = 0; /** * \brief Get the interface version from the message header. */ VSOMEIP_EXPORT virtual interface_version_t get_interface_version() const = 0; /** * \brief Set the interface version in the message header. */ VSOMEIP_EXPORT virtual void set_interface_version(interface_version_t _version) = 0; /** * \brief Get the message type from the message header. */ VSOMEIP_EXPORT virtual message_type_e get_message_type() const = 0; /** * \brief Set the message type in the message header. */ VSOMEIP_EXPORT virtual void set_message_type(message_type_e _type) = 0; /** * \brief Get the return code from the message header. */ VSOMEIP_EXPORT virtual return_code_e get_return_code() const = 0; /** * \brief Set the return code in the message header. */ VSOMEIP_EXPORT virtual void set_return_code(return_code_e _code) = 0; /** * \brief Return the transport mode that was/will be used to send the message. */ VSOMEIP_EXPORT virtual bool is_reliable() const = 0; /** * \brief Set the transport mode that will be used to send the message. */ VSOMEIP_EXPORT virtual void set_reliable(bool _is_reliable) = 0; /** * \brief Return whether or not the message is an initial event. */ VSOMEIP_EXPORT virtual bool is_initial() const = 0; /** * \brief Set whether or not the message is an initial event. */ VSOMEIP_EXPORT virtual void set_initial(bool _is_initial) = 0; /** * \brief Return whether or not the CRC value received is valid. */ VSOMEIP_EXPORT virtual bool is_valid_crc() const = 0; /** * \brief Set whether or not the CRC value received is valid. */ VSOMEIP_EXPORT virtual void set_is_valid_crc(bool _is_valid_crc) = 0; }; /** @} */ } // namespace vsomeip #endif // VSOMEIP_MESSAGE_BASE_HPP
#include <gtest/gtest.h> #include <cpuinfo.h> #include <cpuinfo-mock.h> TEST(PROCESSORS, count) { ASSERT_EQ(8, cpuinfo_get_processors_count()); } TEST(PROCESSORS, non_null) { ASSERT_TRUE(cpuinfo_get_processors()); } TEST(PROCESSORS, smt_id) { for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { ASSERT_EQ(0, cpuinfo_get_processor(i)->smt_id); } } TEST(PROCESSORS, core) { for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { ASSERT_EQ(cpuinfo_get_core(i), cpuinfo_get_processor(i)->core); } } TEST(PROCESSORS, package) { for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { ASSERT_EQ(cpuinfo_get_package(0), cpuinfo_get_processor(i)->package); } } TEST(PROCESSORS, DISABLED_linux_id) { for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { switch (i) { case 0: case 1: case 2: case 3: ASSERT_EQ(i + 4, cpuinfo_get_processor(i)->linux_id); break; case 4: case 5: case 6: case 7: ASSERT_EQ(i - 4, cpuinfo_get_processor(i)->linux_id); break; } } } TEST(PROCESSORS, l1i) { for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { ASSERT_EQ(cpuinfo_get_l1i_cache(i), cpuinfo_get_processor(i)->cache.l1i); } } TEST(PROCESSORS, l1d) { for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { ASSERT_EQ(cpuinfo_get_l1d_cache(i), cpuinfo_get_processor(i)->cache.l1d); } } TEST(PROCESSORS, l2) { for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { switch (i) { case 0: case 1: case 2: case 3: ASSERT_EQ(cpuinfo_get_l2_cache(0), cpuinfo_get_processor(i)->cache.l2); break; case 4: case 5: case 6: case 7: ASSERT_EQ(cpuinfo_get_l2_cache(1), cpuinfo_get_processor(i)->cache.l2); break; } } } TEST(PROCESSORS, l3) { for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { ASSERT_FALSE(cpuinfo_get_processor(i)->cache.l3); } } TEST(PROCESSORS, l4) { for (uint32_t i = 0; i < cpuinfo_get_processors_count(); i++) { ASSERT_FALSE(cpuinfo_get_processor(i)->cache.l4); } } TEST(CORES, count) { ASSERT_EQ(8, cpuinfo_get_cores_count()); } TEST(CORES, non_null) { ASSERT_TRUE(cpuinfo_get_cores()); } TEST(CORES, processor_start) { for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { ASSERT_EQ(i, cpuinfo_get_core(i)->processor_start); } } TEST(CORES, processor_count) { for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { ASSERT_EQ(1, cpuinfo_get_core(i)->processor_count); } } TEST(CORES, core_id) { for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { ASSERT_EQ(i, cpuinfo_get_core(i)->core_id); } } TEST(CORES, package) { for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { ASSERT_EQ(cpuinfo_get_package(0), cpuinfo_get_core(i)->package); } } TEST(CORES, vendor) { for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { ASSERT_EQ(cpuinfo_vendor_arm, cpuinfo_get_core(i)->vendor); } } TEST(CORES, uarch) { for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { ASSERT_EQ(cpuinfo_uarch_cortex_a53, cpuinfo_get_core(i)->uarch); } } TEST(CORES, midr) { for (uint32_t i = 0; i < cpuinfo_get_cores_count(); i++) { ASSERT_EQ(UINT32_C(0x410FD034), cpuinfo_get_core(i)->midr); } } TEST(PACKAGES, count) { ASSERT_EQ(1, cpuinfo_get_packages_count()); } TEST(PACKAGES, name) { for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { ASSERT_EQ("Pinecone Surge S1", std::string(cpuinfo_get_package(i)->name, strnlen(cpuinfo_get_package(i)->name, CPUINFO_PACKAGE_NAME_MAX))); } } TEST(PACKAGES, gpu_name) { for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { ASSERT_EQ("ARM Mali-T860", std::string(cpuinfo_get_package(i)->gpu_name, strnlen(cpuinfo_get_package(i)->gpu_name, CPUINFO_GPU_NAME_MAX))); } } TEST(PACKAGES, processor_start) { for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { ASSERT_EQ(0, cpuinfo_get_package(i)->processor_start); } } TEST(PACKAGES, processor_count) { for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { ASSERT_EQ(8, cpuinfo_get_package(i)->processor_count); } } TEST(PACKAGES, core_start) { for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { ASSERT_EQ(0, cpuinfo_get_package(i)->core_start); } } TEST(PACKAGES, core_count) { for (uint32_t i = 0; i < cpuinfo_get_packages_count(); i++) { ASSERT_EQ(8, cpuinfo_get_package(i)->core_count); } } TEST(ISA, thumb) { #if CPUINFO_ARCH_ARM ASSERT_TRUE(cpuinfo_has_arm_thumb()); #elif CPUINFO_ARCH_ARM64 ASSERT_FALSE(cpuinfo_has_arm_thumb()); #endif } TEST(ISA, thumb2) { #if CPUINFO_ARCH_ARM ASSERT_TRUE(cpuinfo_has_arm_thumb2()); #elif CPUINFO_ARCH_ARM64 ASSERT_FALSE(cpuinfo_has_arm_thumb2()); #endif } TEST(ISA, armv5e) { #if CPUINFO_ARCH_ARM ASSERT_TRUE(cpuinfo_has_arm_v5e()); #elif CPUINFO_ARCH_ARM64 ASSERT_FALSE(cpuinfo_has_arm_v5e()); #endif } TEST(ISA, armv6) { #if CPUINFO_ARCH_ARM ASSERT_TRUE(cpuinfo_has_arm_v6()); #elif CPUINFO_ARCH_ARM64 ASSERT_FALSE(cpuinfo_has_arm_v6()); #endif } TEST(ISA, armv6k) { #if CPUINFO_ARCH_ARM ASSERT_TRUE(cpuinfo_has_arm_v6k()); #elif CPUINFO_ARCH_ARM64 ASSERT_FALSE(cpuinfo_has_arm_v6k()); #endif } TEST(ISA, armv7) { #if CPUINFO_ARCH_ARM ASSERT_TRUE(cpuinfo_has_arm_v7()); #elif CPUINFO_ARCH_ARM64 ASSERT_FALSE(cpuinfo_has_arm_v7()); #endif } TEST(ISA, armv7mp) { #if CPUINFO_ARCH_ARM ASSERT_TRUE(cpuinfo_has_arm_v7mp()); #elif CPUINFO_ARCH_ARM64 ASSERT_FALSE(cpuinfo_has_arm_v7mp()); #endif } TEST(ISA, idiv) { ASSERT_TRUE(cpuinfo_has_arm_idiv()); } TEST(ISA, vfpv2) { ASSERT_FALSE(cpuinfo_has_arm_vfpv2()); } TEST(ISA, vfpv3) { ASSERT_TRUE(cpuinfo_has_arm_vfpv3()); } TEST(ISA, vfpv3_d32) { ASSERT_TRUE(cpuinfo_has_arm_vfpv3_d32()); } TEST(ISA, vfpv3_fp16) { ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16()); } TEST(ISA, vfpv3_fp16_d32) { ASSERT_TRUE(cpuinfo_has_arm_vfpv3_fp16_d32()); } TEST(ISA, vfpv4) { ASSERT_TRUE(cpuinfo_has_arm_vfpv4()); } TEST(ISA, vfpv4_d32) { ASSERT_TRUE(cpuinfo_has_arm_vfpv4_d32()); } TEST(ISA, wmmx) { ASSERT_FALSE(cpuinfo_has_arm_wmmx()); } TEST(ISA, wmmx2) { ASSERT_FALSE(cpuinfo_has_arm_wmmx2()); } TEST(ISA, neon) { ASSERT_TRUE(cpuinfo_has_arm_neon()); } TEST(ISA, neon_fp16) { ASSERT_TRUE(cpuinfo_has_arm_neon_fp16()); } TEST(ISA, neon_fma) { ASSERT_TRUE(cpuinfo_has_arm_neon_fma()); } TEST(ISA, atomics) { ASSERT_FALSE(cpuinfo_has_arm_atomics()); } TEST(ISA, neon_rdm) { ASSERT_FALSE(cpuinfo_has_arm_neon_rdm()); } TEST(ISA, fp16_arith) { ASSERT_FALSE(cpuinfo_has_arm_fp16_arith()); } TEST(ISA, jscvt) { ASSERT_FALSE(cpuinfo_has_arm_jscvt()); } TEST(ISA, fcma) { ASSERT_FALSE(cpuinfo_has_arm_fcma()); } TEST(ISA, aes) { ASSERT_TRUE(cpuinfo_has_arm_aes()); } TEST(ISA, sha1) { ASSERT_TRUE(cpuinfo_has_arm_sha1()); } TEST(ISA, sha2) { ASSERT_TRUE(cpuinfo_has_arm_sha2()); } TEST(ISA, pmull) { ASSERT_TRUE(cpuinfo_has_arm_pmull()); } TEST(ISA, crc32) { ASSERT_TRUE(cpuinfo_has_arm_crc32()); } TEST(L1I, count) { ASSERT_EQ(8, cpuinfo_get_l1i_caches_count()); } TEST(L1I, non_null) { ASSERT_TRUE(cpuinfo_get_l1i_caches()); } TEST(L1I, size) { for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { ASSERT_EQ(16 * 1024, cpuinfo_get_l1i_cache(i)->size); } } TEST(L1I, associativity) { for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { ASSERT_EQ(2, cpuinfo_get_l1i_cache(i)->associativity); } } TEST(L1I, sets) { for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { ASSERT_EQ(cpuinfo_get_l1i_cache(i)->size, cpuinfo_get_l1i_cache(i)->sets * cpuinfo_get_l1i_cache(i)->line_size * cpuinfo_get_l1i_cache(i)->partitions * cpuinfo_get_l1i_cache(i)->associativity); } } TEST(L1I, partitions) { for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->partitions); } } TEST(L1I, line_size) { for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { ASSERT_EQ(64, cpuinfo_get_l1i_cache(i)->line_size); } } TEST(L1I, flags) { for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { ASSERT_EQ(0, cpuinfo_get_l1i_cache(i)->flags); } } TEST(L1I, processors) { for (uint32_t i = 0; i < cpuinfo_get_l1i_caches_count(); i++) { ASSERT_EQ(i, cpuinfo_get_l1i_cache(i)->processor_start); ASSERT_EQ(1, cpuinfo_get_l1i_cache(i)->processor_count); } } TEST(L1D, count) { ASSERT_EQ(8, cpuinfo_get_l1d_caches_count()); } TEST(L1D, non_null) { ASSERT_TRUE(cpuinfo_get_l1d_caches()); } TEST(L1D, size) { for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { ASSERT_EQ(16 * 1024, cpuinfo_get_l1d_cache(i)->size); } } TEST(L1D, associativity) { for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { ASSERT_EQ(4, cpuinfo_get_l1d_cache(i)->associativity); } } TEST(L1D, sets) { for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { ASSERT_EQ(cpuinfo_get_l1d_cache(i)->size, cpuinfo_get_l1d_cache(i)->sets * cpuinfo_get_l1d_cache(i)->line_size * cpuinfo_get_l1d_cache(i)->partitions * cpuinfo_get_l1d_cache(i)->associativity); } } TEST(L1D, partitions) { for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->partitions); } } TEST(L1D, line_size) { for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { ASSERT_EQ(64, cpuinfo_get_l1d_cache(i)->line_size); } } TEST(L1D, flags) { for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { ASSERT_EQ(0, cpuinfo_get_l1d_cache(i)->flags); } } TEST(L1D, processors) { for (uint32_t i = 0; i < cpuinfo_get_l1d_caches_count(); i++) { ASSERT_EQ(i, cpuinfo_get_l1d_cache(i)->processor_start); ASSERT_EQ(1, cpuinfo_get_l1d_cache(i)->processor_count); } } TEST(L2, count) { ASSERT_EQ(2, cpuinfo_get_l2_caches_count()); } TEST(L2, non_null) { ASSERT_TRUE(cpuinfo_get_l2_caches()); } TEST(L2, size) { for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { ASSERT_EQ(256 * 1024, cpuinfo_get_l2_cache(i)->size); } } TEST(L2, associativity) { for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { ASSERT_EQ(16, cpuinfo_get_l2_cache(i)->associativity); } } TEST(L2, sets) { for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { ASSERT_EQ(cpuinfo_get_l2_cache(i)->size, cpuinfo_get_l2_cache(i)->sets * cpuinfo_get_l2_cache(i)->line_size * cpuinfo_get_l2_cache(i)->partitions * cpuinfo_get_l2_cache(i)->associativity); } } TEST(L2, partitions) { for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { ASSERT_EQ(1, cpuinfo_get_l2_cache(i)->partitions); } } TEST(L2, line_size) { for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { ASSERT_EQ(64, cpuinfo_get_l2_cache(i)->line_size); } } TEST(L2, flags) { for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->flags); } } TEST(L2, processors) { for (uint32_t i = 0; i < cpuinfo_get_l2_caches_count(); i++) { switch (i) { case 0: ASSERT_EQ(0, cpuinfo_get_l2_cache(i)->processor_start); ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count); break; case 1: ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_start); ASSERT_EQ(4, cpuinfo_get_l2_cache(i)->processor_count); break; } } } TEST(L3, none) { ASSERT_EQ(0, cpuinfo_get_l3_caches_count()); ASSERT_FALSE(cpuinfo_get_l3_caches()); } TEST(L4, none) { ASSERT_EQ(0, cpuinfo_get_l4_caches_count()); ASSERT_FALSE(cpuinfo_get_l4_caches()); } #include <xiaomi-mi-5c.h> int main(int argc, char* argv[]) { #if CPUINFO_ARCH_ARM cpuinfo_set_hwcap(UINT32_C(0x0027B0D6)); cpuinfo_set_hwcap2(UINT32_C(0x0000001F)); #elif CPUINFO_ARCH_ARM64 cpuinfo_set_hwcap(UINT32_C(0x000000FF)); #endif cpuinfo_mock_filesystem(filesystem); #ifdef __ANDROID__ cpuinfo_mock_android_properties(properties); cpuinfo_mock_gl_renderer("Mali-T860"); #endif cpuinfo_initialize(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
; L0014.asm ; Generated 07.09.2000 by mlevel ; Modified 07.09.2000 by Abe Pralle INCLUDE "Source/Defs.inc" INCLUDE "Source/Levels.inc" ;--------------------------------------------------------------------- SECTION "Level0014Section",ROMX ;--------------------------------------------------------------------- L0014_Contents:: DW L0014_Load DW L0014_Init DW L0014_Check DW L0014_Map dialog: haiku_warn_gtx: INCBIN "Data/Dialog/IntroHaiku/haiku_warn.gtx" haiku_askOkay_gtx: INCBIN "Data/Dialog/IntroHaiku/haiku_askOkay.gtx" quatrain_gtx: INCBIN "Data/Dialog/IntroHaiku/quatrain.gtx" haiku_goAhead_gtx: INCBIN "Data/Dialog/IntroHaiku/haiku_goAhead.gtx" ;--------------------------------------------------------------------- ; Load ;--------------------------------------------------------------------- L0014_Load: DW ((L0014_LoadFinished - L0014_Load2)) ;size L0014_Load2: call ParseMap ;load in tiles used for sprite ship ;bg tiles 1386-1389 to Bank 0 100-103 ldio a,[curROMBank] push af ld a,BANK(BGTiles1024) call SetActiveROM xor a ;bank 0 ld c,4 ;number of tiles to copy ld de,$8000+1600 ld hl,BGTiles1024 + (1386-1024)*16 call VMemCopy pop af call SetActiveROM ret L0014_LoadFinished: ;--------------------------------------------------------------------- ; Map ;--------------------------------------------------------------------- L0014_Map: INCBIN "Data/Levels/L0014_intro_haiku1.lvl" ;--------------------------------------------------------------------- ; Init ;--------------------------------------------------------------------- CRATERINDEX EQU 3 RADARINDEX EQU 50 CRACKMIDINDEX EQU 81 CRACKTOPINDEX EQU 82 QUATRAININDEX EQU 107 SOLDIERINDEX EQU 108 IAMBICINDEX EQU 109 LAVAINDEX EQU 74 VAR_RADAR EQU 0 VAR_CRACK_TOP EQU 1 VAR_CRACK_BOTTOM EQU 2 VAR_DELAY EQU 3 VAR_LAVA EQU 4 VAR_METASPRITE EQU 5 ;5-9 STATE_CROSSCRACK EQU 0 STATE_BOMBER1 EQU 2 STATE_BOMBER2 EQU 3 STATE_LAVA EQU 4 STATE_LAVA2 EQU 5 STATE_LAVA3 EQU 6 STATE_DIALOG2_1 EQU 7 STATE_DIALOG2_2 EQU 8 STATE_DIALOG2_3 EQU 9 STATE_DIALOG_WAIT EQU 10 STATE_NORMAL EQU 11 L0014_Init: DW ((L0014_InitFinished - L0014_Init2)) ;size L0014_Init2: ;ld a,STATE_NORMAL ;ldio [mapState],a ld hl,$0014 call SetJoinMap ld hl,$0014 call SetRespawnMap call SetPressBDialog ld a,BANK(dialog) ld [dialogBank],a ld a,BANK(moon_base_haiku_gbm) ld hl,moon_base_haiku_gbm call InitMusic ld a,[bgTileMap+RADARINDEX] ld [levelVars+VAR_RADAR],a ld a,[bgTileMap+LAVAINDEX] ld [levelVars+VAR_LAVA],a ;----soldiers do nothing ld bc,classB12Soldier ld de,classDoNothing call ChangeClass ;fill in hole at $d190, $d191 if not occupied ld a,MAPBANK ldio [$ff70],a ld hl,$d190 ld a,[hl] or a jr nz,.firstFilled ld [hl],45 .firstFilled inc hl ld a,[hl] or a jr nz,.secondFilled ld [hl],46 .secondFilled ld a,10 ld [camera_i],a ld [camera_j],a ld a,1 ld [mapLeft],a ld a,1 ld [mapTop],a ld a,10 ld [levelVars + VAR_CRACK_TOP],a inc a ld [levelVars + VAR_CRACK_BOTTOM],a ldio a,[mapState] cp STATE_CROSSCRACK jr nz,.checkBomber1 ld a,1 ld [heroesIdle],a call ((.createCompanions-L0014_Init2)+levelCheckRAM) jr .createBomber1 .checkBomber1 cp STATE_BOMBER1 jr nz,.checkBomber2 ld a,1 ld [heroesIdle],a .createBomber1 ld bc,$0202 ld d,100 ld e,6 ld hl,levelVars+VAR_METASPRITE ld a,220 ld [metaSprite_x],a ld a,52 ld [metaSprite_y],a call CreateMetaSprite ret .checkBomber2 cp STATE_BOMBER2 jr nz,.checkLava1 ld a,1 ld [heroesIdle],a call ((.createCompanions-L0014_Init2)+levelCheckRAM) ld bc,$0202 ld d,100 ld e,6 ld hl,levelVars+VAR_METASPRITE ld a,220 ld [metaSprite_x],a ld a,88 ld [metaSprite_y],a call CreateMetaSprite ret .checkLava1 ;cp STATE_LAVA1 ;jr nz,.checkLava2 .checkLava2 ;cp STATE_LAVA2 ;jr nz,.checkLava3 .checkLava3 ;cp STATE_LAVA3 cp STATE_NORMAL jr z,.checkNormal ld a,1 ld [heroesIdle],a .checkNormal ld a,STATE_NORMAL ldio [mapState],a ;be sure ld bc,$1614 ld de,0 ld hl,$2c00 call BlitMap call SetBGSpecialFlags ret .createCompanions ld c,QUATRAININDEX ld hl,$d48d call CreateInitAndDrawObject ld hl,$d306 call SetActorDestLoc ld c,IAMBICINDEX ld hl,$d50d call CreateInitAndDrawObject ld hl,$d387 call SetActorDestLoc ld bc,classQuatrain ld de,classActor call ChangeClass ret L0014_InitFinished: ;--------------------------------------------------------------------- ; Check ;--------------------------------------------------------------------- L0014_Check: DW ((L0014_CheckFinished - L0014_Check2)) ;size L0014_Check2: ;if any soldiers are killed change them to class B12 Soldier ld c,SOLDIERINDEX call GetFirst or a jr z,.animateRadar call GetNextObject or a jr nz,.animateRadar .soldierDefend ld bc,classDoNothing ld de,classB12Soldier call ChangeClass ld bc,(GROUP_HERO<<8) | GROUP_MONSTERB xor a ;enemies call SetFOF .animateRadar ;animate the radar tower (index 47-52) based on timer/8 ldio a,[updateTimer] rrca ;(t/8)*6 == t/4*3 and %00000110 ld b,a add b add b ld b,a ld a,[levelVars+VAR_RADAR] add b ld hl,bgTileMap + RADARINDEX ld c,6 .animateTower ld [hl+],a inc a dec c jr nz,.animateTower ;animate the lava on updateTimer / 16 ldio a,[updateTimer] rlca swap a and %00000011 ld b,a ld a,[levelVars+VAR_LAVA] add b ld [bgTileMap + LAVAINDEX],a ldio a,[mapState] cp STATE_NORMAL jr nz,.checkDialogWait ;normal xor a ld [heroesIdle],a ret .checkDialogWait cp STATE_DIALOG_WAIT jr nz,.checkCrossCrack call CheckDialogContinue or a ret z ldio a,[mapState+1] ldio [mapState],a ret .checkCrossCrack cp STATE_CROSSCRACK jr nz,.checkBomber1 ld c,QUATRAININDEX call GetFirst call IsActorAtDest or a ret z ld c,IAMBICINDEX call GetFirst call IsActorAtDest or a ret z ld de,((.setBomber1-L0014_Check2)+levelCheckRAM) call SetDialogSkip call SetSpeakerToFirstHero ld de,haiku_warn_gtx call ShowDialogAtBottomNoWait ld a,STATE_DIALOG_WAIT ldio [mapState],a ld a,STATE_BOMBER1 ldio [mapState+1],a ret .checkDialog2 cp STATE_DIALOG2_1 jr nz,.checkBomber1 ret .setBomber1 call ClearDialog ld a,STATE_BOMBER1 ldio [mapState],a .checkBomber1 cp STATE_BOMBER1 jr nz,.checkBomber2 ld de,0 call SetDialogSkip ;bomber1 ld hl,levelVars+VAR_METASPRITE ;bomber metasprite ld bc,$fc00 ;x -= 4 call ScrollMetaSprite ld a,[levelVars+VAR_METASPRITE+1] ;get x pos of first sprite ld h,((spriteOAMBuffer>>8) & $ff) ld l,a inc hl ld a,[hl] cp 224 jr nz,.bomber1StillActive ;reset bomber to second fly-by position ld bc,$dc58 ld hl,levelVars+VAR_METASPRITE call SetMetaSpritePos ld a,STATE_BOMBER2 ldio [mapState],a .bomber1StillActive cp 188 jr nz,.afterBombSound1 ld hl,((.bombSound-L0014_Check2)+levelCheckRAM) call PlaySound .afterBombSound1 cp 88 jr nz,.b1CheckPos2 ld a,20 ld b,8 call SetupFadeFromSaturated call ((.explosion1 - L0014_Check2) + levelCheckRAM) ;create a 2x2 crater ld a,MAPBANK ldio [$ff70],a ld hl,$d30d ld a,CRATERINDEX ld [hl+],a inc a ld [hl+],a inc a ld hl,$d38d ld [hl+],a inc a ld [hl+],a ret .b1CheckPos2 cp 64 ret nz call ((.explosion1 - L0014_Check2) + levelCheckRAM) ld c,QUATRAININDEX call GetFirst ld hl,$d586 call SetActorDestLoc ld c,IAMBICINDEX call GetFirst ld hl,$d607 call SetActorDestLoc ret .checkBomber2 cp STATE_BOMBER2 jr nz,.checkLava ;bomber2 ld hl,levelVars+VAR_METASPRITE ;bomber metasprite ld bc,$fc00 ;x -= 4 call ScrollMetaSprite ld a,[levelVars+VAR_METASPRITE+1] ;get x pos of first sprite ld h,((spriteOAMBuffer>>8) & $ff) ld l,a inc hl ld a,[hl] cp 224 jr nz,.bomber2StillActive ;kill bomber ld hl,levelVars+VAR_METASPRITE call FreeMetaSprite ld c,QUATRAININDEX call GetFirst ld hl,$d888 ;run in circles call SetActorDestLoc ld c,IAMBICINDEX call GetFirst ld hl,$d888 call SetActorDestLoc ld a,STATE_LAVA ldio [mapState],a .bomber2StillActive cp 144 jr nz,.afterBombSound2 ld hl,((.bombSound-L0014_Check2)+levelCheckRAM) call PlaySound .afterBombSound2 cp 44 jr nz,.checkPos20 ld a,20 ld b,8 call SetupFadeFromSaturated call ((.explosion2 - L0014_Check2) + levelCheckRAM) call ((.drawCrack1 - L0014_Check2) + levelCheckRAM) ret .checkPos20 cp 20 ret nz call ((.explosion2 - L0014_Check2) + levelCheckRAM) ld c,QUATRAININDEX call GetFirst ld hl,$d306 call SetActorDestLoc ld c,IAMBICINDEX call GetFirst ld hl,$d387 call SetActorDestLoc ret .checkLava cp STATE_LAVA jr nz,.checkLava2 ;extend crack to top and bottom ld hl,levelVars + VAR_DELAY dec [hl] ret nz ld a,[updateTimer] and %1000 jr nz,.afterQuakeSound1 ld hl,((.earthquakeSound-L0014_Check2)+levelCheckRAM) call PlaySound .afterQuakeSound1 ld a,[levelVars + VAR_CRACK_TOP] or a jr nz,.crackNotDone ld a,[levelVars + VAR_CRACK_BOTTOM] cp 19 jr nz,.crackNotDone ld a,30 ld [levelVars + VAR_DELAY],a ld a,STATE_LAVA2 ;crack has extended ldio [mapState],a ret .crackNotDone ld a,[levelVars + VAR_CRACK_TOP] or a jr z,.afterCheckTop dec a ld [levelVars + VAR_CRACK_TOP],a .afterCheckTop ld a,[levelVars + VAR_CRACK_BOTTOM] cp 19 jr z,.afterCheckBottom inc a ld [levelVars + VAR_CRACK_BOTTOM],a .afterCheckBottom call ((.drawCrack1 - L0014_Check2) + levelCheckRAM) ret .checkLava2 cp STATE_LAVA2 jr nz,.checkLava3 ld a,10 ldio [jiggleDuration],a ld a,[updateTimer] and %1000 jr nz,.afterQuakeSound2 ld hl,((.earthquakeSound-L0014_Check2)+levelCheckRAM) call PlaySound .afterQuakeSound2 ld hl,levelVars + VAR_DELAY dec [hl] ret nz ;blit the second stage of lava to the screen call ((.scootObjects - L0014_Check2) + levelCheckRAM) ld bc,$1614 ld de,0 ld hl,$1600 call BlitMap call SetBGSpecialFlags ld a,30 ld [levelVars + VAR_DELAY],a ld a,STATE_LAVA3 ldio [mapState],a ret .checkLava3 cp STATE_LAVA3 jr nz,.checkDialog2_1 ld a,10 ldio [jiggleDuration],a ld a,[updateTimer] and %1000 jr nz,.afterQuakeSound3 ld hl,((.earthquakeSound-L0014_Check2)+levelCheckRAM) call PlaySound .afterQuakeSound3 ld hl,levelVars + VAR_DELAY dec [hl] ret nz ;blit the third stage of lava to the screen call ((.scootObjects - L0014_Check2) + levelCheckRAM) ld bc,$1614 ld de,0 ld hl,$2c00 call BlitMap call SetBGSpecialFlags ld c,QUATRAININDEX call GetFirst ld hl,$d403 call SetActorDestLoc ld c,IAMBICINDEX call GetFirst ld hl,$d502 call SetActorDestLoc ld a,30 ld [levelVars + VAR_DELAY],a ld a,STATE_DIALOG2_1 ldio [mapState],a ret .checkDialog2_1 cp STATE_DIALOG2_1 jr nz,.checkDialog2_2 ld de,((.setNormal-L0014_Check2)+levelCheckRAM) call SetDialogSkip call SetSpeakerToFirstHero ld de,haiku_askOkay_gtx call ShowDialogAtBottomNoWait ld a,STATE_DIALOG2_2 ldio [mapState+1],a ld a,STATE_DIALOG_WAIT ldio [mapState],a ret .checkDialog2_2 cp STATE_DIALOG2_2 jr nz,.checkDialog2_3 call SetSpeakerToFirstHero ld de,quatrain_gtx ld c,QUATRAININDEX call ShowDialogAtTopNoWait ld a,STATE_DIALOG2_3 ldio [mapState+1],a ld a,STATE_DIALOG_WAIT ldio [mapState],a ret .checkDialog2_3 call SetSpeakerToFirstHero ld de,haiku_goAhead_gtx call ShowDialogAtBottomNoWait ld a,STATE_NORMAL ldio [mapState+1],a ld a,STATE_DIALOG_WAIT ldio [mapState],a ret .setNormal call ClearDialog ld a,STATE_NORMAL ldio [mapState],a ret .explosion1 ;drop the bomb ld bc,$0404 ld de,$0a01 ld hl,$d28c call CreateBigExplosion ld hl,((.bigExplosionSound-L0014_Check2)+levelCheckRAM) call PlaySound ld a,10 ldio [jiggleDuration],a ret .explosion2 ;drop the bomb ld bc,$0404 ld de,$0a01 ld hl,$d488 call CreateBigExplosion ld hl,((.bigExplosionSound-L0014_Check2)+levelCheckRAM) call PlaySound ld a,10 ldio [jiggleDuration],a ret .drawCrack1 call ((.drawCrackTop - L0014_Check2) + levelCheckRAM) call ((.drawCrackMid1 - L0014_Check2) + levelCheckRAM) call ((.drawCrackBottom - L0014_Check2) + levelCheckRAM) ld a,3 ld [levelVars + VAR_DELAY],a ld a,6 ldio [jiggleDuration],a ret .drawCrackTop ld h,9 ;x coord ld a,[levelVars + VAR_CRACK_TOP] ld l,a call ConvertXYToLocHL ld a,MAPBANK ldio [$ff70],a ld a,CRACKTOPINDEX ld [hl+],a inc a ld [hl],a ret .drawCrackMid1 ld h,9 ;x coord ld a,[levelVars + VAR_CRACK_TOP] ld l,a ld c,a inc l call ConvertXYToLocHL ld a,[levelVars + VAR_CRACK_BOTTOM] sub c ret z dec a ret z ld c,a ;c is (bottom_y - top_y) - 1 (is >= 0) ld a,MAPBANK ldio [$ff70],a ld de,128 ;level pitch .drawMid1Loop ld a,CRACKMIDINDEX ld [hl+],a dec a ld [hl-],a add hl,de dec c jr nz,.drawMid1Loop ret .drawCrackBottom ld h,9 ;x coord ld a,[levelVars + VAR_CRACK_BOTTOM] ld l,a call ConvertXYToLocHL ld a,MAPBANK ldio [$ff70],a ld a,CRACKTOPINDEX + 2 ld [hl+],a inc a ld [hl],a ret .scootObjects ;scoots everyone < half left, >half right ;loop through 255 objects ld a,OBJLISTBANK ldio [$ff70],a ld b,((objExists>>8) & $ff) ld c,1 .scootLoop ld a,[bc] or a jr z,.nextObj ld a,c push bc call IndexToPointerDE call GetFacing ld c,a call RemoveFromMap call GetCurLocation call ConvertLocHLToXY ld a,h ;x coord cp 9 ;< half? jr nc,.greaterThanHalf dec h jr .setNewLoc .greaterThanHalf inc h .setNewLoc call ConvertXYToLocHL call SetCurLocation call GetClass ld b,METHOD_DRAW call CallMethod ld a,OBJLISTBANK ldio [$ff70],a pop bc .nextObj inc c jr nz,.scootLoop ret .bombSound DB 1,$1f,$80,$f5,$80,$86 .bigExplosionSound DB 4,$00,$f3,$81,$80 .earthquakeSound DB 4,$00,$f7,$67,$80 L0014_CheckFinished: PRINT "0014 Script Sizes (Load/Init/Check) (of $500): " PRINT (L0014_LoadFinished - L0014_Load2) PRINT " / " PRINT (L0014_InitFinished - L0014_Init2) PRINT " / " PRINT (L0014_CheckFinished - L0014_Check2) PRINT "\n"
mod_a: begin section text mod_b: extern public fat public n input n load n fat: sub one jmpz fim jmp mod_b fim: output n stop section data n: space one: const 1 end
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r8 push %rbp push %rcx lea addresses_UC_ht+0x1688d, %rcx nop nop nop nop nop xor %r11, %r11 mov (%rcx), %bp xor %r8, %r8 pop %rcx pop %rbp pop %r8 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r13 push %rax push %rdx // Faulty Load mov $0x54a307000000008d, %rdx nop nop and %rax, %rax mov (%rdx), %r11w lea oracles, %rdx and $0xff, %r11 shlq $12, %r11 mov (%rdx,%r11,1), %r11 pop %rdx pop %rax pop %r13 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': True, 'congruent': 11, 'size': 2, 'same': True, 'NT': True}} {'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 */
// ============================================================================= // === GPUQREngine/Source/GPUQREngine_ExpertDense.cpp ========================== // ============================================================================= // // This file contains the dense GPUQREngine wrapper that finds the staircase, // makes a copy of the user's front data, then calls down into the Internal // GPUQREngine factorization routine. // // Other functions include: // - GPUQREngine_Cleanup: Cleans up relevant workspaces in the dense // factorization depending on how we're exiting. // - GPUQREngine_FindStaircase: Finds the staircase for a front and returns // the staircase as an Int* list // ============================================================================= #include "GPUQREngine_Internal.hpp" QREngineResultCode GPUQREngine_Cleanup ( QREngineResultCode code, // The result code that we're exiting with Front *userFronts, // The user-provided list of fronts Front *fronts, // The internal copy of the user's fronts Int numFronts, // The number of fronts to be factorized Workspace *wsMongoF, // Pointer to the total GPU Front workspace Workspace *wsMongoR // Pointer to the total CPU R workspace ); QREngineResultCode GPUQREngine ( size_t gpuMemorySize, // The total available GPU memory size in bytes Front *userFronts, // The list of fronts to factorize Int numFronts, // The number of fronts to factorize QREngineStats *stats // An optional parameter. If present, statistics // are collected and passed back to the caller // via this struct ) { /* Allocate workspaces */ Front *fronts = (Front*) SuiteSparse_calloc(numFronts, sizeof(Front)); if(!fronts) { return QRENGINE_OUTOFMEMORY; } size_t FSize, RSize; FSize = RSize = 0; for(int f=0; f<numFronts; f++) { /* Configure the front */ Front *userFront = &(userFronts[f]); Int m = userFront->fm; Int n = userFront->fn; Front *front = new (&fronts[f]) Front(f, EMPTY, m, n); FSize += front->getNumFrontValues(); RSize += front->getNumRValues(); } // We have to allocate page-locked CPU-GPU space to leverage asynchronous // memory transfers. This has to be done in a way that the CUDA driver is // aware of, which unfortunately means making a copy of the user input. // calloc pagelocked space on CPU, and calloc space on the GPU Workspace *wsMongoF = Workspace::allocate(FSize, // CPU and GPU sizeof(float), true, true, true, true); // calloc pagelocked space on the CPU. Nothing on the GPU Workspace *wsMongoR = Workspace::allocate(RSize, // CPU sizeof(float), true, true, false, true); /* Cleanup and return if we ran out of memory. */ if(!wsMongoF || !wsMongoR) { return GPUQREngine_Cleanup (QRENGINE_OUTOFMEMORY, userFronts, fronts, numFronts, wsMongoF, wsMongoR); } /* Prepare the fronts for GPU execution. */ size_t FOffset, ROffset; FOffset = ROffset = 0; for(int f=0; f<numFronts; f++) { // Set the front pointers; make the copy from user data into front data. Front *front = &(fronts[f]); front->F = CPU_REFERENCE(wsMongoF, float*) + FOffset; front->gpuF = GPU_REFERENCE(wsMongoF, float*) + FOffset; front->cpuR = CPU_REFERENCE(wsMongoR, float*) + ROffset; FOffset += front->getNumFrontValues(); ROffset += front->getNumRValues(); /* COPY USER DATA (user's F to our F) */ Front *userFront = &(userFronts[f]); float *userF = userFront->F; float *F = front->F; Int m = userFront->fm; Int n = userFront->fn; bool isColMajor = userFront->isColMajor; Int ldn = userFront->ldn; for(Int i=0; i<m; i++) { for(Int j=0; j<n; j++) { F[i*n+j] = (isColMajor ? userF[j*ldn+i] : userF[i*ldn+j]); } } /* Attach either the user-specified Stair, or compute it. */ front->Stair = userFront->Stair; if(!front->Stair) front->Stair = GPUQREngine_FindStaircase(front); /* Cleanup and return if we ran out of memory building the staircase */ if(!front->Stair) { return GPUQREngine_Cleanup (QRENGINE_OUTOFMEMORY, userFronts, fronts, numFronts, wsMongoF, wsMongoR); } } /* Transfer the fronts to the GPU. */ if(!wsMongoF->transfer(cudaMemcpyHostToDevice)) { return GPUQREngine_Cleanup (QRENGINE_GPUERROR, userFronts, fronts, numFronts, wsMongoF, wsMongoR); } /* Do the factorization for this set of fronts. */ QREngineResultCode result = GPUQREngine_Internal(gpuMemorySize, fronts, numFronts, NULL, NULL, NULL, stats); if(result != QRENGINE_SUCCESS) { return GPUQREngine_Cleanup (result, userFronts, fronts, numFronts, wsMongoF, wsMongoR); } /* COPY USER DATA (our R back to user's R) */ for(int f=0; f<numFronts; f++) { Front *userFront = &(userFronts[f]); float *R = (&fronts[f])->cpuR; float *userR = userFront->cpuR; Int m = userFront->fm; Int n = userFront->fn; Int rank = userFront->rank; bool isColMajor = userFront->isColMajor; Int ldn = userFront->ldn; for(Int i=0; i<rank; i++) { for(Int j=0; j<n; j++) { userR[i*ldn+j] = (isColMajor ? R[j*n+i] : R[i*n+j]); } } } /* Return that the factorization was successful. */ return GPUQREngine_Cleanup (QRENGINE_SUCCESS, userFronts, fronts, numFronts, wsMongoF, wsMongoR); } QREngineResultCode GPUQREngine_Cleanup ( QREngineResultCode code, // The result code that we're exiting with Front *userFronts, // The user-provided list of fronts Front *fronts, // The internal copy of the user's fronts Int numFronts, // The number of fronts to be factorized Workspace *wsMongoF, // Pointer to the total GPU Front workspace Workspace *wsMongoR // Pointer to the total CPU R workspace ) { /* Cleanup fronts. */ for(int f=0; f<numFronts; f++) { Front *userFront = (&userFronts[f]); Front *front = &(fronts[f]); if(front != NULL) { /* If we had to attach our own stair, clean it up. */ if(userFront->Stair == NULL && front->Stair != NULL) { front->Stair = (Int *) SuiteSparse_free(front->Stair); } /* Detach front data since it's managed by the mongo. */ front->F = NULL; } } fronts = (Front *) SuiteSparse_free(fronts); /* Free the mongo structures. Note that Workspace checks for NULL. */ wsMongoF = Workspace::destroy(wsMongoF); wsMongoR = Workspace::destroy(wsMongoR); return code; } Int *GPUQREngine_FindStaircase ( Front *front // The front whose staircase we are computing ) { Int fm = front->fm; Int fn = front->fn; float *F = front->F; Int *Stair = (Int*) SuiteSparse_malloc(fn, sizeof(Int)); if(!F || !Stair) return NULL; Int lastStair = 0; for(int j=0; j<fn; j++) { int i; for(i=fm-1; i>lastStair && F[i*fn+j] == 0.0; i--); Stair[j] = lastStair = i; } return Stair; }
; A085287: Expansion of (1+4x)/((1-x^2)(1-3x)). ; 1,7,22,70,211,637,1912,5740,17221,51667,155002,465010,1395031,4185097,12555292,37665880,112997641,338992927,1016978782,3050936350,9152809051,27458427157,82375281472,247125844420,741377533261,2224132599787,6672397799362,20017193398090,60051580194271,180154740582817,540464221748452,1621392665245360,4864177995736081,14592533987208247,43777601961624742,131332805884874230,393998417654622691,1181995252963868077,3545985758891604232,10637957276674812700,31913871830024438101,95741615490073314307,287224846470219942922,861674539410659828770,2585023618231979486311,7755070854695938458937,23265212564087815376812,69795637692263446130440,209386913076790338391321,628160739230371015173967,1884482217691113045521902,5653446653073339136565710,16960339959220017409697131,50881019877660052229091397,152643059632980156687274192,457929178898940470061822580,1373787536696821410185467741,4121362610090464230556403227,12364087830271392691669209682,37092263490814178075007629050,111276790472442534225022887151,333830371417327602675068661457,1001491114251982808025205984372,3004473342755948424075617953120,9013420028267845272226853859361,27040260084803535816680561578087,81120780254410607450041684734262,243362340763231822350125054202790,730087022289695467050375162608371,2190261066869086401151125487825117,6570783200607259203453376463475352,19712349601821777610360129390426060,59137048805465332831080388171278181,177411146416395998493241164513834547,532233439249187995479723493541503642 mov $1,3 pow $1,$0 mul $1,7 div $1,8 mul $1,3 add $1,1 mov $0,$1
; A005909: a(n) = [ tau*a(n-1) ] + [ tau*a(n-2) ]. ; Submitted by Christian Krause ; 0,2,3,7,15,35,80,185,428,991,2295,5316,12314,28525,66078,153070,354588,821407,1902799,4407857,10210855,23653572,54793793,126930502,294036085,681138245,1577865210,3655144370 mov $2,1 lpb $0 sub $0,1 add $5,$1 mov $1,$3 sub $3,$4 add $3,$5 add $3,2 mov $4,$2 mov $2,$3 sub $5,1 add $5,$4 mov $3,$5 add $3,2 lpe mov $0,$3
// serial_sender.cpp #include <wiringPi.h> //for delay() #include <wiringSerial.h> #include <sys/types.h> //#include <sys/socket.h> #include <sys/ioctl.h> //#include <net/if.h> //#include <netinet/in.h> //#include <arpa/inet.h> //#include <ifaddrs.h> #include <unistd.h> #include <cstring> #include <string> #include <vector> #include <thread> #include "serial_sender.h" //#include "canvas/canvas_manager.h" //#include "canvas/canvas.h" using namespace std; using namespace Beamertool; SerialSender::SerialSender(char * serialPortName, int serialPortBaud, int dmxChOut, int led_gpio_pin) { // save parameters this->serialPortName = serialPortName; //"/dev/ttyAMA0" onboard "/dev/ttyUSB0" usb this->serialPortBaud = serialPortBaud; this->dmxChOut = dmxChOut; this->led_gpio_pin = led_gpio_pin; //<0 -> deaktiviert this->led_status = 0; this->led_packet_counter = 0; // Init Serial Port //this->fd = serialOpen (this->serialPortName,this->serialPortBaud); this->fd = serialOpen ("/dev/ttyUSB0",9600); if (this->fd < 0) { printf ("init_net: Kann seriellen Port nicht öffnen ...(%s)\n", strerror(errno)); exit (EXIT_FAILURE); } // check for root this->is_root = false; if (getuid() == 0) { this->is_root = true; } // init LED //initLED(); //setLED(1); // Start net listener //memset(&this->client_address, '\0', sizeof(this->client_address)); this->quit = false; cyclic_sender_thread = thread(&SerialSender::cyclicSender, this); } SerialSender::~SerialSender() { // stop listening this->quit = true; cyclic_sender_thread.join(); //close serial Port serialClose (this->fd); // poweroff led //setLED(0); //quitLED(); } void SerialSender::cyclicSender() { while (!this->quit) { //Byte String zusammenbauen //Beispiel: "1c127w2c127w3c127w4c127w\n" //Erklärung: 1c -> Kanal 1, 127w -> Wert von diesem Kanal auf 127 setzen // der Empfänger (Arduino) übernimmt einen Wert immer mit dem 'w' // am Ende \n um die Reflektion vom Arduino im Serial Monitor besser beobachten zu können //***TODO*** sprintf(this->sendString,"\0"); for (int i=0; i<this->dmxChOut; i++) { sprintf(this->sendString,"%s%ic%iw",this->sendString,1+i,this->dmx[i]); //Startadresse für DMX Out hardcoded = 1 ***MAGIC*** } sprintf(this->sendString,"%s\n",this->sendString); //Bytes verschicken /* if (sendCount == 0) { serialPrintf(this->fd, "1c127w2c127w3c127w4c127w\n"); sendCount++; } else { serialPrintf(this->fd, "1c120w2c120w3c120w4c120w\n"); sendCount = 0; } sleep(1); //test */ //serialPrintf(this->fd, this->sendString); serialPuts(this->fd, this->sendString); //delay (100); //9600 bit/s : (130*8) bit -> 9,2Hz ~10 Hz -> dabei werden irgendwo trotzdem bytes verschluckt delay (200); //5Hz läuft stabil //bei 115200 sollte es 12x schneller gehen } } void SerialSender::setValues(int values[16]) { //Werte übernehmen for (int i=0; i<16; i++) { this->dmx[i] = values[i]; } } void SerialSender::initLED() { if (this->is_root && this->led_gpio_pin >= 0) { FILE *ptr; ptr = fopen("/sys/class/gpio/export", "w"); fprintf(ptr, "%d", this->led_gpio_pin); // enable GPIO-Port fclose(ptr); char gpio[50]; sprintf(gpio, "/sys/class/gpio/gpio%d/direction", this->led_gpio_pin); ptr = fopen(gpio, "w"); fprintf(ptr, "out"); // set Port to output fclose(ptr); } } void SerialSender::setLED(int value) { if (this->is_root && this->led_gpio_pin >= 0) { int set_value; if (value >= 1) { set_value = 1; this->led_status = 1; } else { set_value = 0; this->led_status = 0; } FILE *ledptr; char gpio[50]; sprintf(gpio, "/sys/class/gpio/gpio%d/value", this->led_gpio_pin); ledptr = fopen(gpio, "w"); fprintf(ledptr, "%d", set_value); fclose(ledptr); } } void SerialSender::quitLED() { if (this->is_root && this->led_gpio_pin >= 0) { FILE *ptr; ptr = fopen("/sys/class/gpio/unexport", "w"); fprintf(ptr, "%d", this->led_gpio_pin); fclose(ptr); } }
; --------------------------------------------------------------------------- ; Object 19 - blank ; --------------------------------------------------------------------------- Obj19: rts
; A164013: 3 times centered triangular numbers: 9*n*(n+1)/2 + 3. ; 3,12,30,57,93,138,192,255,327,408,498,597,705,822,948,1083,1227,1380,1542,1713,1893,2082,2280,2487,2703,2928,3162,3405,3657,3918,4188,4467,4755,5052,5358,5673,5997,6330,6672,7023,7383,7752,8130,8517,8913,9318,9732,10155,10587,11028,11478,11937,12405,12882,13368,13863,14367,14880,15402,15933,16473,17022,17580,18147,18723,19308,19902,20505,21117,21738,22368,23007,23655,24312,24978,25653,26337,27030,27732,28443,29163,29892,30630,31377,32133,32898,33672,34455,35247,36048,36858,37677,38505,39342 sub $1,$0 bin $1,2 mul $1,9 add $1,3 mov $0,$1
; A128964: a(n) = (n^3-n)*6^n. ; 0,216,5184,77760,933120,9797760,94058496,846526464,7255941120,59861514240,478892113920,3735358488576,28524555730944,213934167982080,1579821548175360,11510128422420480,82872924641427456,590469588070170624,4168020621671792640,29176144351702548480,202697423917091389440,1398612225027930587136,9590483828762952597504,65389662468838313164800,443512493266903341465600,2993709329551597554892800,20117726694586735568879616,134634017109926614960963584,897560114066177433073090560,5962363614868178662556958720,39474959105334148386584002560,260534730095205379351454416896,1714486610949093464119248420864,11251318384353425858282567761920,73644993061222423799667716259840,480858484105628767162536264990720,3132449553602381683230236240510976,20360922098415480940996535563321344,132070846043776092590247798248570880,854984950704445230978972588661800960 add $0,2 mov $2,6 pow $2,$0 bin $0,3 mul $0,$2
; A251194: Number of (n+1) X (1+1) 0..1 arrays with no 2 X 2 subblock having the minimum of its diagonal elements less than the absolute difference of its antidiagonal elements. ; Submitted by Christian Krause ; 10,25,64,164,421,1081,2776,7129,18308,47017,120745,310087,796339,2045090,5252026,13487806,34638235,88954966,228446570,586677031,1506654001,3869260528,9936705457,25518600938,65534698261,168300632413,432215354953,1109978675533,2850552730298,7320546824296,18800005078702,48280572400165,123990055403140,318420703703612,817740940734637,2100052661073193,5393176444508908,13850296566725953,35569152420661892,91345668869193589,234586169568476101,602444227887951535,1547145973622999791,3973248564584232962 add $0,2 seq $0,123888 ; Expansion of g.f.: x/((1-x^2)^3 -1+x). add $0,1
;=============================================================================== ; Copyright 2014-2021 Intel Corporation ; ; 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. ;=============================================================================== ; ; ; Purpose: Cryptography Primitive. ; Rijndael Inverse Cipher function ; ; Content: ; DecryptCBC_RIJ128pipe_AES_NI() ; ; %include "asmdefs.inc" %include "ia_emm.inc" ;*************************************************************** ;* Purpose: pipelined RIJ128 CBC decryption ;* ;* void DecryptCBC_RIJ128pipe_AES_NI(const Ipp32u* inpBlk, ;* Ipp32u* outBlk, ;* int nr, ;* const Ipp32u* pRKey, ;* int len, ;* const Ipp8u* pIV) ;*************************************************************** ;%if (_IPP >= _IPP_P8) && (_IPP < _IPP_G9) %if (_IPP >= _IPP_P8) ;; ;; Lib = G9 ;; ;; Caller = ippsRijndael128DecryptCBC ;; segment .text align=IPP_ALIGN_FACTOR align IPP_ALIGN_FACTOR IPPASM DecryptCBC_RIJ128pipe_AES_NI,PUBLIC USES_GPR esi,edi,ebx,ebp mov ebp, esp ; save original esp to use it to reach parameters %xdefine pInpBlk [ebp + ARG_1 + 0*sizeof(dword)] ; input block address %xdefine pOutBlk [ebp + ARG_1 + 1*sizeof(dword)] ; output block address %xdefine nr [ebp + ARG_1 + 2*sizeof(dword)] ; number of rounds %xdefine pKey [ebp + ARG_1 + 3*sizeof(dword)] ; key material address %xdefine len [ebp + ARG_1 + 4*sizeof(dword)] ; length(byte) %xdefine pIV [ebp + ARG_1 + 5*sizeof(dword)] ; IV %xdefine SC (4) %assign BLKS_PER_LOOP (4) %assign BYTES_PER_BLK (16) %assign BYTES_PER_LOOP (BYTES_PER_BLK*BLKS_PER_LOOP) mov esi,pInpBlk ; input data address mov edi,pOutBlk ; output data address mov ecx,pKey ; key material address mov eax,nr ; number of rounds sub esp, 16*(1+4+1) ; allocate stack lea edx, [esp+16] and edx, -16 mov ebx, pIV movdqu xmm4, oword [ebx] ; save IV movdqa oword [edx+0*16], xmm4 ; into the stack sub dword len, BYTES_PER_LOOP jl .short_input lea ebx,[eax*SC] ; keys offset lea ecx,[ecx+ebx*4] ;; ;; pipelined processing ;; .blks_loop: movdqa xmm4, oword [ecx] ; keys for whitening lea ebx, [ecx-16] ; set pointer to the round's key material movdqu xmm0, oword [esi+0*BYTES_PER_BLK] ; get input blocks movdqu xmm1, oword [esi+1*BYTES_PER_BLK] movdqu xmm2, oword [esi+2*BYTES_PER_BLK] movdqu xmm3, oword [esi+3*BYTES_PER_BLK] movdqa oword [edx+1*16], xmm0 ; and save as IVx movdqa oword [edx+2*16], xmm1 ; for next operations movdqa oword [edx+3*16], xmm2 ; into the stack movdqa oword [edx+4*16], xmm3 pxor xmm0, xmm4 ;whitening pxor xmm1, xmm4 pxor xmm2, xmm4 pxor xmm3, xmm4 movdqa xmm4, oword [ebx] ; pre load operation's keys sub ebx, 16 mov eax, nr ; counter depending on key length sub eax, 1 .cipher_loop: aesdec xmm0, xmm4 ; regular round aesdec xmm1, xmm4 aesdec xmm2, xmm4 aesdec xmm3, xmm4 movdqa xmm4, oword [ebx] ; pre load operation's keys sub ebx, 16 dec eax jnz .cipher_loop aesdeclast xmm0, xmm4 ; irregular round and IV pxor xmm0, oword [edx+0*16] ; xor with IV movdqu oword [edi+0*16], xmm0 ; and store output blocls aesdeclast xmm1, xmm4 pxor xmm1, oword [edx+1*16] movdqu oword [edi+1*16], xmm1 aesdeclast xmm2, xmm4 pxor xmm2, oword [edx+2*16] movdqu oword [edi+2*16], xmm2 aesdeclast xmm3, xmm4 pxor xmm3, oword [edx+3*16] movdqu oword [edi+3*16], xmm3 movdqa xmm4, oword [edx+4*16] ; update IV movdqa oword [edx+0*16], xmm4 add esi, BYTES_PER_LOOP add edi, BYTES_PER_LOOP sub dword len, BYTES_PER_LOOP jge .blks_loop ;; ;; block-by-block processing ;; .short_input: add dword len, BYTES_PER_LOOP jz .quit mov eax, nr mov ecx, pKey lea ebx,[eax*SC] ; set pointer to the key material lea ebx,[ecx+ebx*4] .single_blk_loop: movdqu xmm0, oword [esi] ; get input block movdqa oword [edx+16], xmm0 ; and save as IV for future pxor xmm0, oword [ebx] ; whitening cmp eax,12 ; switch according to number of rounds jl .key_128_s jz .key_192_s .key_256_s: aesdec xmm0, oword [ecx+9*SC*4+4*SC*4] aesdec xmm0, oword [ecx+9*SC*4+3*SC*4] .key_192_s: aesdec xmm0, oword [ecx+9*SC*4+2*SC*4] aesdec xmm0, oword [ecx+9*SC*4+1*SC*4] .key_128_s: aesdec xmm0, oword [ecx+9*SC*4-0*SC*4] aesdec xmm0, oword [ecx+9*SC*4-1*SC*4] aesdec xmm0, oword [ecx+9*SC*4-2*SC*4] aesdec xmm0, oword [ecx+9*SC*4-3*SC*4] aesdec xmm0, oword [ecx+9*SC*4-4*SC*4] aesdec xmm0, oword [ecx+9*SC*4-5*SC*4] aesdec xmm0, oword [ecx+9*SC*4-6*SC*4] aesdec xmm0, oword [ecx+9*SC*4-7*SC*4] aesdec xmm0, oword [ecx+9*SC*4-8*SC*4] aesdeclast xmm0, oword [ecx+9*SC*4-9*SC*4] pxor xmm0, oword [edx+0*16] ; add IV movdqu oword [edi], xmm0 ; and save output blocl movdqa xmm4, oword [edx+1*16] ; update IV movdqa oword [edx+0*16], xmm4 add esi, BYTES_PER_BLK add edi, BYTES_PER_BLK sub dword len, BYTES_PER_BLK jnz .single_blk_loop .quit: add esp, 16*(1+4+1) ; free stack REST_GPR ret ENDFUNC DecryptCBC_RIJ128pipe_AES_NI %endif
;ASTER 02/03/2009 2135 ;TO BE ASSEMBLED IN KEIL MICROVISION V3.60 ;ARTIFICIAL INTELLIGENCE ;MICROCOMPUTER B ;REV 0 LAST UPDATED 04/03/2009 1610 ;----------------------------------------------------------------------------------------------------------- ;SET THE ASSEMBLER FOR AT89S52 $NOMOD51 $INCLUDE (AT89X52.h) ;----------------------------------------------------------------------------------------------------------- ORG 0000H RESET: SJMP 0030H ORG 0030H START: NOP MOV SP,#10H ;RELOCATE STACK OVER 10H CLR A MOV P0,A MOV P1,A MOV P2,A MOV P3,#0FFH LCALL DELAYIN MOV R0,#20H ;CLEAR RAM FROM 20H TO 7FH CLR A CLRALL: MOV @R0,A INC R0 CJNE R0,#7FH,CLRALL MOV T2CON,#30H ;SET UP THE UART 9600BPS MOV RCAP2H,#0FFH MOV RCAP2L,#0DCH ANL PCON,#7FH MOV IE,#90H ;ENABLE INTERRUPTS: SERIAL MOV IP,#10H MOV SCON,#58H SETB TR2 ;START BAUD GEN TIMER ;---------------------------------------------------------------------------------------------------------- ;********************************************************************************************************** ;THE PROGRAM MAIN ;PASS DIRECTION IN R2,BANK0 : 00H->FORWARD, 01H->BACKWARD MAIN: MAIN_END: LJMP MAIN ;MAIN ENDS HERE ;********************************************************************************************************** ;---------------------------------------------------------------------------------------------------------- ;INTERRUPT SERVICE ROUTINES ORG 0023H LJMP 1000H ORG 1000H SERCON: CLR TR2 JNB RI,TXI CLR RI MOV A,SBUF JB 20H,SKIPC CJNE A,#0CEH,EXITC MOV SBUF,#9EH SETB 20H SJMP EXITC SKIPC: CJNE A,#0BEH,SKIPC2 MOV SBUF,#0BEH CLR 20H SJMP EXITC SKIPC2: SETB 21H MOV SBUF,#9EH SJMP EXITC TXI: CLR TI EXITC: SETB TR2 RETI ;---------------------------------------------------------------------------------------------------------- ;MOTOR DRIVING ROUTINES ;MOTOR 1: BASE RIGHT MOTOR :: MOTOR CODE: 01H BSERGT: NOP CJNE R2,#00H,BACK1 SETB P2.0 CLR P2.1 MOV 34H,#00H SJMP DONE1 BACK1: CJNE R2,#01H,RSTP1 CLR P2.0 SETB P2.1 MOV 34H,#01H SJMP DONE1 RSTP1: CJNE R2,#02H,HSTP1 CLR P2.0 CLR P2.1 MOV 34H,#04H SJMP DONE1 HSTP1: MOV R3,34H CJNE R3,#00H,RREV1 RFOR1: CLR P2.0 CLR P2.1 LCALL DELAYHS SETB P2.1 LCALL DELAYHS CLR P2.1 MOV 34H,#04H SJMP DONE1 RREV1: CJNE R3,#01H,DONE1 CLR P2.0 CLR P2.1 LCALL DELAYHS SETB P2.0 LCALL DELAYHS CLR P2.0 MOV 34H,#04H DONE1: NOP RET ;MOTOR 2: BASE LEFT MOTOR :: MOTOR CODE: 02H BSELFT: NOP CJNE R2,#00H,BACK2 SETB P2.2 CLR P2.3 MOV 38H,#00H SJMP DONE2 BACK2: CJNE R2,#01H,RSTP2 CLR P2.2 SETB P2.3 MOV 38H,#01H SJMP DONE2 RSTP2: CJNE R2,#02H,HSTP2 CLR P2.2 CLR P2.3 MOV 38H,#04H SJMP DONE2 HSTP2: MOV R3,38H CJNE R3,#00H,RREV2 RFOR2: CLR P2.2 CLR P2.3 LCALL DELAYHS SETB P2.3 LCALL DELAYHS CLR P2.3 MOV 38H,#04H SJMP DONE2 RREV2: CJNE R3,#01H,DONE2 CLR P2.2 CLR P2.3 LCALL DELAYHS SETB P2.2 LCALL DELAYHS CLR P2.2 MOV 38H,#04H DONE2: NOP RET ;MOTOR 3: SHOULDER RIGHT MOTOR :: MOTOR CODE: 03H SHLRGT: NOP CJNE R2,#00H,BACK3 SETB P2.4 CLR P2.5 MOV 3CH,#00H SJMP DONE1 BACK3: CJNE R2,#01H,RSTP3 CLR P2.4 SETB P2.5 MOV 3CH,#01H SJMP DONE3 RSTP3: CJNE R2,#02H,HSTP3 CLR P2.4 CLR P2.5 MOV 3CH,#04H SJMP DONE3 HSTP3: MOV R3,3CH CJNE R3,#00H,RREV3 RFOR3: CLR P2.4 CLR P2.5 LCALL DELAYHS SETB P2.5 LCALL DELAYHS CLR P2.5 MOV 3CH,#04H SJMP DONE3 RREV3: CJNE R3,#01H,DONE3 CLR P2.4 CLR P2.5 LCALL DELAYHS SETB P2.4 LCALL DELAYHS CLR P2.4 MOV 3CH,#04H DONE3: NOP RET ;MOTOR 4: SHOULDER LEFT MOTOR :: MOTOR CODE: 04H SHLLFT: NOP CJNE R2,#00H,BACK4 SETB P2.6 CLR P2.7 MOV 40H,#00H SJMP DONE4 BACK4: CJNE R2,#01H,RSTP4 CLR P2.6 SETB P2.7 MOV 40H,#01H SJMP DONE4 RSTP4: CJNE R2,#02H,HSTP4 CLR P2.6 CLR P2.7 MOV 40H,#04H SJMP DONE4 HSTP4: MOV R3,40H CJNE R3,#00H,RREV4 RFOR4: CLR P2.6 CLR P2.7 LCALL DELAYHS SETB P2.7 LCALL DELAYHS CLR P2.7 MOV 40H,#04H SJMP DONE4 RREV4: CJNE R3,#01H,DONE4 CLR P2.6 CLR P2.7 LCALL DELAYHS SETB P2.6 LCALL DELAYHS CLR P2.6 MOV 40H,#04H DONE4: NOP RET ;MOTOR 5: ARM ELBOW RIGHT MOTOR :: MOTOR CODE : 05H ELRGT: NOP CJNE R2,#00H,BACK5 SETB P1.0 CLR P1.1 MOV 44H,#00H SJMP DONE5 BACK5: CJNE R2,#01H,RSTP5 CLR P1.0 SETB P1.1 MOV 44H,#01H SJMP DONE5 RSTP5: CJNE R2,#02H,HSTP5 CLR P1.0 CLR P1.1 MOV 44H,#04H SJMP DONE5 HSTP5: MOV R3,44H CJNE R3,#00H,RREV5 RFOR5: CLR P1.0 CLR P1.1 LCALL DELAYHS SETB P1.1 LCALL DELAYHS CLR P1.1 MOV 44H,#04H SJMP DONE5 RREV5: CJNE R3,#01H,DONE5 CLR P1.0 CLR P1.1 LCALL DELAYHS SETB P1.0 LCALL DELAYHS CLR P1.0 MOV 44H,#04H DONE5: NOP RET ;MOTOR 6: ARM ELBOW RIGHT MOTOR :: MOTOR CODE : 06H ELLFT: NOP CJNE R2,#00H,BACK6 SETB P1.2 CLR P1.3 MOV 48H,#00H SJMP DONE6 BACK6: CJNE R2,#01H,RSTP6 CLR P1.2 SETB P1.3 MOV 48H,#01H SJMP DONE6 RSTP6: CJNE R2,#02H,HSTP6 CLR P1.2 CLR P1.3 MOV 48H,#04H SJMP DONE6 HSTP6: MOV R3,48H CJNE R3,#00H,RREV6 RFOR6: CLR P1.2 CLR P1.3 LCALL DELAYHS SETB P1.3 LCALL DELAYHS CLR P1.3 MOV 48H,#04H SJMP DONE6 RREV6: CJNE R3,#01H,DONE6 CLR P1.2 CLR P1.3 LCALL DELAYHS SETB P1.2 LCALL DELAYHS CLR P1.2 MOV 48H,#04H DONE6: NOP RET ;MOTOR 7: RIGHT CLASPER :: MOTOR CODE: 07H ;MOTOR 8: LEFT CLASPER :: MOTOR CODE : 08H ;------------------------------------------------------------------------------------------------- ;DELAY ROUTINES ;DELAY INIT DELAYIN: MOV R7,#07H MOV R6,#0FFH MOV R5,#0FFH DJNZ R5,$ DJNZ R6,$-2 DJNZ R7,$-4 RET DELAYHS: MOV R7,#0A0H DJNZ R7,$ RET ;-------------------------------------------------------------------------------------------------- END
.model tiny .code org 100h kkk: nop ; ID count db 90h ; ID mov cx,80h mov si,0080h mov di,0ff7fh rep movsb ; save param lea ax,begp ; begin prog mov cx,ax sub ax,100h mov ds:[0fah],ax ; len VIR add cx,fso mov ds:[0f8h],cx ; begin buffer W ADD CX,AX mov ds:[0f6h],cx ; begin buffer R mov cx,ax lea si,kkk mov di,ds:[0f8h] RB: REP MOVSB ; move v mov al,3 ; inf. only 3 file mov count,al stc LEA DX,FFF MOV AH,4EH MOV CX,20H INT 21H ; find first or ax,ax jz LLL jmp done LLL: MOV AH,2FH INT 21H ; get DTA mov ax,es:[bx+1ah] mov ds:[0fch],ax ; size add bx,1eh mov ds:[0feh],bx ; point to name mov ax,'OC' ; "CO" sub ax,ds:[009eh] je fin ; if file name CO*.com then skip add ax,180h ; if new len file + len VIR + 180h > FFF0 add ax,ds:[0fah] ; then skip this file add ax,fso cmp ax,0fff0h ja fin clc mov ax,3d02h mov dx,bx int 21h ; open file mov bx,ax mov ah,3fh mov cx,ds:[0fch] mov dx,ds:[0f6h] int 21h ; read file mov bx,dx mov ax,[bx] sub ax,9090h jz fin ; if file inf. then skip this file mov al,'M' mov di,dx mov cx,ds:[0fch] repne scasb jne cont mov al,'Z' cmp es:[di],al je fin ; if converted then skip cont: MOV AX,ds:[0fch] mov bx,ds:[0f6h] mov [bx-2],ax ; correct old len mov ah,3ch mov cx,00h mov dx,ds:[0feh] ; point to name clc int 21h ; create file mov bx,ax ; # mov ah,40h mov cx,ds:[0fch] add cx,ds:[0fah] mov DX,ds:[0f8h] int 21h ; write file mov ah,3eh int 21h ;close file dec count jz done FIN: stc mov ah,4fh int 21h ; find next or ax,ax jnz done JMP lll DONE: mov cx,80h mov si,0ff7fh mov di,0080h rep movsb ; restore param MOV AX,0A4F3H mov ds:[0fff9h],ax mov al,0eah mov ds:[0fffbh],al mov ax,100h mov ds:[0fffch],ax ; remove REP MOVSB and FAR JMP cs:0100 lea si,begp lea di,kkk mov ax,cs mov ds:[0fffeh],ax mov kk,ax mov cx,fso db 0eah dw 0fff9h kk dw 0000h fff db '*?.com',0 fso dw 0005h ; source len file begp: MOV AX,4C00H int 21h ; exit end kkk
; A259902: n*a(n+1) = (2*n^2+3n-1)*a(n)-(n^2-n-2)*a(n-1); a(0)=0, a(1)=1. ; Submitted by Christian Krause ; 0,1,4,26,220,2300,28648,414212,6818728,125907560,2577034480,57906103064,1417086592336,37515931327184,1068289141830880,32558309340991280,1057440044863257952,36460006715962829408,1330080906206563365952,51183492956063789966240 mov $2,1 mov $4,1 lpb $0 sub $0,1 mov $3,$4 add $4,$2 mul $2,$0 add $2,$3 add $4,$2 add $2,$4 lpe mov $0,$3
<% import collections import pwnlib.abi import pwnlib.constants import pwnlib.shellcraft import six %> <%docstring>mpx(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str Invokes the syscall mpx. See 'man 2 mpx' for more information. Arguments: vararg(int): vararg Returns: long </%docstring> <%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/> <% abi = pwnlib.abi.ABI.syscall() stack = abi.stack regs = abi.register_arguments[1:] allregs = pwnlib.shellcraft.registers.current() can_pushstr = [] can_pushstr_array = [] argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4'] argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4] # Load all of the arguments into their destination registers / stack slots. register_arguments = dict() stack_arguments = collections.OrderedDict() string_arguments = dict() dict_arguments = dict() array_arguments = dict() syscall_repr = [] for name, arg in zip(argument_names, argument_values): if arg is not None: syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) # If the argument itself (input) is a register... if arg in allregs: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[index] = arg # The argument is not a register. It is a string value, and we # are expecting a string value elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): if isinstance(arg, six.text_type): arg = arg.encode('utf-8') string_arguments[name] = arg # The argument is not a register. It is a dictionary, and we are # expecting K:V paris. elif name in can_pushstr_array and isinstance(arg, dict): array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] # The arguent is not a register. It is a list, and we are expecting # a list of arguments. elif name in can_pushstr_array and isinstance(arg, (list, tuple)): array_arguments[name] = arg # The argument is not a register, string, dict, or list. # It could be a constant string ('O_RDONLY') for an integer argument, # an actual integer value, or a constant. else: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[target] = arg # Some syscalls have different names on various architectures. # Determine which syscall number to use for the current architecture. for syscall in ['SYS_mpx']: if hasattr(pwnlib.constants, syscall): break else: raise Exception("Could not locate any syscalls: %r" % syscalls) %> /* mpx(${', '.join(syscall_repr)}) */ %for name, arg in string_arguments.items(): ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} %endfor %for name, arg in array_arguments.items(): ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} %endfor %for name, arg in stack_arguments.items(): ${pwnlib.shellcraft.push(arg)} %endfor ${pwnlib.shellcraft.setregs(register_arguments)} ${pwnlib.shellcraft.syscall(syscall)}
_bigtest: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "user.h" #include "fcntl.h" int main() { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp 6: 81 ec 30 02 00 00 sub $0x230,%esp char buf[512]; int fd, i, sectors; fd = open("big.file", O_CREATE | O_WRONLY); c: c7 44 24 04 01 02 00 movl $0x201,0x4(%esp) 13: 00 14: c7 04 24 9c 09 00 00 movl $0x99c,(%esp) 1b: e8 64 04 00 00 call 484 <open> 20: 89 84 24 24 02 00 00 mov %eax,0x224(%esp) if(fd < 0){ 27: 83 bc 24 24 02 00 00 cmpl $0x0,0x224(%esp) 2e: 00 2f: 79 19 jns 4a <main+0x4a> printf(2, "big: cannot open big.file for writing\n"); 31: c7 44 24 04 a8 09 00 movl $0x9a8,0x4(%esp) 38: 00 39: c7 04 24 02 00 00 00 movl $0x2,(%esp) 40: e8 8f 05 00 00 call 5d4 <printf> exit(); 45: e8 fa 03 00 00 call 444 <exit> } sectors = 0; 4a: c7 84 24 28 02 00 00 movl $0x0,0x228(%esp) 51: 00 00 00 00 55: eb 01 jmp 58 <main+0x58> if(cc <= 0) break; sectors++; if (sectors % 100 == 0) printf(2, "."); } 57: 90 nop exit(); } sectors = 0; while(1){ *(int*)buf = sectors; 58: 8d 44 24 1c lea 0x1c(%esp),%eax 5c: 8b 94 24 28 02 00 00 mov 0x228(%esp),%edx 63: 89 10 mov %edx,(%eax) int cc = write(fd, buf, sizeof(buf)); 65: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 6c: 00 6d: 8d 44 24 1c lea 0x1c(%esp),%eax 71: 89 44 24 04 mov %eax,0x4(%esp) 75: 8b 84 24 24 02 00 00 mov 0x224(%esp),%eax 7c: 89 04 24 mov %eax,(%esp) 7f: e8 e0 03 00 00 call 464 <write> 84: 89 84 24 20 02 00 00 mov %eax,0x220(%esp) if(cc <= 0) 8b: 83 bc 24 20 02 00 00 cmpl $0x0,0x220(%esp) 92: 00 93: 7e 32 jle c7 <main+0xc7> break; sectors++; 95: ff 84 24 28 02 00 00 incl 0x228(%esp) if (sectors % 100 == 0) 9c: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax a3: b9 64 00 00 00 mov $0x64,%ecx a8: 99 cltd a9: f7 f9 idiv %ecx ab: 89 d0 mov %edx,%eax ad: 85 c0 test %eax,%eax af: 75 a6 jne 57 <main+0x57> printf(2, "."); b1: c7 44 24 04 cf 09 00 movl $0x9cf,0x4(%esp) b8: 00 b9: c7 04 24 02 00 00 00 movl $0x2,(%esp) c0: e8 0f 05 00 00 call 5d4 <printf> } c5: eb 90 jmp 57 <main+0x57> sectors = 0; while(1){ *(int*)buf = sectors; int cc = write(fd, buf, sizeof(buf)); if(cc <= 0) break; c7: 90 nop sectors++; if (sectors % 100 == 0) printf(2, "."); } printf(1, "\nwrote %d sectors\n", sectors); c8: 8b 84 24 28 02 00 00 mov 0x228(%esp),%eax cf: 89 44 24 08 mov %eax,0x8(%esp) d3: c7 44 24 04 d1 09 00 movl $0x9d1,0x4(%esp) da: 00 db: c7 04 24 01 00 00 00 movl $0x1,(%esp) e2: e8 ed 04 00 00 call 5d4 <printf> close(fd); e7: 8b 84 24 24 02 00 00 mov 0x224(%esp),%eax ee: 89 04 24 mov %eax,(%esp) f1: e8 76 03 00 00 call 46c <close> fd = open("big.file", O_RDONLY); f6: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) fd: 00 fe: c7 04 24 9c 09 00 00 movl $0x99c,(%esp) 105: e8 7a 03 00 00 call 484 <open> 10a: 89 84 24 24 02 00 00 mov %eax,0x224(%esp) if(fd < 0){ 111: 83 bc 24 24 02 00 00 cmpl $0x0,0x224(%esp) 118: 00 119: 79 19 jns 134 <main+0x134> printf(2, "big: cannot re-open big.file for reading\n"); 11b: c7 44 24 04 e4 09 00 movl $0x9e4,0x4(%esp) 122: 00 123: c7 04 24 02 00 00 00 movl $0x2,(%esp) 12a: e8 a5 04 00 00 call 5d4 <printf> exit(); 12f: e8 10 03 00 00 call 444 <exit> } for(i = 0; i < sectors; i++){ 134: c7 84 24 2c 02 00 00 movl $0x0,0x22c(%esp) 13b: 00 00 00 00 13f: e9 98 00 00 00 jmp 1dc <main+0x1dc> int cc = read(fd, buf, sizeof(buf)); 144: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 14b: 00 14c: 8d 44 24 1c lea 0x1c(%esp),%eax 150: 89 44 24 04 mov %eax,0x4(%esp) 154: 8b 84 24 24 02 00 00 mov 0x224(%esp),%eax 15b: 89 04 24 mov %eax,(%esp) 15e: e8 f9 02 00 00 call 45c <read> 163: 89 84 24 1c 02 00 00 mov %eax,0x21c(%esp) if(cc <= 0){ 16a: 83 bc 24 1c 02 00 00 cmpl $0x0,0x21c(%esp) 171: 00 172: 7f 24 jg 198 <main+0x198> printf(2, "big: read error at sector %d\n", i); 174: 8b 84 24 2c 02 00 00 mov 0x22c(%esp),%eax 17b: 89 44 24 08 mov %eax,0x8(%esp) 17f: c7 44 24 04 0e 0a 00 movl $0xa0e,0x4(%esp) 186: 00 187: c7 04 24 02 00 00 00 movl $0x2,(%esp) 18e: e8 41 04 00 00 call 5d4 <printf> exit(); 193: e8 ac 02 00 00 call 444 <exit> } if(*(int*)buf != i){ 198: 8d 44 24 1c lea 0x1c(%esp),%eax 19c: 8b 00 mov (%eax),%eax 19e: 3b 84 24 2c 02 00 00 cmp 0x22c(%esp),%eax 1a5: 74 2e je 1d5 <main+0x1d5> printf(2, "big: read the wrong data (%d) for sector %d\n", *(int*)buf, i); 1a7: 8d 44 24 1c lea 0x1c(%esp),%eax if(cc <= 0){ printf(2, "big: read error at sector %d\n", i); exit(); } if(*(int*)buf != i){ printf(2, "big: read the wrong data (%d) for sector %d\n", 1ab: 8b 00 mov (%eax),%eax 1ad: 8b 94 24 2c 02 00 00 mov 0x22c(%esp),%edx 1b4: 89 54 24 0c mov %edx,0xc(%esp) 1b8: 89 44 24 08 mov %eax,0x8(%esp) 1bc: c7 44 24 04 2c 0a 00 movl $0xa2c,0x4(%esp) 1c3: 00 1c4: c7 04 24 02 00 00 00 movl $0x2,(%esp) 1cb: e8 04 04 00 00 call 5d4 <printf> *(int*)buf, i); exit(); 1d0: e8 6f 02 00 00 call 444 <exit> fd = open("big.file", O_RDONLY); if(fd < 0){ printf(2, "big: cannot re-open big.file for reading\n"); exit(); } for(i = 0; i < sectors; i++){ 1d5: ff 84 24 2c 02 00 00 incl 0x22c(%esp) 1dc: 8b 84 24 2c 02 00 00 mov 0x22c(%esp),%eax 1e3: 3b 84 24 28 02 00 00 cmp 0x228(%esp),%eax 1ea: 0f 8c 54 ff ff ff jl 144 <main+0x144> *(int*)buf, i); exit(); } } exit(); 1f0: e8 4f 02 00 00 call 444 <exit> 1f5: 66 90 xchg %ax,%ax 1f7: 90 nop 000001f8 <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 1f8: 55 push %ebp 1f9: 89 e5 mov %esp,%ebp 1fb: 57 push %edi 1fc: 53 push %ebx asm volatile("cld; rep stosb" : 1fd: 8b 4d 08 mov 0x8(%ebp),%ecx 200: 8b 55 10 mov 0x10(%ebp),%edx 203: 8b 45 0c mov 0xc(%ebp),%eax 206: 89 cb mov %ecx,%ebx 208: 89 df mov %ebx,%edi 20a: 89 d1 mov %edx,%ecx 20c: fc cld 20d: f3 aa rep stos %al,%es:(%edi) 20f: 89 ca mov %ecx,%edx 211: 89 fb mov %edi,%ebx 213: 89 5d 08 mov %ebx,0x8(%ebp) 216: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 219: 5b pop %ebx 21a: 5f pop %edi 21b: 5d pop %ebp 21c: c3 ret 0000021d <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 21d: 55 push %ebp 21e: 89 e5 mov %esp,%ebp 220: 83 ec 10 sub $0x10,%esp char *os; os = s; 223: 8b 45 08 mov 0x8(%ebp),%eax 226: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 229: 90 nop 22a: 8b 45 0c mov 0xc(%ebp),%eax 22d: 8a 10 mov (%eax),%dl 22f: 8b 45 08 mov 0x8(%ebp),%eax 232: 88 10 mov %dl,(%eax) 234: 8b 45 08 mov 0x8(%ebp),%eax 237: 8a 00 mov (%eax),%al 239: 84 c0 test %al,%al 23b: 0f 95 c0 setne %al 23e: ff 45 08 incl 0x8(%ebp) 241: ff 45 0c incl 0xc(%ebp) 244: 84 c0 test %al,%al 246: 75 e2 jne 22a <strcpy+0xd> ; return os; 248: 8b 45 fc mov -0x4(%ebp),%eax } 24b: c9 leave 24c: c3 ret 0000024d <strcmp>: int strcmp(const char *p, const char *q) { 24d: 55 push %ebp 24e: 89 e5 mov %esp,%ebp while(*p && *p == *q) 250: eb 06 jmp 258 <strcmp+0xb> p++, q++; 252: ff 45 08 incl 0x8(%ebp) 255: ff 45 0c incl 0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 258: 8b 45 08 mov 0x8(%ebp),%eax 25b: 8a 00 mov (%eax),%al 25d: 84 c0 test %al,%al 25f: 74 0e je 26f <strcmp+0x22> 261: 8b 45 08 mov 0x8(%ebp),%eax 264: 8a 10 mov (%eax),%dl 266: 8b 45 0c mov 0xc(%ebp),%eax 269: 8a 00 mov (%eax),%al 26b: 38 c2 cmp %al,%dl 26d: 74 e3 je 252 <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 26f: 8b 45 08 mov 0x8(%ebp),%eax 272: 8a 00 mov (%eax),%al 274: 0f b6 d0 movzbl %al,%edx 277: 8b 45 0c mov 0xc(%ebp),%eax 27a: 8a 00 mov (%eax),%al 27c: 0f b6 c0 movzbl %al,%eax 27f: 89 d1 mov %edx,%ecx 281: 29 c1 sub %eax,%ecx 283: 89 c8 mov %ecx,%eax } 285: 5d pop %ebp 286: c3 ret 00000287 <strlen>: uint strlen(char *s) { 287: 55 push %ebp 288: 89 e5 mov %esp,%ebp 28a: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 28d: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 294: eb 03 jmp 299 <strlen+0x12> 296: ff 45 fc incl -0x4(%ebp) 299: 8b 55 fc mov -0x4(%ebp),%edx 29c: 8b 45 08 mov 0x8(%ebp),%eax 29f: 01 d0 add %edx,%eax 2a1: 8a 00 mov (%eax),%al 2a3: 84 c0 test %al,%al 2a5: 75 ef jne 296 <strlen+0xf> ; return n; 2a7: 8b 45 fc mov -0x4(%ebp),%eax } 2aa: c9 leave 2ab: c3 ret 000002ac <memset>: void* memset(void *dst, int c, uint n) { 2ac: 55 push %ebp 2ad: 89 e5 mov %esp,%ebp 2af: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 2b2: 8b 45 10 mov 0x10(%ebp),%eax 2b5: 89 44 24 08 mov %eax,0x8(%esp) 2b9: 8b 45 0c mov 0xc(%ebp),%eax 2bc: 89 44 24 04 mov %eax,0x4(%esp) 2c0: 8b 45 08 mov 0x8(%ebp),%eax 2c3: 89 04 24 mov %eax,(%esp) 2c6: e8 2d ff ff ff call 1f8 <stosb> return dst; 2cb: 8b 45 08 mov 0x8(%ebp),%eax } 2ce: c9 leave 2cf: c3 ret 000002d0 <strchr>: char* strchr(const char *s, char c) { 2d0: 55 push %ebp 2d1: 89 e5 mov %esp,%ebp 2d3: 83 ec 04 sub $0x4,%esp 2d6: 8b 45 0c mov 0xc(%ebp),%eax 2d9: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 2dc: eb 12 jmp 2f0 <strchr+0x20> if(*s == c) 2de: 8b 45 08 mov 0x8(%ebp),%eax 2e1: 8a 00 mov (%eax),%al 2e3: 3a 45 fc cmp -0x4(%ebp),%al 2e6: 75 05 jne 2ed <strchr+0x1d> return (char*)s; 2e8: 8b 45 08 mov 0x8(%ebp),%eax 2eb: eb 11 jmp 2fe <strchr+0x2e> } char* strchr(const char *s, char c) { for(; *s; s++) 2ed: ff 45 08 incl 0x8(%ebp) 2f0: 8b 45 08 mov 0x8(%ebp),%eax 2f3: 8a 00 mov (%eax),%al 2f5: 84 c0 test %al,%al 2f7: 75 e5 jne 2de <strchr+0xe> if(*s == c) return (char*)s; return 0; 2f9: b8 00 00 00 00 mov $0x0,%eax } 2fe: c9 leave 2ff: c3 ret 00000300 <gets>: char* gets(char *buf, int max) { 300: 55 push %ebp 301: 89 e5 mov %esp,%ebp 303: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 306: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 30d: eb 42 jmp 351 <gets+0x51> cc = read(0, &c, 1); 30f: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 316: 00 317: 8d 45 ef lea -0x11(%ebp),%eax 31a: 89 44 24 04 mov %eax,0x4(%esp) 31e: c7 04 24 00 00 00 00 movl $0x0,(%esp) 325: e8 32 01 00 00 call 45c <read> 32a: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 32d: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 331: 7e 29 jle 35c <gets+0x5c> break; buf[i++] = c; 333: 8b 55 f4 mov -0xc(%ebp),%edx 336: 8b 45 08 mov 0x8(%ebp),%eax 339: 01 c2 add %eax,%edx 33b: 8a 45 ef mov -0x11(%ebp),%al 33e: 88 02 mov %al,(%edx) 340: ff 45 f4 incl -0xc(%ebp) if(c == '\n' || c == '\r') 343: 8a 45 ef mov -0x11(%ebp),%al 346: 3c 0a cmp $0xa,%al 348: 74 13 je 35d <gets+0x5d> 34a: 8a 45 ef mov -0x11(%ebp),%al 34d: 3c 0d cmp $0xd,%al 34f: 74 0c je 35d <gets+0x5d> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 351: 8b 45 f4 mov -0xc(%ebp),%eax 354: 40 inc %eax 355: 3b 45 0c cmp 0xc(%ebp),%eax 358: 7c b5 jl 30f <gets+0xf> 35a: eb 01 jmp 35d <gets+0x5d> cc = read(0, &c, 1); if(cc < 1) break; 35c: 90 nop buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 35d: 8b 55 f4 mov -0xc(%ebp),%edx 360: 8b 45 08 mov 0x8(%ebp),%eax 363: 01 d0 add %edx,%eax 365: c6 00 00 movb $0x0,(%eax) return buf; 368: 8b 45 08 mov 0x8(%ebp),%eax } 36b: c9 leave 36c: c3 ret 0000036d <stat>: int stat(char *n, struct stat *st) { 36d: 55 push %ebp 36e: 89 e5 mov %esp,%ebp 370: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 373: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 37a: 00 37b: 8b 45 08 mov 0x8(%ebp),%eax 37e: 89 04 24 mov %eax,(%esp) 381: e8 fe 00 00 00 call 484 <open> 386: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 389: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 38d: 79 07 jns 396 <stat+0x29> return -1; 38f: b8 ff ff ff ff mov $0xffffffff,%eax 394: eb 23 jmp 3b9 <stat+0x4c> r = fstat(fd, st); 396: 8b 45 0c mov 0xc(%ebp),%eax 399: 89 44 24 04 mov %eax,0x4(%esp) 39d: 8b 45 f4 mov -0xc(%ebp),%eax 3a0: 89 04 24 mov %eax,(%esp) 3a3: e8 f4 00 00 00 call 49c <fstat> 3a8: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 3ab: 8b 45 f4 mov -0xc(%ebp),%eax 3ae: 89 04 24 mov %eax,(%esp) 3b1: e8 b6 00 00 00 call 46c <close> return r; 3b6: 8b 45 f0 mov -0x10(%ebp),%eax } 3b9: c9 leave 3ba: c3 ret 000003bb <atoi>: int atoi(const char *s) { 3bb: 55 push %ebp 3bc: 89 e5 mov %esp,%ebp 3be: 83 ec 10 sub $0x10,%esp int n; n = 0; 3c1: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 3c8: eb 21 jmp 3eb <atoi+0x30> n = n*10 + *s++ - '0'; 3ca: 8b 55 fc mov -0x4(%ebp),%edx 3cd: 89 d0 mov %edx,%eax 3cf: c1 e0 02 shl $0x2,%eax 3d2: 01 d0 add %edx,%eax 3d4: d1 e0 shl %eax 3d6: 89 c2 mov %eax,%edx 3d8: 8b 45 08 mov 0x8(%ebp),%eax 3db: 8a 00 mov (%eax),%al 3dd: 0f be c0 movsbl %al,%eax 3e0: 01 d0 add %edx,%eax 3e2: 83 e8 30 sub $0x30,%eax 3e5: 89 45 fc mov %eax,-0x4(%ebp) 3e8: ff 45 08 incl 0x8(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 3eb: 8b 45 08 mov 0x8(%ebp),%eax 3ee: 8a 00 mov (%eax),%al 3f0: 3c 2f cmp $0x2f,%al 3f2: 7e 09 jle 3fd <atoi+0x42> 3f4: 8b 45 08 mov 0x8(%ebp),%eax 3f7: 8a 00 mov (%eax),%al 3f9: 3c 39 cmp $0x39,%al 3fb: 7e cd jle 3ca <atoi+0xf> n = n*10 + *s++ - '0'; return n; 3fd: 8b 45 fc mov -0x4(%ebp),%eax } 400: c9 leave 401: c3 ret 00000402 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 402: 55 push %ebp 403: 89 e5 mov %esp,%ebp 405: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 408: 8b 45 08 mov 0x8(%ebp),%eax 40b: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 40e: 8b 45 0c mov 0xc(%ebp),%eax 411: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 414: eb 10 jmp 426 <memmove+0x24> *dst++ = *src++; 416: 8b 45 f8 mov -0x8(%ebp),%eax 419: 8a 10 mov (%eax),%dl 41b: 8b 45 fc mov -0x4(%ebp),%eax 41e: 88 10 mov %dl,(%eax) 420: ff 45 fc incl -0x4(%ebp) 423: ff 45 f8 incl -0x8(%ebp) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 426: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 42a: 0f 9f c0 setg %al 42d: ff 4d 10 decl 0x10(%ebp) 430: 84 c0 test %al,%al 432: 75 e2 jne 416 <memmove+0x14> *dst++ = *src++; return vdst; 434: 8b 45 08 mov 0x8(%ebp),%eax } 437: c9 leave 438: c3 ret 439: 66 90 xchg %ax,%ax 43b: 90 nop 0000043c <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 43c: b8 01 00 00 00 mov $0x1,%eax 441: cd 40 int $0x40 443: c3 ret 00000444 <exit>: SYSCALL(exit) 444: b8 02 00 00 00 mov $0x2,%eax 449: cd 40 int $0x40 44b: c3 ret 0000044c <wait>: SYSCALL(wait) 44c: b8 03 00 00 00 mov $0x3,%eax 451: cd 40 int $0x40 453: c3 ret 00000454 <pipe>: SYSCALL(pipe) 454: b8 04 00 00 00 mov $0x4,%eax 459: cd 40 int $0x40 45b: c3 ret 0000045c <read>: SYSCALL(read) 45c: b8 05 00 00 00 mov $0x5,%eax 461: cd 40 int $0x40 463: c3 ret 00000464 <write>: SYSCALL(write) 464: b8 10 00 00 00 mov $0x10,%eax 469: cd 40 int $0x40 46b: c3 ret 0000046c <close>: SYSCALL(close) 46c: b8 15 00 00 00 mov $0x15,%eax 471: cd 40 int $0x40 473: c3 ret 00000474 <kill>: SYSCALL(kill) 474: b8 06 00 00 00 mov $0x6,%eax 479: cd 40 int $0x40 47b: c3 ret 0000047c <exec>: SYSCALL(exec) 47c: b8 07 00 00 00 mov $0x7,%eax 481: cd 40 int $0x40 483: c3 ret 00000484 <open>: SYSCALL(open) 484: b8 0f 00 00 00 mov $0xf,%eax 489: cd 40 int $0x40 48b: c3 ret 0000048c <mknod>: SYSCALL(mknod) 48c: b8 11 00 00 00 mov $0x11,%eax 491: cd 40 int $0x40 493: c3 ret 00000494 <unlink>: SYSCALL(unlink) 494: b8 12 00 00 00 mov $0x12,%eax 499: cd 40 int $0x40 49b: c3 ret 0000049c <fstat>: SYSCALL(fstat) 49c: b8 08 00 00 00 mov $0x8,%eax 4a1: cd 40 int $0x40 4a3: c3 ret 000004a4 <link>: SYSCALL(link) 4a4: b8 13 00 00 00 mov $0x13,%eax 4a9: cd 40 int $0x40 4ab: c3 ret 000004ac <mkdir>: SYSCALL(mkdir) 4ac: b8 14 00 00 00 mov $0x14,%eax 4b1: cd 40 int $0x40 4b3: c3 ret 000004b4 <chdir>: SYSCALL(chdir) 4b4: b8 09 00 00 00 mov $0x9,%eax 4b9: cd 40 int $0x40 4bb: c3 ret 000004bc <dup>: SYSCALL(dup) 4bc: b8 0a 00 00 00 mov $0xa,%eax 4c1: cd 40 int $0x40 4c3: c3 ret 000004c4 <getpid>: SYSCALL(getpid) 4c4: b8 0b 00 00 00 mov $0xb,%eax 4c9: cd 40 int $0x40 4cb: c3 ret 000004cc <sbrk>: SYSCALL(sbrk) 4cc: b8 0c 00 00 00 mov $0xc,%eax 4d1: cd 40 int $0x40 4d3: c3 ret 000004d4 <sleep>: SYSCALL(sleep) 4d4: b8 0d 00 00 00 mov $0xd,%eax 4d9: cd 40 int $0x40 4db: c3 ret 000004dc <uptime>: SYSCALL(uptime) 4dc: b8 0e 00 00 00 mov $0xe,%eax 4e1: cd 40 int $0x40 4e3: c3 ret 000004e4 <getppid>: SYSCALL(getppid) // USER DEFINED SYS CALL 4e4: b8 16 00 00 00 mov $0x16,%eax 4e9: cd 40 int $0x40 4eb: c3 ret 000004ec <icount>: SYSCALL(icount) // USER DEFINED SYS CALL 4ec: b8 17 00 00 00 mov $0x17,%eax 4f1: cd 40 int $0x40 4f3: c3 ret 000004f4 <signal>: SYSCALL(signal) // USER DEFINED SYS CALL 4f4: b8 18 00 00 00 mov $0x18,%eax 4f9: cd 40 int $0x40 4fb: c3 ret 000004fc <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 4fc: 55 push %ebp 4fd: 89 e5 mov %esp,%ebp 4ff: 83 ec 28 sub $0x28,%esp 502: 8b 45 0c mov 0xc(%ebp),%eax 505: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 508: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 50f: 00 510: 8d 45 f4 lea -0xc(%ebp),%eax 513: 89 44 24 04 mov %eax,0x4(%esp) 517: 8b 45 08 mov 0x8(%ebp),%eax 51a: 89 04 24 mov %eax,(%esp) 51d: e8 42 ff ff ff call 464 <write> } 522: c9 leave 523: c3 ret 00000524 <printint>: static void printint(int fd, int xx, int base, int sgn) { 524: 55 push %ebp 525: 89 e5 mov %esp,%ebp 527: 83 ec 48 sub $0x48,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 52a: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 531: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 535: 74 17 je 54e <printint+0x2a> 537: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 53b: 79 11 jns 54e <printint+0x2a> neg = 1; 53d: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 544: 8b 45 0c mov 0xc(%ebp),%eax 547: f7 d8 neg %eax 549: 89 45 ec mov %eax,-0x14(%ebp) 54c: eb 06 jmp 554 <printint+0x30> } else { x = xx; 54e: 8b 45 0c mov 0xc(%ebp),%eax 551: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 554: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 55b: 8b 4d 10 mov 0x10(%ebp),%ecx 55e: 8b 45 ec mov -0x14(%ebp),%eax 561: ba 00 00 00 00 mov $0x0,%edx 566: f7 f1 div %ecx 568: 89 d0 mov %edx,%eax 56a: 8a 80 9c 0c 00 00 mov 0xc9c(%eax),%al 570: 8d 4d dc lea -0x24(%ebp),%ecx 573: 8b 55 f4 mov -0xc(%ebp),%edx 576: 01 ca add %ecx,%edx 578: 88 02 mov %al,(%edx) 57a: ff 45 f4 incl -0xc(%ebp) }while((x /= base) != 0); 57d: 8b 55 10 mov 0x10(%ebp),%edx 580: 89 55 d4 mov %edx,-0x2c(%ebp) 583: 8b 45 ec mov -0x14(%ebp),%eax 586: ba 00 00 00 00 mov $0x0,%edx 58b: f7 75 d4 divl -0x2c(%ebp) 58e: 89 45 ec mov %eax,-0x14(%ebp) 591: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 595: 75 c4 jne 55b <printint+0x37> if(neg) 597: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 59b: 74 2c je 5c9 <printint+0xa5> buf[i++] = '-'; 59d: 8d 55 dc lea -0x24(%ebp),%edx 5a0: 8b 45 f4 mov -0xc(%ebp),%eax 5a3: 01 d0 add %edx,%eax 5a5: c6 00 2d movb $0x2d,(%eax) 5a8: ff 45 f4 incl -0xc(%ebp) while(--i >= 0) 5ab: eb 1c jmp 5c9 <printint+0xa5> putc(fd, buf[i]); 5ad: 8d 55 dc lea -0x24(%ebp),%edx 5b0: 8b 45 f4 mov -0xc(%ebp),%eax 5b3: 01 d0 add %edx,%eax 5b5: 8a 00 mov (%eax),%al 5b7: 0f be c0 movsbl %al,%eax 5ba: 89 44 24 04 mov %eax,0x4(%esp) 5be: 8b 45 08 mov 0x8(%ebp),%eax 5c1: 89 04 24 mov %eax,(%esp) 5c4: e8 33 ff ff ff call 4fc <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 5c9: ff 4d f4 decl -0xc(%ebp) 5cc: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 5d0: 79 db jns 5ad <printint+0x89> putc(fd, buf[i]); } 5d2: c9 leave 5d3: c3 ret 000005d4 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 5d4: 55 push %ebp 5d5: 89 e5 mov %esp,%ebp 5d7: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 5da: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 5e1: 8d 45 0c lea 0xc(%ebp),%eax 5e4: 83 c0 04 add $0x4,%eax 5e7: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 5ea: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 5f1: e9 78 01 00 00 jmp 76e <printf+0x19a> c = fmt[i] & 0xff; 5f6: 8b 55 0c mov 0xc(%ebp),%edx 5f9: 8b 45 f0 mov -0x10(%ebp),%eax 5fc: 01 d0 add %edx,%eax 5fe: 8a 00 mov (%eax),%al 600: 0f be c0 movsbl %al,%eax 603: 25 ff 00 00 00 and $0xff,%eax 608: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 60b: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 60f: 75 2c jne 63d <printf+0x69> if(c == '%'){ 611: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 615: 75 0c jne 623 <printf+0x4f> state = '%'; 617: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 61e: e9 48 01 00 00 jmp 76b <printf+0x197> } else { putc(fd, c); 623: 8b 45 e4 mov -0x1c(%ebp),%eax 626: 0f be c0 movsbl %al,%eax 629: 89 44 24 04 mov %eax,0x4(%esp) 62d: 8b 45 08 mov 0x8(%ebp),%eax 630: 89 04 24 mov %eax,(%esp) 633: e8 c4 fe ff ff call 4fc <putc> 638: e9 2e 01 00 00 jmp 76b <printf+0x197> } } else if(state == '%'){ 63d: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 641: 0f 85 24 01 00 00 jne 76b <printf+0x197> if(c == 'd'){ 647: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 64b: 75 2d jne 67a <printf+0xa6> printint(fd, *ap, 10, 1); 64d: 8b 45 e8 mov -0x18(%ebp),%eax 650: 8b 00 mov (%eax),%eax 652: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 659: 00 65a: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 661: 00 662: 89 44 24 04 mov %eax,0x4(%esp) 666: 8b 45 08 mov 0x8(%ebp),%eax 669: 89 04 24 mov %eax,(%esp) 66c: e8 b3 fe ff ff call 524 <printint> ap++; 671: 83 45 e8 04 addl $0x4,-0x18(%ebp) 675: e9 ea 00 00 00 jmp 764 <printf+0x190> } else if(c == 'x' || c == 'p'){ 67a: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 67e: 74 06 je 686 <printf+0xb2> 680: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 684: 75 2d jne 6b3 <printf+0xdf> printint(fd, *ap, 16, 0); 686: 8b 45 e8 mov -0x18(%ebp),%eax 689: 8b 00 mov (%eax),%eax 68b: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 692: 00 693: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 69a: 00 69b: 89 44 24 04 mov %eax,0x4(%esp) 69f: 8b 45 08 mov 0x8(%ebp),%eax 6a2: 89 04 24 mov %eax,(%esp) 6a5: e8 7a fe ff ff call 524 <printint> ap++; 6aa: 83 45 e8 04 addl $0x4,-0x18(%ebp) 6ae: e9 b1 00 00 00 jmp 764 <printf+0x190> } else if(c == 's'){ 6b3: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 6b7: 75 43 jne 6fc <printf+0x128> s = (char*)*ap; 6b9: 8b 45 e8 mov -0x18(%ebp),%eax 6bc: 8b 00 mov (%eax),%eax 6be: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 6c1: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 6c5: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 6c9: 75 25 jne 6f0 <printf+0x11c> s = "(null)"; 6cb: c7 45 f4 59 0a 00 00 movl $0xa59,-0xc(%ebp) while(*s != 0){ 6d2: eb 1c jmp 6f0 <printf+0x11c> putc(fd, *s); 6d4: 8b 45 f4 mov -0xc(%ebp),%eax 6d7: 8a 00 mov (%eax),%al 6d9: 0f be c0 movsbl %al,%eax 6dc: 89 44 24 04 mov %eax,0x4(%esp) 6e0: 8b 45 08 mov 0x8(%ebp),%eax 6e3: 89 04 24 mov %eax,(%esp) 6e6: e8 11 fe ff ff call 4fc <putc> s++; 6eb: ff 45 f4 incl -0xc(%ebp) 6ee: eb 01 jmp 6f1 <printf+0x11d> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 6f0: 90 nop 6f1: 8b 45 f4 mov -0xc(%ebp),%eax 6f4: 8a 00 mov (%eax),%al 6f6: 84 c0 test %al,%al 6f8: 75 da jne 6d4 <printf+0x100> 6fa: eb 68 jmp 764 <printf+0x190> putc(fd, *s); s++; } } else if(c == 'c'){ 6fc: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 700: 75 1d jne 71f <printf+0x14b> putc(fd, *ap); 702: 8b 45 e8 mov -0x18(%ebp),%eax 705: 8b 00 mov (%eax),%eax 707: 0f be c0 movsbl %al,%eax 70a: 89 44 24 04 mov %eax,0x4(%esp) 70e: 8b 45 08 mov 0x8(%ebp),%eax 711: 89 04 24 mov %eax,(%esp) 714: e8 e3 fd ff ff call 4fc <putc> ap++; 719: 83 45 e8 04 addl $0x4,-0x18(%ebp) 71d: eb 45 jmp 764 <printf+0x190> } else if(c == '%'){ 71f: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 723: 75 17 jne 73c <printf+0x168> putc(fd, c); 725: 8b 45 e4 mov -0x1c(%ebp),%eax 728: 0f be c0 movsbl %al,%eax 72b: 89 44 24 04 mov %eax,0x4(%esp) 72f: 8b 45 08 mov 0x8(%ebp),%eax 732: 89 04 24 mov %eax,(%esp) 735: e8 c2 fd ff ff call 4fc <putc> 73a: eb 28 jmp 764 <printf+0x190> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 73c: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 743: 00 744: 8b 45 08 mov 0x8(%ebp),%eax 747: 89 04 24 mov %eax,(%esp) 74a: e8 ad fd ff ff call 4fc <putc> putc(fd, c); 74f: 8b 45 e4 mov -0x1c(%ebp),%eax 752: 0f be c0 movsbl %al,%eax 755: 89 44 24 04 mov %eax,0x4(%esp) 759: 8b 45 08 mov 0x8(%ebp),%eax 75c: 89 04 24 mov %eax,(%esp) 75f: e8 98 fd ff ff call 4fc <putc> } state = 0; 764: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 76b: ff 45 f0 incl -0x10(%ebp) 76e: 8b 55 0c mov 0xc(%ebp),%edx 771: 8b 45 f0 mov -0x10(%ebp),%eax 774: 01 d0 add %edx,%eax 776: 8a 00 mov (%eax),%al 778: 84 c0 test %al,%al 77a: 0f 85 76 fe ff ff jne 5f6 <printf+0x22> putc(fd, c); } state = 0; } } } 780: c9 leave 781: c3 ret 782: 66 90 xchg %ax,%ax 00000784 <free>: static Header base; static Header *freep; void free(void *ap) { 784: 55 push %ebp 785: 89 e5 mov %esp,%ebp 787: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 78a: 8b 45 08 mov 0x8(%ebp),%eax 78d: 83 e8 08 sub $0x8,%eax 790: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 793: a1 b8 0c 00 00 mov 0xcb8,%eax 798: 89 45 fc mov %eax,-0x4(%ebp) 79b: eb 24 jmp 7c1 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 79d: 8b 45 fc mov -0x4(%ebp),%eax 7a0: 8b 00 mov (%eax),%eax 7a2: 3b 45 fc cmp -0x4(%ebp),%eax 7a5: 77 12 ja 7b9 <free+0x35> 7a7: 8b 45 f8 mov -0x8(%ebp),%eax 7aa: 3b 45 fc cmp -0x4(%ebp),%eax 7ad: 77 24 ja 7d3 <free+0x4f> 7af: 8b 45 fc mov -0x4(%ebp),%eax 7b2: 8b 00 mov (%eax),%eax 7b4: 3b 45 f8 cmp -0x8(%ebp),%eax 7b7: 77 1a ja 7d3 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7b9: 8b 45 fc mov -0x4(%ebp),%eax 7bc: 8b 00 mov (%eax),%eax 7be: 89 45 fc mov %eax,-0x4(%ebp) 7c1: 8b 45 f8 mov -0x8(%ebp),%eax 7c4: 3b 45 fc cmp -0x4(%ebp),%eax 7c7: 76 d4 jbe 79d <free+0x19> 7c9: 8b 45 fc mov -0x4(%ebp),%eax 7cc: 8b 00 mov (%eax),%eax 7ce: 3b 45 f8 cmp -0x8(%ebp),%eax 7d1: 76 ca jbe 79d <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 7d3: 8b 45 f8 mov -0x8(%ebp),%eax 7d6: 8b 40 04 mov 0x4(%eax),%eax 7d9: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 7e0: 8b 45 f8 mov -0x8(%ebp),%eax 7e3: 01 c2 add %eax,%edx 7e5: 8b 45 fc mov -0x4(%ebp),%eax 7e8: 8b 00 mov (%eax),%eax 7ea: 39 c2 cmp %eax,%edx 7ec: 75 24 jne 812 <free+0x8e> bp->s.size += p->s.ptr->s.size; 7ee: 8b 45 f8 mov -0x8(%ebp),%eax 7f1: 8b 50 04 mov 0x4(%eax),%edx 7f4: 8b 45 fc mov -0x4(%ebp),%eax 7f7: 8b 00 mov (%eax),%eax 7f9: 8b 40 04 mov 0x4(%eax),%eax 7fc: 01 c2 add %eax,%edx 7fe: 8b 45 f8 mov -0x8(%ebp),%eax 801: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 804: 8b 45 fc mov -0x4(%ebp),%eax 807: 8b 00 mov (%eax),%eax 809: 8b 10 mov (%eax),%edx 80b: 8b 45 f8 mov -0x8(%ebp),%eax 80e: 89 10 mov %edx,(%eax) 810: eb 0a jmp 81c <free+0x98> } else bp->s.ptr = p->s.ptr; 812: 8b 45 fc mov -0x4(%ebp),%eax 815: 8b 10 mov (%eax),%edx 817: 8b 45 f8 mov -0x8(%ebp),%eax 81a: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 81c: 8b 45 fc mov -0x4(%ebp),%eax 81f: 8b 40 04 mov 0x4(%eax),%eax 822: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 829: 8b 45 fc mov -0x4(%ebp),%eax 82c: 01 d0 add %edx,%eax 82e: 3b 45 f8 cmp -0x8(%ebp),%eax 831: 75 20 jne 853 <free+0xcf> p->s.size += bp->s.size; 833: 8b 45 fc mov -0x4(%ebp),%eax 836: 8b 50 04 mov 0x4(%eax),%edx 839: 8b 45 f8 mov -0x8(%ebp),%eax 83c: 8b 40 04 mov 0x4(%eax),%eax 83f: 01 c2 add %eax,%edx 841: 8b 45 fc mov -0x4(%ebp),%eax 844: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 847: 8b 45 f8 mov -0x8(%ebp),%eax 84a: 8b 10 mov (%eax),%edx 84c: 8b 45 fc mov -0x4(%ebp),%eax 84f: 89 10 mov %edx,(%eax) 851: eb 08 jmp 85b <free+0xd7> } else p->s.ptr = bp; 853: 8b 45 fc mov -0x4(%ebp),%eax 856: 8b 55 f8 mov -0x8(%ebp),%edx 859: 89 10 mov %edx,(%eax) freep = p; 85b: 8b 45 fc mov -0x4(%ebp),%eax 85e: a3 b8 0c 00 00 mov %eax,0xcb8 } 863: c9 leave 864: c3 ret 00000865 <morecore>: static Header* morecore(uint nu) { 865: 55 push %ebp 866: 89 e5 mov %esp,%ebp 868: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 86b: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 872: 77 07 ja 87b <morecore+0x16> nu = 4096; 874: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 87b: 8b 45 08 mov 0x8(%ebp),%eax 87e: c1 e0 03 shl $0x3,%eax 881: 89 04 24 mov %eax,(%esp) 884: e8 43 fc ff ff call 4cc <sbrk> 889: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 88c: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 890: 75 07 jne 899 <morecore+0x34> return 0; 892: b8 00 00 00 00 mov $0x0,%eax 897: eb 22 jmp 8bb <morecore+0x56> hp = (Header*)p; 899: 8b 45 f4 mov -0xc(%ebp),%eax 89c: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 89f: 8b 45 f0 mov -0x10(%ebp),%eax 8a2: 8b 55 08 mov 0x8(%ebp),%edx 8a5: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 8a8: 8b 45 f0 mov -0x10(%ebp),%eax 8ab: 83 c0 08 add $0x8,%eax 8ae: 89 04 24 mov %eax,(%esp) 8b1: e8 ce fe ff ff call 784 <free> return freep; 8b6: a1 b8 0c 00 00 mov 0xcb8,%eax } 8bb: c9 leave 8bc: c3 ret 000008bd <malloc>: void* malloc(uint nbytes) { 8bd: 55 push %ebp 8be: 89 e5 mov %esp,%ebp 8c0: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 8c3: 8b 45 08 mov 0x8(%ebp),%eax 8c6: 83 c0 07 add $0x7,%eax 8c9: c1 e8 03 shr $0x3,%eax 8cc: 40 inc %eax 8cd: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 8d0: a1 b8 0c 00 00 mov 0xcb8,%eax 8d5: 89 45 f0 mov %eax,-0x10(%ebp) 8d8: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8dc: 75 23 jne 901 <malloc+0x44> base.s.ptr = freep = prevp = &base; 8de: c7 45 f0 b0 0c 00 00 movl $0xcb0,-0x10(%ebp) 8e5: 8b 45 f0 mov -0x10(%ebp),%eax 8e8: a3 b8 0c 00 00 mov %eax,0xcb8 8ed: a1 b8 0c 00 00 mov 0xcb8,%eax 8f2: a3 b0 0c 00 00 mov %eax,0xcb0 base.s.size = 0; 8f7: c7 05 b4 0c 00 00 00 movl $0x0,0xcb4 8fe: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 901: 8b 45 f0 mov -0x10(%ebp),%eax 904: 8b 00 mov (%eax),%eax 906: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 909: 8b 45 f4 mov -0xc(%ebp),%eax 90c: 8b 40 04 mov 0x4(%eax),%eax 90f: 3b 45 ec cmp -0x14(%ebp),%eax 912: 72 4d jb 961 <malloc+0xa4> if(p->s.size == nunits) 914: 8b 45 f4 mov -0xc(%ebp),%eax 917: 8b 40 04 mov 0x4(%eax),%eax 91a: 3b 45 ec cmp -0x14(%ebp),%eax 91d: 75 0c jne 92b <malloc+0x6e> prevp->s.ptr = p->s.ptr; 91f: 8b 45 f4 mov -0xc(%ebp),%eax 922: 8b 10 mov (%eax),%edx 924: 8b 45 f0 mov -0x10(%ebp),%eax 927: 89 10 mov %edx,(%eax) 929: eb 26 jmp 951 <malloc+0x94> else { p->s.size -= nunits; 92b: 8b 45 f4 mov -0xc(%ebp),%eax 92e: 8b 40 04 mov 0x4(%eax),%eax 931: 89 c2 mov %eax,%edx 933: 2b 55 ec sub -0x14(%ebp),%edx 936: 8b 45 f4 mov -0xc(%ebp),%eax 939: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 93c: 8b 45 f4 mov -0xc(%ebp),%eax 93f: 8b 40 04 mov 0x4(%eax),%eax 942: c1 e0 03 shl $0x3,%eax 945: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 948: 8b 45 f4 mov -0xc(%ebp),%eax 94b: 8b 55 ec mov -0x14(%ebp),%edx 94e: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 951: 8b 45 f0 mov -0x10(%ebp),%eax 954: a3 b8 0c 00 00 mov %eax,0xcb8 return (void*)(p + 1); 959: 8b 45 f4 mov -0xc(%ebp),%eax 95c: 83 c0 08 add $0x8,%eax 95f: eb 38 jmp 999 <malloc+0xdc> } if(p == freep) 961: a1 b8 0c 00 00 mov 0xcb8,%eax 966: 39 45 f4 cmp %eax,-0xc(%ebp) 969: 75 1b jne 986 <malloc+0xc9> if((p = morecore(nunits)) == 0) 96b: 8b 45 ec mov -0x14(%ebp),%eax 96e: 89 04 24 mov %eax,(%esp) 971: e8 ef fe ff ff call 865 <morecore> 976: 89 45 f4 mov %eax,-0xc(%ebp) 979: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 97d: 75 07 jne 986 <malloc+0xc9> return 0; 97f: b8 00 00 00 00 mov $0x0,%eax 984: eb 13 jmp 999 <malloc+0xdc> nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 986: 8b 45 f4 mov -0xc(%ebp),%eax 989: 89 45 f0 mov %eax,-0x10(%ebp) 98c: 8b 45 f4 mov -0xc(%ebp),%eax 98f: 8b 00 mov (%eax),%eax 991: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 994: e9 70 ff ff ff jmp 909 <malloc+0x4c> } 999: c9 leave 99a: c3 ret
/* * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES) * * This file is part of Orfeo Toolbox * * https://www.orfeo-toolbox.org/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "otbSOMImageClassificationFilter.h" #include "otbImage.h" #include "otbSOMMap.h" #include "otbImageFileReader.h" #include "otbImageFileWriter.h" int otbSOMImageClassificationFilter(int itkNotUsed(argc), char * argv[]) { const char * infname = argv[1]; const char * somfname = argv[2]; const char * outfname = argv[3]; const unsigned int Dimension = 2; typedef double PixelType; typedef unsigned short LabeledPixelType; typedef otb::VectorImage<PixelType, Dimension> ImageType; typedef otb::Image<LabeledPixelType, Dimension> LabeledImageType; typedef otb::SOMMap<ImageType::PixelType> SOMMapType; typedef otb::SOMImageClassificationFilter<ImageType, LabeledImageType, SOMMapType> ClassificationFilterType; typedef otb::ImageFileReader<ImageType> ReaderType; typedef otb::ImageFileReader<SOMMapType> SOMReaderType; typedef otb::ImageFileWriter<LabeledImageType> WriterType; // Instantiating object ClassificationFilterType::Pointer filter = ClassificationFilterType::New(); ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(infname); SOMReaderType::Pointer somreader = SOMReaderType::New(); somreader->SetFileName(somfname); somreader->Update(); filter->SetMap(somreader->GetOutput()); filter->SetInput(reader->GetOutput()); WriterType::Pointer writer = WriterType::New(); writer->SetInput(filter->GetOutput()); writer->SetFileName(outfname); writer->Update(); return EXIT_SUCCESS; }
#include<iostream> #include<bits/stdc++.h> using namespace std; class Solution { public: int minCostClimbingStairs(vector<int>& cost) { int n = cost.size(); vector<int> dp(n); dp[0] = cost[0]; dp[1] = cost[1]; for(int i=2;i<n;i++){ dp[i] = cost[i] + min(dp[i-1],dp[i-2]); } return min(dp[n-1],dp[n-2]); } }; int main(){ vector<int> num({10,15,20,7}); Solution s; cout<<s.minCostClimbingStairs(num)<<endl; return 0; }
; A071721: Expansion of (1+x^2*C^2)*C^2, where C = (1-(1-4*x)^(1/2))/(2*x) is g.f. for Catalan numbers, A000108. ; 1,2,6,18,56,180,594,2002,6864,23868,83980,298452,1069776,3863080,14040810,51325650,188574240,695987820,2579248980,9593714460,35804293200,134032593240,503154100020,1893689067348,7144084508256,27010813341400,102332395687704,388428801668712,1476988529802016,5625488570881872,21459299074269210,81978857675642578,313604131070389824,1201215823474975308,4606682905515140996,17687025781906304460,67982011877522577744,261566116924769918072,1007383017885938197980,3883403341093032616860,14983583098722812050400,57861022640533091650440,223618098586361815402920,864893280775822682854680,3347635468968502760331360,12966421714911850633585200,50256890091315746992766340,194918248969956637183124820,756448693874895545153233344,2937418825153087031138331768,11413048025516311463214083400,44368762550516619129823202712,172577409020019616600822856736,671603693144342074394111327088,2614909797161730799089740733096,10186084622472109253114357176680,39696991857859956813391124896704,154775014864694904258506195798832,603713069676909363394290249110064,2355811938937086113912258671343568,9196553987977471215600616136354880,35915219568921542350448755398113952,140312225631452705924447852800213626,548366638634089359382147315534333650 seq $0,245 ; a(n) = 3*(2*n)!/((n+2)!*(n-1)!). mul $0,2 mov $1,1 max $1,$0 mov $0,$1
; ****************************************************************************** ; ****************************************************************************** ; ; Name: personality_mega65.asm ; Purpose: Mega65 Personality Code ; Date: 22nd July 2019 ; Author: Paul Robson ; ; ****************************************************************************** ; ****************************************************************************** ; ****************************************************************************** ; ; Constants ; ; ****************************************************************************** EXTWidth = 40 ; screen width EXTHeight = 25 ; screen height ; ****************************************************************************** ; ; Memory Allocation ; ; ****************************************************************************** EXTZPWork = 4 ; Zero Page work for EXT EXTZeroPage = $10 ; Zero Page allocated from here EXTNonZeroPage = $2000 ; Non-Zero page allocated from here EXTEndOfMemory = $4000 ; Memory ends. EXTScreen = $1000 ; 2k screen RAM here EXTCharSet = $800 ; 2k character set (0-7F) here ; ****************************************************************************** ; ; Initialisation, Vector Tables, Character Set ; ; ****************************************************************************** * = 0 .word 0 ; forces it to be a 128k ROM (at least) * = $FFFA ; create the vectors. .word EXTDummyInterrupt .word EXTStartPersonalise .word EXTDummyInterrupt * = $A000 ; put the font at $A000 EXTCBMFont: .binary "c64-chargen.rom" * = $E000 EXTDummyInterrupt: ; interrupt that does nothing. rti ; ****************************************************************************** ; ; Macro which resets the 65x02 stack to its default value. ; ; ****************************************************************************** EXTResetStack: .macro ldx #$FF ; reset 6502 stack. txs .endm ; ****************************************************************************** ; ; Set up code. Initialise everything except the video code (done ; by ExtReset. Puts in Dummy NMI,IRQ and Reset vectors is required ; Code will start assembly after this point via "jmp Start" ; ; ****************************************************************************** EXTStartPersonalise: #EXTResetStack ; reset stack jsr EXTReset ; reset video jsr EXTClearScreen ; clear screen jmp Start ; start main application ; ****************************************************************************** ; ; Macro called at the end of assembly to pad the ROM out to the ; relevant size and any other tidying up. ; ; ****************************************************************************** EXTEndCode: .macro ; don't need to do anything. .endm ; ****************************************************************************** ; ; Read a key from the keyboard buffer, or whatever. This should return ; non-zero values once for every key press (e.g. a successful read ; removes the key from the input Queue) ; ; ****************************************************************************** EXTReadKey: phz lda #$0F ; set up to write to read keyboard. sta EXTZPWork+3 lda #$FD sta EXTZPWork+2 lda #$36 sta EXTZPWork+1 lda #$10 sta EXTZPWork+0 ldz #0 nop ; read keyboard lda (EXTZPWork),z beq _EXTRKExit pha ; save key tza ; reset input nop sta (EXTZPWork),z pla ; restore/return value _EXTRKExit: plz rts ; ****************************************************************************** ; ; Read a byte from the screen (C64 codes, e.g. @ = 0) at XY -> A ; ; ****************************************************************************** EXTReadScreen: phy ; save Y txa ; multiply XY by 2 asl a sta EXTZPWork ; into EXTZPWork tya rol a ora #EXTScreen>>8 ; move into screen area sta EXTZPWork+1 ; read character there ldy #0 lda (EXTZPWork),y ply ; restore Y and exit. rts ; ****************************************************************************** ; ; Write a byte A to the screen (C64 codes, e.g. @ = 0) at XY ; ; ****************************************************************************** EXTWriteScreen: phy pha jsr EXTReadScreen ; set up the address into EXTZPWork ldy #0 pla ; restore and write. sta (EXTZPWork),y ply rts ; ****************************************************************************** ; ; Clear the screen ; ; ****************************************************************************** EXTClearScreen: pha ; save registers phy lda #EXTScreen & $FF ; set up pointer sta EXTZPWork lda #EXTScreen >> 8 sta EXTZPWork+1 ldy #0 _EXTCSLoop: lda #32 sta (EXTZPWork),y iny lda #0 sta (EXTZPWork),y iny bne _EXTCSLoop inc EXTZPWork+1 ; next screen page lda EXTZPWork+1 cmp #(EXTScreen>>8)+8 ; done 2k ? bne _EXTCSLoop ply ; restore pla rts ; ****************************************************************************** ; ; Scroll the whole display up one line. ; ; ****************************************************************************** EXTScrollDisplay: pha ; save registers phy lda #EXTScreen & $FF ; set pointer to screen sta EXTZPWork+0 lda #EXTScreen >> 8 sta EXTZPWork+1 _EXTScroll: ldy #EXTWidth*2 ; x 2 because of two byte format. lda (EXTZPWork),y ldy #0 sta (EXTZPWork),y inc EXTZPWork ; bump address inc EXTZPWork bne _EXTNoCarry inc EXTZPWork+1 _EXTNoCarry: lda EXTZPWork ; done ? cmp #(EXTScreen+2*EXTWidth*(EXTHeight-1)) & $FF bne _EXTScroll lda EXTZPWork+1 cmp #(EXTScreen+2*EXTWidth*(EXTHeight-1)) >> 8 bne _EXTScroll ; ldy #0 ; clear bottom line. _EXTLastLine: lda #32 sta (EXTZPWork),y iny iny cpy #EXTWidth*2 bne _EXTLastLine ply ; restore and exit. pla rts ; ****************************************************************************** ; ; Reset the Display System ; ; ****************************************************************************** EXTWrite .macro ; write to register using ldz #\1 ; address already set up lda #\2 nop sta (EXTZPWork),z .endm EXTReset: pha ; save registers phx phy lda #$0F ; set up to write to video system. sta EXTZPWork+3 lda #$FD sta EXTZPWork+2 lda #$30 sta EXTZPWork+1 lda #$00 sta EXTZPWork+0 #EXTWrite $30,$40 ; Charset #EXTWrite $20,$00 ; border #EXTWrite $21,$00 ; background #EXTWrite $6F,$60 ; 60Hz #EXTWrite $18,$42 ; screen address $0800 video address $2000 #EXTWrite $11,$1B #EXTWrite $16,$C8 #EXTWrite $54,$C5 #EXTWrite $58,80 #EXTWrite $59,0 #EXTWrite $00,$FF #EXTWrite $01,$FF #EXTWrite $30,4 #EXTWrite $70,$FF lda #$00 ; colour RAM at $1F800-1FFFF (2kb) sta EXTZPWork+3 lda #$01 sta EXTZPWork+2 lda #$F8 sta EXTZPWork+1 lda #$00 sta EXTZPWork+0 ldz #0 _EXTClearColorRam: lda #8 ; fill that with this colour. nop sta (EXTZPWork),z dez bne _EXTClearColorRam inc EXTZPWork+1 bne _EXTClearColorRam ldx #0 ; copy PET Font into memory. _EXTCopyCBMFont: lda EXTCBMFont,x sta EXTCharSet,x lda EXTCBMFont+$100,x sta EXTCharSet+$100,x lda EXTCBMFont+$200,x sta EXTCharSet+$200,x lda EXTCBMFont+$300,x sta EXTCharSet+$300,x dex bne _EXTCopyCBMFont ply ; restore and exit. plx pla rts
;------------------------------------------------------------------------------ ;* ;* Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR> ;* SPDX-License-Identifier: BSD-2-Clause-Patent ;* ;* CpuAsm.asm ;* ;* Abstract: ;* ;------------------------------------------------------------------------------ #include <Base.h> DEFAULT REL SECTION .text extern ASM_PFX(SecCoreStartupWithStack) ; ; SecCore Entry Point ; ; Processor is in flat protected mode ; ; @param[in] RAX Initial value of the EAX register (BIST: Built-in Self Test) ; @param[in] DI 'BP': boot-strap processor, or 'AP': application processor ; @param[in] RBP Pointer to the start of the Boot Firmware Volume ; @param[in] DS Selector allowing flat access to all addresses ; @param[in] ES Selector allowing flat access to all addresses ; @param[in] FS Selector allowing flat access to all addresses ; @param[in] GS Selector allowing flat access to all addresses ; @param[in] SS Selector allowing flat access to all addresses ; ; @return None This routine does not return ; global ASM_PFX(_ModuleEntryPoint) ASM_PFX(_ModuleEntryPoint): ; ; Fill the temporary RAM with the initial stack value. ; The loop below will seed the heap as well, but that's harmless. ; mov rax, (FixedPcdGet32 (PcdInitValueInTempStack) << 32) | FixedPcdGet32 (PcdInitValueInTempStack) ; qword to store mov rdi, FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) ; base address, ; relative to ; ES mov rcx, FixedPcdGet32 (PcdOvmfSecPeiTempRamSize) / 8 ; qword count cld ; store from base ; up rep stosq ; ; Load temporary RAM stack based on PCDs ; %define SEC_TOP_OF_STACK (FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) + \ FixedPcdGet32 (PcdOvmfSecPeiTempRamSize)) mov rsp, SEC_TOP_OF_STACK nop ; ; Setup parameters and call SecCoreStartupWithStack ; rcx: BootFirmwareVolumePtr ; rdx: TopOfCurrentStack ; mov rcx, rbp mov rdx, rsp sub rsp, 0x20 call ASM_PFX(SecCoreStartupWithStack)
INCLUDE "color/data/map_palettes.asm" INCLUDE "color/data/map_palette_sets.asm" INCLUDE "color/data/map_palette_assignments.asm" INCLUDE "color/data/roofpalettes.asm" ; Load colors for new map and tile placement LoadTilesetPalette: push bc push de push hl ld a,[rSVBK] ld d,a xor a ld [rSVBK],a ld a,[wCurMapTileset] ; Located in wram bank 1 ld b,a ld a,$02 ld [rSVBK],a push de ; push previous wram bank ld a,1 ld [W2_TileBasedPalettes],a ld a,b ; Get wCurMapTileset push af ld d,0 ld e,a sla e sla e sla e ld hl, MapPaletteSets add hl,de ld d,h ld e,l ld hl,W2_BgPaletteData ; palette data to be copied to wram at hl ld b,$08 .nextPalette ld c,$08 ld a,[de] ; # at de is the palette index for MapPalettes inc de push de ld d,0 ld e,a sla e rl d sla e rl d sla e rl d push hl ld hl, MapPalettes add hl,de ld d,h ld e,l ; de now points to map's palette data pop hl .nextColor ld a,[de] inc de ld [hli],a dec c jr nz,.nextColor pop de dec b jr nz,.nextPalette ; Start copying palette assignments pop af ; Retrieve wCurMapTileset ld hl,$0000 cp $00 jr z,.doneMultiplication ld c,a ld de,$0060 ; Each palette assignment takes $60 bytes .addLoop add hl,de dec c jr nz,.addLoop .doneMultiplication: ld bc, MapPaletteAssignments add hl,bc push hl pop de ; de points to MapPaletteAssignments ld hl, W2_TilesetPaletteMap ld b,$60 .copyLoop ld a,[de] inc de ld [hli],a dec b jr nz,.copyLoop ; Set the remaining values to 7 for text ld b,$a0 ld a,7 .fillLoop ld [hli],a dec b jr nz,.fillLoop ; There used to be special-case code for tile $78 here (pokeball in pc), but now ; it uses palette 7 as well. Those areas still need to load the variant of the ; textbox palette (PC_POKEBALL_PAL). ; Switch to wram bank 1 just to read wCurMap xor a ld [rSVBK],a ld a,[wCurMap] ld b,a ld a,2 ld [rSVBK],a ; Check for celadon mart roof (make the "outside" blue) ld a,b cp CELADON_MART_ROOF jr nz,.notCeladonRoof ld a,BLUE ld hl,W2_TilesetPaletteMap + $4b ld [hli],a ld [hli],a ld [hli],a ld [hli],a ld [hli],a .notCeladonRoof ; Check for celadon 3rd floor (fix miscoloration on counter) ld a,b cp CELADON_MART_3 jr nz,.notCeladon3rd ld hl,W2_TilesetPaletteMap + $37 ld [hl],BROWN .notCeladon3rd ; Check for celadon 1st floor (change bench color from blue to yellow) ld a,b cp CELADON_MART_1 jr nz,.notCeladon1st ld hl,W2_TilesetPaletteMap + $07 ld a,YELLOW ld [hli],a ld [hli],a ld l,$17 ld [hli],a ld [hli],a .notCeladon1st ; Retrieve former wram bank pop af ld b,a xor a ld [rSVBK],a ld a,[wCurMapTileset] ld c,a ld a,b ld [rSVBK],a ; Restore previous wram bank ld a,c and a ; Check whether tileset 0 is loaded call z, LoadTownPalette cp PLATEAU ; tileset 0 isn't the only outside tileset call z, LoadTownPalette pop hl pop de pop bc ret ; Towns have different roof colors while using the same tileset LoadTownPalette: ld a,[rSVBK] ld b,a xor a ld [rSVBK],a ; Get the current map. ld a, [wCurMap] ld c, a cp ROUTE_10 ; Route 10 has 50 rows in cerulean city; check if player is there or not. jr nz, .notRoute10 ld a, [wYCoord] cp 50 jr nc, .notRoute10 ld c, CERULEAN_CITY .notRoute10 ld a, c add a ld c, a ld a,$02 ld [rSVBK],a push bc ; push previous wram bank push de push hl ld hl, RoofPalettes ld b, 0 add hl, bc ld e, [hl] inc hl ld d, [hl] ld hl, W2_BgPaletteData + $32 ld b,$04 .copyLoop ld a,[de] inc de ld [hli],a dec b jr nz,.copyLoop pop hl pop de ld a, [wCurMap] ld [W2_TownMapLoaded],a pop af ld [rSVBK],a ; Restore wram bank ret
DoPlayerMovement:: call .GetDPad ld a, movement_step_sleep ld [wMovementAnimation], a xor a ld [wWalkingIntoEdgeWarp], a call .TranslateIntoMovement ld c, a ld a, [wMovementAnimation] ld [wPlayerNextMovement], a ret .GetDPad: ldh a, [hJoyDown] ld [wCurInput], a ; Standing downhill instead moves down. ld hl, wBikeFlags bit BIKEFLAGS_DOWNHILL_F, [hl] ret z ld c, a and D_PAD ret nz ld a, c or D_DOWN ld [wCurInput], a ret .TranslateIntoMovement: IF DEF(_DEBUG) ld a, [wCurInput] and B_BUTTON jr z, .regular_move call .GetAction ld a, [wWalkingTile] cp -1 ld a, STEP_BACK_LEDGE jr z, .hopback ld a, STEP_BIKE .hopback call .DoStep scf ret .regular_move ENDC ld a, [wPlayerState] cp PLAYER_NORMAL jr z, .Normal cp PLAYER_SURF jr z, .Surf cp PLAYER_SURF_PIKA jr z, .Surf cp PLAYER_BIKE jr z, .Normal cp PLAYER_SKATE jr z, .Ice .Normal: call .CheckForced call .GetAction call .CheckTile ret c call .CheckTurning ret c call .TryStep ret c call .TryJump ret c call .CheckWarp ret c jr .NotMoving .Surf: call .CheckForced call .GetAction call .CheckTile ret c call .CheckTurning ret c call .TrySurf ret c jr .NotMoving .Ice: call .CheckForced call .GetAction call .CheckTile ret c call .CheckTurning ret c call .TryStep ret c call .TryJump ret c call .CheckWarp ret c ld a, [wWalkingDirection] cp STANDING jr z, .HitWall call .BumpSound .HitWall: call .StandInPlace xor a ret .NotMoving: ld a, [wWalkingDirection] cp STANDING jr z, .Standing ; Walking into an edge warp won't bump. ld a, [wWalkingIntoEdgeWarp] and a jr nz, .CantMove call .BumpSound .CantMove: call ._WalkInPlace xor a ret .Standing: call .StandInPlace xor a ret .CheckTile: ; Tiles such as waterfalls and warps move the player ; in a given direction, overriding input. ld a, [wPlayerStandingTile] ld c, a call CheckWhirlpoolTile jr c, .not_whirlpool ld a, 3 scf ret .not_whirlpool and $f0 cp HI_NYBBLE_CURRENT jr z, .water cp HI_NYBBLE_WALK jr z, .land1 cp HI_NYBBLE_WALK_ALT jr z, .land2 cp HI_NYBBLE_WARPS jr z, .warps jr .no_walk .water ld a, c maskbits NUM_DIRECTIONS ld c, a ld b, 0 ld hl, .water_table add hl, bc ld a, [hl] ld [wWalkingDirection], a jr .continue_walk .water_table db RIGHT ; COLL_WATERFALL_RIGHT db LEFT ; COLL_WATERFALL_LEFT db UP ; COLL_WATERFALL_UP db DOWN ; COLL_WATERFALL .land1 ld a, c and 7 ld c, a ld b, 0 ld hl, .land1_table add hl, bc ld a, [hl] cp STANDING jr z, .no_walk ld [wWalkingDirection], a jr .continue_walk .land1_table db STANDING ; COLL_BRAKE db RIGHT ; COLL_WALK_RIGHT db LEFT ; COLL_WALK_LEFT db UP ; COLL_WALK_UP db DOWN ; COLL_WALK_DOWN db STANDING ; COLL_BRAKE_45 db STANDING ; COLL_BRAKE_46 db STANDING ; COLL_BRAKE_47 .land2 ld a, c and 7 ld c, a ld b, 0 ld hl, .land2_table add hl, bc ld a, [hl] cp STANDING jr z, .no_walk ld [wWalkingDirection], a jr .continue_walk .land2_table db RIGHT ; COLL_WALK_RIGHT_ALT db LEFT ; COLL_WALK_LEFT_ALT db UP ; COLL_WALK_UP_ALT db DOWN ; COLL_WALK_DOWN_ALT db STANDING ; COLL_BRAKE_ALT db STANDING ; COLL_BRAKE_55 db STANDING ; COLL_BRAKE_56 db STANDING ; COLL_BRAKE_57 .warps ld a, c cp COLL_DOOR jr z, .down cp COLL_DOOR_79 jr z, .down cp COLL_STAIRCASE jr z, .down cp COLL_CAVE jr nz, .no_walk .down ld a, DOWN ld [wWalkingDirection], a jr .continue_walk .no_walk xor a ret .continue_walk ld a, STEP_WALK call .DoStep ld a, 5 scf ret .CheckTurning: ; If the player is turning, change direction first. This also lets ; the player change facing without moving by tapping a direction. ld a, [wPlayerTurningDirection] cp 0 jr nz, .not_turning ld a, [wWalkingDirection] cp STANDING jr z, .not_turning ld e, a ld a, [wPlayerDirection] rrca rrca maskbits NUM_DIRECTIONS cp e jr z, .not_turning ld a, STEP_TURN call .DoStep ld a, 2 scf ret .not_turning xor a ret .TryStep: ; Surfing actually calls .TrySurf directly instead of passing through here. ld a, [wPlayerState] cp PLAYER_SURF jr z, .TrySurf cp PLAYER_SURF_PIKA jr z, .TrySurf call .CheckLandPerms jr c, .bump call .CheckNPC and a jr z, .bump cp 2 jr z, .bump ld a, [wSpinning] and a jr nz, .spin ld a, [wPlayerStandingTile] call CheckIceTile jr nc, .ice ; Downhill riding is slower when not moving down. call .BikeCheck jr nz, .walk ld hl, wBikeFlags bit BIKEFLAGS_DOWNHILL_F, [hl] jr z, .fast ld a, [wWalkingDirection] cp DOWN jr z, .fast ld a, STEP_WALK call .DoStep scf ret .fast ld a, STEP_BIKE call .DoStep scf ret .walk ld a, STEP_WALK call .DoStep scf ret .ice ld a, STEP_ICE call .DoStep scf ret ; unused xor a ret .spin ld de, SFX_SQUEAK call PlaySFX ld a, STEP_SPIN call .DoStep scf ret .bump xor a ld [wSpinning], a ret .TrySurf: call .CheckSurfPerms ld [wWalkingIntoLand], a jr c, .surf_bump call .CheckNPC ld [wWalkingIntoNPC], a and a jr z, .surf_bump cp 2 jr z, .surf_bump ld a, [wWalkingIntoLand] and a jr nz, .ExitWater ld a, STEP_WALK call .DoStep scf ret .ExitWater: call .GetOutOfWater call PlayMapMusic ld a, STEP_WALK call .DoStep ld a, 6 scf ret .surf_bump xor a ret .TryJump: ld a, [wPlayerStandingTile] ld e, a and $f0 cp HI_NYBBLE_LEDGES jr nz, .DontJump ld a, e and 7 ld e, a ld d, 0 ld hl, .data_8021e add hl, de ld a, [wFacingDirection] and [hl] jr z, .DontJump ; make sure the place the player lands is clear ld a, [wPlayerStandingMapX] ld d, a ld a, [wWalkingX] add a ; *2 add d ld d, a ld a, [wPlayerStandingMapY] ld e, a ld a, [wWalkingY] add a ; *2 add e ld e, a ; make sure tile is walkable push de call GetCoordTile call .CheckWalkable pop de jr c, .DontJump ; make sure there's no NPC xor a ldh [hMapObjectIndexBuffer], a farcall IsNPCAtCoord jr c, .DontJump ; A-ok ld de, SFX_JUMP_OVER_LEDGE call PlaySFX ld a, STEP_LEDGE call .DoStep ld a, 7 scf ret .DontJump: xor a ret .data_8021e db FACE_RIGHT ; COLL_HOP_RIGHT db FACE_LEFT ; COLL_HOP_LEFT db FACE_UP ; COLL_HOP_UP db FACE_DOWN ; COLL_HOP_DOWN db FACE_RIGHT | FACE_DOWN ; COLL_HOP_DOWN_RIGHT db FACE_DOWN | FACE_LEFT ; COLL_HOP_DOWN_LEFT db FACE_UP | FACE_RIGHT ; COLL_HOP_UP_RIGHT db FACE_UP | FACE_LEFT ; COLL_HOP_UP_LEFT .CheckWarp: ; Bug: Since no case is made for STANDING here, it will check ; [.edgewarps + $ff]. This resolves to $3e at $8035a. ; This causes wWalkingIntoEdgeWarp to be nonzero when standing on tile $3e, ; making bumps silent. ld a, [wWalkingDirection] ; cp STANDING ; jr z, .not_warp ld e, a ld d, 0 ld hl, .EdgeWarps add hl, de ld a, [wPlayerStandingTile] cp [hl] jr nz, .not_warp ld a, TRUE ld [wWalkingIntoEdgeWarp], a ld a, [wWalkingDirection] ; This is in the wrong place. cp STANDING jr z, .not_warp ld e, a ld a, [wPlayerDirection] rrca rrca maskbits NUM_DIRECTIONS cp e jr nz, .not_warp call WarpCheck jr nc, .not_warp call .StandInPlace scf ld a, 1 ret .not_warp xor a ret .EdgeWarps: db COLL_WARP_CARPET_DOWN db COLL_WARP_CARPET_UP db COLL_WARP_CARPET_LEFT db COLL_WARP_CARPET_RIGHT .DoStep: ld e, a ld d, 0 ld hl, .Steps add hl, de add hl, de ld a, [hli] ld h, [hl] ld l, a ld a, [wWalkingDirection] ld e, a cp STANDING jp z, .StandInPlace add hl, de ld a, [hl] ld [wMovementAnimation], a ld hl, .FinishFacing add hl, de ld a, [hl] ld [wPlayerTurningDirection], a ld a, 4 ret .Steps: ; entries correspond to STEP_* constants dw .SlowStep dw .NormalStep dw .FastStep dw .JumpStep dw .SlideStep dw .TurningStep dw .BackJumpStep dw .FinishFacing dw .SpinStep .SlowStep: slow_step DOWN slow_step UP slow_step LEFT slow_step RIGHT .NormalStep: step DOWN step UP step LEFT step RIGHT .FastStep: big_step DOWN big_step UP big_step LEFT big_step RIGHT .JumpStep: jump_step DOWN jump_step UP jump_step LEFT jump_step RIGHT .SlideStep: fast_slide_step DOWN fast_slide_step UP fast_slide_step LEFT fast_slide_step RIGHT .BackJumpStep: jump_step UP jump_step DOWN jump_step RIGHT jump_step LEFT .TurningStep: turn_step DOWN turn_step UP turn_step LEFT turn_step RIGHT .FinishFacing: db $80 | DOWN db $80 | UP db $80 | LEFT db $80 | RIGHT .SpinStep: turn_in_down turn_in_up turn_in_left turn_in_right .StandInPlace: ld a, 0 ld [wPlayerTurningDirection], a ld a, movement_step_sleep ld [wMovementAnimation], a xor a ret ._WalkInPlace: ld a, 0 ld [wPlayerTurningDirection], a ld a, movement_step_bump ld [wMovementAnimation], a xor a ret .CheckForced: ; When sliding on ice or spinning, input is forced to remain in the same direction. call CheckSpinning jr z, .not_spinning dec a jr .force .not_spinning call CheckStandingOnIce ret nc ld a, [wPlayerTurningDirection] cp 0 ret z .force maskbits NUM_DIRECTIONS ld e, a ld d, 0 ld hl, .forced_dpad add hl, de ld a, [wCurInput] and BUTTONS or [hl] ld [wCurInput], a ret .forced_dpad db D_DOWN, D_UP, D_LEFT, D_RIGHT .GetAction: ; Poll player input and update movement info. ld hl, .action_table ld de, .action_table_1_end - .action_table_1 ld a, [wCurInput] bit D_DOWN_F, a jr nz, .d_down bit D_UP_F, a jr nz, .d_up bit D_LEFT_F, a jr nz, .d_left bit D_RIGHT_F, a jr nz, .d_right ; Standing jr .update .d_down add hl, de .d_up add hl, de .d_left add hl, de .d_right add hl, de .update ld a, [hli] ld [wWalkingDirection], a ld a, [hli] ld [wFacingDirection], a ld a, [hli] ld [wWalkingX], a ld a, [hli] ld [wWalkingY], a ld a, [hli] ld h, [hl] ld l, a ld a, [hl] ld [wWalkingTile], a ret player_action: MACRO ; walk direction, facing, x movement, y movement, tile collision pointer db \1, \2, \3, \4 dw \5 ENDM .action_table: .action_table_1 player_action STANDING, FACE_CURRENT, 0, 0, wPlayerStandingTile .action_table_1_end player_action RIGHT, FACE_RIGHT, 1, 0, wTileRight player_action LEFT, FACE_LEFT, -1, 0, wTileLeft player_action UP, FACE_UP, 0, -1, wTileUp player_action DOWN, FACE_DOWN, 0, 1, wTileDown .CheckNPC: ; Returns 0 if there is an NPC in front that you can't move ; Returns 1 if there is no NPC in front ; Returns 2 if there is a movable NPC in front ld a, 0 ldh [hMapObjectIndexBuffer], a ; Load the next X coordinate into d ld a, [wPlayerStandingMapX] ld d, a ld a, [wWalkingX] add d ld d, a ; Load the next Y coordinate into e ld a, [wPlayerStandingMapY] ld e, a ld a, [wWalkingY] add e ld e, a ; Find an object struct with coordinates equal to d,e ld bc, wObjectStructs ; redundant farcall IsNPCAtCoord jr nc, .is_npc ld hl, OBJECT_MOVEMENTTYPE add hl, bc ld a, [hl] cp SPRITEMOVEDATA_FOLLOWING jr z, .is_npc call .CheckStrengthBoulder jr c, .no_bump xor a ret .is_npc ld a, 1 ret .no_bump ld a, 2 ret .CheckStrengthBoulder: ld hl, wBikeFlags bit BIKEFLAGS_STRENGTH_ACTIVE_F, [hl] jr z, .not_boulder ld hl, OBJECT_DIRECTION_WALKING add hl, bc ld a, [hl] cp STANDING jr nz, .not_boulder ld hl, OBJECT_PALETTE add hl, bc bit STRENGTH_BOULDER_F, [hl] jr z, .not_boulder ld hl, OBJECT_FLAGS2 add hl, bc set 2, [hl] ld a, [wWalkingDirection] ld d, a ld hl, OBJECT_RANGE add hl, bc ld a, [hl] and %11111100 or d ld [hl], a scf ret .not_boulder xor a ret .CheckLandPerms: ; Return 0 if walking onto land and tile permissions allow it. ; Otherwise, return carry. ld a, [wTilePermissions] ld d, a ld a, [wFacingDirection] and d jr nz, .NotWalkable ld a, [wWalkingTile] call .CheckWalkable jr c, .NotWalkable xor a ret .NotWalkable: scf ret .CheckSurfPerms: ; Return 0 if moving in water, or 1 if moving onto land. ; Otherwise, return carry. ld a, [wTilePermissions] ld d, a ld a, [wFacingDirection] and d jr nz, .NotSurfable ld a, [wWalkingTile] call .CheckSurfable jr c, .NotSurfable and a ret .NotSurfable: scf ret .BikeCheck: ld a, [wPlayerState] cp PLAYER_BIKE ret z cp PLAYER_SKATE ret .CheckWalkable: ; Return 0 if tile a is land. Otherwise, return carry. call GetTileCollision and a ; LANDTILE? ret z scf ret .CheckSurfable: ; Return 0 if tile a is water, or 1 if land. ; Otherwise, return carry. call GetTileCollision cp WATERTILE jr z, .Water ; Can walk back onto land from water. and a ; LANDTILE? jr z, .Land jr .Neither .Water: xor a ret .Land: ld a, 1 and a ret .Neither: scf ret .BumpSound: call CheckSFX ret c ld de, SFX_BUMP call PlaySFX ret .GetOutOfWater: push bc ld a, PLAYER_NORMAL ld [wPlayerState], a call ReplaceKrisSprite ; UpdateSprites pop bc ret CheckStandingOnIce:: ld a, [wPlayerTurningDirection] cp 0 jr z, .not_ice cp $f0 jr z, .not_ice ld a, [wPlayerStandingTile] call CheckIceTile jr nc, .yep ld a, [wPlayerState] cp PLAYER_SKATE jr nz, .not_ice .yep scf ret .not_ice and a ret CheckSpinning:: ld a, [wPlayerStandingTile] cp COLL_STOP_SPIN jr z, .stop_spin call CheckSpinTile jr z, .start_spin ld a, [wSpinning] and a ret .start_spin ld a, c inc a ld [wSpinning], a and a ret .stop_spin xor a ld [wSpinning], a ret CheckSpinTile: cp COLL_SPIN_UP ld c, UP ret z cp COLL_SPIN_DOWN ld c, DOWN ret z cp COLL_SPIN_LEFT ld c, LEFT ret z cp COLL_SPIN_RIGHT ld c, RIGHT ret z ld c, STANDING ret StopPlayerForEvent:: ld hl, wPlayerNextMovement ld a, movement_step_sleep cp [hl] ret z ld [hl], a ld a, 0 ld [wPlayerTurningDirection], a ret
#include <cstdint> #include <memory> #include <string> #include "common/common/base64.h" #include "common/http/header_map_impl.h" #include "common/http/headers.h" #include "common/http/message_impl.h" #include "common/runtime/runtime_impl.h" #include "common/runtime/uuid_util.h" #include "common/tracing/http_tracer_impl.h" #include "test/mocks/http/mocks.h" #include "test/mocks/local_info/mocks.h" #include "test/mocks/router/mocks.h" #include "test/mocks/runtime/mocks.h" #include "test/mocks/stats/mocks.h" #include "test/mocks/thread_local/mocks.h" #include "test/mocks/tracing/mocks.h" #include "test/mocks/upstream/mocks.h" #include "test/test_common/environment.h" #include "test/test_common/printers.h" #include "test/test_common/utility.h" #include "gmock/gmock.h" #include "gtest/gtest.h" using testing::_; using testing::Eq; using testing::NiceMock; using testing::Return; using testing::ReturnPointee; namespace Envoy { namespace Tracing { namespace { TEST(HttpTracerUtilityTest, IsTracing) { NiceMock<StreamInfo::MockStreamInfo> stream_info; NiceMock<Stats::MockStore> stats; Runtime::RandomGeneratorImpl random; std::string not_traceable_guid = random.uuid(); std::string forced_guid = random.uuid(); UuidUtils::setTraceableUuid(forced_guid, UuidTraceStatus::Forced); Http::TestHeaderMapImpl forced_header{{"x-request-id", forced_guid}}; std::string sampled_guid = random.uuid(); UuidUtils::setTraceableUuid(sampled_guid, UuidTraceStatus::Sampled); Http::TestHeaderMapImpl sampled_header{{"x-request-id", sampled_guid}}; std::string client_guid = random.uuid(); UuidUtils::setTraceableUuid(client_guid, UuidTraceStatus::Client); Http::TestHeaderMapImpl client_header{{"x-request-id", client_guid}}; Http::TestHeaderMapImpl not_traceable_header{{"x-request-id", not_traceable_guid}}; Http::TestHeaderMapImpl empty_header{}; // Force traced. { EXPECT_CALL(stream_info, healthCheck()).WillOnce(Return(false)); Decision result = HttpTracerUtility::isTracing(stream_info, forced_header); EXPECT_EQ(Reason::ServiceForced, result.reason); EXPECT_TRUE(result.traced); } // Sample traced. { EXPECT_CALL(stream_info, healthCheck()).WillOnce(Return(false)); Decision result = HttpTracerUtility::isTracing(stream_info, sampled_header); EXPECT_EQ(Reason::Sampling, result.reason); EXPECT_TRUE(result.traced); } // Health Check request. { Http::TestHeaderMapImpl traceable_header_hc{{"x-request-id", forced_guid}}; EXPECT_CALL(stream_info, healthCheck()).WillOnce(Return(true)); Decision result = HttpTracerUtility::isTracing(stream_info, traceable_header_hc); EXPECT_EQ(Reason::HealthCheck, result.reason); EXPECT_FALSE(result.traced); } // Client traced. { EXPECT_CALL(stream_info, healthCheck()).WillOnce(Return(false)); Decision result = HttpTracerUtility::isTracing(stream_info, client_header); EXPECT_EQ(Reason::ClientForced, result.reason); EXPECT_TRUE(result.traced); } // No request id. { Http::TestHeaderMapImpl headers; EXPECT_CALL(stream_info, healthCheck()).WillOnce(Return(false)); Decision result = HttpTracerUtility::isTracing(stream_info, headers); EXPECT_EQ(Reason::NotTraceableRequestId, result.reason); EXPECT_FALSE(result.traced); } // Broken request id. { Http::TestHeaderMapImpl headers{{"x-request-id", "not-real-x-request-id"}}; EXPECT_CALL(stream_info, healthCheck()).WillOnce(Return(false)); Decision result = HttpTracerUtility::isTracing(stream_info, headers); EXPECT_EQ(Reason::NotTraceableRequestId, result.reason); EXPECT_FALSE(result.traced); } } class HttpConnManFinalizerImplTest : public testing::Test { protected: struct CustomTagCase { std::string custom_tag; bool set; std::string value; }; void expectSetCustomTags(const std::vector<CustomTagCase>& cases) { for (const CustomTagCase& cas : cases) { envoy::type::tracing::v2::CustomTag custom_tag; TestUtility::loadFromYaml(cas.custom_tag, custom_tag); config.custom_tags_.emplace(custom_tag.tag(), HttpTracerUtility::createCustomTag(custom_tag)); if (cas.set) { EXPECT_CALL(span, setTag(Eq(custom_tag.tag()), Eq(cas.value))); } else { EXPECT_CALL(span, setTag(Eq(custom_tag.tag()), _)).Times(0); } } } NiceMock<MockSpan> span; NiceMock<MockConfig> config; NiceMock<StreamInfo::MockStreamInfo> stream_info; }; TEST_F(HttpConnManFinalizerImplTest, OriginalAndLongPath) { const std::string path(300, 'a'); const std::string path_prefix = "http://"; const std::string expected_path(256, 'a'); Http::TestHeaderMapImpl request_headers{{"x-request-id", "id"}, {"x-envoy-original-path", path}, {":method", "GET"}, {"x-forwarded-proto", "http"}}; Http::TestHeaderMapImpl response_headers; Http::TestHeaderMapImpl response_trailers; absl::optional<Http::Protocol> protocol = Http::Protocol::Http2; EXPECT_CALL(stream_info, bytesReceived()).WillOnce(Return(10)); EXPECT_CALL(stream_info, bytesSent()).WillOnce(Return(11)); EXPECT_CALL(stream_info, protocol()).WillRepeatedly(ReturnPointee(&protocol)); absl::optional<uint32_t> response_code; EXPECT_CALL(stream_info, responseCode()).WillRepeatedly(ReturnPointee(&response_code)); EXPECT_CALL(span, setTag(_, _)).Times(testing::AnyNumber()); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpUrl), Eq(path_prefix + expected_path))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpMethod), Eq("GET"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpProtocol), Eq("HTTP/2"))); HttpTracerUtility::finalizeDownstreamSpan(span, &request_headers, &response_headers, &response_trailers, stream_info, config); } TEST_F(HttpConnManFinalizerImplTest, NoGeneratedId) { const std::string path(300, 'a'); const std::string path_prefix = "http://"; const std::string expected_path(256, 'a'); Http::TestHeaderMapImpl request_headers{ {"x-envoy-original-path", path}, {":method", "GET"}, {"x-forwarded-proto", "http"}}; Http::TestHeaderMapImpl response_headers; Http::TestHeaderMapImpl response_trailers; absl::optional<Http::Protocol> protocol = Http::Protocol::Http2; EXPECT_CALL(stream_info, bytesReceived()).WillOnce(Return(10)); EXPECT_CALL(stream_info, bytesSent()).WillOnce(Return(11)); EXPECT_CALL(stream_info, protocol()).WillRepeatedly(ReturnPointee(&protocol)); absl::optional<uint32_t> response_code; EXPECT_CALL(stream_info, responseCode()).WillRepeatedly(ReturnPointee(&response_code)); EXPECT_CALL(span, setTag(_, _)).Times(testing::AnyNumber()); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpUrl), Eq(path_prefix + expected_path))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpMethod), Eq("GET"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpProtocol), Eq("HTTP/2"))); HttpTracerUtility::finalizeDownstreamSpan(span, &request_headers, &response_headers, &response_trailers, stream_info, config); } TEST_F(HttpConnManFinalizerImplTest, NullRequestHeadersAndNullRouteEntry) { EXPECT_CALL(stream_info, bytesReceived()).WillOnce(Return(10)); EXPECT_CALL(stream_info, bytesSent()).WillOnce(Return(11)); absl::optional<uint32_t> response_code; EXPECT_CALL(stream_info, responseCode()).WillRepeatedly(ReturnPointee(&response_code)); EXPECT_CALL(stream_info, upstreamHost()).WillRepeatedly(Return(nullptr)); EXPECT_CALL(stream_info, routeEntry()).WillRepeatedly(Return(nullptr)); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpStatusCode), Eq("0"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().Error), Eq(Tracing::Tags::get().True))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().ResponseSize), Eq("11"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().ResponseFlags), Eq("-"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().RequestSize), Eq("10"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().Component), Eq(Tracing::Tags::get().Proxy))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().UpstreamCluster), _)).Times(0); expectSetCustomTags({{"{ tag: a, request_header: { name: X-Ax } }", false, ""}, {R"EOF( tag: b metadata: kind: { route: {} } metadata_key: { key: m.rot, path: [ {key: not-found } ] } default_value: _c)EOF", true, "_c"}, {R"EOF( tag: c metadata: kind: { cluster: {} } metadata_key: { key: m.cluster, path: [ {key: not-found } ] })EOF", false, ""}, {R"EOF( tag: d metadata: kind: { host: {} } metadata_key: { key: m.host, path: [ {key: not-found } ] })EOF", false, ""}}); HttpTracerUtility::finalizeDownstreamSpan(span, nullptr, nullptr, nullptr, stream_info, config); } TEST_F(HttpConnManFinalizerImplTest, StreamInfoLogs) { stream_info.host_->cluster_.name_ = "my_upstream_cluster"; EXPECT_CALL(stream_info, bytesReceived()).WillOnce(Return(10)); EXPECT_CALL(stream_info, bytesSent()).WillOnce(Return(11)); absl::optional<uint32_t> response_code; EXPECT_CALL(stream_info, responseCode()).WillRepeatedly(ReturnPointee(&response_code)); EXPECT_CALL(stream_info, upstreamHost()).Times(2); const auto start_timestamp = SystemTime{std::chrono::duration_cast<SystemTime::duration>(std::chrono::hours{123})}; EXPECT_CALL(stream_info, startTime()).WillRepeatedly(Return(start_timestamp)); const absl::optional<std::chrono::nanoseconds> nanoseconds = std::chrono::nanoseconds{10}; EXPECT_CALL(stream_info, lastDownstreamRxByteReceived()).WillRepeatedly(Return(nanoseconds)); EXPECT_CALL(stream_info, firstUpstreamTxByteSent()).WillRepeatedly(Return(nanoseconds)); EXPECT_CALL(stream_info, lastUpstreamTxByteSent()).WillRepeatedly(Return(nanoseconds)); EXPECT_CALL(stream_info, firstUpstreamRxByteReceived()).WillRepeatedly(Return(nanoseconds)); EXPECT_CALL(stream_info, lastUpstreamRxByteReceived()).WillRepeatedly(Return(nanoseconds)); EXPECT_CALL(stream_info, firstDownstreamTxByteSent()).WillRepeatedly(Return(nanoseconds)); EXPECT_CALL(stream_info, lastDownstreamTxByteSent()).WillRepeatedly(Return(nanoseconds)); const auto log_timestamp = start_timestamp + std::chrono::duration_cast<SystemTime::duration>(*nanoseconds); EXPECT_CALL(span, log(log_timestamp, Tracing::Logs::get().LastDownstreamRxByteReceived)); EXPECT_CALL(span, log(log_timestamp, Tracing::Logs::get().FirstUpstreamTxByteSent)); EXPECT_CALL(span, log(log_timestamp, Tracing::Logs::get().LastUpstreamTxByteSent)); EXPECT_CALL(span, log(log_timestamp, Tracing::Logs::get().FirstUpstreamRxByteReceived)); EXPECT_CALL(span, log(log_timestamp, Tracing::Logs::get().LastUpstreamRxByteReceived)); EXPECT_CALL(span, log(log_timestamp, Tracing::Logs::get().FirstDownstreamTxByteSent)); EXPECT_CALL(span, log(log_timestamp, Tracing::Logs::get().LastDownstreamTxByteSent)); EXPECT_CALL(config, verbose).WillOnce(Return(true)); HttpTracerUtility::finalizeDownstreamSpan(span, nullptr, nullptr, nullptr, stream_info, config); } TEST_F(HttpConnManFinalizerImplTest, UpstreamClusterTagSet) { stream_info.host_->cluster_.name_ = "my_upstream_cluster"; EXPECT_CALL(stream_info, bytesReceived()).WillOnce(Return(10)); EXPECT_CALL(stream_info, bytesSent()).WillOnce(Return(11)); absl::optional<uint32_t> response_code; EXPECT_CALL(stream_info, responseCode()).WillRepeatedly(ReturnPointee(&response_code)); EXPECT_CALL(stream_info, upstreamHost()).Times(2); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().Component), Eq(Tracing::Tags::get().Proxy))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().UpstreamCluster), Eq("my_upstream_cluster"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpStatusCode), Eq("0"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().Error), Eq(Tracing::Tags::get().True))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().ResponseSize), Eq("11"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().ResponseFlags), Eq("-"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().RequestSize), Eq("10"))); HttpTracerUtility::finalizeDownstreamSpan(span, nullptr, nullptr, nullptr, stream_info, config); } TEST_F(HttpConnManFinalizerImplTest, SpanOptionalHeaders) { Http::TestHeaderMapImpl request_headers{{"x-request-id", "id"}, {":path", "/test"}, {":method", "GET"}, {"x-forwarded-proto", "https"}}; Http::TestHeaderMapImpl response_headers; Http::TestHeaderMapImpl response_trailers; absl::optional<Http::Protocol> protocol = Http::Protocol::Http10; EXPECT_CALL(stream_info, bytesReceived()).WillOnce(Return(10)); EXPECT_CALL(stream_info, protocol()).WillRepeatedly(ReturnPointee(&protocol)); // Check that span is populated correctly. EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().GuidXRequestId), Eq("id"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpUrl), Eq("https:///test"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpMethod), Eq("GET"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().UserAgent), Eq("-"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpProtocol), Eq("HTTP/1.0"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().DownstreamCluster), Eq("-"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().RequestSize), Eq("10"))); absl::optional<uint32_t> response_code; EXPECT_CALL(stream_info, responseCode()).WillRepeatedly(ReturnPointee(&response_code)); EXPECT_CALL(stream_info, bytesSent()).WillOnce(Return(100)); EXPECT_CALL(stream_info, upstreamHost()).WillOnce(Return(nullptr)); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpStatusCode), Eq("0"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().Error), Eq(Tracing::Tags::get().True))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().ResponseSize), Eq("100"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().ResponseFlags), Eq("-"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().Component), Eq(Tracing::Tags::get().Proxy))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().UpstreamCluster), _)).Times(0); HttpTracerUtility::finalizeDownstreamSpan(span, &request_headers, &response_headers, &response_trailers, stream_info, config); } TEST_F(HttpConnManFinalizerImplTest, SpanCustomTags) { TestEnvironment::setEnvVar("E_CC", "c", 1); Http::TestHeaderMapImpl request_headers{{"x-request-id", "id"}, {":path", "/test"}, {":method", "GET"}, {"x-forwarded-proto", "https"}, {"x-bb", "b"}}; ProtobufWkt::Struct fake_struct; std::string yaml = R"EOF( ree: foo: bar nuu: 1 boo: true poo: false stt: { some: thing } lii: [ something ] emp: "")EOF"; TestUtility::loadFromYaml(yaml, fake_struct); (*stream_info.metadata_.mutable_filter_metadata())["m.req"].MergeFrom(fake_struct); NiceMock<Router::MockRouteEntry> route_entry; EXPECT_CALL(stream_info, routeEntry()).WillRepeatedly(Return(&route_entry)); (*route_entry.metadata_.mutable_filter_metadata())["m.rot"].MergeFrom(fake_struct); std::shared_ptr<envoy::api::v2::core::Metadata> host_metadata = std::make_shared<envoy::api::v2::core::Metadata>(); (*host_metadata->mutable_filter_metadata())["m.host"].MergeFrom(fake_struct); (*stream_info.host_->cluster_.metadata_.mutable_filter_metadata())["m.cluster"].MergeFrom( fake_struct); absl::optional<Http::Protocol> protocol = Http::Protocol::Http10; EXPECT_CALL(stream_info, bytesReceived()).WillOnce(Return(10)); EXPECT_CALL(stream_info, protocol()).WillRepeatedly(ReturnPointee(&protocol)); absl::optional<uint32_t> response_code; EXPECT_CALL(stream_info, responseCode()).WillRepeatedly(ReturnPointee(&response_code)); EXPECT_CALL(stream_info, bytesSent()).WillOnce(Return(100)); EXPECT_CALL(*stream_info.host_, metadata()).WillRepeatedly(Return(host_metadata)); EXPECT_CALL(config, customTags()); EXPECT_CALL(span, setTag(_, _)).Times(testing::AnyNumber()); expectSetCustomTags( {{"{ tag: aa, literal: { value: a } }", true, "a"}, {"{ tag: bb-1, request_header: { name: X-Bb, default_value: _b } }", true, "b"}, {"{ tag: bb-2, request_header: { name: X-Bb-Not-Found, default_value: b2 } }", true, "b2"}, {"{ tag: bb-3, request_header: { name: X-Bb-Not-Found } }", false, ""}, {"{ tag: cc-1, environment: { name: E_CC } }", true, "c"}, {"{ tag: cc-1-a, environment: { name: E_CC, default_value: _c } }", true, "c"}, {"{ tag: cc-2, environment: { name: E_CC_NOT_FOUND, default_value: c2 } }", true, "c2"}, {"{ tag: cc-3, environment: { name: E_CC_NOT_FOUND} }", false, ""}, {R"EOF( tag: dd-1, metadata: kind: { request: {} } metadata_key: { key: m.req, path: [ { key: ree }, { key: foo } ] })EOF", true, "bar"}, {R"EOF( tag: dd-2, metadata: kind: { request: {} } metadata_key: { key: m.req, path: [ { key: not-found } ] } default_value: d2)EOF", true, "d2"}, {R"EOF( tag: dd-3, metadata: kind: { request: {} } metadata_key: { key: m.req, path: [ { key: not-found } ] })EOF", false, ""}, {R"EOF( tag: dd-4, metadata: kind: { request: {} } metadata_key: { key: m.req, path: [ { key: ree }, { key: nuu } ] } default_value: _d)EOF", true, "1"}, {R"EOF( tag: dd-5, metadata: kind: { route: {} } metadata_key: { key: m.rot, path: [ { key: ree }, { key: boo } ] })EOF", true, "true"}, {R"EOF( tag: dd-6, metadata: kind: { route: {} } metadata_key: { key: m.rot, path: [ { key: ree }, { key: poo } ] })EOF", true, "false"}, {R"EOF( tag: dd-7, metadata: kind: { cluster: {} } metadata_key: { key: m.cluster, path: [ { key: ree }, { key: emp } ] } default_value: _d)EOF", true, ""}, {R"EOF( tag: dd-8, metadata: kind: { cluster: {} } metadata_key: { key: m.cluster, path: [ { key: ree }, { key: lii } ] } default_value: _d)EOF", true, "[\"something\"]"}, {R"EOF( tag: dd-9, metadata: kind: { host: {} } metadata_key: { key: m.host, path: [ { key: ree }, { key: stt } ] })EOF", true, R"({"some":"thing"})"}, {R"EOF( tag: dd-10, metadata: kind: { host: {} } metadata_key: { key: m.host, path: [ { key: not-found } ] })EOF", false, ""}}); HttpTracerUtility::finalizeDownstreamSpan(span, &request_headers, nullptr, nullptr, stream_info, config); } TEST_F(HttpConnManFinalizerImplTest, SpanPopulatedFailureResponse) { Http::TestHeaderMapImpl request_headers{{"x-request-id", "id"}, {":path", "/test"}, {":method", "GET"}, {"x-forwarded-proto", "http"}}; Http::TestHeaderMapImpl response_headers; Http::TestHeaderMapImpl response_trailers; request_headers.setHost("api"); request_headers.setUserAgent("agent"); request_headers.setEnvoyDownstreamServiceCluster("downstream_cluster"); request_headers.setClientTraceId("client_trace_id"); absl::optional<Http::Protocol> protocol = Http::Protocol::Http10; EXPECT_CALL(stream_info, protocol()).WillRepeatedly(ReturnPointee(&protocol)); EXPECT_CALL(stream_info, bytesReceived()).WillOnce(Return(10)); // Check that span is populated correctly. EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().GuidXRequestId), Eq("id"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpUrl), Eq("http://api/test"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpMethod), Eq("GET"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().UserAgent), Eq("agent"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpProtocol), Eq("HTTP/1.0"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().DownstreamCluster), Eq("downstream_cluster"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().RequestSize), Eq("10"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().GuidXClientTraceId), Eq("client_trace_id"))); EXPECT_CALL(config, verbose).WillOnce(Return(false)); EXPECT_CALL(config, maxPathTagLength).WillOnce(Return(256)); absl::optional<uint32_t> response_code(503); EXPECT_CALL(stream_info, responseCode()).WillRepeatedly(ReturnPointee(&response_code)); EXPECT_CALL(stream_info, bytesSent()).WillOnce(Return(100)); ON_CALL(stream_info, hasResponseFlag(StreamInfo::ResponseFlag::UpstreamRequestTimeout)) .WillByDefault(Return(true)); EXPECT_CALL(stream_info, upstreamHost()).WillOnce(Return(nullptr)); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().Error), Eq(Tracing::Tags::get().True))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpStatusCode), Eq("503"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().ResponseSize), Eq("100"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().ResponseFlags), Eq("UT"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().Component), Eq(Tracing::Tags::get().Proxy))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().UpstreamCluster), _)).Times(0); HttpTracerUtility::finalizeDownstreamSpan(span, &request_headers, &response_headers, &response_trailers, stream_info, config); } TEST_F(HttpConnManFinalizerImplTest, GrpcOkStatus) { const std::string path_prefix = "http://"; Http::TestHeaderMapImpl request_headers{{":method", "POST"}, {":scheme", "http"}, {":path", "/pb.Foo/Bar"}, {":authority", "example.com:80"}, {"content-type", "application/grpc"}, {"te", "trailers"}}; Http::TestHeaderMapImpl response_headers{{":status", "200"}, {"content-type", "application/grpc"}}; Http::TestHeaderMapImpl response_trailers{{"grpc-status", "0"}, {"grpc-message", ""}}; absl::optional<Http::Protocol> protocol = Http::Protocol::Http2; absl::optional<uint32_t> response_code(200); EXPECT_CALL(stream_info, responseCode()).WillRepeatedly(ReturnPointee(&response_code)); EXPECT_CALL(stream_info, bytesReceived()).WillOnce(Return(10)); EXPECT_CALL(stream_info, bytesSent()).WillOnce(Return(11)); EXPECT_CALL(stream_info, protocol()).WillRepeatedly(ReturnPointee(&protocol)); EXPECT_CALL(span, setTag(_, _)).Times(testing::AnyNumber()); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpMethod), Eq("POST"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpProtocol), Eq("HTTP/2"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpStatusCode), Eq("200"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().GrpcStatusCode), Eq("0"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().GrpcMessage), Eq(""))); HttpTracerUtility::finalizeDownstreamSpan(span, &request_headers, &response_headers, &response_trailers, stream_info, config); } TEST_F(HttpConnManFinalizerImplTest, GrpcErrorTag) { const std::string path_prefix = "http://"; Http::TestHeaderMapImpl request_headers{{":method", "POST"}, {":scheme", "http"}, {":path", "/pb.Foo/Bar"}, {":authority", "example.com:80"}, {"content-type", "application/grpc"}, {"te", "trailers"}}; Http::TestHeaderMapImpl response_headers{{":status", "200"}, {"content-type", "application/grpc"}}; Http::TestHeaderMapImpl response_trailers{{"grpc-status", "7"}, {"grpc-message", "permission denied"}}; absl::optional<Http::Protocol> protocol = Http::Protocol::Http2; absl::optional<uint32_t> response_code(200); EXPECT_CALL(stream_info, responseCode()).WillRepeatedly(ReturnPointee(&response_code)); EXPECT_CALL(stream_info, bytesReceived()).WillOnce(Return(10)); EXPECT_CALL(stream_info, bytesSent()).WillOnce(Return(11)); EXPECT_CALL(stream_info, protocol()).WillRepeatedly(ReturnPointee(&protocol)); EXPECT_CALL(span, setTag(_, _)).Times(testing::AnyNumber()); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().Error), Eq(Tracing::Tags::get().True))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpMethod), Eq("POST"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpProtocol), Eq("HTTP/2"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpStatusCode), Eq("200"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().GrpcStatusCode), Eq("7"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().GrpcMessage), Eq("permission denied"))); HttpTracerUtility::finalizeDownstreamSpan(span, &request_headers, &response_headers, &response_trailers, stream_info, config); } TEST_F(HttpConnManFinalizerImplTest, GrpcTrailersOnly) { const std::string path_prefix = "http://"; Http::TestHeaderMapImpl request_headers{{":method", "POST"}, {":scheme", "http"}, {":path", "/pb.Foo/Bar"}, {":authority", "example.com:80"}, {"content-type", "application/grpc"}, {"te", "trailers"}}; Http::TestHeaderMapImpl response_headers{{":status", "200"}, {"content-type", "application/grpc"}, {"grpc-status", "7"}, {"grpc-message", "permission denied"}}; Http::TestHeaderMapImpl response_trailers; absl::optional<Http::Protocol> protocol = Http::Protocol::Http2; absl::optional<uint32_t> response_code(200); EXPECT_CALL(stream_info, responseCode()).WillRepeatedly(ReturnPointee(&response_code)); EXPECT_CALL(stream_info, bytesReceived()).WillOnce(Return(10)); EXPECT_CALL(stream_info, bytesSent()).WillOnce(Return(11)); EXPECT_CALL(stream_info, protocol()).WillRepeatedly(ReturnPointee(&protocol)); EXPECT_CALL(span, setTag(_, _)).Times(testing::AnyNumber()); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().Error), Eq(Tracing::Tags::get().True))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpMethod), Eq("POST"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpProtocol), Eq("HTTP/2"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().HttpStatusCode), Eq("200"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().GrpcStatusCode), Eq("7"))); EXPECT_CALL(span, setTag(Eq(Tracing::Tags::get().GrpcMessage), Eq("permission denied"))); HttpTracerUtility::finalizeDownstreamSpan(span, &request_headers, &response_headers, &response_trailers, stream_info, config); } TEST(HttpTracerUtilityTest, operationTypeToString) { EXPECT_EQ("ingress", HttpTracerUtility::toString(OperationName::Ingress)); EXPECT_EQ("egress", HttpTracerUtility::toString(OperationName::Egress)); } TEST(HttpNullTracerTest, BasicFunctionality) { HttpNullTracer null_tracer; MockConfig config; StreamInfo::MockStreamInfo stream_info; Http::TestHeaderMapImpl request_headers; Http::TestHeaderMapImpl response_headers; Http::TestHeaderMapImpl response_trailers; SpanPtr span_ptr = null_tracer.startSpan(config, request_headers, stream_info, {Reason::Sampling, true}); EXPECT_TRUE(dynamic_cast<NullSpan*>(span_ptr.get()) != nullptr); span_ptr->setOperation("foo"); span_ptr->setTag("foo", "bar"); span_ptr->injectContext(request_headers); EXPECT_NE(nullptr, span_ptr->spawnChild(config, "foo", SystemTime())); } class HttpTracerImplTest : public testing::Test { public: HttpTracerImplTest() { driver_ = new MockDriver(); DriverPtr driver_ptr(driver_); tracer_ = std::make_unique<HttpTracerImpl>(std::move(driver_ptr), local_info_); } Http::TestHeaderMapImpl request_headers_{ {":path", "/"}, {":method", "GET"}, {"x-request-id", "foo"}, {":authority", "test"}}; Http::TestHeaderMapImpl response_headers; Http::TestHeaderMapImpl response_trailers; StreamInfo::MockStreamInfo stream_info_; NiceMock<LocalInfo::MockLocalInfo> local_info_; MockConfig config_; MockDriver* driver_; HttpTracerPtr tracer_; }; TEST_F(HttpTracerImplTest, BasicFunctionalityNullSpan) { EXPECT_CALL(config_, operationName()).Times(2); EXPECT_CALL(stream_info_, startTime()); const std::string operation_name = "ingress"; EXPECT_CALL(*driver_, startSpan_(_, _, operation_name, stream_info_.start_time_, _)) .WillOnce(Return(nullptr)); tracer_->startSpan(config_, request_headers_, stream_info_, {Reason::Sampling, true}); } TEST_F(HttpTracerImplTest, BasicFunctionalityNodeSet) { EXPECT_CALL(stream_info_, startTime()); EXPECT_CALL(local_info_, nodeName()); EXPECT_CALL(config_, operationName()).Times(2).WillRepeatedly(Return(OperationName::Egress)); NiceMock<MockSpan>* span = new NiceMock<MockSpan>(); const std::string operation_name = "egress test"; EXPECT_CALL(*driver_, startSpan_(_, _, operation_name, stream_info_.start_time_, _)) .WillOnce(Return(span)); EXPECT_CALL(*span, setTag(_, _)).Times(testing::AnyNumber()); EXPECT_CALL(*span, setTag(Eq(Tracing::Tags::get().NodeId), Eq("node_name"))); tracer_->startSpan(config_, request_headers_, stream_info_, {Reason::Sampling, true}); } } // namespace } // namespace Tracing } // namespace Envoy
; A134489: a(n) = Fibonacci(5*n + 2). ; Submitted by Jamie Morken(s1) ; 1,13,144,1597,17711,196418,2178309,24157817,267914296,2971215073,32951280099,365435296162,4052739537881,44945570212853,498454011879264,5527939700884757,61305790721611591,679891637638612258 mul $0,5 mov $1,1 mov $2,1 lpb $0 sub $0,2 add $1,$2 add $2,$1 lpe lpb $0 div $0,4 add $2,$1 lpe mov $0,$2
;=============================================================================== ; Copyright 2014-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. ;=============================================================================== ; ; ; Purpose: Cryptography Primitive. ; Reduction over AES-GCM polynomial (x^128 + x^7 + x^2 + x + 1) ; ; Content: ; GCMreduce() ; .686P .387 .XMM .MODEL FLAT,C INCLUDE asmdefs.inc INCLUDE ia_emm.inc IF _IPP GE _IPP_P8 my_emulator = 0; set 1 for emulation include emulator.inc IFDEF IPP_PIC LD_ADDR MACRO reg:REQ, addr:REQ LOCAL LABEL call LABEL LABEL: pop reg sub reg, LABEL-addr ENDM ELSE LD_ADDR MACRO reg:REQ, addr:REQ lea reg, addr ENDM ENDIF IPPCODE SEGMENT 'CODE' ALIGN (IPP_ALIGN_FACTOR) ALIGN IPP_ALIGN_FACTOR CONST_TABLE: _u128_str DB 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 u128_str equ [eax+(_u128_str - CONST_TABLE)] ;************************************************************* ;* void GCMmul_avx(const Ipp8u* pA, Ipp8u* pB) ;************************************************************* ;; ;; Lib = G9 ;; ;; Caller = ippsRijndael128GCMProcessIV ;; Caller = ippsRijndael128GCMProcessAAD ;; Caller = ippsRijndael128GCMEncrypt ;; Caller = ippsRijndael128GCMDecrypt ;; Caller = ippsRijndael128GCMGetTag ;; ALIGN IPP_ALIGN_FACTOR IPPASM GCMmul_avx PROC NEAR C PUBLIC \ USES esi edi,\ pSrc: PTR BYTE,\ ; const multiplier pDst: PTR BYTE ; multiplier/result mov edi, pDst mov esi, pSrc LD_ADDR eax, CONST_TABLE movdqu xmm1, oword ptr[edi] ; multiplicand and reduced result movdqu xmm0, oword ptr[esi] ; const multiplicand ;pshufb xmm1, oword ptr u128_str; convert 2-nd multiplier my_pshufbM xmm1, oword ptr u128_str; convert 2-nd multiplier ; ; carry-less multiplication (caratsuba) ; pshufd xmm4, xmm0, 01001110b ; xmm4 = {a[1]:a[0]} pshufd xmm5, xmm1, 01001110b ; xmm5 = {b[1]:b[0]} pxor xmm4, xmm0 pxor xmm5, xmm1 ;pclmulqdq xmm4, xmm5, 00h ; xmm4={xx:a[1]+a[0]}{yy:b[1]+b[0]} my_pclmulqdq xmm4, xmm5, 00h ; xmm4={xx:a[1]+a[0]}{yy:b[1]+b[0]} movdqu xmm3, xmm0 ;pclmulqdq xmm3, xmm1, 00h ; xmm3=a0*b0 my_pclmulqdq xmm3, xmm1, 00h ; xmm3=a0*b0 movdqu xmm6, xmm0 ;pclmulqdq xmm6, xmm1, 11h ; xmm6=a1*b1 my_pclmulqdq xmm6, xmm1, 11h ; xmm6=a1*b1 pxor xmm5, xmm5 pxor xmm4, xmm3 ; xmm4= a1*b0+a0*b1 pxor xmm4, xmm6 ;palignr xmm5, xmm4, 8 my_palignr xmm5, xmm4, 8 pslldq xmm4, 8 pxor xmm3, xmm4 pxor xmm6, xmm5 ; register pair <xmm6:xmm3> holds the result of ; the carry-less multiplication of xmm0 by xmm1 ; we shift the result of the multiplication by one bit position to the left ; cope for the fact that bits are reversed movdqu xmm4, xmm3 movdqu xmm5, xmm6 pslld xmm3, 1 pslld xmm6, 1 psrld xmm4, 31 psrld xmm5, 31 ;palignr xmm5,xmm4, 12 my_palignr xmm5,xmm4, 12 pslldq xmm4, 4 por xmm3, xmm4 por xmm6, xmm5 ;first phase of the reduction movdqu xmm0, xmm3 movdqu xmm1, xmm3 movdqu xmm2, xmm3 ;move xmm3 into xmm7, xmm8, xmm9 in order to perform the three shifts independently pslld xmm0, 31 ; packed right shifting << 31 pslld xmm1, 30 ; packed right shifting shift << 30 pslld xmm2, 25 ; packed right shifting shift << 25 pxor xmm0, xmm1 ;xor the shifted versions pxor xmm0, xmm2 movdqu xmm1, xmm0 ; xmm1 uses on the reduction second phase pslldq xmm0, 12 pxor xmm3, xmm0 ;first phase of the reduction complete ;second phase of the reduction movdqu xmm2,xmm3 ; make 3 copies of xmm3 (in in xmm2, xmm4, xmm5) for doing three shift operations movdqu xmm4,xmm3 movdqu xmm5,xmm3 psrldq xmm1, 4 psrld xmm2,1 ; packed left shifting >> 1 psrld xmm4,2 ; packed left shifting >> 2 psrld xmm5,7 ; packed left shifting >> 7 pxor xmm2,xmm4 ; xor the shifted versions pxor xmm2,xmm5 pxor xmm2,xmm1 pxor xmm3, xmm2 pxor xmm6, xmm3 ;the result is in xmm6 ;pshufb xmm6, oword ptr u128_str ; convert result back my_pshufbM xmm6, oword ptr u128_str ; convert result back movdqu oword ptr[edi], xmm6 ret IPPASM GCMmul_avx endp ENDIF END
; A059165: a(n) = (n+1)*2^(n+4). ; 0,16,64,192,512,1280,3072,7168,16384,36864,81920,180224,393216,851968,1835008,3932160,8388608,17825792,37748736,79691776,167772160,352321536,738197504,1543503872,3221225472,6710886400,13958643712,28991029248,60129542144,124554051584,257698037760,532575944704,1099511627776,2267742732288,4672924418048,9620726743040,19791209299968,40681930227712,83562883710976,171523813933056,351843720888320,721279627821056,1477743627730944,3025855999639552,6192449487634432,12666373951979520,25895697857380352,52917295621603328,108086391056891904,220676381741154304,450359962737049600,918734323983581184,1873497444986126336,3819052484010180608,7782220156096217088,15852670688344145920,32281802128991715328,65716525762590277632,133738894534394249216,272089475087215886336,553402322211286548480,1125251388496282648576,2287396265139984400384,4648579506574807007232,9444732965739290427392,19184613836657933680640,38959523483674573012992,79099638588066557329408,160560460417567937265664,325843287318005519745024,661131307601750329917440,1341152081134979240689664,2720083094132915643088896,5515724051991745609596928,11182563831435319866032128,22667359117774297025740800,45939181145355908638834688,93087288110326446452375552,188592427859882151254163456,382020558998222819207151616,773712524553362671811952640,1566767862220559410419204096,3172221350668786954429005824,6421813953792910176039206912,12998370412496492886440804352,26306225834814330841606389760,53231421689271351820662341632,107700783417828083916223807488,217877446914226928382245863424,440706653985595377864088223744,891316828285473797927369441280,1802440697199513680253124870144,3644495475656159529303021715456,7368219113826583396199587381248,14894894552681695467586262663168,30106701755420448285546701127680,60847228810955011271841753858048,122962108222138251945180210921472,248459517644732962693353828253696,501989637690378842992694469328896 mov $1,2 pow $1,$0 mul $0,8 mul $1,$0 mov $0,$1
// Copyright 2013 The Emscripten Authors. All rights reserved. // Emscripten is available under two separate licenses, the MIT license and the // University of Illinois/NCSA Open Source License. Both these licenses can be // found in the LICENSE file. #include <stdio.h> #include <emscripten.h> void later(void *) {} int main() { #if FIRST FILE *f = fopen("waka.txt", "w"); fputc('a', f); fputc('z', f); fclose(f); EM_ASM( FS.saveFilesToDB(['waka.txt', 'moar.txt'], function() { out('save ok'); var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://localhost:8888/report_result?1'); xhr.send(); setTimeout(function() { window.close() }, 1000); }, function(e) { abort('saving should succeed ' + e); }); ); #else EM_ASM( FS.loadFilesFromDB(['waka.txt', 'moar.txt'], function() { function stringy(arr) { return Array.prototype.map.call(arr, function(x) { return String.fromCharCode(x) }).join(""); } assert(stringy(FS.analyzePath('waka.txt').object.contents) == 'az'); var secret = stringy(FS.analyzePath('moar.txt').object.contents); out('load: ' + secret); var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://localhost:8888/report_result?' + secret); xhr.send(); setTimeout(function() { window.close() }, 1000); }, function() { abort('loading should succeed'); }); ); #endif emscripten_async_call(later, NULL, 100); // keep runtime alive return 0; }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r9 push %rbx push %rcx push %rdi push %rsi lea addresses_normal_ht+0xd5c3, %rsi lea addresses_normal_ht+0x1ae7d, %rdi nop nop nop lfence mov $67, %rcx rep movsw nop nop nop cmp $13035, %rbx lea addresses_UC_ht+0x1adfd, %r10 clflush (%r10) nop nop nop nop nop and $4893, %r9 mov $0x6162636465666768, %r11 movq %r11, %xmm5 movups %xmm5, (%r10) nop nop nop nop nop cmp $24212, %rbx lea addresses_D_ht+0x1515d, %r10 clflush (%r10) inc %r9 vmovups (%r10), %ymm2 vextracti128 $1, %ymm2, %xmm2 vpextrq $0, %xmm2, %rdi add $2287, %r9 lea addresses_UC_ht+0x7dfd, %rsi lea addresses_normal_ht+0x1b5bd, %rdi nop nop nop nop dec %r12 mov $79, %rcx rep movsq mfence lea addresses_WC_ht+0xc37d, %rsi nop nop nop nop nop xor $34469, %r12 mov $0x6162636465666768, %r10 movq %r10, (%rsi) nop nop nop nop nop cmp %rbx, %rbx lea addresses_normal_ht+0xe67d, %rdi nop nop nop nop dec %rsi mov $0x6162636465666768, %r11 movq %r11, %xmm6 movups %xmm6, (%rdi) xor %r11, %r11 lea addresses_D_ht+0x15341, %r10 nop nop nop nop nop cmp %rdi, %rdi mov $0x6162636465666768, %r11 movq %r11, %xmm4 vmovups %ymm4, (%r10) nop nop nop nop nop inc %r9 lea addresses_WT_ht+0x4a7d, %rsi lea addresses_A_ht+0x1af1d, %rdi nop nop add %r10, %r10 mov $121, %rcx rep movsq nop nop nop nop sub %r9, %r9 lea addresses_A_ht+0x15cab, %r9 nop dec %r11 movups (%r9), %xmm2 vpextrq $0, %xmm2, %rcx nop nop nop nop and $65246, %r11 pop %rsi pop %rdi pop %rcx pop %rbx pop %r9 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r15 push %r8 push %r9 push %rbp push %rcx push %rsi // Store lea addresses_D+0x1cead, %rsi clflush (%rsi) dec %rcx movw $0x5152, (%rsi) nop nop nop nop nop add $60856, %r15 // Store mov $0x1f4e5100000008dd, %r13 nop nop nop nop cmp %rsi, %rsi mov $0x5152535455565758, %r15 movq %r15, %xmm7 movntdq %xmm7, (%r13) and %rcx, %rcx // Store lea addresses_normal+0x12ffd, %r9 nop nop nop and $56975, %r15 mov $0x5152535455565758, %rcx movq %rcx, %xmm0 vmovups %ymm0, (%r9) nop nop nop and $28007, %r9 // Store lea addresses_A+0x14ffd, %rsi nop and $14259, %rcx movb $0x51, (%rsi) nop nop nop dec %r13 // Store lea addresses_D+0x1f5, %r9 clflush (%r9) inc %rbp movb $0x51, (%r9) nop nop nop add $42589, %rbp // Store lea addresses_US+0x1542, %r8 nop nop nop nop nop inc %rbp mov $0x5152535455565758, %r9 movq %r9, (%r8) cmp %r15, %r15 // Store mov $0x389bfa000000067d, %rbp nop nop nop nop nop inc %r13 mov $0x5152535455565758, %r15 movq %r15, %xmm0 vmovups %ymm0, (%rbp) nop nop add %r8, %r8 // Store lea addresses_normal+0x9dbd, %r9 add %r15, %r15 movw $0x5152, (%r9) nop nop nop nop nop cmp $49143, %r9 // Faulty Load mov $0x6d66e5000000027d, %r15 nop nop add %rbp, %rbp vmovups (%r15), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $1, %xmm3, %r13 lea oracles, %rcx and $0xff, %r13 shlq $12, %r13 mov (%rcx,%r13,1), %r13 pop %rsi pop %rcx pop %rbp pop %r9 pop %r8 pop %r15 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_NC', 'same': False, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 2, 'congruent': 4, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'dst': {'type': 'addresses_NC', 'same': False, 'size': 16, 'congruent': 3, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal', 'same': False, 'size': 32, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_US', 'same': False, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_NC', 'same': False, 'size': 32, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal', 'same': False, 'size': 2, 'congruent': 5, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_NC', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 16, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 32, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': True}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 16, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 32, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 16, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'00': 1} 00 */
// -*- C++ -*- // // Package: SiPixelPhase1GeometryDebug // Class : SiPixelPhase1GeometryDebug // // Original Author: Marcel Schneider #include "DQM/SiPixelPhase1Common/interface/SiPixelPhase1Base.h" #include "FWCore/Framework/interface/MakerMacros.h" // This small plugin plots out varois geometry quantities against each other. // This is useful to see where a specific module or ROC ends up in a 2D map. class SiPixelPhase1GeometryDebug : public SiPixelPhase1Base { enum { DETID, LADBLD, ROC, FED }; public: explicit SiPixelPhase1GeometryDebug(const edm::ParameterSet& conf) : SiPixelPhase1Base(conf) { } void analyze(const edm::Event& iEvent, const edm::EventSetup&) override { auto& all = geometryInterface.allModules(); GeometryInterface::Column ladder = geometryInterface.intern("PXLadder"); GeometryInterface::Column blade = geometryInterface.intern("PXBlade"); GeometryInterface::Column roc = geometryInterface.intern("ROC"); GeometryInterface::Column fed = geometryInterface.intern("FED"); for (auto iq : all) { auto rocno = geometryInterface.extract(roc, iq); auto fedno = geometryInterface.extract(fed, iq); auto detid = iq.sourceModule.rawId(); auto ladbld = geometryInterface.extract(ladder, iq); if (ladbld.second == GeometryInterface::UNDEFINED) ladbld = geometryInterface.extract(blade, iq); histo[DETID ].fill((float) detid, iq.sourceModule, &iEvent, iq.col, iq.row); histo[LADBLD].fill((float) ladbld.second, iq.sourceModule, &iEvent, iq.col, iq.row); histo[ROC ].fill((float) rocno.second, iq.sourceModule, &iEvent, iq.col, iq.row); histo[FED ].fill((float) fedno.second, iq.sourceModule, &iEvent, iq.col, iq.row); } } }; DEFINE_FWK_MODULE(SiPixelPhase1GeometryDebug);
; A027983: T(n,n+1) + T(n,n+2) + ... + T(n,2n), T given by A027960. ; 1,5,14,35,81,180,389,825,1726,3575,7349,15020,30561,61965,125294,252795,509161,1024100,2057549,4130225,8284926,16609455,33282989,66669660,133507081,267285605,535010414,1070731475,2142612801 mov $1,1 mov $2,4 mov $4,1 lpb $0 sub $0,1 add $5,$2 add $1,$5 mul $2,2 mov $3,$5 mov $5,$4 add $4,$3 lpe mov $0,$1
#include "test.hpp" #include <limits> #include <string> #include <math.h> #include <string.h> #include <limits.h> using namespace pugi; TEST_XML(dom_attr_assign, "<node/>") { xml_node node = doc.child(STR("node")); node.append_attribute(STR("attr1")) = STR("v1"); xml_attribute() = STR("v1"); node.append_attribute(STR("attr2")) = -2147483647; node.append_attribute(STR("attr3")) = -2147483647 - 1; xml_attribute() = -2147483647 - 1; node.append_attribute(STR("attr4")) = 4294967295u; node.append_attribute(STR("attr5")) = 4294967294u; xml_attribute() = 4294967295u; node.append_attribute(STR("attr6")) = 0.5; xml_attribute() = 0.5; node.append_attribute(STR("attr7")) = 0.25f; xml_attribute() = 0.25f; node.append_attribute(STR("attr8")) = true; xml_attribute() = true; CHECK_NODE(node, STR("<node attr1=\"v1\" attr2=\"-2147483647\" attr3=\"-2147483648\" attr4=\"4294967295\" attr5=\"4294967294\" attr6=\"0.5\" attr7=\"0.25\" attr8=\"true\"/>")); } TEST_XML(dom_attr_set_name, "<node attr='value' />") { xml_attribute attr = doc.child(STR("node")).attribute(STR("attr")); CHECK(attr.set_name(STR("n"))); CHECK(!xml_attribute().set_name(STR("n"))); CHECK_NODE(doc, STR("<node n=\"value\"/>")); } TEST_XML(dom_attr_set_value, "<node/>") { xml_node node = doc.child(STR("node")); CHECK(node.append_attribute(STR("attr1")).set_value(STR("v1"))); CHECK(!xml_attribute().set_value(STR("v1"))); CHECK(node.append_attribute(STR("attr2")).set_value(-2147483647)); CHECK(node.append_attribute(STR("attr3")).set_value(-2147483647 - 1)); CHECK(!xml_attribute().set_value(-2147483647)); CHECK(node.append_attribute(STR("attr4")).set_value(4294967295u)); CHECK(node.append_attribute(STR("attr5")).set_value(4294967294u)); CHECK(!xml_attribute().set_value(4294967295u)); CHECK(node.append_attribute(STR("attr6")).set_value(0.5)); CHECK(!xml_attribute().set_value(0.5)); CHECK(node.append_attribute(STR("attr7")).set_value(0.25f)); CHECK(!xml_attribute().set_value(0.25f)); CHECK(node.append_attribute(STR("attr8")).set_value(true)); CHECK(!xml_attribute().set_value(true)); CHECK_NODE(node, STR("<node attr1=\"v1\" attr2=\"-2147483647\" attr3=\"-2147483648\" attr4=\"4294967295\" attr5=\"4294967294\" attr6=\"0.5\" attr7=\"0.25\" attr8=\"true\"/>")); } #if LONG_MAX > 2147483647 TEST_XML(dom_attr_assign_long, "<node/>") { xml_node node = doc.child(STR("node")); node.append_attribute(STR("attr1")) = -9223372036854775807l; node.append_attribute(STR("attr2")) = -9223372036854775807l - 1; xml_attribute() = -9223372036854775807l - 1; node.append_attribute(STR("attr3")) = 18446744073709551615ul; node.append_attribute(STR("attr4")) = 18446744073709551614ul; xml_attribute() = 18446744073709551615ul; CHECK_NODE(node, STR("<node attr1=\"-9223372036854775807\" attr2=\"-9223372036854775808\" attr3=\"18446744073709551615\" attr4=\"18446744073709551614\"/>")); } TEST_XML(dom_attr_set_value_long, "<node/>") { xml_node node = doc.child(STR("node")); CHECK(node.append_attribute(STR("attr1")).set_value(-9223372036854775807l)); CHECK(node.append_attribute(STR("attr2")).set_value(-9223372036854775807l - 1)); CHECK(!xml_attribute().set_value(-9223372036854775807l - 1)); CHECK(node.append_attribute(STR("attr3")).set_value(18446744073709551615ul)); CHECK(node.append_attribute(STR("attr4")).set_value(18446744073709551614ul)); CHECK(!xml_attribute().set_value(18446744073709551615ul)); CHECK_NODE(node, STR("<node attr1=\"-9223372036854775807\" attr2=\"-9223372036854775808\" attr3=\"18446744073709551615\" attr4=\"18446744073709551614\"/>")); } #else TEST_XML(dom_attr_assign_long, "<node/>") { xml_node node = doc.child(STR("node")); node.append_attribute(STR("attr1")) = -2147483647l; node.append_attribute(STR("attr2")) = -2147483647l - 1; xml_attribute() = -2147483647l - 1; node.append_attribute(STR("attr3")) = 4294967295ul; node.append_attribute(STR("attr4")) = 4294967294ul; xml_attribute() = 4294967295ul; CHECK_NODE(node, STR("<node attr1=\"-2147483647\" attr2=\"-2147483648\" attr3=\"4294967295\" attr4=\"4294967294\"/>")); } TEST_XML(dom_attr_set_value_long, "<node/>") { xml_node node = doc.child(STR("node")); CHECK(node.append_attribute(STR("attr1")).set_value(-2147483647l)); CHECK(node.append_attribute(STR("attr2")).set_value(-2147483647l - 1)); CHECK(!xml_attribute().set_value(-2147483647l - 1)); CHECK(node.append_attribute(STR("attr3")).set_value(4294967295ul)); CHECK(node.append_attribute(STR("attr4")).set_value(4294967294ul)); CHECK(!xml_attribute().set_value(4294967295ul)); CHECK_NODE(node, STR("<node attr1=\"-2147483647\" attr2=\"-2147483648\" attr3=\"4294967295\" attr4=\"4294967294\"/>")); } #endif #ifdef PUGIXML_HAS_LONG_LONG TEST_XML(dom_attr_assign_llong, "<node/>") { xml_node node = doc.child(STR("node")); node.append_attribute(STR("attr1")) = -9223372036854775807ll; node.append_attribute(STR("attr2")) = -9223372036854775807ll - 1; xml_attribute() = -9223372036854775807ll - 1; node.append_attribute(STR("attr3")) = 18446744073709551615ull; node.append_attribute(STR("attr4")) = 18446744073709551614ull; xml_attribute() = 18446744073709551615ull; CHECK_NODE(node, STR("<node attr1=\"-9223372036854775807\" attr2=\"-9223372036854775808\" attr3=\"18446744073709551615\" attr4=\"18446744073709551614\"/>")); } TEST_XML(dom_attr_set_value_llong, "<node/>") { xml_node node = doc.child(STR("node")); CHECK(node.append_attribute(STR("attr1")).set_value(-9223372036854775807ll)); CHECK(node.append_attribute(STR("attr2")).set_value(-9223372036854775807ll - 1)); CHECK(!xml_attribute().set_value(-9223372036854775807ll - 1)); CHECK(node.append_attribute(STR("attr3")).set_value(18446744073709551615ull)); CHECK(node.append_attribute(STR("attr4")).set_value(18446744073709551614ull)); CHECK(!xml_attribute().set_value(18446744073709551615ull)); CHECK_NODE(node, STR("<node attr1=\"-9223372036854775807\" attr2=\"-9223372036854775808\" attr3=\"18446744073709551615\" attr4=\"18446744073709551614\"/>")); } #endif TEST_XML(dom_attr_assign_large_number_float, "<node attr='' />") { xml_node node = doc.child(STR("node")); node.attribute(STR("attr")) = std::numeric_limits<float>::max(); CHECK(test_node(node, STR("<node attr=\"3.40282347e+038\"/>"), STR(""), format_raw) || test_node(node, STR("<node attr=\"3.40282347e+38\"/>"), STR(""), format_raw)); } TEST_XML(dom_attr_assign_large_number_double, "<node attr='' />") { xml_node node = doc.child(STR("node")); node.attribute(STR("attr")) = std::numeric_limits<double>::max(); // Borland C does not print double values with enough precision #ifdef __BORLANDC__ CHECK_NODE(node, STR("<node attr=\"1.7976931348623156e+308\"/>")); #else CHECK_NODE(node, STR("<node attr=\"1.7976931348623157e+308\"/>")); #endif } TEST_XML(dom_node_set_name, "<node>text</node>") { CHECK(doc.child(STR("node")).set_name(STR("n"))); CHECK(!doc.child(STR("node")).first_child().set_name(STR("n"))); CHECK(!xml_node().set_name(STR("n"))); CHECK_NODE(doc, STR("<n>text</n>")); } TEST_XML(dom_node_set_value, "<node>text</node>") { CHECK(doc.child(STR("node")).first_child().set_value(STR("no text"))); CHECK(!doc.child(STR("node")).set_value(STR("no text"))); CHECK(!xml_node().set_value(STR("no text"))); CHECK_NODE(doc, STR("<node>no text</node>")); } TEST_XML(dom_node_set_value_allocated, "<node>text</node>") { CHECK(doc.child(STR("node")).first_child().set_value(STR("no text"))); CHECK(!doc.child(STR("node")).set_value(STR("no text"))); CHECK(!xml_node().set_value(STR("no text"))); CHECK(doc.child(STR("node")).first_child().set_value(STR("no text at all"))); CHECK_NODE(doc, STR("<node>no text at all</node>")); } TEST_XML(dom_node_prepend_attribute, "<node><child/></node>") { CHECK(xml_node().prepend_attribute(STR("a")) == xml_attribute()); CHECK(doc.prepend_attribute(STR("a")) == xml_attribute()); xml_attribute a1 = doc.child(STR("node")).prepend_attribute(STR("a1")); CHECK(a1); a1 = STR("v1"); xml_attribute a2 = doc.child(STR("node")).prepend_attribute(STR("a2")); CHECK(a2 && a1 != a2); a2 = STR("v2"); xml_attribute a3 = doc.child(STR("node")).child(STR("child")).prepend_attribute(STR("a3")); CHECK(a3 && a1 != a3 && a2 != a3); a3 = STR("v3"); CHECK_NODE(doc, STR("<node a2=\"v2\" a1=\"v1\"><child a3=\"v3\"/></node>")); } TEST_XML(dom_node_append_attribute, "<node><child/></node>") { CHECK(xml_node().append_attribute(STR("a")) == xml_attribute()); CHECK(doc.append_attribute(STR("a")) == xml_attribute()); xml_attribute a1 = doc.child(STR("node")).append_attribute(STR("a1")); CHECK(a1); a1 = STR("v1"); xml_attribute a2 = doc.child(STR("node")).append_attribute(STR("a2")); CHECK(a2 && a1 != a2); a2 = STR("v2"); xml_attribute a3 = doc.child(STR("node")).child(STR("child")).append_attribute(STR("a3")); CHECK(a3 && a1 != a3 && a2 != a3); a3 = STR("v3"); CHECK_NODE(doc, STR("<node a1=\"v1\" a2=\"v2\"><child a3=\"v3\"/></node>")); } TEST_XML(dom_node_insert_attribute_after, "<node a1='v1'><child a2='v2'/></node>") { CHECK(xml_node().insert_attribute_after(STR("a"), xml_attribute()) == xml_attribute()); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); xml_attribute a1 = node.attribute(STR("a1")); xml_attribute a2 = child.attribute(STR("a2")); CHECK(node.insert_attribute_after(STR("a"), xml_attribute()) == xml_attribute()); CHECK(node.insert_attribute_after(STR("a"), a2) == xml_attribute()); xml_attribute a3 = node.insert_attribute_after(STR("a3"), a1); CHECK(a3 && a3 != a2 && a3 != a1); a3 = STR("v3"); xml_attribute a4 = node.insert_attribute_after(STR("a4"), a1); CHECK(a4 && a4 != a3 && a4 != a2 && a4 != a1); a4 = STR("v4"); xml_attribute a5 = node.insert_attribute_after(STR("a5"), a3); CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); a5 = STR("v5"); CHECK(child.insert_attribute_after(STR("a"), a4) == xml_attribute()); CHECK_NODE(doc, STR("<node a1=\"v1\" a4=\"v4\" a3=\"v3\" a5=\"v5\"><child a2=\"v2\"/></node>")); } TEST_XML(dom_node_insert_attribute_before, "<node a1='v1'><child a2='v2'/></node>") { CHECK(xml_node().insert_attribute_before(STR("a"), xml_attribute()) == xml_attribute()); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); xml_attribute a1 = node.attribute(STR("a1")); xml_attribute a2 = child.attribute(STR("a2")); CHECK(node.insert_attribute_before(STR("a"), xml_attribute()) == xml_attribute()); CHECK(node.insert_attribute_before(STR("a"), a2) == xml_attribute()); xml_attribute a3 = node.insert_attribute_before(STR("a3"), a1); CHECK(a3 && a3 != a2 && a3 != a1); a3 = STR("v3"); xml_attribute a4 = node.insert_attribute_before(STR("a4"), a1); CHECK(a4 && a4 != a3 && a4 != a2 && a4 != a1); a4 = STR("v4"); xml_attribute a5 = node.insert_attribute_before(STR("a5"), a3); CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); a5 = STR("v5"); CHECK(child.insert_attribute_before(STR("a"), a4) == xml_attribute()); CHECK_NODE(doc, STR("<node a5=\"v5\" a3=\"v3\" a4=\"v4\" a1=\"v1\"><child a2=\"v2\"/></node>")); } TEST_XML(dom_node_prepend_copy_attribute, "<node a1='v1'><child a2='v2'/><child/></node>") { CHECK(xml_node().prepend_copy(xml_attribute()) == xml_attribute()); CHECK(xml_node().prepend_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute()); CHECK(doc.prepend_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute()); CHECK(doc.child(STR("node")).prepend_copy(xml_attribute()) == xml_attribute()); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); xml_attribute a1 = node.attribute(STR("a1")); xml_attribute a2 = child.attribute(STR("a2")); xml_attribute a3 = node.prepend_copy(a1); CHECK(a3 && a3 != a2 && a3 != a1); xml_attribute a4 = node.prepend_copy(a2); CHECK(a4 && a4 != a3 && a4 != a2 && a4 != a1); xml_attribute a5 = node.last_child().prepend_copy(a1); CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); CHECK_NODE(doc, STR("<node a2=\"v2\" a1=\"v1\" a1=\"v1\"><child a2=\"v2\"/><child a1=\"v1\"/></node>")); a3.set_name(STR("a3")); a3 = STR("v3"); a4.set_name(STR("a4")); a4 = STR("v4"); a5.set_name(STR("a5")); a5 = STR("v5"); CHECK_NODE(doc, STR("<node a4=\"v4\" a3=\"v3\" a1=\"v1\"><child a2=\"v2\"/><child a5=\"v5\"/></node>")); } TEST_XML(dom_node_append_copy_attribute, "<node a1='v1'><child a2='v2'/><child/></node>") { CHECK(xml_node().append_copy(xml_attribute()) == xml_attribute()); CHECK(xml_node().append_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute()); CHECK(doc.append_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute()); CHECK(doc.child(STR("node")).append_copy(xml_attribute()) == xml_attribute()); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); xml_attribute a1 = node.attribute(STR("a1")); xml_attribute a2 = child.attribute(STR("a2")); xml_attribute a3 = node.append_copy(a1); CHECK(a3 && a3 != a2 && a3 != a1); xml_attribute a4 = node.append_copy(a2); CHECK(a4 && a4 != a3 && a4 != a2 && a4 != a1); xml_attribute a5 = node.last_child().append_copy(a1); CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); CHECK_NODE(doc, STR("<node a1=\"v1\" a1=\"v1\" a2=\"v2\"><child a2=\"v2\"/><child a1=\"v1\"/></node>")); a3.set_name(STR("a3")); a3 = STR("v3"); a4.set_name(STR("a4")); a4 = STR("v4"); a5.set_name(STR("a5")); a5 = STR("v5"); CHECK_NODE(doc, STR("<node a1=\"v1\" a3=\"v3\" a4=\"v4\"><child a2=\"v2\"/><child a5=\"v5\"/></node>")); } TEST_XML(dom_node_insert_copy_after_attribute, "<node a1='v1'><child a2='v2'/>text</node>") { CHECK(xml_node().insert_copy_after(xml_attribute(), xml_attribute()) == xml_attribute()); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); xml_attribute a1 = node.attribute(STR("a1")); xml_attribute a2 = child.attribute(STR("a2")); CHECK(node.insert_copy_after(a1, xml_attribute()) == xml_attribute()); CHECK(node.insert_copy_after(xml_attribute(), a1) == xml_attribute()); CHECK(node.insert_copy_after(a2, a2) == xml_attribute()); CHECK(node.last_child().insert_copy_after(a2, a2) == xml_attribute()); xml_attribute a3 = node.insert_copy_after(a1, a1); CHECK(a3 && a3 != a2 && a3 != a1); xml_attribute a4 = node.insert_copy_after(a2, a1); CHECK(a4 && a4 != a3 && a4 != a2 && a4 != a1); xml_attribute a5 = node.insert_copy_after(a4, a1); CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); CHECK(child.insert_copy_after(a4, a4) == xml_attribute()); CHECK_NODE(doc, STR("<node a1=\"v1\" a2=\"v2\" a2=\"v2\" a1=\"v1\"><child a2=\"v2\"/>text</node>")); a3.set_name(STR("a3")); a3 = STR("v3"); a4.set_name(STR("a4")); a4 = STR("v4"); a5.set_name(STR("a5")); a5 = STR("v5"); CHECK_NODE(doc, STR("<node a1=\"v1\" a5=\"v5\" a4=\"v4\" a3=\"v3\"><child a2=\"v2\"/>text</node>")); } TEST_XML(dom_node_insert_copy_before_attribute, "<node a1='v1'><child a2='v2'/>text</node>") { CHECK(xml_node().insert_copy_before(xml_attribute(), xml_attribute()) == xml_attribute()); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); xml_attribute a1 = node.attribute(STR("a1")); xml_attribute a2 = child.attribute(STR("a2")); CHECK(node.insert_copy_before(a1, xml_attribute()) == xml_attribute()); CHECK(node.insert_copy_before(xml_attribute(), a1) == xml_attribute()); CHECK(node.insert_copy_before(a2, a2) == xml_attribute()); CHECK(node.last_child().insert_copy_before(a2, a2) == xml_attribute()); xml_attribute a3 = node.insert_copy_before(a1, a1); CHECK(a3 && a3 != a2 && a3 != a1); xml_attribute a4 = node.insert_copy_before(a2, a1); CHECK(a4 && a4 != a3 && a4 != a2 && a4 != a1); xml_attribute a5 = node.insert_copy_before(a4, a1); CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); CHECK(child.insert_copy_before(a4, a4) == xml_attribute()); CHECK_NODE(doc, STR("<node a1=\"v1\" a2=\"v2\" a2=\"v2\" a1=\"v1\"><child a2=\"v2\"/>text</node>")); a3.set_name(STR("a3")); a3 = STR("v3"); a4.set_name(STR("a4")); a4 = STR("v4"); a5.set_name(STR("a5")); a5 = STR("v5"); CHECK_NODE(doc, STR("<node a3=\"v3\" a4=\"v4\" a5=\"v5\" a1=\"v1\"><child a2=\"v2\"/>text</node>")); } TEST_XML(dom_node_remove_attribute, "<node a1='v1' a2='v2' a3='v3'><child a4='v4'/></node>") { CHECK(!xml_node().remove_attribute(STR("a"))); CHECK(!xml_node().remove_attribute(xml_attribute())); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); CHECK(!node.remove_attribute(STR("a"))); CHECK(!node.remove_attribute(xml_attribute())); CHECK(!node.remove_attribute(child.attribute(STR("a4")))); CHECK_NODE(doc, STR("<node a1=\"v1\" a2=\"v2\" a3=\"v3\"><child a4=\"v4\"/></node>")); CHECK(node.remove_attribute(STR("a1"))); CHECK(node.remove_attribute(node.attribute(STR("a3")))); CHECK(child.remove_attribute(STR("a4"))); CHECK_NODE(doc, STR("<node a2=\"v2\"><child/></node>")); } TEST_XML(dom_node_remove_attributes, "<node a1='v1' a2='v2' a3='v3'><child a4='v4'/></node>") { CHECK(!xml_node().remove_attributes()); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); CHECK(child.remove_attributes()); CHECK_NODE(child, STR("<child/>")); CHECK(node.remove_attributes()); CHECK_NODE(node, STR("<node><child/></node>")); } TEST_XML(dom_node_remove_attributes_lots, "<node/>") { xml_node node = doc.child(STR("node")); // this test makes sure we generate at least 2 pages (64K) worth of attribute data // so that we can trigger page deallocation to make sure code is memory safe for (size_t i = 0; i < 10000; ++i) node.append_attribute(STR("a")) = STR("v"); CHECK_STRING(node.attribute(STR("a")).value(), STR("v")); CHECK(node.remove_attributes()); CHECK_STRING(node.attribute(STR("a")).value(), STR("")); CHECK_NODE(node, STR("<node/>")); } TEST_XML(dom_node_prepend_child, "<node>foo<child/></node>") { CHECK(xml_node().prepend_child() == xml_node()); CHECK(doc.child(STR("node")).first_child().prepend_child() == xml_node()); CHECK(doc.prepend_child(node_document) == xml_node()); CHECK(doc.prepend_child(node_null) == xml_node()); xml_node n1 = doc.child(STR("node")).prepend_child(); CHECK(n1); CHECK(n1.set_name(STR("n1"))); xml_node n2 = doc.child(STR("node")).prepend_child(); CHECK(n2 && n1 != n2); CHECK(n2.set_name(STR("n2"))); xml_node n3 = doc.child(STR("node")).child(STR("child")).prepend_child(node_pcdata); CHECK(n3 && n1 != n3 && n2 != n3); CHECK(n3.set_value(STR("n3"))); xml_node n4 = doc.prepend_child(node_comment); CHECK(n4 && n1 != n4 && n2 != n4 && n3 != n4); CHECK(n4.set_value(STR("n4"))); CHECK_NODE(doc, STR("<!--n4--><node><n2/><n1/>foo<child>n3</child></node>")); } TEST_XML(dom_node_append_child, "<node>foo<child/></node>") { CHECK(xml_node().append_child() == xml_node()); CHECK(doc.child(STR("node")).first_child().append_child() == xml_node()); CHECK(doc.append_child(node_document) == xml_node()); CHECK(doc.append_child(node_null) == xml_node()); xml_node n1 = doc.child(STR("node")).append_child(); CHECK(n1); CHECK(n1.set_name(STR("n1"))); xml_node n2 = doc.child(STR("node")).append_child(); CHECK(n2 && n1 != n2); CHECK(n2.set_name(STR("n2"))); xml_node n3 = doc.child(STR("node")).child(STR("child")).append_child(node_pcdata); CHECK(n3 && n1 != n3 && n2 != n3); CHECK(n3.set_value(STR("n3"))); xml_node n4 = doc.append_child(node_comment); CHECK(n4 && n1 != n4 && n2 != n4 && n3 != n4); CHECK(n4.set_value(STR("n4"))); CHECK_NODE(doc, STR("<node>foo<child>n3</child><n1/><n2/></node><!--n4-->")); } TEST_XML(dom_node_insert_child_after, "<node>foo<child/></node>") { CHECK(xml_node().insert_child_after(node_element, xml_node()) == xml_node()); CHECK(doc.child(STR("node")).first_child().insert_child_after(node_element, xml_node()) == xml_node()); CHECK(doc.insert_child_after(node_document, xml_node()) == xml_node()); CHECK(doc.insert_child_after(node_null, xml_node()) == xml_node()); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); CHECK(node.insert_child_after(node_element, xml_node()) == xml_node()); CHECK(node.insert_child_after(node_element, node) == xml_node()); CHECK(child.insert_child_after(node_element, node) == xml_node()); xml_node n1 = node.insert_child_after(node_element, child); CHECK(n1 && n1 != node && n1 != child); CHECK(n1.set_name(STR("n1"))); xml_node n2 = node.insert_child_after(node_element, child); CHECK(n2 && n2 != node && n2 != child && n2 != n1); CHECK(n2.set_name(STR("n2"))); xml_node n3 = node.insert_child_after(node_pcdata, n2); CHECK(n3 && n3 != node && n3 != child && n3 != n1 && n3 != n2); CHECK(n3.set_value(STR("n3"))); xml_node n4 = node.insert_child_after(node_pi, node.first_child()); CHECK(n4 && n4 != node && n4 != child && n4 != n1 && n4 != n2 && n4 != n3); CHECK(n4.set_name(STR("n4"))); CHECK(child.insert_child_after(node_element, n3) == xml_node()); CHECK_NODE(doc, STR("<node>foo<?n4?><child/><n2/>n3<n1/></node>")); } TEST_XML(dom_node_insert_child_before, "<node>foo<child/></node>") { CHECK(xml_node().insert_child_before(node_element, xml_node()) == xml_node()); CHECK(doc.child(STR("node")).first_child().insert_child_before(node_element, xml_node()) == xml_node()); CHECK(doc.insert_child_before(node_document, xml_node()) == xml_node()); CHECK(doc.insert_child_before(node_null, xml_node()) == xml_node()); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); CHECK(node.insert_child_before(node_element, xml_node()) == xml_node()); CHECK(node.insert_child_before(node_element, node) == xml_node()); CHECK(child.insert_child_before(node_element, node) == xml_node()); xml_node n1 = node.insert_child_before(node_element, child); CHECK(n1 && n1 != node && n1 != child); CHECK(n1.set_name(STR("n1"))); xml_node n2 = node.insert_child_before(node_element, child); CHECK(n2 && n2 != node && n2 != child && n2 != n1); CHECK(n2.set_name(STR("n2"))); xml_node n3 = node.insert_child_before(node_pcdata, n2); CHECK(n3 && n3 != node && n3 != child && n3 != n1 && n3 != n2); CHECK(n3.set_value(STR("n3"))); xml_node n4 = node.insert_child_before(node_pi, node.first_child()); CHECK(n4 && n4 != node && n4 != child && n4 != n1 && n4 != n2 && n4 != n3); CHECK(n4.set_name(STR("n4"))); CHECK(child.insert_child_before(node_element, n3) == xml_node()); CHECK_NODE(doc, STR("<node><?n4?>foo<n1/>n3<n2/><child/></node>")); } TEST_XML(dom_node_prepend_child_name, "<node>foo<child/></node>") { CHECK(xml_node().prepend_child(STR("")) == xml_node()); CHECK(doc.child(STR("node")).first_child().prepend_child(STR("")) == xml_node()); xml_node n1 = doc.child(STR("node")).prepend_child(STR("n1")); CHECK(n1); xml_node n2 = doc.child(STR("node")).prepend_child(STR("n2")); CHECK(n2 && n1 != n2); CHECK_NODE(doc, STR("<node><n2/><n1/>foo<child/></node>")); } TEST_XML(dom_node_append_child_name, "<node>foo<child/></node>") { CHECK(xml_node().append_child(STR("")) == xml_node()); CHECK(doc.child(STR("node")).first_child().append_child(STR("")) == xml_node()); xml_node n1 = doc.child(STR("node")).append_child(STR("n1")); CHECK(n1); xml_node n2 = doc.child(STR("node")).append_child(STR("n2")); CHECK(n2 && n1 != n2); CHECK_NODE(doc, STR("<node>foo<child/><n1/><n2/></node>")); } TEST_XML(dom_node_insert_child_after_name, "<node>foo<child/></node>") { CHECK(xml_node().insert_child_after(STR(""), xml_node()) == xml_node()); CHECK(doc.child(STR("node")).first_child().insert_child_after(STR(""), xml_node()) == xml_node()); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); CHECK(node.insert_child_after(STR(""), node) == xml_node()); CHECK(child.insert_child_after(STR(""), node) == xml_node()); xml_node n1 = node.insert_child_after(STR("n1"), child); CHECK(n1 && n1 != node && n1 != child); xml_node n2 = node.insert_child_after(STR("n2"), child); CHECK(n2 && n2 != node && n2 != child && n2 != n1); CHECK(child.insert_child_after(STR(""), n2) == xml_node()); CHECK_NODE(doc, STR("<node>foo<child/><n2/><n1/></node>")); } TEST_XML(dom_node_insert_child_before_name, "<node>foo<child/></node>") { CHECK(xml_node().insert_child_before(STR(""), xml_node()) == xml_node()); CHECK(doc.child(STR("node")).first_child().insert_child_before(STR(""), xml_node()) == xml_node()); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); CHECK(node.insert_child_before(STR(""), node) == xml_node()); CHECK(child.insert_child_before(STR(""), node) == xml_node()); xml_node n1 = node.insert_child_before(STR("n1"), child); CHECK(n1 && n1 != node && n1 != child); xml_node n2 = node.insert_child_before(STR("n2"), child); CHECK(n2 && n2 != node && n2 != child && n2 != n1); CHECK(child.insert_child_before(STR(""), n2) == xml_node()); CHECK_NODE(doc, STR("<node>foo<n1/><n2/><child/></node>")); } TEST_XML(dom_node_remove_child, "<node><n1/><n2/><n3/><child><n4/></child></node>") { CHECK(!xml_node().remove_child(STR("a"))); CHECK(!xml_node().remove_child(xml_node())); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); CHECK(!node.remove_child(STR("a"))); CHECK(!node.remove_child(xml_node())); CHECK(!node.remove_child(child.child(STR("n4")))); CHECK_NODE(doc, STR("<node><n1/><n2/><n3/><child><n4/></child></node>")); CHECK(node.remove_child(STR("n1"))); CHECK(node.remove_child(node.child(STR("n3")))); CHECK(child.remove_child(STR("n4"))); CHECK_NODE(doc, STR("<node><n2/><child/></node>")); } TEST_XML(dom_node_remove_children, "<node><n1/><n2/><n3/><child><n4/></child></node>") { CHECK(!xml_node().remove_children()); xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); CHECK(child.remove_children()); CHECK_NODE(child, STR("<child/>")); CHECK(node.remove_children()); CHECK_NODE(node, STR("<node/>")); } TEST_XML(dom_node_remove_children_lots, "<node/>") { xml_node node = doc.child(STR("node")); // this test makes sure we generate at least 2 pages (64K) worth of node data // so that we can trigger page deallocation to make sure code is memory safe for (size_t i = 0; i < 10000; ++i) node.append_child().set_name(STR("n")); CHECK(node.child(STR("n"))); CHECK(node.remove_children()); CHECK(!node.child(STR("n"))); CHECK_NODE(node, STR("<node/>")); } TEST_XML(dom_node_remove_child_complex, "<node id='1'><n1 id1='1' id2='2'/><n2/><n3/><child><n4/></child></node>") { CHECK(doc.child(STR("node")).remove_child(STR("n1"))); CHECK_NODE(doc, STR("<node id=\"1\"><n2/><n3/><child><n4/></child></node>")); CHECK(doc.remove_child(STR("node"))); CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_remove_child_complex_allocated, "<node id='1'><n1 id1='1' id2='2'/><n2/><n3/><child><n4/></child></node>") { doc.append_copy(doc.child(STR("node"))); CHECK(doc.remove_child(STR("node"))); CHECK(doc.remove_child(STR("node"))); CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_prepend_copy, "<node>foo<child/></node>") { CHECK(xml_node().prepend_copy(xml_node()) == xml_node()); CHECK(doc.child(STR("node")).first_child().prepend_copy(doc.child(STR("node"))) == xml_node()); CHECK(doc.prepend_copy(doc) == xml_node()); CHECK(doc.prepend_copy(xml_node()) == xml_node()); xml_node n1 = doc.child(STR("node")).prepend_copy(doc.child(STR("node")).first_child()); CHECK(n1); CHECK_STRING(n1.value(), STR("foo")); CHECK_NODE(doc, STR("<node>foofoo<child/></node>")); xml_node n2 = doc.child(STR("node")).prepend_copy(doc.child(STR("node")).child(STR("child"))); CHECK(n2 && n2 != n1); CHECK_STRING(n2.name(), STR("child")); CHECK_NODE(doc, STR("<node><child/>foofoo<child/></node>")); xml_node n3 = doc.child(STR("node")).child(STR("child")).prepend_copy(doc.child(STR("node")).first_child().next_sibling()); CHECK(n3 && n3 != n1 && n3 != n2); CHECK_STRING(n3.value(), STR("foo")); CHECK_NODE(doc, STR("<node><child>foo</child>foofoo<child/></node>")); } TEST_XML(dom_node_append_copy, "<node>foo<child/></node>") { CHECK(xml_node().append_copy(xml_node()) == xml_node()); CHECK(doc.child(STR("node")).first_child().append_copy(doc.child(STR("node"))) == xml_node()); CHECK(doc.append_copy(doc) == xml_node()); CHECK(doc.append_copy(xml_node()) == xml_node()); xml_node n1 = doc.child(STR("node")).append_copy(doc.child(STR("node")).first_child()); CHECK(n1); CHECK_STRING(n1.value(), STR("foo")); CHECK_NODE(doc, STR("<node>foo<child/>foo</node>")); xml_node n2 = doc.child(STR("node")).append_copy(doc.child(STR("node")).child(STR("child"))); CHECK(n2 && n2 != n1); CHECK_STRING(n2.name(), STR("child")); CHECK_NODE(doc, STR("<node>foo<child/>foo<child/></node>")); xml_node n3 = doc.child(STR("node")).child(STR("child")).append_copy(doc.child(STR("node")).first_child()); CHECK(n3 && n3 != n1 && n3 != n2); CHECK_STRING(n3.value(), STR("foo")); CHECK_NODE(doc, STR("<node>foo<child>foo</child>foo<child/></node>")); } TEST_XML(dom_node_insert_copy_after, "<node>foo<child/></node>") { xml_node child = doc.child(STR("node")).child(STR("child")); CHECK(xml_node().insert_copy_after(xml_node(), xml_node()) == xml_node()); CHECK(doc.child(STR("node")).first_child().insert_copy_after(doc.child(STR("node")), doc.child(STR("node"))) == xml_node()); CHECK(doc.insert_copy_after(doc, doc) == xml_node()); CHECK(doc.insert_copy_after(xml_node(), doc.child(STR("node"))) == xml_node()); CHECK(doc.insert_copy_after(doc.child(STR("node")), xml_node()) == xml_node()); CHECK(doc.insert_copy_after(doc.child(STR("node")), child) == xml_node()); xml_node n1 = doc.child(STR("node")).insert_copy_after(child, doc.child(STR("node")).first_child()); CHECK(n1); CHECK_STRING(n1.name(), STR("child")); CHECK_NODE(doc, STR("<node>foo<child/><child/></node>")); xml_node n2 = doc.child(STR("node")).insert_copy_after(doc.child(STR("node")).first_child(), doc.child(STR("node")).last_child()); CHECK(n2 && n2 != n1); CHECK_STRING(n2.value(), STR("foo")); CHECK_NODE(doc, STR("<node>foo<child/><child/>foo</node>")); xml_node n3 = doc.child(STR("node")).insert_copy_after(doc.child(STR("node")).first_child(), doc.child(STR("node")).first_child()); CHECK(n3 && n3 != n1 && n3 != n2); CHECK_STRING(n3.value(), STR("foo")); CHECK_NODE(doc, STR("<node>foofoo<child/><child/>foo</node>")); } TEST_XML(dom_node_insert_copy_before, "<node>foo<child/></node>") { xml_node child = doc.child(STR("node")).child(STR("child")); CHECK(xml_node().insert_copy_before(xml_node(), xml_node()) == xml_node()); CHECK(doc.child(STR("node")).first_child().insert_copy_before(doc.child(STR("node")), doc.child(STR("node"))) == xml_node()); CHECK(doc.insert_copy_before(doc, doc) == xml_node()); CHECK(doc.insert_copy_before(xml_node(), doc.child(STR("node"))) == xml_node()); CHECK(doc.insert_copy_before(doc.child(STR("node")), xml_node()) == xml_node()); CHECK(doc.insert_copy_before(doc.child(STR("node")), child) == xml_node()); xml_node n1 = doc.child(STR("node")).insert_copy_before(child, doc.child(STR("node")).first_child()); CHECK(n1); CHECK_STRING(n1.name(), STR("child")); CHECK_NODE(doc, STR("<node><child/>foo<child/></node>")); xml_node n2 = doc.child(STR("node")).insert_copy_before(doc.child(STR("node")).first_child(), doc.child(STR("node")).last_child()); CHECK(n2 && n2 != n1); CHECK_STRING(n2.name(), STR("child")); CHECK_NODE(doc, STR("<node><child/>foo<child/><child/></node>")); xml_node n3 = doc.child(STR("node")).insert_copy_before(doc.child(STR("node")).first_child().next_sibling(), doc.child(STR("node")).first_child()); CHECK(n3 && n3 != n1 && n3 != n2); CHECK_STRING(n3.value(), STR("foo")); CHECK_NODE(doc, STR("<node>foo<child/>foo<child/><child/></node>")); } TEST_XML(dom_node_copy_recursive, "<node>foo<child/></node>") { doc.child(STR("node")).append_copy(doc.child(STR("node"))); CHECK_NODE(doc, STR("<node>foo<child/><node>foo<child/></node></node>")); } TEST_XML(dom_node_copy_crossdoc, "<node/>") { xml_document newdoc; newdoc.append_copy(doc.child(STR("node"))); CHECK_NODE(doc, STR("<node/>")); CHECK_NODE(newdoc, STR("<node/>")); } TEST_XML(dom_node_copy_crossdoc_attribute, "<node attr='value'/>") { xml_document newdoc; newdoc.append_child(STR("copy")).append_copy(doc.child(STR("node")).attribute(STR("attr"))); CHECK_NODE(doc, STR("<node attr=\"value\"/>")); CHECK_NODE(newdoc, STR("<copy attr=\"value\"/>")); } TEST_XML_FLAGS(dom_node_copy_types, "<?xml version='1.0'?><!DOCTYPE id><root><?pi value?><!--comment--><node id='1'>pcdata<![CDATA[cdata]]></node></root>", parse_full) { doc.append_copy(doc.child(STR("root"))); CHECK_NODE(doc, STR("<?xml version=\"1.0\"?><!DOCTYPE id><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root>")); doc.insert_copy_before(doc.first_child(), doc.first_child()); CHECK_NODE(doc, STR("<?xml version=\"1.0\"?><?xml version=\"1.0\"?><!DOCTYPE id><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root>")); doc.insert_copy_after(doc.first_child().next_sibling().next_sibling(), doc.first_child()); CHECK_NODE(doc, STR("<?xml version=\"1.0\"?><!DOCTYPE id><?xml version=\"1.0\"?><!DOCTYPE id><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root><root><?pi value?><!--comment--><node id=\"1\">pcdata<![CDATA[cdata]]></node></root>")); } TEST(dom_node_declaration_name) { xml_document doc; doc.append_child(node_declaration); // name 'xml' is auto-assigned CHECK(doc.first_child().type() == node_declaration); CHECK_STRING(doc.first_child().name(), STR("xml")); doc.insert_child_after(node_declaration, doc.first_child()); doc.insert_child_before(node_declaration, doc.first_child()); doc.prepend_child(node_declaration); CHECK_NODE(doc, STR("<?xml?><?xml?><?xml?><?xml?>")); } TEST(dom_node_declaration_attributes) { xml_document doc; xml_node node = doc.append_child(node_declaration); node.append_attribute(STR("version")) = STR("1.0"); node.append_attribute(STR("encoding")) = STR("utf-8"); CHECK_NODE(doc, STR("<?xml version=\"1.0\" encoding=\"utf-8\"?>")); } TEST(dom_node_declaration_top_level) { xml_document doc; doc.append_child().set_name(STR("node")); xml_node node = doc.first_child(); node.append_child(node_pcdata).set_value(STR("text")); CHECK(node.insert_child_before(node_declaration, node.first_child()) == xml_node()); CHECK(node.insert_child_after(node_declaration, node.first_child()) == xml_node()); CHECK(node.append_child(node_declaration) == xml_node()); CHECK_NODE(doc, STR("<node>text</node>")); CHECK(doc.insert_child_before(node_declaration, node)); CHECK(doc.insert_child_after(node_declaration, node)); CHECK(doc.append_child(node_declaration)); CHECK_NODE(doc, STR("<?xml?><node>text</node><?xml?><?xml?>")); } TEST(dom_node_declaration_copy) { xml_document doc; doc.append_child(node_declaration); doc.append_child().set_name(STR("node")); doc.last_child().append_copy(doc.first_child()); CHECK_NODE(doc, STR("<?xml?><node/>")); } TEST(dom_string_out_of_memory) { const unsigned int length = 65536; static char_t string[length + 1]; for (unsigned int i = 0; i < length; ++i) string[i] = 'a'; string[length] = 0; xml_document doc; xml_node node = doc.append_child(); xml_attribute attr = node.append_attribute(STR("a")); xml_node text = node.append_child(node_pcdata); // no value => long value test_runner::_memory_fail_threshold = 32; CHECK_ALLOC_FAIL(CHECK(!node.set_name(string))); CHECK_ALLOC_FAIL(CHECK(!text.set_value(string))); CHECK_ALLOC_FAIL(CHECK(!attr.set_name(string))); CHECK_ALLOC_FAIL(CHECK(!attr.set_value(string))); // set some names/values test_runner::_memory_fail_threshold = 0; node.set_name(STR("n")); attr.set_value(STR("v")); text.set_value(STR("t")); // some value => long value test_runner::_memory_fail_threshold = 32; CHECK_ALLOC_FAIL(CHECK(!node.set_name(string))); CHECK_ALLOC_FAIL(CHECK(!text.set_value(string))); CHECK_ALLOC_FAIL(CHECK(!attr.set_name(string))); CHECK_ALLOC_FAIL(CHECK(!attr.set_value(string))); // check that original state was preserved test_runner::_memory_fail_threshold = 0; CHECK_NODE(doc, STR("<n a=\"v\">t</n>")); } TEST(dom_node_out_of_memory) { test_runner::_memory_fail_threshold = 65536; // exhaust memory limit xml_document doc; xml_node n = doc.append_child(); CHECK(n.set_name(STR("n"))); xml_attribute a = n.append_attribute(STR("a")); CHECK(a); CHECK_ALLOC_FAIL(while (n.append_child(node_comment)) { /* nop */ }); CHECK_ALLOC_FAIL(while (n.append_attribute(STR("b"))) { /* nop */ }); // verify all node modification operations CHECK_ALLOC_FAIL(CHECK(!n.append_child())); CHECK_ALLOC_FAIL(CHECK(!n.prepend_child())); CHECK_ALLOC_FAIL(CHECK(!n.insert_child_after(node_element, n.first_child()))); CHECK_ALLOC_FAIL(CHECK(!n.insert_child_before(node_element, n.first_child()))); CHECK_ALLOC_FAIL(CHECK(!n.append_attribute(STR("")))); CHECK_ALLOC_FAIL(CHECK(!n.prepend_attribute(STR("")))); CHECK_ALLOC_FAIL(CHECK(!n.insert_attribute_after(STR(""), a))); CHECK_ALLOC_FAIL(CHECK(!n.insert_attribute_before(STR(""), a))); // verify node copy operations CHECK_ALLOC_FAIL(CHECK(!n.append_copy(n.first_child()))); CHECK_ALLOC_FAIL(CHECK(!n.prepend_copy(n.first_child()))); CHECK_ALLOC_FAIL(CHECK(!n.insert_copy_after(n.first_child(), n.first_child()))); CHECK_ALLOC_FAIL(CHECK(!n.insert_copy_before(n.first_child(), n.first_child()))); CHECK_ALLOC_FAIL(CHECK(!n.append_copy(a))); CHECK_ALLOC_FAIL(CHECK(!n.prepend_copy(a))); CHECK_ALLOC_FAIL(CHECK(!n.insert_copy_after(a, a))); CHECK_ALLOC_FAIL(CHECK(!n.insert_copy_before(a, a))); } TEST(dom_node_memory_limit) { const unsigned int length = 65536; static char_t string[length + 1]; for (unsigned int i = 0; i < length; ++i) string[i] = 'a'; string[length] = 0; test_runner::_memory_fail_threshold = 32768 * 2 + sizeof(string); xml_document doc; for (int j = 0; j < 32; ++j) { CHECK(doc.append_child().set_name(string)); CHECK(doc.remove_child(doc.first_child())); } } TEST(dom_node_memory_limit_pi) { const unsigned int length = 65536; static char_t string[length + 1]; for (unsigned int i = 0; i < length; ++i) string[i] = 'a'; string[length] = 0; test_runner::_memory_fail_threshold = 32768 * 2 + sizeof(string); xml_document doc; for (int j = 0; j < 32; ++j) { CHECK(doc.append_child(node_pi).set_value(string)); CHECK(doc.remove_child(doc.first_child())); } } TEST(dom_node_doctype_top_level) { xml_document doc; doc.append_child().set_name(STR("node")); xml_node node = doc.first_child(); node.append_child(node_pcdata).set_value(STR("text")); CHECK(node.insert_child_before(node_doctype, node.first_child()) == xml_node()); CHECK(node.insert_child_after(node_doctype, node.first_child()) == xml_node()); CHECK(node.append_child(node_doctype) == xml_node()); CHECK_NODE(doc, STR("<node>text</node>")); CHECK(doc.insert_child_before(node_doctype, node)); CHECK(doc.insert_child_after(node_doctype, node)); CHECK(doc.append_child(node_doctype)); CHECK_NODE(doc, STR("<!DOCTYPE><node>text</node><!DOCTYPE><!DOCTYPE>")); } TEST(dom_node_doctype_copy) { xml_document doc; doc.append_child(node_doctype); doc.append_child().set_name(STR("node")); doc.last_child().append_copy(doc.first_child()); CHECK_NODE(doc, STR("<!DOCTYPE><node/>")); } TEST(dom_node_doctype_value) { xml_document doc; xml_node node = doc.append_child(node_doctype); CHECK(node.type() == node_doctype); CHECK_STRING(node.value(), STR("")); CHECK_NODE(node, STR("<!DOCTYPE>")); CHECK(node.set_value(STR("id [ foo ]"))); CHECK_NODE(node, STR("<!DOCTYPE id [ foo ]>")); } TEST_XML(dom_node_append_buffer_native, "<node>test</node>") { xml_node node = doc.child(STR("node")); const char_t data1[] = STR("<child1 id='1' /><child2>text</child2>"); const char_t data2[] = STR("<child3 />"); CHECK(node.append_buffer(data1, sizeof(data1))); CHECK(node.append_buffer(data2, sizeof(data2))); CHECK(node.append_buffer(data1, sizeof(data1))); CHECK(node.append_buffer(data2, sizeof(data2))); CHECK(node.append_buffer(data2, sizeof(data2))); CHECK_NODE(doc, STR("<node>test<child1 id=\"1\"/><child2>text</child2><child3/><child1 id=\"1\"/><child2>text</child2><child3/><child3/></node>")); } TEST_XML(dom_node_append_buffer_convert, "<node>test</node>") { xml_node node = doc.child(STR("node")); const char data[] = {0, 0, 0, '<', 0, 0, 0, 'n', 0, 0, 0, '/', 0, 0, 0, '>'}; CHECK(node.append_buffer(data, sizeof(data))); CHECK(node.append_buffer(data, sizeof(data), parse_default, encoding_utf32_be)); CHECK_NODE(doc, STR("<node>test<n/><n/></node>")); } TEST_XML(dom_node_append_buffer_remove, "<node>test</node>") { xml_node node = doc.child(STR("node")); const char data1[] = "<child1 id='1' /><child2>text</child2>"; const char data2[] = "<child3 />"; CHECK(node.append_buffer(data1, sizeof(data1))); CHECK(node.append_buffer(data2, sizeof(data2))); CHECK(node.append_buffer(data1, sizeof(data1))); CHECK(node.append_buffer(data2, sizeof(data2))); CHECK_NODE(doc, STR("<node>test<child1 id=\"1\"/><child2>text</child2><child3/><child1 id=\"1\"/><child2>text</child2><child3/></node>")); while (node.remove_child(STR("child2"))) {} CHECK_NODE(doc, STR("<node>test<child1 id=\"1\"/><child3/><child1 id=\"1\"/><child3/></node>")); while (node.remove_child(STR("child1"))) {} CHECK_NODE(doc, STR("<node>test<child3/><child3/></node>")); while (node.remove_child(STR("child3"))) {} CHECK_NODE(doc, STR("<node>test</node>")); CHECK(doc.remove_child(STR("node"))); CHECK(!doc.first_child()); } TEST(dom_node_append_buffer_empty_document) { xml_document doc; const char data[] = "<child1 id='1' /><child2>text</child2>"; doc.append_buffer(data, sizeof(data)); CHECK_NODE(doc, STR("<child1 id=\"1\"/><child2>text</child2>")); } TEST_XML(dom_node_append_buffer_invalid_type, "<node>test</node>") { const char data[] = "<child1 id='1' /><child2>text</child2>"; CHECK(xml_node().append_buffer(data, sizeof(data)).status == status_append_invalid_root); CHECK(doc.first_child().first_child().append_buffer(data, sizeof(data)).status == status_append_invalid_root); } TEST_XML(dom_node_append_buffer_close_external, "<node />") { xml_node node = doc.child(STR("node")); const char data[] = "<child1 /></node><child2 />"; CHECK(node.append_buffer(data, sizeof(data)).status == status_end_element_mismatch); CHECK_NODE(doc, STR("<node><child1/></node>")); CHECK(node.append_buffer(data, sizeof(data)).status == status_end_element_mismatch); CHECK_NODE(doc, STR("<node><child1/><child1/></node>")); } TEST(dom_node_append_buffer_out_of_memory_extra) { test_runner::_memory_fail_threshold = 1; xml_document doc; CHECK_ALLOC_FAIL(CHECK(doc.append_buffer("<n/>", 4).status == status_out_of_memory)); CHECK(!doc.first_child()); } TEST(dom_node_append_buffer_out_of_memory_buffer) { test_runner::_memory_fail_threshold = 32768 + 128; char data[128] = {0}; xml_document doc; CHECK_ALLOC_FAIL(CHECK(doc.append_buffer(data, sizeof(data)).status == status_out_of_memory)); CHECK(!doc.first_child()); } TEST(dom_node_append_buffer_out_of_memory_nodes) { unsigned int count = 4000; std::basic_string<char_t> data; for (unsigned int i = 0; i < count; ++i) data += STR("<a/>"); test_runner::_memory_fail_threshold = 32768 + 128 + data.length() * sizeof(char_t) + 32; #ifdef PUGIXML_COMPACT // ... and some space for hash table test_runner::_memory_fail_threshold += 2048; #endif xml_document doc; CHECK_ALLOC_FAIL(CHECK(doc.append_buffer(data.c_str(), data.length() * sizeof(char_t), parse_fragment).status == status_out_of_memory)); unsigned int valid = 0; for (xml_node n = doc.first_child(); n; n = n.next_sibling()) { CHECK_STRING(n.name(), STR("a")); valid++; } CHECK(valid > 0 && valid < count); } TEST(dom_node_append_buffer_out_of_memory_name) { test_runner::_memory_fail_threshold = 32768 + 4096; char data[4096] = {0}; xml_document doc; CHECK(doc.append_child(STR("root"))); CHECK_ALLOC_FAIL(CHECK(doc.first_child().append_buffer(data, sizeof(data)).status == status_out_of_memory)); CHECK_STRING(doc.first_child().name(), STR("root")); } TEST_XML(dom_node_append_buffer_fragment, "<node />") { xml_node node = doc.child(STR("node")); CHECK(node.append_buffer("1", 1).status == status_no_document_element); CHECK_NODE(doc, STR("<node>1</node>")); CHECK(node.append_buffer("2", 1, parse_fragment)); CHECK_NODE(doc, STR("<node>12</node>")); CHECK(node.append_buffer("3", 1).status == status_no_document_element); CHECK_NODE(doc, STR("<node>123</node>")); CHECK(node.append_buffer("4", 1, parse_fragment)); CHECK_NODE(doc, STR("<node>1234</node>")); } TEST_XML(dom_node_append_buffer_empty, "<node />") { xml_node node = doc.child(STR("node")); CHECK(node.append_buffer("", 0).status == status_no_document_element); CHECK(node.append_buffer("", 0, parse_fragment).status == status_ok); CHECK(node.append_buffer(0, 0).status == status_no_document_element); CHECK(node.append_buffer(0, 0, parse_fragment).status == status_ok); CHECK_NODE(doc, STR("<node/>")); } TEST_XML(dom_node_prepend_move, "<node>foo<child/></node>") { xml_node child = doc.child(STR("node")).child(STR("child")); CHECK(xml_node().prepend_move(xml_node()) == xml_node()); CHECK(doc.child(STR("node")).first_child().prepend_move(child) == xml_node()); CHECK(doc.prepend_move(doc) == xml_node()); CHECK(doc.prepend_move(xml_node()) == xml_node()); xml_node n1 = doc.child(STR("node")).prepend_move(doc.child(STR("node")).first_child()); CHECK(n1 && n1 == doc.child(STR("node")).first_child()); CHECK_STRING(n1.value(), STR("foo")); CHECK_NODE(doc, STR("<node>foo<child/></node>")); xml_node n2 = doc.child(STR("node")).prepend_move(doc.child(STR("node")).child(STR("child"))); CHECK(n2 && n2 != n1 && n2 == child); CHECK_STRING(n2.name(), STR("child")); CHECK_NODE(doc, STR("<node><child/>foo</node>")); xml_node n3 = doc.child(STR("node")).child(STR("child")).prepend_move(doc.child(STR("node")).first_child().next_sibling()); CHECK(n3 && n3 == n1 && n3 != n2); CHECK_STRING(n3.value(), STR("foo")); CHECK_NODE(doc, STR("<node><child>foo</child></node>")); } TEST_XML(dom_node_append_move, "<node>foo<child/></node>") { xml_node child = doc.child(STR("node")).child(STR("child")); CHECK(xml_node().append_move(xml_node()) == xml_node()); CHECK(doc.child(STR("node")).first_child().append_move(child) == xml_node()); CHECK(doc.append_move(doc) == xml_node()); CHECK(doc.append_move(xml_node()) == xml_node()); xml_node n1 = doc.child(STR("node")).append_move(doc.child(STR("node")).first_child()); CHECK(n1 && n1 == doc.child(STR("node")).last_child()); CHECK_STRING(n1.value(), STR("foo")); CHECK_NODE(doc, STR("<node><child/>foo</node>")); xml_node n2 = doc.child(STR("node")).append_move(doc.child(STR("node")).last_child()); CHECK(n2 && n2 == n1); CHECK_STRING(n2.value(), STR("foo")); CHECK_NODE(doc, STR("<node><child/>foo</node>")); xml_node n3 = doc.child(STR("node")).child(STR("child")).append_move(doc.child(STR("node")).last_child()); CHECK(n3 && n3 == n1 && n3 == n2); CHECK_STRING(n3.value(), STR("foo")); CHECK_NODE(doc, STR("<node><child>foo</child></node>")); } TEST_XML(dom_node_insert_move_after, "<node>foo<child>bar</child></node>") { xml_node child = doc.child(STR("node")).child(STR("child")); CHECK(xml_node().insert_move_after(xml_node(), xml_node()) == xml_node()); CHECK(doc.child(STR("node")).first_child().insert_move_after(doc.child(STR("node")), doc.child(STR("node"))) == xml_node()); CHECK(doc.insert_move_after(doc, doc) == xml_node()); CHECK(doc.insert_move_after(xml_node(), doc.child(STR("node"))) == xml_node()); CHECK(doc.insert_move_after(doc.child(STR("node")), xml_node()) == xml_node()); CHECK(doc.insert_move_after(doc.child(STR("node")), child) == xml_node()); xml_node n1 = doc.child(STR("node")).insert_move_after(child, doc.child(STR("node")).first_child()); CHECK(n1 && n1 == child); CHECK_STRING(n1.name(), STR("child")); CHECK_NODE(doc, STR("<node>foo<child>bar</child></node>")); xml_node n2 = doc.child(STR("node")).insert_move_after(doc.child(STR("node")).first_child(), child); CHECK(n2 && n2 != n1); CHECK_STRING(n2.value(), STR("foo")); CHECK_NODE(doc, STR("<node><child>bar</child>foo</node>")); xml_node n3 = child.insert_move_after(doc.child(STR("node")).last_child(), child.first_child()); CHECK(n3 && n3 != n1 && n3 == n2); CHECK_STRING(n3.value(), STR("foo")); CHECK_NODE(doc, STR("<node><child>barfoo</child></node>")); } TEST_XML(dom_node_insert_move_before, "<node>foo<child>bar</child></node>") { xml_node child = doc.child(STR("node")).child(STR("child")); CHECK(xml_node().insert_move_before(xml_node(), xml_node()) == xml_node()); CHECK(doc.child(STR("node")).first_child().insert_move_before(doc.child(STR("node")), doc.child(STR("node"))) == xml_node()); CHECK(doc.insert_move_before(doc, doc) == xml_node()); CHECK(doc.insert_move_before(xml_node(), doc.child(STR("node"))) == xml_node()); CHECK(doc.insert_move_before(doc.child(STR("node")), xml_node()) == xml_node()); CHECK(doc.insert_move_before(doc.child(STR("node")), child) == xml_node()); xml_node n1 = doc.child(STR("node")).insert_move_before(child, doc.child(STR("node")).first_child()); CHECK(n1 && n1 == child); CHECK_STRING(n1.name(), STR("child")); CHECK_NODE(doc, STR("<node><child>bar</child>foo</node>")); xml_node n2 = doc.child(STR("node")).insert_move_before(doc.child(STR("node")).last_child(), child); CHECK(n2 && n2 != n1); CHECK_STRING(n2.value(), STR("foo")); CHECK_NODE(doc, STR("<node>foo<child>bar</child></node>")); xml_node n3 = child.insert_move_before(doc.child(STR("node")).first_child(), child.first_child()); CHECK(n3 && n3 != n1 && n3 == n2); CHECK_STRING(n3.value(), STR("foo")); CHECK_NODE(doc, STR("<node><child>foobar</child></node>")); } TEST_XML(dom_node_move_recursive, "<root><node>foo<child/></node></root>") { xml_node root = doc.child(STR("root")); xml_node node = root.child(STR("node")); xml_node foo = node.first_child(); xml_node child = node.last_child(); CHECK(node.prepend_move(node) == xml_node()); CHECK(node.prepend_move(root) == xml_node()); CHECK(node.append_move(node) == xml_node()); CHECK(node.append_move(root) == xml_node()); CHECK(node.insert_move_before(node, foo) == xml_node()); CHECK(node.insert_move_before(root, foo) == xml_node()); CHECK(node.insert_move_after(node, foo) == xml_node()); CHECK(node.insert_move_after(root, foo) == xml_node()); CHECK(child.append_move(node) == xml_node()); CHECK_NODE(doc, STR("<root><node>foo<child/></node></root>")); } TEST_XML(dom_node_move_marker, "<node />") { xml_node node = doc.child(STR("node")); CHECK(doc.insert_move_before(node, node) == xml_node()); CHECK(doc.insert_move_after(node, node) == xml_node()); CHECK_NODE(doc, STR("<node/>")); } TEST_XML(dom_node_move_crossdoc, "<node/>") { xml_document newdoc; CHECK(newdoc.append_move(doc.child(STR("node"))) == xml_node()); CHECK_NODE(newdoc, STR("")); } TEST_XML(dom_node_move_tree, "<root><n1 a1='v1'><c1/>t1</n1><n2 a2='v2'><c2/>t2</n2><n3 a3='v3'><c3/>t3</n3><n4 a4='v4'><c4/>t4</n4></root>") { xml_node root = doc.child(STR("root")); xml_node n1 = root.child(STR("n1")); xml_node n2 = root.child(STR("n2")); xml_node n3 = root.child(STR("n3")); xml_node n4 = root.child(STR("n4")); // n2 n1 n3 n4 CHECK(n2 == root.prepend_move(n2)); // n2 n3 n4 n1 CHECK(n1 == root.append_move(n1)); // n2 n4 n3 n1 CHECK(n4 == root.insert_move_before(n4, n3)); // n2 n4 n1 + n3 CHECK(n3 == doc.insert_move_after(n3, root)); CHECK_NODE(doc, STR("<root><n2 a2=\"v2\"><c2/>t2</n2><n4 a4=\"v4\"><c4/>t4</n4><n1 a1=\"v1\"><c1/>t1</n1></root><n3 a3=\"v3\"><c3/>t3</n3>")); CHECK(n1 == root.child(STR("n1"))); CHECK(n2 == root.child(STR("n2"))); CHECK(n3 == doc.child(STR("n3"))); CHECK(n4 == root.child(STR("n4"))); } TEST(dom_node_copy_stackless) { unsigned int count = 20000; std::basic_string<char_t> data; for (unsigned int i = 0; i < count; ++i) data += STR("<a>"); data += STR("text"); for (unsigned int j = 0; j < count; ++j) data += STR("</a>"); xml_document doc; CHECK(doc.load_string(data.c_str())); xml_document copy; CHECK(copy.append_copy(doc.first_child())); CHECK_NODE(doc, data.c_str()); } TEST(dom_node_copy_copyless) { std::basic_string<char_t> data; data += STR("<node>"); for (int i = 0; i < 10000; ++i) data += STR("pcdata"); data += STR("<?name value?><child attr1=\"\" attr2=\"value2\"/></node>"); std::basic_string<char_t> datacopy = data; // the document is parsed in-place so there should only be 1 page worth of allocations test_runner::_memory_fail_threshold = 32768 + 128; #ifdef PUGIXML_COMPACT // ... and some space for hash table test_runner::_memory_fail_threshold += 2048; #endif xml_document doc; CHECK(doc.load_buffer_inplace(&datacopy[0], datacopy.size() * sizeof(char_t), parse_full)); // this copy should share all string storage; since there are not a lot of nodes we should not have *any* allocations here (everything will fit in the same page in the document) xml_node copy = doc.append_copy(doc.child(STR("node"))); xml_node copy2 = doc.append_copy(copy); CHECK_NODE(copy, data.c_str()); CHECK_NODE(copy2, data.c_str()); } TEST(dom_node_copy_copyless_mix) { xml_document doc; CHECK(doc.load_string(STR("<node>pcdata<?name value?><child attr1=\"\" attr2=\"value2\" /></node>"), parse_full)); xml_node child = doc.child(STR("node")).child(STR("child")); child.set_name(STR("copychild")); child.attribute(STR("attr2")).set_name(STR("copyattr2")); child.attribute(STR("attr1")).set_value(STR("copyvalue1")); std::basic_string<char_t> data; for (int i = 0; i < 10000; ++i) data += STR("pcdata"); doc.child(STR("node")).text().set(data.c_str()); xml_node copy = doc.append_copy(doc.child(STR("node"))); xml_node copy2 = doc.append_copy(copy); std::basic_string<char_t> dataxml; dataxml += STR("<node>"); dataxml += data; dataxml += STR("<?name value?><copychild attr1=\"copyvalue1\" copyattr2=\"value2\"/></node>"); CHECK_NODE(copy, dataxml.c_str()); CHECK_NODE(copy2, dataxml.c_str()); } TEST_XML(dom_node_copy_copyless_taint, "<node attr=\"value\" />") { xml_node node = doc.child(STR("node")); xml_node copy = doc.append_copy(node); CHECK_NODE(doc, STR("<node attr=\"value\"/><node attr=\"value\"/>")); node.set_name(STR("nod1")); CHECK_NODE(doc, STR("<nod1 attr=\"value\"/><node attr=\"value\"/>")); xml_node copy2 = doc.append_copy(copy); CHECK_NODE(doc, STR("<nod1 attr=\"value\"/><node attr=\"value\"/><node attr=\"value\"/>")); copy.attribute(STR("attr")).set_value(STR("valu2")); CHECK_NODE(doc, STR("<nod1 attr=\"value\"/><node attr=\"valu2\"/><node attr=\"value\"/>")); copy2.attribute(STR("attr")).set_name(STR("att3")); CHECK_NODE(doc, STR("<nod1 attr=\"value\"/><node attr=\"valu2\"/><node att3=\"value\"/>")); } TEST(dom_node_copy_attribute_copyless) { std::basic_string<char_t> data; data += STR("<node attr=\""); for (int i = 0; i < 10000; ++i) data += STR("data"); data += STR("\"/>"); std::basic_string<char_t> datacopy = data; // the document is parsed in-place so there should only be 1 page worth of allocations test_runner::_memory_fail_threshold = 32768 + 128; #ifdef PUGIXML_COMPACT // ... and some space for hash table test_runner::_memory_fail_threshold += 2048; #endif xml_document doc; CHECK(doc.load_buffer_inplace(&datacopy[0], datacopy.size() * sizeof(char_t), parse_full)); // this copy should share all string storage; since there are not a lot of nodes we should not have *any* allocations here (everything will fit in the same page in the document) xml_node copy1 = doc.append_child(STR("node")); copy1.append_copy(doc.first_child().first_attribute()); xml_node copy2 = doc.append_child(STR("node")); copy2.append_copy(copy1.first_attribute()); CHECK_NODE(copy1, data.c_str()); CHECK_NODE(copy2, data.c_str()); } TEST_XML(dom_node_copy_attribute_copyless_taint, "<node attr=\"value\" />") { xml_node node = doc.child(STR("node")); xml_attribute attr = node.first_attribute(); xml_node copy1 = doc.append_child(STR("copy1")); xml_node copy2 = doc.append_child(STR("copy2")); xml_node copy3 = doc.append_child(STR("copy3")); CHECK_NODE(doc, STR("<node attr=\"value\"/><copy1/><copy2/><copy3/>")); copy1.append_copy(attr); CHECK_NODE(doc, STR("<node attr=\"value\"/><copy1 attr=\"value\"/><copy2/><copy3/>")); attr.set_name(STR("att1")); copy2.append_copy(attr); CHECK_NODE(doc, STR("<node att1=\"value\"/><copy1 attr=\"value\"/><copy2 att1=\"value\"/><copy3/>")); copy1.first_attribute().set_value(STR("valu2")); copy3.append_copy(copy1.first_attribute()); CHECK_NODE(doc, STR("<node att1=\"value\"/><copy1 attr=\"valu2\"/><copy2 att1=\"value\"/><copy3 attr=\"valu2\"/>")); } TEST_XML(dom_node_copy_out_of_memory_node, "<node><child1 /><child2 /><child3>text1<child4 />text2</child3></node>") { test_runner::_memory_fail_threshold = 32768 * 2 + 4096; xml_document copy; CHECK_ALLOC_FAIL(for (int i = 0; i < 1000; ++i) copy.append_copy(doc.first_child())); } TEST_XML(dom_node_copy_out_of_memory_attr, "<node attr1='' attr2='' attr3='' attr4='' attr5='' attr6='' attr7='' attr8='' attr9='' attr10='' attr11='' attr12='' attr13='' attr14='' attr15='' />") { test_runner::_memory_fail_threshold = 32768 * 2 + 4096; xml_document copy; CHECK_ALLOC_FAIL(for (int i = 0; i < 1000; ++i) copy.append_copy(doc.first_child())); } TEST_XML(dom_node_remove_deallocate, "<node attr='value'>text</node>") { xml_node node = doc.child(STR("node")); xml_attribute attr = node.attribute(STR("attr")); attr.set_name(STR("longattr")); attr.set_value(STR("longvalue")); node.set_name(STR("longnode")); node.text().set(STR("longtext")); node.remove_attribute(attr); doc.remove_child(node); CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_set_deallocate, "<node attr='value'>text</node>") { xml_node node = doc.child(STR("node")); xml_attribute attr = node.attribute(STR("attr")); attr.set_name(STR("longattr")); attr.set_value(STR("longvalue")); node.set_name(STR("longnode")); attr.set_name(STR("")); attr.set_value(STR("")); node.set_name(STR("")); node.text().set(STR("")); CHECK_NODE(doc, STR("<:anonymous :anonymous=\"\"></:anonymous>")); } TEST(dom_node_copy_declaration_empty_name) { xml_document doc1; xml_node decl1 = doc1.append_child(node_declaration); decl1.set_name(STR("")); xml_document doc2; xml_node decl2 = doc2.append_copy(decl1); CHECK_STRING(decl2.name(), STR("")); } template <typename T> bool fp_equal(T lhs, T rhs) { // Several compilers compare float/double values on x87 stack without proper rounding // This causes roundtrip tests to fail, although they correctly preserve the data. #if (defined(_MSC_VER) && _MSC_VER < 1400) || defined(__MWERKS__) return memcmp(&lhs, &rhs, sizeof(T)) == 0; #else return lhs == rhs; #endif } TEST(dom_fp_roundtrip_min_max_float) { xml_document doc; xml_node node = doc.append_child(STR("node")); xml_attribute attr = node.append_attribute(STR("attr")); node.text().set(std::numeric_limits<float>::min()); CHECK(fp_equal(node.text().as_float(), std::numeric_limits<float>::min())); attr.set_value(std::numeric_limits<float>::max()); CHECK(fp_equal(attr.as_float(), std::numeric_limits<float>::max())); } TEST(dom_fp_roundtrip_min_max_double) { xml_document doc; xml_node node = doc.append_child(STR("node")); xml_attribute attr = node.append_attribute(STR("attr")); attr.set_value(std::numeric_limits<double>::min()); CHECK(fp_equal(attr.as_double(), std::numeric_limits<double>::min())); node.text().set(std::numeric_limits<double>::max()); CHECK(fp_equal(node.text().as_double(), std::numeric_limits<double>::max())); } TEST(dom_fp_double_custom_precision) { xml_document doc; xml_node node = doc.append_child(STR("node")); xml_attribute attr = node.append_attribute(STR("attr")); attr.set_value(std::numeric_limits<double>::min(), 20); CHECK(fp_equal(attr.as_double(), std::numeric_limits<double>::min())); attr.set_value(1.0f, 5); CHECK(fp_equal(attr.as_double(), static_cast<double>(1.0f))); attr.set_value(3.1415926f, 3); CHECK(!fp_equal(attr.as_double(), static_cast<double>(3.1415926f))); node.text().set(1.0f, 5); CHECK(fp_equal(node.text().as_double(), static_cast<double>(1.0f))); node.text().set(3.1415926f, 3); CHECK(!fp_equal(node.text().as_double(), static_cast<double>(3.1415926f))); node.text().set(std::numeric_limits<double>::max(), 20); CHECK(fp_equal(node.text().as_double(), std::numeric_limits<double>::max())); } const double fp_roundtrip_base[] = { 0.31830988618379067154, 0.43429448190325182765, 0.57721566490153286061, 0.69314718055994530942, 0.70710678118654752440, 0.78539816339744830962, }; TEST(dom_fp_roundtrip_float) { xml_document doc; for (int e = -125; e <= 128; ++e) { for (size_t i = 0; i < sizeof(fp_roundtrip_base) / sizeof(fp_roundtrip_base[0]); ++i) { float value = static_cast<float>(ldexp(fp_roundtrip_base[i], e)); doc.text().set(value); CHECK(fp_equal(doc.text().as_float(), value)); } } } // Borland C does not print double values with enough precision #ifndef __BORLANDC__ TEST(dom_fp_roundtrip_double) { xml_document doc; for (int e = -1021; e <= 1024; ++e) { for (size_t i = 0; i < sizeof(fp_roundtrip_base) / sizeof(fp_roundtrip_base[0]); ++i) { #if (defined(_MSC_VER) && _MSC_VER < 1400) || defined(__MWERKS__) // Not all runtime libraries guarantee roundtripping for denormals if (e == -1021 && fp_roundtrip_base[i] < 0.5) continue; #endif #ifdef __DMC__ // Digital Mars C does not roundtrip on exactly one combination if (e == -12 && i == 1) continue; #endif double value = ldexp(fp_roundtrip_base[i], e); doc.text().set(value); CHECK(fp_equal(doc.text().as_double(), value)); } } } #endif
; A062731: Sum of divisors of 2*n. ; Submitted by Christian Krause ; 3,7,12,15,18,28,24,31,39,42,36,60,42,56,72,63,54,91,60,90,96,84,72,124,93,98,120,120,90,168,96,127,144,126,144,195,114,140,168,186,126,224,132,180,234,168,144,252,171,217,216,210,162,280,216,248,240,210,180,360,186,224,312,255,252,336,204,270,288,336,216,403,222,266,372,300,288,392,240,378,363,294,252,480,324,308,360,372,270,546,336,360,384,336,360,508,294,399,468,465 add $0,1 mov $1,$0 mul $0,2 mov $2,$0 lpb $1 mov $3,$2 dif $3,$1 cmp $3,$2 cmp $3,0 mul $3,$1 add $0,$3 sub $1,1 lpe add $0,1
// Copyright 2014 The Chromium 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 "extensions/browser/api/bluetooth_socket/bluetooth_api_socket.h" #include "base/lazy_instance.h" #include "device/bluetooth/bluetooth_socket.h" #include "net/base/io_buffer.h" namespace { const char kSocketNotConnectedError[] = "Socket not connected"; const char kSocketNotListeningError[] = "Socket not listening"; } // namespace namespace extensions { // static static base::LazyInstance< BrowserContextKeyedAPIFactory<ApiResourceManager<BluetoothApiSocket> > > g_server_factory = LAZY_INSTANCE_INITIALIZER; // static template <> BrowserContextKeyedAPIFactory<ApiResourceManager<BluetoothApiSocket> >* ApiResourceManager<BluetoothApiSocket>::GetFactoryInstance() { return g_server_factory.Pointer(); } BluetoothApiSocket::BluetoothApiSocket(const std::string& owner_extension_id) : ApiResource(owner_extension_id), persistent_(false), buffer_size_(0), paused_(false), connected_(false) { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); } BluetoothApiSocket::BluetoothApiSocket( const std::string& owner_extension_id, scoped_refptr<device::BluetoothSocket> socket, const std::string& device_address, const device::BluetoothUUID& uuid) : ApiResource(owner_extension_id), socket_(socket), device_address_(device_address), uuid_(uuid), persistent_(false), buffer_size_(0), paused_(true), connected_(true) { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); } BluetoothApiSocket::~BluetoothApiSocket() { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); if (socket_.get()) socket_->Close(); } void BluetoothApiSocket::AdoptConnectedSocket( scoped_refptr<device::BluetoothSocket> socket, const std::string& device_address, const device::BluetoothUUID& uuid) { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); if (socket_.get()) socket_->Close(); socket_ = socket; device_address_ = device_address; uuid_ = uuid; connected_ = true; } void BluetoothApiSocket::AdoptListeningSocket( scoped_refptr<device::BluetoothSocket> socket, const device::BluetoothUUID& uuid) { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); if (socket_.get()) socket_->Close(); socket_ = socket; device_address_ = ""; uuid_ = uuid; connected_ = false; } void BluetoothApiSocket::Disconnect(const base::Closure& callback) { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); if (!socket_.get()) { callback.Run(); return; } connected_ = false; socket_->Disconnect(callback); } bool BluetoothApiSocket::IsPersistent() const { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); return persistent_; } void BluetoothApiSocket::Receive( int count, const ReceiveCompletionCallback& success_callback, const ErrorCompletionCallback& error_callback) { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); if (!socket_.get() || !IsConnected()) { error_callback.Run(BluetoothApiSocket::kNotConnected, kSocketNotConnectedError); return; } socket_->Receive(count, success_callback, base::Bind(&OnSocketReceiveError, error_callback)); } // static void BluetoothApiSocket::OnSocketReceiveError( const ErrorCompletionCallback& error_callback, device::BluetoothSocket::ErrorReason reason, const std::string& message) { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); BluetoothApiSocket::ErrorReason error_reason; switch (reason) { case device::BluetoothSocket::kIOPending: error_reason = BluetoothApiSocket::kIOPending; break; case device::BluetoothSocket::kDisconnected: error_reason = BluetoothApiSocket::kDisconnected; break; case device::BluetoothSocket::kSystemError: error_reason = BluetoothApiSocket::kSystemError; break; } error_callback.Run(error_reason, message); } void BluetoothApiSocket::Send(scoped_refptr<net::IOBuffer> buffer, int buffer_size, const SendCompletionCallback& success_callback, const ErrorCompletionCallback& error_callback) { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); if (!socket_.get() || !IsConnected()) { error_callback.Run(BluetoothApiSocket::kNotConnected, kSocketNotConnectedError); return; } socket_->Send(buffer, buffer_size, success_callback, base::Bind(&OnSocketSendError, error_callback)); } // static void BluetoothApiSocket::OnSocketSendError( const ErrorCompletionCallback& error_callback, const std::string& message) { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); error_callback.Run(BluetoothApiSocket::kSystemError, message); } void BluetoothApiSocket::Accept( const AcceptCompletionCallback& success_callback, const ErrorCompletionCallback& error_callback) { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); if (!socket_.get() || IsConnected()) { error_callback.Run(BluetoothApiSocket::kNotListening, kSocketNotListeningError); return; } socket_->Accept(success_callback, base::Bind(&OnSocketAcceptError, error_callback)); } // static void BluetoothApiSocket::OnSocketAcceptError( const ErrorCompletionCallback& error_callback, const std::string& message) { DCHECK(content::BrowserThread::CurrentlyOn(kThreadId)); error_callback.Run(BluetoothApiSocket::kSystemError, message); } } // namespace extensions
#include <cstdio> #include "NCInterface.H" #include <AMReX.H> #define abort_func amrex::Abort namespace ncutils { namespace { char recname[NC_MAX_NAME + 1]; void check_nc_error(int ierr) { if (ierr != NC_NOERR) { printf("\n%s\n\n", nc_strerror(ierr)); abort_func("Encountered NetCDF error; aborting"); } } } // namespace std::string NCDim::name() const { check_nc_error(nc_inq_dimname(ncid, dimid, recname)); return std::string(recname); } size_t NCDim::len() const { size_t dlen; check_nc_error(nc_inq_dimlen(ncid, dimid, &dlen)); return dlen; } std::string NCVar::name() const { check_nc_error(nc_inq_varname(ncid, varid, recname)); return std::string(recname); } int NCVar::ndim() const { int ndims; check_nc_error(nc_inq_varndims(ncid, varid, &ndims)); return ndims; } std::vector<size_t> NCVar::shape() const { int ndims = ndim(); std::vector<int> dimids(ndims); std::vector<size_t> vshape(ndims); for (int i = 0; i < ndims; ++i) check_nc_error(nc_inq_vardimid(ncid, varid, dimids.data())); for (int i = 0; i < ndims; ++i) check_nc_error(nc_inq_dimlen(ncid, dimids[i], &vshape[i])); return vshape; } void NCVar::put(const double* ptr) const { check_nc_error(nc_put_var_double(ncid, varid, ptr)); } void NCVar::put(const float* ptr) const { check_nc_error(nc_put_var_float(ncid, varid, ptr)); } void NCVar::put(const int* ptr) const { check_nc_error(nc_put_var_int(ncid, varid, ptr)); } void NCVar::put( const double* dptr, const std::vector<size_t>& start, const std::vector<size_t>& count) const { check_nc_error( nc_put_vara_double(ncid, varid, start.data(), count.data(), dptr)); } void NCVar::put( const double* dptr, const std::vector<size_t>& start, const std::vector<size_t>& count, const std::vector<ptrdiff_t>& stride) const { check_nc_error(nc_put_vars_double( ncid, varid, start.data(), count.data(), stride.data(), dptr)); } void NCVar::put( const float* dptr, const std::vector<size_t>& start, const std::vector<size_t>& count) const { check_nc_error( nc_put_vara_float(ncid, varid, start.data(), count.data(), dptr)); } void NCVar::put( const float* dptr, const std::vector<size_t>& start, const std::vector<size_t>& count, const std::vector<ptrdiff_t>& stride) const { check_nc_error(nc_put_vars_float( ncid, varid, start.data(), count.data(), stride.data(), dptr)); } void NCVar::put( const int* dptr, const std::vector<size_t>& start, const std::vector<size_t>& count) const { check_nc_error( nc_put_vara_int(ncid, varid, start.data(), count.data(), dptr)); } void NCVar::put( const int* dptr, const std::vector<size_t>& start, const std::vector<size_t>& count, const std::vector<ptrdiff_t>& stride) const { check_nc_error(nc_put_vars_int( ncid, varid, start.data(), count.data(), stride.data(), dptr)); } void NCVar::put( const char** dptr, const std::vector<size_t>& start, const std::vector<size_t>& count) const { check_nc_error( nc_put_vara_string(ncid, varid, start.data(), count.data(), dptr)); } void NCVar::put( const char** dptr, const std::vector<size_t>& start, const std::vector<size_t>& count, const std::vector<ptrdiff_t>& stride) const { check_nc_error(nc_put_vars_string( ncid, varid, start.data(), count.data(), stride.data(), dptr)); } void NCVar::get(double* ptr) const { check_nc_error(nc_get_var_double(ncid, varid, ptr)); } void NCVar::get(float* ptr) const { check_nc_error(nc_get_var_float(ncid, varid, ptr)); } void NCVar::get(int* ptr) const { check_nc_error(nc_get_var_int(ncid, varid, ptr)); } void NCVar::get( double* dptr, const std::vector<size_t>& start, const std::vector<size_t>& count) const { check_nc_error( nc_get_vara_double(ncid, varid, start.data(), count.data(), dptr)); } void NCVar::get( double* dptr, const std::vector<size_t>& start, const std::vector<size_t>& count, const std::vector<ptrdiff_t>& stride) const { check_nc_error(nc_get_vars_double( ncid, varid, start.data(), count.data(), stride.data(), dptr)); } void NCVar::get( float* dptr, const std::vector<size_t>& start, const std::vector<size_t>& count) const { check_nc_error( nc_get_vara_float(ncid, varid, start.data(), count.data(), dptr)); } void NCVar::get( float* dptr, const std::vector<size_t>& start, const std::vector<size_t>& count, const std::vector<ptrdiff_t>& stride) const { check_nc_error(nc_get_vars_float( ncid, varid, start.data(), count.data(), stride.data(), dptr)); } void NCVar::get( int* dptr, const std::vector<size_t>& start, const std::vector<size_t>& count) const { check_nc_error( nc_get_vara_int(ncid, varid, start.data(), count.data(), dptr)); } void NCVar::get( int* dptr, const std::vector<size_t>& start, const std::vector<size_t>& count, const std::vector<ptrdiff_t>& stride) const { check_nc_error(nc_get_vars_int( ncid, varid, start.data(), count.data(), stride.data(), dptr)); } bool NCVar::has_attr(const std::string& name) const { int ierr; size_t lenp; ierr = nc_inq_att(ncid, varid, name.data(), NULL, &lenp); return (ierr == NC_NOERR); } void NCVar::put_attr(const std::string& name, const std::string& value) const { check_nc_error( nc_put_att_text(ncid, varid, name.data(), value.size(), value.data())); } void NCVar::put_attr( const std::string& name, const std::vector<double>& value) const { check_nc_error(nc_put_att_double( ncid, varid, name.data(), NC_DOUBLE, value.size(), value.data())); } void NCVar::put_attr( const std::string& name, const std::vector<float>& value) const { check_nc_error(nc_put_att_float( ncid, varid, name.data(), NC_FLOAT, value.size(), value.data())); } void NCVar::put_attr( const std::string& name, const std::vector<int>& value) const { check_nc_error(nc_put_att_int( ncid, varid, name.data(), NC_INT, value.size(), value.data())); } std::string NCVar::get_attr(const std::string& name) const { size_t lenp; std::vector<char> aval; check_nc_error(nc_inq_attlen(ncid, varid, name.data(), &lenp)); aval.resize(lenp); check_nc_error(nc_get_att_text(ncid, varid, name.data(), aval.data())); return std::string{aval.begin(), aval.end()}; } void NCVar::get_attr(const std::string& name, std::vector<double>& values) const { size_t lenp; check_nc_error(nc_inq_attlen(ncid, varid, name.data(), &lenp)); values.resize(lenp); check_nc_error(nc_get_att_double(ncid, varid, name.data(), values.data())); } void NCVar::get_attr(const std::string& name, std::vector<float>& values) const { size_t lenp; check_nc_error(nc_inq_attlen(ncid, varid, name.data(), &lenp)); values.resize(lenp); check_nc_error(nc_get_att_float(ncid, varid, name.data(), values.data())); } void NCVar::get_attr(const std::string& name, std::vector<int>& values) const { size_t lenp; check_nc_error(nc_inq_attlen(ncid, varid, name.data(), &lenp)); values.resize(lenp); check_nc_error(nc_get_att_int(ncid, varid, name.data(), values.data())); } //Uncomment for parallel NetCDF /* void NCVar::par_access(const int cmode) const { check_nc_error(nc_var_par_access(ncid, varid, cmode)); } */ std::string NCGroup::name() const { size_t nlen; std::vector<char> grpname; check_nc_error(nc_inq_grpname_len(ncid, &nlen)); grpname.resize(nlen + 1); check_nc_error(nc_inq_grpname(ncid, grpname.data())); return std::string{grpname.begin(), grpname.end()}; } std::string NCGroup::full_name() const { size_t nlen; std::vector<char> grpname; check_nc_error(nc_inq_grpname_full(ncid, &nlen, NULL)); grpname.resize(nlen); check_nc_error(nc_inq_grpname_full(ncid, &nlen, grpname.data())); return std::string{grpname.begin(), grpname.end()}; } NCGroup NCGroup::def_group(const std::string& name) const { int newid; check_nc_error(nc_def_grp(ncid, name.data(), &newid)); return NCGroup(newid, this); } NCGroup NCGroup::group(const std::string& name) const { int newid; check_nc_error(nc_inq_ncid(ncid, name.data(), &newid)); return NCGroup(newid, this); } NCDim NCGroup::dim(const std::string& name) const { int newid; check_nc_error(nc_inq_dimid(ncid, name.data(), &newid)); return NCDim{ncid, newid}; } NCDim NCGroup::def_dim(const std::string& name, const size_t len) const { int newid; check_nc_error(nc_def_dim(ncid, name.data(), len, &newid)); return NCDim{ncid, newid}; } NCVar NCGroup::def_scalar(const std::string& name, const nc_type dtype) const { int newid; check_nc_error(nc_def_var(ncid, name.data(), dtype, 0, NULL, &newid)); return NCVar{ncid, newid}; } NCVar NCGroup::def_array( const std::string& name, const nc_type dtype, const std::vector<std::string>& dnames) const { int newid; int ndims = dnames.size(); std::vector<int> dimids(ndims); for (int i = 0; i < ndims; ++i) dimids[i] = dim(dnames[i]).dimid; check_nc_error( nc_def_var(ncid, name.data(), dtype, ndims, dimids.data(), &newid)); return NCVar{ncid, newid}; } NCVar NCGroup::var(const std::string& name) const { int varid; check_nc_error(nc_inq_varid(ncid, name.data(), &varid)); return NCVar{ncid, varid}; } int NCGroup::num_groups() const { int ngrps; check_nc_error(nc_inq_grps(ncid, &ngrps, NULL)); return ngrps; } int NCGroup::num_dimensions() const { int ndims; check_nc_error(nc_inq(ncid, &ndims, NULL, NULL, NULL)); return ndims; } int NCGroup::num_attributes() const { int nattrs; check_nc_error(nc_inq(ncid, NULL, NULL, &nattrs, NULL)); return nattrs; } int NCGroup::num_variables() const { int nvars; check_nc_error(nc_inq(ncid, NULL, &nvars, NULL, NULL)); return nvars; } bool NCGroup::has_group(const std::string& name) const { int ierr = nc_inq_ncid(ncid, name.data(), NULL); return (ierr == NC_NOERR); } bool NCGroup::has_dim(const std::string& name) const { int ierr = nc_inq_dimid(ncid, name.data(), NULL); return (ierr == NC_NOERR); } bool NCGroup::has_var(const std::string& name) const { int ierr = nc_inq_varid(ncid, name.data(), NULL); return (ierr == NC_NOERR); } bool NCGroup::has_attr(const std::string& name) const { int ierr; size_t lenp; ierr = nc_inq_att(ncid, NC_GLOBAL, name.data(), NULL, &lenp); return (ierr == NC_NOERR); } void NCGroup::put_attr(const std::string& name, const std::string& value) const { check_nc_error(nc_put_att_text( ncid, NC_GLOBAL, name.data(), value.size(), value.data())); } void NCGroup::put_attr( const std::string& name, const std::vector<double>& value) const { check_nc_error(nc_put_att_double( ncid, NC_GLOBAL, name.data(), NC_DOUBLE, value.size(), value.data())); } void NCGroup::put_attr( const std::string& name, const std::vector<float>& value) const { check_nc_error(nc_put_att_float( ncid, NC_GLOBAL, name.data(), NC_FLOAT, value.size(), value.data())); } void NCGroup::put_attr( const std::string& name, const std::vector<int>& value) const { check_nc_error(nc_put_att_int( ncid, NC_GLOBAL, name.data(), NC_INT, value.size(), value.data())); } std::string NCGroup::get_attr(const std::string& name) const { size_t lenp; std::vector<char> aval; check_nc_error(nc_inq_attlen(ncid, NC_GLOBAL, name.data(), &lenp)); aval.resize(lenp); check_nc_error(nc_get_att_text(ncid, NC_GLOBAL, name.data(), aval.data())); return std::string{aval.begin(), aval.end()}; } void NCGroup::get_attr( const std::string& name, std::vector<double>& values) const { size_t lenp; check_nc_error(nc_inq_attlen(ncid, NC_GLOBAL, name.data(), &lenp)); values.resize(lenp); check_nc_error( nc_get_att_double(ncid, NC_GLOBAL, name.data(), values.data())); } void NCGroup::get_attr( const std::string& name, std::vector<float>& values) const { size_t lenp; check_nc_error(nc_inq_attlen(ncid, NC_GLOBAL, name.data(), &lenp)); values.resize(lenp); check_nc_error( nc_get_att_float(ncid, NC_GLOBAL, name.data(), values.data())); } void NCGroup::get_attr(const std::string& name, std::vector<int>& values) const { size_t lenp; check_nc_error(nc_inq_attlen(ncid, NC_GLOBAL, name.data(), &lenp)); values.resize(lenp); check_nc_error(nc_get_att_int(ncid, NC_GLOBAL, name.data(), values.data())); } std::vector<NCGroup> NCGroup::all_groups() const { std::vector<NCGroup> grps; int ngrps = num_groups(); // Empty list of groups return early without error if (ngrps < 1) return grps; std::vector<int> gids(ngrps); check_nc_error(nc_inq_grps(ncid, &ngrps, gids.data())); grps.reserve(ngrps); for (int i = 0; i < ngrps; ++i) grps.emplace_back(NCGroup(gids[i], this)); return grps; } std::vector<NCDim> NCGroup::all_dims() const { std::vector<NCDim> adims; int ndims = num_dimensions(); adims.reserve(ndims); for (int i = 0; i < ndims; ++i) { adims.emplace_back(NCDim{ncid, i}); } return adims; } std::vector<NCVar> NCGroup::all_vars() const { std::vector<NCVar> avars; int nvars = num_variables(); avars.reserve(nvars); for (int i = 0; i < nvars; ++i) { avars.emplace_back(NCVar{ncid, i}); } return avars; } void NCGroup::enter_def_mode() const { int ierr; ierr = nc_redef(ncid); // Ignore already in define mode error if (ierr == NC_EINDEFINE) return; // Handle all other errors check_nc_error(ierr); } void NCGroup::exit_def_mode() const { check_nc_error(nc_enddef(ncid)); } NCFile NCFile::create(const std::string& name, const int cmode) { int ncid; check_nc_error(nc_create(name.data(), cmode, &ncid)); return NCFile(ncid); } NCFile NCFile::open(const std::string& name, const int cmode) { int ncid; check_nc_error(nc_open(name.data(), cmode, &ncid)); return NCFile(ncid); } //Uncomment for parallel NetCDF /* NCFile NCFile::create_par( const std::string& name, const int cmode, MPI_Comm comm, MPI_Info info) { int ncid; check_nc_error(nc_create_par(name.data(), cmode, comm, info, &ncid)); return NCFile(ncid); } //Uncomment for parallel NetCDF NCFile NCFile::open_par( const std::string& name, const int cmode, MPI_Comm comm, MPI_Info info) { int ncid; check_nc_error(nc_open_par(name.data(), cmode, comm, info, &ncid)); return NCFile(ncid); } */ NCFile::~NCFile() { if (is_open) check_nc_error(nc_close(ncid)); } void NCFile::close() { is_open = false; check_nc_error(nc_close(ncid)); } } // namespace ncutils
%ifdef CONFIG { "Match": "All", "RegData": { "RBX": "0xFFFFFFFFFFFF00D1", "RCX": "0x00000000000000D1", "RDX": "0xDAD1", "RDI": "0xDAD1" } } %endif mov rax, qword 0xDEADBEEFBAD0DAD1 mov rbx, -1 mov rcx, -1 mov rdx, -1 mov rdi, -1 movzx bx, al ; 8bit-> 16bit movzx ecx, al ; 8bit-> 32bit movzx edx, ax ; 16bit-> 32bit movzx rdi, ax ; 16bit -> 64bit hlt
#include "afk/io/Unicode.hpp" using std::ostream; using std::u8string; ostream &operator<<(ostream &os, const char8_t *c) { return os << reinterpret_cast<const char *>(c); } ostream &operator<<(ostream &os, const u8string &s) { return os << reinterpret_cast<const char *>(s.data()); } auto afk::io::to_cstr(const std::u8string &s) -> const char * { return reinterpret_cast<const char *>(s.data()); } auto afk::io::to_cstr(const char8_t *s) -> const char * { return reinterpret_cast<const char *>(s); }
/* * Copyright (C) 2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/command_stream/preemption.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/test/common/cmd_parse/hw_parse.h" #include "shared/test/common/mocks/mock_debugger.h" #include "shared/test/common/mocks/mock_device.h" #include "test.h" #include <array> using namespace NEO; using PreemptionXeHPTest = ::testing::Test; XEHPTEST_F(PreemptionXeHPTest, givenRevisionA0toBWhenProgrammingSipThenGlobalSipIsSet) { using PIPE_CONTROL = XeHpFamily::PIPE_CONTROL; using MI_LOAD_REGISTER_IMM = XeHpFamily::MI_LOAD_REGISTER_IMM; using STATE_SIP = XeHpFamily::STATE_SIP; HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); std::array<uint32_t, 2> revisions = {hwInfoConfig.getHwRevIdFromStepping(REVID::REVISION_A0, hwInfo), hwInfoConfig.getHwRevIdFromStepping(REVID::REVISION_B, hwInfo)}; for (auto revision : revisions) { hwInfo.platform.usRevId = revision; std::unique_ptr<MockDevice> mockDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0)); mockDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(new MockDebugger); auto sipAllocation = SipKernel::getSipKernel(*mockDevice).getSipAllocation(); size_t requiredSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*mockDevice); StackVec<char, 1024> streamStorage(1024); LinearStream cmdStream{streamStorage.begin(), streamStorage.size()}; auto expectedGlobalSipWaSize = sizeof(PIPE_CONTROL) + 2 * sizeof(MI_LOAD_REGISTER_IMM); EXPECT_EQ(expectedGlobalSipWaSize, requiredSize); PreemptionHelper::programStateSip<FamilyType>(cmdStream, *mockDevice); EXPECT_NE(0U, cmdStream.getUsed()); GenCmdList cmdList; ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( cmdList, ptrOffset(cmdStream.getCpuBase(), 0), cmdStream.getUsed())); auto itorLRI = findMmio<FamilyType>(cmdList.begin(), cmdList.end(), 0xE42C); EXPECT_NE(cmdList.end(), itorLRI); auto cmdLRI = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itorLRI); auto sipAddress = cmdLRI->getDataDword() & 0xfffffff8; EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), sipAddress); } } XEHPTEST_F(PreemptionXeHPTest, givenRevisionA0toBWhenProgrammingSipEndWaThenGlobalSipIsRestored) { using PIPE_CONTROL = XeHpFamily::PIPE_CONTROL; using MI_LOAD_REGISTER_IMM = XeHpFamily::MI_LOAD_REGISTER_IMM; using STATE_SIP = XeHpFamily::STATE_SIP; HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); std::array<uint32_t, 2> revisions = {hwInfoConfig.getHwRevIdFromStepping(REVID::REVISION_A0, hwInfo), hwInfoConfig.getHwRevIdFromStepping(REVID::REVISION_B, hwInfo)}; for (auto revision : revisions) { hwInfo.platform.usRevId = revision; std::unique_ptr<MockDevice> mockDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo, 0)); mockDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(new MockDebugger); StackVec<char, 1024> streamStorage(1024); LinearStream cmdStream{streamStorage.begin(), streamStorage.size()}; PreemptionHelper::programStateSipEndWa<FamilyType>(cmdStream, *mockDevice); EXPECT_NE(0U, cmdStream.getUsed()); GenCmdList cmdList; ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( cmdList, ptrOffset(cmdStream.getCpuBase(), 0), cmdStream.getUsed())); auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end()); EXPECT_NE(cmdList.end(), itorPC); auto itorLRI = findMmio<FamilyType>(itorPC, cmdList.end(), 0xE42C); EXPECT_NE(cmdList.end(), itorLRI); auto cmdLRI = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itorLRI); auto sipAddress = cmdLRI->getDataDword() & 0xfffffff8; EXPECT_EQ(0u, sipAddress); } }
; A024912: Numbers k such that 10*k + 1 is prime. ; 1,3,4,6,7,10,13,15,18,19,21,24,25,27,28,31,33,40,42,43,46,49,52,54,57,60,63,64,66,69,70,75,76,81,82,88,91,94,97,99,102,103,105,106,109,115,117,118,120,123,129,130,132,136,138,145,147,148,151,153,157,160,162,172,174,180,181,183,186,187,190,193,195,201,208,211,213,214,216,222,225,228,231,234,235,237,238,241,244,252,253,255,259,262,267,271,273,274,279,280 seq $0,126785 ; Numbers k such that 10*k + 11 is prime. add $0,1
/********************************************************************** Audacity: A Digital Audio Editor ChangeSpeed.cpp Vaughan Johnson, Dominic Mazzoni *******************************************************************//** \class EffectChangeSpeed \brief An Effect that affects both pitch & speed. *//*******************************************************************/ #include "../Audacity.h" #include "ChangeSpeed.h" #include <math.h> #include <wx/intl.h> #include "../LabelTrack.h" #include "../Prefs.h" #include "../Project.h" #include "../Resample.h" #include "../ShuttleGui.h" #include "../widgets/valnum.h" #include "TimeWarper.h" #include "../WaveTrack.h" enum { ID_PercentChange = 10000, ID_Multiplier, ID_FromVinyl, ID_ToVinyl, ID_ToLength }; // the standard vinyl rpm choices // If the percent change is not one of these ratios, the choice control gets "n/a". enum kVinyl { kVinyl_33AndAThird = 0, kVinyl_45, kVinyl_78, kVinyl_NA, nVinyl }; static const wxChar *kVinylStrings[nVinyl] = { wxT("33\u2153"), wxT("45"), wxT("78"), /* i18n-hint: n/a is an English abbreviation meaning "not applicable". */ XO("n/a"), }; // Soundtouch is not reasonable below -99% or above 3000%. // Define keys, defaults, minimums, and maximums for the effect parameters // // Name Type Key Def Min Max Scale Param( Percentage, double, wxT("Percentage"), 0.0, -99.0, 4900.0, 1 ); // We warp the slider to go up to 400%, but user can enter higher values static const double kSliderMax = 100.0; // warped above zero to actually go up to 400% static const double kSliderWarp = 1.30105; // warp power takes max from 100 to 400. // // EffectChangeSpeed // BEGIN_EVENT_TABLE(EffectChangeSpeed, wxEvtHandler) EVT_TEXT(ID_PercentChange, EffectChangeSpeed::OnText_PercentChange) EVT_TEXT(ID_Multiplier, EffectChangeSpeed::OnText_Multiplier) EVT_SLIDER(ID_PercentChange, EffectChangeSpeed::OnSlider_PercentChange) EVT_CHOICE(ID_FromVinyl, EffectChangeSpeed::OnChoice_Vinyl) EVT_CHOICE(ID_ToVinyl, EffectChangeSpeed::OnChoice_Vinyl) EVT_TEXT(ID_ToLength, EffectChangeSpeed::OnTimeCtrl_ToLength) EVT_COMMAND(ID_ToLength, EVT_TIMETEXTCTRL_UPDATED, EffectChangeSpeed::OnTimeCtrlUpdate) END_EVENT_TABLE() EffectChangeSpeed::EffectChangeSpeed() { // effect parameters m_PercentChange = DEF_Percentage; mFromVinyl = kVinyl_33AndAThird; mToVinyl = kVinyl_33AndAThird; mFromLength = 0.0; mToLength = 0.0; mFormat = _("hh:mm:ss + milliseconds"); mbLoopDetect = false; SetLinearEffectFlag(true); } EffectChangeSpeed::~EffectChangeSpeed() { } // IdentInterface implementation wxString EffectChangeSpeed::GetSymbol() { return CHANGESPEED_PLUGIN_SYMBOL; } wxString EffectChangeSpeed::GetDescription() { return _("Changes the speed of a track, also changing its pitch"); } wxString EffectChangeSpeed::ManualPage() { return wxT("Change_Speed"); } // EffectDefinitionInterface implementation EffectType EffectChangeSpeed::GetType() { return EffectTypeProcess; } // EffectClientInterface implementation bool EffectChangeSpeed::DefineParams( ShuttleParams & S ){ S.SHUTTLE_PARAM( m_PercentChange, Percentage ); return true; } bool EffectChangeSpeed::GetAutomationParameters(CommandParameters & parms) { parms.Write(KEY_Percentage, m_PercentChange); return true; } bool EffectChangeSpeed::SetAutomationParameters(CommandParameters & parms) { ReadAndVerifyDouble(Percentage); m_PercentChange = Percentage; return true; } bool EffectChangeSpeed::LoadFactoryDefaults() { mFromVinyl = kVinyl_33AndAThird; mFormat = _("hh:mm:ss + milliseconds"); return Effect::LoadFactoryDefaults(); } // Effect implementation bool EffectChangeSpeed::CheckWhetherSkipEffect() { return (m_PercentChange == 0.0); } double EffectChangeSpeed::CalcPreviewInputLength(double previewLength) { return previewLength * (100.0 + m_PercentChange) / 100.0; } bool EffectChangeSpeed::Startup() { wxString base = wxT("/Effects/ChangeSpeed/"); // Migrate settings from 2.1.0 or before // Already migrated, so bail if (gPrefs->Exists(base + wxT("Migrated"))) { return true; } // Load the old "current" settings if (gPrefs->Exists(base)) { // Retrieve last used control values gPrefs->Read(base + wxT("PercentChange"), &m_PercentChange, 0); // default format "4" is the same as the Selection toolbar: "hh:mm:ss + milliseconds"; gPrefs->Read(base + wxT("TimeFormat"), &mFormat, _("hh:mm:ss + milliseconds")); gPrefs->Read(base + wxT("VinylChoice"), &mFromVinyl, 0); if (mFromVinyl == kVinyl_NA) { mFromVinyl = kVinyl_33AndAThird; } SetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"), mFormat); SetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl); SaveUserPreset(GetCurrentSettingsGroup()); // Do not migrate again gPrefs->Write(base + wxT("Migrated"), true); gPrefs->Flush(); } return true; } bool EffectChangeSpeed::Init() { // The selection might have changed since the last time EffectChangeSpeed // was invoked, so recalculate the Length parameters. mFromLength = mT1 - mT0; return true; } bool EffectChangeSpeed::Process() { // Similar to EffectSoundTouch::Process() // Iterate over each track. // Track::All is needed because this effect needs to introduce // silence in the sync-lock group tracks to keep sync CopyInputTracks(Track::All); // Set up mOutputTracks. bool bGoodResult = true; TrackListIterator iter(mOutputTracks.get()); Track* t; mCurTrackNum = 0; mMaxNewLength = 0.0; mFactor = 100.0 / (100.0 + m_PercentChange); t = iter.First(); while (t != NULL) { if (t->GetKind() == Track::Label) { if (t->GetSelected() || t->IsSyncLockSelected()) { if (!ProcessLabelTrack(static_cast<LabelTrack*>(t))) { bGoodResult = false; break; } } } else if (t->GetKind() == Track::Wave && t->GetSelected()) { WaveTrack *pOutWaveTrack = (WaveTrack*)t; //Get start and end times from track mCurT0 = pOutWaveTrack->GetStartTime(); mCurT1 = pOutWaveTrack->GetEndTime(); //Set the current bounds to whichever left marker is //greater and whichever right marker is less: mCurT0 = wxMax(mT0, mCurT0); mCurT1 = wxMin(mT1, mCurT1); // Process only if the right marker is to the right of the left marker if (mCurT1 > mCurT0) { //Transform the marker timepoints to samples auto start = pOutWaveTrack->TimeToLongSamples(mCurT0); auto end = pOutWaveTrack->TimeToLongSamples(mCurT1); //ProcessOne() (implemented below) processes a single track if (!ProcessOne(pOutWaveTrack, start, end)) { bGoodResult = false; break; } } mCurTrackNum++; } else if (t->IsSyncLockSelected()) { t->SyncLockAdjust(mT1, mT0 + (mT1 - mT0) * mFactor); } //Iterate to the next track t=iter.Next(); } if (bGoodResult) ReplaceProcessedTracks(bGoodResult); // Update selection. mT1 = mT0 + (((mT1 - mT0) * 100.0) / (100.0 + m_PercentChange)); return bGoodResult; } void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S) { GetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"), mFormat, mFormat); GetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl, mFromVinyl); S.SetBorder(5); S.StartVerticalLay(0); { S.AddSpace(0, 5); S.AddTitle(_("Change Speed, affecting both Tempo and Pitch")); S.AddSpace(0, 10); // Speed multiplier and percent change controls. S.StartMultiColumn(4, wxCENTER); { FloatingPointValidator<double> vldMultiplier(3, &mMultiplier, NumValidatorStyle::THREE_TRAILING_ZEROES); vldMultiplier.SetRange(MIN_Percentage / 100.0, ((MAX_Percentage / 100.0) + 1)); mpTextCtrl_Multiplier = S.Id(ID_Multiplier).AddTextBox(_("Speed Multiplier:"), wxT(""), 12); mpTextCtrl_Multiplier->SetValidator(vldMultiplier); FloatingPointValidator<double> vldPercentage(3, &m_PercentChange, NumValidatorStyle::THREE_TRAILING_ZEROES); vldPercentage.SetRange(MIN_Percentage, MAX_Percentage); mpTextCtrl_PercentChange = S.Id(ID_PercentChange).AddTextBox(_("Percent Change:"), wxT(""), 12); mpTextCtrl_PercentChange->SetValidator(vldPercentage); } S.EndMultiColumn(); // Percent change slider. S.StartHorizontalLay(wxEXPAND); { S.SetStyle(wxSL_HORIZONTAL); mpSlider_PercentChange = S.Id(ID_PercentChange).AddSlider( {}, 0, (int)kSliderMax, (int)MIN_Percentage); mpSlider_PercentChange->SetName(_("Percent Change")); } S.EndHorizontalLay(); // Vinyl rpm controls. S.StartMultiColumn(5, wxCENTER); { /* i18n-hint: "rpm" is an English abbreviation meaning "revolutions per minute". */ S.AddUnits(_("Standard Vinyl rpm:")); wxASSERT(nVinyl == WXSIZEOF(kVinylStrings)); wxArrayString vinylChoices; for (int i = 0; i < nVinyl; i++) { if (i == kVinyl_NA) { vinylChoices.Add(wxGetTranslation(kVinylStrings[i])); } else { vinylChoices.Add(kVinylStrings[i]); } } mpChoice_FromVinyl = S.Id(ID_FromVinyl).AddChoice(_("from"), wxT(""), &vinylChoices); mpChoice_FromVinyl->SetName(_("From rpm")); mpChoice_FromVinyl->SetSizeHints(100, -1); mpChoice_ToVinyl = S.Id(ID_ToVinyl).AddChoice(_("to"), wxT(""), &vinylChoices); mpChoice_ToVinyl->SetName(_("To rpm")); mpChoice_ToVinyl->SetSizeHints(100, -1); } S.EndMultiColumn(); // From/To time controls. S.StartStatic(_("Selection Length"), 0); { S.StartMultiColumn(2, wxALIGN_LEFT); { S.AddPrompt(_("Current Length:")); mpFromLengthCtrl = safenew NumericTextCtrl(S.GetParent(), wxID_ANY, NumericConverter::TIME, mFormat, mFromLength, mProjectRate, NumericTextCtrl::Options{} .ReadOnly(true) .MenuEnabled(false)); mpFromLengthCtrl->SetName(_("from")); mpFromLengthCtrl->SetToolTip(_("Current length of selection.")); S.AddWindow(mpFromLengthCtrl, wxALIGN_LEFT); S.AddPrompt(_("New Length:")); mpToLengthCtrl = safenew NumericTextCtrl(S.GetParent(), ID_ToLength, NumericConverter::TIME, mFormat, mToLength, mProjectRate); mpToLengthCtrl->SetName(_("to")); S.AddWindow(mpToLengthCtrl, wxALIGN_LEFT); } S.EndMultiColumn(); } S.EndStatic(); } S.EndVerticalLay(); } bool EffectChangeSpeed::TransferDataToWindow() { mbLoopDetect = true; if (!mUIParent->TransferDataToWindow()) { return false; } if (mFromVinyl == kVinyl_NA) { mFromVinyl = kVinyl_33AndAThird; } Update_Text_PercentChange(); Update_Text_Multiplier(); Update_Slider_PercentChange(); Update_TimeCtrl_ToLength(); // Set from/to Vinyl controls - mFromVinyl must be set first. mpChoice_FromVinyl->SetSelection(mFromVinyl); // Then update to get correct mToVinyl. Update_Vinyl(); // Then update ToVinyl control. mpChoice_ToVinyl->SetSelection(mToVinyl); // Set From Length control. // Set the format first so we can get sample accuracy. mpFromLengthCtrl->SetFormatName(mFormat); mpFromLengthCtrl->SetValue(mFromLength); mbLoopDetect = false; return true; } bool EffectChangeSpeed::TransferDataFromWindow() { // mUIParent->TransferDataFromWindow() loses some precision, so save and restore it. double exactPercent = m_PercentChange; if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow()) { return false; } m_PercentChange = exactPercent; SetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"), mFormat); SetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl); return true; } // EffectChangeSpeed implementation // Labels are time-scaled linearly inside the affected region, and labels after // the region are shifted along according to how the region size changed. bool EffectChangeSpeed::ProcessLabelTrack(LabelTrack *lt) { RegionTimeWarper warper { mT0, mT1, std::make_unique<LinearTimeWarper>(mT0, mT0, mT1, mT0 + (mT1-mT0)*mFactor) }; lt->WarpLabels(warper); return true; } // ProcessOne() takes a track, transforms it to bunch of buffer-blocks, // and calls libsamplerate code on these blocks. bool EffectChangeSpeed::ProcessOne(WaveTrack * track, sampleCount start, sampleCount end) { if (track == NULL) return false; // initialization, per examples of Mixer::Mixer and // EffectSoundTouch::ProcessOne auto outputTrack = mFactory->NewWaveTrack(track->GetSampleFormat(), track->GetRate()); //Get the length of the selection (as double). len is //used simple to calculate a progress meter, so it is easier //to make it a double now than it is to do it later auto len = (end - start).as_double(); // Initiate processing buffers, most likely shorter than // the length of the selection being processed. auto inBufferSize = track->GetMaxBlockSize(); Floats inBuffer{ inBufferSize }; // mFactor is at most 100-fold so this shouldn't overflow size_t auto outBufferSize = size_t( mFactor * inBufferSize + 10 ); Floats outBuffer{ outBufferSize }; // Set up the resampling stuff for this track. Resample resample(true, mFactor, mFactor); // constant rate resampling //Go through the track one buffer at a time. samplePos counts which //sample the current buffer starts at. bool bResult = true; auto samplePos = start; while (samplePos < end) { //Get a blockSize of samples (smaller than the size of the buffer) auto blockSize = limitSampleBufferSize( track->GetBestBlockSize(samplePos), end - samplePos ); //Get the samples from the track and put them in the buffer track->Get((samplePtr) inBuffer.get(), floatSample, samplePos, blockSize); const auto results = resample.Process(mFactor, inBuffer.get(), blockSize, ((samplePos + blockSize) >= end), outBuffer.get(), outBufferSize); const auto outgen = results.second; if (outgen > 0) outputTrack->Append((samplePtr)outBuffer.get(), floatSample, outgen); // Increment samplePos samplePos += results.first; // Update the Progress meter if (TrackProgress(mCurTrackNum, (samplePos - start).as_double() / len)) { bResult = false; break; } } // Flush the output WaveTrack (since it's buffered, too) outputTrack->Flush(); // Take the output track and insert it in place of the original // sample data double newLength = outputTrack->GetEndTime(); if (bResult) { LinearTimeWarper warper { mCurT0, mCurT0, mCurT1, mCurT0 + newLength }; track->ClearAndPaste( mCurT0, mCurT1, outputTrack.get(), true, false, &warper); } if (newLength > mMaxNewLength) mMaxNewLength = newLength; return bResult; } // handler implementations for EffectChangeSpeed void EffectChangeSpeed::OnText_PercentChange(wxCommandEvent & WXUNUSED(evt)) { if (mbLoopDetect) return; mpTextCtrl_PercentChange->GetValidator()->TransferFromWindow(); UpdateUI(); mbLoopDetect = true; Update_Text_Multiplier(); Update_Slider_PercentChange(); Update_Vinyl(); Update_TimeCtrl_ToLength(); mbLoopDetect = false; } void EffectChangeSpeed::OnText_Multiplier(wxCommandEvent & WXUNUSED(evt)) { if (mbLoopDetect) return; mpTextCtrl_Multiplier->GetValidator()->TransferFromWindow(); m_PercentChange = 100 * (mMultiplier - 1); UpdateUI(); mbLoopDetect = true; Update_Text_PercentChange(); Update_Slider_PercentChange(); Update_Vinyl(); Update_TimeCtrl_ToLength(); mbLoopDetect = false; } void EffectChangeSpeed::OnSlider_PercentChange(wxCommandEvent & WXUNUSED(evt)) { if (mbLoopDetect) return; m_PercentChange = (double)(mpSlider_PercentChange->GetValue()); // Warp positive values to actually go up faster & further than negatives. if (m_PercentChange > 0.0) m_PercentChange = pow(m_PercentChange, kSliderWarp); UpdateUI(); mbLoopDetect = true; Update_Text_PercentChange(); Update_Text_Multiplier(); Update_Vinyl(); Update_TimeCtrl_ToLength(); mbLoopDetect = false; } void EffectChangeSpeed::OnChoice_Vinyl(wxCommandEvent & WXUNUSED(evt)) { // Treat mpChoice_FromVinyl and mpChoice_ToVinyl as one control since we need // both to calculate Percent Change. mFromVinyl = mpChoice_FromVinyl->GetSelection(); mToVinyl = mpChoice_ToVinyl->GetSelection(); // Use this as the 'preferred' choice. if (mFromVinyl != kVinyl_NA) { SetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl); } // If mFromVinyl & mToVinyl are set, then there's a NEW percent change. if ((mFromVinyl != kVinyl_NA) && (mToVinyl != kVinyl_NA)) { double fromRPM; double toRPM; switch (mFromVinyl) { default: case kVinyl_33AndAThird: fromRPM = 33.0 + (1.0 / 3.0); break; case kVinyl_45: fromRPM = 45.0; break; case kVinyl_78: fromRPM = 78; break; } switch (mToVinyl) { default: case kVinyl_33AndAThird: toRPM = 33.0 + (1.0 / 3.0); break; case kVinyl_45: toRPM = 45.0; break; case kVinyl_78: toRPM = 78; break; } m_PercentChange = ((toRPM * 100.0) / fromRPM) - 100.0; UpdateUI(); mbLoopDetect = true; Update_Text_PercentChange(); Update_Text_Multiplier(); Update_Slider_PercentChange(); Update_TimeCtrl_ToLength(); } mbLoopDetect = false; } void EffectChangeSpeed::OnTimeCtrl_ToLength(wxCommandEvent & WXUNUSED(evt)) { if (mbLoopDetect) return; mToLength = mpToLengthCtrl->GetValue(); // Division by (double) 0.0 is not an error and we want to show "infinite" in // text controls, so take care that we handle infinite values when they occur. m_PercentChange = ((mFromLength * 100.0) / mToLength) - 100.0; UpdateUI(); mbLoopDetect = true; Update_Text_PercentChange(); Update_Text_Multiplier(); Update_Slider_PercentChange(); Update_Vinyl(); mbLoopDetect = false; } void EffectChangeSpeed::OnTimeCtrlUpdate(wxCommandEvent & evt) { mFormat = evt.GetString(); mpFromLengthCtrl->SetFormatName(mFormat); // Update From/To Length controls (precision has changed). mpToLengthCtrl->SetValue(mToLength); mpFromLengthCtrl->SetValue(mFromLength); } // helper functions void EffectChangeSpeed::Update_Text_PercentChange() // Update Text Percent control from percent change. { mpTextCtrl_PercentChange->GetValidator()->TransferToWindow(); } void EffectChangeSpeed::Update_Text_Multiplier() // Update Multiplier control from percent change. { mMultiplier = 1 + (m_PercentChange) / 100.0; mpTextCtrl_Multiplier->GetValidator()->TransferToWindow(); } void EffectChangeSpeed::Update_Slider_PercentChange() // Update Slider Percent control from percent change. { auto unwarped = std::min<double>(m_PercentChange, MAX_Percentage); if (unwarped > 0.0) // Un-warp values above zero to actually go up to kSliderMax. unwarped = pow(m_PercentChange, (1.0 / kSliderWarp)); // Caution: m_PercentChange could be infinite. int unwarpedi = (int)(unwarped + 0.5); unwarpedi = std::min<int>(unwarpedi, (int)kSliderMax); mpSlider_PercentChange->SetValue(unwarpedi); } void EffectChangeSpeed::Update_Vinyl() // Update Vinyl controls from percent change. { // Match Vinyl rpm when within 0.01% of a standard ratio. // Ratios calculated as: ((toRPM / fromRPM) - 1) * 100 * 100 // Caution: m_PercentChange could be infinite int ratio = (int)((m_PercentChange * 100) + 0.5); switch (ratio) { case 0: // toRPM is the same as fromRPM if (mFromVinyl != kVinyl_NA) { mpChoice_ToVinyl->SetSelection(mpChoice_FromVinyl->GetSelection()); } else { // Use the last saved option. GetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl, 0); mpChoice_FromVinyl->SetSelection(mFromVinyl); mpChoice_ToVinyl->SetSelection(mFromVinyl); } break; case 3500: mpChoice_FromVinyl->SetSelection(kVinyl_33AndAThird); mpChoice_ToVinyl->SetSelection(kVinyl_45); break; case 13400: mpChoice_FromVinyl->SetSelection(kVinyl_33AndAThird); mpChoice_ToVinyl->SetSelection(kVinyl_78); break; case -2593: mpChoice_FromVinyl->SetSelection(kVinyl_45); mpChoice_ToVinyl->SetSelection(kVinyl_33AndAThird); break; case 7333: mpChoice_FromVinyl->SetSelection(kVinyl_45); mpChoice_ToVinyl->SetSelection(kVinyl_78); break; case -5727: mpChoice_FromVinyl->SetSelection(kVinyl_78); mpChoice_ToVinyl->SetSelection(kVinyl_33AndAThird); break; case -4231: mpChoice_FromVinyl->SetSelection(kVinyl_78); mpChoice_ToVinyl->SetSelection(kVinyl_45); break; default: mpChoice_ToVinyl->SetSelection(kVinyl_NA); } // and update variables. mFromVinyl = mpChoice_FromVinyl->GetSelection(); mToVinyl = mpChoice_ToVinyl->GetSelection(); } void EffectChangeSpeed::Update_TimeCtrl_ToLength() // Update ToLength control from percent change. { mToLength = (mFromLength * 100.0) / (100.0 + m_PercentChange); // Set the format first so we can get sample accuracy. mpToLengthCtrl->SetFormatName(mFormat); // Negative times do not make sense. // 359999 = 99h:59m:59s which is a little less disturbing than overflow characters // though it may still look a bit strange with some formats. mToLength = TrapDouble(mToLength, 0.0, 359999.0); mpToLengthCtrl->SetValue(mToLength); } void EffectChangeSpeed::UpdateUI() // Disable OK and Preview if not in sensible range. { EnableApply(m_PercentChange >= MIN_Percentage && m_PercentChange <= MAX_Percentage); }
; ; Copyright (c) 2016, Alliance for Open Media. All rights reserved ; ; This source code is subject to the terms of the BSD 2 Clause License and ; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License ; was not distributed with this source code in the LICENSE file, you can ; obtain it at www.aomedia.org/license/software. If the Alliance for Open ; Media Patent License 1.0 was not distributed with this source code in the ; PATENTS file, you can obtain it at www.aomedia.org/license/patent. ; ; %include "third_party/x86inc/x86inc.asm" ; This file provides SSSE3 version of the forward transformation. Part ; of the macro definitions are originally derived from the ffmpeg project. ; The current version applies to x86 64-bit only. SECTION_RODATA pw_11585x2: times 8 dw 23170 pd_8192: times 4 dd 8192 %macro TRANSFORM_COEFFS 2 pw_%1_%2: dw %1, %2, %1, %2, %1, %2, %1, %2 pw_%2_m%1: dw %2, -%1, %2, -%1, %2, -%1, %2, -%1 %endmacro TRANSFORM_COEFFS 11585, 11585 TRANSFORM_COEFFS 15137, 6270 TRANSFORM_COEFFS 16069, 3196 TRANSFORM_COEFFS 9102, 13623 SECTION .text %if ARCH_X86_64 %macro SUM_SUB 3 psubw m%3, m%1, m%2 paddw m%1, m%2 SWAP %2, %3 %endmacro ; butterfly operation %macro MUL_ADD_2X 6 ; dst1, dst2, src, round, coefs1, coefs2 pmaddwd m%1, m%3, %5 pmaddwd m%2, m%3, %6 paddd m%1, %4 paddd m%2, %4 psrad m%1, 14 psrad m%2, 14 %endmacro %macro BUTTERFLY_4X 7 ; dst1, dst2, coef1, coef2, round, tmp1, tmp2 punpckhwd m%6, m%2, m%1 MUL_ADD_2X %7, %6, %6, %5, [pw_%4_%3], [pw_%3_m%4] punpcklwd m%2, m%1 MUL_ADD_2X %1, %2, %2, %5, [pw_%4_%3], [pw_%3_m%4] packssdw m%1, m%7 packssdw m%2, m%6 %endmacro ; matrix transpose %macro INTERLEAVE_2X 4 punpckh%1 m%4, m%2, m%3 punpckl%1 m%2, m%3 SWAP %3, %4 %endmacro %macro TRANSPOSE8X8 9 INTERLEAVE_2X wd, %1, %2, %9 INTERLEAVE_2X wd, %3, %4, %9 INTERLEAVE_2X wd, %5, %6, %9 INTERLEAVE_2X wd, %7, %8, %9 INTERLEAVE_2X dq, %1, %3, %9 INTERLEAVE_2X dq, %2, %4, %9 INTERLEAVE_2X dq, %5, %7, %9 INTERLEAVE_2X dq, %6, %8, %9 INTERLEAVE_2X qdq, %1, %5, %9 INTERLEAVE_2X qdq, %3, %7, %9 INTERLEAVE_2X qdq, %2, %6, %9 INTERLEAVE_2X qdq, %4, %8, %9 SWAP %2, %5 SWAP %4, %7 %endmacro ; 1D forward 8x8 DCT transform %macro FDCT8_1D 1 SUM_SUB 0, 7, 9 SUM_SUB 1, 6, 9 SUM_SUB 2, 5, 9 SUM_SUB 3, 4, 9 SUM_SUB 0, 3, 9 SUM_SUB 1, 2, 9 SUM_SUB 6, 5, 9 %if %1 == 0 SUM_SUB 0, 1, 9 %endif BUTTERFLY_4X 2, 3, 6270, 15137, m8, 9, 10 pmulhrsw m6, m12 pmulhrsw m5, m12 %if %1 == 0 pmulhrsw m0, m12 pmulhrsw m1, m12 %else BUTTERFLY_4X 1, 0, 11585, 11585, m8, 9, 10 SWAP 0, 1 %endif SUM_SUB 4, 5, 9 SUM_SUB 7, 6, 9 BUTTERFLY_4X 4, 7, 3196, 16069, m8, 9, 10 BUTTERFLY_4X 5, 6, 13623, 9102, m8, 9, 10 SWAP 1, 4 SWAP 3, 6 %endmacro %macro DIVIDE_ROUND_2X 4 ; dst1, dst2, tmp1, tmp2 psraw m%3, m%1, 15 psraw m%4, m%2, 15 psubw m%1, m%3 psubw m%2, m%4 psraw m%1, 1 psraw m%2, 1 %endmacro %macro STORE_OUTPUT 2 ; index, result ; const __m128i sign_bits = _mm_cmplt_epi16(*poutput, zero); ; __m128i out0 = _mm_unpacklo_epi16(*poutput, sign_bits); ; __m128i out1 = _mm_unpackhi_epi16(*poutput, sign_bits); ; _mm_store_si128((__m128i *)(dst_ptr), out0); ; _mm_store_si128((__m128i *)(dst_ptr + 4), out1); pxor m11, m11 pcmpgtw m11, m%2 movdqa m12, m%2 punpcklwd m%2, m11 punpckhwd m12, m11 mova [outputq + 4*%1 + 0], m%2 mova [outputq + 4*%1 + 16], m12 %endmacro INIT_XMM ssse3 cglobal fdct8x8, 3, 5, 13, input, output, stride mova m8, [pd_8192] mova m12, [pw_11585x2] lea r3, [2 * strideq] lea r4, [4 * strideq] mova m0, [inputq] mova m1, [inputq + r3] lea inputq, [inputq + r4] mova m2, [inputq] mova m3, [inputq + r3] lea inputq, [inputq + r4] mova m4, [inputq] mova m5, [inputq + r3] lea inputq, [inputq + r4] mova m6, [inputq] mova m7, [inputq + r3] ; left shift by 2 to increase forward transformation precision psllw m0, 2 psllw m1, 2 psllw m2, 2 psllw m3, 2 psllw m4, 2 psllw m5, 2 psllw m6, 2 psllw m7, 2 ; column transform FDCT8_1D 0 TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9 FDCT8_1D 1 TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9 DIVIDE_ROUND_2X 0, 1, 9, 10 DIVIDE_ROUND_2X 2, 3, 9, 10 DIVIDE_ROUND_2X 4, 5, 9, 10 DIVIDE_ROUND_2X 6, 7, 9, 10 STORE_OUTPUT 0, 0 STORE_OUTPUT 8, 1 STORE_OUTPUT 16, 2 STORE_OUTPUT 24, 3 STORE_OUTPUT 32, 4 STORE_OUTPUT 40, 5 STORE_OUTPUT 48, 6 STORE_OUTPUT 56, 7 RET %endif
; A021581: Decimal expansion of 1/577. ; Submitted by Jon Maiga ; 0,0,1,7,3,3,1,0,2,2,5,3,0,3,2,9,2,8,9,4,2,8,0,7,6,2,5,6,4,9,9,1,3,3,4,4,8,8,7,3,4,8,3,5,3,5,5,2,8,5,9,6,1,8,7,1,7,5,0,4,3,3,2,7,5,5,6,3,2,5,8,2,3,2,2,3,5,7,0,1,9,0,6,4,1,2,4,7,8,3,3,6,2,2,1,8,3,7,0 add $0,1 mov $2,10 pow $2,$0 div $2,577 mov $0,$2 mod $0,10
#left shift li $s0, 9 sll $t2, $s0, 4 #AND li $t2, 0xdc0 li $t1, 0x3c00 and $t0, $t1, $t2 #OR or $t0, $t1, $t2 #NOR li $t3, 0 nor $t0, $t1, $t3
; ================================================================== ; MikeOS -- The Mike Operating System kernel ; Copyright (C) 2006 - 2014 MikeOS Developers -- see doc/LICENSE.TXT ; ; BASIC CODE INTERPRETER (4.5) ; ================================================================== ; ------------------------------------------------------------------ ; Token types %DEFINE VARIABLE 1 %DEFINE STRING_VAR 2 %DEFINE NUMBER 3 %DEFINE STRING 4 %DEFINE QUOTE 5 %DEFINE CHAR 6 %DEFINE UNKNOWN 7 %DEFINE LABEL 8 ; ------------------------------------------------------------------ ; The BASIC interpreter execution starts here -- a parameter string ; is passed in SI and copied into the first string, unless SI = 0 os_run_basic: mov word [orig_stack], sp ; Save stack pointer -- we might jump to the ; error printing code and quit in the middle ; some nested loops, and we want to preserve ; the stack mov word [load_point], ax ; AX was passed as starting location of code mov word [prog], ax ; prog = pointer to current execution point in code add bx, ax ; We were passed the .BAS byte size in BX dec bx dec bx mov word [prog_end], bx ; Make note of program end point call clear_ram ; Clear variables etc. from previous run ; of a BASIC program cmp si, 0 ; Passed a parameter string? je mainloop mov di, string_vars ; If so, copy it into $1 call os_string_copy mainloop: call get_token ; Get a token from the start of the line cmp ax, STRING ; Is the type a string of characters? je .keyword ; If so, let's see if it's a keyword to process cmp ax, VARIABLE ; If it's a variable at the start of the line, je near assign ; this is an assign (eg "X = Y + 5") cmp ax, STRING_VAR ; Same for a string variable (eg $1) je near assign cmp ax, LABEL ; Don't need to do anything here - skip je mainloop mov si, err_syntax ; Otherwise show an error and quit jmp error .keyword: mov si, token ; Start trying to match commands mov di, alert_cmd call os_string_compare jc near do_alert mov di, askfile_cmd call os_string_compare jc near do_askfile mov di, break_cmd call os_string_compare jc near do_break mov di, case_cmd call os_string_compare jc near do_case mov di, call_cmd call os_string_compare jc near do_call mov di, cls_cmd call os_string_compare jc near do_cls mov di, cursor_cmd call os_string_compare jc near do_cursor mov di, curschar_cmd call os_string_compare jc near do_curschar mov di, curscol_cmd call os_string_compare jc near do_curscol mov di, curspos_cmd call os_string_compare jc near do_curspos mov di, delete_cmd call os_string_compare jc near do_delete mov di, do_cmd call os_string_compare jc near do_do mov di, end_cmd call os_string_compare jc near do_end mov di, else_cmd call os_string_compare jc near do_else mov di, files_cmd call os_string_compare jc near do_files mov di, for_cmd call os_string_compare jc near do_for mov di, getkey_cmd call os_string_compare jc near do_getkey mov di, gosub_cmd call os_string_compare jc near do_gosub mov di, goto_cmd call os_string_compare jc near do_goto mov di, if_cmd call os_string_compare jc near do_if mov di, include_cmd call os_string_compare jc near do_include mov di, ink_cmd call os_string_compare jc near do_ink mov di, input_cmd call os_string_compare jc near do_input mov di, len_cmd call os_string_compare jc near do_len mov di, listbox_cmd call os_string_compare jc near do_listbox mov di, load_cmd call os_string_compare jc near do_load mov di, loop_cmd call os_string_compare jc near do_loop mov di, move_cmd call os_string_compare jc near do_move mov di, next_cmd call os_string_compare jc near do_next mov di, number_cmd call os_string_compare jc near do_number mov di, page_cmd call os_string_compare jc near do_page mov di, pause_cmd call os_string_compare jc near do_pause mov di, peek_cmd call os_string_compare jc near do_peek mov di, peekint_cmd call os_string_compare jc near do_peekint mov di, poke_cmd call os_string_compare jc near do_poke mov di, pokeint_cmd call os_string_compare jc near do_pokeint mov di, port_cmd call os_string_compare jc near do_port mov di, print_cmd call os_string_compare jc near do_print mov di, rand_cmd call os_string_compare jc near do_rand mov di, read_cmd call os_string_compare jc near do_read mov di, rem_cmd call os_string_compare jc near do_rem mov di, rename_cmd call os_string_compare jc near do_rename mov di, return_cmd call os_string_compare jc near do_return mov di, save_cmd call os_string_compare jc near do_save mov di, serial_cmd call os_string_compare jc near do_serial mov di, size_cmd call os_string_compare jc near do_size mov di, sound_cmd call os_string_compare jc near do_sound mov di, string_cmd call os_string_compare jc near do_string mov di, waitkey_cmd call os_string_compare jc near do_waitkey mov si, err_cmd_unknown ; Command not found? jmp error ; ------------------------------------------------------------------ ; CLEAR RAM clear_ram: pusha mov al, 0 mov di, variables mov cx, 52 rep stosb mov di, for_variables mov cx, 52 rep stosb mov di, for_code_points mov cx, 52 rep stosb mov di, do_loop_store mov cx, 10 rep stosb mov byte [gosub_depth], 0 mov byte [loop_in], 0 mov di, gosub_points mov cx, 20 rep stosb mov di, string_vars mov cx, 1024 rep stosb mov byte [ink_colour], 7 ; White ink popa ret ; ------------------------------------------------------------------ ; ASSIGNMENT assign: cmp ax, VARIABLE ; Are we starting with a number var? je .do_num_var mov di, string_vars ; Otherwise it's a string var mov ax, 128 mul bx ; (BX = string number, passed back from get_token) add di, ax push di call get_token mov byte al, [token] cmp al, '=' jne near .error call get_token ; See if second is quote cmp ax, QUOTE je .second_is_quote cmp ax, STRING_VAR jne near .error mov si, string_vars ; Otherwise it's a string var mov ax, 128 mul bx ; (BX = string number, passed back from get_token) add si, ax pop di call os_string_copy jmp .string_check_for_more .second_is_quote: mov si, token pop di call os_string_copy .string_check_for_more: push di mov word ax, [prog] ; Save code location in case there's no delimiter mov word [.tmp_loc], ax call get_token ; Any more to deal with in this assignment? mov byte al, [token] cmp al, '+' je .string_theres_more mov word ax, [.tmp_loc] ; Not a delimiter, so step back before the token mov word [prog], ax ; that we just grabbed pop di jmp mainloop ; And go back to the code interpreter! .string_theres_more: call get_token cmp ax, STRING_VAR je .another_string_var cmp ax, QUOTE je .another_quote cmp ax, VARIABLE je .add_number_var jmp .error .another_string_var: pop di mov si, string_vars mov ax, 128 mul bx ; (BX = string number, passed back from get_token) add si, ax mov ax, di mov cx, di mov bx, si call os_string_join jmp .string_check_for_more .another_quote: pop di mov ax, di mov cx, di mov bx, token call os_string_join jmp .string_check_for_more .add_number_var: mov ax, 0 mov byte al, [token] call get_var call os_int_to_string mov bx, ax pop di mov ax, di mov cx, di call os_string_join jmp .string_check_for_more .do_num_var: mov ax, 0 mov byte al, [token] mov byte [.tmp], al call get_token mov byte al, [token] cmp al, '=' jne near .error call get_token cmp ax, NUMBER je .second_is_num cmp ax, VARIABLE je .second_is_variable cmp ax, STRING je near .second_is_string cmp ax, UNKNOWN jne near .error mov byte al, [token] ; Address of string var? cmp al, '&' jne near .error call get_token ; Let's see if there's a string var cmp ax, STRING_VAR jne near .error mov di, string_vars mov ax, 128 mul bx add di, ax mov bx, di mov byte al, [.tmp] call set_var jmp mainloop .second_is_variable: mov ax, 0 mov byte al, [token] call get_var mov bx, ax mov byte al, [.tmp] call set_var jmp .check_for_more .second_is_num: mov si, token call os_string_to_int mov bx, ax ; Number to insert in variable table mov ax, 0 mov byte al, [.tmp] call set_var ; The assignment could be simply "X = 5" etc. Or it could be ; "X = Y + 5" -- ie more complicated. So here we check to see if ; there's a delimiter... .check_for_more: mov word ax, [prog] ; Save code location in case there's no delimiter mov word [.tmp_loc], ax call get_token ; Any more to deal with in this assignment? mov byte al, [token] cmp al, '+' je .theres_more cmp al, '-' je .theres_more cmp al, '*' je .theres_more cmp al, '/' je .theres_more cmp al, '%' je .theres_more mov word ax, [.tmp_loc] ; Not a delimiter, so step back before the token mov word [prog], ax ; that we just grabbed jmp mainloop ; And go back to the code interpreter! .theres_more: mov byte [.delim], al call get_token cmp ax, VARIABLE je .handle_variable mov si, token call os_string_to_int mov bx, ax mov ax, 0 mov byte al, [.tmp] call get_var ; This also points SI at right place in variable table cmp byte [.delim], '+' jne .not_plus add ax, bx jmp .finish .not_plus: cmp byte [.delim], '-' jne .not_minus sub ax, bx jmp .finish .not_minus: cmp byte [.delim], '*' jne .not_times mul bx jmp .finish .not_times: cmp byte [.delim], '/' jne .not_divide cmp bx, 0 je .divide_zero mov dx, 0 div bx jmp .finish .not_divide: mov dx, 0 div bx mov ax, dx ; Get remainder .finish: mov bx, ax mov byte al, [.tmp] call set_var jmp .check_for_more .divide_zero: mov si, err_divide_by_zero jmp error .handle_variable: mov ax, 0 mov byte al, [token] call get_var mov bx, ax mov ax, 0 mov byte al, [.tmp] call get_var cmp byte [.delim], '+' jne .vnot_plus add ax, bx jmp .vfinish .vnot_plus: cmp byte [.delim], '-' jne .vnot_minus sub ax, bx jmp .vfinish .vnot_minus: cmp byte [.delim], '*' jne .vnot_times mul bx jmp .vfinish .vnot_times: cmp byte [.delim], '/' jne .vnot_divide mov dx, 0 div bx jmp .finish .vnot_divide: mov dx, 0 div bx mov ax, dx ; Get remainder .vfinish: mov bx, ax mov byte al, [.tmp] call set_var jmp .check_for_more .second_is_string: ; These are "X = word" functions mov di, token mov si, ink_keyword call os_string_compare je .is_ink mov si, progstart_keyword call os_string_compare je .is_progstart mov si, ramstart_keyword call os_string_compare je .is_ramstart mov si, timer_keyword call os_string_compare je .is_timer mov si, variables_keyword call os_string_compare je .is_variables mov si, version_keyword call os_string_compare je .is_version jmp .error .is_ink: mov ax, 0 mov byte al, [.tmp] mov bx, 0 mov byte bl, [ink_colour] call set_var jmp mainloop .is_progstart: mov ax, 0 mov byte al, [.tmp] mov word bx, [load_point] call set_var jmp mainloop .is_ramstart: mov ax, 0 mov byte al, [.tmp] mov word bx, [prog_end] inc bx inc bx inc bx call set_var jmp mainloop .is_timer: mov ah, 0 int 1Ah mov bx, dx mov ax, 0 mov byte al, [.tmp] call set_var jmp mainloop .is_variables: mov bx, vars_loc mov ax, 0 mov byte al, [.tmp] call set_var jmp mainloop .is_version: call os_get_api_version mov bh, 0 mov bl, al mov al, [.tmp] call set_var jmp mainloop .error: mov si, err_syntax jmp error .tmp db 0 .tmp_loc dw 0 .delim db 0 ; ================================================================== ; SPECIFIC COMMAND CODE STARTS HERE ; ------------------------------------------------------------------ ; ALERT do_alert: mov bh, [work_page] ; Store the cursor position mov ah, 03h int 10h call get_token cmp ax, QUOTE je .is_quote cmp ax, STRING_VAR je .is_string mov si, err_syntax jmp error .is_string: mov si, string_vars mov ax, 128 mul bx add ax, si jmp .display_message .is_quote: mov ax, token ; First string for alert box .display_message: mov bx, 0 ; Others are blank mov cx, 0 mov dx, 0 ; One-choice box call os_dialog_box mov bh, [work_page] ; Move the cursor back mov ah, 02h int 10h jmp mainloop ;------------------------------------------------------------------- ; ASKFILE do_askfile: mov bh, [work_page] ; Store the cursor position mov ah, 03h int 10h call get_token cmp ax, STRING_VAR jne .error mov si, string_vars ; Get the string location mov ax, 128 mul bx add ax, si mov word [.tmp], ax call os_file_selector ; Present the selector mov word di, [.tmp] ; Copy the string mov si, ax call os_string_copy mov bh, [work_page] ; Move the cursor back mov ah, 02h int 10h jmp mainloop .error: mov si, err_syntax jmp error .data: .tmp dw 0 ; ------------------------------------------------------------------ ; BREAK do_break: mov si, err_break jmp error ; ------------------------------------------------------------------ ; CALL do_call: call get_token cmp ax, NUMBER je .is_number mov ax, 0 mov byte al, [token] call get_var jmp .execute_call .is_number: mov si, token call os_string_to_int .execute_call: mov bx, 0 mov cx, 0 mov dx, 0 mov di, 0 mov si, 0 call ax jmp mainloop ; ------------------------------------------------------------------ ; CASE do_case: call get_token cmp ax, STRING jne .error mov si, token mov di, upper_keyword call os_string_compare jc .uppercase mov di, lower_keyword call os_string_compare jc .lowercase jmp .error .uppercase: call get_token cmp ax, STRING_VAR jne .error mov si, string_vars mov ax, 128 mul bx add ax, si call os_string_uppercase jmp mainloop .lowercase: call get_token cmp ax, STRING_VAR jne .error mov si, string_vars mov ax, 128 mul bx add ax, si call os_string_lowercase jmp mainloop .error: mov si, err_syntax jmp error ; ------------------------------------------------------------------ ; CLS do_cls: mov ah, 5 mov byte al, [work_page] int 10h call os_clear_screen mov ah, 5 mov byte al, [disp_page] int 10h jmp mainloop ; ------------------------------------------------------------------ ; CURSOR do_cursor: call get_token mov si, token mov di, .on_str call os_string_compare jc .turn_on mov si, token mov di, .off_str call os_string_compare jc .turn_off mov si, err_syntax jmp error .turn_on: call os_show_cursor jmp mainloop .turn_off: call os_hide_cursor jmp mainloop .on_str db "ON", 0 .off_str db "OFF", 0 ; ------------------------------------------------------------------ ; CURSCHAR do_curschar: call get_token cmp ax, VARIABLE je .is_variable mov si, err_syntax jmp error .is_variable: mov ax, 0 mov byte al, [token] push ax ; Store variable we're going to use mov ah, 08h mov bx, 0 mov byte bh, [work_page] int 10h ; Get char at current cursor location mov bx, 0 ; We only want the lower byte (the char, not attribute) mov bl, al pop ax ; Get the variable back call set_var ; And store the value jmp mainloop ; ------------------------------------------------------------------ ; CURSCOL do_curscol: call get_token cmp ax, VARIABLE jne .error mov ah, 0 mov byte al, [token] push ax mov ah, 8 mov bx, 0 mov byte bh, [work_page] int 10h mov bh, 0 mov bl, ah ; Get colour for higher byte; ignore lower byte (char) pop ax call set_var jmp mainloop .error: mov si, err_syntax jmp error ; ------------------------------------------------------------------ ; CURSPOS do_curspos: mov byte bh, [work_page] mov ah, 3 int 10h call get_token cmp ax, VARIABLE jne .error mov ah, 0 ; Get the column in the first variable mov byte al, [token] mov bx, 0 mov bl, dl call set_var call get_token cmp ax, VARIABLE jne .error mov ah, 0 ; Get the row to the second mov byte al, [token] mov bx, 0 mov bl, dh call set_var jmp mainloop .error: mov si, err_syntax jmp error ; ------------------------------------------------------------------ ; DELETE do_delete: call get_token cmp ax, QUOTE je .is_quote cmp ax, STRING_VAR jne near .error mov si, string_vars mov ax, 128 mul bx add si, ax jmp .get_filename .is_quote: mov si, token .get_filename: mov ax, si call os_file_exists jc .no_file call os_remove_file jc .del_fail jmp .returngood .no_file: mov ax, 0 mov byte al, 'R' mov bx, 2 call set_var jmp mainloop .returngood: mov ax, 0 mov byte al, 'R' mov bx, 0 call set_var jmp mainloop .del_fail: mov ax, 0 mov byte al, 'R' mov bx, 1 call set_var jmp mainloop .error: mov si, err_syntax jmp error ; ------------------------------------------------------------------ ; DO do_do: cmp byte [loop_in], 20 je .loop_max mov word di, do_loop_store mov byte al, [loop_in] mov ah, 0 add di, ax mov word ax, [prog] sub ax, 3 stosw inc byte [loop_in] inc byte [loop_in] jmp mainloop .loop_max: mov si, err_doloop_maximum jmp error ;------------------------------------------------------------------- ; ELSE do_else: cmp byte [last_if_true], 1 je .last_true inc word [prog] jmp mainloop .last_true: mov word si, [prog] .next_line: lodsb cmp al, 10 jne .next_line dec si mov word [prog], si jmp mainloop ; ------------------------------------------------------------------ ; END do_end: mov ah, 5 ; Restore active page mov al, 0 int 10h mov byte [work_page], 0 mov byte [disp_page], 0 mov word sp, [orig_stack] ret ; ------------------------------------------------------------------ ; FILES do_files: mov ax, .filelist ; get a copy of the filelist call os_get_file_list mov si, ax call os_get_cursor_pos ; move cursor to start of line mov dl, 0 call os_move_cursor mov ah, 9 ; print character function mov bh, [work_page] ; define parameters (page, colour, times) mov bl, [ink_colour] mov cx, 1 .file_list_loop: lodsb ; get a byte from the list cmp al, ',' ; a comma means the next file, so create a new line for it je .nextfile cmp al, 0 ; the list is null terminated je .end_of_list int 10h ; okay, it's not a comma or a null so print it call os_get_cursor_pos ; find the location of the cursor inc dl ; move the cursor forward call os_move_cursor jmp .file_list_loop ; keep going until the list is finished .nextfile: call os_get_cursor_pos ; if the column is over 60 we need a new line cmp dl, 60 jge .newline .next_column: ; print spaces until the next column mov al, ' ' int 10h inc dl call os_move_cursor cmp dl, 15 je .file_list_loop cmp dl, 30 je .file_list_loop cmp dl, 45 je .file_list_loop cmp dl, 60 je .file_list_loop jmp .next_column .newline: call os_print_newline ; create a new line jmp .file_list_loop .end_of_list: call os_print_newline jmp mainloop ; preform next command .data: .filelist times 256 db 0 ; ------------------------------------------------------------------ ; FOR do_for: call get_token ; Get the variable we're using in this loop cmp ax, VARIABLE jne near .error mov ax, 0 mov byte al, [token] mov byte [.tmp_var], al ; Store it in a temporary location for now call get_token mov ax, 0 ; Check it's followed up with '=' mov byte al, [token] cmp al, '=' jne .error call get_token ; Next we want a number cmp ax, VARIABLE je .first_is_var cmp ax, NUMBER jne .error mov si, token ; Convert it call os_string_to_int jmp .continue .first_is_var: mov ax, 0 ; It's a variable, so get it's value mov al, [token] call get_var ; At this stage, we've read something like "FOR X = 1" ; so let's store that 1 in the variable table .continue: mov bx, ax mov ax, 0 mov byte al, [.tmp_var] call set_var call get_token ; Next we're looking for "TO" cmp ax, STRING jne .error mov ax, token call os_string_uppercase mov si, token mov di, .to_string call os_string_compare jnc .error ; So now we're at "FOR X = 1 TO" call get_token cmp ax, VARIABLE je .second_is_var cmp ax, NUMBER jne .error .second_is_number: mov si, token ; Get target number call os_string_to_int jmp .continue2 .second_is_var: mov ax, 0 ; It's a variable, so get it's value mov al, [token] call get_var .continue2: mov bx, ax mov ax, 0 mov byte al, [.tmp_var] sub al, 65 ; Store target number in table mov di, for_variables add di, ax add di, ax mov ax, bx stosw ; So we've got the variable, assigned it the starting number, and put into ; our table the limit it should reach. But we also need to store the point in ; code after the FOR line we should return to if NEXT X doesn't complete the loop... mov ax, 0 mov byte al, [.tmp_var] sub al, 65 ; Store code position to return to in table mov di, for_code_points add di, ax add di, ax mov word ax, [prog] stosw jmp mainloop .error: mov si, err_syntax jmp error .tmp_var db 0 .to_string db 'TO', 0 ; ------------------------------------------------------------------ ; GETKEY do_getkey: call get_token cmp ax, VARIABLE je .is_variable mov si, err_syntax jmp error .is_variable: mov ax, 0 mov byte al, [token] push ax call os_check_for_key cmp ax, 48E0h je .up_pressed cmp ax, 50E0h je .down_pressed cmp ax, 4BE0h je .left_pressed cmp ax, 4DE0h je .right_pressed .store: mov bx, 0 mov bl, al pop ax call set_var jmp mainloop .up_pressed: mov ax, 1 jmp .store .down_pressed: mov ax, 2 jmp .store .left_pressed: mov ax, 3 jmp .store .right_pressed: mov ax, 4 jmp .store ; ------------------------------------------------------------------ ; GOSUB do_gosub: call get_token ; Get the number (label) cmp ax, STRING je .is_ok mov si, err_goto_notlabel jmp error .is_ok: mov si, token ; Back up this label mov di, .tmp_token call os_string_copy mov ax, .tmp_token call os_string_length mov di, .tmp_token ; Add ':' char to end for searching add di, ax mov al, ':' stosb mov al, 0 stosb inc byte [gosub_depth] mov ax, 0 mov byte al, [gosub_depth] ; Get current GOSUB nest level cmp al, 9 jle .within_limit mov si, err_nest_limit jmp error .within_limit: mov di, gosub_points ; Move into our table of pointers add di, ax ; Table is words (not bytes) add di, ax mov word ax, [prog] stosw ; Store current location before jump mov word ax, [load_point] mov word [prog], ax ; Return to start of program to find label .loop: call get_token cmp ax, LABEL jne .line_loop mov si, token mov di, .tmp_token call os_string_compare jc mainloop .line_loop: ; Go to end of line mov word si, [prog] mov byte al, [si] inc word [prog] cmp al, 10 jne .line_loop mov word ax, [prog] mov word bx, [prog_end] cmp ax, bx jg .past_end jmp .loop .past_end: mov si, err_label_notfound jmp error .tmp_token times 30 db 0 ; ------------------------------------------------------------------ ; GOTO do_goto: call get_token ; Get the next token cmp ax, STRING je .is_ok mov si, err_goto_notlabel jmp error .is_ok: mov si, token ; Back up this label mov di, .tmp_token call os_string_copy mov ax, .tmp_token call os_string_length mov di, .tmp_token ; Add ':' char to end for searching add di, ax mov al, ':' stosb mov al, 0 stosb mov word ax, [load_point] mov word [prog], ax ; Return to start of program to find label .loop: call get_token cmp ax, LABEL jne .line_loop mov si, token mov di, .tmp_token call os_string_compare jc mainloop .line_loop: ; Go to end of line mov word si, [prog] mov byte al, [si] inc word [prog] cmp al, 10 jne .line_loop mov word ax, [prog] mov word bx, [prog_end] cmp ax, bx jg .past_end jmp .loop .past_end: mov si, err_label_notfound jmp error .tmp_token times 30 db 0 ; ------------------------------------------------------------------ ; IF do_if: call get_token cmp ax, VARIABLE ; If can only be followed by a variable je .num_var cmp ax, STRING_VAR je near .string_var mov si, err_syntax jmp error .num_var: mov ax, 0 mov byte al, [token] call get_var mov dx, ax ; Store value of first part of comparison call get_token ; Get the delimiter mov byte al, [token] cmp al, '=' je .equals cmp al, '>' je .greater cmp al, '<' je .less mov si, err_syntax ; If not one of the above, error out jmp error .equals: call get_token ; Is this 'X = Y' (equals another variable?) cmp ax, CHAR je .equals_char mov byte al, [token] call is_letter jc .equals_var mov si, token ; Otherwise it's, eg 'X = 1' (a number) call os_string_to_int cmp ax, dx ; On to the THEN bit if 'X = num' matches je near .on_to_then jmp .finish_line ; Otherwise skip the rest of the line .equals_char: mov ax, 0 mov byte al, [token] cmp ax, dx je near .on_to_then jmp .finish_line .equals_var: mov ax, 0 mov byte al, [token] call get_var cmp ax, dx ; Do the variables match? je near .on_to_then ; On to the THEN bit if so jmp .finish_line ; Otherwise skip the rest of the line .greater: call get_token ; Greater than a variable or number? mov byte al, [token] call is_letter jc .greater_var mov si, token ; Must be a number here... call os_string_to_int cmp ax, dx jl near .on_to_then jmp .finish_line .greater_var: ; Variable in this case mov ax, 0 mov byte al, [token] call get_var cmp ax, dx ; Make the comparison! jl .on_to_then jmp .finish_line .less: call get_token mov byte al, [token] call is_letter jc .less_var mov si, token call os_string_to_int cmp ax, dx jg .on_to_then jmp .finish_line .less_var: mov ax, 0 mov byte al, [token] call get_var cmp ax, dx jg .on_to_then jmp .finish_line .string_var: mov byte [.tmp_string_var], bl call get_token mov byte al, [token] cmp al, '=' jne .error call get_token cmp ax, STRING_VAR je .second_is_string_var cmp ax, QUOTE jne .error mov si, string_vars mov ax, 128 mul bx add si, ax mov di, token call os_string_compare je .on_to_then jmp .finish_line .second_is_string_var: mov si, string_vars mov ax, 128 mul bx add si, ax mov di, string_vars mov bx, 0 mov byte bl, [.tmp_string_var] mov ax, 128 mul bx add di, ax call os_string_compare jc .on_to_then jmp .finish_line .on_to_then: call get_token mov si, token ; Look for AND for more comparison mov di, and_keyword call os_string_compare jc do_if mov si, token ; Look for THEN to perform more operations mov di, then_keyword call os_string_compare jc .then_present mov si, err_syntax jmp error .then_present: ; Continue rest of line like any other command! mov byte [last_if_true], 1 jmp mainloop .finish_line: ; IF wasn't fulfilled, so skip rest of line mov word si, [prog] mov byte al, [si] inc word [prog] cmp al, 10 jne .finish_line mov byte [last_if_true], 0 jmp mainloop .error: mov si, err_syntax jmp error .tmp_string_var db 0 ; ------------------------------------------------------------------ ; INCLUDE do_include: call get_token cmp ax, QUOTE je .is_ok mov si, err_syntax jmp error .is_ok: mov ax, token mov word cx, [prog_end] inc cx ; Add a bit of space after original code inc cx inc cx push cx call os_load_file jc .load_fail pop cx add cx, bx mov word [prog_end], cx jmp mainloop .load_fail: pop cx mov si, err_file_notfound jmp error ; ------------------------------------------------------------------ ; INK do_ink: call get_token ; Get column cmp ax, VARIABLE je .first_is_var mov si, token call os_string_to_int mov byte [ink_colour], al jmp mainloop .first_is_var: mov ax, 0 mov byte al, [token] call get_var mov byte [ink_colour], al jmp mainloop ; ------------------------------------------------------------------ ; INPUT do_input: mov al, 0 ; Clear string from previous usage mov di, .tmpstring mov cx, 128 rep stosb call get_token cmp ax, VARIABLE ; We can only INPUT to variables! je .number_var cmp ax, STRING_VAR je .string_var mov si, err_syntax jmp error .number_var: mov ax, .tmpstring ; Get input from the user call os_input_string mov ax, .tmpstring call os_string_length cmp ax, 0 jne .char_entered mov byte [.tmpstring], '0' ; If enter hit, fill variable with zero mov byte [.tmpstring + 1], 0 .char_entered: mov si, .tmpstring ; Convert to integer format call os_string_to_int mov bx, ax mov ax, 0 mov byte al, [token] ; Get the variable where we're storing it... call set_var ; ...and store it! call os_print_newline jmp mainloop .string_var: push bx mov ax, .tmpstring call os_input_string mov si, .tmpstring mov di, string_vars pop bx mov ax, 128 mul bx add di, ax call os_string_copy call os_print_newline jmp mainloop .tmpstring times 128 db 0 ; ----------------------------------------------------------- ; LEN do_len: call get_token cmp ax, STRING_VAR jne .error mov si, string_vars mov ax, 128 mul bx add si, ax mov ax, si call os_string_length mov word [.num1], ax call get_token cmp ax, VARIABLE je .is_ok mov si, err_syntax jmp error .is_ok: mov ax, 0 mov byte al, [token] mov bl, al jmp .finish .finish: mov bx, [.num1] mov byte al, [token] call set_var mov ax, 0 jmp mainloop .error: mov si, err_syntax jmp error .num1 dw 0 ; ------------------------------------------------------------------ ; LISTBOX do_listbox: mov bh, [work_page] ; Store the cursor position mov ah, 03h int 10h call get_token cmp ax, STRING_VAR jne .error mov si, string_vars mov ax, 128 mul bx add si, ax mov word [.s1], si call get_token cmp ax, STRING_VAR jne .error mov si, string_vars mov ax, 128 mul bx add si, ax mov word [.s2], si call get_token cmp ax, STRING_VAR jne .error mov si, string_vars mov ax, 128 mul bx add si, ax mov word [.s3], si call get_token cmp ax, VARIABLE jne .error mov byte al, [token] mov byte [.var], al mov word ax, [.s1] mov word bx, [.s2] mov word cx, [.s3] call os_list_dialog jc .esc_pressed pusha mov bh, [work_page] ; Move the cursor back mov ah, 02h int 10h popa mov bx, ax mov ax, 0 mov byte al, [.var] call set_var jmp mainloop .esc_pressed: mov ax, 0 mov byte al, [.var] mov bx, 0 call set_var jmp mainloop .error: mov si, err_syntax jmp error .s1 dw 0 .s2 dw 0 .s3 dw 0 .var db 0 ; ------------------------------------------------------------------ ; LOAD do_load: call get_token cmp ax, QUOTE je .is_quote cmp ax, STRING_VAR jne .error mov si, string_vars mov ax, 128 mul bx add si, ax jmp .get_position .is_quote: mov si, token .get_position: mov ax, si call os_file_exists jc .file_not_exists mov dx, ax ; Store for now call get_token cmp ax, VARIABLE je .second_is_var cmp ax, NUMBER jne .error mov si, token call os_string_to_int .load_part: mov cx, ax mov ax, dx call os_load_file mov ax, 0 mov byte al, 'S' call set_var mov ax, 0 mov byte al, 'R' mov bx, 0 call set_var jmp mainloop .second_is_var: mov ax, 0 mov byte al, [token] call get_var jmp .load_part .file_not_exists: mov ax, 0 mov byte al, 'R' mov bx, 1 call set_var call get_token ; Skip past the loading point -- unnecessary now jmp mainloop .error: mov si, err_syntax jmp error ; ------------------------------------------------------------------ ; LOOP do_loop: cmp byte [loop_in], 0 je .no_do dec byte [loop_in] dec byte [loop_in] mov dx, 0 call get_token mov di, token mov si, .endless_word call os_string_compare jc .loop_back mov si, .while_word call os_string_compare jc .while_set mov si, .until_word call os_string_compare jnc .error .get_first_var: call get_token cmp ax, VARIABLE jne .error mov al, [token] call get_var mov cx, ax .check_equals: call get_token cmp ax, UNKNOWN jne .error mov ax, [token] cmp al, '=' je .sign_ok cmp al, '>' je .sign_ok cmp al, '<' je .sign_ok jmp .error .sign_ok: mov byte [.sign], al .get_second_var: call get_token cmp ax, NUMBER je .second_is_num cmp ax, VARIABLE je .second_is_var cmp ax, CHAR jne .error .second_is_char: mov ah, 0 mov al, [token] jmp .check_true .second_is_var: mov al, [token] call get_var jmp .check_true .second_is_num: mov si, token call os_string_to_int .check_true: mov byte bl, [.sign] cmp bl, '=' je .sign_equals cmp bl, '>' je .sign_greater jmp .sign_lesser .sign_equals: cmp ax, cx jne .false jmp .true .sign_greater: cmp ax, cx jge .false jmp .true .sign_lesser: cmp ax, cx jle .false jmp .true .true: cmp dx, 1 je .loop_back jmp mainloop .false: cmp dx, 1 je mainloop .loop_back: mov word si, do_loop_store mov byte al, [loop_in] mov ah, 0 add si, ax lodsw mov word [prog], ax jmp mainloop .while_set: mov dx, 1 jmp .get_first_var .no_do: mov si, err_loop jmp error .error: mov si, err_syntax jmp error .data: .while_word db "WHILE", 0 .until_word db "UNTIL", 0 .endless_word db "ENDLESS", 0 .sign db 0 ; ------------------------------------------------------------------ ; MOVE do_move: call get_token cmp ax, VARIABLE je .first_is_var mov si, token call os_string_to_int mov dl, al jmp .onto_second .first_is_var: mov ax, 0 mov byte al, [token] call get_var mov dl, al .onto_second: call get_token cmp ax, VARIABLE je .second_is_var mov si, token call os_string_to_int mov dh, al jmp .finish .second_is_var: mov ax, 0 mov byte al, [token] call get_var mov dh, al .finish: mov byte bh, [work_page] mov ah, 2 int 10h jmp mainloop ; ------------------------------------------------------------------ ; NEXT do_next: call get_token cmp ax, VARIABLE ; NEXT must be followed by a variable jne .error mov ax, 0 mov byte al, [token] call get_var inc ax ; NEXT increments the variable, of course! mov bx, ax mov ax, 0 mov byte al, [token] sub al, 65 mov si, for_variables add si, ax add si, ax lodsw ; Get the target number from the table inc ax ; (Make the loop inclusive of target number) cmp ax, bx ; Do the variable and target match? je .loop_finished mov ax, 0 ; If not, store the updated variable mov byte al, [token] call set_var mov ax, 0 ; Find the code point and go back mov byte al, [token] sub al, 65 mov si, for_code_points add si, ax add si, ax lodsw mov word [prog], ax jmp mainloop .loop_finished: jmp mainloop .error: mov si, err_syntax jmp error ;------------------------------------------------------------------- ; NUMBER do_number: call get_token ; Check if it's string to number, or number to string cmp ax, STRING_VAR je .is_string cmp ax, VARIABLE je .is_variable jmp .error .is_string: mov si, string_vars mov ax, 128 mul bx add si, ax mov [.tmp], si call get_token mov si, [.tmp] cmp ax, VARIABLE jne .error call os_string_to_int mov bx, ax mov ax, 0 mov byte al, [token] call set_var jmp mainloop .is_variable: mov ax, 0 ; Get the value of the number mov byte al, [token] call get_var call os_int_to_string ; Convert to a string mov [.tmp], ax call get_token ; Get the second parameter mov si, [.tmp] cmp ax, STRING_VAR ; Make sure it's a string variable jne .error mov di, string_vars ; Locate string variable mov ax, 128 mul bx add di, ax call os_string_copy ; Save converted string jmp mainloop .error: mov si, err_syntax jmp error .tmp dw 0 ;------------------------------------------------------------------- ; PAGE do_page: call get_token cmp ax, NUMBER jne .error mov si, token call os_string_to_int mov byte [work_page], al ; Set work page variable call get_token cmp ax, NUMBER jne .error mov si, token call os_string_to_int mov byte [disp_page], al ; Set display page variable ; Change display page -- AL should already be present from the os_string_to_int mov ah, 5 int 10h jmp mainloop .error: mov si, err_syntax jmp error ; ------------------------------------------------------------------ ; PAUSE do_pause: call get_token cmp ax, VARIABLE je .is_var mov si, token call os_string_to_int jmp .finish .is_var: mov ax, 0 mov byte al, [token] call get_var .finish: call os_pause jmp mainloop ; ------------------------------------------------------------------ ; PEEK do_peek: call get_token cmp ax, VARIABLE jne .error mov ax, 0 mov byte al, [token] mov byte [.tmp_var], al call get_token cmp ax, VARIABLE je .dereference cmp ax, NUMBER jne .error mov si, token call os_string_to_int .store: mov si, ax mov bx, 0 mov byte bl, [si] mov ax, 0 mov byte al, [.tmp_var] call set_var jmp mainloop .dereference: mov byte al, [token] call get_var jmp .store .error: mov si, err_syntax jmp error .tmp_var db 0 ; ------------------------------------------------------------------ ; PEEKINT do_peekint: call get_token cmp ax, VARIABLE jne .error .get_second: mov al, [token] mov cx, ax call get_token cmp ax, VARIABLE je .address_is_var cmp ax, NUMBER jne .error .address_is_number: mov si, token call os_string_to_int jmp .load_data .address_is_var: mov al, [token] call get_var .load_data: mov si, ax mov bx, [si] mov ax, cx call set_var jmp mainloop .error: mov si, err_syntax jmp error ; ------------------------------------------------------------------ ; POKE do_poke: call get_token cmp ax, VARIABLE je .first_is_var cmp ax, NUMBER jne .error mov si, token call os_string_to_int cmp ax, 255 jg .error mov byte [.first_value], al jmp .onto_second .first_is_var: mov ax, 0 mov byte al, [token] call get_var mov byte [.first_value], al .onto_second: call get_token cmp ax, VARIABLE je .second_is_var cmp ax, NUMBER jne .error mov si, token call os_string_to_int .got_value: mov di, ax mov ax, 0 mov byte al, [.first_value] mov byte [di], al jmp mainloop .second_is_var: mov ax, 0 mov byte al, [token] call get_var jmp .got_value .error: mov si, err_syntax jmp error .first_value db 0 ; ------------------------------------------------------------------ ; POKEINT do_pokeint: call get_token cmp ax, VARIABLE je .data_is_var cmp ax, NUMBER jne .error .data_is_num: mov si, token call os_string_to_int jmp .get_second .data_is_var: mov al, [token] call get_var .get_second: mov cx, ax call get_token cmp ax, VARIABLE je .address_is_var cmp ax, NUMBER jne .error .address_is_num: mov si, token call os_string_to_int jmp .save_data .address_is_var: mov al, [token] call get_var .save_data: mov si, ax mov [si], cx jmp mainloop .error: mov si, err_syntax jmp error ; ------------------------------------------------------------------ ; PORT do_port: call get_token mov si, token mov di, .out_cmd call os_string_compare jc .do_out_cmd mov di, .in_cmd call os_string_compare jc .do_in_cmd jmp .error .do_out_cmd: call get_token cmp ax, NUMBER jne .error mov si, token call os_string_to_int ; Now AX = port number mov dx, ax call get_token cmp ax, NUMBER je .out_is_num cmp ax, VARIABLE je .out_is_var jmp .error .out_is_num: mov si, token call os_string_to_int call os_port_byte_out jmp mainloop .out_is_var: mov ax, 0 mov byte al, [token] call get_var call os_port_byte_out jmp mainloop .do_in_cmd: call get_token cmp ax, NUMBER jne .error mov si, token call os_string_to_int mov dx, ax call get_token cmp ax, VARIABLE jne .error mov byte cl, [token] call os_port_byte_in mov bx, 0 mov bl, al mov al, cl call set_var jmp mainloop .error: mov si, err_syntax jmp error .out_cmd db "OUT", 0 .in_cmd db "IN", 0 ; ------------------------------------------------------------------ ; PRINT do_print: call get_token ; Get part after PRINT cmp ax, QUOTE ; What type is it? je .print_quote cmp ax, VARIABLE ; Numerical variable (eg X) je .print_var cmp ax, STRING_VAR ; String variable (eg $1) je .print_string_var cmp ax, STRING ; Special keyword (eg CHR or HEX) je .print_keyword mov si, err_print_type ; We only print quoted strings and vars! jmp error .print_var: mov ax, 0 mov byte al, [token] call get_var ; Get its value call os_int_to_string ; Convert to string mov si, ax call os_print_string jmp .newline_or_not .print_quote: ; If it's quoted text, print it mov si, token .print_quote_loop: lodsb cmp al, 0 je .newline_or_not mov ah, 09h mov byte bl, [ink_colour] mov byte bh, [work_page] mov cx, 1 int 10h mov ah, 3 int 10h cmp dl, 79 jge .quote_newline inc dl .move_cur_quote: mov byte bh, [work_page] mov ah, 02h int 10h jmp .print_quote_loop .quote_newline: cmp dh, 24 je .move_cur_quote mov dl, 0 inc dh jmp .move_cur_quote .print_string_var: mov si, string_vars mov ax, 128 mul bx add si, ax jmp .print_quote_loop .print_keyword: mov si, token mov di, chr_keyword call os_string_compare jc .is_chr mov di, hex_keyword call os_string_compare jc .is_hex mov si, err_syntax jmp error .is_chr: call get_token cmp ax, VARIABLE je .is_chr_variable cmp ax, NUMBER je .is_chr_number .is_chr_variable: mov ax, 0 mov byte al, [token] call get_var jmp .print_chr .is_chr_number: mov si, token call os_string_to_int .print_chr: mov ah, 09h mov byte bl, [ink_colour] mov byte bh, [work_page] mov cx, 1 int 10h mov ah, 3 ; Move the cursor forward int 10h inc dl cmp dl, 79 jg .end_line ; If it's over the end of the line .move_cur: mov ah, 2 int 10h jmp .newline_or_not .is_hex: call get_token cmp ax, VARIABLE jne .error mov ax, 0 mov byte al, [token] call get_var call os_print_2hex jmp .newline_or_not .end_line: mov dl, 0 inc dh cmp dh, 25 jl .move_cur mov dh, 24 mov dl, 79 jmp .move_cur .error: mov si, err_syntax jmp error .newline_or_not: ; We want to see if the command ends with ';' -- which means that ; we shouldn't print a newline after it finishes. So we store the ; current program location to pop ahead and see if there's the ';' ; character -- otherwise we put the program location back and resume ; the main loop mov word ax, [prog] mov word [.tmp_loc], ax call get_token cmp ax, UNKNOWN jne .ignore mov ax, 0 mov al, [token] cmp al, ';' jne .ignore jmp mainloop ; And go back to interpreting the code! .ignore: mov ah, 5 mov al, [work_page] int 10h mov bh, [work_page] call os_print_newline mov ah, 5 mov al, [disp_page] mov word ax, [.tmp_loc] mov word [prog], ax jmp mainloop .tmp_loc dw 0 ; ------------------------------------------------------------------ ; RAND do_rand: call get_token cmp ax, VARIABLE jne .error mov byte al, [token] mov byte [.tmp], al call get_token cmp ax, NUMBER jne .error mov si, token call os_string_to_int mov word [.num1], ax call get_token cmp ax, NUMBER jne .error mov si, token call os_string_to_int mov word [.num2], ax mov word ax, [.num1] mov word bx, [.num2] call os_get_random mov bx, cx mov ax, 0 mov byte al, [.tmp] call set_var jmp mainloop .tmp db 0 .num1 dw 0 .num2 dw 0 .error: mov si, err_syntax jmp error ; ------------------------------------------------------------------ ; READ do_read: call get_token ; Get the next token cmp ax, STRING ; Check for a label je .is_ok mov si, err_goto_notlabel jmp error .is_ok: mov si, token ; Back up this label mov di, .tmp_token call os_string_copy mov ax, .tmp_token call os_string_length mov di, .tmp_token ; Add ':' char to end for searching add di, ax mov al, ':' stosb mov al, 0 stosb call get_token ; Now get the offset variable cmp ax, VARIABLE je .second_part_is_var mov si, err_syntax jmp error .second_part_is_var: mov ax, 0 mov byte al, [token] call get_var cmp ax, 0 ; Want to be searching for at least the first byte! jg .var_bigger_than_zero mov si, err_syntax jmp error .var_bigger_than_zero: mov word [.to_skip], ax call get_token ; And now the var to store result into cmp ax, VARIABLE je .third_part_is_var mov si, err_syntax jmp error .third_part_is_var: ; Keep it for later mov ax, 0 mov byte al, [token] mov byte [.var_to_use], al ; OK, so now we have all the stuff we need. Let's search for the label mov word ax, [prog] ; Store current location mov word [.curr_location], ax mov word ax, [load_point] mov word [prog], ax ; Return to start of program to find label .loop: call get_token cmp ax, LABEL jne .line_loop mov si, token mov di, .tmp_token call os_string_compare jc .found_label .line_loop: ; Go to end of line mov word si, [prog] mov byte al, [si] inc word [prog] cmp al, 10 jne .line_loop mov word ax, [prog] mov word bx, [prog_end] cmp ax, bx jg .past_end jmp .loop .past_end: mov si, err_label_notfound jmp error .found_label: mov word cx, [.to_skip] ; Skip requested number of data entries .data_skip_loop: push cx call get_token pop cx loop .data_skip_loop cmp ax, NUMBER je .data_is_num mov si, err_syntax jmp error .data_is_num: mov si, token call os_string_to_int mov bx, ax mov ax, 0 mov byte al, [.var_to_use] call set_var mov word ax, [.curr_location] mov word [prog], ax jmp mainloop .curr_location dw 0 .to_skip dw 0 .var_to_use db 0 .tmp_token times 30 db 0 ; ------------------------------------------------------------------ ; REM do_rem: mov word si, [prog] mov byte al, [si] inc word [prog] cmp al, 10 ; Find end of line after REM jne do_rem jmp mainloop ; ------------------------------------------------------------------ ; RENAME do_rename: call get_token cmp ax, STRING_VAR ; Is it a string or a quote? je .first_is_string cmp ax, QUOTE je .first_is_quote jmp .error .first_is_string: mov si, string_vars ; Locate string mov ax, 128 mul bx add si, ax jmp .save_file1 .first_is_quote: mov si, token ; The location of quotes is provided .save_file1: mov word di, .file1 ; The filename is saved to temporary strings because call os_string_copy ; getting a second quote will overwrite the previous .get_second: call get_token cmp ax, STRING_VAR je .second_is_string cmp ax, QUOTE je .second_is_quote jmp .error .second_is_string: mov si, string_vars ; Locate second string mov ax, 128 mul bx add si, ax jmp .save_file2 .second_is_quote: mov si, token .save_file2: mov word di, .file2 call os_string_copy .check_exists: mov word ax, .file1 ; Check if the source file exists call os_file_exists jc .file_not_found ; If it doesn't exists set "R = 1" clc mov ax, .file2 ; The second file is the destination and should not exist call os_file_exists jnc .file_exists ; If it exists set "R = 3" .rename: mov word ax, .file1 ; Seem to be okay, lets rename mov word bx, .file2 call os_rename_file jc .rename_failed ; If it failed set "R = 2", usually caused by a read-only disk mov ax, 0 ; It worked sucessfully, so set "R = 0" to indicate no error mov byte al, 'R' mov bx, 0 call set_var jmp mainloop .error: mov si, err_syntax jmp error .file_not_found: mov ax, 0 ; Set R variable to 1 mov byte al, 'R' mov bx, 1 call set_var jmp mainloop .rename_failed: mov ax, 0 ; Set R variable to 2 mov byte al, 'R' mov bx, 2 call set_var jmp mainloop .file_exists: mov ax, 0 mov byte al, 'R' ; Set R variable to 3 mov bx, 3 call set_var jmp mainloop .data: .file1 times 12 db 0 .file2 times 12 db 0 ; ------------------------------------------------------------------ ; RETURN do_return: mov ax, 0 mov byte al, [gosub_depth] cmp al, 0 jne .is_ok mov si, err_return jmp error .is_ok: mov si, gosub_points add si, ax ; Table is words (not bytes) add si, ax lodsw mov word [prog], ax dec byte [gosub_depth] jmp mainloop ; ------------------------------------------------------------------ ; SAVE do_save: call get_token cmp ax, QUOTE je .is_quote cmp ax, STRING_VAR jne near .error mov si, string_vars mov ax, 128 mul bx add si, ax jmp .get_position .is_quote: mov si, token .get_position: mov di, .tmp_filename call os_string_copy call get_token cmp ax, VARIABLE je .second_is_var cmp ax, NUMBER jne .error mov si, token call os_string_to_int .set_data_loc: mov word [.data_loc], ax call get_token cmp ax, VARIABLE je .third_is_var cmp ax, NUMBER jne .error mov si, token call os_string_to_int .check_exists: mov word [.data_size], ax mov word ax, .tmp_filename call os_file_exists jc .write_file jmp .file_exists_fail .write_file: mov word ax, .tmp_filename mov word bx, [.data_loc] mov word cx, [.data_size] call os_write_file jc .save_failure mov ax, 0 mov byte al, 'R' mov bx, 0 call set_var jmp mainloop .second_is_var: mov ax, 0 mov byte al, [token] call get_var jmp .set_data_loc .third_is_var: mov ax, 0 mov byte al, [token] call get_var jmp .check_exists .file_exists_fail: mov ax, 0 mov byte al, 'R' mov bx, 2 call set_var jmp mainloop .save_failure: mov ax, 0 mov byte al, 'R' mov bx, 1 call set_var jmp mainloop .error: mov si, err_syntax jmp error .filename_loc dw 0 .data_loc dw 0 .data_size dw 0 .tmp_filename times 15 db 0 ; ------------------------------------------------------------------ ; SERIAL do_serial: call get_token mov si, token mov di, .on_cmd call os_string_compare jc .do_on_cmd mov di, .send_cmd call os_string_compare jc .do_send_cmd mov di, .rec_cmd call os_string_compare jc .do_rec_cmd jmp .error .do_on_cmd: call get_token cmp ax, NUMBER je .do_on_cmd_ok jmp .error .do_on_cmd_ok: mov si, token call os_string_to_int cmp ax, 1200 je .on_cmd_slow_mode cmp ax, 9600 je .on_cmd_fast_mode jmp .error .on_cmd_fast_mode: mov ax, 0 call os_serial_port_enable jmp mainloop .on_cmd_slow_mode: mov ax, 1 call os_serial_port_enable jmp mainloop .do_send_cmd: call get_token cmp ax, NUMBER je .send_number cmp ax, VARIABLE je .send_variable jmp .error .send_number: mov si, token call os_string_to_int call os_send_via_serial jmp mainloop .send_variable: mov ax, 0 mov byte al, [token] call get_var call os_send_via_serial jmp mainloop .do_rec_cmd: call get_token cmp ax, VARIABLE jne .error mov byte al, [token] mov cx, 0 mov cl, al call os_get_via_serial mov bx, 0 mov bl, al mov al, cl call set_var jmp mainloop .error: mov si, err_syntax jmp error .on_cmd db "ON", 0 .send_cmd db "SEND", 0 .rec_cmd db "REC", 0 ; ------------------------------------------------------------------ ; SIZE do_size: call get_token cmp ax, STRING_VAR je .is_string cmp ax, QUOTE je .is_quote jmp .error .is_string: mov si, string_vars mov ax, 128 mul bx add si, ax mov ax, si jmp .get_size .is_quote: mov ax, token .get_size: call os_get_file_size jc .file_not_found mov ax, 0 mov al, 'S' call set_var mov ax, 0 mov al, 'R' mov bx, 0 call set_var jmp mainloop .error: mov si, err_syntax jmp error .file_not_found: mov ax, 0 mov al, [token] mov bx, 0 call set_var mov ax, 0 mov al, 'R' mov bx, 1 call set_var jmp mainloop ; ------------------------------------------------------------------ ; SOUND do_sound: call get_token cmp ax, VARIABLE je .first_is_var mov si, token call os_string_to_int jmp .done_first .first_is_var: mov ax, 0 mov byte al, [token] call get_var .done_first: call os_speaker_tone call get_token cmp ax, VARIABLE je .second_is_var mov si, token call os_string_to_int jmp .finish .second_is_var: mov ax, 0 mov byte al, [token] call get_var .finish: call os_pause call os_speaker_off jmp mainloop ;------------------------------------------------------------------- ; STRING do_string: call get_token ; The first parameter is the word 'GET' or 'SET' mov si, token mov di, .get_cmd call os_string_compare jc .set_str mov di, .set_cmd call os_string_compare jc .get_str jmp .error .set_str: mov cx, 1 jmp .check_second .get_str: mov cx, 2 .check_second: call get_token ; The next should be a string variable, locate it cmp ax, STRING_VAR jne .error mov si, string_vars mov ax, 128 mul bx add si, ax mov word [.string_loc], si .check_third: call get_token ; Now there should be a number cmp ax, NUMBER je .third_is_number cmp ax, VARIABLE je .third_is_variable jmp .error .third_is_number: mov si, token call os_string_to_int jmp .got_number .third_is_variable: mov ah, 0 mov al, [token] call get_var jmp .got_number .got_number: cmp ax, 128 jg .outrange cmp ax, 0 je .outrange sub ax, 1 mov dx, ax .check_forth: call get_token ; Next a numerical variable cmp ax, VARIABLE jne .error mov byte al, [token] mov byte [.tmp], al cmp cx, 2 je .set_var .get_var: mov word si, [.string_loc] ; Move to string location add si, dx ; Add offset lodsb ; Load data mov ah, 0 mov bx, ax ; Set data in numerical variable mov byte al, [.tmp] call set_var jmp mainloop .set_var: mov byte al, [.tmp] ; Retrieve the variable call get_var ; Get it's value mov di, [.string_loc] ; Locate the string add di, dx ; Add the offset stosb ; Store data jmp mainloop .error: mov si, err_syntax jmp error .outrange: mov si, err_string_range jmp error .data: .get_cmd db "GET", 0 .set_cmd db "SET", 0 .string_loc dw 0 .tmp db 0 ; ------------------------------------------------------------------ ; WAITKEY do_waitkey: call get_token cmp ax, VARIABLE je .is_variable mov si, err_syntax jmp error .is_variable: mov ax, 0 mov byte al, [token] push ax call os_wait_for_key cmp ax, 48E0h je .up_pressed cmp ax, 50E0h je .down_pressed cmp ax, 4BE0h je .left_pressed cmp ax, 4DE0h je .right_pressed .store: mov bx, 0 mov bl, al pop ax call set_var jmp mainloop .up_pressed: mov ax, 1 jmp .store .down_pressed: mov ax, 2 jmp .store .left_pressed: mov ax, 3 jmp .store .right_pressed: mov ax, 4 jmp .store ; ================================================================== ; INTERNAL ROUTINES FOR INTERPRETER ; ------------------------------------------------------------------ ; Get value of variable character specified in AL (eg 'A') get_var: mov ah, 0 sub al, 65 mov si, variables add si, ax add si, ax lodsw ret ; ------------------------------------------------------------------ ; Set value of variable character specified in AL (eg 'A') ; with number specified in BX set_var: mov ah, 0 sub al, 65 ; Remove ASCII codes before 'A' mov di, variables ; Find position in table (of words) add di, ax add di, ax mov ax, bx stosw ret ; ------------------------------------------------------------------ ; Get token from current position in prog get_token: mov word si, [prog] lodsb cmp al, 10 je .newline cmp al, ' ' je .newline call is_number jc get_number_token cmp al, '"' je get_quote_token cmp al, 39 ; Quote mark (') je get_char_token cmp al, '$' je near get_string_var_token jmp get_string_token .newline: inc word [prog] jmp get_token get_number_token: mov word si, [prog] mov di, token .loop: lodsb cmp al, 10 je .done cmp al, ' ' je .done call is_number jc .fine mov si, err_char_in_num jmp error .fine: stosb inc word [prog] jmp .loop .done: mov al, 0 ; Zero-terminate the token stosb mov ax, NUMBER ; Pass back the token type ret get_char_token: inc word [prog] ; Move past first quote (') mov word si, [prog] lodsb mov byte [token], al lodsb cmp al, 39 ; Needs to finish with another quote je .is_ok mov si, err_quote_term jmp error .is_ok: inc word [prog] inc word [prog] mov ax, CHAR ret get_quote_token: inc word [prog] ; Move past first quote (") char mov word si, [prog] mov di, token .loop: lodsb cmp al, '"' je .done cmp al, 10 je .error stosb inc word [prog] jmp .loop .done: mov al, 0 ; Zero-terminate the token stosb inc word [prog] ; Move past final quote mov ax, QUOTE ; Pass back token type ret .error: mov si, err_quote_term jmp error get_string_var_token: lodsb mov bx, 0 ; If it's a string var, pass number of string in BX mov bl, al sub bl, 49 inc word [prog] inc word [prog] mov ax, STRING_VAR ret get_string_token: mov word si, [prog] mov di, token .loop: lodsb cmp al, 10 je .done cmp al, ' ' je .done stosb inc word [prog] jmp .loop .done: mov al, 0 ; Zero-terminate the token stosb mov ax, token call os_string_uppercase mov ax, token call os_string_length ; How long was the token? cmp ax, 1 ; If 1 char, it's a variable or delimiter je .is_not_string mov si, token ; If the token ends with ':', it's a label add si, ax dec si lodsb cmp al, ':' je .is_label mov ax, STRING ; Otherwise it's a general string of characters ret .is_label: mov ax, LABEL ret .is_not_string: mov byte al, [token] call is_letter jc .is_var mov ax, UNKNOWN ret .is_var: mov ax, VARIABLE ; Otherwise probably a variable ret ; ------------------------------------------------------------------ ; Set carry flag if AL contains ASCII number is_number: cmp al, 48 jl .not_number cmp al, 57 jg .not_number stc ret .not_number: clc ret ; ------------------------------------------------------------------ ; Set carry flag if AL contains ASCII letter is_letter: cmp al, 65 jl .not_letter cmp al, 90 jg .not_letter stc ret .not_letter: clc ret ; ------------------------------------------------------------------ ; Print error message and quit out error: mov ah, 5 ; Revert display page mov al, 0 int 10h mov byte [work_page], 0 mov byte [disp_page], 0 call os_print_newline call os_print_string ; Print error message mov si, line_num_starter call os_print_string ; And now print the line number where the error occurred. We do this ; by working from the start of the program to the current point, ; counting the number of newline characters along the way mov word si, [load_point] mov word bx, [prog] mov cx, 1 .loop: lodsb cmp al, 10 jne .not_newline inc cx .not_newline: cmp si, bx je .finish jmp .loop .finish: mov ax, cx call os_int_to_string mov si, ax call os_print_string call os_print_newline mov word sp, [orig_stack] ; Restore the stack to as it was when BASIC started ret ; And finish ; Error messages text... err_char_in_num db "Error: unexpected char in number", 0 err_cmd_unknown db "Error: unknown command", 0 err_divide_by_zero db "Error: attempt to divide by zero", 0 err_doloop_maximum db "Error: DO/LOOP nesting limit exceeded", 0 err_file_notfound db "Error: file not found", 0 err_goto_notlabel db "Error: GOTO or GOSUB not followed by label", 0 err_label_notfound db "Error: label not found", 0 err_nest_limit db "Error: FOR or GOSUB nest limit exceeded", 0 err_next db "Error: NEXT without FOR", 0 err_loop db "Error: LOOP without DO", 0 err_print_type db "Error: PRINT not followed by quoted text or variable", 0 err_quote_term db "Error: quoted string or char not terminated correctly", 0 err_return db "Error: RETURN without GOSUB", 0 err_string_range db "Error: string location out of range", 0 err_syntax db "Error: syntax error", 0 err_break db "BREAK CALLED", 0 line_num_starter db " - line ", 0 ; ================================================================== ; DATA SECTION orig_stack dw 0 ; Original stack location when BASIC started prog dw 0 ; Pointer to current location in BASIC code prog_end dw 0 ; Pointer to final byte of BASIC code load_point dw 0 token_type db 0 ; Type of last token read (eg NUMBER, VARIABLE) token times 255 db 0 ; Storage space for the token vars_loc: variables times 26 dw 0 ; Storage space for variables A to Z for_variables times 26 dw 0 ; Storage for FOR loops for_code_points times 26 dw 0 ; Storage for code positions where FOR loops start do_loop_store times 10 dw 0 ; Storage for DO loops loop_in db 0 ; Loop level last_if_true db 1 ; Checking for 'ELSE' ink_colour db 0 ; Text printing colour work_page db 0 ; Page to print to disp_page db 0 ; Page to display alert_cmd db "ALERT", 0 askfile_cmd db "ASKFILE", 0 break_cmd db "BREAK", 0 call_cmd db "CALL", 0 case_cmd db "CASE", 0 cls_cmd db "CLS", 0 cursor_cmd db "CURSOR", 0 curschar_cmd db "CURSCHAR", 0 curscol_cmd db "CURSCOL", 0 curspos_cmd db "CURSPOS", 0 delete_cmd db "DELETE", 0 do_cmd db "DO", 0 else_cmd db "ELSE", 0 end_cmd db "END", 0 files_cmd db "FILES", 0 for_cmd db "FOR", 0 gosub_cmd db "GOSUB", 0 goto_cmd db "GOTO", 0 getkey_cmd db "GETKEY", 0 if_cmd db "IF", 0 include_cmd db "INCLUDE", 0 ink_cmd db "INK", 0 input_cmd db "INPUT", 0 len_cmd db "LEN", 0 listbox_cmd db "LISTBOX", 0 load_cmd db "LOAD", 0 loop_cmd db "LOOP", 0 move_cmd db "MOVE", 0 next_cmd db "NEXT", 0 number_cmd db "NUMBER", 0 page_cmd db "PAGE", 0 pause_cmd db "PAUSE", 0 peek_cmd db "PEEK", 0 peekint_cmd db "PEEKINT", 0 poke_cmd db "POKE", 0 pokeint_cmd db "POKEINT", 0 port_cmd db "PORT", 0 print_cmd db "PRINT", 0 rand_cmd db "RAND", 0 read_cmd db "READ", 0 rem_cmd db "REM", 0 rename_cmd db "RENAME", 0 return_cmd db "RETURN", 0 save_cmd db "SAVE", 0 serial_cmd db "SERIAL", 0 size_cmd db "SIZE", 0 sound_cmd db "SOUND", 0 string_cmd db "STRING", 0 waitkey_cmd db "WAITKEY", 0 and_keyword db "AND", 0 then_keyword db "THEN", 0 chr_keyword db "CHR", 0 hex_keyword db "HEX", 0 lower_keyword db "LOWER", 0 upper_keyword db "UPPER", 0 ink_keyword db "INK", 0 progstart_keyword db "PROGSTART", 0 ramstart_keyword db "RAMSTART", 0 timer_keyword db "TIMER", 0 variables_keyword db "VARIABLES", 0 version_keyword db "VERSION", 0 gosub_depth db 0 gosub_points times 10 dw 0 ; Points in code to RETURN to string_vars times 1024 db 0 ; 8 * 128 byte strings ; ------------------------------------------------------------------
// stdafx.cpp : source file that includes just the standard includes // Kinect2ForcePlate.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" /////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////// University of Bristol //////////////// ////////////// Computer Science Department //////////////// //===================================================================================================// /////// This is an open source code for: /////// //////// "3D Data Acquisition and Registration using Two Opposing Kinects" ////////// //////////////// V. Soleimani, M. Mirmehdi, D. Damen, S. Hannuna, M. Camplani ///////////////// //////////////// International Conference on 3D Vision, Stanford, 2016 ///////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////
; A228679: Number of nX4 binary arrays with no two ones adjacent horizontally, diagonally or antidiagonally. ; Submitted by Christian Krause ; 8,40,216,1152,6160,32928,176032,941056,5030848,26894720,143778176,768632832,4109082880,21967006208,117434808832,627802177536,3356207397888,17942161561600,95918137153536,512774840614912,2741275476889600,14654758082879488,78343798818578432,418823072930594816,2239012775283376128,11969680115290439680,63989470557731127296,342085360913538875392,1828775783443447480320,9776568214371758112768,52265174832035342712832,279407706295920960208896,1493703342396481010925568,7985283243130761403432960 mov $2,8 mov $4,1 lpb $0 sub $0,1 mov $3,$1 mul $4,2 add $4,$1 add $2,$4 mov $1,$2 sub $1,$3 mul $2,4 lpe mov $0,$2
#ifndef CLIENT_HPP #define CLIENT_HPP #include <QTimer> #include <QUdpSocket> #include <qqml.h> #include "snakedata.hpp" #include "commands.hpp" class Client : public QObject { Q_OBJECT Q_PROPERTY(SnakeController* snakeController READ getSnakeConroller NOTIFY snakeDataChanged) Q_PROPERTY(QVector<ClientData> otherPlayers READ getOtherPlayers NOTIFY otherPlayersChanged) static Client* s_Client; public: static Client* getClient(); Client(uint id = UINT_MAX); Q_INVOKABLE void eat(uint x, uint y); Q_INVOKABLE void joinGame(const QString& name = "Test", const QHostAddress& ip = QHostAddress::Broadcast, quint16 port = 45454); Q_INVOKABLE void sendGameData(); template<typename T> void sendCommand(const T& cmdData); void handleCommands(Command& cmd); SnakeController* getSnakeConroller() { return &snakeController; } const QVector<ClientData>& getOtherPlayers() const { return otherPlayers; } void setId(uint id) { myId = id; } void setOtherPlayers(const QVector<ClientData> op) { otherPlayers = op; emit otherPlayersChanged(); } const QString& getName() const { return name; } private slots: void processPendingDatagrams(); signals: void snakeDataChanged(); void otherPlayersChanged(); void popupScoreAnimation(const QString& word, uint combo, uint score); void resetAnimation(); void death(); private: QUdpSocket* udpSocket = nullptr; SnakeController snakeController; QString name; QVector<ClientData> otherPlayers; QHostAddress serverIp; quint16 port; uint myId; }; #endif // CLIENT_HPP
.global s_prepare_buffers s_prepare_buffers: push %r15 push %rax push %rbp push %rcx lea addresses_A_ht+0x1004c, %rcx nop nop xor %r15, %r15 movw $0x6162, (%rcx) nop nop nop nop nop inc %rbp pop %rcx pop %rbp pop %rax pop %r15 ret .global s_faulty_load s_faulty_load: push %r13 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi // Store lea addresses_WT+0x14ac9, %r13 clflush (%r13) nop inc %rax movl $0x51525354, (%r13) nop nop nop nop nop xor %rdi, %rdi // Store lea addresses_A+0x19835, %rbp nop nop add %rsi, %rsi mov $0x5152535455565758, %rcx movq %rcx, %xmm2 movups %xmm2, (%rbp) nop nop nop nop dec %r13 // Store lea addresses_WC+0x1dd29, %rdi nop inc %rcx movb $0x51, (%rdi) nop nop sub %rsi, %rsi // Faulty Load lea addresses_A+0x16729, %rdi nop nop nop nop add $23377, %rbp movb (%rdi), %cl lea oracles, %rax and $0xff, %rcx shlq $12, %rcx mov (%rax,%rcx,1), %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': True, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': True, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 7}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_A', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'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 */
;=============================================================================== ; Constants MapLastColumn = 202 ; (5 * 40) + 2 extra hidden rows, i.e. start of 6th screen ;=============================================================================== ; Variables Operator Calc MapRAMRowStartLow ; increments are 6 screens x 40 characters per row (240) byte <MAPRAM, <MAPRAM+240, <MAPRAM+480 byte <MAPRAM+720, <MAPRAM+960, <MAPRAM+1200 byte <MAPRAM+1440, <MAPRAM+1680, <MAPRAM+1920 MapRAMRowStartHigh byte >MAPRAM, >MAPRAM+240, >MAPRAM+480 byte >MAPRAM+720, >MAPRAM+960, >MAPRAM+1200 byte >MAPRAM+1440, >MAPRAM+1680, >MAPRAM+1920 MAPCOLORRAM = MAPRAM + (6 * 8 * 40) ; 6 screens x 8 rows x 40 characters MapRAMCOLRowStartLow ; increments are number of screens x 40 characters per row byte <MAPCOLORRAM, <MAPCOLORRAM+240, <MAPCOLORRAM+480 byte <MAPCOLORRAM+720, <MAPCOLORRAM+960, <MAPCOLORRAM+1200 byte <MAPCOLORRAM+1440, <MAPCOLORRAM+1680, <MAPCOLORRAM+1920 MapRAMCOLRowStartHigh byte >MAPCOLORRAM, >MAPCOLORRAM+240, >MAPCOLORRAM+480 byte >MAPCOLORRAM+720, >MAPCOLORRAM+960, >MAPCOLORRAM+1200 byte >MAPCOLORRAM+1440, >MAPCOLORRAM+1680, >MAPCOLORRAM+1920 Operator HiLo ;=============================================================================== ; Macros/Subroutines gameMapInit jsr gameMapUpdate ; update the cloud colors & map row 7 colors on init ; clouds colors LIBSCREEN_COPYMAPROWCOLOR_VVA 0, 2, screenColumn LIBSCREEN_COPYMAPROWCOLOR_VVA 1, 3, screenColumn ; ground colors LIBSCREEN_COPYMAPROWCOLOR_VVA 7, 22, screenColumn rts ;=============================================================================== gameMapUpdate ; no need to update the cloud colors or map row 7 colors ; as they have the same colors across the row ; clouds characters LIBSCREEN_COPYMAPROW_VVA 0, 2, screenColumn LIBSCREEN_COPYMAPROW_VVA 1, 3, screenColumn ; ground characters LIBSCREEN_COPYMAPROW_VVA 2, 17, screenColumn LIBSCREEN_COPYMAPROW_VVA 3, 18, screenColumn LIBSCREEN_COPYMAPROW_VVA 4, 19, screenColumn LIBSCREEN_COPYMAPROW_VVA 5, 20, screenColumn LIBSCREEN_COPYMAPROW_VVA 6, 21, screenColumn LIBSCREEN_COPYMAPROW_VVA 7, 22, screenColumn ; ground colors LIBSCREEN_COPYMAPROWCOLOR_VVA 2, 17, screenColumn LIBSCREEN_COPYMAPROWCOLOR_VVA 3, 18, screenColumn LIBSCREEN_COPYMAPROWCOLOR_VVA 4, 19, screenColumn LIBSCREEN_COPYMAPROWCOLOR_VVA 5, 20, screenColumn LIBSCREEN_COPYMAPROWCOLOR_VVA 6, 21, screenColumn rts
; A221217: T(n,k) = ((n+k)^2-2*n+3-(n+k-1)*(1+2*(-1)^(n+k)))/2; n , k > 0, read by antidiagonals. ; 1,6,5,4,3,2,15,14,13,12,11,10,9,8,7,28,27,26,25,24,23,22,21,20,19,18,17,16,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,66,65,64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,91,90,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71,70,69,68,67,120,119,118,117,116,115,114,113,112 mov $2,1 lpb $0 sub $0,$2 add $2,4 add $1,$2 lpe sub $1,$0 mov $0,$1 add $0,1
// Copyright (C) 2018-2019 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #pragma once #include <map> #include <opencv2/core/core.hpp> #include <opencv2/core/mat.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <string> #include <vector> #include "PreprocessingOptions.hpp" #include "backend.hpp" using namespace cv; class ImageDecoder { public: /** * @brief Load single image to blob * @param name - image file name * @param blob - blob object to load image data to * @return original image sizes */ Size loadToBlob(std::string name, std::shared_ptr<VBlob> blob, PreprocessingOptions preprocessingOptions); /** * @brief Load a list of images to blob * @param names - list of images filenames * @param blob - blob object to load images data to * @return original image size */ std::map<std::string, cv::Size> loadToBlob(std::vector<std::string> names, std::shared_ptr<VBlob> blob, PreprocessingOptions preprocessingOptions); /** * @brief Insert image data to blob at specified batch position. * Does no checks if blob has sufficient space * @param name - image file name * @param batch_pos - batch position image should be loaded to * @param blob - blob object to load image data to * @return original image size */ Size insertIntoBlob(std::string name, int batch_pos, std::shared_ptr<VBlob> blob, PreprocessingOptions preprocessingOptions); };
Name: zel_obj_data.asm Type: file Size: 1751 Last-Modified: '2016-05-13T04:20:48Z' SHA-1: CEEF93F18C04B5C5541A257BBB086457EE3DBF0C Description: null
SECTION code_clib SECTION code_fp_math48 PUBLIC copysign_callee EXTERN cm48_sccz80_copysign_callee defc copysign_callee = cm48_sccz80_copysign_callee
; A141354: Expansion of (1-5*x-x^2+x^3)/((1+x)*(1-x)^3). ; 1,-3,-7,-15,-23,-35,-47,-63,-79,-99,-119,-143,-167,-195,-223,-255,-287,-323,-359,-399,-439,-483,-527,-575,-623,-675,-727,-783,-839,-899,-959,-1023,-1087,-1155,-1223,-1295,-1367,-1443,-1519,-1599,-1679,-1763,-1847 add $0,1 pow $0,2 sub $1,$0 div $1,4 mul $1,4 add $1,1
; A180973: Numbers n such that 9^10 + n^2 is a square. ; Submitted by Jamie Morken(w1) ; 0,78732,262440,796068,2391120,7174332,21523320,64570068,193710240,581130732,1743392200 mov $2,$0 lpb $0 sub $0,1 mov $3,3 mov $4,$2 sub $2,2 add $4,8 pow $3,$4 add $1,$3 lpe mov $0,$1 mul $0,4
; A047281: Numbers that are congruent to {0, 3, 6} mod 7. ; 0,3,6,7,10,13,14,17,20,21,24,27,28,31,34,35,38,41,42,45,48,49,52,55,56,59,62,63,66,69,70,73,76,77,80,83,84,87,90,91,94,97,98,101,104,105,108,111,112,115,118,119,122,125,126,129,132,133,136,139,140,143,146,147,150,153,154,157,160,161,164,167,168,171,174,175,178,181,182,185,188,189,192,195,196,199,202,203,206,209,210,213,216,217,220,223,224,227,230,231 mov $2,7 mul $2,$0 mod $0,3 mul $0,2 add $0,$2 div $0,3
#include "search.h" using namespace std; bool CDir::ListFiles(){ /// Open Directory for reading DIR * direc = opendir(m_Path.c_str()); if (direc == NULL) return false; struct dirent * item = readdir (direc); if (m_Paths.size()==0) m_Paths.push_back(GetFullPath (m_Path)); while (item){ //Skips "." and ".." if (strcmp(item->d_name,".") == 0 || strcmp(item->d_name,"..") == 0){ item = readdir (direc); continue; } // item is directory if(item->d_type == DT_DIR){ Directory(item->d_name); } // item directory else if (item->d_type == DT_REG) { RegularFile(item->d_name); } item = readdir (direc); } return true; } void CDir::Directory(const string & dir){ m_Path = m_Path + "/" + dir; m_Paths.push_back(GetFullPath (m_Path)); if ( ListFiles() == false) throw runtime_error("Could not open file/directory"); m_Path.resize(m_Path.length() - 1 - dir.length()); } void CDir::RegularFile(const string & filename){ m_Paths.push_back(GetFullPath(m_Path + "/" + filename)); } list <string> CDir::GetPaths()const{ return m_Paths; } string CDir::GetFullPath (const string & rel_path)const{ char resolved_path[100]; char * res = realpath(rel_path.c_str(),resolved_path); if (!res) throw runtime_error("Can not resolve full path of file/directory"); return string(resolved_path); } //
// Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include <vector> #include <gtest/gtest.h> #include "low_precision_transformations/pad_transformation.hpp" using namespace LayerTestsDefinitions; namespace { const std::vector<ngraph::element::Type> netPrecisions = { ngraph::element::f32, // ngraph::element::f16 }; const std::vector<ngraph::PartialShape> inputShapes = { { 1, 3, 16, 16}, { 4, 3, 16, 16} }; const std::vector<ngraph::pass::low_precision::LayerTransformation::Params> trasformationParamValues = { LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; namespace commonTestCases { const std::vector<ngraph::op::PadMode> padModes = { ngraph::op::PadMode::CONSTANT, ngraph::op::PadMode::EDGE, ngraph::op::PadMode::REFLECT, ngraph::op::PadMode::SYMMETRIC }; const std::vector<LayerTestsDefinitions::PadTransformationParam> params = { // tensor quantization { { 256ul, ngraph::Shape{ 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 12.8f } }, { 0, 0, 1, 1 }, { 0, 0, 1, 1 }, 0.f, "Pad", "U8" }, // per-channel quantization with the same values { { 256ul, ngraph::Shape{ 1, 3, 1, 1 }, { -127.f, -127.f, -127.f }, { 128.f, 128.f, 128.f }, { 0.f, 0.f, 0.f }, { 255.f, 255.f, 255.f } }, { 0, 0, 1, 1 }, { 0, 0, 1, 1 }, 0.f, "Pad", "U8" }, // per-channel quantization with different values { { 256ul, ngraph::Shape{ 1, 3, 1, 1 }, { -127.f, 0.f, 128.f / 2.f }, { 128.f / 4.f, 128.f / 2.f, 128.f }, { 0.f, 0.f, 0.f }, { 255.f / 4.f, 255.f / 2.f, 255.f } }, { 0, 0, 1, 1 }, { 0, 0, 1, 1 }, 0.f, "Pad", "U8" }, }; INSTANTIATE_TEST_CASE_P(smoke_LPT, PadTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes), ::testing::ValuesIn(padModes), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), PadTransformation::getTestCaseName); } // namespace commonTestCases namespace testCasesForConstantMode { const std::vector<LayerTestsDefinitions::PadTransformationParam> params = { // tensor quantization { { 256ul, ngraph::Shape{ 1, 1, 1, 1 }, { -2.f }, { 10.5f }, { -2.f }, { 10.5f } }, { 0, 0, 1, 1 }, { 0, 0, 1, 1 }, 0.f, "Pad", "FP32" }, // tensor quantization with subtract, non zero padValue and pad by unique dimension { { 256ul, ngraph::Shape{ 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 12.8f } }, { 0, 0, 2, 0 }, { 0, 0, 1, 0 }, 2.f, "Pad", "U8" }, // per-channel quantization with different values, non zero padValue and pad by channel { { 256ul, ngraph::Shape{ 1, 3, 1, 1 }, { -127.f, 0.f, 128.f / 2.f }, { 128.f / 4.f, 128.f / 2.f, 128.f }, { 0.f, 0.f, 0.f }, { 255.f / 4.f, 255.f / 2.f, 255.f } }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 }, 2.f, "Pad", "U8" }, // per-channel quantization with subtract { { 256ul, ngraph::Shape{ 1, 3, 1, 1 }, { -2.f, -4.f, -6.f }, { 10.5f, 8.5f, 6.5f }, { -2.f, -4.f, -6.f }, { 10.5f, 8.5f, 6.5f } }, { 0, 0, 1, 1 }, { 0, 0, 1, 1 }, 0.f, "Pad", "FP32" }, }; INSTANTIATE_TEST_CASE_P(smoke_LPT, PadTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes), ::testing::Values(ngraph::op::PadMode::CONSTANT), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), PadTransformation::getTestCaseName); } // namespace testCasesForConstantMode namespace testCasesForOtherModes { const std::vector<ngraph::op::PadMode> modesWithoutConstant = { ngraph::op::PadMode::EDGE, ngraph::op::PadMode::REFLECT, ngraph::op::PadMode::SYMMETRIC }; const std::vector<LayerTestsDefinitions::PadTransformationParam> params = { // tensor quantization { { 256ul, ngraph::Shape{ 1, 1, 1, 1 }, { -2.f }, { 10.5f }, { -2.f }, { 10.5f } }, { 0, 0, 1, 1 }, { 0, 0, 1, 1 }, 0.f, "Pad", "U8" }, // per-channel quantization with subtract { { 256ul, ngraph::Shape{ 1, 3, 1, 1 }, { -2.f, -4.f, -6.f }, { 10.5f, 8.5f, 6.5f }, { -2.f, -4.f, -6.f }, { 10.5f, 8.5f, 6.5f } }, { 0, 0, 1, 1 }, { 0, 0, 1, 1 }, 0.f, "Pad", "U8" }, }; INSTANTIATE_TEST_CASE_P(smoke_LPT, PadTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(inputShapes), ::testing::ValuesIn(modesWithoutConstant), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), PadTransformation::getTestCaseName); } // namespace testCasesForOtherModes } // namespace
; ******************************************************************************************* ; ******************************************************************************************* ; ; Name : simpleunary.asm ; Purpose : Simple unary functions. ; Date : 3rd July 2019 ; Author : paul@robsons.org.uk ; ; ******************************************************************************************* ; ******************************************************************************************* ; ******************************************************************************************* ; ; len(s) => length ; ; ******************************************************************************************* Function_Len: ;; len( jsr EvaluateNext ; get the value you are absoluting sta DTemp1 ; save address sty DTemp1+2 lda #RParenTokenID ; check ) jsr CheckNextToken ldy #0 _FLenFindEnt: lda [DTemp1],y ; read the next character and #$00FF ; look at LSB only beq _FLEndFound iny ; do 64k maximum bne _FLenFindEnt jsr ReportError .text "Len() used on non string",0 _FLEndFound: sty EXSValueL+0,x ; save length. stz EXSValueH+0,x rts ; ******************************************************************************************* ; ; abs s => absolute value ; ; ******************************************************************************************* Function_Abs: ;; abs( jsr EvaluateNext ; get the value you are absoluting lda #RParenTokenID ; check ) jsr CheckNextToken lda EXSValueH+2,x ; get sign of result from the upper word. bmi _FAbsNegative ; negate it if negative sta EXSValueH+0,x ; otherwise just copy it. lda EXSValueL+2,x sta EXSValueL+0,x rts _FAbsNegative: sec ; copy 0 - 2nd stack => 1st stack. lda #0 sbc EXSValueL+2,x sta EXSValueL+0,x lda #0 sbc EXSValueH+2,x sta EXSValueH+0,x rts ; ******************************************************************************************* ; ; sign of number ; ; ******************************************************************************************* Function_Sgn: ;; sgn( jsr EvaluateNext ; get an integer lda #RParenTokenID ; check ) jsr CheckNextToken stz EXSValueL+0,x ; zero the result stz EXSValueH+0,x lda EXSValueH+2,x ; get sign of result from high bit of upper wod. bmi _FSgnNegative ; set to -1 if signed ora EXSValueL+2,x ; exit if zero as we already reset it. beq _FSgnExit ; inc EXSValueL+0,x ; > 0 so make result 1 if positive and non-zero _FSgnExit: rts ; _FSgnNegative: lda #$FFFF ; set the return value to -1 as negative. sta EXSValueL+0,x sta EXSValueH+0,x rts ; ******************************************************************************************* ; ; random integer ; ; (Galois LFSR) ; ******************************************************************************************* Function_Random: ;; rnd() lda DRandom ; check for non-zero ora DRandom+2 ; they don't like these :) bne _Rnd_NotZero lda #$B7 ; initialise it to the same value. sta DRandom lda #$D5 sta DRandom+2 _Rnd_NotZero: jsr _Rnd_Process ; call randomiser twice sta EXSValueH+0,x jsr _Rnd_Process sta EXSValueL+0,x rts _Rnd_Process: asl DRandom ; shift right, exit rol DRandom+2 bcc _Rnd_Exit lda DRandom ; taps effectively eor #$D454 sta DRandom lda DRandom+2 eor #$55D5 sta DRandom+2 _Rnd_Exit: lda DRandom eor DRandom+2 rts
// 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 <qt/clientmodel.h> #include <checkpoints.h> #include <clientversion.h> #include <config.h> #include <interfaces/handler.h> #include <interfaces/node.h> #include <net.h> #include <netbase.h> #include <qt/bantablemodel.h> #include <qt/guiconstants.h> #include <qt/guiutil.h> #include <qt/peertablemodel.h> #include <util/system.h> #include <validation.h> #include <QDebug> #include <QThread> #include <QTimer> #include <cstdint> static int64_t nLastHeaderTipUpdateNotification = 0; static int64_t nLastBlockTipUpdateNotification = 0; ClientModel::ClientModel(interfaces::Node &node, OptionsModel *_optionsModel, QObject *parent) : QObject(parent), m_node(node), optionsModel(_optionsModel), peerTableModel(nullptr), banTableModel(nullptr), m_thread(new QThread(this)) { cachedBestHeaderHeight = -1; cachedBestHeaderTime = -1; peerTableModel = new PeerTableModel(m_node, this); banTableModel = new BanTableModel(m_node, this); QTimer *timer = new QTimer; timer->setInterval(MODEL_UPDATE_DELAY); connect(timer, &QTimer::timeout, [this] { // no locking required at this point // the following calls will acquire the required lock Q_EMIT mempoolSizeChanged(m_node.getMempoolSize(), m_node.getMempoolDynamicUsage()); Q_EMIT bytesChanged(m_node.getTotalBytesRecv(), m_node.getTotalBytesSent()); }); connect(m_thread, &QThread::finished, timer, &QObject::deleteLater); connect(m_thread, &QThread::started, [timer] { timer->start(); }); // move timer to thread so that polling doesn't disturb main event loop timer->moveToThread(m_thread); m_thread->start(); subscribeToCoreSignals(); } ClientModel::~ClientModel() { unsubscribeFromCoreSignals(); m_thread->quit(); m_thread->wait(); } int ClientModel::getNumConnections(NumConnections flags) const { CConnman::NumConnections connections = CConnman::CONNECTIONS_NONE; if (flags == CONNECTIONS_IN) { connections = CConnman::CONNECTIONS_IN; } else if (flags == CONNECTIONS_OUT) { connections = CConnman::CONNECTIONS_OUT; } else if (flags == CONNECTIONS_ALL) { connections = CConnman::CONNECTIONS_ALL; } return m_node.getNodeCount(connections); } int ClientModel::getHeaderTipHeight() const { if (cachedBestHeaderHeight == -1) { // make sure we initially populate the cache via a cs_main lock // otherwise we need to wait for a tip update int height; int64_t blockTime; if (m_node.getHeaderTip(height, blockTime)) { cachedBestHeaderHeight = height; cachedBestHeaderTime = blockTime; } } return cachedBestHeaderHeight; } int64_t ClientModel::getHeaderTipTime() const { if (cachedBestHeaderTime == -1) { int height; int64_t blockTime; if (m_node.getHeaderTip(height, blockTime)) { cachedBestHeaderHeight = height; cachedBestHeaderTime = blockTime; } } return cachedBestHeaderTime; } void ClientModel::updateNumConnections(int numConnections) { Q_EMIT numConnectionsChanged(numConnections); } void ClientModel::updateNetworkActive(bool networkActive) { Q_EMIT networkActiveChanged(networkActive); } void ClientModel::updateAlert() { Q_EMIT alertsChanged(getStatusBarWarnings()); } enum BlockSource ClientModel::getBlockSource() const { if (m_node.getReindex()) { return BlockSource::REINDEX; } else if (m_node.getImporting()) { return BlockSource::DISK; } else if (getNumConnections() > 0) { return BlockSource::NETWORK; } return BlockSource::NONE; } QString ClientModel::getStatusBarWarnings() const { return QString::fromStdString(m_node.getWarnings()); } OptionsModel *ClientModel::getOptionsModel() { return optionsModel; } PeerTableModel *ClientModel::getPeerTableModel() { return peerTableModel; } BanTableModel *ClientModel::getBanTableModel() { return banTableModel; } QString ClientModel::formatFullVersion() const { return QString::fromStdString(FormatFullVersion()); } QString ClientModel::formatSubVersion() const { return QString::fromStdString(userAgent(GetConfig())); } bool ClientModel::isReleaseVersion() const { return CLIENT_VERSION_IS_RELEASE; } QString ClientModel::formatClientStartupTime() const { return QDateTime::fromTime_t(GetStartupTime()).toString(); } QString ClientModel::dataDir() const { return GUIUtil::boostPathToQString(GetDataDir()); } QString ClientModel::blocksDir() const { return GUIUtil::boostPathToQString(GetBlocksDir()); } void ClientModel::updateBanlist() { banTableModel->refresh(); } // Handlers for core signals static void ShowProgress(ClientModel *clientmodel, const std::string &title, int nProgress) { // emits signal "showProgress" bool invoked = QMetaObject::invokeMethod( clientmodel, "showProgress", Qt::QueuedConnection, Q_ARG(QString, QString::fromStdString(title)), Q_ARG(int, nProgress)); assert(invoked); } static void NotifyNumConnectionsChanged(ClientModel *clientmodel, int newNumConnections) { // Too noisy: qDebug() << "NotifyNumConnectionsChanged: " + // QString::number(newNumConnections); bool invoked = QMetaObject::invokeMethod( clientmodel, "updateNumConnections", Qt::QueuedConnection, Q_ARG(int, newNumConnections)); assert(invoked); } static void NotifyNetworkActiveChanged(ClientModel *clientmodel, bool networkActive) { bool invoked = QMetaObject::invokeMethod(clientmodel, "updateNetworkActive", Qt::QueuedConnection, Q_ARG(bool, networkActive)); assert(invoked); } static void NotifyAlertChanged(ClientModel *clientmodel) { qDebug() << "NotifyAlertChanged"; bool invoked = QMetaObject::invokeMethod(clientmodel, "updateAlert", Qt::QueuedConnection); assert(invoked); } static void BannedListChanged(ClientModel *clientmodel) { qDebug() << QString("%1: Requesting update for peer banlist").arg(__func__); bool invoked = QMetaObject::invokeMethod(clientmodel, "updateBanlist", Qt::QueuedConnection); assert(invoked); } static void BlockTipChanged(ClientModel *clientmodel, SynchronizationState sync_state, int height, int64_t blockTime, double verificationProgress, bool fHeader) { if (fHeader) { // cache best headers time and height to reduce future cs_main locks clientmodel->cachedBestHeaderHeight = height; clientmodel->cachedBestHeaderTime = blockTime; } // Throttle GUI notifications about (a) blocks during initial sync, and (b) // both blocks and headers during reindex. const bool throttle = (sync_state != SynchronizationState::POST_INIT && !fHeader) || sync_state == SynchronizationState::INIT_REINDEX; const int64_t now = throttle ? GetTimeMillis() : 0; int64_t &nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification; if (throttle && now < nLastUpdateNotification + MODEL_UPDATE_DELAY) { return; } bool invoked = QMetaObject::invokeMethod( clientmodel, "numBlocksChanged", Qt::QueuedConnection, Q_ARG(int, height), Q_ARG(QDateTime, QDateTime::fromTime_t(blockTime)), Q_ARG(double, verificationProgress), Q_ARG(bool, fHeader), Q_ARG(SynchronizationState, sync_state)); assert(invoked); nLastUpdateNotification = now; } void ClientModel::subscribeToCoreSignals() { // Connect signals to client m_handler_show_progress = m_node.handleShowProgress(std::bind( ShowProgress, this, std::placeholders::_1, std::placeholders::_2)); m_handler_notify_num_connections_changed = m_node.handleNotifyNumConnectionsChanged(std::bind( NotifyNumConnectionsChanged, this, std::placeholders::_1)); m_handler_notify_network_active_changed = m_node.handleNotifyNetworkActiveChanged( std::bind(NotifyNetworkActiveChanged, this, std::placeholders::_1)); m_handler_notify_alert_changed = m_node.handleNotifyAlertChanged(std::bind(NotifyAlertChanged, this)); m_handler_banned_list_changed = m_node.handleBannedListChanged(std::bind(BannedListChanged, this)); m_handler_notify_block_tip = m_node.handleNotifyBlockTip(std::bind( BlockTipChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, false)); m_handler_notify_header_tip = m_node.handleNotifyHeaderTip(std::bind( BlockTipChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, true)); } void ClientModel::unsubscribeFromCoreSignals() { // Disconnect signals from client m_handler_show_progress->disconnect(); m_handler_notify_num_connections_changed->disconnect(); m_handler_notify_network_active_changed->disconnect(); m_handler_notify_alert_changed->disconnect(); m_handler_banned_list_changed->disconnect(); m_handler_notify_block_tip->disconnect(); m_handler_notify_header_tip->disconnect(); } bool ClientModel::getProxyInfo(std::string &ip_port) const { proxyType ipv4, ipv6; if (m_node.getProxy((Network)1, ipv4) && m_node.getProxy((Network)2, ipv6)) { ip_port = ipv4.proxy.ToStringIPPort(); return true; } return false; }
; The MIT License (MIT) ; Copyright (c) 2015 Itay Grudev <itay@grudev.com> ; 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. ; ; Move data from a variable into another variable movv macro to, from push from pop to endm ; Compare two memory variables cmpv macro var1, var2, register mov register, var1 cmp register, var2 endm ; Add two memory variables addv macro to, from, register mov register, to add register, from mov to, register endm ; Subtract two memory variables subv macro to, from, register mov register, to sub register, from mov to, register endm ; Return Control to DOS return macro code mov ah, 4ch mov al, code int 21h endm ; Save registers to stack save_registers macro push ax push bx push cx push dx endm ; Restore registers from stack restore_registers macro pop dx pop cx pop bx pop ax endm ; Checks for a keypress; Sets ZF if no keypress is available ; Otherwise returns it's scan code into AH and it's ASCII into al ; Removes the charecter from the Type Ahead Buffer { USING AX } check_keypress: mov ah, 1 ; Checks if there is a character in the type ahead buffer int 16h ; MS-DOS BIOS Keyboard Services Interrupt jz check_keypress_empty mov ah, 0 int 16h ret check_keypress_empty: cmp ax, ax ; Explicitly sets the ZF ret
Sound57_PlatformKnock_Header: smpsHeaderStartSong 2, 1 smpsHeaderVoice Sound57_PlatformKnock_Voices smpsHeaderTempoSFX $01 smpsHeaderChanSFX $01 smpsHeaderSFXChannel cFM5, Sound57_PlatformKnock_FM5, $00, $00 ; FM5 Data Sound57_PlatformKnock_FM5: smpsSetvoice $00 dc.b nCs6, $15 smpsStop Sound57_PlatformKnock_Voices: ; Voice $00 ; $04 ; $09, $00, $70, $30, $1C, $DF, $1F, $1F, $15, $0B, $12, $0F ; $0C, $00, $0D, $0D, $07, $FA, $2F, $FA, $00, $00, $29, $00 smpsVcAlgorithm $04 smpsVcFeedback $00 smpsVcUnusedBits $00 smpsVcDetune $03, $07, $00, $00 smpsVcCoarseFreq $00, $00, $00, $09 smpsVcRateScale $00, $00, $03, $00 smpsVcAttackRate $1F, $1F, $1F, $1C smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $0F, $12, $0B, $15 smpsVcDecayRate2 $0D, $0D, $00, $0C smpsVcDecayLevel $0F, $02, $0F, $00 smpsVcReleaseRate $0A, $0F, $0A, $07 smpsVcTotalLevel $00, $29, $00, $00
title bfpsig - BASIC floating point error routine comment ! --------------------------------------------------------------------------- This module defines the __fpsignal routine for BASIC Copyright (C) Microsoft Corp. 1984, 1985, 1986 Written by Gregory F. Whitten --------------------------------------------------------------------------- Revision History 5/12/84 Greg Whitten signal routine moved to this module for C/Pascal/FORTRAN math sharing 09/26/86 Greg Whitten converted to BASIC signal handling 04/16/87 Greg Whitten SS must be equal to DGROUP (DS restored from SS) 04/21/87 Greg Whitten map invalid errors to overflow because integer overflow generates an invalid exception 05/13/87 Len Oorthuys QBI variation - update the pcode offset of errors that occur in executors 09/04/87 Leo Notenboom [1] Ensure that stack passed to B$RUNERR points to the address of the exception. 10/09/87 Brian Lewis [2] Bug fix - offset of math error is at bp+08, not bp+0ah. 03/10/88 Brian Lewis SizeD versions cannot assume ds == ss. 04/12/88 Brian Lewis Last change was bogus. --------------------------------------------------------------------------- ! include version.inc IncludeOnce exint IncludeOnce context IncludeOnce qbimsgs externP B$RUNERR externFP __fpmath sBegin CODE assumes cs,CODE assumes es,NOTHING assumes ss,DATA errtab label byte db ER_OV ; invalid (assume integer overflow) db ER_FC ; denormal db ER_DV0 ; zerodivide db ER_OV ; overflow db ER_OV ; underflow db ER_FC ; precision db ER_FC ; unemulated db ER_FC ; sqrtneg db ER_OV ; intoverflow db ER_FC ; stkoverflow db ER_FC ; stkunderflow ; process floating point error - dispatch to BASIC error handling ; ; there is stuff (return addresses) left on the stack labelFP <PUBLIC,__fpsignal> sub al,81h ; convert to 0 based error numbers mov bx,offset errtab xlat byte ptr cs:[bx] cbw ; (ax) = BASIC error code xchg ax,cx ; (cx) = BASIC error code push ss pop ds ; (ds) = DGROUP mov bx,sp nextframe: mov ax,[bx+0ah] ; (ax) = segment of math error cmp ax,seg __fpmath ; another iret on stack? jnz gotseg add bx,6 jmp nextframe ; go try the next frame gotseg: lea sp,[bx+08h] ; reset stack to that at error time mov dx,cs cmp ax,dx ; executor segment? jnz sigexit ; Not in the executors - exit mov ax,[bx+08] ; (ax) = offset of math error cmp ax,codeOFFSET __fpsignal; in the mathpack? jnb sigexit ; In the mathpack - exit mov [grs.GRS_oTxCur],si ; record oTx of error sigexit: mov bx,cx ; (bx) = BASIC error code jmp B$RUNERR ; goto BASIC error handler sEnd CODE end
; A307662: Triangle T(i,j=1..i) read by rows which contain the naturally ordered divisors-or-ones of the row number i. ; 1,1,2,1,1,3,1,2,1,4,1,1,1,1,5,1,2,3,1,1,6,1,1,1,1,1,1,7,1,2,1,4,1,1,1,8,1,1,3,1,1,1,1,1,9,1,2,1,1,5,1,1,1,1,10,1,1,1,1,1,1,1,1,1,1,11,1,2,3,4,1,6,1,1,1,1,1,12,1,1,1,1,1,1,1,1,1,1,1,1,13,1,2,1,1,1,1,7,1,1 lpb $0 add $2,1 sub $0,$2 lpe add $0,1 lpb $0 add $2,1 gcd $0,$2 lpe
;; ;; BSD 2-Clause License ;; ;; Copyright (c) 2021, Manas Kamal Choudhury ;; 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. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; ;; /PROJECT - Aurora's Xeneva v1.0 ;; @callback.asm -- system call interface for xnclib ;; ;;===================================================================================== section .text [BITS 64] ;;========================================================= ;; Memory Stuffs ;;========================================================= global mmap mmap: mov r12, 29 mov r13, rcx mov r14, rdx mov r15, r8 syscall ret global munmap munmap: mov r12, 30 mov r13, rcx mov r14, rdx syscall ret global valloc valloc: mov r12, 5 mov r13, rcx syscall ret global sys_exit sys_exit: mov r12, 25 syscall ret global sys_print_text sys_print_text: mov r12, 0 mov r13, rcx mov r14, rdx mov r15, r8 syscall ret global sys_wait sys_wait: mov r12, 1 syscall ret global ioquery ioquery: mov r12, 31 mov r13, rcx mov r14, rdx mov r15, r8 syscall ret global create_process create_process: mov r12, 2 mov r13, rcx mov r14, rdx syscall ret global message_send message_send: mov r12, 6 mov r13, rcx mov r14, rdx syscall ret global message_receive message_receive: mov r12, 7 mov r13, rcx syscall ret global get_current_pid get_current_pid mov r12, 9 syscall ret global map_shared_memory map_shared_memory: mov r12, 8 mov r13, rcx mov r14, rdx mov r15, r8 syscall ret global sys_sleep sys_sleep: mov r12, 24 mov r13, rcx syscall ret global create_uthread create_uthread: mov r12, 18 mov r13, rcx mov r14, rdx syscall ret global sys_open_file sys_open_file: mov r12, 19 mov r13, rcx mov r14, rdx syscall ret global sys_read_file sys_read_file: mov r12, 20 mov r13, rcx mov r14, rdx mov r15, r8 syscall ret global sys_unblock_id sys_unblock_id: mov r12, 17 mov r13, rcx syscall ret global sys_get_current_time sys_get_current_time: mov r12, 32 mov r13, rcx syscall ret global sys_get_system_tick sys_get_system_tick: mov r12, 33 syscall ret global sys_kill sys_kill: mov r12, 34 mov r13, rcx mov r14, rdx syscall ret global sys_set_signal sys_set_signal: mov r12, 35 mov r13, rcx mov r14, rdx syscall ret global sys_unmap_sh_mem sys_unmap_sh_mem: mov r12, 36 mov r13, rcx mov r14, rdx mov r15, r8 syscall ret global sys_get_used_ram sys_get_used_ram: mov r12, 22 syscall ret global sys_write_file sys_write_file: mov r12, 37 mov r13, rcx mov r14, rdx mov r15, r8 syscall ret global sys_ttype_create sys_ttype_create: mov r12,13 mov r13, rcx mov r14, rdx syscall ret global sys_attach_tty sys_attach_tty: mov r12,26 mov r13,rcx syscall ret global sys_pipe sys_pipe: mov r12, 16 mov r13, rcx mov r14, rdx syscall ret global vfree vfree: mov r12, 38 mov r13, rcx syscall ret global sys_get_free_ram sys_get_free_ram: mov r12, 23 syscall ret global sys_create_timer sys_create_timer: mov r12, 10 mov r13, rcx mov r14, rdx syscall ret global sys_destroy_timer sys_destroy_timer: mov r12, 11 mov r13, rcx syscall ret global sys_start_timer sys_start_timer: mov r12, 14 mov r13, rcx syscall ret global sys_pause_timer sys_pause_timer: mov r12, 15 mov r13, rcx syscall ret global sys_ttype_dup sys_ttype_dup: mov r12, 21 mov r13, rcx mov r14, rdx syscall ret
db MUK ; pokedex id db 105 ; base hp db 105 ; base attack db 75 ; base defense db 50 ; base speed db 65 ; base special db POISON ; species type 1 db POISON ; species type 2 db 75 ; catch rate db 157 ; base exp yield INCBIN "pic/gsmon/muk.pic",0,1 ; 77, sprite dimensions dw MukPicFront dw MukPicBack ; attacks known at lvl 0 db POUND db POISON_GAS db 0 db 0 db 0 ; growth rate ; learnset tmlearn 6,8 tmlearn 12,15 tmlearn 20,21,24 tmlearn 25,28,31,32 tmlearn 34,36,37,38 tmlearn 44,47,48 tmlearn 50,54 db BANK(MukPicFront)
; void *zx_cxy2saddr(uchar x, uchar y) SECTION code_clib SECTION code_arch PUBLIC zx_cxy2saddr EXTERN asm_zx_cxy2saddr zx_cxy2saddr: pop af pop de pop hl push hl push de push af ld h,e jp asm_zx_cxy2saddr
PresetsMenuGtclassic: dw #presets_goto_gtclassic_crateria dw #presets_goto_gtclassic_brinstar dw #presets_goto_gtclassic_kraid dw #presets_goto_gtclassic_bootless_upper_norfair dw #presets_goto_gtclassic_hi_jump_upper_norfair dw #presets_goto_gtclassic_lower_norfair dw #presets_goto_gtclassic_maridia dw #presets_goto_gtclassic_wrecked_ship dw #presets_goto_gtclassic_tourian dw #$0000 %cm_header("PRESETS FOR GT CLASSIC") presets_goto_gtclassic_crateria: %cm_submenu("Crateria", #presets_submenu_gtclassic_crateria) presets_goto_gtclassic_brinstar: %cm_submenu("Brinstar", #presets_submenu_gtclassic_brinstar) presets_goto_gtclassic_kraid: %cm_submenu("Kraid's Lair", #presets_submenu_gtclassic_kraid) presets_goto_gtclassic_bootless_upper_norfair: %cm_submenu("Bootless Upper Norfair", #presets_submenu_gtclassic_bootless_upper_norfair) presets_goto_gtclassic_hi_jump_upper_norfair: %cm_submenu("Hi Jump Upper Norfair", #presets_submenu_gtclassic_hi_jump_upper_norfair) presets_goto_gtclassic_lower_norfair: %cm_submenu("Lower Norfair", #presets_submenu_gtclassic_lower_norfair) presets_goto_gtclassic_maridia: %cm_submenu("Maridia", #presets_submenu_gtclassic_maridia) presets_goto_gtclassic_wrecked_ship: %cm_submenu("Wrecked Ship", #presets_submenu_gtclassic_wrecked_ship) presets_goto_gtclassic_tourian: %cm_submenu("Tourian", #presets_submenu_gtclassic_tourian) presets_submenu_gtclassic_crateria: dw #presets_gtclassic_crateria_ceres_elevator dw #presets_gtclassic_crateria_ceres_escape dw #presets_gtclassic_crateria_ceres_last_3_rooms dw #presets_gtclassic_crateria_ship dw #presets_gtclassic_crateria_parlor dw #presets_gtclassic_crateria_parlor_downback dw #presets_gtclassic_crateria_climb_down dw #presets_gtclassic_crateria_pit_room dw #presets_gtclassic_crateria_morph dw #presets_gtclassic_crateria_construction_zone_down dw #presets_gtclassic_crateria_construction_zone_up dw #presets_gtclassic_crateria_pit_room_revisit dw #presets_gtclassic_crateria_climb_up dw #presets_gtclassic_crateria_parlor_revisit dw #presets_gtclassic_crateria_flyway dw #presets_gtclassic_crateria_bomb_torizo dw #presets_gtclassic_crateria_alcatraz dw #presets_gtclassic_crateria_terminator dw #presets_gtclassic_crateria_green_pirate_shaft dw #$0000 %cm_header("CRATERIA") presets_submenu_gtclassic_brinstar: dw #presets_gtclassic_brinstar_green_brinstar_elevator dw #presets_gtclassic_brinstar_early_supers dw #presets_gtclassic_brinstar_dachora_room dw #presets_gtclassic_brinstar_big_pink dw #presets_gtclassic_brinstar_green_hill_zone dw #presets_gtclassic_brinstar_noob_bridge dw #presets_gtclassic_brinstar_red_tower dw #presets_gtclassic_brinstar_hellway dw #presets_gtclassic_brinstar_caterpillars_down dw #presets_gtclassic_brinstar_alpha_power_bombs dw #presets_gtclassic_brinstar_caterpillars_up dw #presets_gtclassic_brinstar_reverse_hellway dw #presets_gtclassic_brinstar_red_tower_down dw #presets_gtclassic_brinstar_skree_boost dw #presets_gtclassic_brinstar_below_spazer dw #presets_gtclassic_brinstar_breaking_tube dw #$0000 %cm_header("BRINSTAR") presets_submenu_gtclassic_kraid: dw #presets_gtclassic_kraid_entering_kraids_lair dw #presets_gtclassic_kraid_kraid_kihunters dw #presets_gtclassic_kraid_mini_kraid dw #presets_gtclassic_kraid_kraid_2 dw #presets_gtclassic_kraid_leaving_varia dw #presets_gtclassic_kraid_mini_kraid_revisit dw #presets_gtclassic_kraid_kraid_kihunters_revisit dw #presets_gtclassic_kraid_kraid_etank dw #presets_gtclassic_kraid_leaving_kraids_lair dw #$0000 %cm_header("KRAID'S LAIR") presets_submenu_gtclassic_bootless_upper_norfair: dw #presets_gtclassic_bootless_upper_norfair_business_center dw #presets_gtclassic_bootless_upper_norfair_cathedral dw #presets_gtclassic_bootless_upper_norfair_rising_tide dw #presets_gtclassic_bootless_upper_norfair_bubble_mountain dw #presets_gtclassic_bootless_upper_norfair_magdollite_tunnel dw #presets_gtclassic_bootless_upper_norfair_kronic_room dw #presets_gtclassic_bootless_upper_norfair_lava_dive dw #presets_gtclassic_bootless_upper_norfair_ln_main_hall dw #presets_gtclassic_bootless_upper_norfair_prepillars dw #presets_gtclassic_bootless_upper_norfair_green_gate_glitch dw #presets_gtclassic_bootless_upper_norfair_gt_code dw #$0000 %cm_header("BOOTLESS UPPER NORFAIR") presets_submenu_gtclassic_hi_jump_upper_norfair: dw #presets_gtclassic_hi_jump_upper_norfair_business_center dw #presets_gtclassic_hi_jump_upper_norfair_hi_jump_etank dw #presets_gtclassic_hi_jump_upper_norfair_leaving_hi_jump dw #presets_gtclassic_hi_jump_upper_norfair_business_center_revisit dw #presets_gtclassic_hi_jump_upper_norfair_precathedral dw #presets_gtclassic_hi_jump_upper_norfair_cathedral dw #presets_gtclassic_hi_jump_upper_norfair_rising_tide dw #presets_gtclassic_hi_jump_upper_norfair_bubble_mountain dw #presets_gtclassic_hi_jump_upper_norfair_magdollite_tunnel dw #presets_gtclassic_hi_jump_upper_norfair_kronic_room dw #presets_gtclassic_hi_jump_upper_norfair_lava_dive dw #presets_gtclassic_hi_jump_upper_norfair_ln_main_hall dw #presets_gtclassic_hi_jump_upper_norfair_prepillars dw #presets_gtclassic_hi_jump_upper_norfair_green_gate_glitch dw #presets_gtclassic_hi_jump_upper_norfair_gt_code dw #$0000 %cm_header("HI JUMP UPPER NORFAIR") presets_submenu_gtclassic_lower_norfair: dw #presets_gtclassic_lower_norfair_leaving_golden_torizo dw #presets_gtclassic_lower_norfair_green_gate_revisit dw #presets_gtclassic_lower_norfair_worst_room_in_the_game dw #presets_gtclassic_lower_norfair_amphitheatre dw #presets_gtclassic_lower_norfair_kihunter_stairs_down dw #presets_gtclassic_lower_norfair_wasteland dw #presets_gtclassic_lower_norfair_metal_ninja_pirates dw #presets_gtclassic_lower_norfair_plowerhouse dw #presets_gtclassic_lower_norfair_ridley dw #presets_gtclassic_lower_norfair_leaving_ridley dw #presets_gtclassic_lower_norfair_reverse_plowerhouse dw #presets_gtclassic_lower_norfair_wasteland_revisit dw #presets_gtclassic_lower_norfair_kihunter_stairs_up dw #presets_gtclassic_lower_norfair_fireflea_room dw #presets_gtclassic_lower_norfair_springball_maze dw #presets_gtclassic_lower_norfair_three_musketeers dw #presets_gtclassic_lower_norfair_single_chamber_final dw #presets_gtclassic_lower_norfair_bubble_mountain_final dw #presets_gtclassic_lower_norfair_frog_speedway dw #presets_gtclassic_lower_norfair_business_center_final dw #$0000 %cm_header("LOWER NORFAIR") presets_submenu_gtclassic_maridia: dw #presets_gtclassic_maridia_maridia_tube_revisit dw #presets_gtclassic_maridia_fish_tank dw #presets_gtclassic_maridia_mt_everest dw #presets_gtclassic_maridia_crab_shaft dw #presets_gtclassic_maridia_aqueduct dw #presets_gtclassic_maridia_botwoon_hallway dw #presets_gtclassic_maridia_botwoon dw #presets_gtclassic_maridia_halfie_setup dw #presets_gtclassic_maridia_draygon dw #presets_gtclassic_maridia_reverse_halfie_spikesuit dw #presets_gtclassic_maridia_womple_jump dw #presets_gtclassic_maridia_reverse_halfie_climb dw #presets_gtclassic_maridia_reverse_botwoon_etank dw #presets_gtclassic_maridia_reverse_botwoon_hallway dw #presets_gtclassic_maridia_aqueduct_revisit dw #presets_gtclassic_maridia_reverse_crab_shaft dw #presets_gtclassic_maridia_mt_everest_revisit dw #presets_gtclassic_maridia_red_brinstar_green_gate dw #$0000 %cm_header("MARIDIA") presets_submenu_gtclassic_wrecked_ship: dw #presets_gtclassic_wrecked_ship_crateria_kihunters dw #presets_gtclassic_wrecked_ship_moat dw #presets_gtclassic_wrecked_ship_ocean dw #presets_gtclassic_wrecked_ship_wrecked_ship_shaft dw #presets_gtclassic_wrecked_ship_basement dw #presets_gtclassic_wrecked_ship_phantoon dw #presets_gtclassic_wrecked_ship_shaft_climb dw #presets_gtclassic_wrecked_ship_ocean_revisit dw #presets_gtclassic_wrecked_ship_crateria_kihunters_revisit dw #presets_gtclassic_wrecked_ship_parlor_return dw #presets_gtclassic_wrecked_ship_terminator_revisit dw #presets_gtclassic_wrecked_ship_green_pirate_shaft_2 dw #presets_gtclassic_wrecked_ship_g4_elevator dw #$0000 %cm_header("WRECKED SHIP") presets_submenu_gtclassic_tourian: dw #presets_gtclassic_tourian_tourian_elevator_room dw #presets_gtclassic_tourian_metroids_1 dw #presets_gtclassic_tourian_metroids_2 dw #presets_gtclassic_tourian_metroids_3 dw #presets_gtclassic_tourian_metroids_4 dw #presets_gtclassic_tourian_giant_hoppers dw #presets_gtclassic_tourian_baby_skip dw #presets_gtclassic_tourian_gadora_room dw #presets_gtclassic_tourian_zeb_skip dw #presets_gtclassic_tourian_mother_brain_2 dw #presets_gtclassic_tourian_zebes_escape dw #presets_gtclassic_tourian_escape_room_3 dw #presets_gtclassic_tourian_escape_room_4 dw #presets_gtclassic_tourian_escape_climb dw #presets_gtclassic_tourian_escape_parlor dw #$0000 %cm_header("TOURIAN") ; Crateria presets_gtclassic_crateria_ceres_elevator: %cm_preset("Ceres Elevator", #preset_gtclassic_crateria_ceres_elevator) presets_gtclassic_crateria_ceres_escape: %cm_preset("Ceres Escape", #preset_gtclassic_crateria_ceres_escape) presets_gtclassic_crateria_ceres_last_3_rooms: %cm_preset("Ceres Last 3 rooms", #preset_gtclassic_crateria_ceres_last_3_rooms) presets_gtclassic_crateria_ship: %cm_preset("Ship", #preset_gtclassic_crateria_ship) presets_gtclassic_crateria_parlor: %cm_preset("Parlor", #preset_gtclassic_crateria_parlor) presets_gtclassic_crateria_parlor_downback: %cm_preset("Parlor Downback", #preset_gtclassic_crateria_parlor_downback) presets_gtclassic_crateria_climb_down: %cm_preset("Climb Down", #preset_gtclassic_crateria_climb_down) presets_gtclassic_crateria_pit_room: %cm_preset("Pit Room", #preset_gtclassic_crateria_pit_room) presets_gtclassic_crateria_morph: %cm_preset("Morph", #preset_gtclassic_crateria_morph) presets_gtclassic_crateria_construction_zone_down: %cm_preset("Construction Zone Down", #preset_gtclassic_crateria_construction_zone_down) presets_gtclassic_crateria_construction_zone_up: %cm_preset("Construction Zone Up", #preset_gtclassic_crateria_construction_zone_up) presets_gtclassic_crateria_pit_room_revisit: %cm_preset("Pit Room Revisit", #preset_gtclassic_crateria_pit_room_revisit) presets_gtclassic_crateria_climb_up: %cm_preset("Climb Up", #preset_gtclassic_crateria_climb_up) presets_gtclassic_crateria_parlor_revisit: %cm_preset("Parlor Revisit", #preset_gtclassic_crateria_parlor_revisit) presets_gtclassic_crateria_flyway: %cm_preset("Flyway", #preset_gtclassic_crateria_flyway) presets_gtclassic_crateria_bomb_torizo: %cm_preset("Bomb Torizo", #preset_gtclassic_crateria_bomb_torizo) presets_gtclassic_crateria_alcatraz: %cm_preset("Alcatraz", #preset_gtclassic_crateria_alcatraz) presets_gtclassic_crateria_terminator: %cm_preset("Terminator", #preset_gtclassic_crateria_terminator) presets_gtclassic_crateria_green_pirate_shaft: %cm_preset("Green Pirate Shaft", #preset_gtclassic_crateria_green_pirate_shaft) ; Brinstar presets_gtclassic_brinstar_green_brinstar_elevator: %cm_preset("Green Brinstar Elevator", #preset_gtclassic_brinstar_green_brinstar_elevator) presets_gtclassic_brinstar_early_supers: %cm_preset("Early Supers", #preset_gtclassic_brinstar_early_supers) presets_gtclassic_brinstar_dachora_room: %cm_preset("Dachora Room", #preset_gtclassic_brinstar_dachora_room) presets_gtclassic_brinstar_big_pink: %cm_preset("Big Pink", #preset_gtclassic_brinstar_big_pink) presets_gtclassic_brinstar_green_hill_zone: %cm_preset("Green Hill Zone", #preset_gtclassic_brinstar_green_hill_zone) presets_gtclassic_brinstar_noob_bridge: %cm_preset("Noob Bridge", #preset_gtclassic_brinstar_noob_bridge) presets_gtclassic_brinstar_red_tower: %cm_preset("Red Tower", #preset_gtclassic_brinstar_red_tower) presets_gtclassic_brinstar_hellway: %cm_preset("Hellway", #preset_gtclassic_brinstar_hellway) presets_gtclassic_brinstar_caterpillars_down: %cm_preset("Caterpillars Down", #preset_gtclassic_brinstar_caterpillars_down) presets_gtclassic_brinstar_alpha_power_bombs: %cm_preset("Alpha Power Bombs", #preset_gtclassic_brinstar_alpha_power_bombs) presets_gtclassic_brinstar_caterpillars_up: %cm_preset("Caterpillars Up", #preset_gtclassic_brinstar_caterpillars_up) presets_gtclassic_brinstar_reverse_hellway: %cm_preset("Reverse Hellway", #preset_gtclassic_brinstar_reverse_hellway) presets_gtclassic_brinstar_red_tower_down: %cm_preset("Red Tower Down", #preset_gtclassic_brinstar_red_tower_down) presets_gtclassic_brinstar_skree_boost: %cm_preset("Skree Boost", #preset_gtclassic_brinstar_skree_boost) presets_gtclassic_brinstar_below_spazer: %cm_preset("Below Spazer", #preset_gtclassic_brinstar_below_spazer) presets_gtclassic_brinstar_breaking_tube: %cm_preset("Breaking Tube", #preset_gtclassic_brinstar_breaking_tube) ; Kraid's Lair presets_gtclassic_kraid_entering_kraids_lair: %cm_preset("Entering Kraid's Lair", #preset_gtclassic_kraid_entering_kraids_lair) presets_gtclassic_kraid_kraid_kihunters: %cm_preset("Kraid Kihunters", #preset_gtclassic_kraid_kraid_kihunters) presets_gtclassic_kraid_mini_kraid: %cm_preset("Mini Kraid", #preset_gtclassic_kraid_mini_kraid) presets_gtclassic_kraid_kraid_2: %cm_preset("Kraid", #preset_gtclassic_kraid_kraid_2) presets_gtclassic_kraid_leaving_varia: %cm_preset("Leaving Varia", #preset_gtclassic_kraid_leaving_varia) presets_gtclassic_kraid_mini_kraid_revisit: %cm_preset("Mini Kraid Revisit", #preset_gtclassic_kraid_mini_kraid_revisit) presets_gtclassic_kraid_kraid_kihunters_revisit: %cm_preset("Kraid Kihunters Revisit", #preset_gtclassic_kraid_kraid_kihunters_revisit) presets_gtclassic_kraid_kraid_etank: %cm_preset("Kraid E-tank", #preset_gtclassic_kraid_kraid_etank) presets_gtclassic_kraid_leaving_kraids_lair: %cm_preset("Leaving Kraid's Lair", #preset_gtclassic_kraid_leaving_kraids_lair) ; Bootless Upper Norfair presets_gtclassic_bootless_upper_norfair_business_center: %cm_preset("Business Center", #preset_gtclassic_bootless_upper_norfair_business_center) presets_gtclassic_bootless_upper_norfair_cathedral: %cm_preset("Cathedral", #preset_gtclassic_bootless_upper_norfair_cathedral) presets_gtclassic_bootless_upper_norfair_rising_tide: %cm_preset("Rising Tide", #preset_gtclassic_bootless_upper_norfair_rising_tide) presets_gtclassic_bootless_upper_norfair_bubble_mountain: %cm_preset("Bubble Mountain", #preset_gtclassic_bootless_upper_norfair_bubble_mountain) presets_gtclassic_bootless_upper_norfair_magdollite_tunnel: %cm_preset("Magdollite Tunnel", #preset_gtclassic_bootless_upper_norfair_magdollite_tunnel) presets_gtclassic_bootless_upper_norfair_kronic_room: %cm_preset("Kronic Room", #preset_gtclassic_bootless_upper_norfair_kronic_room) presets_gtclassic_bootless_upper_norfair_lava_dive: %cm_preset("Lava Dive", #preset_gtclassic_bootless_upper_norfair_lava_dive) presets_gtclassic_bootless_upper_norfair_ln_main_hall: %cm_preset("LN Main Hall", #preset_gtclassic_bootless_upper_norfair_ln_main_hall) presets_gtclassic_bootless_upper_norfair_prepillars: %cm_preset("Pre-Pillars", #preset_gtclassic_bootless_upper_norfair_prepillars) presets_gtclassic_bootless_upper_norfair_green_gate_glitch: %cm_preset("Green Gate Glitch", #preset_gtclassic_bootless_upper_norfair_green_gate_glitch) presets_gtclassic_bootless_upper_norfair_gt_code: %cm_preset("GT Code", #preset_gtclassic_bootless_upper_norfair_gt_code) ; Hi Jump Upper Norfair presets_gtclassic_hi_jump_upper_norfair_business_center: %cm_preset("Business Center", #preset_gtclassic_hi_jump_upper_norfair_business_center) presets_gtclassic_hi_jump_upper_norfair_hi_jump_etank: %cm_preset("Hi Jump E-tank", #preset_gtclassic_hi_jump_upper_norfair_hi_jump_etank) presets_gtclassic_hi_jump_upper_norfair_leaving_hi_jump: %cm_preset("Leaving Hi Jump", #preset_gtclassic_hi_jump_upper_norfair_leaving_hi_jump) presets_gtclassic_hi_jump_upper_norfair_business_center_revisit: %cm_preset("Business Center Revisit", #preset_gtclassic_hi_jump_upper_norfair_business_center_revisit) presets_gtclassic_hi_jump_upper_norfair_precathedral: %cm_preset("Pre-Cathedral", #preset_gtclassic_hi_jump_upper_norfair_precathedral) presets_gtclassic_hi_jump_upper_norfair_cathedral: %cm_preset("Cathedral", #preset_gtclassic_hi_jump_upper_norfair_cathedral) presets_gtclassic_hi_jump_upper_norfair_rising_tide: %cm_preset("Rising Tide", #preset_gtclassic_hi_jump_upper_norfair_rising_tide) presets_gtclassic_hi_jump_upper_norfair_bubble_mountain: %cm_preset("Bubble Mountain", #preset_gtclassic_hi_jump_upper_norfair_bubble_mountain) presets_gtclassic_hi_jump_upper_norfair_magdollite_tunnel: %cm_preset("Magdollite Tunnel", #preset_gtclassic_hi_jump_upper_norfair_magdollite_tunnel) presets_gtclassic_hi_jump_upper_norfair_kronic_room: %cm_preset("Kronic Room", #preset_gtclassic_hi_jump_upper_norfair_kronic_room) presets_gtclassic_hi_jump_upper_norfair_lava_dive: %cm_preset("Lava Dive", #preset_gtclassic_hi_jump_upper_norfair_lava_dive) presets_gtclassic_hi_jump_upper_norfair_ln_main_hall: %cm_preset("LN Main Hall", #preset_gtclassic_hi_jump_upper_norfair_ln_main_hall) presets_gtclassic_hi_jump_upper_norfair_prepillars: %cm_preset("Pre-Pillars", #preset_gtclassic_hi_jump_upper_norfair_prepillars) presets_gtclassic_hi_jump_upper_norfair_green_gate_glitch: %cm_preset("Green Gate Glitch", #preset_gtclassic_hi_jump_upper_norfair_green_gate_glitch) presets_gtclassic_hi_jump_upper_norfair_gt_code: %cm_preset("GT Code", #preset_gtclassic_hi_jump_upper_norfair_gt_code) ; Lower Norfair presets_gtclassic_lower_norfair_leaving_golden_torizo: %cm_preset("Leaving Golden Torizo", #preset_gtclassic_lower_norfair_leaving_golden_torizo) presets_gtclassic_lower_norfair_green_gate_revisit: %cm_preset("Green Gate Revisit", #preset_gtclassic_lower_norfair_green_gate_revisit) presets_gtclassic_lower_norfair_worst_room_in_the_game: %cm_preset("Worst Room in the Game", #preset_gtclassic_lower_norfair_worst_room_in_the_game) presets_gtclassic_lower_norfair_amphitheatre: %cm_preset("Amphitheatre", #preset_gtclassic_lower_norfair_amphitheatre) presets_gtclassic_lower_norfair_kihunter_stairs_down: %cm_preset("Kihunter Stairs Down", #preset_gtclassic_lower_norfair_kihunter_stairs_down) presets_gtclassic_lower_norfair_wasteland: %cm_preset("Wasteland", #preset_gtclassic_lower_norfair_wasteland) presets_gtclassic_lower_norfair_metal_ninja_pirates: %cm_preset("Metal Ninja Pirates", #preset_gtclassic_lower_norfair_metal_ninja_pirates) presets_gtclassic_lower_norfair_plowerhouse: %cm_preset("Plowerhouse", #preset_gtclassic_lower_norfair_plowerhouse) presets_gtclassic_lower_norfair_ridley: %cm_preset("Ridley", #preset_gtclassic_lower_norfair_ridley) presets_gtclassic_lower_norfair_leaving_ridley: %cm_preset("Leaving Ridley", #preset_gtclassic_lower_norfair_leaving_ridley) presets_gtclassic_lower_norfair_reverse_plowerhouse: %cm_preset("Reverse Plowerhouse", #preset_gtclassic_lower_norfair_reverse_plowerhouse) presets_gtclassic_lower_norfair_wasteland_revisit: %cm_preset("Wasteland Revisit", #preset_gtclassic_lower_norfair_wasteland_revisit) presets_gtclassic_lower_norfair_kihunter_stairs_up: %cm_preset("Kihunter Stairs Up", #preset_gtclassic_lower_norfair_kihunter_stairs_up) presets_gtclassic_lower_norfair_fireflea_room: %cm_preset("Fireflea Room", #preset_gtclassic_lower_norfair_fireflea_room) presets_gtclassic_lower_norfair_springball_maze: %cm_preset("Springball Maze", #preset_gtclassic_lower_norfair_springball_maze) presets_gtclassic_lower_norfair_three_musketeers: %cm_preset("Three Musketeers", #preset_gtclassic_lower_norfair_three_musketeers) presets_gtclassic_lower_norfair_single_chamber_final: %cm_preset("Single Chamber Final", #preset_gtclassic_lower_norfair_single_chamber_final) presets_gtclassic_lower_norfair_bubble_mountain_final: %cm_preset("Bubble Mountain Final", #preset_gtclassic_lower_norfair_bubble_mountain_final) presets_gtclassic_lower_norfair_frog_speedway: %cm_preset("Frog Speedway", #preset_gtclassic_lower_norfair_frog_speedway) presets_gtclassic_lower_norfair_business_center_final: %cm_preset("Business Center Final", #preset_gtclassic_lower_norfair_business_center_final) ; Maridia presets_gtclassic_maridia_maridia_tube_revisit: %cm_preset("Maridia Tube Revisit", #preset_gtclassic_maridia_maridia_tube_revisit) presets_gtclassic_maridia_fish_tank: %cm_preset("Fish Tank", #preset_gtclassic_maridia_fish_tank) presets_gtclassic_maridia_mt_everest: %cm_preset("Mt Everest", #preset_gtclassic_maridia_mt_everest) presets_gtclassic_maridia_crab_shaft: %cm_preset("Crab Shaft", #preset_gtclassic_maridia_crab_shaft) presets_gtclassic_maridia_aqueduct: %cm_preset("Aqueduct", #preset_gtclassic_maridia_aqueduct) presets_gtclassic_maridia_botwoon_hallway: %cm_preset("Botwoon Hallway", #preset_gtclassic_maridia_botwoon_hallway) presets_gtclassic_maridia_botwoon: %cm_preset("Botwoon", #preset_gtclassic_maridia_botwoon) presets_gtclassic_maridia_halfie_setup: %cm_preset("Halfie Setup", #preset_gtclassic_maridia_halfie_setup) presets_gtclassic_maridia_draygon: %cm_preset("Draygon", #preset_gtclassic_maridia_draygon) presets_gtclassic_maridia_reverse_halfie_spikesuit: %cm_preset("Reverse Halfie (Spikesuit)", #preset_gtclassic_maridia_reverse_halfie_spikesuit) presets_gtclassic_maridia_womple_jump: %cm_preset("Womple Jump", #preset_gtclassic_maridia_womple_jump) presets_gtclassic_maridia_reverse_halfie_climb: %cm_preset("Reverse Halfie Climb", #preset_gtclassic_maridia_reverse_halfie_climb) presets_gtclassic_maridia_reverse_botwoon_etank: %cm_preset("Reverse Botwoon E-tank", #preset_gtclassic_maridia_reverse_botwoon_etank) presets_gtclassic_maridia_reverse_botwoon_hallway: %cm_preset("Reverse Botwoon Hallway", #preset_gtclassic_maridia_reverse_botwoon_hallway) presets_gtclassic_maridia_aqueduct_revisit: %cm_preset("Aqueduct Revisit", #preset_gtclassic_maridia_aqueduct_revisit) presets_gtclassic_maridia_reverse_crab_shaft: %cm_preset("Reverse Crab Shaft", #preset_gtclassic_maridia_reverse_crab_shaft) presets_gtclassic_maridia_mt_everest_revisit: %cm_preset("Mt Everest Revisit", #preset_gtclassic_maridia_mt_everest_revisit) presets_gtclassic_maridia_red_brinstar_green_gate: %cm_preset("Red Brinstar Green Gate", #preset_gtclassic_maridia_red_brinstar_green_gate) ; Wrecked Ship presets_gtclassic_wrecked_ship_crateria_kihunters: %cm_preset("Crateria Kihunters", #preset_gtclassic_wrecked_ship_crateria_kihunters) presets_gtclassic_wrecked_ship_moat: %cm_preset("Moat", #preset_gtclassic_wrecked_ship_moat) presets_gtclassic_wrecked_ship_ocean: %cm_preset("Ocean", #preset_gtclassic_wrecked_ship_ocean) presets_gtclassic_wrecked_ship_wrecked_ship_shaft: %cm_preset("Wrecked Ship Shaft", #preset_gtclassic_wrecked_ship_wrecked_ship_shaft) presets_gtclassic_wrecked_ship_basement: %cm_preset("Basement", #preset_gtclassic_wrecked_ship_basement) presets_gtclassic_wrecked_ship_phantoon: %cm_preset("Phantoon", #preset_gtclassic_wrecked_ship_phantoon) presets_gtclassic_wrecked_ship_shaft_climb: %cm_preset("Shaft Climb", #preset_gtclassic_wrecked_ship_shaft_climb) presets_gtclassic_wrecked_ship_ocean_revisit: %cm_preset("Ocean Revisit", #preset_gtclassic_wrecked_ship_ocean_revisit) presets_gtclassic_wrecked_ship_crateria_kihunters_revisit: %cm_preset("Crateria Kihunters Revisit", #preset_gtclassic_wrecked_ship_crateria_kihunters_revisit) presets_gtclassic_wrecked_ship_parlor_return: %cm_preset("Parlor Return", #preset_gtclassic_wrecked_ship_parlor_return) presets_gtclassic_wrecked_ship_terminator_revisit: %cm_preset("Terminator Revisit", #preset_gtclassic_wrecked_ship_terminator_revisit) presets_gtclassic_wrecked_ship_green_pirate_shaft_2: %cm_preset("Green Pirate Shaft", #preset_gtclassic_wrecked_ship_green_pirate_shaft_2) presets_gtclassic_wrecked_ship_g4_elevator: %cm_preset("G4 Elevator", #preset_gtclassic_wrecked_ship_g4_elevator) ; Tourian presets_gtclassic_tourian_tourian_elevator_room: %cm_preset("Tourian Elevator Room", #preset_gtclassic_tourian_tourian_elevator_room) presets_gtclassic_tourian_metroids_1: %cm_preset("Metroids 1", #preset_gtclassic_tourian_metroids_1) presets_gtclassic_tourian_metroids_2: %cm_preset("Metroids 2", #preset_gtclassic_tourian_metroids_2) presets_gtclassic_tourian_metroids_3: %cm_preset("Metroids 3", #preset_gtclassic_tourian_metroids_3) presets_gtclassic_tourian_metroids_4: %cm_preset("Metroids 4", #preset_gtclassic_tourian_metroids_4) presets_gtclassic_tourian_giant_hoppers: %cm_preset("Giant Hoppers", #preset_gtclassic_tourian_giant_hoppers) presets_gtclassic_tourian_baby_skip: %cm_preset("Baby Skip", #preset_gtclassic_tourian_baby_skip) presets_gtclassic_tourian_gadora_room: %cm_preset("Gadora Room", #preset_gtclassic_tourian_gadora_room) presets_gtclassic_tourian_zeb_skip: %cm_preset("Zeb Skip", #preset_gtclassic_tourian_zeb_skip) presets_gtclassic_tourian_mother_brain_2: %cm_preset("Mother Brain 2", #preset_gtclassic_tourian_mother_brain_2) presets_gtclassic_tourian_zebes_escape: %cm_preset("Zebes Escape", #preset_gtclassic_tourian_zebes_escape) presets_gtclassic_tourian_escape_room_3: %cm_preset("Escape Room 3", #preset_gtclassic_tourian_escape_room_3) presets_gtclassic_tourian_escape_room_4: %cm_preset("Escape Room 4", #preset_gtclassic_tourian_escape_room_4) presets_gtclassic_tourian_escape_climb: %cm_preset("Escape Climb", #preset_gtclassic_tourian_escape_climb) presets_gtclassic_tourian_escape_parlor: %cm_preset("Escape Parlor", #preset_gtclassic_tourian_escape_parlor)
; A036545: a(n) = T(4,n), array T given by A048471. ; 1,17,65,209,641,1937,5825,17489,52481,157457,472385,1417169,4251521,12754577,38263745,114791249,344373761,1033121297,3099363905,9298091729,27894275201,83682825617,251048476865,753145430609,2259436291841,6778308875537,20334926626625,61004779879889,183014339639681,549043018919057,1647129056757185,4941387170271569 mov $1,3 pow $1,$0 mul $1,8 sub $1,7
; ; Old School Computer Architecture - SD Card driver ; Taken from the OSCA Bootcode by Phil Ruston 2011 ; ; Ported by Stefano Bodrato, 2012 ; ; Power off the sdcard slot ; ; $Id: sd_power_off.asm,v 1.1 2012/07/10 05:55:38 stefano Exp $ ; XLIB sd_power_off INCLUDE "osca.def" sd_power_off: push af in a,(sys_sdcard_ctrl2) set sd_power,a ; set power control hi: inactive - no power to SD res sd_cs,a ; ensure /CS is low - no power to this pin ; out (sys_sdcard_ctrl2),a xor a out (sys_sdcard_ctrl1),a pop af ret
;-------------------------------------------------------- ; Category 8 Function 43H Set Device Parameters - not supported for DOS 2.X and DOS 3.X ;-------------------------------------------------------- ; ; ; IODSETPARAM PROC NEAR RET IODSETPARAM ENDP
.include "vc4.qinc" # Uniforms .set srcAddr, ra0 .set tgtAddr, ra1 .set srcStride, rb0 .set tgtStride, rb1 .set lineWidth, ra2 .set lineCount, ra3 mov srcAddr, unif; mov tgtAddr, unif; mov srcStride, unif; mov tgtStride, unif; mov lineWidth, unif; mov lineCount, unif; # Variables .set y, ra4 # Iterator over all lines .set srcPtr, ra5 .set tgtPtr, ra6 .set vpmSetup, rb2 .set vdwSetup, rb3 .set vdwStride, rb4 # Register Constants .set num8, ra7 ldi num8, 8; .set num16, rb5 ldi num16, 16; .set num32, ra8 ldi num32, 32; .set maskCO, rb6 ldi maskCO, 0.5; # TODO: Generate vector mask to allow for any multiple of 8-wide columns (not just 16x8) # Create VPM Setup ldi r0, vpm_setup(0, 1, h32(0)); ldi r1, 4; mul24 r1, qpu_num, r1; add vpmSetup, r0, r1; # Create VPM DMA Basic setup ;shl r1, r1, 7; ldi r0, vdw_setup_0(16, 4, dma_v32(0, 0)); add vdwSetup, r0, r1; # Create VPM DMA Stride setup ldi vdwStride, vdw_setup_1(0); # Calculate base source and target address of each tile column mul24 r0, elem_num, 8; add srcPtr, srcAddr, r0; mov tgtPtr, tgtAddr; # Adjust stride sub srcStride, srcStride, num8; # Remove read bytes ;mov r0, 4; shl tgtStride, tgtStride, r0; # Multiply by 16 (block size) # Line Iterator shr r0, lineCount, 4; # Move in steps of 16 lines max y, r0, 1; # At least one iteration in for loop # Start loading very first line mov r2, srcPtr; mov t0s, r2; add r2, r2, 4; mov t0s, r2; add r2, r2, 4; :y # Loop over lines # Initiate VPM write and make sure last VDW finished read vw_wait; mov vw_setup, vpmSetup; .rep b, 4 # 4 Blocks of 32Bits each # Clear mask accumulator r0, init mask iterator r1 mov r0, 0; mov r1, 1; .rep l, 4 # 4 Lines of 8Bits each # Wait for current load and start next ;ldtmu0 mov t0s, r2; add r2, r2, srcStride; # Read 4 loaded pixels and update mask fmin.setf nop, r4.8cf, maskCO; shl r1, r1, 1; v8adds.ifcs r0, r0, r1; fmin.setf nop, r4.8df, maskCO; shl r1, r1, 1; v8adds.ifcs r0, r0, r1; # Wait for current load and start next ;ldtmu0 mov t0s, r2; add r2, r2, 4; # Read 4 loaded pixels and update mask fmin.setf nop, r4.8af, maskCO; shl r1, r1, 1; v8adds.ifcs r0, r0, r1; fmin.setf nop, r4.8bf, maskCO; shl r1, r1, 1; v8adds.ifcs r0, r0, r1; fmin.setf nop, r4.8cf, maskCO; shl r1, r1, 1; v8adds.ifcs r0, r0, r1; fmin.setf nop, r4.8df, maskCO; shl r1, r1, 1; v8adds.ifcs r0, r0, r1; # Wait for current load and start next ;ldtmu0 mov t0s, r2; add r2, r2, 4; # Read 4 loaded pixels and update mask fmin.setf nop, r4.8af, maskCO; shl r1, r1, 1; v8adds.ifcs r0, r0, r1; fmin.setf nop, r4.8bf, maskCO; shl r1, r1, 1; v8adds.ifcs r0, r0, r1; .endr # Write to VPM mov vpm, r0; .endr # Initiate VDW from VPM to memory mov vw_setup, vdwSetup; mov vw_setup, vdwStride; mov vw_addr, tgtPtr; # Increase adresses to next line add tgtPtr, tgtPtr, tgtStride; # Make sure to finish VDW # read vw_wait; # Line loop :y sub.setf y, y, 1; brr.anynz -, :y nop nop nop # Read last two unused lines (outside of bounds) ldtmu0; ldtmu0; mov.setf irq, nop; nop; thrend nop nop
; A126587: a(n) is the number of integer lattice points inside the right triangle with legs 3n and 4n (and hypotenuse 5n). ; 3,17,43,81,131,193,267,353,451,561,683,817,963,1121,1291,1473,1667,1873,2091,2321,2563,2817,3083,3361,3651,3953,4267,4593,4931,5281,5643,6017,6403,6801,7211,7633,8067,8513,8971,9441,9923,10417,10923,11441,11971,12513,13067,13633,14211,14801,15403,16017,16643,17281,17931,18593,19267,19953,20651,21361,22083,22817,23563,24321,25091,25873,26667,27473,28291,29121,29963,30817,31683,32561,33451,34353,35267,36193,37131,38081,39043,40017,41003,42001,43011,44033,45067,46113,47171,48241,49323,50417,51523,52641,53771,54913,56067,57233,58411,59601 mov $1,6 mul $1,$0 add $1,8 mul $1,$0 add $1,3 mov $0,$1
#include <iostream> #include <vector> #include <numeric> #include "ctc.h" #ifdef WARPCTC_ENABLE_GPU #include "THC.h" #include "THCTensor.h" #include "detail/reduce.h" extern THCState* state; #else #include "TH.h" #endif extern "C" int cpu_ctc(THFloatTensor *probs, THFloatTensor *grads, THIntTensor *labels, THIntTensor *label_sizes, THIntTensor *sizes, int minibatch_size, THFloatTensor *costs, int blank_label) { float *probs_ptr = THFloatTensor_data(probs); float *grads_ptr; if (THFloatTensor_storage(grads)) { grads_ptr = THFloatTensor_data(grads); } else { grads_ptr = NULL; // this will trigger the score forward code path } int *sizes_ptr = THIntTensor_data(sizes); int *labels_ptr = THIntTensor_data(labels); int *label_sizes_ptr = THIntTensor_data(label_sizes); float *costs_ptr = THFloatTensor_data(costs); int probs_size = THFloatTensor_size(probs, 2); ctcOptions options; memset(&options, 0, sizeof(options)); options.loc = CTC_CPU; options.num_threads = 0; // will use default number of threads options.blank_label = blank_label; #if defined(CTC_DISABLE_OMP) || defined(APPLE) // have to use at least one options.num_threads = std::max(options.num_threads, (unsigned int) 1); #endif size_t cpu_size_bytes; get_workspace_size(label_sizes_ptr, sizes_ptr, probs_size, minibatch_size, options, &cpu_size_bytes); float* cpu_workspace = new float[cpu_size_bytes / sizeof(float)]; compute_ctc_loss(probs_ptr, grads_ptr, labels_ptr, label_sizes_ptr, sizes_ptr, probs_size, minibatch_size, costs_ptr, cpu_workspace, options); delete[] cpu_workspace; return 1; } #ifdef WARPCTC_ENABLE_GPU extern "C" int gpu_ctc(THCudaTensor *probs, THCudaTensor *grads, THIntTensor *labels, THIntTensor *label_sizes, THIntTensor *sizes, int minibatch_size, THFloatTensor *costs, int blank_label) { float *probs_ptr = THCudaTensor_data(state, probs); float *grads_ptr; if (THCudaTensor_storage(state, grads)) { grads_ptr = THCudaTensor_data(state, grads); } else { grads_ptr = NULL; // this will trigger the score forward code path } int *sizes_ptr = THIntTensor_data(sizes); int *labels_ptr = THIntTensor_data(labels); int *label_sizes_ptr = THIntTensor_data(label_sizes); float *costs_ptr = THFloatTensor_data(costs); int probs_size = THCudaTensor_size(state, probs, 2); ctcOptions options; memset(&options, 0, sizeof(options)); options.loc = CTC_GPU; options.blank_label = blank_label; options.stream = THCState_getCurrentStream(state); size_t gpu_size_bytes; get_workspace_size(label_sizes_ptr, sizes_ptr, probs_size, minibatch_size, options, &gpu_size_bytes); void* gpu_workspace; THCudaMalloc(state, &gpu_workspace, gpu_size_bytes); compute_ctc_loss(probs_ptr, grads_ptr, labels_ptr, label_sizes_ptr, sizes_ptr, probs_size, minibatch_size, costs_ptr, gpu_workspace, options); THCudaFree(state, (void *) gpu_workspace); return 1; } #endif
/** * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "fl/server/iteration.h" #include <memory> #include <vector> #include <string> #include <numeric> #include <unordered_map> #include "fl/server/model_store.h" #include "fl/server/server.h" namespace mindspore { namespace fl { namespace server { class Server; Iteration::~Iteration() { move_to_next_thread_running_ = false; next_iteration_cv_.notify_all(); if (move_to_next_thread_.joinable()) { move_to_next_thread_.join(); } } void Iteration::RegisterMessageCallback(const std::shared_ptr<ps::core::TcpCommunicator> &communicator) { MS_EXCEPTION_IF_NULL(communicator); communicator_ = communicator; MS_EXCEPTION_IF_NULL(communicator_); communicator_->RegisterMsgCallBack("syncIteration", std::bind(&Iteration::HandleSyncIterationRequest, this, std::placeholders::_1)); communicator_->RegisterMsgCallBack( "notifyLeaderToNextIter", std::bind(&Iteration::HandleNotifyLeaderMoveToNextIterRequest, this, std::placeholders::_1)); communicator_->RegisterMsgCallBack( "prepareForNextIter", std::bind(&Iteration::HandlePrepareForNextIterRequest, this, std::placeholders::_1)); communicator_->RegisterMsgCallBack("proceedToNextIter", std::bind(&Iteration::HandleMoveToNextIterRequest, this, std::placeholders::_1)); communicator_->RegisterMsgCallBack("endLastIter", std::bind(&Iteration::HandleEndLastIterRequest, this, std::placeholders::_1)); } void Iteration::RegisterEventCallback(const std::shared_ptr<ps::core::ServerNode> &server_node) { MS_EXCEPTION_IF_NULL(server_node); server_node_ = server_node; server_node->RegisterCustomEventCallback(static_cast<uint32_t>(ps::UserDefineEvent::kIterationRunning), std::bind(&Iteration::ProcessIterationRunningEvent, this)); server_node->RegisterCustomEventCallback(static_cast<uint32_t>(ps::UserDefineEvent::kIterationCompleted), std::bind(&Iteration::ProcessIterationEndEvent, this)); } void Iteration::AddRound(const std::shared_ptr<Round> &round) { MS_EXCEPTION_IF_NULL(round); rounds_.push_back(round); } void Iteration::InitRounds(const std::vector<std::shared_ptr<ps::core::CommunicatorBase>> &communicators, const TimeOutCb &timeout_cb, const FinishIterCb &finish_iteration_cb) { if (communicators.empty()) { MS_LOG(EXCEPTION) << "Communicators for rounds is empty."; return; } // The time window for one iteration, which will be used in some round kernels. size_t iteration_time_window = 0; for (auto &round : rounds_) { MS_EXCEPTION_IF_NULL(round); round->Initialize(timeout_cb, finish_iteration_cb); for (auto &communicator : communicators) { round->RegisterMsgCallBack(communicator); } if (round->check_timeout()) { iteration_time_window += round->time_window(); } } LocalMetaStore::GetInstance().put_value(kCtxTotalTimeoutDuration, iteration_time_window); MS_LOG(INFO) << "Time window for one iteration is " << iteration_time_window; // Initialize the thread which will handle the signal from round kernels. move_to_next_thread_ = std::thread([this]() { while (move_to_next_thread_running_.load()) { std::unique_lock<std::mutex> lock(next_iteration_mutex_); next_iteration_cv_.wait(lock); if (!move_to_next_thread_running_.load()) { break; } lock.unlock(); MoveToNextIteration(is_last_iteration_valid_, move_to_next_reason_); } }); return; } void Iteration::ClearRounds() { rounds_.clear(); } void Iteration::NotifyNext(bool is_last_iter_valid, const std::string &reason) { std::unique_lock<std::mutex> lock(next_iteration_mutex_); is_last_iteration_valid_ = is_last_iter_valid; move_to_next_reason_ = reason; next_iteration_cv_.notify_one(); } void Iteration::MoveToNextIteration(bool is_last_iter_valid, const std::string &reason) { iteration_num_ = LocalMetaStore::GetInstance().curr_iter_num(); MS_LOG(INFO) << "Notify cluster starts to proceed to next iteration. Iteration is " << iteration_num_ << " validation is " << is_last_iter_valid << ". Reason: " << reason; if (IsMoveToNextIterRequestReentrant(iteration_num_)) { return; } MS_ERROR_IF_NULL_WO_RET_VAL(server_node_); if (server_node_->rank_id() == kLeaderServerRank) { std::unique_lock<std::mutex> lock(iter_move_mtx_); if (!BroadcastPrepareForNextIterRequest(iteration_num_, is_last_iter_valid, reason)) { MS_LOG(ERROR) << "Broadcast prepare for next iteration request failed."; return; } if (!BroadcastMoveToNextIterRequest(is_last_iter_valid, reason)) { MS_LOG(ERROR) << "Broadcast proceed to next iteration request failed."; return; } if (!BroadcastEndLastIterRequest(iteration_num_)) { MS_LOG(ERROR) << "Broadcast end last iteration request failed."; return; } } else { // If this server is the follower server, notify leader server to control the cluster to proceed to next iteration. if (!NotifyLeaderMoveToNextIteration(is_last_iter_valid, reason)) { MS_LOG(ERROR) << "Server " << server_node_->rank_id() << " notifying the leader server failed."; return; } } } void Iteration::SetIterationRunning() { MS_LOG(INFO) << "Iteration " << iteration_num_ << " start running."; MS_ERROR_IF_NULL_WO_RET_VAL(server_node_); if (server_node_->rank_id() == kLeaderServerRank) { // This event helps worker/server to be consistent in iteration state. server_node_->BroadcastEvent(static_cast<uint32_t>(ps::UserDefineEvent::kIterationRunning)); if (server_recovery_ != nullptr) { // Save data to the persistent storage in case the recovery happens at the beginning. if (!server_recovery_->Save(iteration_num_, instance_state_)) { MS_LOG(WARNING) << "Save recovery data failed."; } } } std::unique_lock<std::mutex> lock(iteration_state_mtx_); iteration_state_ = IterationState::kRunning; start_timestamp_ = LongToUlong(CURRENT_TIME_MILLI.count()); MS_LOG(INFO) << "Iteratoin " << iteration_num_ << " start global timer."; global_iter_timer_->Start(std::chrono::milliseconds(global_iteration_time_window_)); } void Iteration::SetIterationEnd() { MS_LOG(INFO) << "Iteration " << iteration_num_ << " ends."; MS_ERROR_IF_NULL_WO_RET_VAL(server_node_); if (server_node_->rank_id() == kLeaderServerRank) { // This event helps worker/server to be consistent in iteration state. server_node_->BroadcastEvent(static_cast<uint32_t>(ps::UserDefineEvent::kIterationCompleted)); } std::unique_lock<std::mutex> lock(iteration_state_mtx_); iteration_state_ = IterationState::kCompleted; complete_timestamp_ = LongToUlong(CURRENT_TIME_MILLI.count()); } void Iteration::ScalingBarrier() { MS_LOG(INFO) << "Starting Iteration scaling barrier."; std::unique_lock<std::mutex> lock(iteration_state_mtx_); if (iteration_state_.load() != IterationState::kCompleted) { iteration_state_cv_.wait(lock); } MS_LOG(INFO) << "Ending Iteration scaling barrier."; } bool Iteration::ReInitForScaling(uint32_t server_num, uint32_t server_rank) { for (auto &round : rounds_) { if (!round->ReInitForScaling(server_num)) { MS_LOG(WARNING) << "Reinitializing round " << round->name() << " for scaling failed."; return false; } } if (server_rank != kLeaderServerRank) { if (!SyncIteration(server_rank)) { MS_LOG(ERROR) << "Synchronizing iteration failed."; return false; } } return true; } bool Iteration::ReInitForUpdatingHyperParams(const std::vector<RoundConfig> &updated_rounds_config) { for (const auto &updated_round : updated_rounds_config) { for (const auto &round : rounds_) { if (updated_round.name == round->name()) { MS_LOG(INFO) << "Reinitialize for round " << round->name(); if (!round->ReInitForUpdatingHyperParams(updated_round.threshold_count, updated_round.time_window, server_node_->server_num())) { MS_LOG(ERROR) << "Reinitializing for round " << round->name() << " failed."; return false; } } } } return true; } const std::vector<std::shared_ptr<Round>> &Iteration::rounds() const { return rounds_; } bool Iteration::is_last_iteration_valid() const { return is_last_iteration_valid_; } void Iteration::set_metrics(const std::shared_ptr<IterationMetrics> &metrics) { metrics_ = metrics; } void Iteration::set_loss(float loss) { loss_ = loss; } void Iteration::set_accuracy(float accuracy) { accuracy_ = accuracy; } InstanceState Iteration::instance_state() const { return instance_state_.load(); } bool Iteration::EnableServerInstance(std::string *result) { MS_ERROR_IF_NULL_W_RET_VAL(result, false); // Before enabling server instance, we should judge whether this request should be handled. std::unique_lock<std::mutex> lock(instance_mtx_); if (is_instance_being_updated_) { *result = "The instance is being updated. Please retry enabling server later."; MS_LOG(WARNING) << *result; return false; } if (instance_state_.load() == InstanceState::kFinish) { *result = "The instance is completed. Please do not enabling server now."; MS_LOG(WARNING) << *result; return false; } // Start enabling server instance. is_instance_being_updated_ = true; instance_state_ = InstanceState::kRunning; *result = "Enabling FL-Server succeeded."; MS_LOG(INFO) << *result; // End enabling server instance. is_instance_being_updated_ = false; return true; } bool Iteration::DisableServerInstance(std::string *result) { MS_ERROR_IF_NULL_W_RET_VAL(result, false); // Before disabling server instance, we should judge whether this request should be handled. std::unique_lock<std::mutex> lock(instance_mtx_); if (is_instance_being_updated_) { *result = "The instance is being updated. Please retry disabling server later."; MS_LOG(WARNING) << *result; return false; } if (instance_state_.load() == InstanceState::kFinish) { *result = "The instance is completed. Please do not disabling server now."; MS_LOG(WARNING) << *result; return false; } if (instance_state_.load() == InstanceState::kDisable) { *result = "Disabling FL-Server succeeded."; MS_LOG(INFO) << *result; return true; } // Start disabling server instance. is_instance_being_updated_ = true; // If instance is running, we should drop current iteration and move to the next. instance_state_ = InstanceState::kDisable; if (!ForciblyMoveToNextIteration()) { *result = "Disabling instance failed. Can't drop current iteration and move to the next."; MS_LOG(ERROR) << result; return false; } *result = "Disabling FL-Server succeeded."; MS_LOG(INFO) << *result; // End disabling server instance. is_instance_being_updated_ = false; return true; } void Iteration::StartNewInstance() { iteration_num_ = 1; LocalMetaStore::GetInstance().set_curr_iter_num(iteration_num_); is_instance_being_updated_ = false; ModelStore::GetInstance().Reset(); // Update the hyper-parameters on server and reinitialize rounds. UpdateHyperParams(new_instance_json_); if (!ReInitRounds()) { MS_LOG(ERROR) << "Reinitializing rounds failed."; } instance_state_ = InstanceState::kRunning; MS_LOG(INFO) << "Process iteration new instance successful."; } bool Iteration::NewInstance(const nlohmann::json &new_instance_json, std::string *result) { MS_ERROR_IF_NULL_W_RET_VAL(result, false); // Before new instance, we should judge whether this request should be handled. std::unique_lock<std::mutex> lock(instance_mtx_); if (is_instance_being_updated_) { *result = "The instance is being updated. Please retry new instance later."; MS_LOG(WARNING) << *result; return false; } if (iteration_num_ == 1) { *result = "This is just the first iteration, do not need to new instance."; MS_LOG(WARNING) << *result; return false; } // Start new server instance. is_instance_being_updated_ = true; new_instance_json_ = new_instance_json; *result = "New FL-Server instance succeeded."; if (instance_state_.load() == InstanceState::kFinish || instance_state_.load() == InstanceState::kDisable) { StartNewInstance(); } else { MS_LOG(INFO) << "Process new instance success, cluster will start new job after this iteration end."; } return true; } void Iteration::WaitAllRoundsFinish() const { while (running_round_num_.load() != 0) { std::this_thread::sleep_for(std::chrono::milliseconds(kThreadSleepTime)); } } void Iteration::set_recovery_handler(const std::shared_ptr<ServerRecovery> &server_recovery) { MS_EXCEPTION_IF_NULL(server_recovery); server_recovery_ = server_recovery; } bool Iteration::SyncAfterRecovery(uint64_t) { NotifyNext(false, "Move to next iteration after recovery."); return true; } bool Iteration::SyncIteration(uint32_t rank) { MS_ERROR_IF_NULL_W_RET_VAL(communicator_, false); SyncIterationRequest sync_iter_req; sync_iter_req.set_rank(rank); std::shared_ptr<std::vector<unsigned char>> sync_iter_rsp_msg = nullptr; if (!communicator_->SendPbRequest(sync_iter_req, kLeaderServerRank, ps::core::TcpUserCommand::kSyncIteration, &sync_iter_rsp_msg)) { MS_LOG(ERROR) << "Sending sync iter message to leader server failed."; return false; } MS_ERROR_IF_NULL_W_RET_VAL(sync_iter_rsp_msg, false); SyncIterationResponse sync_iter_rsp; (void)sync_iter_rsp.ParseFromArray(sync_iter_rsp_msg->data(), SizeToInt(sync_iter_rsp_msg->size())); iteration_num_ = sync_iter_rsp.iteration(); MS_LOG(INFO) << "After synchronizing, server " << rank << " current iteration number is " << iteration_num_; return true; } void Iteration::HandleSyncIterationRequest(const std::shared_ptr<ps::core::MessageHandler> &message) { MS_ERROR_IF_NULL_WO_RET_VAL(message); MS_ERROR_IF_NULL_WO_RET_VAL(communicator_); SyncIterationRequest sync_iter_req; (void)sync_iter_req.ParseFromArray(message->data(), SizeToInt(message->len())); uint32_t rank = sync_iter_req.rank(); MS_LOG(INFO) << "Synchronizing iteration request from rank " << rank; SyncIterationResponse sync_iter_rsp; sync_iter_rsp.set_iteration(iteration_num_); std::string sync_iter_rsp_msg = sync_iter_rsp.SerializeAsString(); if (!communicator_->SendResponse(sync_iter_rsp_msg.data(), sync_iter_rsp_msg.size(), message)) { MS_LOG(ERROR) << "Sending response failed."; return; } } bool Iteration::IsMoveToNextIterRequestReentrant(uint64_t iteration_num) { std::unique_lock<std::mutex> lock(pinned_mtx_); if (pinned_iter_num_ == iteration_num) { MS_LOG(DEBUG) << "MoveToNextIteration is not reentrant. Ignore this call."; return true; } pinned_iter_num_ = iteration_num; return false; } bool Iteration::NotifyLeaderMoveToNextIteration(bool is_last_iter_valid, const std::string &reason) { MS_ERROR_IF_NULL_W_RET_VAL(communicator_, false); MS_LOG(INFO) << "Notify leader server to control the cluster to proceed to next iteration."; NotifyLeaderMoveToNextIterRequest notify_leader_to_next_iter_req; notify_leader_to_next_iter_req.set_rank(server_node_->rank_id()); notify_leader_to_next_iter_req.set_is_last_iter_valid(is_last_iter_valid); notify_leader_to_next_iter_req.set_iter_num(iteration_num_); notify_leader_to_next_iter_req.set_reason(reason); while (communicator_->running() && !communicator_->SendPbRequest(notify_leader_to_next_iter_req, kLeaderServerRank, ps::core::TcpUserCommand::kNotifyLeaderToNextIter)) { MS_LOG(WARNING) << "Sending notify leader server to proceed next iteration request to leader server 0 failed."; std::this_thread::sleep_for(std::chrono::milliseconds(kRetryDurationForPrepareForNextIter)); } MS_LOG(INFO) << "Notify leader server to control the cluster to proceed to next iteration success"; return true; } void Iteration::HandleNotifyLeaderMoveToNextIterRequest(const std::shared_ptr<ps::core::MessageHandler> &message) { MS_ERROR_IF_NULL_WO_RET_VAL(message); MS_ERROR_IF_NULL_WO_RET_VAL(communicator_); NotifyLeaderMoveToNextIterResponse notify_leader_to_next_iter_rsp; notify_leader_to_next_iter_rsp.set_result("success"); if (!communicator_->SendResponse(notify_leader_to_next_iter_rsp.SerializeAsString().data(), notify_leader_to_next_iter_rsp.SerializeAsString().size(), message)) { MS_LOG(WARNING) << "Sending response failed."; return; } NotifyLeaderMoveToNextIterRequest notify_leader_to_next_iter_req; (void)notify_leader_to_next_iter_req.ParseFromArray(message->data(), SizeToInt(message->len())); const auto &rank = notify_leader_to_next_iter_req.rank(); const auto &is_last_iter_valid = notify_leader_to_next_iter_req.is_last_iter_valid(); const auto &iter_num = notify_leader_to_next_iter_req.iter_num(); const auto &reason = notify_leader_to_next_iter_req.reason(); MS_LOG(INFO) << "Leader server receives NotifyLeaderMoveToNextIterRequest from rank " << rank << ". Iteration number: " << iter_num << ". Reason: " << reason; if (IsMoveToNextIterRequestReentrant(iter_num)) { return; } std::unique_lock<std::mutex> lock(iter_move_mtx_); if (!BroadcastPrepareForNextIterRequest(iter_num, is_last_iter_valid, reason)) { MS_LOG(ERROR) << "Broadcast prepare for next iteration request failed."; return; } if (!BroadcastMoveToNextIterRequest(is_last_iter_valid, reason)) { MS_LOG(ERROR) << "Broadcast proceed to next iteration request failed."; return; } if (!BroadcastEndLastIterRequest(iteration_num_)) { MS_LOG(ERROR) << "Broadcast end last iteration request failed."; return; } } bool Iteration::BroadcastPrepareForNextIterRequest(size_t last_iteration, bool is_last_iter_valid, const std::string &reason) { MS_ERROR_IF_NULL_W_RET_VAL(communicator_, false); PrepareForNextIter(last_iteration, is_last_iter_valid); MS_LOG(INFO) << "Notify all follower servers to prepare for next iteration."; PrepareForNextIterRequest prepare_next_iter_req; prepare_next_iter_req.set_is_last_iter_valid(is_last_iter_valid); prepare_next_iter_req.set_reason(reason); prepare_next_iter_req.set_last_iteration(last_iteration); std::vector<uint32_t> offline_servers = {}; for (uint32_t i = 1; i < server_node_->server_num(); i++) { if (!communicator_->SendPbRequest(prepare_next_iter_req, i, ps::core::TcpUserCommand::kPrepareForNextIter)) { MS_LOG(WARNING) << "Sending prepare for next iteration request to server " << i << " failed. Retry later."; offline_servers.push_back(i); continue; } } // Retry sending to offline servers to notify them to prepare. (void)std::for_each(offline_servers.begin(), offline_servers.end(), [&](uint32_t rank) { // Should avoid endless loop if the server communicator is stopped. while (communicator_->running() && !communicator_->SendPbRequest(prepare_next_iter_req, rank, ps::core::TcpUserCommand::kPrepareForNextIter)) { MS_LOG(WARNING) << "Retry sending prepare for next iteration request to server " << rank << " failed. The server has not recovered yet."; std::this_thread::sleep_for(std::chrono::milliseconds(kRetryDurationForPrepareForNextIter)); } MS_LOG(INFO) << "Offline server " << rank << " preparing for next iteration success."; }); std::this_thread::sleep_for(std::chrono::milliseconds(kServerSleepTimeForNetworking)); return true; } void Iteration::HandlePrepareForNextIterRequest(const std::shared_ptr<ps::core::MessageHandler> &message) { MS_ERROR_IF_NULL_WO_RET_VAL(message); MS_ERROR_IF_NULL_WO_RET_VAL(communicator_); PrepareForNextIterRequest prepare_next_iter_req; (void)prepare_next_iter_req.ParseFromArray(message->data(), SizeToInt(message->len())); const auto &reason = prepare_next_iter_req.reason(); auto is_last_iter_valid = prepare_next_iter_req.is_last_iter_valid(); auto last_iteration = prepare_next_iter_req.last_iteration(); MS_LOG(INFO) << "Prepare next iteration for this rank " << server_node_->rank_id() << ", last iteration: " << last_iteration << ", last iteration valid: " << is_last_iter_valid << ", reason: " << reason; PrepareForNextIter(last_iteration, is_last_iter_valid); PrepareForNextIterResponse prepare_next_iter_rsp; prepare_next_iter_rsp.set_result("success"); if (!communicator_->SendResponse(prepare_next_iter_rsp.SerializeAsString().data(), prepare_next_iter_rsp.SerializeAsString().size(), message)) { MS_LOG(ERROR) << "Sending response failed."; return; } } void Iteration::PrepareForNextIter(size_t last_iteration, bool is_last_iter_valid) { MS_LOG(INFO) << "Prepare for next iteration. Switch the server to safemode."; Server::GetInstance().SwitchToSafeMode(); if (server_node_) { server_node_->SetIterationResult(last_iteration, is_last_iter_valid); } MS_LOG(INFO) << "Start waiting for rounds to finish."; WaitAllRoundsFinish(); MS_LOG(INFO) << "End waiting for rounds to finish."; } bool Iteration::BroadcastMoveToNextIterRequest(bool is_last_iter_valid, const std::string &reason) { MS_ERROR_IF_NULL_W_RET_VAL(communicator_, false); MS_LOG(INFO) << "Notify all follower servers to proceed to next iteration. Set last iteration number " << iteration_num_; MoveToNextIterRequest proceed_to_next_iter_req; proceed_to_next_iter_req.set_is_last_iter_valid(is_last_iter_valid); proceed_to_next_iter_req.set_last_iter_num(iteration_num_); proceed_to_next_iter_req.set_reason(reason); for (uint32_t i = 1; i < server_node_->server_num(); i++) { if (!communicator_->SendPbRequest(proceed_to_next_iter_req, i, ps::core::TcpUserCommand::kProceedToNextIter)) { MS_LOG(WARNING) << "Sending proceed to next iteration request to server " << i << " failed."; continue; } } Next(is_last_iter_valid, reason); return true; } void Iteration::HandleMoveToNextIterRequest(const std::shared_ptr<ps::core::MessageHandler> &message) { MS_ERROR_IF_NULL_WO_RET_VAL(message); MS_ERROR_IF_NULL_WO_RET_VAL(communicator_); MoveToNextIterRequest proceed_to_next_iter_req; (void)proceed_to_next_iter_req.ParseFromArray(message->data(), SizeToInt(message->len())); const auto &is_last_iter_valid = proceed_to_next_iter_req.is_last_iter_valid(); const auto &last_iter_num = proceed_to_next_iter_req.last_iter_num(); const auto &reason = proceed_to_next_iter_req.reason(); MS_LOG(INFO) << "Receive proceeding to next iteration request. This server current iteration is " << iteration_num_ << ". The iteration number from leader server is " << last_iter_num << ". Last iteration is valid or not: " << is_last_iter_valid << ". Reason: " << reason; // Synchronize the iteration number with leader server. iteration_num_ = last_iter_num; Next(is_last_iter_valid, reason); MoveToNextIterResponse proceed_to_next_iter_rsp; proceed_to_next_iter_rsp.set_result("success"); if (!communicator_->SendResponse(proceed_to_next_iter_rsp.SerializeAsString().data(), proceed_to_next_iter_rsp.SerializeAsString().size(), message)) { MS_LOG(ERROR) << "Sending response failed."; return; } } void Iteration::Next(bool is_iteration_valid, const std::string &reason) { MS_LOG(INFO) << "Prepare for next iteration."; is_last_iteration_valid_ = is_iteration_valid; if (is_iteration_valid) { // Store the model which is successfully aggregated for this iteration. const auto &model = Executor::GetInstance().GetModel(); std::unordered_map<std::string, size_t> feature_map; for (auto weight : model) { std::string weight_fullname = weight.first; if (weight.second == nullptr) { continue; } size_t weight_size = weight.second->size; feature_map[weight_fullname] = weight_size; } if (LocalMetaStore::GetInstance().verifyAggregationFeatureMap(feature_map)) { ModelStore::GetInstance().StoreModelByIterNum(iteration_num_, model); ModelStore::GetInstance().StoreCompressModelByIterNum(iteration_num_, model); iteration_result_ = IterationResult::kSuccess; MS_LOG(INFO) << "Iteration " << iteration_num_ << " is successfully finished."; } else { MS_LOG(WARNING) << "Verify feature maps failed, iteration " << iteration_num_ << " will not be stored."; } } else { // Store last iteration's model because this iteration is considered as invalid. const auto &iter_to_model = ModelStore::GetInstance().iteration_to_model(); size_t latest_iter_num = iter_to_model.rbegin()->first; const auto &model = ModelStore::GetInstance().GetModelByIterNum(latest_iter_num); ModelStore::GetInstance().StoreModelByIterNum(iteration_num_, model); ModelStore::GetInstance().StoreCompressModelByIterNum(iteration_num_, model); iteration_result_ = IterationResult::kFail; MS_LOG(WARNING) << "Iteration " << iteration_num_ << " is invalid. Reason: " << reason; } for (auto &round : rounds_) { MS_ERROR_IF_NULL_WO_RET_VAL(round); round->Reset(); } MS_LOG(INFO) << "Iteratoin " << iteration_num_ << " stop global timer."; global_iter_timer_->Stop(); for (const auto &round : rounds_) { MS_ERROR_IF_NULL_WO_RET_VAL(round); round->KernelSummarize(); } for (const auto &round : rounds_) { if (round->name() == "startFLJob") { round_client_num_map_[kStartFLJobTotalClientNum] += round->kernel_total_client_num(); round_client_num_map_[kStartFLJobAcceptClientNum] += round->kernel_accept_client_num(); round_client_num_map_[kStartFLJobRejectClientNum] += round->kernel_reject_client_num(); } else if (round->name() == "updateModel") { round_client_num_map_[kUpdateModelTotalClientNum] += round->kernel_total_client_num(); round_client_num_map_[kUpdateModelAcceptClientNum] += round->kernel_accept_client_num(); round_client_num_map_[kUpdateModelRejectClientNum] += round->kernel_reject_client_num(); set_loss(loss_ + round->kernel_upload_loss()); } else if (round->name() == "getModel") { round_client_num_map_[kGetModelTotalClientNum] += round->kernel_total_client_num(); round_client_num_map_[kGetModelAcceptClientNum] += round->kernel_accept_client_num(); round_client_num_map_[kGetModelRejectClientNum] += round->kernel_reject_client_num(); } } } bool Iteration::BroadcastEndLastIterRequest(uint64_t last_iter_num) { MS_ERROR_IF_NULL_W_RET_VAL(communicator_, false); MS_LOG(INFO) << "Notify all follower servers to end last iteration."; EndLastIterRequest end_last_iter_req; end_last_iter_req.set_last_iter_num(last_iter_num); for (uint32_t i = 1; i < server_node_->server_num(); i++) { std::shared_ptr<std::vector<unsigned char>> client_info_rsp_msg = nullptr; if (!communicator_->SendPbRequest(end_last_iter_req, i, ps::core::TcpUserCommand::kEndLastIter, &client_info_rsp_msg)) { MS_LOG(WARNING) << "Sending ending last iteration request to server " << i << " failed."; continue; } UpdateRoundClientNumMap(client_info_rsp_msg); UpdateRoundClientUploadLoss(client_info_rsp_msg); } EndLastIter(); return true; } void Iteration::HandleEndLastIterRequest(const std::shared_ptr<ps::core::MessageHandler> &message) { MS_ERROR_IF_NULL_WO_RET_VAL(message); MS_ERROR_IF_NULL_WO_RET_VAL(communicator_); EndLastIterRequest end_last_iter_req; (void)end_last_iter_req.ParseFromArray(message->data(), SizeToInt(message->len())); const auto &last_iter_num = end_last_iter_req.last_iter_num(); // If the iteration number is not matched, return error. if (last_iter_num != iteration_num_) { std::string reason = "The iteration of this server " + std::to_string(server_node_->rank_id()) + " is " + std::to_string(iteration_num_) + ", iteration to be ended is " + std::to_string(last_iter_num); EndLastIterResponse end_last_iter_rsp; end_last_iter_rsp.set_result(reason); if (!communicator_->SendResponse(end_last_iter_rsp.SerializeAsString().data(), end_last_iter_rsp.SerializeAsString().size(), message)) { MS_LOG(ERROR) << "Sending response failed."; return; } return; } EndLastIterResponse end_last_iter_rsp; end_last_iter_rsp.set_result("success"); for (const auto &round : rounds_) { if (round == nullptr) { continue; } if (round->name() == "startFLJob") { end_last_iter_rsp.set_startfljob_total_client_num(round->kernel_total_client_num()); end_last_iter_rsp.set_startfljob_accept_client_num(round->kernel_accept_client_num()); end_last_iter_rsp.set_startfljob_reject_client_num(round->kernel_reject_client_num()); } else if (round->name() == "updateModel") { end_last_iter_rsp.set_updatemodel_total_client_num(round->kernel_total_client_num()); end_last_iter_rsp.set_updatemodel_accept_client_num(round->kernel_accept_client_num()); end_last_iter_rsp.set_updatemodel_reject_client_num(round->kernel_reject_client_num()); end_last_iter_rsp.set_upload_loss(round->kernel_upload_loss()); } else if (round->name() == "getModel") { end_last_iter_rsp.set_getmodel_total_client_num(round->kernel_total_client_num()); end_last_iter_rsp.set_getmodel_accept_client_num(round->kernel_accept_client_num()); end_last_iter_rsp.set_getmodel_reject_client_num(round->kernel_reject_client_num()); } } EndLastIter(); if (!communicator_->SendResponse(end_last_iter_rsp.SerializeAsString().data(), end_last_iter_rsp.SerializeAsString().size(), message)) { MS_LOG(ERROR) << "Sending response failed."; return; } } void Iteration::EndLastIter() { MS_LOG(INFO) << "End the last iteration " << iteration_num_; if (iteration_num_ == ps::PSContext::instance()->fl_iteration_num()) { MS_LOG(INFO) << "Iteration loop " << iteration_loop_count_ << " is completed. Iteration number: " << ps::PSContext::instance()->fl_iteration_num(); iteration_loop_count_++; instance_state_ = InstanceState::kFinish; } SetIterationEnd(); if (!SummarizeIteration()) { MS_LOG(WARNING) << "Summarizing iteration data failed."; } if (is_instance_being_updated_) { StartNewInstance(); } else { iteration_num_++; } LocalMetaStore::GetInstance().set_curr_iter_num(iteration_num_); MS_ERROR_IF_NULL_WO_RET_VAL(server_node_); if (server_node_->rank_id() == kLeaderServerRank) { // Save current iteration number for recovery. MS_ERROR_IF_NULL_WO_RET_VAL(server_recovery_); if (!server_recovery_->Save(iteration_num_, instance_state_)) { MS_LOG(WARNING) << "Can't save current iteration number into persistent storage."; } } for (const auto &round : rounds_) { MS_ERROR_IF_NULL_WO_RET_VAL(round); round->InitkernelClientVisitedNum(); round->InitkernelClientUploadLoss(); } round_client_num_map_.clear(); set_loss(0.0f); Server::GetInstance().CancelSafeMode(); iteration_state_cv_.notify_all(); if (iteration_num_ > ps::PSContext::instance()->fl_iteration_num()) { MS_LOG(WARNING) << "The server's training job is finished."; } else { MS_LOG(INFO) << "Move to next iteration:" << iteration_num_ << "\n"; } } bool Iteration::ForciblyMoveToNextIteration() { NotifyNext(false, "Forcibly move to next iteration."); return true; } bool Iteration::SummarizeIteration() { // If the metrics_ is not initialized or the server is not the leader server, do not summarize. if (server_node_->rank_id() != kLeaderServerRank || metrics_ == nullptr) { MS_LOG(INFO) << "This server will not summarize for iteration."; return true; } metrics_->set_fl_name(ps::PSContext::instance()->fl_name()); metrics_->set_fl_iteration_num(ps::PSContext::instance()->fl_iteration_num()); metrics_->set_cur_iteration_num(iteration_num_); metrics_->set_instance_state(instance_state_.load()); uint64_t update_model_threshold = ps::PSContext::instance()->start_fl_job_threshold() * ps::PSContext::instance()->update_model_ratio(); if (update_model_threshold > 0) { metrics_->set_loss(loss_ / update_model_threshold); } metrics_->set_accuracy(accuracy_); metrics_->set_round_client_num_map(round_client_num_map_); metrics_->set_iteration_result(iteration_result_.load()); if (complete_timestamp_ < start_timestamp_) { MS_LOG(ERROR) << "The complete_timestamp_: " << complete_timestamp_ << ", start_timestamp_: " << start_timestamp_ << ". One of them is invalid."; metrics_->set_iteration_time_cost(UINT64_MAX); } else { metrics_->set_iteration_time_cost(complete_timestamp_ - start_timestamp_); } if (!metrics_->Summarize()) { MS_LOG(ERROR) << "Summarizing metrics failed."; return false; } return true; } bool Iteration::UpdateHyperParams(const nlohmann::json &json) { for (const auto &item : json.items()) { std::string key = item.key(); if (key == "start_fl_job_threshold") { ps::PSContext::instance()->set_start_fl_job_threshold(item.value().get<uint64_t>()); continue; } if (key == "start_fl_job_time_window") { ps::PSContext::instance()->set_start_fl_job_time_window(item.value().get<uint64_t>()); continue; } if (key == "update_model_ratio") { ps::PSContext::instance()->set_update_model_ratio(item.value().get<float>()); continue; } if (key == "update_model_time_window") { ps::PSContext::instance()->set_update_model_time_window(item.value().get<uint64_t>()); continue; } if (key == "fl_iteration_num") { ps::PSContext::instance()->set_fl_iteration_num(item.value().get<uint64_t>()); continue; } if (key == "client_epoch_num") { ps::PSContext::instance()->set_client_epoch_num(item.value().get<uint64_t>()); continue; } if (key == "client_batch_size") { ps::PSContext::instance()->set_client_batch_size(item.value().get<uint64_t>()); continue; } if (key == "client_learning_rate") { ps::PSContext::instance()->set_client_learning_rate(item.value().get<float>()); continue; } if (key == "global_iteration_time_window") { ps::PSContext::instance()->set_global_iteration_time_window(item.value().get<uint64_t>()); continue; } } MS_LOG(INFO) << "start_fl_job_threshold: " << ps::PSContext::instance()->start_fl_job_threshold(); MS_LOG(INFO) << "start_fl_job_time_window: " << ps::PSContext::instance()->start_fl_job_time_window(); MS_LOG(INFO) << "update_model_ratio: " << ps::PSContext::instance()->update_model_ratio(); MS_LOG(INFO) << "update_model_time_window: " << ps::PSContext::instance()->update_model_time_window(); MS_LOG(INFO) << "fl_iteration_num: " << ps::PSContext::instance()->fl_iteration_num(); MS_LOG(INFO) << "client_epoch_num: " << ps::PSContext::instance()->client_epoch_num(); MS_LOG(INFO) << "client_batch_size: " << ps::PSContext::instance()->client_batch_size(); MS_LOG(INFO) << "client_learning_rate: " << ps::PSContext::instance()->client_learning_rate(); MS_LOG(INFO) << "global_iteration_time_window: " << ps::PSContext::instance()->global_iteration_time_window(); return true; } bool Iteration::ReInitRounds() { size_t start_fl_job_threshold = ps::PSContext::instance()->start_fl_job_threshold(); float update_model_ratio = ps::PSContext::instance()->update_model_ratio(); size_t update_model_threshold = static_cast<size_t>(std::ceil(start_fl_job_threshold * update_model_ratio)); uint64_t start_fl_job_time_window = ps::PSContext::instance()->start_fl_job_time_window(); uint64_t update_model_time_window = ps::PSContext::instance()->update_model_time_window(); std::vector<RoundConfig> new_round_config = { {"startFLJob", true, start_fl_job_time_window, true, start_fl_job_threshold}, {"updateModel", true, update_model_time_window, true, update_model_threshold}}; if (!ReInitForUpdatingHyperParams(new_round_config)) { MS_LOG(ERROR) << "Reinitializing for updating hyper-parameters failed."; return false; } size_t executor_threshold = 0; const std::string &server_mode = ps::PSContext::instance()->server_mode(); uint32_t worker_num = ps::PSContext::instance()->initial_worker_num(); if (server_mode == ps::kServerModeFL || server_mode == ps::kServerModeHybrid) { executor_threshold = update_model_threshold; } else if (server_mode == ps::kServerModePS) { executor_threshold = worker_num; } else { MS_LOG(ERROR) << "Server mode " << server_mode << " is not supported."; return false; } if (!Executor::GetInstance().ReInitForUpdatingHyperParams(executor_threshold)) { MS_LOG(ERROR) << "Reinitializing executor failed."; return false; } return true; } void Iteration::InitGlobalIterTimer(const TimeOutCb &timeout_cb) { global_iteration_time_window_ = ps::PSContext::instance()->global_iteration_time_window(); global_iter_timer_ = std::make_shared<IterationTimer>(); MS_LOG(INFO) << "Global iteration time window is: " << global_iteration_time_window_; // Set the timeout callback for the timer. global_iter_timer_->SetTimeOutCallBack([this, timeout_cb](bool, const std::string &) -> void { std::string reason = "Global Iteration " + std::to_string(iteration_num_) + " timeout! This iteration is invalid. Proceed to next iteration."; timeout_cb(false, reason); }); } void Iteration::UpdateRoundClientNumMap(const std::shared_ptr<std::vector<unsigned char>> &client_info_rsp_msg) { MS_ERROR_IF_NULL_WO_RET_VAL(client_info_rsp_msg); EndLastIterResponse end_last_iter_rsp; (void)end_last_iter_rsp.ParseFromArray(client_info_rsp_msg->data(), SizeToInt(client_info_rsp_msg->size())); round_client_num_map_[kStartFLJobTotalClientNum] += end_last_iter_rsp.startfljob_total_client_num(); round_client_num_map_[kStartFLJobAcceptClientNum] += end_last_iter_rsp.startfljob_accept_client_num(); round_client_num_map_[kStartFLJobRejectClientNum] += end_last_iter_rsp.startfljob_reject_client_num(); round_client_num_map_[kUpdateModelTotalClientNum] += end_last_iter_rsp.updatemodel_total_client_num(); round_client_num_map_[kUpdateModelAcceptClientNum] += end_last_iter_rsp.updatemodel_accept_client_num(); round_client_num_map_[kUpdateModelRejectClientNum] += end_last_iter_rsp.updatemodel_reject_client_num(); round_client_num_map_[kGetModelTotalClientNum] += end_last_iter_rsp.getmodel_total_client_num(); round_client_num_map_[kGetModelAcceptClientNum] += end_last_iter_rsp.getmodel_accept_client_num(); round_client_num_map_[kGetModelRejectClientNum] += end_last_iter_rsp.getmodel_reject_client_num(); } void Iteration::UpdateRoundClientUploadLoss(const std::shared_ptr<std::vector<unsigned char>> &client_info_rsp_msg) { MS_ERROR_IF_NULL_WO_RET_VAL(client_info_rsp_msg); EndLastIterResponse end_last_iter_rsp; (void)end_last_iter_rsp.ParseFromArray(client_info_rsp_msg->data(), SizeToInt(client_info_rsp_msg->size())); set_loss(loss_ + end_last_iter_rsp.upload_loss()); } void Iteration::set_instance_state(InstanceState state) { instance_state_ = state; MS_LOG(INFO) << "Server instance state is " << GetInstanceStateStr(instance_state_); } } // namespace server } // namespace fl } // namespace mindspore
; A124158: Maximal number of edges in a rectangle visibility graph with n nodes. ; 0,1,3,6,10,15,21,28,34,40,46,52,58,64,70,76,82,88,94,100,106,112,118,124,130,136,142,148,154,160,166,172,178,184,190,196,202,208,214,220,226,232,238,244,250,256,262,268,274,280,286,292,298,304,310,316,322,328,334,340 mov $2,$0 lpb $2 trn $0,7 add $1,$2 sub $1,$0 mov $0,$2 sub $2,1 lpe
; A144647: Second differences of A001515 (or A144301). ; Submitted by Jamie Morken(w2) ; 1,4,25,199,1936,22411,301939,4649800,80654599,1556992441,33120019516,769887934729,19419368959225,528311452144204,15421347559288441,480784227676809991,15945180393017896024,560549114426134288675 mov $1,1 mov $2,1 mov $3,$0 lpb $3 add $0,1 mul $1,$3 mul $1,$0 add $2,$1 sub $3,1 add $4,2 div $1,$4 add $2,$1 lpe mov $0,$2
/* Copyright (c) 2018 vesoft inc. All rights reserved. * * This source code is licensed under Apache 2.0 License, * attached with Common Clause Condition 1.0, found in the LICENSES directory. */ #include "base/Base.h" #include "kvstore/RocksEngine.h" #include <folly/String.h> #include "fs/FileUtils.h" #include "kvstore/KVStore.h" #include "kvstore/RocksEngineConfig.h" namespace nebula { namespace kvstore { using fs::FileUtils; using fs::FileType; const char* kSystemParts = "__system__parts__"; RocksEngine::RocksEngine(GraphSpaceID spaceId, const std::string& dataPath, std::shared_ptr<rocksdb::MergeOperator> mergeOp, std::shared_ptr<rocksdb::CompactionFilterFactory> cfFactory) : KVEngine(spaceId) , dataPath_(dataPath) { LOG(INFO) << "open rocksdb on " << dataPath; if (FileUtils::fileType(dataPath.c_str()) == FileType::NOTEXIST) { FileUtils::makeDir(dataPath); } rocksdb::Options options; rocksdb::DB* db = nullptr; rocksdb::Status status = initRocksdbOptions(options); CHECK(status.ok()); if (mergeOp != nullptr) { options.merge_operator = mergeOp; } if (cfFactory != nullptr) { options.compaction_filter_factory = cfFactory; } status = rocksdb::DB::Open(options, dataPath_, &db); CHECK(status.ok()); db_.reset(db); partsNum_ = allParts().size(); } RocksEngine::~RocksEngine() { } ResultCode RocksEngine::get(const std::string& key, std::string* value) { rocksdb::ReadOptions options; rocksdb::Status status = db_->Get(options, rocksdb::Slice(key), value); if (status.ok()) { return ResultCode::SUCCEEDED; } else if (status.IsNotFound()) { VLOG(3) << "Get: " << key << " Not Found"; return ResultCode::ERR_KEY_NOT_FOUND; } else { VLOG(3) << "Get Failed: " << key << " " << status.ToString(); return ResultCode::ERR_UNKNOWN; } } ResultCode RocksEngine::multiGet(const std::vector<std::string>& keys, std::vector<std::string>* values) { rocksdb::ReadOptions options; std::vector<rocksdb::Slice> slices; for (unsigned int index = 0 ; index < keys.size() ; index++) { slices.emplace_back(keys[index]); } std::vector<rocksdb::Status> status = db_->MultiGet(options, slices, values); auto code = std::all_of(status.begin(), status.end(), [](rocksdb::Status s) { return s.ok(); }); if (code) { return ResultCode::SUCCEEDED; } else { return ResultCode::ERR_UNKNOWN; } } ResultCode RocksEngine::put(std::string key, std::string value) { rocksdb::WriteOptions options; options.disableWAL = FLAGS_rocksdb_disable_wal; rocksdb::Status status = db_->Put(options, key, value); if (status.ok()) { return ResultCode::SUCCEEDED; } else { VLOG(3) << "Put Failed: " << key << status.ToString(); return ResultCode::ERR_UNKNOWN; } } ResultCode RocksEngine::multiPut(std::vector<KV> keyValues) { rocksdb::WriteBatch updates(FLAGS_batch_reserved_bytes); for (size_t i = 0; i < keyValues.size(); i++) { updates.Put(keyValues[i].first, keyValues[i].second); } rocksdb::WriteOptions options; options.disableWAL = FLAGS_rocksdb_disable_wal; rocksdb::Status status = db_->Write(options, &updates); if (status.ok()) { return ResultCode::SUCCEEDED; } else { VLOG(3) << "MultiPut Failed: " << status.ToString(); return ResultCode::ERR_UNKNOWN; } } ResultCode RocksEngine::range(const std::string& start, const std::string& end, std::unique_ptr<KVIterator>* storageIter) { rocksdb::ReadOptions options; rocksdb::Iterator* iter = db_->NewIterator(options); if (iter) { iter->Seek(rocksdb::Slice(start)); } storageIter->reset(new RocksRangeIter(iter, start, end)); return ResultCode::SUCCEEDED; } ResultCode RocksEngine::prefix(const std::string& prefix, std::unique_ptr<KVIterator>* storageIter) { rocksdb::ReadOptions options; rocksdb::Iterator* iter = db_->NewIterator(options); if (iter) { iter->Seek(rocksdb::Slice(prefix)); } storageIter->reset(new RocksPrefixIter(iter, prefix)); return ResultCode::SUCCEEDED; } ResultCode RocksEngine::remove(const std::string& key) { rocksdb::WriteOptions options; options.disableWAL = FLAGS_rocksdb_disable_wal; auto status = db_->Delete(options, key); if (status.ok()) { return ResultCode::SUCCEEDED; } else { VLOG(3) << "Remove Failed: " << key << status.ToString(); return ResultCode::ERR_UNKNOWN; } } ResultCode RocksEngine::multiRemove(std::vector<std::string> keys) { rocksdb::WriteBatch deletes(FLAGS_batch_reserved_bytes); for (size_t i = 0; i < keys.size(); i++) { deletes.Delete(keys[i]); } rocksdb::WriteOptions options; options.disableWAL = FLAGS_rocksdb_disable_wal; rocksdb::Status status = db_->Write(options, &deletes); if (status.ok()) { return ResultCode::SUCCEEDED; } else { VLOG(3) << "MultiRemove Failed: " << status.ToString(); return ResultCode::ERR_UNKNOWN; } } ResultCode RocksEngine::removeRange(const std::string& start, const std::string& end) { rocksdb::WriteOptions options; options.disableWAL = FLAGS_rocksdb_disable_wal; auto status = db_->DeleteRange(options, db_->DefaultColumnFamily(), start, end); if (status.ok()) { return ResultCode::SUCCEEDED; } else { VLOG(3) << "RemoveRange Failed: " << status.ToString(); return ResultCode::ERR_UNKNOWN; } } std::string RocksEngine::partKey(PartitionID partId) { std::string key; static const size_t prefixLen = ::strlen(kSystemParts); key.reserve(prefixLen + sizeof(PartitionID)); key.append(kSystemParts, prefixLen); key.append(reinterpret_cast<const char*>(&partId), sizeof(PartitionID)); return key; } void RocksEngine::addPart(PartitionID partId) { auto ret = put(partKey(partId), ""); if (ret == ResultCode::SUCCEEDED) { partsNum_++; CHECK_GE(partsNum_, 0); } } void RocksEngine::removePart(PartitionID partId) { rocksdb::WriteOptions options; options.disableWAL = FLAGS_rocksdb_disable_wal; auto status = db_->Delete(options, partKey(partId)); if (status.ok()) { partsNum_--; CHECK_GE(partsNum_, 0); } } std::vector<PartitionID> RocksEngine::allParts() { std::unique_ptr<KVIterator> iter; static const size_t prefixLen = ::strlen(kSystemParts); static const std::string prefixStr(kSystemParts, prefixLen); CHECK_EQ(ResultCode::SUCCEEDED, this->prefix(prefixStr, &iter)); std::vector<PartitionID> parts; while (iter->valid()) { auto key = iter->key(); CHECK_EQ(key.size(), prefixLen + sizeof(PartitionID)); parts.emplace_back( *reinterpret_cast<const PartitionID*>(key.data() + key.size() - sizeof(PartitionID))); iter->next(); } return parts; } int32_t RocksEngine::totalPartsNum() { return partsNum_; } ResultCode RocksEngine::ingest(const std::vector<std::string>& files) { rocksdb::IngestExternalFileOptions options; rocksdb::Status status = db_->IngestExternalFile(files, options); if (status.ok()) { return ResultCode::SUCCEEDED; } else { LOG(ERROR) << "Ingest Failed: " << status.ToString(); return ResultCode::ERR_UNKNOWN; } } ResultCode RocksEngine::setOption(const std::string& configKey, const std::string& configValue) { std::unordered_map<std::string, std::string> configOptions = { {configKey, configValue} }; rocksdb::Status status = db_->SetOptions(configOptions); if (status.ok()) { return ResultCode::SUCCEEDED; } else { LOG(ERROR) << "SetOption Failed: " << configKey << ":" << configValue; return ResultCode::ERR_INVALID_ARGUMENT; } } ResultCode RocksEngine::setDBOption(const std::string& configKey, const std::string& configValue) { std::unordered_map<std::string, std::string> configOptions = { {configKey, configValue} }; rocksdb::Status status = db_->SetDBOptions(configOptions); if (status.ok()) { return ResultCode::SUCCEEDED; } else { LOG(ERROR) << "SetDBOption Failed: " << configKey << ":" << configValue; return ResultCode::ERR_INVALID_ARGUMENT; } } ResultCode RocksEngine::compactAll() { rocksdb::CompactRangeOptions options; rocksdb::Status status = db_->CompactRange(options, nullptr, nullptr); if (status.ok()) { return ResultCode::SUCCEEDED; } else { LOG(ERROR) << "CompactAll Failed: " << status.ToString(); return ResultCode::ERR_UNKNOWN; } } } // namespace kvstore } // namespace nebula
def main(a0:i8, c0:i8, e0:i8, g0:i8, i0:i8, a1:i8, c1:i8, e1:i8, g1:i8, i1:i8, a2:i8, c2:i8, e2:i8, g2:i8, i2:i8, b0:i8, d0:i8, f0:i8, h0:i8, j0:i8, b1:i8, d1:i8, f1:i8, h1:i8, j1:i8, b2:i8, d2:i8, f2:i8, h2:i8, j2:i8, m:i8, n:i8, o:i8, p:i8, q:i8, en:bool) -> (v:i8, w:i8, x:i8, y:i8, z:i8) { v:i8 = dmuladdregaci_i8i8(a2, b2, t11, en, en, en, en) @dsp(x0, y0+2); t11:i8 = dmuladdregacio_i8i8(a1, b1, t5, en, en, en, en) @dsp(x0, y0+1); t5:i8 = dmuladdregaco_i8i8(a0, b0, m, en, en, en, en) @dsp(x0, y0); w:i8 = dmuladdregaci_i8i8(c2, d2, t29, en, en, en, en) @dsp(x1, y1+2); t29:i8 = dmuladdregacio_i8i8(c1, d1, t23, en, en, en, en) @dsp(x1, y1+1); t23:i8 = dmuladdregaco_i8i8(c0, d0, n, en, en, en, en) @dsp(x1, y1); x:i8 = dmuladdregaci_i8i8(e2, f2, t47, en, en, en, en) @dsp(x2, y2+2); t47:i8 = dmuladdregacio_i8i8(e1, f1, t41, en, en, en, en) @dsp(x2, y2+1); t41:i8 = dmuladdregaco_i8i8(e0, f0, o, en, en, en, en) @dsp(x2, y2); y:i8 = dmuladdregaci_i8i8(g2, h2, t65, en, en, en, en) @dsp(x3, y3+2); t65:i8 = dmuladdregacio_i8i8(g1, h1, t59, en, en, en, en) @dsp(x3, y3+1); t59:i8 = dmuladdregaco_i8i8(g0, h0, p, en, en, en, en) @dsp(x3, y3); z:i8 = dmuladdregaci_i8i8(i2, j2, t83, en, en, en, en) @dsp(x4, y4+2); t83:i8 = dmuladdregacio_i8i8(i1, j1, t77, en, en, en, en) @dsp(x4, y4+1); t77:i8 = dmuladdregaco_i8i8(i0, j0, q, en, en, en, en) @dsp(x4, y4); }
SFX_Cry18_2_Ch1: dutycycle 80 unknownsfx0x20 10, 245, 128, 6 unknownsfx0x20 3, 226, 160, 6 unknownsfx0x20 3, 242, 192, 6 unknownsfx0x20 3, 226, 224, 6 unknownsfx0x20 3, 210, 0, 7 unknownsfx0x20 3, 194, 224, 6 unknownsfx0x20 3, 210, 192, 6 unknownsfx0x20 8, 193, 160, 6 endchannel SFX_Cry18_2_Ch2: dutycycle 15 unknownsfx0x20 9, 213, 49, 6 unknownsfx0x20 3, 210, 82, 6 unknownsfx0x20 3, 226, 113, 6 unknownsfx0x20 3, 178, 145, 6 unknownsfx0x20 3, 194, 178, 6 unknownsfx0x20 3, 178, 145, 6 unknownsfx0x20 3, 194, 113, 6 unknownsfx0x20 8, 177, 81, 6 endchannel SFX_Cry18_2_Ch3: unknownnoise0x20 6, 227, 76 unknownnoise0x20 4, 195, 60 unknownnoise0x20 5, 212, 60 unknownnoise0x20 4, 196, 44 unknownnoise0x20 6, 180, 60 unknownnoise0x20 8, 193, 44 endchannel
lda {m1} ora {m1}+1 bne {la1}
#ifndef ARGUMENT_RANGE_NON_ZERO_HPP_ #define ARGUMENT_RANGE_NON_ZERO_HPP_ #include <string> #include "Ranges/Set/Set.hpp" namespace cli { template <typename T = float> class Non_zero_range : public Excluding_set_range<T> { public: explicit Non_zero_range() : Excluding_set_range<T>({(T)0}) { } virtual ~Non_zero_range() {}; virtual Non_zero_range* clone() const { return new Non_zero_range(*this); } virtual std::string get_title() const { return "non-zero"; } }; template <typename T = float> // then int are converted into floats in the excluding set check function Non_zero_range<T>* Non_zero() { return new Non_zero_range<T>(); } } #endif /* ARGUMENT_RANGE_NON_ZERO_HPP_ */
;=============================================================================== ; Copyright 2015-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. ;=============================================================================== ; ; ; Purpose: Cryptography Primitive. ; Big Number Operations ; ; Content: ; cpMontSqr1024_avx2() ; include asmdefs.inc include ia_32e.inc IF (_IPP32E GE _IPP32E_L9) IPPCODE SEGMENT 'CODE' ALIGN (IPP_ALIGN_FACTOR) DIGIT_BITS = 27 DIGIT_MASK = (1 SHL DIGIT_BITS) -1 ;************************************************************* ;* void cpMontSqr1024_avx2(Ipp64u* pR, ;* const Ipp64u* pA, ;* const Ipp64u* pModulus, int mSize, ;* Ipp64u k0, ;* Ipp64u* pBuffer) ;************************************************************* ALIGN IPP_ALIGN_FACTOR IPPASM cpMontSqr1024_avx2 PROC PUBLIC FRAME USES_GPR rsi,rdi,rbx,rbp,r12,r13,r14 LOCAL_FRAME = sizeof(qword)*7 USES_XMM_AVX ymm6,ymm7,ymm8,ymm9,ymm10,ymm11,ymm12,ymm13,ymm14 COMP_ABI 6 movsxd rcx, ecx ; redLen value counter vpxor ymm11, ymm11, ymm11 ;; expands A and M operands vmovdqu ymmword ptr[rsi+rcx*sizeof(qword)], ymm11 vmovdqu ymmword ptr[rdx+rcx*sizeof(qword)], ymm11 ; ; stack struct ; pResult = 0 ; pointer to result pA = pResult+sizeof(qword) ; pointer to A operand pM = pA+sizeof(qword) ; pointer to modulus redLen = pM+sizeof(qword) ; length m0 = redLen+sizeof(qword) ; m0 value pA2 = m0+sizeof(qword) ; pointer to buffer (contains doubled input (A*2) and temporary result (A^2) ) pAxA = pA2+sizeof(qword) ; pointer to temporary result (A^2) mov qword ptr[rsp+pResult], rdi ; store pointer to result mov qword ptr[rsp+pA], rsi ; store pointer to input A mov qword ptr[rsp+pM], rdx ; store pointer to modulus mov qword ptr[rsp+redLen], rcx ; store redLen mov qword ptr[rsp+m0], r8 ; store m0 value mov rcx, 40 mov rdi, r9 mov qword ptr[rsp+pAxA], rdi ; pointer to temporary result (low A^2) lea rbx, [rdi+rcx*sizeof(qword)] ; pointer to temporary result (high A^2) lea r9, [rbx+rcx*sizeof(qword)] ; pointer to doubled input (A*2) mov qword ptr[rsp+pA2], r9 mov rax, rsi mov rcx, sizeof(ymmword)/sizeof(qword) ;; doubling input vmovdqu ymm0, ymmword ptr[rsi] vmovdqu ymm1, ymmword ptr[rsi+sizeof(ymmword)] vmovdqu ymm2, ymmword ptr[rsi+sizeof(ymmword)*2] vmovdqu ymm3, ymmword ptr[rsi+sizeof(ymmword)*3] vmovdqu ymm4, ymmword ptr[rsi+sizeof(ymmword)*4] vmovdqu ymm5, ymmword ptr[rsi+sizeof(ymmword)*5] vmovdqu ymm6, ymmword ptr[rsi+sizeof(ymmword)*6] vmovdqu ymm7, ymmword ptr[rsi+sizeof(ymmword)*7] vmovdqu ymm8, ymmword ptr[rsi+sizeof(ymmword)*8] vmovdqu ymm9, ymmword ptr[rsi+sizeof(ymmword)*9] vmovdqu ymmword ptr[r9], ymm0 vpbroadcastq ymm10, qword ptr[rax] ; ymm10 = {a0:a0:a0:a0} vpaddq ymm1, ymm1, ymm1 vmovdqu ymmword ptr[r9+sizeof(ymmword)], ymm1 vpaddq ymm2, ymm2, ymm2 vmovdqu ymmword ptr[r9+sizeof(ymmword)*2], ymm2 vpaddq ymm3, ymm3, ymm3 vmovdqu ymmword ptr[r9+sizeof(ymmword)*3], ymm3 vpaddq ymm4, ymm4, ymm4 vmovdqu ymmword ptr[r9+sizeof(ymmword)*4], ymm4 vpaddq ymm5, ymm5, ymm5 vmovdqu ymmword ptr[r9+sizeof(ymmword)*5], ymm5 vpaddq ymm6, ymm6, ymm6 vmovdqu ymmword ptr[r9+sizeof(ymmword)*6], ymm6 vpaddq ymm7, ymm7, ymm7 vmovdqu ymmword ptr[r9+sizeof(ymmword)*7], ymm7 vpaddq ymm8, ymm8, ymm8 vmovdqu ymmword ptr[r9+sizeof(ymmword)*8], ymm8 vpaddq ymm9, ymm9, ymm9 vmovdqu ymmword ptr[r9+sizeof(ymmword)*9], ymm9 ;; ;; squaring ;; vpmuludq ymm0, ymm10, ymmword ptr[rsi] vpbroadcastq ymm14, qword ptr[rax+sizeof(qword)*4] ; ymm14 = {a4:a4:a4:a4} vmovdqu ymmword ptr[rbx], ymm11 vpmuludq ymm1, ymm10, ymmword ptr[r9+sizeof(ymmword)] vmovdqu ymmword ptr[rbx+sizeof(ymmword)], ymm11 vpmuludq ymm2, ymm10, ymmword ptr[r9+sizeof(ymmword)*2] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*2], ymm11 vpmuludq ymm3, ymm10, ymmword ptr[r9+sizeof(ymmword)*3] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*3], ymm11 vpmuludq ymm4, ymm10, ymmword ptr[r9+sizeof(ymmword)*4] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*4], ymm11 vpmuludq ymm5, ymm10, ymmword ptr[r9+sizeof(ymmword)*5] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*5], ymm11 vpmuludq ymm6, ymm10, ymmword ptr[r9+sizeof(ymmword)*6] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*6], ymm11 vpmuludq ymm7, ymm10, ymmword ptr[r9+sizeof(ymmword)*7] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*7], ymm11 vpmuludq ymm8, ymm10, ymmword ptr[r9+sizeof(ymmword)*8] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*8], ymm11 vpmuludq ymm9, ymm10, ymmword ptr[r9+sizeof(ymmword)*9] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*9], ymm11 jmp sqr1024_ep ALIGN IPP_ALIGN_FACTOR sqr1024_loop4: vpmuludq ymm0, ymm10, ymmword ptr[rsi] vpbroadcastq ymm14, qword ptr[rax+sizeof(qword)*4] ; ymm14 = {a4:a4:a4:a4} vpaddq ymm0, ymm0, ymmword ptr[rdi] vpmuludq ymm1, ymm10, ymmword ptr[r9+sizeof(ymmword)] vpaddq ymm1, ymm1, ymmword ptr[rdi+sizeof(ymmword)] vpmuludq ymm2, ymm10, ymmword ptr[r9+sizeof(ymmword)*2] vpaddq ymm2, ymm2, ymmword ptr[rdi+sizeof(ymmword)*2] vpmuludq ymm3, ymm10, ymmword ptr[r9+sizeof(ymmword)*3] vpaddq ymm3, ymm3, ymmword ptr[rdi+sizeof(ymmword)*3] vpmuludq ymm4, ymm10, ymmword ptr[r9+sizeof(ymmword)*4] vpaddq ymm4, ymm4, ymmword ptr[rdi+sizeof(ymmword)*4] vpmuludq ymm5, ymm10, ymmword ptr[r9+sizeof(ymmword)*5] vpaddq ymm5, ymm5, ymmword ptr[rdi+sizeof(ymmword)*5] vpmuludq ymm6, ymm10, ymmword ptr[r9+sizeof(ymmword)*6] vpaddq ymm6, ymm6, ymmword ptr[rdi+sizeof(ymmword)*6] vpmuludq ymm7, ymm10, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm7, ymm7, ymmword ptr[rdi+sizeof(ymmword)*7] vpmuludq ymm8, ymm10, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm8, ymm8, ymmword ptr[rdi+sizeof(ymmword)*8] vpmuludq ymm9, ymm10, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm9, ymm9, ymmword ptr[rdi+sizeof(ymmword)*9] sqr1024_ep: vmovdqu ymmword ptr[rdi], ymm0 vmovdqu ymmword ptr[rdi+sizeof(ymmword)], ymm1 vpmuludq ymm11, ymm14, ymmword ptr[rsi+sizeof(ymmword)] vpbroadcastq ymm10, qword ptr[rax+sizeof(qword)*8] ; ymm10 = {a8:a8:a8:a8} vpaddq ymm2, ymm2, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*2] vpaddq ymm3, ymm3, ymm12 vpmuludq ymm13, ymm14, ymmword ptr[r9+sizeof(ymmword)*3] vpaddq ymm4, ymm4, ymm13 vpmuludq ymm11, ymm14, ymmword ptr[r9+sizeof(ymmword)*4] vpaddq ymm5, ymm5, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*5] vpaddq ymm6, ymm6, ymm12 vpmuludq ymm13, ymm14, ymmword ptr[r9+sizeof(ymmword)*6] vpaddq ymm7, ymm7, ymm13 vpmuludq ymm11, ymm14, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm8, ymm8, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm9, ymm9, ymm12 vpmuludq ymm0, ymm14, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm0, ymm0, ymmword ptr[rbx] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*2], ymm2 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*3], ymm3 vpmuludq ymm11, ymm10, ymmword ptr[rsi+sizeof(ymmword)*2] vpbroadcastq ymm14, qword ptr[rax+sizeof(qword)*12] ; ymm14 = {a12:a12:a12:a12} vpaddq ymm4, ymm4, ymm11 vpmuludq ymm12, ymm10, ymmword ptr[r9+sizeof(ymmword)*3] vpaddq ymm5, ymm5, ymm12 vpmuludq ymm13, ymm10, ymmword ptr[r9+sizeof(ymmword)*4] vpaddq ymm6, ymm6, ymm13 vpmuludq ymm11, ymm10, ymmword ptr[r9+sizeof(ymmword)*5] vpaddq ymm7, ymm7, ymm11 vpmuludq ymm12, ymm10, ymmword ptr[r9+sizeof(ymmword)*6] vpaddq ymm8, ymm8, ymm12 vpmuludq ymm13, ymm10, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm9, ymm9, ymm13 vpmuludq ymm11, ymm10, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm0, ymm0, ymm11 vpmuludq ymm1, ymm10, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm1, ymm1, ymmword ptr[rbx+sizeof(ymmword)] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*4], ymm4 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*5], ymm5 vpmuludq ymm11, ymm14, ymmword ptr[rsi+sizeof(ymmword)*3] vpbroadcastq ymm10, qword ptr[rax+sizeof(qword)*16] ; ymm10 = {a16:a16:a16:a16} vpaddq ymm6, ymm6, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*4] vpaddq ymm7, ymm7, ymm12 vpmuludq ymm13, ymm14, ymmword ptr[r9+sizeof(ymmword)*5] vpaddq ymm8, ymm8, ymm13 vpmuludq ymm11, ymm14, ymmword ptr[r9+sizeof(ymmword)*6] vpaddq ymm9, ymm9, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm0, ymm0, ymm12 vpmuludq ymm13, ymm14, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm1, ymm1, ymm13 vpmuludq ymm2, ymm14, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm2, ymm2, ymmword ptr[rbx+sizeof(ymmword)*2] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*6], ymm6 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*7], ymm7 vpmuludq ymm11, ymm10, ymmword ptr[rsi+sizeof(ymmword)*4] vpbroadcastq ymm14, qword ptr[rax+sizeof(qword)*20] ; ymm14 = {a20:a20:a20:a20} vpaddq ymm8, ymm8, ymm11 vpmuludq ymm12, ymm10, ymmword ptr[r9+sizeof(ymmword)*5] vpaddq ymm9, ymm9, ymm12 vpmuludq ymm13, ymm10, ymmword ptr[r9+sizeof(ymmword)*6] vpaddq ymm0, ymm0, ymm13 vpmuludq ymm11, ymm10, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm1, ymm1, ymm11 vpmuludq ymm12, ymm10, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm2, ymm2, ymm12 vpmuludq ymm3, ymm10, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm3, ymm3, ymmword ptr[rbx+sizeof(ymmword)*3] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*8], ymm8 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*9], ymm9 vpmuludq ymm11, ymm14, ymmword ptr[rsi+sizeof(ymmword)*5] vpbroadcastq ymm10, qword ptr[rax+sizeof(qword)*24] ; ymm10 = {a24:a24:a24:a24} vpaddq ymm0, ymm0, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*6] vpaddq ymm1, ymm1, ymm12 vpmuludq ymm13, ymm14, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm2, ymm2, ymm13 vpmuludq ymm11, ymm14, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm3, ymm3, ymm11 vpmuludq ymm4, ymm14, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm4, ymm4, ymmword ptr[rbx+sizeof(ymmword)*4] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*10], ymm0 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*11], ymm1 vpmuludq ymm11, ymm10, ymmword ptr[rsi+sizeof(ymmword)*6] vpbroadcastq ymm14, qword ptr[rax+sizeof(qword)*28] ; ymm14 = {a28:a28:a28:a28} vpaddq ymm2, ymm2, ymm11 vpmuludq ymm12, ymm10, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm3, ymm3, ymm12 vpmuludq ymm13, ymm10, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm4, ymm4, ymm13 vpmuludq ymm5, ymm10, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm5, ymm5, ymmword ptr[rbx+sizeof(ymmword)*5] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*12], ymm2 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*13], ymm3 vpmuludq ymm11, ymm14, ymmword ptr[rsi+sizeof(ymmword)*7] vpbroadcastq ymm10, qword ptr[rax+sizeof(qword)*32] ; ymm10 = {a32:a32:a32:a32} vpaddq ymm4, ymm4, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm5, ymm5, ymm12 vpmuludq ymm6, ymm14, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm6, ymm6, ymmword ptr[rbx+sizeof(ymmword)*6] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*14], ymm4 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*15], ymm5 vpmuludq ymm11, ymm10, ymmword ptr[rsi+sizeof(ymmword)*8] vpbroadcastq ymm14, qword ptr[rax+sizeof(qword)*36] ; ymm14 = {a36:a36:a36:a36} vpaddq ymm6, ymm6, ymm11 vpmuludq ymm7, ymm10, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm7, ymm7, ymmword ptr[rbx+sizeof(ymmword)*7] vpmuludq ymm8, ymm14, ymmword ptr[rsi+sizeof(ymmword)*9] vpbroadcastq ymm10, qword ptr[rax+sizeof(qword)] ; ymm10 = {a[1/2/3]:a[1/2/3]:a[1/2/3]:a[1/2/3]} vpaddq ymm8, ymm8, ymmword ptr[rbx+sizeof(ymmword)*8] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*16], ymm6 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*17], ymm7 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*18], ymm8 add rdi, sizeof(qword) add rbx, sizeof(qword) add rax, sizeof(qword) sub rcx, 1 jnz sqr1024_loop4 ;; ;; reduction ;; mov rdi, qword ptr[rsp+pAxA] ; restore pointer to temporary result (low A^2) mov rcx, qword ptr[rsp+pM] ; restore pointer to modulus mov r8, qword ptr[rsp+m0] ; restore m0 value mov r9, 38 ; modulus length mov r10, qword ptr[rdi] ; load low part of temporary result mov r11, qword ptr[rdi+sizeof(qword)] ; mov r12, qword ptr[rdi+sizeof(qword)*2] ; mov r13, qword ptr[rdi+sizeof(qword)*3] ; mov rdx, r10 ; y0 = (ac0*k0) & DIGIT_MASK imul edx, r8d and edx, DIGIT_MASK vmovd xmm10, edx vmovdqu ymm1, ymmword ptr[rdi+sizeof(ymmword)*1] ; load other data vmovdqu ymm2, ymmword ptr[rdi+sizeof(ymmword)*2] ; vmovdqu ymm3, ymmword ptr[rdi+sizeof(ymmword)*3] ; vmovdqu ymm4, ymmword ptr[rdi+sizeof(ymmword)*4] ; vmovdqu ymm5, ymmword ptr[rdi+sizeof(ymmword)*5] ; vmovdqu ymm6, ymmword ptr[rdi+sizeof(ymmword)*6] ; mov rax, rdx ; ac0 += pn[0]*y0 imul rax, qword ptr[rcx] add r10, rax vpbroadcastq ymm10, xmm10 vmovdqu ymm7, ymmword ptr[rdi+sizeof(ymmword)*7] ; load other data vmovdqu ymm8, ymmword ptr[rdi+sizeof(ymmword)*8] ; vmovdqu ymm9, ymmword ptr[rdi+sizeof(ymmword)*9] ; mov rax, rdx ; ac1 += pn[1]*y0 imul rax, qword ptr[rcx+sizeof(qword)] add r11, rax mov rax, rdx ; ac2 += pn[2]*y0 imul rax, qword ptr[rcx+sizeof(qword)*2] add r12, rax shr r10, DIGIT_BITS ; updtae ac1 imul rdx, qword ptr[rcx+sizeof(qword)*3] ; ac3 += pn[3]*y0 add r13, rdx add r11, r10 ; updtae ac1 mov rdx, r11 ; y1 = (ac1*k0) & DIGIT_MASK imul edx, r8d and rdx, DIGIT_MASK ALIGN IPP_ALIGN_FACTOR reduction_loop: vmovd xmm11, edx vpbroadcastq ymm11, xmm11 vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)] mov rax, rdx ; ac1 += pn[0]*y1 imul rax, qword ptr[rcx] vpaddq ymm1, ymm1, ymm14 vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*2] vpaddq ymm2, ymm2, ymm14 vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*3] vpaddq ymm3, ymm3, ymm14 vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*4] add r11, rax shr r11, DIGIT_BITS ; update ac2 vpaddq ymm4, ymm4, ymm14 vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*5] mov rax, rdx ; ac2 += pn[1]*y1 imul rax, qword ptr[rcx+sizeof(qword)] vpaddq ymm5, ymm5, ymm14 add r12, rax vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*6] imul rdx, qword ptr[rcx+sizeof(qword)*2] ; ac3 += pn[2]*y1 add r12, r11 vpaddq ymm6, ymm6, ymm14 add r13, rdx vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*7] mov rdx, r12 ; y2 = (ac2*m0) & DIGIT_MASK imul edx, r8d vpaddq ymm7, ymm7, ymm14 vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*8] vpaddq ymm8, ymm8, ymm14 and rdx, DIGIT_MASK vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*9] vpaddq ymm9, ymm9, ymm14 ;; ------------------------------------------------------------ vmovd xmm12, edx vpbroadcastq ymm12, xmm12 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)-sizeof(qword)] mov rax, rdx ; ac2 += pn[0]*y2 imul rax, qword ptr[rcx] vpaddq ymm1, ymm1, ymm14 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*2-sizeof(qword)] vpaddq ymm2, ymm2, ymm14 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*3-sizeof(qword)] vpaddq ymm3, ymm3, ymm14 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*4-sizeof(qword)] vpaddq ymm4, ymm4, ymm14 add rax, r12 shr rax, DIGIT_BITS ; update ac3 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*5-sizeof(qword)] imul rdx, qword ptr[rcx+sizeof(qword)] ; ac3 += pn[1]*y2 vpaddq ymm5, ymm5, ymm14 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*6-sizeof(qword)] vpaddq ymm6, ymm6, ymm14 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*7-sizeof(qword)] vpaddq ymm7, ymm7, ymm14 add rdx, r13 add rdx, rax ; update ac3 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*8-sizeof(qword)] vpaddq ymm8, ymm8, ymm14 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*9-sizeof(qword)] vpaddq ymm9, ymm9, ymm14 sub r9, 2 jz exit_reduction_loop ;; ------------------------------------------------------------ vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)-sizeof(qword)*2] mov r13, rdx ; y3 = (ac3*m0) & DIGIT_MASK imul edx, r8d vpaddq ymm1, ymm1, ymm14 vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*2-sizeof(qword)*2] vpaddq ymm2, ymm2, ymm14 and rdx, DIGIT_MASK vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*3-sizeof(qword)*2] vmovd xmm13, edx vpaddq ymm3, ymm3, ymm14 vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*4-sizeof(qword)*2] vpbroadcastq ymm13, xmm13 vpaddq ymm4, ymm4, ymm14 vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*5-sizeof(qword)*2] imul rdx, qword ptr[rcx] ; ac3 += pn[0]*y3 vpaddq ymm5, ymm5, ymm14 vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*6-sizeof(qword)*2] vpaddq ymm6, ymm6, ymm14 add r13, rdx vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*7-sizeof(qword)*2] vpaddq ymm7, ymm7, ymm14 shr r13, DIGIT_BITS vmovq xmm0, r13 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)-sizeof(qword)*3] vpaddq ymm1, ymm1, ymm0 vpaddq ymm1, ymm1, ymm14 vmovdqu ymmword ptr[rdi], ymm1 vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*8-sizeof(qword)*2] vpaddq ymm8, ymm8, ymm14 vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*9-sizeof(qword)*2] vpaddq ymm9, ymm9, ymm14 ;; ------------------------------------------------------------ vmovq rdx, xmm1 ; y0 = (ac0*k0) & DIGIT_MASK imul edx, r8d and edx, DIGIT_MASK vmovq r10, xmm1 ; update lowest part of temporary result mov r11, qword ptr[rdi+sizeof(qword)] ; mov r12, qword ptr[rdi+sizeof(qword)*2] ; mov r13, qword ptr[rdi+sizeof(qword)*3] ; vmovd xmm10, edx vpbroadcastq ymm10, xmm10 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*2-sizeof(qword)*3] mov rax, rdx ; ac0 += pn[0]*y0 imul rax, qword ptr[rcx] vpaddq ymm1, ymm2, ymm14 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*3-sizeof(qword)*3] add r10, rax vpaddq ymm2, ymm3, ymm14 shr r10, DIGIT_BITS ; updtae ac1 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*4-sizeof(qword)*3] mov rax, rdx ; ac1 += pn[1]*y0 imul rax, qword ptr[rcx+sizeof(qword)] vpaddq ymm3, ymm4, ymm14 add r11, rax vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*5-sizeof(qword)*3] mov rax, rdx ; ac2 += pn[2]*y0 imul rax, qword ptr[rcx+sizeof(qword)*2] vpaddq ymm4, ymm5, ymm14 add r12, rax vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*6-sizeof(qword)*3] imul rdx, qword ptr[rcx+sizeof(qword)*3] ; ac3 += pn[3]*y0 vpaddq ymm5, ymm6, ymm14 add r13, rdx add r11, r10 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*7-sizeof(qword)*3] mov rdx, r11 ; y1 = (ac1*k0) & DIGIT_MASK imul edx, r8d vpaddq ymm6, ymm7, ymm14 and rdx, DIGIT_MASK vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*8-sizeof(qword)*3] vpaddq ymm7, ymm8, ymm14 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*9-sizeof(qword)*3] vpaddq ymm8, ymm9, ymm14 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*10-sizeof(qword)*3] vpaddq ymm9, ymm14, ymmword ptr[rdi+sizeof(ymmword)*10] add rdi, sizeof(qword)*4 sub r9, 2 jnz reduction_loop exit_reduction_loop: mov rdi, qword ptr[rsp+pResult] ; restore pointer to result mov qword ptr[rdi], r12 mov qword ptr[rdi+sizeof(qword)], r13 vmovdqu ymmword ptr[rdi+sizeof(ymmword)-sizeof(qword)*2], ymm1 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*2-sizeof(qword)*2], ymm2 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*3-sizeof(qword)*2], ymm3 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*4-sizeof(qword)*2], ymm4 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*5-sizeof(qword)*2], ymm5 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*6-sizeof(qword)*2], ymm6 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*7-sizeof(qword)*2], ymm7 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*8-sizeof(qword)*2], ymm8 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*9-sizeof(qword)*2], ymm9 ;; ;; normalization ;; mov r9, 38 xor rax, rax norm_loop: add rax, qword ptr[rdi] add rdi, sizeof(qword) mov rdx, DIGIT_MASK and rdx, rax shr rax, DIGIT_BITS mov qword ptr[rdi-sizeof(qword)], rdx sub r9, 1 jg norm_loop mov qword ptr[rdi], rax REST_XMM_AVX REST_GPR ret IPPASM cpMontSqr1024_avx2 ENDP ;************************************************************* ;* void cpSqr1024_avx2(Ipp64u* pR, ;* const Ipp64u* pA, int nsA, ;* Ipp64u* pBuffer) ;************************************************************* ALIGN IPP_ALIGN_FACTOR IPPASM cpSqr1024_avx2 PROC PUBLIC FRAME USES_GPR rsi,rdi,rbx LOCAL_FRAME = sizeof(qword)*5 USES_XMM_AVX ymm6,ymm7,ymm8,ymm9,ymm10,ymm11,ymm12,ymm13,ymm14 COMP_ABI 4 movsxd rdx, edx ; redLen value counter vpxor ymm11, ymm11, ymm11 ;; expands A operand vmovdqu ymmword ptr[rsi+rdx*sizeof(qword)], ymm11 ; ; stack struct ; pResult = 0 ; pointer to result pA = pResult+sizeof(qword) ; pointer to A operand redLen = pA+sizeof(qword) ; length pA2 = redLen+sizeof(qword) ; pointer to buffer (contains doubled input (A*2) and temporary result (A^2) ) pAxA = pA2+sizeof(qword) ; pointer to temporary result (A^2) mov qword ptr[rsp+pResult], rdi ; store pointer to result mov qword ptr[rsp+pA], rsi ; store pointer to input A mov qword ptr[rsp+redLen], rdx ; store redLen mov rdx, 40 mov rdi, rcx ; pointer to buffer mov qword ptr[rsp+pAxA], rdi ; pointer to temporary result (low A^2) lea rbx, [rdi+rdx*sizeof(qword)] ; pointer to temporary result (high A^2) lea r9, [rbx+rdx*sizeof(qword)] ; pointer to doubled input (A*2) mov qword ptr[rsp+pA2], r9 mov rax, rsi mov rcx, sizeof(ymmword)/sizeof(qword) ;; doubling input vmovdqu ymm0, ymmword ptr[rsi] vmovdqu ymm1, ymmword ptr[rsi+sizeof(ymmword)] vmovdqu ymm2, ymmword ptr[rsi+sizeof(ymmword)*2] vmovdqu ymm3, ymmword ptr[rsi+sizeof(ymmword)*3] vmovdqu ymm4, ymmword ptr[rsi+sizeof(ymmword)*4] vmovdqu ymm5, ymmword ptr[rsi+sizeof(ymmword)*5] vmovdqu ymm6, ymmword ptr[rsi+sizeof(ymmword)*6] vmovdqu ymm7, ymmword ptr[rsi+sizeof(ymmword)*7] vmovdqu ymm8, ymmword ptr[rsi+sizeof(ymmword)*8] vmovdqu ymm9, ymmword ptr[rsi+sizeof(ymmword)*9] vmovdqu ymmword ptr[r9], ymm0 vpbroadcastq ymm10, qword ptr[rax] ; ymm10 = {a0:a0:a0:a0} vpaddq ymm1, ymm1, ymm1 vmovdqu ymmword ptr[r9+sizeof(ymmword)], ymm1 vpaddq ymm2, ymm2, ymm2 vmovdqu ymmword ptr[r9+sizeof(ymmword)*2], ymm2 vpaddq ymm3, ymm3, ymm3 vmovdqu ymmword ptr[r9+sizeof(ymmword)*3], ymm3 vpaddq ymm4, ymm4, ymm4 vmovdqu ymmword ptr[r9+sizeof(ymmword)*4], ymm4 vpaddq ymm5, ymm5, ymm5 vmovdqu ymmword ptr[r9+sizeof(ymmword)*5], ymm5 vpaddq ymm6, ymm6, ymm6 vmovdqu ymmword ptr[r9+sizeof(ymmword)*6], ymm6 vpaddq ymm7, ymm7, ymm7 vmovdqu ymmword ptr[r9+sizeof(ymmword)*7], ymm7 vpaddq ymm8, ymm8, ymm8 vmovdqu ymmword ptr[r9+sizeof(ymmword)*8], ymm8 vpaddq ymm9, ymm9, ymm9 vmovdqu ymmword ptr[r9+sizeof(ymmword)*9], ymm9 ;; ;; squaring ;; vpmuludq ymm0, ymm10, ymmword ptr[rsi] vpbroadcastq ymm14, qword ptr[rax+sizeof(qword)*4] ; ymm14 = {a4:a4:a4:a4} vmovdqu ymmword ptr[rbx], ymm11 vpmuludq ymm1, ymm10, ymmword ptr[r9+sizeof(ymmword)] vmovdqu ymmword ptr[rbx+sizeof(ymmword)], ymm11 vpmuludq ymm2, ymm10, ymmword ptr[r9+sizeof(ymmword)*2] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*2], ymm11 vpmuludq ymm3, ymm10, ymmword ptr[r9+sizeof(ymmword)*3] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*3], ymm11 vpmuludq ymm4, ymm10, ymmword ptr[r9+sizeof(ymmword)*4] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*4], ymm11 vpmuludq ymm5, ymm10, ymmword ptr[r9+sizeof(ymmword)*5] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*5], ymm11 vpmuludq ymm6, ymm10, ymmword ptr[r9+sizeof(ymmword)*6] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*6], ymm11 vpmuludq ymm7, ymm10, ymmword ptr[r9+sizeof(ymmword)*7] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*7], ymm11 vpmuludq ymm8, ymm10, ymmword ptr[r9+sizeof(ymmword)*8] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*8], ymm11 vpmuludq ymm9, ymm10, ymmword ptr[r9+sizeof(ymmword)*9] vmovdqu ymmword ptr[rbx+sizeof(ymmword)*9], ymm11 jmp sqr1024_ep ALIGN IPP_ALIGN_FACTOR sqr1024_loop4: vpmuludq ymm0, ymm10, ymmword ptr[rsi] vpbroadcastq ymm14, qword ptr[rax+sizeof(qword)*4] ; ymm14 = {a4:a4:a4:a4} vpaddq ymm0, ymm0, ymmword ptr[rdi] vpmuludq ymm1, ymm10, ymmword ptr[r9+sizeof(ymmword)] vpaddq ymm1, ymm1, ymmword ptr[rdi+sizeof(ymmword)] vpmuludq ymm2, ymm10, ymmword ptr[r9+sizeof(ymmword)*2] vpaddq ymm2, ymm2, ymmword ptr[rdi+sizeof(ymmword)*2] vpmuludq ymm3, ymm10, ymmword ptr[r9+sizeof(ymmword)*3] vpaddq ymm3, ymm3, ymmword ptr[rdi+sizeof(ymmword)*3] vpmuludq ymm4, ymm10, ymmword ptr[r9+sizeof(ymmword)*4] vpaddq ymm4, ymm4, ymmword ptr[rdi+sizeof(ymmword)*4] vpmuludq ymm5, ymm10, ymmword ptr[r9+sizeof(ymmword)*5] vpaddq ymm5, ymm5, ymmword ptr[rdi+sizeof(ymmword)*5] vpmuludq ymm6, ymm10, ymmword ptr[r9+sizeof(ymmword)*6] vpaddq ymm6, ymm6, ymmword ptr[rdi+sizeof(ymmword)*6] vpmuludq ymm7, ymm10, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm7, ymm7, ymmword ptr[rdi+sizeof(ymmword)*7] vpmuludq ymm8, ymm10, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm8, ymm8, ymmword ptr[rdi+sizeof(ymmword)*8] vpmuludq ymm9, ymm10, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm9, ymm9, ymmword ptr[rdi+sizeof(ymmword)*9] sqr1024_ep: vmovdqu ymmword ptr[rdi], ymm0 vmovdqu ymmword ptr[rdi+sizeof(ymmword)], ymm1 vpmuludq ymm11, ymm14, ymmword ptr[rsi+sizeof(ymmword)] vpbroadcastq ymm10, qword ptr[rax+sizeof(qword)*8] ; ymm10 = {a8:a8:a8:a8} vpaddq ymm2, ymm2, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*2] vpaddq ymm3, ymm3, ymm12 vpmuludq ymm13, ymm14, ymmword ptr[r9+sizeof(ymmword)*3] vpaddq ymm4, ymm4, ymm13 vpmuludq ymm11, ymm14, ymmword ptr[r9+sizeof(ymmword)*4] vpaddq ymm5, ymm5, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*5] vpaddq ymm6, ymm6, ymm12 vpmuludq ymm13, ymm14, ymmword ptr[r9+sizeof(ymmword)*6] vpaddq ymm7, ymm7, ymm13 vpmuludq ymm11, ymm14, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm8, ymm8, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm9, ymm9, ymm12 vpmuludq ymm0, ymm14, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm0, ymm0, ymmword ptr[rbx] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*2], ymm2 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*3], ymm3 vpmuludq ymm11, ymm10, ymmword ptr[rsi+sizeof(ymmword)*2] vpbroadcastq ymm14, qword ptr[rax+sizeof(qword)*12] ; ymm14 = {a12:a12:a12:a12} vpaddq ymm4, ymm4, ymm11 vpmuludq ymm12, ymm10, ymmword ptr[r9+sizeof(ymmword)*3] vpaddq ymm5, ymm5, ymm12 vpmuludq ymm13, ymm10, ymmword ptr[r9+sizeof(ymmword)*4] vpaddq ymm6, ymm6, ymm13 vpmuludq ymm11, ymm10, ymmword ptr[r9+sizeof(ymmword)*5] vpaddq ymm7, ymm7, ymm11 vpmuludq ymm12, ymm10, ymmword ptr[r9+sizeof(ymmword)*6] vpaddq ymm8, ymm8, ymm12 vpmuludq ymm13, ymm10, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm9, ymm9, ymm13 vpmuludq ymm11, ymm10, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm0, ymm0, ymm11 vpmuludq ymm1, ymm10, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm1, ymm1, ymmword ptr[rbx+sizeof(ymmword)] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*4], ymm4 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*5], ymm5 vpmuludq ymm11, ymm14, ymmword ptr[rsi+sizeof(ymmword)*3] vpbroadcastq ymm10, qword ptr[rax+sizeof(qword)*16] ; ymm10 = {a16:a16:a16:a16} vpaddq ymm6, ymm6, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*4] vpaddq ymm7, ymm7, ymm12 vpmuludq ymm13, ymm14, ymmword ptr[r9+sizeof(ymmword)*5] vpaddq ymm8, ymm8, ymm13 vpmuludq ymm11, ymm14, ymmword ptr[r9+sizeof(ymmword)*6] vpaddq ymm9, ymm9, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm0, ymm0, ymm12 vpmuludq ymm13, ymm14, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm1, ymm1, ymm13 vpmuludq ymm2, ymm14, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm2, ymm2, ymmword ptr[rbx+sizeof(ymmword)*2] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*6], ymm6 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*7], ymm7 vpmuludq ymm11, ymm10, ymmword ptr[rsi+sizeof(ymmword)*4] vpbroadcastq ymm14, qword ptr[rax+sizeof(qword)*20] ; ymm14 = {a20:a20:a20:a20} vpaddq ymm8, ymm8, ymm11 vpmuludq ymm12, ymm10, ymmword ptr[r9+sizeof(ymmword)*5] vpaddq ymm9, ymm9, ymm12 vpmuludq ymm13, ymm10, ymmword ptr[r9+sizeof(ymmword)*6] vpaddq ymm0, ymm0, ymm13 vpmuludq ymm11, ymm10, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm1, ymm1, ymm11 vpmuludq ymm12, ymm10, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm2, ymm2, ymm12 vpmuludq ymm3, ymm10, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm3, ymm3, ymmword ptr[rbx+sizeof(ymmword)*3] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*8], ymm8 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*9], ymm9 vpmuludq ymm11, ymm14, ymmword ptr[rsi+sizeof(ymmword)*5] vpbroadcastq ymm10, qword ptr[rax+sizeof(qword)*24] ; ymm10 = {a24:a24:a24:a24} vpaddq ymm0, ymm0, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*6] vpaddq ymm1, ymm1, ymm12 vpmuludq ymm13, ymm14, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm2, ymm2, ymm13 vpmuludq ymm11, ymm14, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm3, ymm3, ymm11 vpmuludq ymm4, ymm14, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm4, ymm4, ymmword ptr[rbx+sizeof(ymmword)*4] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*10], ymm0 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*11], ymm1 vpmuludq ymm11, ymm10, ymmword ptr[rsi+sizeof(ymmword)*6] vpbroadcastq ymm14, qword ptr[rax+sizeof(qword)*28] ; ymm14 = {a28:a28:a28:a28} vpaddq ymm2, ymm2, ymm11 vpmuludq ymm12, ymm10, ymmword ptr[r9+sizeof(ymmword)*7] vpaddq ymm3, ymm3, ymm12 vpmuludq ymm13, ymm10, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm4, ymm4, ymm13 vpmuludq ymm5, ymm10, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm5, ymm5, ymmword ptr[rbx+sizeof(ymmword)*5] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*12], ymm2 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*13], ymm3 vpmuludq ymm11, ymm14, ymmword ptr[rsi+sizeof(ymmword)*7] vpbroadcastq ymm10, qword ptr[rax+sizeof(qword)*32] ; ymm10 = {a32:a32:a32:a32} vpaddq ymm4, ymm4, ymm11 vpmuludq ymm12, ymm14, ymmword ptr[r9+sizeof(ymmword)*8] vpaddq ymm5, ymm5, ymm12 vpmuludq ymm6, ymm14, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm6, ymm6, ymmword ptr[rbx+sizeof(ymmword)*6] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*14], ymm4 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*15], ymm5 vpmuludq ymm11, ymm10, ymmword ptr[rsi+sizeof(ymmword)*8] vpbroadcastq ymm14, qword ptr[rax+sizeof(qword)*36] ; ymm14 = {a36:a36:a36:a36} vpaddq ymm6, ymm6, ymm11 vpmuludq ymm7, ymm10, ymmword ptr[r9+sizeof(ymmword)*9] vpaddq ymm7, ymm7, ymmword ptr[rbx+sizeof(ymmword)*7] vpmuludq ymm8, ymm14, ymmword ptr[rsi+sizeof(ymmword)*9] vpbroadcastq ymm10, qword ptr[rax+sizeof(qword)] ; ymm10 = {a[1/2/3]:a[1/2/3]:a[1/2/3]:a[1/2/3]} vpaddq ymm8, ymm8, ymmword ptr[rbx+sizeof(ymmword)*8] vmovdqu ymmword ptr[rdi+sizeof(ymmword)*16], ymm6 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*17], ymm7 vmovdqu ymmword ptr[rdi+sizeof(ymmword)*18], ymm8 add rdi, sizeof(qword) add rbx, sizeof(qword) add rax, sizeof(qword) sub rcx, 1 jnz sqr1024_loop4 ;; ;; normalization ;; mov rsi, qword ptr[rsp+pAxA] mov rdi, qword ptr[rsp+pResult] mov r9, 38*2 xor rax, rax norm_loop: add rax, qword ptr[rsi] add rsi, sizeof(qword) mov rdx, DIGIT_MASK and rdx, rax shr rax, DIGIT_BITS mov qword ptr[rdi], rdx add rdi, sizeof(qword) sub r9, 1 jg norm_loop mov qword ptr[rdi], rax REST_XMM_AVX REST_GPR ret IPPASM cpSqr1024_avx2 ENDP ;************************************************************* ;* void cpMontRed1024_avx2(Ipp64u* pR, ;* Ipp64u* pProduct, ;* const Ipp64u* pModulus, int mSize, ;* Ipp64u k0) ;************************************************************* ALIGN IPP_ALIGN_FACTOR IPPASM cpMontRed1024_avx2 PROC PUBLIC FRAME USES_GPR rsi,rdi,r12,r13 LOCAL_FRAME = sizeof(qword)*0 USES_XMM_AVX ymm6,ymm7,ymm8,ymm9,ymm10,ymm11,ymm12,ymm13,ymm14 COMP_ABI 5 movsxd r9, ecx ; redLen value counter (length of modulus) mov rcx, rdx ; pointer to modulus vpxor ymm11, ymm11, ymm11 ;; expands M operands vmovdqu ymmword ptr[rdx+r9*sizeof(qword)], ymm11 ;; ;; reduction ;; mov r10, qword ptr[rsi] ; load low part of temporary result mov r11, qword ptr[rsi+sizeof(qword)] ; mov r12, qword ptr[rsi+sizeof(qword)*2] ; mov r13, qword ptr[rsi+sizeof(qword)*3] ; mov rdx, r10 ; y0 = (ac0*k0) & DIGIT_MASK imul edx, r8d and edx, DIGIT_MASK vmovd xmm10, edx vmovdqu ymm1, ymmword ptr[rsi+sizeof(ymmword)*1] ; load other data vmovdqu ymm2, ymmword ptr[rsi+sizeof(ymmword)*2] ; vmovdqu ymm3, ymmword ptr[rsi+sizeof(ymmword)*3] ; vmovdqu ymm4, ymmword ptr[rsi+sizeof(ymmword)*4] ; vmovdqu ymm5, ymmword ptr[rsi+sizeof(ymmword)*5] ; vmovdqu ymm6, ymmword ptr[rsi+sizeof(ymmword)*6] ; mov rax, rdx ; ac0 += pn[0]*y0 imul rax, qword ptr[rcx] add r10, rax vpbroadcastq ymm10, xmm10 vmovdqu ymm7, ymmword ptr[rsi+sizeof(ymmword)*7] ; load other data vmovdqu ymm8, ymmword ptr[rsi+sizeof(ymmword)*8] ; vmovdqu ymm9, ymmword ptr[rsi+sizeof(ymmword)*9] ; mov rax, rdx ; ac1 += pn[1]*y0 imul rax, qword ptr[rcx+sizeof(qword)] add r11, rax mov rax, rdx ; ac2 += pn[2]*y0 imul rax, qword ptr[rcx+sizeof(qword)*2] add r12, rax shr r10, DIGIT_BITS ; updtae ac1 imul rdx, qword ptr[rcx+sizeof(qword)*3] ; ac3 += pn[3]*y0 add r13, rdx add r11, r10 ; updtae ac1 mov rdx, r11 ; y1 = (ac1*k0) & DIGIT_MASK imul edx, r8d and rdx, DIGIT_MASK ALIGN IPP_ALIGN_FACTOR reduction_loop: vmovd xmm11, edx vpbroadcastq ymm11, xmm11 vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)] mov rax, rdx ; ac1 += pn[0]*y1 imul rax, qword ptr[rcx] vpaddq ymm1, ymm1, ymm14 vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*2] vpaddq ymm2, ymm2, ymm14 vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*3] vpaddq ymm3, ymm3, ymm14 vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*4] add r11, rax shr r11, DIGIT_BITS ; update ac2 vpaddq ymm4, ymm4, ymm14 vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*5] mov rax, rdx ; ac2 += pn[1]*y1 imul rax, qword ptr[rcx+sizeof(qword)] vpaddq ymm5, ymm5, ymm14 add r12, rax vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*6] imul rdx, qword ptr[rcx+sizeof(qword)*2] ; ac3 += pn[2]*y1 add r12, r11 vpaddq ymm6, ymm6, ymm14 add r13, rdx vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*7] mov rdx, r12 ; y2 = (ac2*m0) & DIGIT_MASK imul edx, r8d vpaddq ymm7, ymm7, ymm14 vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*8] vpaddq ymm8, ymm8, ymm14 and rdx, DIGIT_MASK vpmuludq ymm14, ymm10, ymmword ptr[rcx+sizeof(ymmword)*9] vpaddq ymm9, ymm9, ymm14 ;; ------------------------------------------------------------ vmovd xmm12, edx vpbroadcastq ymm12, xmm12 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)-sizeof(qword)] mov rax, rdx ; ac2 += pn[0]*y2 imul rax, qword ptr[rcx] vpaddq ymm1, ymm1, ymm14 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*2-sizeof(qword)] vpaddq ymm2, ymm2, ymm14 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*3-sizeof(qword)] vpaddq ymm3, ymm3, ymm14 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*4-sizeof(qword)] vpaddq ymm4, ymm4, ymm14 add rax, r12 shr rax, DIGIT_BITS ; update ac3 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*5-sizeof(qword)] imul rdx, qword ptr[rcx+sizeof(qword)] ; ac3 += pn[1]*y2 vpaddq ymm5, ymm5, ymm14 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*6-sizeof(qword)] vpaddq ymm6, ymm6, ymm14 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*7-sizeof(qword)] vpaddq ymm7, ymm7, ymm14 add rdx, r13 add rdx, rax ; update ac3 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*8-sizeof(qword)] vpaddq ymm8, ymm8, ymm14 vpmuludq ymm14, ymm11, ymmword ptr[rcx+sizeof(ymmword)*9-sizeof(qword)] vpaddq ymm9, ymm9, ymm14 sub r9, 2 jz exit_reduction_loop ;; ------------------------------------------------------------ vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)-sizeof(qword)*2] mov r13, rdx ; y3 = (ac3*m0) & DIGIT_MASK imul edx, r8d vpaddq ymm1, ymm1, ymm14 vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*2-sizeof(qword)*2] vpaddq ymm2, ymm2, ymm14 and rdx, DIGIT_MASK vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*3-sizeof(qword)*2] vmovd xmm13, edx vpaddq ymm3, ymm3, ymm14 vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*4-sizeof(qword)*2] vpbroadcastq ymm13, xmm13 vpaddq ymm4, ymm4, ymm14 vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*5-sizeof(qword)*2] imul rdx, qword ptr[rcx] ; ac3 += pn[0]*y3 vpaddq ymm5, ymm5, ymm14 vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*6-sizeof(qword)*2] vpaddq ymm6, ymm6, ymm14 add r13, rdx vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*7-sizeof(qword)*2] vpaddq ymm7, ymm7, ymm14 shr r13, DIGIT_BITS vmovq xmm0, r13 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)-sizeof(qword)*3] vpaddq ymm1, ymm1, ymm0 vpaddq ymm1, ymm1, ymm14 vmovdqu ymmword ptr[rsi], ymm1 vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*8-sizeof(qword)*2] vpaddq ymm8, ymm8, ymm14 vpmuludq ymm14, ymm12, ymmword ptr[rcx+sizeof(ymmword)*9-sizeof(qword)*2] vpaddq ymm9, ymm9, ymm14 ;; ------------------------------------------------------------ vmovq rdx, xmm1 ; y0 = (ac0*k0) & DIGIT_MASK imul edx, r8d and edx, DIGIT_MASK vmovq r10, xmm1 ; update lowest part of temporary result mov r11, qword ptr[rsi+sizeof(qword)] ; mov r12, qword ptr[rsi+sizeof(qword)*2] ; mov r13, qword ptr[rsi+sizeof(qword)*3] ; vmovd xmm10, edx vpbroadcastq ymm10, xmm10 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*2-sizeof(qword)*3] mov rax, rdx ; ac0 += pn[0]*y0 imul rax, qword ptr[rcx] vpaddq ymm1, ymm2, ymm14 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*3-sizeof(qword)*3] add r10, rax vpaddq ymm2, ymm3, ymm14 shr r10, DIGIT_BITS ; updtae ac1 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*4-sizeof(qword)*3] mov rax, rdx ; ac1 += pn[1]*y0 imul rax, qword ptr[rcx+sizeof(qword)] vpaddq ymm3, ymm4, ymm14 add r11, rax vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*5-sizeof(qword)*3] mov rax, rdx ; ac2 += pn[2]*y0 imul rax, qword ptr[rcx+sizeof(qword)*2] vpaddq ymm4, ymm5, ymm14 add r12, rax vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*6-sizeof(qword)*3] imul rdx, qword ptr[rcx+sizeof(qword)*3] ; ac3 += pn[3]*y0 vpaddq ymm5, ymm6, ymm14 add r13, rdx add r11, r10 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*7-sizeof(qword)*3] mov rdx, r11 ; y1 = (ac1*k0) & DIGIT_MASK imul edx, r8d vpaddq ymm6, ymm7, ymm14 and rdx, DIGIT_MASK vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*8-sizeof(qword)*3] vpaddq ymm7, ymm8, ymm14 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*9-sizeof(qword)*3] vpaddq ymm8, ymm9, ymm14 vpmuludq ymm14, ymm13, ymmword ptr[rcx+sizeof(ymmword)*10-sizeof(qword)*3] vpaddq ymm9, ymm14, ymmword ptr[rsi+sizeof(ymmword)*10] add rsi, sizeof(qword)*4 sub r9, 2 jnz reduction_loop exit_reduction_loop: mov rsi, qword ptr[rsp+pResult] ; restore pointer to result mov qword ptr[rsi], r12 mov qword ptr[rsi+sizeof(qword)], r13 vmovdqu ymmword ptr[rsi+sizeof(ymmword)-sizeof(qword)*2], ymm1 vmovdqu ymmword ptr[rsi+sizeof(ymmword)*2-sizeof(qword)*2], ymm2 vmovdqu ymmword ptr[rsi+sizeof(ymmword)*3-sizeof(qword)*2], ymm3 vmovdqu ymmword ptr[rsi+sizeof(ymmword)*4-sizeof(qword)*2], ymm4 vmovdqu ymmword ptr[rsi+sizeof(ymmword)*5-sizeof(qword)*2], ymm5 vmovdqu ymmword ptr[rsi+sizeof(ymmword)*6-sizeof(qword)*2], ymm6 vmovdqu ymmword ptr[rsi+sizeof(ymmword)*7-sizeof(qword)*2], ymm7 vmovdqu ymmword ptr[rsi+sizeof(ymmword)*8-sizeof(qword)*2], ymm8 vmovdqu ymmword ptr[rsi+sizeof(ymmword)*9-sizeof(qword)*2], ymm9 ;; ;; normalization ;; mov r9, 38 xor rax, rax norm_loop: add rax, qword ptr[rsi] add rsi, sizeof(qword) mov rdx, DIGIT_MASK and rdx, rax shr rax, DIGIT_BITS mov qword ptr[rdi], rdx add rdi, sizeof(qword) sub r9, 1 jg norm_loop mov qword ptr[rdi], rax REST_XMM_AVX REST_GPR ret IPPASM cpMontRed1024_avx2 ENDP ENDIF ; _IPP32E_L9 END
; A214661: Odd numbers by transposing the left half of A176271, triangle read by rows: T(n,k) = A176271(n - 1 + k, k), 1 <= k <= n. ; Submitted by Jamie Morken(s4) ; 1,3,9,7,15,25,13,23,35,49,21,33,47,63,81,31,45,61,79,99,121,43,59,77,97,119,143,169,57,75,95,117,141,167,195,225,73,93,115,139,165,193,223,255,289,91,113,137,163,191,221,253,287,323,361,111,135,161,189,219,251,285,321,359,399,441,133,159,187,217,249,283,319,357,397,439,483,529,157,185,215,247,281,317,355,395,437,481,527,575,625,183,213,245,279,315,353,393,435,479 mov $1,$0 lpb $1 sub $2,1 add $1,$2 lpe sub $2,$1 bin $2,2 add $1,$2 mov $0,$1 mul $0,2 add $0,1
_test: file format elf32-i386 Disassembly of section .text: 00000000 <main>: exit(); } int main(void) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 51 push %ecx e: 83 ec 0c sub $0xc,%esp printf(1, "test\n"); 11: 68 d0 07 00 00 push $0x7d0 16: 6a 01 push $0x1 18: e8 93 04 00 00 call 4b0 <printf> new_fork(100); 1d: c7 04 24 64 00 00 00 movl $0x64,(%esp) 24: e8 47 00 00 00 call 70 <new_fork> exit(); 29: e8 24 03 00 00 call 352 <exit> 2e: 66 90 xchg %ax,%ax 00000030 <lcg_rand>: #define N 10 unsigned long next=1; unsigned int lcg_rand(int b) { 30: 55 push %ebp unsigned long a = ((unsigned long)b * 279470273UL) % 42949671UL; return a < 0 ? -1*a : a; 31: ba 33 01 00 90 mov $0x90000133,%edx #define N 10 unsigned long next=1; unsigned int lcg_rand(int b) { 36: 89 e5 mov %esp,%ebp unsigned long a = ((unsigned long)b * 279470273UL) % 42949671UL; return a < 0 ? -1*a : a; 38: 69 4d 08 c1 60 a8 10 imul $0x10a860c1,0x8(%ebp),%ecx } 3f: 5d pop %ebp unsigned long next=1; unsigned int lcg_rand(int b) { unsigned long a = ((unsigned long)b * 279470273UL) % 42949671UL; return a < 0 ? -1*a : a; 40: 89 c8 mov %ecx,%eax 42: f7 e2 mul %edx 44: 89 c8 mov %ecx,%eax 46: 29 d0 sub %edx,%eax 48: d1 e8 shr %eax 4a: 01 d0 add %edx,%eax 4c: c1 e8 19 shr $0x19,%eax 4f: 69 c0 27 5c 8f 02 imul $0x28f5c27,%eax,%eax 55: 29 c1 sub %eax,%ecx 57: 89 c8 mov %ecx,%eax } 59: c3 ret 5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000060 <wait_>: void wait_(unsigned int seed) { 60: 55 push %ebp 61: 89 e5 mov %esp,%ebp if(seed<=0) return; seed--; wait_(seed); } 63: 5d pop %ebp 64: c3 ret 65: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 69: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000070 <new_fork>: int counter = 0; void new_fork(unsigned int tickets){ if(counter >= N) 70: a1 04 0b 00 00 mov 0xb04,%eax 75: 83 f8 09 cmp $0x9,%eax 78: 7e 02 jle 7c <new_fork+0xc> 7a: f3 c3 repz ret wait_(seed); } int counter = 0; void new_fork(unsigned int tickets){ 7c: 55 push %ebp if(counter >= N) return; counter++; 7d: 83 c0 01 add $0x1,%eax wait_(seed); } int counter = 0; void new_fork(unsigned int tickets){ 80: 89 e5 mov %esp,%ebp 82: 57 push %edi 83: 56 push %esi 84: 53 push %ebx 85: 83 ec 18 sub $0x18,%esp if(counter >= N) return; counter++; 88: a3 04 0b 00 00 mov %eax,0xb04 int pid = fork(1); 8d: 6a 01 push $0x1 8f: e8 b6 02 00 00 call 34a <fork> 94: 89 c7 mov %eax,%edi cht(pid, tickets); 96: 58 pop %eax 97: 5a pop %edx 98: ff 75 08 pushl 0x8(%ebp) 9b: 57 push %edi 9c: e8 59 03 00 00 call 3fa <cht> if(pid == 0){ a1: 83 c4 10 add $0x10,%esp a4: 83 ff 00 cmp $0x0,%edi a7: 74 45 je ee <new_fork+0x7e> a9: be f4 03 00 00 mov $0x3f4,%esi new_fork(tickets+100); } if(pid > 0){ ae: 7e 24 jle d4 <new_fork+0x64> wait_(seed); } int counter = 0; void new_fork(unsigned int tickets){ b0: bb 05 36 00 00 mov $0x3605,%ebx b5: 8d 76 00 lea 0x0(%esi),%esi new_fork(tickets+100); } if(pid > 0){ for(int i = 0; i < 1012; i++){ for(int j = 0; j < 13829; j++){ printf(1, ""); b8: 83 ec 08 sub $0x8,%esp bb: 68 d5 07 00 00 push $0x7d5 c0: 6a 01 push $0x1 c2: e8 e9 03 00 00 call 4b0 <printf> if(pid == 0){ new_fork(tickets+100); } if(pid > 0){ for(int i = 0; i < 1012; i++){ for(int j = 0; j < 13829; j++){ c7: 83 c4 10 add $0x10,%esp ca: 83 eb 01 sub $0x1,%ebx cd: 75 e9 jne b8 <new_fork+0x48> cht(pid, tickets); if(pid == 0){ new_fork(tickets+100); } if(pid > 0){ for(int i = 0; i < 1012; i++){ cf: 83 ee 01 sub $0x1,%esi d2: 75 dc jne b0 <new_fork+0x40> for(int j = 0; j < 13829; j++){ printf(1, ""); } } } printf(1, "Returning Pid >>>> %d with %d tickets\n", pid, tickets); d4: ff 75 08 pushl 0x8(%ebp) d7: 57 push %edi d8: 68 d8 07 00 00 push $0x7d8 dd: 6a 01 push $0x1 df: e8 cc 03 00 00 call 4b0 <printf> wait(); e4: e8 71 02 00 00 call 35a <wait> exit(); e9: e8 64 02 00 00 call 352 <exit> counter++; int pid = fork(1); cht(pid, tickets); if(pid == 0){ new_fork(tickets+100); ee: 8b 45 08 mov 0x8(%ebp),%eax f1: 83 ec 0c sub $0xc,%esp f4: 83 c0 64 add $0x64,%eax f7: 50 push %eax f8: e8 73 ff ff ff call 70 <new_fork> fd: 83 c4 10 add $0x10,%esp 100: eb d2 jmp d4 <new_fork+0x64> 102: 66 90 xchg %ax,%ax 104: 66 90 xchg %ax,%ax 106: 66 90 xchg %ax,%ax 108: 66 90 xchg %ax,%ax 10a: 66 90 xchg %ax,%ax 10c: 66 90 xchg %ax,%ax 10e: 66 90 xchg %ax,%ax 00000110 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 53 push %ebx 114: 8b 45 08 mov 0x8(%ebp),%eax 117: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 11a: 89 c2 mov %eax,%edx 11c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 120: 83 c1 01 add $0x1,%ecx 123: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 127: 83 c2 01 add $0x1,%edx 12a: 84 db test %bl,%bl 12c: 88 5a ff mov %bl,-0x1(%edx) 12f: 75 ef jne 120 <strcpy+0x10> ; return os; } 131: 5b pop %ebx 132: 5d pop %ebp 133: c3 ret 134: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 13a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000140 <strcmp>: int strcmp(const char *p, const char *q) { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 56 push %esi 144: 53 push %ebx 145: 8b 55 08 mov 0x8(%ebp),%edx 148: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 14b: 0f b6 02 movzbl (%edx),%eax 14e: 0f b6 19 movzbl (%ecx),%ebx 151: 84 c0 test %al,%al 153: 75 1e jne 173 <strcmp+0x33> 155: eb 29 jmp 180 <strcmp+0x40> 157: 89 f6 mov %esi,%esi 159: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 160: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 163: 0f b6 02 movzbl (%edx),%eax p++, q++; 166: 8d 71 01 lea 0x1(%ecx),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 169: 0f b6 59 01 movzbl 0x1(%ecx),%ebx 16d: 84 c0 test %al,%al 16f: 74 0f je 180 <strcmp+0x40> 171: 89 f1 mov %esi,%ecx 173: 38 d8 cmp %bl,%al 175: 74 e9 je 160 <strcmp+0x20> p++, q++; return (uchar)*p - (uchar)*q; 177: 29 d8 sub %ebx,%eax } 179: 5b pop %ebx 17a: 5e pop %esi 17b: 5d pop %ebp 17c: c3 ret 17d: 8d 76 00 lea 0x0(%esi),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 180: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; 182: 29 d8 sub %ebx,%eax } 184: 5b pop %ebx 185: 5e pop %esi 186: 5d pop %ebp 187: c3 ret 188: 90 nop 189: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000190 <strlen>: uint strlen(char *s) { 190: 55 push %ebp 191: 89 e5 mov %esp,%ebp 193: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 196: 80 39 00 cmpb $0x0,(%ecx) 199: 74 12 je 1ad <strlen+0x1d> 19b: 31 d2 xor %edx,%edx 19d: 8d 76 00 lea 0x0(%esi),%esi 1a0: 83 c2 01 add $0x1,%edx 1a3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 1a7: 89 d0 mov %edx,%eax 1a9: 75 f5 jne 1a0 <strlen+0x10> ; return n; } 1ab: 5d pop %ebp 1ac: c3 ret uint strlen(char *s) { int n; for(n = 0; s[n]; n++) 1ad: 31 c0 xor %eax,%eax ; return n; } 1af: 5d pop %ebp 1b0: c3 ret 1b1: eb 0d jmp 1c0 <memset> 1b3: 90 nop 1b4: 90 nop 1b5: 90 nop 1b6: 90 nop 1b7: 90 nop 1b8: 90 nop 1b9: 90 nop 1ba: 90 nop 1bb: 90 nop 1bc: 90 nop 1bd: 90 nop 1be: 90 nop 1bf: 90 nop 000001c0 <memset>: void* memset(void *dst, int c, uint n) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 57 push %edi 1c4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 1c7: 8b 4d 10 mov 0x10(%ebp),%ecx 1ca: 8b 45 0c mov 0xc(%ebp),%eax 1cd: 89 d7 mov %edx,%edi 1cf: fc cld 1d0: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 1d2: 89 d0 mov %edx,%eax 1d4: 5f pop %edi 1d5: 5d pop %ebp 1d6: c3 ret 1d7: 89 f6 mov %esi,%esi 1d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001e0 <strchr>: char* strchr(const char *s, char c) { 1e0: 55 push %ebp 1e1: 89 e5 mov %esp,%ebp 1e3: 53 push %ebx 1e4: 8b 45 08 mov 0x8(%ebp),%eax 1e7: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 1ea: 0f b6 10 movzbl (%eax),%edx 1ed: 84 d2 test %dl,%dl 1ef: 74 1d je 20e <strchr+0x2e> if(*s == c) 1f1: 38 d3 cmp %dl,%bl 1f3: 89 d9 mov %ebx,%ecx 1f5: 75 0d jne 204 <strchr+0x24> 1f7: eb 17 jmp 210 <strchr+0x30> 1f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 200: 38 ca cmp %cl,%dl 202: 74 0c je 210 <strchr+0x30> } char* strchr(const char *s, char c) { for(; *s; s++) 204: 83 c0 01 add $0x1,%eax 207: 0f b6 10 movzbl (%eax),%edx 20a: 84 d2 test %dl,%dl 20c: 75 f2 jne 200 <strchr+0x20> if(*s == c) return (char*)s; return 0; 20e: 31 c0 xor %eax,%eax } 210: 5b pop %ebx 211: 5d pop %ebp 212: c3 ret 213: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000220 <gets>: char* gets(char *buf, int max) { 220: 55 push %ebp 221: 89 e5 mov %esp,%ebp 223: 57 push %edi 224: 56 push %esi 225: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 226: 31 f6 xor %esi,%esi cc = read(0, &c, 1); 228: 8d 7d e7 lea -0x19(%ebp),%edi return 0; } char* gets(char *buf, int max) { 22b: 83 ec 1c sub $0x1c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 22e: eb 29 jmp 259 <gets+0x39> cc = read(0, &c, 1); 230: 83 ec 04 sub $0x4,%esp 233: 6a 01 push $0x1 235: 57 push %edi 236: 6a 00 push $0x0 238: e8 2d 01 00 00 call 36a <read> if(cc < 1) 23d: 83 c4 10 add $0x10,%esp 240: 85 c0 test %eax,%eax 242: 7e 1d jle 261 <gets+0x41> break; buf[i++] = c; 244: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 248: 8b 55 08 mov 0x8(%ebp),%edx 24b: 89 de mov %ebx,%esi if(c == '\n' || c == '\r') 24d: 3c 0a cmp $0xa,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 24f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 253: 74 1b je 270 <gets+0x50> 255: 3c 0d cmp $0xd,%al 257: 74 17 je 270 <gets+0x50> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 259: 8d 5e 01 lea 0x1(%esi),%ebx 25c: 3b 5d 0c cmp 0xc(%ebp),%ebx 25f: 7c cf jl 230 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 261: 8b 45 08 mov 0x8(%ebp),%eax 264: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 268: 8d 65 f4 lea -0xc(%ebp),%esp 26b: 5b pop %ebx 26c: 5e pop %esi 26d: 5f pop %edi 26e: 5d pop %ebp 26f: c3 ret break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 270: 8b 45 08 mov 0x8(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 273: 89 de mov %ebx,%esi break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 275: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 279: 8d 65 f4 lea -0xc(%ebp),%esp 27c: 5b pop %ebx 27d: 5e pop %esi 27e: 5f pop %edi 27f: 5d pop %ebp 280: c3 ret 281: eb 0d jmp 290 <stat> 283: 90 nop 284: 90 nop 285: 90 nop 286: 90 nop 287: 90 nop 288: 90 nop 289: 90 nop 28a: 90 nop 28b: 90 nop 28c: 90 nop 28d: 90 nop 28e: 90 nop 28f: 90 nop 00000290 <stat>: int stat(char *n, struct stat *st) { 290: 55 push %ebp 291: 89 e5 mov %esp,%ebp 293: 56 push %esi 294: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 295: 83 ec 08 sub $0x8,%esp 298: 6a 00 push $0x0 29a: ff 75 08 pushl 0x8(%ebp) 29d: e8 f0 00 00 00 call 392 <open> if(fd < 0) 2a2: 83 c4 10 add $0x10,%esp 2a5: 85 c0 test %eax,%eax 2a7: 78 27 js 2d0 <stat+0x40> return -1; r = fstat(fd, st); 2a9: 83 ec 08 sub $0x8,%esp 2ac: ff 75 0c pushl 0xc(%ebp) 2af: 89 c3 mov %eax,%ebx 2b1: 50 push %eax 2b2: e8 f3 00 00 00 call 3aa <fstat> 2b7: 89 c6 mov %eax,%esi close(fd); 2b9: 89 1c 24 mov %ebx,(%esp) 2bc: e8 b9 00 00 00 call 37a <close> return r; 2c1: 83 c4 10 add $0x10,%esp 2c4: 89 f0 mov %esi,%eax } 2c6: 8d 65 f8 lea -0x8(%ebp),%esp 2c9: 5b pop %ebx 2ca: 5e pop %esi 2cb: 5d pop %ebp 2cc: c3 ret 2cd: 8d 76 00 lea 0x0(%esi),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 2d0: b8 ff ff ff ff mov $0xffffffff,%eax 2d5: eb ef jmp 2c6 <stat+0x36> 2d7: 89 f6 mov %esi,%esi 2d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002e0 <atoi>: return r; } int atoi(const char *s) { 2e0: 55 push %ebp 2e1: 89 e5 mov %esp,%ebp 2e3: 53 push %ebx 2e4: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 2e7: 0f be 11 movsbl (%ecx),%edx 2ea: 8d 42 d0 lea -0x30(%edx),%eax 2ed: 3c 09 cmp $0x9,%al 2ef: b8 00 00 00 00 mov $0x0,%eax 2f4: 77 1f ja 315 <atoi+0x35> 2f6: 8d 76 00 lea 0x0(%esi),%esi 2f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 300: 8d 04 80 lea (%eax,%eax,4),%eax 303: 83 c1 01 add $0x1,%ecx 306: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 30a: 0f be 11 movsbl (%ecx),%edx 30d: 8d 5a d0 lea -0x30(%edx),%ebx 310: 80 fb 09 cmp $0x9,%bl 313: 76 eb jbe 300 <atoi+0x20> n = n*10 + *s++ - '0'; return n; } 315: 5b pop %ebx 316: 5d pop %ebp 317: c3 ret 318: 90 nop 319: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000320 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 320: 55 push %ebp 321: 89 e5 mov %esp,%ebp 323: 56 push %esi 324: 53 push %ebx 325: 8b 5d 10 mov 0x10(%ebp),%ebx 328: 8b 45 08 mov 0x8(%ebp),%eax 32b: 8b 75 0c mov 0xc(%ebp),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 32e: 85 db test %ebx,%ebx 330: 7e 14 jle 346 <memmove+0x26> 332: 31 d2 xor %edx,%edx 334: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 338: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 33c: 88 0c 10 mov %cl,(%eax,%edx,1) 33f: 83 c2 01 add $0x1,%edx { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 342: 39 da cmp %ebx,%edx 344: 75 f2 jne 338 <memmove+0x18> *dst++ = *src++; return vdst; } 346: 5b pop %ebx 347: 5e pop %esi 348: 5d pop %ebp 349: c3 ret 0000034a <fork>: 34a: b8 01 00 00 00 mov $0x1,%eax 34f: cd 40 int $0x40 351: c3 ret 00000352 <exit>: 352: b8 02 00 00 00 mov $0x2,%eax 357: cd 40 int $0x40 359: c3 ret 0000035a <wait>: 35a: b8 03 00 00 00 mov $0x3,%eax 35f: cd 40 int $0x40 361: c3 ret 00000362 <pipe>: 362: b8 04 00 00 00 mov $0x4,%eax 367: cd 40 int $0x40 369: c3 ret 0000036a <read>: 36a: b8 05 00 00 00 mov $0x5,%eax 36f: cd 40 int $0x40 371: c3 ret 00000372 <write>: 372: b8 10 00 00 00 mov $0x10,%eax 377: cd 40 int $0x40 379: c3 ret 0000037a <close>: 37a: b8 15 00 00 00 mov $0x15,%eax 37f: cd 40 int $0x40 381: c3 ret 00000382 <kill>: 382: b8 06 00 00 00 mov $0x6,%eax 387: cd 40 int $0x40 389: c3 ret 0000038a <exec>: 38a: b8 07 00 00 00 mov $0x7,%eax 38f: cd 40 int $0x40 391: c3 ret 00000392 <open>: 392: b8 0f 00 00 00 mov $0xf,%eax 397: cd 40 int $0x40 399: c3 ret 0000039a <mknod>: 39a: b8 11 00 00 00 mov $0x11,%eax 39f: cd 40 int $0x40 3a1: c3 ret 000003a2 <unlink>: 3a2: b8 12 00 00 00 mov $0x12,%eax 3a7: cd 40 int $0x40 3a9: c3 ret 000003aa <fstat>: 3aa: b8 08 00 00 00 mov $0x8,%eax 3af: cd 40 int $0x40 3b1: c3 ret 000003b2 <link>: 3b2: b8 13 00 00 00 mov $0x13,%eax 3b7: cd 40 int $0x40 3b9: c3 ret 000003ba <mkdir>: 3ba: b8 14 00 00 00 mov $0x14,%eax 3bf: cd 40 int $0x40 3c1: c3 ret 000003c2 <chdir>: 3c2: b8 09 00 00 00 mov $0x9,%eax 3c7: cd 40 int $0x40 3c9: c3 ret 000003ca <dup>: 3ca: b8 0a 00 00 00 mov $0xa,%eax 3cf: cd 40 int $0x40 3d1: c3 ret 000003d2 <getpid>: 3d2: b8 0b 00 00 00 mov $0xb,%eax 3d7: cd 40 int $0x40 3d9: c3 ret 000003da <sbrk>: 3da: b8 0c 00 00 00 mov $0xc,%eax 3df: cd 40 int $0x40 3e1: c3 ret 000003e2 <sleep>: 3e2: b8 0d 00 00 00 mov $0xd,%eax 3e7: cd 40 int $0x40 3e9: c3 ret 000003ea <uptime>: 3ea: b8 0e 00 00 00 mov $0xe,%eax 3ef: cd 40 int $0x40 3f1: c3 ret 000003f2 <cps>: 3f2: b8 16 00 00 00 mov $0x16,%eax 3f7: cd 40 int $0x40 3f9: c3 ret 000003fa <cht>: 3fa: b8 17 00 00 00 mov $0x17,%eax 3ff: cd 40 int $0x40 401: c3 ret 402: 66 90 xchg %ax,%ax 404: 66 90 xchg %ax,%ax 406: 66 90 xchg %ax,%ax 408: 66 90 xchg %ax,%ax 40a: 66 90 xchg %ax,%ax 40c: 66 90 xchg %ax,%ax 40e: 66 90 xchg %ax,%ax 00000410 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 410: 55 push %ebp 411: 89 e5 mov %esp,%ebp 413: 57 push %edi 414: 56 push %esi 415: 53 push %ebx 416: 89 c6 mov %eax,%esi 418: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 41b: 8b 5d 08 mov 0x8(%ebp),%ebx 41e: 85 db test %ebx,%ebx 420: 74 7e je 4a0 <printint+0x90> 422: 89 d0 mov %edx,%eax 424: c1 e8 1f shr $0x1f,%eax 427: 84 c0 test %al,%al 429: 74 75 je 4a0 <printint+0x90> neg = 1; x = -xx; 42b: 89 d0 mov %edx,%eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 42d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) x = -xx; 434: f7 d8 neg %eax 436: 89 75 c0 mov %esi,-0x40(%ebp) } else { x = xx; } i = 0; 439: 31 ff xor %edi,%edi 43b: 8d 5d d7 lea -0x29(%ebp),%ebx 43e: 89 ce mov %ecx,%esi 440: eb 08 jmp 44a <printint+0x3a> 442: 8d b6 00 00 00 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 448: 89 cf mov %ecx,%edi 44a: 31 d2 xor %edx,%edx 44c: 8d 4f 01 lea 0x1(%edi),%ecx 44f: f7 f6 div %esi 451: 0f b6 92 08 08 00 00 movzbl 0x808(%edx),%edx }while((x /= base) != 0); 458: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 45a: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 45d: 75 e9 jne 448 <printint+0x38> if(neg) 45f: 8b 45 c4 mov -0x3c(%ebp),%eax 462: 8b 75 c0 mov -0x40(%ebp),%esi 465: 85 c0 test %eax,%eax 467: 74 08 je 471 <printint+0x61> buf[i++] = '-'; 469: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1) 46e: 8d 4f 02 lea 0x2(%edi),%ecx 471: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi 475: 8d 76 00 lea 0x0(%esi),%esi 478: 0f b6 07 movzbl (%edi),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 47b: 83 ec 04 sub $0x4,%esp 47e: 83 ef 01 sub $0x1,%edi 481: 6a 01 push $0x1 483: 53 push %ebx 484: 56 push %esi 485: 88 45 d7 mov %al,-0x29(%ebp) 488: e8 e5 fe ff ff call 372 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 48d: 83 c4 10 add $0x10,%esp 490: 39 df cmp %ebx,%edi 492: 75 e4 jne 478 <printint+0x68> putc(fd, buf[i]); } 494: 8d 65 f4 lea -0xc(%ebp),%esp 497: 5b pop %ebx 498: 5e pop %esi 499: 5f pop %edi 49a: 5d pop %ebp 49b: c3 ret 49c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; } else { x = xx; 4a0: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 4a2: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 4a9: eb 8b jmp 436 <printint+0x26> 4ab: 90 nop 4ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000004b0 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 4b0: 55 push %ebp 4b1: 89 e5 mov %esp,%ebp 4b3: 57 push %edi 4b4: 56 push %esi 4b5: 53 push %ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4b6: 8d 45 10 lea 0x10(%ebp),%eax } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 4b9: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4bc: 8b 75 0c mov 0xc(%ebp),%esi } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 4bf: 8b 7d 08 mov 0x8(%ebp),%edi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4c2: 89 45 d0 mov %eax,-0x30(%ebp) 4c5: 0f b6 1e movzbl (%esi),%ebx 4c8: 83 c6 01 add $0x1,%esi 4cb: 84 db test %bl,%bl 4cd: 0f 84 b0 00 00 00 je 583 <printf+0xd3> 4d3: 31 d2 xor %edx,%edx 4d5: eb 39 jmp 510 <printf+0x60> 4d7: 89 f6 mov %esi,%esi 4d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 4e0: 83 f8 25 cmp $0x25,%eax 4e3: 89 55 d4 mov %edx,-0x2c(%ebp) state = '%'; 4e6: ba 25 00 00 00 mov $0x25,%edx state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 4eb: 74 18 je 505 <printf+0x55> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4ed: 8d 45 e2 lea -0x1e(%ebp),%eax 4f0: 83 ec 04 sub $0x4,%esp 4f3: 88 5d e2 mov %bl,-0x1e(%ebp) 4f6: 6a 01 push $0x1 4f8: 50 push %eax 4f9: 57 push %edi 4fa: e8 73 fe ff ff call 372 <write> 4ff: 8b 55 d4 mov -0x2c(%ebp),%edx 502: 83 c4 10 add $0x10,%esp 505: 83 c6 01 add $0x1,%esi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 508: 0f b6 5e ff movzbl -0x1(%esi),%ebx 50c: 84 db test %bl,%bl 50e: 74 73 je 583 <printf+0xd3> c = fmt[i] & 0xff; if(state == 0){ 510: 85 d2 test %edx,%edx uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 512: 0f be cb movsbl %bl,%ecx 515: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 518: 74 c6 je 4e0 <printf+0x30> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 51a: 83 fa 25 cmp $0x25,%edx 51d: 75 e6 jne 505 <printf+0x55> if(c == 'd'){ 51f: 83 f8 64 cmp $0x64,%eax 522: 0f 84 f8 00 00 00 je 620 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 528: 81 e1 f7 00 00 00 and $0xf7,%ecx 52e: 83 f9 70 cmp $0x70,%ecx 531: 74 5d je 590 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 533: 83 f8 73 cmp $0x73,%eax 536: 0f 84 84 00 00 00 je 5c0 <printf+0x110> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 53c: 83 f8 63 cmp $0x63,%eax 53f: 0f 84 ea 00 00 00 je 62f <printf+0x17f> putc(fd, *ap); ap++; } else if(c == '%'){ 545: 83 f8 25 cmp $0x25,%eax 548: 0f 84 c2 00 00 00 je 610 <printf+0x160> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 54e: 8d 45 e7 lea -0x19(%ebp),%eax 551: 83 ec 04 sub $0x4,%esp 554: c6 45 e7 25 movb $0x25,-0x19(%ebp) 558: 6a 01 push $0x1 55a: 50 push %eax 55b: 57 push %edi 55c: e8 11 fe ff ff call 372 <write> 561: 83 c4 0c add $0xc,%esp 564: 8d 45 e6 lea -0x1a(%ebp),%eax 567: 88 5d e6 mov %bl,-0x1a(%ebp) 56a: 6a 01 push $0x1 56c: 50 push %eax 56d: 57 push %edi 56e: 83 c6 01 add $0x1,%esi 571: e8 fc fd ff ff call 372 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 576: 0f b6 5e ff movzbl -0x1(%esi),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 57a: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 57d: 31 d2 xor %edx,%edx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 57f: 84 db test %bl,%bl 581: 75 8d jne 510 <printf+0x60> putc(fd, c); } state = 0; } } } 583: 8d 65 f4 lea -0xc(%ebp),%esp 586: 5b pop %ebx 587: 5e pop %esi 588: 5f pop %edi 589: 5d pop %ebp 58a: c3 ret 58b: 90 nop 58c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 590: 83 ec 0c sub $0xc,%esp 593: b9 10 00 00 00 mov $0x10,%ecx 598: 6a 00 push $0x0 59a: 8b 5d d0 mov -0x30(%ebp),%ebx 59d: 89 f8 mov %edi,%eax 59f: 8b 13 mov (%ebx),%edx 5a1: e8 6a fe ff ff call 410 <printint> ap++; 5a6: 89 d8 mov %ebx,%eax 5a8: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 5ab: 31 d2 xor %edx,%edx if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; 5ad: 83 c0 04 add $0x4,%eax 5b0: 89 45 d0 mov %eax,-0x30(%ebp) 5b3: e9 4d ff ff ff jmp 505 <printf+0x55> 5b8: 90 nop 5b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 5c0: 8b 45 d0 mov -0x30(%ebp),%eax 5c3: 8b 18 mov (%eax),%ebx ap++; 5c5: 83 c0 04 add $0x4,%eax 5c8: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) s = "(null)"; 5cb: b8 00 08 00 00 mov $0x800,%eax 5d0: 85 db test %ebx,%ebx 5d2: 0f 44 d8 cmove %eax,%ebx while(*s != 0){ 5d5: 0f b6 03 movzbl (%ebx),%eax 5d8: 84 c0 test %al,%al 5da: 74 23 je 5ff <printf+0x14f> 5dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 5e0: 88 45 e3 mov %al,-0x1d(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5e3: 8d 45 e3 lea -0x1d(%ebp),%eax 5e6: 83 ec 04 sub $0x4,%esp 5e9: 6a 01 push $0x1 ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 5eb: 83 c3 01 add $0x1,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5ee: 50 push %eax 5ef: 57 push %edi 5f0: e8 7d fd ff ff call 372 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 5f5: 0f b6 03 movzbl (%ebx),%eax 5f8: 83 c4 10 add $0x10,%esp 5fb: 84 c0 test %al,%al 5fd: 75 e1 jne 5e0 <printf+0x130> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 5ff: 31 d2 xor %edx,%edx 601: e9 ff fe ff ff jmp 505 <printf+0x55> 606: 8d 76 00 lea 0x0(%esi),%esi 609: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 610: 83 ec 04 sub $0x4,%esp 613: 88 5d e5 mov %bl,-0x1b(%ebp) 616: 8d 45 e5 lea -0x1b(%ebp),%eax 619: 6a 01 push $0x1 61b: e9 4c ff ff ff jmp 56c <printf+0xbc> } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 620: 83 ec 0c sub $0xc,%esp 623: b9 0a 00 00 00 mov $0xa,%ecx 628: 6a 01 push $0x1 62a: e9 6b ff ff ff jmp 59a <printf+0xea> 62f: 8b 5d d0 mov -0x30(%ebp),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 632: 83 ec 04 sub $0x4,%esp 635: 8b 03 mov (%ebx),%eax 637: 6a 01 push $0x1 639: 88 45 e4 mov %al,-0x1c(%ebp) 63c: 8d 45 e4 lea -0x1c(%ebp),%eax 63f: 50 push %eax 640: 57 push %edi 641: e8 2c fd ff ff call 372 <write> 646: e9 5b ff ff ff jmp 5a6 <printf+0xf6> 64b: 66 90 xchg %ax,%ax 64d: 66 90 xchg %ax,%ax 64f: 90 nop 00000650 <free>: static Header base; static Header *freep; void free(void *ap) { 650: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 651: a1 08 0b 00 00 mov 0xb08,%eax static Header base; static Header *freep; void free(void *ap) { 656: 89 e5 mov %esp,%ebp 658: 57 push %edi 659: 56 push %esi 65a: 53 push %ebx 65b: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 65e: 8b 10 mov (%eax),%edx void free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; 660: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 663: 39 c8 cmp %ecx,%eax 665: 73 19 jae 680 <free+0x30> 667: 89 f6 mov %esi,%esi 669: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 670: 39 d1 cmp %edx,%ecx 672: 72 1c jb 690 <free+0x40> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 674: 39 d0 cmp %edx,%eax 676: 73 18 jae 690 <free+0x40> static Header base; static Header *freep; void free(void *ap) { 678: 89 d0 mov %edx,%eax Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 67a: 39 c8 cmp %ecx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 67c: 8b 10 mov (%eax),%edx free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 67e: 72 f0 jb 670 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 680: 39 d0 cmp %edx,%eax 682: 72 f4 jb 678 <free+0x28> 684: 39 d1 cmp %edx,%ecx 686: 73 f0 jae 678 <free+0x28> 688: 90 nop 689: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi break; if(bp + bp->s.size == p->s.ptr){ 690: 8b 73 fc mov -0x4(%ebx),%esi 693: 8d 3c f1 lea (%ecx,%esi,8),%edi 696: 39 d7 cmp %edx,%edi 698: 74 19 je 6b3 <free+0x63> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 69a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 69d: 8b 50 04 mov 0x4(%eax),%edx 6a0: 8d 34 d0 lea (%eax,%edx,8),%esi 6a3: 39 f1 cmp %esi,%ecx 6a5: 74 23 je 6ca <free+0x7a> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 6a7: 89 08 mov %ecx,(%eax) freep = p; 6a9: a3 08 0b 00 00 mov %eax,0xb08 } 6ae: 5b pop %ebx 6af: 5e pop %esi 6b0: 5f pop %edi 6b1: 5d pop %ebp 6b2: c3 ret bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 6b3: 03 72 04 add 0x4(%edx),%esi 6b6: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 6b9: 8b 10 mov (%eax),%edx 6bb: 8b 12 mov (%edx),%edx 6bd: 89 53 f8 mov %edx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 6c0: 8b 50 04 mov 0x4(%eax),%edx 6c3: 8d 34 d0 lea (%eax,%edx,8),%esi 6c6: 39 f1 cmp %esi,%ecx 6c8: 75 dd jne 6a7 <free+0x57> p->s.size += bp->s.size; 6ca: 03 53 fc add -0x4(%ebx),%edx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 6cd: a3 08 0b 00 00 mov %eax,0xb08 bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 6d2: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 6d5: 8b 53 f8 mov -0x8(%ebx),%edx 6d8: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 6da: 5b pop %ebx 6db: 5e pop %esi 6dc: 5f pop %edi 6dd: 5d pop %ebp 6de: c3 ret 6df: 90 nop 000006e0 <malloc>: return freep; } void* malloc(uint nbytes) { 6e0: 55 push %ebp 6e1: 89 e5 mov %esp,%ebp 6e3: 57 push %edi 6e4: 56 push %esi 6e5: 53 push %ebx 6e6: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6e9: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 6ec: 8b 15 08 0b 00 00 mov 0xb08,%edx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6f2: 8d 78 07 lea 0x7(%eax),%edi 6f5: c1 ef 03 shr $0x3,%edi 6f8: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 6fb: 85 d2 test %edx,%edx 6fd: 0f 84 a3 00 00 00 je 7a6 <malloc+0xc6> 703: 8b 02 mov (%edx),%eax 705: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 708: 39 cf cmp %ecx,%edi 70a: 76 74 jbe 780 <malloc+0xa0> 70c: 81 ff 00 10 00 00 cmp $0x1000,%edi 712: be 00 10 00 00 mov $0x1000,%esi 717: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx 71e: 0f 43 f7 cmovae %edi,%esi 721: ba 00 80 00 00 mov $0x8000,%edx 726: 81 ff ff 0f 00 00 cmp $0xfff,%edi 72c: 0f 46 da cmovbe %edx,%ebx 72f: eb 10 jmp 741 <malloc+0x61> 731: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 738: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 73a: 8b 48 04 mov 0x4(%eax),%ecx 73d: 39 cf cmp %ecx,%edi 73f: 76 3f jbe 780 <malloc+0xa0> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 741: 39 05 08 0b 00 00 cmp %eax,0xb08 747: 89 c2 mov %eax,%edx 749: 75 ed jne 738 <malloc+0x58> char *p; Header *hp; if(nu < 4096) nu = 4096; p = sbrk(nu * sizeof(Header)); 74b: 83 ec 0c sub $0xc,%esp 74e: 53 push %ebx 74f: e8 86 fc ff ff call 3da <sbrk> if(p == (char*)-1) 754: 83 c4 10 add $0x10,%esp 757: 83 f8 ff cmp $0xffffffff,%eax 75a: 74 1c je 778 <malloc+0x98> return 0; hp = (Header*)p; hp->s.size = nu; 75c: 89 70 04 mov %esi,0x4(%eax) free((void*)(hp + 1)); 75f: 83 ec 0c sub $0xc,%esp 762: 83 c0 08 add $0x8,%eax 765: 50 push %eax 766: e8 e5 fe ff ff call 650 <free> return freep; 76b: 8b 15 08 0b 00 00 mov 0xb08,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 771: 83 c4 10 add $0x10,%esp 774: 85 d2 test %edx,%edx 776: 75 c0 jne 738 <malloc+0x58> return 0; 778: 31 c0 xor %eax,%eax 77a: eb 1c jmp 798 <malloc+0xb8> 77c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) 780: 39 cf cmp %ecx,%edi 782: 74 1c je 7a0 <malloc+0xc0> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 784: 29 f9 sub %edi,%ecx 786: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 789: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 78c: 89 78 04 mov %edi,0x4(%eax) } freep = prevp; 78f: 89 15 08 0b 00 00 mov %edx,0xb08 return (void*)(p + 1); 795: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 798: 8d 65 f4 lea -0xc(%ebp),%esp 79b: 5b pop %ebx 79c: 5e pop %esi 79d: 5f pop %edi 79e: 5d pop %ebp 79f: c3 ret base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 7a0: 8b 08 mov (%eax),%ecx 7a2: 89 0a mov %ecx,(%edx) 7a4: eb e9 jmp 78f <malloc+0xaf> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 7a6: c7 05 08 0b 00 00 0c movl $0xb0c,0xb08 7ad: 0b 00 00 7b0: c7 05 0c 0b 00 00 0c movl $0xb0c,0xb0c 7b7: 0b 00 00 base.s.size = 0; 7ba: b8 0c 0b 00 00 mov $0xb0c,%eax 7bf: c7 05 10 0b 00 00 00 movl $0x0,0xb10 7c6: 00 00 00 7c9: e9 3e ff ff ff jmp 70c <malloc+0x2c>
// // Copyright 2016 Pixar // // Licensed under the Apache License, Version 2.0 (the "Apache License") // with the following modification; you may not use this file except in // compliance with the Apache License and the following modification to it: // Section 6. Trademarks. is deleted and replaced with: // // 6. Trademarks. This License does not grant permission to use the trade // names, trademarks, service marks, or product names of the Licensor // and its affiliates, except as required to comply with Section 4(c) of // the License and to reproduce the content of the NOTICE file. // // You may obtain a copy of the Apache License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the Apache License with the above modification is // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the Apache License for the specific // language governing permissions and limitations under the Apache License. // //////////////////////////////////////////////////////////////////////// // This file is generated by a script. Do not edit directly. Edit the // wrapMatrix3.template.cpp file to make changes. #include "pxr/pxr.h" #include "pxr/base/gf/matrix3d.h" #include "pxr/base/gf/matrix3f.h" #include "pxr/base/gf/pyBufferUtils.h" #include "pxr/base/gf/quatf.h" #include "pxr/base/gf/rotation.h" #include "pxr/base/tf/py3Compat.h" #include "pxr/base/tf/pyUtils.h" #include "pxr/base/tf/pyContainerConversions.h" #include "pxr/base/tf/wrapTypeHelpers.h" #include <boost/python/class.hpp> #include <boost/python/def.hpp> #include <boost/python/detail/api_placeholder.hpp> #include <boost/python/errors.hpp> #include <boost/python/extract.hpp> #include <boost/python/make_constructor.hpp> #include <boost/python/operators.hpp> #include <boost/python/return_arg.hpp> #include <boost/python/tuple.hpp> #include <string> #include <vector> using namespace boost::python; using std::string; using std::vector; PXR_NAMESPACE_USING_DIRECTIVE namespace { //////////////////////////////////////////////////////////////////////// // Python buffer protocol support. #if PY_MAJOR_VERSION == 2 // Python's getreadbuf interface function. static Py_ssize_t getreadbuf(PyObject *self, Py_ssize_t segment, void **ptrptr) { if (segment != 0) { // Always one-segment. PyErr_SetString(PyExc_ValueError, "accessed non-existent segment"); return -1; } GfMatrix3f &mat = extract<GfMatrix3f &>(self); *ptrptr = static_cast<void *>(mat.GetArray()); // Return size in bytes. return sizeof(GfMatrix3f); } // Python's getwritebuf interface function. static Py_ssize_t getwritebuf(PyObject *self, Py_ssize_t segment, void **ptrptr) { PyErr_SetString(PyExc_ValueError, "writable buffers supported only with " "new-style buffer protocol."); return -1; } // Python's getsegcount interface function. static Py_ssize_t getsegcount(PyObject *self, Py_ssize_t *lenp) { if (lenp) *lenp = sizeof(GfMatrix3f); return 1; // Always one contiguous segment. } // Python's getcharbuf interface function. static Py_ssize_t getcharbuf(PyObject *self, Py_ssize_t segment, const char **ptrptr) { return getreadbuf(self, segment, (void **) ptrptr); } #endif // Python's getbuffer interface function. static int getbuffer(PyObject *self, Py_buffer *view, int flags) { if (view == NULL) { PyErr_SetString(PyExc_ValueError, "NULL view in getbuffer"); return -1; } // We don't support fortran order. if ((flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) { PyErr_SetString(PyExc_ValueError, "Fortran contiguity unsupported"); return -1; } GfMatrix3f &mat = extract<GfMatrix3f &>(self); view->obj = self; view->buf = static_cast<void *>(mat.GetArray()); view->len = sizeof(GfMatrix3f); view->readonly = 0; view->itemsize = sizeof(float); if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view->format = Gf_GetPyBufferFmtFor<float>(); } else { view->format = NULL; } if ((flags & PyBUF_ND) == PyBUF_ND) { view->ndim = 2; static Py_ssize_t shape[] = { 3, 3 }; view->shape = shape; } else { view->ndim = 0; view->shape = NULL; } if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { static Py_ssize_t strides[] = { 3 * sizeof(float), sizeof(float) }; view->strides = strides; } else { view->strides = NULL; } view->suboffsets = NULL; view->internal = NULL; Py_INCREF(self); // need to retain a reference to self. return 0; } // This structure serves to instantiate a PyBufferProcs instance with pointers // to the right buffer protocol functions. static PyBufferProcs bufferProcs = { #if PY_MAJOR_VERSION == 2 (readbufferproc) getreadbuf, /*bf_getreadbuffer*/ (writebufferproc) getwritebuf, /*bf_getwritebuffer*/ (segcountproc) getsegcount, /*bf_getsegcount*/ (charbufferproc) getcharbuf, /*bf_getcharbuffer*/ #endif (getbufferproc) getbuffer, (releasebufferproc) 0, }; // End python buffer protocol support. //////////////////////////////////////////////////////////////////////// static string _Repr(GfMatrix3f const &self) { static char newline[] = ",\n "; return TF_PY_REPR_PREFIX + "Matrix3f(" + TfPyRepr(self[0][0]) + ", " + TfPyRepr(self[0][1]) + ", " + TfPyRepr(self[0][2]) + newline + TfPyRepr(self[1][0]) + ", " + TfPyRepr(self[1][1]) + ", " + TfPyRepr(self[1][2]) + newline + TfPyRepr(self[2][0]) + ", " + TfPyRepr(self[2][1]) + ", " + TfPyRepr(self[2][2]) + ")"; } static GfMatrix3f GetInverseWrapper( const GfMatrix3f &self ) { return self.GetInverse(); } static void throwIndexErr( const char *msg ) { PyErr_SetString(PyExc_IndexError, msg); boost::python::throw_error_already_set(); } static int normalizeIndex(int index) { return TfPyNormalizeIndex(index, 3, true /*throw error*/); } // Return number of rows static int __len__(GfMatrix3f const &self) { return 3; } static float __getitem__float(GfMatrix3f const &self, tuple index) { int i1=0, i2=0; if (len(index) == 2) { i1 = normalizeIndex(extract<int>(index[0])); i2 = normalizeIndex(extract<int>(index[1])); } else throwIndexErr("Index has incorrect size."); return self[i1][i2]; } static GfVec3f __getitem__vector(GfMatrix3f const &self, int index) { return GfVec3f(self[normalizeIndex(index)]); } static void __setitem__float(GfMatrix3f &self, tuple index, float value) { int i1=0, i2=0; if (len(index) == 2) { i1 = normalizeIndex(extract<int>(index[0])); i2 = normalizeIndex(extract<int>(index[1])); } else throwIndexErr("Index has incorrect size."); self[i1][i2] = value; } static void __setitem__vector( GfMatrix3f &self, int index, GfVec3f value ) { int ni = normalizeIndex(index); self[ni][0] = value[0]; self[ni][1] = value[1]; self[ni][2] = value[2]; } static bool __contains__float( const GfMatrix3f &self, float value ) { for( int i = 0; i < 3; ++i ) for( int j = 0; j < 3; ++j ) if( self[i][j] == value ) return true; return false; } // Check rows against GfVec static bool __contains__vector( const GfMatrix3f &self, GfVec3f value ) { for( int i = 0; i < 3; ++i ) if( self.GetRow(i) == value ) return true; return false; } #if PY_MAJOR_VERSION == 2 static GfMatrix3f __truediv__(const GfMatrix3f &self, GfMatrix3f value) { return self / value; } #endif static GfMatrix3f *__init__() { // Default constructor produces identity from python. return new GfMatrix3f(1); } // This adds support for python's builtin pickling library // This is used by our Shake plugins which need to pickle entire classes // (including code), which we don't support in pxml. struct GfMatrix3f_Pickle_Suite : boost::python::pickle_suite { static boost::python::tuple getinitargs(const GfMatrix3f &m) { return boost::python::make_tuple( m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]); } }; static size_t __hash__(GfMatrix3f const &m) { return hash_value(m); } static boost::python::tuple get_dimension() { // At one time this was a constant static tuple we returned for // dimension. With boost building for python 3 that results in // a segfault at shutdown. Building for python 2 with a static // tuple returned here seems to work fine. // // It seems likely that this has to do with the order of // destruction of these objects when deinitializing, but we did // not dig deeply into this difference. return make_tuple(3, 3); } } // anonymous namespace void wrapMatrix3f() { typedef GfMatrix3f This; def("IsClose", (bool (*)(const GfMatrix3f &m1, const GfMatrix3f &m2, double)) GfIsClose); class_<This> cls( "Matrix3f", no_init); cls .def_pickle(GfMatrix3f_Pickle_Suite()) .def("__init__", make_constructor(__init__)) .def(init< const GfMatrix3d & >()) .def(init< const GfMatrix3f & >()) .def(init< int >()) .def(init< float >()) .def(init< float, float, float, float, float, float, float, float, float >()) .def(init< const GfVec3f & >()) .def(init< const vector< vector<float> >& >()) .def(init< const vector< vector<double> >& >()) .def(init< const GfRotation& >()) .def(init< const GfQuatf& >()) .def( TfTypePythonClass() ) .add_static_property("dimension", get_dimension) .def( "__len__", __len__, "Return number of rows" ) .def( "__getitem__", __getitem__float ) .def( "__getitem__", __getitem__vector ) .def( "__setitem__", __setitem__float ) .def( "__setitem__", __setitem__vector ) .def( "__contains__", __contains__float ) .def( "__contains__", __contains__vector, "Check rows against GfVec" ) .def("Set", (This &(This::*)(float, float, float, float, float, float, float, float, float))&This::Set, return_self<>()) .def("SetIdentity", &This::SetIdentity, return_self<>()) .def("SetZero", &This::SetZero, return_self<>()) .def("SetDiagonal", (This & (This::*)(float))&This::SetDiagonal, return_self<>()) .def("SetDiagonal", (This & (This::*)(const GfVec3f &))&This::SetDiagonal, return_self<>()) .def("SetRow", &This::SetRow) .def("SetColumn", &This::SetColumn) .def("GetRow", &This::GetRow) .def("GetColumn", &This::GetColumn) .def("GetTranspose", &This::GetTranspose) .def("GetInverse", GetInverseWrapper) .def("GetDeterminant", &This::GetDeterminant) .def("GetHandedness", &This::GetHandedness) .def("IsLeftHanded", &This::IsLeftHanded) .def("IsRightHanded", &This::IsRightHanded) .def("Orthonormalize", &This::Orthonormalize, (arg("issueWarning") = true)) .def("GetOrthonormalized", &This::GetOrthonormalized, (arg("issueWarning") = true)) .def( str(self) ) .def( self == self ) .def( self == GfMatrix3d() ) .def( self != self ) .def( self != GfMatrix3d() ) .def( self *= self ) .def( self * self ) .def( self *= double() ) .def( self * double() ) .def( double() * self ) .def( self += self ) .def( self + self ) .def( self -= self ) .def( self - self ) .def( -self ) .def( self / self ) .def( self * GfVec3f() ) .def( GfVec3f() * self ) #if PY_MAJOR_VERSION == 2 // Needed only to support "from __future__ import division" in // python 2. In python 3 builds boost::python adds this for us. .def("__truediv__", __truediv__ ) #endif .def("SetScale", (This & (This::*)( const GfVec3f & ))&This::SetScale, return_self<>()) .def("SetRotate", (This & (This::*)( const GfQuatf & )) &This::SetRotate, return_self<>()) .def("SetRotate", (This & (This::*)( const GfRotation & )) &This::SetRotate, return_self<>()) .def("ExtractRotation", &This::ExtractRotation) .def("SetScale", (This & (This::*)( float ))&This::SetScale, return_self<>()) .def("__repr__", _Repr) .def("__hash__", __hash__) ; to_python_converter<std::vector<This>, TfPySequenceToPython<std::vector<This> > >(); // Install buffer protocol: set the tp_as_buffer slot to point to a // structure of function pointers that implement the buffer protocol for // this type, and set the type flags to indicate that this type supports the // buffer protocol. auto *typeObj = reinterpret_cast<PyTypeObject *>(cls.ptr()); typeObj->tp_as_buffer = &bufferProcs; typeObj->tp_flags |= (TfPy_TPFLAGS_HAVE_NEWBUFFER | TfPy_TPFLAGS_HAVE_GETCHARBUFFER); }
; ******************************************************************************************** ; ******************************************************************************************** ; ; Name : sendparam.asm ; Purpose : .. ; Created : 15th Nov 1991 ; Updated : 4th Jan 2021 ; Authors : Fred Bowen ; ; ******************************************************************************************** ; ******************************************************************************************** ; Send parameters to device ; ; Entry: .a = number of bytes in format ; .y = pointer to TABLD entry sendp sta xcnt ; save number of string bytes phy jsr Clear_DS ; clear old status ldx #0 sdp1 pla dec xcnt bmi tranr tay iny ; move down table phy lda tabld,y ; get next entry bpl sdp5 ; if not escape code cmp #xsca ; if not secondary address beq rsca cmp #xid beq rid ; if disk id cmp #xrcl +lbeq rdcn ; if record number cmp #xwrt beq rwrt ; if W or L cmp #xfat beq rfat ; if "@" symbol request cmp #xfn1 +lbeq rsfn ; if filename 1 cmp #xfn2 +lbeq rdfn ; if filename 2 cmp #xrec bne sdp2 ; if not record type lda dosrcl ; get rec # cmp #1 ; kludge to allow DOPEN#lf,"relfile",L [911024] bne sdp5 ; (note RECORD byte 0 = byte 1 anyhow) dec bra sdp5 ; always branch sdp2 cmp #xd1 bne sdp3 ; if not drive 1 lda dosds1 bra sdp4 ; always branch sdp3 cmp #xd2 bne sdp1 ; if not drive 2, continue lda dosds2 sdp4 ora #'0' ; change # to PETSCII sdp5 sta dosstr,x ; else into buffer inx bra sdp1 ; always tranr txa ; length to a pha ldx #<dosstr ; set filename ldy #>dosstr jsr _setnam lda dosla ; set channel ldx dosfa ldy dossa jsr _setlfs pla rts rsca lda dossa_temp ; secondary address (record) bra sdp5 ; always rfat bbr7 parsts,l240_1 ; if "@" not encountered lda #'@' bra sdp5 ; always l240_1 lda dosflags lsr bcc sdp1 ; if "/" not encountered lda #'/' bra sdp5 ; ID subroutine rid lda dosdid ; include id sta dosstr,x inx lda dosdid+1 bra sdp5 ; always rwrt lda dosrcl ; check for L or W beq l241_1 ; zero then write lda #'L' bra sdp5 ; always l241_1 lda #'S' ; send W,S sta dosrcl lda #'W' bra sdp5 ; always ; Move record number rdcn lda poker sta dosstr,x lda poker+1 inx bra sdp5 ; always ; Move file names rsfn ldy dosf1l ; file name 1: get length beq rdrt0 ; if null string ldy #0 ; move name to dosstr l242_1 lda savram,y sta dosstr,x inx iny cpy dosf1l bne l242_1 ; if move not complete bra rdrt1 ; always rdfn lda dosf2a sta index1 lda dosf2a+1 sta index1+1 ldy dosf2l beq rdrt0 ; if null string ldy #0 ; move name to dosstr l243_1 jsr indin1_ram1 sta dosstr,x inx iny cpy dosf2l bne l243_1 ; if move not complete !text $89 ; hop rdrt0 dex ; case cdd=sd rdrt1 +lbra sdp1 ; get next symbol ; Syntax checker DOS write chk1 and #$e6 ; for HEADER, DLOAD, SCRATCH, TYPE, LIST +lbne snerr chk2 lda parsts ; for DSAVE and #1 cmp #1 ; check required parameters +lbne snerr ; error if 1 missing lda parsts ; reload for return rts chk3 and #$e7 ; for COLLECT +lbne snerr ; check optional parameters rts chk4 and #$c4 ; for COPY, CONCAT +lbne snerr ; check optional parameters lda parsts chk5 and #3 ; for RENAME cmp #3 ; check required parameters +lbne snerr lda parsts ; reload for return rts chk6 and #5 ; for APPEND, DOPEN cmp #5 ; check required parameters +lbne snerr lda parsts ; reload for rts rts ;.end ; Allocate DS$ if nesessary, but use old DS$ string otherwise ; Called by DS$ and DS Check_DS ; chkds. lda dsdesc beq Read_DS_1 ; branch if DS$ is not in memory rts ; else return & use old one ; Allocate DS$ if necessary & Read DOS error channel Read_DS ; errchl. lda dsdesc ; has DS$ space been allocated? bne Read_DS_2 ; yes Read_DS_1 lda #40 ; no- get 40 char string sta dsdesc jsr getspa ; allocate space for DS$ stx dsdesc+1 ; low address of string sty dsdesc+2 ; high " " " ldx #dsdesc+1 ; set up string back pointer to dsdesc ldy #40 lda #<dsdesc jsr sta_far_ram1 ; sta (dsdesc+1),y iny lda #>dsdesc jsr sta_far_ram1 ; sta (dsdesc+1),y Read_DS_2 ldx dosfa ; fa cpx #2 bcs l244_1 ; if =0 or 1 use default [910429] ldx _default_drive ; (was dosffn) [900710] stx dosfa l244_1 lda #doslfn ; la (reserved la) ldy #$6f ; sa (command channel) jsr _setlfs lda #0 ; no name (so no setbank) jsr _setnam jsr _open ; get command channel ldx #doslfn jsr _chkin bcs l244_4 ; a problem (file already open??) ldy #$ff l244_2 iny ; read disk error message jsr _basin cmp #cr beq l244_3 ; if eol ldx #dsdesc+1 jsr sta_far_ram1 ; sta (dsdesc+1),y copy to DS$ cpy #40 bcc l244_2 ; loop unless too long l244_3 lda #0 ; errend. ldx #dsdesc+1 ; terminate DS$ with a null jsr sta_far_ram1 ; sta (dsdesc+1),y jsr _clrch ; shut down command channel lda #doslfn sec ; not a real close jmp _close ; close it and rts l244_4 pha ; errbad. jsr l244_3 jsr Clear_DS ; flag 'no DS available' plx ; get error +lbra error ; Clear_DS subroutine - forget current DS$ message, if any ; Clear_DS ; oldclr. lda dsdesc ; check for allocation beq l245_1 ; branch if not allocated phy ; mark current DS$ string as garbage phx ; lda #40 ; standard DS$ allocation tay ldx #dsdesc+1 jsr sta_far_ram1 ; sta (dsdesc+1),y length of garbage iny lda #$ff jsr sta_far_ram1 ; sta (dsdesc+1),y garbage flagged inc sta dsdesc ; (0) kill DS$ plx ply l245_1 rts ; Read DOS error message, but don't care what it is. Want to stop disk LED blink. ; Suck_DS ldx dosfa ; fa lda #doslfn ; la (reserved la) ldy #$6f ; sa (command channel) jsr _setlfs lda #0 ; no name (so no setbank) jsr _setnam jsr _open ; get command channel ldx #doslfn jsr _chkin bcs l246_2 ; skip input if problem l246_1 jsr _basin ; read disk error message cmp #cr bne l246_1 ; loop until eol l246_2 jsr _clrch ; shut down command channel lda #doslfn sec ; not a real close jmp _close ; close it ; R-U-sure subroutine are_you_sure bbs7 runmod,response_fake ; branch if not direct mode jsr _primm ; else prompt user for y/n answer !text "ARE YOU SURE? ", 0 response_get jsr _clrch ; clear channel for basin jsr _basin ; next char pha ; save first char of reply l247_1 cmp #cr ; eat chars until end of line beq l247_2 ; if cr received, exit jsr _basin bne l247_1 ; continue to ignore l247_2 jsr _bsout ; new line [910212] FAB pla cmp #'Y' ; z set means ans=y..... rts response_fake lda #0 ; ...or not in direct mode rts ;.end ;***************************************************************** ; OPTWRD - get an optional, unsigned 2-byte value in y,a. ; ; case 1 : pointer at end of line: ; return a=y=0, clear c to flag 'default' ; case 2 : pointer is at comma, next non-blank is also a comma: ; return a=y=0, clear c to flag 'default' ; case 3 : pointer is at comma, next non-blank is not a comma: ; get word in y,a, set c to flag 'non-default' ;***************************************************************** optwrd jsr chrgot beq l248_1 jsr chkcom cmp #',' beq l248_1 jsr getwrd sec rts l248_1 lda #0 tay optw99 clc rts comsad jsr chkcom ; get a comma & signed 2-byte arg in y,a [910307] +lbra sadwrd optsad jsr chrgot ; get a comma & optional, signed 2-byte arg in y,a [910307] beq l249_1 ; eol, therefore this arg is not specified jsr chkcom ; eat comma cmp #',' ; is next a comma too? beq l249_1 ; yes, therefore this arg is not specified jsr sadwrd ; get signed word sec rts l249_1 lda #0 ; default optional arg to zero tay clc rts ;***************************************************************** ; OPTBYT - get an optional 1 byte value in x. ; ; Enter with default value in x. ; ; case 1 : pointer at end of line: ; return default x. ; case 2 : pointer is at comma, next non-blank is also a comma: ; return default x. ; case 3 : pointer is at comma, next non-blank is not a comma: ; get byte in x. ;***************************************************************** optzer ldx #0 ; optional byte, with default=0 optbyt jsr chrgot beq optw99 ; EOL: clc/rts jsr chkcom cmp #',' beq optw99 ; Comma: clc/rts jsr getbyt sec rts prtdec phy phx tax ; prints decimal value of chr in .a lda #0 jsr linprt plx ply rts retpat ; f.bowen dey ; [910828] lda (fndpnt),y ; restore pointers sta txtptr+1 dey lda (fndpnt),y sta txtptr dey lda (fndpnt),y sta curlin+1 ; fixes a problem when RETURNing to a GOSUB in direct mode dey ; or LOOPing to a DO in direct mode. 'curlin+1' must not be tax ; restored to $ff without also resetting 'runmod' inx bne l250_1 ; branch if GOSUB or DO was from a program lda #%11000000 trb runmod ; else force return to direct mode l250_1 lda (fndpnt),y sta curlin rts vbits !text $01,$02,$04,$01,$02,$04 ; for stereo filter, volume bit setting sbits !text $01,$02,$04,$08,$10,$20,$40,$80 rbits !text $80,$40,$20,$10,$08,$04,$02,$01 ;.end ; ******************************************************************************************** ; ; Date Changes ; ==== ======= ; ; ********************************************************************************************